blob: f697c492b2ab74fbe955994faa88b6167449a383 [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>
Eric Miao4fe32242008-09-05 22:38:23 +080023#include <linux/leds.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070024#include <linux/mmc/host.h>
Dmitry Baryshkove5d3bf32008-11-25 00:57:28 +030025#include <linux/mtd/physmap.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010026#include <linux/pm.h>
Richard Purdiec3f8f652007-09-03 00:27:00 +010027#include <linux/backlight.h>
Russell Kingfced80c2008-09-06 12:10:45 +010028#include <linux/io.h>
Eric Miaof72de662008-09-06 08:46:23 +080029#include <linux/i2c.h>
30#include <linux/i2c/pca953x.h>
Eric Miao859b7962008-09-03 12:09:24 +080031#include <linux/spi/spi.h>
32#include <linux/spi/ads7846.h>
33#include <linux/spi/corgi_lcd.h>
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +040034#include <linux/mtd/sharpsl.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070035
36#include <asm/setup.h>
37#include <asm/memory.h>
38#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010039#include <mach/hardware.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070040#include <asm/irq.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010041#include <asm/system.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070042
43#include <asm/mach/arch.h>
44#include <asm/mach/map.h>
45#include <asm/mach/irq.h>
46
Eric Miao51c62982009-01-02 23:17:22 +080047#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010048#include <mach/pxa27x-udc.h>
Russell Kingafd2fc02008-08-07 11:05:25 +010049#include <mach/reset.h>
Mark Brownf8787fd2008-08-26 13:30:03 +010050#include <mach/i2c.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010051#include <mach/irda.h>
52#include <mach/mmc.h>
53#include <mach/ohci.h>
54#include <mach/udc.h>
55#include <mach/pxafb.h>
Eric Miao859b7962008-09-03 12:09:24 +080056#include <mach/pxa2xx_spi.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010057#include <mach/spitz.h>
58#include <mach/sharpsl.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070059
60#include <asm/mach/sharpsl_param.h>
61#include <asm/hardware/scoop.h>
62
63#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010064#include "devices.h"
Richard Purdie0dd28f12005-09-13 01:25:34 -070065#include "sharpsl.h"
66
Eric Miao5e96ade2008-09-03 09:47:42 +080067static unsigned long spitz_pin_config[] __initdata = {
68 /* Chip Selects */
69 GPIO78_nCS_2, /* SCOOP #2 */
Eric Miaofaf2f0a2008-11-16 15:56:58 +080070 GPIO79_nCS_3, /* NAND */
Eric Miao5e96ade2008-09-03 09:47:42 +080071 GPIO80_nCS_4, /* SCOOP #1 */
72
73 /* LCD - 16bpp Active TFT */
74 GPIO58_LCD_LDD_0,
75 GPIO59_LCD_LDD_1,
76 GPIO60_LCD_LDD_2,
77 GPIO61_LCD_LDD_3,
78 GPIO62_LCD_LDD_4,
79 GPIO63_LCD_LDD_5,
80 GPIO64_LCD_LDD_6,
81 GPIO65_LCD_LDD_7,
82 GPIO66_LCD_LDD_8,
83 GPIO67_LCD_LDD_9,
84 GPIO68_LCD_LDD_10,
85 GPIO69_LCD_LDD_11,
86 GPIO70_LCD_LDD_12,
87 GPIO71_LCD_LDD_13,
88 GPIO72_LCD_LDD_14,
89 GPIO73_LCD_LDD_15,
90 GPIO74_LCD_FCLK,
91 GPIO75_LCD_LCLK,
92 GPIO76_LCD_PCLK,
93
94 /* PC Card */
95 GPIO48_nPOE,
96 GPIO49_nPWE,
97 GPIO50_nPIOR,
98 GPIO51_nPIOW,
99 GPIO85_nPCE_1,
100 GPIO54_nPCE_2,
Eric Miao5e96ade2008-09-03 09:47:42 +0800101 GPIO55_nPREG,
102 GPIO56_nPWAIT,
103 GPIO57_nIOIS16,
Eric Miaofaf2f0a2008-11-16 15:56:58 +0800104 GPIO104_PSKTSEL,
Eric Miao5e96ade2008-09-03 09:47:42 +0800105
106 /* MMC */
107 GPIO32_MMC_CLK,
108 GPIO112_MMC_CMD,
109 GPIO92_MMC_DAT_0,
110 GPIO109_MMC_DAT_1,
111 GPIO110_MMC_DAT_2,
112 GPIO111_MMC_DAT_3,
113
114 /* GPIOs */
115 GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
116 GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
117 GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
118 GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
119 GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
120 GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
121 GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
122 GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
123 GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
124
Eric Miao6f584cf2008-11-28 16:00:24 +0800125 /* I2C */
126 GPIO117_I2C_SCL,
127 GPIO118_I2C_SDA,
128
Eric Miao5e96ade2008-09-03 09:47:42 +0800129 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
130};
131
Richard Purdie0dd28f12005-09-13 01:25:34 -0700132/*
133 * Spitz SCOOP Device #1
134 */
135static struct resource spitz_scoop_resources[] = {
136 [0] = {
137 .start = 0x10800000,
138 .end = 0x10800fff,
139 .flags = IORESOURCE_MEM,
140 },
141};
142
143static struct scoop_config spitz_scoop_setup = {
Eric Miaofff14722008-09-05 22:15:23 +0800144 .io_dir = SPITZ_SCP_IO_DIR,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700145 .io_out = SPITZ_SCP_IO_OUT,
Eric Miaofff14722008-09-05 22:15:23 +0800146 .suspend_clr = SPITZ_SCP_SUS_CLR,
147 .suspend_set = SPITZ_SCP_SUS_SET,
148 .gpio_base = SPITZ_SCP_GPIO_BASE,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700149};
150
151struct platform_device spitzscoop_device = {
152 .name = "sharp-scoop",
153 .id = 0,
154 .dev = {
155 .platform_data = &spitz_scoop_setup,
156 },
157 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
158 .resource = spitz_scoop_resources,
159};
160
161/*
162 * Spitz SCOOP Device #2
163 */
164static struct resource spitz_scoop2_resources[] = {
165 [0] = {
166 .start = 0x08800040,
167 .end = 0x08800fff,
168 .flags = IORESOURCE_MEM,
169 },
170};
171
172static struct scoop_config spitz_scoop2_setup = {
Eric Miaofff14722008-09-05 22:15:23 +0800173 .io_dir = SPITZ_SCP2_IO_DIR,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700174 .io_out = SPITZ_SCP2_IO_OUT,
Eric Miaofff14722008-09-05 22:15:23 +0800175 .suspend_clr = SPITZ_SCP2_SUS_CLR,
176 .suspend_set = SPITZ_SCP2_SUS_SET,
177 .gpio_base = SPITZ_SCP2_GPIO_BASE,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700178};
179
180struct platform_device spitzscoop2_device = {
181 .name = "sharp-scoop",
182 .id = 1,
183 .dev = {
184 .platform_data = &spitz_scoop2_setup,
185 },
186 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
187 .resource = spitz_scoop2_resources,
188};
189
Richard Purdiea63ae442005-11-08 19:15:43 +0000190#define SPITZ_PWR_SD 0x01
191#define SPITZ_PWR_CF 0x02
192
193/* Power control is shared with between one of the CF slots and SD */
194static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
195{
196 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
197
198 if (new_cpr & 0x0007) {
Eric Miaofff14722008-09-05 22:15:23 +0800199 gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
Richard Purdiea63ae442005-11-08 19:15:43 +0000200 if (!(cpr & 0x0002) && !(cpr & 0x0004))
201 mdelay(5);
202 if (device == SPITZ_PWR_CF)
203 cpr |= 0x0002;
204 if (device == SPITZ_PWR_SD)
205 cpr |= 0x0004;
206 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
207 } else {
208 if (device == SPITZ_PWR_CF)
209 cpr &= ~0x0002;
210 if (device == SPITZ_PWR_SD)
211 cpr &= ~0x0004;
Richard Purdiea63ae442005-11-08 19:15:43 +0000212 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
Richard Purdie945b9572006-01-05 20:44:57 +0000213 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
Richard Purdiea63ae442005-11-08 19:15:43 +0000214 mdelay(1);
Eric Miaofff14722008-09-05 22:15:23 +0800215 gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
Richard Purdie945b9572006-01-05 20:44:57 +0000216 } else {
217 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
Richard Purdiea63ae442005-11-08 19:15:43 +0000218 }
219 }
220}
221
Richard Purdiea63ae442005-11-08 19:15:43 +0000222static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
223{
224 /* Only need to override behaviour for slot 0 */
225 if (nr == 0)
226 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
227 else
228 write_scoop_reg(scoop, SCOOP_CPR, cpr);
229}
230
Richard Purdie0dd28f12005-09-13 01:25:34 -0700231static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
232{
233 .dev = &spitzscoop_device.dev,
234 .irq = SPITZ_IRQ_GPIO_CF_IRQ,
235 .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
236 .cd_irq_str = "PCMCIA0 CD",
237},{
238 .dev = &spitzscoop2_device.dev,
239 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
240 .cd_irq = -1,
241},
242};
243
Richard Purdiea63ae442005-11-08 19:15:43 +0000244static struct scoop_pcmcia_config spitz_pcmcia_config = {
245 .devs = &spitz_pcmcia_scoop[0],
246 .num_devs = 2,
Richard Purdiea63ae442005-11-08 19:15:43 +0000247 .power_ctrl = spitz_pcmcia_pwr,
248};
249
250EXPORT_SYMBOL(spitzscoop_device);
251EXPORT_SYMBOL(spitzscoop2_device);
252
Richard Purdie0dd28f12005-09-13 01:25:34 -0700253/*
254 * Spitz Keyboard Device
255 */
256static struct platform_device spitzkbd_device = {
257 .name = "spitz-keyboard",
258 .id = -1,
259};
260
261
262/*
Richard Purdie31791082006-03-31 02:31:09 -0800263 * Spitz LEDs
264 */
Eric Miao4fe32242008-09-05 22:38:23 +0800265static struct gpio_led spitz_gpio_leds[] = {
266 {
267 .name = "spitz:amber:charge",
268 .default_trigger = "sharpsl-charge",
269 .gpio = SPITZ_GPIO_LED_ORANGE,
270 },
271 {
272 .name = "spitz:green:hddactivity",
273 .default_trigger = "ide-disk",
274 .gpio = SPITZ_GPIO_LED_GREEN,
275 },
276};
277
278static struct gpio_led_platform_data spitz_gpio_leds_info = {
279 .leds = spitz_gpio_leds,
280 .num_leds = ARRAY_SIZE(spitz_gpio_leds),
281};
282
Richard Purdie31791082006-03-31 02:31:09 -0800283static struct platform_device spitzled_device = {
Eric Miao4fe32242008-09-05 22:38:23 +0800284 .name = "leds-gpio",
Richard Purdie31791082006-03-31 02:31:09 -0800285 .id = -1,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700286 .dev = {
Eric Miao4fe32242008-09-05 22:38:23 +0800287 .platform_data = &spitz_gpio_leds_info,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700288 },
Richard Purdie0dd28f12005-09-13 01:25:34 -0700289};
290
Eric Miao859b7962008-09-03 12:09:24 +0800291#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
292static struct pxa2xx_spi_master spitz_spi_info = {
293 .num_chipselect = 3,
294};
Richard Purdie0dd28f12005-09-13 01:25:34 -0700295
Eric Miao859b7962008-09-03 12:09:24 +0800296static struct ads7846_platform_data spitz_ads7846_info = {
297 .model = 7846,
298 .vref_delay_usecs = 100,
299 .x_plate_ohms = 419,
300 .y_plate_ohms = 486,
301 .gpio_pendown = SPITZ_GPIO_TP_INT,
302};
Richard Purdie0dd28f12005-09-13 01:25:34 -0700303
Eric Miao859b7962008-09-03 12:09:24 +0800304static void spitz_ads7846_cs(u32 command)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700305{
Eric Miao859b7962008-09-03 12:09:24 +0800306 gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
Richard Purdie0dd28f12005-09-13 01:25:34 -0700307}
308
Eric Miao859b7962008-09-03 12:09:24 +0800309static struct pxa2xx_spi_chip spitz_ads7846_chip = {
310 .cs_control = spitz_ads7846_cs,
311};
Richard Purdie0dd28f12005-09-13 01:25:34 -0700312
Eric Miao859b7962008-09-03 12:09:24 +0800313static void spitz_bl_kick_battery(void)
314{
315 void (*kick_batt)(void);
316
317 kick_batt = symbol_get(sharpsl_battery_kick);
318 if (kick_batt) {
319 kick_batt();
320 symbol_put(sharpsl_battery_kick);
321 }
322}
323
324static struct corgi_lcd_platform_data spitz_lcdcon_info = {
325 .init_mode = CORGI_LCD_MODE_VGA,
326 .max_intensity = 0x2f,
327 .default_intensity = 0x1f,
328 .limit_mask = 0x0b,
Eric Miaoff7a4c72008-09-07 11:30:06 +0800329 .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
330 .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
Eric Miao859b7962008-09-03 12:09:24 +0800331 .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
Dmitry Baryshkovb6e642e2008-10-29 11:40:46 +0800393 err = gpio_direction_output(SPITZ_GPIO_ADS7846_CS, 1);
394 if (err)
395 goto err_free_3;
396 err = gpio_direction_output(SPITZ_GPIO_LCDCON_CS, 1);
397 if (err)
398 goto err_free_3;
399 err = gpio_direction_output(SPITZ_GPIO_MAX1111_CS, 1);
400 if (err)
401 goto err_free_3;
402
Eric Miaoff7a4c72008-09-07 11:30:06 +0800403 if (machine_is_akita()) {
404 spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
405 spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
406 }
407
Eric Miao859b7962008-09-03 12:09:24 +0800408 pxa2xx_set_spi_info(2, &spitz_spi_info);
409 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
410 return;
411
Dmitry Baryshkovb6e642e2008-10-29 11:40:46 +0800412err_free_3:
413 gpio_free(SPITZ_GPIO_MAX1111_CS);
Eric Miao859b7962008-09-03 12:09:24 +0800414err_free_2:
415 gpio_free(SPITZ_GPIO_LCDCON_CS);
416err_free_1:
417 gpio_free(SPITZ_GPIO_ADS7846_CS);
418}
419#else
420static inline void spitz_init_spi(void) {}
Richard Purdie0dd28f12005-09-13 01:25:34 -0700421#endif
Richard Purdie0dd28f12005-09-13 01:25:34 -0700422
423/*
424 * MMC/SD Device
425 *
426 * The card detect interrupt isn't debounced so we delay it by 250ms
427 * to give the card a chance to fully insert/eject.
428 */
429
430static struct pxamci_platform_data spitz_mci_platform_data;
431
David Howells40220c12006-10-09 12:19:47 +0100432static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700433{
434 int err;
435
Eric Miaodd5980d2008-09-02 17:34:33 +0800436 err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT");
437 if (err)
438 goto err_out;
439
440 err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP");
441 if (err)
442 goto err_free_1;
443
444 gpio_direction_input(SPITZ_GPIO_nSD_DETECT);
445 gpio_direction_input(SPITZ_GPIO_nSD_WP);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700446
447 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
448
Russell King9ded96f2006-01-08 01:02:07 -0800449 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
Eric Miaodd5980d2008-09-02 17:34:33 +0800450 IRQF_DISABLED | IRQF_TRIGGER_RISING |
451 IRQF_TRIGGER_FALLING,
Russell King9ded96f2006-01-08 01:02:07 -0800452 "MMC card detect", data);
Eric Miaodd5980d2008-09-02 17:34:33 +0800453 if (err) {
454 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
455 __func__);
456 goto err_free_2;
457 }
458 return 0;
Richard Purdie0dd28f12005-09-13 01:25:34 -0700459
Eric Miaodd5980d2008-09-02 17:34:33 +0800460err_free_2:
461 gpio_free(SPITZ_GPIO_nSD_WP);
462err_free_1:
463 gpio_free(SPITZ_GPIO_nSD_DETECT);
464err_out:
Russell King2687bd32008-01-23 14:05:58 +0000465 return err;
Richard Purdie0dd28f12005-09-13 01:25:34 -0700466}
467
Richard Purdie0dd28f12005-09-13 01:25:34 -0700468static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
469{
470 struct pxamci_platform_data* p_d = dev->platform_data;
471
Richard Purdiea63ae442005-11-08 19:15:43 +0000472 if (( 1 << vdd) & p_d->ocr_mask)
473 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
474 else
475 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700476}
477
478static int spitz_mci_get_ro(struct device *dev)
479{
Eric Miaodd5980d2008-09-02 17:34:33 +0800480 return gpio_get_value(SPITZ_GPIO_nSD_WP);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700481}
482
483static void spitz_mci_exit(struct device *dev, void *data)
484{
485 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
Eric Miaodd5980d2008-09-02 17:34:33 +0800486 gpio_free(SPITZ_GPIO_nSD_WP);
487 gpio_free(SPITZ_GPIO_nSD_DETECT);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700488}
489
490static struct pxamci_platform_data spitz_mci_platform_data = {
491 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
492 .init = spitz_mci_init,
493 .get_ro = spitz_mci_get_ro,
494 .setpower = spitz_mci_setpower,
495 .exit = spitz_mci_exit,
496};
497
498
499/*
Richard Purdie3125c682006-01-05 20:44:52 +0000500 * USB Host (OHCI)
501 */
502static int spitz_ohci_init(struct device *dev)
503{
Eric Miaodd5980d2008-09-02 17:34:33 +0800504 int err;
Richard Purdie3125c682006-01-05 20:44:52 +0000505
Eric Miaodd5980d2008-09-02 17:34:33 +0800506 err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
507 if (err)
508 return err;
509
Eric Miao5e96ade2008-09-03 09:47:42 +0800510 /* Only Port 2 is connected
511 * Setup USB Port 2 Output Control Register
512 */
Richard Purdie3125c682006-01-05 20:44:52 +0000513 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
514
Eric Miao097b5332008-09-27 15:49:57 +0800515 return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
Richard Purdie3125c682006-01-05 20:44:52 +0000516}
517
518static struct pxaohci_platform_data spitz_ohci_platform_data = {
519 .port_mode = PMM_NPS_MODE,
520 .init = spitz_ohci_init,
Eric Miao097b5332008-09-27 15:49:57 +0800521 .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
Richard Purdie0c27c5d2006-06-08 22:44:07 +0100522 .power_budget = 150,
Richard Purdie3125c682006-01-05 20:44:52 +0000523};
524
525
526/*
Richard Purdiedc078452005-10-30 14:50:25 +0000527 * Irda
528 */
Eric Miaofff14722008-09-05 22:15:23 +0800529static int spitz_irda_startup(struct device *dev)
530{
531 int rc;
532
533 rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
534 if (rc)
535 goto err;
536
537 rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
538 if (rc)
539 goto err_dir;
540
541 return 0;
542
543err_dir:
544 gpio_free(SPITZ_GPIO_IR_ON);
545err:
546 return rc;
547}
548
549static void spitz_irda_shutdown(struct device *dev)
550{
551 gpio_free(SPITZ_GPIO_IR_ON);
552}
553
Richard Purdiedc078452005-10-30 14:50:25 +0000554static void spitz_irda_transceiver_mode(struct device *dev, int mode)
555{
Eric Miaofff14722008-09-05 22:15:23 +0800556 gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100557 pxa2xx_transceiver_mode(dev, mode);
Richard Purdiedc078452005-10-30 14:50:25 +0000558}
559
Richard Purdie94cabd02005-11-12 18:53:48 +0000560#ifdef CONFIG_MACH_AKITA
561static void akita_irda_transceiver_mode(struct device *dev, int mode)
562{
Eric Miaof72de662008-09-06 08:46:23 +0800563 gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100564 pxa2xx_transceiver_mode(dev, mode);
Richard Purdie94cabd02005-11-12 18:53:48 +0000565}
566#endif
567
Richard Purdiedc078452005-10-30 14:50:25 +0000568static struct pxaficp_platform_data spitz_ficp_platform_data = {
Eric Miaofff14722008-09-05 22:15:23 +0800569 .transceiver_cap = IR_SIRMODE | IR_OFF,
570 .transceiver_mode = spitz_irda_transceiver_mode,
571 .startup = spitz_irda_startup,
572 .shutdown = spitz_irda_shutdown,
Richard Purdiedc078452005-10-30 14:50:25 +0000573};
574
575
576/*
Richard Purdie0dd28f12005-09-13 01:25:34 -0700577 * Spitz PXA Framebuffer
578 */
Richard Purdied14b2722006-09-20 22:54:21 +0100579
580static struct pxafb_mode_info spitz_pxafb_modes[] = {
581{
582 .pixclock = 19231,
583 .xres = 480,
584 .yres = 640,
585 .bpp = 16,
586 .hsync_len = 40,
587 .left_margin = 46,
588 .right_margin = 125,
589 .vsync_len = 3,
590 .upper_margin = 1,
591 .lower_margin = 0,
592 .sync = 0,
593},{
594 .pixclock = 134617,
595 .xres = 240,
596 .yres = 320,
597 .bpp = 16,
598 .hsync_len = 20,
599 .left_margin = 20,
600 .right_margin = 46,
601 .vsync_len = 2,
602 .upper_margin = 1,
603 .lower_margin = 0,
604 .sync = 0,
605},
606};
607
608static struct pxafb_mach_info spitz_pxafb_info = {
609 .modes = &spitz_pxafb_modes[0],
610 .num_modes = 2,
611 .fixed_modes = 1,
Eric Miao79009a02008-09-03 10:00:38 +0800612 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700613};
614
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400615static struct mtd_partition sharpsl_nand_partitions[] = {
616 {
617 .name = "System Area",
618 .offset = 0,
619 .size = 7 * 1024 * 1024,
620 },
621 {
622 .name = "Root Filesystem",
623 .offset = 7 * 1024 * 1024,
624 },
625 {
626 .name = "Home Filesystem",
627 .offset = MTDPART_OFS_APPEND,
628 .size = MTDPART_SIZ_FULL,
629 },
630};
631
632static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
633
634static struct nand_bbt_descr sharpsl_bbt = {
635 .options = 0,
636 .offs = 4,
637 .len = 2,
638 .pattern = scan_ff_pattern
639};
640
641static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
642 .badblock_pattern = &sharpsl_bbt,
643 .partitions = sharpsl_nand_partitions,
644 .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
645};
646
647static struct resource sharpsl_nand_resources[] = {
648 {
649 .start = 0x0C000000,
650 .end = 0x0C000FFF,
651 .flags = IORESOURCE_MEM,
652 },
653};
654
655static struct platform_device sharpsl_nand_device = {
656 .name = "sharpsl-nand",
657 .id = -1,
658 .resource = sharpsl_nand_resources,
659 .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
660 .dev.platform_data = &sharpsl_nand_platform_data,
661};
662
Richard Purdie0dd28f12005-09-13 01:25:34 -0700663
Dmitry Baryshkove5d3bf32008-11-25 00:57:28 +0300664static struct mtd_partition sharpsl_rom_parts[] = {
665 {
666 .name ="Boot PROM Filesystem",
667 .offset = 0x00140000,
668 .size = MTDPART_SIZ_FULL,
669 },
670};
671
672static struct physmap_flash_data sharpsl_rom_data = {
673 .width = 2,
674 .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
675 .parts = sharpsl_rom_parts,
676};
677
678static struct resource sharpsl_rom_resources[] = {
679 {
680 .start = 0x00000000,
681 .end = 0x007fffff,
682 .flags = IORESOURCE_MEM,
683 },
684};
685
686static struct platform_device sharpsl_rom_device = {
687 .name = "physmap-flash",
688 .id = -1,
689 .resource = sharpsl_rom_resources,
690 .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
691 .dev.platform_data = &sharpsl_rom_data,
692};
693
Richard Purdie0dd28f12005-09-13 01:25:34 -0700694static struct platform_device *devices[] __initdata = {
695 &spitzscoop_device,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700696 &spitzkbd_device,
Richard Purdie31791082006-03-31 02:31:09 -0800697 &spitzled_device,
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400698 &sharpsl_nand_device,
Dmitry Baryshkove5d3bf32008-11-25 00:57:28 +0300699 &sharpsl_rom_device,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700700};
701
Richard Purdie74617fb2006-06-19 19:57:12 +0100702static void spitz_poweroff(void)
703{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100704 arm_machine_restart('g');
Richard Purdie74617fb2006-06-19 19:57:12 +0100705}
706
707static void spitz_restart(char mode)
708{
709 /* Bootloader magic for a reboot */
710 if((MSC0 & 0xffff0000) == 0x7ff00000)
711 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
712
713 spitz_poweroff();
714}
715
Richard Purdie0dd28f12005-09-13 01:25:34 -0700716static void __init common_init(void)
717{
Dmitry Baryshkov69fc7ee2008-10-09 16:58:13 +0100718 init_gpio_reset(SPITZ_GPIO_ON_RESET, 1);
Richard Purdie74617fb2006-06-19 19:57:12 +0100719 pm_power_off = spitz_poweroff;
720 arm_pm_restart = spitz_restart;
721
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400722 if (machine_is_spitz()) {
723 sharpsl_nand_partitions[1].size = 5 * 1024 * 1024;
724 } else if (machine_is_akita()) {
725 sharpsl_nand_partitions[1].size = 58 * 1024 * 1024;
726 } else if (machine_is_borzoi()) {
727 sharpsl_nand_partitions[1].size = 32 * 1024 * 1024;
728 }
729
Richard Purdie0dd28f12005-09-13 01:25:34 -0700730 PMCR = 0x00;
731
Richard Purdie0dd28f12005-09-13 01:25:34 -0700732 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
733 PCFR |= PCFR_OPDE;
734
Eric Miao5e96ade2008-09-03 09:47:42 +0800735 pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
Richard Purdie0dd28f12005-09-13 01:25:34 -0700736
Eric Miao859b7962008-09-03 12:09:24 +0800737 spitz_init_spi();
Richard Purdie0dd28f12005-09-13 01:25:34 -0700738
739 platform_add_devices(devices, ARRAY_SIZE(devices));
740 pxa_set_mci_info(&spitz_mci_platform_data);
Richard Purdie3125c682006-01-05 20:44:52 +0000741 pxa_set_ohci_info(&spitz_ohci_platform_data);
Richard Purdiedc078452005-10-30 14:50:25 +0000742 pxa_set_ficp_info(&spitz_ficp_platform_data);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700743 set_pxa_fb_info(&spitz_pxafb_info);
Mark Brownf8787fd2008-08-26 13:30:03 +0100744 pxa_set_i2c_info(NULL);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700745}
746
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100747#if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700748static void __init spitz_init(void)
749{
Richard Purdiea63ae442005-11-08 19:15:43 +0000750 platform_scoop_config = &spitz_pcmcia_config;
751
Richard Purdie0dd28f12005-09-13 01:25:34 -0700752 common_init();
753
754 platform_device_register(&spitzscoop2_device);
755}
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100756#endif
Richard Purdie0dd28f12005-09-13 01:25:34 -0700757
Richard Purdie94cabd02005-11-12 18:53:48 +0000758#ifdef CONFIG_MACH_AKITA
759/*
760 * Akita IO Expander
761 */
Eric Miaof72de662008-09-06 08:46:23 +0800762static struct pca953x_platform_data akita_ioexp = {
763 .gpio_base = AKITA_IOEXP_GPIO_BASE,
Richard Purdie94cabd02005-11-12 18:53:48 +0000764};
765
Eric Miaof72de662008-09-06 08:46:23 +0800766static struct i2c_board_info akita_i2c_board_info[] = {
767 {
768 .type = "max7310",
769 .addr = 0x18,
770 .platform_data = &akita_ioexp,
771 },
772};
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100773
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400774static struct nand_bbt_descr sharpsl_akita_bbt = {
775 .options = 0,
776 .offs = 4,
777 .len = 1,
778 .pattern = scan_ff_pattern
779};
780
781static struct nand_ecclayout akita_oobinfo = {
782 .eccbytes = 24,
783 .eccpos = {
784 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
785 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
786 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37},
787 .oobfree = {{0x08, 0x09}}
788};
789
Richard Purdie94cabd02005-11-12 18:53:48 +0000790static void __init akita_init(void)
791{
792 spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
793
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400794 sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
795 sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
796
Richard Purdie94cabd02005-11-12 18:53:48 +0000797 /* We just pretend the second element of the array doesn't exist */
798 spitz_pcmcia_config.num_devs = 1;
799 platform_scoop_config = &spitz_pcmcia_config;
Richard Purdie94cabd02005-11-12 18:53:48 +0000800
Eric Miaof72de662008-09-06 08:46:23 +0800801 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
Richard Purdie94cabd02005-11-12 18:53:48 +0000802
Richard Purdie94cabd02005-11-12 18:53:48 +0000803 common_init();
804}
805#endif
806
Richard Purdie0dd28f12005-09-13 01:25:34 -0700807static void __init fixup_spitz(struct machine_desc *desc,
808 struct tag *tags, char **cmdline, struct meminfo *mi)
809{
810 sharpsl_save_param();
811 mi->nr_banks = 1;
812 mi->bank[0].start = 0xa0000000;
813 mi->bank[0].node = 0;
814 mi->bank[0].size = (64*1024*1024);
815}
816
817#ifdef CONFIG_MACH_SPITZ
818MACHINE_START(SPITZ, "SHARP Spitz")
Richard Purdie0dd28f12005-09-13 01:25:34 -0700819 .phys_io = 0x40000000,
820 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
821 .fixup = fixup_spitz,
822 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100823 .init_irq = pxa27x_init_irq,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700824 .init_machine = spitz_init,
825 .timer = &pxa_timer,
826MACHINE_END
827#endif
828
829#ifdef CONFIG_MACH_BORZOI
830MACHINE_START(BORZOI, "SHARP Borzoi")
Richard Purdie0dd28f12005-09-13 01:25:34 -0700831 .phys_io = 0x40000000,
832 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
833 .fixup = fixup_spitz,
834 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100835 .init_irq = pxa27x_init_irq,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700836 .init_machine = spitz_init,
837 .timer = &pxa_timer,
838MACHINE_END
839#endif
Richard Purdie94cabd02005-11-12 18:53:48 +0000840
841#ifdef CONFIG_MACH_AKITA
842MACHINE_START(AKITA, "SHARP Akita")
Richard Purdie94cabd02005-11-12 18:53:48 +0000843 .phys_io = 0x40000000,
844 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
845 .fixup = fixup_spitz,
846 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100847 .init_irq = pxa27x_init_irq,
Richard Purdie94cabd02005-11-12 18:53:48 +0000848 .init_machine = akita_init,
849 .timer = &pxa_timer,
850MACHINE_END
851#endif