Lines Matching refs:tb10x_gpio

55 struct tb10x_gpio {  struct
63 static inline u32 tb10x_reg_read(struct tb10x_gpio *gpio, unsigned int offs) in tb10x_reg_read() argument
68 static inline void tb10x_reg_write(struct tb10x_gpio *gpio, unsigned int offs, in tb10x_reg_write()
74 static inline void tb10x_set_bits(struct tb10x_gpio *gpio, unsigned int offs, in tb10x_set_bits()
90 static inline struct tb10x_gpio *to_tb10x_gpio(struct gpio_chip *chip) in to_tb10x_gpio()
92 return container_of(chip, struct tb10x_gpio, gc); in to_tb10x_gpio()
97 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); in tb10x_gpio_direction_in() local
101 tb10x_set_bits(tb10x_gpio, OFFSET_TO_REG_DDR, mask, val); in tb10x_gpio_direction_in()
108 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); in tb10x_gpio_get() local
111 val = tb10x_reg_read(tb10x_gpio, OFFSET_TO_REG_DATA); in tb10x_gpio_get()
121 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); in tb10x_gpio_set() local
125 tb10x_set_bits(tb10x_gpio, OFFSET_TO_REG_DATA, mask, val); in tb10x_gpio_set()
131 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); in tb10x_gpio_direction_out() local
136 tb10x_set_bits(tb10x_gpio, OFFSET_TO_REG_DDR, mask, val); in tb10x_gpio_direction_out()
153 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); in tb10x_gpio_to_irq() local
155 return irq_create_mapping(tb10x_gpio->domain, offset); in tb10x_gpio_to_irq()
172 struct tb10x_gpio *tb10x_gpio = data; in tb10x_gpio_irq_cascade() local
173 u32 r = tb10x_reg_read(tb10x_gpio, OFFSET_TO_REG_CHANGE); in tb10x_gpio_irq_cascade()
174 u32 m = tb10x_reg_read(tb10x_gpio, OFFSET_TO_REG_INT_EN); in tb10x_gpio_irq_cascade()
179 generic_handle_irq(irq_find_mapping(tb10x_gpio->domain, i)); in tb10x_gpio_irq_cascade()
186 struct tb10x_gpio *tb10x_gpio; in tb10x_gpio_probe() local
198 tb10x_gpio = devm_kzalloc(&pdev->dev, sizeof(*tb10x_gpio), GFP_KERNEL); in tb10x_gpio_probe()
199 if (tb10x_gpio == NULL) in tb10x_gpio_probe()
202 spin_lock_init(&tb10x_gpio->spinlock); in tb10x_gpio_probe()
205 tb10x_gpio->base = devm_ioremap_resource(&pdev->dev, mem); in tb10x_gpio_probe()
206 if (IS_ERR(tb10x_gpio->base)) in tb10x_gpio_probe()
207 return PTR_ERR(tb10x_gpio->base); in tb10x_gpio_probe()
209 tb10x_gpio->gc.label = of_node_full_name(dn); in tb10x_gpio_probe()
210 tb10x_gpio->gc.dev = &pdev->dev; in tb10x_gpio_probe()
211 tb10x_gpio->gc.owner = THIS_MODULE; in tb10x_gpio_probe()
212 tb10x_gpio->gc.direction_input = tb10x_gpio_direction_in; in tb10x_gpio_probe()
213 tb10x_gpio->gc.get = tb10x_gpio_get; in tb10x_gpio_probe()
214 tb10x_gpio->gc.direction_output = tb10x_gpio_direction_out; in tb10x_gpio_probe()
215 tb10x_gpio->gc.set = tb10x_gpio_set; in tb10x_gpio_probe()
216 tb10x_gpio->gc.request = tb10x_gpio_request; in tb10x_gpio_probe()
217 tb10x_gpio->gc.free = tb10x_gpio_free; in tb10x_gpio_probe()
218 tb10x_gpio->gc.base = -1; in tb10x_gpio_probe()
219 tb10x_gpio->gc.ngpio = ngpio; in tb10x_gpio_probe()
220 tb10x_gpio->gc.can_sleep = false; in tb10x_gpio_probe()
223 ret = gpiochip_add(&tb10x_gpio->gc); in tb10x_gpio_probe()
229 platform_set_drvdata(pdev, tb10x_gpio); in tb10x_gpio_probe()
240 tb10x_gpio->gc.to_irq = tb10x_gpio_to_irq; in tb10x_gpio_probe()
241 tb10x_gpio->irq = ret; in tb10x_gpio_probe()
245 dev_name(&pdev->dev), tb10x_gpio); in tb10x_gpio_probe()
249 tb10x_gpio->domain = irq_domain_add_linear(dn, in tb10x_gpio_probe()
250 tb10x_gpio->gc.ngpio, in tb10x_gpio_probe()
252 if (!tb10x_gpio->domain) { in tb10x_gpio_probe()
257 ret = irq_alloc_domain_generic_chips(tb10x_gpio->domain, in tb10x_gpio_probe()
258 tb10x_gpio->gc.ngpio, 1, tb10x_gpio->gc.label, in tb10x_gpio_probe()
264 gc = tb10x_gpio->domain->gc->gc[0]; in tb10x_gpio_probe()
265 gc->reg_base = tb10x_gpio->base; in tb10x_gpio_probe()
280 gpiochip_remove(&tb10x_gpio->gc); in tb10x_gpio_probe()
288 struct tb10x_gpio *tb10x_gpio = platform_get_drvdata(pdev); in tb10x_gpio_remove() local
290 if (tb10x_gpio->gc.to_irq) { in tb10x_gpio_remove()
291 irq_remove_generic_chip(tb10x_gpio->domain->gc->gc[0], in tb10x_gpio_remove()
292 BIT(tb10x_gpio->gc.ngpio) - 1, 0, 0); in tb10x_gpio_remove()
293 kfree(tb10x_gpio->domain->gc); in tb10x_gpio_remove()
294 irq_domain_remove(tb10x_gpio->domain); in tb10x_gpio_remove()
295 free_irq(tb10x_gpio->irq, tb10x_gpio); in tb10x_gpio_remove()
297 gpiochip_remove(&tb10x_gpio->gc); in tb10x_gpio_remove()