Lines Matching +full:edge +full:- +full:offset
1 // SPDX-License-Identifier: GPL-2.0-only
7 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
15 * non-SMP platforms (Orion, Dove, Kirkwood, Armada 370) and the SMP
19 * - the basic variant, called "orion-gpio", with the simplest
21 * non-SMP Discovery systems
22 * - the mv78200 variant for MV78200 Discovery systems. This variant
23 * turns the edge mask and level mask registers into CPU0 edge
24 * mask/level mask registers, and adds CPU1 edge mask/level mask
26 * - the armadaxp variant for Armada XP systems. This variant keeps
27 * the normal cause/edge mask/level mask registers when the global
28 * interrupts are used, but adds per-CPU cause/edge mask/level mask
29 * registers n a separate memory area for the per-CPU GPIO
77 /* The MV78200 has per-CPU registers for edge mask and level mask */
82 * The Armada XP has per-CPU registers for interrupt cause, interrupt
98 u32 offset; member
114 u32 offset; member
139 struct regmap **map, unsigned int *offset) in mvebu_gpioreg_edge_cause() argument
143 switch (mvchip->soc_variant) { in mvebu_gpioreg_edge_cause()
147 *map = mvchip->regs; in mvebu_gpioreg_edge_cause()
148 *offset = GPIO_EDGE_CAUSE_OFF + mvchip->offset; in mvebu_gpioreg_edge_cause()
152 *map = mvchip->percpu_regs; in mvebu_gpioreg_edge_cause()
153 *offset = GPIO_EDGE_CAUSE_ARMADAXP_OFF(cpu); in mvebu_gpioreg_edge_cause()
164 unsigned int offset; in mvebu_gpio_read_edge_cause() local
167 mvebu_gpioreg_edge_cause(mvchip, &map, &offset); in mvebu_gpio_read_edge_cause()
168 regmap_read(map, offset, &val); in mvebu_gpio_read_edge_cause()
177 unsigned int offset; in mvebu_gpio_write_edge_cause() local
179 mvebu_gpioreg_edge_cause(mvchip, &map, &offset); in mvebu_gpio_write_edge_cause()
180 regmap_write(map, offset, val); in mvebu_gpio_write_edge_cause()
185 struct regmap **map, unsigned int *offset) in mvebu_gpioreg_edge_mask() argument
189 switch (mvchip->soc_variant) { in mvebu_gpioreg_edge_mask()
192 *map = mvchip->regs; in mvebu_gpioreg_edge_mask()
193 *offset = GPIO_EDGE_MASK_OFF + mvchip->offset; in mvebu_gpioreg_edge_mask()
197 *map = mvchip->regs; in mvebu_gpioreg_edge_mask()
198 *offset = GPIO_EDGE_MASK_MV78200_OFF(cpu); in mvebu_gpioreg_edge_mask()
202 *map = mvchip->percpu_regs; in mvebu_gpioreg_edge_mask()
203 *offset = GPIO_EDGE_MASK_ARMADAXP_OFF(cpu); in mvebu_gpioreg_edge_mask()
214 unsigned int offset; in mvebu_gpio_read_edge_mask() local
217 mvebu_gpioreg_edge_mask(mvchip, &map, &offset); in mvebu_gpio_read_edge_mask()
218 regmap_read(map, offset, &val); in mvebu_gpio_read_edge_mask()
227 unsigned int offset; in mvebu_gpio_write_edge_mask() local
229 mvebu_gpioreg_edge_mask(mvchip, &map, &offset); in mvebu_gpio_write_edge_mask()
230 regmap_write(map, offset, val); in mvebu_gpio_write_edge_mask()
235 struct regmap **map, unsigned int *offset) in mvebu_gpioreg_level_mask() argument
239 switch (mvchip->soc_variant) { in mvebu_gpioreg_level_mask()
242 *map = mvchip->regs; in mvebu_gpioreg_level_mask()
243 *offset = GPIO_LEVEL_MASK_OFF + mvchip->offset; in mvebu_gpioreg_level_mask()
247 *map = mvchip->regs; in mvebu_gpioreg_level_mask()
248 *offset = GPIO_LEVEL_MASK_MV78200_OFF(cpu); in mvebu_gpioreg_level_mask()
252 *map = mvchip->percpu_regs; in mvebu_gpioreg_level_mask()
253 *offset = GPIO_LEVEL_MASK_ARMADAXP_OFF(cpu); in mvebu_gpioreg_level_mask()
264 unsigned int offset; in mvebu_gpio_read_level_mask() local
267 mvebu_gpioreg_level_mask(mvchip, &map, &offset); in mvebu_gpio_read_level_mask()
268 regmap_read(map, offset, &val); in mvebu_gpio_read_level_mask()
277 unsigned int offset; in mvebu_gpio_write_level_mask() local
279 mvebu_gpioreg_level_mask(mvchip, &map, &offset); in mvebu_gpio_write_level_mask()
280 regmap_write(map, offset, val); in mvebu_gpio_write_level_mask()
289 return mvpwm->offset + PWM_BLINK_ON_DURATION_OFF; in mvebu_pwmreg_blink_on_duration()
294 return mvpwm->offset + PWM_BLINK_OFF_DURATION_OFF; in mvebu_pwmreg_blink_off_duration()
304 regmap_update_bits(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, in mvebu_gpio_set()
313 regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u); in mvebu_gpio_get()
318 regmap_read(mvchip->regs, GPIO_DATA_IN_OFF + mvchip->offset, in mvebu_gpio_get()
320 regmap_read(mvchip->regs, GPIO_IN_POL_OFF + mvchip->offset, in mvebu_gpio_get()
324 regmap_read(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, &u); in mvebu_gpio_get()
335 regmap_update_bits(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, in mvebu_gpio_blink()
348 ret = pinctrl_gpio_direction_input(chip->base + pin); in mvebu_gpio_direction_input()
352 regmap_update_bits(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, in mvebu_gpio_direction_input()
368 ret = pinctrl_gpio_direction_output(chip->base + pin); in mvebu_gpio_direction_output()
375 regmap_update_bits(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, in mvebu_gpio_direction_output()
386 regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u); in mvebu_gpio_get_direction()
398 return irq_create_mapping(mvchip->domain, pin); in mvebu_gpio_to_irq()
407 struct mvebu_gpio_chip *mvchip = gc->private; in mvebu_gpio_irq_ack()
408 u32 mask = d->mask; in mvebu_gpio_irq_ack()
418 struct mvebu_gpio_chip *mvchip = gc->private; in mvebu_gpio_edge_irq_mask()
420 u32 mask = d->mask; in mvebu_gpio_edge_irq_mask()
423 ct->mask_cache_priv &= ~mask; in mvebu_gpio_edge_irq_mask()
424 mvebu_gpio_write_edge_mask(mvchip, ct->mask_cache_priv); in mvebu_gpio_edge_irq_mask()
431 struct mvebu_gpio_chip *mvchip = gc->private; in mvebu_gpio_edge_irq_unmask()
433 u32 mask = d->mask; in mvebu_gpio_edge_irq_unmask()
437 ct->mask_cache_priv |= mask; in mvebu_gpio_edge_irq_unmask()
438 mvebu_gpio_write_edge_mask(mvchip, ct->mask_cache_priv); in mvebu_gpio_edge_irq_unmask()
445 struct mvebu_gpio_chip *mvchip = gc->private; in mvebu_gpio_level_irq_mask()
447 u32 mask = d->mask; in mvebu_gpio_level_irq_mask()
450 ct->mask_cache_priv &= ~mask; in mvebu_gpio_level_irq_mask()
451 mvebu_gpio_write_level_mask(mvchip, ct->mask_cache_priv); in mvebu_gpio_level_irq_mask()
458 struct mvebu_gpio_chip *mvchip = gc->private; in mvebu_gpio_level_irq_unmask()
460 u32 mask = d->mask; in mvebu_gpio_level_irq_unmask()
463 ct->mask_cache_priv |= mask; in mvebu_gpio_level_irq_unmask()
464 mvebu_gpio_write_level_mask(mvchip, ct->mask_cache_priv); in mvebu_gpio_level_irq_unmask()
476 * Edge IRQ handlers: Change in DATA_IN are latched in EDGE_CAUSE.
478 * Both-edge handlers: Similar to regular Edge handlers, but also swaps
486 * EDGE cause mask
487 * data-in /--------| |-----| |----\
488 * -----| |----- ---- to main cause reg
489 * X \----------------| |----/
498 struct mvebu_gpio_chip *mvchip = gc->private; in mvebu_gpio_irq_set_type()
502 pin = d->hwirq; in mvebu_gpio_irq_set_type()
504 regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u); in mvebu_gpio_irq_set_type()
506 return -EINVAL; in mvebu_gpio_irq_set_type()
510 return -EINVAL; in mvebu_gpio_irq_set_type()
513 if (!(ct->type & type)) in mvebu_gpio_irq_set_type()
515 return -EINVAL; in mvebu_gpio_irq_set_type()
523 regmap_update_bits(mvchip->regs, in mvebu_gpio_irq_set_type()
524 GPIO_IN_POL_OFF + mvchip->offset, in mvebu_gpio_irq_set_type()
529 regmap_update_bits(mvchip->regs, in mvebu_gpio_irq_set_type()
530 GPIO_IN_POL_OFF + mvchip->offset, in mvebu_gpio_irq_set_type()
536 regmap_read(mvchip->regs, in mvebu_gpio_irq_set_type()
537 GPIO_IN_POL_OFF + mvchip->offset, &in_pol); in mvebu_gpio_irq_set_type()
538 regmap_read(mvchip->regs, in mvebu_gpio_irq_set_type()
539 GPIO_DATA_IN_OFF + mvchip->offset, &data_in); in mvebu_gpio_irq_set_type()
549 regmap_update_bits(mvchip->regs, in mvebu_gpio_irq_set_type()
550 GPIO_IN_POL_OFF + mvchip->offset, in mvebu_gpio_irq_set_type()
570 regmap_read(mvchip->regs, GPIO_DATA_IN_OFF + mvchip->offset, &data_in); in mvebu_gpio_irq_handler()
577 for (i = 0; i < mvchip->chip.ngpio; i++) { in mvebu_gpio_irq_handler()
580 irq = irq_find_mapping(mvchip->domain, i); in mvebu_gpio_irq_handler()
590 regmap_read(mvchip->regs, in mvebu_gpio_irq_handler()
591 GPIO_IN_POL_OFF + mvchip->offset, in mvebu_gpio_irq_handler()
594 regmap_write(mvchip->regs, in mvebu_gpio_irq_handler()
595 GPIO_IN_POL_OFF + mvchip->offset, in mvebu_gpio_irq_handler()
623 struct mvebu_gpio_chip *mvchip = mvpwm->mvchip; in mvebu_pwm_request()
628 spin_lock_irqsave(&mvpwm->lock, flags); in mvebu_pwm_request()
630 if (mvpwm->gpiod) { in mvebu_pwm_request()
631 ret = -EBUSY; in mvebu_pwm_request()
633 desc = gpiochip_request_own_desc(&mvchip->chip, in mvebu_pwm_request()
634 pwm->hwpwm, "mvebu-pwm", in mvebu_pwm_request()
642 mvpwm->gpiod = desc; in mvebu_pwm_request()
645 spin_unlock_irqrestore(&mvpwm->lock, flags); in mvebu_pwm_request()
654 spin_lock_irqsave(&mvpwm->lock, flags); in mvebu_pwm_free()
655 gpiochip_free_own_desc(mvpwm->gpiod); in mvebu_pwm_free()
656 mvpwm->gpiod = NULL; in mvebu_pwm_free()
657 spin_unlock_irqrestore(&mvpwm->lock, flags); in mvebu_pwm_free()
665 struct mvebu_gpio_chip *mvchip = mvpwm->mvchip; in mvebu_pwm_get_state()
670 spin_lock_irqsave(&mvpwm->lock, flags); in mvebu_pwm_get_state()
672 regmap_read(mvpwm->regs, mvebu_pwmreg_blink_on_duration(mvpwm), &u); in mvebu_pwm_get_state()
678 state->duty_cycle = DIV_ROUND_UP_ULL(val * NSEC_PER_SEC, in mvebu_pwm_get_state()
679 mvpwm->clk_rate); in mvebu_pwm_get_state()
681 regmap_read(mvpwm->regs, mvebu_pwmreg_blink_off_duration(mvpwm), &u); in mvebu_pwm_get_state()
687 state->period = DIV_ROUND_UP_ULL(val * NSEC_PER_SEC, mvpwm->clk_rate); in mvebu_pwm_get_state()
689 regmap_read(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, &u); in mvebu_pwm_get_state()
691 state->enabled = true; in mvebu_pwm_get_state()
693 state->enabled = false; in mvebu_pwm_get_state()
695 spin_unlock_irqrestore(&mvpwm->lock, flags); in mvebu_pwm_get_state()
702 struct mvebu_gpio_chip *mvchip = mvpwm->mvchip; in mvebu_pwm_apply()
707 if (state->polarity != PWM_POLARITY_NORMAL) in mvebu_pwm_apply()
708 return -EINVAL; in mvebu_pwm_apply()
710 val = (unsigned long long) mvpwm->clk_rate * state->duty_cycle; in mvebu_pwm_apply()
713 return -EINVAL; in mvebu_pwm_apply()
725 val = (unsigned long long) mvpwm->clk_rate * state->period; in mvebu_pwm_apply()
727 val -= on; in mvebu_pwm_apply()
729 return -EINVAL; in mvebu_pwm_apply()
737 spin_lock_irqsave(&mvpwm->lock, flags); in mvebu_pwm_apply()
739 regmap_write(mvpwm->regs, mvebu_pwmreg_blink_on_duration(mvpwm), on); in mvebu_pwm_apply()
740 regmap_write(mvpwm->regs, mvebu_pwmreg_blink_off_duration(mvpwm), off); in mvebu_pwm_apply()
741 if (state->enabled) in mvebu_pwm_apply()
742 mvebu_gpio_blink(&mvchip->chip, pwm->hwpwm, 1); in mvebu_pwm_apply()
744 mvebu_gpio_blink(&mvchip->chip, pwm->hwpwm, 0); in mvebu_pwm_apply()
746 spin_unlock_irqrestore(&mvpwm->lock, flags); in mvebu_pwm_apply()
761 struct mvebu_pwm *mvpwm = mvchip->mvpwm; in mvebu_pwm_suspend()
763 regmap_read(mvchip->regs, GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, in mvebu_pwm_suspend()
764 &mvpwm->blink_select); in mvebu_pwm_suspend()
765 regmap_read(mvpwm->regs, mvebu_pwmreg_blink_on_duration(mvpwm), in mvebu_pwm_suspend()
766 &mvpwm->blink_on_duration); in mvebu_pwm_suspend()
767 regmap_read(mvpwm->regs, mvebu_pwmreg_blink_off_duration(mvpwm), in mvebu_pwm_suspend()
768 &mvpwm->blink_off_duration); in mvebu_pwm_suspend()
773 struct mvebu_pwm *mvpwm = mvchip->mvpwm; in mvebu_pwm_resume()
775 regmap_write(mvchip->regs, GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, in mvebu_pwm_resume()
776 mvpwm->blink_select); in mvebu_pwm_resume()
777 regmap_write(mvpwm->regs, mvebu_pwmreg_blink_on_duration(mvpwm), in mvebu_pwm_resume()
778 mvpwm->blink_on_duration); in mvebu_pwm_resume()
779 regmap_write(mvpwm->regs, mvebu_pwmreg_blink_off_duration(mvpwm), in mvebu_pwm_resume()
780 mvpwm->blink_off_duration); in mvebu_pwm_resume()
787 struct device *dev = &pdev->dev; in mvebu_pwm_probe()
790 u32 offset; in mvebu_pwm_probe() local
793 if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) { in mvebu_pwm_probe()
794 int ret = of_property_read_u32(dev->of_node, in mvebu_pwm_probe()
795 "marvell,pwm-offset", &offset); in mvebu_pwm_probe()
807 offset = 0; in mvebu_pwm_probe()
810 if (IS_ERR(mvchip->clk)) in mvebu_pwm_probe()
811 return PTR_ERR(mvchip->clk); in mvebu_pwm_probe()
815 return -ENOMEM; in mvebu_pwm_probe()
816 mvchip->mvpwm = mvpwm; in mvebu_pwm_probe()
817 mvpwm->mvchip = mvchip; in mvebu_pwm_probe()
818 mvpwm->offset = offset; in mvebu_pwm_probe()
820 if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) { in mvebu_pwm_probe()
821 mvpwm->regs = mvchip->regs; in mvebu_pwm_probe()
823 switch (mvchip->offset) { in mvebu_pwm_probe()
832 mvpwm->offset += PWM_BLINK_COUNTER_B_OFF; in mvebu_pwm_probe()
835 return -EINVAL; in mvebu_pwm_probe()
842 mvpwm->regs = devm_regmap_init_mmio(&pdev->dev, base, in mvebu_pwm_probe()
844 if (IS_ERR(mvpwm->regs)) in mvebu_pwm_probe()
845 return PTR_ERR(mvpwm->regs); in mvebu_pwm_probe()
856 return -EINVAL; in mvebu_pwm_probe()
859 regmap_write(mvchip->regs, in mvebu_pwm_probe()
860 GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, set); in mvebu_pwm_probe()
862 mvpwm->clk_rate = clk_get_rate(mvchip->clk); in mvebu_pwm_probe()
863 if (!mvpwm->clk_rate) { in mvebu_pwm_probe()
865 return -EINVAL; in mvebu_pwm_probe()
868 mvpwm->chip.dev = dev; in mvebu_pwm_probe()
869 mvpwm->chip.ops = &mvebu_pwm_ops; in mvebu_pwm_probe()
870 mvpwm->chip.npwm = mvchip->chip.ngpio; in mvebu_pwm_probe()
872 spin_lock_init(&mvpwm->lock); in mvebu_pwm_probe()
874 return pwmchip_add(&mvpwm->chip); in mvebu_pwm_probe()
887 regmap_read(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, &out); in mvebu_gpio_dbg_show()
888 regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &io_conf); in mvebu_gpio_dbg_show()
889 regmap_read(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, &blink); in mvebu_gpio_dbg_show()
890 regmap_read(mvchip->regs, GPIO_IN_POL_OFF + mvchip->offset, &in_pol); in mvebu_gpio_dbg_show()
891 regmap_read(mvchip->regs, GPIO_DATA_IN_OFF + mvchip->offset, &data_in); in mvebu_gpio_dbg_show()
903 seq_printf(s, " gpio-%-3d (%-20.20s)", chip->base + i, label); in mvebu_gpio_dbg_show()
912 seq_printf(s, " in %s (act %s) - IRQ", in mvebu_gpio_dbg_show()
920 seq_puts(s, " edge "); in mvebu_gpio_dbg_show()
932 .compatible = "marvell,orion-gpio",
936 .compatible = "marvell,mv78200-gpio",
940 .compatible = "marvell,armadaxp-gpio",
944 .compatible = "marvell,armada-370-gpio",
948 .compatible = "marvell,armada-8k-gpio",
961 regmap_read(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, in mvebu_gpio_suspend()
962 &mvchip->out_reg); in mvebu_gpio_suspend()
963 regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, in mvebu_gpio_suspend()
964 &mvchip->io_conf_reg); in mvebu_gpio_suspend()
965 regmap_read(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, in mvebu_gpio_suspend()
966 &mvchip->blink_en_reg); in mvebu_gpio_suspend()
967 regmap_read(mvchip->regs, GPIO_IN_POL_OFF + mvchip->offset, in mvebu_gpio_suspend()
968 &mvchip->in_pol_reg); in mvebu_gpio_suspend()
970 switch (mvchip->soc_variant) { in mvebu_gpio_suspend()
973 regmap_read(mvchip->regs, GPIO_EDGE_MASK_OFF + mvchip->offset, in mvebu_gpio_suspend()
974 &mvchip->edge_mask_regs[0]); in mvebu_gpio_suspend()
975 regmap_read(mvchip->regs, GPIO_LEVEL_MASK_OFF + mvchip->offset, in mvebu_gpio_suspend()
976 &mvchip->level_mask_regs[0]); in mvebu_gpio_suspend()
980 regmap_read(mvchip->regs, in mvebu_gpio_suspend()
982 &mvchip->edge_mask_regs[i]); in mvebu_gpio_suspend()
983 regmap_read(mvchip->regs, in mvebu_gpio_suspend()
985 &mvchip->level_mask_regs[i]); in mvebu_gpio_suspend()
990 regmap_read(mvchip->regs, in mvebu_gpio_suspend()
992 &mvchip->edge_mask_regs[i]); in mvebu_gpio_suspend()
993 regmap_read(mvchip->regs, in mvebu_gpio_suspend()
995 &mvchip->level_mask_regs[i]); in mvebu_gpio_suspend()
1013 regmap_write(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, in mvebu_gpio_resume()
1014 mvchip->out_reg); in mvebu_gpio_resume()
1015 regmap_write(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, in mvebu_gpio_resume()
1016 mvchip->io_conf_reg); in mvebu_gpio_resume()
1017 regmap_write(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, in mvebu_gpio_resume()
1018 mvchip->blink_en_reg); in mvebu_gpio_resume()
1019 regmap_write(mvchip->regs, GPIO_IN_POL_OFF + mvchip->offset, in mvebu_gpio_resume()
1020 mvchip->in_pol_reg); in mvebu_gpio_resume()
1022 switch (mvchip->soc_variant) { in mvebu_gpio_resume()
1025 regmap_write(mvchip->regs, GPIO_EDGE_MASK_OFF + mvchip->offset, in mvebu_gpio_resume()
1026 mvchip->edge_mask_regs[0]); in mvebu_gpio_resume()
1027 regmap_write(mvchip->regs, GPIO_LEVEL_MASK_OFF + mvchip->offset, in mvebu_gpio_resume()
1028 mvchip->level_mask_regs[0]); in mvebu_gpio_resume()
1032 regmap_write(mvchip->regs, in mvebu_gpio_resume()
1034 mvchip->edge_mask_regs[i]); in mvebu_gpio_resume()
1035 regmap_write(mvchip->regs, in mvebu_gpio_resume()
1037 mvchip->level_mask_regs[i]); in mvebu_gpio_resume()
1042 regmap_write(mvchip->regs, in mvebu_gpio_resume()
1044 mvchip->edge_mask_regs[i]); in mvebu_gpio_resume()
1045 regmap_write(mvchip->regs, in mvebu_gpio_resume()
1047 mvchip->level_mask_regs[i]); in mvebu_gpio_resume()
1069 mvchip->regs = devm_regmap_init_mmio(&pdev->dev, base, in mvebu_gpio_probe_raw()
1071 if (IS_ERR(mvchip->regs)) in mvebu_gpio_probe_raw()
1072 return PTR_ERR(mvchip->regs); in mvebu_gpio_probe_raw()
1076 * registers, so no offset is needed. in mvebu_gpio_probe_raw()
1078 mvchip->offset = 0; in mvebu_gpio_probe_raw()
1082 * per-CPU registers in mvebu_gpio_probe_raw()
1084 if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_ARMADAXP) { in mvebu_gpio_probe_raw()
1089 mvchip->percpu_regs = in mvebu_gpio_probe_raw()
1090 devm_regmap_init_mmio(&pdev->dev, base, in mvebu_gpio_probe_raw()
1092 if (IS_ERR(mvchip->percpu_regs)) in mvebu_gpio_probe_raw()
1093 return PTR_ERR(mvchip->percpu_regs); in mvebu_gpio_probe_raw()
1102 mvchip->regs = syscon_node_to_regmap(pdev->dev.parent->of_node); in mvebu_gpio_probe_syscon()
1103 if (IS_ERR(mvchip->regs)) in mvebu_gpio_probe_syscon()
1104 return PTR_ERR(mvchip->regs); in mvebu_gpio_probe_syscon()
1106 if (of_property_read_u32(pdev->dev.of_node, "offset", &mvchip->offset)) in mvebu_gpio_probe_syscon()
1107 return -EINVAL; in mvebu_gpio_probe_syscon()
1116 struct device_node *np = pdev->dev.of_node; in mvebu_gpio_probe()
1125 match = of_match_device(mvebu_gpio_of_match, &pdev->dev); in mvebu_gpio_probe()
1127 soc_variant = (unsigned long) match->data; in mvebu_gpio_probe()
1138 mvchip = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_gpio_chip), in mvebu_gpio_probe()
1141 return -ENOMEM; in mvebu_gpio_probe()
1145 if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) { in mvebu_gpio_probe()
1146 dev_err(&pdev->dev, "Missing ngpios OF property\n"); in mvebu_gpio_probe()
1147 return -ENODEV; in mvebu_gpio_probe()
1150 id = of_alias_get_id(pdev->dev.of_node, "gpio"); in mvebu_gpio_probe()
1152 dev_err(&pdev->dev, "Couldn't get OF id\n"); in mvebu_gpio_probe()
1156 mvchip->clk = devm_clk_get(&pdev->dev, NULL); in mvebu_gpio_probe()
1158 if (!IS_ERR(mvchip->clk)) in mvebu_gpio_probe()
1159 clk_prepare_enable(mvchip->clk); in mvebu_gpio_probe()
1161 mvchip->soc_variant = soc_variant; in mvebu_gpio_probe()
1162 mvchip->chip.label = dev_name(&pdev->dev); in mvebu_gpio_probe()
1163 mvchip->chip.parent = &pdev->dev; in mvebu_gpio_probe()
1164 mvchip->chip.request = gpiochip_generic_request; in mvebu_gpio_probe()
1165 mvchip->chip.free = gpiochip_generic_free; in mvebu_gpio_probe()
1166 mvchip->chip.get_direction = mvebu_gpio_get_direction; in mvebu_gpio_probe()
1167 mvchip->chip.direction_input = mvebu_gpio_direction_input; in mvebu_gpio_probe()
1168 mvchip->chip.get = mvebu_gpio_get; in mvebu_gpio_probe()
1169 mvchip->chip.direction_output = mvebu_gpio_direction_output; in mvebu_gpio_probe()
1170 mvchip->chip.set = mvebu_gpio_set; in mvebu_gpio_probe()
1172 mvchip->chip.to_irq = mvebu_gpio_to_irq; in mvebu_gpio_probe()
1173 mvchip->chip.base = id * MVEBU_MAX_GPIO_PER_BANK; in mvebu_gpio_probe()
1174 mvchip->chip.ngpio = ngpios; in mvebu_gpio_probe()
1175 mvchip->chip.can_sleep = false; in mvebu_gpio_probe()
1176 mvchip->chip.dbg_show = mvebu_gpio_dbg_show; in mvebu_gpio_probe()
1192 regmap_write(mvchip->regs, in mvebu_gpio_probe()
1193 GPIO_EDGE_CAUSE_OFF + mvchip->offset, 0); in mvebu_gpio_probe()
1194 regmap_write(mvchip->regs, in mvebu_gpio_probe()
1195 GPIO_EDGE_MASK_OFF + mvchip->offset, 0); in mvebu_gpio_probe()
1196 regmap_write(mvchip->regs, in mvebu_gpio_probe()
1197 GPIO_LEVEL_MASK_OFF + mvchip->offset, 0); in mvebu_gpio_probe()
1200 regmap_write(mvchip->regs, GPIO_EDGE_CAUSE_OFF, 0); in mvebu_gpio_probe()
1202 regmap_write(mvchip->regs, in mvebu_gpio_probe()
1204 regmap_write(mvchip->regs, in mvebu_gpio_probe()
1209 regmap_write(mvchip->regs, GPIO_EDGE_CAUSE_OFF, 0); in mvebu_gpio_probe()
1210 regmap_write(mvchip->regs, GPIO_EDGE_MASK_OFF, 0); in mvebu_gpio_probe()
1211 regmap_write(mvchip->regs, GPIO_LEVEL_MASK_OFF, 0); in mvebu_gpio_probe()
1213 regmap_write(mvchip->percpu_regs, in mvebu_gpio_probe()
1215 regmap_write(mvchip->percpu_regs, in mvebu_gpio_probe()
1217 regmap_write(mvchip->percpu_regs, in mvebu_gpio_probe()
1225 devm_gpiochip_add_data(&pdev->dev, &mvchip->chip, mvchip); in mvebu_gpio_probe()
1238 mvchip->domain = in mvebu_gpio_probe()
1240 if (!mvchip->domain) { in mvebu_gpio_probe()
1241 dev_err(&pdev->dev, "couldn't allocate irq domain %s (DT).\n", in mvebu_gpio_probe()
1242 mvchip->chip.label); in mvebu_gpio_probe()
1243 err = -ENODEV; in mvebu_gpio_probe()
1248 mvchip->domain, ngpios, 2, np->name, handle_level_irq, in mvebu_gpio_probe()
1251 dev_err(&pdev->dev, "couldn't allocate irq chips %s (DT).\n", in mvebu_gpio_probe()
1252 mvchip->chip.label); in mvebu_gpio_probe()
1260 gc = irq_get_domain_generic_chip(mvchip->domain, 0); in mvebu_gpio_probe()
1261 gc->private = mvchip; in mvebu_gpio_probe()
1262 ct = &gc->chip_types[0]; in mvebu_gpio_probe()
1263 ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW; in mvebu_gpio_probe()
1264 ct->chip.irq_mask = mvebu_gpio_level_irq_mask; in mvebu_gpio_probe()
1265 ct->chip.irq_unmask = mvebu_gpio_level_irq_unmask; in mvebu_gpio_probe()
1266 ct->chip.irq_set_type = mvebu_gpio_irq_set_type; in mvebu_gpio_probe()
1267 ct->chip.name = mvchip->chip.label; in mvebu_gpio_probe()
1269 ct = &gc->chip_types[1]; in mvebu_gpio_probe()
1270 ct->type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; in mvebu_gpio_probe()
1271 ct->chip.irq_ack = mvebu_gpio_irq_ack; in mvebu_gpio_probe()
1272 ct->chip.irq_mask = mvebu_gpio_edge_irq_mask; in mvebu_gpio_probe()
1273 ct->chip.irq_unmask = mvebu_gpio_edge_irq_unmask; in mvebu_gpio_probe()
1274 ct->chip.irq_set_type = mvebu_gpio_irq_set_type; in mvebu_gpio_probe()
1275 ct->handler = handle_edge_irq; in mvebu_gpio_probe()
1276 ct->chip.name = mvchip->chip.label; in mvebu_gpio_probe()
1295 irq_domain_remove(mvchip->domain); in mvebu_gpio_probe()
1297 pwmchip_remove(&mvchip->mvpwm->chip); in mvebu_gpio_probe()
1304 .name = "mvebu-gpio",