提交 1e354641 编写于 作者: K Kuninori Morimoto 提交者: Rafael J. Wysocki

ARM: mach-shmobile: kzm9g: add PCF8757 gpio-key

This patch adds extra GPIO via PCF8757 chip,
and use it as gpio-key.
Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: NSimon Horman <horms@verge.net.au>
Acked-by: NMagnus Damm <damm@opensource.se>
Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
上级 7775a933
...@@ -19,9 +19,12 @@ ...@@ -19,9 +19,12 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio_keys.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c/pcf857x.h>
#include <linux/input.h>
#include <linux/mmc/host.h> #include <linux/mmc/host.h>
#include <linux/mmc/sh_mmcif.h> #include <linux/mmc/sh_mmcif.h>
#include <linux/mmc/sh_mobile_sdhi.h> #include <linux/mmc/sh_mobile_sdhi.h>
...@@ -39,6 +42,18 @@ ...@@ -39,6 +42,18 @@
#include <asm/mach/arch.h> #include <asm/mach/arch.h>
#include <video/sh_mobile_lcdc.h> #include <video/sh_mobile_lcdc.h>
/*
* external GPIO
*/
#define GPIO_PCF8575_BASE (GPIO_NR)
#define GPIO_PCF8575_PORT10 (GPIO_NR + 8)
#define GPIO_PCF8575_PORT11 (GPIO_NR + 9)
#define GPIO_PCF8575_PORT12 (GPIO_NR + 10)
#define GPIO_PCF8575_PORT13 (GPIO_NR + 11)
#define GPIO_PCF8575_PORT14 (GPIO_NR + 12)
#define GPIO_PCF8575_PORT15 (GPIO_NR + 13)
#define GPIO_PCF8575_PORT16 (GPIO_NR + 14)
/* SMSC 9221 */ /* SMSC 9221 */
static struct resource smsc9221_resources[] = { static struct resource smsc9221_resources[] = {
[0] = { [0] = {
...@@ -225,7 +240,38 @@ static struct platform_device sdhi0_device = { ...@@ -225,7 +240,38 @@ static struct platform_device sdhi0_device = {
}, },
}; };
/* KEY */
#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
static struct gpio_keys_button gpio_buttons[] = {
GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"),
GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"),
GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"),
GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"),
GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"),
GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"),
GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"),
};
static struct gpio_keys_platform_data gpio_key_info = {
.buttons = gpio_buttons,
.nbuttons = ARRAY_SIZE(gpio_buttons),
.poll_interval = 250, /* poling at this point */
};
static struct platform_device gpio_keys_device = {
/* gpio-pcf857x.c driver doesn't support gpio_to_irq() */
.name = "gpio-keys-polled",
.dev = {
.platform_data = &gpio_key_info,
},
};
/* I2C */ /* I2C */
static struct pcf857x_platform_data pcf8575_pdata = {
.gpio_base = GPIO_PCF8575_BASE,
};
static struct i2c_board_info i2c1_devices[] = { static struct i2c_board_info i2c1_devices[] = {
{ {
I2C_BOARD_INFO("st1232-ts", 0x55), I2C_BOARD_INFO("st1232-ts", 0x55),
...@@ -233,12 +279,20 @@ static struct i2c_board_info i2c1_devices[] = { ...@@ -233,12 +279,20 @@ static struct i2c_board_info i2c1_devices[] = {
}, },
}; };
static struct i2c_board_info i2c3_devices[] = {
{
I2C_BOARD_INFO("pcf8575", 0x20),
.platform_data = &pcf8575_pdata,
},
};
static struct platform_device *kzm_devices[] __initdata = { static struct platform_device *kzm_devices[] __initdata = {
&smsc_device, &smsc_device,
&usb_host_device, &usb_host_device,
&lcdc_device, &lcdc_device,
&mmc_device, &mmc_device,
&sdhi0_device, &sdhi0_device,
&gpio_keys_device,
}; };
/* /*
...@@ -373,12 +427,17 @@ static void __init kzm_init(void) ...@@ -373,12 +427,17 @@ static void __init kzm_init(void)
gpio_request(GPIO_PORT15, NULL); gpio_request(GPIO_PORT15, NULL);
gpio_direction_output(GPIO_PORT15, 1); /* power */ gpio_direction_output(GPIO_PORT15, 1); /* power */
/* I2C 3 */
gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL);
gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL);
#ifdef CONFIG_CACHE_L2X0 #ifdef CONFIG_CACHE_L2X0
/* Early BRESP enable, Shared attribute override enable, 64K*8way */ /* Early BRESP enable, Shared attribute override enable, 64K*8way */
l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff); l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
#endif #endif
i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices)); i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices));
sh73a0_add_standard_devices(); sh73a0_add_standard_devices();
platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices)); platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册