Lines Matching full:pctrl
55 struct lpi_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in lpi_gpio_get_functions_count() local
57 return pctrl->data->nfunctions; in lpi_gpio_get_functions_count()
63 struct lpi_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in lpi_gpio_get_function_name() local
65 return pctrl->data->functions[function].name; in lpi_gpio_get_function_name()
73 struct lpi_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in lpi_gpio_get_function_groups() local
75 *groups = pctrl->data->functions[function].groups; in lpi_gpio_get_function_groups()
76 *num_qgroups = pctrl->data->functions[function].ngroups; in lpi_gpio_get_function_groups()
84 struct lpi_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in lpi_gpio_set_mux() local
85 const struct lpi_pingroup *g = &pctrl->data->groups[group_num]; in lpi_gpio_set_mux()
97 val = lpi_gpio_read(pctrl, pin, LPI_GPIO_CFG_REG); in lpi_gpio_set_mux()
99 lpi_gpio_write(pctrl, pin, LPI_GPIO_CFG_REG, val); in lpi_gpio_set_mux()
158 struct lpi_pinctrl *pctrl = dev_get_drvdata(pctldev->dev); in lpi_config_set() local
166 g = &pctrl->data->groups[group]; in lpi_config_set()
205 mutex_lock(&pctrl->slew_access_lock); in lpi_config_set()
207 sval = ioread32(pctrl->slew_base + LPI_SLEW_RATE_CTL_REG); in lpi_config_set()
210 iowrite32(sval, pctrl->slew_base + LPI_SLEW_RATE_CTL_REG); in lpi_config_set()
212 mutex_unlock(&pctrl->slew_access_lock); in lpi_config_set()
219 val = lpi_gpio_read(pctrl, group, LPI_GPIO_CFG_REG); in lpi_config_set()
226 lpi_gpio_write(pctrl, group, LPI_GPIO_CFG_REG, val); in lpi_config_set()
230 lpi_gpio_write(pctrl, group, LPI_GPIO_VALUE_REG, val); in lpi_config_set()
349 static int lpi_build_pin_desc_groups(struct lpi_pinctrl *pctrl) in lpi_build_pin_desc_groups() argument
353 for (i = 0; i < pctrl->data->npins; i++) { in lpi_build_pin_desc_groups()
354 const struct pinctrl_pin_desc *pin_info = pctrl->desc.pins + i; in lpi_build_pin_desc_groups()
356 ret = pinctrl_generic_add_group(pctrl->ctrl, pin_info->name, in lpi_build_pin_desc_groups()
366 pinctrl_generic_remove_group(pctrl->ctrl, i - 1); in lpi_build_pin_desc_groups()
375 struct lpi_pinctrl *pctrl; in lpi_pinctrl_probe() local
378 pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL); in lpi_pinctrl_probe()
379 if (!pctrl) in lpi_pinctrl_probe()
382 platform_set_drvdata(pdev, pctrl); in lpi_pinctrl_probe()
388 pctrl->data = data; in lpi_pinctrl_probe()
389 pctrl->dev = &pdev->dev; in lpi_pinctrl_probe()
391 pctrl->clks[0].id = "core"; in lpi_pinctrl_probe()
392 pctrl->clks[1].id = "audio"; in lpi_pinctrl_probe()
394 pctrl->tlmm_base = devm_platform_ioremap_resource(pdev, 0); in lpi_pinctrl_probe()
395 if (IS_ERR(pctrl->tlmm_base)) in lpi_pinctrl_probe()
396 return dev_err_probe(dev, PTR_ERR(pctrl->tlmm_base), in lpi_pinctrl_probe()
399 pctrl->slew_base = devm_platform_ioremap_resource(pdev, 1); in lpi_pinctrl_probe()
400 if (IS_ERR(pctrl->slew_base)) in lpi_pinctrl_probe()
401 return dev_err_probe(dev, PTR_ERR(pctrl->slew_base), in lpi_pinctrl_probe()
405 ret = devm_clk_bulk_get_optional(dev, MAX_LPI_NUM_CLKS, pctrl->clks); in lpi_pinctrl_probe()
407 ret = devm_clk_bulk_get(dev, MAX_LPI_NUM_CLKS, pctrl->clks); in lpi_pinctrl_probe()
412 ret = clk_bulk_prepare_enable(MAX_LPI_NUM_CLKS, pctrl->clks); in lpi_pinctrl_probe()
416 pctrl->desc.pctlops = &lpi_gpio_pinctrl_ops; in lpi_pinctrl_probe()
417 pctrl->desc.pmxops = &lpi_gpio_pinmux_ops; in lpi_pinctrl_probe()
418 pctrl->desc.confops = &lpi_gpio_pinconf_ops; in lpi_pinctrl_probe()
419 pctrl->desc.owner = THIS_MODULE; in lpi_pinctrl_probe()
420 pctrl->desc.name = dev_name(dev); in lpi_pinctrl_probe()
421 pctrl->desc.pins = data->pins; in lpi_pinctrl_probe()
422 pctrl->desc.npins = data->npins; in lpi_pinctrl_probe()
423 pctrl->chip = lpi_gpio_template; in lpi_pinctrl_probe()
424 pctrl->chip.parent = dev; in lpi_pinctrl_probe()
425 pctrl->chip.base = -1; in lpi_pinctrl_probe()
426 pctrl->chip.ngpio = data->npins; in lpi_pinctrl_probe()
427 pctrl->chip.label = dev_name(dev); in lpi_pinctrl_probe()
428 pctrl->chip.of_gpio_n_cells = 2; in lpi_pinctrl_probe()
429 pctrl->chip.can_sleep = false; in lpi_pinctrl_probe()
431 mutex_init(&pctrl->slew_access_lock); in lpi_pinctrl_probe()
433 pctrl->ctrl = devm_pinctrl_register(dev, &pctrl->desc, pctrl); in lpi_pinctrl_probe()
434 if (IS_ERR(pctrl->ctrl)) { in lpi_pinctrl_probe()
435 ret = PTR_ERR(pctrl->ctrl); in lpi_pinctrl_probe()
440 ret = lpi_build_pin_desc_groups(pctrl); in lpi_pinctrl_probe()
444 ret = devm_gpiochip_add_data(dev, &pctrl->chip, pctrl); in lpi_pinctrl_probe()
446 dev_err(pctrl->dev, "can't add gpio chip\n"); in lpi_pinctrl_probe()
453 mutex_destroy(&pctrl->slew_access_lock); in lpi_pinctrl_probe()
454 clk_bulk_disable_unprepare(MAX_LPI_NUM_CLKS, pctrl->clks); in lpi_pinctrl_probe()
462 struct lpi_pinctrl *pctrl = platform_get_drvdata(pdev); in lpi_pinctrl_remove() local
465 mutex_destroy(&pctrl->slew_access_lock); in lpi_pinctrl_remove()
466 clk_bulk_disable_unprepare(MAX_LPI_NUM_CLKS, pctrl->clks); in lpi_pinctrl_remove()
468 for (i = 0; i < pctrl->data->npins; i++) in lpi_pinctrl_remove()
469 pinctrl_generic_remove_group(pctrl->ctrl, i); in lpi_pinctrl_remove()