Lines Matching refs:ochip

51 static void __iomem *GPIO_OUT(struct orion_gpio_chip *ochip)  in GPIO_OUT()  argument
53 return ochip->base + GPIO_OUT_OFF; in GPIO_OUT()
56 static void __iomem *GPIO_IO_CONF(struct orion_gpio_chip *ochip) in GPIO_IO_CONF() argument
58 return ochip->base + GPIO_IO_CONF_OFF; in GPIO_IO_CONF()
61 static void __iomem *GPIO_BLINK_EN(struct orion_gpio_chip *ochip) in GPIO_BLINK_EN() argument
63 return ochip->base + GPIO_BLINK_EN_OFF; in GPIO_BLINK_EN()
66 static void __iomem *GPIO_IN_POL(struct orion_gpio_chip *ochip) in GPIO_IN_POL() argument
68 return ochip->base + GPIO_IN_POL_OFF; in GPIO_IN_POL()
71 static void __iomem *GPIO_DATA_IN(struct orion_gpio_chip *ochip) in GPIO_DATA_IN() argument
73 return ochip->base + GPIO_DATA_IN_OFF; in GPIO_DATA_IN()
76 static void __iomem *GPIO_EDGE_CAUSE(struct orion_gpio_chip *ochip) in GPIO_EDGE_CAUSE() argument
78 return ochip->base + GPIO_EDGE_CAUSE_OFF; in GPIO_EDGE_CAUSE()
81 static void __iomem *GPIO_EDGE_MASK(struct orion_gpio_chip *ochip) in GPIO_EDGE_MASK() argument
83 return ochip->base + ochip->mask_offset + GPIO_EDGE_MASK_OFF; in GPIO_EDGE_MASK()
86 static void __iomem *GPIO_LEVEL_MASK(struct orion_gpio_chip *ochip) in GPIO_LEVEL_MASK() argument
88 return ochip->base + ochip->mask_offset + GPIO_LEVEL_MASK_OFF; in GPIO_LEVEL_MASK()
96 __set_direction(struct orion_gpio_chip *ochip, unsigned pin, int input) in __set_direction() argument
100 u = readl(GPIO_IO_CONF(ochip)); in __set_direction()
105 writel(u, GPIO_IO_CONF(ochip)); in __set_direction()
108 static void __set_level(struct orion_gpio_chip *ochip, unsigned pin, int high) in __set_level() argument
112 u = readl(GPIO_OUT(ochip)); in __set_level()
117 writel(u, GPIO_OUT(ochip)); in __set_level()
121 __set_blinking(struct orion_gpio_chip *ochip, unsigned pin, int blink) in __set_blinking() argument
125 u = readl(GPIO_BLINK_EN(ochip)); in __set_blinking()
130 writel(u, GPIO_BLINK_EN(ochip)); in __set_blinking()
134 orion_gpio_is_valid(struct orion_gpio_chip *ochip, unsigned pin, int mode) in orion_gpio_is_valid() argument
136 if (pin >= ochip->chip.ngpio) in orion_gpio_is_valid()
139 if ((mode & GPIO_INPUT_OK) && !test_bit(pin, &ochip->valid_input)) in orion_gpio_is_valid()
142 if ((mode & GPIO_OUTPUT_OK) && !test_bit(pin, &ochip->valid_output)) in orion_gpio_is_valid()
157 struct orion_gpio_chip *ochip = gpiochip_get_data(chip); in orion_gpio_request() local
159 if (orion_gpio_is_valid(ochip, pin, GPIO_INPUT_OK) || in orion_gpio_request()
160 orion_gpio_is_valid(ochip, pin, GPIO_OUTPUT_OK)) in orion_gpio_request()
168 struct orion_gpio_chip *ochip = gpiochip_get_data(chip); in orion_gpio_direction_input() local
171 if (!orion_gpio_is_valid(ochip, pin, GPIO_INPUT_OK)) in orion_gpio_direction_input()
174 spin_lock_irqsave(&ochip->lock, flags); in orion_gpio_direction_input()
175 __set_direction(ochip, pin, 1); in orion_gpio_direction_input()
176 spin_unlock_irqrestore(&ochip->lock, flags); in orion_gpio_direction_input()
183 struct orion_gpio_chip *ochip = gpiochip_get_data(chip); in orion_gpio_get() local
186 if (readl(GPIO_IO_CONF(ochip)) & (1 << pin)) { in orion_gpio_get()
187 val = readl(GPIO_DATA_IN(ochip)) ^ readl(GPIO_IN_POL(ochip)); in orion_gpio_get()
189 val = readl(GPIO_OUT(ochip)); in orion_gpio_get()
198 struct orion_gpio_chip *ochip = gpiochip_get_data(chip); in orion_gpio_direction_output() local
201 if (!orion_gpio_is_valid(ochip, pin, GPIO_OUTPUT_OK)) in orion_gpio_direction_output()
204 spin_lock_irqsave(&ochip->lock, flags); in orion_gpio_direction_output()
205 __set_blinking(ochip, pin, 0); in orion_gpio_direction_output()
206 __set_level(ochip, pin, value); in orion_gpio_direction_output()
207 __set_direction(ochip, pin, 0); in orion_gpio_direction_output()
208 spin_unlock_irqrestore(&ochip->lock, flags); in orion_gpio_direction_output()
215 struct orion_gpio_chip *ochip = gpiochip_get_data(chip); in orion_gpio_set() local
218 spin_lock_irqsave(&ochip->lock, flags); in orion_gpio_set()
219 __set_level(ochip, pin, value); in orion_gpio_set()
220 spin_unlock_irqrestore(&ochip->lock, flags); in orion_gpio_set()
225 struct orion_gpio_chip *ochip = gpiochip_get_data(chip); in orion_gpio_to_irq() local
227 return irq_create_mapping(ochip->domain, in orion_gpio_to_irq()
228 ochip->secondary_irq_base + pin); in orion_gpio_to_irq()
239 struct orion_gpio_chip *ochip = orion_gpio_chips + i; in orion_gpio_chip_find() local
240 struct gpio_chip *chip = &ochip->chip; in orion_gpio_chip_find()
243 return ochip; in orion_gpio_chip_find()
251 struct orion_gpio_chip *ochip = orion_gpio_chip_find(pin); in orion_gpio_set_unused() local
253 if (ochip == NULL) in orion_gpio_set_unused()
256 pin -= ochip->chip.base; in orion_gpio_set_unused()
259 __set_level(ochip, pin, 0); in orion_gpio_set_unused()
260 __set_direction(ochip, pin, 0); in orion_gpio_set_unused()
265 struct orion_gpio_chip *ochip = orion_gpio_chip_find(pin); in orion_gpio_set_valid() local
267 if (ochip == NULL) in orion_gpio_set_valid()
270 pin -= ochip->chip.base; in orion_gpio_set_valid()
276 __set_bit(pin, &ochip->valid_input); in orion_gpio_set_valid()
278 __clear_bit(pin, &ochip->valid_input); in orion_gpio_set_valid()
281 __set_bit(pin, &ochip->valid_output); in orion_gpio_set_valid()
283 __clear_bit(pin, &ochip->valid_output); in orion_gpio_set_valid()
288 struct orion_gpio_chip *ochip = orion_gpio_chip_find(pin); in orion_gpio_set_blink() local
291 if (ochip == NULL) in orion_gpio_set_blink()
294 spin_lock_irqsave(&ochip->lock, flags); in orion_gpio_set_blink()
295 __set_level(ochip, pin & 31, 0); in orion_gpio_set_blink()
296 __set_blinking(ochip, pin & 31, blink); in orion_gpio_set_blink()
297 spin_unlock_irqrestore(&ochip->lock, flags); in orion_gpio_set_blink()
355 struct orion_gpio_chip *ochip = gc->private; in gpio_irq_set_type() local
359 pin = d->hwirq - ochip->secondary_irq_base; in gpio_irq_set_type()
361 u = readl(GPIO_IO_CONF(ochip)) & (1 << pin); in gpio_irq_set_type()
379 u = readl(GPIO_IN_POL(ochip)); in gpio_irq_set_type()
381 writel(u, GPIO_IN_POL(ochip)); in gpio_irq_set_type()
383 u = readl(GPIO_IN_POL(ochip)); in gpio_irq_set_type()
385 writel(u, GPIO_IN_POL(ochip)); in gpio_irq_set_type()
389 v = readl(GPIO_IN_POL(ochip)) ^ readl(GPIO_DATA_IN(ochip)); in gpio_irq_set_type()
394 u = readl(GPIO_IN_POL(ochip)); in gpio_irq_set_type()
399 writel(u, GPIO_IN_POL(ochip)); in gpio_irq_set_type()
406 struct orion_gpio_chip *ochip = irq_desc_get_handler_data(desc); in gpio_irq_handler() local
410 if (ochip == NULL) in gpio_irq_handler()
413 cause = readl(GPIO_DATA_IN(ochip)) & readl(GPIO_LEVEL_MASK(ochip)); in gpio_irq_handler()
414 cause |= readl(GPIO_EDGE_CAUSE(ochip)) & readl(GPIO_EDGE_MASK(ochip)); in gpio_irq_handler()
416 for (i = 0; i < ochip->chip.ngpio; i++) { in gpio_irq_handler()
419 irq = ochip->secondary_irq_base + i; in gpio_irq_handler()
429 polarity = readl(GPIO_IN_POL(ochip)); in gpio_irq_handler()
431 writel(polarity, GPIO_IN_POL(ochip)); in gpio_irq_handler()
443 struct orion_gpio_chip *ochip = gpiochip_get_data(chip); in orion_gpio_dbg_show() local
448 out = readl_relaxed(GPIO_OUT(ochip)); in orion_gpio_dbg_show()
449 io_conf = readl_relaxed(GPIO_IO_CONF(ochip)); in orion_gpio_dbg_show()
450 blink = readl_relaxed(GPIO_BLINK_EN(ochip)); in orion_gpio_dbg_show()
451 in_pol = readl_relaxed(GPIO_IN_POL(ochip)); in orion_gpio_dbg_show()
452 data_in = readl_relaxed(GPIO_DATA_IN(ochip)); in orion_gpio_dbg_show()
453 cause = readl_relaxed(GPIO_EDGE_CAUSE(ochip)); in orion_gpio_dbg_show()
454 edg_msk = readl_relaxed(GPIO_EDGE_MASK(ochip)); in orion_gpio_dbg_show()
455 lvl_msk = readl_relaxed(GPIO_LEVEL_MASK(ochip)); in orion_gpio_dbg_show()
525 struct orion_gpio_chip *ochip; in orion_gpio_init() local
537 ochip = orion_gpio_chips + orion_gpio_chip_count; in orion_gpio_init()
538 ochip->chip.label = kstrdup(gc_label, GFP_KERNEL); in orion_gpio_init()
539 ochip->chip.request = orion_gpio_request; in orion_gpio_init()
540 ochip->chip.direction_input = orion_gpio_direction_input; in orion_gpio_init()
541 ochip->chip.get = orion_gpio_get; in orion_gpio_init()
542 ochip->chip.direction_output = orion_gpio_direction_output; in orion_gpio_init()
543 ochip->chip.set = orion_gpio_set; in orion_gpio_init()
544 ochip->chip.to_irq = orion_gpio_to_irq; in orion_gpio_init()
545 ochip->chip.base = gpio_base; in orion_gpio_init()
546 ochip->chip.ngpio = ngpio; in orion_gpio_init()
547 ochip->chip.can_sleep = 0; in orion_gpio_init()
549 ochip->chip.of_node = np; in orion_gpio_init()
551 ochip->chip.dbg_show = orion_gpio_dbg_show; in orion_gpio_init()
553 spin_lock_init(&ochip->lock); in orion_gpio_init()
554 ochip->base = (void __iomem *)base; in orion_gpio_init()
555 ochip->valid_input = 0; in orion_gpio_init()
556 ochip->valid_output = 0; in orion_gpio_init()
557 ochip->mask_offset = mask_offset; in orion_gpio_init()
558 ochip->secondary_irq_base = secondary_irq_base; in orion_gpio_init()
560 gpiochip_add_data(&ochip->chip, ochip); in orion_gpio_init()
565 writel(0, GPIO_EDGE_CAUSE(ochip)); in orion_gpio_init()
566 writel(0, GPIO_EDGE_MASK(ochip)); in orion_gpio_init()
567 writel(0, GPIO_LEVEL_MASK(ochip)); in orion_gpio_init()
577 ochip); in orion_gpio_init()
583 ochip->base, handle_level_irq); in orion_gpio_init()
584 gc->private = ochip; in orion_gpio_init()
586 ct->regs.mask = ochip->mask_offset + GPIO_LEVEL_MASK_OFF; in orion_gpio_init()
591 ct->chip.name = ochip->chip.label; in orion_gpio_init()
594 ct->regs.mask = ochip->mask_offset + GPIO_EDGE_MASK_OFF; in orion_gpio_init()
602 ct->chip.name = ochip->chip.label; in orion_gpio_init()
608 ochip->domain = irq_domain_add_legacy(np, in orion_gpio_init()
609 ochip->chip.ngpio, in orion_gpio_init()
610 ochip->secondary_irq_base, in orion_gpio_init()
611 ochip->secondary_irq_base, in orion_gpio_init()
613 ochip); in orion_gpio_init()
614 if (!ochip->domain) in orion_gpio_init()
616 ochip->chip.label); in orion_gpio_init()