Merge tag 'sound-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
[pandora-kernel.git] / arch / arm / mach-omap2 / board-zoom-debugboard.c
1 /*
2  * Copyright (C) 2009 Texas Instruments Inc.
3  * Mikkel Christensen <mlc@ti.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  */
9
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/gpio.h>
13 #include <linux/serial_8250.h>
14 #include <linux/smsc911x.h>
15 #include <linux/interrupt.h>
16
17 #include <plat/gpmc.h>
18 #include <plat/gpmc-smsc911x.h>
19
20 #include <mach/board-zoom.h>
21
22 #define ZOOM_SMSC911X_CS        7
23 #define ZOOM_SMSC911X_GPIO      158
24 #define ZOOM_QUADUART_CS        3
25 #define ZOOM_QUADUART_GPIO      102
26 #define ZOOM_QUADUART_RST_GPIO  152
27 #define QUART_CLK               1843200
28 #define DEBUG_BASE              0x08000000
29 #define ZOOM_ETHR_START DEBUG_BASE
30
31 static struct omap_smsc911x_platform_data zoom_smsc911x_cfg = {
32         .cs             = ZOOM_SMSC911X_CS,
33         .gpio_irq       = ZOOM_SMSC911X_GPIO,
34         .gpio_reset     = -EINVAL,
35         .flags          = SMSC911X_USE_32BIT,
36 };
37
38 static inline void __init zoom_init_smsc911x(void)
39 {
40         gpmc_smsc911x_init(&zoom_smsc911x_cfg);
41 }
42
43 static struct plat_serial8250_port serial_platform_data[] = {
44         {
45                 .mapbase        = ZOOM_UART_BASE,
46                 .flags          = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ,
47                 .irqflags       = IRQF_SHARED | IRQF_TRIGGER_RISING,
48                 .iotype         = UPIO_MEM,
49                 .regshift       = 1,
50                 .uartclk        = QUART_CLK,
51         }, {
52                 .flags          = 0
53         }
54 };
55
56 static struct platform_device zoom_debugboard_serial_device = {
57         .name                   = "serial8250",
58         .id                     = PLAT8250_DEV_PLATFORM,
59         .dev                    = {
60                 .platform_data  = serial_platform_data,
61         },
62 };
63
64 static inline void __init zoom_init_quaduart(void)
65 {
66         int quart_cs;
67         unsigned long cs_mem_base;
68         int quart_gpio = 0;
69
70         if (gpio_request_one(ZOOM_QUADUART_RST_GPIO,
71                                 GPIOF_OUT_INIT_LOW,
72                                 "TL16CP754C GPIO") < 0) {
73                 pr_err("Failed to request GPIO%d for TL16CP754C\n",
74                         ZOOM_QUADUART_RST_GPIO);
75                 return;
76         }
77
78         quart_cs = ZOOM_QUADUART_CS;
79
80         if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) {
81                 printk(KERN_ERR "Failed to request GPMC mem"
82                                 "for Quad UART(TL16CP754C)\n");
83                 return;
84         }
85
86         quart_gpio = ZOOM_QUADUART_GPIO;
87
88         if (gpio_request_one(quart_gpio, GPIOF_IN, "TL16CP754C GPIO") < 0)
89                 printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
90                                                                 quart_gpio);
91
92         serial_platform_data[0].irq = gpio_to_irq(102);
93 }
94
95 static inline int omap_zoom_debugboard_detect(void)
96 {
97         int debug_board_detect = 0;
98         int ret = 1;
99
100         debug_board_detect = ZOOM_SMSC911X_GPIO;
101
102         if (gpio_request_one(debug_board_detect, GPIOF_IN,
103                              "Zoom debug board detect") < 0) {
104                 printk(KERN_ERR "Failed to request GPIO%d for Zoom debug"
105                 "board detect\n", debug_board_detect);
106                 return 0;
107         }
108
109         if (!gpio_get_value(debug_board_detect)) {
110                 ret = 0;
111         }
112         gpio_free(debug_board_detect);
113         return ret;
114 }
115
116 static struct platform_device *zoom_devices[] __initdata = {
117         &zoom_debugboard_serial_device,
118 };
119
120 int __init zoom_debugboard_init(void)
121 {
122         if (!omap_zoom_debugboard_detect())
123                 return 0;
124
125         zoom_init_smsc911x();
126         zoom_init_quaduart();
127         return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
128 }