Lines Matching refs:pctl
120 struct axp20x_pctl *pctl = gpiochip_get_data(chip); in axp20x_gpio_get() local
124 ret = regmap_read(pctl->regmap, AXP20X_GPIO20_SS, &val); in axp20x_gpio_get()
128 return !!(val & BIT(offset + pctl->desc->gpio_status_offset)); in axp20x_gpio_get()
134 struct axp20x_pctl *pctl = gpiochip_get_data(chip); in axp20x_gpio_get_direction() local
142 ret = regmap_read(pctl->regmap, reg, &val); in axp20x_gpio_get_direction()
172 struct axp20x_pctl *pctl = gpiochip_get_data(chip); in axp20x_gpio_set() local
179 regmap_update_bits(pctl->regmap, reg, in axp20x_gpio_set()
188 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_set() local
195 return regmap_update_bits(pctl->regmap, reg, AXP20X_GPIO_FUNCTIONS, in axp20x_pmx_set()
201 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_func_cnt() local
203 return ARRAY_SIZE(pctl->funcs); in axp20x_pmx_func_cnt()
209 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_func_name() local
211 return pctl->funcs[selector].name; in axp20x_pmx_func_name()
219 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_func_groups() local
221 *groups = pctl->funcs[selector].groups; in axp20x_pmx_func_groups()
222 *num_groups = pctl->funcs[selector].ngroups; in axp20x_pmx_func_groups()
230 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_set_mux() local
236 pctl->funcs[function].muxval); in axp20x_pmx_set_mux()
239 mask = pctl->desc->ldo_mask; in axp20x_pmx_set_mux()
241 mask = pctl->desc->adc_mask; in axp20x_pmx_set_mux()
255 return axp20x_pmx_set(pctldev, group, pctl->funcs[function].muxval); in axp20x_pmx_set_mux()
262 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_gpio_set_direction() local
266 pctl->funcs[AXP20X_FUNC_GPIO_IN].muxval); in axp20x_pmx_gpio_set_direction()
269 pctl->funcs[AXP20X_FUNC_GPIO_OUT].muxval); in axp20x_pmx_gpio_set_direction()
283 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_groups_cnt() local
285 return pctl->desc->npins; in axp20x_groups_cnt()
291 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_group_pins() local
293 *pins = (unsigned int *)&pctl->desc->pins[selector]; in axp20x_group_pins()
302 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_group_name() local
304 return pctl->desc->pins[selector].name; in axp20x_group_name()
344 struct axp20x_pctl *pctl = platform_get_drvdata(pdev); in axp20x_build_funcs_groups() local
345 int i, ret, pin, npins = pctl->desc->npins; in axp20x_build_funcs_groups()
347 pctl->funcs[AXP20X_FUNC_GPIO_OUT].name = "gpio_out"; in axp20x_build_funcs_groups()
348 pctl->funcs[AXP20X_FUNC_GPIO_OUT].muxval = AXP20X_MUX_GPIO_OUT; in axp20x_build_funcs_groups()
349 pctl->funcs[AXP20X_FUNC_GPIO_IN].name = "gpio_in"; in axp20x_build_funcs_groups()
350 pctl->funcs[AXP20X_FUNC_GPIO_IN].muxval = AXP20X_MUX_GPIO_IN; in axp20x_build_funcs_groups()
351 pctl->funcs[AXP20X_FUNC_LDO].name = "ldo"; in axp20x_build_funcs_groups()
356 pctl->funcs[AXP20X_FUNC_ADC].name = "adc"; in axp20x_build_funcs_groups()
357 pctl->funcs[AXP20X_FUNC_ADC].muxval = pctl->desc->adc_mux; in axp20x_build_funcs_groups()
361 pctl->funcs[i].ngroups = npins; in axp20x_build_funcs_groups()
362 pctl->funcs[i].groups = devm_kcalloc(&pdev->dev, in axp20x_build_funcs_groups()
365 if (!pctl->funcs[i].groups) in axp20x_build_funcs_groups()
368 pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name; in axp20x_build_funcs_groups()
371 ret = axp20x_funcs_groups_from_mask(&pdev->dev, pctl->desc->ldo_mask, in axp20x_build_funcs_groups()
372 npins, &pctl->funcs[AXP20X_FUNC_LDO], in axp20x_build_funcs_groups()
373 pctl->desc->pins); in axp20x_build_funcs_groups()
377 ret = axp20x_funcs_groups_from_mask(&pdev->dev, pctl->desc->adc_mask, in axp20x_build_funcs_groups()
378 npins, &pctl->funcs[AXP20X_FUNC_ADC], in axp20x_build_funcs_groups()
379 pctl->desc->pins); in axp20x_build_funcs_groups()
396 struct axp20x_pctl *pctl; in axp20x_pctl_probe() local
409 pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL); in axp20x_pctl_probe()
410 if (!pctl) in axp20x_pctl_probe()
413 pctl->chip.base = -1; in axp20x_pctl_probe()
414 pctl->chip.can_sleep = true; in axp20x_pctl_probe()
415 pctl->chip.request = gpiochip_generic_request; in axp20x_pctl_probe()
416 pctl->chip.free = gpiochip_generic_free; in axp20x_pctl_probe()
417 pctl->chip.parent = &pdev->dev; in axp20x_pctl_probe()
418 pctl->chip.label = dev_name(&pdev->dev); in axp20x_pctl_probe()
419 pctl->chip.owner = THIS_MODULE; in axp20x_pctl_probe()
420 pctl->chip.get = axp20x_gpio_get; in axp20x_pctl_probe()
421 pctl->chip.get_direction = axp20x_gpio_get_direction; in axp20x_pctl_probe()
422 pctl->chip.set = axp20x_gpio_set; in axp20x_pctl_probe()
423 pctl->chip.direction_input = axp20x_gpio_input; in axp20x_pctl_probe()
424 pctl->chip.direction_output = axp20x_gpio_output; in axp20x_pctl_probe()
426 pctl->desc = of_device_get_match_data(dev); in axp20x_pctl_probe()
428 pctl->chip.ngpio = pctl->desc->npins; in axp20x_pctl_probe()
430 pctl->regmap = axp20x->regmap; in axp20x_pctl_probe()
431 pctl->dev = &pdev->dev; in axp20x_pctl_probe()
433 platform_set_drvdata(pdev, pctl); in axp20x_pctl_probe()
447 pctrl_desc->pins = pctl->desc->pins; in axp20x_pctl_probe()
448 pctrl_desc->npins = pctl->desc->npins; in axp20x_pctl_probe()
452 pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, pctl); in axp20x_pctl_probe()
453 if (IS_ERR(pctl->pctl_dev)) { in axp20x_pctl_probe()
455 return PTR_ERR(pctl->pctl_dev); in axp20x_pctl_probe()
458 ret = devm_gpiochip_add_data(&pdev->dev, &pctl->chip, pctl); in axp20x_pctl_probe()
464 ret = gpiochip_add_pin_range(&pctl->chip, dev_name(&pdev->dev), in axp20x_pctl_probe()
465 pctl->desc->pins->number, in axp20x_pctl_probe()
466 pctl->desc->pins->number, in axp20x_pctl_probe()
467 pctl->desc->npins); in axp20x_pctl_probe()