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