Lines Matching +full:pctrl +full:- +full:syscon

1 // SPDX-License-Identifier: GPL-2.0-or-later
10 #include <linux/mfd/syscon.h>
18 #include <linux/pinctrl/pinconf-generic.h>
20 #include "pinctrl-utils.h"
32 * struct zynq_pinctrl - driver data
33 * @pctrl: Pinctrl device
34 * @syscon: Syscon regmap
35 * @pctrl_offset: Offset for pinctrl into the @syscon space
42 struct pinctrl_dev *pctrl; member
43 struct regmap *syscon; member
58 * struct zynq_pinmux_function - a pinmux function
827 struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in zynq_pctrl_get_groups_count() local
829 return pctrl->ngroups; in zynq_pctrl_get_groups_count()
835 struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in zynq_pctrl_get_group_name() local
837 return pctrl->groups[selector].name; in zynq_pctrl_get_group_name()
845 struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in zynq_pctrl_get_group_pins() local
847 *pins = pctrl->groups[selector].pins; in zynq_pctrl_get_group_pins()
848 *num_pins = pctrl->groups[selector].npins; in zynq_pctrl_get_group_pins()
864 struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in zynq_pmux_get_functions_count() local
866 return pctrl->nfuncs; in zynq_pmux_get_functions_count()
872 struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in zynq_pmux_get_function_name() local
874 return pctrl->funcs[selector].name; in zynq_pmux_get_function_name()
882 struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in zynq_pmux_get_function_groups() local
884 *groups = pctrl->funcs[selector].groups; in zynq_pmux_get_function_groups()
885 *num_groups = pctrl->funcs[selector].ngroups; in zynq_pmux_get_function_groups()
894 struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in zynq_pinmux_set_mux() local
895 const struct zynq_pctrl_group *pgrp = &pctrl->groups[group]; in zynq_pinmux_set_mux()
896 const struct zynq_pinmux_function *func = &pctrl->funcs[function]; in zynq_pinmux_set_mux()
907 ret = regmap_read(pctrl->syscon, in zynq_pinmux_set_mux()
908 pctrl->pctrl_offset + func->mux, &reg); in zynq_pinmux_set_mux()
912 reg &= ~func->mux_mask; in zynq_pinmux_set_mux()
913 reg |= pgrp->pins[0] << func->mux_shift; in zynq_pinmux_set_mux()
914 ret = regmap_write(pctrl->syscon, in zynq_pinmux_set_mux()
915 pctrl->pctrl_offset + func->mux, reg); in zynq_pinmux_set_mux()
919 for (i = 0; i < pgrp->npins; i++) { in zynq_pinmux_set_mux()
920 unsigned int pin = pgrp->pins[i]; in zynq_pinmux_set_mux()
921 u32 reg, addr = pctrl->pctrl_offset + (4 * pin); in zynq_pinmux_set_mux()
923 ret = regmap_read(pctrl->syscon, addr, &reg); in zynq_pinmux_set_mux()
928 reg |= func->mux_val << ZYNQ_PINMUX_MUX_SHIFT; in zynq_pinmux_set_mux()
929 ret = regmap_write(pctrl->syscon, addr, reg); in zynq_pinmux_set_mux()
971 {"io-standard", PIN_CONFIG_IOSTANDARD, zynq_iostd_lvcmos18},
976 = { PCONFDUMP(PIN_CONFIG_IOSTANDARD, "IO-standard", NULL, true),
993 struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in zynq_pinconf_cfg_get() local
996 return -ENOTSUPP; in zynq_pinconf_cfg_get()
998 ret = regmap_read(pctrl->syscon, pctrl->pctrl_offset + (4 * pin), &reg); in zynq_pinconf_cfg_get()
1000 return -EIO; in zynq_pinconf_cfg_get()
1005 return -EINVAL; in zynq_pinconf_cfg_get()
1010 return -EINVAL; in zynq_pinconf_cfg_get()
1015 return -EINVAL; in zynq_pinconf_cfg_get()
1025 return -EINVAL; in zynq_pinconf_cfg_get()
1027 return -EINVAL; in zynq_pinconf_cfg_get()
1036 return -ENOTSUPP; in zynq_pinconf_cfg_get()
1052 struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in zynq_pinconf_cfg_set() local
1055 return -ENOTSUPP; in zynq_pinconf_cfg_set()
1057 ret = regmap_read(pctrl->syscon, pctrl->pctrl_offset + (4 * pin), &reg); in zynq_pinconf_cfg_set()
1059 return -EIO; in zynq_pinconf_cfg_set()
1085 dev_warn(pctldev->dev, in zynq_pinconf_cfg_set()
1101 dev_warn(pctldev->dev, in zynq_pinconf_cfg_set()
1113 ret = regmap_write(pctrl->syscon, pctrl->pctrl_offset + (4 * pin), reg); in zynq_pinconf_cfg_set()
1115 return -EIO; in zynq_pinconf_cfg_set()
1126 struct zynq_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in zynq_pinconf_group_set() local
1127 const struct zynq_pctrl_group *pgrp = &pctrl->groups[selector]; in zynq_pinconf_group_set()
1129 for (i = 0; i < pgrp->npins; i++) { in zynq_pinconf_group_set()
1130 ret = zynq_pinconf_cfg_set(pctldev, pgrp->pins[i], configs, in zynq_pinconf_group_set()
1165 struct zynq_pinctrl *pctrl; in zynq_pinctrl_probe() local
1167 pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); in zynq_pinctrl_probe()
1168 if (!pctrl) in zynq_pinctrl_probe()
1169 return -ENOMEM; in zynq_pinctrl_probe()
1171 pctrl->syscon = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in zynq_pinctrl_probe()
1172 "syscon"); in zynq_pinctrl_probe()
1173 if (IS_ERR(pctrl->syscon)) { in zynq_pinctrl_probe()
1174 dev_err(&pdev->dev, "unable to get syscon\n"); in zynq_pinctrl_probe()
1175 return PTR_ERR(pctrl->syscon); in zynq_pinctrl_probe()
1180 dev_err(&pdev->dev, "missing IO resource\n"); in zynq_pinctrl_probe()
1181 return -ENODEV; in zynq_pinctrl_probe()
1183 pctrl->pctrl_offset = res->start; in zynq_pinctrl_probe()
1185 pctrl->groups = zynq_pctrl_groups; in zynq_pinctrl_probe()
1186 pctrl->ngroups = ARRAY_SIZE(zynq_pctrl_groups); in zynq_pinctrl_probe()
1187 pctrl->funcs = zynq_pmux_functions; in zynq_pinctrl_probe()
1188 pctrl->nfuncs = ARRAY_SIZE(zynq_pmux_functions); in zynq_pinctrl_probe()
1190 pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &zynq_desc, pctrl); in zynq_pinctrl_probe()
1191 if (IS_ERR(pctrl->pctrl)) in zynq_pinctrl_probe()
1192 return PTR_ERR(pctrl->pctrl); in zynq_pinctrl_probe()
1194 platform_set_drvdata(pdev, pctrl); in zynq_pinctrl_probe()
1196 dev_info(&pdev->dev, "zynq pinctrl initialized\n"); in zynq_pinctrl_probe()
1202 { .compatible = "xlnx,pinctrl-zynq" },
1209 .name = "zynq-pinctrl",