1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <common.h>
21#include <netdev.h>
22#include <twl4030.h>
23#include <asm/io.h>
24#include <asm/arch/mmc_host_def.h>
25#include <asm/arch/omap3-regs.h>
26#include <asm/arch/mux.h>
27#include <asm/arch/mem.h>
28#include <asm/arch/sys_proto.h>
29#include <asm/gpio.h>
30#include <asm/mach-types.h>
31#include "dig297.h"
32
33DECLARE_GLOBAL_DATA_PTR;
34
35#ifdef CONFIG_CMD_NET
36static void setup_net_chip(void);
37
38#define NET_LAN9221_RESET_GPIO 12
39
40
41#define NET_LAN9220_GPMC_CONFIG1 (DEVICESIZE_16BIT)
42#define NET_LAN9220_GPMC_CONFIG2 (CSWROFFTIME(8) | \
43 CSRDOFFTIME(7) | \
44 ADVONTIME(1))
45#define NET_LAN9220_GPMC_CONFIG3 (ADVWROFFTIME(2) | \
46 ADVRDOFFTIME(2) | \
47 ADVONTIME(1))
48#define NET_LAN9220_GPMC_CONFIG4 (WEOFFTIME(8) | \
49 WEONTIME(1) | \
50 OEOFFTIME(7)| \
51 OEONTIME(1))
52#define NET_LAN9220_GPMC_CONFIG5 (PAGEBURSTACCESSTIME(0) | \
53 RDACCESSTIME(6) | \
54 WRCYCLETIME(0x1D) | \
55 RDCYCLETIME(0x1D))
56#define NET_LAN9220_GPMC_CONFIG6 ((1 << 31) | \
57 WRACCESSTIME(0x1D) | \
58 WRDATAONADMUXBUS(3))
59
60static const u32 gpmc_lan_config[] = {
61 NET_LAN9220_GPMC_CONFIG1,
62 NET_LAN9220_GPMC_CONFIG2,
63 NET_LAN9220_GPMC_CONFIG3,
64 NET_LAN9220_GPMC_CONFIG4,
65 NET_LAN9220_GPMC_CONFIG5,
66 NET_LAN9220_GPMC_CONFIG6,
67
68};
69#endif
70
71
72
73
74
75int board_init(void)
76{
77 gpmc_init();
78
79 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
80
81 return 0;
82}
83
84
85
86
87
88int misc_init_r(void)
89{
90 struct gpio *gpio1_base = (struct gpio *)OMAP34XX_GPIO1_BASE;
91 struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
92
93 twl4030_power_init();
94 twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
95
96
97
98
99
100
101
102
103
104 writel(~(GPIO19 | GPIO20), &gpio1_base->oe);
105 writel(~(GPIO31), &gpio5_base->oe);
106
107
108 writel((GPIO19 | GPIO20), &gpio1_base->setdataout);
109 writel(0, &gpio5_base->setdataout);
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
122
123
124
125
126void set_muxconf_regs(void)
127{
128 MUX_DIG297();
129}
130
131#ifdef CONFIG_GENERIC_MMC
132int board_mmc_init(bd_t *bis)
133{
134 return omap_mmc_init(0, 0, 0, -1, -1);
135}
136
137void board_mmc_power_init(void)
138{
139 twl4030_power_mmc_init(0);
140}
141#endif
142
143#ifdef CONFIG_CMD_NET
144
145
146
147
148
149static void setup_net_chip(void)
150{
151 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
152
153
154 enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5],
155 CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
156
157
158 writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
159
160 writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
161
162 writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
163 &ctrl_base->gpmc_nadv_ale);
164
165
166 if (!gpio_request(NET_LAN9221_RESET_GPIO, "")) {
167 gpio_direction_output(NET_LAN9221_RESET_GPIO, 0);
168 gpio_set_value(NET_LAN9221_RESET_GPIO, 1);
169 udelay(1);
170 gpio_set_value(NET_LAN9221_RESET_GPIO, 0);
171 udelay(31000);
172 gpio_set_value(NET_LAN9221_RESET_GPIO, 1);
173 }
174}
175#endif
176
177int board_eth_init(bd_t *bis)
178{
179 int rc = 0;
180 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
181 return rc;
182}
183