gta0x-add-minimal-GSM-flowcontrol.patch
[linux-2.6/openmoko-kernel/knife-kernel.git] / arch / arm / mach-s3c2440 / mach-gta02.c
blob1d7d262f839ab8e334a3d9ba38def71ea7777423
1 /*
2 * linux/arch/arm/mach-s3c2440/mach-gta02.c
4 * S3C2440 Machine Support for the FIC GTA02 (Neo1973)
6 * Copyright (C) 2006-2007 by Openmoko, Inc.
7 * Author: Harald Welte <laforge@openmoko.org>
8 * All rights reserved.
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.
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.
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
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/glamo.h>
39 #include <linux/spi/spi_bitbang.h>
40 #include <linux/mmc/host.h>
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>
48 #include <linux/pcf50633.h>
49 #include <linux/lis302dl.h>
51 #include <asm/mach/arch.h>
52 #include <asm/mach/map.h>
53 #include <asm/mach/irq.h>
55 #include <asm/hardware.h>
56 #include <asm/io.h>
57 #include <asm/irq.h>
58 #include <asm/mach-types.h>
60 #include <asm/arch-s3c2410/regs-irq.h>
61 #include <asm/arch/regs-gpio.h>
62 #include <asm/arch/regs-gpioj.h>
63 #include <asm/arch/fb.h>
64 #include <asm/arch/mci.h>
65 #include <asm/arch/ts.h>
66 #include <asm/arch/spi.h>
67 #include <asm/arch/spi-gpio.h>
68 #include <asm/arch/usb-control.h>
70 #include <asm/arch/gta02.h>
72 #include <asm/plat-s3c/regs-serial.h>
73 #include <asm/plat-s3c/nand.h>
74 #include <asm/plat-s3c24xx/devs.h>
75 #include <asm/plat-s3c24xx/cpu.h>
76 #include <asm/plat-s3c24xx/pm.h>
77 #include <asm/plat-s3c24xx/udc.h>
78 #include <asm/plat-s3c24xx/neo1973.h>
79 #include <linux/jbt6k74.h>
81 #include <linux/glamofb.h>
83 #include <asm/arch/fiq_ipc_gta02.h>
84 #include "fiq_c_isr.h"
85 #include <linux/gta02_hdq.h>
86 #include <linux/bq27000_battery.h>
88 #include "../plat-s3c24xx/neo1973_pm_gps.h"
90 /* arbitrates which sensor IRQ owns the shared SPI bus */
91 static spinlock_t motion_irq_lock;
93 /* the dependency of jbt / LCM on pcf50633 resume */
94 struct resume_dependency resume_dep_jbt_pcf;
95 /* the dependency of jbt / LCM on glamo resume */
96 struct resume_dependency resume_dep_jbt_glamo;
97 /* the dependency of Glamo MCI on pcf50633 resume (has to power SD slot) */
98 struct resume_dependency resume_dep_glamo_mci_pcf;
101 static int gta02_charger_online_status;
102 static int gta02_charger_active_status;
104 /* define FIQ IPC struct */
106 * contains stuff FIQ ISR modifies and normal kernel code can see and use
107 * this is defined in <asm/arch/fiq_ipc_gta02.h>, you should customize
108 * the definition in there and include the same definition in your kernel
109 * module that wants to interoperate with your FIQ code.
111 struct fiq_ipc fiq_ipc;
112 EXPORT_SYMBOL(fiq_ipc);
114 #define DIVISOR_FROM_US(x) ((x) << 1)
116 #define FIQ_DIVISOR_VIBRATOR DIVISOR_FROM_US(100)
118 #ifdef CONFIG_GTA02_HDQ
119 /* HDQ specific */
120 #define HDQ_SAMPLE_PERIOD_US 20
121 /* private HDQ FSM state -- all other info interesting for caller in fiq_ipc */
122 static enum hdq_bitbang_states hdq_state;
123 static u8 hdq_ctr;
124 static u8 hdq_ctr2;
125 static u8 hdq_bit;
126 static u8 hdq_shifter;
127 static u8 hdq_tx_data_done;
129 #define FIQ_DIVISOR_HDQ DIVISOR_FROM_US(HDQ_SAMPLE_PERIOD_US)
130 #endif
131 /* define FIQ ISR */
133 FIQ_HANDLER_START()
134 /* define your locals here -- no initializers though */
135 u16 divisor;
136 FIQ_HANDLER_ENTRY(256, 512)
137 /* Your ISR here :-) */
138 divisor = 0xffff;
140 /* Vibrator servicing */
142 if (fiq_ipc.vib_pwm_latched || fiq_ipc.vib_pwm) { /* not idle */
143 if (((u8)_fiq_count_fiqs) == fiq_ipc.vib_pwm_latched)
144 neo1973_gpb_setpin(fiq_ipc.vib_gpio_pin, 0);
145 if (((u8)_fiq_count_fiqs) == 0) {
146 fiq_ipc.vib_pwm_latched = fiq_ipc.vib_pwm;
147 if (fiq_ipc.vib_pwm_latched)
148 neo1973_gpb_setpin(fiq_ipc.vib_gpio_pin, 1);
150 divisor = FIQ_DIVISOR_VIBRATOR;
153 #ifdef CONFIG_GTA02_HDQ
154 /* HDQ servicing */
156 switch (hdq_state) {
157 case HDQB_IDLE:
158 if (fiq_ipc.hdq_request_ctr == fiq_ipc.hdq_transaction_ctr)
159 break;
160 hdq_ctr = 210 / HDQ_SAMPLE_PERIOD_US;
161 s3c2410_gpio_setpin(fiq_ipc.hdq_gpio_pin, 0);
162 s3c2410_gpio_cfgpin(fiq_ipc.hdq_gpio_pin, S3C2410_GPIO_OUTPUT);
163 hdq_tx_data_done = 0;
164 hdq_state = HDQB_TX_BREAK;
165 break;
167 case HDQB_TX_BREAK: /* issue low for > 190us */
168 if (--hdq_ctr == 0) {
169 hdq_ctr = 60 / HDQ_SAMPLE_PERIOD_US;
170 hdq_state = HDQB_TX_BREAK_RECOVERY;
171 s3c2410_gpio_setpin(fiq_ipc.hdq_gpio_pin, 1);
173 break;
175 case HDQB_TX_BREAK_RECOVERY: /* issue low for > 40us */
176 if (--hdq_ctr)
177 break;
178 hdq_shifter = fiq_ipc.hdq_ads;
179 hdq_bit = 8; /* 8 bits of ads / rw */
180 hdq_tx_data_done = 0; /* doing ads */
181 /* fallthru on last one */
182 case HDQB_ADS_CALC:
183 if (hdq_shifter & 1)
184 hdq_ctr = 50 / HDQ_SAMPLE_PERIOD_US;
185 else
186 hdq_ctr = 120 / HDQ_SAMPLE_PERIOD_US;
187 /* carefully precompute the other phase length */
188 hdq_ctr2 = (210 - (hdq_ctr * HDQ_SAMPLE_PERIOD_US)) /
189 HDQ_SAMPLE_PERIOD_US;
190 hdq_state = HDQB_ADS_LOW;
191 hdq_shifter >>= 1;
192 hdq_bit--;
193 s3c2410_gpio_setpin(fiq_ipc.hdq_gpio_pin, 0);
194 break;
196 case HDQB_ADS_LOW:
197 if (--hdq_ctr)
198 break;
199 s3c2410_gpio_setpin(fiq_ipc.hdq_gpio_pin, 1);
200 hdq_state = HDQB_ADS_HIGH;
201 break;
203 case HDQB_ADS_HIGH:
204 if (--hdq_ctr2 > 1) /* account for HDQB_ADS_CALC */
205 break;
206 if (hdq_bit) { /* more bits to do */
207 hdq_state = HDQB_ADS_CALC;
208 break;
210 /* no more bits, wait it out until hdq_ctr2 exhausted */
211 if (hdq_ctr2)
212 break;
213 /* ok no more bits and very last state */
214 hdq_ctr = 60 / HDQ_SAMPLE_PERIOD_US;
215 /* FIXME 0 = read */
216 if (fiq_ipc.hdq_ads & 0x80) { /* write the byte out */
217 /* set delay before payload */
218 hdq_ctr = 300 / HDQ_SAMPLE_PERIOD_US;
219 /* already high, no need to write */
220 hdq_state = HDQB_WAIT_TX;
221 break;
223 /* read the next byte */
224 hdq_bit = 8; /* 8 bits of data */
225 hdq_ctr = 3000 / HDQ_SAMPLE_PERIOD_US;
226 hdq_state = HDQB_WAIT_RX;
227 s3c2410_gpio_cfgpin(fiq_ipc.hdq_gpio_pin, S3C2410_GPIO_INPUT);
228 break;
230 case HDQB_WAIT_TX: /* issue low for > 40us */
231 if (--hdq_ctr)
232 break;
233 if (!hdq_tx_data_done) { /* was that the data sent? */
234 hdq_tx_data_done++;
235 hdq_shifter = fiq_ipc.hdq_tx_data;
236 hdq_bit = 8; /* 8 bits of data */
237 hdq_state = HDQB_ADS_CALC; /* start sending */
238 break;
240 fiq_ipc.hdq_error = 0;
241 fiq_ipc.hdq_transaction_ctr++;
242 hdq_state = HDQB_IDLE; /* all tx is done */
243 /* idle in input mode, it's pulled up by 10K */
244 s3c2410_gpio_cfgpin(fiq_ipc.hdq_gpio_pin, S3C2410_GPIO_INPUT);
245 break;
247 case HDQB_WAIT_RX: /* wait for battery to talk to us */
248 if (s3c2410_gpio_getpin(fiq_ipc.hdq_gpio_pin) == 0) {
249 /* it talks to us! */
250 hdq_ctr2 = 1;
251 hdq_bit = 8; /* 8 bits of data */
252 /* timeout */
253 hdq_ctr = 300 / HDQ_SAMPLE_PERIOD_US;
254 hdq_state = HDQB_DATA_RX_LOW;
255 break;
257 if (--hdq_ctr == 0) { /* timed out, error */
258 fiq_ipc.hdq_error = 1;
259 fiq_ipc.hdq_transaction_ctr++;
260 hdq_state = HDQB_IDLE; /* abort */
262 break;
265 * HDQ basically works by measuring the low time of the bit cell
266 * 32-50us --> '1', 80 - 145us --> '0'
269 case HDQB_DATA_RX_LOW:
270 if (s3c2410_gpio_getpin(fiq_ipc.hdq_gpio_pin)) {
271 fiq_ipc.hdq_rx_data >>= 1;
272 if (hdq_ctr2 <= (65 / HDQ_SAMPLE_PERIOD_US))
273 fiq_ipc.hdq_rx_data |= 0x80;
275 if (--hdq_bit == 0) {
276 fiq_ipc.hdq_error = 0;
277 fiq_ipc.hdq_transaction_ctr++; /* done */
278 hdq_state = HDQB_IDLE;
279 } else
280 hdq_state = HDQB_DATA_RX_HIGH;
281 /* timeout */
282 hdq_ctr = 1000 / HDQ_SAMPLE_PERIOD_US;
283 hdq_ctr2 = 1;
284 break;
286 hdq_ctr2++;
287 if (--hdq_ctr)
288 break;
289 /* timed out, error */
290 fiq_ipc.hdq_error = 2;
291 fiq_ipc.hdq_transaction_ctr++;
292 hdq_state = HDQB_IDLE; /* abort */
293 break;
295 case HDQB_DATA_RX_HIGH:
296 if (!s3c2410_gpio_getpin(fiq_ipc.hdq_gpio_pin)) {
297 /* it talks to us! */
298 hdq_ctr2 = 1;
299 /* timeout */
300 hdq_ctr = 400 / HDQ_SAMPLE_PERIOD_US;
301 hdq_state = HDQB_DATA_RX_LOW;
302 break;
304 if (--hdq_ctr)
305 break;
306 /* timed out, error */
307 fiq_ipc.hdq_error = 3;
308 fiq_ipc.hdq_transaction_ctr++;
309 /* we're in input mode already */
310 hdq_state = HDQB_IDLE; /* abort */
311 break;
314 if (hdq_state != HDQB_IDLE) /* ie, not idle */
315 if (divisor > FIQ_DIVISOR_HDQ)
316 divisor = FIQ_DIVISOR_HDQ; /* keep us going */
317 #endif
319 /* disable further timer interrupts if nobody has any work
320 * or adjust rate according to who still has work
322 * CAUTION: it means forground code must disable FIQ around
323 * its own non-atomic S3C2410_INTMSK changes... not common
324 * thankfully and taken care of by the fiq-basis patch
326 if (divisor == 0xffff) /* mask the fiq irq source */
327 __raw_writel(__raw_readl(S3C2410_INTMSK) | _fiq_ack_mask,
328 S3C2410_INTMSK);
329 else /* still working, maybe at a different rate */
330 __raw_writel(divisor, S3C2410_TCNTB(_fiq_timer_index));
331 _fiq_timer_divisor = divisor;
333 FIQ_HANDLER_END()
337 * this gets called every 1ms when we paniced.
340 static long gta02_panic_blink(long count)
342 long delay = 0;
343 static long last_blink;
344 static char led;
346 if (count - last_blink < 100) /* 200ms period, fast blink */
347 return 0;
349 led ^= 1;
350 s3c2410_gpio_cfgpin(GTA02_GPIO_AUX_LED, S3C2410_GPIO_OUTPUT);
351 neo1973_gpb_setpin(GTA02_GPIO_AUX_LED, led);
353 last_blink = count;
354 return delay;
359 * returns PCB revision information in b9,b8 and b2,b1,b0
360 * Pre-GTA02 A6 returns 0x000
361 * GTA02 A6 returns 0x101
362 * ...
365 int gta02_get_pcb_revision(void)
367 int n;
368 int u = 0;
369 static unsigned long pinlist[] = {
370 GTA02_PCB_ID1_0,
371 GTA02_PCB_ID1_1,
372 GTA02_PCB_ID1_2,
373 GTA02_PCB_ID2_0,
374 GTA02_PCB_ID2_1,
376 static int pin_offset[] = {
377 0, 1, 2, 8, 9
380 for (n = 0 ; n < ARRAY_SIZE(pinlist); n++) {
382 * set the PCB version GPIO to be pulled-down input
383 * force low briefly first
385 s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT);
386 s3c2410_gpio_setpin(pinlist[n], 0);
387 /* misnomer: it is a pullDOWN in 2442 */
388 s3c2410_gpio_pullup(pinlist[n], 1);
389 s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_INPUT);
391 udelay(10);
393 if (s3c2410_gpio_getpin(pinlist[n]))
394 u |= 1 << pin_offset[n];
397 * when not being interrogated, all of the revision GPIO
398 * are set to output HIGH without pulldown so no current flows
399 * if they are NC or pulled up.
401 s3c2410_gpio_setpin(pinlist[n], 1);
402 s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT);
403 /* misnomer: it is a pullDOWN in 2442 */
404 s3c2410_gpio_pullup(pinlist[n], 0);
407 return u;
410 struct platform_device gta02_version_device = {
411 .name = "neo1973-version",
412 .num_resources = 0,
415 struct platform_device gta02_resume_reason_device = {
416 .name = "neo1973-resume",
417 .num_resources = 0,
420 struct platform_device gta02_memconfig_device = {
421 .name = "neo1973-memconfig",
422 .num_resources = 0,
425 static struct map_desc gta02_iodesc[] __initdata = {
427 .virtual = 0xe0000000,
428 .pfn = __phys_to_pfn(S3C2410_CS3+0x01000000),
429 .length = SZ_1M,
430 .type = MT_DEVICE
434 #define UCON S3C2410_UCON_DEFAULT
435 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
436 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
438 static struct s3c2410_uartcfg gta02_uartcfgs[] = {
439 [0] = {
440 .hwport = 0,
441 .flags = 0,
442 .ucon = UCON,
443 .ulcon = ULCON,
444 .ufcon = UFCON,
446 [1] = {
447 .hwport = 1,
448 .flags = 0,
449 .ucon = UCON,
450 .ulcon = ULCON,
451 .ufcon = UFCON,
453 [2] = {
454 .hwport = 2,
455 .flags = 0,
456 .ucon = UCON,
457 .ulcon = ULCON,
458 .ufcon = UFCON,
463 /* BQ27000 Battery */
465 static int gta02_get_charger_online_status(void)
467 return gta02_charger_online_status;
470 static int gta02_get_charger_active_status(void)
472 return gta02_charger_active_status;
476 struct bq27000_platform_data bq27000_pdata = {
477 .name = "bat",
478 .rsense_mohms = 20,
479 .hdq_read = gta02hdq_read,
480 .hdq_write = gta02hdq_write,
481 .hdq_initialized = gta02hdq_initialized,
482 .get_charger_online_status = gta02_get_charger_online_status,
483 .get_charger_active_status = gta02_get_charger_active_status
486 struct platform_device bq27000_battery_device = {
487 .name = "bq27000-battery",
488 .dev = {
489 .platform_data = &bq27000_pdata,
494 /* PMU driver info */
496 static int pmu_callback(struct device *dev, unsigned int feature,
497 enum pmu_event event)
499 switch (feature) {
500 case PCF50633_FEAT_MBC:
501 switch (event) {
502 case PMU_EVT_CHARGER_IDLE:
503 gta02_charger_active_status = 0;
504 break;
505 case PMU_EVT_CHARGER_ACTIVE:
506 gta02_charger_active_status = 1;
507 break;
508 case PMU_EVT_USB_INSERT:
509 gta02_charger_online_status = 1;
510 break;
511 case PMU_EVT_USB_REMOVE:
512 gta02_charger_online_status = 0;
513 break;
514 case PMU_EVT_INSERT: /* adapter is unsused */
515 case PMU_EVT_REMOVE: /* adapter is unused */
516 break;
517 default:
518 break;
520 break;
521 default:
522 break;
525 bq27000_charging_state_change(&bq27000_battery_device);
526 return 0;
529 static struct platform_device gta01_pm_gps_dev = {
530 .name = "neo1973-pm-gps",
533 static struct platform_device gta01_pm_bt_dev = {
534 .name = "neo1973-pm-bt",
537 /* this is called when pc50633 is probed, unfortunately quite late in the
538 * day since it is an I2C bus device. Here we can belatedly define some
539 * platform devices with the advantage that we can mark the pcf50633 as the
540 * parent. This makes them get suspended and resumed with their parent
541 * the pcf50633 still around.
544 static void gta02_pcf50633_attach_child_devices(struct device *parent_device)
546 gta01_pm_gps_dev.dev.parent = parent_device;
547 gta01_pm_bt_dev.dev.parent = parent_device;
548 platform_device_register(&gta01_pm_bt_dev);
549 platform_device_register(&gta01_pm_gps_dev);
552 static struct pcf50633_platform_data gta02_pcf_pdata = {
553 .used_features = PCF50633_FEAT_MBC |
554 PCF50633_FEAT_BBC |
555 PCF50633_FEAT_RTC |
556 PCF50633_FEAT_CHGCUR |
557 PCF50633_FEAT_BATVOLT |
558 PCF50633_FEAT_BATTEMP |
559 PCF50633_FEAT_PWM_BL,
560 .onkey_seconds_sig_init = 4,
561 .onkey_seconds_shutdown = 8,
562 .cb = &pmu_callback,
563 .r_fix_batt = 10000,
564 .r_fix_batt_par = 10000,
565 .r_sense_milli = 220,
566 .flag_use_apm_emulation = 0,
567 .resumers = {
568 [0] = PCF50633_INT1_USBINS |
569 PCF50633_INT1_USBREM |
570 PCF50633_INT1_ALARM,
571 [1] = PCF50633_INT2_ONKEYF,
572 [2] = PCF50633_INT3_ONKEY1S
574 /* warning: these get rewritten during machine init below
575 * depending on pcb variant
577 .rails = {
578 [PCF50633_REGULATOR_AUTO] = {
579 .name = "io_3v3",
580 .flags = PMU_VRAIL_F_SUSPEND_ON,
581 .voltage = {
582 .init = 3300,
583 .max = 3300,
586 [PCF50633_REGULATOR_DOWN1] = {
587 .name = "core_1v3",
588 /* Wow, when we are going into suspend, after pcf50633
589 * runs its suspend (which happens real early since it
590 * is an i2c device) we are running out of the 22uF cap
591 * on core_1v3 rail !!!!
593 .voltage = {
594 .init = 1300,
595 .max = 1600,
598 [PCF50633_REGULATOR_DOWN2] = {
599 .name = "core_1v8",
600 .flags = PMU_VRAIL_F_SUSPEND_ON,
601 .voltage = {
602 .init = 1800,
603 .max = 1800,
606 [PCF50633_REGULATOR_HCLDO] = {
607 .name = "sd_3v3",
608 .voltage = {
609 .init = 2000,
610 .max = 3300,
613 [PCF50633_REGULATOR_LDO1] = {
614 .name = "gsensor_3v3",
615 .voltage = {
616 .init = 1300,
617 .max = 1330,
620 [PCF50633_REGULATOR_LDO2] = {
621 .name = "codec_3v3",
622 .voltage = {
623 .init = 3300,
624 .max = 3300,
627 [PCF50633_REGULATOR_LDO3] = {
628 .name = "unused3",
629 .voltage = {
630 .init = 3000,
631 .max = 3000,
634 [PCF50633_REGULATOR_LDO4] = {
635 .name = "bt_3v2",
636 .voltage = {
637 .init = 2500,
638 .max = 3300,
641 [PCF50633_REGULATOR_LDO5] = {
642 .name = "rf3v",
643 .voltage = {
644 .init = 1500,
645 .max = 1500,
648 [PCF50633_REGULATOR_LDO6] = {
649 .name = "lcm_3v",
650 .flags = PMU_VRAIL_F_SUSPEND_ON,
651 .voltage = {
652 .init = 0,
653 .max = 3300,
656 [PCF50633_REGULATOR_MEMLDO] = {
657 .name = "memldo",
658 .flags = PMU_VRAIL_F_SUSPEND_ON,
659 .voltage = {
660 .init = 1800,
661 .max = 1800,
665 .defer_resume_backlight = 1,
666 .resume_backlight_ramp_speed = 5,
667 .attach_child_devices = gta02_pcf50633_attach_child_devices
671 #if 0 /* currently unused */
672 static void cfg_pmu_vrail(struct pmu_voltage_rail *vrail, char *name,
673 unsigned int flags, unsigned int init,
674 unsigned int max)
676 vrail->name = name;
677 vrail->flags = flags;
678 vrail->voltage.init = init;
679 vrail->voltage.max = max;
681 #endif
683 static void mangle_pmu_pdata_by_system_rev(void)
685 switch (system_rev) {
686 case GTA02v1_SYSTEM_REV:
687 /* FIXME: this is only in v1 due to wrong PMU variant */
688 gta02_pcf_pdata.rails[PCF50633_REGULATOR_DOWN2].flags =
689 PMU_VRAIL_F_SUSPEND_ON;
690 break;
691 case GTA02v2_SYSTEM_REV:
692 case GTA02v3_SYSTEM_REV:
693 case GTA02v4_SYSTEM_REV:
694 case GTA02v5_SYSTEM_REV:
695 case GTA02v6_SYSTEM_REV:
696 /* we need to keep the 1.8V going since this is the SDRAM
697 * self-refresh voltage */
698 gta02_pcf_pdata.rails[PCF50633_REGULATOR_DOWN2].flags =
699 PMU_VRAIL_F_SUSPEND_ON;
700 gta02_pcf_pdata.rails[PCF50633_REGULATOR_DOWN2].name =
701 "io_1v8",
702 gta02_pcf_pdata.rails[PCF50633_REGULATOR_LDO1].name =
703 "gsensor_3v3",
704 gta02_pcf_pdata.rails[PCF50633_REGULATOR_LDO1].voltage.init =
705 3300;
706 gta02_pcf_pdata.rails[PCF50633_REGULATOR_LDO1].voltage.max =
707 3300;
708 gta02_pcf_pdata.rails[PCF50633_REGULATOR_LDO1].flags &=
709 ~PMU_VRAIL_F_SUSPEND_ON;
710 gta02_pcf_pdata.rails[PCF50633_REGULATOR_LDO3].flags =
711 PMU_VRAIL_F_UNUSED;
712 gta02_pcf_pdata.rails[PCF50633_REGULATOR_LDO5] = ((struct pmu_voltage_rail) {
713 .name = "rf_3v",
714 .voltage = {
715 .init = 0,
716 .max = 3000,
719 gta02_pcf_pdata.rails[PCF50633_REGULATOR_LDO6] =
720 ((struct pmu_voltage_rail) {
721 .name = "lcm_3v",
722 .flags = PMU_VRAIL_F_SUSPEND_ON,
723 .voltage = {
724 .init = 3000,
725 .max = 3000,
728 break;
729 default:
730 break;
734 static struct resource gta02_pmu_resources[] = {
735 [0] = {
736 .flags = IORESOURCE_IRQ,
737 .start = GTA02_IRQ_PCF50633,
738 .end = GTA02_IRQ_PCF50633,
742 struct platform_device gta02_pmu_dev = {
743 .name = "pcf50633",
744 .num_resources = ARRAY_SIZE(gta02_pmu_resources),
745 .resource = gta02_pmu_resources,
746 .dev = {
747 .platform_data = &gta02_pcf_pdata,
751 /* FIQ */
753 static struct resource sc32440_fiq_resources[] = {
754 [0] = {
755 .flags = IORESOURCE_IRQ,
756 .start = IRQ_TIMER3,
757 .end = IRQ_TIMER3,
761 struct platform_device sc32440_fiq_device = {
762 .name = "sc32440_fiq",
763 .num_resources = 1,
764 .resource = sc32440_fiq_resources,
767 #ifdef CONFIG_GTA02_HDQ
768 /* HDQ */
770 static struct resource gta02_hdq_resources[] = {
771 [0] = {
772 .start = GTA02v5_GPIO_HDQ,
773 .end = GTA02v5_GPIO_HDQ,
777 struct platform_device gta02_hdq_device = {
778 .name = "gta02-hdq",
779 .num_resources = 1,
780 .resource = gta02_hdq_resources,
782 #endif
785 /* NOR Flash */
787 #define GTA02_FLASH_BASE 0x18000000 /* GCS3 */
788 #define GTA02_FLASH_SIZE 0x200000 /* 2MBytes */
790 static struct physmap_flash_data gta02_nor_flash_data = {
791 .width = 2,
794 static struct resource gta02_nor_flash_resource = {
795 .start = GTA02_FLASH_BASE,
796 .end = GTA02_FLASH_BASE + GTA02_FLASH_SIZE - 1,
797 .flags = IORESOURCE_MEM,
800 static struct platform_device gta02_nor_flash = {
801 .name = "physmap-flash",
802 .id = 0,
803 .dev = {
804 .platform_data = &gta02_nor_flash_data,
806 .resource = &gta02_nor_flash_resource,
807 .num_resources = 1,
812 static struct resource gta02_sdio_resources[] = {
813 [0] = {
814 .flags = IORESOURCE_IRQ,
815 .start = IRQ_SDI,
816 .end = IRQ_SDI,
818 [1] = {
819 .flags = IORESOURCE_MEM,
820 .start = S3C2410_PA_SDI,
821 .end = S3C2410_PA_SDI + S3C24XX_SZ_SDI - 1,
823 [2] = {
824 .flags = IORESOURCE_DMA,
825 .start = 0, /* Channel 0 for SDI */
826 .end = 0,
831 static struct platform_device gta02_sdio_dev = {
832 .name = "s3c24xx-sdio",
833 .id = -1,
834 .dev = {
835 .coherent_dma_mask = 0xffffffff,
837 .resource = gta02_sdio_resources,
838 .num_resources = ARRAY_SIZE(gta02_sdio_resources),
841 struct platform_device s3c24xx_pwm_device = {
842 .name = "s3c24xx_pwm",
843 .num_resources = 0,
847 static struct platform_device *gta02_devices[] __initdata = {
848 &s3c_device_usb,
849 &s3c_device_wdt,
850 &s3c_device_i2c,
851 &s3c_device_iis,
852 // &s3c_device_sdi, /* FIXME: temporary disable to avoid s3cmci bind */
853 &s3c_device_usbgadget,
854 &s3c_device_nand,
855 &s3c_device_ts,
856 &gta02_nor_flash,
857 &sc32440_fiq_device,
858 &gta02_version_device,
859 &gta02_memconfig_device,
860 &gta02_resume_reason_device,
861 &s3c24xx_pwm_device,
865 static struct s3c2410_nand_set gta02_nand_sets[] = {
866 [0] = {
867 .name = "neo1973-nand",
868 .nr_chips = 1,
869 .flags = S3C2410_NAND_BBT,
873 /* choose a set of timings which should suit most 512Mbit
874 * chips and beyond.
877 static struct s3c2410_platform_nand gta02_nand_info = {
878 .tacls = 20,
879 .twrph0 = 60,
880 .twrph1 = 20,
881 .nr_sets = ARRAY_SIZE(gta02_nand_sets),
882 .sets = gta02_nand_sets,
885 static struct s3c24xx_mci_pdata gta02_mmc_cfg = {
886 .gpio_detect = GTA02v1_GPIO_nSD_DETECT,
887 .set_power = NULL,
888 .ocr_avail = MMC_VDD_32_33,
891 static void gta02_udc_command(enum s3c2410_udc_cmd_e cmd)
893 printk(KERN_DEBUG "%s(%d)\n", __func__, cmd);
895 switch (cmd) {
896 case S3C2410_UDC_P_ENABLE:
897 neo1973_gpb_setpin(GTA02_GPIO_USB_PULLUP, 1);
898 break;
899 case S3C2410_UDC_P_DISABLE:
900 neo1973_gpb_setpin(GTA02_GPIO_USB_PULLUP, 0);
901 break;
902 case S3C2410_UDC_P_RESET:
903 /* FIXME! */
904 break;
905 default:
906 break;
910 /* get PMU to set USB current limit accordingly */
912 static void gta02_udc_vbus_draw(unsigned int ma)
914 if (!pcf50633_global)
915 return;
917 pcf50633_notify_usb_current_limit_change(pcf50633_global, ma);
920 static struct s3c2410_udc_mach_info gta02_udc_cfg = {
921 .vbus_draw = gta02_udc_vbus_draw,
922 .udc_command = gta02_udc_command,
926 static struct s3c2410_ts_mach_info gta02_ts_cfg = {
927 .delay = 10000,
928 .presc = 50000000 / 1000000, /* 50 MHz PCLK / 1MHz */
929 /* simple averaging, 2^n samples */
930 .oversampling_shift = 5,
931 /* averaging filter length, 2^n */
932 .excursion_filter_len_bits = 5,
933 /* flagged for beauty contest on next sample if differs from
934 * average more than this
936 .reject_threshold_vs_avg = 2,
940 /* SPI: LCM control interface attached to Glamo3362 */
942 static void gta02_jbt6k74_reset(int devidx, int level)
944 glamo_lcm_reset(level);
947 /* finally bring up deferred backlight resume now LCM is resumed itself */
949 static void gta02_jbt6k74_resuming(int devidx)
951 pcf50633_backlight_resume(pcf50633_global);
954 static int gta02_jbt6k74_all_dependencies_resumed(int devidx)
956 if (!resume_dep_jbt_pcf.called_flag)
957 return 0;
959 if (!resume_dep_jbt_glamo.called_flag)
960 return 0;
962 return 1;
965 /* register jbt resume action to be dependent on pcf50633 and glamo resume */
967 static void gta02_jbt6k74_suspending(int devindex, struct spi_device *spi)
969 void jbt6k74_resume(void *spi); /* little white lies about types */
971 resume_dep_jbt_pcf.callback = jbt6k74_resume;
972 resume_dep_jbt_pcf.context = (void *)spi;
973 pcf50633_register_resume_dependency(pcf50633_global,
974 &resume_dep_jbt_pcf);
975 resume_dep_jbt_glamo.callback = jbt6k74_resume;
976 resume_dep_jbt_glamo.context = (void *)spi;
977 glamo_register_resume_dependency(&resume_dep_jbt_glamo);
981 const struct jbt6k74_platform_data jbt6k74_pdata = {
982 .reset = gta02_jbt6k74_reset,
983 .resuming = gta02_jbt6k74_resuming,
984 .suspending = gta02_jbt6k74_suspending,
985 .all_dependencies_resumed = gta02_jbt6k74_all_dependencies_resumed,
988 static struct spi_board_info gta02_spi_board_info[] = {
990 .modalias = "jbt6k74",
991 /* platform_data */
992 .platform_data = &jbt6k74_pdata,
993 /* controller_data */
994 /* irq */
995 .max_speed_hz = 10 * 1000 * 1000,
996 .bus_num = 2,
997 /* chip_select */
1001 #if 0 /* currently this is not used and we use gpio spi */
1002 static struct glamo_spi_info glamo_spi_cfg = {
1003 .board_size = ARRAY_SIZE(gta02_spi_board_info),
1004 .board_info = gta02_spi_board_info,
1006 #endif /* 0 */
1008 static struct glamo_spigpio_info glamo_spigpio_cfg = {
1009 .pin_clk = GLAMO_GPIO10_OUTPUT,
1010 .pin_mosi = GLAMO_GPIO11_OUTPUT,
1011 .pin_cs = GLAMO_GPIO12_OUTPUT,
1012 .pin_miso = 0,
1013 .board_size = ARRAY_SIZE(gta02_spi_board_info),
1014 .board_info = gta02_spi_board_info,
1017 static struct resource gta02_vibrator_resources[] = {
1018 [0] = {
1019 .start = GTA02_GPIO_VIBRATOR_ON,
1020 .end = GTA02_GPIO_VIBRATOR_ON,
1024 static struct platform_device gta02_vibrator_dev = {
1025 .name = "neo1973-vibrator",
1026 .num_resources = ARRAY_SIZE(gta02_vibrator_resources),
1027 .resource = gta02_vibrator_resources,
1030 /* SPI: Accelerometers attached to SPI of s3c244x */
1033 * Situation is that Linux SPI can't work in an interrupt context, so we
1034 * implement our own bitbang here. Arbitration is needed because not only
1035 * can this interrupt happen at any time even if foreground wants to use
1036 * the bitbang API from Linux, but multiple motion sensors can be on the
1037 * same SPI bus, and multiple interrupts can happen.
1039 * Foreground / interrupt arbitration is okay because the interrupts are
1040 * disabled around all the foreground SPI code.
1042 * Interrupt / Interrupt arbitration is evidently needed, otherwise we
1043 * lose edge-triggered service after a while due to the two sensors sharing
1044 * the SPI bus having irqs at the same time eventually.
1046 * Servicing is typ 75 - 100us at 400MHz.
1049 /* #define DEBUG_SPEW_MS */
1050 #define MG_PER_SAMPLE 18
1052 struct lis302dl_platform_data lis302_pdata[];
1054 void gat02_lis302dl_bitbang_read(struct lis302dl_info *lis)
1056 struct lis302dl_platform_data *pdata = lis->pdata;
1057 u8 shifter = 0xc0 | LIS302DL_REG_OUT_X; /* read, autoincrement */
1058 int n, n1;
1059 unsigned long other_cs;
1060 unsigned long flags;
1061 #ifdef DEBUG_SPEW_MS
1062 s8 x, y, z;
1063 #endif
1065 local_save_flags(flags);
1068 * Huh.. "quirk"... CS on this device is not really "CS" like you can
1069 * expect. Instead when 1 it selects I2C interface mode. Because we
1070 * have 2 devices on one interface, the "disabled" device when we talk
1071 * to an "enabled" device sees the clocks as I2C clocks, creating
1072 * havoc.
1073 * I2C sees MOSI going LOW while CLK HIGH as a START action, we must
1074 * ensure this is never issued.
1077 if (&lis302_pdata[0] == pdata)
1078 other_cs = lis302_pdata[1].pin_chip_select;
1079 else
1080 other_cs = lis302_pdata[0].pin_chip_select;
1082 s3c2410_gpio_setpin(other_cs, 1);
1083 s3c2410_gpio_setpin(pdata->pin_chip_select, 1);
1084 s3c2410_gpio_setpin(pdata->pin_clk, 1);
1085 s3c2410_gpio_setpin(pdata->pin_chip_select, 0);
1086 for (n = 0; n < 8; n++) { /* write the r/w, inc and address */
1087 s3c2410_gpio_setpin(pdata->pin_clk, 0);
1088 s3c2410_gpio_setpin(pdata->pin_mosi, (shifter >> 7) & 1);
1089 s3c2410_gpio_setpin(pdata->pin_clk, 0);
1090 s3c2410_gpio_setpin(pdata->pin_clk, 1);
1091 s3c2410_gpio_setpin(pdata->pin_clk, 1);
1092 shifter <<= 1;
1095 for (n = 0; n < 5; n++) { /* 5 consequetive registers */
1096 for (n1 = 0; n1 < 8; n1++) { /* 8 bits each */
1097 s3c2410_gpio_setpin(pdata->pin_clk, 0);
1098 s3c2410_gpio_setpin(pdata->pin_clk, 0);
1099 shifter <<= 1;
1100 if (s3c2410_gpio_getpin(pdata->pin_miso))
1101 shifter |= 1;
1102 s3c2410_gpio_setpin(pdata->pin_clk, 1);
1103 s3c2410_gpio_setpin(pdata->pin_clk, 1);
1105 switch (n) {
1106 case 0:
1107 #ifdef DEBUG_SPEW_MS
1108 x = shifter;
1109 #endif
1110 input_report_rel(lis->input_dev, REL_X, MG_PER_SAMPLE * (s8)shifter);
1111 break;
1112 case 2:
1113 #ifdef DEBUG_SPEW_MS
1114 y = shifter;
1115 #endif
1116 input_report_rel(lis->input_dev, REL_Y, MG_PER_SAMPLE * (s8)shifter);
1117 break;
1118 case 4:
1119 #ifdef DEBUG_SPEW_MS
1120 z = shifter;
1121 #endif
1122 input_report_rel(lis->input_dev, REL_Z, MG_PER_SAMPLE * (s8)shifter);
1123 break;
1126 s3c2410_gpio_setpin(pdata->pin_chip_select, 1);
1127 s3c2410_gpio_setpin(other_cs, 1);
1128 local_irq_restore(flags);
1130 input_sync(lis->input_dev);
1131 #ifdef DEBUG_SPEW_MS
1132 printk("%s: %d %d %d\n", pdata->name, x, y, z);
1133 #endif
1137 void gat02_lis302dl_suspend_io(struct lis302dl_info *lis, int resume)
1139 struct lis302dl_platform_data *pdata = lis->pdata;
1141 if (!resume) {
1143 * we don't want to power them with a high level
1144 * because GSENSOR_3V3 is not up during suspend
1146 s3c2410_gpio_setpin(pdata->pin_chip_select, 0);
1147 s3c2410_gpio_setpin(pdata->pin_clk, 0);
1148 s3c2410_gpio_setpin(pdata->pin_mosi, 0);
1149 /* misnomer: it is a pullDOWN in 2442 */
1150 s3c2410_gpio_pullup(pdata->pin_miso, 1);
1151 return;
1154 /* back to normal */
1155 s3c2410_gpio_setpin(pdata->pin_chip_select, 1);
1156 s3c2410_gpio_setpin(pdata->pin_clk, 1);
1157 /* misnomer: it is a pullDOWN in 2442 */
1158 s3c2410_gpio_pullup(pdata->pin_miso, 0);
1161 struct lis302dl_platform_data lis302_pdata[] = {
1163 .name = "lis302-1 (top)",
1164 .pin_chip_select= S3C2410_GPD12,
1165 .pin_clk = S3C2410_GPG7,
1166 .pin_mosi = S3C2410_GPG6,
1167 .pin_miso = S3C2410_GPG5,
1168 .open_drain = 1, /* altered at runtime by PCB rev */
1169 .lis302dl_bitbang_read = gat02_lis302dl_bitbang_read,
1170 .lis302dl_suspend_io = gat02_lis302dl_suspend_io,
1171 }, {
1172 .name = "lis302-2 (bottom)",
1173 .pin_chip_select= S3C2410_GPD13,
1174 .pin_clk = S3C2410_GPG7,
1175 .pin_mosi = S3C2410_GPG6,
1176 .pin_miso = S3C2410_GPG5,
1177 .open_drain = 1, /* altered at runtime by PCB rev */
1178 .lis302dl_bitbang_read = gat02_lis302dl_bitbang_read,
1179 .lis302dl_suspend_io = gat02_lis302dl_suspend_io,
1183 static struct spi_board_info gta02_spi_acc_bdinfo[] = {
1185 .modalias = "lis302dl",
1186 .platform_data = &lis302_pdata[0],
1187 .irq = GTA02_IRQ_GSENSOR_1,
1188 .max_speed_hz = 10 * 1000 * 1000,
1189 .bus_num = 1,
1190 .chip_select = 0,
1191 .mode = SPI_MODE_3,
1194 .modalias = "lis302dl",
1195 .platform_data = &lis302_pdata[1],
1196 .irq = GTA02_IRQ_GSENSOR_2,
1197 .max_speed_hz = 10 * 1000 * 1000,
1198 .bus_num = 1,
1199 .chip_select = 1,
1200 .mode = SPI_MODE_3,
1204 static void spi_acc_cs(struct s3c2410_spigpio_info *spigpio_info,
1205 int csid, int cs)
1207 struct lis302dl_platform_data * plat_data =
1208 (struct lis302dl_platform_data *)spigpio_info->
1209 board_info->platform_data;
1210 switch (cs) {
1211 case BITBANG_CS_ACTIVE:
1212 s3c2410_gpio_setpin(plat_data[csid].pin_chip_select, 0);
1213 break;
1214 case BITBANG_CS_INACTIVE:
1215 s3c2410_gpio_setpin(plat_data[csid].pin_chip_select, 1);
1216 break;
1220 static struct s3c2410_spigpio_info spi_gpio_cfg = {
1221 .pin_clk = S3C2410_GPG7,
1222 .pin_mosi = S3C2410_GPG6,
1223 .pin_miso = S3C2410_GPG5,
1224 .board_size = ARRAY_SIZE(gta02_spi_acc_bdinfo),
1225 .board_info = gta02_spi_acc_bdinfo,
1226 .chip_select = &spi_acc_cs,
1227 .num_chipselect = 2,
1230 static struct resource s3c_spi_acc_resource[] = {
1231 [0] = {
1232 .start = S3C2410_GPG3,
1233 .end = S3C2410_GPG3,
1235 [1] = {
1236 .start = S3C2410_GPG5,
1237 .end = S3C2410_GPG5,
1239 [2] = {
1240 .start = S3C2410_GPG6,
1241 .end = S3C2410_GPG6,
1243 [3] = {
1244 .start = S3C2410_GPG7,
1245 .end = S3C2410_GPG7,
1249 static struct platform_device s3c_device_spi_acc = {
1250 .name = "spi_s3c24xx_gpio",
1251 .id = 1,
1252 .num_resources = ARRAY_SIZE(s3c_spi_acc_resource),
1253 .resource = s3c_spi_acc_resource,
1254 .dev = {
1255 .platform_data = &spi_gpio_cfg,
1259 static struct resource gta02_led_resources[] = {
1261 .name = "gta02-power:orange",
1262 .start = GTA02_GPIO_PWR_LED1,
1263 .end = GTA02_GPIO_PWR_LED1,
1264 }, {
1265 .name = "gta02-power:blue",
1266 .start = GTA02_GPIO_PWR_LED2,
1267 .end = GTA02_GPIO_PWR_LED2,
1268 }, {
1269 .name = "gta02-aux:red",
1270 .start = GTA02_GPIO_AUX_LED,
1271 .end = GTA02_GPIO_AUX_LED,
1275 struct platform_device gta02_led_dev = {
1276 .name = "gta02-led",
1277 .num_resources = ARRAY_SIZE(gta02_led_resources),
1278 .resource = gta02_led_resources,
1281 static struct resource gta02_button_resources[] = {
1282 [0] = {
1283 .start = GTA02_GPIO_AUX_KEY,
1284 .end = GTA02_GPIO_AUX_KEY,
1286 [1] = {
1287 .start = GTA02_GPIO_HOLD_KEY,
1288 .end = GTA02_GPIO_HOLD_KEY,
1290 [2] = {
1291 .start = GTA02_GPIO_JACK_INSERT,
1292 .end = GTA02_GPIO_JACK_INSERT,
1296 static struct platform_device gta02_button_dev = {
1297 .name = "neo1973-button",
1298 .num_resources = ARRAY_SIZE(gta02_button_resources),
1299 .resource = gta02_button_resources,
1302 static struct platform_device gta02_pm_gsm_dev = {
1303 .name = "neo1973-pm-gsm",
1306 static struct platform_device gta02_pm_usbhost_dev = {
1307 .name = "neo1973-pm-host",
1311 /* USB */
1312 static struct s3c2410_hcd_info gta02_usb_info = {
1313 .port[0] = {
1314 .flags = S3C_HCDFLG_USED,
1316 .port[1] = {
1317 .flags = 0,
1321 static int glamo_irq_is_wired(void)
1323 int rc;
1324 int count = 0;
1327 * GTA02 S-Media IRQs prior to A5 are broken due to a lack of
1328 * a pullup on the INT# line. Check for the bad behaviour.
1330 s3c2410_gpio_setpin(S3C2410_GPG4, 0);
1331 s3c2410_gpio_cfgpin(S3C2410_GPG4, S3C2410_GPG4_OUTP);
1332 s3c2410_gpio_cfgpin(S3C2410_GPG4, S3C2410_GPG4_INP);
1334 * we force it low ourselves for a moment and resume being input.
1335 * If there is a pullup, it won't stay low for long. But if the
1336 * level converter is there as on < A5 revision, the weak keeper
1337 * on the input of the LC will hold the line low indefinitiely
1340 rc = s3c2410_gpio_getpin(S3C2410_GPG4);
1341 while ((!rc) && ((count++) < 10));
1342 if (rc) { /* it got pulled back up, it's good */
1343 printk(KERN_INFO "Detected S-Media IRQ# pullup, "
1344 "enabling interrupt\n");
1345 return 0;
1346 } else /* Gah we can't work with this level converter */
1347 printk(KERN_WARNING "** Detected bad IRQ# circuit found"
1348 " on pre-A5 GTA02: S-Media interrupt disabled **\n");
1349 return -ENODEV;
1353 static void
1354 gta02_glamo_mmc_set_power(unsigned char power_mode, unsigned short vdd)
1356 int mv = 1650;
1357 int timeout = 100;
1359 printk(KERN_DEBUG "mmc_set_power(power_mode=%u, vdd=%u\n",
1360 power_mode, vdd);
1362 switch (system_rev) {
1363 case GTA02v1_SYSTEM_REV:
1364 case GTA02v2_SYSTEM_REV:
1365 break;
1366 case GTA02v3_SYSTEM_REV:
1367 case GTA02v4_SYSTEM_REV:
1368 case GTA02v5_SYSTEM_REV:
1369 case GTA02v6_SYSTEM_REV:
1370 switch (power_mode) {
1371 case MMC_POWER_ON:
1372 case MMC_POWER_UP:
1373 /* depend on pcf50633 driver init + not suspended */
1374 while (pcf50633_ready(pcf50633_global) && (timeout--))
1375 msleep(5);
1377 if (!timeout) {
1378 printk(KERN_ERR"gta02_glamo_mmc_set_power "
1379 "BAILING on timeout\n");
1380 return;
1382 /* select and set the voltage */
1383 if (vdd > 7)
1384 mv += 350 + 100 * (vdd - 8);
1385 printk(KERN_INFO "SD power -> %dmV\n", mv);
1386 pcf50633_voltage_set(pcf50633_global,
1387 PCF50633_REGULATOR_HCLDO, mv);
1388 pcf50633_onoff_set(pcf50633_global,
1389 PCF50633_REGULATOR_HCLDO, 1);
1390 break;
1391 case MMC_POWER_OFF:
1392 /* power off happens during suspend, when pcf50633 can
1393 * be already gone and not coming back... just forget
1394 * the action then because pcf50633 suspend already
1395 * dealt with it, otherwise we spin forever
1397 if (pcf50633_ready(pcf50633_global))
1398 return;
1399 pcf50633_onoff_set(pcf50633_global,
1400 PCF50633_REGULATOR_HCLDO, 0);
1401 break;
1403 break;
1408 static int gta02_glamo_mci_all_dependencies_resumed(struct platform_device *dev)
1410 return resume_dep_glamo_mci_pcf.called_flag;
1413 /* register jbt resume action to be dependent on pcf50633 and glamo resume */
1415 static void gta02_glamo_mci_suspending(struct platform_device *dev)
1417 void glamo_mci_resume(void *dev); /* little white lies about types */
1419 resume_dep_glamo_mci_pcf.callback = glamo_mci_resume;
1420 resume_dep_glamo_mci_pcf.context = (void *)dev;
1421 pcf50633_register_resume_dependency(pcf50633_global,
1422 &resume_dep_glamo_mci_pcf);
1427 /* Smedia Glamo 3362 */
1430 * we crank down SD Card clock dynamically when GPS is powered
1433 static int gta02_glamo_mci_use_slow(void)
1435 return neo1973_pm_gps_is_on();
1438 static struct glamofb_platform_data gta02_glamo_pdata = {
1439 .width = 43,
1440 .height = 58,
1441 /* 24.5MHz --> 40.816ns */
1442 .pixclock = 40816,
1443 .left_margin = 8,
1444 .right_margin = 16,
1445 .upper_margin = 2,
1446 .lower_margin = 16,
1447 .hsync_len = 8,
1448 .vsync_len = 2,
1449 .fb_mem_size = 0x400000, /* glamo has 8 megs of SRAM. we use 4 */
1450 .xres = {
1451 .min = 240,
1452 .max = 640,
1453 .defval = 480,
1455 .yres = {
1456 .min = 320,
1457 .max = 640,
1458 .defval = 640,
1460 .bpp = {
1461 .min = 16,
1462 .max = 16,
1463 .defval = 16,
1465 //.spi_info = &glamo_spi_cfg,
1466 .spigpio_info = &glamo_spigpio_cfg,
1468 /* glamo MMC function platform data */
1469 .glamo_set_mci_power = gta02_glamo_mmc_set_power,
1470 .glamo_mci_use_slow = gta02_glamo_mci_use_slow,
1471 .glamo_irq_is_wired = glamo_irq_is_wired,
1472 .mci_suspending = gta02_glamo_mci_suspending,
1473 .mci_all_dependencies_resumed =
1474 gta02_glamo_mci_all_dependencies_resumed,
1477 static struct resource gta02_glamo_resources[] = {
1478 [0] = {
1479 .start = S3C2410_CS1,
1480 .end = S3C2410_CS1 + 0x1000000 - 1,
1481 .flags = IORESOURCE_MEM,
1483 [1] = {
1484 .start = GTA02_IRQ_3D,
1485 .end = GTA02_IRQ_3D,
1486 .flags = IORESOURCE_IRQ,
1488 [2] = {
1489 .start = GTA02v1_GPIO_3D_RESET,
1490 .end = GTA02v1_GPIO_3D_RESET,
1494 static struct platform_device gta02_glamo_dev = {
1495 .name = "glamo3362",
1496 .num_resources = ARRAY_SIZE(gta02_glamo_resources),
1497 .resource = gta02_glamo_resources,
1498 .dev = {
1499 .platform_data = &gta02_glamo_pdata,
1503 static void mangle_glamo_res_by_system_rev(void)
1505 switch (system_rev) {
1506 case GTA02v1_SYSTEM_REV:
1507 break;
1508 default:
1509 gta02_glamo_resources[2].start = GTA02_GPIO_3D_RESET;
1510 gta02_glamo_resources[2].end = GTA02_GPIO_3D_RESET;
1511 break;
1514 switch (system_rev) {
1515 case GTA02v1_SYSTEM_REV:
1516 case GTA02v2_SYSTEM_REV:
1517 case GTA02v3_SYSTEM_REV:
1518 /* case GTA02v4_SYSTEM_REV: - FIXME: handle this later */
1519 /* The hardware is missing a pull-up resistor and thus can't
1520 * support the Smedia Glamo IRQ */
1521 gta02_glamo_resources[1].start = 0;
1522 gta02_glamo_resources[1].end = 0;
1523 break;
1527 static void __init gta02_map_io(void)
1529 s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc));
1530 s3c24xx_init_clocks(12000000);
1531 s3c24xx_init_uarts(gta02_uartcfgs, ARRAY_SIZE(gta02_uartcfgs));
1534 extern int gta_gsm_interrupts;
1536 static irqreturn_t gta02_modem_irq(int irq, void *param)
1538 printk(KERN_DEBUG "modem wakeup interrupt\n");
1539 gta_gsm_interrupts++;
1540 return IRQ_HANDLED;
1543 static irqreturn_t ar6000_wow_irq(int irq, void *param)
1545 printk(KERN_DEBUG "ar6000_wow interrupt\n");
1546 return IRQ_HANDLED;
1549 static void __init gta02_machine_init(void)
1551 int rc;
1553 /* set the panic callback to make AUX blink fast */
1554 panic_blink = gta02_panic_blink;
1556 switch (system_rev) {
1557 case GTA02v6_SYSTEM_REV:
1558 /* we need push-pull interrupt from motion sensors */
1559 lis302_pdata[0].open_drain = 0;
1560 lis302_pdata[1].open_drain = 0;
1561 break;
1562 default:
1563 break;
1566 spin_lock_init(&motion_irq_lock);
1568 s3c_device_usb.dev.platform_data = &gta02_usb_info;
1569 s3c_device_nand.dev.platform_data = &gta02_nand_info;
1570 s3c_device_sdi.dev.platform_data = &gta02_mmc_cfg;
1572 /* Only GTA02v1 has a SD_DETECT GPIO. Since the slot is not
1573 * hot-pluggable, this is not required anyway */
1574 switch (system_rev) {
1575 case GTA02v1_SYSTEM_REV:
1576 break;
1577 default:
1578 gta02_mmc_cfg.gpio_detect = 0;
1579 break;
1582 /* acc sensor chip selects */
1583 s3c2410_gpio_setpin(S3C2410_GPD12, 1);
1584 s3c2410_gpio_cfgpin(S3C2410_GPD12, S3C2410_GPIO_OUTPUT);
1585 s3c2410_gpio_setpin(S3C2410_GPD13, 1);
1586 s3c2410_gpio_cfgpin(S3C2410_GPD13, S3C2410_GPIO_OUTPUT);
1588 s3c24xx_udc_set_platdata(&gta02_udc_cfg);
1589 set_s3c2410ts_info(&gta02_ts_cfg);
1591 /* FIXME: hardcoded WLAN module power-up */
1592 s3c2410_gpio_cfgpin(GTA02_CHIP_PWD, S3C2410_GPIO_OUTPUT);
1594 /* Power is down */
1595 s3c2410_gpio_setpin(GTA02_CHIP_PWD, 1);
1596 mdelay(100);
1598 switch (system_rev) {
1599 case GTA02v1_SYSTEM_REV:
1600 s3c2410_gpio_setpin(GTA02_CHIP_PWD, 0);
1601 break;
1602 default:
1603 /* Chip is in reset state */
1604 s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 0);
1605 s3c2410_gpio_cfgpin(GTA02_GPIO_nWLAN_RESET, S3C2410_GPIO_OUTPUT);
1606 mdelay(100);
1607 /* Power is up */
1608 s3c2410_gpio_setpin(GTA02_CHIP_PWD, 0);
1609 mdelay(100);
1610 /* Chip is out of reset */
1611 s3c2410_gpio_setpin(GTA02_GPIO_nWLAN_RESET, 1);
1612 break;
1614 mangle_glamo_res_by_system_rev();
1615 platform_device_register(&gta02_glamo_dev);
1617 platform_device_register(&s3c_device_spi_acc);
1618 platform_device_register(&gta02_button_dev);
1619 platform_device_register(&gta02_pm_gsm_dev);
1620 platform_device_register(&gta02_pm_usbhost_dev);
1622 mangle_pmu_pdata_by_system_rev();
1623 platform_device_register(&gta02_pmu_dev);
1624 platform_device_register(&gta02_vibrator_dev);
1625 platform_device_register(&gta02_led_dev);
1628 platform_device_register(&gta02_sdio_dev);
1630 platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices));
1632 #ifdef CONFIG_GTA02_HDQ
1633 switch (system_rev) {
1634 case GTA02v5_SYSTEM_REV:
1635 case GTA02v6_SYSTEM_REV:
1636 platform_device_register(&gta02_hdq_device);
1637 platform_device_register(&bq27000_battery_device);
1638 break;
1639 default:
1640 break;
1642 #endif
1643 s3c2410_pm_init();
1645 /* Make sure the modem can wake us up */
1646 set_irq_type(GTA02_IRQ_MODEM, IRQT_RISING);
1647 rc = request_irq(GTA02_IRQ_MODEM, gta02_modem_irq, IRQF_DISABLED,
1648 "modem", NULL);
1649 if (rc < 0)
1650 printk(KERN_ERR "GTA02: can't request GSM modem wakeup IRQ\n");
1651 enable_irq_wake(GTA02_IRQ_MODEM);
1653 /* Make sure the wifi module can wake us up*/
1654 set_irq_type(GTA02_IRQ_WLAN_GPIO1, IRQT_RISING);
1655 rc = request_irq(GTA02_IRQ_WLAN_GPIO1, ar6000_wow_irq, IRQF_DISABLED,
1656 "ar6000", NULL);
1658 if (rc < 0)
1659 printk(KERN_ERR "GTA02: can't request ar6k wakeup IRQ\n");
1660 enable_irq_wake(GTA02_IRQ_WLAN_GPIO1);
1663 MACHINE_START(NEO1973_GTA02, "GTA02")
1664 .phys_io = S3C2410_PA_UART,
1665 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
1666 .boot_params = S3C2410_SDRAM_PA + 0x100,
1667 .map_io = gta02_map_io,
1668 .init_irq = s3c24xx_init_irq,
1669 .init_machine = gta02_machine_init,
1670 .timer = &s3c24xx_timer,
1671 MACHINE_END