1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35#include <common.h>
36#include <i2c.h>
37#include <net.h>
38#include <netdev.h>
39#include <asm/arch/hardware.h>
40#include <asm/arch/emif_defs.h>
41#include <asm/arch/emac_defs.h>
42#include <asm/arch/pinmux_defs.h>
43#include <asm/io.h>
44#include <nand.h>
45#include <asm/arch/nand_defs.h>
46#include <asm/arch/davinci_misc.h>
47
48#ifdef CONFIG_DAVINCI_MMC
49#include <mmc.h>
50#include <asm/arch/sdmmc_defs.h>
51#endif
52
53DECLARE_GLOBAL_DATA_PTR;
54
55static const struct pinmux_resource pinmuxes[] = {
56#ifdef CONFIG_SPI_FLASH
57 PINMUX_ITEM(spi0_pins_base),
58 PINMUX_ITEM(spi0_pins_scs0),
59 PINMUX_ITEM(spi0_pins_ena),
60#endif
61 PINMUX_ITEM(uart2_pins_txrx),
62 PINMUX_ITEM(i2c0_pins),
63#ifdef CONFIG_USB_DA8XX
64 PINMUX_ITEM(usb_pins),
65#endif
66#ifdef CONFIG_USE_NAND
67 PINMUX_ITEM(emifa_pins),
68 PINMUX_ITEM(emifa_pins_cs0),
69 PINMUX_ITEM(emifa_pins_cs2),
70 PINMUX_ITEM(emifa_pins_cs3),
71#endif
72#if defined(CONFIG_DRIVER_TI_EMAC)
73 PINMUX_ITEM(emac_pins_rmii),
74 PINMUX_ITEM(emac_pins_mdio),
75 PINMUX_ITEM(emac_pins_rmii_clk_source),
76#endif
77#ifdef CONFIG_DAVINCI_MMC
78 PINMUX_ITEM(mmc0_pins_8bit)
79#endif
80};
81
82static const struct lpsc_resource lpsc[] = {
83 { DAVINCI_LPSC_AEMIF },
84 { DAVINCI_LPSC_SPI0 },
85 { DAVINCI_LPSC_EMAC },
86 { DAVINCI_LPSC_UART2 },
87 { DAVINCI_LPSC_GPIO },
88#ifdef CONFIG_DAVINCI_MMC
89 { DAVINCI_LPSC_MMC_SD },
90#endif
91
92};
93
94#ifdef CONFIG_DAVINCI_MMC
95static struct davinci_mmc mmc_sd0 = {
96 .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
97 .host_caps = MMC_MODE_8BIT,
98 .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
99 .version = MMC_CTLR_VERSION_2,
100};
101
102int board_mmc_init(bd_t *bis)
103{
104 mmc_sd0.input_clk = clk_get(DAVINCI_MMCSD_CLKID);
105
106 printf("%x\n", mmc_sd0.input_clk);
107
108
109 return davinci_mmc_init(bis, &mmc_sd0);
110}
111#endif
112
113int board_init(void)
114{
115#ifndef CONFIG_USE_IRQ
116 irq_init();
117#endif
118
119#ifdef CONFIG_NAND_DAVINCI
120
121 writel(readl(&davinci_syscfg_regs->cfgchip3) & ~2,
122 &davinci_syscfg_regs->cfgchip3);
123
124 writel((DAVINCI_ABCR_WSETUP(0) |
125 DAVINCI_ABCR_WSTROBE(2) |
126 DAVINCI_ABCR_WHOLD(0) |
127 DAVINCI_ABCR_RSETUP(0) |
128 DAVINCI_ABCR_RSTROBE(2) |
129 DAVINCI_ABCR_RHOLD(0) |
130 DAVINCI_ABCR_TA(2) |
131 DAVINCI_ABCR_ASIZE_8BIT),
132 &davinci_emif_regs->ab2cr);
133#endif
134
135
136 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA830_EVM;
137
138
139 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
140
141
142
143
144
145
146
147 if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
148 return 1;
149
150
151 writel(readl(&davinci_syscfg_regs->suspsrc) &
152 ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
153 DAVINCI_SYSCFG_SUSPSRC_SPI0 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
154 DAVINCI_SYSCFG_SUSPSRC_UART2),
155 &davinci_syscfg_regs->suspsrc);
156
157
158 if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
159 return 1;
160
161
162 writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
163 DAVINCI_UART_PWREMU_MGMT_UTRST),
164 &davinci_uart2_ctrl_regs->pwremu_mgmt);
165
166 return(0);
167}
168
169
170#ifdef CONFIG_NAND_DAVINCI
171int board_nand_init(struct nand_chip *nand)
172{
173 davinci_nand_init(nand);
174
175 return 0;
176}
177#endif
178
179#if defined(CONFIG_DRIVER_TI_EMAC)
180
181#define PHY_SW_I2C_ADDR 0x5f
182
183
184
185
186int board_eth_init(bd_t *bis)
187{
188 u_int8_t mac_addr[6];
189 u_int8_t switch_start_cmd[2] = { 0x01, 0x23 };
190 struct eth_device *dev;
191
192
193 if (dvevm_read_mac_address(mac_addr))
194
195 davinci_sync_env_enetaddr(mac_addr);
196
197
198 if (!eth_getenv_enetaddr("ethaddr", mac_addr))
199 return -1;
200
201
202 if (i2c_write(PHY_SW_I2C_ADDR, 0, 0,
203 switch_start_cmd, sizeof(switch_start_cmd))) {
204 printf("Ethernet switch start failed!\n");
205 return -1;
206 }
207
208
209 if (!davinci_emac_initialize()) {
210 printf("Error: Ethernet init failed!\n");
211 return -1;
212 }
213
214 dev = eth_get_dev();
215
216
217 memcpy(dev->enetaddr, mac_addr, 6);
218 dev->write_hwaddr(dev);
219
220 return 0;
221}
222#endif
223