• Home
  • Raw
  • Download

Lines Matching +full:analog +full:- +full:level

1 // SPDX-License-Identifier: GPL-2.0-only
12 #include <linux/pinctrl/pinconf-generic.h>
20 #include <dt-bindings/pinctrl/qcom,pmic-mpp.h>
23 #include "../pinctrl-utils.h"
57 /* Analog Output: control */
88 * struct pm8xxx_pin_data - dynamic configuration for a pin
91 * @mode: operating mode for the pin (digital, analog or current sink)
99 * @amux: input muxing in analog mode
100 * @aout_level: selector of the output in analog mode
135 {"qcom,amux-route", PM8XXX_CONFIG_AMUX, 0},
136 {"qcom,analog-level", PM8XXX_CONFIG_ALEVEL, 0},
143 PCONFDUMP(PM8XXX_CONFIG_AMUX, "analog mux", NULL, true),
144 PCONFDUMP(PM8XXX_CONFIG_ALEVEL, "analog level", NULL, true),
161 "digital", "analog", "sink",
167 unsigned level; in pm8xxx_mpp_update() local
173 switch (pin->mode) { in pm8xxx_mpp_update()
175 if (pin->dtest) { in pm8xxx_mpp_update()
177 ctrl = pin->dtest - 1; in pm8xxx_mpp_update()
178 } else if (pin->input && pin->output) { in pm8xxx_mpp_update()
180 if (pin->high_z) in pm8xxx_mpp_update()
182 else if (pin->pullup == 600) in pm8xxx_mpp_update()
184 else if (pin->pullup == 10000) in pm8xxx_mpp_update()
188 } else if (pin->input) { in pm8xxx_mpp_update()
190 if (pin->dtest) in pm8xxx_mpp_update()
191 ctrl = pin->dtest; in pm8xxx_mpp_update()
196 ctrl = !!pin->output_value; in pm8xxx_mpp_update()
197 if (pin->paired) in pm8xxx_mpp_update()
201 level = pin->power_source; in pm8xxx_mpp_update()
204 if (pin->output) { in pm8xxx_mpp_update()
206 level = pin->aout_level; in pm8xxx_mpp_update()
207 ctrl = pin->output_value; in pm8xxx_mpp_update()
208 if (pin->paired) in pm8xxx_mpp_update()
212 level = pin->amux; in pm8xxx_mpp_update()
217 level = (pin->drive_strength / 5) - 1; in pm8xxx_mpp_update()
218 if (pin->dtest) { in pm8xxx_mpp_update()
220 ctrl = pin->dtest - 1; in pm8xxx_mpp_update()
223 ctrl = pin->output_value; in pm8xxx_mpp_update()
224 if (pin->paired) in pm8xxx_mpp_update()
229 return -EINVAL; in pm8xxx_mpp_update()
232 val = type << 5 | level << 2 | ctrl; in pm8xxx_mpp_update()
233 ret = regmap_write(pctrl->regmap, pin->reg, val); in pm8xxx_mpp_update()
235 dev_err(pctrl->dev, "failed to write register\n"); in pm8xxx_mpp_update()
244 return pctrl->npins; in pm8xxx_get_groups_count()
261 *pins = &pctrl->desc.pins[group].number; in pm8xxx_get_group_pins()
294 *num_groups = pctrl->npins; in pm8xxx_get_function_groups()
303 struct pm8xxx_pin_data *pin = pctrl->desc.pins[group].drv_data; in pm8xxx_pinmux_set_mux()
305 pin->mode = function; in pm8xxx_pinmux_set_mux()
323 struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; in pm8xxx_pin_config_get()
329 arg = pin->pullup; in pm8xxx_pin_config_get()
332 arg = pin->high_z; in pm8xxx_pin_config_get()
335 arg = pin->input; in pm8xxx_pin_config_get()
338 arg = pin->output_value; in pm8xxx_pin_config_get()
341 arg = pin->power_source; in pm8xxx_pin_config_get()
344 arg = pin->drive_strength; in pm8xxx_pin_config_get()
347 arg = pin->dtest; in pm8xxx_pin_config_get()
350 arg = pin->amux; in pm8xxx_pin_config_get()
353 arg = pin->aout_level; in pm8xxx_pin_config_get()
356 arg = pin->paired; in pm8xxx_pin_config_get()
359 return -EINVAL; in pm8xxx_pin_config_get()
373 struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; in pm8xxx_pin_config_set()
384 pin->pullup = arg; in pm8xxx_pin_config_set()
387 pin->high_z = true; in pm8xxx_pin_config_set()
390 pin->input = true; in pm8xxx_pin_config_set()
393 pin->output = true; in pm8xxx_pin_config_set()
394 pin->output_value = !!arg; in pm8xxx_pin_config_set()
397 pin->power_source = arg; in pm8xxx_pin_config_set()
400 pin->drive_strength = arg; in pm8xxx_pin_config_set()
403 pin->dtest = arg; in pm8xxx_pin_config_set()
406 pin->amux = arg; in pm8xxx_pin_config_set()
409 pin->aout_level = arg; in pm8xxx_pin_config_set()
412 pin->paired = !!arg; in pm8xxx_pin_config_set()
415 dev_err(pctrl->dev, in pm8xxx_pin_config_set()
418 return -EINVAL; in pm8xxx_pin_config_set()
445 struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; in pm8xxx_mpp_direction_input()
447 switch (pin->mode) { in pm8xxx_mpp_direction_input()
449 pin->input = true; in pm8xxx_mpp_direction_input()
452 pin->input = true; in pm8xxx_mpp_direction_input()
453 pin->output = true; in pm8xxx_mpp_direction_input()
456 return -EINVAL; in pm8xxx_mpp_direction_input()
469 struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; in pm8xxx_mpp_direction_output()
471 switch (pin->mode) { in pm8xxx_mpp_direction_output()
473 pin->output = true; in pm8xxx_mpp_direction_output()
476 pin->input = false; in pm8xxx_mpp_direction_output()
477 pin->output = true; in pm8xxx_mpp_direction_output()
480 pin->input = false; in pm8xxx_mpp_direction_output()
481 pin->output = true; in pm8xxx_mpp_direction_output()
493 struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; in pm8xxx_mpp_get()
497 if (!pin->input) in pm8xxx_mpp_get()
498 return !!pin->output_value; in pm8xxx_mpp_get()
500 ret = irq_get_irqchip_state(pin->irq, IRQCHIP_STATE_LINE_LEVEL, &state); in pm8xxx_mpp_get()
510 struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; in pm8xxx_mpp_set()
512 pin->output_value = !!value; in pm8xxx_mpp_set()
521 if (chip->of_gpio_n_cells < 2) in pm8xxx_mpp_of_xlate()
522 return -EINVAL; in pm8xxx_mpp_of_xlate()
525 *flags = gpio_desc->args[1]; in pm8xxx_mpp_of_xlate()
527 return gpio_desc->args[0] - 1; in pm8xxx_mpp_of_xlate()
534 struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; in pm8xxx_mpp_to_irq()
536 return pin->irq; in pm8xxx_mpp_to_irq()
549 struct pm8xxx_pin_data *pin = pctrl->desc.pins[offset].drv_data; in pm8xxx_mpp_dbg_show_one()
561 seq_printf(s, " mpp%-2d:", offset + 1); in pm8xxx_mpp_dbg_show_one()
563 switch (pin->mode) { in pm8xxx_mpp_dbg_show_one()
566 if (pin->dtest) { in pm8xxx_mpp_dbg_show_one()
567 seq_printf(s, "dtest%d\n", pin->dtest); in pm8xxx_mpp_dbg_show_one()
568 } else if (pin->input && pin->output) { in pm8xxx_mpp_dbg_show_one()
569 if (pin->high_z) in pm8xxx_mpp_dbg_show_one()
570 seq_puts(s, "bi-dir high-z"); in pm8xxx_mpp_dbg_show_one()
572 seq_printf(s, "bi-dir %dOhm", pin->pullup); in pm8xxx_mpp_dbg_show_one()
573 } else if (pin->input) { in pm8xxx_mpp_dbg_show_one()
574 if (pin->dtest) in pm8xxx_mpp_dbg_show_one()
575 seq_printf(s, "in dtest%d", pin->dtest); in pm8xxx_mpp_dbg_show_one()
578 } else if (pin->output) { in pm8xxx_mpp_dbg_show_one()
581 if (!pin->paired) { in pm8xxx_mpp_dbg_show_one()
582 seq_puts(s, pin->output_value ? in pm8xxx_mpp_dbg_show_one()
585 seq_puts(s, pin->output_value ? in pm8xxx_mpp_dbg_show_one()
591 seq_puts(s, " analog "); in pm8xxx_mpp_dbg_show_one()
592 if (pin->output) { in pm8xxx_mpp_dbg_show_one()
593 seq_printf(s, "out %s ", aout_lvls[pin->aout_level]); in pm8xxx_mpp_dbg_show_one()
594 if (!pin->paired) { in pm8xxx_mpp_dbg_show_one()
595 seq_puts(s, pin->output_value ? in pm8xxx_mpp_dbg_show_one()
598 seq_puts(s, pin->output_value ? in pm8xxx_mpp_dbg_show_one()
602 seq_printf(s, "input mux %s", amuxs[pin->amux]); in pm8xxx_mpp_dbg_show_one()
606 seq_printf(s, " sink %dmA ", pin->drive_strength); in pm8xxx_mpp_dbg_show_one()
607 if (pin->dtest) { in pm8xxx_mpp_dbg_show_one()
608 seq_printf(s, "dtest%d", pin->dtest); in pm8xxx_mpp_dbg_show_one()
610 if (!pin->paired) { in pm8xxx_mpp_dbg_show_one()
611 seq_puts(s, pin->output_value ? in pm8xxx_mpp_dbg_show_one()
614 seq_puts(s, pin->output_value ? in pm8xxx_mpp_dbg_show_one()
624 unsigned gpio = chip->base; in pm8xxx_mpp_dbg_show()
627 for (i = 0; i < chip->ngpio; i++, gpio++) { in pm8xxx_mpp_dbg_show()
652 unsigned level; in pm8xxx_pin_populate() local
657 ret = regmap_read(pctrl->regmap, pin->reg, &val); in pm8xxx_pin_populate()
659 dev_err(pctrl->dev, "failed to read register\n"); in pm8xxx_pin_populate()
664 level = (val >> 2) & 7; in pm8xxx_pin_populate()
669 pin->mode = PM8XXX_MPP_DIGITAL; in pm8xxx_pin_populate()
670 pin->input = true; in pm8xxx_pin_populate()
671 pin->power_source = level; in pm8xxx_pin_populate()
672 pin->dtest = ctrl; in pm8xxx_pin_populate()
675 pin->mode = PM8XXX_MPP_DIGITAL; in pm8xxx_pin_populate()
676 pin->output = true; in pm8xxx_pin_populate()
677 pin->power_source = level; in pm8xxx_pin_populate()
678 pin->output_value = !!(ctrl & BIT(0)); in pm8xxx_pin_populate()
679 pin->paired = !!(ctrl & BIT(1)); in pm8xxx_pin_populate()
682 pin->mode = PM8XXX_MPP_DIGITAL; in pm8xxx_pin_populate()
683 pin->input = true; in pm8xxx_pin_populate()
684 pin->output = true; in pm8xxx_pin_populate()
685 pin->power_source = level; in pm8xxx_pin_populate()
688 pin->pullup = 600; in pm8xxx_pin_populate()
691 pin->high_z = true; in pm8xxx_pin_populate()
694 pin->pullup = 10000; in pm8xxx_pin_populate()
697 pin->pullup = 30000; in pm8xxx_pin_populate()
702 pin->mode = PM8XXX_MPP_ANALOG; in pm8xxx_pin_populate()
703 pin->input = true; in pm8xxx_pin_populate()
704 pin->amux = level; in pm8xxx_pin_populate()
707 pin->mode = PM8XXX_MPP_ANALOG; in pm8xxx_pin_populate()
708 pin->output = true; in pm8xxx_pin_populate()
709 pin->aout_level = level; in pm8xxx_pin_populate()
710 pin->output_value = !!(ctrl & BIT(0)); in pm8xxx_pin_populate()
711 pin->paired = !!(ctrl & BIT(1)); in pm8xxx_pin_populate()
714 pin->mode = PM8XXX_MPP_SINK; in pm8xxx_pin_populate()
715 pin->drive_strength = 5 * (level + 1); in pm8xxx_pin_populate()
716 pin->output_value = !!(ctrl & BIT(0)); in pm8xxx_pin_populate()
717 pin->paired = !!(ctrl & BIT(1)); in pm8xxx_pin_populate()
720 pin->mode = PM8XXX_MPP_SINK; in pm8xxx_pin_populate()
721 pin->dtest = ctrl + 1; in pm8xxx_pin_populate()
722 pin->drive_strength = 5 * (level + 1); in pm8xxx_pin_populate()
725 pin->mode = PM8XXX_MPP_DIGITAL; in pm8xxx_pin_populate()
726 pin->power_source = level; in pm8xxx_pin_populate()
728 pin->dtest = ctrl; in pm8xxx_pin_populate()
736 { .compatible = "qcom,pm8018-mpp" },
737 { .compatible = "qcom,pm8038-mpp" },
738 { .compatible = "qcom,pm8058-mpp" },
739 { .compatible = "qcom,pm8917-mpp" },
740 { .compatible = "qcom,pm8821-mpp" },
741 { .compatible = "qcom,pm8921-mpp" },
742 { .compatible = "qcom,ssbi-mpp" },
755 pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); in pm8xxx_mpp_probe()
757 return -ENOMEM; in pm8xxx_mpp_probe()
759 pctrl->dev = &pdev->dev; in pm8xxx_mpp_probe()
762 return -EINVAL; in pm8xxx_mpp_probe()
765 pctrl->npins = npins; in pm8xxx_mpp_probe()
767 pctrl->regmap = dev_get_regmap(pdev->dev.parent, NULL); in pm8xxx_mpp_probe()
768 if (!pctrl->regmap) { in pm8xxx_mpp_probe()
769 dev_err(&pdev->dev, "parent regmap unavailable\n"); in pm8xxx_mpp_probe()
770 return -ENXIO; in pm8xxx_mpp_probe()
773 pctrl->desc = pm8xxx_pinctrl_desc; in pm8xxx_mpp_probe()
774 pctrl->desc.npins = pctrl->npins; in pm8xxx_mpp_probe()
776 pins = devm_kcalloc(&pdev->dev, in pm8xxx_mpp_probe()
777 pctrl->desc.npins, in pm8xxx_mpp_probe()
781 return -ENOMEM; in pm8xxx_mpp_probe()
783 pin_data = devm_kcalloc(&pdev->dev, in pm8xxx_mpp_probe()
784 pctrl->desc.npins, in pm8xxx_mpp_probe()
788 return -ENOMEM; in pm8xxx_mpp_probe()
790 for (i = 0; i < pctrl->desc.npins; i++) { in pm8xxx_mpp_probe()
804 pctrl->desc.pins = pins; in pm8xxx_mpp_probe()
806 pctrl->desc.num_custom_params = ARRAY_SIZE(pm8xxx_mpp_bindings); in pm8xxx_mpp_probe()
807 pctrl->desc.custom_params = pm8xxx_mpp_bindings; in pm8xxx_mpp_probe()
809 pctrl->desc.custom_conf_items = pm8xxx_conf_items; in pm8xxx_mpp_probe()
812 pctrl->pctrl = devm_pinctrl_register(&pdev->dev, &pctrl->desc, pctrl); in pm8xxx_mpp_probe()
813 if (IS_ERR(pctrl->pctrl)) { in pm8xxx_mpp_probe()
814 dev_err(&pdev->dev, "couldn't register pm8xxx mpp driver\n"); in pm8xxx_mpp_probe()
815 return PTR_ERR(pctrl->pctrl); in pm8xxx_mpp_probe()
818 pctrl->chip = pm8xxx_mpp_template; in pm8xxx_mpp_probe()
819 pctrl->chip.base = -1; in pm8xxx_mpp_probe()
820 pctrl->chip.parent = &pdev->dev; in pm8xxx_mpp_probe()
821 pctrl->chip.of_node = pdev->dev.of_node; in pm8xxx_mpp_probe()
822 pctrl->chip.of_gpio_n_cells = 2; in pm8xxx_mpp_probe()
823 pctrl->chip.label = dev_name(pctrl->dev); in pm8xxx_mpp_probe()
824 pctrl->chip.ngpio = pctrl->npins; in pm8xxx_mpp_probe()
825 ret = gpiochip_add_data(&pctrl->chip, pctrl); in pm8xxx_mpp_probe()
827 dev_err(&pdev->dev, "failed register gpiochip\n"); in pm8xxx_mpp_probe()
831 ret = gpiochip_add_pin_range(&pctrl->chip, in pm8xxx_mpp_probe()
832 dev_name(pctrl->dev), in pm8xxx_mpp_probe()
833 0, 0, pctrl->chip.ngpio); in pm8xxx_mpp_probe()
835 dev_err(pctrl->dev, "failed to add pin range\n"); in pm8xxx_mpp_probe()
841 dev_dbg(&pdev->dev, "Qualcomm pm8xxx mpp driver probed\n"); in pm8xxx_mpp_probe()
846 gpiochip_remove(&pctrl->chip); in pm8xxx_mpp_probe()
855 gpiochip_remove(&pctrl->chip); in pm8xxx_mpp_remove()
862 .name = "qcom-ssbi-mpp",