Lines Matching refs:offset
224 void (*reg_bit_set)(struct aspeed_gpio *gpio, unsigned int offset,
226 bool (*reg_bit_get)(struct aspeed_gpio *gpio, unsigned int offset,
228 int (*reg_bank_get)(struct aspeed_gpio *gpio, unsigned int offset,
230 void (*privilege_ctrl)(struct aspeed_gpio *gpio, unsigned int offset, int owner);
232 bool (*copro_request)(struct aspeed_gpio *gpio, unsigned int offset);
233 void (*copro_release)(struct aspeed_gpio *gpio, unsigned int offset);
328 static const struct aspeed_gpio_bank *to_bank(unsigned int offset) in to_bank() argument
330 unsigned int bank = GPIO_BANK(offset); in to_bank()
342 struct aspeed_gpio *gpio, unsigned int offset) in find_bank_props() argument
347 if (props->bank == GPIO_BANK(offset)) in find_bank_props()
355 static inline bool have_gpio(struct aspeed_gpio *gpio, unsigned int offset) in have_gpio() argument
357 const struct aspeed_bank_props *props = find_bank_props(gpio, offset); in have_gpio()
359 if (offset >= gpio->chip.ngpio) in have_gpio()
362 return (!props || ((props->input | props->output) & GPIO_BIT(offset))); in have_gpio()
365 static inline bool have_input(struct aspeed_gpio *gpio, unsigned int offset) in have_input() argument
367 const struct aspeed_bank_props *props = find_bank_props(gpio, offset); in have_input()
369 return !props || (props->input & GPIO_BIT(offset)); in have_input()
375 static inline bool have_output(struct aspeed_gpio *gpio, unsigned int offset) in have_output() argument
377 const struct aspeed_bank_props *props = find_bank_props(gpio, offset); in have_output()
379 return !props || (props->output & GPIO_BIT(offset)); in have_output()
382 static void aspeed_gpio_change_cmd_source(struct aspeed_gpio *gpio, unsigned int offset, int cmdsrc) in aspeed_gpio_change_cmd_source() argument
385 gpio->config->llops->privilege_ctrl(gpio, offset, cmdsrc); in aspeed_gpio_change_cmd_source()
389 unsigned int offset) in aspeed_gpio_copro_request() argument
392 return gpio->config->llops->copro_request(gpio, offset); in aspeed_gpio_copro_request()
398 unsigned int offset) in aspeed_gpio_copro_release() argument
401 gpio->config->llops->copro_release(gpio, offset); in aspeed_gpio_copro_release()
410 static int aspeed_gpio_get(struct gpio_chip *gc, unsigned int offset) in aspeed_gpio_get() argument
414 return gpio->config->llops->reg_bit_get(gpio, offset, reg_val); in aspeed_gpio_get()
417 static void __aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset, in __aspeed_gpio_set() argument
422 gpio->config->llops->reg_bit_set(gpio, offset, reg_val, val); in __aspeed_gpio_set()
424 gpio->config->llops->reg_bit_get(gpio, offset, reg_val); in __aspeed_gpio_set()
427 static int aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset, int val) in aspeed_gpio_set() argument
434 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_set()
436 __aspeed_gpio_set(gc, offset, val); in aspeed_gpio_set()
439 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_set()
444 static int aspeed_gpio_dir_in(struct gpio_chip *gc, unsigned int offset) in aspeed_gpio_dir_in() argument
449 if (!have_input(gpio, offset)) in aspeed_gpio_dir_in()
454 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_dir_in()
455 gpio->config->llops->reg_bit_set(gpio, offset, reg_dir, 0); in aspeed_gpio_dir_in()
457 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_dir_in()
463 unsigned int offset, int val) in aspeed_gpio_dir_out() argument
468 if (!have_output(gpio, offset)) in aspeed_gpio_dir_out()
473 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_dir_out()
474 __aspeed_gpio_set(gc, offset, val); in aspeed_gpio_dir_out()
475 gpio->config->llops->reg_bit_set(gpio, offset, reg_dir, 1); in aspeed_gpio_dir_out()
478 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_dir_out()
483 static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) in aspeed_gpio_get_direction() argument
488 if (!have_input(gpio, offset)) in aspeed_gpio_get_direction()
491 if (!have_output(gpio, offset)) in aspeed_gpio_get_direction()
496 val = gpio->config->llops->reg_bit_get(gpio, offset, reg_dir); in aspeed_gpio_get_direction()
503 int *offset) in irqd_to_aspeed_gpio_data() argument
507 *offset = irqd_to_hwirq(d); in irqd_to_aspeed_gpio_data()
512 if (!have_irq(internal, *offset)) in irqd_to_aspeed_gpio_data()
523 int rc, offset; in aspeed_gpio_irq_ack() local
526 rc = irqd_to_aspeed_gpio_data(d, &gpio, &offset); in aspeed_gpio_irq_ack()
532 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_irq_ack()
534 gpio->config->llops->reg_bit_set(gpio, offset, reg_irq_status, 1); in aspeed_gpio_irq_ack()
537 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_irq_ack()
543 int rc, offset; in aspeed_gpio_irq_set_mask() local
546 rc = irqd_to_aspeed_gpio_data(d, &gpio, &offset); in aspeed_gpio_irq_set_mask()
556 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_irq_set_mask()
558 gpio->config->llops->reg_bit_set(gpio, offset, reg_irq_enable, set); in aspeed_gpio_irq_set_mask()
561 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_irq_set_mask()
585 int rc, offset; in aspeed_gpio_set_type() local
588 rc = irqd_to_aspeed_gpio_data(d, &gpio, &offset); in aspeed_gpio_set_type()
614 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_set_type()
616 gpio->config->llops->reg_bit_set(gpio, offset, reg_irq_type0, in aspeed_gpio_set_type()
618 gpio->config->llops->reg_bit_set(gpio, offset, reg_irq_type1, in aspeed_gpio_set_type()
620 gpio->config->llops->reg_bit_set(gpio, offset, reg_irq_type2, in aspeed_gpio_set_type()
624 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_set_type()
661 unsigned int offset; in aspeed_init_irq_valid_mask() local
665 for_each_clear_bit(offset, &input, 32) { in aspeed_init_irq_valid_mask()
666 unsigned int i = props->bank * 32 + offset; in aspeed_init_irq_valid_mask()
679 unsigned int offset, bool enable) in aspeed_gpio_reset_tolerance() argument
686 copro = aspeed_gpio_copro_request(gpio, offset); in aspeed_gpio_reset_tolerance()
688 gpio->config->llops->reg_bit_set(gpio, offset, reg_tolerance, enable); in aspeed_gpio_reset_tolerance()
691 aspeed_gpio_copro_release(gpio, offset); in aspeed_gpio_reset_tolerance()
696 static int aspeed_gpio_request(struct gpio_chip *chip, unsigned int offset) in aspeed_gpio_request() argument
698 if (!have_gpio(gpiochip_get_data(chip), offset)) in aspeed_gpio_request()
701 return pinctrl_gpio_request(chip, offset); in aspeed_gpio_request()
704 static void aspeed_gpio_free(struct gpio_chip *chip, unsigned int offset) in aspeed_gpio_free() argument
706 pinctrl_gpio_free(chip, offset); in aspeed_gpio_free()
734 unsigned int offset, unsigned int timer) in register_allocated_timer() argument
736 if (WARN(gpio->offset_timer[offset] != 0, in register_allocated_timer()
738 offset, gpio->offset_timer[offset])) in register_allocated_timer()
745 gpio->offset_timer[offset] = timer; in register_allocated_timer()
753 unsigned int offset) in unregister_allocated_timer() argument
755 if (WARN(gpio->offset_timer[offset] == 0, in unregister_allocated_timer()
756 "No timer allocated to offset %d\n", offset)) in unregister_allocated_timer()
759 if (WARN(gpio->timer_users[gpio->offset_timer[offset]] == 0, in unregister_allocated_timer()
761 gpio->offset_timer[offset])) in unregister_allocated_timer()
764 gpio->timer_users[gpio->offset_timer[offset]]--; in unregister_allocated_timer()
765 gpio->offset_timer[offset] = 0; in unregister_allocated_timer()
772 unsigned int offset) in timer_allocation_registered() argument
774 return gpio->offset_timer[offset] > 0; in timer_allocation_registered()
778 static void configure_timer(struct aspeed_gpio *gpio, unsigned int offset, in configure_timer() argument
784 gpio->config->llops->reg_bit_set(gpio, offset, reg_debounce_sel1, !!(timer & BIT(1))); in configure_timer()
785 gpio->config->llops->reg_bit_set(gpio, offset, reg_debounce_sel2, !!(timer & BIT(0))); in configure_timer()
788 static int enable_debounce(struct gpio_chip *chip, unsigned int offset, in enable_debounce() argument
808 if (timer_allocation_registered(gpio, offset)) { in enable_debounce()
809 rc = unregister_allocated_timer(gpio, offset); in enable_debounce()
848 configure_timer(gpio, offset, 0); in enable_debounce()
860 register_allocated_timer(gpio, offset, i); in enable_debounce()
861 configure_timer(gpio, offset, i); in enable_debounce()
866 static int disable_debounce(struct gpio_chip *chip, unsigned int offset) in disable_debounce() argument
873 rc = unregister_allocated_timer(gpio, offset); in disable_debounce()
875 configure_timer(gpio, offset, 0); in disable_debounce()
880 static int set_debounce(struct gpio_chip *chip, unsigned int offset, in set_debounce() argument
885 if (!have_debounce(gpio, offset)) in set_debounce()
889 return enable_debounce(chip, offset, usecs); in set_debounce()
891 return disable_debounce(chip, offset); in set_debounce()
894 static int aspeed_gpio_set_config(struct gpio_chip *chip, unsigned int offset, in aspeed_gpio_set_config() argument
901 return set_debounce(chip, offset, arg); in aspeed_gpio_set_config()
905 return pinctrl_gpio_set_config(chip, offset, config); in aspeed_gpio_set_config()
911 return aspeed_gpio_reset_tolerance(chip, offset, arg); in aspeed_gpio_set_config()
945 int rc = 0, bindex, offset = gpio_chip_hwgpio(desc); in aspeed_gpio_copro_grab_gpio() local
946 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_gpio_copro_grab_gpio()
955 if (offset < 0 || offset > gpio->chip.ngpio) in aspeed_gpio_copro_grab_gpio()
957 bindex = offset >> 3; in aspeed_gpio_copro_grab_gpio()
969 aspeed_gpio_change_cmd_source(gpio, offset, in aspeed_gpio_copro_grab_gpio()
977 *bit = GPIO_OFFSET(offset); in aspeed_gpio_copro_grab_gpio()
990 int rc = 0, bindex, offset = gpio_chip_hwgpio(desc); in aspeed_gpio_copro_release_gpio() local
998 if (offset < 0 || offset > gpio->chip.ngpio) in aspeed_gpio_copro_release_gpio()
1000 bindex = offset >> 3; in aspeed_gpio_copro_release_gpio()
1012 aspeed_gpio_change_cmd_source(gpio, offset, in aspeed_gpio_copro_release_gpio()
1022 int rc, offset; in aspeed_gpio_irq_print_chip() local
1024 rc = irqd_to_aspeed_gpio_data(d, &gpio, &offset); in aspeed_gpio_irq_print_chip()
1041 static void aspeed_g4_reg_bit_set(struct aspeed_gpio *gpio, unsigned int offset, in aspeed_g4_reg_bit_set() argument
1044 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_g4_reg_bit_set()
1049 temp = gpio->dcache[GPIO_BANK(offset)]; in aspeed_g4_reg_bit_set()
1054 temp |= GPIO_BIT(offset); in aspeed_g4_reg_bit_set()
1056 temp &= ~GPIO_BIT(offset); in aspeed_g4_reg_bit_set()
1059 gpio->dcache[GPIO_BANK(offset)] = temp; in aspeed_g4_reg_bit_set()
1063 static bool aspeed_g4_reg_bit_get(struct aspeed_gpio *gpio, unsigned int offset, in aspeed_g4_reg_bit_get() argument
1066 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_g4_reg_bit_get()
1069 return !!(ioread32(addr) & GPIO_BIT(offset)); in aspeed_g4_reg_bit_get()
1072 static int aspeed_g4_reg_bank_get(struct aspeed_gpio *gpio, unsigned int offset, in aspeed_g4_reg_bank_get() argument
1075 const struct aspeed_gpio_bank *bank = to_bank(offset); in aspeed_g4_reg_bank_get()
1084 static void aspeed_g4_privilege_ctrl(struct aspeed_gpio *gpio, unsigned int offset, int cmdsrc) in aspeed_g4_privilege_ctrl() argument
1091 aspeed_g4_reg_bit_set(gpio, offset & ~(0x7), reg_cmdsrc1, !!(cmdsrc & BIT(1))); in aspeed_g4_privilege_ctrl()
1093 aspeed_g4_reg_bit_set(gpio, offset & ~(0x7), reg_cmdsrc0, !!(cmdsrc & BIT(0))); in aspeed_g4_privilege_ctrl()
1109 static bool aspeed_g4_copro_request(struct aspeed_gpio *gpio, unsigned int offset) in aspeed_g4_copro_request() argument
1113 if (!gpio->cf_copro_bankmap[offset >> 3]) in aspeed_g4_copro_request()
1122 aspeed_g4_privilege_ctrl(gpio, offset, GPIO_CMDSRC_ARM); in aspeed_g4_copro_request()
1125 gpio->dcache[GPIO_BANK(offset)] = aspeed_g4_reg_bank_get(gpio, offset, reg_rdata); in aspeed_g4_copro_request()
1130 static void aspeed_g4_copro_release(struct aspeed_gpio *gpio, unsigned int offset) in aspeed_g4_copro_release() argument
1134 if (!gpio->cf_copro_bankmap[offset >> 3]) in aspeed_g4_copro_release()
1140 aspeed_g4_privilege_ctrl(gpio, offset, GPIO_CMDSRC_COLDFIRE); in aspeed_g4_copro_release()
1156 static void aspeed_g7_reg_bit_set(struct aspeed_gpio *gpio, unsigned int offset, in aspeed_g7_reg_bit_set() argument
1160 void __iomem *addr = gpio->base + GPIO_G7_CTRL_REG_OFFSET(offset); in aspeed_g7_reg_bit_set()
1169 static bool aspeed_g7_reg_bit_get(struct aspeed_gpio *gpio, unsigned int offset, in aspeed_g7_reg_bit_get() argument
1175 addr = gpio->base + GPIO_G7_CTRL_REG_OFFSET(offset); in aspeed_g7_reg_bit_get()
1185 static int aspeed_g7_reg_bank_get(struct aspeed_gpio *gpio, unsigned int offset, in aspeed_g7_reg_bank_get() argument
1191 addr = gpio->base + GPIO_G7_IRQ_STS_OFFSET(offset >> 5); in aspeed_g7_reg_bank_get()