Lines Matching +full:pctl +full:- +full:regmap
1 // SPDX-License-Identifier: GPL-2.0-only
17 #include <linux/regmap.h>
20 #include <linux/pinctrl/pinconf-generic.h>
26 #include "pinctrl-utils.h"
52 .property = "maxim,active-fps-source",
55 .property = "maxim,active-fps-power-up-slot",
58 .property = "maxim,active-fps-power-down-slot",
61 .property = "maxim,suspend-fps-source",
64 .property = "maxim,suspend-fps-power-up-slot",
67 .property = "maxim,suspend-fps-power-down-slot",
105 struct pinctrl_dev *pctl; member
106 struct regmap *rmap;
150 FUNCTION_GROUP("lpm-control-in", LOW_POWER_MODE_CONTROL_IN),
151 FUNCTION_GROUP("fps-out", FLEXIBLE_POWER_SEQUENCER_OUT),
152 FUNCTION_GROUP("32k-out1", 32K_OUT1),
153 FUNCTION_GROUP("sd0-dvs-in", SD0_DYNAMIC_VOLTAGE_SCALING_IN),
154 FUNCTION_GROUP("sd1-dvs-in", SD1_DYNAMIC_VOLTAGE_SCALING_IN),
155 FUNCTION_GROUP("reference-out", REFERENCE_OUT),
181 return mpci->num_pin_groups; in max77620_pinctrl_get_groups_count()
189 return mpci->pin_groups[group].name; in max77620_pinctrl_get_group_name()
198 *pins = mpci->pin_groups[group].pins; in max77620_pinctrl_get_group_pins()
199 *num_pins = mpci->pin_groups[group].npins; in max77620_pinctrl_get_group_pins()
216 return mpci->num_functions; in max77620_pinctrl_get_funcs_count()
224 return mpci->functions[function].name; in max77620_pinctrl_get_func_name()
234 *groups = mpci->functions[function].groups; in max77620_pinctrl_get_func_groups()
235 *num_groups = mpci->functions[function].ngroups; in max77620_pinctrl_get_func_groups()
249 } else if (function == mpci->pin_groups[group].alt_option) { in max77620_pinctrl_enable()
252 dev_err(mpci->dev, "GPIO %u doesn't have function %u\n", in max77620_pinctrl_enable()
254 return -EINVAL; in max77620_pinctrl_enable()
256 ret = regmap_update_bits(mpci->rmap, MAX77620_REG_AME_GPIO, in max77620_pinctrl_enable()
259 dev_err(mpci->dev, "REG AME GPIO update failed: %d\n", ret); in max77620_pinctrl_enable()
275 struct device *dev = mpci->dev; in max77620_pinconf_get()
283 if (mpci->pin_info[pin].drv_type == MAX77620_PIN_OD_DRV) in max77620_pinconf_get()
288 if (mpci->pin_info[pin].drv_type == MAX77620_PIN_PP_DRV) in max77620_pinconf_get()
293 ret = regmap_read(mpci->rmap, MAX77620_REG_PUE_GPIO, &val); in max77620_pinconf_get()
303 ret = regmap_read(mpci->rmap, MAX77620_REG_PDE_GPIO, &val); in max77620_pinconf_get()
314 return -ENOTSUPP; in max77620_pinconf_get()
328 ret = regmap_read(mpci->rmap, addr, &val); in max77620_get_default_fps()
330 dev_err(mpci->dev, "Reg PUE_GPIO read failed: %d\n", ret); in max77620_get_default_fps()
341 struct max77620_fps_config *fps_config = &mpci->fps_config[pin]; in max77620_set_fps_param()
349 addr = MAX77620_REG_FPS_GPIO1 + pin - 1; in max77620_set_fps_param()
355 param_val = fps_config->active_fps_src; in max77620_set_fps_param()
357 param_val = fps_config->suspend_fps_src; in max77620_set_fps_param()
364 param_val = fps_config->active_power_up_slots; in max77620_set_fps_param()
366 param_val = fps_config->suspend_power_up_slots; in max77620_set_fps_param()
373 param_val = fps_config->active_power_down_slots; in max77620_set_fps_param()
375 param_val = fps_config->suspend_power_down_slots; in max77620_set_fps_param()
379 dev_err(mpci->dev, "Invalid parameter %d for pin %d\n", in max77620_set_fps_param()
381 return -EINVAL; in max77620_set_fps_param()
387 ret = regmap_update_bits(mpci->rmap, addr, mask, param_val << shift); in max77620_set_fps_param()
389 dev_err(mpci->dev, "Reg 0x%02x update failed %d\n", addr, ret); in max77620_set_fps_param()
399 struct device *dev = mpci->dev; in max77620_pinconf_set()
416 ret = regmap_update_bits(mpci->rmap, in max77620_pinconf_set()
423 mpci->pin_info[pin].drv_type = val ? in max77620_pinconf_set()
429 ret = regmap_update_bits(mpci->rmap, in max77620_pinconf_set()
436 mpci->pin_info[pin].drv_type = val ? in max77620_pinconf_set()
444 return -EINVAL; in max77620_pinconf_set()
446 fps_config = &mpci->fps_config[pin]; in max77620_pinconf_set()
450 addr = MAX77620_REG_FPS_GPIO1 + pin - 1; in max77620_pinconf_set()
453 &fps_config->active_fps_src); in max77620_pinconf_set()
460 fps_config->active_fps_src = param_val; in max77620_pinconf_set()
462 fps_config->active_power_up_slots = param_val; in max77620_pinconf_set()
464 fps_config->active_power_down_slots = param_val; in max77620_pinconf_set()
475 return -EINVAL; in max77620_pinconf_set()
477 fps_config = &mpci->fps_config[pin]; in max77620_pinconf_set()
481 addr = MAX77620_REG_FPS_GPIO1 + pin - 1; in max77620_pinconf_set()
484 &fps_config->suspend_fps_src); in max77620_pinconf_set()
491 fps_config->suspend_fps_src = param_val; in max77620_pinconf_set()
493 fps_config->suspend_power_up_slots = param_val; in max77620_pinconf_set()
495 fps_config->suspend_power_down_slots = in max77620_pinconf_set()
506 ret = regmap_update_bits(mpci->rmap, in max77620_pinconf_set()
515 ret = regmap_update_bits(mpci->rmap, in max77620_pinconf_set()
527 return -ENOTSUPP; in max77620_pinconf_set()
552 struct max77620_chip *max77620 = dev_get_drvdata(pdev->dev.parent); in max77620_pinctrl_probe()
556 device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent)); in max77620_pinctrl_probe()
558 mpci = devm_kzalloc(&pdev->dev, sizeof(*mpci), GFP_KERNEL); in max77620_pinctrl_probe()
560 return -ENOMEM; in max77620_pinctrl_probe()
562 mpci->dev = &pdev->dev; in max77620_pinctrl_probe()
563 mpci->rmap = max77620->rmap; in max77620_pinctrl_probe()
565 mpci->pins = max77620_pins_desc; in max77620_pinctrl_probe()
566 mpci->num_pins = ARRAY_SIZE(max77620_pins_desc); in max77620_pinctrl_probe()
567 mpci->functions = max77620_pin_function; in max77620_pinctrl_probe()
568 mpci->num_functions = ARRAY_SIZE(max77620_pin_function); in max77620_pinctrl_probe()
569 mpci->pin_groups = max77620_pingroups; in max77620_pinctrl_probe()
570 mpci->num_pin_groups = ARRAY_SIZE(max77620_pingroups); in max77620_pinctrl_probe()
573 max77620_pinctrl_desc.name = dev_name(&pdev->dev); in max77620_pinctrl_probe()
581 mpci->fps_config[i].active_fps_src = -1; in max77620_pinctrl_probe()
582 mpci->fps_config[i].active_power_up_slots = -1; in max77620_pinctrl_probe()
583 mpci->fps_config[i].active_power_down_slots = -1; in max77620_pinctrl_probe()
584 mpci->fps_config[i].suspend_fps_src = -1; in max77620_pinctrl_probe()
585 mpci->fps_config[i].suspend_power_up_slots = -1; in max77620_pinctrl_probe()
586 mpci->fps_config[i].suspend_power_down_slots = -1; in max77620_pinctrl_probe()
589 mpci->pctl = devm_pinctrl_register(&pdev->dev, &max77620_pinctrl_desc, in max77620_pinctrl_probe()
591 if (IS_ERR(mpci->pctl)) { in max77620_pinctrl_probe()
592 dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); in max77620_pinctrl_probe()
593 return PTR_ERR(mpci->pctl); in max77620_pinctrl_probe()
651 { .name = "max77620-pinctrl", },
652 { .name = "max20024-pinctrl", },
659 .name = "max77620-pinctrl",