aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-lpc32xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio/gpio-lpc32xx.c')
-rw-r--r--drivers/gpio/gpio-lpc32xx.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c
index ddfacc5ce56d..61c2d08d37b6 100644
--- a/drivers/gpio/gpio-lpc32xx.c
+++ b/drivers/gpio/gpio-lpc32xx.c
@@ -59,12 +59,14 @@
59#define GPO3_PIN_TO_BIT(x) (1 << (x)) 59#define GPO3_PIN_TO_BIT(x) (1 << (x))
60#define GPIO012_PIN_IN_SEL(x, y) (((x) >> (y)) & 1) 60#define GPIO012_PIN_IN_SEL(x, y) (((x) >> (y)) & 1)
61#define GPIO3_PIN_IN_SHIFT(x) ((x) == 5 ? 24 : 10 + (x)) 61#define GPIO3_PIN_IN_SHIFT(x) ((x) == 5 ? 24 : 10 + (x))
62#define GPIO3_PIN_IN_SEL(x, y) ((x) >> GPIO3_PIN_IN_SHIFT(y)) 62#define GPIO3_PIN_IN_SEL(x, y) (((x) >> GPIO3_PIN_IN_SHIFT(y)) & 1)
63#define GPIO3_PIN5_IN_SEL(x) (((x) >> 24) & 1) 63#define GPIO3_PIN5_IN_SEL(x) (((x) >> 24) & 1)
64#define GPI3_PIN_IN_SEL(x, y) (((x) >> (y)) & 1) 64#define GPI3_PIN_IN_SEL(x, y) (((x) >> (y)) & 1)
65#define GPO3_PIN_IN_SEL(x, y) (((x) >> (y)) & 1)
65 66
66struct gpio_regs { 67struct gpio_regs {
67 void __iomem *inp_state; 68 void __iomem *inp_state;
69 void __iomem *outp_state;
68 void __iomem *outp_set; 70 void __iomem *outp_set;
69 void __iomem *outp_clr; 71 void __iomem *outp_clr;
70 void __iomem *dir_set; 72 void __iomem *dir_set;
@@ -145,6 +147,7 @@ static struct gpio_regs gpio_grp_regs_p2 = {
145 147
146static struct gpio_regs gpio_grp_regs_p3 = { 148static struct gpio_regs gpio_grp_regs_p3 = {
147 .inp_state = LPC32XX_GPIO_P3_INP_STATE, 149 .inp_state = LPC32XX_GPIO_P3_INP_STATE,
150 .outp_state = LPC32XX_GPIO_P3_OUTP_STATE,
148 .outp_set = LPC32XX_GPIO_P3_OUTP_SET, 151 .outp_set = LPC32XX_GPIO_P3_OUTP_SET,
149 .outp_clr = LPC32XX_GPIO_P3_OUTP_CLR, 152 .outp_clr = LPC32XX_GPIO_P3_OUTP_CLR,
150 .dir_set = LPC32XX_GPIO_P2_DIR_SET, 153 .dir_set = LPC32XX_GPIO_P2_DIR_SET,
@@ -240,6 +243,12 @@ static int __get_gpi_state_p3(struct lpc32xx_gpio_chip *group,
240 return GPI3_PIN_IN_SEL(__raw_readl(group->gpio_grp->inp_state), pin); 243 return GPI3_PIN_IN_SEL(__raw_readl(group->gpio_grp->inp_state), pin);
241} 244}
242 245
246static int __get_gpo_state_p3(struct lpc32xx_gpio_chip *group,
247 unsigned pin)
248{
249 return GPO3_PIN_IN_SEL(__raw_readl(group->gpio_grp->outp_state), pin);
250}
251
243/* 252/*
244 * GENERIC_GPIO primitives. 253 * GENERIC_GPIO primitives.
245 */ 254 */
@@ -340,6 +349,13 @@ static void lpc32xx_gpo_set_value(struct gpio_chip *chip, unsigned pin,
340 __set_gpo_level_p3(group, pin, value); 349 __set_gpo_level_p3(group, pin, value);
341} 350}
342 351
352static int lpc32xx_gpo_get_value(struct gpio_chip *chip, unsigned pin)
353{
354 struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip);
355
356 return __get_gpo_state_p3(group, pin);
357}
358
343static int lpc32xx_gpio_request(struct gpio_chip *chip, unsigned pin) 359static int lpc32xx_gpio_request(struct gpio_chip *chip, unsigned pin)
344{ 360{
345 if (pin < chip->ngpio) 361 if (pin < chip->ngpio)
@@ -427,6 +443,7 @@ static struct lpc32xx_gpio_chip lpc32xx_gpiochip[] = {
427 .label = "gpo_p3", 443 .label = "gpo_p3",
428 .direction_output = lpc32xx_gpio_dir_out_always, 444 .direction_output = lpc32xx_gpio_dir_out_always,
429 .set = lpc32xx_gpo_set_value, 445 .set = lpc32xx_gpo_set_value,
446 .get = lpc32xx_gpo_get_value,
430 .request = lpc32xx_gpio_request, 447 .request = lpc32xx_gpio_request,
431 .base = LPC32XX_GPO_P3_GRP, 448 .base = LPC32XX_GPO_P3_GRP,
432 .ngpio = LPC32XX_GPO_P3_MAX, 449 .ngpio = LPC32XX_GPO_P3_MAX,