diff options
| author | Marek Vasut <marek.vasut@gmail.com> | 2010-07-27 17:11:03 -0400 |
|---|---|---|
| committer | Eric Miao <eric.y.miao@gmail.com> | 2010-08-05 02:32:46 -0400 |
| commit | 02a453e4a5a7ca8c8801140f412d327686112e4e (patch) | |
| tree | 94c4644a6021fce19a2511eac5768c71a06c84fe | |
| parent | a9c0629cdefd9c26746ece510fcc88357869685e (diff) | |
[ARM] pxa/balloon3: PCF857x GPIO expander and LEDs
Add supported for PCF8574A GPIO expander and LEDs attached to it.
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
| -rw-r--r-- | arch/arm/mach-pxa/balloon3.c | 84 | ||||
| -rw-r--r-- | arch/arm/mach-pxa/include/mach/balloon3.h | 11 |
2 files changed, 92 insertions, 3 deletions
diff --git a/arch/arm/mach-pxa/balloon3.c b/arch/arm/mach-pxa/balloon3.c index 91ad56d6e929..6f594bd410dd 100644 --- a/arch/arm/mach-pxa/balloon3.c +++ b/arch/arm/mach-pxa/balloon3.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/mtd/mtd.h> | 26 | #include <linux/mtd/mtd.h> |
| 27 | #include <linux/mtd/partitions.h> | 27 | #include <linux/mtd/partitions.h> |
| 28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 29 | #include <linux/i2c/pcf857x.h> | ||
| 29 | 30 | ||
| 30 | #include <asm/setup.h> | 31 | #include <asm/setup.h> |
| 31 | #include <asm/mach-types.h> | 32 | #include <asm/mach-types.h> |
| @@ -375,15 +376,65 @@ static struct gpio_led_platform_data balloon3_gpio_led_info = { | |||
| 375 | 376 | ||
| 376 | static struct platform_device balloon3_leds = { | 377 | static struct platform_device balloon3_leds = { |
| 377 | .name = "leds-gpio", | 378 | .name = "leds-gpio", |
| 378 | .id = -1, | 379 | .id = 0, |
| 379 | .dev = { | 380 | .dev = { |
| 380 | .platform_data = &balloon3_gpio_led_info, | 381 | .platform_data = &balloon3_gpio_led_info, |
| 381 | } | 382 | } |
| 382 | }; | 383 | }; |
| 383 | 384 | ||
| 385 | struct gpio_led balloon3_pcf_gpio_leds[] = { | ||
| 386 | { | ||
| 387 | .name = "balloon3:green:led0", | ||
| 388 | .gpio = BALLOON3_PCF_GPIO_LED0, | ||
| 389 | .active_low = 1, | ||
| 390 | }, { | ||
| 391 | .name = "balloon3:green:led1", | ||
| 392 | .gpio = BALLOON3_PCF_GPIO_LED1, | ||
| 393 | .active_low = 1, | ||
| 394 | }, { | ||
| 395 | .name = "balloon3:orange:led2", | ||
| 396 | .gpio = BALLOON3_PCF_GPIO_LED2, | ||
| 397 | .active_low = 1, | ||
| 398 | }, { | ||
| 399 | .name = "balloon3:orange:led3", | ||
| 400 | .gpio = BALLOON3_PCF_GPIO_LED3, | ||
| 401 | .active_low = 1, | ||
| 402 | }, { | ||
| 403 | .name = "balloon3:orange:led4", | ||
| 404 | .gpio = BALLOON3_PCF_GPIO_LED4, | ||
| 405 | .active_low = 1, | ||
| 406 | }, { | ||
| 407 | .name = "balloon3:orange:led5", | ||
| 408 | .gpio = BALLOON3_PCF_GPIO_LED5, | ||
| 409 | .active_low = 1, | ||
| 410 | }, { | ||
| 411 | .name = "balloon3:red:led6", | ||
| 412 | .gpio = BALLOON3_PCF_GPIO_LED6, | ||
| 413 | .active_low = 1, | ||
| 414 | }, { | ||
| 415 | .name = "balloon3:red:led7", | ||
| 416 | .gpio = BALLOON3_PCF_GPIO_LED7, | ||
| 417 | .active_low = 1, | ||
| 418 | }, | ||
| 419 | }; | ||
| 420 | |||
| 421 | static struct gpio_led_platform_data balloon3_pcf_gpio_led_info = { | ||
| 422 | .leds = balloon3_pcf_gpio_leds, | ||
| 423 | .num_leds = ARRAY_SIZE(balloon3_pcf_gpio_leds), | ||
| 424 | }; | ||
| 425 | |||
| 426 | static struct platform_device balloon3_pcf_leds = { | ||
| 427 | .name = "leds-gpio", | ||
| 428 | .id = 1, | ||
| 429 | .dev = { | ||
| 430 | .platform_data = &balloon3_pcf_gpio_led_info, | ||
| 431 | } | ||
| 432 | }; | ||
| 433 | |||
| 384 | static void __init balloon3_leds_init(void) | 434 | static void __init balloon3_leds_init(void) |
| 385 | { | 435 | { |
| 386 | platform_device_register(&balloon3_leds); | 436 | platform_device_register(&balloon3_leds); |
| 437 | platform_device_register(&balloon3_pcf_leds); | ||
| 387 | } | 438 | } |
| 388 | #else | 439 | #else |
| 389 | static inline void balloon3_leds_init(void) {} | 440 | static inline void balloon3_leds_init(void) {} |
| @@ -451,6 +502,34 @@ static void __init balloon3_init_irq(void) | |||
| 451 | } | 502 | } |
| 452 | 503 | ||
| 453 | /****************************************************************************** | 504 | /****************************************************************************** |
| 505 | * GPIO expander | ||
| 506 | ******************************************************************************/ | ||
| 507 | #if defined(CONFIG_GPIO_PCF857X) || defined(CONFIG_GPIO_PCF857X_MODULE) | ||
| 508 | static struct pcf857x_platform_data balloon3_pcf857x_pdata = { | ||
| 509 | .gpio_base = BALLOON3_PCF_GPIO_BASE, | ||
| 510 | .n_latch = 0, | ||
| 511 | .setup = NULL, | ||
| 512 | .teardown = NULL, | ||
| 513 | .context = NULL, | ||
| 514 | }; | ||
| 515 | |||
| 516 | static struct i2c_board_info __initdata balloon3_i2c_devs[] = { | ||
| 517 | { | ||
| 518 | I2C_BOARD_INFO("pcf8574a", 0x38), | ||
| 519 | .platform_data = &balloon3_pcf857x_pdata, | ||
| 520 | }, | ||
| 521 | }; | ||
| 522 | |||
| 523 | static void __init balloon3_i2c_init(void) | ||
| 524 | { | ||
| 525 | pxa_set_i2c_info(NULL); | ||
| 526 | i2c_register_board_info(0, ARRAY_AND_SIZE(balloon3_i2c_devs)); | ||
| 527 | } | ||
| 528 | #else | ||
| 529 | static inline void balloon3_i2c_init(void) {} | ||
| 530 | #endif | ||
| 531 | |||
| 532 | /****************************************************************************** | ||
| 454 | * Machine init | 533 | * Machine init |
| 455 | ******************************************************************************/ | 534 | ******************************************************************************/ |
| 456 | static void __init balloon3_init(void) | 535 | static void __init balloon3_init(void) |
| @@ -463,8 +542,7 @@ static void __init balloon3_init(void) | |||
| 463 | pxa_set_btuart_info(NULL); | 542 | pxa_set_btuart_info(NULL); |
| 464 | pxa_set_stuart_info(NULL); | 543 | pxa_set_stuart_info(NULL); |
| 465 | 544 | ||
| 466 | pxa_set_i2c_info(NULL); | 545 | balloon3_i2c_init(); |
| 467 | |||
| 468 | balloon3_irda_init(); | 546 | balloon3_irda_init(); |
| 469 | balloon3_lcd_init(); | 547 | balloon3_lcd_init(); |
| 470 | balloon3_leds_init(); | 548 | balloon3_leds_init(); |
diff --git a/arch/arm/mach-pxa/include/mach/balloon3.h b/arch/arm/mach-pxa/include/mach/balloon3.h index d5dcf750c1ef..238f887ebaea 100644 --- a/arch/arm/mach-pxa/include/mach/balloon3.h +++ b/arch/arm/mach-pxa/include/mach/balloon3.h | |||
| @@ -69,6 +69,17 @@ enum balloon3_features { | |||
| 69 | 69 | ||
| 70 | #define BALLOON3_GPIO_S0_CD (105) | 70 | #define BALLOON3_GPIO_S0_CD (105) |
| 71 | 71 | ||
| 72 | /* PCF8574A Leds */ | ||
| 73 | #define BALLOON3_PCF_GPIO_BASE 160 | ||
| 74 | #define BALLOON3_PCF_GPIO_LED0 (BALLOON3_PCF_GPIO_BASE + 0) | ||
| 75 | #define BALLOON3_PCF_GPIO_LED1 (BALLOON3_PCF_GPIO_BASE + 1) | ||
| 76 | #define BALLOON3_PCF_GPIO_LED2 (BALLOON3_PCF_GPIO_BASE + 2) | ||
| 77 | #define BALLOON3_PCF_GPIO_LED3 (BALLOON3_PCF_GPIO_BASE + 3) | ||
| 78 | #define BALLOON3_PCF_GPIO_LED4 (BALLOON3_PCF_GPIO_BASE + 4) | ||
| 79 | #define BALLOON3_PCF_GPIO_LED5 (BALLOON3_PCF_GPIO_BASE + 5) | ||
| 80 | #define BALLOON3_PCF_GPIO_LED6 (BALLOON3_PCF_GPIO_BASE + 6) | ||
| 81 | #define BALLOON3_PCF_GPIO_LED7 (BALLOON3_PCF_GPIO_BASE + 7) | ||
| 82 | |||
| 72 | /* FPGA Interrupt Mask/Acknowledge Register */ | 83 | /* FPGA Interrupt Mask/Acknowledge Register */ |
| 73 | #define BALLOON3_INT_S0_IRQ (1 << 0) /* PCMCIA 0 IRQ */ | 84 | #define BALLOON3_INT_S0_IRQ (1 << 0) /* PCMCIA 0 IRQ */ |
| 74 | #define BALLOON3_INT_S0_STSCHG (1 << 1) /* PCMCIA 0 status changed */ | 85 | #define BALLOON3_INT_S0_STSCHG (1 << 1) /* PCMCIA 0 status changed */ |
