blob: 0d62d311d41ac8dfacdd4b9aba6c517968b4997d [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
Russell Kinga09e64f2008-08-05 16:14:15 +010047#include <mach/pxa-regs.h>
48#include <mach/pxa2xx-regs.h>
Eric Miao5e96ade2008-09-03 09:47:42 +080049#include <mach/mfp-pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010050#include <mach/pxa27x-udc.h>
Russell Kingafd2fc02008-08-07 11:05:25 +010051#include <mach/reset.h>
Mark Brownf8787fd2008-08-26 13:30:03 +010052#include <mach/i2c.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010053#include <mach/irda.h>
54#include <mach/mmc.h>
55#include <mach/ohci.h>
56#include <mach/udc.h>
57#include <mach/pxafb.h>
Eric Miao859b7962008-09-03 12:09:24 +080058#include <mach/pxa2xx_spi.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010059#include <mach/spitz.h>
60#include <mach/sharpsl.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070061
62#include <asm/mach/sharpsl_param.h>
63#include <asm/hardware/scoop.h>
64
65#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010066#include "devices.h"
Richard Purdie0dd28f12005-09-13 01:25:34 -070067#include "sharpsl.h"
68
Eric Miao5e96ade2008-09-03 09:47:42 +080069static unsigned long spitz_pin_config[] __initdata = {
70 /* Chip Selects */
71 GPIO78_nCS_2, /* SCOOP #2 */
Eric Miaofaf2f0a2008-11-16 15:56:58 +080072 GPIO79_nCS_3, /* NAND */
Eric Miao5e96ade2008-09-03 09:47:42 +080073 GPIO80_nCS_4, /* SCOOP #1 */
74
75 /* LCD - 16bpp Active TFT */
76 GPIO58_LCD_LDD_0,
77 GPIO59_LCD_LDD_1,
78 GPIO60_LCD_LDD_2,
79 GPIO61_LCD_LDD_3,
80 GPIO62_LCD_LDD_4,
81 GPIO63_LCD_LDD_5,
82 GPIO64_LCD_LDD_6,
83 GPIO65_LCD_LDD_7,
84 GPIO66_LCD_LDD_8,
85 GPIO67_LCD_LDD_9,
86 GPIO68_LCD_LDD_10,
87 GPIO69_LCD_LDD_11,
88 GPIO70_LCD_LDD_12,
89 GPIO71_LCD_LDD_13,
90 GPIO72_LCD_LDD_14,
91 GPIO73_LCD_LDD_15,
92 GPIO74_LCD_FCLK,
93 GPIO75_LCD_LCLK,
94 GPIO76_LCD_PCLK,
95
96 /* PC Card */
97 GPIO48_nPOE,
98 GPIO49_nPWE,
99 GPIO50_nPIOR,
100 GPIO51_nPIOW,
101 GPIO85_nPCE_1,
102 GPIO54_nPCE_2,
Eric Miao5e96ade2008-09-03 09:47:42 +0800103 GPIO55_nPREG,
104 GPIO56_nPWAIT,
105 GPIO57_nIOIS16,
Eric Miaofaf2f0a2008-11-16 15:56:58 +0800106 GPIO104_PSKTSEL,
Eric Miao5e96ade2008-09-03 09:47:42 +0800107
Philipp Zabel772885c2009-02-05 17:48:20 +0100108 /* I2S */
109 GPIO28_I2S_BITCLK_OUT,
110 GPIO29_I2S_SDATA_IN,
111 GPIO30_I2S_SDATA_OUT,
112 GPIO31_I2S_SYNC,
113
Eric Miao5e96ade2008-09-03 09:47:42 +0800114 /* MMC */
115 GPIO32_MMC_CLK,
116 GPIO112_MMC_CMD,
117 GPIO92_MMC_DAT_0,
118 GPIO109_MMC_DAT_1,
119 GPIO110_MMC_DAT_2,
120 GPIO111_MMC_DAT_3,
121
122 /* GPIOs */
123 GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
124 GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
125 GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
126 GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
127 GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
128 GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
129 GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
130 GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
131 GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
132
Eric Miao6f584cf2008-11-28 16:00:24 +0800133 /* I2C */
134 GPIO117_I2C_SCL,
135 GPIO118_I2C_SDA,
136
Eric Miao5e96ade2008-09-03 09:47:42 +0800137 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
138};
139
Richard Purdie0dd28f12005-09-13 01:25:34 -0700140/*
141 * Spitz SCOOP Device #1
142 */
143static struct resource spitz_scoop_resources[] = {
144 [0] = {
145 .start = 0x10800000,
146 .end = 0x10800fff,
147 .flags = IORESOURCE_MEM,
148 },
149};
150
151static struct scoop_config spitz_scoop_setup = {
Eric Miaofff14722008-09-05 22:15:23 +0800152 .io_dir = SPITZ_SCP_IO_DIR,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700153 .io_out = SPITZ_SCP_IO_OUT,
Eric Miaofff14722008-09-05 22:15:23 +0800154 .suspend_clr = SPITZ_SCP_SUS_CLR,
155 .suspend_set = SPITZ_SCP_SUS_SET,
156 .gpio_base = SPITZ_SCP_GPIO_BASE,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700157};
158
159struct platform_device spitzscoop_device = {
160 .name = "sharp-scoop",
161 .id = 0,
162 .dev = {
163 .platform_data = &spitz_scoop_setup,
164 },
165 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
166 .resource = spitz_scoop_resources,
167};
168
169/*
170 * Spitz SCOOP Device #2
171 */
172static struct resource spitz_scoop2_resources[] = {
173 [0] = {
174 .start = 0x08800040,
175 .end = 0x08800fff,
176 .flags = IORESOURCE_MEM,
177 },
178};
179
180static struct scoop_config spitz_scoop2_setup = {
Eric Miaofff14722008-09-05 22:15:23 +0800181 .io_dir = SPITZ_SCP2_IO_DIR,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700182 .io_out = SPITZ_SCP2_IO_OUT,
Eric Miaofff14722008-09-05 22:15:23 +0800183 .suspend_clr = SPITZ_SCP2_SUS_CLR,
184 .suspend_set = SPITZ_SCP2_SUS_SET,
185 .gpio_base = SPITZ_SCP2_GPIO_BASE,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700186};
187
188struct platform_device spitzscoop2_device = {
189 .name = "sharp-scoop",
190 .id = 1,
191 .dev = {
192 .platform_data = &spitz_scoop2_setup,
193 },
194 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
195 .resource = spitz_scoop2_resources,
196};
197
Richard Purdiea63ae442005-11-08 19:15:43 +0000198#define SPITZ_PWR_SD 0x01
199#define SPITZ_PWR_CF 0x02
200
201/* Power control is shared with between one of the CF slots and SD */
202static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
203{
204 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
205
206 if (new_cpr & 0x0007) {
Eric Miaofff14722008-09-05 22:15:23 +0800207 gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
Richard Purdiea63ae442005-11-08 19:15:43 +0000208 if (!(cpr & 0x0002) && !(cpr & 0x0004))
209 mdelay(5);
210 if (device == SPITZ_PWR_CF)
211 cpr |= 0x0002;
212 if (device == SPITZ_PWR_SD)
213 cpr |= 0x0004;
214 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
215 } else {
216 if (device == SPITZ_PWR_CF)
217 cpr &= ~0x0002;
218 if (device == SPITZ_PWR_SD)
219 cpr &= ~0x0004;
Richard Purdiea63ae442005-11-08 19:15:43 +0000220 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
Richard Purdie945b9572006-01-05 20:44:57 +0000221 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
Richard Purdiea63ae442005-11-08 19:15:43 +0000222 mdelay(1);
Eric Miaofff14722008-09-05 22:15:23 +0800223 gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
Richard Purdie945b9572006-01-05 20:44:57 +0000224 } else {
225 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
Richard Purdiea63ae442005-11-08 19:15:43 +0000226 }
227 }
228}
229
Richard Purdiea63ae442005-11-08 19:15:43 +0000230static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
231{
232 /* Only need to override behaviour for slot 0 */
233 if (nr == 0)
234 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
235 else
236 write_scoop_reg(scoop, SCOOP_CPR, cpr);
237}
238
Richard Purdie0dd28f12005-09-13 01:25:34 -0700239static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
240{
241 .dev = &spitzscoop_device.dev,
242 .irq = SPITZ_IRQ_GPIO_CF_IRQ,
243 .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
244 .cd_irq_str = "PCMCIA0 CD",
245},{
246 .dev = &spitzscoop2_device.dev,
247 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
248 .cd_irq = -1,
249},
250};
251
Richard Purdiea63ae442005-11-08 19:15:43 +0000252static struct scoop_pcmcia_config spitz_pcmcia_config = {
253 .devs = &spitz_pcmcia_scoop[0],
254 .num_devs = 2,
Richard Purdiea63ae442005-11-08 19:15:43 +0000255 .power_ctrl = spitz_pcmcia_pwr,
256};
257
258EXPORT_SYMBOL(spitzscoop_device);
259EXPORT_SYMBOL(spitzscoop2_device);
260
Richard Purdie0dd28f12005-09-13 01:25:34 -0700261/*
262 * Spitz Keyboard Device
263 */
264static struct platform_device spitzkbd_device = {
265 .name = "spitz-keyboard",
266 .id = -1,
267};
268
269
270/*
Richard Purdie31791082006-03-31 02:31:09 -0800271 * Spitz LEDs
272 */
Eric Miao4fe32242008-09-05 22:38:23 +0800273static struct gpio_led spitz_gpio_leds[] = {
274 {
275 .name = "spitz:amber:charge",
276 .default_trigger = "sharpsl-charge",
277 .gpio = SPITZ_GPIO_LED_ORANGE,
278 },
279 {
280 .name = "spitz:green:hddactivity",
281 .default_trigger = "ide-disk",
282 .gpio = SPITZ_GPIO_LED_GREEN,
283 },
284};
285
286static struct gpio_led_platform_data spitz_gpio_leds_info = {
287 .leds = spitz_gpio_leds,
288 .num_leds = ARRAY_SIZE(spitz_gpio_leds),
289};
290
Richard Purdie31791082006-03-31 02:31:09 -0800291static struct platform_device spitzled_device = {
Eric Miao4fe32242008-09-05 22:38:23 +0800292 .name = "leds-gpio",
Richard Purdie31791082006-03-31 02:31:09 -0800293 .id = -1,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700294 .dev = {
Eric Miao4fe32242008-09-05 22:38:23 +0800295 .platform_data = &spitz_gpio_leds_info,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700296 },
Richard Purdie0dd28f12005-09-13 01:25:34 -0700297};
298
Eric Miao859b7962008-09-03 12:09:24 +0800299#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
300static struct pxa2xx_spi_master spitz_spi_info = {
301 .num_chipselect = 3,
302};
Richard Purdie0dd28f12005-09-13 01:25:34 -0700303
Eric Miao859b7962008-09-03 12:09:24 +0800304static struct ads7846_platform_data spitz_ads7846_info = {
305 .model = 7846,
306 .vref_delay_usecs = 100,
307 .x_plate_ohms = 419,
308 .y_plate_ohms = 486,
309 .gpio_pendown = SPITZ_GPIO_TP_INT,
310};
Richard Purdie0dd28f12005-09-13 01:25:34 -0700311
Eric Miao859b7962008-09-03 12:09:24 +0800312static void spitz_ads7846_cs(u32 command)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700313{
Eric Miao859b7962008-09-03 12:09:24 +0800314 gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
Richard Purdie0dd28f12005-09-13 01:25:34 -0700315}
316
Eric Miao859b7962008-09-03 12:09:24 +0800317static struct pxa2xx_spi_chip spitz_ads7846_chip = {
318 .cs_control = spitz_ads7846_cs,
319};
Richard Purdie0dd28f12005-09-13 01:25:34 -0700320
Eric Miao859b7962008-09-03 12:09:24 +0800321static void spitz_bl_kick_battery(void)
322{
323 void (*kick_batt)(void);
324
325 kick_batt = symbol_get(sharpsl_battery_kick);
326 if (kick_batt) {
327 kick_batt();
328 symbol_put(sharpsl_battery_kick);
329 }
330}
331
332static struct corgi_lcd_platform_data spitz_lcdcon_info = {
333 .init_mode = CORGI_LCD_MODE_VGA,
334 .max_intensity = 0x2f,
335 .default_intensity = 0x1f,
336 .limit_mask = 0x0b,
Eric Miaoff7a4c72008-09-07 11:30:06 +0800337 .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
338 .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
Eric Miao859b7962008-09-03 12:09:24 +0800339 .kick_battery = spitz_bl_kick_battery,
340};
341
342static void spitz_lcdcon_cs(u32 command)
343{
344 gpio_set_value(SPITZ_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
345}
346
347static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
348 .cs_control = spitz_lcdcon_cs,
349};
350
351static void spitz_max1111_cs(u32 command)
352{
353 gpio_set_value(SPITZ_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
354}
355
356static struct pxa2xx_spi_chip spitz_max1111_chip = {
357 .cs_control = spitz_max1111_cs,
358};
359
360static struct spi_board_info spitz_spi_devices[] = {
361 {
362 .modalias = "ads7846",
363 .max_speed_hz = 1200000,
364 .bus_num = 2,
365 .chip_select = 0,
366 .platform_data = &spitz_ads7846_info,
367 .controller_data= &spitz_ads7846_chip,
368 .irq = gpio_to_irq(SPITZ_GPIO_TP_INT),
369 }, {
370 .modalias = "corgi-lcd",
371 .max_speed_hz = 50000,
372 .bus_num = 2,
373 .chip_select = 1,
374 .platform_data = &spitz_lcdcon_info,
375 .controller_data= &spitz_lcdcon_chip,
376 }, {
377 .modalias = "max1111",
378 .max_speed_hz = 450000,
379 .bus_num = 2,
380 .chip_select = 2,
381 .controller_data= &spitz_max1111_chip,
382 },
383};
384
385static void __init spitz_init_spi(void)
386{
387 int err;
388
389 err = gpio_request(SPITZ_GPIO_ADS7846_CS, "ADS7846_CS");
390 if (err)
391 return;
392
393 err = gpio_request(SPITZ_GPIO_LCDCON_CS, "LCDCON_CS");
394 if (err)
395 goto err_free_1;
396
397 err = gpio_request(SPITZ_GPIO_MAX1111_CS, "MAX1111_CS");
398 if (err)
399 goto err_free_2;
400
Dmitry Baryshkovb6e642e2008-10-29 11:40:46 +0800401 err = gpio_direction_output(SPITZ_GPIO_ADS7846_CS, 1);
402 if (err)
403 goto err_free_3;
404 err = gpio_direction_output(SPITZ_GPIO_LCDCON_CS, 1);
405 if (err)
406 goto err_free_3;
407 err = gpio_direction_output(SPITZ_GPIO_MAX1111_CS, 1);
408 if (err)
409 goto err_free_3;
410
Eric Miaoff7a4c72008-09-07 11:30:06 +0800411 if (machine_is_akita()) {
412 spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
413 spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
414 }
415
Eric Miao859b7962008-09-03 12:09:24 +0800416 pxa2xx_set_spi_info(2, &spitz_spi_info);
417 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
418 return;
419
Dmitry Baryshkovb6e642e2008-10-29 11:40:46 +0800420err_free_3:
421 gpio_free(SPITZ_GPIO_MAX1111_CS);
Eric Miao859b7962008-09-03 12:09:24 +0800422err_free_2:
423 gpio_free(SPITZ_GPIO_LCDCON_CS);
424err_free_1:
425 gpio_free(SPITZ_GPIO_ADS7846_CS);
426}
427#else
428static inline void spitz_init_spi(void) {}
Richard Purdie0dd28f12005-09-13 01:25:34 -0700429#endif
Richard Purdie0dd28f12005-09-13 01:25:34 -0700430
431/*
432 * MMC/SD Device
433 *
434 * The card detect interrupt isn't debounced so we delay it by 250ms
435 * to give the card a chance to fully insert/eject.
436 */
437
438static struct pxamci_platform_data spitz_mci_platform_data;
439
David Howells40220c12006-10-09 12:19:47 +0100440static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700441{
442 int err;
443
Eric Miaodd5980d2008-09-02 17:34:33 +0800444 err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT");
445 if (err)
446 goto err_out;
447
448 err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP");
449 if (err)
450 goto err_free_1;
451
452 gpio_direction_input(SPITZ_GPIO_nSD_DETECT);
453 gpio_direction_input(SPITZ_GPIO_nSD_WP);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700454
455 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
456
Russell King9ded96f2006-01-08 01:02:07 -0800457 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
Eric Miaodd5980d2008-09-02 17:34:33 +0800458 IRQF_DISABLED | IRQF_TRIGGER_RISING |
459 IRQF_TRIGGER_FALLING,
Russell King9ded96f2006-01-08 01:02:07 -0800460 "MMC card detect", data);
Eric Miaodd5980d2008-09-02 17:34:33 +0800461 if (err) {
462 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
463 __func__);
464 goto err_free_2;
465 }
466 return 0;
Richard Purdie0dd28f12005-09-13 01:25:34 -0700467
Eric Miaodd5980d2008-09-02 17:34:33 +0800468err_free_2:
469 gpio_free(SPITZ_GPIO_nSD_WP);
470err_free_1:
471 gpio_free(SPITZ_GPIO_nSD_DETECT);
472err_out:
Russell King2687bd32008-01-23 14:05:58 +0000473 return err;
Richard Purdie0dd28f12005-09-13 01:25:34 -0700474}
475
Richard Purdie0dd28f12005-09-13 01:25:34 -0700476static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
477{
478 struct pxamci_platform_data* p_d = dev->platform_data;
479
Richard Purdiea63ae442005-11-08 19:15:43 +0000480 if (( 1 << vdd) & p_d->ocr_mask)
481 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
482 else
483 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700484}
485
486static int spitz_mci_get_ro(struct device *dev)
487{
Eric Miaodd5980d2008-09-02 17:34:33 +0800488 return gpio_get_value(SPITZ_GPIO_nSD_WP);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700489}
490
491static void spitz_mci_exit(struct device *dev, void *data)
492{
493 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
Eric Miaodd5980d2008-09-02 17:34:33 +0800494 gpio_free(SPITZ_GPIO_nSD_WP);
495 gpio_free(SPITZ_GPIO_nSD_DETECT);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700496}
497
498static struct pxamci_platform_data spitz_mci_platform_data = {
499 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
500 .init = spitz_mci_init,
501 .get_ro = spitz_mci_get_ro,
502 .setpower = spitz_mci_setpower,
503 .exit = spitz_mci_exit,
504};
505
506
507/*
Richard Purdie3125c682006-01-05 20:44:52 +0000508 * USB Host (OHCI)
509 */
510static int spitz_ohci_init(struct device *dev)
511{
Eric Miaodd5980d2008-09-02 17:34:33 +0800512 int err;
Richard Purdie3125c682006-01-05 20:44:52 +0000513
Eric Miaodd5980d2008-09-02 17:34:33 +0800514 err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
515 if (err)
516 return err;
517
Eric Miao5e96ade2008-09-03 09:47:42 +0800518 /* Only Port 2 is connected
519 * Setup USB Port 2 Output Control Register
520 */
Richard Purdie3125c682006-01-05 20:44:52 +0000521 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
522
Eric Miao097b5332008-09-27 15:49:57 +0800523 return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
Richard Purdie3125c682006-01-05 20:44:52 +0000524}
525
526static struct pxaohci_platform_data spitz_ohci_platform_data = {
527 .port_mode = PMM_NPS_MODE,
528 .init = spitz_ohci_init,
Eric Miao097b5332008-09-27 15:49:57 +0800529 .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
Richard Purdie0c27c5d2006-06-08 22:44:07 +0100530 .power_budget = 150,
Richard Purdie3125c682006-01-05 20:44:52 +0000531};
532
533
534/*
Richard Purdiedc078452005-10-30 14:50:25 +0000535 * Irda
536 */
Eric Miaofff14722008-09-05 22:15:23 +0800537static int spitz_irda_startup(struct device *dev)
538{
539 int rc;
540
541 rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
542 if (rc)
543 goto err;
544
545 rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
546 if (rc)
547 goto err_dir;
548
549 return 0;
550
551err_dir:
552 gpio_free(SPITZ_GPIO_IR_ON);
553err:
554 return rc;
555}
556
557static void spitz_irda_shutdown(struct device *dev)
558{
559 gpio_free(SPITZ_GPIO_IR_ON);
560}
561
Richard Purdiedc078452005-10-30 14:50:25 +0000562static void spitz_irda_transceiver_mode(struct device *dev, int mode)
563{
Eric Miaofff14722008-09-05 22:15:23 +0800564 gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100565 pxa2xx_transceiver_mode(dev, mode);
Richard Purdiedc078452005-10-30 14:50:25 +0000566}
567
Richard Purdie94cabd02005-11-12 18:53:48 +0000568#ifdef CONFIG_MACH_AKITA
569static void akita_irda_transceiver_mode(struct device *dev, int mode)
570{
Eric Miaof72de662008-09-06 08:46:23 +0800571 gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100572 pxa2xx_transceiver_mode(dev, mode);
Richard Purdie94cabd02005-11-12 18:53:48 +0000573}
574#endif
575
Richard Purdiedc078452005-10-30 14:50:25 +0000576static struct pxaficp_platform_data spitz_ficp_platform_data = {
Eric Miaofff14722008-09-05 22:15:23 +0800577 .transceiver_cap = IR_SIRMODE | IR_OFF,
578 .transceiver_mode = spitz_irda_transceiver_mode,
579 .startup = spitz_irda_startup,
580 .shutdown = spitz_irda_shutdown,
Richard Purdiedc078452005-10-30 14:50:25 +0000581};
582
583
584/*
Richard Purdie0dd28f12005-09-13 01:25:34 -0700585 * Spitz PXA Framebuffer
586 */
Richard Purdied14b2722006-09-20 22:54:21 +0100587
588static struct pxafb_mode_info spitz_pxafb_modes[] = {
589{
590 .pixclock = 19231,
591 .xres = 480,
592 .yres = 640,
593 .bpp = 16,
594 .hsync_len = 40,
595 .left_margin = 46,
596 .right_margin = 125,
597 .vsync_len = 3,
598 .upper_margin = 1,
599 .lower_margin = 0,
600 .sync = 0,
601},{
602 .pixclock = 134617,
603 .xres = 240,
604 .yres = 320,
605 .bpp = 16,
606 .hsync_len = 20,
607 .left_margin = 20,
608 .right_margin = 46,
609 .vsync_len = 2,
610 .upper_margin = 1,
611 .lower_margin = 0,
612 .sync = 0,
613},
614};
615
616static struct pxafb_mach_info spitz_pxafb_info = {
617 .modes = &spitz_pxafb_modes[0],
618 .num_modes = 2,
619 .fixed_modes = 1,
Eric Miao79009a02008-09-03 10:00:38 +0800620 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700621};
622
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400623static struct mtd_partition sharpsl_nand_partitions[] = {
624 {
625 .name = "System Area",
626 .offset = 0,
627 .size = 7 * 1024 * 1024,
628 },
629 {
630 .name = "Root Filesystem",
631 .offset = 7 * 1024 * 1024,
632 },
633 {
634 .name = "Home Filesystem",
635 .offset = MTDPART_OFS_APPEND,
636 .size = MTDPART_SIZ_FULL,
637 },
638};
639
640static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
641
642static struct nand_bbt_descr sharpsl_bbt = {
643 .options = 0,
644 .offs = 4,
645 .len = 2,
646 .pattern = scan_ff_pattern
647};
648
649static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
650 .badblock_pattern = &sharpsl_bbt,
651 .partitions = sharpsl_nand_partitions,
652 .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
653};
654
655static struct resource sharpsl_nand_resources[] = {
656 {
657 .start = 0x0C000000,
658 .end = 0x0C000FFF,
659 .flags = IORESOURCE_MEM,
660 },
661};
662
663static struct platform_device sharpsl_nand_device = {
664 .name = "sharpsl-nand",
665 .id = -1,
666 .resource = sharpsl_nand_resources,
667 .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
668 .dev.platform_data = &sharpsl_nand_platform_data,
669};
670
Richard Purdie0dd28f12005-09-13 01:25:34 -0700671
Dmitry Baryshkove5d3bf32008-11-25 00:57:28 +0300672static struct mtd_partition sharpsl_rom_parts[] = {
673 {
674 .name ="Boot PROM Filesystem",
675 .offset = 0x00140000,
676 .size = MTDPART_SIZ_FULL,
677 },
678};
679
680static struct physmap_flash_data sharpsl_rom_data = {
681 .width = 2,
682 .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
683 .parts = sharpsl_rom_parts,
684};
685
686static struct resource sharpsl_rom_resources[] = {
687 {
688 .start = 0x00000000,
689 .end = 0x007fffff,
690 .flags = IORESOURCE_MEM,
691 },
692};
693
694static struct platform_device sharpsl_rom_device = {
695 .name = "physmap-flash",
696 .id = -1,
697 .resource = sharpsl_rom_resources,
698 .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
699 .dev.platform_data = &sharpsl_rom_data,
700};
701
Richard Purdie0dd28f12005-09-13 01:25:34 -0700702static struct platform_device *devices[] __initdata = {
703 &spitzscoop_device,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700704 &spitzkbd_device,
Richard Purdie31791082006-03-31 02:31:09 -0800705 &spitzled_device,
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400706 &sharpsl_nand_device,
Dmitry Baryshkove5d3bf32008-11-25 00:57:28 +0300707 &sharpsl_rom_device,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700708};
709
Richard Purdie74617fb2006-06-19 19:57:12 +0100710static void spitz_poweroff(void)
711{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100712 arm_machine_restart('g');
Richard Purdie74617fb2006-06-19 19:57:12 +0100713}
714
715static void spitz_restart(char mode)
716{
717 /* Bootloader magic for a reboot */
718 if((MSC0 & 0xffff0000) == 0x7ff00000)
719 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
720
721 spitz_poweroff();
722}
723
Richard Purdie0dd28f12005-09-13 01:25:34 -0700724static void __init common_init(void)
725{
Dmitry Baryshkov69fc7ee2008-10-09 16:58:13 +0100726 init_gpio_reset(SPITZ_GPIO_ON_RESET, 1);
Richard Purdie74617fb2006-06-19 19:57:12 +0100727 pm_power_off = spitz_poweroff;
728 arm_pm_restart = spitz_restart;
729
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400730 if (machine_is_spitz()) {
731 sharpsl_nand_partitions[1].size = 5 * 1024 * 1024;
732 } else if (machine_is_akita()) {
733 sharpsl_nand_partitions[1].size = 58 * 1024 * 1024;
734 } else if (machine_is_borzoi()) {
735 sharpsl_nand_partitions[1].size = 32 * 1024 * 1024;
736 }
737
Richard Purdie0dd28f12005-09-13 01:25:34 -0700738 PMCR = 0x00;
739
Richard Purdie0dd28f12005-09-13 01:25:34 -0700740 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
741 PCFR |= PCFR_OPDE;
742
Eric Miao5e96ade2008-09-03 09:47:42 +0800743 pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
Richard Purdie0dd28f12005-09-13 01:25:34 -0700744
Eric Miao859b7962008-09-03 12:09:24 +0800745 spitz_init_spi();
Richard Purdie0dd28f12005-09-13 01:25:34 -0700746
747 platform_add_devices(devices, ARRAY_SIZE(devices));
748 pxa_set_mci_info(&spitz_mci_platform_data);
Richard Purdie3125c682006-01-05 20:44:52 +0000749 pxa_set_ohci_info(&spitz_ohci_platform_data);
Richard Purdiedc078452005-10-30 14:50:25 +0000750 pxa_set_ficp_info(&spitz_ficp_platform_data);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700751 set_pxa_fb_info(&spitz_pxafb_info);
Mark Brownf8787fd2008-08-26 13:30:03 +0100752 pxa_set_i2c_info(NULL);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700753}
754
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100755#if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
Richard Purdie0dd28f12005-09-13 01:25:34 -0700756static void __init spitz_init(void)
757{
Richard Purdiea63ae442005-11-08 19:15:43 +0000758 platform_scoop_config = &spitz_pcmcia_config;
759
Richard Purdie0dd28f12005-09-13 01:25:34 -0700760 common_init();
761
762 platform_device_register(&spitzscoop2_device);
763}
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100764#endif
Richard Purdie0dd28f12005-09-13 01:25:34 -0700765
Richard Purdie94cabd02005-11-12 18:53:48 +0000766#ifdef CONFIG_MACH_AKITA
767/*
768 * Akita IO Expander
769 */
Eric Miaof72de662008-09-06 08:46:23 +0800770static struct pca953x_platform_data akita_ioexp = {
771 .gpio_base = AKITA_IOEXP_GPIO_BASE,
Richard Purdie94cabd02005-11-12 18:53:48 +0000772};
773
Eric Miaof72de662008-09-06 08:46:23 +0800774static struct i2c_board_info akita_i2c_board_info[] = {
775 {
776 .type = "max7310",
777 .addr = 0x18,
778 .platform_data = &akita_ioexp,
779 },
780};
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100781
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400782static struct nand_bbt_descr sharpsl_akita_bbt = {
783 .options = 0,
784 .offs = 4,
785 .len = 1,
786 .pattern = scan_ff_pattern
787};
788
789static struct nand_ecclayout akita_oobinfo = {
790 .eccbytes = 24,
791 .eccpos = {
792 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
793 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
794 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37},
795 .oobfree = {{0x08, 0x09}}
796};
797
Richard Purdie94cabd02005-11-12 18:53:48 +0000798static void __init akita_init(void)
799{
800 spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
801
Dmitry Baryshkov6af7a8e2008-10-16 19:17:05 +0400802 sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
803 sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
804
Richard Purdie94cabd02005-11-12 18:53:48 +0000805 /* We just pretend the second element of the array doesn't exist */
806 spitz_pcmcia_config.num_devs = 1;
807 platform_scoop_config = &spitz_pcmcia_config;
Richard Purdie94cabd02005-11-12 18:53:48 +0000808
Eric Miaof72de662008-09-06 08:46:23 +0800809 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
Richard Purdie94cabd02005-11-12 18:53:48 +0000810
Richard Purdie94cabd02005-11-12 18:53:48 +0000811 common_init();
812}
813#endif
814
Richard Purdie0dd28f12005-09-13 01:25:34 -0700815static void __init fixup_spitz(struct machine_desc *desc,
816 struct tag *tags, char **cmdline, struct meminfo *mi)
817{
818 sharpsl_save_param();
819 mi->nr_banks = 1;
820 mi->bank[0].start = 0xa0000000;
821 mi->bank[0].node = 0;
822 mi->bank[0].size = (64*1024*1024);
823}
824
825#ifdef CONFIG_MACH_SPITZ
826MACHINE_START(SPITZ, "SHARP Spitz")
Richard Purdie0dd28f12005-09-13 01:25:34 -0700827 .phys_io = 0x40000000,
828 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
829 .fixup = fixup_spitz,
830 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100831 .init_irq = pxa27x_init_irq,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700832 .init_machine = spitz_init,
833 .timer = &pxa_timer,
834MACHINE_END
835#endif
836
837#ifdef CONFIG_MACH_BORZOI
838MACHINE_START(BORZOI, "SHARP Borzoi")
Richard Purdie0dd28f12005-09-13 01:25:34 -0700839 .phys_io = 0x40000000,
840 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
841 .fixup = fixup_spitz,
842 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100843 .init_irq = pxa27x_init_irq,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700844 .init_machine = spitz_init,
845 .timer = &pxa_timer,
846MACHINE_END
847#endif
Richard Purdie94cabd02005-11-12 18:53:48 +0000848
849#ifdef CONFIG_MACH_AKITA
850MACHINE_START(AKITA, "SHARP Akita")
Richard Purdie94cabd02005-11-12 18:53:48 +0000851 .phys_io = 0x40000000,
852 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
853 .fixup = fixup_spitz,
854 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100855 .init_irq = pxa27x_init_irq,
Richard Purdie94cabd02005-11-12 18:53:48 +0000856 .init_machine = akita_init,
857 .timer = &pxa_timer,
858MACHINE_END
859#endif