From 76acd346d2e4a0ce2a5daff817d450caccc286be Mon Sep 17 00:00:00 2001 From: Jun Nie Date: Thu, 19 Nov 2009 16:52:46 +0800 Subject: [PATCH] pxa: add gpio expander on pxa168 aspenite platform Signed-off-by: Jun Nie --- arch/arm/mach-mmp/aspenite.c | 45 ++++++++++++++++++++++++++++++++++++++++++ drivers/gpio/pca953x.c | 1 + 2 files changed, 46 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c index 4562452..d1d4a0d 100644 --- a/arch/arm/mach-mmp/aspenite.c +++ b/arch/arm/mach-mmp/aspenite.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -23,6 +24,10 @@ #include "common.h" +/*used by expander max7312, 16 pins gpio expander */ +#define GPIO_EXT0(x) (NR_BUILTIN_GPIO + (x)) +#define GPIO_EXT1(x) (NR_BUILTIN_GPIO + 16 + (x)) + static unsigned long common_pin_config[] __initdata = { /* Data Flash Interface */ GPIO0_DFI_D15, @@ -85,12 +90,52 @@ static struct platform_device smc91x_device = { .resource = smc91x_resources, }; +static struct i2c_pxa_platform_data pwri2c_info __initdata = { + .use_pio = 0, +}; + +#if defined(CONFIG_GPIO_PCA953X) +/* GPIO expander max7312 could reuse PCA953X */ +static struct pca953x_platform_data max7312_data[] = { + /* two max7312 in system */ + + [0] = { + .gpio_base = GPIO_EXT0(0), + }, + + [1] = { + .gpio_base = GPIO_EXT1(0), + }, +}; +#endif + +static struct i2c_board_info aspenite_i2c_board_info[] = { + +#if defined(CONFIG_GPIO_PCA953X) + { + .type = "max7312", + .addr = 0x10, /* 0x20/0x21 */ + .irq = IRQ_GPIO(122), + .platform_data = &max7312_data[0], + }, + + { + .type = "max7312", + .addr = 0x20, /* 0x40/0x41 */ + .irq = IRQ_GPIO(120), + .platform_data = &max7312_data[1], + }, +#endif +}; + static void __init common_init(void) { mfp_config(ARRAY_AND_SIZE(common_pin_config)); /* on-chip devices */ pxa168_add_uart(1); + pxa168_add_twsi(0, &pwri2c_info, + ARRAY_AND_SIZE(aspenite_i2c_board_info)); /* off-chip devices */ platform_device_register(&smc91x_device); diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c index 6a2fb3f..7822684 100644 --- a/drivers/gpio/pca953x.c +++ b/drivers/gpio/pca953x.c @@ -39,6 +39,7 @@ static const struct i2c_device_id pca953x_id[] = { { "pca9557", 8, }, { "max7310", 8, }, + { "max7312", 16, }, { "max7315", 8, }, { "pca6107", 8, }, { "tca6408", 8, }, -- 1.5.4.3