blob: 3b2b1f15b8e9647fe0fc72efee1e8f78fa11b588 [file] [log] [blame]
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -04001/*
2 * (C) Copyright 2010
3 * ISEE 2007 SL, <www.iseebcn.com>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -04006 */
7#include <common.h>
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -04008#include <twl4030.h>
Javier Martinez Canillas77eea282012-12-27 01:35:56 +00009#include <netdev.h>
Sanjeev Premi84c3b632011-09-08 10:51:01 -040010#include <asm/gpio.h>
Javier Martinez Canillas77eea282012-12-27 01:35:56 +000011#include <asm/io.h>
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -040012#include <asm/arch/mem.h>
Enric Balletbo i Serraf49d7b62010-11-04 15:34:33 -040013#include <asm/arch/mmc_host_def.h>
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -040014#include <asm/arch/mux.h>
15#include <asm/arch/sys_proto.h>
16#include <asm/mach-types.h>
Javier Martinez Canillas77eea282012-12-27 01:35:56 +000017#include "igep00x0.h"
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -040018
John Rigby29565322010-12-20 18:27:51 -070019DECLARE_GLOBAL_DATA_PTR;
20
Javier Martinez Canillas77eea282012-12-27 01:35:56 +000021#if defined(CONFIG_CMD_NET)
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -040022/* GPMC definitions for LAN9221 chips */
23static const u32 gpmc_lan_config[] = {
Javier Martinez Canillas77eea282012-12-27 01:35:56 +000024 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 Serra8a3f6bb2010-10-14 16:54:59 -040030};
Javier Martinez Canillas77eea282012-12-27 01:35:56 +000031#endif
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -040032
33/*
34 * Routine: board_init
35 * Description: Early hardware init.
36 */
37int board_init(void)
38{
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -040039 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -040040 /* boot param addr */
41 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
42
43 return 0;
44}
45
Javier Martinez Canillas9d4f5422012-12-27 03:36:01 +000046#if defined(CONFIG_SHOW_BOOT_PROGRESS) && !defined(CONFIG_SPL_BUILD)
47void 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 Canillasd271a612012-07-28 01:19:34 +000059#ifdef CONFIG_SPL_BUILD
60/*
61 * Routine: omap_rev_string
62 * Description: For SPL builds output board rev
63 */
64void 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 Barada8c4445d2012-11-13 07:40:28 +000073void get_board_mem_timings(struct board_sdrc_timings *timings)
Javier Martinez Canillasd271a612012-07-28 01:19:34 +000074{
Peter Barada8c4445d2012-11-13 07:40:28 +000075 timings->mr = MICRON_V_MR_165;
Javier Martinez Canillasd271a612012-07-28 01:19:34 +000076#ifdef CONFIG_BOOT_NAND
Peter Barada8c4445d2012-11-13 07:40:28 +000077 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 Canillasd271a612012-07-28 01:19:34 +000081#else
82 if (get_cpu_family() == CPU_OMAP34XX) {
Peter Barada8c4445d2012-11-13 07:40:28 +000083 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 Canillasd271a612012-07-28 01:19:34 +000087
88 } else {
Peter Barada8c4445d2012-11-13 07:40:28 +000089 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 Canillasd271a612012-07-28 01:19:34 +000093 }
94#endif
95}
96#endif
97
Javier Martinez Canillas77eea282012-12-27 01:35:56 +000098#if defined(CONFIG_CMD_NET)
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -040099/*
100 * Routine: setup_net_chip
101 * Description: Setting up the configuration GPMC registers specific to the
102 * Ethernet hardware.
103 */
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -0400104static 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 Premi84c3b632011-09-08 10:51:01 -0400120 if (!gpio_request(64, "")) {
121 gpio_direction_output(64, 0);
122 gpio_set_value(64, 1);
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -0400123 udelay(1);
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400124 gpio_set_value(64, 0);
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -0400125 udelay(1);
Sanjeev Premi84c3b632011-09-08 10:51:01 -0400126 gpio_set_value(64, 1);
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -0400127 }
128}
Javier Martinez Canillas77eea282012-12-27 01:35:56 +0000129#else
130static inline void setup_net_chip(void) {}
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -0400131#endif
132
Javier Martinez Canillasd271a612012-07-28 01:19:34 +0000133#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
Enric Balletbo i Serraf49d7b62010-11-04 15:34:33 -0400134int board_mmc_init(bd_t *bis)
135{
Nikita Kiryanove3913f52012-12-03 02:19:47 +0000136 return omap_mmc_init(0, 0, 0, -1, -1);
Enric Balletbo i Serraf49d7b62010-11-04 15:34:33 -0400137}
138#endif
139
Javier Martinez Canillasa2fa28b2013-08-07 17:53:19 +0200140void 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 Serra8a3f6bb2010-10-14 16:54:59 -0400152/*
153 * Routine: misc_init_r
154 * Description: Configure board specific parts
155 */
156int misc_init_r(void)
157{
158 twl4030_power_init();
159
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -0400160 setup_net_chip();
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -0400161
162 dieid_num_r();
163
Javier Martinez Canillasa2fa28b2013-08-07 17:53:19 +0200164 set_fdt();
165
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -0400166 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 */
175void set_muxconf_regs(void)
176{
177 MUX_DEFAULT();
Javier Martinez Canillas77eea282012-12-27 01:35:56 +0000178
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 Serra8a3f6bb2010-10-14 16:54:59 -0400186}
187
Javier Martinez Canillas77eea282012-12-27 01:35:56 +0000188#if defined(CONFIG_CMD_NET)
Enric Balletbo i Serra8a3f6bb2010-10-14 16:54:59 -0400189int 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 Canillas77eea282012-12-27 01:35:56 +0000197#endif