DA8xx: MUSB platform device registration
[deliverable/linux.git] / arch / arm / mach-davinci / board-da830-evm.c
CommitLineData
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>
8593790d
MG
13#include <linux/init.h>
14#include <linux/console.h>
0e9a3ddc 15#include <linux/interrupt.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
8593790d 24#include <mach/cp_intc.h>
32bf078c 25#include <mach/mux.h>
8593790d 26#include <mach/da8xx.h>
0e9a3ddc 27#include <mach/usb.h>
8593790d
MG
28
29#define DA830_EVM_PHY_MASK 0x0
30#define DA830_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
31
32static struct at24_platform_data da830_evm_i2c_eeprom_info = {
33 .byte_len = SZ_256K / 8,
34 .page_size = 64,
35 .flags = AT24_FLAG_ADDR16,
36 .setup = davinci_get_mac_addr,
37 .context = (void *)0x7f00,
38};
39
13e1f044
SC
40static int da830_evm_ui_expander_setup(struct i2c_client *client, int gpio,
41 unsigned ngpio, void *context)
42{
43 gpio_request(gpio + 6, "MUX_MODE");
44#ifdef CONFIG_DA830_UI_LCD
45 gpio_direction_output(gpio + 6, 0);
46#else /* Must be NAND or NOR */
47 gpio_direction_output(gpio + 6, 1);
48#endif
49 return 0;
50}
51
52static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio,
53 unsigned ngpio, void *context)
54{
55 gpio_free(gpio + 6);
56 return 0;
57}
58
59static struct pcf857x_platform_data da830_evm_ui_expander_info = {
60 .gpio_base = DAVINCI_N_GPIO,
61 .setup = da830_evm_ui_expander_setup,
62 .teardown = da830_evm_ui_expander_teardown,
63};
64
8593790d
MG
65static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
66 {
67 I2C_BOARD_INFO("24c256", 0x50),
68 .platform_data = &da830_evm_i2c_eeprom_info,
69 },
1a7ff8ff
C
70 {
71 I2C_BOARD_INFO("tlv320aic3x", 0x18),
13e1f044
SC
72 },
73 {
74 I2C_BOARD_INFO("pcf8574", 0x3f),
75 .platform_data = &da830_evm_ui_expander_info,
76 },
8593790d
MG
77};
78
79static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = {
80 .bus_freq = 100, /* kHz */
81 .bus_delay = 0, /* usec */
82};
83
0e9a3ddc
SS
84/*
85 * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4].
86 */
87#define ON_BD_USB_DRV GPIO_TO_PIN(1, 15)
88#define ON_BD_USB_OVC GPIO_TO_PIN(2, 4)
89
90static const short da830_evm_usb11_pins[] = {
91 DA830_GPIO1_15, DA830_GPIO2_4,
92 -1
93};
94
95static da8xx_ocic_handler_t da830_evm_usb_ocic_handler;
96
97static int da830_evm_usb_set_power(unsigned port, int on)
98{
99 gpio_set_value(ON_BD_USB_DRV, on);
100 return 0;
101}
102
103static int da830_evm_usb_get_power(unsigned port)
104{
105 return gpio_get_value(ON_BD_USB_DRV);
106}
107
108static int da830_evm_usb_get_oci(unsigned port)
109{
110 return !gpio_get_value(ON_BD_USB_OVC);
111}
112
113static irqreturn_t da830_evm_usb_ocic_irq(int, void *);
114
115static int da830_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
116{
117 int irq = gpio_to_irq(ON_BD_USB_OVC);
118 int error = 0;
119
120 if (handler != NULL) {
121 da830_evm_usb_ocic_handler = handler;
122
123 error = request_irq(irq, da830_evm_usb_ocic_irq, IRQF_DISABLED |
124 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
125 "OHCI over-current indicator", NULL);
126 if (error)
127 printk(KERN_ERR "%s: could not request IRQ to watch "
128 "over-current indicator changes\n", __func__);
129 } else
130 free_irq(irq, NULL);
131
132 return error;
133}
134
135static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = {
136 .set_power = da830_evm_usb_set_power,
137 .get_power = da830_evm_usb_get_power,
138 .get_oci = da830_evm_usb_get_oci,
139 .ocic_notify = da830_evm_usb_ocic_notify,
140
141 /* TPS2065 switch @ 5V */
142 .potpgt = (3 + 1) / 2, /* 3 ms max */
143};
144
145static irqreturn_t da830_evm_usb_ocic_irq(int irq, void *dev_id)
146{
147 da830_evm_usb_ocic_handler(&da830_evm_usb11_pdata, 1);
148 return IRQ_HANDLED;
149}
150
151static __init void da830_evm_usb_init(void)
152{
153 u32 cfgchip2;
154 int ret;
155
156 /*
157 * Set up USB clock/mode in the CFGCHIP2 register.
158 * FYI: CFGCHIP2 is 0x0000ef00 initially.
159 */
160 cfgchip2 = __raw_readl(DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP2_REG));
161
162 /* USB2.0 PHY reference clock is 24 MHz */
163 cfgchip2 &= ~CFGCHIP2_REFFREQ;
164 cfgchip2 |= CFGCHIP2_REFFREQ_24MHZ;
165
166 /*
167 * Select internal reference clock for USB 2.0 PHY
168 * and use it as a clock source for USB 1.1 PHY
169 * (this is the default setting anyway).
170 */
171 cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
172 cfgchip2 |= CFGCHIP2_USB2PHYCLKMUX;
173
174 __raw_writel(cfgchip2, DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP2_REG));
175
176 ret = da8xx_pinmux_setup(da830_evm_usb11_pins);
177 if (ret) {
178 pr_warning("%s: USB 1.1 PinMux setup failed: %d\n",
179 __func__, ret);
180 return;
181 }
182
183 ret = gpio_request(ON_BD_USB_DRV, "ON_BD_USB_DRV");
184 if (ret) {
185 printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
186 "power control: %d\n", __func__, ret);
187 return;
188 }
189 gpio_direction_output(ON_BD_USB_DRV, 0);
190
191 ret = gpio_request(ON_BD_USB_OVC, "ON_BD_USB_OVC");
192 if (ret) {
193 printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
194 "over-current indicator: %d\n", __func__, ret);
195 return;
196 }
197 gpio_direction_input(ON_BD_USB_OVC);
198
199 ret = da8xx_register_usb11(&da830_evm_usb11_pdata);
200 if (ret)
201 pr_warning("%s: USB 1.1 registration failed: %d\n",
202 __func__, ret);
203}
204
8593790d
MG
205static struct davinci_uart_config da830_evm_uart_config __initdata = {
206 .enabled_uarts = 0x7,
207};
208
32bf078c
MG
209static const short da830_evm_mcasp1_pins[] = {
210 DA830_AHCLKX1, DA830_ACLKX1, DA830_AFSX1, DA830_AHCLKR1, DA830_AFSR1,
211 DA830_AMUTE1, DA830_AXR1_0, DA830_AXR1_1, DA830_AXR1_2, DA830_AXR1_5,
212 DA830_ACLKR1, DA830_AXR1_6, DA830_AXR1_7, DA830_AXR1_8, DA830_AXR1_10,
213 DA830_AXR1_11,
214 -1
215};
216
e33ef5e3
C
217static u8 da830_iis_serializer_direction[] = {
218 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
219 INACTIVE_MODE, TX_MODE, INACTIVE_MODE, INACTIVE_MODE,
220 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
221};
222
223static struct snd_platform_data da830_evm_snd_data = {
224 .tx_dma_offset = 0x2000,
225 .rx_dma_offset = 0x2000,
226 .op_mode = DAVINCI_MCASP_IIS_MODE,
227 .num_serializer = ARRAY_SIZE(da830_iis_serializer_direction),
228 .tdm_slots = 2,
229 .serial_dir = da830_iis_serializer_direction,
230 .eventq_no = EVENTQ_0,
231 .version = MCASP_VERSION_2,
232 .txnumevt = 1,
233 .rxnumevt = 1,
234};
235
2eb30c81
DG
236/*
237 * GPIO2[1] is used as MMC_SD_WP and GPIO2[2] as MMC_SD_INS.
238 */
239static const short da830_evm_mmc_sd_pins[] = {
240 DA830_MMCSD_DAT_0, DA830_MMCSD_DAT_1, DA830_MMCSD_DAT_2,
241 DA830_MMCSD_DAT_3, DA830_MMCSD_DAT_4, DA830_MMCSD_DAT_5,
242 DA830_MMCSD_DAT_6, DA830_MMCSD_DAT_7, DA830_MMCSD_CLK,
243 DA830_MMCSD_CMD, DA830_GPIO2_1, DA830_GPIO2_2,
244 -1
245};
246
247#define DA830_MMCSD_WP_PIN GPIO_TO_PIN(2, 1)
248
249static int da830_evm_mmc_get_ro(int index)
250{
251 return gpio_get_value(DA830_MMCSD_WP_PIN);
252}
253
254static struct davinci_mmc_config da830_evm_mmc_config = {
255 .get_ro = da830_evm_mmc_get_ro,
256 .wires = 4,
257 .version = MMC_CTLR_VERSION_2,
258};
259
260static inline void da830_evm_init_mmc(void)
261{
262 int ret;
263
264 ret = da8xx_pinmux_setup(da830_evm_mmc_sd_pins);
265 if (ret) {
266 pr_warning("da830_evm_init: mmc/sd mux setup failed: %d\n",
267 ret);
268 return;
269 }
270
271 ret = gpio_request(DA830_MMCSD_WP_PIN, "MMC WP");
272 if (ret) {
273 pr_warning("da830_evm_init: can not open GPIO %d\n",
274 DA830_MMCSD_WP_PIN);
275 return;
276 }
277 gpio_direction_input(DA830_MMCSD_WP_PIN);
278
279 ret = da8xx_register_mmcsd0(&da830_evm_mmc_config);
280 if (ret) {
281 pr_warning("da830_evm_init: mmc/sd registration failed: %d\n",
282 ret);
283 gpio_free(DA830_MMCSD_WP_PIN);
284 }
285}
286
8593790d
MG
287static __init void da830_evm_init(void)
288{
289 struct davinci_soc_info *soc_info = &davinci_soc_info;
290 int ret;
291
292 ret = da8xx_register_edma();
293 if (ret)
294 pr_warning("da830_evm_init: edma registration failed: %d\n",
295 ret);
296
c96b56c5 297 ret = da8xx_pinmux_setup(da830_i2c0_pins);
8593790d
MG
298 if (ret)
299 pr_warning("da830_evm_init: i2c0 mux setup failed: %d\n",
300 ret);
301
302 ret = da8xx_register_i2c(0, &da830_evm_i2c_0_pdata);
303 if (ret)
304 pr_warning("da830_evm_init: i2c0 registration failed: %d\n",
305 ret);
306
0e9a3ddc
SS
307 da830_evm_usb_init();
308
8593790d
MG
309 soc_info->emac_pdata->phy_mask = DA830_EVM_PHY_MASK;
310 soc_info->emac_pdata->mdio_max_freq = DA830_EVM_MDIO_FREQUENCY;
311 soc_info->emac_pdata->rmii_en = 1;
312
c96b56c5 313 ret = da8xx_pinmux_setup(da830_cpgmac_pins);
8593790d
MG
314 if (ret)
315 pr_warning("da830_evm_init: cpgmac mux setup failed: %d\n",
316 ret);
317
318 ret = da8xx_register_emac();
319 if (ret)
320 pr_warning("da830_evm_init: emac registration failed: %d\n",
321 ret);
322
323 ret = da8xx_register_watchdog();
324 if (ret)
325 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
326 ret);
327
328 davinci_serial_init(&da830_evm_uart_config);
329 i2c_register_board_info(1, da830_evm_i2c_devices,
330 ARRAY_SIZE(da830_evm_i2c_devices));
e33ef5e3 331
32bf078c 332 ret = da8xx_pinmux_setup(da830_evm_mcasp1_pins);
e33ef5e3
C
333 if (ret)
334 pr_warning("da830_evm_init: mcasp1 mux setup failed: %d\n",
335 ret);
336
b8864aa4 337 da8xx_register_mcasp(1, &da830_evm_snd_data);
2eb30c81
DG
338
339 da830_evm_init_mmc();
13e1f044
SC
340
341#ifdef CONFIG_DA830_UI_LCD
342 ret = da8xx_pinmux_setup(da830_lcdcntl_pins);
343 if (ret)
344 pr_warning("da830_evm_init: lcdcntl mux setup failed: %d\n",
345 ret);
346
347 ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata);
348 if (ret)
349 pr_warning("da830_evm_init: lcd setup failed: %d\n", ret);
350#endif
c51df70b
MG
351
352 ret = da8xx_register_rtc();
353 if (ret)
354 pr_warning("da830_evm_init: rtc setup failed: %d\n", ret);
8593790d
MG
355}
356
357#ifdef CONFIG_SERIAL_8250_CONSOLE
358static int __init da830_evm_console_init(void)
359{
360 return add_preferred_console("ttyS", 2, "115200");
361}
362console_initcall(da830_evm_console_init);
363#endif
364
365static __init void da830_evm_irq_init(void)
366{
367 struct davinci_soc_info *soc_info = &davinci_soc_info;
368
369 cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA830_N_CP_INTC_IRQ,
370 soc_info->intc_irq_prios);
371}
372
373static void __init da830_evm_map_io(void)
374{
375 da830_init();
376}
377
6af6564d 378MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137 EVM")
8593790d
MG
379 .phys_io = IO_PHYS,
380 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
381 .boot_params = (DA8XX_DDR_BASE + 0x100),
382 .map_io = da830_evm_map_io,
383 .init_irq = da830_evm_irq_init,
384 .timer = &davinci_timer,
385 .init_machine = da830_evm_init,
386MACHINE_END
This page took 0.061122 seconds and 5 git commands to generate.