blob: 0130cad7678258e9d6e2969122583facdf2a9df7 [file] [log] [blame]
Manivannan Sadhasivam604ecc82018-06-14 23:38:32 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
Amit Singh Tomarcae81932020-04-19 19:28:25 +05303 * Actions Semi Owl SoCs platform support.
Manivannan Sadhasivam604ecc82018-06-14 23:38:32 +05304 *
5 * Copyright (C) 2018 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
6 */
7
Tom Rinidec7ea02024-05-20 13:35:03 -06008#include <config.h>
Simon Glassafb02152019-12-28 10:45:01 -07009#include <cpu_func.h>
Simon Glass97589732020-05-10 11:40:02 -060010#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060011#include <asm/cache.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060012#include <asm/global_data.h>
Manivannan Sadhasivam604ecc82018-06-14 23:38:32 +053013#include <linux/arm-smccc.h>
14#include <linux/psci.h>
Manivannan Sadhasivam604ecc82018-06-14 23:38:32 +053015#include <asm/io.h>
16#include <asm/mach-types.h>
17#include <asm/psci.h>
18
Amit Singh Tomar66d495a2020-05-09 13:45:07 +053019#define DMM_INTERLEAVE_PER_CH_CFG 0xe0290028
20
Manivannan Sadhasivam604ecc82018-06-14 23:38:32 +053021DECLARE_GLOBAL_DATA_PTR;
22
Amit Singh Tomar66d495a2020-05-09 13:45:07 +053023unsigned int owl_get_ddrcap(void)
24{
25 unsigned int val, cap;
26
27 /* ddr capacity register initialized by ddr driver
28 * in early bootloader
29 */
30#if defined(CONFIG_MACH_S700)
31 val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0x7;
32 cap = (val + 1) * 256;
33#elif defined(CONFIG_MACH_S900)
34 val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0xf;
35 cap = 64 * (1 << val);
36#endif
37
38 return cap;
39}
40
Manivannan Sadhasivam604ecc82018-06-14 23:38:32 +053041/*
42 * dram_init - sets uboots idea of sdram size
43 */
44int dram_init(void)
45{
Amit Singh Tomar66d495a2020-05-09 13:45:07 +053046 gd->ram_size = owl_get_ddrcap() * 1024 * 1024;
Manivannan Sadhasivam604ecc82018-06-14 23:38:32 +053047 return 0;
48}
49
50/* This is called after dram_init() so use get_ram_size result */
51int dram_init_banksize(void)
52{
Tom Rinibb4dd962022-11-16 13:10:37 -050053 gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE;
Manivannan Sadhasivam604ecc82018-06-14 23:38:32 +053054 gd->bd->bi_dram[0].size = gd->ram_size;
55
56 return 0;
57}
58
59static void show_psci_version(void)
60{
61 struct arm_smccc_res res;
62
63 arm_smccc_smc(ARM_PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0, 0, 0, 0, 0, &res);
64
65 printf("PSCI: v%ld.%ld\n",
Amit Singh Tomarcae81932020-04-19 19:28:25 +053066 PSCI_VERSION_MAJOR(res.a0),
Manivannan Sadhasivam604ecc82018-06-14 23:38:32 +053067 PSCI_VERSION_MINOR(res.a0));
68}
69
70int board_init(void)
71{
72 show_psci_version();
73
74 return 0;
75}
76
Harald Seiler6f14d5f2020-12-15 16:47:52 +010077void reset_cpu(void)
Manivannan Sadhasivam604ecc82018-06-14 23:38:32 +053078{
79 psci_system_reset();
80}