blob: 8b06b7a749df69aa5c7318de908084fc5be01433 [file] [log] [blame]
Richard Purdie0dd28f12005-09-13 01:25:34 -07001/*
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>
Russell Kingd052d1b2005-10-29 19:07:23 +010017#include <linux/platform_device.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070018#include <linux/delay.h>
19#include <linux/major.h>
20#include <linux/fs.h>
21#include <linux/interrupt.h>
Eric Miaodd5980d2008-09-02 17:34:33 +080022#include <linux/gpio.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070023#include <linux/mmc/host.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010024#include <linux/pm.h>
Richard Purdiec3f8f652007-09-03 00:27:00 +010025#include <linux/backlight.h>
Eric Miao859b7962008-09-03 12:09:24 +080026#include <linux/spi/spi.h>
27#include <linux/spi/ads7846.h>
28#include <linux/spi/corgi_lcd.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070029
30#include <asm/setup.h>
31#include <asm/memory.h>
32#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/hardware.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070034#include <asm/irq.h>
35#include <asm/io.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010036#include <asm/system.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070037
38#include <asm/mach/arch.h>
39#include <asm/mach/map.h>
40#include <asm/mach/irq.h>
41
Russell Kinga09e64f2008-08-05 16:14:15 +010042#include <mach/pxa-regs.h>
43#include <mach/pxa2xx-regs.h>
Eric Miao5e96ade2008-09-03 09:47:42 +080044#include <mach/mfp-pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010045#include <mach/pxa27x-udc.h>
Russell Kingafd2fc02008-08-07 11:05:25 +010046#include <mach/reset.h>
Mark Brownf8787fd2008-08-26 13:30:03 +010047#include <mach/i2c.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010048#include <mach/irda.h>
49#include <mach/mmc.h>
50#include <mach/ohci.h>
51#include <mach/udc.h>
52#include <mach/pxafb.h>
Eric Miao859b7962008-09-03 12:09:24 +080053#include <mach/pxa2xx_spi.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010054#include <mach/akita.h>
55#include <mach/spitz.h>
56#include <mach/sharpsl.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070057
58#include <asm/mach/sharpsl_param.h>
59#include <asm/hardware/scoop.h>
60
61#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010062#include "devices.h"
Richard Purdie0dd28f12005-09-13 01:25:34 -070063#include "sharpsl.h"
64
Eric Miao5e96ade2008-09-03 09:47:42 +080065static unsigned long spitz_pin_config[] __initdata = {
66 /* Chip Selects */
67 GPIO78_nCS_2, /* SCOOP #2 */
68 GPIO80_nCS_4, /* SCOOP #1 */
69
70 /* LCD - 16bpp Active TFT */
71 GPIO58_LCD_LDD_0,
72 GPIO59_LCD_LDD_1,
73 GPIO60_LCD_LDD_2,
74 GPIO61_LCD_LDD_3,
75 GPIO62_LCD_LDD_4,
76 GPIO63_LCD_LDD_5,
77 GPIO64_LCD_LDD_6,
78 GPIO65_LCD_LDD_7,
79 GPIO66_LCD_LDD_8,
80 GPIO67_LCD_LDD_9,
81 GPIO68_LCD_LDD_10,
82 GPIO69_LCD_LDD_11,
83 GPIO70_LCD_LDD_12,
84 GPIO71_LCD_LDD_13,
85 GPIO72_LCD_LDD_14,
86 GPIO73_LCD_LDD_15,
87 GPIO74_LCD_FCLK,
88 GPIO75_LCD_LCLK,
89 GPIO76_LCD_PCLK,
90
91 /* PC Card */
92 GPIO48_nPOE,
93 GPIO49_nPWE,
94 GPIO50_nPIOR,
95 GPIO51_nPIOW,
96 GPIO85_nPCE_1,
97 GPIO54_nPCE_2,
98 GPIO79_PSKTSEL,
99 GPIO55_nPREG,
100 GPIO56_nPWAIT,
101 GPIO57_nIOIS16,
102
103 /* MMC */
104 GPIO32_MMC_CLK,
105 GPIO112_MMC_CMD,
106 GPIO92_MMC_DAT_0,
107 GPIO109_MMC_DAT_1,
108 GPIO110_MMC_DAT_2,
109 GPIO111_MMC_DAT_3,
110
111 /* GPIOs */
112 GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
113 GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
114 GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
115 GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
116 GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
117 GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
118 GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
119 GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
120 GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
121
122 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
123};
124
Richard Purdie0dd28f12005-09-13 01:25:34 -0700125/*
126 * Spitz SCOOP Device #1
127 */
128static struct resource spitz_scoop_resources[] = {
129 [0] = {
130 .start = 0x10800000,
131 .end = 0x10800fff,
132 .flags = IORESOURCE_MEM,
133 },
134};
135
136static struct scoop_config spitz_scoop_setup = {
137 .io_dir = SPITZ_SCP_IO_DIR,
138 .io_out = SPITZ_SCP_IO_OUT,
139 .suspend_clr = SPITZ_SCP_SUS_CLR,
140 .suspend_set = SPITZ_SCP_SUS_SET,
141};
142
143struct platform_device spitzscoop_device = {
144 .name = "sharp-scoop",
145 .id = 0,
146 .dev = {
147 .platform_data = &spitz_scoop_setup,
148 },
149 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
150 .resource = spitz_scoop_resources,
151};
152
153/*
154 * Spitz SCOOP Device #2
155 */
156static struct resource spitz_scoop2_resources[] = {
157 [0] = {
158 .start = 0x08800040,
159 .end = 0x08800fff,
160 .flags = IORESOURCE_MEM,
161 },
162};
163
164static struct scoop_config spitz_scoop2_setup = {
165 .io_dir = SPITZ_SCP2_IO_DIR,
166 .io_out = SPITZ_SCP2_IO_OUT,
167 .suspend_clr = SPITZ_SCP2_SUS_CLR,
168 .suspend_set = SPITZ_SCP2_SUS_SET,
169};
170
171struct platform_device spitzscoop2_device = {
172 .name = "sharp-scoop",
173 .id = 1,
174 .dev = {
175 .platform_data = &spitz_scoop2_setup,
176 },
177 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
178 .resource = spitz_scoop2_resources,
179};
180
Richard Purdiea63ae442005-11-08 19:15:43 +0000181#define SPITZ_PWR_SD 0x01
182#define SPITZ_PWR_CF 0x02
183
184/* Power control is shared with between one of the CF slots and SD */
185static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
186{
187 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
188
189 if (new_cpr & 0x0007) {
190 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
191 if (!(cpr & 0x0002) && !(cpr & 0x0004))
192 mdelay(5);
193 if (device == SPITZ_PWR_CF)
194 cpr |= 0x0002;
195 if (device == SPITZ_PWR_SD)
196 cpr |= 0x0004;
197 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
198 } else {
199 if (device == SPITZ_PWR_CF)
200 cpr &= ~0x0002;
201 if (device == SPITZ_PWR_SD)
202 cpr &= ~0x0004;
Richard Purdiea63ae442005-11-08 19:15:43 +0000203 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
Richard Purdie945b9572006-01-05 20:44:57 +0000204 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
Richard Purdiea63ae442005-11-08 19:15:43 +0000205 mdelay(1);
206 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
Richard Purdie945b9572006-01-05 20:44:57 +0000207 } else {
208 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
Richard Purdiea63ae442005-11-08 19:15:43 +0000209 }
210 }
211}
212
Richard Purdiea63ae442005-11-08 19:15:43 +0000213static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
214{
215 /* Only need to override behaviour for slot 0 */
216 if (nr == 0)
217 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
218 else
219 write_scoop_reg(scoop, SCOOP_CPR, cpr);
220}
221
Richard Purdie0dd28f12005-09-13 01:25:34 -0700222static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
223{
224 .dev = &spitzscoop_device.dev,
225 .irq = SPITZ_IRQ_GPIO_CF_IRQ,
226 .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
227 .cd_irq_str = "PCMCIA0 CD",
228},{
229 .dev = &spitzscoop2_device.dev,
230 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
231 .cd_irq = -1,
232},
233};
234
Richard Purdiea63ae442005-11-08 19:15:43 +0000235static struct scoop_pcmcia_config spitz_pcmcia_config = {
236 .devs = &spitz_pcmcia_scoop[0],
237 .num_devs = 2,
Richard Purdiea63ae442005-11-08 19:15:43 +0000238 .power_ctrl = spitz_pcmcia_pwr,
239};
240
241EXPORT_SYMBOL(spitzscoop_device);
242EXPORT_SYMBOL(spitzscoop2_device);
243
Richard Purdie0dd28f12005-09-13 01:25:34 -0700244/*
245 * Spitz Keyboard Device
246 */
247static struct platform_device spitzkbd_device = {
248 .name = "spitz-keyboard",
249 .id = -1,
250};
251
252
253/*
Richard Purdie31791082006-03-31 02:31:09 -0800254 * Spitz LEDs
255 */
256static struct platform_device spitzled_device = {
257 .name = "spitz-led",
258 .id = -1,
259};
260
Eric Miao859b7962008-09-03 12:09:24 +0800261#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
262static struct pxa2xx_spi_master spitz_spi_info = {
263 .num_chipselect = 3,
264};
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100265
Eric Miao859b7962008-09-03 12:09:24 +0800266static struct ads7846_platform_data spitz_ads7846_info = {
267 .model = 7846,
268 .vref_delay_usecs = 100,
269 .x_plate_ohms = 419,
270 .y_plate_ohms = 486,
271 .gpio_pendown = SPITZ_GPIO_TP_INT,
272};
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100273
Eric Miao859b7962008-09-03 12:09:24 +0800274static void spitz_ads7846_cs(u32 command)
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100275{
Eric Miao859b7962008-09-03 12:09:24 +0800276 gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100277}
278
Eric Miao859b7962008-09-03 12:09:24 +0800279static struct pxa2xx_spi_chip spitz_ads7846_chip = {
280 .cs_control = spitz_ads7846_cs,
281};
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100282
Eric Miao859b7962008-09-03 12:09:24 +0800283static void spitz_notify_intensity(int intensity)
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100284{
Eric Miao859b7962008-09-03 12:09:24 +0800285 if (machine_is_spitz() || machine_is_borzoi()) {
286 /* Bit 5 is via SCOOP */
287 if (intensity & 0x0020)
288 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
289 else
290 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100291
Eric Miao859b7962008-09-03 12:09:24 +0800292 if (intensity)
293 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
294 else
295 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
296 return;
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100297 }
Eric Miao859b7962008-09-03 12:09:24 +0800298
299 if (machine_is_akita()) {
300 /* Bit 5 is via IO-Expander */
301 if (intensity & 0x0020)
302 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT);
303 else
304 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT);
305
306 if (intensity)
307 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON);
308 else
309 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON);
310 return;
311 }
312}
313
314static void spitz_bl_kick_battery(void)
315{
316 void (*kick_batt)(void);
317
318 kick_batt = symbol_get(sharpsl_battery_kick);
319 if (kick_batt) {
320 kick_batt();
321 symbol_put(sharpsl_battery_kick);
322 }
323}
324
325static struct corgi_lcd_platform_data spitz_lcdcon_info = {
326 .init_mode = CORGI_LCD_MODE_VGA,
327 .max_intensity = 0x2f,
328 .default_intensity = 0x1f,
329 .limit_mask = 0x0b,
330 .notify = spitz_notify_intensity,
331 .kick_battery = spitz_bl_kick_battery,
332};
333
334static void spitz_lcdcon_cs(u32 command)
335{
336 gpio_set_value(SPITZ_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
337}
338
339static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
340 .cs_control = spitz_lcdcon_cs,
341};
342
343static void spitz_max1111_cs(u32 command)
344{
345 gpio_set_value(SPITZ_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
346}
347
348static struct pxa2xx_spi_chip spitz_max1111_chip = {
349 .cs_control = spitz_max1111_cs,
350};
351
352static struct spi_board_info spitz_spi_devices[] = {
353 {
354 .modalias = "ads7846",
355 .max_speed_hz = 1200000,
356 .bus_num = 2,
357 .chip_select = 0,
358 .platform_data = &spitz_ads7846_info,
359 .controller_data= &spitz_ads7846_chip,
360 .irq = gpio_to_irq(SPITZ_GPIO_TP_INT),
361 }, {
362 .modalias = "corgi-lcd",
363 .max_speed_hz = 50000,
364 .bus_num = 2,
365 .chip_select = 1,
366 .platform_data = &spitz_lcdcon_info,
367 .controller_data= &spitz_lcdcon_chip,
368 }, {
369 .modalias = "max1111",
370 .max_speed_hz = 450000,
371 .bus_num = 2,
372 .chip_select = 2,
373 .controller_data= &spitz_max1111_chip,
374 },
375};
376
377static void __init spitz_init_spi(void)
378{
379 int err;
380
381 err = gpio_request(SPITZ_GPIO_ADS7846_CS, "ADS7846_CS");
382 if (err)
383 return;
384
385 err = gpio_request(SPITZ_GPIO_LCDCON_CS, "LCDCON_CS");
386 if (err)
387 goto err_free_1;
388
389 err = gpio_request(SPITZ_GPIO_MAX1111_CS, "MAX1111_CS");
390 if (err)
391 goto err_free_2;
392
393 pxa2xx_set_spi_info(2, &spitz_spi_info);
394 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
395 return;
396
397err_free_2:
398 gpio_free(SPITZ_GPIO_LCDCON_CS);
399err_free_1:
400 gpio_free(SPITZ_GPIO_ADS7846_CS);
401}
402#else
403static inline void spitz_init_spi(void) {}
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100404#endif
Richard Purdie0dd28f12005-09-13 01:25:34 -0700405
406/*
407 * MMC/SD Device
408 *
409 * The card detect interrupt isn't debounced so we delay it by 250ms
410 * to give the card a chance to fully insert/eject.
411 */
412
413static struct pxamci_platform_data spitz_mci_platform_data;
414
David Howells40220c12006-10-09 12:19:47 +0100415static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700416{
417 int err;
418
Eric Miaodd5980d2008-09-02 17:34:33 +0800419 err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT");
420 if (err)
421 goto err_out;
422
423 err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP");
424 if (err)
425 goto err_free_1;
426
427 gpio_direction_input(SPITZ_GPIO_nSD_DETECT);
428 gpio_direction_input(SPITZ_GPIO_nSD_WP);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700429
430 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
431
Russell King9ded96f2006-01-08 01:02:07 -0800432 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
Eric Miaodd5980d2008-09-02 17:34:33 +0800433 IRQF_DISABLED | IRQF_TRIGGER_RISING |
434 IRQF_TRIGGER_FALLING,
Russell King9ded96f2006-01-08 01:02:07 -0800435 "MMC card detect", data);
Eric Miaodd5980d2008-09-02 17:34:33 +0800436 if (err) {
437 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
438 __func__);
439 goto err_free_2;
440 }
441 return 0;
Richard Purdie0dd28f12005-09-13 01:25:34 -0700442
Eric Miaodd5980d2008-09-02 17:34:33 +0800443err_free_2:
444 gpio_free(SPITZ_GPIO_nSD_WP);
445err_free_1:
446 gpio_free(SPITZ_GPIO_nSD_DETECT);
447err_out:
Russell King2687bd32008-01-23 14:05:58 +0000448 return err;
Richard Purdie0dd28f12005-09-13 01:25:34 -0700449}
450
Richard Purdie0dd28f12005-09-13 01:25:34 -0700451static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
452{
453 struct pxamci_platform_data* p_d = dev->platform_data;
454
Richard Purdiea63ae442005-11-08 19:15:43 +0000455 if (( 1 << vdd) & p_d->ocr_mask)
456 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
457 else
458 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700459}
460
461static int spitz_mci_get_ro(struct device *dev)
462{
Eric Miaodd5980d2008-09-02 17:34:33 +0800463 return gpio_get_value(SPITZ_GPIO_nSD_WP);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700464}
465
466static void spitz_mci_exit(struct device *dev, void *data)
467{
468 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
Eric Miaodd5980d2008-09-02 17:34:33 +0800469 gpio_free(SPITZ_GPIO_nSD_WP);
470 gpio_free(SPITZ_GPIO_nSD_DETECT);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700471}
472
473static struct pxamci_platform_data spitz_mci_platform_data = {
474 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
475 .init = spitz_mci_init,
476 .get_ro = spitz_mci_get_ro,
477 .setpower = spitz_mci_setpower,
478 .exit = spitz_mci_exit,
479};
480
481
482/*
Richard Purdie3125c682006-01-05 20:44:52 +0000483 * USB Host (OHCI)
484 */
485static int spitz_ohci_init(struct device *dev)
486{
Eric Miaodd5980d2008-09-02 17:34:33 +0800487 int err;
488
489 err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
490 if (err)
491 return err;
492
Eric Miao5e96ade2008-09-03 09:47:42 +0800493 /* Only Port 2 is connected
494 * Setup USB Port 2 Output Control Register
495 */
Richard Purdie3125c682006-01-05 20:44:52 +0000496 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
497
Eric Miaodd5980d2008-09-02 17:34:33 +0800498 gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
Richard Purdie3125c682006-01-05 20:44:52 +0000499
500 UHCHR = (UHCHR) &
501 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
502
503 UHCRHDA |= UHCRHDA_NOCP;
504
505 return 0;
506}
507
508static struct pxaohci_platform_data spitz_ohci_platform_data = {
509 .port_mode = PMM_NPS_MODE,
510 .init = spitz_ohci_init,
Richard Purdie0c27c5d2006-06-08 22:44:07 +0100511 .power_budget = 150,
Richard Purdie3125c682006-01-05 20:44:52 +0000512};
513
514
515/*
Richard Purdiedc078452005-10-30 14:50:25 +0000516 * Irda
517 */
518static void spitz_irda_transceiver_mode(struct device *dev, int mode)
519{
520 if (mode & IR_OFF)
521 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
522 else
523 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100524 pxa2xx_transceiver_mode(dev, mode);
Richard Purdiedc078452005-10-30 14:50:25 +0000525}
526
Richard Purdie94cabd02005-11-12 18:53:48 +0000527#ifdef CONFIG_MACH_AKITA
528static void akita_irda_transceiver_mode(struct device *dev, int mode)
529{
530 if (mode & IR_OFF)
531 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
532 else
533 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100534 pxa2xx_transceiver_mode(dev, mode);
Richard Purdie94cabd02005-11-12 18:53:48 +0000535}
536#endif
537
Richard Purdiedc078452005-10-30 14:50:25 +0000538static struct pxaficp_platform_data spitz_ficp_platform_data = {
539 .transceiver_cap = IR_SIRMODE | IR_OFF,
540 .transceiver_mode = spitz_irda_transceiver_mode,
541};
542
543
544/*
Richard Purdie0dd28f12005-09-13 01:25:34 -0700545 * Spitz PXA Framebuffer
546 */
Richard Purdied14b2722006-09-20 22:54:21 +0100547
548static struct pxafb_mode_info spitz_pxafb_modes[] = {
549{
550 .pixclock = 19231,
551 .xres = 480,
552 .yres = 640,
553 .bpp = 16,
554 .hsync_len = 40,
555 .left_margin = 46,
556 .right_margin = 125,
557 .vsync_len = 3,
558 .upper_margin = 1,
559 .lower_margin = 0,
560 .sync = 0,
561},{
562 .pixclock = 134617,
563 .xres = 240,
564 .yres = 320,
565 .bpp = 16,
566 .hsync_len = 20,
567 .left_margin = 20,
568 .right_margin = 46,
569 .vsync_len = 2,
570 .upper_margin = 1,
571 .lower_margin = 0,
572 .sync = 0,
573},
574};
575
576static struct pxafb_mach_info spitz_pxafb_info = {
577 .modes = &spitz_pxafb_modes[0],
578 .num_modes = 2,
579 .fixed_modes = 1,
Eric Miao79009a02008-09-03 10:00:38 +0800580 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700581};
582
583
584static struct platform_device *devices[] __initdata = {
585 &spitzscoop_device,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700586 &spitzkbd_device,
Richard Purdie31791082006-03-31 02:31:09 -0800587 &spitzled_device,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700588};
589
Richard Purdie74617fb2006-06-19 19:57:12 +0100590static void spitz_poweroff(void)
591{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100592 arm_machine_restart('g');
Richard Purdie74617fb2006-06-19 19:57:12 +0100593}
594
595static void spitz_restart(char mode)
596{
597 /* Bootloader magic for a reboot */
598 if((MSC0 & 0xffff0000) == 0x7ff00000)
599 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
600
601 spitz_poweroff();
602}
603
Richard Purdie0dd28f12005-09-13 01:25:34 -0700604static void __init common_init(void)
605{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100606 init_gpio_reset(SPITZ_GPIO_ON_RESET);
Richard Purdie74617fb2006-06-19 19:57:12 +0100607 pm_power_off = spitz_poweroff;
608 arm_pm_restart = spitz_restart;
609
Richard Purdie0dd28f12005-09-13 01:25:34 -0700610 PMCR = 0x00;
611
Richard Purdie0dd28f12005-09-13 01:25:34 -0700612 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
613 PCFR |= PCFR_OPDE;
614
Eric Miao5e96ade2008-09-03 09:47:42 +0800615 pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
Richard Purdie0dd28f12005-09-13 01:25:34 -0700616
Eric Miao859b7962008-09-03 12:09:24 +0800617 spitz_init_spi();
Richard Purdie0dd28f12005-09-13 01:25:34 -0700618
619 platform_add_devices(devices, ARRAY_SIZE(devices));
620 pxa_set_mci_info(&spitz_mci_platform_data);
Richard Purdie3125c682006-01-05 20:44:52 +0000621 pxa_set_ohci_info(&spitz_ohci_platform_data);
Richard Purdiedc078452005-10-30 14:50:25 +0000622 pxa_set_ficp_info(&spitz_ficp_platform_data);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700623 set_pxa_fb_info(&spitz_pxafb_info);
Mark Brownf8787fd2008-08-26 13:30:03 +0100624 pxa_set_i2c_info(NULL);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700625}
626
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100627#if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700628static void __init spitz_init(void)
629{
Richard Purdiea63ae442005-11-08 19:15:43 +0000630 platform_scoop_config = &spitz_pcmcia_config;
631
Richard Purdie0dd28f12005-09-13 01:25:34 -0700632 common_init();
633
634 platform_device_register(&spitzscoop2_device);
635}
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100636#endif
Richard Purdie0dd28f12005-09-13 01:25:34 -0700637
Richard Purdie94cabd02005-11-12 18:53:48 +0000638#ifdef CONFIG_MACH_AKITA
639/*
640 * Akita IO Expander
641 */
642struct platform_device akitaioexp_device = {
643 .name = "akita-ioexp",
644 .id = -1,
645};
646
Richard Purdiebd8f1032006-03-26 21:40:27 +0100647EXPORT_SYMBOL_GPL(akitaioexp_device);
648
Richard Purdie94cabd02005-11-12 18:53:48 +0000649static void __init akita_init(void)
650{
651 spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
652
653 /* We just pretend the second element of the array doesn't exist */
654 spitz_pcmcia_config.num_devs = 1;
655 platform_scoop_config = &spitz_pcmcia_config;
Richard Purdie94cabd02005-11-12 18:53:48 +0000656
657 platform_device_register(&akitaioexp_device);
658
659 spitzscoop_device.dev.parent = &akitaioexp_device.dev;
660 common_init();
661}
662#endif
663
Richard Purdie0dd28f12005-09-13 01:25:34 -0700664static void __init fixup_spitz(struct machine_desc *desc,
665 struct tag *tags, char **cmdline, struct meminfo *mi)
666{
667 sharpsl_save_param();
668 mi->nr_banks = 1;
669 mi->bank[0].start = 0xa0000000;
670 mi->bank[0].node = 0;
671 mi->bank[0].size = (64*1024*1024);
672}
673
674#ifdef CONFIG_MACH_SPITZ
675MACHINE_START(SPITZ, "SHARP Spitz")
Richard Purdie0dd28f12005-09-13 01:25:34 -0700676 .phys_io = 0x40000000,
677 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
678 .fixup = fixup_spitz,
679 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100680 .init_irq = pxa27x_init_irq,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700681 .init_machine = spitz_init,
682 .timer = &pxa_timer,
683MACHINE_END
684#endif
685
686#ifdef CONFIG_MACH_BORZOI
687MACHINE_START(BORZOI, "SHARP Borzoi")
Richard Purdie0dd28f12005-09-13 01:25:34 -0700688 .phys_io = 0x40000000,
689 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
690 .fixup = fixup_spitz,
691 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100692 .init_irq = pxa27x_init_irq,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700693 .init_machine = spitz_init,
694 .timer = &pxa_timer,
695MACHINE_END
696#endif
Richard Purdie94cabd02005-11-12 18:53:48 +0000697
698#ifdef CONFIG_MACH_AKITA
699MACHINE_START(AKITA, "SHARP Akita")
Richard Purdie94cabd02005-11-12 18:53:48 +0000700 .phys_io = 0x40000000,
701 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
702 .fixup = fixup_spitz,
703 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100704 .init_irq = pxa27x_init_irq,
Richard Purdie94cabd02005-11-12 18:53:48 +0000705 .init_machine = akita_init,
706 .timer = &pxa_timer,
707MACHINE_END
708#endif