Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02a453e4 authored by Marek Vasut's avatar Marek Vasut Committed by Eric Miao
Browse files

[ARM] pxa/balloon3: PCF857x GPIO expander and LEDs



Add supported for PCF8574A GPIO expander and LEDs attached to it.

Signed-off-by: default avatarMarek Vasut <marek.vasut@gmail.com>
parent a9c0629c
Loading
Loading
Loading
Loading
+81 −3
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/partitions.h>
#include <linux/types.h>
#include <linux/types.h>
#include <linux/i2c/pcf857x.h>


#include <asm/setup.h>
#include <asm/setup.h>
#include <asm/mach-types.h>
#include <asm/mach-types.h>
@@ -375,15 +376,65 @@ static struct gpio_led_platform_data balloon3_gpio_led_info = {


static struct platform_device balloon3_leds = {
static struct platform_device balloon3_leds = {
	.name	= "leds-gpio",
	.name	= "leds-gpio",
	.id	= -1,
	.id	= 0,
	.dev	= {
	.dev	= {
		.platform_data	= &balloon3_gpio_led_info,
		.platform_data	= &balloon3_gpio_led_info,
	}
	}
};
};


struct gpio_led balloon3_pcf_gpio_leds[] = {
	{
		.name			= "balloon3:green:led0",
		.gpio			= BALLOON3_PCF_GPIO_LED0,
		.active_low		= 1,
	}, {
		.name			= "balloon3:green:led1",
		.gpio			= BALLOON3_PCF_GPIO_LED1,
		.active_low		= 1,
	}, {
		.name			= "balloon3:orange:led2",
		.gpio			= BALLOON3_PCF_GPIO_LED2,
		.active_low		= 1,
	}, {
		.name			= "balloon3:orange:led3",
		.gpio			= BALLOON3_PCF_GPIO_LED3,
		.active_low		= 1,
	}, {
		.name			= "balloon3:orange:led4",
		.gpio			= BALLOON3_PCF_GPIO_LED4,
		.active_low		= 1,
	}, {
		.name			= "balloon3:orange:led5",
		.gpio			= BALLOON3_PCF_GPIO_LED5,
		.active_low		= 1,
	}, {
		.name			= "balloon3:red:led6",
		.gpio			= BALLOON3_PCF_GPIO_LED6,
		.active_low		= 1,
	}, {
		.name			= "balloon3:red:led7",
		.gpio			= BALLOON3_PCF_GPIO_LED7,
		.active_low		= 1,
	},
};

static struct gpio_led_platform_data balloon3_pcf_gpio_led_info = {
	.leds		= balloon3_pcf_gpio_leds,
	.num_leds	= ARRAY_SIZE(balloon3_pcf_gpio_leds),
};

static struct platform_device balloon3_pcf_leds = {
	.name	= "leds-gpio",
	.id	= 1,
	.dev	= {
		.platform_data	= &balloon3_pcf_gpio_led_info,
	}
};

static void __init balloon3_leds_init(void)
static void __init balloon3_leds_init(void)
{
{
	platform_device_register(&balloon3_leds);
	platform_device_register(&balloon3_leds);
	platform_device_register(&balloon3_pcf_leds);
}
}
#else
#else
static inline void balloon3_leds_init(void) {}
static inline void balloon3_leds_init(void) {}
@@ -450,6 +501,34 @@ static void __init balloon3_init_irq(void)
		"enabled\n", __func__, BALLOON3_AUX_NIRQ);
		"enabled\n", __func__, BALLOON3_AUX_NIRQ);
}
}


/******************************************************************************
 * GPIO expander
 ******************************************************************************/
#if defined(CONFIG_GPIO_PCF857X) || defined(CONFIG_GPIO_PCF857X_MODULE)
static struct pcf857x_platform_data balloon3_pcf857x_pdata = {
	.gpio_base	= BALLOON3_PCF_GPIO_BASE,
	.n_latch	= 0,
	.setup		= NULL,
	.teardown	= NULL,
	.context	= NULL,
};

static struct i2c_board_info __initdata balloon3_i2c_devs[] = {
	{
		I2C_BOARD_INFO("pcf8574a", 0x38),
		.platform_data	= &balloon3_pcf857x_pdata,
	},
};

static void __init balloon3_i2c_init(void)
{
	pxa_set_i2c_info(NULL);
	i2c_register_board_info(0, ARRAY_AND_SIZE(balloon3_i2c_devs));
}
#else
static inline void balloon3_i2c_init(void) {}
#endif

/******************************************************************************
/******************************************************************************
 * Machine init
 * Machine init
 ******************************************************************************/
 ******************************************************************************/
@@ -463,8 +542,7 @@ static void __init balloon3_init(void)
	pxa_set_btuart_info(NULL);
	pxa_set_btuart_info(NULL);
	pxa_set_stuart_info(NULL);
	pxa_set_stuart_info(NULL);


	pxa_set_i2c_info(NULL);
	balloon3_i2c_init();

	balloon3_irda_init();
	balloon3_irda_init();
	balloon3_lcd_init();
	balloon3_lcd_init();
	balloon3_leds_init();
	balloon3_leds_init();
+11 −0
Original line number Original line Diff line number Diff line
@@ -69,6 +69,17 @@ enum balloon3_features {


#define BALLOON3_GPIO_S0_CD		(105)
#define BALLOON3_GPIO_S0_CD		(105)


/* PCF8574A Leds */
#define	BALLOON3_PCF_GPIO_BASE		160
#define	BALLOON3_PCF_GPIO_LED0		(BALLOON3_PCF_GPIO_BASE + 0)
#define	BALLOON3_PCF_GPIO_LED1		(BALLOON3_PCF_GPIO_BASE + 1)
#define	BALLOON3_PCF_GPIO_LED2		(BALLOON3_PCF_GPIO_BASE + 2)
#define	BALLOON3_PCF_GPIO_LED3		(BALLOON3_PCF_GPIO_BASE + 3)
#define	BALLOON3_PCF_GPIO_LED4		(BALLOON3_PCF_GPIO_BASE + 4)
#define	BALLOON3_PCF_GPIO_LED5		(BALLOON3_PCF_GPIO_BASE + 5)
#define	BALLOON3_PCF_GPIO_LED6		(BALLOON3_PCF_GPIO_BASE + 6)
#define	BALLOON3_PCF_GPIO_LED7		(BALLOON3_PCF_GPIO_BASE + 7)

/* FPGA Interrupt Mask/Acknowledge Register */
/* FPGA Interrupt Mask/Acknowledge Register */
#define BALLOON3_INT_S0_IRQ		(1 << 0)  /* PCMCIA 0 IRQ */
#define BALLOON3_INT_S0_IRQ		(1 << 0)  /* PCMCIA 0 IRQ */
#define BALLOON3_INT_S0_STSCHG		(1 << 1)  /* PCMCIA 0 status changed */
#define BALLOON3_INT_S0_STSCHG		(1 << 1)  /* PCMCIA 0 status changed */