Manivannan Sadhasivam | 604ecc8 | 2018-06-14 23:38:32 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
Amit Singh Tomar | cae8193 | 2020-04-19 19:28:25 +0530 | [diff] [blame] | 3 | * Actions Semi Owl SoCs platform support. |
Manivannan Sadhasivam | 604ecc8 | 2018-06-14 23:38:32 +0530 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2018 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> |
| 6 | */ |
| 7 | |
Simon Glass | afb0215 | 2019-12-28 10:45:01 -0700 | [diff] [blame] | 8 | #include <cpu_func.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 10 | #include <asm/cache.h> |
Manivannan Sadhasivam | 604ecc8 | 2018-06-14 23:38:32 +0530 | [diff] [blame] | 11 | #include <linux/arm-smccc.h> |
| 12 | #include <linux/psci.h> |
| 13 | #include <common.h> |
| 14 | #include <asm/io.h> |
| 15 | #include <asm/mach-types.h> |
| 16 | #include <asm/psci.h> |
| 17 | |
Amit Singh Tomar | 66d495a | 2020-05-09 13:45:07 +0530 | [diff] [blame] | 18 | #define DMM_INTERLEAVE_PER_CH_CFG 0xe0290028 |
| 19 | |
Manivannan Sadhasivam | 604ecc8 | 2018-06-14 23:38:32 +0530 | [diff] [blame] | 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
Amit Singh Tomar | 66d495a | 2020-05-09 13:45:07 +0530 | [diff] [blame] | 22 | unsigned int owl_get_ddrcap(void) |
| 23 | { |
| 24 | unsigned int val, cap; |
| 25 | |
| 26 | /* ddr capacity register initialized by ddr driver |
| 27 | * in early bootloader |
| 28 | */ |
| 29 | #if defined(CONFIG_MACH_S700) |
| 30 | val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0x7; |
| 31 | cap = (val + 1) * 256; |
| 32 | #elif defined(CONFIG_MACH_S900) |
| 33 | val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0xf; |
| 34 | cap = 64 * (1 << val); |
| 35 | #endif |
| 36 | |
| 37 | return cap; |
| 38 | } |
| 39 | |
Manivannan Sadhasivam | 604ecc8 | 2018-06-14 23:38:32 +0530 | [diff] [blame] | 40 | /* |
| 41 | * dram_init - sets uboots idea of sdram size |
| 42 | */ |
| 43 | int dram_init(void) |
| 44 | { |
Amit Singh Tomar | 66d495a | 2020-05-09 13:45:07 +0530 | [diff] [blame] | 45 | gd->ram_size = owl_get_ddrcap() * 1024 * 1024; |
Manivannan Sadhasivam | 604ecc8 | 2018-06-14 23:38:32 +0530 | [diff] [blame] | 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | /* This is called after dram_init() so use get_ram_size result */ |
| 50 | int dram_init_banksize(void) |
| 51 | { |
| 52 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; |
| 53 | gd->bd->bi_dram[0].size = gd->ram_size; |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | static void show_psci_version(void) |
| 59 | { |
| 60 | struct arm_smccc_res res; |
| 61 | |
| 62 | arm_smccc_smc(ARM_PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0, 0, 0, 0, 0, &res); |
| 63 | |
| 64 | printf("PSCI: v%ld.%ld\n", |
Amit Singh Tomar | cae8193 | 2020-04-19 19:28:25 +0530 | [diff] [blame] | 65 | PSCI_VERSION_MAJOR(res.a0), |
Manivannan Sadhasivam | 604ecc8 | 2018-06-14 23:38:32 +0530 | [diff] [blame] | 66 | PSCI_VERSION_MINOR(res.a0)); |
| 67 | } |
| 68 | |
| 69 | int board_init(void) |
| 70 | { |
| 71 | show_psci_version(); |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | void reset_cpu(ulong addr) |
| 77 | { |
| 78 | psci_system_reset(); |
| 79 | } |