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 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | #include <common.h> |
| 24 | #include <netdev.h> |
| 25 | #include <twl4030.h> |
| 26 | #include <asm/io.h> |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 27 | #include <asm/gpio.h> |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 28 | #include <asm/arch/mem.h> |
Enric Balletbo i Serra | da898a9 | 2010-11-04 15:34:33 -0400 | [diff] [blame] | 29 | #include <asm/arch/mmc_host_def.h> |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 30 | #include <asm/arch/mux.h> |
| 31 | #include <asm/arch/sys_proto.h> |
Philip Balister | 1dc7d23 | 2011-09-14 13:32:22 -0400 | [diff] [blame] | 32 | #include <asm/arch/omap_gpmc.h> |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 33 | #include <asm/mach-types.h> |
| 34 | #include "igep0020.h" |
| 35 | |
John Rigby | 0d21ed0 | 2010-12-20 18:27:51 -0700 | [diff] [blame] | 36 | DECLARE_GLOBAL_DATA_PTR; |
| 37 | |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 38 | /* GPMC definitions for LAN9221 chips */ |
| 39 | static const u32 gpmc_lan_config[] = { |
| 40 | NET_LAN9221_GPMC_CONFIG1, |
| 41 | NET_LAN9221_GPMC_CONFIG2, |
| 42 | NET_LAN9221_GPMC_CONFIG3, |
| 43 | NET_LAN9221_GPMC_CONFIG4, |
| 44 | NET_LAN9221_GPMC_CONFIG5, |
| 45 | NET_LAN9221_GPMC_CONFIG6, |
| 46 | }; |
| 47 | |
| 48 | /* |
| 49 | * Routine: board_init |
| 50 | * Description: Early hardware init. |
| 51 | */ |
| 52 | int board_init(void) |
| 53 | { |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 54 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 55 | /* boot param addr */ |
| 56 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 57 | |
| 58 | return 0; |
| 59 | } |
| 60 | |
Javier Martinez Canillas | 361fc83 | 2012-07-28 01:19:34 +0000 | [diff] [blame] | 61 | #ifdef CONFIG_SPL_BUILD |
| 62 | /* |
| 63 | * Routine: omap_rev_string |
| 64 | * Description: For SPL builds output board rev |
| 65 | */ |
| 66 | void omap_rev_string(void) |
| 67 | { |
| 68 | } |
| 69 | |
| 70 | /* |
| 71 | * Routine: get_board_mem_timings |
| 72 | * Description: If we use SPL then there is no x-loader nor config header |
| 73 | * so we have to setup the DDR timings ourself on both banks. |
| 74 | */ |
| 75 | void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl, |
| 76 | u32 *mr) |
| 77 | { |
| 78 | *mr = MICRON_V_MR_165; |
| 79 | #ifdef CONFIG_BOOT_NAND |
| 80 | *mcfg = MICRON_V_MCFG_200(512 << 20); |
| 81 | *ctrla = MICRON_V_ACTIMA_200; |
| 82 | *ctrlb = MICRON_V_ACTIMB_200; |
| 83 | *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
| 84 | #else |
| 85 | if (get_cpu_family() == CPU_OMAP34XX) { |
| 86 | *mcfg = NUMONYX_V_MCFG_165(512 << 20); |
| 87 | *ctrla = NUMONYX_V_ACTIMA_165; |
| 88 | *ctrlb = NUMONYX_V_ACTIMB_165; |
| 89 | *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; |
| 90 | |
| 91 | } else { |
| 92 | *mcfg = NUMONYX_V_MCFG_200(512 << 20); |
| 93 | *ctrla = NUMONYX_V_ACTIMA_200; |
| 94 | *ctrlb = NUMONYX_V_ACTIMB_200; |
| 95 | *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
| 96 | } |
| 97 | #endif |
| 98 | } |
| 99 | #endif |
| 100 | |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 101 | /* |
| 102 | * Routine: setup_net_chip |
| 103 | * Description: Setting up the configuration GPMC registers specific to the |
| 104 | * Ethernet hardware. |
| 105 | */ |
| 106 | #if defined(CONFIG_CMD_NET) |
| 107 | static void setup_net_chip(void) |
| 108 | { |
| 109 | struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; |
| 110 | |
| 111 | enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000, |
| 112 | GPMC_SIZE_16M); |
| 113 | |
| 114 | /* Enable off mode for NWE in PADCONF_GPMC_NWE register */ |
| 115 | writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe); |
| 116 | /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */ |
| 117 | writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe); |
| 118 | /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */ |
| 119 | writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00, |
| 120 | &ctrl_base->gpmc_nadv_ale); |
| 121 | |
| 122 | /* 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] | 123 | if (!gpio_request(64, "")) { |
| 124 | gpio_direction_output(64, 0); |
| 125 | gpio_set_value(64, 1); |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 126 | udelay(1); |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 127 | gpio_set_value(64, 0); |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 128 | udelay(1); |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 129 | gpio_set_value(64, 1); |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 130 | } |
| 131 | } |
| 132 | #endif |
| 133 | |
Javier Martinez Canillas | 361fc83 | 2012-07-28 01:19:34 +0000 | [diff] [blame] | 134 | #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD) |
Enric Balletbo i Serra | da898a9 | 2010-11-04 15:34:33 -0400 | [diff] [blame] | 135 | int board_mmc_init(bd_t *bis) |
| 136 | { |
Jonathan Solnit | a9b0556 | 2012-02-24 11:30:18 +0000 | [diff] [blame] | 137 | omap_mmc_init(0, 0, 0); |
Enric Balletbo i Serra | da898a9 | 2010-11-04 15:34:33 -0400 | [diff] [blame] | 138 | return 0; |
| 139 | } |
| 140 | #endif |
| 141 | |
Enric Balletbo i Serra | 2ce268c | 2010-10-14 16:54:59 -0400 | [diff] [blame] | 142 | /* |
| 143 | * Routine: misc_init_r |
| 144 | * Description: Configure board specific parts |
| 145 | */ |
| 146 | int misc_init_r(void) |
| 147 | { |
| 148 | twl4030_power_init(); |
| 149 | |
| 150 | #if defined(CONFIG_CMD_NET) |
| 151 | setup_net_chip(); |
| 152 | #endif |
| 153 | |
| 154 | dieid_num_r(); |
| 155 | |
| 156 | return 0; |
| 157 | } |
| 158 | |
| 159 | /* |
| 160 | * Routine: set_muxconf_regs |
| 161 | * Description: Setting up the configuration Mux registers specific to the |
| 162 | * hardware. Many pins need to be moved from protect to primary |
| 163 | * mode. |
| 164 | */ |
| 165 | void set_muxconf_regs(void) |
| 166 | { |
| 167 | MUX_DEFAULT(); |
| 168 | } |
| 169 | |
| 170 | int board_eth_init(bd_t *bis) |
| 171 | { |
| 172 | int rc = 0; |
| 173 | #ifdef CONFIG_SMC911X |
| 174 | rc = smc911x_initialize(0, CONFIG_SMC911X_BASE); |
| 175 | #endif |
| 176 | return rc; |
| 177 | } |