• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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>
19 #include <linux/platform_device.h>
20 #include <linux/fb.h>
21 #include <linux/pm.h>
22 #include <linux/delay.h>
23 #include <linux/mtd/physmap.h>
24 #include <linux/gpio.h>
25 #include <linux/spi/spi.h>
26 #include <linux/spi/ads7846.h>
27 #include <linux/mtd/sharpsl.h>
28 
29 #include <mach/hardware.h>
30 #include <asm/mach-types.h>
31 #include <asm/irq.h>
32 #include <asm/setup.h>
33 #include <asm/system.h>
34 
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include <asm/mach/irq.h>
38 
39 #include <mach/pxa-regs.h>
40 #include <mach/pxa2xx-regs.h>
41 #include <mach/mfp-pxa25x.h>
42 #include <mach/mmc.h>
43 #include <mach/udc.h>
44 #include <mach/i2c.h>
45 #include <mach/irda.h>
46 #include <mach/poodle.h>
47 #include <mach/pxafb.h>
48 #include <mach/sharpsl.h>
49 #include <mach/ssp.h>
50 #include <mach/pxa2xx_spi.h>
51 
52 #include <asm/hardware/scoop.h>
53 #include <asm/hardware/locomo.h>
54 #include <asm/mach/sharpsl_param.h>
55 
56 #include "generic.h"
57 #include "devices.h"
58 #include "sharpsl.h"
59 
60 static unsigned long poodle_pin_config[] __initdata = {
61 	/* I/O */
62 	GPIO79_nCS_3,
63 	GPIO80_nCS_4,
64 	GPIO18_RDY,
65 
66 	/* Clock */
67 	GPIO12_32KHz,
68 
69 	/* SSP1 */
70 	GPIO23_SSP1_SCLK,
71 	GPIO25_SSP1_TXD,
72 	GPIO26_SSP1_RXD,
73 	GPIO24_GPIO,	/* POODLE_GPIO_TP_CS - SFRM as chip select */
74 
75 	/* I2S */
76 	GPIO28_I2S_BITCLK_OUT,
77 	GPIO29_I2S_SDATA_IN,
78 	GPIO30_I2S_SDATA_OUT,
79 	GPIO31_I2S_SYNC,
80 	GPIO32_I2S_SYSCLK,
81 
82 	/* Infra-Red */
83 	GPIO47_FICP_TXD,
84 	GPIO46_FICP_RXD,
85 
86 	/* FFUART */
87 	GPIO40_FFUART_DTR,
88 	GPIO41_FFUART_RTS,
89 	GPIO39_FFUART_TXD,
90 	GPIO37_FFUART_DSR,
91 	GPIO34_FFUART_RXD,
92 	GPIO35_FFUART_CTS,
93 
94 	/* LCD */
95 	GPIO58_LCD_LDD_0,
96 	GPIO59_LCD_LDD_1,
97 	GPIO60_LCD_LDD_2,
98 	GPIO61_LCD_LDD_3,
99 	GPIO62_LCD_LDD_4,
100 	GPIO63_LCD_LDD_5,
101 	GPIO64_LCD_LDD_6,
102 	GPIO65_LCD_LDD_7,
103 	GPIO66_LCD_LDD_8,
104 	GPIO67_LCD_LDD_9,
105 	GPIO68_LCD_LDD_10,
106 	GPIO69_LCD_LDD_11,
107 	GPIO70_LCD_LDD_12,
108 	GPIO71_LCD_LDD_13,
109 	GPIO72_LCD_LDD_14,
110 	GPIO73_LCD_LDD_15,
111 	GPIO74_LCD_FCLK,
112 	GPIO75_LCD_LCLK,
113 	GPIO76_LCD_PCLK,
114 	GPIO77_LCD_BIAS,
115 
116 	/* PC Card */
117 	GPIO48_nPOE,
118 	GPIO49_nPWE,
119 	GPIO50_nPIOR,
120 	GPIO51_nPIOW,
121 	GPIO52_nPCE_1,
122 	GPIO53_nPCE_2,
123 	GPIO54_nPSKTSEL,
124 	GPIO55_nPREG,
125 	GPIO56_nPWAIT,
126 	GPIO57_nIOIS16,
127 
128 	/* MMC */
129 	GPIO6_MMC_CLK,
130 	GPIO8_MMC_CS0,
131 
132 	/* GPIO */
133 	GPIO9_GPIO,	/* POODLE_GPIO_nSD_DETECT */
134 	GPIO7_GPIO,	/* POODLE_GPIO_nSD_WP */
135 	GPIO3_GPIO,	/* POODLE_GPIO_SD_PWR */
136 	GPIO33_GPIO,	/* POODLE_GPIO_SD_PWR1 */
137 
138 	GPIO20_GPIO,	/* POODLE_GPIO_USB_PULLUP */
139 	GPIO22_GPIO,	/* POODLE_GPIO_IR_ON */
140 };
141 
142 static struct resource poodle_scoop_resources[] = {
143 	[0] = {
144 		.start		= 0x10800000,
145 		.end		= 0x10800fff,
146 		.flags		= IORESOURCE_MEM,
147 	},
148 };
149 
150 static struct scoop_config poodle_scoop_setup = {
151 	.io_dir		= POODLE_SCOOP_IO_DIR,
152 	.io_out		= POODLE_SCOOP_IO_OUT,
153 	.gpio_base	= POODLE_SCOOP_GPIO_BASE,
154 };
155 
156 struct platform_device poodle_scoop_device = {
157 	.name		= "sharp-scoop",
158 	.id		= -1,
159 	.dev		= {
160 		.platform_data	= &poodle_scoop_setup,
161 	},
162 	.num_resources	= ARRAY_SIZE(poodle_scoop_resources),
163 	.resource	= poodle_scoop_resources,
164 };
165 
166 static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
167 {
168 	.dev        = &poodle_scoop_device.dev,
169 	.irq        = POODLE_IRQ_GPIO_CF_IRQ,
170 	.cd_irq     = POODLE_IRQ_GPIO_CF_CD,
171 	.cd_irq_str = "PCMCIA0 CD",
172 },
173 };
174 
175 static struct scoop_pcmcia_config poodle_pcmcia_config = {
176 	.devs         = &poodle_pcmcia_scoop[0],
177 	.num_devs     = 1,
178 };
179 
180 EXPORT_SYMBOL(poodle_scoop_device);
181 
182 
183 /* LoCoMo device */
184 static struct resource locomo_resources[] = {
185 	[0] = {
186 		.start		= 0x10000000,
187 		.end		= 0x10001fff,
188 		.flags		= IORESOURCE_MEM,
189 	},
190 	[1] = {
191 		.start		= IRQ_GPIO(10),
192 		.end		= IRQ_GPIO(10),
193 		.flags		= IORESOURCE_IRQ,
194 	},
195 };
196 
197 struct platform_device poodle_locomo_device = {
198 	.name		= "locomo",
199 	.id		= 0,
200 	.num_resources	= ARRAY_SIZE(locomo_resources),
201 	.resource	= locomo_resources,
202 };
203 
204 EXPORT_SYMBOL(poodle_locomo_device);
205 
206 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
207 static struct pxa2xx_spi_master poodle_spi_info = {
208 	.num_chipselect	= 1,
209 };
210 
211 static struct ads7846_platform_data poodle_ads7846_info = {
212 	.model			= 7846,
213 	.vref_delay_usecs	= 100,
214 	.x_plate_ohms		= 419,
215 	.y_plate_ohms		= 486,
216 	.gpio_pendown		= POODLE_GPIO_TP_INT,
217 };
218 
ads7846_cs(u32 command)219 static void ads7846_cs(u32 command)
220 {
221 	gpio_set_value(POODLE_GPIO_TP_CS, !(command == PXA2XX_CS_ASSERT));
222 }
223 
224 static struct pxa2xx_spi_chip poodle_ads7846_chip = {
225 	.cs_control		= ads7846_cs,
226 };
227 
228 static struct spi_board_info poodle_spi_devices[] = {
229 	{
230 		.modalias	= "ads7846",
231 		.max_speed_hz	= 10000,
232 		.bus_num	= 1,
233 		.platform_data	= &poodle_ads7846_info,
234 		.controller_data= &poodle_ads7846_chip,
235 		.irq		= gpio_to_irq(POODLE_GPIO_TP_INT),
236 	},
237 };
238 
poodle_init_spi(void)239 static void __init poodle_init_spi(void)
240 {
241 	int err;
242 
243 	err = gpio_request(POODLE_GPIO_TP_CS, "ADS7846_CS");
244 	if (err)
245 		return;
246 
247 	gpio_direction_output(POODLE_GPIO_TP_CS, 1);
248 
249 	pxa2xx_set_spi_info(1, &poodle_spi_info);
250 	spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
251 }
252 #else
poodle_init_spi(void)253 static inline void poodle_init_spi(void) {}
254 #endif
255 
256 /*
257  * MMC/SD Device
258  *
259  * The card detect interrupt isn't debounced so we delay it by 250ms
260  * to give the card a chance to fully insert/eject.
261  */
262 static struct pxamci_platform_data poodle_mci_platform_data;
263 
poodle_mci_init(struct device * dev,irq_handler_t poodle_detect_int,void * data)264 static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
265 {
266 	int err;
267 
268 	err = gpio_request(POODLE_GPIO_nSD_DETECT, "nSD_DETECT");
269 	if (err)
270 		goto err_out;
271 
272 	err = gpio_request(POODLE_GPIO_nSD_WP, "nSD_WP");
273 	if (err)
274 		goto err_free_1;
275 
276 	err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
277 	if (err)
278 		goto err_free_2;
279 
280 	err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1");
281 	if (err)
282 		goto err_free_3;
283 
284 	gpio_direction_input(POODLE_GPIO_nSD_DETECT);
285 	gpio_direction_input(POODLE_GPIO_nSD_WP);
286 
287 	gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
288 	gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
289 
290 	poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
291 
292 	err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
293 			  IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
294 			  "MMC card detect", data);
295 	if (err) {
296 		pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
297 				__func__);
298 		goto err_free_4;
299 	}
300 
301 	return 0;
302 
303 err_free_4:
304 	gpio_free(POODLE_GPIO_SD_PWR1);
305 err_free_3:
306 	gpio_free(POODLE_GPIO_SD_PWR);
307 err_free_2:
308 	gpio_free(POODLE_GPIO_nSD_WP);
309 err_free_1:
310 	gpio_free(POODLE_GPIO_nSD_DETECT);
311 err_out:
312 	return err;
313 }
314 
poodle_mci_setpower(struct device * dev,unsigned int vdd)315 static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
316 {
317 	struct pxamci_platform_data* p_d = dev->platform_data;
318 
319 	if ((1 << vdd) & p_d->ocr_mask) {
320 		gpio_set_value(POODLE_GPIO_SD_PWR, 1);
321 		mdelay(2);
322 		gpio_set_value(POODLE_GPIO_SD_PWR1, 1);
323 	} else {
324 		gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
325 		gpio_set_value(POODLE_GPIO_SD_PWR, 0);
326 	}
327 }
328 
poodle_mci_get_ro(struct device * dev)329 static int poodle_mci_get_ro(struct device *dev)
330 {
331 	return !!gpio_get_value(POODLE_GPIO_nSD_WP);
332 	return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
333 }
334 
335 
poodle_mci_exit(struct device * dev,void * data)336 static void poodle_mci_exit(struct device *dev, void *data)
337 {
338 	free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
339 	gpio_free(POODLE_GPIO_SD_PWR1);
340 	gpio_free(POODLE_GPIO_SD_PWR);
341 	gpio_free(POODLE_GPIO_nSD_WP);
342 	gpio_free(POODLE_GPIO_nSD_DETECT);
343 }
344 
345 static struct pxamci_platform_data poodle_mci_platform_data = {
346 	.ocr_mask	= MMC_VDD_32_33|MMC_VDD_33_34,
347 	.init 		= poodle_mci_init,
348 	.get_ro		= poodle_mci_get_ro,
349 	.setpower 	= poodle_mci_setpower,
350 	.exit		= poodle_mci_exit,
351 };
352 
353 
354 /*
355  * Irda
356  */
poodle_irda_transceiver_mode(struct device * dev,int mode)357 static void poodle_irda_transceiver_mode(struct device *dev, int mode)
358 {
359 	gpio_set_value(POODLE_GPIO_IR_ON, mode & IR_OFF);
360 	pxa2xx_transceiver_mode(dev, mode);
361 }
362 
poodle_irda_startup(struct device * dev)363 static int poodle_irda_startup(struct device *dev)
364 {
365 	int err;
366 
367 	err = gpio_request(POODLE_GPIO_IR_ON, "IR_ON");
368 	if (err)
369 		return err;
370 
371 	gpio_direction_output(POODLE_GPIO_IR_ON, 1);
372 	return 0;
373 }
374 
poodle_irda_shutdown(struct device * dev)375 static void poodle_irda_shutdown(struct device *dev)
376 {
377 	gpio_free(POODLE_GPIO_IR_ON);
378 }
379 
380 static struct pxaficp_platform_data poodle_ficp_platform_data = {
381 	.transceiver_cap	= IR_SIRMODE | IR_OFF,
382 	.transceiver_mode	= poodle_irda_transceiver_mode,
383 	.startup		= poodle_irda_startup,
384 	.shutdown		= poodle_irda_shutdown,
385 };
386 
387 
388 /*
389  * USB Device Controller
390  */
391 static struct pxa2xx_udc_mach_info udc_info __initdata = {
392 	/* no connect GPIO; poodle can't tell connection status */
393 	.gpio_pullup	= POODLE_GPIO_USB_PULLUP,
394 };
395 
396 
397 /* PXAFB device */
398 static struct pxafb_mode_info poodle_fb_mode = {
399 	.pixclock	= 144700,
400 	.xres		= 320,
401 	.yres		= 240,
402 	.bpp		= 16,
403 	.hsync_len	= 7,
404 	.left_margin	= 11,
405 	.right_margin	= 30,
406 	.vsync_len	= 2,
407 	.upper_margin	= 2,
408 	.lower_margin	= 0,
409 	.sync		= FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
410 };
411 
412 static struct pxafb_mach_info poodle_fb_info = {
413 	.modes		= &poodle_fb_mode,
414 	.num_modes	= 1,
415 	.lcd_conn	= LCD_COLOR_TFT_16BPP,
416 };
417 
418 static struct mtd_partition sharpsl_nand_partitions[] = {
419 	{
420 		.name = "System Area",
421 		.offset = 0,
422 		.size = 7 * 1024 * 1024,
423 	},
424 	{
425 		.name = "Root Filesystem",
426 		.offset = 7 * 1024 * 1024,
427 		.size = 22 * 1024 * 1024,
428 	},
429 	{
430 		.name = "Home Filesystem",
431 		.offset = MTDPART_OFS_APPEND,
432 		.size = MTDPART_SIZ_FULL,
433 	},
434 };
435 
436 static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
437 
438 static struct nand_bbt_descr sharpsl_bbt = {
439 	.options = 0,
440 	.offs = 4,
441 	.len = 2,
442 	.pattern = scan_ff_pattern
443 };
444 
445 static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
446 	.badblock_pattern	= &sharpsl_bbt,
447 	.partitions		= sharpsl_nand_partitions,
448 	.nr_partitions		= ARRAY_SIZE(sharpsl_nand_partitions),
449 };
450 
451 static struct resource sharpsl_nand_resources[] = {
452 	{
453 		.start	= 0x0C000000,
454 		.end	= 0x0C000FFF,
455 		.flags	= IORESOURCE_MEM,
456 	},
457 };
458 
459 static struct platform_device sharpsl_nand_device = {
460 	.name		= "sharpsl-nand",
461 	.id		= -1,
462 	.resource	= sharpsl_nand_resources,
463 	.num_resources	= ARRAY_SIZE(sharpsl_nand_resources),
464 	.dev.platform_data	= &sharpsl_nand_platform_data,
465 };
466 
467 static struct mtd_partition sharpsl_rom_parts[] = {
468 	{
469 		.name	="Boot PROM Filesystem",
470 		.offset	= 0x00120000,
471 		.size	= MTDPART_SIZ_FULL,
472 	},
473 };
474 
475 static struct physmap_flash_data sharpsl_rom_data = {
476 	.width		= 2,
477 	.nr_parts	= ARRAY_SIZE(sharpsl_rom_parts),
478 	.parts		= sharpsl_rom_parts,
479 };
480 
481 static struct resource sharpsl_rom_resources[] = {
482 	{
483 		.start	= 0x00000000,
484 		.end	= 0x007fffff,
485 		.flags	= IORESOURCE_MEM,
486 	},
487 };
488 
489 static struct platform_device sharpsl_rom_device = {
490 	.name	= "physmap-flash",
491 	.id	= -1,
492 	.resource = sharpsl_rom_resources,
493 	.num_resources = ARRAY_SIZE(sharpsl_rom_resources),
494 	.dev.platform_data = &sharpsl_rom_data,
495 };
496 
497 static struct platform_device *devices[] __initdata = {
498 	&poodle_locomo_device,
499 	&poodle_scoop_device,
500 	&sharpsl_nand_device,
501 	&sharpsl_rom_device,
502 };
503 
poodle_poweroff(void)504 static void poodle_poweroff(void)
505 {
506 	arm_machine_restart('h');
507 }
508 
poodle_restart(char mode)509 static void poodle_restart(char mode)
510 {
511 	arm_machine_restart('h');
512 }
513 
poodle_init(void)514 static void __init poodle_init(void)
515 {
516 	int ret = 0;
517 
518 	pm_power_off = poodle_poweroff;
519 	arm_pm_restart = poodle_restart;
520 
521 	PCFR |= PCFR_OPDE;
522 
523 	pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config));
524 
525 	platform_scoop_config = &poodle_pcmcia_config;
526 
527 	ret = platform_add_devices(devices, ARRAY_SIZE(devices));
528 	if (ret)
529 		pr_warning("poodle: Unable to register LoCoMo device\n");
530 
531 	set_pxa_fb_parent(&poodle_locomo_device.dev);
532 	set_pxa_fb_info(&poodle_fb_info);
533 	pxa_set_udc_info(&udc_info);
534 	pxa_set_mci_info(&poodle_mci_platform_data);
535 	pxa_set_ficp_info(&poodle_ficp_platform_data);
536 	pxa_set_i2c_info(NULL);
537 	poodle_init_spi();
538 }
539 
fixup_poodle(struct machine_desc * desc,struct tag * tags,char ** cmdline,struct meminfo * mi)540 static void __init fixup_poodle(struct machine_desc *desc,
541 		struct tag *tags, char **cmdline, struct meminfo *mi)
542 {
543 	sharpsl_save_param();
544 	mi->nr_banks=1;
545 	mi->bank[0].start = 0xa0000000;
546 	mi->bank[0].node = 0;
547 	mi->bank[0].size = (32*1024*1024);
548 }
549 
550 MACHINE_START(POODLE, "SHARP Poodle")
551 	.phys_io	= 0x40000000,
552 	.io_pg_offst	= (io_p2v(0x40000000) >> 18) & 0xfffc,
553 	.fixup		= fixup_poodle,
554 	.map_io		= pxa_map_io,
555 	.init_irq	= pxa25x_init_irq,
556 	.timer		= &pxa_timer,
557 	.init_machine	= poodle_init,
558 MACHINE_END
559