]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-rx51-peripherals.c
rx51: Clean-up for checkpatch.pl
[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 #include "mmc-twl4030.h"
32
33
34 #define SMC91X_CS                       1
35 #define SMC91X_GPIO_IRQ                 54
36 #define SMC91X_GPIO_RESET               164
37 #define SMC91X_GPIO_PWRDWN              86
38
39 #define RX51_TSC2005_RESET_GPIO         104
40 #define RX51_TSC2005_IRQ_GPIO           100
41
42 static struct resource rx51_smc91x_resources[] = {
43         [0] = {
44                 .flags          = IORESOURCE_MEM,
45         },
46         [1] = {
47                 .flags          = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
48         },
49 };
50
51 static struct platform_device rx51_smc91x_device = {
52         .name           = "smc91x",
53         .id             = -1,
54         .num_resources  = ARRAY_SIZE(rx51_smc91x_resources),
55         .resource       = rx51_smc91x_resources,
56 };
57
58 static struct tsc2005_platform_data tsc2005_config = {
59         .reset_gpio             = RX51_TSC2005_RESET_GPIO, /* not used */
60
61         .ts_x_plate_ohm         = 280,
62         .ts_hw_avg              = 0,
63         .ts_touch_pressure      = 1500,
64         .ts_stab_time           = 1000,
65         .ts_pressure_max        = 2048,
66         .ts_pressure_fudge      = 2,
67         .ts_x_max               = 4096,
68         .ts_x_fudge             = 4,
69         .ts_y_max               = 4096,
70         .ts_y_fudge             = 7,
71 };
72
73 static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
74         .turbo_mode     = 0,
75         .single_channel = 1,
76 };
77
78 static struct spi_board_info rx51_peripherals_spi_board_info[] = {
79         [0] = {
80                 .modalias               = "tsc2005",
81                 .bus_num                = 1,
82                 .chip_select            = 0,
83                 .irq                    = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),
84                 .max_speed_hz           = 6000000,
85                 .controller_data        = &tsc2005_mcspi_config,
86                 .platform_data          = &tsc2005_config,
87         },
88 };
89
90 static int rx51_keymap[] = {
91         KEY(0, 0, KEY_Q),
92         KEY(0, 1, KEY_W),
93         KEY(0, 2, KEY_E),
94         KEY(0, 3, KEY_R),
95         KEY(0, 4, KEY_T),
96         KEY(0, 5, KEY_Y),
97         KEY(0, 6, KEY_U),
98         KEY(0, 7, KEY_I),
99         KEY(1, 0, KEY_O),
100         KEY(1, 1, KEY_D),
101         KEY(1, 2, KEY_DOT),
102         KEY(1, 3, KEY_V),
103         KEY(1, 4, KEY_DOWN),
104         KEY(2, 0, KEY_P),
105         KEY(2, 1, KEY_F),
106         KEY(2, 2, KEY_UP),
107         KEY(2, 3, KEY_B),
108         KEY(2, 4, KEY_RIGHT),
109         KEY(3, 0, KEY_COMMA),
110         KEY(3, 1, KEY_G),
111         KEY(3, 2, KEY_ENTER),
112         KEY(3, 3, KEY_N),
113         KEY(4, 0, KEY_BACKSPACE),
114         KEY(4, 1, KEY_H),
115         KEY(4, 3, KEY_M),
116         KEY(4, 4, KEY_LEFTCTRL),
117         KEY(5, 1, KEY_J),
118         KEY(5, 2, KEY_Z),
119         KEY(5, 3, KEY_SPACE),
120         KEY(5, 4, KEY_LEFTSHIFT),
121         KEY(6, 0, KEY_A),
122         KEY(6, 1, KEY_K),
123         KEY(6, 2, KEY_X),
124         KEY(6, 3, KEY_SPACE),
125         KEY(6, 4, KEY_FN),
126         KEY(7, 0, KEY_S),
127         KEY(7, 1, KEY_L),
128         KEY(7, 2, KEY_C),
129         KEY(7, 3, KEY_LEFT),
130         KEY(0xff, 0, KEY_F6),
131         KEY(0xff, 1, KEY_F7),
132         KEY(0xff, 2, KEY_F8),
133         KEY(0xff, 4, KEY_F9),
134         KEY(0xff, 5, KEY_F10),
135 };
136
137 static struct twl4030_keypad_data rx51_kp_data = {
138         .rows           = 8,
139         .cols           = 8,
140         .keymap         = rx51_keymap,
141         .keymapsize     = ARRAY_SIZE(rx51_keymap),
142         .rep            = 1,
143 };
144
145 static struct platform_device *rx51_peripherals_devices[] = {
146         &rx51_smc91x_device,
147 };
148
149 /*
150  * Timings are taken from smsc-lan91c96-ms.pdf
151  */
152 static int smc91x_init_gpmc(int cs)
153 {
154         struct gpmc_timings t;
155         const int t2_r = 45;            /* t2 in Figure 12.10 */
156         const int t2_w = 30;            /* t2 in Figure 12.11 */
157         const int t3 = 15;              /* t3 in Figure 12.10 */
158         const int t5_r = 0;             /* t5 in Figure 12.10 */
159         const int t6_r = 45;            /* t6 in Figure 12.10 */
160         const int t6_w = 0;             /* t6 in Figure 12.11 */
161         const int t7_w = 15;            /* t7 in Figure 12.11 */
162         const int t15 = 12;             /* t15 in Figure 12.2 */
163         const int t20 = 185;            /* t20 in Figure 12.2 */
164
165         memset(&t, 0, sizeof(t));
166
167         t.cs_on = t15;
168         t.cs_rd_off = t3 + t2_r + t5_r; /* Figure 12.10 */
169         t.cs_wr_off = t3 + t2_w + t6_w; /* Figure 12.11 */
170         t.adv_on = t3;                  /* Figure 12.10 */
171         t.adv_rd_off = t3 + t2_r;       /* Figure 12.10 */
172         t.adv_wr_off = t3 + t2_w;       /* Figure 12.11 */
173         t.oe_off = t3 + t2_r + t5_r;    /* Figure 12.10 */
174         t.oe_on = t.oe_off - t6_r;      /* Figure 12.10 */
175         t.we_off = t3 + t2_w + t6_w;    /* Figure 12.11 */
176         t.we_on = t.we_off - t7_w;      /* Figure 12.11 */
177         t.rd_cycle = t20;               /* Figure 12.2 */
178         t.wr_cycle = t20;               /* Figure 12.4 */
179         t.access = t3 + t2_r + t5_r;    /* Figure 12.10 */
180         t.wr_access = t3 + t2_w + t6_w; /* Figure 12.11 */
181
182         gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, GPMC_CONFIG1_DEVICESIZE_16);
183
184         return gpmc_cs_set_timings(cs, &t);
185 }
186
187 static void __init rx51_init_smc91x(void)
188 {
189         unsigned long cs_mem_base;
190         int ret;
191
192         omap_cfg_reg(U8_34XX_GPIO54_DOWN);
193         omap_cfg_reg(G25_34XX_GPIO86_OUT);
194         omap_cfg_reg(H19_34XX_GPIO164_OUT);
195
196         if (gpmc_cs_request(SMC91X_CS, SZ_16M, &cs_mem_base) < 0) {
197                 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
198                 return;
199         }
200
201         rx51_smc91x_resources[0].start = cs_mem_base + 0x300;
202         rx51_smc91x_resources[0].end = cs_mem_base + 0x30f;
203
204         smc91x_init_gpmc(SMC91X_CS);
205
206         if (gpio_request(SMC91X_GPIO_IRQ, "SMC91X irq") < 0)
207                 goto free1;
208
209         gpio_direction_input(SMC91X_GPIO_IRQ);
210         rx51_smc91x_resources[1].start = gpio_to_irq(SMC91X_GPIO_IRQ);
211
212         ret = gpio_request(SMC91X_GPIO_PWRDWN, "SMC91X powerdown");
213         if (ret)
214                 goto free2;
215         gpio_direction_output(SMC91X_GPIO_PWRDWN, 0);
216
217         ret = gpio_request(SMC91X_GPIO_RESET, "SMC91X reset");
218         if (ret)
219                 goto free3;
220         gpio_direction_output(SMC91X_GPIO_RESET, 0);
221         gpio_set_value(SMC91X_GPIO_RESET, 1);
222         msleep(100);
223         gpio_set_value(SMC91X_GPIO_RESET, 0);
224
225         return;
226
227 free3:
228         gpio_free(SMC91X_GPIO_PWRDWN);
229 free2:
230         gpio_free(SMC91X_GPIO_IRQ);
231 free1:
232         gpmc_cs_free(SMC91X_CS);
233
234         printk(KERN_ERR "Could not initialize smc91x\n");
235 }
236
237 static void __init rx51_init_tsc2005(void)
238 {
239         int r;
240
241         r = gpio_request(RX51_TSC2005_IRQ_GPIO, "tsc2005 DAV IRQ");
242         if (r >= 0) {
243                 gpio_direction_input(RX51_TSC2005_IRQ_GPIO);
244         } else {
245                 printk(KERN_ERR "unable to get DAV GPIO");
246         }
247 }
248
249 static struct twl4030_madc_platform_data rx51_madc_data = {
250         .irq_line               = 1,
251 };
252
253 static struct twl4030_hsmmc_info mmc[] = {
254         {
255                 .name           = "external",
256                 .mmc            = 1,
257                 .wires          = 4,
258                 .cover_only     = true,
259                 .gpio_cd        = 160,
260                 .gpio_wp        = -EINVAL,
261         },
262         {
263                 .name           = "internal",
264                 .mmc            = 2,
265                 .wires          = 8,
266                 .gpio_cd        = -EINVAL,
267                 .gpio_wp        = -EINVAL,
268         },
269         {}      /* Terminator */
270 };
271
272 static struct regulator_consumer_supply rx51_vmmc1_supply = {
273         .supply                 = "vmmc",
274 };
275
276 static struct regulator_consumer_supply rx51_vmmc2_supply = {
277         .supply                 = "vmmc",
278 };
279
280 static struct regulator_consumer_supply rx51_vsim_supply = {
281         .supply                 = "vmmc_aux",
282 };
283
284 static struct regulator_init_data rx51_vaux1 = {
285         .constraints = {
286                 .name                   = "V28",
287                 .min_uV                 = 2800000,
288                 .max_uV                 = 2800000,
289                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
290                                         | REGULATOR_MODE_STANDBY,
291                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
292                                         | REGULATOR_CHANGE_STATUS,
293         },
294 };
295
296 static struct regulator_init_data rx51_vaux2 = {
297         .constraints = {
298                 .name                   = "VCSI",
299                 .min_uV                 = 1800000,
300                 .max_uV                 = 1800000,
301                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
302                                         | REGULATOR_MODE_STANDBY,
303                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
304                                         | REGULATOR_CHANGE_STATUS,
305         },
306 };
307
308 /* VAUX3 - adds more power to VIO_18 rail */
309 static struct regulator_init_data rx51_vaux3 = {
310         .constraints = {
311                 .name                   = "VCAM_DIG_18",
312                 .min_uV                 = 1800000,
313                 .max_uV                 = 1800000,
314                 .apply_uV               = true,
315                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
316                                         | REGULATOR_MODE_STANDBY,
317                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
318                                         | REGULATOR_CHANGE_STATUS,
319         },
320 };
321
322 static struct regulator_init_data rx51_vaux4 = {
323         .constraints = {
324                 .name                   = "VCAM_ANA_28",
325                 .min_uV                 = 2800000,
326                 .max_uV                 = 2800000,
327                 .apply_uV               = true,
328                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
329                                         | REGULATOR_MODE_STANDBY,
330                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
331                                         | REGULATOR_CHANGE_STATUS,
332         },
333 };
334
335 static struct regulator_init_data rx51_vmmc1 = {
336         .constraints = {
337                 .min_uV                 = 1850000,
338                 .max_uV                 = 3150000,
339                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
340                                         | REGULATOR_MODE_STANDBY,
341                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
342                                         | REGULATOR_CHANGE_MODE
343                                         | REGULATOR_CHANGE_STATUS,
344         },
345         .num_consumer_supplies  = 1,
346         .consumer_supplies      = &rx51_vmmc1_supply,
347 };
348
349 static struct regulator_init_data rx51_vmmc2 = {
350         .constraints = {
351                 .name                   = "VMMC2_30",
352                 .min_uV                 = 1850000,
353                 .max_uV                 = 3150000,
354                 .apply_uV               = true,
355                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
356                                         | REGULATOR_MODE_STANDBY,
357                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
358                                         | REGULATOR_CHANGE_MODE
359                                         | REGULATOR_CHANGE_STATUS,
360         },
361         .num_consumer_supplies  = 1,
362         .consumer_supplies      = &rx51_vmmc2_supply,
363 };
364
365 static struct regulator_init_data rx51_vsim = {
366         .constraints = {
367                 .name                   = "VMMC2_IO_18",
368                 .min_uV                 = 1800000,
369                 .max_uV                 = 1800000,
370                 .apply_uV               = true,
371                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
372                                         | REGULATOR_MODE_STANDBY,
373                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
374                                         | REGULATOR_CHANGE_STATUS,
375         },
376         .num_consumer_supplies  = 1,
377         .consumer_supplies      = &rx51_vsim_supply,
378 };
379
380 static struct regulator_init_data rx51_vdac = {
381         .constraints = {
382                 .min_uV                 = 1800000,
383                 .max_uV                 = 1800000,
384                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
385                                         | REGULATOR_MODE_STANDBY,
386                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
387                                         | REGULATOR_CHANGE_MODE
388                                         | REGULATOR_CHANGE_STATUS,
389         },
390 };
391
392 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
393 {
394         /* FIXME this gpio setup is just a placeholder for now */
395         gpio_request(gpio + 6, "backlight_pwm");
396         gpio_direction_output(gpio + 6, 0);
397         gpio_request(gpio + 7, "speaker_en");
398         gpio_direction_output(gpio + 7, 1);
399
400         /* set up MMC adapters, linking their regulators to them */
401         twl4030_mmc_init(mmc);
402         rx51_vmmc1_supply.dev = mmc[0].dev;
403         rx51_vmmc2_supply.dev = mmc[1].dev;
404         rx51_vsim_supply.dev = mmc[1].dev;
405
406         return 0;
407 }
408
409 static struct twl4030_gpio_platform_data rx51_gpio_data = {
410         .gpio_base              = OMAP_MAX_GPIO_LINES,
411         .irq_base               = TWL4030_GPIO_IRQ_BASE,
412         .irq_end                = TWL4030_GPIO_IRQ_END,
413         .pulldowns              = BIT(0) | BIT(1) | BIT(2) | BIT(3)
414                                 | BIT(4) | BIT(5)
415                                 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
416                                 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
417                                 | BIT(16) | BIT(17) ,
418         .setup                  = rx51_twlgpio_setup,
419 };
420
421 static struct twl4030_platform_data rx51_twldata = {
422         .irq_base               = TWL4030_IRQ_BASE,
423         .irq_end                = TWL4030_IRQ_END,
424
425         /* platform_data for children goes here */
426         .gpio                   = &rx51_gpio_data,
427         .keypad                 = &rx51_kp_data,
428         .madc                   = &rx51_madc_data,
429
430         .vaux1                  = &rx51_vaux1,
431         .vaux2                  = &rx51_vaux2,
432         .vaux3                  = &rx51_vaux3,
433         .vaux4                  = &rx51_vaux4,
434         .vmmc1                  = &rx51_vmmc1,
435         .vmmc2                  = &rx51_vmmc2,
436         .vsim                   = &rx51_vsim,
437         .vdac                   = &rx51_vdac,
438 };
439
440 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
441         {
442                 I2C_BOARD_INFO("twl5030", 0x48),
443                 .flags = I2C_CLIENT_WAKE,
444                 .irq = INT_34XX_SYS_NIRQ,
445                 .platform_data = &rx51_twldata,
446         },
447 };
448
449 static int __init rx51_i2c_init(void)
450 {
451         omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1,
452                         ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
453         omap_register_i2c_bus(2, 100, NULL, 0);
454         omap_register_i2c_bus(3, 400, NULL, 0);
455         return 0;
456 }
457
458
459 void __init rx51_peripherals_init(void)
460 {
461         platform_add_devices(rx51_peripherals_devices,
462                                 ARRAY_SIZE(rx51_peripherals_devices));
463         spi_register_board_info(rx51_peripherals_spi_board_info,
464                                 ARRAY_SIZE(rx51_peripherals_spi_board_info));
465         rx51_i2c_init();
466         rx51_init_smc91x();
467         rx51_init_tsc2005();
468 }
469