blob: c07e0eae4e9d21b40319062ca14b171dc6b6768b [file] [log] [blame]
Alex Nemirovsky1ecad072020-01-30 12:34:59 -08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2020 - Cortina Access Inc.
4 *
5 */
Tom Rinidec7ea02024-05-20 13:35:03 -06006#include <config.h>
Simon Glass1cedca12023-08-21 21:17:01 -06007#include <event.h>
Simon Glass97589732020-05-10 11:40:02 -06008#include <init.h>
Alex Nemirovsky1ecad072020-01-30 12:34:59 -08009#include <malloc.h>
10#include <errno.h>
11#include <netdev.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060012#include <asm/global_data.h>
Alex Nemirovsky1ecad072020-01-30 12:34:59 -080013#include <asm/io.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060014#include <linux/bitops.h>
Alex Nemirovsky1ecad072020-01-30 12:34:59 -080015#include <linux/compiler.h>
16#include <configs/presidio_asic.h>
17#include <linux/psci.h>
18#include <asm/psci.h>
19#include <cpu_func.h>
20#include <asm/armv8/mmu.h>
21
22DECLARE_GLOBAL_DATA_PTR;
23
24#define CA_PERIPH_BASE 0xE0000000UL
25#define CA_PERIPH_SIZE 0x20000000UL
26#define CA_GLOBAL_BASE 0xf4320000
27#define CA_GLOBAL_JTAG_ID 0xf4320000
28#define CA_GLOBAL_BLOCK_RESET 0xf4320004
29#define CA_GLOBAL_BLOCK_RESET_RESET_DMA BIT(16)
30#define CA_DMA_SEC_SSP_BAUDRATE_CTRL 0xf7001b94
31#define CA_DMA_SEC_SSP_ID 0xf7001b80
32
33int print_cpuinfo(void)
34{
35 printf("CPU: Cortina Presidio G3\n");
36 return 0;
37}
38
39static struct mm_region presidio_mem_map[] = {
40 {
41 .virt = DDR_BASE,
42 .phys = DDR_BASE,
43 .size = PHYS_SDRAM_1_SIZE,
44 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
45 PTE_BLOCK_OUTER_SHARE
46 },
47 {
48 .virt = CA_PERIPH_BASE,
49 .phys = CA_PERIPH_BASE,
50 .size = CA_PERIPH_SIZE,
51 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
52 PTE_BLOCK_NON_SHARE
53 },
54 {
55 /* List terminator */
56 0,
57 }
58};
59
60struct mm_region *mem_map = presidio_mem_map;
61
62static noinline int invoke_psci_fn_smc(u64 function_id, u64 arg0, u64 arg1,
63 u64 arg2)
64{
65 asm volatile("mov x0, %0\n"
66 "mov x1, %1\n"
67 "mov x2, %2\n"
68 "mov x3, %3\n"
69 "smc #0\n"
70 : "+r" (function_id)
71 : "r" (arg0), "r" (arg1), "r" (arg2)
72 );
73
74 return function_id;
75}
76
77int board_early_init_r(void)
78{
79 dcache_disable();
80 return 0;
81}
82
83int board_init(void)
84{
85 unsigned int reg_data, jtag_id;
86
87 /* Enable timer */
Tom Rini6a5dccc2022-11-16 13:10:41 -050088 writel(1, CFG_SYS_TIMER_BASE);
Alex Nemirovsky1ecad072020-01-30 12:34:59 -080089
90 /* Enable snoop in CCI400 slave port#4 */
91 writel(3, 0xF5595000);
92
93 jtag_id = readl(CA_GLOBAL_JTAG_ID);
94
95 /* If this is HGU variant then do not use
96 * the Saturn daughter card ref. clk
97 */
98 if (jtag_id == 0x1010D8F3) {
99 reg_data = readl(0xF3100064);
100 /* change multifunc. REF CLK pin to
101 * a simple GPIO pin
102 */
103 reg_data |= (1 << 1);
104 writel(reg_data, 0xf3100064);
105 }
106
107 return 0;
108}
109
110int dram_init(void)
111{
112 unsigned int ddr_size;
113
114 ddr_size = readl(0x111100c);
115 gd->ram_size = ddr_size * 0x100000;
116 return 0;
117}
118
Harald Seiler6f14d5f2020-12-15 16:47:52 +0100119void reset_cpu(void)
Alex Nemirovsky1ecad072020-01-30 12:34:59 -0800120{
121 invoke_psci_fn_smc(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
122}
123
124#ifdef CONFIG_LAST_STAGE_INIT
Simon Glass1cedca12023-08-21 21:17:01 -0600125static int last_stage_init(void)
Alex Nemirovsky1ecad072020-01-30 12:34:59 -0800126{
127 u32 val;
128
129 val = readl(CA_GLOBAL_BLOCK_RESET);
130 val &= ~CA_GLOBAL_BLOCK_RESET_RESET_DMA;
131 writel(val, CA_GLOBAL_BLOCK_RESET);
132
133 /* reduce output pclk ~3.7Hz to save power consumption */
134 writel(0x000000FF, CA_DMA_SEC_SSP_BAUDRATE_CTRL);
135
136 return 0;
137}
Simon Glass1cedca12023-08-21 21:17:01 -0600138EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
Alex Nemirovsky1ecad072020-01-30 12:34:59 -0800139#endif