]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-rx51-peripherals.c
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-rx51-peripherals.c
1 /*
2  * linux/arch/arm/mach-omap2/board-rx51-flash.c
3  *
4  * Copyright (C) 2008 Nokia
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/input.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/tsc2005.h>
17 #include <linux/i2c.h>
18 #include <linux/i2c/twl4030.h>
19 #include <linux/clk.h>
20 #include <linux/delay.h>
21
22 #include <mach/mcspi.h>
23 #include <mach/gpio.h>
24 #include <mach/mux.h>
25 #include <mach/board.h>
26 #include <mach/common.h>
27 #include <mach/keypad.h>
28 #include <mach/dma.h>
29 #include <mach/gpmc.h>
30
31 #define RX51_DEBUG_BASE                 0x08000000  /* debug board */
32 #define RX51_ETHR_START                 RX51_DEBUG_BASE
33 #define RX51_ETHR_GPIO_IRQ              54
34
35 #define RX51_TSC2005_RESET_GPIO         104
36 #define RX51_TSC2005_IRQ_GPIO           100
37
38 #define RX51_SMC91X_CS                  1
39
40 static struct resource rx51_smc91x_resources[] = {
41         [0] = {
42                 .start  = RX51_ETHR_START,
43                 .end    = RX51_ETHR_START + SZ_4K,
44                 .flags          = IORESOURCE_MEM,
45         },
46         [1] = {
47                 .start          = OMAP_GPIO_IRQ(RX51_ETHR_GPIO_IRQ),
48                 .end    = 0,
49                 .flags          = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
50         },
51 };
52
53 static struct platform_device rx51_smc91x_device = {
54         .name           = "smc91x",
55         .id             = -1,
56         .num_resources  = ARRAY_SIZE(rx51_smc91x_resources),
57         .resource       = rx51_smc91x_resources,
58 };
59
60 static struct tsc2005_platform_data tsc2005_config = {
61         .reset_gpio             = RX51_TSC2005_RESET_GPIO, /* not used */
62
63         .ts_x_plate_ohm         = 280,
64         .ts_hw_avg              = 0,
65         .ts_touch_pressure      = 1500,
66         .ts_stab_time           = 1000,
67         .ts_pressure_max        = 2048,
68         .ts_pressure_fudge      = 2,
69         .ts_x_max               = 4096,
70         .ts_x_fudge             = 4,
71         .ts_y_max               = 4096,
72         .ts_y_fudge             = 7,
73 };
74
75 static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
76         .turbo_mode     = 0,
77         .single_channel = 1,
78 };
79
80
81 static struct spi_board_info rx51_peripherals_spi_board_info[] = {
82         [0] = {
83                 .modalias               = "tsc2005",
84                 .bus_num                = 1,
85                 .chip_select            = 0,
86                 .irq                    = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),
87                 .max_speed_hz           = 6000000,
88                 .controller_data        = &tsc2005_mcspi_config,
89                 .platform_data          = &tsc2005_config,
90         },
91 };
92
93 static int rx51_keymap[] = {
94         KEY(0, 0, KEY_Q),
95         KEY(0, 1, KEY_W),
96         KEY(0, 2, KEY_E),
97         KEY(0, 3, KEY_R),
98         KEY(0, 4, KEY_T),
99         KEY(0, 5, KEY_Y),
100         KEY(0, 6, KEY_U),
101         KEY(0, 7, KEY_I),
102         KEY(1, 0, KEY_O),
103         KEY(1, 1, KEY_D),
104         KEY(1, 2, KEY_DOT ),
105         KEY(1, 3, KEY_V),
106         KEY(1, 4, KEY_DOWN ),
107         KEY(2, 0, KEY_P),
108         KEY(2, 1, KEY_F),
109         KEY(2, 2, KEY_UP ),
110         KEY(2, 3, KEY_B),
111         KEY(2, 4, KEY_RIGHT ),
112         KEY(3, 0, KEY_COMMA ),
113         KEY(3, 1, KEY_G),
114         KEY(3, 2, KEY_ENTER ),
115         KEY(3, 3, KEY_N),
116         KEY(4, 0, KEY_BACKSPACE ),
117         KEY(4, 1, KEY_H),
118         KEY(4, 3, KEY_M),
119         KEY(4, 4, KEY_LEFTCTRL),
120         KEY(5, 1, KEY_J),
121         KEY(5, 2, KEY_Z),
122         KEY(5, 3, KEY_SPACE),
123         KEY(5, 4, KEY_LEFTSHIFT),
124         KEY(6, 0, KEY_A),
125         KEY(6, 1, KEY_K),
126         KEY(6, 2, KEY_X),
127         KEY(6, 3, KEY_SPACE),
128         KEY(6, 4, KEY_FN ),
129         KEY(7, 0, KEY_S),
130         KEY(7, 1, KEY_L),
131         KEY(7, 2, KEY_C),
132         KEY(7, 3, KEY_LEFT),
133         KEY(0xff, 0, KEY_F6),
134         KEY(0xff, 1, KEY_F7),
135         KEY(0xff, 2, KEY_F8),
136         KEY(0xff, 4, KEY_F9),
137         KEY(0xff, 5, KEY_F10),
138 };
139
140 static struct twl4030_keypad_data rx51_kp_data = {
141         .rows           = 8,
142         .cols           = 8,
143         .keymap         = rx51_keymap,
144         .keymapsize     = ARRAY_SIZE(rx51_keymap),
145         .rep            = 1,
146 };
147
148 static struct platform_device *rx51_peripherals_devices[] = {
149         &rx51_smc91x_device,
150 };
151
152 static void __init rx51_init_smc91x(void)
153 {
154         int eth_cs;
155         unsigned long cs_mem_base;
156         unsigned int rate;
157         struct clk *l3ck;
158
159         eth_cs  = RX51_SMC91X_CS;
160
161         l3ck = clk_get(NULL, "core_l3_ck");
162         if (IS_ERR(l3ck))
163                 rate = 100000000;
164         else
165                 rate = clk_get_rate(l3ck);
166
167         if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
168                 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
169                 return;
170         }
171
172         rx51_smc91x_resources[0].start = cs_mem_base + 0x0;
173         rx51_smc91x_resources[0].end   = cs_mem_base + 0xf;
174         udelay(100);
175
176         if (gpio_request(RX51_ETHR_GPIO_IRQ, "SMC91X irq") < 0) {
177                 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
178                         RX51_ETHR_GPIO_IRQ);
179                 return;
180         }
181         gpio_direction_input(RX51_ETHR_GPIO_IRQ);
182 }
183
184 static void __init rx51_init_tsc2005(void)
185 {
186         int r;
187
188         r = gpio_request(RX51_TSC2005_IRQ_GPIO, "tsc2005 DAV IRQ");
189         if (r >= 0) {
190                 gpio_direction_input(RX51_TSC2005_IRQ_GPIO);
191         } else {
192                 printk(KERN_ERR "unable to get DAV GPIO");
193         }
194 }
195
196 static struct twl4030_usb_data rx51_usb_data = {
197         .usb_mode               = T2_USB_MODE_ULPI,
198 };
199
200 static struct twl4030_madc_platform_data rx51_madc_data = {
201         .irq_line               = 1,
202 };
203
204 static struct twl4030_gpio_platform_data rx51_gpio_data = {
205         .gpio_base              = OMAP_MAX_GPIO_LINES,
206         .irq_base               = TWL4030_GPIO_IRQ_BASE,
207         .irq_end                = TWL4030_GPIO_IRQ_END,
208 };
209
210 static struct twl4030_platform_data rx51_twldata = {
211         .irq_base               = TWL4030_IRQ_BASE,
212         .irq_end                = TWL4030_IRQ_END,
213
214         /* platform_data for children goes here */
215         .gpio                   = &rx51_gpio_data,
216         .keypad                 = &rx51_kp_data,
217         .madc                   = &rx51_madc_data,
218         .usb                    = &rx51_usb_data,
219 };
220
221 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
222         {
223                 I2C_BOARD_INFO("twl4030", 0x48),
224                 .flags = I2C_CLIENT_WAKE,
225                 .irq = INT_34XX_SYS_NIRQ,
226                 .platform_data = &rx51_twldata,
227         },
228 };
229
230 static int __init rx51_i2c_init(void)
231 {
232         omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1,
233                         ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
234         omap_register_i2c_bus(2, 100, NULL, 0);
235         omap_register_i2c_bus(3, 400, NULL, 0);
236         return 0;
237 }
238
239
240 void __init rx51_peripherals_init(void)
241 {
242         platform_add_devices(rx51_peripherals_devices,
243                                 ARRAY_SIZE(rx51_peripherals_devices));
244         spi_register_board_info(rx51_peripherals_spi_board_info,
245                                 ARRAY_SIZE(rx51_peripherals_spi_board_info));
246         rx51_i2c_init();
247         rx51_init_smc91x();
248         rx51_init_tsc2005();
249 }
250