diff options
author | Joakim Tjernlund <joakim.tjernlund@infinera.com> | 2018-06-19 12:22:16 -0400 |
---|---|---|
committer | Li Yang <leoyang.li@nxp.com> | 2018-07-24 17:18:22 -0400 |
commit | 1c0b7df5d333b0bf7159ded5fa8dec49cde715fc (patch) | |
tree | 15f6049da1f2e20223983075775acd604982e927 | |
parent | ce397d215ccd07b8ae3f71db689aedb85d56ab40 (diff) |
soc: fsl: qe: gpio: Add qe_gpio_set_multiple
This cousin to gpio-mpc8xxx was lacking a multiple pins method,
add one.
Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Reviewed-by: Qiang Zhao <qiang.zhao@nxp.com>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
-rw-r--r-- | drivers/soc/fsl/qe/gpio.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c index 3b27075c21a7..819bed0f5667 100644 --- a/drivers/soc/fsl/qe/gpio.c +++ b/drivers/soc/fsl/qe/gpio.c | |||
@@ -83,6 +83,33 @@ static void qe_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) | |||
83 | spin_unlock_irqrestore(&qe_gc->lock, flags); | 83 | spin_unlock_irqrestore(&qe_gc->lock, flags); |
84 | } | 84 | } |
85 | 85 | ||
86 | static void qe_gpio_set_multiple(struct gpio_chip *gc, | ||
87 | unsigned long *mask, unsigned long *bits) | ||
88 | { | ||
89 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | ||
90 | struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc); | ||
91 | struct qe_pio_regs __iomem *regs = mm_gc->regs; | ||
92 | unsigned long flags; | ||
93 | int i; | ||
94 | |||
95 | spin_lock_irqsave(&qe_gc->lock, flags); | ||
96 | |||
97 | for (i = 0; i < gc->ngpio; i++) { | ||
98 | if (*mask == 0) | ||
99 | break; | ||
100 | if (__test_and_clear_bit(i, mask)) { | ||
101 | if (test_bit(i, bits)) | ||
102 | qe_gc->cpdata |= (1U << (QE_PIO_PINS - 1 - i)); | ||
103 | else | ||
104 | qe_gc->cpdata &= ~(1U << (QE_PIO_PINS - 1 - i)); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | out_be32(®s->cpdata, qe_gc->cpdata); | ||
109 | |||
110 | spin_unlock_irqrestore(&qe_gc->lock, flags); | ||
111 | } | ||
112 | |||
86 | static int qe_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) | 113 | static int qe_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) |
87 | { | 114 | { |
88 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | 115 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); |
@@ -298,6 +325,7 @@ static int __init qe_add_gpiochips(void) | |||
298 | gc->direction_output = qe_gpio_dir_out; | 325 | gc->direction_output = qe_gpio_dir_out; |
299 | gc->get = qe_gpio_get; | 326 | gc->get = qe_gpio_get; |
300 | gc->set = qe_gpio_set; | 327 | gc->set = qe_gpio_set; |
328 | gc->set_multiple = qe_gpio_set_multiple; | ||
301 | 329 | ||
302 | ret = of_mm_gpiochip_add_data(np, mm_gc, qe_gc); | 330 | ret = of_mm_gpiochip_add_data(np, mm_gc, qe_gc); |
303 | if (ret) | 331 | if (ret) |