Lines Matching refs:ipctl
175 static void rzn1_hw_set_lock(struct rzn1_pinctrl *ipctl, u8 lock, u8 value) in rzn1_hw_set_lock() argument
183 u32 val = ipctl->lev1_protect_phys | !(value & LOCK_LEVEL1); in rzn1_hw_set_lock()
185 writel(val, &ipctl->lev1->status_protect); in rzn1_hw_set_lock()
189 u32 val = ipctl->lev2_protect_phys | !(value & LOCK_LEVEL2); in rzn1_hw_set_lock()
191 writel(val, &ipctl->lev2->status_protect); in rzn1_hw_set_lock()
195 static void rzn1_pinctrl_mdio_select(struct rzn1_pinctrl *ipctl, int mdio, in rzn1_pinctrl_mdio_select() argument
198 if (ipctl->mdio_func[mdio] >= 0 && ipctl->mdio_func[mdio] != func) in rzn1_pinctrl_mdio_select()
199 dev_warn(ipctl->dev, "conflicting setting for mdio%d!\n", mdio); in rzn1_pinctrl_mdio_select()
200 ipctl->mdio_func[mdio] = func; in rzn1_pinctrl_mdio_select()
202 dev_dbg(ipctl->dev, "setting mdio%d to %u\n", mdio, func); in rzn1_pinctrl_mdio_select()
204 writel(func, &ipctl->lev2->l2_mdio[mdio]); in rzn1_pinctrl_mdio_select()
215 static int rzn1_set_hw_pin_func(struct rzn1_pinctrl *ipctl, unsigned int pin, in rzn1_set_hw_pin_func() argument
248 rzn1_pinctrl_mdio_select(ipctl, mdio_channel, mdio_func); in rzn1_set_hw_pin_func()
252 if (pin >= ARRAY_SIZE(ipctl->lev1->conf) || in rzn1_set_hw_pin_func()
256 l1 = readl(&ipctl->lev1->conf[pin]); in rzn1_set_hw_pin_func()
258 l2 = readl(&ipctl->lev2->conf[pin]); in rzn1_set_hw_pin_func()
261 dev_dbg(ipctl->dev, "setting func for pin %u to %u\n", pin, pin_config); in rzn1_set_hw_pin_func()
275 writel(l1, &ipctl->lev1->conf[pin]); in rzn1_set_hw_pin_func()
276 writel(l2, &ipctl->lev2->conf[pin]); in rzn1_set_hw_pin_func()
283 const struct rzn1_pinctrl *ipctl, const char *name) in rzn1_pinctrl_find_group_by_name() argument
287 for (i = 0; i < ipctl->ngroups; i++) { in rzn1_pinctrl_find_group_by_name()
288 if (!strcmp(ipctl->groups[i].name, name)) in rzn1_pinctrl_find_group_by_name()
289 return &ipctl->groups[i]; in rzn1_pinctrl_find_group_by_name()
297 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_get_groups_count() local
299 return ipctl->ngroups; in rzn1_get_groups_count()
305 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_get_group_name() local
307 return ipctl->groups[selector].name; in rzn1_get_group_name()
314 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_get_group_pins() local
316 if (selector >= ipctl->ngroups) in rzn1_get_group_pins()
319 *pins = ipctl->groups[selector].pins; in rzn1_get_group_pins()
320 *npins = ipctl->groups[selector].npins; in rzn1_get_group_pins()
338 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_dt_node_to_map_one() local
346 dev_dbg(ipctl->dev, "processing node %pOF\n", np); in rzn1_dt_node_to_map_one()
348 grp = rzn1_pinctrl_find_group_by_name(ipctl, np->name); in rzn1_dt_node_to_map_one()
350 dev_err(ipctl->dev, "unable to find group for node %pOF\n", np); in rzn1_dt_node_to_map_one()
359 dev_err(ipctl->dev, "%pOF: could not parse property\n", np); in rzn1_dt_node_to_map_one()
434 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_pmx_get_funcs_count() local
436 return ipctl->nfunctions; in rzn1_pmx_get_funcs_count()
442 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_pmx_get_func_name() local
444 return ipctl->functions[selector].name; in rzn1_pmx_get_func_name()
452 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_pmx_get_groups() local
454 *groups = ipctl->functions[selector].groups; in rzn1_pmx_get_groups()
455 *num_groups = ipctl->functions[selector].num_groups; in rzn1_pmx_get_groups()
463 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_set_mux() local
464 struct rzn1_pin_group *grp = &ipctl->groups[group]; in rzn1_set_mux()
467 dev_dbg(ipctl->dev, "set mux %s(%d) group %s(%d)\n", in rzn1_set_mux()
468 ipctl->functions[selector].name, selector, grp->name, group); in rzn1_set_mux()
470 rzn1_hw_set_lock(ipctl, LOCK_ALL, LOCK_ALL); in rzn1_set_mux()
472 rzn1_set_hw_pin_func(ipctl, grp->pins[i], grp->pin_ids[i], 0); in rzn1_set_mux()
473 rzn1_hw_set_lock(ipctl, LOCK_ALL, 0); in rzn1_set_mux()
488 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_pinconf_get() local
494 if (pin >= ARRAY_SIZE(ipctl->lev1->conf)) in rzn1_pinconf_get()
497 l1 = readl(&ipctl->lev1->conf[pin]); in rzn1_pinconf_get()
520 l2 = readl(&ipctl->lev2->conf[pin]); in rzn1_pinconf_get()
540 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_pinconf_set() local
547 if (pin >= ARRAY_SIZE(ipctl->lev1->conf)) in rzn1_pinconf_set()
550 l1 = readl(&ipctl->lev1->conf[pin]); in rzn1_pinconf_set()
559 dev_dbg(ipctl->dev, "set pin %d pull up\n", pin); in rzn1_pinconf_set()
564 dev_dbg(ipctl->dev, "set pin %d pull down\n", pin); in rzn1_pinconf_set()
569 dev_dbg(ipctl->dev, "set pin %d bias off\n", pin); in rzn1_pinconf_set()
574 dev_dbg(ipctl->dev, "set pin %d drv %umA\n", pin, arg); in rzn1_pinconf_set()
589 dev_err(ipctl->dev, in rzn1_pinconf_set()
601 dev_dbg(ipctl->dev, "set pin %d High-Z\n", pin); in rzn1_pinconf_set()
611 rzn1_hw_set_lock(ipctl, LOCK_LEVEL1, LOCK_LEVEL1); in rzn1_pinconf_set()
612 writel(l1, &ipctl->lev1->conf[pin]); in rzn1_pinconf_set()
613 rzn1_hw_set_lock(ipctl, LOCK_LEVEL1, 0); in rzn1_pinconf_set()
623 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_pinconf_group_get() local
624 struct rzn1_pin_group *grp = &ipctl->groups[selector]; in rzn1_pinconf_group_get()
628 dev_dbg(ipctl->dev, "group get %s selector:%u\n", grp->name, selector); in rzn1_pinconf_group_get()
649 struct rzn1_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); in rzn1_pinconf_group_set() local
650 struct rzn1_pin_group *grp = &ipctl->groups[selector]; in rzn1_pinconf_group_set()
654 dev_dbg(ipctl->dev, "group set %s selector:%u configs:%p/%d\n", in rzn1_pinconf_group_set()
686 struct rzn1_pinctrl *ipctl) in rzn1_pinctrl_parse_groups() argument
692 dev_dbg(ipctl->dev, "%s: %s\n", __func__, np->name); in rzn1_pinctrl_parse_groups()
704 dev_err(ipctl->dev, in rzn1_pinctrl_parse_groups()
711 dev_err(ipctl->dev, "Invalid " RZN1_PINS_PROP " in node %pOF\n", in rzn1_pinctrl_parse_groups()
718 grp->pin_ids = devm_kmalloc_array(ipctl->dev, in rzn1_pinctrl_parse_groups()
721 grp->pins = devm_kmalloc_array(ipctl->dev, in rzn1_pinctrl_parse_groups()
754 struct rzn1_pinctrl *ipctl, in rzn1_pinctrl_parse_functions() argument
763 func = &ipctl->functions[index]; in rzn1_pinctrl_parse_functions()
769 dev_err(ipctl->dev, "no groups defined in %pOF\n", np); in rzn1_pinctrl_parse_functions()
772 dev_dbg(ipctl->dev, "function %s has %d groups\n", in rzn1_pinctrl_parse_functions()
775 func->groups = devm_kmalloc_array(ipctl->dev, in rzn1_pinctrl_parse_functions()
783 grp = &ipctl->groups[ipctl->ngroups]; in rzn1_pinctrl_parse_functions()
785 ret = rzn1_pinctrl_parse_groups(np, grp, ipctl); in rzn1_pinctrl_parse_functions()
789 ipctl->ngroups++; in rzn1_pinctrl_parse_functions()
794 grp = &ipctl->groups[ipctl->ngroups]; in rzn1_pinctrl_parse_functions()
796 ret = rzn1_pinctrl_parse_groups(child, grp, ipctl); in rzn1_pinctrl_parse_functions()
802 ipctl->ngroups++; in rzn1_pinctrl_parse_functions()
805 dev_dbg(ipctl->dev, "function %s parsed %u/%u groups\n", in rzn1_pinctrl_parse_functions()
812 struct rzn1_pinctrl *ipctl) in rzn1_pinctrl_probe_dt() argument
825 ipctl->nfunctions = nfuncs; in rzn1_pinctrl_probe_dt()
826 ipctl->functions = devm_kmalloc_array(&pdev->dev, nfuncs, in rzn1_pinctrl_probe_dt()
827 sizeof(*ipctl->functions), in rzn1_pinctrl_probe_dt()
829 if (!ipctl->functions) in rzn1_pinctrl_probe_dt()
832 ipctl->ngroups = 0; in rzn1_pinctrl_probe_dt()
836 ipctl->groups = devm_kmalloc_array(&pdev->dev, in rzn1_pinctrl_probe_dt()
838 sizeof(*ipctl->groups), in rzn1_pinctrl_probe_dt()
840 if (!ipctl->groups) in rzn1_pinctrl_probe_dt()
844 ret = rzn1_pinctrl_parse_functions(child, ipctl, i++); in rzn1_pinctrl_probe_dt()
856 struct rzn1_pinctrl *ipctl; in rzn1_pinctrl_probe() local
861 ipctl = devm_kzalloc(&pdev->dev, sizeof(*ipctl), GFP_KERNEL); in rzn1_pinctrl_probe()
862 if (!ipctl) in rzn1_pinctrl_probe()
865 ipctl->mdio_func[0] = -1; in rzn1_pinctrl_probe()
866 ipctl->mdio_func[1] = -1; in rzn1_pinctrl_probe()
869 ipctl->lev1_protect_phys = (u32)res->start + 0x400; in rzn1_pinctrl_probe()
870 ipctl->lev1 = devm_ioremap_resource(&pdev->dev, res); in rzn1_pinctrl_probe()
871 if (IS_ERR(ipctl->lev1)) in rzn1_pinctrl_probe()
872 return PTR_ERR(ipctl->lev1); in rzn1_pinctrl_probe()
875 ipctl->lev2_protect_phys = (u32)res->start + 0x400; in rzn1_pinctrl_probe()
876 ipctl->lev2 = devm_ioremap_resource(&pdev->dev, res); in rzn1_pinctrl_probe()
877 if (IS_ERR(ipctl->lev2)) in rzn1_pinctrl_probe()
878 return PTR_ERR(ipctl->lev2); in rzn1_pinctrl_probe()
880 ipctl->clk = devm_clk_get(&pdev->dev, NULL); in rzn1_pinctrl_probe()
881 if (IS_ERR(ipctl->clk)) in rzn1_pinctrl_probe()
882 return PTR_ERR(ipctl->clk); in rzn1_pinctrl_probe()
883 ret = clk_prepare_enable(ipctl->clk); in rzn1_pinctrl_probe()
887 ipctl->dev = &pdev->dev; in rzn1_pinctrl_probe()
892 ret = rzn1_pinctrl_probe_dt(pdev, ipctl); in rzn1_pinctrl_probe()
898 platform_set_drvdata(pdev, ipctl); in rzn1_pinctrl_probe()
901 ipctl, &ipctl->pctl); in rzn1_pinctrl_probe()
907 ret = pinctrl_enable(ipctl->pctl); in rzn1_pinctrl_probe()
916 clk_disable_unprepare(ipctl->clk); in rzn1_pinctrl_probe()
923 struct rzn1_pinctrl *ipctl = platform_get_drvdata(pdev); in rzn1_pinctrl_remove() local
925 clk_disable_unprepare(ipctl->clk); in rzn1_pinctrl_remove()