Lines Matching +full:gp +full:- +full:pwm2

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2016-2018 Cirrus Logic
19 #include <linux/pinctrl/pinconf-generic.h>
24 #include "../pinctrl-utils.h"
26 #include "pinctrl-madera.h"
30 * NOTE: IDs are zero-indexed for coding convenience
76 * All single-pin functions can be mapped to any GPIO, however pinmux applies
80 * Since these do not correspond to anything in the actual hardware - they are
81 * merely an adaptation to pinctrl's view of the world - we use the same name
93 /* set of pin numbers for single-pin groups, zero-indexed */
118 * alt-functions always apply to a single pin group, other functions always
197 .name = "dsp-gpio",
212 .name = "fll1-clk",
217 .name = "fll2-clk",
222 .name = "fll3-clk",
227 .name = "fllao-clk",
232 .name = "fll1-lock",
237 .name = "fll2-lock",
242 .name = "fll3-lock",
247 .name = "fllao-lock",
257 .name = "opclk-async",
267 .name = "pwm2",
277 .name = "asrc1-in1-lock",
282 .name = "asrc1-in2-lock",
287 .name = "asrc2-in1-lock",
292 .name = "asrc2-in2-lock",
297 .name = "spkl-short-circuit",
302 .name = "spkr-short-circuit",
307 .name = "spk-shutdown",
312 .name = "spk-overheat-shutdown",
317 .name = "spk-overheat-warn",
322 .name = "timer1-sts",
327 .name = "timer2-sts",
332 .name = "timer3-sts",
337 .name = "timer4-sts",
342 .name = "timer5-sts",
347 .name = "timer6-sts",
352 .name = "timer7-sts",
357 .name = "timer8-sts",
362 .name = "log1-fifo-ne",
367 .name = "log2-fifo-ne",
372 .name = "log3-fifo-ne",
377 .name = "log4-fifo-ne",
382 .name = "log5-fifo-ne",
387 .name = "log6-fifo-ne",
392 .name = "log7-fifo-ne",
397 .name = "log8-fifo-ne",
402 .name = "aux-pdm-clk",
407 .name = "aux-pdm-dat",
425 dev_warn(priv->dev, "%u mA not a valid drive strength", milliamps); in madera_pin_make_drv_str()
449 /* Number of alt function groups plus number of single-pin groups */ in madera_get_groups_count()
450 return priv->chip->n_pin_groups + priv->chip->n_pins; in madera_get_groups_count()
458 if (selector < priv->chip->n_pin_groups) in madera_get_group_name()
459 return priv->chip->pin_groups[selector].name; in madera_get_group_name()
461 selector -= priv->chip->n_pin_groups; in madera_get_group_name()
472 if (selector < priv->chip->n_pin_groups) { in madera_get_group_pins()
473 *pins = priv->chip->pin_groups[selector].pins; in madera_get_group_pins()
474 *num_pins = priv->chip->pin_groups[selector].n_pins; in madera_get_group_pins()
477 selector -= priv->chip->n_pin_groups; in madera_get_group_pins()
488 const struct madera_pin_chip *chip = priv->chip; in madera_pin_dbg_show_fn()
503 for (i = 0; i < chip->n_pin_groups; ++i) { in madera_pin_dbg_show_fn()
504 for (g_pin = 0; g_pin < chip->pin_groups[i].n_pins; ++g_pin) { in madera_pin_dbg_show_fn()
505 if (chip->pin_groups[i].pins[g_pin] == pin) { in madera_pin_dbg_show_fn()
507 chip->pin_groups[i].name); in madera_pin_dbg_show_fn()
524 ret = regmap_read(priv->madera->regmap, reg, &conf[0]); in madera_pin_dbg_show()
528 ret = regmap_read(priv->madera->regmap, reg + 1, &conf[1]); in madera_pin_dbg_show()
603 *num_groups = priv->chip->n_pins; in madera_mux_get_groups()
614 struct madera *madera = priv->madera; in madera_mux_set_mux()
615 const struct madera_pin_groups *pin_group = priv->chip->pin_groups; in madera_mux_set_mux()
616 unsigned int n_chip_groups = priv->chip->n_pin_groups; in madera_mux_set_mux()
621 dev_dbg(priv->dev, "%s selecting %u (%s) for group %u (%s)\n", in madera_mux_set_mux()
626 /* alt func pin assignments are codec-specific */ in madera_mux_set_mux()
628 if (strcmp(func_name, pin_group->name) == 0) in madera_mux_set_mux()
635 return -EINVAL; in madera_mux_set_mux()
637 for (i = 0; i < pin_group->n_pins; ++i) { in madera_mux_set_mux()
638 reg = MADERA_GPIO1_CTRL_1 + (2 * pin_group->pins[i]); in madera_mux_set_mux()
640 dev_dbg(priv->dev, "%s setting 0x%x func bits to 0\n", in madera_mux_set_mux()
643 ret = regmap_update_bits(madera->regmap, reg, in madera_mux_set_mux()
652 * be offset by the number of chip-specific functions at the in madera_mux_set_mux()
655 group -= n_chip_groups; in madera_mux_set_mux()
658 dev_dbg(priv->dev, "%s setting 0x%x func bits to 0x%x\n", in madera_mux_set_mux()
661 ret = regmap_update_bits(madera->regmap, in madera_mux_set_mux()
668 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret); in madera_mux_set_mux()
679 struct madera *madera = priv->madera; in madera_gpio_set_direction()
689 ret = regmap_update_bits(madera->regmap, reg, MADERA_GP1_DIR_MASK, val); in madera_gpio_set_direction()
691 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret); in madera_gpio_set_direction()
701 struct madera *madera = priv->madera; in madera_gpio_request_enable()
706 ret = regmap_update_bits(madera->regmap, reg, MADERA_GP1_FN_MASK, 1); in madera_gpio_request_enable()
708 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret); in madera_gpio_request_enable()
718 struct madera *madera = priv->madera; in madera_gpio_disable_free()
725 ret = regmap_update_bits(madera->regmap, reg, MADERA_GP1_FN_MASK, 1); in madera_gpio_disable_free()
727 dev_err(priv->dev, "Failed to write to 0x%x (%d)\n", reg, ret); in madera_gpio_disable_free()
751 ret = regmap_read(priv->madera->regmap, reg, &conf[0]); in madera_pin_conf_get()
753 ret = regmap_read(priv->madera->regmap, reg + 1, &conf[1]); in madera_pin_conf_get()
756 dev_err(priv->dev, "Failed to read GP%d conf (%d)\n", in madera_pin_conf_get()
812 return -ENOTSUPP; in madera_pin_conf_get()
831 dev_dbg(priv->dev, "%s config 0x%lx\n", __func__, *configs); in madera_pin_conf_set()
870 * we can't configure debounce time per-pin so value in madera_pin_conf_set()
916 return -ENOTSUPP; in madera_pin_conf_set()
920 --num_configs; in madera_pin_conf_set()
923 dev_dbg(priv->dev, in madera_pin_conf_set()
927 ret = regmap_update_bits(priv->madera->regmap, reg, mask[0], conf[0]); in madera_pin_conf_set()
932 ret = regmap_update_bits(priv->madera->regmap, reg, mask[1], conf[1]); in madera_pin_conf_set()
939 dev_err(priv->dev, in madera_pin_conf_set()
953 unsigned int n_groups = priv->chip->n_pin_groups; in madera_pin_conf_group_set()
956 dev_dbg(priv->dev, "%s setting group %s\n", __func__, in madera_pin_conf_group_set()
962 selector - n_groups, in madera_pin_conf_group_set()
966 pin_group = &priv->chip->pin_groups[selector]; in madera_pin_conf_group_set()
968 for (i = 0; i < pin_group->n_pins; ++i) { in madera_pin_conf_group_set()
970 pin_group->pins[i], in madera_pin_conf_group_set()
989 .name = "madera-pinctrl",
999 struct madera *madera = dev_get_drvdata(pdev->dev.parent); in madera_pin_probe()
1000 const struct madera_pdata *pdata = &madera->pdata; in madera_pin_probe()
1007 dev_dbg(&pdev->dev, "%s\n", __func__); in madera_pin_probe()
1009 device_set_node(&pdev->dev, dev_fwnode(pdev->dev.parent)); in madera_pin_probe()
1011 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in madera_pin_probe()
1013 return -ENOMEM; in madera_pin_probe()
1015 priv->dev = &pdev->dev; in madera_pin_probe()
1016 priv->madera = madera; in madera_pin_probe()
1018 switch (madera->type) { in madera_pin_probe()
1021 priv->chip = &cs47l15_pin_chip; in madera_pin_probe()
1025 priv->chip = &cs47l35_pin_chip; in madera_pin_probe()
1030 priv->chip = &cs47l85_pin_chip; in madera_pin_probe()
1035 priv->chip = &cs47l90_pin_chip; in madera_pin_probe()
1041 priv->chip = &cs47l92_pin_chip; in madera_pin_probe()
1047 if (!priv->chip) in madera_pin_probe()
1048 return -ENODEV; in madera_pin_probe()
1050 madera_pin_desc.npins = priv->chip->n_pins; in madera_pin_probe()
1052 ret = devm_pinctrl_register_and_init(&pdev->dev, in madera_pin_probe()
1055 &priv->pctl); in madera_pin_probe()
1057 dev_err(priv->dev, "Failed pinctrl register (%d)\n", ret); in madera_pin_probe()
1062 if (pdata->gpio_configs) { in madera_pin_probe()
1063 ret = pinctrl_register_mappings(pdata->gpio_configs, in madera_pin_probe()
1064 pdata->n_gpio_configs); in madera_pin_probe()
1066 dev_err(priv->dev, in madera_pin_probe()
1073 ret = pinctrl_enable(priv->pctl); in madera_pin_probe()
1075 dev_err(priv->dev, "Failed to enable pinctrl (%d)\n", ret); in madera_pin_probe()
1081 dev_dbg(priv->dev, "pinctrl probed ok\n"); in madera_pin_probe()
1090 if (priv->madera->pdata.gpio_configs) in madera_pin_remove()
1091 pinctrl_unregister_mappings(priv->madera->pdata.gpio_configs); in madera_pin_remove()
1100 .name = "madera-pinctrl",