Lines Matching +full:zynqmp +full:- +full:firmware
1 // SPDX-License-Identifier: GPL-2.0
3 * ZynqMP pin controller
11 #include <dt-bindings/pinctrl/pinctrl-zynqmp.h>
17 #include <linux/firmware/xlnx-zynqmp.h>
20 #include <linux/pinctrl/pinconf-generic.h>
23 #include "pinctrl-utils.h"
44 * struct zynqmp_pmux_function - a pinmux function
48 * @node: Firmware node matching with the function
60 * struct zynqmp_pinctrl - driver data
80 * struct zynqmp_pctrl_group - Pin control group info
97 return pctrl->ngroups; in zynqmp_pctrl_get_groups_count()
105 return pctrl->groups[selector].name; in zynqmp_pctrl_get_group_name()
115 *pins = pctrl->groups[selector].pins; in zynqmp_pctrl_get_group_pins()
116 *npins = pctrl->groups[selector].npins; in zynqmp_pctrl_get_group_pins()
136 dev_err(pctldev->dev, "request failed for pin %u\n", pin); in zynqmp_pinmux_request_pin()
147 return pctrl->nfuncs; in zynqmp_pmux_get_functions_count()
155 return pctrl->funcs[selector].name; in zynqmp_pmux_get_function_name()
159 * zynqmp_pmux_get_function_groups() - Get groups for the function
176 *groups = pctrl->funcs[selector].groups; in zynqmp_pmux_get_function_groups()
177 *num_groups = pctrl->funcs[selector].ngroups; in zynqmp_pmux_get_function_groups()
183 * zynqmp_pinmux_set_mux() - Set requested function for the group
188 * Loop through all pins of the group and call firmware API
198 const struct zynqmp_pctrl_group *pgrp = &pctrl->groups[group]; in zynqmp_pinmux_set_mux()
201 for (i = 0; i < pgrp->npins; i++) { in zynqmp_pinmux_set_mux()
202 unsigned int pin = pgrp->pins[i]; in zynqmp_pinmux_set_mux()
206 dev_err(pctldev->dev, "set mux failed for pin %u\n", in zynqmp_pinmux_set_mux()
222 dev_err(pctldev->dev, "free pin failed for pin %u\n", in zynqmp_pinmux_release_pin()
240 * zynqmp_pinconf_cfg_get() - get config value for the pin
266 return -EINVAL; in zynqmp_pinconf_cfg_get()
274 return -EINVAL; in zynqmp_pinconf_cfg_get()
282 return -EINVAL; in zynqmp_pinconf_cfg_get()
312 dev_warn(pctldev->dev, in zynqmp_pinconf_cfg_get()
315 return -EINVAL; in zynqmp_pinconf_cfg_get()
319 ret = -ENOTSUPP; in zynqmp_pinconf_cfg_get()
333 * zynqmp_pinconf_cfg_set() - Set requested config for the pin
339 * Loop through all configurations and call firmware API
395 dev_warn(pctldev->dev, in zynqmp_pinconf_cfg_set()
398 return -EINVAL; in zynqmp_pinconf_cfg_set()
409 dev_warn(pctldev->dev, in zynqmp_pinconf_cfg_set()
424 dev_warn(pctldev->dev, in zynqmp_pinconf_cfg_set()
427 ret = -ENOTSUPP; in zynqmp_pinconf_cfg_set()
434 dev_warn(pctldev->dev, in zynqmp_pinconf_cfg_set()
443 * zynqmp_pinconf_group_set() - Set requested config for the group
460 const struct zynqmp_pctrl_group *pgrp = &pctrl->groups[selector]; in zynqmp_pinconf_group_set()
462 for (i = 0; i < pgrp->npins; i++) { in zynqmp_pinconf_group_set()
463 ret = zynqmp_pinconf_cfg_set(pctldev, pgrp->pins[i], configs, in zynqmp_pinconf_group_set()
525 * zynqmp_pinctrl_prepare_func_groups() - prepare function and groups data
531 * Query firmware to get group IDs for each function. Firmware returns
536 * Based on the group ID received from the firmware, function stores name of
553 fgroups = devm_kzalloc(dev, sizeof(*fgroups) * func->ngroups, GFP_KERNEL); in zynqmp_pinctrl_prepare_func_groups()
555 return -ENOMEM; in zynqmp_pinctrl_prepare_func_groups()
557 for (index = 0; index < func->ngroups; index += NUM_GROUPS_PER_RESP) { in zynqmp_pinctrl_prepare_func_groups()
571 func->name, in zynqmp_pinctrl_prepare_func_groups()
574 return -ENOMEM; in zynqmp_pinctrl_prepare_func_groups()
578 func->name, in zynqmp_pinctrl_prepare_func_groups()
581 return -ENOMEM; in zynqmp_pinctrl_prepare_func_groups()
585 func->groups = fgroups; in zynqmp_pinctrl_prepare_func_groups()
646 group->pins[group->npins++] = pin; in zynqmp_pinctrl_group_add_pin()
650 * zynqmp_pinctrl_create_pin_groups() - assign pins to respective groups
655 * Query firmware to get groups available for the given pin.
656 * Based on the firmware response(group IDs for the pin), add
692 * zynqmp_pinctrl_prepare_group_pins() - prepare each group's pin data
718 * zynqmp_pinctrl_prepare_function_info() - prepare function info
722 * Query firmware for functions, groups and pin information and
741 ret = zynqmp_pinctrl_get_num_functions(&pctrl->nfuncs); in zynqmp_pinctrl_prepare_function_info()
745 funcs = devm_kzalloc(dev, sizeof(*funcs) * pctrl->nfuncs, GFP_KERNEL); in zynqmp_pinctrl_prepare_function_info()
747 return -ENOMEM; in zynqmp_pinctrl_prepare_function_info()
749 for (i = 0; i < pctrl->nfuncs; i++) { in zynqmp_pinctrl_prepare_function_info()
756 pctrl->ngroups += funcs[i].ngroups; in zynqmp_pinctrl_prepare_function_info()
759 groups = devm_kzalloc(dev, sizeof(*groups) * pctrl->ngroups, GFP_KERNEL); in zynqmp_pinctrl_prepare_function_info()
761 return -ENOMEM; in zynqmp_pinctrl_prepare_function_info()
763 for (i = 0; i < pctrl->nfuncs; i++) { in zynqmp_pinctrl_prepare_function_info()
770 ret = zynqmp_pinctrl_prepare_group_pins(dev, groups, pctrl->ngroups); in zynqmp_pinctrl_prepare_function_info()
774 pctrl->funcs = funcs; in zynqmp_pinctrl_prepare_function_info()
775 pctrl->groups = groups; in zynqmp_pinctrl_prepare_function_info()
798 * zynqmp_pinctrl_prepare_pin_desc() - prepare pin description info
803 * Query number of pins information from firmware and prepare pin
823 return -ENOMEM; in zynqmp_pinctrl_prepare_pin_desc()
827 pin->number = i; in zynqmp_pinctrl_prepare_pin_desc()
828 pin->name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", in zynqmp_pinctrl_prepare_pin_desc()
830 if (!pin->name) in zynqmp_pinctrl_prepare_pin_desc()
831 return -ENOMEM; in zynqmp_pinctrl_prepare_pin_desc()
844 pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); in zynqmp_pinctrl_probe()
846 return -ENOMEM; in zynqmp_pinctrl_probe()
848 ret = zynqmp_pinctrl_prepare_pin_desc(&pdev->dev, in zynqmp_pinctrl_probe()
852 dev_err(&pdev->dev, "pin desc prepare fail with %d\n", ret); in zynqmp_pinctrl_probe()
856 ret = zynqmp_pinctrl_prepare_function_info(&pdev->dev, pctrl); in zynqmp_pinctrl_probe()
858 dev_err(&pdev->dev, "function info prepare fail with %d\n", ret); in zynqmp_pinctrl_probe()
862 pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &zynqmp_desc, pctrl); in zynqmp_pinctrl_probe()
863 if (IS_ERR(pctrl->pctrl)) in zynqmp_pinctrl_probe()
864 return PTR_ERR(pctrl->pctrl); in zynqmp_pinctrl_probe()
872 { .compatible = "xlnx,zynqmp-pinctrl" },
879 .name = "zynqmp-pinctrl",
887 MODULE_DESCRIPTION("ZynqMP Pin Controller Driver");