Lines Matching full:pinctrl

23 #include <linux/pinctrl/pinconf.h>
24 #include <linux/pinctrl/pinconf-generic.h>
25 #include <linux/pinctrl/pinctrl.h>
26 #include <linux/pinctrl/pinmux.h>
31 #include "../pinctrl-utils.h"
92 * nsp IOMUX pinctrl core
312 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_groups_count() local
314 return pinctrl->num_groups; in nsp_get_groups_count()
320 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_group_name() local
322 return pinctrl->groups[selector].name; in nsp_get_group_name()
329 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_group_pins() local
331 *pins = pinctrl->groups[selector].pins; in nsp_get_group_pins()
332 *num_pins = pinctrl->groups[selector].num_pins; in nsp_get_group_pins()
354 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_functions_count() local
356 return pinctrl->num_functions; in nsp_get_functions_count()
362 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_function_name() local
364 return pinctrl->functions[selector].name; in nsp_get_function_name()
372 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_get_function_groups() local
374 *groups = pinctrl->functions[selector].groups; in nsp_get_function_groups()
375 *num_groups = pinctrl->functions[selector].num_groups; in nsp_get_function_groups()
380 static int nsp_pinmux_set(struct nsp_pinctrl *pinctrl, in nsp_pinmux_set() argument
391 for (i = 0; i < pinctrl->num_groups; i++) { in nsp_pinmux_set()
405 dev_err(pinctrl->dev, in nsp_pinmux_set()
407 dev_err(pinctrl->dev, "func:%s grp:%s\n", in nsp_pinmux_set()
414 if (i == pinctrl->num_groups) in nsp_pinmux_set()
423 base_address = pinctrl->base0; in nsp_pinmux_set()
427 base_address = pinctrl->base1; in nsp_pinmux_set()
431 base_address = pinctrl->base2; in nsp_pinmux_set()
438 spin_lock_irqsave(&pinctrl->lock, flags); in nsp_pinmux_set()
443 spin_unlock_irqrestore(&pinctrl->lock, flags); in nsp_pinmux_set()
451 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_pinmux_enable() local
455 if (grp_select >= pinctrl->num_groups || in nsp_pinmux_enable()
456 func_select >= pinctrl->num_functions) in nsp_pinmux_enable()
459 func = &pinctrl->functions[func_select]; in nsp_pinmux_enable()
460 grp = &pinctrl->groups[grp_select]; in nsp_pinmux_enable()
468 return nsp_pinmux_set(pinctrl, func, grp, pinctrl->mux_log); in nsp_pinmux_enable()
476 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_gpio_request_enable() local
481 spin_lock_irqsave(&pinctrl->lock, flags); in nsp_gpio_request_enable()
482 val = readl(pinctrl->base0); in nsp_gpio_request_enable()
486 writel(val, pinctrl->base0); in nsp_gpio_request_enable()
488 spin_unlock_irqrestore(&pinctrl->lock, flags); in nsp_gpio_request_enable()
497 struct nsp_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); in nsp_gpio_disable_free() local
502 spin_lock_irqsave(&pinctrl->lock, flags); in nsp_gpio_disable_free()
503 val = readl(pinctrl->base0); in nsp_gpio_disable_free()
508 writel(val, pinctrl->base0); in nsp_gpio_disable_free()
510 spin_unlock_irqrestore(&pinctrl->lock, flags); in nsp_gpio_disable_free()
528 static int nsp_mux_log_init(struct nsp_pinctrl *pinctrl) in nsp_mux_log_init() argument
534 pinctrl->mux_log = devm_kcalloc(pinctrl->dev, no_of_groups, in nsp_mux_log_init()
537 if (!pinctrl->mux_log) in nsp_mux_log_init()
541 log = &pinctrl->mux_log[i]; in nsp_mux_log_init()
553 struct nsp_pinctrl *pinctrl; in nsp_pinmux_probe() local
559 pinctrl = devm_kzalloc(&pdev->dev, sizeof(*pinctrl), GFP_KERNEL); in nsp_pinmux_probe()
560 if (!pinctrl) in nsp_pinmux_probe()
562 pinctrl->dev = &pdev->dev; in nsp_pinmux_probe()
563 platform_set_drvdata(pdev, pinctrl); in nsp_pinmux_probe()
564 spin_lock_init(&pinctrl->lock); in nsp_pinmux_probe()
566 pinctrl->base0 = devm_platform_ioremap_resource(pdev, 0); in nsp_pinmux_probe()
567 if (IS_ERR(pinctrl->base0)) in nsp_pinmux_probe()
568 return PTR_ERR(pinctrl->base0); in nsp_pinmux_probe()
573 pinctrl->base1 = devm_ioremap(&pdev->dev, res->start, in nsp_pinmux_probe()
575 if (!pinctrl->base1) { in nsp_pinmux_probe()
580 pinctrl->base2 = devm_platform_ioremap_resource(pdev, 2); in nsp_pinmux_probe()
581 if (IS_ERR(pinctrl->base2)) in nsp_pinmux_probe()
582 return PTR_ERR(pinctrl->base2); in nsp_pinmux_probe()
584 ret = nsp_mux_log_init(pinctrl); in nsp_pinmux_probe()
600 pinctrl->groups = nsp_pin_groups; in nsp_pinmux_probe()
601 pinctrl->num_groups = ARRAY_SIZE(nsp_pin_groups); in nsp_pinmux_probe()
602 pinctrl->functions = nsp_pin_functions; in nsp_pinmux_probe()
603 pinctrl->num_functions = ARRAY_SIZE(nsp_pin_functions); in nsp_pinmux_probe()
607 pinctrl->pctl = devm_pinctrl_register(&pdev->dev, &nsp_pinctrl_desc, in nsp_pinmux_probe()
608 pinctrl); in nsp_pinmux_probe()
609 if (IS_ERR(pinctrl->pctl)) { in nsp_pinmux_probe()
610 dev_err(&pdev->dev, "unable to register nsp IOMUX pinctrl\n"); in nsp_pinmux_probe()
611 return PTR_ERR(pinctrl->pctl); in nsp_pinmux_probe()