Lines Matching +full:gpio +full:- +full:pol
3 * GPIO driver
6 * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
11 #include <linux/gpio/driver.h>
22 static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio) in bcma_gpio_get_value() argument
26 return !!bcma_chipco_gpio_in(cc, 1 << gpio); in bcma_gpio_get_value()
29 static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio, in bcma_gpio_set_value() argument
34 bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0); in bcma_gpio_set_value()
37 static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) in bcma_gpio_direction_input() argument
41 bcma_chipco_gpio_outen(cc, 1 << gpio, 0); in bcma_gpio_direction_input()
45 static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, in bcma_gpio_direction_output() argument
50 bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio); in bcma_gpio_direction_output()
51 bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0); in bcma_gpio_direction_output()
55 static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio) in bcma_gpio_request() argument
59 bcma_chipco_gpio_control(cc, 1 << gpio, 0); in bcma_gpio_request()
61 bcma_chipco_gpio_pulldown(cc, 1 << gpio, 0); in bcma_gpio_request()
63 bcma_chipco_gpio_pullup(cc, 1 << gpio, 1 << gpio); in bcma_gpio_request()
68 static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio) in bcma_gpio_free() argument
73 bcma_chipco_gpio_pullup(cc, 1 << gpio, 0); in bcma_gpio_free()
82 int gpio = irqd_to_hwirq(d); in bcma_gpio_irq_unmask() local
83 u32 val = bcma_chipco_gpio_in(cc, BIT(gpio)); in bcma_gpio_irq_unmask()
85 gpiochip_enable_irq(gc, gpio); in bcma_gpio_irq_unmask()
86 bcma_chipco_gpio_polarity(cc, BIT(gpio), val); in bcma_gpio_irq_unmask()
87 bcma_chipco_gpio_intmask(cc, BIT(gpio), BIT(gpio)); in bcma_gpio_irq_unmask()
94 int gpio = irqd_to_hwirq(d); in bcma_gpio_irq_mask() local
96 bcma_chipco_gpio_intmask(cc, BIT(gpio), 0); in bcma_gpio_irq_mask()
97 gpiochip_disable_irq(gc, gpio); in bcma_gpio_irq_mask()
101 .name = "BCMA-GPIO",
111 struct gpio_chip *gc = &cc->gpio; in bcma_gpio_irq_handler()
114 u32 pol = bcma_cc_read32(cc, BCMA_CC_GPIOPOL); in bcma_gpio_irq_handler() local
115 unsigned long irqs = (val ^ pol) & mask; in bcma_gpio_irq_handler()
116 int gpio; in bcma_gpio_irq_handler() local
121 for_each_set_bit(gpio, &irqs, gc->ngpio) in bcma_gpio_irq_handler()
122 generic_handle_domain_irq_safe(gc->irq.domain, gpio); in bcma_gpio_irq_handler()
130 struct gpio_chip *chip = &cc->gpio; in bcma_gpio_irq_init()
131 struct gpio_irq_chip *girq = &chip->irq; in bcma_gpio_irq_init()
134 if (cc->core->bus->hosttype != BCMA_HOSTTYPE_SOC) in bcma_gpio_irq_init()
137 hwirq = bcma_core_irq(cc->core, 0); in bcma_gpio_irq_init()
138 err = request_irq(hwirq, bcma_gpio_irq_handler, IRQF_SHARED, "gpio", in bcma_gpio_irq_init()
148 girq->parent_handler = NULL; in bcma_gpio_irq_init()
149 girq->num_parents = 0; in bcma_gpio_irq_init()
150 girq->parents = NULL; in bcma_gpio_irq_init()
151 girq->default_type = IRQ_TYPE_NONE; in bcma_gpio_irq_init()
152 girq->handler = handle_simple_irq; in bcma_gpio_irq_init()
159 if (cc->core->bus->hosttype != BCMA_HOSTTYPE_SOC) in bcma_gpio_irq_exit()
163 free_irq(bcma_core_irq(cc->core, 0), cc); in bcma_gpio_irq_exit()
178 struct bcma_bus *bus = cc->core->bus; in bcma_gpio_init()
179 struct gpio_chip *chip = &cc->gpio; in bcma_gpio_init()
182 chip->label = "bcma_gpio"; in bcma_gpio_init()
183 chip->owner = THIS_MODULE; in bcma_gpio_init()
184 chip->request = bcma_gpio_request; in bcma_gpio_init()
185 chip->free = bcma_gpio_free; in bcma_gpio_init()
186 chip->get = bcma_gpio_get_value; in bcma_gpio_init()
187 chip->set = bcma_gpio_set_value; in bcma_gpio_init()
188 chip->direction_input = bcma_gpio_direction_input; in bcma_gpio_init()
189 chip->direction_output = bcma_gpio_direction_output; in bcma_gpio_init()
190 chip->parent = bus->dev; in bcma_gpio_init()
191 chip->fwnode = dev_fwnode(&cc->core->dev); in bcma_gpio_init()
193 switch (bus->chipinfo.id) { in bcma_gpio_init()
199 chip->ngpio = 32; in bcma_gpio_init()
202 chip->ngpio = 16; in bcma_gpio_init()
206 * Register SoC GPIO devices with absolute GPIO pin base. in bcma_gpio_init()
208 * GPIO numbers. in bcma_gpio_init()
209 * On some ARM devices, user space may want to access some system GPIO in bcma_gpio_init()
210 * pins directly, which is easier to do with a predictable GPIO base. in bcma_gpio_init()
213 cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC) in bcma_gpio_init()
214 chip->base = bus->num * BCMA_GPIO_MAX_PINS; in bcma_gpio_init()
216 chip->base = -1; in bcma_gpio_init()
234 gpiochip_remove(&cc->gpio); in bcma_gpio_unregister()