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