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()
143 struct tb10x_gpio *tb10x_gpio = to_tb10x_gpio(chip); in tb10x_gpio_to_irq() local
145 return irq_create_mapping(tb10x_gpio->domain, offset); in tb10x_gpio_to_irq()
162 struct tb10x_gpio *tb10x_gpio = data; in tb10x_gpio_irq_cascade() local
163 u32 r = tb10x_reg_read(tb10x_gpio, OFFSET_TO_REG_CHANGE); in tb10x_gpio_irq_cascade()
164 u32 m = tb10x_reg_read(tb10x_gpio, OFFSET_TO_REG_INT_EN); in tb10x_gpio_irq_cascade()
169 generic_handle_irq(irq_find_mapping(tb10x_gpio->domain, i)); in tb10x_gpio_irq_cascade()
176 struct tb10x_gpio *tb10x_gpio; in tb10x_gpio_probe() local
188 tb10x_gpio = devm_kzalloc(&pdev->dev, sizeof(*tb10x_gpio), GFP_KERNEL); in tb10x_gpio_probe()
189 if (tb10x_gpio == NULL) in tb10x_gpio_probe()
192 spin_lock_init(&tb10x_gpio->spinlock); in tb10x_gpio_probe()
195 tb10x_gpio->base = devm_ioremap_resource(&pdev->dev, mem); in tb10x_gpio_probe()
196 if (IS_ERR(tb10x_gpio->base)) in tb10x_gpio_probe()
197 return PTR_ERR(tb10x_gpio->base); in tb10x_gpio_probe()
199 tb10x_gpio->gc.label = of_node_full_name(dn); in tb10x_gpio_probe()
200 tb10x_gpio->gc.dev = &pdev->dev; in tb10x_gpio_probe()
201 tb10x_gpio->gc.owner = THIS_MODULE; in tb10x_gpio_probe()
202 tb10x_gpio->gc.direction_input = tb10x_gpio_direction_in; in tb10x_gpio_probe()
203 tb10x_gpio->gc.get = tb10x_gpio_get; in tb10x_gpio_probe()
204 tb10x_gpio->gc.direction_output = tb10x_gpio_direction_out; in tb10x_gpio_probe()
205 tb10x_gpio->gc.set = tb10x_gpio_set; in tb10x_gpio_probe()
206 tb10x_gpio->gc.request = gpiochip_generic_request; in tb10x_gpio_probe()
207 tb10x_gpio->gc.free = gpiochip_generic_free; in tb10x_gpio_probe()
208 tb10x_gpio->gc.base = -1; in tb10x_gpio_probe()
209 tb10x_gpio->gc.ngpio = ngpio; in tb10x_gpio_probe()
210 tb10x_gpio->gc.can_sleep = false; in tb10x_gpio_probe()
213 ret = gpiochip_add(&tb10x_gpio->gc); in tb10x_gpio_probe()
219 platform_set_drvdata(pdev, tb10x_gpio); in tb10x_gpio_probe()
230 tb10x_gpio->gc.to_irq = tb10x_gpio_to_irq; in tb10x_gpio_probe()
231 tb10x_gpio->irq = ret; in tb10x_gpio_probe()
235 dev_name(&pdev->dev), tb10x_gpio); in tb10x_gpio_probe()
239 tb10x_gpio->domain = irq_domain_add_linear(dn, in tb10x_gpio_probe()
240 tb10x_gpio->gc.ngpio, in tb10x_gpio_probe()
242 if (!tb10x_gpio->domain) { in tb10x_gpio_probe()
247 ret = irq_alloc_domain_generic_chips(tb10x_gpio->domain, in tb10x_gpio_probe()
248 tb10x_gpio->gc.ngpio, 1, tb10x_gpio->gc.label, in tb10x_gpio_probe()
254 gc = tb10x_gpio->domain->gc->gc[0]; in tb10x_gpio_probe()
255 gc->reg_base = tb10x_gpio->base; in tb10x_gpio_probe()
270 gpiochip_remove(&tb10x_gpio->gc); in tb10x_gpio_probe()
278 struct tb10x_gpio *tb10x_gpio = platform_get_drvdata(pdev); in tb10x_gpio_remove() local
280 if (tb10x_gpio->gc.to_irq) { in tb10x_gpio_remove()
281 irq_remove_generic_chip(tb10x_gpio->domain->gc->gc[0], in tb10x_gpio_remove()
282 BIT(tb10x_gpio->gc.ngpio) - 1, 0, 0); in tb10x_gpio_remove()
283 kfree(tb10x_gpio->domain->gc); in tb10x_gpio_remove()
284 irq_domain_remove(tb10x_gpio->domain); in tb10x_gpio_remove()
286 gpiochip_remove(&tb10x_gpio->gc); in tb10x_gpio_remove()