1af9ecc857ebc48431a2c9698090da4f5591005c
[kernel.git] / arch / arm / mach-s3c2440 / mach-gta02.c
1 /*
2  * linux/arch/arm/mach-s3c2442/mach-gta02.c
3  *
4  * S3C2442 Machine Support for Openmoko GTA02 / FreeRunner.
5  *
6  * Copyright (C) 2006-2009 by Openmoko, Inc.
7  * Authors: Harald Welte <laforge@openmoko.org>
8  *          Andy Green <andy@openmoko.org>
9  *          Werner Almesberger <werner@openmoko.org>
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License as
14  * published by the Free Software Foundation; either version 2 of
15  * the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25  * MA 02111-1307 USA
26  *
27  */
28
29 #include <linux/kernel.h>
30 #include <linux/types.h>
31 #include <linux/interrupt.h>
32 #include <linux/list.h>
33 #include <linux/delay.h>
34 #include <linux/timer.h>
35 #include <linux/init.h>
36 #include <linux/gpio.h>
37 #include <linux/workqueue.h>
38 #include <linux/platform_device.h>
39 #include <linux/serial_core.h>
40 #include <linux/spi/spi.h>
41
42 #include <linux/mmc/host.h>
43
44 #include <linux/mtd/mtd.h>
45 #include <linux/mtd/nand.h>
46 #include <linux/mtd/nand_ecc.h>
47 #include <linux/mtd/partitions.h>
48 #include <linux/mtd/physmap.h>
49 #include <linux/io.h>
50
51 #include <linux/i2c.h>
52 #include <linux/backlight.h>
53 #include <linux/regulator/machine.h>
54
55 #include <linux/mfd/pcf50633/core.h>
56 #include <linux/mfd/pcf50633/mbc.h>
57 #include <linux/mfd/pcf50633/adc.h>
58 #include <linux/mfd/pcf50633/gpio.h>
59 #include <linux/mfd/pcf50633/pmic.h>
60
61 #include <linux/input.h>
62 #include <linux/gpio_keys.h>
63
64 #include <linux/leds.h>
65 #include <linux/leds_pwm.h>
66
67 #include <asm/mach/arch.h>
68 #include <asm/mach/map.h>
69 #include <asm/mach/irq.h>
70
71 #include <asm/irq.h>
72 #include <asm/mach-types.h>
73
74 #include <mach/regs-irq.h>
75 #include <mach/regs-gpio.h>
76 #include <mach/regs-gpioj.h>
77 #include <mach/fb.h>
78
79 #include <mach/spi.h>
80 #include <mach/spi-gpio.h>
81 #include <plat/usb-control.h>
82 #include <mach/regs-mem.h>
83 #include <mach/hardware.h>
84
85 #include <mach/gta02.h>
86
87 #include <plat/regs-serial.h>
88 #include <plat/nand.h>
89 #include <plat/devs.h>
90 #include <plat/cpu.h>
91 #include <plat/pm.h>
92 #include <plat/udc.h>
93 #include <plat/gpio-cfg.h>
94 #include <plat/iic.h>
95
96 static struct pcf50633 *gta02_pcf;
97
98 /*
99  * This gets called every 1ms when we paniced.
100  */
101
102 static long gta02_panic_blink(long count)
103 {
104         long delay = 0;
105         static long last_blink;
106         static char led;
107
108         /* Fast blink: 200ms period. */
109         if (count - last_blink < 100)
110                 return 0;
111
112         led ^= 1;
113         gpio_direction_output(GTA02_GPIO_AUX_LED, led);
114
115         last_blink = count;
116
117         return delay;
118 }
119
120
121 static struct map_desc gta02_iodesc[] __initdata = {
122         {
123                 .virtual        = 0xe0000000,
124                 .pfn            = __phys_to_pfn(S3C2410_CS3 + 0x01000000),
125                 .length         = SZ_1M,
126                 .type           = MT_DEVICE
127         },
128 };
129
130 #define UCON (S3C2410_UCON_DEFAULT | S3C2443_UCON_RXERR_IRQEN)
131 #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
132 #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
133
134 static struct s3c2410_uartcfg gta02_uartcfgs[] = {
135         [0] = {
136                 .hwport         = 0,
137                 .flags          = 0,
138                 .ucon           = UCON,
139                 .ulcon          = ULCON,
140                 .ufcon          = UFCON,
141         },
142         [1] = {
143                 .hwport         = 1,
144                 .flags          = 0,
145                 .ucon           = UCON,
146                 .ulcon          = ULCON,
147                 .ufcon          = UFCON,
148         },
149         [2] = {
150                 .hwport         = 2,
151                 .flags          = 0,
152                 .ucon           = UCON,
153                 .ulcon          = ULCON,
154                 .ufcon          = UFCON,
155         },
156 };
157
158 #ifdef CONFIG_CHARGER_PCF50633
159 /*
160  * On GTA02 the 1A charger features a 48K resistor to 0V on the ID pin.
161  * We use this to recognize that we can pull 1A from the USB socket.
162  *
163  * These constants are the measured pcf50633 ADC levels with the 1A
164  * charger / 48K resistor, and with no pulldown resistor.
165  */
166
167 #define ADC_NOM_CHG_DETECT_1A 6
168 #define ADC_NOM_CHG_DETECT_USB 43
169
170 static void
171 gta02_configure_pmu_for_charger(struct pcf50633 *pcf, void *unused, int res)
172 {
173         int  ma;
174
175         /* Interpret charger type */
176         if (res < ((ADC_NOM_CHG_DETECT_USB + ADC_NOM_CHG_DETECT_1A) / 2)) {
177
178                 /*
179                  * Sanity - stop GPO driving out now that we have a 1A charger
180                  * GPO controls USB Host power generation on GTA02
181                  */
182                 pcf50633_gpio_set(pcf, PCF50633_GPO, 0);
183
184                 ma = 1000;
185         } else
186                 ma = 100;
187
188         pcf50633_mbc_usb_curlim_set(pcf, ma);
189 }
190
191 static struct delayed_work gta02_charger_work;
192 static int gta02_usb_vbus_draw;
193
194 static void gta02_charger_worker(struct work_struct *work)
195 {
196         if (gta02_usb_vbus_draw) {
197                 pcf50633_mbc_usb_curlim_set(gta02_pcf, gta02_usb_vbus_draw);
198                 return;
199         }
200
201 #ifdef CONFIG_PCF50633_ADC
202         pcf50633_adc_async_read(gta02_pcf,
203                                 PCF50633_ADCC1_MUX_ADCIN1,
204                                 PCF50633_ADCC1_AVERAGE_16,
205                                 gta02_configure_pmu_for_charger,
206                                 NULL);
207 #else
208         /*
209          * If the PCF50633 ADC is disabled we fallback to a
210          * 100mA limit for safety.
211          */
212         pcf50633_mbc_usb_curlim_set(pcf, 100);
213 #endif
214 }
215
216 #define GTA02_CHARGER_CONFIGURE_TIMEOUT ((3000 * HZ) / 1000)
217
218 static void gta02_pmu_event_callback(struct pcf50633 *pcf, int irq)
219 {
220         if (irq == PCF50633_IRQ_USBINS) {
221                 schedule_delayed_work(&gta02_charger_work,
222                                       GTA02_CHARGER_CONFIGURE_TIMEOUT);
223
224                 return;
225         }
226
227         if (irq == PCF50633_IRQ_USBREM) {
228                 cancel_delayed_work_sync(&gta02_charger_work);
229                 gta02_usb_vbus_draw = 0;
230         }
231 }
232
233 static void gta02_udc_vbus_draw(unsigned int ma)
234 {
235         if (!gta02_pcf)
236                 return;
237
238         gta02_usb_vbus_draw = ma;
239
240         schedule_delayed_work(&gta02_charger_work,
241                               GTA02_CHARGER_CONFIGURE_TIMEOUT);
242 }
243 #else /* !CONFIG_CHARGER_PCF50633 */
244 #define gta02_pmu_event_callback        NULL
245 #define gta02_udc_vbus_draw             NULL
246 #endif
247
248 /*
249  * This is called when pc50633 is probed, unfortunately quite late in the
250  * day since it is an I2C bus device. Here we can belatedly define some
251  * platform devices with the advantage that we can mark the pcf50633 as the
252  * parent. This makes them get suspended and resumed with their parent
253  * the pcf50633 still around.
254  */
255
256 static void gta02_pmu_attach_child_devices(struct pcf50633 *pcf);
257
258
259 static char *gta02_batteries[] = {
260         "battery",
261 };
262
263 struct pcf50633_platform_data gta02_pcf_pdata = {
264         .resumers = {
265                 [0] =   PCF50633_INT1_USBINS |
266                         PCF50633_INT1_USBREM |
267                         PCF50633_INT1_ALARM,
268                 [1] =   PCF50633_INT2_ONKEYF,
269                 [2] =   PCF50633_INT3_ONKEY1S,
270                 [3] =   PCF50633_INT4_LOWSYS |
271                         PCF50633_INT4_LOWBAT |
272                         PCF50633_INT4_HIGHTMP,
273         },
274
275         .batteries = gta02_batteries,
276         .num_batteries = ARRAY_SIZE(gta02_batteries),
277
278         .charger_reference_current_ma = 1000,
279
280         .reg_init_data = {
281                 [PCF50633_REGULATOR_AUTO] = {
282                         .constraints = {
283                                 .min_uV = 3300000,
284                                 .max_uV = 3300000,
285                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
286                                 .always_on = 1,
287                                 .apply_uV = 1,
288                                 .state_mem = {
289                                         .enabled = 1,
290                                 },
291                         },
292                 },
293                 [PCF50633_REGULATOR_DOWN1] = {
294                         .constraints = {
295                                 .min_uV = 1300000,
296                                 .max_uV = 1600000,
297                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
298                                 .always_on = 1,
299                                 .apply_uV = 1,
300                         },
301                 },
302                 [PCF50633_REGULATOR_DOWN2] = {
303                         .constraints = {
304                                 .min_uV = 1800000,
305                                 .max_uV = 1800000,
306                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
307                                 .apply_uV = 1,
308                                 .always_on = 1,
309                                 .state_mem = {
310                                         .enabled = 1,
311                                 },
312                         },
313                 },
314                 [PCF50633_REGULATOR_HCLDO] = {
315                         .constraints = {
316                                 .min_uV = 2000000,
317                                 .max_uV = 3300000,
318                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
319                                 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
320                                 .always_on = 1,
321                         },
322                 },
323                 [PCF50633_REGULATOR_LDO1] = {
324                         .constraints = {
325                                 .min_uV = 3300000,
326                                 .max_uV = 3300000,
327                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
328                                 .apply_uV = 1,
329                                 .state_mem = {
330                                         .enabled = 0,
331                                 },
332                         },
333                 },
334                 [PCF50633_REGULATOR_LDO2] = {
335                         .constraints = {
336                                 .min_uV = 3300000,
337                                 .max_uV = 3300000,
338                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
339                                 .apply_uV = 1,
340                         },
341                 },
342                 [PCF50633_REGULATOR_LDO3] = {
343                         .constraints = {
344                                 .min_uV = 3000000,
345                                 .max_uV = 3000000,
346                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
347                                 .apply_uV = 1,
348                         },
349                 },
350                 [PCF50633_REGULATOR_LDO4] = {
351                         .constraints = {
352                                 .min_uV = 3200000,
353                                 .max_uV = 3200000,
354                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
355                                 .apply_uV = 1,
356                         },
357                 },
358                 [PCF50633_REGULATOR_LDO5] = {
359                         .constraints = {
360                                 .min_uV = 3000000,
361                                 .max_uV = 3000000,
362                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
363                                 .apply_uV = 1,
364                                 .state_mem = {
365                                         .enabled = 1,
366                                 },
367                         },
368                 },
369                 [PCF50633_REGULATOR_LDO6] = {
370                         .constraints = {
371                                 .min_uV = 3000000,
372                                 .max_uV = 3000000,
373                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
374                         },
375                 },
376                 [PCF50633_REGULATOR_MEMLDO] = {
377                         .constraints = {
378                                 .min_uV = 1800000,
379                                 .max_uV = 1800000,
380                                 .valid_modes_mask = REGULATOR_MODE_NORMAL,
381                                 .state_mem = {
382                                         .enabled = 1,
383                                 },
384                         },
385                 },
386
387         },
388         .probe_done = gta02_pmu_attach_child_devices,
389         .mbc_event_callback = gta02_pmu_event_callback,
390 };
391
392
393 /* NOR Flash. */
394
395 #define GTA02_FLASH_BASE        0x18000000 /* GCS3 */
396 #define GTA02_FLASH_SIZE        0x200000 /* 2MBytes */
397
398 static struct physmap_flash_data gta02_nor_flash_data = {
399         .width          = 2,
400 };
401
402 static struct resource gta02_nor_flash_resource = {
403         .start          = GTA02_FLASH_BASE,
404         .end            = GTA02_FLASH_BASE + GTA02_FLASH_SIZE - 1,
405         .flags          = IORESOURCE_MEM,
406 };
407
408 static struct platform_device gta02_nor_flash = {
409         .name           = "physmap-flash",
410         .id             = 0,
411         .dev            = {
412                 .platform_data  = &gta02_nor_flash_data,
413         },
414         .resource       = &gta02_nor_flash_resource,
415         .num_resources  = 1,
416 };
417
418 static struct i2c_board_info gta02_i2c_devs[] __initdata = {
419         {
420                 I2C_BOARD_INFO("pcf50633", 0x73),
421                 .irq = GTA02_IRQ_PCF50633,
422                 .platform_data = &gta02_pcf_pdata,
423         },
424         {
425                 I2C_BOARD_INFO("wm8753", 0x1a),
426         },
427 };
428
429 static struct s3c2410_nand_set __initdata gta02_nand_sets[] = {
430         [0] = {
431                 /*
432                  * This name is also hard-coded in the boot loaders, so
433                  * changing it would would require all users to upgrade
434                  * their boot loaders, some of which are stored in a NOR
435                  * that is considered to be immutable.
436                  */
437                 .name           = "neo1973-nand",
438                 .nr_chips       = 1,
439                 .flash_bbt      = 1,
440         },
441 };
442
443 /*
444  * Choose a set of timings derived from S3C@2442B MCP54
445  * data sheet (K5D2G13ACM-D075 MCP Memory).
446  */
447
448 static struct s3c2410_platform_nand __initdata gta02_nand_info = {
449         .tacls          = 0,
450         .twrph0         = 25,
451         .twrph1         = 15,
452         .nr_sets        = ARRAY_SIZE(gta02_nand_sets),
453         .sets           = gta02_nand_sets,
454 };
455
456
457 static void gta02_udc_command(enum s3c2410_udc_cmd_e cmd)
458 {
459         switch (cmd) {
460         case S3C2410_UDC_P_ENABLE:
461                 pr_debug("%s S3C2410_UDC_P_ENABLE\n", __func__);
462                 gpio_direction_output(GTA02_GPIO_USB_PULLUP, 1);
463                 break;
464         case S3C2410_UDC_P_DISABLE:
465                 pr_debug("%s S3C2410_UDC_P_DISABLE\n", __func__);
466                 gpio_direction_output(GTA02_GPIO_USB_PULLUP, 0);
467                 break;
468         case S3C2410_UDC_P_RESET:
469                 pr_debug("%s S3C2410_UDC_P_RESET\n", __func__);
470                 /* FIXME: Do something here. */
471         }
472 }
473
474 /* Get PMU to set USB current limit accordingly. */
475 static struct s3c2410_udc_mach_info gta02_udc_cfg = {
476         .vbus_draw      = gta02_udc_vbus_draw,
477         .udc_command    = gta02_udc_command,
478
479 };
480
481
482
483 static void gta02_bl_set_intensity(int intensity)
484 {
485         struct pcf50633 *pcf = gta02_pcf;
486         int old_intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT);
487
488         /* We map 8-bit intensity to 6-bit intensity in hardware. */
489         intensity >>= 2;
490
491         /*
492          * This can happen during, eg, print of panic on blanked console,
493          * but we can't service i2c without interrupts active, so abort.
494          */
495         if (in_atomic()) {
496                 printk(KERN_ERR "gta02_bl_set_intensity called while atomic\n");
497                 return;
498         }
499
500         old_intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT);
501         if (intensity == old_intensity)
502                 return;
503
504         /* We can't do this anywhere else. */
505         pcf50633_reg_write(pcf, PCF50633_REG_LEDDIM, 5);
506
507         if (!(pcf50633_reg_read(pcf, PCF50633_REG_LEDENA) & 3))
508                 old_intensity = 0;
509
510         /*
511          * The PCF50633 cannot handle LEDOUT = 0 (datasheet p60)
512          * if seen, you have to re-enable the LED unit.
513          */
514         if (!intensity || !old_intensity)
515                 pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0);
516
517         /* Illegal to set LEDOUT to 0. */
518         if (!intensity)
519                 pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f, 2);
520         else
521                 pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f,
522                                           intensity);
523
524         if (intensity)
525                 pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 2);
526
527 }
528
529 static struct generic_bl_info gta02_bl_info = {
530         .name                   = "gta02-bl",
531         .max_intensity          = 0xff,
532         .default_intensity      = 0xff,
533         .set_bl_intensity       = gta02_bl_set_intensity,
534 };
535
536 static struct platform_device gta02_bl_dev = {
537         .name                   = "generic-bl",
538         .id                     = 1,
539         .dev = {
540                 .platform_data = &gta02_bl_info,
541         },
542 };
543
544
545
546 /* USB */
547 static struct s3c2410_hcd_info gta02_usb_info __initdata = {
548         .port[0]        = {
549                 .flags  = S3C_HCDFLG_USED,
550         },
551         .port[1]        = {
552                 .flags  = 0,
553         },
554 };
555
556 /* Buttons */
557 static struct gpio_keys_button gta02_buttons[] = {
558         {
559                 .gpio = GTA02_GPIO_AUX_KEY,
560                 .code = KEY_PHONE,
561                 .desc = "Aux",
562                 .type = EV_KEY,
563                 .debounce_interval = 100,
564         },
565         {
566                 .gpio = GTA02_GPIO_HOLD_KEY,
567                 .code = KEY_PAUSE,
568                 .desc = "Hold",
569                 .type = EV_KEY,
570                 .debounce_interval = 100,
571         },
572 };
573
574 static struct gpio_keys_platform_data gta02_buttons_pdata = {
575         .buttons = gta02_buttons,
576         .nbuttons = ARRAY_SIZE(gta02_buttons),
577 };
578
579 static struct platform_device gta02_buttons_device = {
580         .name = "gpio-keys",
581         .id = -1,
582         .dev = {
583                 .platform_data = &gta02_buttons_pdata,
584         },
585 };
586
587 /* LEDs */
588 static struct gpio_led gta02_gpio_leds[] = {
589         {
590                 .name   = "gta02:red:aux",
591                 .gpio   = GTA02_GPIO_AUX_LED,
592         },
593 };
594
595 static struct gpio_led_platform_data gta02_gpio_leds_pdata = {
596         .leds = gta02_gpio_leds,
597         .num_leds = ARRAY_SIZE(gta02_gpio_leds),
598 };
599
600 static struct platform_device gta02_leds_device = {
601         .name = "leds-gpio",
602         .id   = -1,
603         .dev = {
604                 .platform_data = &gta02_gpio_leds_pdata,
605         },
606 };
607
608 static inline int gta02_pwm_to_gpio(int pwm_id)
609 {
610         return S3C2410_GPB(pwm_id);
611 }
612
613 static int gta02_pwm_led_init(struct device *dev, struct led_pwm *led)
614 {
615         int ret;
616         int gpio = gta02_pwm_to_gpio(led->pwm_id);
617
618         ret = gpio_request(gpio, dev_name(dev));
619         if (ret)
620                 return ret;
621
622         gpio_direction_output(gpio, 0);
623
624         return 0;
625 }
626
627 static enum led_brightness gta02_pwm_led_notify(struct device *dev,
628         struct led_pwm *led, enum led_brightness brightness)
629 {
630         int gpio = gta02_pwm_to_gpio(led->pwm_id);
631
632         if (brightness == led->max_brightness || brightness == 0) {
633                 s3c2410_gpio_cfgpin(gpio, S3C2410_GPIO_OUTPUT);
634                 gpio_set_value(gpio, brightness ? 1 : 0);
635
636                 brightness = 0;
637         } else {
638                 s3c2410_gpio_cfgpin(gpio, S3C2410_GPIO_SFN2);
639         }
640
641         return brightness;
642 }
643
644 static void gta02_pwm_led_exit(struct device *dev, struct led_pwm *led)
645 {
646         gpio_free(gta02_pwm_to_gpio(led->pwm_id));
647 }
648
649 static struct led_pwm gta02_pwm_leds[] = {
650         {
651                 .name = "gta02:orange:power",
652                 .max_brightness = 0xff,
653                 .pwm_period_ns = 1000000,
654                 .pwm_id = 0,
655         },
656         {
657                 .name = "gta02:blue:power",
658                 .max_brightness = 0xff,
659                 .pwm_period_ns = 1000000,
660                 .pwm_id = 1,
661         },
662         {
663                 .name = "gta02::vibrator",
664                 .max_brightness = 0x3f,
665                 .pwm_period_ns = 60000000,
666                 .pwm_id = 3,
667         }
668 };
669
670 static struct led_pwm_platform_data gta02_pwm_leds_pdata = {
671         .num_leds = ARRAY_SIZE(gta02_pwm_leds),
672         .leds = gta02_pwm_leds,
673
674         .init = gta02_pwm_led_init,
675         .notify = gta02_pwm_led_notify,
676         .exit = gta02_pwm_led_exit,
677 };
678
679 static struct platform_device gta02_pwm_leds_device = {
680         .name   = "leds_pwm",
681         .id     = -1,
682         .dev = {
683                 .platform_data = &gta02_pwm_leds_pdata,
684         }
685 };
686
687 static void __init gta02_map_io(void)
688 {
689         s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc));
690         s3c24xx_init_clocks(12000000);
691         s3c24xx_init_uarts(gta02_uartcfgs, ARRAY_SIZE(gta02_uartcfgs));
692 }
693
694
695 /* These are the guys that don't need to be children of PMU. */
696
697 static struct platform_device *gta02_devices[] __initdata = {
698         &s3c_device_ohci,
699         &s3c_device_wdt,
700         &s3c_device_sdi,
701         &s3c_device_usbgadget,
702         &s3c_device_nand,
703         &gta02_nor_flash,
704         &s3c_device_timer[0],
705         &s3c_device_timer[1],
706         &s3c_device_timer[3],
707         &s3c_device_iis,
708         &s3c_device_i2c0,
709         &gta02_buttons_device,
710         &gta02_leds_device,
711         &gta02_pwm_leds_device,
712 };
713
714 /* These guys DO need to be children of PMU. */
715
716 static struct platform_device *gta02_devices_pmu_children[] = {
717         &gta02_bl_dev,
718 };
719
720
721 /*
722  * This is called when pc50633 is probed, quite late in the day since it is an
723  * I2C bus device.  Here we can define platform devices with the advantage that
724  * we can mark the pcf50633 as the parent.  This makes them get suspended and
725  * resumed with their parent the pcf50633 still around.  All devices whose
726  * operation depends on something from pcf50633 must have this relationship
727  * made explicit like this, or suspend and resume will become an unreliable
728  * hellworld.
729  */
730
731 static void gta02_pmu_attach_child_devices(struct pcf50633 *pcf)
732 {
733         int n;
734
735         /* Grab a copy of the now probed PMU pointer. */
736         gta02_pcf = pcf;
737
738         for (n = 0; n < ARRAY_SIZE(gta02_devices_pmu_children); n++)
739                 gta02_devices_pmu_children[n]->dev.parent = pcf->dev;
740
741         platform_add_devices(gta02_devices_pmu_children,
742                              ARRAY_SIZE(gta02_devices_pmu_children));
743 }
744
745 static void gta02_poweroff(void)
746 {
747         pcf50633_reg_set_bit_mask(gta02_pcf, PCF50633_REG_OOCSHDWN, 1, 1);
748 }
749
750 static void __init gta02_machine_init(void)
751 {
752         /* Set the panic callback to make AUX LED blink at ~5Hz. */
753         panic_blink = gta02_panic_blink;
754
755         s3c_pm_init();
756
757 #ifdef CONFIG_CHARGER_PCF50633
758         INIT_DELAYED_WORK(&gta02_charger_work, gta02_charger_worker);
759 #endif
760
761         s3c24xx_udc_set_platdata(&gta02_udc_cfg);
762         s3c_ohci_set_platdata(&gta02_usb_info);
763         s3c_nand_set_platdata(&gta02_nand_info);
764         s3c_i2c0_set_platdata(NULL);
765
766         i2c_register_board_info(0, gta02_i2c_devs, ARRAY_SIZE(gta02_i2c_devs));
767
768         platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices));
769
770         pm_power_off = gta02_poweroff;
771 }
772
773
774 MACHINE_START(NEO1973_GTA02, "GTA02")
775         /* Maintainer: Nelson Castillo <arhuaco@freaks-unidos.net> */
776         .phys_io        = S3C2410_PA_UART,
777         .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
778         .boot_params    = S3C2410_SDRAM_PA + 0x100,
779         .map_io         = gta02_map_io,
780         .init_irq       = s3c24xx_init_irq,
781         .init_machine   = gta02_machine_init,
782         .timer          = &s3c24xx_timer,
783 MACHINE_END