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