Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2010 |
| 3 | * ISEE 2007 SL, <www.iseebcn.com> |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 6 | */ |
| 7 | #include <common.h> |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 8 | #include <dm.h> |
| 9 | #include <ns16550.h> |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 10 | #include <twl4030.h> |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 11 | #include <netdev.h> |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 12 | #include <asm/gpio.h> |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 13 | #include <asm/io.h> |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 14 | #include <asm/arch/mem.h> |
Enric Balletbo i Serra | da898a9 | 2010-11-04 15:34:33 -0400 | [diff] [blame] | 15 | #include <asm/arch/mmc_host_def.h> |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 16 | #include <asm/arch/mux.h> |
| 17 | #include <asm/arch/sys_proto.h> |
| 18 | #include <asm/mach-types.h> |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 19 | #include "igep00x0.h" |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 20 | |
John Rigby | 0d21ed0 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 23 | #if defined(CONFIG_CMD_NET) |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 24 | /* GPMC definitions for LAN9221 chips */ |
| 25 | static const u32 gpmc_lan_config[] = { |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 26 | NET_LAN9221_GPMC_CONFIG1, |
| 27 | NET_LAN9221_GPMC_CONFIG2, |
| 28 | NET_LAN9221_GPMC_CONFIG3, |
| 29 | NET_LAN9221_GPMC_CONFIG4, |
| 30 | NET_LAN9221_GPMC_CONFIG5, |
| 31 | NET_LAN9221_GPMC_CONFIG6, |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 32 | }; |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 33 | #endif |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 34 | |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 35 | static const struct ns16550_platdata igep_serial = { |
| 36 | OMAP34XX_UART3, |
| 37 | 2, |
| 38 | V_NS16550_CLK |
| 39 | }; |
| 40 | |
| 41 | U_BOOT_DEVICE(igep_uart) = { |
| 42 | "serial_omap", |
| 43 | &igep_serial |
| 44 | }; |
| 45 | |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 46 | /* |
| 47 | * Routine: board_init |
| 48 | * Description: Early hardware init. |
| 49 | */ |
| 50 | int board_init(void) |
| 51 | { |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 52 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 53 | /* boot param addr */ |
| 54 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 55 | |
| 56 | return 0; |
| 57 | } |
| 58 | |
Javier Martinez Canillas | d549ace | 2012-12-27 03:36:01 +0000 | [diff] [blame] | 59 | #if defined(CONFIG_SHOW_BOOT_PROGRESS) && !defined(CONFIG_SPL_BUILD) |
| 60 | void show_boot_progress(int val) |
| 61 | { |
| 62 | if (val < 0) { |
| 63 | /* something went wrong */ |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | if (!gpio_request(IGEP00X0_GPIO_LED, "")) |
| 68 | gpio_direction_output(IGEP00X0_GPIO_LED, 1); |
| 69 | } |
| 70 | #endif |
| 71 | |
Javier Martinez Canillas | 361fc83 | 2012-07-28 01:19:34 +0000 | [diff] [blame] | 72 | #ifdef CONFIG_SPL_BUILD |
| 73 | /* |
| 74 | * Routine: omap_rev_string |
| 75 | * Description: For SPL builds output board rev |
| 76 | */ |
| 77 | void omap_rev_string(void) |
| 78 | { |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | * Routine: get_board_mem_timings |
| 83 | * Description: If we use SPL then there is no x-loader nor config header |
| 84 | * so we have to setup the DDR timings ourself on both banks. |
| 85 | */ |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 86 | void get_board_mem_timings(struct board_sdrc_timings *timings) |
Javier Martinez Canillas | 361fc83 | 2012-07-28 01:19:34 +0000 | [diff] [blame] | 87 | { |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 88 | timings->mr = MICRON_V_MR_165; |
Javier Martinez Canillas | 361fc83 | 2012-07-28 01:19:34 +0000 | [diff] [blame] | 89 | #ifdef CONFIG_BOOT_NAND |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 90 | timings->mcfg = MICRON_V_MCFG_200(256 << 20); |
| 91 | timings->ctrla = MICRON_V_ACTIMA_200; |
| 92 | timings->ctrlb = MICRON_V_ACTIMB_200; |
| 93 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
Javier Martinez Canillas | 361fc83 | 2012-07-28 01:19:34 +0000 | [diff] [blame] | 94 | #else |
| 95 | if (get_cpu_family() == CPU_OMAP34XX) { |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 96 | timings->mcfg = NUMONYX_V_MCFG_165(256 << 20); |
| 97 | timings->ctrla = NUMONYX_V_ACTIMA_165; |
| 98 | timings->ctrlb = NUMONYX_V_ACTIMB_165; |
| 99 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
Javier Martinez Canillas | 361fc83 | 2012-07-28 01:19:34 +0000 | [diff] [blame] | 100 | |
| 101 | } else { |
Peter Barada | edb5c2f | 2012-11-13 07:40:28 +0000 | [diff] [blame] | 102 | timings->mcfg = NUMONYX_V_MCFG_200(256 << 20); |
| 103 | timings->ctrla = NUMONYX_V_ACTIMA_200; |
| 104 | timings->ctrlb = NUMONYX_V_ACTIMB_200; |
| 105 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
Javier Martinez Canillas | 361fc83 | 2012-07-28 01:19:34 +0000 | [diff] [blame] | 106 | } |
| 107 | #endif |
| 108 | } |
| 109 | #endif |
| 110 | |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 111 | #if defined(CONFIG_CMD_NET) |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 112 | /* |
| 113 | * Routine: setup_net_chip |
| 114 | * Description: Setting up the configuration GPMC registers specific to the |
| 115 | * Ethernet hardware. |
| 116 | */ |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 117 | static void setup_net_chip(void) |
| 118 | { |
| 119 | struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; |
| 120 | |
| 121 | enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000, |
| 122 | GPMC_SIZE_16M); |
| 123 | |
| 124 | /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ |
| 125 | writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); |
| 126 | /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ |
| 127 | writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); |
| 128 | /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ |
| 129 | writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, |
| 130 | &ctrl_base->gpmc_nadv_ale); |
| 131 | |
| 132 | /* Make GPIO 64 as output pin and send a magic pulse through it */ |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 133 | if (!gpio_request(64, "")) { |
| 134 | gpio_direction_output(64, 0); |
| 135 | gpio_set_value(64, 1); |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 136 | udelay(1); |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 137 | gpio_set_value(64, 0); |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 138 | udelay(1); |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 139 | gpio_set_value(64, 1); |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 140 | } |
| 141 | } |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 142 | #else |
| 143 | static inline void setup_net_chip(void) {} |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 144 | #endif |
| 145 | |
Javier Martinez Canillas | 361fc83 | 2012-07-28 01:19:34 +0000 | [diff] [blame] | 146 | #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD) |
Enric Balletbo i Serra | da898a9 | 2010-11-04 15:34:33 -0400 | [diff] [blame] | 147 | int board_mmc_init(bd_t *bis) |
| 148 | { |
Nikita Kiryanov | 4be9dbc | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 149 | return omap_mmc_init(0, 0, 0, -1, -1); |
Enric Balletbo i Serra | da898a9 | 2010-11-04 15:34:33 -0400 | [diff] [blame] | 150 | } |
| 151 | #endif |
| 152 | |
Javier Martinez Canillas | 7a0155e | 2013-08-07 17:53:19 +0200 | [diff] [blame] | 153 | void set_fdt(void) |
| 154 | { |
| 155 | switch (gd->bd->bi_arch_number) { |
| 156 | case MACH_TYPE_IGEP0020: |
| 157 | setenv("dtbfile", "omap3-igep0020.dtb"); |
| 158 | break; |
| 159 | case MACH_TYPE_IGEP0030: |
| 160 | setenv("dtbfile", "omap3-igep0030.dtb"); |
| 161 | break; |
| 162 | } |
| 163 | } |
| 164 | |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 165 | /* |
| 166 | * Routine: misc_init_r |
| 167 | * Description: Configure board specific parts |
| 168 | */ |
| 169 | int misc_init_r(void) |
| 170 | { |
| 171 | twl4030_power_init(); |
| 172 | |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 173 | setup_net_chip(); |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 174 | |
| 175 | dieid_num_r(); |
| 176 | |
Javier Martinez Canillas | 7a0155e | 2013-08-07 17:53:19 +0200 | [diff] [blame] | 177 | set_fdt(); |
| 178 | |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | /* |
| 183 | * Routine: set_muxconf_regs |
| 184 | * Description: Setting up the configuration Mux registers specific to the |
| 185 | * hardware. Many pins need to be moved from protect to primary |
| 186 | * mode. |
| 187 | */ |
| 188 | void set_muxconf_regs(void) |
| 189 | { |
| 190 | MUX_DEFAULT(); |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 191 | |
| 192 | #if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020) |
| 193 | MUX_IGEP0020(); |
| 194 | #endif |
| 195 | |
| 196 | #if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030) |
| 197 | MUX_IGEP0030(); |
| 198 | #endif |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 199 | } |
| 200 | |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 201 | #if defined(CONFIG_CMD_NET) |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 202 | int board_eth_init(bd_t *bis) |
| 203 | { |
| 204 | int rc = 0; |
| 205 | #ifdef CONFIG_SMC911X |
| 206 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 207 | #endif |
| 208 | return rc; |
| 209 | } |
Javier Martinez Canillas | e9b1452 | 2012-12-27 01:35:56 +0000 | [diff] [blame] | 210 | #endif |