3 * ISEE 2007 SL, <www.iseebcn.com>
5 * SPDX-License-Identifier: GPL-2.0+
8 #include <status_led.h>
16 #include <asm/arch/mem.h>
17 #include <asm/arch/mmc_host_def.h>
18 #include <asm/arch/mux.h>
19 #include <asm/arch/sys_proto.h>
20 #include <asm/mach-types.h>
21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/nand.h>
23 #include <linux/mtd/nand.h>
24 #include <linux/mtd/onenand.h>
25 #include <jffs2/load_kernel.h>
28 DECLARE_GLOBAL_DATA_PTR;
30 static const struct ns16550_platdata igep_serial = {
31 .base = OMAP34XX_UART3,
33 .clock = V_NS16550_CLK
36 U_BOOT_DEVICE(igep_uart) = {
43 * Description: Early hardware init.
49 /* find out flash memory type, assume NAND first */
50 gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
53 /* Issue a RESET and then READID */
54 writeb(NAND_CMD_RESET, &gpmc_cfg->cs[0].nand_cmd);
55 writeb(NAND_CMD_STATUS, &gpmc_cfg->cs[0].nand_cmd);
56 while ((readl(&gpmc_cfg->cs[0].nand_dat) & NAND_STATUS_READY)
57 != NAND_STATUS_READY) {
60 gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
61 gpmc_init(); /* reinitialize for OneNAND */
67 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
69 #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
70 status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
76 #ifdef CONFIG_SPL_BUILD
78 * Routine: get_board_mem_timings
79 * Description: If we use SPL then there is no x-loader nor config header
80 * so we have to setup the DDR timings ourself on both banks.
82 void get_board_mem_timings(struct board_sdrc_timings *timings)
84 int mfr, id, err = identify_nand_chip(&mfr, &id);
86 timings->mr = MICRON_V_MR_165;
90 timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
91 timings->ctrla = HYNIX_V_ACTIMA_200;
92 timings->ctrlb = HYNIX_V_ACTIMB_200;
95 timings->mcfg = MICRON_V_MCFG_200(256 << 20);
96 timings->ctrla = MICRON_V_ACTIMA_200;
97 timings->ctrlb = MICRON_V_ACTIMB_200;
100 /* Should not happen... */
103 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
104 gpmc_cs0_flash = MTD_DEV_TYPE_NAND;
106 if (get_cpu_family() == CPU_OMAP34XX) {
107 timings->mcfg = NUMONYX_V_MCFG_165(256 << 20);
108 timings->ctrla = NUMONYX_V_ACTIMA_165;
109 timings->ctrlb = NUMONYX_V_ACTIMB_165;
110 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
112 timings->mcfg = NUMONYX_V_MCFG_200(256 << 20);
113 timings->ctrla = NUMONYX_V_ACTIMA_200;
114 timings->ctrlb = NUMONYX_V_ACTIMB_200;
115 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
117 gpmc_cs0_flash = MTD_DEV_TYPE_ONENAND;
121 #ifdef CONFIG_SPL_OS_BOOT
122 int spl_start_uboot(void)
124 /* break into full u-boot on 'c' */
125 if (serial_tstc() && serial_getc() == 'c')
133 int onenand_board_init(struct mtd_info *mtd)
135 if (gpmc_cs0_flash == MTD_DEV_TYPE_ONENAND) {
136 struct onenand_chip *this = mtd->priv;
137 this->base = (void *)CONFIG_SYS_ONENAND_BASE;
143 #if defined(CONFIG_CMD_NET)
144 static void reset_net_chip(int gpio)
146 if (!gpio_request(gpio, "eth nrst")) {
147 gpio_direction_output(gpio, 1);
149 gpio_set_value(gpio, 0);
151 gpio_set_value(gpio, 1);
157 * Routine: setup_net_chip
158 * Description: Setting up the configuration GPMC registers specific to the
161 static void setup_net_chip(void)
163 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
164 static const u32 gpmc_lan_config[] = {
165 NET_LAN9221_GPMC_CONFIG1,
166 NET_LAN9221_GPMC_CONFIG2,
167 NET_LAN9221_GPMC_CONFIG3,
168 NET_LAN9221_GPMC_CONFIG4,
169 NET_LAN9221_GPMC_CONFIG5,
170 NET_LAN9221_GPMC_CONFIG6,
173 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
174 CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
176 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
177 writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
178 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
179 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
180 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
181 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
182 &ctrl_base->gpmc_nadv_ale);
187 int board_eth_init(bd_t *bis)
189 #ifdef CONFIG_SMC911X
190 return smc911x_initialize(0, CONFIG_SMC911X_BASE);
196 static inline void setup_net_chip(void) {}
199 #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
200 int board_mmc_init(bd_t *bis)
202 return omap_mmc_init(0, 0, 0, -1, -1);
206 #if defined(CONFIG_GENERIC_MMC)
207 void board_mmc_power_init(void)
209 twl4030_power_mmc_init(0);
215 switch (gd->bd->bi_arch_number) {
216 case MACH_TYPE_IGEP0020:
217 setenv("fdtfile", "omap3-igep0020.dtb");
219 case MACH_TYPE_IGEP0030:
220 setenv("fdtfile", "omap3-igep0030.dtb");
226 * Routine: misc_init_r
227 * Description: Configure board specific parts
229 int misc_init_r(void)
231 twl4030_power_init();
235 omap_die_id_display();
242 void board_mtdparts_default(const char **mtdids, const char **mtdparts)
244 struct mtd_info *mtd = get_mtd_device(NULL, 0);
247 static char parts[48];
248 const char *linux_name = "omap2-nand";
249 if (strncmp(mtd->name, "onenand0", 8) == 0)
250 linux_name = "omap2-onenand";
251 snprintf(ids, sizeof(ids), "%s=%s", mtd->name, linux_name);
252 snprintf(parts, sizeof(parts), "mtdparts=%s:%dk(SPL),-(UBI)",
253 linux_name, 4 * mtd->erasesize >> 10);
260 * Routine: set_muxconf_regs
261 * Description: Setting up the configuration Mux registers specific to the
262 * hardware. Many pins need to be moved from protect to primary
265 void set_muxconf_regs(void)
269 #if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
273 #if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)