[MTD] struct device - replace bus_id with dev_name(), dev_set_name()
[pandora-kernel.git] / arch / arm / mach-pxa / spitz.c
1 /*
2  * Support for Sharp SL-Cxx00 Series of PDAs
3  * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi)
4  *
5  * Copyright (c) 2005 Richard Purdie
6  *
7  * Based on Sharp's 2.4 kernel patches/lubbock.c
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  *
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/major.h>
20 #include <linux/fs.h>
21 #include <linux/interrupt.h>
22 #include <linux/gpio.h>
23 #include <linux/leds.h>
24 #include <linux/mmc/host.h>
25 #include <linux/pm.h>
26 #include <linux/backlight.h>
27 #include <linux/io.h>
28 #include <linux/i2c.h>
29 #include <linux/i2c/pca953x.h>
30 #include <linux/spi/spi.h>
31 #include <linux/spi/ads7846.h>
32 #include <linux/spi/corgi_lcd.h>
33 #include <linux/mtd/sharpsl.h>
34
35 #include <asm/setup.h>
36 #include <asm/memory.h>
37 #include <asm/mach-types.h>
38 #include <mach/hardware.h>
39 #include <asm/irq.h>
40 #include <asm/system.h>
41
42 #include <asm/mach/arch.h>
43 #include <asm/mach/map.h>
44 #include <asm/mach/irq.h>
45
46 #include <mach/pxa-regs.h>
47 #include <mach/pxa2xx-regs.h>
48 #include <mach/mfp-pxa27x.h>
49 #include <mach/pxa27x-udc.h>
50 #include <mach/reset.h>
51 #include <mach/i2c.h>
52 #include <mach/irda.h>
53 #include <mach/mmc.h>
54 #include <mach/ohci.h>
55 #include <mach/udc.h>
56 #include <mach/pxafb.h>
57 #include <mach/pxa2xx_spi.h>
58 #include <mach/spitz.h>
59 #include <mach/sharpsl.h>
60
61 #include <asm/mach/sharpsl_param.h>
62 #include <asm/hardware/scoop.h>
63
64 #include "generic.h"
65 #include "devices.h"
66 #include "sharpsl.h"
67
68 static unsigned long spitz_pin_config[] __initdata = {
69         /* Chip Selects */
70         GPIO78_nCS_2,   /* SCOOP #2 */
71         GPIO79_nCS_3,   /* NAND */
72         GPIO80_nCS_4,   /* SCOOP #1 */
73
74         /* LCD - 16bpp Active TFT */
75         GPIO58_LCD_LDD_0,
76         GPIO59_LCD_LDD_1,
77         GPIO60_LCD_LDD_2,
78         GPIO61_LCD_LDD_3,
79         GPIO62_LCD_LDD_4,
80         GPIO63_LCD_LDD_5,
81         GPIO64_LCD_LDD_6,
82         GPIO65_LCD_LDD_7,
83         GPIO66_LCD_LDD_8,
84         GPIO67_LCD_LDD_9,
85         GPIO68_LCD_LDD_10,
86         GPIO69_LCD_LDD_11,
87         GPIO70_LCD_LDD_12,
88         GPIO71_LCD_LDD_13,
89         GPIO72_LCD_LDD_14,
90         GPIO73_LCD_LDD_15,
91         GPIO74_LCD_FCLK,
92         GPIO75_LCD_LCLK,
93         GPIO76_LCD_PCLK,
94
95         /* PC Card */
96         GPIO48_nPOE,
97         GPIO49_nPWE,
98         GPIO50_nPIOR,
99         GPIO51_nPIOW,
100         GPIO85_nPCE_1,
101         GPIO54_nPCE_2,
102         GPIO55_nPREG,
103         GPIO56_nPWAIT,
104         GPIO57_nIOIS16,
105         GPIO104_PSKTSEL,
106
107         /* MMC */
108         GPIO32_MMC_CLK,
109         GPIO112_MMC_CMD,
110         GPIO92_MMC_DAT_0,
111         GPIO109_MMC_DAT_1,
112         GPIO110_MMC_DAT_2,
113         GPIO111_MMC_DAT_3,
114
115         /* GPIOs */
116         GPIO9_GPIO,     /* SPITZ_GPIO_nSD_DETECT */
117         GPIO81_GPIO,    /* SPITZ_GPIO_nSD_WP */
118         GPIO41_GPIO,    /* SPITZ_GPIO_USB_CONNECT */
119         GPIO37_GPIO,    /* SPITZ_GPIO_USB_HOST */
120         GPIO35_GPIO,    /* SPITZ_GPIO_USB_DEVICE */
121         GPIO22_GPIO,    /* SPITZ_GPIO_HSYNC */
122         GPIO94_GPIO,    /* SPITZ_GPIO_CF_CD */
123         GPIO105_GPIO,   /* SPITZ_GPIO_CF_IRQ */
124         GPIO106_GPIO,   /* SPITZ_GPIO_CF2_IRQ */
125
126         GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
127 };
128
129 /*
130  * Spitz SCOOP Device #1
131  */
132 static struct resource spitz_scoop_resources[] = {
133         [0] = {
134                 .start          = 0x10800000,
135                 .end            = 0x10800fff,
136                 .flags          = IORESOURCE_MEM,
137         },
138 };
139
140 static struct scoop_config spitz_scoop_setup = {
141         .io_dir         = SPITZ_SCP_IO_DIR,
142         .io_out         = SPITZ_SCP_IO_OUT,
143         .suspend_clr    = SPITZ_SCP_SUS_CLR,
144         .suspend_set    = SPITZ_SCP_SUS_SET,
145         .gpio_base      = SPITZ_SCP_GPIO_BASE,
146 };
147
148 struct platform_device spitzscoop_device = {
149         .name           = "sharp-scoop",
150         .id             = 0,
151         .dev            = {
152                 .platform_data  = &spitz_scoop_setup,
153         },
154         .num_resources  = ARRAY_SIZE(spitz_scoop_resources),
155         .resource       = spitz_scoop_resources,
156 };
157
158 /*
159  * Spitz SCOOP Device #2
160  */
161 static struct resource spitz_scoop2_resources[] = {
162         [0] = {
163                 .start          = 0x08800040,
164                 .end            = 0x08800fff,
165                 .flags          = IORESOURCE_MEM,
166         },
167 };
168
169 static struct scoop_config spitz_scoop2_setup = {
170         .io_dir         = SPITZ_SCP2_IO_DIR,
171         .io_out         = SPITZ_SCP2_IO_OUT,
172         .suspend_clr    = SPITZ_SCP2_SUS_CLR,
173         .suspend_set    = SPITZ_SCP2_SUS_SET,
174         .gpio_base      = SPITZ_SCP2_GPIO_BASE,
175 };
176
177 struct platform_device spitzscoop2_device = {
178         .name           = "sharp-scoop",
179         .id             = 1,
180         .dev            = {
181                 .platform_data  = &spitz_scoop2_setup,
182         },
183         .num_resources  = ARRAY_SIZE(spitz_scoop2_resources),
184         .resource       = spitz_scoop2_resources,
185 };
186
187 #define SPITZ_PWR_SD 0x01
188 #define SPITZ_PWR_CF 0x02
189
190 /* Power control is shared with between one of the CF slots and SD */
191 static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
192 {
193         unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
194
195         if (new_cpr & 0x0007) {
196                 gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
197                 if (!(cpr & 0x0002) && !(cpr & 0x0004))
198                         mdelay(5);
199                 if (device == SPITZ_PWR_CF)
200                         cpr |= 0x0002;
201                 if (device == SPITZ_PWR_SD)
202                         cpr |= 0x0004;
203                 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
204         } else {
205                 if (device == SPITZ_PWR_CF)
206                         cpr &= ~0x0002;
207                 if (device == SPITZ_PWR_SD)
208                         cpr &= ~0x0004;
209                 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
210                         write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
211                         mdelay(1);
212                         gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
213                 } else {
214                         write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
215                 }
216         }
217 }
218
219 static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
220 {
221         /* Only need to override behaviour for slot 0 */
222         if (nr == 0)
223                 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
224         else
225                 write_scoop_reg(scoop, SCOOP_CPR, cpr);
226 }
227
228 static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
229 {
230         .dev        = &spitzscoop_device.dev,
231         .irq        = SPITZ_IRQ_GPIO_CF_IRQ,
232         .cd_irq     = SPITZ_IRQ_GPIO_CF_CD,
233         .cd_irq_str = "PCMCIA0 CD",
234 },{
235         .dev        = &spitzscoop2_device.dev,
236         .irq        = SPITZ_IRQ_GPIO_CF2_IRQ,
237         .cd_irq     = -1,
238 },
239 };
240
241 static struct scoop_pcmcia_config spitz_pcmcia_config = {
242         .devs         = &spitz_pcmcia_scoop[0],
243         .num_devs     = 2,
244         .power_ctrl   = spitz_pcmcia_pwr,
245 };
246
247 EXPORT_SYMBOL(spitzscoop_device);
248 EXPORT_SYMBOL(spitzscoop2_device);
249
250 /*
251  * Spitz Keyboard Device
252  */
253 static struct platform_device spitzkbd_device = {
254         .name           = "spitz-keyboard",
255         .id             = -1,
256 };
257
258
259 /*
260  * Spitz LEDs
261  */
262 static struct gpio_led spitz_gpio_leds[] = {
263         {
264                 .name                   = "spitz:amber:charge",
265                 .default_trigger        = "sharpsl-charge",
266                 .gpio                   = SPITZ_GPIO_LED_ORANGE,
267         },
268         {
269                 .name                   = "spitz:green:hddactivity",
270                 .default_trigger        = "ide-disk",
271                 .gpio                   = SPITZ_GPIO_LED_GREEN,
272         },
273 };
274
275 static struct gpio_led_platform_data spitz_gpio_leds_info = {
276         .leds           = spitz_gpio_leds,
277         .num_leds       = ARRAY_SIZE(spitz_gpio_leds),
278 };
279
280 static struct platform_device spitzled_device = {
281         .name           = "leds-gpio",
282         .id             = -1,
283         .dev            = {
284                 .platform_data = &spitz_gpio_leds_info,
285         },
286 };
287
288 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
289 static struct pxa2xx_spi_master spitz_spi_info = {
290         .num_chipselect = 3,
291 };
292
293 static struct ads7846_platform_data spitz_ads7846_info = {
294         .model                  = 7846,
295         .vref_delay_usecs       = 100,
296         .x_plate_ohms           = 419,
297         .y_plate_ohms           = 486,
298         .gpio_pendown           = SPITZ_GPIO_TP_INT,
299 };
300
301 static void spitz_ads7846_cs(u32 command)
302 {
303         gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
304 }
305
306 static struct pxa2xx_spi_chip spitz_ads7846_chip = {
307         .cs_control             = spitz_ads7846_cs,
308 };
309
310 static void spitz_bl_kick_battery(void)
311 {
312         void (*kick_batt)(void);
313
314         kick_batt = symbol_get(sharpsl_battery_kick);
315         if (kick_batt) {
316                 kick_batt();
317                 symbol_put(sharpsl_battery_kick);
318         }
319 }
320
321 static struct corgi_lcd_platform_data spitz_lcdcon_info = {
322         .init_mode              = CORGI_LCD_MODE_VGA,
323         .max_intensity          = 0x2f,
324         .default_intensity      = 0x1f,
325         .limit_mask             = 0x0b,
326         .gpio_backlight_cont    = SPITZ_GPIO_BACKLIGHT_CONT,
327         .gpio_backlight_on      = SPITZ_GPIO_BACKLIGHT_ON,
328         .kick_battery           = spitz_bl_kick_battery,
329 };
330
331 static void spitz_lcdcon_cs(u32 command)
332 {
333         gpio_set_value(SPITZ_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
334 }
335
336 static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
337         .cs_control     = spitz_lcdcon_cs,
338 };
339
340 static void spitz_max1111_cs(u32 command)
341 {
342         gpio_set_value(SPITZ_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
343 }
344
345 static struct pxa2xx_spi_chip spitz_max1111_chip = {
346         .cs_control     = spitz_max1111_cs,
347 };
348
349 static struct spi_board_info spitz_spi_devices[] = {
350         {
351                 .modalias       = "ads7846",
352                 .max_speed_hz   = 1200000,
353                 .bus_num        = 2,
354                 .chip_select    = 0,
355                 .platform_data  = &spitz_ads7846_info,
356                 .controller_data= &spitz_ads7846_chip,
357                 .irq            = gpio_to_irq(SPITZ_GPIO_TP_INT),
358         }, {
359                 .modalias       = "corgi-lcd",
360                 .max_speed_hz   = 50000,
361                 .bus_num        = 2,
362                 .chip_select    = 1,
363                 .platform_data  = &spitz_lcdcon_info,
364                 .controller_data= &spitz_lcdcon_chip,
365         }, {
366                 .modalias       = "max1111",
367                 .max_speed_hz   = 450000,
368                 .bus_num        = 2,
369                 .chip_select    = 2,
370                 .controller_data= &spitz_max1111_chip,
371         },
372 };
373
374 static void __init spitz_init_spi(void)
375 {
376         int err;
377
378         err = gpio_request(SPITZ_GPIO_ADS7846_CS, "ADS7846_CS");
379         if (err)
380                 return;
381
382         err = gpio_request(SPITZ_GPIO_LCDCON_CS, "LCDCON_CS");
383         if (err)
384                 goto err_free_1;
385
386         err = gpio_request(SPITZ_GPIO_MAX1111_CS, "MAX1111_CS");
387         if (err)
388                 goto err_free_2;
389
390         err = gpio_direction_output(SPITZ_GPIO_ADS7846_CS, 1);
391         if (err)
392                 goto err_free_3;
393         err = gpio_direction_output(SPITZ_GPIO_LCDCON_CS, 1);
394         if (err)
395                 goto err_free_3;
396         err = gpio_direction_output(SPITZ_GPIO_MAX1111_CS, 1);
397         if (err)
398                 goto err_free_3;
399
400         if (machine_is_akita()) {
401                 spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
402                 spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
403         }
404
405         pxa2xx_set_spi_info(2, &spitz_spi_info);
406         spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
407         return;
408
409 err_free_3:
410         gpio_free(SPITZ_GPIO_MAX1111_CS);
411 err_free_2:
412         gpio_free(SPITZ_GPIO_LCDCON_CS);
413 err_free_1:
414         gpio_free(SPITZ_GPIO_ADS7846_CS);
415 }
416 #else
417 static inline void spitz_init_spi(void) {}
418 #endif
419
420 /*
421  * MMC/SD Device
422  *
423  * The card detect interrupt isn't debounced so we delay it by 250ms
424  * to give the card a chance to fully insert/eject.
425  */
426
427 static struct pxamci_platform_data spitz_mci_platform_data;
428
429 static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data)
430 {
431         int err;
432
433         err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT");
434         if (err)
435                 goto err_out;
436
437         err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP");
438         if (err)
439                 goto err_free_1;
440
441         gpio_direction_input(SPITZ_GPIO_nSD_DETECT);
442         gpio_direction_input(SPITZ_GPIO_nSD_WP);
443
444         spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
445
446         err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
447                           IRQF_DISABLED | IRQF_TRIGGER_RISING |
448                           IRQF_TRIGGER_FALLING,
449                           "MMC card detect", data);
450         if (err) {
451                 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
452                                 __func__);
453                 goto err_free_2;
454         }
455         return 0;
456
457 err_free_2:
458         gpio_free(SPITZ_GPIO_nSD_WP);
459 err_free_1:
460         gpio_free(SPITZ_GPIO_nSD_DETECT);
461 err_out:
462         return err;
463 }
464
465 static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
466 {
467         struct pxamci_platform_data* p_d = dev->platform_data;
468
469         if (( 1 << vdd) & p_d->ocr_mask)
470                 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
471         else
472                 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
473 }
474
475 static int spitz_mci_get_ro(struct device *dev)
476 {
477         return gpio_get_value(SPITZ_GPIO_nSD_WP);
478 }
479
480 static void spitz_mci_exit(struct device *dev, void *data)
481 {
482         free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
483         gpio_free(SPITZ_GPIO_nSD_WP);
484         gpio_free(SPITZ_GPIO_nSD_DETECT);
485 }
486
487 static struct pxamci_platform_data spitz_mci_platform_data = {
488         .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
489         .init           = spitz_mci_init,
490         .get_ro         = spitz_mci_get_ro,
491         .setpower       = spitz_mci_setpower,
492         .exit           = spitz_mci_exit,
493 };
494
495
496 /*
497  * USB Host (OHCI)
498  */
499 static int spitz_ohci_init(struct device *dev)
500 {
501         int err;
502
503         err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
504         if (err)
505                 return err;
506
507         /* Only Port 2 is connected
508          * Setup USB Port 2 Output Control Register
509          */
510         UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
511
512         return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
513 }
514
515 static struct pxaohci_platform_data spitz_ohci_platform_data = {
516         .port_mode      = PMM_NPS_MODE,
517         .init           = spitz_ohci_init,
518         .flags          = ENABLE_PORT_ALL | NO_OC_PROTECTION,
519         .power_budget   = 150,
520 };
521
522
523 /*
524  * Irda
525  */
526 static int spitz_irda_startup(struct device *dev)
527 {
528         int rc;
529
530         rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
531         if (rc)
532                 goto err;
533
534         rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
535         if (rc)
536                 goto err_dir;
537
538         return 0;
539
540 err_dir:
541         gpio_free(SPITZ_GPIO_IR_ON);
542 err:
543         return rc;
544 }
545
546 static void spitz_irda_shutdown(struct device *dev)
547 {
548         gpio_free(SPITZ_GPIO_IR_ON);
549 }
550
551 static void spitz_irda_transceiver_mode(struct device *dev, int mode)
552 {
553         gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
554         pxa2xx_transceiver_mode(dev, mode);
555 }
556
557 #ifdef CONFIG_MACH_AKITA
558 static void akita_irda_transceiver_mode(struct device *dev, int mode)
559 {
560         gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF);
561         pxa2xx_transceiver_mode(dev, mode);
562 }
563 #endif
564
565 static struct pxaficp_platform_data spitz_ficp_platform_data = {
566         .transceiver_cap        = IR_SIRMODE | IR_OFF,
567         .transceiver_mode       = spitz_irda_transceiver_mode,
568         .startup                = spitz_irda_startup,
569         .shutdown               = spitz_irda_shutdown,
570 };
571
572
573 /*
574  * Spitz PXA Framebuffer
575  */
576
577 static struct pxafb_mode_info spitz_pxafb_modes[] = {
578 {
579         .pixclock       = 19231,
580         .xres           = 480,
581         .yres           = 640,
582         .bpp            = 16,
583         .hsync_len      = 40,
584         .left_margin    = 46,
585         .right_margin   = 125,
586         .vsync_len      = 3,
587         .upper_margin   = 1,
588         .lower_margin   = 0,
589         .sync           = 0,
590 },{
591         .pixclock       = 134617,
592         .xres           = 240,
593         .yres           = 320,
594         .bpp            = 16,
595         .hsync_len      = 20,
596         .left_margin    = 20,
597         .right_margin   = 46,
598         .vsync_len      = 2,
599         .upper_margin   = 1,
600         .lower_margin   = 0,
601         .sync           = 0,
602 },
603 };
604
605 static struct pxafb_mach_info spitz_pxafb_info = {
606         .modes          = &spitz_pxafb_modes[0],
607         .num_modes      = 2,
608         .fixed_modes    = 1,
609         .lcd_conn       = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
610 };
611
612 static struct mtd_partition sharpsl_nand_partitions[] = {
613         {
614                 .name = "System Area",
615                 .offset = 0,
616                 .size = 7 * 1024 * 1024,
617         },
618         {
619                 .name = "Root Filesystem",
620                 .offset = 7 * 1024 * 1024,
621         },
622         {
623                 .name = "Home Filesystem",
624                 .offset = MTDPART_OFS_APPEND,
625                 .size = MTDPART_SIZ_FULL,
626         },
627 };
628
629 static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
630
631 static struct nand_bbt_descr sharpsl_bbt = {
632         .options = 0,
633         .offs = 4,
634         .len = 2,
635         .pattern = scan_ff_pattern
636 };
637
638 static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
639         .badblock_pattern       = &sharpsl_bbt,
640         .partitions             = sharpsl_nand_partitions,
641         .nr_partitions          = ARRAY_SIZE(sharpsl_nand_partitions),
642 };
643
644 static struct resource sharpsl_nand_resources[] = {
645         {
646                 .start  = 0x0C000000,
647                 .end    = 0x0C000FFF,
648                 .flags  = IORESOURCE_MEM,
649         },
650 };
651
652 static struct platform_device sharpsl_nand_device = {
653         .name           = "sharpsl-nand",
654         .id             = -1,
655         .resource       = sharpsl_nand_resources,
656         .num_resources  = ARRAY_SIZE(sharpsl_nand_resources),
657         .dev.platform_data      = &sharpsl_nand_platform_data,
658 };
659
660
661 static struct platform_device *devices[] __initdata = {
662         &spitzscoop_device,
663         &spitzkbd_device,
664         &spitzled_device,
665         &sharpsl_nand_device,
666 };
667
668 static void spitz_poweroff(void)
669 {
670         arm_machine_restart('g');
671 }
672
673 static void spitz_restart(char mode)
674 {
675         /* Bootloader magic for a reboot */
676         if((MSC0 & 0xffff0000) == 0x7ff00000)
677                 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
678
679         spitz_poweroff();
680 }
681
682 static void __init common_init(void)
683 {
684         init_gpio_reset(SPITZ_GPIO_ON_RESET, 1);
685         pm_power_off = spitz_poweroff;
686         arm_pm_restart = spitz_restart;
687
688         if (machine_is_spitz()) {
689                 sharpsl_nand_partitions[1].size = 5 * 1024 * 1024;
690         } else if (machine_is_akita()) {
691                 sharpsl_nand_partitions[1].size = 58 * 1024 * 1024;
692         } else if (machine_is_borzoi()) {
693                 sharpsl_nand_partitions[1].size = 32 * 1024 * 1024;
694         }
695
696         PMCR = 0x00;
697
698         /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
699         PCFR |= PCFR_OPDE;
700
701         pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
702
703         spitz_init_spi();
704
705         platform_add_devices(devices, ARRAY_SIZE(devices));
706         pxa_set_mci_info(&spitz_mci_platform_data);
707         pxa_set_ohci_info(&spitz_ohci_platform_data);
708         pxa_set_ficp_info(&spitz_ficp_platform_data);
709         set_pxa_fb_info(&spitz_pxafb_info);
710         pxa_set_i2c_info(NULL);
711 }
712
713 #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
714 static void __init spitz_init(void)
715 {
716         platform_scoop_config = &spitz_pcmcia_config;
717
718         common_init();
719
720         platform_device_register(&spitzscoop2_device);
721 }
722 #endif
723
724 #ifdef CONFIG_MACH_AKITA
725 /*
726  * Akita IO Expander
727  */
728 static struct pca953x_platform_data akita_ioexp = {
729         .gpio_base              = AKITA_IOEXP_GPIO_BASE,
730 };
731
732 static struct i2c_board_info akita_i2c_board_info[] = {
733         {
734                 .type           = "max7310",
735                 .addr           = 0x18,
736                 .platform_data  = &akita_ioexp,
737         },
738 };
739
740 static struct nand_bbt_descr sharpsl_akita_bbt = {
741         .options = 0,
742         .offs = 4,
743         .len = 1,
744         .pattern = scan_ff_pattern
745 };
746
747 static struct nand_ecclayout akita_oobinfo = {
748         .eccbytes = 24,
749         .eccpos = {
750                    0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
751                    0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
752                    0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37},
753         .oobfree = {{0x08, 0x09}}
754 };
755
756 static void __init akita_init(void)
757 {
758         spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
759
760         sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
761         sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
762
763         /* We just pretend the second element of the array doesn't exist */
764         spitz_pcmcia_config.num_devs = 1;
765         platform_scoop_config = &spitz_pcmcia_config;
766
767         i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
768
769         common_init();
770 }
771 #endif
772
773 static void __init fixup_spitz(struct machine_desc *desc,
774                 struct tag *tags, char **cmdline, struct meminfo *mi)
775 {
776         sharpsl_save_param();
777         mi->nr_banks = 1;
778         mi->bank[0].start = 0xa0000000;
779         mi->bank[0].node = 0;
780         mi->bank[0].size = (64*1024*1024);
781 }
782
783 #ifdef CONFIG_MACH_SPITZ
784 MACHINE_START(SPITZ, "SHARP Spitz")
785         .phys_io        = 0x40000000,
786         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
787         .fixup          = fixup_spitz,
788         .map_io         = pxa_map_io,
789         .init_irq       = pxa27x_init_irq,
790         .init_machine   = spitz_init,
791         .timer          = &pxa_timer,
792 MACHINE_END
793 #endif
794
795 #ifdef CONFIG_MACH_BORZOI
796 MACHINE_START(BORZOI, "SHARP Borzoi")
797         .phys_io        = 0x40000000,
798         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
799         .fixup          = fixup_spitz,
800         .map_io         = pxa_map_io,
801         .init_irq       = pxa27x_init_irq,
802         .init_machine   = spitz_init,
803         .timer          = &pxa_timer,
804 MACHINE_END
805 #endif
806
807 #ifdef CONFIG_MACH_AKITA
808 MACHINE_START(AKITA, "SHARP Akita")
809         .phys_io        = 0x40000000,
810         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
811         .fixup          = fixup_spitz,
812         .map_io         = pxa_map_io,
813         .init_irq       = pxa27x_init_irq,
814         .init_machine   = akita_init,
815         .timer          = &pxa_timer,
816 MACHINE_END
817 #endif