Lines Matching full:pctrl
65 struct lpi_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in lpi_gpio_get_functions_count() local
67 return pctrl->data->nfunctions; in lpi_gpio_get_functions_count()
73 struct lpi_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in lpi_gpio_get_function_name() local
75 return pctrl->data->functions[function].name; in lpi_gpio_get_function_name()
83 struct lpi_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in lpi_gpio_get_function_groups() local
85 *groups = pctrl->data->functions[function].groups; in lpi_gpio_get_function_groups()
86 *num_qgroups = pctrl->data->functions[function].ngroups; in lpi_gpio_get_function_groups()
94 struct lpi_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in lpi_gpio_set_mux() local
95 const struct lpi_pingroup *g = &pctrl->data->groups[group]; in lpi_gpio_set_mux()
107 mutex_lock(&pctrl->lock); in lpi_gpio_set_mux()
108 val = lpi_gpio_read(pctrl, pin, LPI_GPIO_CFG_REG); in lpi_gpio_set_mux()
117 !test_and_set_bit(group, pctrl->ever_gpio)) { in lpi_gpio_set_mux()
118 u32 io_val = lpi_gpio_read(pctrl, group, LPI_GPIO_VALUE_REG); in lpi_gpio_set_mux()
122 lpi_gpio_write(pctrl, group, LPI_GPIO_VALUE_REG, in lpi_gpio_set_mux()
126 lpi_gpio_write(pctrl, group, LPI_GPIO_VALUE_REG, in lpi_gpio_set_mux()
132 lpi_gpio_write(pctrl, pin, LPI_GPIO_CFG_REG, val); in lpi_gpio_set_mux()
133 mutex_unlock(&pctrl->lock); in lpi_gpio_set_mux()
189 static int lpi_config_set_slew_rate(struct lpi_pinctrl *pctrl, in lpi_config_set_slew_rate() argument
198 dev_err(pctrl->dev, "invalid slew rate %u for pin: %d\n", in lpi_config_set_slew_rate()
207 if (pctrl->data->flags & LPI_FLAG_SLEW_RATE_SAME_REG) in lpi_config_set_slew_rate()
208 reg = pctrl->tlmm_base + LPI_TLMM_REG_OFFSET * group + LPI_GPIO_CFG_REG; in lpi_config_set_slew_rate()
210 reg = pctrl->slew_base + LPI_SLEW_RATE_CTL_REG; in lpi_config_set_slew_rate()
212 mutex_lock(&pctrl->lock); in lpi_config_set_slew_rate()
219 mutex_unlock(&pctrl->lock); in lpi_config_set_slew_rate()
227 struct lpi_pinctrl *pctrl = dev_get_drvdata(pctldev->dev); in lpi_config_set() local
234 g = &pctrl->data->groups[group]; in lpi_config_set()
263 ret = lpi_config_set_slew_rate(pctrl, g, group, arg); in lpi_config_set()
278 lpi_gpio_write(pctrl, group, LPI_GPIO_VALUE_REG, val); in lpi_config_set()
281 mutex_lock(&pctrl->lock); in lpi_config_set()
282 val = lpi_gpio_read(pctrl, group, LPI_GPIO_CFG_REG); in lpi_config_set()
289 lpi_gpio_write(pctrl, group, LPI_GPIO_CFG_REG, val); in lpi_config_set()
290 mutex_unlock(&pctrl->lock); in lpi_config_set()
407 static int lpi_build_pin_desc_groups(struct lpi_pinctrl *pctrl) in lpi_build_pin_desc_groups() argument
411 for (i = 0; i < pctrl->data->npins; i++) { in lpi_build_pin_desc_groups()
412 const struct pinctrl_pin_desc *pin_info = pctrl->desc.pins + i; in lpi_build_pin_desc_groups()
414 ret = pinctrl_generic_add_group(pctrl->ctrl, pin_info->name, in lpi_build_pin_desc_groups()
424 pinctrl_generic_remove_group(pctrl->ctrl, i - 1); in lpi_build_pin_desc_groups()
433 struct lpi_pinctrl *pctrl; in lpi_pinctrl_probe() local
436 pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL); in lpi_pinctrl_probe()
437 if (!pctrl) in lpi_pinctrl_probe()
440 platform_set_drvdata(pdev, pctrl); in lpi_pinctrl_probe()
449 pctrl->data = data; in lpi_pinctrl_probe()
450 pctrl->dev = &pdev->dev; in lpi_pinctrl_probe()
452 pctrl->clks[0].id = "core"; in lpi_pinctrl_probe()
453 pctrl->clks[1].id = "audio"; in lpi_pinctrl_probe()
455 pctrl->tlmm_base = devm_platform_ioremap_resource(pdev, 0); in lpi_pinctrl_probe()
456 if (IS_ERR(pctrl->tlmm_base)) in lpi_pinctrl_probe()
457 return dev_err_probe(dev, PTR_ERR(pctrl->tlmm_base), in lpi_pinctrl_probe()
461 pctrl->slew_base = devm_platform_ioremap_resource(pdev, 1); in lpi_pinctrl_probe()
462 if (IS_ERR(pctrl->slew_base)) in lpi_pinctrl_probe()
463 return dev_err_probe(dev, PTR_ERR(pctrl->slew_base), in lpi_pinctrl_probe()
467 ret = devm_clk_bulk_get_optional(dev, MAX_LPI_NUM_CLKS, pctrl->clks); in lpi_pinctrl_probe()
471 ret = clk_bulk_prepare_enable(MAX_LPI_NUM_CLKS, pctrl->clks); in lpi_pinctrl_probe()
475 pctrl->desc.pctlops = &lpi_gpio_pinctrl_ops; in lpi_pinctrl_probe()
476 pctrl->desc.pmxops = &lpi_gpio_pinmux_ops; in lpi_pinctrl_probe()
477 pctrl->desc.confops = &lpi_gpio_pinconf_ops; in lpi_pinctrl_probe()
478 pctrl->desc.owner = THIS_MODULE; in lpi_pinctrl_probe()
479 pctrl->desc.name = dev_name(dev); in lpi_pinctrl_probe()
480 pctrl->desc.pins = data->pins; in lpi_pinctrl_probe()
481 pctrl->desc.npins = data->npins; in lpi_pinctrl_probe()
482 pctrl->chip = lpi_gpio_template; in lpi_pinctrl_probe()
483 pctrl->chip.parent = dev; in lpi_pinctrl_probe()
484 pctrl->chip.base = -1; in lpi_pinctrl_probe()
485 pctrl->chip.ngpio = data->npins; in lpi_pinctrl_probe()
486 pctrl->chip.label = dev_name(dev); in lpi_pinctrl_probe()
487 pctrl->chip.can_sleep = false; in lpi_pinctrl_probe()
489 mutex_init(&pctrl->lock); in lpi_pinctrl_probe()
491 pctrl->ctrl = devm_pinctrl_register(dev, &pctrl->desc, pctrl); in lpi_pinctrl_probe()
492 if (IS_ERR(pctrl->ctrl)) { in lpi_pinctrl_probe()
493 ret = PTR_ERR(pctrl->ctrl); in lpi_pinctrl_probe()
498 ret = lpi_build_pin_desc_groups(pctrl); in lpi_pinctrl_probe()
502 ret = devm_gpiochip_add_data(dev, &pctrl->chip, pctrl); in lpi_pinctrl_probe()
504 dev_err(pctrl->dev, "can't add gpio chip\n"); in lpi_pinctrl_probe()
511 mutex_destroy(&pctrl->lock); in lpi_pinctrl_probe()
512 clk_bulk_disable_unprepare(MAX_LPI_NUM_CLKS, pctrl->clks); in lpi_pinctrl_probe()
520 struct lpi_pinctrl *pctrl = platform_get_drvdata(pdev); in lpi_pinctrl_remove() local
523 mutex_destroy(&pctrl->lock); in lpi_pinctrl_remove()
524 clk_bulk_disable_unprepare(MAX_LPI_NUM_CLKS, pctrl->clks); in lpi_pinctrl_remove()
526 for (i = 0; i < pctrl->data->npins; i++) in lpi_pinctrl_remove()
527 pinctrl_generic_remove_group(pctrl->ctrl, i); in lpi_pinctrl_remove()