Lines Matching full:pinctrl

31 #include <linux/pinctrl/pinconf.h>
32 #include <linux/pinctrl/pinconf-generic.h>
33 #include <linux/pinctrl/pinctrl.h>
34 #include <linux/pinctrl/pinmux.h>
39 #include "../pinctrl-utils.h"
100 * nsp IOMUX pinctrl core
320 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_groups_count() local
322 return pinctrl->num_groups; in nsp_get_groups_count()
328 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_group_name() local
330 return pinctrl->groups[selector].name; in nsp_get_group_name()
337 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_group_pins() local
339 *pins = pinctrl->groups[selector].pins; in nsp_get_group_pins()
340 *num_pins = pinctrl->groups[selector].num_pins; in nsp_get_group_pins()
362 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_functions_count() local
364 return pinctrl->num_functions; in nsp_get_functions_count()
370 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_function_name() local
372 return pinctrl->functions[selector].name; in nsp_get_function_name()
380 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_function_groups() local
382 *groups = pinctrl->functions[selector].groups; in nsp_get_function_groups()
383 *num_groups = pinctrl->functions[selector].num_groups; in nsp_get_function_groups()
388 static int nsp_pinmux_set(struct nsp_pinctrl *pinctrl, in nsp_pinmux_set() argument
399 for (i = 0; i < pinctrl->num_groups; i++) { in nsp_pinmux_set()
413 dev_err(pinctrl->dev, in nsp_pinmux_set()
415 dev_err(pinctrl->dev, "func:%s grp:%s\n", in nsp_pinmux_set()
422 if (i == pinctrl->num_groups) in nsp_pinmux_set()
431 base_address = pinctrl->base0; in nsp_pinmux_set()
435 base_address = pinctrl->base1; in nsp_pinmux_set()
439 base_address = pinctrl->base2; in nsp_pinmux_set()
446 spin_lock_irqsave(&pinctrl->lock, flags); in nsp_pinmux_set()
451 spin_unlock_irqrestore(&pinctrl->lock, flags); in nsp_pinmux_set()
459 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_pinmux_enable() local
463 if (grp_select >= pinctrl->num_groups || in nsp_pinmux_enable()
464 func_select >= pinctrl->num_functions) in nsp_pinmux_enable()
467 func = &pinctrl->functions[func_select]; in nsp_pinmux_enable()
468 grp = &pinctrl->groups[grp_select]; in nsp_pinmux_enable()
476 return nsp_pinmux_set(pinctrl, func, grp, pinctrl->mux_log); in nsp_pinmux_enable()
484 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_gpio_request_enable() local
489 spin_lock_irqsave(&pinctrl->lock, flags); in nsp_gpio_request_enable()
490 val = readl(pinctrl->base0); in nsp_gpio_request_enable()
494 writel(val, pinctrl->base0); in nsp_gpio_request_enable()
496 spin_unlock_irqrestore(&pinctrl->lock, flags); in nsp_gpio_request_enable()
505 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_gpio_disable_free() local
510 spin_lock_irqsave(&pinctrl->lock, flags); in nsp_gpio_disable_free()
511 val = readl(pinctrl->base0); in nsp_gpio_disable_free()
516 writel(val, pinctrl->base0); in nsp_gpio_disable_free()
518 spin_unlock_irqrestore(&pinctrl->lock, flags); in nsp_gpio_disable_free()
536 static int nsp_mux_log_init(struct nsp_pinctrl *pinctrl) in nsp_mux_log_init() argument
542 pinctrl->mux_log = devm_kcalloc(pinctrl->dev, no_of_groups, in nsp_mux_log_init()
545 if (!pinctrl->mux_log) in nsp_mux_log_init()
549 log = &pinctrl->mux_log[i]; in nsp_mux_log_init()
561 struct nsp_pinctrl *pinctrl; in nsp_pinmux_probe() local
567 pinctrl = devm_kzalloc(&pdev->dev, sizeof(*pinctrl), GFP_KERNEL); in nsp_pinmux_probe()
568 if (!pinctrl) in nsp_pinmux_probe()
570 pinctrl->dev = &pdev->dev; in nsp_pinmux_probe()
571 platform_set_drvdata(pdev, pinctrl); in nsp_pinmux_probe()
572 spin_lock_init(&pinctrl->lock); in nsp_pinmux_probe()
574 pinctrl->base0 = devm_platform_ioremap_resource(pdev, 0); in nsp_pinmux_probe()
575 if (IS_ERR(pinctrl->base0)) in nsp_pinmux_probe()
576 return PTR_ERR(pinctrl->base0); in nsp_pinmux_probe()
581 pinctrl->base1 = devm_ioremap(&pdev->dev, res->start, in nsp_pinmux_probe()
583 if (!pinctrl->base1) { in nsp_pinmux_probe()
588 pinctrl->base2 = devm_platform_ioremap_resource(pdev, 2); in nsp_pinmux_probe()
589 if (IS_ERR(pinctrl->base2)) in nsp_pinmux_probe()
590 return PTR_ERR(pinctrl->base2); in nsp_pinmux_probe()
592 ret = nsp_mux_log_init(pinctrl); in nsp_pinmux_probe()
608 pinctrl->groups = nsp_pin_groups; in nsp_pinmux_probe()
609 pinctrl->num_groups = ARRAY_SIZE(nsp_pin_groups); in nsp_pinmux_probe()
610 pinctrl->functions = nsp_pin_functions; in nsp_pinmux_probe()
611 pinctrl->num_functions = ARRAY_SIZE(nsp_pin_functions); in nsp_pinmux_probe()
615 pinctrl->pctl = devm_pinctrl_register(&pdev->dev, &nsp_pinctrl_desc, in nsp_pinmux_probe()
616 pinctrl); in nsp_pinmux_probe()
617 if (IS_ERR(pinctrl->pctl)) { in nsp_pinmux_probe()
618 dev_err(&pdev->dev, "unable to register nsp IOMUX pinctrl\n"); in nsp_pinmux_probe()
619 return PTR_ERR(pinctrl->pctl); in nsp_pinmux_probe()