1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * (C) Copyright 2002
3*4882a593Smuzhiyun * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4*4882a593Smuzhiyun * Marius Groeger <mgroeger@sysgo.de>
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * (C) Copyright 2002
7*4882a593Smuzhiyun * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * (C) Copyright 2003
10*4882a593Smuzhiyun * Texas Instruments, <www.ti.com>
11*4882a593Smuzhiyun * Kshitij Gupta <Kshitij@ti.com>
12*4882a593Smuzhiyun *
13*4882a593Smuzhiyun * (C) Copyright 2004
14*4882a593Smuzhiyun * ARM Ltd.
15*4882a593Smuzhiyun * Philippe Robin, <philippe.robin@arm.com>
16*4882a593Smuzhiyun *
17*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+
18*4882a593Smuzhiyun */
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun #include <common.h>
21*4882a593Smuzhiyun #include <dm.h>
22*4882a593Smuzhiyun #include <netdev.h>
23*4882a593Smuzhiyun #include <asm/io.h>
24*4882a593Smuzhiyun #include <dm/platform_data/serial_pl01x.h>
25*4882a593Smuzhiyun #include "arm-ebi.h"
26*4882a593Smuzhiyun #include "integrator-sc.h"
27*4882a593Smuzhiyun #include <asm/mach-types.h>
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun DECLARE_GLOBAL_DATA_PTR;
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun static const struct pl01x_serial_platdata serial_platdata = {
32*4882a593Smuzhiyun .base = 0x16000000,
33*4882a593Smuzhiyun #ifdef CONFIG_ARCH_CINTEGRATOR
34*4882a593Smuzhiyun .type = TYPE_PL011,
35*4882a593Smuzhiyun .clock = 14745600,
36*4882a593Smuzhiyun #else
37*4882a593Smuzhiyun .type = TYPE_PL010,
38*4882a593Smuzhiyun .clock = 0, /* Not used for PL010 */
39*4882a593Smuzhiyun #endif
40*4882a593Smuzhiyun };
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun U_BOOT_DEVICE(integrator_serials) = {
43*4882a593Smuzhiyun .name = "serial_pl01x",
44*4882a593Smuzhiyun .platdata = &serial_platdata,
45*4882a593Smuzhiyun };
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun void peripheral_power_enable (void);
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun #if defined(CONFIG_SHOW_BOOT_PROGRESS)
show_boot_progress(int progress)50*4882a593Smuzhiyun void show_boot_progress(int progress)
51*4882a593Smuzhiyun {
52*4882a593Smuzhiyun printf("Boot reached stage %d\n", progress);
53*4882a593Smuzhiyun }
54*4882a593Smuzhiyun #endif
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun #define COMP_MODE_ENABLE ((unsigned int)0x0000EAEF)
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun /*
59*4882a593Smuzhiyun * Miscellaneous platform dependent initialisations
60*4882a593Smuzhiyun */
61*4882a593Smuzhiyun
board_init(void)62*4882a593Smuzhiyun int board_init (void)
63*4882a593Smuzhiyun {
64*4882a593Smuzhiyun u32 val;
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun /* arch number of Integrator Board */
67*4882a593Smuzhiyun #ifdef CONFIG_ARCH_CINTEGRATOR
68*4882a593Smuzhiyun gd->bd->bi_arch_number = MACH_TYPE_CINTEGRATOR;
69*4882a593Smuzhiyun #else
70*4882a593Smuzhiyun gd->bd->bi_arch_number = MACH_TYPE_INTEGRATOR;
71*4882a593Smuzhiyun #endif
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun /* adress of boot parameters */
74*4882a593Smuzhiyun gd->bd->bi_boot_params = 0x00000100;
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun #ifdef CONFIG_CM_REMAP
77*4882a593Smuzhiyun extern void cm_remap(void);
78*4882a593Smuzhiyun cm_remap(); /* remaps writeable memory to 0x00000000 */
79*4882a593Smuzhiyun #endif
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun #ifdef CONFIG_ARCH_CINTEGRATOR
82*4882a593Smuzhiyun /*
83*4882a593Smuzhiyun * Flash protection on the Integrator/CP is in a simple register
84*4882a593Smuzhiyun */
85*4882a593Smuzhiyun val = readl(CP_FLASHPROG);
86*4882a593Smuzhiyun val |= (CP_FLASHPROG_FLVPPEN | CP_FLASHPROG_FLWREN);
87*4882a593Smuzhiyun writel(val, CP_FLASHPROG);
88*4882a593Smuzhiyun #else
89*4882a593Smuzhiyun /*
90*4882a593Smuzhiyun * The Integrator/AP has some special protection mechanisms
91*4882a593Smuzhiyun * for the external memories, first the External Bus Interface (EBI)
92*4882a593Smuzhiyun * then the system controller (SC).
93*4882a593Smuzhiyun *
94*4882a593Smuzhiyun * The system comes up with the flash memory non-writable and
95*4882a593Smuzhiyun * configuration locked. If we want U-Boot to be used for flash
96*4882a593Smuzhiyun * access we cannot have the flash memory locked.
97*4882a593Smuzhiyun */
98*4882a593Smuzhiyun writel(EBI_UNLOCK_MAGIC, EBI_BASE + EBI_LOCK_REG);
99*4882a593Smuzhiyun val = readl(EBI_BASE + EBI_CSR1_REG);
100*4882a593Smuzhiyun val &= EBI_CSR_WREN_MASK;
101*4882a593Smuzhiyun val |= EBI_CSR_WREN_ENABLE;
102*4882a593Smuzhiyun writel(val, EBI_BASE + EBI_CSR1_REG);
103*4882a593Smuzhiyun writel(0, EBI_BASE + EBI_LOCK_REG);
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun /*
106*4882a593Smuzhiyun * Set up the system controller to remove write protection from
107*4882a593Smuzhiyun * the flash memory and enable Vpp
108*4882a593Smuzhiyun */
109*4882a593Smuzhiyun writel(SC_CTRL_FLASHVPP | SC_CTRL_FLASHWP, SC_CTRLS);
110*4882a593Smuzhiyun #endif
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun icache_enable ();
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun return 0;
115*4882a593Smuzhiyun }
116*4882a593Smuzhiyun
misc_init_r(void)117*4882a593Smuzhiyun int misc_init_r (void)
118*4882a593Smuzhiyun {
119*4882a593Smuzhiyun env_set("verify", "n");
120*4882a593Smuzhiyun return (0);
121*4882a593Smuzhiyun }
122*4882a593Smuzhiyun
123*4882a593Smuzhiyun /*
124*4882a593Smuzhiyun * The Integrator remaps the Flash memory to 0x00000000 and executes U-Boot
125*4882a593Smuzhiyun * from there, which means we cannot test the RAM underneath the ROM at this
126*4882a593Smuzhiyun * point. It will be unmapped later on, when we are executing from the
127*4882a593Smuzhiyun * relocated in RAM U-Boot. We simply assume that this RAM is usable if the
128*4882a593Smuzhiyun * RAM on higher addresses works fine.
129*4882a593Smuzhiyun */
130*4882a593Smuzhiyun #define REMAPPED_FLASH_SZ 0x40000
131*4882a593Smuzhiyun
dram_init(void)132*4882a593Smuzhiyun int dram_init (void)
133*4882a593Smuzhiyun {
134*4882a593Smuzhiyun gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
135*4882a593Smuzhiyun #ifdef CONFIG_CM_SPD_DETECT
136*4882a593Smuzhiyun {
137*4882a593Smuzhiyun extern void dram_query(void);
138*4882a593Smuzhiyun u32 cm_reg_sdram;
139*4882a593Smuzhiyun u32 sdram_shift;
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun dram_query(); /* Assembler accesses to CM registers */
142*4882a593Smuzhiyun /* Queries the SPD values */
143*4882a593Smuzhiyun
144*4882a593Smuzhiyun /* Obtain the SDRAM size from the CM SDRAM register */
145*4882a593Smuzhiyun
146*4882a593Smuzhiyun cm_reg_sdram = readl(CM_BASE + OS_SDRAM);
147*4882a593Smuzhiyun /* Register SDRAM size
148*4882a593Smuzhiyun *
149*4882a593Smuzhiyun * 0xXXXXXXbbb000bb 16 MB
150*4882a593Smuzhiyun * 0xXXXXXXbbb001bb 32 MB
151*4882a593Smuzhiyun * 0xXXXXXXbbb010bb 64 MB
152*4882a593Smuzhiyun * 0xXXXXXXbbb011bb 128 MB
153*4882a593Smuzhiyun * 0xXXXXXXbbb100bb 256 MB
154*4882a593Smuzhiyun *
155*4882a593Smuzhiyun */
156*4882a593Smuzhiyun sdram_shift = ((cm_reg_sdram & 0x0000001C)/4)%4;
157*4882a593Smuzhiyun gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE +
158*4882a593Smuzhiyun REMAPPED_FLASH_SZ,
159*4882a593Smuzhiyun 0x01000000 << sdram_shift);
160*4882a593Smuzhiyun }
161*4882a593Smuzhiyun #else
162*4882a593Smuzhiyun gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE +
163*4882a593Smuzhiyun REMAPPED_FLASH_SZ,
164*4882a593Smuzhiyun PHYS_SDRAM_1_SIZE);
165*4882a593Smuzhiyun #endif /* CM_SPD_DETECT */
166*4882a593Smuzhiyun /* We only have one bank of RAM, set it to whatever was detected */
167*4882a593Smuzhiyun gd->bd->bi_dram[0].size = gd->ram_size;
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun return 0;
170*4882a593Smuzhiyun }
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun #ifdef CONFIG_CMD_NET
board_eth_init(bd_t * bis)173*4882a593Smuzhiyun int board_eth_init(bd_t *bis)
174*4882a593Smuzhiyun {
175*4882a593Smuzhiyun int rc = 0;
176*4882a593Smuzhiyun #ifdef CONFIG_SMC91111
177*4882a593Smuzhiyun rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
178*4882a593Smuzhiyun #endif
179*4882a593Smuzhiyun rc += pci_eth_init(bis);
180*4882a593Smuzhiyun return rc;
181*4882a593Smuzhiyun }
182*4882a593Smuzhiyun #endif
183