]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-rx51-peripherals.c
49c3d80eff58237155dca31d8862b895807a2ccd
[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-2009 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 #include <linux/regulator/machine.h>
22
23 #include <mach/mcspi.h>
24 #include <mach/gpio.h>
25 #include <mach/mux.h>
26 #include <mach/board.h>
27 #include <mach/common.h>
28 #include <mach/dma.h>
29 #include <mach/gpmc.h>
30
31 #define RX51_ETHR_GPIO_IRQ              54
32
33 #define RX51_TSC2005_RESET_GPIO         104
34 #define RX51_TSC2005_IRQ_GPIO           100
35
36 #define RX51_SMC91X_CS                  1
37
38 static struct resource rx51_smc91x_resources[] = {
39         [0] = {
40                 .flags          = IORESOURCE_MEM,
41         },
42         [1] = {
43                 .flags          = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
44         },
45 };
46
47 static struct platform_device rx51_smc91x_device = {
48         .name           = "smc91x",
49         .id             = -1,
50         .num_resources  = ARRAY_SIZE(rx51_smc91x_resources),
51         .resource       = rx51_smc91x_resources,
52 };
53
54 static struct tsc2005_platform_data tsc2005_config = {
55         .reset_gpio             = RX51_TSC2005_RESET_GPIO, /* not used */
56
57         .ts_x_plate_ohm         = 280,
58         .ts_hw_avg              = 0,
59         .ts_touch_pressure      = 1500,
60         .ts_stab_time           = 1000,
61         .ts_pressure_max        = 2048,
62         .ts_pressure_fudge      = 2,
63         .ts_x_max               = 4096,
64         .ts_x_fudge             = 4,
65         .ts_y_max               = 4096,
66         .ts_y_fudge             = 7,
67 };
68
69 static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
70         .turbo_mode     = 0,
71         .single_channel = 1,
72 };
73
74
75 static struct spi_board_info rx51_peripherals_spi_board_info[] = {
76         [0] = {
77                 .modalias               = "tsc2005",
78                 .bus_num                = 1,
79                 .chip_select            = 0,
80                 .irq                    = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),
81                 .max_speed_hz           = 6000000,
82                 .controller_data        = &tsc2005_mcspi_config,
83                 .platform_data          = &tsc2005_config,
84         },
85 };
86
87 static int rx51_keymap[] = {
88         KEY(0, 0, KEY_Q),
89         KEY(0, 1, KEY_W),
90         KEY(0, 2, KEY_E),
91         KEY(0, 3, KEY_R),
92         KEY(0, 4, KEY_T),
93         KEY(0, 5, KEY_Y),
94         KEY(0, 6, KEY_U),
95         KEY(0, 7, KEY_I),
96         KEY(1, 0, KEY_O),
97         KEY(1, 1, KEY_D),
98         KEY(1, 2, KEY_DOT ),
99         KEY(1, 3, KEY_V),
100         KEY(1, 4, KEY_DOWN ),
101         KEY(2, 0, KEY_P),
102         KEY(2, 1, KEY_F),
103         KEY(2, 2, KEY_UP ),
104         KEY(2, 3, KEY_B),
105         KEY(2, 4, KEY_RIGHT ),
106         KEY(3, 0, KEY_COMMA ),
107         KEY(3, 1, KEY_G),
108         KEY(3, 2, KEY_ENTER ),
109         KEY(3, 3, KEY_N),
110         KEY(4, 0, KEY_BACKSPACE ),
111         KEY(4, 1, KEY_H),
112         KEY(4, 3, KEY_M),
113         KEY(4, 4, KEY_LEFTCTRL),
114         KEY(5, 1, KEY_J),
115         KEY(5, 2, KEY_Z),
116         KEY(5, 3, KEY_SPACE),
117         KEY(5, 4, KEY_LEFTSHIFT),
118         KEY(6, 0, KEY_A),
119         KEY(6, 1, KEY_K),
120         KEY(6, 2, KEY_X),
121         KEY(6, 3, KEY_SPACE),
122         KEY(6, 4, KEY_FN ),
123         KEY(7, 0, KEY_S),
124         KEY(7, 1, KEY_L),
125         KEY(7, 2, KEY_C),
126         KEY(7, 3, KEY_LEFT),
127         KEY(0xff, 0, KEY_F6),
128         KEY(0xff, 1, KEY_F7),
129         KEY(0xff, 2, KEY_F8),
130         KEY(0xff, 4, KEY_F9),
131         KEY(0xff, 5, KEY_F10),
132 };
133
134 static struct twl4030_keypad_data rx51_kp_data = {
135         .rows           = 8,
136         .cols           = 8,
137         .keymap         = rx51_keymap,
138         .keymapsize     = ARRAY_SIZE(rx51_keymap),
139         .rep            = 1,
140 };
141
142 static struct platform_device *rx51_peripherals_devices[] = {
143         &rx51_smc91x_device,
144 };
145
146 static void __init rx51_init_smc91x(void)
147 {
148         int eth_cs;
149         unsigned long cs_mem_base;
150         unsigned int rate;
151         struct clk *l3ck;
152
153         eth_cs  = RX51_SMC91X_CS;
154
155         l3ck = clk_get(NULL, "core_l3_ck");
156         if (IS_ERR(l3ck))
157                 rate = 100000000;
158         else
159                 rate = clk_get_rate(l3ck);
160
161         if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
162                 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
163                 return;
164         }
165
166         rx51_smc91x_resources[0].start = cs_mem_base + 0x0;
167         rx51_smc91x_resources[0].end   = cs_mem_base + 0xf;
168         udelay(100);
169
170         if (gpio_request(RX51_ETHR_GPIO_IRQ, "SMC91X irq") < 0) {
171                 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
172                         RX51_ETHR_GPIO_IRQ);
173                 return;
174         }
175         gpio_direction_input(RX51_ETHR_GPIO_IRQ);
176         rx51_smc91x_resources[1].start = gpio_to_irq(RX51_ETHR_GPIO_IRQ);
177 }
178
179 static void __init rx51_init_tsc2005(void)
180 {
181         int r;
182
183         r = gpio_request(RX51_TSC2005_IRQ_GPIO, "tsc2005 DAV IRQ");
184         if (r >= 0) {
185                 gpio_direction_input(RX51_TSC2005_IRQ_GPIO);
186         } else {
187                 printk(KERN_ERR "unable to get DAV GPIO");
188         }
189 }
190
191 static struct twl4030_madc_platform_data rx51_madc_data = {
192         .irq_line               = 1,
193 };
194
195 static struct regulator_init_data rx51_vaux1 = {
196         .constraints = {
197                 .name                   = "V28",
198                 .min_uV                 = 2800000,
199                 .max_uV                 = 2800000,
200                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
201                                         | REGULATOR_MODE_STANDBY,
202                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
203                                         | REGULATOR_CHANGE_STATUS,
204         },
205 };
206
207 static struct regulator_init_data rx51_vaux2 = {
208         .constraints = {
209                 .name                   = "VCSI",
210                 .min_uV                 = 1800000,
211                 .max_uV                 = 1800000,
212                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
213                                         | REGULATOR_MODE_STANDBY,
214                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
215                                         | REGULATOR_CHANGE_STATUS,
216         },
217 };
218
219 /* VAUX3 - adds more power to VIO_18 rail */
220 static struct regulator_init_data rx51_vaux3 = {
221         .constraints = {
222                 .name                   = "VCAM_DIG_18",
223                 .min_uV                 = 1800000,
224                 .max_uV                 = 1800000,
225                 .apply_uV               = true,
226                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
227                                         | REGULATOR_MODE_STANDBY,
228                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
229                                         | REGULATOR_CHANGE_STATUS,
230         },
231 };
232
233 static struct regulator_init_data rx51_vaux4 = {
234         .constraints = {
235                 .name                   = "VCAM_ANA_28",
236                 .min_uV                 = 2800000,
237                 .max_uV                 = 2800000,
238                 .apply_uV               = true,
239                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
240                                         | REGULATOR_MODE_STANDBY,
241                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
242                                         | REGULATOR_CHANGE_STATUS,
243         },
244 };
245
246 static struct regulator_init_data rx51_vmmc1 = {
247         .constraints = {
248                 .min_uV                 = 1850000,
249                 .max_uV                 = 3150000,
250                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
251                                         | REGULATOR_MODE_STANDBY,
252                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
253                                         | REGULATOR_CHANGE_MODE
254                                         | REGULATOR_CHANGE_STATUS,
255         },
256 };
257
258 static struct regulator_init_data rx51_vmmc2 = {
259         .constraints = {
260                 .name                   = "VMMC2_30",
261                 .min_uV                 = 1850000,
262                 .max_uV                 = 3150000,
263                 .apply_uV               = true,
264                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
265                                         | REGULATOR_MODE_STANDBY,
266                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
267                                         | REGULATOR_CHANGE_MODE
268                                         | REGULATOR_CHANGE_STATUS,
269         },
270 };
271
272 static struct regulator_init_data rx51_vsim = {
273         .constraints = {
274                 .name                   = "VMMC2_IO_18",
275                 .min_uV                 = 1800000,
276                 .max_uV                 = 1800000,
277                 .apply_uV               = true,
278                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
279                                         | REGULATOR_MODE_STANDBY,
280                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
281                                         | REGULATOR_CHANGE_STATUS,
282         },
283 };
284
285 static struct regulator_init_data rx51_vdac = {
286         .constraints = {
287                 .min_uV                 = 1800000,
288                 .max_uV                 = 1800000,
289                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
290                                         | REGULATOR_MODE_STANDBY,
291                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
292                                         | REGULATOR_CHANGE_MODE
293                                         | REGULATOR_CHANGE_STATUS,
294         },
295 };
296
297 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
298 {
299         /* FIXME this gpio setup is just a placeholder for now */
300         gpio_request(gpio + 6, "backlight_pwm");
301         gpio_direction_output(gpio + 6, 0);
302         gpio_request(gpio + 7, "speaker_en");
303         gpio_direction_output(gpio + 7, 1);
304
305         /* FIXME connect power supplies to devices; register MMC */
306
307         return 0;
308 }
309
310 static struct twl4030_gpio_platform_data rx51_gpio_data = {
311         .gpio_base              = OMAP_MAX_GPIO_LINES,
312         .irq_base               = TWL4030_GPIO_IRQ_BASE,
313         .irq_end                = TWL4030_GPIO_IRQ_END,
314         .pulldowns              = BIT(0) | BIT(1) | BIT(2) | BIT(3)
315                                 | BIT(4) | BIT(5)
316                                 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
317                                 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
318                                 | BIT(16) | BIT(17) ,
319         .setup                  = rx51_twlgpio_setup,
320 };
321
322 static struct twl4030_platform_data rx51_twldata = {
323         .irq_base               = TWL4030_IRQ_BASE,
324         .irq_end                = TWL4030_IRQ_END,
325
326         /* platform_data for children goes here */
327         .gpio                   = &rx51_gpio_data,
328         .keypad                 = &rx51_kp_data,
329         .madc                   = &rx51_madc_data,
330
331         .vaux1                  = &rx51_vaux1,
332         .vaux2                  = &rx51_vaux2,
333         .vaux3                  = &rx51_vaux3,
334         .vaux4                  = &rx51_vaux4,
335         .vmmc1                  = &rx51_vmmc1,
336         .vmmc2                  = &rx51_vmmc2,
337         .vsim                   = &rx51_vsim,
338         .vdac                   = &rx51_vdac,
339 };
340
341 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
342         {
343                 I2C_BOARD_INFO("twl5030", 0x48),
344                 .flags = I2C_CLIENT_WAKE,
345                 .irq = INT_34XX_SYS_NIRQ,
346                 .platform_data = &rx51_twldata,
347         },
348 };
349
350 static int __init rx51_i2c_init(void)
351 {
352         omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1,
353                         ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
354         omap_register_i2c_bus(2, 100, NULL, 0);
355         omap_register_i2c_bus(3, 400, NULL, 0);
356         return 0;
357 }
358
359
360 void __init rx51_peripherals_init(void)
361 {
362         platform_add_devices(rx51_peripherals_devices,
363                                 ARRAY_SIZE(rx51_peripherals_devices));
364         spi_register_board_info(rx51_peripherals_spi_board_info,
365                                 ARRAY_SIZE(rx51_peripherals_spi_board_info));
366         rx51_i2c_init();
367         rx51_init_smc91x();
368         rx51_init_tsc2005();
369 }
370