Lines Matching full:pctl
129 struct axp20x_pctl *pctl = gpiochip_get_data(chip); in axp20x_gpio_get() local
135 ret = regmap_read(pctl->regmap, AXP20X_GPIO3_CTRL, &val); in axp20x_gpio_get()
141 ret = regmap_read(pctl->regmap, AXP20X_GPIO20_SS, &val); in axp20x_gpio_get()
145 return !!(val & BIT(offset + pctl->desc->gpio_status_offset)); in axp20x_gpio_get()
151 struct axp20x_pctl *pctl = gpiochip_get_data(chip); in axp20x_gpio_get_direction() local
157 ret = regmap_read(pctl->regmap, AXP20X_GPIO3_CTRL, &val); in axp20x_gpio_get_direction()
170 ret = regmap_read(pctl->regmap, reg, &val); in axp20x_gpio_get_direction()
203 struct axp20x_pctl *pctl = gpiochip_get_data(chip); in axp20x_gpio_set() local
208 regmap_update_bits(pctl->regmap, AXP20X_GPIO3_CTRL, in axp20x_gpio_set()
219 regmap_update_bits(pctl->regmap, reg, in axp20x_gpio_set()
228 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_set() local
233 return regmap_update_bits(pctl->regmap, AXP20X_GPIO3_CTRL, in axp20x_pmx_set()
243 return regmap_update_bits(pctl->regmap, reg, AXP20X_GPIO_FUNCTIONS, in axp20x_pmx_set()
249 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_func_cnt() local
251 return ARRAY_SIZE(pctl->funcs); in axp20x_pmx_func_cnt()
257 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_func_name() local
259 return pctl->funcs[selector].name; in axp20x_pmx_func_name()
267 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_func_groups() local
269 *groups = pctl->funcs[selector].groups; in axp20x_pmx_func_groups()
270 *num_groups = pctl->funcs[selector].ngroups; in axp20x_pmx_func_groups()
278 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_set_mux() local
284 pctl->funcs[function].muxval); in axp20x_pmx_set_mux()
287 mask = pctl->desc->ldo_mask; in axp20x_pmx_set_mux()
289 mask = pctl->desc->adc_mask; in axp20x_pmx_set_mux()
303 return axp20x_pmx_set(pctldev, group, pctl->funcs[function].muxval); in axp20x_pmx_set_mux()
310 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_pmx_gpio_set_direction() local
314 pctl->funcs[AXP20X_FUNC_GPIO_IN].muxval); in axp20x_pmx_gpio_set_direction()
317 pctl->funcs[AXP20X_FUNC_GPIO_OUT].muxval); in axp20x_pmx_gpio_set_direction()
331 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_groups_cnt() local
333 return pctl->desc->npins; in axp20x_groups_cnt()
339 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_group_pins() local
341 *pins = (unsigned int *)&pctl->desc->pins[selector]; in axp20x_group_pins()
350 struct axp20x_pctl *pctl = pinctrl_dev_get_drvdata(pctldev); in axp20x_group_name() local
352 return pctl->desc->pins[selector].name; in axp20x_group_name()
392 struct axp20x_pctl *pctl = platform_get_drvdata(pdev); in axp20x_build_funcs_groups() local
393 int i, ret, pin, npins = pctl->desc->npins; in axp20x_build_funcs_groups()
395 pctl->funcs[AXP20X_FUNC_GPIO_OUT].name = "gpio_out"; in axp20x_build_funcs_groups()
396 pctl->funcs[AXP20X_FUNC_GPIO_OUT].muxval = AXP20X_MUX_GPIO_OUT; in axp20x_build_funcs_groups()
397 pctl->funcs[AXP20X_FUNC_GPIO_IN].name = "gpio_in"; in axp20x_build_funcs_groups()
398 pctl->funcs[AXP20X_FUNC_GPIO_IN].muxval = AXP20X_MUX_GPIO_IN; in axp20x_build_funcs_groups()
399 pctl->funcs[AXP20X_FUNC_LDO].name = "ldo"; in axp20x_build_funcs_groups()
404 pctl->funcs[AXP20X_FUNC_ADC].name = "adc"; in axp20x_build_funcs_groups()
405 pctl->funcs[AXP20X_FUNC_ADC].muxval = pctl->desc->adc_mux; in axp20x_build_funcs_groups()
409 pctl->funcs[i].ngroups = npins; in axp20x_build_funcs_groups()
410 pctl->funcs[i].groups = devm_kcalloc(&pdev->dev, in axp20x_build_funcs_groups()
413 if (!pctl->funcs[i].groups) in axp20x_build_funcs_groups()
416 pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name; in axp20x_build_funcs_groups()
419 ret = axp20x_funcs_groups_from_mask(&pdev->dev, pctl->desc->ldo_mask, in axp20x_build_funcs_groups()
420 npins, &pctl->funcs[AXP20X_FUNC_LDO], in axp20x_build_funcs_groups()
421 pctl->desc->pins); in axp20x_build_funcs_groups()
425 ret = axp20x_funcs_groups_from_mask(&pdev->dev, pctl->desc->adc_mask, in axp20x_build_funcs_groups()
426 npins, &pctl->funcs[AXP20X_FUNC_ADC], in axp20x_build_funcs_groups()
427 pctl->desc->pins); in axp20x_build_funcs_groups()
445 struct axp20x_pctl *pctl; in axp20x_pctl_probe() local
458 pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL); in axp20x_pctl_probe()
459 if (!pctl) in axp20x_pctl_probe()
462 pctl->chip.base = -1; in axp20x_pctl_probe()
463 pctl->chip.can_sleep = true; in axp20x_pctl_probe()
464 pctl->chip.request = gpiochip_generic_request; in axp20x_pctl_probe()
465 pctl->chip.free = gpiochip_generic_free; in axp20x_pctl_probe()
466 pctl->chip.parent = &pdev->dev; in axp20x_pctl_probe()
467 pctl->chip.label = dev_name(&pdev->dev); in axp20x_pctl_probe()
468 pctl->chip.owner = THIS_MODULE; in axp20x_pctl_probe()
469 pctl->chip.get = axp20x_gpio_get; in axp20x_pctl_probe()
470 pctl->chip.get_direction = axp20x_gpio_get_direction; in axp20x_pctl_probe()
471 pctl->chip.set = axp20x_gpio_set; in axp20x_pctl_probe()
472 pctl->chip.direction_input = pinctrl_gpio_direction_input; in axp20x_pctl_probe()
473 pctl->chip.direction_output = axp20x_gpio_output; in axp20x_pctl_probe()
475 pctl->desc = of_device_get_match_data(dev); in axp20x_pctl_probe()
477 pctl->chip.ngpio = pctl->desc->npins; in axp20x_pctl_probe()
479 pctl->regmap = axp20x->regmap; in axp20x_pctl_probe()
480 pctl->dev = &pdev->dev; in axp20x_pctl_probe()
482 platform_set_drvdata(pdev, pctl); in axp20x_pctl_probe()
496 pctrl_desc->pins = pctl->desc->pins; in axp20x_pctl_probe()
497 pctrl_desc->npins = pctl->desc->npins; in axp20x_pctl_probe()
501 pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, pctl); in axp20x_pctl_probe()
502 if (IS_ERR(pctl->pctl_dev)) { in axp20x_pctl_probe()
504 return PTR_ERR(pctl->pctl_dev); in axp20x_pctl_probe()
507 ret = devm_gpiochip_add_data(&pdev->dev, &pctl->chip, pctl); in axp20x_pctl_probe()
513 ret = gpiochip_add_pin_range(&pctl->chip, dev_name(&pdev->dev), in axp20x_pctl_probe()
514 pctl->desc->pins->number, in axp20x_pctl_probe()
515 pctl->desc->pins->number, in axp20x_pctl_probe()
516 pctl->desc->npins); in axp20x_pctl_probe()