Commit | Line | Data |
---|---|---|
8593790d MG |
1 | /* |
2 | * TI DA830/OMAP L137 EVM board | |
3 | * | |
4 | * Author: Mark A. Greer <mgreer@mvista.com> | |
5 | * Derived from: arch/arm/mach-davinci/board-dm644x-evm.c | |
6 | * | |
7 | * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under | |
8 | * the terms of the GNU General Public License version 2. This program | |
9 | * is licensed "as is" without any warranty of any kind, whether express | |
10 | * or implied. | |
11 | */ | |
12 | #include <linux/kernel.h> | |
13 | #include <linux/module.h> | |
14 | #include <linux/init.h> | |
15 | #include <linux/console.h> | |
13e1f044 | 16 | #include <linux/gpio.h> |
8593790d | 17 | #include <linux/i2c.h> |
13e1f044 | 18 | #include <linux/i2c/pcf857x.h> |
8593790d MG |
19 | #include <linux/i2c/at24.h> |
20 | ||
21 | #include <asm/mach-types.h> | |
22 | #include <asm/mach/arch.h> | |
23 | ||
24 | #include <mach/common.h> | |
25 | #include <mach/irqs.h> | |
26 | #include <mach/cp_intc.h> | |
32bf078c | 27 | #include <mach/mux.h> |
2eb30c81 | 28 | #include <mach/gpio.h> |
8593790d | 29 | #include <mach/da8xx.h> |
e33ef5e3 | 30 | #include <mach/asp.h> |
8593790d MG |
31 | |
32 | #define DA830_EVM_PHY_MASK 0x0 | |
33 | #define DA830_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */ | |
34 | ||
35 | static struct at24_platform_data da830_evm_i2c_eeprom_info = { | |
36 | .byte_len = SZ_256K / 8, | |
37 | .page_size = 64, | |
38 | .flags = AT24_FLAG_ADDR16, | |
39 | .setup = davinci_get_mac_addr, | |
40 | .context = (void *)0x7f00, | |
41 | }; | |
42 | ||
13e1f044 SC |
43 | static int da830_evm_ui_expander_setup(struct i2c_client *client, int gpio, |
44 | unsigned ngpio, void *context) | |
45 | { | |
46 | gpio_request(gpio + 6, "MUX_MODE"); | |
47 | #ifdef CONFIG_DA830_UI_LCD | |
48 | gpio_direction_output(gpio + 6, 0); | |
49 | #else /* Must be NAND or NOR */ | |
50 | gpio_direction_output(gpio + 6, 1); | |
51 | #endif | |
52 | return 0; | |
53 | } | |
54 | ||
55 | static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio, | |
56 | unsigned ngpio, void *context) | |
57 | { | |
58 | gpio_free(gpio + 6); | |
59 | return 0; | |
60 | } | |
61 | ||
62 | static struct pcf857x_platform_data da830_evm_ui_expander_info = { | |
63 | .gpio_base = DAVINCI_N_GPIO, | |
64 | .setup = da830_evm_ui_expander_setup, | |
65 | .teardown = da830_evm_ui_expander_teardown, | |
66 | }; | |
67 | ||
8593790d MG |
68 | static struct i2c_board_info __initdata da830_evm_i2c_devices[] = { |
69 | { | |
70 | I2C_BOARD_INFO("24c256", 0x50), | |
71 | .platform_data = &da830_evm_i2c_eeprom_info, | |
72 | }, | |
1a7ff8ff C |
73 | { |
74 | I2C_BOARD_INFO("tlv320aic3x", 0x18), | |
13e1f044 SC |
75 | }, |
76 | { | |
77 | I2C_BOARD_INFO("pcf8574", 0x3f), | |
78 | .platform_data = &da830_evm_ui_expander_info, | |
79 | }, | |
8593790d MG |
80 | }; |
81 | ||
82 | static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = { | |
83 | .bus_freq = 100, /* kHz */ | |
84 | .bus_delay = 0, /* usec */ | |
85 | }; | |
86 | ||
87 | static struct davinci_uart_config da830_evm_uart_config __initdata = { | |
88 | .enabled_uarts = 0x7, | |
89 | }; | |
90 | ||
32bf078c MG |
91 | static const short da830_evm_mcasp1_pins[] = { |
92 | DA830_AHCLKX1, DA830_ACLKX1, DA830_AFSX1, DA830_AHCLKR1, DA830_AFSR1, | |
93 | DA830_AMUTE1, DA830_AXR1_0, DA830_AXR1_1, DA830_AXR1_2, DA830_AXR1_5, | |
94 | DA830_ACLKR1, DA830_AXR1_6, DA830_AXR1_7, DA830_AXR1_8, DA830_AXR1_10, | |
95 | DA830_AXR1_11, | |
96 | -1 | |
97 | }; | |
98 | ||
e33ef5e3 C |
99 | static u8 da830_iis_serializer_direction[] = { |
100 | RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, | |
101 | INACTIVE_MODE, TX_MODE, INACTIVE_MODE, INACTIVE_MODE, | |
102 | INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, | |
103 | }; | |
104 | ||
105 | static struct snd_platform_data da830_evm_snd_data = { | |
106 | .tx_dma_offset = 0x2000, | |
107 | .rx_dma_offset = 0x2000, | |
108 | .op_mode = DAVINCI_MCASP_IIS_MODE, | |
109 | .num_serializer = ARRAY_SIZE(da830_iis_serializer_direction), | |
110 | .tdm_slots = 2, | |
111 | .serial_dir = da830_iis_serializer_direction, | |
112 | .eventq_no = EVENTQ_0, | |
113 | .version = MCASP_VERSION_2, | |
114 | .txnumevt = 1, | |
115 | .rxnumevt = 1, | |
116 | }; | |
117 | ||
2eb30c81 DG |
118 | /* |
119 | * GPIO2[1] is used as MMC_SD_WP and GPIO2[2] as MMC_SD_INS. | |
120 | */ | |
121 | static const short da830_evm_mmc_sd_pins[] = { | |
122 | DA830_MMCSD_DAT_0, DA830_MMCSD_DAT_1, DA830_MMCSD_DAT_2, | |
123 | DA830_MMCSD_DAT_3, DA830_MMCSD_DAT_4, DA830_MMCSD_DAT_5, | |
124 | DA830_MMCSD_DAT_6, DA830_MMCSD_DAT_7, DA830_MMCSD_CLK, | |
125 | DA830_MMCSD_CMD, DA830_GPIO2_1, DA830_GPIO2_2, | |
126 | -1 | |
127 | }; | |
128 | ||
129 | #define DA830_MMCSD_WP_PIN GPIO_TO_PIN(2, 1) | |
130 | ||
131 | static int da830_evm_mmc_get_ro(int index) | |
132 | { | |
133 | return gpio_get_value(DA830_MMCSD_WP_PIN); | |
134 | } | |
135 | ||
136 | static struct davinci_mmc_config da830_evm_mmc_config = { | |
137 | .get_ro = da830_evm_mmc_get_ro, | |
138 | .wires = 4, | |
139 | .version = MMC_CTLR_VERSION_2, | |
140 | }; | |
141 | ||
142 | static inline void da830_evm_init_mmc(void) | |
143 | { | |
144 | int ret; | |
145 | ||
146 | ret = da8xx_pinmux_setup(da830_evm_mmc_sd_pins); | |
147 | if (ret) { | |
148 | pr_warning("da830_evm_init: mmc/sd mux setup failed: %d\n", | |
149 | ret); | |
150 | return; | |
151 | } | |
152 | ||
153 | ret = gpio_request(DA830_MMCSD_WP_PIN, "MMC WP"); | |
154 | if (ret) { | |
155 | pr_warning("da830_evm_init: can not open GPIO %d\n", | |
156 | DA830_MMCSD_WP_PIN); | |
157 | return; | |
158 | } | |
159 | gpio_direction_input(DA830_MMCSD_WP_PIN); | |
160 | ||
161 | ret = da8xx_register_mmcsd0(&da830_evm_mmc_config); | |
162 | if (ret) { | |
163 | pr_warning("da830_evm_init: mmc/sd registration failed: %d\n", | |
164 | ret); | |
165 | gpio_free(DA830_MMCSD_WP_PIN); | |
166 | } | |
167 | } | |
168 | ||
8593790d MG |
169 | static __init void da830_evm_init(void) |
170 | { | |
171 | struct davinci_soc_info *soc_info = &davinci_soc_info; | |
172 | int ret; | |
173 | ||
174 | ret = da8xx_register_edma(); | |
175 | if (ret) | |
176 | pr_warning("da830_evm_init: edma registration failed: %d\n", | |
177 | ret); | |
178 | ||
c96b56c5 | 179 | ret = da8xx_pinmux_setup(da830_i2c0_pins); |
8593790d MG |
180 | if (ret) |
181 | pr_warning("da830_evm_init: i2c0 mux setup failed: %d\n", | |
182 | ret); | |
183 | ||
184 | ret = da8xx_register_i2c(0, &da830_evm_i2c_0_pdata); | |
185 | if (ret) | |
186 | pr_warning("da830_evm_init: i2c0 registration failed: %d\n", | |
187 | ret); | |
188 | ||
189 | soc_info->emac_pdata->phy_mask = DA830_EVM_PHY_MASK; | |
190 | soc_info->emac_pdata->mdio_max_freq = DA830_EVM_MDIO_FREQUENCY; | |
191 | soc_info->emac_pdata->rmii_en = 1; | |
192 | ||
c96b56c5 | 193 | ret = da8xx_pinmux_setup(da830_cpgmac_pins); |
8593790d MG |
194 | if (ret) |
195 | pr_warning("da830_evm_init: cpgmac mux setup failed: %d\n", | |
196 | ret); | |
197 | ||
198 | ret = da8xx_register_emac(); | |
199 | if (ret) | |
200 | pr_warning("da830_evm_init: emac registration failed: %d\n", | |
201 | ret); | |
202 | ||
203 | ret = da8xx_register_watchdog(); | |
204 | if (ret) | |
205 | pr_warning("da830_evm_init: watchdog registration failed: %d\n", | |
206 | ret); | |
207 | ||
208 | davinci_serial_init(&da830_evm_uart_config); | |
209 | i2c_register_board_info(1, da830_evm_i2c_devices, | |
210 | ARRAY_SIZE(da830_evm_i2c_devices)); | |
e33ef5e3 | 211 | |
32bf078c | 212 | ret = da8xx_pinmux_setup(da830_evm_mcasp1_pins); |
e33ef5e3 C |
213 | if (ret) |
214 | pr_warning("da830_evm_init: mcasp1 mux setup failed: %d\n", | |
215 | ret); | |
216 | ||
b8864aa4 | 217 | da8xx_register_mcasp(1, &da830_evm_snd_data); |
2eb30c81 DG |
218 | |
219 | da830_evm_init_mmc(); | |
13e1f044 SC |
220 | |
221 | #ifdef CONFIG_DA830_UI_LCD | |
222 | ret = da8xx_pinmux_setup(da830_lcdcntl_pins); | |
223 | if (ret) | |
224 | pr_warning("da830_evm_init: lcdcntl mux setup failed: %d\n", | |
225 | ret); | |
226 | ||
227 | ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata); | |
228 | if (ret) | |
229 | pr_warning("da830_evm_init: lcd setup failed: %d\n", ret); | |
230 | #endif | |
8593790d MG |
231 | } |
232 | ||
233 | #ifdef CONFIG_SERIAL_8250_CONSOLE | |
234 | static int __init da830_evm_console_init(void) | |
235 | { | |
236 | return add_preferred_console("ttyS", 2, "115200"); | |
237 | } | |
238 | console_initcall(da830_evm_console_init); | |
239 | #endif | |
240 | ||
241 | static __init void da830_evm_irq_init(void) | |
242 | { | |
243 | struct davinci_soc_info *soc_info = &davinci_soc_info; | |
244 | ||
245 | cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA830_N_CP_INTC_IRQ, | |
246 | soc_info->intc_irq_prios); | |
247 | } | |
248 | ||
249 | static void __init da830_evm_map_io(void) | |
250 | { | |
251 | da830_init(); | |
252 | } | |
253 | ||
baf09a4c | 254 | MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP L137 EVM") |
8593790d MG |
255 | .phys_io = IO_PHYS, |
256 | .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc, | |
257 | .boot_params = (DA8XX_DDR_BASE + 0x100), | |
258 | .map_io = da830_evm_map_io, | |
259 | .init_irq = da830_evm_irq_init, | |
260 | .timer = &davinci_timer, | |
261 | .init_machine = da830_evm_init, | |
262 | MACHINE_END |