blob: 2279cc0e36efe5902db9b1b84325b645f65dd5f3 [file] [log] [blame]
Enric Balletbo i Serra2ce268c2010-10-14 16:54:59 -04001/*
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 Premi7b3dc822011-09-08 10:51:01 -040027#include <asm/gpio.h>
Enric Balletbo i Serra2ce268c2010-10-14 16:54:59 -040028#include <asm/arch/mem.h>
Enric Balletbo i Serrada898a92010-11-04 15:34:33 -040029#include <asm/arch/mmc_host_def.h>
Enric Balletbo i Serra2ce268c2010-10-14 16:54:59 -040030#include <asm/arch/mux.h>
31#include <asm/arch/sys_proto.h>
32#include <asm/mach-types.h>
33#include "igep0020.h"
34
John Rigby0d21ed02010-12-20 18:27:51 -070035DECLARE_GLOBAL_DATA_PTR;
36
Enric Balletbo i Serra2ce268c2010-10-14 16:54:59 -040037/* GPMC definitions for LAN9221 chips */
38static const u32 gpmc_lan_config[] = {
39 NET_LAN9221_GPMC_CONFIG1,
40 NET_LAN9221_GPMC_CONFIG2,
41 NET_LAN9221_GPMC_CONFIG3,
42 NET_LAN9221_GPMC_CONFIG4,
43 NET_LAN9221_GPMC_CONFIG5,
44 NET_LAN9221_GPMC_CONFIG6,
45};
46
47/*
48 * Routine: board_init
49 * Description: Early hardware init.
50 */
51int board_init(void)
52{
Enric Balletbo i Serra2ce268c2010-10-14 16:54:59 -040053 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
54 /* board id for Linux */
55 gd->bd->bi_arch_number = MACH_TYPE_IGEP0020;
56 /* boot param addr */
57 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
58
59 return 0;
60}
61
62/*
63 * Routine: setup_net_chip
64 * Description: Setting up the configuration GPMC registers specific to the
65 * Ethernet hardware.
66 */
67#if defined(CONFIG_CMD_NET)
68static void setup_net_chip(void)
69{
70 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
71
72 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
73 GPMC_SIZE_16M);
74
75 /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
76 writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
77 /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
78 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
79 /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
80 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
81 &ctrl_base->gpmc_nadv_ale);
82
83 /* Make GPIO 64 as output pin and send a magic pulse through it */
Sanjeev Premi7b3dc822011-09-08 10:51:01 -040084 if (!gpio_request(64, "")) {
85 gpio_direction_output(64, 0);
86 gpio_set_value(64, 1);
Enric Balletbo i Serra2ce268c2010-10-14 16:54:59 -040087 udelay(1);
Sanjeev Premi7b3dc822011-09-08 10:51:01 -040088 gpio_set_value(64, 0);
Enric Balletbo i Serra2ce268c2010-10-14 16:54:59 -040089 udelay(1);
Sanjeev Premi7b3dc822011-09-08 10:51:01 -040090 gpio_set_value(64, 1);
Enric Balletbo i Serra2ce268c2010-10-14 16:54:59 -040091 }
92}
93#endif
94
Enric Balletbo i Serrada898a92010-11-04 15:34:33 -040095#ifdef CONFIG_GENERIC_MMC
96int board_mmc_init(bd_t *bis)
97{
98 omap_mmc_init(0);
99 return 0;
100}
101#endif
102
Enric Balletbo i Serra2ce268c2010-10-14 16:54:59 -0400103/*
104 * Routine: misc_init_r
105 * Description: Configure board specific parts
106 */
107int misc_init_r(void)
108{
109 twl4030_power_init();
110
111#if defined(CONFIG_CMD_NET)
112 setup_net_chip();
113#endif
114
115 dieid_num_r();
116
117 return 0;
118}
119
120/*
121 * Routine: set_muxconf_regs
122 * Description: Setting up the configuration Mux registers specific to the
123 * hardware. Many pins need to be moved from protect to primary
124 * mode.
125 */
126void set_muxconf_regs(void)
127{
128 MUX_DEFAULT();
129}
130
131int board_eth_init(bd_t *bis)
132{
133 int rc = 0;
134#ifdef CONFIG_SMC911X
135 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
136#endif
137 return rc;
138}