Lines Matching +full:single +full:- +full:chip
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2016-2018 Cirrus Logic
17 #include <linux/pinctrl/pinconf-generic.h>
22 #include "../pinctrl-utils.h"
24 #include "pinctrl-madera.h"
28 * NOTE: IDs are zero-indexed for coding convenience
74 * All single-pin functions can be mapped to any GPIO, however pinmux applies
78 * Since these do not correspond to anything in the actual hardware - they are
79 * merely an adaptation to pinctrl's view of the world - we use the same name
91 /* set of pin numbers for single-pin groups, zero-indexed */
116 * alt-functions always apply to a single pin group, other functions always
195 .name = "dsp-gpio",
210 .name = "fll1-clk",
215 .name = "fll2-clk",
220 .name = "fll3-clk",
225 .name = "fllao-clk",
230 .name = "fll1-lock",
235 .name = "fll2-lock",
240 .name = "fll3-lock",
245 .name = "fllao-lock",
255 .name = "opclk-async",
275 .name = "asrc1-in1-lock",
280 .name = "asrc1-in2-lock",
285 .name = "asrc2-in1-lock",
290 .name = "asrc2-in2-lock",
295 .name = "spkl-short-circuit",
300 .name = "spkr-short-circuit",
305 .name = "spk-shutdown",
310 .name = "spk-overheat-shutdown",
315 .name = "spk-overheat-warn",
320 .name = "timer1-sts",
325 .name = "timer2-sts",
330 .name = "timer3-sts",
335 .name = "timer4-sts",
340 .name = "timer5-sts",
345 .name = "timer6-sts",
350 .name = "timer7-sts",
355 .name = "timer8-sts",
360 .name = "log1-fifo-ne",
365 .name = "log2-fifo-ne",
370 .name = "log3-fifo-ne",
375 .name = "log4-fifo-ne",
380 .name = "log5-fifo-ne",
385 .name = "log6-fifo-ne",
390 .name = "log7-fifo-ne",
395 .name = "log8-fifo-ne",
400 .name = "aux-pdm-clk",
405 .name = "aux-pdm-dat",
423 dev_warn(priv->dev, "%u mA not a valid drive strength", milliamps); in madera_pin_make_drv_str()
447 /* Number of alt function groups plus number of single-pin groups */ in madera_get_groups_count()
448 return priv->chip->n_pin_groups + priv->chip->n_pins; in madera_get_groups_count()
456 if (selector < priv->chip->n_pin_groups) in madera_get_group_name()
457 return priv->chip->pin_groups[selector].name; in madera_get_group_name()
459 selector -= priv->chip->n_pin_groups; in madera_get_group_name()
470 if (selector < priv->chip->n_pin_groups) { in madera_get_group_pins()
471 *pins = priv->chip->pin_groups[selector].pins; in madera_get_group_pins()
472 *num_pins = priv->chip->pin_groups[selector].n_pins; in madera_get_group_pins()
474 /* return the dummy group for a single pin */ in madera_get_group_pins()
475 selector -= priv->chip->n_pin_groups; in madera_get_group_pins()
486 const struct madera_pin_chip *chip = priv->chip; in madera_pin_dbg_show_fn() local
501 for (i = 0; i < chip->n_pin_groups; ++i) { in madera_pin_dbg_show_fn()
502 for (g_pin = 0; g_pin < chip->pin_groups[i].n_pins; ++g_pin) { in madera_pin_dbg_show_fn()
503 if (chip->pin_groups[i].pins[g_pin] == pin) { in madera_pin_dbg_show_fn()
505 chip->pin_groups[i].name); in madera_pin_dbg_show_fn()
522 ret = regmap_read(priv->madera->regmap, reg, &conf[0]); in madera_pin_dbg_show()
526 ret = regmap_read(priv->madera->regmap, reg + 1, &conf[1]); in madera_pin_dbg_show()
597 /* alt func always maps to a single group */ in madera_mux_get_groups()
601 *num_groups = priv->chip->n_pins; in madera_mux_get_groups()
612 struct madera *madera = priv->madera; in madera_mux_set_mux()
613 const struct madera_pin_groups *pin_group = priv->chip->pin_groups; in madera_mux_set_mux()
614 unsigned int n_chip_groups = priv->chip->n_pin_groups; in madera_mux_set_mux()
619 dev_dbg(priv->dev, "%s selecting %u (%s) for group %u (%s)\n", in madera_mux_set_mux()
624 /* alt func pin assignments are codec-specific */ in madera_mux_set_mux()
626 if (strcmp(func_name, pin_group->name) == 0) in madera_mux_set_mux()
633 return -EINVAL; in madera_mux_set_mux()
635 for (i = 0; i < pin_group->n_pins; ++i) { in madera_mux_set_mux()
636 reg = MADERA_GPIO1_CTRL_1 + (2 * pin_group->pins[i]); in madera_mux_set_mux()
638 dev_dbg(priv->dev, "%s setting 0x%x func bits to 0\n", in madera_mux_set_mux()
641 ret = regmap_update_bits(madera->regmap, reg, in madera_mux_set_mux()
650 * be offset by the number of chip-specific functions at the in madera_mux_set_mux()
653 group -= n_chip_groups; in madera_mux_set_mux()
656 dev_dbg(priv->dev, "%s setting 0x%x func bits to 0x%x\n", in madera_mux_set_mux()
659 ret = regmap_update_bits(madera->regmap, in madera_mux_set_mux()
666 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret); in madera_mux_set_mux()
677 struct madera *madera = priv->madera; in madera_gpio_set_direction()
687 ret = regmap_update_bits(madera->regmap, reg, MADERA_GP1_DIR_MASK, val); in madera_gpio_set_direction()
689 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret); in madera_gpio_set_direction()
699 struct madera *madera = priv->madera; in madera_gpio_request_enable()
704 ret = regmap_update_bits(madera->regmap, reg, MADERA_GP1_FN_MASK, 1); in madera_gpio_request_enable()
706 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret); in madera_gpio_request_enable()
716 struct madera *madera = priv->madera; in madera_gpio_disable_free()
723 ret = regmap_update_bits(madera->regmap, reg, MADERA_GP1_FN_MASK, 1); in madera_gpio_disable_free()
725 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret); in madera_gpio_disable_free()
749 ret = regmap_read(priv->madera->regmap, reg, &conf[0]); in madera_pin_conf_get()
751 ret = regmap_read(priv->madera->regmap, reg + 1, &conf[1]); in madera_pin_conf_get()
754 dev_err(priv->dev, "Failed to read GP%d conf (%d)\n", in madera_pin_conf_get()
810 return -ENOTSUPP; in madera_pin_conf_get()
829 dev_dbg(priv->dev, "%s config 0x%lx\n", __func__, *configs); in madera_pin_conf_set()
868 * we can't configure debounce time per-pin so value in madera_pin_conf_set()
914 return -ENOTSUPP; in madera_pin_conf_set()
918 --num_configs; in madera_pin_conf_set()
921 dev_dbg(priv->dev, in madera_pin_conf_set()
925 ret = regmap_update_bits(priv->madera->regmap, reg, mask[0], conf[0]); in madera_pin_conf_set()
930 ret = regmap_update_bits(priv->madera->regmap, reg, mask[1], conf[1]); in madera_pin_conf_set()
937 dev_err(priv->dev, in madera_pin_conf_set()
951 unsigned int n_groups = priv->chip->n_pin_groups; in madera_pin_conf_group_set()
954 dev_dbg(priv->dev, "%s setting group %s\n", __func__, in madera_pin_conf_group_set()
958 /* group is a single pin, convert to pin number and set */ in madera_pin_conf_group_set()
960 selector - n_groups, in madera_pin_conf_group_set()
964 pin_group = &priv->chip->pin_groups[selector]; in madera_pin_conf_group_set()
966 for (i = 0; i < pin_group->n_pins; ++i) { in madera_pin_conf_group_set()
968 pin_group->pins[i], in madera_pin_conf_group_set()
987 .name = "madera-pinctrl",
997 struct madera *madera = dev_get_drvdata(pdev->dev.parent); in madera_pin_probe()
998 const struct madera_pdata *pdata = &madera->pdata; in madera_pin_probe()
1005 dev_dbg(&pdev->dev, "%s\n", __func__); in madera_pin_probe()
1007 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in madera_pin_probe()
1009 return -ENOMEM; in madera_pin_probe()
1011 priv->dev = &pdev->dev; in madera_pin_probe()
1012 priv->madera = madera; in madera_pin_probe()
1013 pdev->dev.of_node = madera->dev->of_node; in madera_pin_probe()
1015 switch (madera->type) { in madera_pin_probe()
1018 priv->chip = &cs47l15_pin_chip; in madera_pin_probe()
1022 priv->chip = &cs47l35_pin_chip; in madera_pin_probe()
1027 priv->chip = &cs47l85_pin_chip; in madera_pin_probe()
1032 priv->chip = &cs47l90_pin_chip; in madera_pin_probe()
1038 priv->chip = &cs47l92_pin_chip; in madera_pin_probe()
1044 if (!priv->chip) in madera_pin_probe()
1045 return -ENODEV; in madera_pin_probe()
1047 madera_pin_desc.npins = priv->chip->n_pins; in madera_pin_probe()
1049 ret = devm_pinctrl_register_and_init(&pdev->dev, in madera_pin_probe()
1052 &priv->pctl); in madera_pin_probe()
1054 dev_err(priv->dev, "Failed pinctrl register (%d)\n", ret); in madera_pin_probe()
1059 if (pdata->gpio_configs) { in madera_pin_probe()
1060 ret = pinctrl_register_mappings(pdata->gpio_configs, in madera_pin_probe()
1061 pdata->n_gpio_configs); in madera_pin_probe()
1063 dev_err(priv->dev, in madera_pin_probe()
1070 ret = pinctrl_enable(priv->pctl); in madera_pin_probe()
1072 dev_err(priv->dev, "Failed to enable pinctrl (%d)\n", ret); in madera_pin_probe()
1078 dev_dbg(priv->dev, "pinctrl probed ok\n"); in madera_pin_probe()
1087 if (priv->madera->pdata.gpio_configs) in madera_pin_remove()
1088 pinctrl_unregister_mappings(priv->madera->pdata.gpio_configs); in madera_pin_remove()
1097 .name = "madera-pinctrl",