diff options
author | Eric Miao <eric.miao@marvell.com> | 2008-09-03 00:09:24 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-09-23 17:04:37 -0400 |
commit | 859b796349d2073bd58e55d176e03b2d53cb8c36 (patch) | |
tree | 8f64519f54feaa7b4519252b98a2669378e431e7 /arch/arm/mach-pxa/spitz.c | |
parent | 79009a063aa04c32143bff4fc0b7b8c6482af12d (diff) |
[ARM] pxa/spitz: use SPI-based driver for ads7846, corgi-lcd and max1111
Signed-off-by: Eric Miao <eric.miao@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-pxa/spitz.c')
-rw-r--r-- | arch/arm/mach-pxa/spitz.c | 291 |
1 files changed, 124 insertions, 167 deletions
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 075fd8dda92e..8b06b7a749df 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c | |||
@@ -23,6 +23,9 @@ | |||
23 | #include <linux/mmc/host.h> | 23 | #include <linux/mmc/host.h> |
24 | #include <linux/pm.h> | 24 | #include <linux/pm.h> |
25 | #include <linux/backlight.h> | 25 | #include <linux/backlight.h> |
26 | #include <linux/spi/spi.h> | ||
27 | #include <linux/spi/ads7846.h> | ||
28 | #include <linux/spi/corgi_lcd.h> | ||
26 | 29 | ||
27 | #include <asm/setup.h> | 30 | #include <asm/setup.h> |
28 | #include <asm/memory.h> | 31 | #include <asm/memory.h> |
@@ -47,6 +50,7 @@ | |||
47 | #include <mach/ohci.h> | 50 | #include <mach/ohci.h> |
48 | #include <mach/udc.h> | 51 | #include <mach/udc.h> |
49 | #include <mach/pxafb.h> | 52 | #include <mach/pxafb.h> |
53 | #include <mach/pxa2xx_spi.h> | ||
50 | #include <mach/akita.h> | 54 | #include <mach/akita.h> |
51 | #include <mach/spitz.h> | 55 | #include <mach/spitz.h> |
52 | #include <mach/sharpsl.h> | 56 | #include <mach/sharpsl.h> |
@@ -237,64 +241,6 @@ static struct scoop_pcmcia_config spitz_pcmcia_config = { | |||
237 | EXPORT_SYMBOL(spitzscoop_device); | 241 | EXPORT_SYMBOL(spitzscoop_device); |
238 | EXPORT_SYMBOL(spitzscoop2_device); | 242 | EXPORT_SYMBOL(spitzscoop2_device); |
239 | 243 | ||
240 | |||
241 | /* | ||
242 | * Spitz SSP Device | ||
243 | * | ||
244 | * Set the parent as the scoop device because a lot of SSP devices | ||
245 | * also use scoop functions and this makes the power up/down order | ||
246 | * work correctly. | ||
247 | */ | ||
248 | struct platform_device spitzssp_device = { | ||
249 | .name = "corgi-ssp", | ||
250 | .dev = { | ||
251 | .parent = &spitzscoop_device.dev, | ||
252 | }, | ||
253 | .id = -1, | ||
254 | }; | ||
255 | |||
256 | struct corgissp_machinfo spitz_ssp_machinfo = { | ||
257 | .port = 2, | ||
258 | .cs_lcdcon = SPITZ_GPIO_LCDCON_CS, | ||
259 | .cs_ads7846 = SPITZ_GPIO_ADS7846_CS, | ||
260 | .cs_max1111 = SPITZ_GPIO_MAX1111_CS, | ||
261 | .clk_lcdcon = 520, | ||
262 | .clk_ads7846 = 14, | ||
263 | .clk_max1111 = 56, | ||
264 | }; | ||
265 | |||
266 | |||
267 | /* | ||
268 | * Spitz Backlight Device | ||
269 | */ | ||
270 | static void spitz_bl_kick_battery(void) | ||
271 | { | ||
272 | void (*kick_batt)(void); | ||
273 | |||
274 | kick_batt = symbol_get(sharpsl_battery_kick); | ||
275 | if (kick_batt) { | ||
276 | kick_batt(); | ||
277 | symbol_put(sharpsl_battery_kick); | ||
278 | } | ||
279 | } | ||
280 | |||
281 | static struct generic_bl_info spitz_bl_machinfo = { | ||
282 | .name = "corgi-bl", | ||
283 | .default_intensity = 0x1f, | ||
284 | .limit_mask = 0x0b, | ||
285 | .max_intensity = 0x2f, | ||
286 | .kick_battery = spitz_bl_kick_battery, | ||
287 | }; | ||
288 | |||
289 | static struct platform_device spitzbl_device = { | ||
290 | .name = "generic-bl", | ||
291 | .dev = { | ||
292 | .platform_data = &spitz_bl_machinfo, | ||
293 | }, | ||
294 | .id = -1, | ||
295 | }; | ||
296 | |||
297 | |||
298 | /* | 244 | /* |
299 | * Spitz Keyboard Device | 245 | * Spitz Keyboard Device |
300 | */ | 246 | */ |
@@ -312,83 +258,150 @@ static struct platform_device spitzled_device = { | |||
312 | .id = -1, | 258 | .id = -1, |
313 | }; | 259 | }; |
314 | 260 | ||
315 | /* | 261 | #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) |
316 | * Spitz Touch Screen Device | 262 | static struct pxa2xx_spi_master spitz_spi_info = { |
317 | */ | 263 | .num_chipselect = 3, |
264 | }; | ||
318 | 265 | ||
319 | static unsigned long (*get_hsync_invperiod)(struct device *dev); | 266 | static struct ads7846_platform_data spitz_ads7846_info = { |
267 | .model = 7846, | ||
268 | .vref_delay_usecs = 100, | ||
269 | .x_plate_ohms = 419, | ||
270 | .y_plate_ohms = 486, | ||
271 | .gpio_pendown = SPITZ_GPIO_TP_INT, | ||
272 | }; | ||
320 | 273 | ||
321 | static void inline sharpsl_wait_sync(int gpio) | 274 | static void spitz_ads7846_cs(u32 command) |
322 | { | 275 | { |
323 | while((GPLR(gpio) & GPIO_bit(gpio)) == 0); | 276 | gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT)); |
324 | while((GPLR(gpio) & GPIO_bit(gpio)) != 0); | ||
325 | } | 277 | } |
326 | 278 | ||
327 | static struct device *spitz_pxafb_dev; | 279 | static struct pxa2xx_spi_chip spitz_ads7846_chip = { |
280 | .cs_control = spitz_ads7846_cs, | ||
281 | }; | ||
328 | 282 | ||
329 | static int is_pxafb_device(struct device * dev, void * data) | 283 | static void spitz_notify_intensity(int intensity) |
330 | { | 284 | { |
331 | struct platform_device *pdev = container_of(dev, struct platform_device, dev); | 285 | if (machine_is_spitz() || machine_is_borzoi()) { |
286 | /* Bit 5 is via SCOOP */ | ||
287 | if (intensity & 0x0020) | ||
288 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT); | ||
289 | else | ||
290 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT); | ||
291 | |||
292 | if (intensity) | ||
293 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON); | ||
294 | else | ||
295 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON); | ||
296 | return; | ||
297 | } | ||
332 | 298 | ||
333 | return (strncmp(pdev->name, "pxa2xx-fb", 9) == 0); | 299 | if (machine_is_akita()) { |
300 | /* Bit 5 is via IO-Expander */ | ||
301 | if (intensity & 0x0020) | ||
302 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT); | ||
303 | else | ||
304 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT); | ||
305 | |||
306 | if (intensity) | ||
307 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON); | ||
308 | else | ||
309 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON); | ||
310 | return; | ||
311 | } | ||
334 | } | 312 | } |
335 | 313 | ||
336 | static unsigned long spitz_get_hsync_invperiod(void) | 314 | static void spitz_bl_kick_battery(void) |
337 | { | 315 | { |
338 | #ifdef CONFIG_FB_PXA | 316 | void (*kick_batt)(void); |
339 | if (!spitz_pxafb_dev) { | ||
340 | spitz_pxafb_dev = bus_find_device(&platform_bus_type, NULL, NULL, is_pxafb_device); | ||
341 | if (!spitz_pxafb_dev) | ||
342 | return 0; | ||
343 | } | ||
344 | if (!get_hsync_invperiod) | ||
345 | get_hsync_invperiod = symbol_get(pxafb_get_hsync_time); | ||
346 | if (!get_hsync_invperiod) | ||
347 | #endif | ||
348 | return 0; | ||
349 | 317 | ||
350 | return get_hsync_invperiod(spitz_pxafb_dev); | 318 | kick_batt = symbol_get(sharpsl_battery_kick); |
319 | if (kick_batt) { | ||
320 | kick_batt(); | ||
321 | symbol_put(sharpsl_battery_kick); | ||
322 | } | ||
351 | } | 323 | } |
352 | 324 | ||
353 | static void spitz_put_hsync(void) | 325 | static struct corgi_lcd_platform_data spitz_lcdcon_info = { |
354 | { | 326 | .init_mode = CORGI_LCD_MODE_VGA, |
355 | put_device(spitz_pxafb_dev); | 327 | .max_intensity = 0x2f, |
356 | if (get_hsync_invperiod) | 328 | .default_intensity = 0x1f, |
357 | symbol_put(pxafb_get_hsync_time); | 329 | .limit_mask = 0x0b, |
358 | spitz_pxafb_dev = NULL; | 330 | .notify = spitz_notify_intensity, |
359 | get_hsync_invperiod = NULL; | 331 | .kick_battery = spitz_bl_kick_battery, |
360 | } | 332 | }; |
361 | 333 | ||
362 | static void spitz_wait_hsync(void) | 334 | static void spitz_lcdcon_cs(u32 command) |
363 | { | 335 | { |
364 | sharpsl_wait_sync(SPITZ_GPIO_HSYNC); | 336 | gpio_set_value(SPITZ_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT)); |
365 | } | 337 | } |
366 | 338 | ||
367 | static struct resource spitzts_resources[] = { | 339 | static struct pxa2xx_spi_chip spitz_lcdcon_chip = { |
368 | [0] = { | 340 | .cs_control = spitz_lcdcon_cs, |
369 | .start = SPITZ_IRQ_GPIO_TP_INT, | ||
370 | .end = SPITZ_IRQ_GPIO_TP_INT, | ||
371 | .flags = IORESOURCE_IRQ, | ||
372 | }, | ||
373 | }; | 341 | }; |
374 | 342 | ||
375 | static struct corgits_machinfo spitz_ts_machinfo = { | 343 | static void spitz_max1111_cs(u32 command) |
376 | .get_hsync_invperiod = spitz_get_hsync_invperiod, | 344 | { |
377 | .put_hsync = spitz_put_hsync, | 345 | gpio_set_value(SPITZ_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT)); |
378 | .wait_hsync = spitz_wait_hsync, | 346 | } |
347 | |||
348 | static struct pxa2xx_spi_chip spitz_max1111_chip = { | ||
349 | .cs_control = spitz_max1111_cs, | ||
379 | }; | 350 | }; |
380 | 351 | ||
381 | static struct platform_device spitzts_device = { | 352 | static struct spi_board_info spitz_spi_devices[] = { |
382 | .name = "corgi-ts", | 353 | { |
383 | .dev = { | 354 | .modalias = "ads7846", |
384 | .parent = &spitzssp_device.dev, | 355 | .max_speed_hz = 1200000, |
385 | .platform_data = &spitz_ts_machinfo, | 356 | .bus_num = 2, |
357 | .chip_select = 0, | ||
358 | .platform_data = &spitz_ads7846_info, | ||
359 | .controller_data= &spitz_ads7846_chip, | ||
360 | .irq = gpio_to_irq(SPITZ_GPIO_TP_INT), | ||
361 | }, { | ||
362 | .modalias = "corgi-lcd", | ||
363 | .max_speed_hz = 50000, | ||
364 | .bus_num = 2, | ||
365 | .chip_select = 1, | ||
366 | .platform_data = &spitz_lcdcon_info, | ||
367 | .controller_data= &spitz_lcdcon_chip, | ||
368 | }, { | ||
369 | .modalias = "max1111", | ||
370 | .max_speed_hz = 450000, | ||
371 | .bus_num = 2, | ||
372 | .chip_select = 2, | ||
373 | .controller_data= &spitz_max1111_chip, | ||
386 | }, | 374 | }, |
387 | .id = -1, | ||
388 | .num_resources = ARRAY_SIZE(spitzts_resources), | ||
389 | .resource = spitzts_resources, | ||
390 | }; | 375 | }; |
391 | 376 | ||
377 | static void __init spitz_init_spi(void) | ||
378 | { | ||
379 | int err; | ||
380 | |||
381 | err = gpio_request(SPITZ_GPIO_ADS7846_CS, "ADS7846_CS"); | ||
382 | if (err) | ||
383 | return; | ||
384 | |||
385 | err = gpio_request(SPITZ_GPIO_LCDCON_CS, "LCDCON_CS"); | ||
386 | if (err) | ||
387 | goto err_free_1; | ||
388 | |||
389 | err = gpio_request(SPITZ_GPIO_MAX1111_CS, "MAX1111_CS"); | ||
390 | if (err) | ||
391 | goto err_free_2; | ||
392 | |||
393 | pxa2xx_set_spi_info(2, &spitz_spi_info); | ||
394 | spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); | ||
395 | return; | ||
396 | |||
397 | err_free_2: | ||
398 | gpio_free(SPITZ_GPIO_LCDCON_CS); | ||
399 | err_free_1: | ||
400 | gpio_free(SPITZ_GPIO_ADS7846_CS); | ||
401 | } | ||
402 | #else | ||
403 | static inline void spitz_init_spi(void) {} | ||
404 | #endif | ||
392 | 405 | ||
393 | /* | 406 | /* |
394 | * MMC/SD Device | 407 | * MMC/SD Device |
@@ -532,14 +545,6 @@ static struct pxaficp_platform_data spitz_ficp_platform_data = { | |||
532 | * Spitz PXA Framebuffer | 545 | * Spitz PXA Framebuffer |
533 | */ | 546 | */ |
534 | 547 | ||
535 | static void spitz_lcd_power(int on, struct fb_var_screeninfo *var) | ||
536 | { | ||
537 | if (on) | ||
538 | corgi_lcdtg_hw_init(var->xres); | ||
539 | else | ||
540 | corgi_lcdtg_suspend(); | ||
541 | } | ||
542 | |||
543 | static struct pxafb_mode_info spitz_pxafb_modes[] = { | 548 | static struct pxafb_mode_info spitz_pxafb_modes[] = { |
544 | { | 549 | { |
545 | .pixclock = 19231, | 550 | .pixclock = 19231, |
@@ -573,16 +578,12 @@ static struct pxafb_mach_info spitz_pxafb_info = { | |||
573 | .num_modes = 2, | 578 | .num_modes = 2, |
574 | .fixed_modes = 1, | 579 | .fixed_modes = 1, |
575 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING, | 580 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING, |
576 | .pxafb_lcd_power = spitz_lcd_power, | ||
577 | }; | 581 | }; |
578 | 582 | ||
579 | 583 | ||
580 | static struct platform_device *devices[] __initdata = { | 584 | static struct platform_device *devices[] __initdata = { |
581 | &spitzscoop_device, | 585 | &spitzscoop_device, |
582 | &spitzssp_device, | ||
583 | &spitzkbd_device, | 586 | &spitzkbd_device, |
584 | &spitzts_device, | ||
585 | &spitzbl_device, | ||
586 | &spitzled_device, | 587 | &spitzled_device, |
587 | }; | 588 | }; |
588 | 589 | ||
@@ -613,44 +614,21 @@ static void __init common_init(void) | |||
613 | 614 | ||
614 | pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config)); | 615 | pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config)); |
615 | 616 | ||
616 | corgi_ssp_set_machinfo(&spitz_ssp_machinfo); | 617 | spitz_init_spi(); |
617 | 618 | ||
618 | platform_add_devices(devices, ARRAY_SIZE(devices)); | 619 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
619 | pxa_set_mci_info(&spitz_mci_platform_data); | 620 | pxa_set_mci_info(&spitz_mci_platform_data); |
620 | pxa_set_ohci_info(&spitz_ohci_platform_data); | 621 | pxa_set_ohci_info(&spitz_ohci_platform_data); |
621 | pxa_set_ficp_info(&spitz_ficp_platform_data); | 622 | pxa_set_ficp_info(&spitz_ficp_platform_data); |
622 | set_pxa_fb_parent(&spitzssp_device.dev); | ||
623 | set_pxa_fb_info(&spitz_pxafb_info); | 623 | set_pxa_fb_info(&spitz_pxafb_info); |
624 | pxa_set_i2c_info(NULL); | 624 | pxa_set_i2c_info(NULL); |
625 | } | 625 | } |
626 | 626 | ||
627 | #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI) | 627 | #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI) |
628 | static void spitz_bl_set_intensity(int intensity) | ||
629 | { | ||
630 | if (intensity > 0x10) | ||
631 | intensity += 0x10; | ||
632 | |||
633 | /* Bits 0-4 are accessed via the SSP interface */ | ||
634 | corgi_ssp_blduty_set(intensity & 0x1f); | ||
635 | |||
636 | /* Bit 5 is via SCOOP */ | ||
637 | if (intensity & 0x0020) | ||
638 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT); | ||
639 | else | ||
640 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT); | ||
641 | |||
642 | if (intensity) | ||
643 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON); | ||
644 | else | ||
645 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON); | ||
646 | } | ||
647 | |||
648 | static void __init spitz_init(void) | 628 | static void __init spitz_init(void) |
649 | { | 629 | { |
650 | platform_scoop_config = &spitz_pcmcia_config; | 630 | platform_scoop_config = &spitz_pcmcia_config; |
651 | 631 | ||
652 | spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity; | ||
653 | |||
654 | common_init(); | 632 | common_init(); |
655 | 633 | ||
656 | platform_device_register(&spitzscoop2_device); | 634 | platform_device_register(&spitzscoop2_device); |
@@ -668,26 +646,6 @@ struct platform_device akitaioexp_device = { | |||
668 | 646 | ||
669 | EXPORT_SYMBOL_GPL(akitaioexp_device); | 647 | EXPORT_SYMBOL_GPL(akitaioexp_device); |
670 | 648 | ||
671 | static void akita_bl_set_intensity(int intensity) | ||
672 | { | ||
673 | if (intensity > 0x10) | ||
674 | intensity += 0x10; | ||
675 | |||
676 | /* Bits 0-4 are accessed via the SSP interface */ | ||
677 | corgi_ssp_blduty_set(intensity & 0x1f); | ||
678 | |||
679 | /* Bit 5 is via IO-Expander */ | ||
680 | if (intensity & 0x0020) | ||
681 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT); | ||
682 | else | ||
683 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT); | ||
684 | |||
685 | if (intensity) | ||
686 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON); | ||
687 | else | ||
688 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON); | ||
689 | } | ||
690 | |||
691 | static void __init akita_init(void) | 649 | static void __init akita_init(void) |
692 | { | 650 | { |
693 | spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode; | 651 | spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode; |
@@ -695,7 +653,6 @@ static void __init akita_init(void) | |||
695 | /* We just pretend the second element of the array doesn't exist */ | 653 | /* We just pretend the second element of the array doesn't exist */ |
696 | spitz_pcmcia_config.num_devs = 1; | 654 | spitz_pcmcia_config.num_devs = 1; |
697 | platform_scoop_config = &spitz_pcmcia_config; | 655 | platform_scoop_config = &spitz_pcmcia_config; |
698 | spitz_bl_machinfo.set_bl_intensity = akita_bl_set_intensity; | ||
699 | 656 | ||
700 | platform_device_register(&akitaioexp_device); | 657 | platform_device_register(&akitaioexp_device); |
701 | 658 | ||