Lines Matching refs:offset

251 static const struct aspeed_gpio_bank *to_bank(unsigned int offset)  in to_bank()  argument
253 unsigned int bank = GPIO_BANK(offset); in to_bank()
265 struct aspeed_gpio *gpio, unsigned int offset) in find_bank_props() argument
270 if (props->bank == GPIO_BANK(offset)) in find_bank_props()
278 static inline bool have_gpio(struct aspeed_gpio *gpio, unsigned int offset) in have_gpio() argument
280 const struct aspeed_bank_props *props = find_bank_props(gpio, offset); in have_gpio()
281 const struct aspeed_gpio_bank *bank = to_bank(offset); in have_gpio()
282 unsigned int group = GPIO_OFFSET(offset) / 8; in have_gpio()
285 (!props || ((props->input | props->output) & GPIO_BIT(offset))); in have_gpio()
288 static inline bool have_input(struct aspeed_gpio *gpio, unsigned int offset) in have_input() argument
290 const struct aspeed_bank_props *props = find_bank_props(gpio, offset); in have_input()
292 return !props || (props->input & GPIO_BIT(offset)); in have_input()
298 static inline bool have_output(struct aspeed_gpio *gpio, unsigned int offset) in have_output() argument
300 const struct aspeed_bank_props *props = find_bank_props(gpio, offset); in have_output()
302 return !props || (props->output & GPIO_BIT(offset)); in have_output()
338 unsigned int offset) in aspeed_gpio_copro_request() argument
340 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_gpio_copro_request()
344 if (!gpio->cf_copro_bankmap[offset >> 3]) in aspeed_gpio_copro_request()
353 aspeed_gpio_change_cmd_source(gpio, bank, offset >> 3, GPIO_CMDSRC_ARM); in aspeed_gpio_copro_request()
356 gpio->dcache[GPIO_BANK(offset)] = ioread32(bank_reg(gpio, bank, reg_rdata)); in aspeed_gpio_copro_request()
362 unsigned int offset) in aspeed_gpio_copro_release() argument
364 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_gpio_copro_release()
368 if (!gpio->cf_copro_bankmap[offset >> 3]) in aspeed_gpio_copro_release()
374 aspeed_gpio_change_cmd_source(gpio, bank, offset >> 3, in aspeed_gpio_copro_release()
381 static int aspeed_gpio_get(struct gpio_chip *gc, unsigned int offset) in aspeed_gpio_get() argument
384 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_gpio_get()
386 return !!(ioread32(bank_reg(gpio, bank, reg_val)) & GPIO_BIT(offset)); in aspeed_gpio_get()
389 static void __aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset, in __aspeed_gpio_set() argument
393 const struct aspeed_gpio_bank *bank = to_bank(offset); in __aspeed_gpio_set()
398 reg = gpio->dcache[GPIO_BANK(offset)]; in __aspeed_gpio_set()
401 reg |= GPIO_BIT(offset); in __aspeed_gpio_set()
403 reg &= ~GPIO_BIT(offset); in __aspeed_gpio_set()
404 gpio->dcache[GPIO_BANK(offset)] = reg; in __aspeed_gpio_set()
409 static void aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset, in aspeed_gpio_set() argument
417 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_set()
419 __aspeed_gpio_set(gc, offset, val); in aspeed_gpio_set()
422 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_set()
426 static int aspeed_gpio_dir_in(struct gpio_chip *gc, unsigned int offset) in aspeed_gpio_dir_in() argument
429 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_gpio_dir_in()
435 if (!have_input(gpio, offset)) in aspeed_gpio_dir_in()
441 reg &= ~GPIO_BIT(offset); in aspeed_gpio_dir_in()
443 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_dir_in()
446 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_dir_in()
454 unsigned int offset, int val) in aspeed_gpio_dir_out() argument
457 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_gpio_dir_out()
463 if (!have_output(gpio, offset)) in aspeed_gpio_dir_out()
469 reg |= GPIO_BIT(offset); in aspeed_gpio_dir_out()
471 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_dir_out()
472 __aspeed_gpio_set(gc, offset, val); in aspeed_gpio_dir_out()
476 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_dir_out()
482 static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) in aspeed_gpio_get_direction() argument
485 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_gpio_get_direction()
489 if (!have_input(gpio, offset)) in aspeed_gpio_get_direction()
492 if (!have_output(gpio, offset)) in aspeed_gpio_get_direction()
497 val = ioread32(bank_reg(gpio, bank, reg_dir)) & GPIO_BIT(offset); in aspeed_gpio_get_direction()
508 u32 *bit, int *offset) in irqd_to_aspeed_gpio_data() argument
512 *offset = irqd_to_hwirq(d); in irqd_to_aspeed_gpio_data()
517 if (!have_irq(internal, *offset)) in irqd_to_aspeed_gpio_data()
521 *bank = to_bank(*offset); in irqd_to_aspeed_gpio_data()
522 *bit = GPIO_BIT(*offset); in irqd_to_aspeed_gpio_data()
533 int rc, offset; in aspeed_gpio_irq_ack() local
537 rc = irqd_to_aspeed_gpio_data(d, &gpio, &bank, &bit, &offset); in aspeed_gpio_irq_ack()
544 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_irq_ack()
549 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_irq_ack()
560 int rc, offset; in aspeed_gpio_irq_set_mask() local
563 rc = irqd_to_aspeed_gpio_data(d, &gpio, &bank, &bit, &offset); in aspeed_gpio_irq_set_mask()
570 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_irq_set_mask()
580 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_irq_set_mask()
605 int rc, offset; in aspeed_gpio_set_type() local
608 rc = irqd_to_aspeed_gpio_data(d, &gpio, &bank, &bit, &offset); in aspeed_gpio_set_type()
634 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_set_type()
652 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_set_type()
695 unsigned int offset; in aspeed_init_irq_valid_mask() local
699 for_each_clear_bit(offset, &input, 32) { in aspeed_init_irq_valid_mask()
700 unsigned int i = props->bank * 32 + offset; in aspeed_init_irq_valid_mask()
713 unsigned int offset, bool enable) in aspeed_gpio_reset_tolerance() argument
721 treg = bank_reg(gpio, to_bank(offset), reg_tolerance); in aspeed_gpio_reset_tolerance()
724 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_reset_tolerance()
729 val |= GPIO_BIT(offset); in aspeed_gpio_reset_tolerance()
731 val &= ~GPIO_BIT(offset); in aspeed_gpio_reset_tolerance()
736 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_reset_tolerance()
742 static int aspeed_gpio_request(struct gpio_chip *chip, unsigned int offset) in aspeed_gpio_request() argument
744 if (!have_gpio(gpiochip_get_data(chip), offset)) in aspeed_gpio_request()
747 return pinctrl_gpio_request(chip->base + offset); in aspeed_gpio_request()
750 static void aspeed_gpio_free(struct gpio_chip *chip, unsigned int offset) in aspeed_gpio_free() argument
752 pinctrl_gpio_free(chip->base + offset); in aspeed_gpio_free()
780 unsigned int offset, unsigned int timer) in register_allocated_timer() argument
782 if (WARN(gpio->offset_timer[offset] != 0, in register_allocated_timer()
784 offset, gpio->offset_timer[offset])) in register_allocated_timer()
791 gpio->offset_timer[offset] = timer; in register_allocated_timer()
799 unsigned int offset) in unregister_allocated_timer() argument
801 if (WARN(gpio->offset_timer[offset] == 0, in unregister_allocated_timer()
802 "No timer allocated to offset %d\n", offset)) in unregister_allocated_timer()
805 if (WARN(gpio->timer_users[gpio->offset_timer[offset]] == 0, in unregister_allocated_timer()
807 gpio->offset_timer[offset])) in unregister_allocated_timer()
810 gpio->timer_users[gpio->offset_timer[offset]]--; in unregister_allocated_timer()
811 gpio->offset_timer[offset] = 0; in unregister_allocated_timer()
818 unsigned int offset) in timer_allocation_registered() argument
820 return gpio->offset_timer[offset] > 0; in timer_allocation_registered()
824 static void configure_timer(struct aspeed_gpio *gpio, unsigned int offset, in configure_timer() argument
827 const struct aspeed_gpio_bank *bank = to_bank(offset); in configure_timer()
828 const u32 mask = GPIO_BIT(offset); in configure_timer()
837 iowrite32((val & ~mask) | GPIO_SET_DEBOUNCE1(timer, offset), addr); in configure_timer()
841 iowrite32((val & ~mask) | GPIO_SET_DEBOUNCE2(timer, offset), addr); in configure_timer()
844 static int enable_debounce(struct gpio_chip *chip, unsigned int offset, in enable_debounce() argument
865 if (timer_allocation_registered(gpio, offset)) { in enable_debounce()
866 rc = unregister_allocated_timer(gpio, offset); in enable_debounce()
905 configure_timer(gpio, offset, 0); in enable_debounce()
919 register_allocated_timer(gpio, offset, i); in enable_debounce()
920 configure_timer(gpio, offset, i); in enable_debounce()
928 static int disable_debounce(struct gpio_chip *chip, unsigned int offset) in disable_debounce() argument
936 rc = unregister_allocated_timer(gpio, offset); in disable_debounce()
938 configure_timer(gpio, offset, 0); in disable_debounce()
945 static int set_debounce(struct gpio_chip *chip, unsigned int offset, in set_debounce() argument
950 if (!have_debounce(gpio, offset)) in set_debounce()
954 return enable_debounce(chip, offset, usecs); in set_debounce()
956 return disable_debounce(chip, offset); in set_debounce()
959 static int aspeed_gpio_set_config(struct gpio_chip *chip, unsigned int offset, in aspeed_gpio_set_config() argument
966 return set_debounce(chip, offset, arg); in aspeed_gpio_set_config()
970 return pinctrl_gpio_set_config(offset, config); in aspeed_gpio_set_config()
976 return aspeed_gpio_reset_tolerance(chip, offset, arg); in aspeed_gpio_set_config()
1010 int rc = 0, bindex, offset = gpio_chip_hwgpio(desc); in aspeed_gpio_copro_grab_gpio() local
1011 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_gpio_copro_grab_gpio()
1018 if (offset < 0 || offset > gpio->chip.ngpio) in aspeed_gpio_copro_grab_gpio()
1020 bindex = offset >> 3; in aspeed_gpio_copro_grab_gpio()
1041 *bit = GPIO_OFFSET(offset); in aspeed_gpio_copro_grab_gpio()
1056 int rc = 0, bindex, offset = gpio_chip_hwgpio(desc); in aspeed_gpio_copro_release_gpio() local
1057 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_gpio_copro_release_gpio()
1063 if (offset < 0 || offset > gpio->chip.ngpio) in aspeed_gpio_copro_release_gpio()
1065 bindex = offset >> 3; in aspeed_gpio_copro_release_gpio()