Lines Matching refs:pmx
28 static inline u32 pmx_readl(struct tegra_pmx *pmx, u32 bank, u32 reg) in pmx_readl() argument
30 return readl(pmx->regs[bank] + reg); in pmx_readl()
33 static inline void pmx_writel(struct tegra_pmx *pmx, u32 val, u32 bank, u32 reg) in pmx_writel() argument
35 writel_relaxed(val, pmx->regs[bank] + reg); in pmx_writel()
37 pmx_readl(pmx, bank, reg); in pmx_writel()
42 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinctrl_get_groups_count() local
44 return pmx->soc->ngroups; in tegra_pinctrl_get_groups_count()
50 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinctrl_get_group_name() local
52 return pmx->soc->groups[group].name; in tegra_pinctrl_get_group_name()
60 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinctrl_get_group_pins() local
62 *pins = pmx->soc->groups[group].pins; in tegra_pinctrl_get_group_pins()
63 *num_pins = pmx->soc->groups[group].npins; in tegra_pinctrl_get_group_pins()
223 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinctrl_get_funcs_count() local
225 return pmx->soc->nfunctions; in tegra_pinctrl_get_funcs_count()
231 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinctrl_get_func_name() local
233 return pmx->soc->functions[function].name; in tegra_pinctrl_get_func_name()
241 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinctrl_get_func_groups() local
243 *groups = pmx->soc->functions[function].groups; in tegra_pinctrl_get_func_groups()
244 *num_groups = pmx->soc->functions[function].ngroups; in tegra_pinctrl_get_func_groups()
253 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinctrl_set_mux() local
258 g = &pmx->soc->groups[group]; in tegra_pinctrl_set_mux()
270 val = pmx_readl(pmx, g->mux_bank, g->mux_reg); in tegra_pinctrl_set_mux()
273 pmx_writel(pmx, val, g->mux_bank, g->mux_reg); in tegra_pinctrl_set_mux()
281 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinctrl_get_group() local
286 for (group = 0; group < pmx->soc->ngroups; ++group) { in tegra_pinctrl_get_group()
292 return &pmx->soc->groups[group]; in tegra_pinctrl_get_group()
304 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinctrl_gpio_request_enable() local
308 if (!pmx->soc->sfsel_in_mux) in tegra_pinctrl_gpio_request_enable()
319 value = pmx_readl(pmx, group->mux_bank, group->mux_reg); in tegra_pinctrl_gpio_request_enable()
321 pmx_writel(pmx, value, group->mux_bank, group->mux_reg); in tegra_pinctrl_gpio_request_enable()
330 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinctrl_gpio_disable_free() local
334 if (!pmx->soc->sfsel_in_mux) in tegra_pinctrl_gpio_disable_free()
345 value = pmx_readl(pmx, group->mux_bank, group->mux_reg); in tegra_pinctrl_gpio_disable_free()
347 pmx_writel(pmx, value, group->mux_bank, group->mux_reg); in tegra_pinctrl_gpio_disable_free()
359 static int tegra_pinconf_reg(struct tegra_pmx *pmx, in tegra_pinconf_reg() argument
409 if (pmx->soc->hsm_in_mux) { in tegra_pinconf_reg()
420 if (pmx->soc->schmitt_in_mux) { in tegra_pinconf_reg()
461 if (pmx->soc->drvtype_in_mux) { in tegra_pinconf_reg()
472 dev_err(pmx->dev, "Invalid config param %04x\n", param); in tegra_pinconf_reg()
488 dev_err(pmx->dev, in tegra_pinconf_reg()
516 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinconf_group_get() local
525 g = &pmx->soc->groups[group]; in tegra_pinconf_group_get()
527 ret = tegra_pinconf_reg(pmx, g, param, true, &bank, ®, &bit, in tegra_pinconf_group_get()
532 val = pmx_readl(pmx, bank, reg); in tegra_pinconf_group_get()
545 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinconf_group_set() local
554 g = &pmx->soc->groups[group]; in tegra_pinconf_group_set()
560 ret = tegra_pinconf_reg(pmx, g, param, true, &bank, ®, &bit, in tegra_pinconf_group_set()
565 val = pmx_readl(pmx, bank, reg); in tegra_pinconf_group_set()
591 pmx_writel(pmx, val, bank, reg); in tegra_pinconf_group_set()
615 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); in tegra_pinconf_group_dbg_show() local
622 g = &pmx->soc->groups[group]; in tegra_pinconf_group_dbg_show()
625 ret = tegra_pinconf_reg(pmx, g, cfg_params[i].param, false, in tegra_pinconf_group_dbg_show()
630 val = pmx_readl(pmx, bank, reg); in tegra_pinconf_group_dbg_show()
684 static void tegra_pinctrl_clear_parked_bits(struct tegra_pmx *pmx) in tegra_pinctrl_clear_parked_bits() argument
690 for (i = 0; i < pmx->soc->ngroups; ++i) { in tegra_pinctrl_clear_parked_bits()
691 g = &pmx->soc->groups[i]; in tegra_pinctrl_clear_parked_bits()
703 val = pmx_readl(pmx, bank, reg); in tegra_pinctrl_clear_parked_bits()
705 pmx_writel(pmx, val, bank, reg); in tegra_pinctrl_clear_parked_bits()
723 struct tegra_pmx *pmx = dev_get_drvdata(dev); in tegra_pinctrl_suspend() local
724 u32 *backup_regs = pmx->backup_regs; in tegra_pinctrl_suspend()
729 for (i = 0; i < pmx->nbanks; i++) { in tegra_pinctrl_suspend()
731 regs = pmx->regs[i]; in tegra_pinctrl_suspend()
736 return pinctrl_force_sleep(pmx->pctl); in tegra_pinctrl_suspend()
741 struct tegra_pmx *pmx = dev_get_drvdata(dev); in tegra_pinctrl_resume() local
742 u32 *backup_regs = pmx->backup_regs; in tegra_pinctrl_resume()
747 for (i = 0; i < pmx->nbanks; i++) { in tegra_pinctrl_resume()
749 regs = pmx->regs[i]; in tegra_pinctrl_resume()
755 readl_relaxed(pmx->regs[0]); in tegra_pinctrl_resume()
766 static bool tegra_pinctrl_gpio_node_has_range(struct tegra_pmx *pmx) in tegra_pinctrl_gpio_node_has_range() argument
771 np = of_find_compatible_node(NULL, NULL, pmx->soc->gpio_compatible); in tegra_pinctrl_gpio_node_has_range()
785 struct tegra_pmx *pmx; in tegra_pinctrl_probe() local
792 pmx = devm_kzalloc(&pdev->dev, sizeof(*pmx), GFP_KERNEL); in tegra_pinctrl_probe()
793 if (!pmx) in tegra_pinctrl_probe()
796 pmx->dev = &pdev->dev; in tegra_pinctrl_probe()
797 pmx->soc = soc_data; in tegra_pinctrl_probe()
803 pmx->group_pins = devm_kcalloc(&pdev->dev, in tegra_pinctrl_probe()
804 soc_data->ngroups * 4, sizeof(*pmx->group_pins), in tegra_pinctrl_probe()
806 if (!pmx->group_pins) in tegra_pinctrl_probe()
809 group_pins = pmx->group_pins; in tegra_pinctrl_probe()
827 BUG_ON(group_pins - pmx->group_pins >= in tegra_pinctrl_probe()
834 tegra_pinctrl_gpio_range.npins = pmx->soc->ngpios; in tegra_pinctrl_probe()
836 tegra_pinctrl_desc.pins = pmx->soc->pins; in tegra_pinctrl_probe()
837 tegra_pinctrl_desc.npins = pmx->soc->npins; in tegra_pinctrl_probe()
845 pmx->nbanks = i; in tegra_pinctrl_probe()
847 pmx->regs = devm_kcalloc(&pdev->dev, pmx->nbanks, sizeof(*pmx->regs), in tegra_pinctrl_probe()
849 if (!pmx->regs) in tegra_pinctrl_probe()
852 pmx->backup_regs = devm_kzalloc(&pdev->dev, backup_regs_size, in tegra_pinctrl_probe()
854 if (!pmx->backup_regs) in tegra_pinctrl_probe()
857 for (i = 0; i < pmx->nbanks; i++) { in tegra_pinctrl_probe()
858 pmx->regs[i] = devm_platform_ioremap_resource(pdev, i); in tegra_pinctrl_probe()
859 if (IS_ERR(pmx->regs[i])) in tegra_pinctrl_probe()
860 return PTR_ERR(pmx->regs[i]); in tegra_pinctrl_probe()
863 pmx->pctl = devm_pinctrl_register(&pdev->dev, &tegra_pinctrl_desc, pmx); in tegra_pinctrl_probe()
864 if (IS_ERR(pmx->pctl)) { in tegra_pinctrl_probe()
866 return PTR_ERR(pmx->pctl); in tegra_pinctrl_probe()
869 tegra_pinctrl_clear_parked_bits(pmx); in tegra_pinctrl_probe()
871 if (pmx->soc->ngpios > 0 && !tegra_pinctrl_gpio_node_has_range(pmx)) in tegra_pinctrl_probe()
872 pinctrl_add_gpio_range(pmx->pctl, &tegra_pinctrl_gpio_range); in tegra_pinctrl_probe()
874 platform_set_drvdata(pdev, pmx); in tegra_pinctrl_probe()