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