1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include <common.h>
17#include <i2c.h>
18#include <net.h>
19#include <netdev.h>
20#include <spi.h>
21#include <spi_flash.h>
22#include <asm/arch/hardware.h>
23#include <asm/arch/pinmux_defs.h>
24#include <asm/io.h>
25#include <asm/arch/davinci_misc.h>
26#include <linux/errno.h>
27#include <hwconfig.h>
28#include <asm/mach-types.h>
29#include <asm/setup.h>
30
31#ifdef CONFIG_MMC_DAVINCI
32#include <mmc.h>
33#include <asm/arch/sdmmc_defs.h>
34#endif
35
36DECLARE_GLOBAL_DATA_PTR;
37
38u8 board_rev;
39
40#define EEPROM_I2C_ADDR 0x50
41#define EEPROM_REV_OFFSET 0x3F00
42#define EEPROM_MAC_OFFSET 0x3F06
43
44#ifdef CONFIG_MMC_DAVINCI
45static struct davinci_mmc mmc_sd0 = {
46 .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
47 .host_caps = MMC_MODE_4BIT,
48 .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
49 .version = MMC_CTLR_VERSION_2,
50};
51
52int board_mmc_init(bd_t *bis)
53{
54 mmc_sd0.input_clk = clk_get(DAVINCI_MMCSD_CLKID);
55
56
57 return davinci_mmc_init(bis, &mmc_sd0);
58}
59#endif
60
61const struct pinmux_resource pinmuxes[] = {
62 PINMUX_ITEM(spi0_pins_base),
63 PINMUX_ITEM(spi0_pins_scs0),
64 PINMUX_ITEM(uart1_pins_txrx),
65 PINMUX_ITEM(i2c0_pins),
66 PINMUX_ITEM(mmc0_pins),
67};
68
69const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
70
71const struct lpsc_resource lpsc[] = {
72 { DAVINCI_LPSC_SPI0 },
73 { DAVINCI_LPSC_UART1 },
74 { DAVINCI_LPSC_MMC_SD },
75};
76
77const int lpsc_size = ARRAY_SIZE(lpsc);
78
79u32 get_board_rev(void)
80{
81 u8 buf[2];
82
83 if (!board_rev) {
84 if (i2c_read(EEPROM_I2C_ADDR, EEPROM_REV_OFFSET, 2, buf, 2)) {
85 printf("\nBoard revision read failed!\n");
86 } else {
87
88
89
90
91
92 if ((buf[0] ^ buf[1]) == 0xFF)
93 board_rev = buf[0];
94 else
95 board_rev = 3;
96 }
97 }
98
99 return board_rev;
100}
101
102
103
104
105void get_board_serial(struct tag_serialnr *serialnr)
106{
107 u32 offset;
108 u8 buf[6];
109
110 if (!board_rev)
111 board_rev = get_board_rev();
112
113
114 offset = (board_rev == 3) ? EEPROM_REV_OFFSET : EEPROM_MAC_OFFSET;
115
116 if (i2c_read(EEPROM_I2C_ADDR, offset, 2, buf, 6)) {
117 printf("\nBoard serial read failed!\n");
118 } else {
119 u8 *nr;
120
121 nr = (u8 *)&serialnr->low;
122 nr[0] = buf[5];
123 nr[1] = buf[4];
124 nr[2] = buf[3];
125 nr[3] = buf[2];
126 nr = (u8 *)&serialnr->high;
127 nr[0] = buf[1];
128 nr[1] = buf[0];
129 nr[2] = 0;
130 nr[3] = 0;
131 }
132}
133
134int board_early_init_f(void)
135{
136
137
138
139
140
141
142 if (da8xx_configure_lpsc_items(lpsc, ARRAY_SIZE(lpsc)))
143 return 1;
144
145 return 0;
146}
147
148int board_init(void)
149{
150 irq_init();
151
152
153
154 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DA850_EVM;
155
156
157 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
158
159
160 writel(readl(&davinci_syscfg_regs->suspsrc) &
161 ~(DAVINCI_SYSCFG_SUSPSRC_EMAC | DAVINCI_SYSCFG_SUSPSRC_I2C |
162 DAVINCI_SYSCFG_SUSPSRC_SPI0 | DAVINCI_SYSCFG_SUSPSRC_TIMER0 |
163 DAVINCI_SYSCFG_SUSPSRC_UART1),
164 &davinci_syscfg_regs->suspsrc);
165
166
167 if (davinci_configure_pin_mux_items(pinmuxes, ARRAY_SIZE(pinmuxes)))
168 return 1;
169
170
171 writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST |
172 DAVINCI_UART_PWREMU_MGMT_UTRST),
173 &davinci_uart1_ctrl_regs->pwremu_mgmt);
174
175 return 0;
176}
177