GTA04: remove unused code from board file.
[gta04.git] / arch / arm / mach-omap2 / board-omap3gta04.c
1 /*
2  * linux/arch/arm/mach-omap2/board-omap3gta04.c
3  *
4  * Copyright (C) 2008 Texas Instruments
5  *
6  * Modified from mach-omap2/board-omap3gta04.c
7  *
8  * Initial code: Syed Mohammed Khasim
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/err.h>
20 #include <linux/clk.h>
21 #include <linux/io.h>
22 #include <linux/leds.h>
23 #include <linux/gpio.h>
24 #include <linux/irq.h>
25 #include <linux/input.h>
26 #include <linux/gpio_keys.h>
27 #include <linux/backlight.h>
28 #include <linux/pwm.h>
29 #include <linux/pwm_backlight.h>
30 #include <linux/rfkill-regulator.h>
31 #include <linux/gpio-reg.h>
32 #include <linux/gpio-w2sg0004.h>
33 #include <linux/extcon/extcon_gpio.h>
34 #include <linux/opp.h>
35 #include <linux/cpu.h>
36
37 #include <linux/mtd/mtd.h>
38 #include <linux/mtd/partitions.h>
39 #include <linux/mtd/nand.h>
40 #include <linux/mmc/host.h>
41 #include <linux/mmc/card.h>
42 #include <linux/mmc/sdio.h>
43
44 #include <linux/regulator/machine.h>
45 #include <linux/i2c/twl.h>
46 #include <linux/i2c/tsc2007.h>
47
48 #include <linux/i2c/bmp085.h>
49 #ifdef CONFIG_LEDS_TCA6507
50 #include <linux/leds-tca6507.h>
51 #endif
52
53 #include <linux/sysfs.h>
54
55 #include <asm/mach-types.h>
56 #include <asm/mach/arch.h>
57 #include <asm/mach/map.h>
58 #include <asm/mach/flash.h>
59
60 #include <sound/soc.h>
61
62 #include "common.h"
63 #include <video/omapdss.h>
64 #include <video/omap-panel-generic-dpi.h>
65 #include <plat/gpmc.h>
66 #include <linux/platform_data/mtd-nand-omap2.h>
67 #include <plat/usb.h>
68 #include <plat/clock.h>
69 #include <plat/omap-pm.h>
70 #include <linux/platform_data/gpio-omap.h>
71 #include <linux/platform_data/spi-omap2-mcspi.h>
72 #include <linux/platform_data/omap-pwm.h>
73 #include <plat/omap-serial.h>
74 #include <plat/omap_device.h>
75
76 #include "mux.h"
77 #include "hsmmc.h"
78 #include "pm.h"
79 #include "common-board-devices.h"
80 #include "control.h"
81
82 #define GPMC_CS0_BASE  0x60
83 #define GPMC_CS_SIZE   0x30
84
85 #define NAND_BLOCK_SIZE         SZ_128K
86
87 #define AUX_BUTTON_GPIO         7
88 #define TWL4030_MSECURE_GPIO    22
89 #define TS_PENIRQ_GPIO          160
90 #define WO3G_GPIO               (gta04_version >= 4 ? 10 : 176)
91
92 /* see: https://patchwork.kernel.org/patch/120449/
93  * OMAP3 gta04 revision
94  * Run time detection of gta04 revision is done by reading GPIO.
95  * GPIO ID -
96  *      AXBX    = GPIO173, GPIO172, GPIO171: 1 1 1
97  *      C1_3    = GPIO173, GPIO172, GPIO171: 1 1 0
98  *      C4      = GPIO173, GPIO172, GPIO171: 1 0 1
99  *      XM      = GPIO173, GPIO172, GPIO171: 0 0 0
100  */
101 enum {
102         gta04_BOARD_UNKN = 0,
103         gta04_BOARD_AXBX,
104         gta04_BOARD_C1_3,
105         gta04_BOARD_C4,
106         gta04_BOARD_XM,
107 };
108
109 static u8 gta04_version;        /* counts 2..9 */
110
111 static void __init gta04_init_rev(void)
112 {
113         int ret;
114         u16 gta04_rev = 0;
115         static char revision[8] = {     /* revision table defined by pull-down
116                                          * R305, R306, R307 */
117                 9,
118                 6,
119                 7,
120                 3,
121                 8,
122                 4,
123                 5,
124                 2
125         };
126         printk("Running gta04_init_rev()\n");
127
128         omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
129         omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
130         omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
131
132         udelay(100);
133
134         ret = gpio_request(171, "rev_id_0");
135         if (ret < 0)
136                 goto fail0;
137
138         ret = gpio_request(172, "rev_id_1");
139         if (ret < 0)
140                 goto fail1;
141
142         ret = gpio_request(173, "rev_id_2");
143         if (ret < 0)
144                 goto fail2;
145
146         udelay(100);
147
148         gpio_direction_input(171);
149         gpio_direction_input(172);
150         gpio_direction_input(173);
151
152         udelay(100);
153
154         gta04_rev = gpio_get_value(171)
155                                 | (gpio_get_value(172) << 1)
156                                 | (gpio_get_value(173) << 2);
157
158         printk("gta04_rev %u\n", gta04_rev);
159
160         gta04_version = revision[gta04_rev];
161
162         return;
163
164 fail2:
165         gpio_free(172);
166 fail1:
167         gpio_free(171);
168 fail0:
169         printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
170         gta04_version = 0;
171
172         return;
173 }
174
175
176 static struct mtd_partition gta04_nand_partitions[] = {
177         /* All the partition sizes are listed in terms of NAND block size */
178         {
179                 .name           = "X-Loader",
180                 .offset         = 0,
181                 .size           = 4 * NAND_BLOCK_SIZE,
182                 .mask_flags     = MTD_WRITEABLE,        /* force read-only */
183         },
184         {
185                 .name           = "U-Boot",
186                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
187                 .size           = 15 * NAND_BLOCK_SIZE,
188         },
189         {
190                 .name           = "U-Boot Env",
191                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x260000 */
192                 .size           = 1 * NAND_BLOCK_SIZE,
193         },
194         {
195                 .name           = "Kernel",
196                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
197                 .size           = 32 * NAND_BLOCK_SIZE,
198         },
199         {
200                 .name           = "File System",
201                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x680000 */
202                 .size           = MTDPART_SIZ_FULL,
203         },
204 };
205
206 static struct omap_pwm_pdata pwm_pdata = {
207         .timer_id = 11,
208 };
209
210 static struct pwm_lookup board_pwm_lookup[] = {
211         // GPT11_PWM_EVT - Active High
212         PWM_LOOKUP("omap-pwm", 0, "pwm-backlight", NULL),
213 };
214
215 static struct platform_device pwm_device = {
216         .name           = "omap-pwm",
217         .id             = 0,
218         .dev.platform_data = &pwm_pdata,
219 };
220
221 static struct platform_pwm_backlight_data pwm_backlight = {
222         .pwm_id         = 0,
223         .max_brightness = 100,
224         .dft_brightness = 100,
225         .pwm_period_ns  = 2000000, /* 500 Hz */
226         .lth_brightness = 11, /* Below 11% display appears as off */
227 };
228 static struct platform_device backlight_device = {
229         .name = "pwm-backlight",
230         .dev = {
231                 .platform_data = &pwm_backlight,
232         },
233         .id = -1,
234 };
235
236 static int gta04_enable_lcd(struct omap_dss_device *dssdev)
237 {
238         static int did_reg = 0;
239         printk("gta04_enable_lcd()\n");
240         if (!did_reg) {
241                 /* Cannot do this in gta04_init() as clocks aren't
242                  * initialised yet, so do it here.
243                  */
244                 platform_device_register(&backlight_device);
245                 did_reg = 1;
246         }
247         return 0;
248 }
249
250 static void gta04_disable_lcd(struct omap_dss_device *dssdev)
251 {
252         printk("gta04_disable_lcd()\n");
253 }
254
255 static struct omap_dss_device gta04_lcd_device = {
256         .type = OMAP_DISPLAY_TYPE_DPI,
257         .name = "lcd",
258         .driver_name = "td028ttec1_panel",
259         .phy.dpi.data_lines = 24,
260         .platform_enable = gta04_enable_lcd,
261         .platform_disable = gta04_disable_lcd,
262 };
263
264 static struct omap_dss_device *gta04_dss_devices[] = {
265         &gta04_lcd_device,
266 };
267
268 static struct omap_dss_board_info gta04_dss_data = {
269         .num_devices = ARRAY_SIZE(gta04_dss_devices),
270         .devices = gta04_dss_devices,
271 };
272
273 static struct regulator_consumer_supply gta04_vdac_supply =
274         REGULATOR_SUPPLY("vdda_dac","omapdss.0");
275
276 static struct regulator_consumer_supply gta04_vdvi_supplies[] = {
277         REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
278         REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
279         REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
280 };
281
282 #include "sdram-micron-mt46h32m32lf-6.h"
283
284 /* "+2" because TWL4030 adds 2 LED drives as gpio outputs */
285 #define GPIO_WIFI_RESET (OMAP_MAX_GPIO_LINES + TWL4030_GPIO_MAX + 2)
286 #define GPIO_BT_REG (GPIO_WIFI_RESET + 1)
287 #define GPIO_GPS_CTRL (GPIO_BT_REG + 1)
288
289
290 static struct omap2_hsmmc_info mmc[] = {
291         {
292                 .mmc            = 1,
293                  // only 4 wires are connected, and they cannot be removed...
294                 .caps           = (MMC_CAP_4_BIT_DATA
295                                    |MMC_CAP_NONREMOVABLE
296                                    |MMC_CAP_POWER_OFF_CARD),
297                 .gpio_cd        = -EINVAL,      // no card detect
298                 .gpio_wp        = -EINVAL,      // no write protect
299                 .gpio_reset     = -EINVAL,
300         },
301         { // this is the WiFi SDIO interface
302                 .mmc            = 2,
303                 .caps           = (MMC_CAP_4_BIT_DATA // only 4 wires are connected
304                                    |MMC_CAP_NONREMOVABLE
305                                    |MMC_CAP_POWER_OFF_CARD),
306                 .gpio_cd        = -EINVAL, // virtual card detect
307                 .gpio_wp        = -EINVAL,      // no write protect
308                 .gpio_reset     = GPIO_WIFI_RESET,
309                 .transceiver    = true, // external transceiver
310                 .ocr_mask       = MMC_VDD_31_32,        /* 3.15 is what we want */
311                 .deferred       = true,
312         },
313         {}      /* Terminator */
314 };
315
316 static struct regulator_consumer_supply gta04_vmmc1_supply[] = {
317         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
318 };
319
320 static struct regulator_consumer_supply gta04_vsim_supply[] = {
321         REGULATOR_SUPPLY("vrfkill", "rfkill-regulator.0"),
322 };
323
324 static struct twl4030_gpio_platform_data gta04_gpio_data = {
325         .use_leds       = true,
326         .pullups        = BIT(1),
327         .pulldowns      = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
328                                 | BIT(15) | BIT(16) | BIT(17),
329 };
330
331 static struct twl4030_clock_init_data gta04_clock = {
332         .ck32k_lowpwr_enable = 1, /* Reduce power when on backup battery */
333 };
334
335 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
336 static struct regulator_init_data gta04_vmmc1 = {
337         .constraints = {
338                 .name                   = "VMMC1",
339                 .min_uV                 = 1850000,
340                 .max_uV                 = 3150000,
341                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
342                                         | REGULATOR_MODE_STANDBY,
343                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
344                                         | REGULATOR_CHANGE_MODE
345                                         | REGULATOR_CHANGE_STATUS,
346         },
347         .num_consumer_supplies  = 1,
348         .consumer_supplies      = gta04_vmmc1_supply,
349 };
350
351 /* VAUX4 powers Bluetooth and WLAN */
352
353 static struct regulator_consumer_supply gta04_vaux4_supply[] = {
354         REGULATOR_SUPPLY("vgpio","regulator-gpio.0"),
355         REGULATOR_SUPPLY("vmmc","omap_hsmmc.1")
356 };
357
358 static struct twl_regulator_driver_data vaux4_data = {
359         .features = TWL4030_ALLOW_UNSUPPORTED,
360 };
361
362 static struct regulator_init_data gta04_vaux4 = {
363         .constraints = {
364                 .name                   = "VAUX4",
365                 .min_uV                 = 2800000,
366                 /* FIXME: this is a HW issue - 3.15V or 3.3V isn't supported
367                  * officially - set CONFIG_TWL4030_ALLOW_UNSUPPORTED */
368                 .max_uV                 = 3150000,
369                 .valid_modes_mask       = (REGULATOR_MODE_NORMAL
370                                            | REGULATOR_MODE_STANDBY),
371                 .valid_ops_mask         = (REGULATOR_CHANGE_VOLTAGE
372                                            | REGULATOR_CHANGE_MODE
373                                            | REGULATOR_CHANGE_STATUS),
374         },
375         .num_consumer_supplies  = ARRAY_SIZE(gta04_vaux4_supply),
376         .consumer_supplies      = gta04_vaux4_supply,
377         .driver_data = &vaux4_data,
378 };
379
380 /* VAUX3 for Camera */
381
382 static struct regulator_consumer_supply gta04_vaux3_supply = {
383         .supply                 = "vaux3",
384 };
385
386 static struct regulator_init_data gta04_vaux3 = {
387         .constraints = {
388                 .name                   = "VAUX3",
389                 .min_uV                 = 2500000,
390                 .max_uV                 = 2500000,
391                 .valid_modes_mask       = (REGULATOR_MODE_NORMAL
392                                            | REGULATOR_MODE_STANDBY),
393                 .valid_ops_mask         = (REGULATOR_CHANGE_VOLTAGE
394                                            | REGULATOR_CHANGE_MODE
395                                            | REGULATOR_CHANGE_STATUS),
396         },
397         .num_consumer_supplies  = 1,
398         .consumer_supplies      = &gta04_vaux3_supply,
399 };
400
401 /* VAUX2 for Sensors ITG3200 (and LIS302/LSM303) */
402
403 static struct regulator_consumer_supply gta04_vaux2_supply = {
404         .supply                 = "vaux2",
405 };
406
407 static struct regulator_init_data gta04_vaux2 = {
408         .constraints = {
409                 .name                   = "VAUX2",
410                 .min_uV                 = 2800000,
411                 .max_uV                 = 2800000,
412                 .always_on              = 1,
413                 .valid_modes_mask       = REGULATOR_MODE_NORMAL,
414                 .valid_ops_mask         = 0,
415         },
416         .num_consumer_supplies  = 1,
417         .consumer_supplies      = &gta04_vaux2_supply,
418 };
419
420 /* VAUX1 unused */
421
422 static struct regulator_consumer_supply gta04_vaux1_supply = {
423         .supply                 = "vaux1",
424 };
425
426 static struct regulator_init_data gta04_vaux1 = {
427         .constraints = {
428                 .name                   = "VAUX1",
429                 .min_uV                 = 2500000,
430                 .max_uV                 = 3000000,
431                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
432                 | REGULATOR_MODE_STANDBY,
433                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
434                 | REGULATOR_CHANGE_MODE
435                 | REGULATOR_CHANGE_STATUS,
436         },
437         .num_consumer_supplies  = 1,
438         .consumer_supplies      = &gta04_vaux1_supply,
439 };
440
441 /* VSIM used for powering the external GPS Antenna */
442
443 static struct regulator_init_data gta04_vsim = {
444         .constraints = {
445                 .name                   = "VSIM",
446                 .min_uV                 = 2800000,
447                 .max_uV                 = 2800000,
448                 .apply_uV               = 1,
449                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
450                                         | REGULATOR_MODE_STANDBY,
451                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
452                                         | REGULATOR_CHANGE_MODE
453                                         | REGULATOR_CHANGE_STATUS,
454         },
455         .num_consumer_supplies  = ARRAY_SIZE(gta04_vsim_supply),
456         .consumer_supplies      = gta04_vsim_supply,
457 };
458
459 /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
460 static struct regulator_init_data gta04_vdac = {
461         .constraints = {
462                 .name                   = "VDAC",
463                 .min_uV                 = 1800000,
464                 .max_uV                 = 1800000,
465                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
466                                         | REGULATOR_MODE_STANDBY,
467                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
468                                         | REGULATOR_CHANGE_STATUS,
469         },
470         .num_consumer_supplies  = 1,
471         .consumer_supplies      = &gta04_vdac_supply,
472 };
473
474 /* VPLL2 for digital video outputs */
475 static struct regulator_init_data gta04_vpll2 = {
476         .constraints = {
477                 .name                   = "VDVI",
478                 .min_uV                 = 1800000,
479                 .max_uV                 = 1800000,
480                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
481                                         | REGULATOR_MODE_STANDBY,
482                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
483                                         | REGULATOR_CHANGE_STATUS,
484         },
485         .num_consumer_supplies  = ARRAY_SIZE(gta04_vdvi_supplies),
486         .consumer_supplies      = gta04_vdvi_supplies,
487 };
488
489 /* rfkill devices for GPS and Bluetooth to control regulators */
490
491 static struct rfkill_regulator_platform_data gps_rfkill_data = {
492         .name = "GPS",
493         .type = RFKILL_TYPE_GPS,
494 };
495
496 static struct platform_device gps_rfkill_device = {
497         .name = "rfkill-regulator",
498         .id = 0,
499         .dev.platform_data = &gps_rfkill_data,
500 };
501
502 static struct gpio_reg_data bt_gpio_data = {
503         .gpio = GPIO_BT_REG,
504 };
505
506 static struct platform_device bt_gpio_reg_device = {
507         .name = "regulator-gpio",
508         .id = 0,
509         .dev.platform_data = &bt_gpio_data,
510 };
511
512 static struct gpio_w2sg_data gps_gpio_data = {
513         .ctrl_gpio      = GPIO_GPS_CTRL,
514         .on_off_gpio    = 145,
515         .rx_gpio        = 147,
516         .on_state       = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0,
517         .off_state      = OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE4,
518 };
519
520 static struct platform_device gps_gpio_device = {
521         .name = "w2s-gpio",
522         .id = 0,
523         .dev.platform_data = &gps_gpio_data,
524 };
525
526 static struct gpio_extcon_platform_data antenna_extcon_data = {
527         .name = "gps_antenna",
528         .gpio = 144,
529         .debounce = 10,
530         .irq_flags = IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING,
531         .state_on = "external",
532         .state_off = "internal",
533 };
534
535 static struct platform_device antenna_extcon_dev = {
536         .name = "extcon-gpio",
537         .id = -1,
538         .dev.platform_data = &antenna_extcon_data,
539 };
540
541 static struct twl4030_usb_data gta04_usb_data = {
542         .usb_mode       = T2_USB_MODE_ULPI,
543 };
544
545 static struct twl4030_codec_data omap3_codec = {
546         .voice_fmt      = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_IB_NF,
547 };
548
549 static struct twl4030_vibra_data gta04_vibra_data = {
550         .coexist        =       0,
551 };
552
553 static struct twl4030_audio_data omap3_audio_pdata = {
554         .audio_mclk = 26000000,
555         .codec = &omap3_codec,
556         .vibra = &gta04_vibra_data,
557 };
558
559 static struct twl4030_madc_platform_data gta04_madc_data = {
560         .irq_line       = 1,
561 };
562
563 static struct twl4030_ins __initdata sleep_on_seq[] = {
564         /* Turn off HFCLKOUT */
565         {MSG_SINGULAR(DEV_GRP_P3, RES_HFCLKOUT, RES_STATE_OFF), 2},
566         /* Turn OFF VDD1 */
567         {MSG_SINGULAR(DEV_GRP_P1, RES_VDD1, RES_STATE_OFF), 2},
568         /* Turn OFF VDD2 */
569         {MSG_SINGULAR(DEV_GRP_P1, RES_VDD2, RES_STATE_OFF), 2},
570         /* Turn OFF VPLL1 */
571         {MSG_SINGULAR(DEV_GRP_P1, RES_VPLL1, RES_STATE_OFF), 2},
572
573         {MSG_SINGULAR(DEV_GRP_P1, RES_VINTANA1, RES_STATE_OFF), 2},
574         {MSG_SINGULAR(DEV_GRP_P1, RES_VINTANA2, RES_STATE_OFF), 2},
575         {MSG_SINGULAR(DEV_GRP_P1, RES_VINTDIG, RES_STATE_OFF), 2},
576
577 //      {MSG_SINGULAR(DEV_GRP_P1, RES_REGEN, RES_STATE_OFF), 2},
578
579 };
580
581 static struct twl4030_script sleep_on_script __initdata = {
582         .script = sleep_on_seq,
583         .size   = ARRAY_SIZE(sleep_on_seq),
584         .flags  = TWL4030_SLEEP_SCRIPT,
585 };
586
587 static struct twl4030_ins wakeup_p12_seq[] __initdata = {
588         {MSG_SINGULAR(DEV_GRP_P1, RES_VINTANA1, RES_STATE_ACTIVE), 2},
589         {MSG_SINGULAR(DEV_GRP_P1, RES_VINTANA2, RES_STATE_ACTIVE), 2},
590         {MSG_SINGULAR(DEV_GRP_P1, RES_VINTDIG, RES_STATE_ACTIVE), 2},
591
592         /* Turn on HFCLKOUT */
593         {MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
594         /* Turn ON VDD1 */
595         {MSG_SINGULAR(DEV_GRP_P1, RES_VDD1, RES_STATE_ACTIVE), 2},
596         /* Turn ON VDD2 */
597         {MSG_SINGULAR(DEV_GRP_P1, RES_VDD2, RES_STATE_ACTIVE), 2},
598         /* Turn ON VPLL1 */
599         {MSG_SINGULAR(DEV_GRP_P1, RES_VPLL1, RES_STATE_ACTIVE), 2},
600 };
601
602 static struct twl4030_script wakeup_p12_script __initdata = {
603         .script = wakeup_p12_seq,
604         .size   = ARRAY_SIZE(wakeup_p12_seq),
605         .flags  = TWL4030_WAKEUP12_SCRIPT,
606 };
607
608 /* Turn the HFCLK on when CPU asks for it. */
609 static struct twl4030_ins wakeup_p3_seq[] __initdata = {
610         {MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
611 };
612
613 static struct twl4030_script wakeup_p3_script __initdata = {
614         .script = wakeup_p3_seq,
615         .size   = ARRAY_SIZE(wakeup_p3_seq),
616         .flags  = TWL4030_WAKEUP3_SCRIPT,
617 };
618
619 static struct twl4030_ins wrst_seq[] __initdata = {
620 /*
621  * Reset twl4030.
622  * Reset VDD1 regulator.
623  * Reset VDD2 regulator.
624  * Reset VPLL1 regulator.
625  * Enable sysclk output.
626  * Reenable twl4030.
627  */
628         {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
629         {MSG_SINGULAR(DEV_GRP_P1, RES_VDD1, RES_STATE_WRST), 15},
630         {MSG_SINGULAR(DEV_GRP_P1, RES_VDD2, RES_STATE_WRST), 15},
631         {MSG_SINGULAR(DEV_GRP_P1, RES_VPLL1, RES_STATE_WRST), 0x60},
632         {MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
633         {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
634 };
635
636 static struct twl4030_script wrst_script __initdata = {
637         .script = wrst_seq,
638         .size   = ARRAY_SIZE(wrst_seq),
639         .flags  = TWL4030_WRST_SCRIPT,
640 };
641
642 static struct twl4030_script *twl4030_scripts[] __initdata = {
643         &wakeup_p12_script,
644         &wakeup_p3_script,
645         &sleep_on_script,
646         &wrst_script,
647 };
648
649 #define TWL_RES_CFG(_res, _devg) { .resource = _res, .devgroup = _devg, \
650         .type = TWL4030_RESCONFIG_UNDEF, .type2 = TWL4030_RESCONFIG_UNDEF,}
651
652 #define DEV_GRP_ALL (DEV_GRP_P1|DEV_GRP_P2|DEV_GRP_P3)
653 static struct twl4030_resconfig twl4030_rconfig[] = {
654         TWL_RES_CFG(RES_HFCLKOUT, DEV_GRP_P3),
655         TWL_RES_CFG(RES_VINTANA1, DEV_GRP_ALL),
656         TWL_RES_CFG(RES_VINTANA1, DEV_GRP_P1),
657         TWL_RES_CFG(RES_VINTANA2, DEV_GRP_ALL),
658         TWL_RES_CFG(RES_VINTANA2, DEV_GRP_P1),
659         TWL_RES_CFG(RES_VINTDIG, DEV_GRP_ALL),
660         TWL_RES_CFG(RES_VINTDIG, DEV_GRP_P1),
661         { 0, 0},
662 };
663
664 struct twl4030_power_data gta04_power_scripts = {
665 //      .scripts        = twl4030_scripts,
666 //      .num            = ARRAY_SIZE(twl4030_scripts),
667         .resource_config = twl4030_rconfig,
668         .use_poweroff   = 1,
669 };
670
671 /* override TWL defaults */
672
673 static int gta04_batt_table[] = {
674         /* 0 C*/
675         30800, 29500, 28300, 27100,
676         26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
677         17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
678         11600, 11200, 10800, 10400, 10000, 9630,  9280,  8950,  8620,  8310,
679         8020,  7730,  7460,  7200,  6950,  6710,  6470,  6250,  6040,  5830,
680         5640,  5450,  5260,  5090,  4920,  4760,  4600,  4450,  4310,  4170,
681         4040,  3910,  3790,  3670,  3550
682 };
683
684 static struct twl4030_bci_platform_data gta04_bci_data = {
685         .battery_tmp_tbl        = gta04_batt_table,
686         .tblsize                = ARRAY_SIZE(gta04_batt_table),
687         .bb_uvolt               = 3200000,
688         .bb_uamp                = 150,
689 };
690
691
692 static struct twl4030_platform_data gta04_twldata = {
693         /* platform_data for children goes here */
694         .bci            = &gta04_bci_data,
695         .gpio           = &gta04_gpio_data,
696         .madc           = &gta04_madc_data,
697         .power          = &gta04_power_scripts, /* empty but if not present, pm_power_off is not initialized */
698         .usb            = &gta04_usb_data,
699         .audio          = &omap3_audio_pdata,
700         .clock          = &gta04_clock,
701
702         .vaux1          = &gta04_vaux1,
703         .vaux2          = &gta04_vaux2,
704         .vaux3          = &gta04_vaux3,
705         .vaux4          = &gta04_vaux4,
706         .vmmc1          = &gta04_vmmc1,
707         .vsim           = &gta04_vsim,
708         .vdac           = &gta04_vdac,
709         .vpll2          = &gta04_vpll2,
710 };
711
712
713 #if defined(CONFIG_SND_SOC_GTM601)
714
715 static struct platform_device gta04_gtm601_codec_audio_device = {
716         .name   = "gtm601_codec_audio",
717         .id     = -1,
718 };
719 static struct platform_device gta04_voice_device = {
720         .name = "gta04-voice",
721         .id = -1,
722 };
723 #endif
724
725 #if defined(CONFIG_SND_SOC_SI47XX)
726
727 static struct platform_device gta04_si47xx_codec_audio_device = {
728         .name   = "si47xx_codec_audio",
729         .id     = -1,
730         .dev    = {
731                 .platform_data  = NULL,
732         },
733 };
734 #endif
735
736 #if defined(CONFIG_SND_SOC_W2CBW003)
737
738 static struct platform_device gta04_w2cbw003_codec_audio_device = {
739         .name   = "w2cbw003_codec_audio",
740         .id     = -1,
741 };
742 static struct platform_device gta04_headset_device = {
743         .name = "gta04-headset",
744         .id = -1,
745 };
746 #endif
747
748 #ifdef CONFIG_TOUCHSCREEN_TSC2007
749
750 /* TouchScreen */
751
752 static int ts_get_pendown_state(void)
753 {
754         int val = 0;
755
756         val = gpio_get_value(TS_PENIRQ_GPIO);
757
758         return val ? 0 : 1;
759 }
760
761 static int __init tsc2007_init(void)
762 {
763         printk("tsc2007_init()\n");
764         omap_mux_init_gpio(TS_PENIRQ_GPIO, OMAP_PIN_INPUT_PULLUP);
765         if (gpio_request(TS_PENIRQ_GPIO, "tsc2007_pen_down")) {
766                 printk(KERN_ERR "Failed to request GPIO %d for "
767                            "TSC2007 pen down IRQ\n", TS_PENIRQ_GPIO);
768                 return  -ENODEV;
769         }
770
771         if (gpio_direction_input(TS_PENIRQ_GPIO)) {
772                 printk(KERN_WARNING "GPIO#%d cannot be configured as "
773                            "input\n", TS_PENIRQ_GPIO);
774                 return -ENXIO;
775         }
776 //      debounce isn't handled properly when power-saving and we lose
777 //      interrupts, so don't bother for now.
778 //      gpio_set_debounce(TS_PENIRQ_GPIO, (0x0a+1)*31);
779         irq_set_irq_type(gpio_to_irq(TS_PENIRQ_GPIO), IRQ_TYPE_EDGE_FALLING);
780         return 0;
781 }
782
783 static void tsc2007_exit(void)
784 {
785         gpio_free(TS_PENIRQ_GPIO);
786 }
787
788 struct tsc2007_platform_data __initdata tsc2007_info = {
789         .model                  = 2007,
790         .x_plate_ohms           = 600,  // range: 250 .. 900
791         .get_pendown_state      = ts_get_pendown_state,
792         .init_platform_hw       = tsc2007_init,
793         .exit_platform_hw       = tsc2007_exit,
794 };
795
796 #endif
797
798
799 #ifdef CONFIG_BMP085
800
801 #define BMP085_EOC_IRQ_GPIO             113     /* BMP085 end of conversion GPIO */
802
803 struct bmp085_platform_data __initdata bmp085_info = {
804         .gpio = BMP085_EOC_IRQ_GPIO,
805 };
806
807 #endif
808
809 #ifdef CONFIG_LEDS_TCA6507
810
811 void tca6507_setup(unsigned gpio_base, unsigned ngpio)
812 {
813         omap_hsmmc_late_init(mmc);
814 }
815
816 static struct led_info tca6507_leds[] = {
817         [0] = { .name = "gta04:red:aux" },
818         [1] = { .name = "gta04:green:aux" },
819         [3] = { .name = "gta04:red:power", .default_trigger = "default-on" },
820         [4] = { .name = "gta04:green:power" },
821
822         [6] = { .name = "gta04:wlan:reset", .flags = TCA6507_MAKE_GPIO },
823 };
824 static struct tca6507_platform_data tca6507_info = {
825         .leds = {
826                 .num_leds = 7,
827                 .leds = tca6507_leds,
828         },
829         .gpio_base = GPIO_WIFI_RESET,
830         .setup = tca6507_setup,
831 };
832 #endif
833
834 #ifdef CONFIG_TOUCHSCREEN_TSC2007
835 static struct i2c_board_info __initdata tsc2007_boardinfo =
836 {
837         I2C_BOARD_INFO("tsc2007", 0x48),
838         .type           = "tsc2007",
839         .platform_data  = &tsc2007_info,
840 };
841 #endif
842 #ifdef CONFIG_BMP085
843 static struct i2c_board_info __initdata bmp085_boardinfo =
844 {
845         I2C_BOARD_INFO("bmp085", 0x77),
846         .type           = "bmp085",
847         .platform_data  = &bmp085_info,
848 };
849 #endif
850 static struct i2c_board_info __initdata gta04_i2c2_boardinfo[] = {
851 #ifdef CONFIG_LIS302
852 {
853         I2C_BOARD_INFO("lis302top", 0x1c),
854         .type           = "lis302",
855         .platform_data  = &lis302_info,
856         .irq            =  -EINVAL,
857 },
858 {
859         I2C_BOARD_INFO("lis302bottom", 0x1d),
860         .type           = "lis302",
861         .platform_data  = &lis302_info,
862         .irq            =  114,
863 },
864 #endif
865 #if defined(CONFIG_LEDS_TCA6507)
866 {
867         I2C_BOARD_INFO("tca6507", 0x45),
868         .type           = "tca6507",
869         .platform_data  = &tca6507_info,
870 },
871 #endif
872 #ifdef CONFIG_INPUT_BMA150
873 {
874         I2C_BOARD_INFO("bma150", 0x41),
875         .type           = "bma150",
876 },
877 #endif
878 #ifdef CONFIG_SENSORS_HMC5843
879 {
880         I2C_BOARD_INFO("hmc5843", 0x1e),
881         .type           = "hmc5883",
882 },
883 #endif
884
885         /* FIXME: add other drivers for BMA180, Si472x, Camera */
886 };
887
888 static int __init gta04_i2c_init(void)
889 {
890         omap3_pmic_get_config(&gta04_twldata,
891                               (TWL_COMMON_PDATA_USB |
892                                TWL_COMMON_PDATA_MADC |
893                                TWL_COMMON_PDATA_AUDIO),
894                               (TWL_COMMON_REGULATOR_VDAC |
895                                TWL_COMMON_REGULATOR_VPLL2));
896
897         omap_pmic_init(1, 2600, "twl4030", 7 + OMAP_INTC_START,
898                        &gta04_twldata);
899 #ifdef CONFIG_TOUCHSCREEN_TSC2007
900         tsc2007_boardinfo.irq = gpio_to_irq(TS_PENIRQ_GPIO);
901         i2c_register_board_info(2, &tsc2007_boardinfo, 1);
902 #endif
903 #ifdef CONFIG_BMP085
904         i2c_register_board_info(2, &bmp085_boardinfo, 1);
905 #endif
906         omap_register_i2c_bus(2, 400,  gta04_i2c2_boardinfo,
907                                 ARRAY_SIZE(gta04_i2c2_boardinfo));
908         /* Bus 3 is attached to the DVI port where devices like the pico DLP
909          * projector don't work reliably with 400kHz */
910         omap_register_i2c_bus(3, 100, NULL, 0);
911         return 0;
912 }
913
914 static struct gpio_keys_button gpio_buttons[] = {
915         {
916                 .code                   = KEY_PHONE,
917                 .gpio                   = AUX_BUTTON_GPIO,
918                 .desc                   = "AUX",
919                 .wakeup                 = 1,
920         },
921 };
922 static struct gpio_keys_button gpio_3G_buttons[] = {
923         {
924                 .code                   = KEY_UNKNOWN,
925                 .gpio                   = -1/*WO3G_GPIO*/,
926                 .desc                   = "Option",
927                 .wakeup                 = 1,
928         },
929 };
930
931 static struct gpio_keys_platform_data gpio_key_info = {
932         .buttons        = gpio_buttons,
933         .nbuttons       = ARRAY_SIZE(gpio_buttons),
934         .name           = "Phone button",
935 };
936 static struct gpio_keys_platform_data gpio_3G_info = {
937         .buttons        = gpio_3G_buttons,
938         .nbuttons       = ARRAY_SIZE(gpio_3G_buttons),
939         .name           = "3G Wakeup",
940 };
941
942 static struct platform_device keys_gpio = {
943         .name   = "gpio-keys",
944         .id     = 0,
945         .dev    = {
946                 .platform_data  = &gpio_key_info,
947         },
948 };
949 static struct platform_device keys_3G_gpio = {
950         .name   = "gpio-keys",
951         .id     = 1,
952         .dev    = {
953                 .platform_data  = &gpio_3G_info,
954         },
955 };
956
957 #if defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER)
958
959 static struct platform_device gta04_vaux1_virtual_regulator_device = {
960         .name           = "reg-virt-consumer",
961         .id                     = 1,
962         .dev            = {
963                 .platform_data  = "vaux1",
964         },
965 };
966
967 static struct platform_device gta04_vaux2_virtual_regulator_device = {
968         .name           = "reg-virt-consumer",
969         .id                     = 2,
970         .dev            = {
971                 .platform_data  = "vaux2",
972         },
973 };
974
975 static struct platform_device gta04_vaux3_virtual_regulator_device = {
976         .name           = "reg-virt-consumer",
977         .id                     = 3,
978         .dev            = {
979                 .platform_data  = "vaux3",
980         },
981 };
982 #endif
983
984
985 static struct platform_device madc_hwmon = {
986         .name   = "twl4030_madc_hwmon",
987         .id     = -1,
988 };
989
990 static struct platform_device *gta04_devices[] __initdata = {
991         &pwm_device,
992         &keys_gpio,
993         &keys_3G_gpio,
994         &gps_rfkill_device,
995         &bt_gpio_reg_device,
996         &gps_gpio_device,
997         &antenna_extcon_dev,
998 #if defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER)
999         &gta04_vaux1_virtual_regulator_device,
1000         &gta04_vaux2_virtual_regulator_device,
1001         &gta04_vaux3_virtual_regulator_device,
1002 #endif
1003 #if defined(CONFIG_SND_SOC_GTM601)
1004         &gta04_gtm601_codec_audio_device,
1005         &gta04_voice_device,
1006 #endif
1007 #if defined(CONFIG_SND_SOC_SI47XX)
1008         &gta04_si47xx_codec_audio_device,
1009 #endif
1010 #if defined(CONFIG_SND_SOC_W2CBW003)
1011         &gta04_w2cbw003_codec_audio_device,
1012         &gta04_headset_device,
1013 #endif
1014         &madc_hwmon,
1015 };
1016
1017 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
1018
1019         /* HSUSB0 - is not a EHCI port; TPS65950 configured by twl4030.c and musb driver */
1020         .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,    /* HSUSB1 - n/a */
1021         .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,                /* HSUSB2 - USB3322C <-> WWAN */
1022         .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,    /* HSUSB3 - n/a */
1023
1024         .phy_reset  = true,
1025         .reset_gpio_port[0]  = -EINVAL,
1026         .reset_gpio_port[1]  = 174,
1027         .reset_gpio_port[2]  = -EINVAL
1028 };
1029
1030 static struct omap_board_mux board_mux[] __initdata = {
1031         /* Enable GPT11_PWM_EVT instead of GPIO-57 */
1032         OMAP3_MUX(GPMC_NCS6, OMAP_MUX_MODE3),
1033
1034         { .reg_offset = OMAP_MUX_TERMINATOR },
1035 };
1036
1037 #define DEFAULT_RXDMA_POLLRATE          1       /* RX DMA polling rate (us) */
1038 #define DEFAULT_RXDMA_BUFSIZE           4096    /* RX DMA buffer size */
1039 #define DEFAULT_RXDMA_TIMEOUT           (3 * HZ)/* RX DMA timeout (jiffies) */
1040 #define DEFAULT_AUTOSUSPEND_DELAY       -1
1041
1042 static void gta04_serial_init(void)
1043 {
1044         struct omap_board_data bdata;
1045         struct omap_uart_port_info info = {
1046                 .dma_enabled    = false,
1047                 .dma_rx_buf_size = DEFAULT_RXDMA_BUFSIZE,
1048                 .dma_rx_poll_rate = DEFAULT_RXDMA_POLLRATE,
1049                 .dma_rx_timeout = DEFAULT_RXDMA_TIMEOUT,
1050                 .autosuspend_timeout = DEFAULT_AUTOSUSPEND_DELAY,
1051                 .DTR_present = 1,
1052         };
1053
1054         bdata.flags = 0;
1055         bdata.pads = NULL;
1056
1057         bdata.id = 0;
1058         info.DTR_gpio = GPIO_BT_REG;
1059         omap_serial_init_port(&bdata, &info);
1060
1061         /* GPS port.  modem lines are used for on/off management
1062          * and antenna detection.
1063          */
1064         bdata.id = 1;
1065         info.DTR_gpio = GPIO_GPS_CTRL;
1066         omap_serial_init_port(&bdata, &info);
1067
1068         bdata.id = 2;
1069         omap_serial_init_port(&bdata, NULL);
1070 }
1071
1072 static int __init gta04_opp_init(void)
1073 {
1074         int r = 0;
1075
1076         if (!machine_is_gta04())
1077                 return 0;
1078
1079         /* Initialize the omap3 opp table */
1080         r = omap3_opp_init();
1081         if (r < 0 && r != -EEXIST) {
1082                 pr_err("%s: opp default init failed\n", __func__);
1083                 return r;
1084         }
1085
1086         /* Custom OPP enabled for all xM versions */
1087         if (cpu_is_omap3630()) {
1088                 struct device *mpu_dev, *iva_dev;
1089
1090                 mpu_dev = get_cpu_device(0);
1091                 iva_dev = omap_device_get_by_hwmod_name("iva");
1092
1093                 if (!mpu_dev || !iva_dev) {
1094                         pr_err("%s: Aiee.. no mpu/dsp devices? %p %p\n",
1095                                 __func__, mpu_dev, iva_dev);
1096                         return -ENODEV;
1097                 }
1098                 /* Enable MPU 1GHz and lower opps */
1099                 r = opp_enable(mpu_dev,   800000000);
1100                 if (omap3_has_mpu_1ghz())
1101                         r |= opp_enable(mpu_dev, 1000000000);
1102                 /* TODO: MPU 1GHz needs SR and ABB */
1103
1104                 /* Enable IVA 800MHz and lower opps */
1105                 r |= opp_enable(iva_dev, 660000000);
1106                 if (omap3_has_mpu_1ghz())
1107                         r |= opp_enable(iva_dev, 800000000);
1108                 /* TODO: DSP 800MHz needs SR and ABB */
1109                 if (r) {
1110                         pr_err("%s: failed to enable higher opp %d\n",
1111                                 __func__, r);
1112                         /*
1113                          * Cleanup - disable the higher freqs - we dont care
1114                          * about the results
1115                          */
1116                         opp_disable(mpu_dev, 800000000);
1117                         opp_disable(mpu_dev, 1000000000);
1118                         opp_disable(iva_dev, 660000000);
1119                         opp_disable(iva_dev, 800000000);
1120                 }
1121         }
1122         return 0;
1123 }
1124 device_initcall(gta04_opp_init);
1125
1126 static void __init gta04_init(void)
1127 {
1128         printk("running gta04_init()\n");
1129         omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
1130         gta04_init_rev();
1131         gta04_i2c_init();
1132
1133         regulator_has_full_constraints/*_listed*/(/*all_reg_data*/);
1134         gta04_serial_init();
1135         omap_sdrc_init(mt46h32m32lf6_sdrc_params,
1136                        mt46h32m32lf6_sdrc_params);
1137
1138         omap_display_init(&gta04_dss_data);
1139
1140         omap_mux_init_gpio(WO3G_GPIO, OMAP_PIN_INPUT | OMAP_WAKEUP_EN);
1141         gpio_3G_buttons[0].gpio = WO3G_GPIO;
1142         platform_add_devices(gta04_devices,
1143                              ARRAY_SIZE(gta04_devices));
1144         omap_hsmmc_init(mmc);
1145
1146         printk(KERN_INFO "Revision GTA04A%d\n", gta04_version);
1147
1148         gpio_request(13, "IrDA_select");
1149         gpio_direction_output(13, true);
1150
1151         if(gta04_version >= 4) { /* feature of GTA04A4 */
1152                 omap_mux_init_gpio(186, OMAP_PIN_OUTPUT);    // this needs CONFIG_OMAP_MUX!
1153                 gpio_request(186, "WWAN_RESET");
1154                 gpio_direction_output(186, 0); // keep initial value
1155                 gpio_export(186, 0);    // no direction change
1156         }
1157
1158         // enable AUX out/Headset switch
1159         gpio_request(55, "AUX_OUT");
1160         gpio_direction_output(55, true);
1161         gpio_export(55, 0);     // no direction change
1162
1163         // disable Video out switch
1164         gpio_request(23, "VIDEO_OUT");
1165         gpio_direction_output(23, false);
1166         gpio_export(23, 0);     // no direction change
1167
1168         pwm_add_table(board_pwm_lookup, ARRAY_SIZE(board_pwm_lookup));
1169
1170         usb_musb_init(NULL);
1171         usbhs_init(&usbhs_bdata);
1172         omap_nand_flash_init(NAND_BUSWIDTH_16, gta04_nand_partitions,
1173                 ARRAY_SIZE(gta04_nand_partitions));
1174
1175         /* Ensure SDRC pins are mux'd for self-refresh */
1176         omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
1177         omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
1178
1179         /* TPS65950 mSecure initialization for write access enabling to RTC registers */
1180         omap_mux_init_gpio(TWL4030_MSECURE_GPIO, OMAP_PIN_OUTPUT);      // this needs CONFIG_OMAP_MUX!
1181         gpio_request(TWL4030_MSECURE_GPIO, "mSecure");
1182         gpio_direction_output(TWL4030_MSECURE_GPIO, true);
1183
1184         omap_mux_init_gpio(145, OMAP_PIN_OUTPUT);
1185         omap_mux_init_gpio(174, OMAP_PIN_OUTPUT);
1186         omap_mux_init_gpio(23, OMAP_PIN_OUTPUT); // enable TV out
1187         omap_mux_init_gpio(55, OMAP_PIN_OUTPUT);
1188         omap_mux_init_gpio(13, OMAP_PIN_OUTPUT);
1189
1190         printk("gta04_init done...\n");
1191 }
1192
1193 MACHINE_START(GTA04, "GTA04")
1194         /* Maintainer: Nikolaus Schaller - http://www.gta04.org */
1195         .atag_offset    =       0x100,
1196         .reserve        =       omap_reserve,
1197         .map_io         =       omap3_map_io,
1198         .init_irq       =       omap3_init_irq,
1199         .handle_irq     =       omap3_intc_handle_irq,
1200         .init_early     =       omap3_init_early,
1201         .init_machine   =       gta04_init,
1202         .init_late      =       omap3630_init_late,
1203         .timer          =       &omap3_secure_timer,
1204         .restart        =       omap_prcm_restart,
1205 MACHINE_END