Lines Matching +full:conf +full:- +full:ds

1 // SPDX-License-Identifier: GPL-2.0-only
14 * The AO bank is special because it belongs to the Always-On power
46 #include <linux/pinctrl/pinconf-generic.h>
56 #include "../pinctrl-utils.h"
57 #include "pinctrl-meson.h"
64 * meson_get_bank() - find the bank containing a given pin
77 for (i = 0; i < pc->data->num_banks; i++) { in meson_get_bank()
78 if (pin >= pc->data->banks[i].first && in meson_get_bank()
79 pin <= pc->data->banks[i].last) { in meson_get_bank()
80 *bank = &pc->data->banks[i]; in meson_get_bank()
85 return -EINVAL; in meson_get_bank()
89 * meson_calc_reg_and_bit() - calculate register and bit for a pin
93 * @reg_type: the type of register needed (pull-enable, pull, etc...)
101 struct meson_reg_desc *desc = &bank->regs[reg_type]; in meson_calc_reg_and_bit()
103 *bit = (desc->bit + pin - bank->first) * meson_bit_strides[reg_type]; in meson_calc_reg_and_bit()
104 *reg = (desc->reg + (*bit / 32)) * 4; in meson_calc_reg_and_bit()
112 return pc->data->num_groups; in meson_get_groups_count()
120 return pc->data->groups[selector].name; in meson_get_group_name()
128 *pins = pc->data->groups[selector].pins; in meson_get_group_pins()
129 *num_pins = pc->data->groups[selector].num_pins; in meson_get_group_pins()
137 seq_printf(s, " %s", dev_name(pcdev->dev)); in meson_pin_dbg_show()
153 return pc->data->num_funcs; in meson_pmx_get_funcs_count()
162 return pc->data->funcs[selector].name; in meson_pmx_get_func_name()
172 *groups = pc->data->funcs[selector].groups; in meson_pmx_get_groups()
173 *num_groups = pc->data->funcs[selector].num_groups; in meson_pmx_get_groups()
193 return regmap_update_bits(pc->reg_gpio, reg, BIT(bit), in meson_pinconf_set_gpio_bit()
210 ret = regmap_read(pc->reg_gpio, reg, &val); in meson_pinconf_get_gpio_bit()
273 ret = regmap_update_bits(pc->reg_pullen, reg, BIT(bit), 0); in meson_pinconf_disable_bias()
295 ret = regmap_update_bits(pc->reg_pull, reg, BIT(bit), val); in meson_pinconf_enable_bias()
300 ret = regmap_update_bits(pc->reg_pullen, reg, BIT(bit), BIT(bit)); in meson_pinconf_enable_bias()
315 if (!pc->reg_ds) { in meson_pinconf_set_drive_strength()
316 dev_err(pc->dev, "drive-strength not supported\n"); in meson_pinconf_set_drive_strength()
317 return -ENOTSUPP; in meson_pinconf_set_drive_strength()
335 dev_warn_once(pc->dev, in meson_pinconf_set_drive_strength()
336 "pin %u: invalid drive-strength : %d , default to 4mA\n", in meson_pinconf_set_drive_strength()
341 ret = regmap_update_bits(pc->reg_ds, reg, 0x3 << bit, ds_val << bit); in meson_pinconf_set_drive_strength()
390 ret = -ENOTSUPP; in meson_pinconf_set()
404 int ret, conf; in meson_pinconf_get_pull() local
412 ret = regmap_read(pc->reg_pullen, reg, &val); in meson_pinconf_get_pull()
417 conf = PIN_CONFIG_BIAS_DISABLE; in meson_pinconf_get_pull()
421 ret = regmap_read(pc->reg_pull, reg, &val); in meson_pinconf_get_pull()
426 conf = PIN_CONFIG_BIAS_PULL_UP; in meson_pinconf_get_pull()
428 conf = PIN_CONFIG_BIAS_PULL_DOWN; in meson_pinconf_get_pull()
431 return conf; in meson_pinconf_get_pull()
443 if (!pc->reg_ds) in meson_pinconf_get_drive_strength()
444 return -ENOTSUPP; in meson_pinconf_get_drive_strength()
452 ret = regmap_read(pc->reg_ds, reg, &val); in meson_pinconf_get_drive_strength()
470 return -EINVAL; in meson_pinconf_get_drive_strength()
491 return -EINVAL; in meson_pinconf_get()
501 return -EINVAL; in meson_pinconf_get()
507 return -EINVAL; in meson_pinconf_get()
511 return -EINVAL; in meson_pinconf_get()
517 return -ENOTSUPP; in meson_pinconf_get()
521 dev_dbg(pc->dev, "pinconf for pin %u is %lu\n", pin, *config); in meson_pinconf_get()
531 struct meson_pmx_group *group = &pc->data->groups[num_group]; in meson_pinconf_group_set()
534 dev_dbg(pc->dev, "set pinconf for group %s\n", group->name); in meson_pinconf_group_set()
536 for (i = 0; i < group->num_pins; i++) { in meson_pinconf_group_set()
537 meson_pinconf_set(pcdev, group->pins[i], configs, in meson_pinconf_group_set()
547 return -ENOTSUPP; in meson_pinconf_group_get()
599 regmap_read(pc->reg_gpio, reg, &val); in meson_gpio_get()
608 pc->chip.label = pc->data->name; in meson_gpiolib_register()
609 pc->chip.parent = pc->dev; in meson_gpiolib_register()
610 pc->chip.fwnode = pc->fwnode; in meson_gpiolib_register()
611 pc->chip.request = gpiochip_generic_request; in meson_gpiolib_register()
612 pc->chip.free = gpiochip_generic_free; in meson_gpiolib_register()
613 pc->chip.set_config = gpiochip_generic_config; in meson_gpiolib_register()
614 pc->chip.get_direction = meson_gpio_get_direction; in meson_gpiolib_register()
615 pc->chip.direction_input = meson_gpio_direction_input; in meson_gpiolib_register()
616 pc->chip.direction_output = meson_gpio_direction_output; in meson_gpiolib_register()
617 pc->chip.get = meson_gpio_get; in meson_gpiolib_register()
618 pc->chip.set = meson_gpio_set; in meson_gpiolib_register()
619 pc->chip.base = -1; in meson_gpiolib_register()
620 pc->chip.ngpio = pc->data->num_pins; in meson_gpiolib_register()
621 pc->chip.can_sleep = false; in meson_gpiolib_register()
623 ret = gpiochip_add_data(&pc->chip, pc); in meson_gpiolib_register()
625 dev_err(pc->dev, "can't add gpio chip %s\n", in meson_gpiolib_register()
626 pc->data->name); in meson_gpiolib_register()
646 i = of_property_match_string(node, "reg-names", name); in meson_map_resource()
650 base = devm_ioremap_resource(pc->dev, &res); in meson_map_resource()
654 meson_regmap_config.max_register = resource_size(&res) - 4; in meson_map_resource()
655 meson_regmap_config.name = devm_kasprintf(pc->dev, GFP_KERNEL, in meson_map_resource()
656 "%pOFn-%s", node, in meson_map_resource()
659 return ERR_PTR(-ENOMEM); in meson_map_resource()
661 return devm_regmap_init_mmio(pc->dev, base, &meson_regmap_config); in meson_map_resource()
669 chips = gpiochip_node_count(pc->dev); in meson_pinctrl_parse_dt()
671 dev_err(pc->dev, "no gpio node found\n"); in meson_pinctrl_parse_dt()
672 return -EINVAL; in meson_pinctrl_parse_dt()
675 dev_err(pc->dev, "multiple gpio nodes\n"); in meson_pinctrl_parse_dt()
676 return -EINVAL; in meson_pinctrl_parse_dt()
679 pc->fwnode = gpiochip_node_get_first(pc->dev); in meson_pinctrl_parse_dt()
680 gpio_np = to_of_node(pc->fwnode); in meson_pinctrl_parse_dt()
682 pc->reg_mux = meson_map_resource(pc, gpio_np, "mux"); in meson_pinctrl_parse_dt()
683 if (IS_ERR_OR_NULL(pc->reg_mux)) { in meson_pinctrl_parse_dt()
684 dev_err(pc->dev, "mux registers not found\n"); in meson_pinctrl_parse_dt()
685 return pc->reg_mux ? PTR_ERR(pc->reg_mux) : -ENOENT; in meson_pinctrl_parse_dt()
688 pc->reg_gpio = meson_map_resource(pc, gpio_np, "gpio"); in meson_pinctrl_parse_dt()
689 if (IS_ERR_OR_NULL(pc->reg_gpio)) { in meson_pinctrl_parse_dt()
690 dev_err(pc->dev, "gpio registers not found\n"); in meson_pinctrl_parse_dt()
691 return pc->reg_gpio ? PTR_ERR(pc->reg_gpio) : -ENOENT; in meson_pinctrl_parse_dt()
694 pc->reg_pull = meson_map_resource(pc, gpio_np, "pull"); in meson_pinctrl_parse_dt()
695 if (IS_ERR(pc->reg_pull)) in meson_pinctrl_parse_dt()
696 pc->reg_pull = NULL; in meson_pinctrl_parse_dt()
698 pc->reg_pullen = meson_map_resource(pc, gpio_np, "pull-enable"); in meson_pinctrl_parse_dt()
699 if (IS_ERR(pc->reg_pullen)) in meson_pinctrl_parse_dt()
700 pc->reg_pullen = NULL; in meson_pinctrl_parse_dt()
702 pc->reg_ds = meson_map_resource(pc, gpio_np, "ds"); in meson_pinctrl_parse_dt()
703 if (IS_ERR(pc->reg_ds)) { in meson_pinctrl_parse_dt()
704 dev_dbg(pc->dev, "ds registers not found - skipping\n"); in meson_pinctrl_parse_dt()
705 pc->reg_ds = NULL; in meson_pinctrl_parse_dt()
708 if (pc->data->parse_dt) in meson_pinctrl_parse_dt()
709 return pc->data->parse_dt(pc); in meson_pinctrl_parse_dt()
716 if (!pc->reg_pull) in meson8_aobus_parse_dt_extra()
717 return -EINVAL; in meson8_aobus_parse_dt_extra()
719 pc->reg_pullen = pc->reg_pull; in meson8_aobus_parse_dt_extra()
727 pc->reg_pull = pc->reg_gpio; in meson_a1_parse_dt_extra()
728 pc->reg_pullen = pc->reg_gpio; in meson_a1_parse_dt_extra()
729 pc->reg_ds = pc->reg_gpio; in meson_a1_parse_dt_extra()
737 struct device *dev = &pdev->dev; in meson_pinctrl_probe()
743 return -ENOMEM; in meson_pinctrl_probe()
745 pc->dev = dev; in meson_pinctrl_probe()
746 pc->data = (struct meson_pinctrl_data *) of_device_get_match_data(dev); in meson_pinctrl_probe()
752 pc->desc.name = "pinctrl-meson"; in meson_pinctrl_probe()
753 pc->desc.owner = THIS_MODULE; in meson_pinctrl_probe()
754 pc->desc.pctlops = &meson_pctrl_ops; in meson_pinctrl_probe()
755 pc->desc.pmxops = pc->data->pmx_ops; in meson_pinctrl_probe()
756 pc->desc.confops = &meson_pinconf_ops; in meson_pinctrl_probe()
757 pc->desc.pins = pc->data->pins; in meson_pinctrl_probe()
758 pc->desc.npins = pc->data->num_pins; in meson_pinctrl_probe()
760 pc->pcdev = devm_pinctrl_register(pc->dev, &pc->desc, pc); in meson_pinctrl_probe()
761 if (IS_ERR(pc->pcdev)) { in meson_pinctrl_probe()
762 dev_err(pc->dev, "can't register pinctrl device"); in meson_pinctrl_probe()
763 return PTR_ERR(pc->pcdev); in meson_pinctrl_probe()