Lines Matching +full:gp +full:- +full:pwm3

6  * Gregory CLEMENT <gregory.clement@free-electrons.com>
17 #include <linux/pinctrl/pinconf-generic.h>
28 #include "../pinctrl-utils.h"
176 PIN_GRP_GPIO_3("pwm3", 14, 1, BIT(6) | BIT(23), 0, BIT(23), BIT(6),
232 *offset -= GPIO_PER_REG; in armada_37xx_update_reg()
240 while (*grp < info->ngroups) { in armada_37xx_find_next_grp_by_pin()
241 struct armada_37xx_pin_group *group = &info->groups[*grp]; in armada_37xx_find_next_grp_by_pin()
245 for (j = 0; j < (group->npins + group->extra_npins); j++) in armada_37xx_find_next_grp_by_pin()
246 if (group->pins[j] == pin) in armada_37xx_find_next_grp_by_pin()
255 return -ENOTSUPP; in armada_37xx_pin_config_group_get()
262 return -ENOTSUPP; in armada_37xx_pin_config_group_set()
275 return info->ngroups; in armada_37xx_get_groups_count()
283 return info->groups[group].name; in armada_37xx_get_group_name()
293 if (selector >= info->ngroups) in armada_37xx_get_group_pins()
294 return -EINVAL; in armada_37xx_get_group_pins()
296 *pins = info->groups[selector].pins; in armada_37xx_get_group_pins()
297 *npins = info->groups[selector].npins + in armada_37xx_get_group_pins()
298 info->groups[selector].extra_npins; in armada_37xx_get_group_pins()
319 return info->nfuncs; in armada_37xx_pmx_get_funcs_count()
327 return info->funcs[selector].name; in armada_37xx_pmx_get_func_name()
337 *groups = info->funcs[selector].groups; in armada_37xx_pmx_get_groups()
338 *num_groups = info->funcs[selector].ngroups; in armada_37xx_pmx_get_groups()
348 struct device *dev = info->dev; in armada_37xx_pmx_set_by_name()
350 unsigned int mask = grp->reg_mask; in armada_37xx_pmx_set_by_name()
353 dev_dbg(dev, "enable function %s group %s\n", name, grp->name); in armada_37xx_pmx_set_by_name()
355 func = match_string(grp->funcs, NB_FUNCS, name); in armada_37xx_pmx_set_by_name()
357 return -ENOTSUPP; in armada_37xx_pmx_set_by_name()
359 val = grp->val[func]; in armada_37xx_pmx_set_by_name()
361 regmap_update_bits(info->regmap, reg, mask, val); in armada_37xx_pmx_set_by_name()
372 struct armada_37xx_pin_group *grp = &info->groups[group]; in armada_37xx_pmx_set()
373 const char *name = info->funcs[selector].name; in armada_37xx_pmx_set()
396 return regmap_update_bits(info->regmap, reg, mask, 0); in armada_37xx_gpio_direction_input()
408 regmap_read(info->regmap, reg, &val); in armada_37xx_gpio_get_direction()
426 ret = regmap_update_bits(info->regmap, reg, mask, mask); in armada_37xx_gpio_direction_output()
433 regmap_update_bits(info->regmap, reg, mask, val); in armada_37xx_gpio_direction_output()
447 regmap_read(info->regmap, reg, &val); in armada_37xx_gpio_get()
463 regmap_update_bits(info->regmap, reg, mask, val); in armada_37xx_gpio_set()
471 struct gpio_chip *chip = range->gc; in armada_37xx_pmx_gpio_set_direction()
473 dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n", in armada_37xx_pmx_gpio_set_direction()
474 offset, range->name, offset, input ? "input" : "output"); in armada_37xx_pmx_gpio_set_direction()
493 dev_dbg(info->dev, "requesting gpio %d\n", offset); in armada_37xx_gpio_request_enable()
532 raw_spin_lock_irqsave(&info->irq_lock, flags); in armada_37xx_irq_ack()
533 writel(d->mask, info->base + reg); in armada_37xx_irq_ack()
534 raw_spin_unlock_irqrestore(&info->irq_lock, flags); in armada_37xx_irq_ack()
545 raw_spin_lock_irqsave(&info->irq_lock, flags); in armada_37xx_irq_mask()
546 val = readl(info->base + reg); in armada_37xx_irq_mask()
547 writel(val & ~d->mask, info->base + reg); in armada_37xx_irq_mask()
548 raw_spin_unlock_irqrestore(&info->irq_lock, flags); in armada_37xx_irq_mask()
561 raw_spin_lock_irqsave(&info->irq_lock, flags); in armada_37xx_irq_unmask()
562 val = readl(info->base + reg); in armada_37xx_irq_unmask()
563 writel(val | d->mask, info->base + reg); in armada_37xx_irq_unmask()
564 raw_spin_unlock_irqrestore(&info->irq_lock, flags); in armada_37xx_irq_unmask()
575 raw_spin_lock_irqsave(&info->irq_lock, flags); in armada_37xx_irq_set_wake()
576 val = readl(info->base + reg); in armada_37xx_irq_set_wake()
578 val |= (BIT(d->hwirq % GPIO_PER_REG)); in armada_37xx_irq_set_wake()
580 val &= ~(BIT(d->hwirq % GPIO_PER_REG)); in armada_37xx_irq_set_wake()
581 writel(val, info->base + reg); in armada_37xx_irq_set_wake()
582 raw_spin_unlock_irqrestore(&info->irq_lock, flags); in armada_37xx_irq_set_wake()
594 raw_spin_lock_irqsave(&info->irq_lock, flags); in armada_37xx_irq_set_type()
596 val = readl(info->base + reg); in armada_37xx_irq_set_type()
599 val &= ~(BIT(d->hwirq % GPIO_PER_REG)); in armada_37xx_irq_set_type()
602 val |= (BIT(d->hwirq % GPIO_PER_REG)); in armada_37xx_irq_set_type()
608 regmap_read(info->regmap, in_reg, &in_val); in armada_37xx_irq_set_type()
611 if (in_val & BIT(d->hwirq % GPIO_PER_REG)) in armada_37xx_irq_set_type()
612 val |= BIT(d->hwirq % GPIO_PER_REG); /* falling */ in armada_37xx_irq_set_type()
614 val &= ~(BIT(d->hwirq % GPIO_PER_REG)); /* rising */ in armada_37xx_irq_set_type()
618 raw_spin_unlock_irqrestore(&info->irq_lock, flags); in armada_37xx_irq_set_type()
619 return -EINVAL; in armada_37xx_irq_set_type()
621 writel(val, info->base + reg); in armada_37xx_irq_set_type()
622 raw_spin_unlock_irqrestore(&info->irq_lock, flags); in armada_37xx_irq_set_type()
635 regmap_read(info->regmap, INPUT_VAL + 4*reg_idx, &l); in armada_37xx_edge_both_irq_swap_pol()
637 raw_spin_lock_irqsave(&info->irq_lock, flags); in armada_37xx_edge_both_irq_swap_pol()
638 p = readl(info->base + IRQ_POL + 4 * reg_idx); in armada_37xx_edge_both_irq_swap_pol()
641 * For the gpios which are used for both-edge irqs, when their in armada_37xx_edge_both_irq_swap_pol()
651 writel(p, info->base + IRQ_POL + 4 * reg_idx); in armada_37xx_edge_both_irq_swap_pol()
655 ret = -1; in armada_37xx_edge_both_irq_swap_pol()
658 raw_spin_unlock_irqrestore(&info->irq_lock, flags); in armada_37xx_edge_both_irq_swap_pol()
667 struct irq_domain *d = gc->irq.domain; in armada_37xx_irq_handler()
671 for (i = 0; i <= d->revmap_size / GPIO_PER_REG; i++) { in armada_37xx_irq_handler()
675 raw_spin_lock_irqsave(&info->irq_lock, flags); in armada_37xx_irq_handler()
676 status = readl_relaxed(info->base + IRQ_STATUS + 4 * i); in armada_37xx_irq_handler()
678 status &= readl_relaxed(info->base + IRQ_EN + 4 * i); in armada_37xx_irq_handler()
679 raw_spin_unlock_irqrestore(&info->irq_lock, flags); in armada_37xx_irq_handler()
681 u32 hwirq = ffs(status) - 1; in armada_37xx_irq_handler()
696 info->base + in armada_37xx_irq_handler()
706 raw_spin_lock_irqsave(&info->irq_lock, flags); in armada_37xx_irq_handler()
707 status = readl_relaxed(info->base + in armada_37xx_irq_handler()
710 status &= readl_relaxed(info->base + IRQ_EN + 4 * i); in armada_37xx_irq_handler()
711 raw_spin_unlock_irqrestore(&info->irq_lock, flags); in armada_37xx_irq_handler()
725 d->mask = BIT(d->hwirq % GPIO_PER_REG); in armada_37xx_irq_startup()
737 seq_printf(p, info->data->name); in armada_37xx_irq_print_chip()
755 struct gpio_chip *gc = &info->gpio_chip; in armada_37xx_irqchip_register()
756 struct gpio_irq_chip *girq = &gc->irq; in armada_37xx_irqchip_register()
757 struct device_node *np = to_of_node(gc->fwnode); in armada_37xx_irqchip_register()
758 struct device *dev = &pdev->dev; in armada_37xx_irqchip_register()
761 raw_spin_lock_init(&info->irq_lock); in armada_37xx_irqchip_register()
769 info->base = devm_platform_ioremap_resource(pdev, 1); in armada_37xx_irqchip_register()
770 if (IS_ERR(info->base)) in armada_37xx_irqchip_register()
771 return PTR_ERR(info->base); in armada_37xx_irqchip_register()
774 girq->parent_handler = armada_37xx_irq_handler; in armada_37xx_irqchip_register()
780 girq->num_parents = nr_irq_parent; in armada_37xx_irqchip_register()
781 girq->parents = devm_kcalloc(dev, nr_irq_parent, sizeof(*girq->parents), GFP_KERNEL); in armada_37xx_irqchip_register()
782 if (!girq->parents) in armada_37xx_irqchip_register()
783 return -ENOMEM; in armada_37xx_irqchip_register()
789 girq->parents[i] = irq; in armada_37xx_irqchip_register()
791 girq->default_type = IRQ_TYPE_NONE; in armada_37xx_irqchip_register()
792 girq->handler = handle_edge_irq; in armada_37xx_irqchip_register()
800 struct device *dev = &pdev->dev; in armada_37xx_gpiochip_register()
807 return -ENODEV; in armada_37xx_gpiochip_register()
809 info->gpio_chip = armada_37xx_gpiolib_chip; in armada_37xx_gpiochip_register()
811 gc = &info->gpio_chip; in armada_37xx_gpiochip_register()
812 gc->ngpio = info->data->nr_pins; in armada_37xx_gpiochip_register()
813 gc->parent = dev; in armada_37xx_gpiochip_register()
814 gc->base = -1; in armada_37xx_gpiochip_register()
815 gc->fwnode = fwnode; in armada_37xx_gpiochip_register()
816 gc->label = info->data->name; in armada_37xx_gpiochip_register()
826 * armada_37xx_add_function() - Add a new function to the list
840 return -EOVERFLOW; in armada_37xx_add_function()
842 while (funcs->ngroups) { in armada_37xx_add_function()
844 if (strcmp(funcs->name, name) == 0) { in armada_37xx_add_function()
845 funcs->ngroups++; in armada_37xx_add_function()
847 return -EEXIST; in armada_37xx_add_function()
854 funcs->name = name; in armada_37xx_add_function()
855 funcs->ngroups = 1; in armada_37xx_add_function()
856 (*funcsize)--; in armada_37xx_add_function()
862 * armada_37xx_fill_group() - complete the group array
872 int n, num = 0, funcsize = info->data->nr_pins; in armada_37xx_fill_group()
873 struct device *dev = info->dev; in armada_37xx_fill_group()
875 for (n = 0; n < info->ngroups; n++) { in armada_37xx_fill_group()
876 struct armada_37xx_pin_group *grp = &info->groups[n]; in armada_37xx_fill_group()
879 grp->pins = devm_kcalloc(dev, grp->npins + grp->extra_npins, in armada_37xx_fill_group()
880 sizeof(*grp->pins), in armada_37xx_fill_group()
882 if (!grp->pins) in armada_37xx_fill_group()
883 return -ENOMEM; in armada_37xx_fill_group()
885 for (i = 0; i < grp->npins; i++) in armada_37xx_fill_group()
886 grp->pins[i] = grp->start_pin + i; in armada_37xx_fill_group()
888 for (j = 0; j < grp->extra_npins; j++) in armada_37xx_fill_group()
889 grp->pins[i+j] = grp->extra_pin + j; in armada_37xx_fill_group()
891 for (f = 0; (f < NB_FUNCS) && grp->funcs[f]; f++) { in armada_37xx_fill_group()
894 ret = armada_37xx_add_function(info->funcs, &funcsize, in armada_37xx_fill_group()
895 grp->funcs[f]); in armada_37xx_fill_group()
896 if (ret == -EOVERFLOW) in armada_37xx_fill_group()
898 info->data->nr_pins); in armada_37xx_fill_group()
905 info->nfuncs = num; in armada_37xx_fill_group()
911 * armada_37xx_fill_func() - complete the funcs array
916 * - the list of the pins included in the group
917 * - the list of pinmux functions that can be selected for this group
922 struct armada_37xx_pmx_func *funcs = info->funcs; in armada_37xx_fill_func()
923 struct device *dev = info->dev; in armada_37xx_fill_func()
926 for (n = 0; n < info->nfuncs; n++) { in armada_37xx_fill_func()
935 return -ENOMEM; in armada_37xx_fill_func()
939 for (g = 0; g < info->ngroups; g++) { in armada_37xx_fill_func()
940 struct armada_37xx_pin_group *gp = &info->groups[g]; in armada_37xx_fill_func() local
943 f = match_string(gp->funcs, NB_FUNCS, name); in armada_37xx_fill_func()
947 *groups = gp->name; in armada_37xx_fill_func()
957 const struct armada_37xx_pin_data *pin_data = info->data; in armada_37xx_pinctrl_register()
958 struct pinctrl_desc *ctrldesc = &info->pctl; in armada_37xx_pinctrl_register()
960 struct device *dev = &pdev->dev; in armada_37xx_pinctrl_register()
964 info->groups = pin_data->groups; in armada_37xx_pinctrl_register()
965 info->ngroups = pin_data->ngroups; in armada_37xx_pinctrl_register()
967 ctrldesc->name = "armada_37xx-pinctrl"; in armada_37xx_pinctrl_register()
968 ctrldesc->owner = THIS_MODULE; in armada_37xx_pinctrl_register()
969 ctrldesc->pctlops = &armada_37xx_pctrl_ops; in armada_37xx_pinctrl_register()
970 ctrldesc->pmxops = &armada_37xx_pmx_ops; in armada_37xx_pinctrl_register()
971 ctrldesc->confops = &armada_37xx_pinconf_ops; in armada_37xx_pinctrl_register()
973 pindesc = devm_kcalloc(dev, pin_data->nr_pins, sizeof(*pindesc), GFP_KERNEL); in armada_37xx_pinctrl_register()
975 return -ENOMEM; in armada_37xx_pinctrl_register()
977 ctrldesc->pins = pindesc; in armada_37xx_pinctrl_register()
978 ctrldesc->npins = pin_data->nr_pins; in armada_37xx_pinctrl_register()
980 pin_names = devm_kasprintf_strarray(dev, pin_data->name, pin_data->nr_pins); in armada_37xx_pinctrl_register()
985 for (pin = 0; pin < pin_data->nr_pins; pin++) { in armada_37xx_pinctrl_register()
986 pdesc->number = pin; in armada_37xx_pinctrl_register()
987 pdesc->name = pin_names[pin]; in armada_37xx_pinctrl_register()
995 info->funcs = devm_kcalloc(dev, pin_data->nr_pins, sizeof(*info->funcs), GFP_KERNEL); in armada_37xx_pinctrl_register()
996 if (!info->funcs) in armada_37xx_pinctrl_register()
997 return -ENOMEM; in armada_37xx_pinctrl_register()
1007 info->pctl_dev = devm_pinctrl_register(dev, ctrldesc, info); in armada_37xx_pinctrl_register()
1008 if (IS_ERR(info->pctl_dev)) in armada_37xx_pinctrl_register()
1009 return dev_err_probe(dev, PTR_ERR(info->pctl_dev), "could not register pinctrl driver\n"); in armada_37xx_pinctrl_register()
1019 regmap_read(info->regmap, OUTPUT_EN, &info->pm.out_en_l); in armada_3700_pinctrl_suspend()
1020 regmap_read(info->regmap, OUTPUT_EN + sizeof(u32), &info->pm.out_en_h); in armada_3700_pinctrl_suspend()
1021 regmap_read(info->regmap, OUTPUT_VAL, &info->pm.out_val_l); in armada_3700_pinctrl_suspend()
1022 regmap_read(info->regmap, OUTPUT_VAL + sizeof(u32), in armada_3700_pinctrl_suspend()
1023 &info->pm.out_val_h); in armada_3700_pinctrl_suspend()
1025 info->pm.irq_en_l = readl(info->base + IRQ_EN); in armada_3700_pinctrl_suspend()
1026 info->pm.irq_en_h = readl(info->base + IRQ_EN + sizeof(u32)); in armada_3700_pinctrl_suspend()
1027 info->pm.irq_pol_l = readl(info->base + IRQ_POL); in armada_3700_pinctrl_suspend()
1028 info->pm.irq_pol_h = readl(info->base + IRQ_POL + sizeof(u32)); in armada_3700_pinctrl_suspend()
1031 regmap_read(info->regmap, SELECTION, &info->pm.selection); in armada_3700_pinctrl_suspend()
1044 regmap_write(info->regmap, OUTPUT_EN, info->pm.out_en_l); in armada_3700_pinctrl_resume()
1045 regmap_write(info->regmap, OUTPUT_EN + sizeof(u32), in armada_3700_pinctrl_resume()
1046 info->pm.out_en_h); in armada_3700_pinctrl_resume()
1047 regmap_write(info->regmap, OUTPUT_VAL, info->pm.out_val_l); in armada_3700_pinctrl_resume()
1048 regmap_write(info->regmap, OUTPUT_VAL + sizeof(u32), in armada_3700_pinctrl_resume()
1049 info->pm.out_val_h); in armada_3700_pinctrl_resume()
1053 * that time. GPIOs used for both-edge IRQs may not be synchronized in armada_3700_pinctrl_resume()
1055 * re-configured manually. in armada_3700_pinctrl_resume()
1057 gc = &info->gpio_chip; in armada_3700_pinctrl_resume()
1058 d = gc->irq.domain; in armada_3700_pinctrl_resume()
1059 for (i = 0; i < gc->ngpio; i++) { in armada_3700_pinctrl_resume()
1064 mask = info->pm.irq_en_l; in armada_3700_pinctrl_resume()
1065 irq_pol = &info->pm.irq_pol_l; in armada_3700_pinctrl_resume()
1068 mask = info->pm.irq_en_h; in armada_3700_pinctrl_resume()
1069 irq_pol = &info->pm.irq_pol_h; in armada_3700_pinctrl_resume()
1080 * Synchronize level and polarity for both-edge irqs: in armada_3700_pinctrl_resume()
1081 * - a high input level expects a falling edge, in armada_3700_pinctrl_resume()
1082 * - a low input level exepects a rising edge. in armada_3700_pinctrl_resume()
1086 regmap_read(info->regmap, input_reg, &level); in armada_3700_pinctrl_resume()
1092 writel(info->pm.irq_en_l, info->base + IRQ_EN); in armada_3700_pinctrl_resume()
1093 writel(info->pm.irq_en_h, info->base + IRQ_EN + sizeof(u32)); in armada_3700_pinctrl_resume()
1094 writel(info->pm.irq_pol_l, info->base + IRQ_POL); in armada_3700_pinctrl_resume()
1095 writel(info->pm.irq_pol_h, info->base + IRQ_POL + sizeof(u32)); in armada_3700_pinctrl_resume()
1098 regmap_write(info->regmap, SELECTION, info->pm.selection); in armada_3700_pinctrl_resume()
1112 .compatible = "marvell,armada3710-sb-pinctrl",
1116 .compatible = "marvell,armada3710-nb-pinctrl",
1132 struct device *dev = &pdev->dev; in armada_37xx_pinctrl_probe()
1152 return -ENOMEM; in armada_37xx_pinctrl_probe()
1154 info->dev = dev; in armada_37xx_pinctrl_probe()
1155 info->regmap = regmap; in armada_37xx_pinctrl_probe()
1156 info->data = of_device_get_match_data(dev); in armada_37xx_pinctrl_probe()
1173 .name = "armada-37xx-pinctrl",