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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Simon Horman <horms@verge.net.au>
Acked-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
This commit is contained in:
Kuninori Morimoto 2012-04-22 23:54:14 -07:00 committed by Rafael J. Wysocki
parent 7775a93363
commit 1e35464125

View file

@ -19,9 +19,12 @@
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/gpio_keys.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/i2c.h>
#include <linux/i2c/pcf857x.h>
#include <linux/input.h>
#include <linux/mmc/host.h>
#include <linux/mmc/sh_mmcif.h>
#include <linux/mmc/sh_mobile_sdhi.h>
@ -39,6 +42,18 @@
#include <asm/mach/arch.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 */
static struct resource smsc9221_resources[] = {
[0] = {
@ -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 */
static struct pcf857x_platform_data pcf8575_pdata = {
.gpio_base = GPIO_PCF8575_BASE,
};
static struct i2c_board_info i2c1_devices[] = {
{
I2C_BOARD_INFO("st1232-ts", 0x55),
@ -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 = {
&smsc_device,
&usb_host_device,
&lcdc_device,
&mmc_device,
&sdhi0_device,
&gpio_keys_device,
};
/*
@ -373,12 +427,17 @@ static void __init kzm_init(void)
gpio_request(GPIO_PORT15, NULL);
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
/* Early BRESP enable, Shared attribute override enable, 64K*8way */
l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
#endif
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();
platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));