kernel: check return code of nla_parse in pcomp_lzma on 2.6.31
[openwrt.git] / target / linux / s3c24xx / files-2.6.31 / arch / arm / mach-s3c2442 / mach-gta02.c
1 /*
2 * linux/arch/arm/mach-s3c2442/mach-gta02.c
3 *
4 * S3C2442 Machine Support for the Openmoko Freerunner (GTA02)
5 *
6 * Copyright (C) 2006-2007 by Openmoko, Inc.
7 * Author: Harald Welte <laforge@openmoko.org>
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 *
25 */
26
27 #include <linux/kernel.h>
28 #include <linux/types.h>
29 #include <linux/interrupt.h>
30 #include <linux/list.h>
31 #include <linux/delay.h>
32 #include <linux/timer.h>
33 #include <linux/init.h>
34 #include <linux/workqueue.h>
35 #include <linux/platform_device.h>
36 #include <linux/serial_core.h>
37 #include <linux/spi/spi.h>
38 #include <linux/spi/spi_gpio.h>
39 #include <linux/spi/spi_bitbang.h>
40 #include <linux/mmc/host.h>
41 #include <linux/leds.h>
42 #include <linux/gpio_keys.h>
43
44 #include <linux/mtd/mtd.h>
45 #include <linux/mtd/nand.h>
46 #include <linux/mtd/nand_ecc.h>
47 #include <linux/mtd/partitions.h>
48 #include <linux/mtd/physmap.h>
49
50 #include <linux/i2c.h>
51 #include <linux/backlight.h>
52 #include <linux/regulator/machine.h>
53
54 #include <linux/mfd/pcf50633/core.h>
55 #include <linux/mfd/pcf50633/mbc.h>
56 #include <linux/mfd/pcf50633/adc.h>
57 #include <linux/mfd/pcf50633/gpio.h>
58 #include <linux/mfd/pcf50633/pmic.h>
59
60 #include <linux/lis302dl.h>
61
62 #include <asm/mach/arch.h>
63 #include <asm/mach/map.h>
64 #include <asm/mach/irq.h>
65
66 #include <mach/hardware.h>
67 #include <mach/io.h>
68 #include <asm/irq.h>
69 #include <asm/mach-types.h>
70
71 #include <mach/regs-irq.h>
72 #include <mach/regs-gpio.h>
73 #include <mach/regs-gpioj.h>
74 #include <mach/fb.h>
75 #include <mach/mci.h>
76 #include <mach/ts.h>
77 #include <mach/spi.h>
78 #include <mach/spi-gpio.h>
79 #include <mach/regs-mem.h>
80 #include <plat/pwm.h>
81 #include <mach/cpu.h>
82
83 #include <mach/gta02.h>
84
85 #include <plat/regs-serial.h>
86 #include <plat/nand.h>
87 #include <plat/devs.h>
88 #include <plat/cpu.h>
89 #include <plat/pm.h>
90 #include <plat/udc.h>
91 #include <plat/iic.h>
92 #include <plat/usb-control.h>
93 #include <plat/regs-timer.h>
94 #include <plat/gpio-core.h>
95
96 #include <mach/gta02-pm-gsm.h>
97 #include <mach/gta02-pm-gps.h>
98 #include <mach/gta02-pm-wlan.h>
99
100 #include <linux/jbt6k74.h>
101 #include <linux/glamofb.h>
102 #include <linux/mfd/glamo.h>
103
104 #include <linux/hdq.h>
105 #include <linux/bq27000_battery.h>
106
107 #include <linux/touchscreen/ts_filter_chain.h>
108 #ifdef CONFIG_TOUCHSCREEN_FILTER
109 #include <linux/touchscreen/ts_filter_linear.h>
110 #include <linux/touchscreen/ts_filter_mean.h>
111 #include <linux/touchscreen/ts_filter_median.h>
112 #include <linux/touchscreen/ts_filter_group.h>
113 #endif
114
115 #include <asm/fiq.h>
116
117 #include <linux/gta02-vibrator.h>
118
119 /* -------------------------------------------------------------------------------
120 * GTA02 FIQ related
121 *
122 * Calls into vibrator and hdq and based on the return values
123 * determines if we the FIQ source be kept alive
124 */
125
126 #define DIVISOR_FROM_US(x) ((x) << 3)
127
128 #ifdef CONFIG_HDQ_GPIO_BITBANG
129 #define FIQ_DIVISOR_HDQ DIVISOR_FROM_US(HDQ_SAMPLE_PERIOD_US)
130 extern int hdq_fiq_handler(void);
131 #endif
132
133 #ifdef CONFIG_LEDS_GTA02_VIBRATOR
134 #define FIQ_DIVISOR_VIBRATOR DIVISOR_FROM_US(100)
135 extern int gta02_vibrator_fiq_handler(void);
136 #endif
137
138 #if defined(CONFIG_LEDS_GTA02_VIBRATOR) || defined(CONFIG_HDQ_GPIO_BITBANG)
139
140 /* Global data related to our fiq source */
141 static u32 gta02_fiq_ack_mask;
142 static struct s3c2410_pwm gta02_fiq_pwm_timer;
143 static u16 gta02_fiq_timer_index;
144 static int gta02_fiq_irq;
145
146 static void gta02_fiq_handler(void)
147 {
148 u16 divisor = 0xffff;
149
150 /* Vibrator servicing */
151
152 /* disable further timer interrupts if nobody has any work
153 * or adjust rate according to who still has work
154 *
155 * CAUTION: it means forground code must disable FIQ around
156 * its own non-atomic S3C2410_INTMSK changes... not common
157 * thankfully and taken care of by the fiq-basis patch
158 */
159
160 #ifdef CONFIG_LEDS_GTA02_VIBRATOR
161 if (gta02_vibrator_fiq_handler())
162 divisor = FIQ_DIVISOR_VIBRATOR;
163 #endif
164
165 #ifdef CONFIG_HDQ_GPIO_BITBANG
166 if (hdq_fiq_handler())
167 divisor = FIQ_DIVISOR_HDQ;
168 #endif
169
170 if (divisor == 0xffff) /* mask the fiq irq source */
171 __raw_writel(__raw_readl(S3C2410_INTMSK) | gta02_fiq_ack_mask,
172 S3C2410_INTMSK);
173 else /* still working, maybe at a different rate */
174 __raw_writel(divisor, S3C2410_TCNTB(gta02_fiq_timer_index));
175
176 __raw_writel(gta02_fiq_ack_mask, S3C2410_SRCPND);
177 }
178
179 static void gta02_fiq_kick(void)
180 {
181 unsigned long flags;
182 u32 tcon;
183
184 /* we have to take care about FIQ because this modification is
185 * non-atomic, FIQ could come in after the read and before the
186 * writeback and its changes to the register would be lost
187 * (platform INTMSK mod code is taken care of already)
188 */
189 local_save_flags(flags);
190 local_fiq_disable();
191 /* allow FIQs to resume */
192 __raw_writel(__raw_readl(S3C2410_INTMSK) &
193 ~(1 << (gta02_fiq_irq - S3C2410_CPUIRQ_OFFSET)),
194 S3C2410_INTMSK);
195 tcon = __raw_readl(S3C2410_TCON) & ~S3C2410_TCON_T3START;
196 /* fake the timer to a count of 1 */
197 __raw_writel(1, S3C2410_TCNTB(gta02_fiq_timer_index));
198 __raw_writel(tcon | S3C2410_TCON_T3MANUALUPD, S3C2410_TCON);
199 __raw_writel(tcon | S3C2410_TCON_T3MANUALUPD | S3C2410_TCON_T3START,
200 S3C2410_TCON);
201 __raw_writel(tcon | S3C2410_TCON_T3START, S3C2410_TCON);
202 local_irq_restore(flags);
203 }
204
205 static int gta02_fiq_enable(void)
206 {
207 int irq_index_fiq = IRQ_TIMER3;
208 int rc = 0;
209
210 local_fiq_disable();
211
212 gta02_fiq_irq = irq_index_fiq;
213 gta02_fiq_ack_mask = 1 << (irq_index_fiq - S3C2410_CPUIRQ_OFFSET);
214 gta02_fiq_timer_index = (irq_index_fiq - IRQ_TIMER0);
215
216 /* set up the timer to operate as a pwm device */
217
218 rc = s3c2410_pwm_init(&gta02_fiq_pwm_timer);
219 if (rc)
220 goto bail;
221
222 gta02_fiq_pwm_timer.timerid = PWM0 + gta02_fiq_timer_index;
223 gta02_fiq_pwm_timer.prescaler = (6 - 1) / 2;
224 gta02_fiq_pwm_timer.divider = S3C2410_TCFG1_MUX3_DIV2;
225 /* default rate == ~32us */
226 gta02_fiq_pwm_timer.counter = gta02_fiq_pwm_timer.comparer = 3000;
227
228 rc = s3c2410_pwm_enable(&gta02_fiq_pwm_timer);
229 if (rc)
230 goto bail;
231
232 s3c2410_pwm_start(&gta02_fiq_pwm_timer);
233
234 /* let our selected interrupt be a magic FIQ interrupt */
235 __raw_writel(gta02_fiq_ack_mask, S3C2410_INTMOD);
236
237 /* it's ready to go as soon as we unmask the source in S3C2410_INTMSK */
238 local_fiq_enable();
239
240 set_fiq_c_handler(gta02_fiq_handler);
241
242 return 0;
243
244 bail:
245 printk(KERN_ERR "Could not initialize FIQ for GTA02: %d\n", rc);
246
247 return rc;
248 }
249
250 static void gta02_fiq_disable(void)
251 {
252 __raw_writel(0, S3C2410_INTMOD);
253 local_fiq_disable();
254 gta02_fiq_irq = 0; /* no active source interrupt now either */
255
256 }
257 /* -------------------- /GTA02 FIQ Handler ------------------------------------- */
258
259 #endif
260
261 /*
262 * this gets called every 1ms when we paniced.
263 */
264
265 static long gta02_panic_blink(long count)
266 {
267 long delay = 0;
268 static long last_blink;
269 static char led;
270
271 if (count - last_blink < 100) /* 200ms period, fast blink */
272 return 0;
273
274 led ^= 1;
275 s3c2410_gpio_cfgpin(GTA02_GPIO_AUX_LED, S3C2410_GPIO_OUTPUT);
276 s3c2410_gpio_setpin(GTA02_GPIO_AUX_LED, led);
277
278 last_blink = count;
279 return delay;
280 }
281
282
283 /**
284 * returns PCB revision information in b9,b8 and b2,b1,b0
285 * Pre-GTA02 A6 returns 0x000
286 * GTA02 A6 returns 0x101
287 * ...
288 */
289
290 int gta02_get_pcb_revision(void)
291 {
292 int n;
293 int u = 0;
294 static unsigned long pinlist[] = {
295 GTA02_PCB_ID1_0,
296 GTA02_PCB_ID1_1,
297 GTA02_PCB_ID1_2,
298 GTA02_PCB_ID2_0,
299 GTA02_PCB_ID2_1,
300 };
301 static int pin_offset[] = {
302 0, 1, 2, 8, 9
303 };
304
305 for (n = 0 ; n < ARRAY_SIZE(pinlist); n++) {
306 /*
307 * set the PCB version GPIO to be pulled-down input
308 * force low briefly first
309 */
310 s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT);
311 s3c2410_gpio_setpin(pinlist[n], 0);
312 /* misnomer: it is a pullDOWN in 2442 */
313 s3c2410_gpio_pullup(pinlist[n], 1);
314 s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_INPUT);
315
316 udelay(10);
317
318 if (s3c2410_gpio_getpin(pinlist[n]))
319 u |= 1 << pin_offset[n];
320
321 /*
322 * when not being interrogated, all of the revision GPIO
323 * are set to output HIGH without pulldown so no current flows
324 * if they are NC or pulled up.
325 */
326 s3c2410_gpio_setpin(pinlist[n], 1);
327 s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT);
328 /* misnomer: it is a pullDOWN in 2442 */
329 s3c2410_gpio_pullup(pinlist[n], 0);
330 }
331
332 return u;
333 }
334
335 struct platform_device gta02_resume_reason_device = {
336 .name = "gta02-resume",
337 .num_resources = 0,
338 };
339
340 static struct map_desc gta02_iodesc[] __initdata = {
341 {
342 .virtual = 0xe0000000,
343 .pfn = __phys_to_pfn(S3C2410_CS3+0x01000000),
344 .length = SZ_1M,
345 .type = MT_DEVICE
346 },
347 };
348
349 #define UCON (S3C2410_UCON_DEFAULT | S3C2443_UCON_RXERR_IRQEN)
350 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
351 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
352
353 static struct s3c2410_uartcfg gta02_uartcfgs[] = {
354 [0] = {
355 .hwport = 0,
356 .flags = 0,
357 .ucon = UCON,
358 .ulcon = ULCON,
359 .ufcon = UFCON,
360 },
361 [1] = {
362 .hwport = 1,
363 .flags = 0,
364 .ucon = UCON,
365 .ulcon = ULCON,
366 .ufcon = UFCON,
367 },
368 [2] = {
369 .hwport = 2,
370 .flags = 0,
371 .ucon = UCON,
372 .ulcon = ULCON,
373 .ufcon = UFCON,
374 },
375
376 };
377
378 struct pcf50633 *gta02_pcf;
379
380 #ifdef CONFIG_CHARGER_PCF50633
381 #ifdef CONFIG_HDQ_GPIO_BITBANG
382 static int gta02_get_charger_online_status(void)
383 {
384 struct pcf50633 *pcf = gta02_pcf;
385
386 return pcf50633_mbc_get_status(pcf) & PCF50633_MBC_USB_ONLINE;
387 }
388
389 static int gta02_get_charger_active_status(void)
390 {
391 struct pcf50633 *pcf = gta02_pcf;
392
393 return pcf50633_mbc_get_status(pcf) & PCF50633_MBC_USB_ACTIVE;
394 }
395 #endif
396
397 #define ADC_NOM_CHG_DETECT_1A 6
398 #define ADC_NOM_CHG_DETECT_USB 43
399
400 static void
401 gta02_configure_pmu_for_charger(struct pcf50633 *pcf, void *unused, int res)
402 {
403 int ma;
404
405 /* Interpret charger type */
406 if (res < ((ADC_NOM_CHG_DETECT_USB + ADC_NOM_CHG_DETECT_1A) / 2)) {
407
408 /* Stop GPO driving out now that we have a IA charger */
409 pcf50633_gpio_set(pcf, PCF50633_GPO, 0);
410
411 ma = 1000;
412 } else
413 ma = 100;
414
415 pcf50633_mbc_usb_curlim_set(pcf, ma);
416 }
417
418 static struct delayed_work gta02_charger_work;
419 static int gta02_usb_vbus_draw;
420
421 static void gta02_charger_worker(struct work_struct *work)
422 {
423 struct pcf50633 *pcf = gta02_pcf;
424
425 if (gta02_usb_vbus_draw) {
426 pcf50633_mbc_usb_curlim_set(pcf, gta02_usb_vbus_draw);
427 return;
428 } else {
429 #ifdef CONFIG_PCF50633_ADC
430 pcf50633_adc_async_read(pcf,
431 PCF50633_ADCC1_MUX_ADCIN1,
432 PCF50633_ADCC1_AVERAGE_16,
433 gta02_configure_pmu_for_charger, NULL);
434 #else
435 /* If the PCF50633 ADC is disabled we fallback to a 100mA limit for safety. */
436 pcf50633_mbc_usb_curlim_set(pcf, 100);
437 #endif
438 return;
439 }
440 }
441
442 #define GTA02_CHARGER_CONFIGURE_TIMEOUT ((3000 * HZ) / 1000)
443 static void gta02_pmu_event_callback(struct pcf50633 *pcf, int irq)
444 {
445 if (irq == PCF50633_IRQ_USBINS) {
446 schedule_delayed_work(&gta02_charger_work,
447 GTA02_CHARGER_CONFIGURE_TIMEOUT);
448 return;
449 } else if (irq == PCF50633_IRQ_USBREM) {
450 cancel_delayed_work_sync(&gta02_charger_work);
451 gta02_usb_vbus_draw = 0;
452 }
453 }
454
455 static void gta02_pmu_force_shutdown(struct pcf50633 *pcf)
456 {
457 pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_OOCSHDWN,
458 PCF50633_OOCSHDWN_GOSTDBY, PCF50633_OOCSHDWN_GOSTDBY);
459 }
460
461
462 static void gta02_udc_vbus_draw(unsigned int ma)
463 {
464 if (!gta02_pcf)
465 return;
466
467 gta02_usb_vbus_draw = ma;
468
469 schedule_delayed_work(&gta02_charger_work,
470 GTA02_CHARGER_CONFIGURE_TIMEOUT);
471 }
472
473 static int gta02_udc_vbus_status(void)
474 {
475 struct pcf50633 *pcf = gta02_pcf;
476 if (!gta02_pcf)
477 return -ENODEV;
478
479 return !!(pcf50633_mbc_get_status(pcf) & PCF50633_MBC_USB_ONLINE);
480 }
481
482 #else /* !CONFIG_CHARGER_PCF50633 */
483 #ifdef CONFIG_HDQ_GPIO_BITBANG
484 #define gta02_get_charger_online_status NULL
485 #define gta02_get_charger_active_status NULL
486 #endif
487 #define gta02_pmu_event_callback NULL
488 #define gta02_udc_vbus_draw NULL
489 #define gta02_udc_vbus_status NULL
490 #endif
491
492
493 static struct platform_device gta02_pm_gps_dev = {
494 .name = "gta02-pm-gps",
495 };
496
497 static struct platform_device gta02_pm_bt_dev = {
498 .name = "gta02-pm-bt",
499 };
500
501 static struct platform_device gta02_pm_gsm_dev = {
502 .name = "gta02-pm-gsm",
503 };
504
505 static struct platform_device gta02_pm_wlan_dev = {
506 .name = "gta02-pm-wlan",
507 };
508
509 /* this is called when pc50633 is probed, unfortunately quite late in the
510 * day since it is an I2C bus device. Here we can belatedly define some
511 * platform devices with the advantage that we can mark the pcf50633 as the
512 * parent. This makes them get suspended and resumed with their parent
513 * the pcf50633 still around.
514 */
515
516 static struct platform_device gta02_glamo_dev;
517
518 static void gta02_pmu_attach_child_devices(struct pcf50633 *pcf);
519 static void gta02_pmu_regulator_registered(struct pcf50633 *pcf, int id);
520
521 static struct regulator_consumer_supply ldo4_consumers[] = {
522 {
523 .dev = &gta02_pm_bt_dev.dev,
524 .supply = "BT_3V2",
525 },
526 };
527
528 static struct regulator_consumer_supply ldo5_consumers[] = {
529 {
530 .dev = &gta02_pm_gps_dev.dev,
531 .supply = "RF_3V",
532 },
533 };
534
535 static struct regulator_consumer_supply hcldo_consumers[] = {
536 {
537 .dev = &gta02_glamo_dev.dev,
538 .supply = "SD_3V3",
539 },
540 };
541
542 static struct regulator_consumer_supply ldo6_consumers[] = {
543 { .supply = "VDC" },
544 { .supply = "VDDIO" },
545 };
546
547 static char *gta02_batteries[] = {
548 "battery",
549 };
550
551 #ifdef CONFIG_CHARGER_PCF50633
552
553 struct pcf50633_platform_data gta02_pcf_pdata = {
554 .resumers = {
555 [0] = PCF50633_INT1_USBINS |
556 PCF50633_INT1_USBREM |
557 PCF50633_INT1_ALARM,
558 [1] = PCF50633_INT2_ONKEYF,
559 [2] = PCF50633_INT3_ONKEY1S,
560 [3] = PCF50633_INT4_LOWSYS |
561 PCF50633_INT4_LOWBAT |
562 PCF50633_INT4_HIGHTMP,
563 },
564
565 .batteries = gta02_batteries,
566 .num_batteries = ARRAY_SIZE(gta02_batteries),
567 .charging_restart_interval = (900 * HZ),
568 .chg_ref_current_ma = 1000,
569
570 .reg_init_data = {
571 [PCF50633_REGULATOR_AUTO] = {
572 .constraints = {
573 .name = "IO_3V3",
574 .min_uV = 3300000,
575 .max_uV = 3300000,
576 .valid_modes_mask = REGULATOR_MODE_NORMAL,
577 .boot_on = 1,
578 .always_on = 1,
579 .apply_uV = 1,
580 .state_mem = {
581 .enabled = 1,
582 },
583 },
584 .num_consumer_supplies = 0,
585 },
586 [PCF50633_REGULATOR_DOWN1] = {
587 .constraints = {
588 .name = "CORE_1V3",
589 .min_uV = 1300000,
590 .max_uV = 1600000,
591 .valid_modes_mask = REGULATOR_MODE_NORMAL,
592 .boot_on = 1,
593 .always_on = 1,
594 .apply_uV = 1,
595 },
596 .num_consumer_supplies = 0,
597 },
598 [PCF50633_REGULATOR_DOWN2] = {
599 .constraints = {
600 .name = "IO_1V8",
601 .min_uV = 1800000,
602 .max_uV = 1800000,
603 .valid_modes_mask = REGULATOR_MODE_NORMAL,
604 .apply_uV = 1,
605 .boot_on = 1,
606 .always_on = 1,
607 .state_mem = {
608 .enabled = 1,
609 },
610 },
611 .num_consumer_supplies = 0,
612 },
613 [PCF50633_REGULATOR_HCLDO] = {
614 .constraints = {
615 .name = "SD_3V3",
616 .min_uV = 2000000,
617 .max_uV = 3300000,
618 .valid_modes_mask = REGULATOR_MODE_NORMAL,
619 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
620 .boot_on = 1,
621 },
622 .num_consumer_supplies = ARRAY_SIZE(hcldo_consumers),
623 .consumer_supplies = hcldo_consumers,
624 },
625 [PCF50633_REGULATOR_LDO1] = {
626 .constraints = {
627 .name = "GSENSOR_3V3",
628 .min_uV = 3300000,
629 .max_uV = 3300000,
630 .valid_modes_mask = REGULATOR_MODE_NORMAL,
631 .apply_uV = 1,
632 .always_on = 1,
633 },
634 .num_consumer_supplies = 0,
635 },
636 [PCF50633_REGULATOR_LDO2] = {
637 .constraints = {
638 .name = "CODEC_3V3",
639 .min_uV = 3300000,
640 .max_uV = 3300000,
641 .valid_modes_mask = REGULATOR_MODE_NORMAL,
642 .apply_uV = 1,
643 .always_on = 1,
644 },
645 .num_consumer_supplies = 0,
646 },
647 [PCF50633_REGULATOR_LDO3] = {
648 .constraints = {
649 .min_uV = 3000000,
650 .max_uV = 3000000,
651 .valid_modes_mask = REGULATOR_MODE_NORMAL,
652 .apply_uV = 1,
653 .always_on = 1,
654 },
655 .num_consumer_supplies = 0,
656 },
657 [PCF50633_REGULATOR_LDO4] = {
658 .constraints = {
659 .name = "BT_3V2",
660 .min_uV = 3200000,
661 .max_uV = 3200000,
662 .valid_modes_mask = REGULATOR_MODE_NORMAL,
663 .always_on = 1,
664 .apply_uV = 1,
665 },
666 .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
667 .consumer_supplies = ldo4_consumers,
668 },
669 [PCF50633_REGULATOR_LDO5] = {
670 .constraints = {
671 .name = "RF_3V",
672 .min_uV = 3000000,
673 .max_uV = 3000000,
674 .valid_modes_mask = REGULATOR_MODE_NORMAL,
675 .apply_uV = 1,
676 .state_mem = {
677 .enabled = 1,
678 },
679 },
680 .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
681 .consumer_supplies = ldo5_consumers,
682 },
683 [PCF50633_REGULATOR_LDO6] = {
684 .constraints = {
685 .name = "LCM_3V",
686 .min_uV = 3000000,
687 .max_uV = 3000000,
688 .always_on = 0,
689 .valid_modes_mask = REGULATOR_MODE_NORMAL,
690 .apply_uV = 1,
691 },
692 .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers),
693 .consumer_supplies = ldo6_consumers,
694 },
695 },
696 .probe_done = gta02_pmu_attach_child_devices,
697 .regulator_registered = gta02_pmu_regulator_registered,
698 .mbc_event_callback = gta02_pmu_event_callback,
699 .force_shutdown = gta02_pmu_force_shutdown,
700 };
701
702 #endif
703
704 #ifdef CONFIG_HDQ_GPIO_BITBANG
705 /* BQ27000 Battery */
706
707 struct bq27000_platform_data bq27000_pdata = {
708 .name = "battery",
709 .rsense_mohms = 20,
710 .hdq_read = hdq_read,
711 .hdq_write = hdq_write,
712 .hdq_initialized = hdq_initialized,
713 .get_charger_online_status = gta02_get_charger_online_status,
714 .get_charger_active_status = gta02_get_charger_active_status
715 };
716
717 struct platform_device bq27000_battery_device = {
718 .name = "bq27000-battery",
719 .dev = {
720 .platform_data = &bq27000_pdata,
721 },
722 };
723
724 /* HDQ */
725
726 static void gta02_hdq_attach_child_devices(struct device *parent_device)
727 {
728 switch (S3C_SYSTEM_REV_ATAG) {
729 case GTA02v5_SYSTEM_REV:
730 case GTA02v6_SYSTEM_REV:
731 bq27000_battery_device.dev.parent = parent_device;
732 platform_device_register(&bq27000_battery_device);
733 break;
734 default:
735 break;
736 }
737 }
738
739 static void gta02_hdq_gpio_direction_out(void)
740 {
741 s3c2410_gpio_cfgpin(GTA02v5_GPIO_HDQ, S3C2410_GPIO_OUTPUT);
742 }
743
744 static void gta02_hdq_gpio_direction_in(void)
745 {
746 s3c2410_gpio_cfgpin(GTA02v5_GPIO_HDQ, S3C2410_GPIO_INPUT);
747 }
748
749 static void gta02_hdq_gpio_set_value(int val)
750 {
751
752 s3c2410_gpio_setpin(GTA02v5_GPIO_HDQ, val);
753 }
754
755 static int gta02_hdq_gpio_get_value(void)
756 {
757 return s3c2410_gpio_getpin(GTA02v5_GPIO_HDQ);
758 }
759
760 static struct resource gta02_hdq_resources[] = {
761 [0] = {
762 .start = GTA02v5_GPIO_HDQ,
763 .end = GTA02v5_GPIO_HDQ,
764 },
765 };
766
767 struct hdq_platform_data gta02_hdq_platform_data = {
768 .attach_child_devices = gta02_hdq_attach_child_devices,
769 .gpio_dir_out = gta02_hdq_gpio_direction_out,
770 .gpio_dir_in = gta02_hdq_gpio_direction_in,
771 .gpio_set = gta02_hdq_gpio_set_value,
772 .gpio_get = gta02_hdq_gpio_get_value,
773
774 .enable_fiq = gta02_fiq_enable,
775 .disable_fiq = gta02_fiq_disable,
776 .kick_fiq = gta02_fiq_kick,
777
778 };
779
780 struct platform_device gta02_hdq_device = {
781 .name = "hdq",
782 .num_resources = 1,
783 .resource = gta02_hdq_resources,
784 .dev = {
785 .platform_data = &gta02_hdq_platform_data,
786 },
787 };
788 #endif
789
790
791 /* vibrator (child of FIQ) */
792
793 static struct resource gta02_vibrator_resources[] = {
794 [0] = {
795 .start = GTA02_GPIO_VIBRATOR_ON,
796 .end = GTA02_GPIO_VIBRATOR_ON,
797 },
798 };
799 struct gta02_vib_platform_data gta02_vib_pdata = {
800 .enable_fiq = gta02_fiq_enable,
801 .disable_fiq = gta02_fiq_disable,
802 .kick_fiq = gta02_fiq_kick,
803 };
804
805 static struct platform_device gta02_vibrator_dev = {
806 .name = "gta02-vibrator",
807 .num_resources = ARRAY_SIZE(gta02_vibrator_resources),
808 .resource = gta02_vibrator_resources,
809 .dev = {
810 .platform_data = &gta02_vib_pdata,
811 },
812 };
813
814 /* NOR Flash */
815
816 #define GTA02_FLASH_BASE S3C2410_CS3 /* GCS3 */
817 #define GTA02_FLASH_SIZE 0x200000 /* 2MBytes */
818
819 static struct physmap_flash_data gta02_nor_flash_data = {
820 .width = 2,
821 };
822
823 static struct resource gta02_nor_flash_resource = {
824 .start = GTA02_FLASH_BASE,
825 .end = GTA02_FLASH_BASE + GTA02_FLASH_SIZE - 1,
826 .flags = IORESOURCE_MEM,
827 };
828
829 static struct platform_device gta02_nor_flash = {
830 .name = "physmap-flash",
831 .id = 0,
832 .dev = {
833 .platform_data = &gta02_nor_flash_data,
834 },
835 .resource = &gta02_nor_flash_resource,
836 .num_resources = 1,
837 };
838
839
840 struct platform_device s3c24xx_pwm_device = {
841 .name = "s3c24xx_pwm",
842 .num_resources = 0,
843 };
844
845 static struct i2c_board_info gta02_i2c_devs[] __initdata = {
846 {
847 I2C_BOARD_INFO("pcf50633", 0x73),
848 .irq = GTA02_IRQ_PCF50633,
849 .platform_data = &gta02_pcf_pdata,
850 },
851 {
852 I2C_BOARD_INFO("wm8753", 0x1a),
853 },
854 };
855
856 static struct s3c2410_nand_set gta02_nand_sets[] = {
857 [0] = {
858 .name = "neo1973-nand",
859 .nr_chips = 1,
860 .flags = S3C2410_NAND_BBT,
861 },
862 };
863
864 /* choose a set of timings derived from S3C@2442B MCP54
865 * data sheet (K5D2G13ACM-D075 MCP Memory)
866 */
867
868 static struct s3c2410_platform_nand gta02_nand_info = {
869 .tacls = 0,
870 .twrph0 = 25,
871 .twrph1 = 15,
872 .nr_sets = ARRAY_SIZE(gta02_nand_sets),
873 .sets = gta02_nand_sets,
874 .software_ecc = 1,
875 };
876
877
878 static void gta02_s3c_mmc_set_power(unsigned char power_mode,
879 unsigned short vdd)
880 {
881 static int is_on = -1;
882 int on;
883
884 on = power_mode == MMC_POWER_ON || power_mode == MMC_POWER_UP;
885 if (is_on != on)
886 gta02_wlan_reset(!on);
887 is_on = on;
888 }
889
890
891 static struct s3c24xx_mci_pdata gta02_s3c_mmc_cfg = {
892 .set_power = gta02_s3c_mmc_set_power,
893 };
894
895 static void gta02_udc_command(enum s3c2410_udc_cmd_e cmd)
896 {
897 switch (cmd) {
898 case S3C2410_UDC_P_ENABLE:
899 printk(KERN_DEBUG "%s S3C2410_UDC_P_ENABLE\n", __func__);
900 s3c2410_gpio_setpin(GTA02_GPIO_USB_PULLUP, 1);
901 break;
902 case S3C2410_UDC_P_DISABLE:
903 printk(KERN_DEBUG "%s S3C2410_UDC_P_DISABLE\n", __func__);
904 s3c2410_gpio_setpin(GTA02_GPIO_USB_PULLUP, 0);
905 break;
906 case S3C2410_UDC_P_RESET:
907 printk(KERN_DEBUG "%s S3C2410_UDC_P_RESET\n", __func__);
908 /* FIXME! */
909 break;
910 default:
911 break;
912 }
913 }
914
915 /* get PMU to set USB current limit accordingly */
916
917 static struct s3c2410_udc_mach_info gta02_udc_cfg = {
918 .vbus_draw = gta02_udc_vbus_draw,
919 .udc_command = gta02_udc_command,
920 /* .get_vbus_status = gta02_udc_vbus_status,*/
921 };
922
923
924 /* Touchscreen configuration. */
925
926 #ifdef CONFIG_TOUCHSCREEN_FILTER
927 const static struct ts_filter_group_configuration gta02_ts_group = {
928 .length = 12,
929 .close_enough = 10,
930 .threshold = 6, /* At least half of the points in a group. */
931 .attempts = 10,
932 };
933
934 const static struct ts_filter_median_configuration gta02_ts_median = {
935 .extent = 20,
936 .decimation_below = 3,
937 .decimation_threshold = 8 * 3,
938 .decimation_above = 4,
939 };
940
941 const static struct ts_filter_mean_configuration gta02_ts_mean = {
942 .length = 4,
943 };
944
945 const static struct ts_filter_linear_configuration gta02_ts_linear = {
946 .constants = {1, 0, 0, 0, 1, 0, 1}, /* Don't modify coords. */
947 .coord0 = 0,
948 .coord1 = 1,
949 };
950 #endif
951
952 const static struct ts_filter_chain_configuration gta02_filter_configuration[] =
953 {
954 #ifdef CONFIG_TOUCHSCREEN_FILTER
955 {&ts_filter_group_api, &gta02_ts_group.config},
956 {&ts_filter_median_api, &gta02_ts_median.config},
957 {&ts_filter_mean_api, &gta02_ts_mean.config},
958 {&ts_filter_linear_api, &gta02_ts_linear.config},
959 #endif
960 {NULL, NULL},
961 };
962
963 const static struct s3c2410_ts_mach_info gta02_ts_cfg = {
964 .delay = 10000,
965 .presc = 0xff, /* slow as we can go */
966 .filter_config = gta02_filter_configuration,
967 };
968
969
970
971 static void gta02_bl_set_intensity(int intensity)
972 {
973 struct pcf50633 *pcf = gta02_pcf;
974 int old_intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT);
975 int ret;
976
977 /*
978 * One code path that leads here is from a kernel panic. Trying to turn
979 * the backlight on just gives us a nearly endless stream of complaints
980 * and accomplishes nothing. We can't win. Just give up.
981 *
982 * In the unlikely event that there's another path leading here while
983 * we're atomic, we print at least a warning.
984 */
985 if (in_atomic()) {
986 printk(KERN_ERR
987 "gta02_bl_set_intensity called while atomic\n");
988 return;
989 }
990
991 if (!(pcf50633_reg_read(pcf, PCF50633_REG_LEDENA) & 3))
992 old_intensity = 0;
993 else
994 old_intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT);
995
996 if (intensity == old_intensity)
997 return;
998
999 /* We can't do this anywhere else */
1000 pcf50633_reg_write(pcf, PCF50633_REG_LEDDIM, 5);
1001
1002 /*
1003 * The PCF50633 cannot handle LEDOUT = 0 (datasheet p60)
1004 * if seen, you have to re-enable the LED unit
1005 */
1006 if (!intensity || !old_intensity)
1007 pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0);
1008
1009 if (!intensity) /* illegal to set LEDOUT to 0 */
1010 ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f,
1011 2);
1012 else
1013 ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f,
1014 intensity);
1015
1016 if (intensity)
1017 pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 2);
1018
1019 }
1020
1021 static struct generic_bl_info gta02_bl_info = {
1022 .name = "gta02-bl",
1023 .max_intensity = 0x3f,
1024 .default_intensity = 0x3f,
1025 .set_bl_intensity = gta02_bl_set_intensity,
1026 };
1027
1028 static struct platform_device gta02_bl_dev = {
1029 .name = "generic-bl",
1030 .id = 1,
1031 .dev = {
1032 .platform_data = &gta02_bl_info,
1033 },
1034 };
1035
1036 /* SPI: LCM control interface attached to Glamo3362 */
1037
1038 static void gta02_jbt6k74_reset(int devidx, int level)
1039 {
1040 gpio_set_value(GTA02_GPIO_GLAMO(4), level);
1041 }
1042
1043 static int jbt_probed = 0;
1044
1045 static void gta02_jbt6k74_probe_completed(struct device *dev)
1046 {
1047 struct pcf50633 *pcf = gta02_pcf;
1048 if (!jbt_probed) {
1049 /* Switch on backlight. Qi does not do it for us */
1050 pcf50633_reg_write(pcf, PCF50633_REG_LEDOUT, 0x01);
1051 pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0x00);
1052 pcf50633_reg_write(pcf, PCF50633_REG_LEDDIM, 0x01);
1053 pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0x01);
1054
1055 gta02_bl_dev.dev.parent = dev;
1056 platform_device_register(&gta02_bl_dev);
1057 jbt_probed = 1;
1058 }
1059 }
1060
1061 const struct jbt6k74_platform_data jbt6k74_pdata = {
1062 .reset = gta02_jbt6k74_reset,
1063 .probe_completed = gta02_jbt6k74_probe_completed,
1064 };
1065
1066 /*----------- SPI: Accelerometers attached to SPI of s3c244x ----------------- */
1067
1068 void gta02_lis302dl_suspend_io(struct lis302dl_info *lis, int resume)
1069 {
1070 struct lis302dl_platform_data *pdata = lis->pdata;
1071
1072 if (!resume) {
1073 /*
1074 * we don't want to power them with a high level
1075 * because GSENSOR_3V3 is not up during suspend
1076 */
1077 s3c2410_gpio_setpin(pdata->pin_chip_select, 0);
1078 s3c2410_gpio_setpin(pdata->pin_clk, 0);
1079 s3c2410_gpio_setpin(pdata->pin_mosi, 0);
1080 /* misnomer: it is a pullDOWN in 2442 */
1081 s3c2410_gpio_pullup(pdata->pin_miso, 1);
1082 return;
1083 }
1084
1085 /* back to normal */
1086 s3c2410_gpio_setpin(pdata->pin_chip_select, 1);
1087 s3c2410_gpio_setpin(pdata->pin_clk, 1);
1088 /* misnomer: it is a pullDOWN in 2442 */
1089 s3c2410_gpio_pullup(pdata->pin_miso, 0);
1090
1091 s3c2410_gpio_cfgpin(pdata->pin_chip_select, S3C2410_GPIO_OUTPUT);
1092 s3c2410_gpio_cfgpin(pdata->pin_clk, S3C2410_GPIO_OUTPUT);
1093 s3c2410_gpio_cfgpin(pdata->pin_mosi, S3C2410_GPIO_OUTPUT);
1094 s3c2410_gpio_cfgpin(pdata->pin_miso, S3C2410_GPIO_INPUT);
1095
1096 }
1097
1098 struct lis302dl_platform_data lis302_pdata_top = {
1099 .name = "lis302-1 (top)",
1100 .pin_chip_select= S3C2410_GPD(12),
1101 .pin_clk = S3C2410_GPG(7),
1102 .pin_mosi = S3C2410_GPG(6),
1103 .pin_miso = S3C2410_GPG(5),
1104 .interrupt = GTA02_IRQ_GSENSOR_1,
1105 .open_drain = 1, /* altered at runtime by PCB rev */
1106 .lis302dl_suspend_io = gta02_lis302dl_suspend_io,
1107 };
1108
1109 struct lis302dl_platform_data lis302_pdata_bottom = {
1110 .name = "lis302-2 (bottom)",
1111 .pin_chip_select= S3C2410_GPD(13),
1112 .pin_clk = S3C2410_GPG(7),
1113 .pin_mosi = S3C2410_GPG(6),
1114 .pin_miso = S3C2410_GPG(5),
1115 .interrupt = GTA02_IRQ_GSENSOR_2,
1116 .open_drain = 1, /* altered at runtime by PCB rev */
1117 .lis302dl_suspend_io = gta02_lis302dl_suspend_io,
1118 };
1119
1120 static struct spi_board_info gta02_spi_board_info[] = {
1121 {
1122 .modalias = "jbt6k74",
1123 .platform_data = &jbt6k74_pdata,
1124 .controller_data = (void*)GTA02_GPIO_GLAMO(12),
1125 /* irq */
1126 .max_speed_hz = 100 * 1000,
1127 .bus_num = 2,
1128 .chip_select = 0
1129 },
1130 {
1131 .modalias = "lis302dl",
1132 /* platform_data */
1133 .platform_data = &lis302_pdata_top,
1134 /* controller_data */
1135 /* irq */
1136 .max_speed_hz = 100 * 1000,
1137 .bus_num = 3,
1138 .chip_select = 0,
1139 },
1140
1141 {
1142 .modalias = "lis302dl",
1143 /* platform_data */
1144 .platform_data = &lis302_pdata_bottom,
1145 /* controller_data */
1146 /* irq */
1147 .max_speed_hz = 100 * 1000,
1148 .bus_num = 3,
1149 .chip_select = 1,
1150 },
1151
1152 };
1153
1154 static void gta02_lis302_chip_select(struct s3c2410_spigpio_info *info, int csid, int cs)
1155 {
1156
1157 /*
1158 * Huh... "quirk"... CS on this device is not really "CS" like you can
1159 * expect.
1160 *
1161 * When it is 0 it selects SPI interface mode.
1162 * When it is 1 it selects I2C interface mode.
1163 *
1164 * Because we have 2 devices on one interface we have to make sure
1165 * that the "disabled" device (actually in I2C mode) don't think we're
1166 * talking to it.
1167 *
1168 * When we talk to the "enabled" device, the "disabled" device sees
1169 * the clocks as I2C clocks, creating havoc.
1170 *
1171 * I2C sees MOSI going LOW while CLK HIGH as a START action, thus we
1172 * must ensure this is never issued.
1173 */
1174
1175 int cs_gpio, other_cs_gpio;
1176
1177 cs_gpio = csid ? S3C2410_GPD(13) : S3C2410_GPD(12);
1178 other_cs_gpio = csid ? S3C2410_GPD(12) : S3C2410_GPD(13);
1179
1180
1181 if (cs == BITBANG_CS_ACTIVE) {
1182 s3c2410_gpio_setpin(other_cs_gpio, 1);
1183 s3c2410_gpio_setpin(cs_gpio, 1);
1184 s3c2410_gpio_setpin(info->pin_clk, 1);
1185 s3c2410_gpio_setpin(cs_gpio, 0);
1186 } else {
1187 s3c2410_gpio_setpin(cs_gpio, 1);
1188 s3c2410_gpio_setpin(other_cs_gpio, 1);
1189 }
1190 }
1191
1192 static struct s3c2410_spigpio_info gta02_spigpio_cfg = {
1193 .pin_clk = S3C2410_GPG(7),
1194 .pin_mosi = S3C2410_GPG(6),
1195 .pin_miso = S3C2410_GPG(5),
1196 .bus_num = 3,
1197 .num_chipselect = 2,
1198 .chip_select = gta02_lis302_chip_select,
1199 };
1200
1201 static struct platform_device gta02_spi_gpio_dev = {
1202 .name = "spi_s3c24xx_gpio",
1203 .dev = {
1204 .platform_data = &gta02_spigpio_cfg,
1205 },
1206 };
1207
1208 /*----------- / SPI: Accelerometers attached to SPI of s3c244x ----------------- */
1209
1210 static struct gpio_led gta02_gpio_leds[] = {
1211 {
1212 .name = "gta02-power:orange",
1213 .gpio = GTA02_GPIO_PWR_LED1,
1214 }, {
1215 .name = "gta02-power:blue",
1216 .gpio = GTA02_GPIO_PWR_LED2,
1217 }, {
1218 .name = "gta02-aux:red",
1219 .gpio = GTA02_GPIO_AUX_LED,
1220 },
1221 };
1222
1223 static struct gpio_led_platform_data gta02_gpio_leds_pdata = {
1224 .leds = gta02_gpio_leds,
1225 .num_leds = ARRAY_SIZE(gta02_gpio_leds),
1226 };
1227
1228 struct platform_device gta02_led_dev = {
1229 .name = "leds-gpio",
1230 .id = -1,
1231 .dev = {
1232 .platform_data = &gta02_gpio_leds_pdata,
1233 },
1234 };
1235
1236 static struct gpio_keys_button gta02_buttons[] = {
1237 {
1238 .gpio = GTA02_GPIO_AUX_KEY,
1239 .code = KEY_PHONE,
1240 .desc = "Aux",
1241 .type = EV_KEY,
1242 .debounce_interval = 100,
1243 },
1244 {
1245 .gpio = GTA02_GPIO_HOLD_KEY,
1246 .code = KEY_PAUSE,
1247 .desc = "Hold",
1248 .type = EV_KEY,
1249 .debounce_interval = 100,
1250 },
1251 };
1252
1253 static struct gpio_keys_platform_data gta02_buttons_pdata = {
1254 .buttons = gta02_buttons,
1255 .nbuttons = ARRAY_SIZE(gta02_buttons),
1256 };
1257
1258 static struct platform_device gta02_button_dev = {
1259 .name = "gpio-keys",
1260 .id = -1,
1261 .dev = {
1262 .platform_data = &gta02_buttons_pdata,
1263 },
1264 };
1265
1266 static struct platform_device gta02_pm_usbhost_dev = {
1267 .name = "gta02-pm-host",
1268 };
1269
1270 /* USB */
1271 static struct s3c2410_hcd_info gta02_usb_info = {
1272 .port[0] = {
1273 .flags = S3C_HCDFLG_USED,
1274 },
1275 .port[1] = {
1276 .flags = 0,
1277 },
1278 };
1279
1280 /*
1281 * we crank down SD Card clock dynamically when GPS is powered
1282 */
1283
1284 static int gta02_glamo_mci_use_slow(void)
1285 {
1286 return gta02_pm_gps_is_on();
1287 }
1288
1289 static void gta02_glamo_external_reset(int level)
1290 {
1291 s3c2410_gpio_setpin(GTA02_GPIO_3D_RESET, level);
1292 s3c2410_gpio_cfgpin(GTA02_GPIO_3D_RESET, S3C2410_GPIO_OUTPUT);
1293 }
1294
1295 /*
1296 static struct fb_videomode gta02_glamo_modes[] = {
1297 {
1298 .name = "480x640",
1299 .xres = 480,
1300 .yres = 640,
1301 .pixclock = 40816,
1302 .left_margin = 8,
1303 .right_margin = 63,
1304 .upper_margin = 2,
1305 .lower_margin = 4,
1306 .hsync_len = 8,
1307 .vsync_len = 2,
1308 .vmode = FB_VMODE_NONINTERLACED,
1309 }, {
1310 .name = "240x320",
1311 .xres = 240,
1312 .yres = 320,
1313 .pixclock = 40816,
1314 .left_margin = 8,
1315 .right_margin = 88,
1316 .upper_margin = 2,
1317 .lower_margin = 2,
1318 .hsync_len = 8,
1319 .vsync_len = 2,
1320 .vmode = FB_VMODE_NONINTERLACED,
1321 }
1322 };*/
1323
1324 struct spi_gpio_platform_data spigpio_platform_data = {
1325 .sck = GTA02_GPIO_GLAMO(10),
1326 .mosi = GTA02_GPIO_GLAMO(11),
1327 .miso = GTA02_GPIO_GLAMO(5),
1328 .num_chipselect = 1,
1329 };
1330
1331 static struct platform_device spigpio_device = {
1332 .name = "spi_gpio",
1333 .id = 2,
1334 .dev = {
1335 .platform_data = &spigpio_platform_data,
1336 },
1337 };
1338
1339 static void gta02_glamo_registered(struct device *dev)
1340 {
1341 if (gpio_request(GTA02_GPIO_GLAMO(4), "jbt6k74 reset"))
1342 printk("gta02: Failed to request jbt6k74 reset pin\n");
1343 if (gpio_direction_output(GTA02_GPIO_GLAMO(4), 1))
1344 printk("gta02: Failed to configure jbt6k74 reset pin\n");
1345 spigpio_device.dev.parent = dev;
1346 platform_device_register(&spigpio_device);
1347 }
1348
1349 static struct fb_videomode gta02_glamo_modes[] = {
1350 {
1351 .name = "480x640",
1352 .xres = 480,
1353 .yres = 640,
1354 .pixclock = 40816,
1355 .left_margin = 8,
1356 .right_margin = 16,
1357 .upper_margin = 2,
1358 .lower_margin = 16,
1359 .hsync_len = 8,
1360 .vsync_len = 2,
1361 .vmode = FB_VMODE_NONINTERLACED,
1362 }, {
1363 .name = "240x320",
1364 .xres = 240,
1365 .yres = 320,
1366 .pixclock = 40816,
1367 .left_margin = 8,
1368 .right_margin = 16,
1369 .upper_margin = 2,
1370 .lower_margin = 16,
1371 .hsync_len = 8,
1372 .vsync_len = 2,
1373 .vmode = FB_VMODE_NONINTERLACED,
1374 }
1375 };
1376
1377
1378 static struct glamo_fb_platform_data gta02_glamo_fb_pdata = {
1379 .width = 43,
1380 .height = 58,
1381
1382 .num_modes = ARRAY_SIZE(gta02_glamo_modes),
1383 .modes = gta02_glamo_modes,
1384 };
1385
1386 static struct glamo_mmc_platform_data gta02_glamo_mmc_pdata = {
1387 .glamo_mmc_use_slow = gta02_glamo_mci_use_slow,
1388 };
1389
1390 static struct glamo_platform_data gta02_glamo_pdata = {
1391 .fb_data = &gta02_glamo_fb_pdata,
1392 .mmc_data = &gta02_glamo_mmc_pdata,
1393 .gpio_base = GTA02_GPIO_GLAMO_BASE,
1394
1395 .osci_clock_rate = 32768,
1396
1397 .glamo_external_reset = gta02_glamo_external_reset,
1398 .registered = gta02_glamo_registered,
1399 };
1400
1401 static struct resource gta02_glamo_resources[] = {
1402 [0] = {
1403 .start = S3C2410_CS1,
1404 .end = S3C2410_CS1 + 0x1000000 - 1,
1405 .flags = IORESOURCE_MEM,
1406 },
1407 [1] = {
1408 .start = GTA02_IRQ_3D,
1409 .end = GTA02_IRQ_3D,
1410 .flags = IORESOURCE_IRQ,
1411 },
1412 [2] = {
1413 .start = GTA02_GPIO_3D_RESET,
1414 .end = GTA02_GPIO_3D_RESET,
1415 },
1416 };
1417
1418 static struct platform_device gta02_glamo_dev = {
1419 .name = "glamo3362",
1420 .num_resources = ARRAY_SIZE(gta02_glamo_resources),
1421 .resource = gta02_glamo_resources,
1422 .dev = {
1423 .platform_data = &gta02_glamo_pdata,
1424 },
1425 };
1426
1427 static void __init gta02_map_io(void)
1428 {
1429 s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc));
1430 s3c24xx_init_clocks(12000000);
1431 s3c24xx_init_uarts(gta02_uartcfgs, ARRAY_SIZE(gta02_uartcfgs));
1432 }
1433
1434 static irqreturn_t gta02_modem_irq(int irq, void *param)
1435 {
1436 /* printk(KERN_DEBUG "modem wakeup interrupt\n");*/
1437 gta_gsm_interrupts++;
1438 return IRQ_HANDLED;
1439 }
1440
1441 static irqreturn_t ar6000_wow_irq(int irq, void *param)
1442 {
1443 /* printk(KERN_DEBUG "ar6000_wow interrupt\n");*/
1444 return IRQ_HANDLED;
1445 }
1446
1447 /*
1448 * hardware_ecc=1|0
1449 */
1450 static char hardware_ecc_str[4] __initdata = "";
1451
1452 static int __init hardware_ecc_setup(char *str)
1453 {
1454 if (str)
1455 strlcpy(hardware_ecc_str, str, sizeof(hardware_ecc_str));
1456 return 1;
1457 }
1458
1459 __setup("hardware_ecc=", hardware_ecc_setup);
1460
1461 /* these are the guys that don't need to be children of PMU */
1462
1463 static struct platform_device *gta02_devices[] __initdata = {
1464 &s3c_device_i2c0,
1465 &s3c_device_usb,
1466 &s3c_device_wdt,
1467 &s3c_device_sdi,
1468 &s3c_device_usbgadget,
1469 &s3c_device_nand,
1470 &gta02_nor_flash,
1471
1472 &s3c24xx_pwm_device,
1473 &gta02_led_dev,
1474 &gta02_pm_wlan_dev, /* not dependent on PMU */
1475 &s3c_device_iis,
1476 };
1477
1478 /* these guys DO need to be children of PMU */
1479
1480 static struct platform_device *gta02_devices_pmu_children[] = {
1481 &s3c_device_ts, /* input 1 */
1482 &gta02_pm_gsm_dev,
1483 &gta02_pm_usbhost_dev,
1484 &gta02_spi_gpio_dev, /* input 2 and 3 */
1485 &gta02_button_dev, /* input 4 */
1486 &gta02_resume_reason_device,
1487 };
1488
1489 static void gta02_register_glamo(void)
1490 {
1491 platform_device_register(&gta02_glamo_dev);
1492 }
1493
1494 static void gta02_pmu_regulator_registered(struct pcf50633 *pcf, int id)
1495 {
1496 struct platform_device *regulator, *pdev;
1497
1498 gta02_pcf = pcf;
1499
1500 regulator = pcf->regulator_pdev[id];
1501
1502 switch(id) {
1503 case PCF50633_REGULATOR_LDO4:
1504 pdev = &gta02_pm_bt_dev;
1505 break;
1506 case PCF50633_REGULATOR_LDO5:
1507 pdev = &gta02_pm_gps_dev;
1508 break;
1509 case PCF50633_REGULATOR_HCLDO:
1510 gta02_register_glamo();
1511 return;
1512 default:
1513 return;
1514 }
1515
1516 pdev->dev.parent = &regulator->dev;
1517 platform_device_register(pdev);
1518 }
1519
1520 /* this is called when pc50633 is probed, unfortunately quite late in the
1521 * day since it is an I2C bus device. Here we can belatedly define some
1522 * platform devices with the advantage that we can mark the pcf50633 as the
1523 * parent. This makes them get suspended and resumed with their parent
1524 * the pcf50633 still around.
1525 */
1526
1527 static void gta02_pmu_attach_child_devices(struct pcf50633 *pcf)
1528 {
1529 int n;
1530
1531 for (n = 0; n < ARRAY_SIZE(gta02_devices_pmu_children); n++)
1532 gta02_devices_pmu_children[n]->dev.parent = pcf->dev;
1533
1534 platform_add_devices(gta02_devices_pmu_children,
1535 ARRAY_SIZE(gta02_devices_pmu_children));
1536
1537 regulator_has_full_constraints();
1538 }
1539
1540 static void gta02_poweroff(void)
1541 {
1542 pcf50633_reg_set_bit_mask(gta02_pcf, PCF50633_REG_OOCSHDWN,
1543 PCF50633_OOCSHDWN_GOSTDBY, PCF50633_OOCSHDWN_GOSTDBY);
1544 }
1545
1546
1547 /* On hardware rev 5 and earlier the leds are missing a resistor and reading
1548 * from their gpio pins will always return 0, so we have to shadow the
1549 * led states software */
1550 static unsigned long gpb_shadow;
1551 extern struct s3c_gpio_chip s3c24xx_gpios[];
1552
1553 static void gta02_gpb_set(struct gpio_chip *chip,
1554 unsigned offset, int value)
1555 {
1556 void __iomem *base = S3C24XX_GPIO_BASE(S3C2410_GPB(0));
1557 unsigned long flags;
1558 unsigned long dat;
1559
1560 local_irq_save(flags);
1561
1562 dat = __raw_readl(base + 0x04) | gpb_shadow;
1563 dat &= ~(1 << offset);
1564 gpb_shadow &= ~(1 << offset);
1565 if (value) {
1566 dat |= 1 << offset;
1567 switch (offset) {
1568 case 0 ... 2:
1569 gpb_shadow |= 1 << offset;
1570 break;
1571 default:
1572 break;
1573 }
1574 }
1575 __raw_writel(dat, base + 0x04);
1576
1577 local_irq_restore(flags);
1578 }
1579
1580 static int gta02_gpb_get(struct gpio_chip *chip, unsigned offset)
1581 {
1582 void __iomem *base = S3C24XX_GPIO_BASE(S3C2410_GPB(0));
1583 unsigned long val;
1584
1585 val = __raw_readl(base + 0x04) | gpb_shadow;
1586 val >>= offset;
1587 val &= 1;
1588
1589 return val;
1590 }
1591
1592 static void gta02_hijack_gpb(void) {
1593 s3c24xx_gpios[1].chip.set = gta02_gpb_set;
1594 s3c24xx_gpios[1].chip.get = gta02_gpb_get;
1595 }
1596
1597 static void __init gta02_machine_init(void)
1598 {
1599 int rc;
1600
1601 /* set the panic callback to make AUX blink fast */
1602 panic_blink = gta02_panic_blink;
1603
1604 switch (S3C_SYSTEM_REV_ATAG) {
1605 case GTA02v6_SYSTEM_REV:
1606 /* we need push-pull interrupt from motion sensors */
1607 lis302_pdata_top.open_drain = 0;
1608 lis302_pdata_bottom.open_drain = 0;
1609 break;
1610 default:
1611 break;
1612 }
1613 if (S3C_SYSTEM_REV_ATAG <= GTA02v5_SYSTEM_REV)
1614 gta02_hijack_gpb();
1615
1616 #ifdef CONFIG_CHARGER_PCF50633
1617 INIT_DELAYED_WORK(&gta02_charger_work, gta02_charger_worker);
1618 #endif
1619
1620 /* Glamo chip select optimization */
1621 /* *((u32 *)(S3C2410_MEMREG(((1 + 1) << 2)))) = 0x1280; */
1622
1623 /* do not force soft ecc if we are asked to use hardware_ecc */
1624 if (hardware_ecc_str[0] == '1')
1625 gta02_nand_info.software_ecc = 0;
1626
1627 s3c_device_usb.dev.platform_data = &gta02_usb_info;
1628 s3c_device_nand.dev.platform_data = &gta02_nand_info;
1629 s3c_device_sdi.dev.platform_data = &gta02_s3c_mmc_cfg;
1630
1631 /* acc sensor chip selects */
1632 s3c2410_gpio_setpin(S3C2410_GPD(12), 1);
1633 s3c2410_gpio_cfgpin(S3C2410_GPD(12), S3C2410_GPIO_OUTPUT);
1634 s3c2410_gpio_setpin(S3C2410_GPD(13), 1);
1635 s3c2410_gpio_cfgpin(S3C2410_GPD(13), S3C2410_GPIO_OUTPUT);
1636
1637
1638 s3c24xx_udc_set_platdata(&gta02_udc_cfg);
1639 s3c_i2c0_set_platdata(NULL);
1640 set_s3c2410ts_info(&gta02_ts_cfg);
1641
1642 i2c_register_board_info(0, gta02_i2c_devs, ARRAY_SIZE(gta02_i2c_devs));
1643 spi_register_board_info(gta02_spi_board_info,
1644 ARRAY_SIZE(gta02_spi_board_info));
1645
1646 platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices));
1647
1648 s3c_pm_init();
1649
1650 /* Make sure the modem can wake us up */
1651 set_irq_type(GTA02_IRQ_MODEM, IRQ_TYPE_EDGE_RISING);
1652 rc = request_irq(GTA02_IRQ_MODEM, gta02_modem_irq, IRQF_DISABLED,
1653 "modem", NULL);
1654 if (rc < 0)
1655 printk(KERN_ERR "GTA02: can't request GSM modem wakeup IRQ\n");
1656 enable_irq_wake(GTA02_IRQ_MODEM);
1657
1658 /* Make sure the wifi module can wake us up*/
1659 set_irq_type(GTA02_IRQ_WLAN_GPIO1, IRQ_TYPE_EDGE_RISING);
1660 rc = request_irq(GTA02_IRQ_WLAN_GPIO1, ar6000_wow_irq, IRQF_DISABLED,
1661 "ar6000", NULL);
1662
1663 if (rc < 0)
1664 printk(KERN_ERR "GTA02: can't request ar6k wakeup IRQ\n");
1665 enable_irq_wake(GTA02_IRQ_WLAN_GPIO1);
1666
1667 pm_power_off = gta02_poweroff;
1668
1669 /* Register the HDQ and vibrator as children of pwm device */
1670 #ifdef CONFIG_HDQ_GPIO_BITBANG
1671 gta02_hdq_device.dev.parent = &s3c24xx_pwm_device.dev;
1672 platform_device_register(&gta02_hdq_device);
1673 #endif
1674 gta02_vibrator_dev.dev.parent = &s3c24xx_pwm_device.dev;
1675 platform_device_register(&gta02_vibrator_dev);
1676 }
1677
1678 MACHINE_START(NEO1973_GTA02, "GTA02")
1679 .phys_io = S3C2410_PA_UART,
1680 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
1681 .boot_params = S3C2410_SDRAM_PA + 0x100,
1682 .map_io = gta02_map_io,
1683 .init_irq = s3c24xx_init_irq,
1684 .init_machine = gta02_machine_init,
1685 .timer = &s3c24xx_timer,
1686 MACHINE_END
This page took 0.138328 seconds and 5 git commands to generate.