Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0aaa529 authored by Lee Jones's avatar Lee Jones Committed by Mayank Grover
Browse files

pinctrl: msm: Add ability for drivers to supply a reserved GPIO list



When booting MSM based platforms with Device Tree or some ACPI
implementations, it is possible to provide a list of reserved pins
via the 'gpio-reserved-ranges' and 'gpios' properties respectively.
However some ACPI tables are not populated with this information,
thus it has to come from a knowledgable device driver instead.

Here we provide the MSM common driver with additional support to
parse this informtion and correctly populate the widely used
'valid_mask'.

Change-Id: I4958293d4694e5dbf09782508b58430b01cd3a35
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


Git-commit: 4c0efbfb2669aa99e43e5deee30f39afd69cad65
Signed-off-by: default avatarMayank Grover <groverm@codeaurora.org>
parent 00f1edbb
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -988,8 +988,23 @@ static int msm_gpio_init_valid_mask(struct gpio_chip *chip,
	int ret;
	unsigned int len, i;
	unsigned int max_gpios = pctrl->soc->ngpios;
	const int *reserved = pctrl->soc->reserved_gpios;
	u16 *tmp;

	/* Driver provided reserved list overrides */
	if (reserved) {
		bitmap_fill(chip->valid_mask, max_gpios);
		for (i = 0; reserved[i] >= 0; i++) {
			if (i >= max_gpios || reserved[i] >= max_gpios) {
				dev_err(pctrl->dev, "invalid list of reserved"
						"GPIOs\n");
				return -EINVAL;
			}
			clear_bit(reserved[i], chip->valid_mask);
		}
		return 0;
	}

	/* The number of GPIOs in the ACPI tables */
	len = ret = device_property_read_u16_array(pctrl->dev, "gpios", NULL, 0);
	if (ret < 0)
@@ -1019,6 +1034,9 @@ static int msm_gpio_init_valid_mask(struct gpio_chip *chip,

static bool msm_gpio_needs_valid_mask(struct msm_pinctrl *pctrl)
{
	if (pctrl->soc->reserved_gpios)
		return true;

	return device_property_read_u16_array(pctrl->dev, "gpios", NULL, 0) > 0;
}

+1 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ struct msm_pinctrl_soc_data {
	bool pull_no_keeper;
	struct pinctrl_qup *qup_regs;
	unsigned int nqup_regs;
	const int *reserved_gpios;
};

int msm_pinctrl_probe(struct platform_device *pdev,