blob: cdacea09abfa14de7157d6f14deef9a0f03fc59b [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
Philipp Zabel772885c2009-02-05 17:48:20 +0100106 /* I2S */
107 GPIO28_I2S_BITCLK_OUT,
108 GPIO29_I2S_SDATA_IN,
109 GPIO30_I2S_SDATA_OUT,
110 GPIO31_I2S_SYNC,
111
Eric Miao5e96ade2008-09-03 09:47:42 +0800112 /* MMC */
113 GPIO32_MMC_CLK,
114 GPIO112_MMC_CMD,
115 GPIO92_MMC_DAT_0,
116 GPIO109_MMC_DAT_1,
117 GPIO110_MMC_DAT_2,
118 GPIO111_MMC_DAT_3,
119
120 /* GPIOs */
121 GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
122 GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
123 GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
124 GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
125 GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
126 GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
127 GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
128 GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
129 GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
130
Eric Miao6f584cf2008-11-28 16:00:24 +0800131 /* I2C */
132 GPIO117_I2C_SCL,
133 GPIO118_I2C_SDA,
134
Eric Miao5e96ade2008-09-03 09:47:42 +0800135 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
136};
137
Richard Purdie0dd28f12005-09-13 01:25:34 -0700138/*
139 * Spitz SCOOP Device #1
140 */
141static struct resource spitz_scoop_resources[] = {
142 [0] = {
143 .start = 0x10800000,
144 .end = 0x10800fff,
145 .flags = IORESOURCE_MEM,
146 },
147};
148
149static struct scoop_config spitz_scoop_setup = {
Eric Miaofff14722008-09-05 22:15:23 +0800150 .io_dir = SPITZ_SCP_IO_DIR,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700151 .io_out = SPITZ_SCP_IO_OUT,
Eric Miaofff14722008-09-05 22:15:23 +0800152 .suspend_clr = SPITZ_SCP_SUS_CLR,
153 .suspend_set = SPITZ_SCP_SUS_SET,
154 .gpio_base = SPITZ_SCP_GPIO_BASE,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700155};
156
157struct platform_device spitzscoop_device = {
158 .name = "sharp-scoop",
159 .id = 0,
160 .dev = {
161 .platform_data = &spitz_scoop_setup,
162 },
163 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
164 .resource = spitz_scoop_resources,
165};
166
167/*
168 * Spitz SCOOP Device #2
169 */
170static struct resource spitz_scoop2_resources[] = {
171 [0] = {
172 .start = 0x08800040,
173 .end = 0x08800fff,
174 .flags = IORESOURCE_MEM,
175 },
176};
177
178static struct scoop_config spitz_scoop2_setup = {
Eric Miaofff14722008-09-05 22:15:23 +0800179 .io_dir = SPITZ_SCP2_IO_DIR,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700180 .io_out = SPITZ_SCP2_IO_OUT,
Eric Miaofff14722008-09-05 22:15:23 +0800181 .suspend_clr = SPITZ_SCP2_SUS_CLR,
182 .suspend_set = SPITZ_SCP2_SUS_SET,
183 .gpio_base = SPITZ_SCP2_GPIO_BASE,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700184};
185
186struct platform_device spitzscoop2_device = {
187 .name = "sharp-scoop",
188 .id = 1,
189 .dev = {
190 .platform_data = &spitz_scoop2_setup,
191 },
192 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
193 .resource = spitz_scoop2_resources,
194};
195
Richard Purdiea63ae442005-11-08 19:15:43 +0000196#define SPITZ_PWR_SD 0x01
197#define SPITZ_PWR_CF 0x02
198
199/* Power control is shared with between one of the CF slots and SD */
200static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
201{
202 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
203
204 if (new_cpr & 0x0007) {
Eric Miaofff14722008-09-05 22:15:23 +0800205 gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
Richard Purdiea63ae442005-11-08 19:15:43 +0000206 if (!(cpr & 0x0002) && !(cpr & 0x0004))
207 mdelay(5);
208 if (device == SPITZ_PWR_CF)
209 cpr |= 0x0002;
210 if (device == SPITZ_PWR_SD)
211 cpr |= 0x0004;
212 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
213 } else {
214 if (device == SPITZ_PWR_CF)
215 cpr &= ~0x0002;
216 if (device == SPITZ_PWR_SD)
217 cpr &= ~0x0004;
Richard Purdiea63ae442005-11-08 19:15:43 +0000218 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
Richard Purdie945b9572006-01-05 20:44:57 +0000219 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
Richard Purdiea63ae442005-11-08 19:15:43 +0000220 mdelay(1);
Eric Miaofff14722008-09-05 22:15:23 +0800221 gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
Richard Purdie945b9572006-01-05 20:44:57 +0000222 } else {
223 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
Richard Purdiea63ae442005-11-08 19:15:43 +0000224 }
225 }
226}
227
Richard Purdiea63ae442005-11-08 19:15:43 +0000228static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
229{
230 /* Only need to override behaviour for slot 0 */
231 if (nr == 0)
232 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
233 else
234 write_scoop_reg(scoop, SCOOP_CPR, cpr);
235}
236
Richard Purdie0dd28f12005-09-13 01:25:34 -0700237static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
238{
239 .dev = &spitzscoop_device.dev,
240 .irq = SPITZ_IRQ_GPIO_CF_IRQ,
241 .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
242 .cd_irq_str = "PCMCIA0 CD",
243},{
244 .dev = &spitzscoop2_device.dev,
245 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
246 .cd_irq = -1,
247},
248};
249
Richard Purdiea63ae442005-11-08 19:15:43 +0000250static struct scoop_pcmcia_config spitz_pcmcia_config = {
251 .devs = &spitz_pcmcia_scoop[0],
252 .num_devs = 2,
Richard Purdiea63ae442005-11-08 19:15:43 +0000253 .power_ctrl = spitz_pcmcia_pwr,
254};
255
256EXPORT_SYMBOL(spitzscoop_device);
257EXPORT_SYMBOL(spitzscoop2_device);
258
Richard Purdie0dd28f12005-09-13 01:25:34 -0700259/*
260 * Spitz Keyboard Device
261 */
262static struct platform_device spitzkbd_device = {
263 .name = "spitz-keyboard",
264 .id = -1,
265};
266
267
268/*
Richard Purdie31791082006-03-31 02:31:09 -0800269 * Spitz LEDs
270 */
Eric Miao4fe32242008-09-05 22:38:23 +0800271static struct gpio_led spitz_gpio_leds[] = {
272 {
273 .name = "spitz:amber:charge",
274 .default_trigger = "sharpsl-charge",
275 .gpio = SPITZ_GPIO_LED_ORANGE,
276 },
277 {
278 .name = "spitz:green:hddactivity",
279 .default_trigger = "ide-disk",
280 .gpio = SPITZ_GPIO_LED_GREEN,
281 },
282};
283
284static struct gpio_led_platform_data spitz_gpio_leds_info = {
285 .leds = spitz_gpio_leds,
286 .num_leds = ARRAY_SIZE(spitz_gpio_leds),
287};
288
Richard Purdie31791082006-03-31 02:31:09 -0800289static struct platform_device spitzled_device = {
Eric Miao4fe32242008-09-05 22:38:23 +0800290 .name = "leds-gpio",
Richard Purdie31791082006-03-31 02:31:09 -0800291 .id = -1,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700292 .dev = {
Eric Miao4fe32242008-09-05 22:38:23 +0800293 .platform_data = &spitz_gpio_leds_info,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700294 },
Richard Purdie0dd28f12005-09-13 01:25:34 -0700295};
296
Eric Miao859b7962008-09-03 12:09:24 +0800297#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
298static struct pxa2xx_spi_master spitz_spi_info = {
299 .num_chipselect = 3,
300};
Richard Purdie0dd28f12005-09-13 01:25:34 -0700301
Eric Miao3e36c0d2009-02-06 16:49:23 +0800302static void spitz_wait_for_hsync(void)
303{
304 while (gpio_get_value(SPITZ_GPIO_HSYNC))
305 cpu_relax();
306
307 while (!gpio_get_value(SPITZ_GPIO_HSYNC))
308 cpu_relax();
309}
310
Eric Miao859b7962008-09-03 12:09:24 +0800311static struct ads7846_platform_data spitz_ads7846_info = {
312 .model = 7846,
313 .vref_delay_usecs = 100,
314 .x_plate_ohms = 419,
315 .y_plate_ohms = 486,
316 .gpio_pendown = SPITZ_GPIO_TP_INT,
Eric Miao3e36c0d2009-02-06 16:49:23 +0800317 .wait_for_sync = spitz_wait_for_hsync,
Eric Miao859b7962008-09-03 12:09:24 +0800318};
Richard Purdie0dd28f12005-09-13 01:25:34 -0700319
Eric Miao859b7962008-09-03 12:09:24 +0800320static void spitz_ads7846_cs(u32 command)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700321{
Eric Miao859b7962008-09-03 12:09:24 +0800322 gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
Richard Purdie0dd28f12005-09-13 01:25:34 -0700323}
324
Eric Miao859b7962008-09-03 12:09:24 +0800325static struct pxa2xx_spi_chip spitz_ads7846_chip = {
326 .cs_control = spitz_ads7846_cs,
327};
Richard Purdie0dd28f12005-09-13 01:25:34 -0700328
Eric Miao859b7962008-09-03 12:09:24 +0800329static void spitz_bl_kick_battery(void)
330{
331 void (*kick_batt)(void);
332
333 kick_batt = symbol_get(sharpsl_battery_kick);
334 if (kick_batt) {
335 kick_batt();
336 symbol_put(sharpsl_battery_kick);
337 }
338}
339
340static struct corgi_lcd_platform_data spitz_lcdcon_info = {
341 .init_mode = CORGI_LCD_MODE_VGA,
342 .max_intensity = 0x2f,
343 .default_intensity = 0x1f,
344 .limit_mask = 0x0b,
Eric Miaoff7a4c72008-09-07 11:30:06 +0800345 .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
346 .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
Eric Miao859b7962008-09-03 12:09:24 +0800347 .kick_battery = spitz_bl_kick_battery,
348};
349
350static void spitz_lcdcon_cs(u32 command)
351{
352 gpio_set_value(SPITZ_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
353}
354
355static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
356 .cs_control = spitz_lcdcon_cs,
357};
358
359static void spitz_max1111_cs(u32 command)
360{
361 gpio_set_value(SPITZ_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
362}
363
364static struct pxa2xx_spi_chip spitz_max1111_chip = {
365 .cs_control = spitz_max1111_cs,
366};
367
368static struct spi_board_info spitz_spi_devices[] = {
369 {
370 .modalias = "ads7846",
371 .max_speed_hz = 1200000,
372 .bus_num = 2,
373 .chip_select = 0,
374 .platform_data = &spitz_ads7846_info,
375 .controller_data= &spitz_ads7846_chip,
376 .irq = gpio_to_irq(SPITZ_GPIO_TP_INT),
377 }, {
378 .modalias = "corgi-lcd",
379 .max_speed_hz = 50000,
380 .bus_num = 2,
381 .chip_select = 1,
382 .platform_data = &spitz_lcdcon_info,
383 .controller_data= &spitz_lcdcon_chip,
384 }, {
385 .modalias = "max1111",
386 .max_speed_hz = 450000,
387 .bus_num = 2,
388 .chip_select = 2,
389 .controller_data= &spitz_max1111_chip,
390 },
391};
392
393static void __init spitz_init_spi(void)
394{
395 int err;
396
397 err = gpio_request(SPITZ_GPIO_ADS7846_CS, "ADS7846_CS");
398 if (err)
399 return;
400
401 err = gpio_request(SPITZ_GPIO_LCDCON_CS, "LCDCON_CS");
402 if (err)
403 goto err_free_1;
404
405 err = gpio_request(SPITZ_GPIO_MAX1111_CS, "MAX1111_CS");
406 if (err)
407 goto err_free_2;
408
Dmitry Baryshkovb6e642e2008-10-29 11:40:46 +0800409 err = gpio_direction_output(SPITZ_GPIO_ADS7846_CS, 1);
410 if (err)
411 goto err_free_3;
412 err = gpio_direction_output(SPITZ_GPIO_LCDCON_CS, 1);
413 if (err)
414 goto err_free_3;
415 err = gpio_direction_output(SPITZ_GPIO_MAX1111_CS, 1);
416 if (err)
417 goto err_free_3;
418
Eric Miaoff7a4c72008-09-07 11:30:06 +0800419 if (machine_is_akita()) {
420 spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
421 spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
422 }
423
Eric Miao859b7962008-09-03 12:09:24 +0800424 pxa2xx_set_spi_info(2, &spitz_spi_info);
425 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
426 return;
427
Dmitry Baryshkovb6e642e2008-10-29 11:40:46 +0800428err_free_3:
429 gpio_free(SPITZ_GPIO_MAX1111_CS);
Eric Miao859b7962008-09-03 12:09:24 +0800430err_free_2:
431 gpio_free(SPITZ_GPIO_LCDCON_CS);
432err_free_1:
433 gpio_free(SPITZ_GPIO_ADS7846_CS);
434}
435#else
436static inline void spitz_init_spi(void) {}
Richard Purdie0dd28f12005-09-13 01:25:34 -0700437#endif
Richard Purdie0dd28f12005-09-13 01:25:34 -0700438
439/*
440 * MMC/SD Device
441 *
442 * The card detect interrupt isn't debounced so we delay it by 250ms
443 * to give the card a chance to fully insert/eject.
444 */
445
446static struct pxamci_platform_data spitz_mci_platform_data;
447
David Howells40220c12006-10-09 12:19:47 +0100448static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700449{
450 int err;
451
Eric Miaodd5980d2008-09-02 17:34:33 +0800452 err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT");
453 if (err)
454 goto err_out;
455
456 err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP");
457 if (err)
458 goto err_free_1;
459
460 gpio_direction_input(SPITZ_GPIO_nSD_DETECT);
461 gpio_direction_input(SPITZ_GPIO_nSD_WP);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700462
463 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
464
Russell King9ded96f2006-01-08 01:02:07 -0800465 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
Eric Miaodd5980d2008-09-02 17:34:33 +0800466 IRQF_DISABLED | IRQF_TRIGGER_RISING |
467 IRQF_TRIGGER_FALLING,
Russell King9ded96f2006-01-08 01:02:07 -0800468 "MMC card detect", data);
Eric Miaodd5980d2008-09-02 17:34:33 +0800469 if (err) {
470 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
471 __func__);
472 goto err_free_2;
473 }
474 return 0;
Richard Purdie0dd28f12005-09-13 01:25:34 -0700475
Eric Miaodd5980d2008-09-02 17:34:33 +0800476err_free_2:
477 gpio_free(SPITZ_GPIO_nSD_WP);
478err_free_1:
479 gpio_free(SPITZ_GPIO_nSD_DETECT);
480err_out:
Russell King2687bd32008-01-23 14:05:58 +0000481 return err;
Richard Purdie0dd28f12005-09-13 01:25:34 -0700482}
483
Richard Purdie0dd28f12005-09-13 01:25:34 -0700484static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
485{
486 struct pxamci_platform_data* p_d = dev->platform_data;
487
Richard Purdiea63ae442005-11-08 19:15:43 +0000488 if (( 1 << vdd) & p_d->ocr_mask)
489 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
490 else
491 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700492}
493
494static int spitz_mci_get_ro(struct device *dev)
495{
Eric Miaodd5980d2008-09-02 17:34:33 +0800496 return gpio_get_value(SPITZ_GPIO_nSD_WP);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700497}
498
499static void spitz_mci_exit(struct device *dev, void *data)
500{
501 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
Eric Miaodd5980d2008-09-02 17:34:33 +0800502 gpio_free(SPITZ_GPIO_nSD_WP);
503 gpio_free(SPITZ_GPIO_nSD_DETECT);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700504}
505
506static struct pxamci_platform_data spitz_mci_platform_data = {
507 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
508 .init = spitz_mci_init,
509 .get_ro = spitz_mci_get_ro,
510 .setpower = spitz_mci_setpower,
511 .exit = spitz_mci_exit,
512};
513
514
515/*
Richard Purdie3125c682006-01-05 20:44:52 +0000516 * USB Host (OHCI)
517 */
518static int spitz_ohci_init(struct device *dev)
519{
Eric Miaodd5980d2008-09-02 17:34:33 +0800520 int err;
Richard Purdie3125c682006-01-05 20:44:52 +0000521
Eric Miaodd5980d2008-09-02 17:34:33 +0800522 err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
523 if (err)
524 return err;
525
Eric Miao5e96ade2008-09-03 09:47:42 +0800526 /* Only Port 2 is connected
527 * Setup USB Port 2 Output Control Register
528 */
Richard Purdie3125c682006-01-05 20:44:52 +0000529 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
530
Eric Miao097b5332008-09-27 15:49:57 +0800531 return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
Richard Purdie3125c682006-01-05 20:44:52 +0000532}
533
534static struct pxaohci_platform_data spitz_ohci_platform_data = {
535 .port_mode = PMM_NPS_MODE,
536 .init = spitz_ohci_init,
Eric Miao097b5332008-09-27 15:49:57 +0800537 .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
Richard Purdie0c27c5d2006-06-08 22:44:07 +0100538 .power_budget = 150,
Richard Purdie3125c682006-01-05 20:44:52 +0000539};
540
541
542/*
Richard Purdiedc078452005-10-30 14:50:25 +0000543 * Irda
544 */
Eric Miaofff14722008-09-05 22:15:23 +0800545static int spitz_irda_startup(struct device *dev)
546{
547 int rc;
548
549 rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
550 if (rc)
551 goto err;
552
553 rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
554 if (rc)
555 goto err_dir;
556
557 return 0;
558
559err_dir:
560 gpio_free(SPITZ_GPIO_IR_ON);
561err:
562 return rc;
563}
564
565static void spitz_irda_shutdown(struct device *dev)
566{
567 gpio_free(SPITZ_GPIO_IR_ON);
568}
569
Richard Purdiedc078452005-10-30 14:50:25 +0000570static void spitz_irda_transceiver_mode(struct device *dev, int mode)
571{
Eric Miaofff14722008-09-05 22:15:23 +0800572 gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100573 pxa2xx_transceiver_mode(dev, mode);
Richard Purdiedc078452005-10-30 14:50:25 +0000574}
575
Richard Purdie94cabd02005-11-12 18:53:48 +0000576#ifdef CONFIG_MACH_AKITA
577static void akita_irda_transceiver_mode(struct device *dev, int mode)
578{
Eric Miaof72de662008-09-06 08:46:23 +0800579 gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100580 pxa2xx_transceiver_mode(dev, mode);
Richard Purdie94cabd02005-11-12 18:53:48 +0000581}
582#endif
583
Richard Purdiedc078452005-10-30 14:50:25 +0000584static struct pxaficp_platform_data spitz_ficp_platform_data = {
Eric Miaofff14722008-09-05 22:15:23 +0800585 .transceiver_cap = IR_SIRMODE | IR_OFF,
586 .transceiver_mode = spitz_irda_transceiver_mode,
587 .startup = spitz_irda_startup,
588 .shutdown = spitz_irda_shutdown,
Richard Purdiedc078452005-10-30 14:50:25 +0000589};
590
591
592/*
Richard Purdie0dd28f12005-09-13 01:25:34 -0700593 * Spitz PXA Framebuffer
594 */
Richard Purdied14b2722006-09-20 22:54:21 +0100595
596static struct pxafb_mode_info spitz_pxafb_modes[] = {
597{
598 .pixclock = 19231,
599 .xres = 480,
600 .yres = 640,
601 .bpp = 16,
602 .hsync_len = 40,
603 .left_margin = 46,
604 .right_margin = 125,
605 .vsync_len = 3,
606 .upper_margin = 1,
607 .lower_margin = 0,
608 .sync = 0,
609},{
610 .pixclock = 134617,
611 .xres = 240,
612 .yres = 320,
613 .bpp = 16,
614 .hsync_len = 20,
615 .left_margin = 20,
616 .right_margin = 46,
617 .vsync_len = 2,
618 .upper_margin = 1,
619 .lower_margin = 0,
620 .sync = 0,
621},
622};
623
624static struct pxafb_mach_info spitz_pxafb_info = {
625 .modes = &spitz_pxafb_modes[0],
626 .num_modes = 2,
627 .fixed_modes = 1,
Eric Miao79009a02008-09-03 10:00:38 +0800628 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700629};
630
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400631static struct mtd_partition sharpsl_nand_partitions[] = {
632 {
633 .name = "System Area",
634 .offset = 0,
635 .size = 7 * 1024 * 1024,
636 },
637 {
638 .name = "Root Filesystem",
639 .offset = 7 * 1024 * 1024,
640 },
641 {
642 .name = "Home Filesystem",
643 .offset = MTDPART_OFS_APPEND,
644 .size = MTDPART_SIZ_FULL,
645 },
646};
647
648static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
649
650static struct nand_bbt_descr sharpsl_bbt = {
651 .options = 0,
652 .offs = 4,
653 .len = 2,
654 .pattern = scan_ff_pattern
655};
656
657static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
658 .badblock_pattern = &sharpsl_bbt,
659 .partitions = sharpsl_nand_partitions,
660 .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
661};
662
663static struct resource sharpsl_nand_resources[] = {
664 {
665 .start = 0x0C000000,
666 .end = 0x0C000FFF,
667 .flags = IORESOURCE_MEM,
668 },
669};
670
671static struct platform_device sharpsl_nand_device = {
672 .name = "sharpsl-nand",
673 .id = -1,
674 .resource = sharpsl_nand_resources,
675 .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
676 .dev.platform_data = &sharpsl_nand_platform_data,
677};
678
Richard Purdie0dd28f12005-09-13 01:25:34 -0700679
Dmitry Baryshkove5d3bf32008-11-25 00:57:28 +0300680static struct mtd_partition sharpsl_rom_parts[] = {
681 {
682 .name ="Boot PROM Filesystem",
683 .offset = 0x00140000,
684 .size = MTDPART_SIZ_FULL,
685 },
686};
687
688static struct physmap_flash_data sharpsl_rom_data = {
689 .width = 2,
690 .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
691 .parts = sharpsl_rom_parts,
692};
693
694static struct resource sharpsl_rom_resources[] = {
695 {
696 .start = 0x00000000,
697 .end = 0x007fffff,
698 .flags = IORESOURCE_MEM,
699 },
700};
701
702static struct platform_device sharpsl_rom_device = {
703 .name = "physmap-flash",
704 .id = -1,
705 .resource = sharpsl_rom_resources,
706 .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
707 .dev.platform_data = &sharpsl_rom_data,
708};
709
Richard Purdie0dd28f12005-09-13 01:25:34 -0700710static struct platform_device *devices[] __initdata = {
711 &spitzscoop_device,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700712 &spitzkbd_device,
Richard Purdie31791082006-03-31 02:31:09 -0800713 &spitzled_device,
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400714 &sharpsl_nand_device,
Dmitry Baryshkove5d3bf32008-11-25 00:57:28 +0300715 &sharpsl_rom_device,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700716};
717
Richard Purdie74617fb2006-06-19 19:57:12 +0100718static void spitz_poweroff(void)
719{
Russell Kingbe093be2009-03-19 16:20:24 +0000720 arm_machine_restart('g', NULL);
Richard Purdie74617fb2006-06-19 19:57:12 +0100721}
722
Russell Kingbe093be2009-03-19 16:20:24 +0000723static void spitz_restart(char mode, const char *cmd)
Richard Purdie74617fb2006-06-19 19:57:12 +0100724{
725 /* Bootloader magic for a reboot */
726 if((MSC0 & 0xffff0000) == 0x7ff00000)
727 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
728
729 spitz_poweroff();
730}
731
Richard Purdie0dd28f12005-09-13 01:25:34 -0700732static void __init common_init(void)
733{
Daniel Ribeiro216e3b72009-05-05 22:43:18 -0300734 init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0);
Richard Purdie74617fb2006-06-19 19:57:12 +0100735 pm_power_off = spitz_poweroff;
736 arm_pm_restart = spitz_restart;
737
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400738 if (machine_is_spitz()) {
739 sharpsl_nand_partitions[1].size = 5 * 1024 * 1024;
740 } else if (machine_is_akita()) {
741 sharpsl_nand_partitions[1].size = 58 * 1024 * 1024;
742 } else if (machine_is_borzoi()) {
743 sharpsl_nand_partitions[1].size = 32 * 1024 * 1024;
744 }
745
Richard Purdie0dd28f12005-09-13 01:25:34 -0700746 PMCR = 0x00;
747
Richard Purdie0dd28f12005-09-13 01:25:34 -0700748 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
749 PCFR |= PCFR_OPDE;
750
Eric Miao5e96ade2008-09-03 09:47:42 +0800751 pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
Richard Purdie0dd28f12005-09-13 01:25:34 -0700752
Eric Miao859b7962008-09-03 12:09:24 +0800753 spitz_init_spi();
Richard Purdie0dd28f12005-09-13 01:25:34 -0700754
755 platform_add_devices(devices, ARRAY_SIZE(devices));
756 pxa_set_mci_info(&spitz_mci_platform_data);
Richard Purdie3125c682006-01-05 20:44:52 +0000757 pxa_set_ohci_info(&spitz_ohci_platform_data);
Richard Purdiedc078452005-10-30 14:50:25 +0000758 pxa_set_ficp_info(&spitz_ficp_platform_data);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700759 set_pxa_fb_info(&spitz_pxafb_info);
Mark Brownf8787fd2008-08-26 13:30:03 +0100760 pxa_set_i2c_info(NULL);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700761}
762
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100763#if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700764static void __init spitz_init(void)
765{
Richard Purdiea63ae442005-11-08 19:15:43 +0000766 platform_scoop_config = &spitz_pcmcia_config;
767
Richard Purdie0dd28f12005-09-13 01:25:34 -0700768 common_init();
769
770 platform_device_register(&spitzscoop2_device);
771}
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100772#endif
Richard Purdie0dd28f12005-09-13 01:25:34 -0700773
Richard Purdie94cabd02005-11-12 18:53:48 +0000774#ifdef CONFIG_MACH_AKITA
775/*
776 * Akita IO Expander
777 */
Eric Miaof72de662008-09-06 08:46:23 +0800778static struct pca953x_platform_data akita_ioexp = {
779 .gpio_base = AKITA_IOEXP_GPIO_BASE,
Richard Purdie94cabd02005-11-12 18:53:48 +0000780};
781
Eric Miaof72de662008-09-06 08:46:23 +0800782static struct i2c_board_info akita_i2c_board_info[] = {
783 {
784 .type = "max7310",
785 .addr = 0x18,
786 .platform_data = &akita_ioexp,
787 },
788};
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100789
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400790static struct nand_bbt_descr sharpsl_akita_bbt = {
791 .options = 0,
792 .offs = 4,
793 .len = 1,
794 .pattern = scan_ff_pattern
795};
796
797static struct nand_ecclayout akita_oobinfo = {
798 .eccbytes = 24,
799 .eccpos = {
800 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
801 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
802 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37},
803 .oobfree = {{0x08, 0x09}}
804};
805
Richard Purdie94cabd02005-11-12 18:53:48 +0000806static void __init akita_init(void)
807{
808 spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
809
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400810 sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
811 sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
812
Richard Purdie94cabd02005-11-12 18:53:48 +0000813 /* We just pretend the second element of the array doesn't exist */
814 spitz_pcmcia_config.num_devs = 1;
815 platform_scoop_config = &spitz_pcmcia_config;
Richard Purdie94cabd02005-11-12 18:53:48 +0000816
Eric Miaof72de662008-09-06 08:46:23 +0800817 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
Richard Purdie94cabd02005-11-12 18:53:48 +0000818
Richard Purdie94cabd02005-11-12 18:53:48 +0000819 common_init();
820}
821#endif
822
Richard Purdie0dd28f12005-09-13 01:25:34 -0700823static void __init fixup_spitz(struct machine_desc *desc,
824 struct tag *tags, char **cmdline, struct meminfo *mi)
825{
826 sharpsl_save_param();
827 mi->nr_banks = 1;
828 mi->bank[0].start = 0xa0000000;
829 mi->bank[0].node = 0;
830 mi->bank[0].size = (64*1024*1024);
831}
832
833#ifdef CONFIG_MACH_SPITZ
834MACHINE_START(SPITZ, "SHARP Spitz")
Richard Purdie0dd28f12005-09-13 01:25:34 -0700835 .phys_io = 0x40000000,
836 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
837 .fixup = fixup_spitz,
838 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100839 .init_irq = pxa27x_init_irq,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700840 .init_machine = spitz_init,
841 .timer = &pxa_timer,
842MACHINE_END
843#endif
844
845#ifdef CONFIG_MACH_BORZOI
846MACHINE_START(BORZOI, "SHARP Borzoi")
Richard Purdie0dd28f12005-09-13 01:25:34 -0700847 .phys_io = 0x40000000,
848 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
849 .fixup = fixup_spitz,
850 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100851 .init_irq = pxa27x_init_irq,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700852 .init_machine = spitz_init,
853 .timer = &pxa_timer,
854MACHINE_END
855#endif
Richard Purdie94cabd02005-11-12 18:53:48 +0000856
857#ifdef CONFIG_MACH_AKITA
858MACHINE_START(AKITA, "SHARP Akita")
Richard Purdie94cabd02005-11-12 18:53:48 +0000859 .phys_io = 0x40000000,
860 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
861 .fixup = fixup_spitz,
862 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100863 .init_irq = pxa27x_init_irq,
Richard Purdie94cabd02005-11-12 18:53:48 +0000864 .init_machine = akita_init,
865 .timer = &pxa_timer,
866MACHINE_END
867#endif