blob: f0f46f2dcb74e134e64df514c1b71945cd43adf1 [file] [log] [blame]
Manivannan Sadhasivameba65892018-06-14 23:38:32 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
Amit Singh Tomarb1a6bb32020-04-19 19:28:25 +05303 * Actions Semi Owl SoCs platform support.
Manivannan Sadhasivameba65892018-06-14 23:38:32 +05304 *
5 * Copyright (C) 2018 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
6 */
7
Simon Glass9a3b4ce2019-12-28 10:45:01 -07008#include <cpu_func.h>
Simon Glass691d7192020-05-10 11:40:02 -06009#include <init.h>
Simon Glass90526e92020-05-10 11:39:56 -060010#include <asm/cache.h>
Simon Glass401d1c42020-10-30 21:38:53 -060011#include <asm/global_data.h>
Manivannan Sadhasivameba65892018-06-14 23:38:32 +053012#include <linux/arm-smccc.h>
13#include <linux/psci.h>
14#include <common.h>
15#include <asm/io.h>
16#include <asm/mach-types.h>
17#include <asm/psci.h>
18
Amit Singh Tomar3ca564e2020-05-09 13:45:07 +053019#define DMM_INTERLEAVE_PER_CH_CFG 0xe0290028
20
Manivannan Sadhasivameba65892018-06-14 23:38:32 +053021DECLARE_GLOBAL_DATA_PTR;
22
Amit Singh Tomar3ca564e2020-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 Sadhasivameba65892018-06-14 23:38:32 +053041/*
42 * dram_init - sets uboots idea of sdram size
43 */
44int dram_init(void)
45{
Amit Singh Tomar3ca564e2020-05-09 13:45:07 +053046 gd->ram_size = owl_get_ddrcap() * 1024 * 1024;
Manivannan Sadhasivameba65892018-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 Riniaa6e94d2022-11-16 13:10:37 -050053 gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE;
Manivannan Sadhasivameba65892018-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 Tomarb1a6bb32020-04-19 19:28:25 +053066 PSCI_VERSION_MAJOR(res.a0),
Manivannan Sadhasivameba65892018-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 Seiler35b65dd2020-12-15 16:47:52 +010077void reset_cpu(void)
Manivannan Sadhasivameba65892018-06-14 23:38:32 +053078{
79 psci_system_reset();
80}