blob: 461af1c582bb9f57a92bd9f1273f0dd0d433ac7c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-pxa/poodle.c
3 *
4 * Support for the SHARP Poodle Board.
5 *
6 * Based on:
7 * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre
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 * Change Log
14 * 12-Dec-2002 Sharp Corporation for Poodle
15 * John Lenz <lenz@cs.wisc.edu> updates to 2.6
16 */
17#include <linux/kernel.h>
18#include <linux/init.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010019#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/fb.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010021#include <linux/pm.h>
Richard Purdie88660352006-06-19 19:58:51 +010022#include <linux/delay.h>
Eric Miaoce529142008-07-18 08:59:04 +080023#include <linux/gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <asm/mach-types.h>
27#include <asm/irq.h>
28#include <asm/setup.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010029#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33#include <asm/mach/irq.h>
34
Russell Kinga09e64f2008-08-05 16:14:15 +010035#include <mach/pxa-regs.h>
36#include <mach/pxa2xx-regs.h>
Eric Miao26b4c8d2008-07-18 09:05:17 +080037#include <mach/mfp-pxa25x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010038#include <mach/mmc.h>
39#include <mach/udc.h>
Mark Brownf8787fd2008-08-26 13:30:03 +010040#include <mach/i2c.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010041#include <mach/irda.h>
42#include <mach/poodle.h>
43#include <mach/pxafb.h>
44#include <mach/sharpsl.h>
45#include <mach/ssp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47#include <asm/hardware/scoop.h>
48#include <asm/hardware/locomo.h>
49#include <asm/mach/sharpsl_param.h>
50
51#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010052#include "devices.h"
Richard Purdiefaed5682006-06-19 20:46:05 +010053#include "sharpsl.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Eric Miao26b4c8d2008-07-18 09:05:17 +080055static unsigned long poodle_pin_config[] __initdata = {
56 /* I/O */
57 GPIO79_nCS_3,
58 GPIO80_nCS_4,
59 GPIO18_RDY,
60
61 /* Clock */
62 GPIO12_32KHz,
63
64 /* SSP1 */
65 GPIO23_SSP1_SCLK,
66 GPIO24_SSP1_SFRM,
67 GPIO25_SSP1_TXD,
68 GPIO26_SSP1_RXD,
69
70 /* I2S */
71 GPIO28_I2S_BITCLK_OUT,
72 GPIO29_I2S_SDATA_IN,
73 GPIO30_I2S_SDATA_OUT,
74 GPIO31_I2S_SYNC,
75 GPIO32_I2S_SYSCLK,
76
77 /* Infra-Red */
78 GPIO47_FICP_TXD,
79 GPIO46_FICP_RXD,
80
81 /* FFUART */
82 GPIO40_FFUART_DTR,
83 GPIO41_FFUART_RTS,
84 GPIO39_FFUART_TXD,
85 GPIO37_FFUART_DSR,
86 GPIO34_FFUART_RXD,
87 GPIO35_FFUART_CTS,
88
89 /* LCD */
90 GPIO58_LCD_LDD_0,
91 GPIO59_LCD_LDD_1,
92 GPIO60_LCD_LDD_2,
93 GPIO61_LCD_LDD_3,
94 GPIO62_LCD_LDD_4,
95 GPIO63_LCD_LDD_5,
96 GPIO64_LCD_LDD_6,
97 GPIO65_LCD_LDD_7,
98 GPIO66_LCD_LDD_8,
99 GPIO67_LCD_LDD_9,
100 GPIO68_LCD_LDD_10,
101 GPIO69_LCD_LDD_11,
102 GPIO70_LCD_LDD_12,
103 GPIO71_LCD_LDD_13,
104 GPIO72_LCD_LDD_14,
105 GPIO73_LCD_LDD_15,
106 GPIO74_LCD_FCLK,
107 GPIO75_LCD_LCLK,
108 GPIO76_LCD_PCLK,
109 GPIO77_LCD_ACBIAS,
110
111 /* PC Card */
112 GPIO48_nPOE,
113 GPIO49_nPWE,
114 GPIO50_nPIOR,
115 GPIO51_nPIOW,
116 GPIO52_nPCE_1,
117 GPIO53_nPCE_2,
118 GPIO54_nPSKTSEL,
119 GPIO55_nPREG,
120 GPIO56_nPWAIT,
121 GPIO57_nIOIS16,
122
123 /* MMC */
124 GPIO6_MMC_CLK,
125 GPIO8_MMC_CS0,
126
127 /* GPIO */
128 GPIO9_GPIO, /* POODLE_GPIO_nSD_DETECT */
129 GPIO7_GPIO, /* POODLE_GPIO_nSD_WP */
130 GPIO3_GPIO, /* POODLE_GPIO_SD_PWR */
131 GPIO33_GPIO, /* POODLE_GPIO_SD_PWR1 */
132
133 GPIO20_GPIO, /* POODLE_GPIO_USB_PULLUP */
134 GPIO22_GPIO, /* POODLE_GPIO_IR_ON */
135};
136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137static struct resource poodle_scoop_resources[] = {
138 [0] = {
139 .start = 0x10800000,
140 .end = 0x10800fff,
141 .flags = IORESOURCE_MEM,
142 },
143};
144
145static struct scoop_config poodle_scoop_setup = {
146 .io_dir = POODLE_SCOOP_IO_DIR,
147 .io_out = POODLE_SCOOP_IO_OUT,
148};
149
150struct platform_device poodle_scoop_device = {
151 .name = "sharp-scoop",
152 .id = -1,
153 .dev = {
154 .platform_data = &poodle_scoop_setup,
155 },
156 .num_resources = ARRAY_SIZE(poodle_scoop_resources),
157 .resource = poodle_scoop_resources,
158};
159
Richard Purdie0ce76252005-09-05 20:49:54 +0100160static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
161{
162 .dev = &poodle_scoop_device.dev,
163 .irq = POODLE_IRQ_GPIO_CF_IRQ,
164 .cd_irq = POODLE_IRQ_GPIO_CF_CD,
165 .cd_irq_str = "PCMCIA0 CD",
166},
167};
168
Richard Purdiea63ae442005-11-08 19:15:43 +0000169static struct scoop_pcmcia_config poodle_pcmcia_config = {
170 .devs = &poodle_pcmcia_scoop[0],
171 .num_devs = 1,
Richard Purdiea63ae442005-11-08 19:15:43 +0000172};
173
174EXPORT_SYMBOL(poodle_scoop_device);
175
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
177/* LoCoMo device */
178static struct resource locomo_resources[] = {
179 [0] = {
180 .start = 0x10000000,
181 .end = 0x10001fff,
182 .flags = IORESOURCE_MEM,
183 },
184 [1] = {
185 .start = IRQ_GPIO(10),
186 .end = IRQ_GPIO(10),
187 .flags = IORESOURCE_IRQ,
188 },
189};
190
Richard Purdiefaed5682006-06-19 20:46:05 +0100191struct platform_device poodle_locomo_device = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 .name = "locomo",
193 .id = 0,
194 .num_resources = ARRAY_SIZE(locomo_resources),
195 .resource = locomo_resources,
196};
197
Richard Purdiefaed5682006-06-19 20:46:05 +0100198EXPORT_SYMBOL(poodle_locomo_device);
199
200/*
201 * Poodle SSP Device
202 */
203
204struct platform_device poodle_ssp_device = {
205 .name = "corgi-ssp",
206 .id = -1,
207};
208
209struct corgissp_machinfo poodle_ssp_machinfo = {
210 .port = 1,
211 .cs_lcdcon = -1,
212 .cs_ads7846 = -1,
213 .cs_max1111 = -1,
214 .clk_lcdcon = 2,
215 .clk_ads7846 = 36,
216 .clk_max1111 = 2,
217};
218
219
220/*
221 * Poodle Touch Screen Device
222 */
223static struct resource poodlets_resources[] = {
224 [0] = {
225 .start = POODLE_IRQ_GPIO_TP_INT,
226 .end = POODLE_IRQ_GPIO_TP_INT,
227 .flags = IORESOURCE_IRQ,
228 },
229};
230
eric miao6a0bd092008-01-31 02:41:16 +0100231static unsigned long poodle_get_hsync_invperiod(void)
Richard Purdiefaed5682006-06-19 20:46:05 +0100232{
233 return 0;
234}
235
236static void poodle_null_hsync(void)
237{
238}
239
240static struct corgits_machinfo poodle_ts_machinfo = {
eric miao6a0bd092008-01-31 02:41:16 +0100241 .get_hsync_invperiod = poodle_get_hsync_invperiod,
242 .put_hsync = poodle_null_hsync,
243 .wait_hsync = poodle_null_hsync,
Richard Purdiefaed5682006-06-19 20:46:05 +0100244};
245
246static struct platform_device poodle_ts_device = {
247 .name = "corgi-ts",
248 .dev = {
249 .platform_data = &poodle_ts_machinfo,
250 },
251 .id = -1,
252 .num_resources = ARRAY_SIZE(poodlets_resources),
253 .resource = poodlets_resources,
254};
255
Richard Purdie13b9d472005-09-15 14:53:22 +0100256
257/*
258 * MMC/SD Device
259 *
260 * The card detect interrupt isn't debounced so we delay it by 250ms
261 * to give the card a chance to fully insert/eject.
262 */
263static struct pxamci_platform_data poodle_mci_platform_data;
264
David Howells40220c12006-10-09 12:19:47 +0100265static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
Richard Purdie13b9d472005-09-15 14:53:22 +0100266{
267 int err;
268
Eric Miaoce529142008-07-18 08:59:04 +0800269 err = gpio_request(POODLE_GPIO_nSD_DETECT, "nSD_DETECT");
270 if (err)
271 goto err_out;
272
273 err = gpio_request(POODLE_GPIO_nSD_WP, "nSD_WP");
274 if (err)
275 goto err_free_1;
276
277 err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
278 if (err)
279 goto err_free_2;
280
281 err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1");
282 if (err)
283 goto err_free_3;
284
285 gpio_direction_input(POODLE_GPIO_nSD_DETECT);
286 gpio_direction_input(POODLE_GPIO_nSD_WP);
287
288 gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
289 gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
Richard Purdie13b9d472005-09-15 14:53:22 +0100290
291 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
292
Russell King9ded96f2006-01-08 01:02:07 -0800293 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
Thomas Gleixner52e405e2006-07-03 02:20:05 +0200294 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Russell King9ded96f2006-01-08 01:02:07 -0800295 "MMC card detect", data);
Eric Miaoce529142008-07-18 08:59:04 +0800296 if (err) {
297 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
298 __func__);
299 goto err_free_4;
300 }
Richard Purdie13b9d472005-09-15 14:53:22 +0100301
Eric Miaoce529142008-07-18 08:59:04 +0800302 return 0;
303
304err_free_4:
305 gpio_free(POODLE_GPIO_SD_PWR1);
306err_free_3:
307 gpio_free(POODLE_GPIO_SD_PWR);
308err_free_2:
309 gpio_free(POODLE_GPIO_nSD_WP);
310err_free_1:
311 gpio_free(POODLE_GPIO_nSD_DETECT);
312err_out:
Russell King2687bd32008-01-23 14:05:58 +0000313 return err;
Richard Purdie13b9d472005-09-15 14:53:22 +0100314}
315
316static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
317{
318 struct pxamci_platform_data* p_d = dev->platform_data;
319
Eric Miaoce529142008-07-18 08:59:04 +0800320 if ((1 << vdd) & p_d->ocr_mask) {
321 gpio_set_value(POODLE_GPIO_SD_PWR, 1);
Richard Purdie88660352006-06-19 19:58:51 +0100322 mdelay(2);
Eric Miaoce529142008-07-18 08:59:04 +0800323 gpio_set_value(POODLE_GPIO_SD_PWR1, 1);
Richard Purdie88660352006-06-19 19:58:51 +0100324 } else {
Eric Miaoce529142008-07-18 08:59:04 +0800325 gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
326 gpio_set_value(POODLE_GPIO_SD_PWR, 0);
Richard Purdie88660352006-06-19 19:58:51 +0100327 }
Richard Purdie13b9d472005-09-15 14:53:22 +0100328}
329
Richard Purdie88660352006-06-19 19:58:51 +0100330static int poodle_mci_get_ro(struct device *dev)
331{
Eric Miaoce529142008-07-18 08:59:04 +0800332 return !!gpio_get_value(POODLE_GPIO_nSD_WP);
Richard Purdie88660352006-06-19 19:58:51 +0100333 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
334}
335
336
Richard Purdie13b9d472005-09-15 14:53:22 +0100337static void poodle_mci_exit(struct device *dev, void *data)
338{
339 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
Eric Miaoce529142008-07-18 08:59:04 +0800340 gpio_free(POODLE_GPIO_SD_PWR1);
341 gpio_free(POODLE_GPIO_SD_PWR);
342 gpio_free(POODLE_GPIO_nSD_WP);
343 gpio_free(POODLE_GPIO_nSD_DETECT);
Richard Purdie13b9d472005-09-15 14:53:22 +0100344}
345
346static struct pxamci_platform_data poodle_mci_platform_data = {
347 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
348 .init = poodle_mci_init,
Richard Purdie88660352006-06-19 19:58:51 +0100349 .get_ro = poodle_mci_get_ro,
Richard Purdie13b9d472005-09-15 14:53:22 +0100350 .setpower = poodle_mci_setpower,
351 .exit = poodle_mci_exit,
352};
353
354
355/*
Richard Purdie8e4b8712005-10-30 14:38:52 +0000356 * Irda
357 */
358static void poodle_irda_transceiver_mode(struct device *dev, int mode)
359{
Eric Miaoce529142008-07-18 08:59:04 +0800360 gpio_set_value(POODLE_GPIO_IR_ON, mode & IR_OFF);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100361 pxa2xx_transceiver_mode(dev, mode);
Richard Purdie8e4b8712005-10-30 14:38:52 +0000362}
363
Eric Miaoce529142008-07-18 08:59:04 +0800364static int poodle_irda_startup(struct device *dev)
365{
366 int err;
367
368 err = gpio_request(POODLE_GPIO_IR_ON, "IR_ON");
369 if (err)
370 return err;
371
372 gpio_direction_output(POODLE_GPIO_IR_ON, 1);
373 return 0;
374}
375
376static void poodle_irda_shutdown(struct device *dev)
377{
378 gpio_free(POODLE_GPIO_IR_ON);
379}
380
Richard Purdie8e4b8712005-10-30 14:38:52 +0000381static struct pxaficp_platform_data poodle_ficp_platform_data = {
Eric Miaoce529142008-07-18 08:59:04 +0800382 .transceiver_cap = IR_SIRMODE | IR_OFF,
383 .transceiver_mode = poodle_irda_transceiver_mode,
384 .startup = poodle_irda_startup,
385 .shutdown = poodle_irda_shutdown,
Richard Purdie8e4b8712005-10-30 14:38:52 +0000386};
387
388
389/*
Richard Purdie13b9d472005-09-15 14:53:22 +0100390 * USB Device Controller
391 */
Richard Purdie13b9d472005-09-15 14:53:22 +0100392static struct pxa2xx_udc_mach_info udc_info __initdata = {
393 /* no connect GPIO; poodle can't tell connection status */
Eric Miao1730aad2008-07-18 08:51:07 +0800394 .gpio_pullup = POODLE_GPIO_USB_PULLUP,
Richard Purdie13b9d472005-09-15 14:53:22 +0100395};
396
397
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398/* PXAFB device */
Richard Purdied14b2722006-09-20 22:54:21 +0100399static struct pxafb_mode_info poodle_fb_mode = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 .pixclock = 144700,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 .xres = 320,
402 .yres = 240,
403 .bpp = 16,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 .hsync_len = 7,
405 .left_margin = 11,
406 .right_margin = 30,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 .vsync_len = 2,
408 .upper_margin = 2,
409 .lower_margin = 0,
410 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
Richard Purdied14b2722006-09-20 22:54:21 +0100411};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412
Richard Purdied14b2722006-09-20 22:54:21 +0100413static struct pxafb_mach_info poodle_fb_info = {
414 .modes = &poodle_fb_mode,
415 .num_modes = 1,
Eric Miaocf5eb8c2008-07-18 08:53:52 +0800416 .lcd_conn = LCD_COLOR_TFT_16BPP,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417};
418
419static struct platform_device *devices[] __initdata = {
Richard Purdiefaed5682006-06-19 20:46:05 +0100420 &poodle_locomo_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 &poodle_scoop_device,
Richard Purdiefaed5682006-06-19 20:46:05 +0100422 &poodle_ssp_device,
423 &poodle_ts_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424};
425
Richard Purdie74617fb2006-06-19 19:57:12 +0100426static void poodle_poweroff(void)
427{
Richard Purdie74617fb2006-06-19 19:57:12 +0100428 arm_machine_restart('h');
429}
430
431static void poodle_restart(char mode)
432{
Richard Purdie74617fb2006-06-19 19:57:12 +0100433 arm_machine_restart('h');
434}
435
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436static void __init poodle_init(void)
437{
438 int ret = 0;
439
Richard Purdie74617fb2006-06-19 19:57:12 +0100440 pm_power_off = poodle_poweroff;
441 arm_pm_restart = poodle_restart;
442
Richard Purdief29d2452005-09-15 14:53:22 +0100443 PCFR |= PCFR_OPDE;
444
Eric Miao26b4c8d2008-07-18 09:05:17 +0800445 pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446
Eric Miao2b0defd2008-08-09 05:54:22 -0400447 platform_scoop_config = &poodle_pcmcia_config;
448 corgi_ssp_set_machinfo(&poodle_ssp_machinfo);
449
450 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
451 if (ret)
452 pr_warning("poodle: Unable to register LoCoMo device\n");
453
Richard Purdiefaed5682006-06-19 20:46:05 +0100454 set_pxa_fb_parent(&poodle_locomo_device.dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 set_pxa_fb_info(&poodle_fb_info);
Richard Purdie13b9d472005-09-15 14:53:22 +0100456 pxa_set_udc_info(&udc_info);
457 pxa_set_mci_info(&poodle_mci_platform_data);
Richard Purdie8e4b8712005-10-30 14:38:52 +0000458 pxa_set_ficp_info(&poodle_ficp_platform_data);
Mark Brownf8787fd2008-08-26 13:30:03 +0100459 pxa_set_i2c_info(NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460}
461
462static void __init fixup_poodle(struct machine_desc *desc,
463 struct tag *tags, char **cmdline, struct meminfo *mi)
464{
465 sharpsl_save_param();
Richard Purdieb2e6f752006-04-02 17:11:00 +0100466 mi->nr_banks=1;
467 mi->bank[0].start = 0xa0000000;
468 mi->bank[0].node = 0;
469 mi->bank[0].size = (32*1024*1024);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470}
471
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472MACHINE_START(POODLE, "SHARP Poodle")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100473 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100474 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100475 .fixup = fixup_poodle,
Richard Purdief29d2452005-09-15 14:53:22 +0100476 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100477 .init_irq = pxa25x_init_irq,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100478 .timer = &pxa_timer,
479 .init_machine = poodle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480MACHINE_END