blob: f0fe0fd3aabe66ba0f096221eb8de985211e61ba [file] [log] [blame]
wdenk3d3befa2004-03-14 15:06:13 +00001/*
2 * (C) Copyright 2002
3 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 * Marius Groeger <mgroeger@sysgo.de>
5 *
6 * (C) Copyright 2002
7 * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
8 *
9 * (C) Copyright 2003
10 * Texas Instruments, <www.ti.com>
11 * Kshitij Gupta <Kshitij@ti.com>
12 *
13 * (C) Copyright 2004
14 * ARM Ltd.
15 * Philippe Robin, <philippe.robin@arm.com>
16 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +020017 * SPDX-License-Identifier: GPL-2.0+
wdenk3d3befa2004-03-14 15:06:13 +000018 */
19
20#include <common.h>
Ben Warren10efa022008-08-31 20:37:00 -070021#include <netdev.h>
Linus Walleij7c045d02011-11-09 06:14:40 +000022#include <asm/io.h>
Linus Walleij701ed162011-11-09 06:15:59 +000023#include "arm-ebi.h"
Linus Walleij1dc26802011-11-09 06:16:37 +000024#include "integrator-sc.h"
Ben Warren10efa022008-08-31 20:37:00 -070025
Wolfgang Denkd87080b2006-03-31 18:32:53 +020026DECLARE_GLOBAL_DATA_PTR;
27
wdenk3d3befa2004-03-14 15:06:13 +000028void peripheral_power_enable (void);
29
30#if defined(CONFIG_SHOW_BOOT_PROGRESS)
31void show_boot_progress(int progress)
32{
Wolfgang Denk716c1dc2005-09-25 18:49:35 +020033 printf("Boot reached stage %d\n", progress);
wdenk3d3befa2004-03-14 15:06:13 +000034}
35#endif
36
37#define COMP_MODE_ENABLE ((unsigned int)0x0000EAEF)
38
wdenk3d3befa2004-03-14 15:06:13 +000039/*
40 * Miscellaneous platform dependent initialisations
41 */
42
43int board_init (void)
44{
Linus Walleij701ed162011-11-09 06:15:59 +000045 u32 val;
46
wdenk3d3befa2004-03-14 15:06:13 +000047 /* arch number of Integrator Board */
Jean-Christophe PLAGNIOL-VILLARD576afd42009-05-17 00:58:37 +020048#ifdef CONFIG_ARCH_CINTEGRATOR
49 gd->bd->bi_arch_number = MACH_TYPE_CINTEGRATOR;
50#else
wdenk731215e2004-10-10 18:41:04 +000051 gd->bd->bi_arch_number = MACH_TYPE_INTEGRATOR;
Jean-Christophe PLAGNIOL-VILLARD576afd42009-05-17 00:58:37 +020052#endif
wdenk3d3befa2004-03-14 15:06:13 +000053
54 /* adress of boot parameters */
55 gd->bd->bi_boot_params = 0x00000100;
56
wdenkbc54f302004-07-11 18:10:30 +000057 gd->flags = 0;
58
Wolfgang Denk0148e8c2005-09-25 16:22:14 +020059#ifdef CONFIG_CM_REMAP
60extern void cm_remap(void);
61 cm_remap(); /* remaps writeable memory to 0x00000000 */
62#endif
Wolfgang Denk716c1dc2005-09-25 18:49:35 +020063
Linus Walleij1dc26802011-11-09 06:16:37 +000064#ifdef CONFIG_ARCH_CINTEGRATOR
Linus Walleij701ed162011-11-09 06:15:59 +000065 /*
Linus Walleij1dc26802011-11-09 06:16:37 +000066 * Flash protection on the Integrator/CP is in a simple register
67 */
68 val = readl(CP_FLASHPROG);
69 val |= (CP_FLASHPROG_FLVPPEN | CP_FLASHPROG_FLWREN);
70 writel(val, CP_FLASHPROG);
71#else
72 /*
73 * The Integrator/AP has some special protection mechanisms
74 * for the external memories, first the External Bus Interface (EBI)
75 * then the system controller (SC).
76 *
Linus Walleij701ed162011-11-09 06:15:59 +000077 * The system comes up with the flash memory non-writable and
78 * configuration locked. If we want U-Boot to be used for flash
79 * access we cannot have the flash memory locked.
80 */
81 writel(EBI_UNLOCK_MAGIC, EBI_BASE + EBI_LOCK_REG);
82 val = readl(EBI_BASE + EBI_CSR1_REG);
83 val &= EBI_CSR_WREN_MASK;
84 val |= EBI_CSR_WREN_ENABLE;
85 writel(val, EBI_BASE + EBI_CSR1_REG);
86 writel(0, EBI_BASE + EBI_LOCK_REG);
87
Linus Walleij1dc26802011-11-09 06:16:37 +000088 /*
89 * Set up the system controller to remove write protection from
90 * the flash memory and enable Vpp
91 */
92 writel(SC_CTRL_FLASHVPP | SC_CTRL_FLASHWP, SC_CTRLS);
93#endif
94
wdenk3d3befa2004-03-14 15:06:13 +000095 icache_enable ();
96
wdenk3d3befa2004-03-14 15:06:13 +000097 return 0;
98}
99
wdenk3d3befa2004-03-14 15:06:13 +0000100int misc_init_r (void)
101{
wdenk3d3befa2004-03-14 15:06:13 +0000102 setenv("verify", "n");
103 return (0);
104}
105
Linus Walleij46b5ccb2011-10-23 21:02:03 +0000106/*
107 * The Integrator remaps the Flash memory to 0x00000000 and executes U-Boot
108 * from there, which means we cannot test the RAM underneath the ROM at this
109 * point. It will be unmapped later on, when we are executing from the
110 * relocated in RAM U-Boot. We simply assume that this RAM is usable if the
111 * RAM on higher addresses works fine.
112 */
113#define REMAPPED_FLASH_SZ 0x40000
114
wdenk3d3befa2004-03-14 15:06:13 +0000115int dram_init (void)
116{
Linus Walleij26c82632011-07-25 01:50:08 +0000117 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
Wolfgang Denk0148e8c2005-09-25 16:22:14 +0200118#ifdef CONFIG_CM_SPD_DETECT
119 {
120extern void dram_query(void);
Linus Walleij7c045d02011-11-09 06:14:40 +0000121 u32 cm_reg_sdram;
122 u32 sdram_shift;
Wolfgang Denk0148e8c2005-09-25 16:22:14 +0200123
124 dram_query(); /* Assembler accesses to CM registers */
Wolfgang Denk716c1dc2005-09-25 18:49:35 +0200125 /* Queries the SPD values */
Wolfgang Denk0148e8c2005-09-25 16:22:14 +0200126
127 /* Obtain the SDRAM size from the CM SDRAM register */
128
Linus Walleij7c045d02011-11-09 06:14:40 +0000129 cm_reg_sdram = readl(CM_BASE + OS_SDRAM);
Wolfgang Denk716c1dc2005-09-25 18:49:35 +0200130 /* Register SDRAM size
Wolfgang Denk0148e8c2005-09-25 16:22:14 +0200131 *
Wolfgang Denk716c1dc2005-09-25 18:49:35 +0200132 * 0xXXXXXXbbb000bb 16 MB
133 * 0xXXXXXXbbb001bb 32 MB
134 * 0xXXXXXXbbb010bb 64 MB
135 * 0xXXXXXXbbb011bb 128 MB
136 * 0xXXXXXXbbb100bb 256 MB
137 *
Wolfgang Denk0148e8c2005-09-25 16:22:14 +0200138 */
Linus Walleij7c045d02011-11-09 06:14:40 +0000139 sdram_shift = ((cm_reg_sdram & 0x0000001C)/4)%4;
Linus Walleij46b5ccb2011-10-23 21:02:03 +0000140 gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE +
141 REMAPPED_FLASH_SZ,
Linus Walleij26c82632011-07-25 01:50:08 +0000142 0x01000000 << sdram_shift);
Wolfgang Denk0148e8c2005-09-25 16:22:14 +0200143 }
Linus Walleij26c82632011-07-25 01:50:08 +0000144#else
Linus Walleij46b5ccb2011-10-23 21:02:03 +0000145 gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE +
146 REMAPPED_FLASH_SZ,
Linus Walleij26c82632011-07-25 01:50:08 +0000147 PHYS_SDRAM_1_SIZE);
Wolfgang Denk0148e8c2005-09-25 16:22:14 +0200148#endif /* CM_SPD_DETECT */
Linus Walleij46b5ccb2011-10-23 21:02:03 +0000149 /* We only have one bank of RAM, set it to whatever was detected */
150 gd->bd->bi_dram[0].size = gd->ram_size;
Wolfgang Denk0148e8c2005-09-25 16:22:14 +0200151
wdenk3d3befa2004-03-14 15:06:13 +0000152 return 0;
153}
Wolfgang Denk74f43042005-09-25 01:48:28 +0200154
Ben Warren7194ab82009-10-04 22:37:03 -0700155#ifdef CONFIG_CMD_NET
Ben Warren10efa022008-08-31 20:37:00 -0700156int board_eth_init(bd_t *bis)
157{
Ben Warren7194ab82009-10-04 22:37:03 -0700158 int rc = 0;
159#ifdef CONFIG_SMC91111
160 rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
161#endif
Ben Warren7194ab82009-10-04 22:37:03 -0700162 rc += pci_eth_init(bis);
Ben Warren7194ab82009-10-04 22:37:03 -0700163 return rc;
Ben Warren10efa022008-08-31 20:37:00 -0700164}
Jean-Christophe PLAGNIOL-VILLARD576afd42009-05-17 00:58:37 +0200165#endif