Skip to content

Commit 4c0efbf

Browse files
Lee Joneslinusw
authored andcommitted
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'. Signed-off-by: Lee Jones <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent a188339 commit 4c0efbf

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

drivers/pinctrl/qcom/pinctrl-msm.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,23 @@ static int msm_gpio_init_valid_mask(struct gpio_chip *chip)
607607
int ret;
608608
unsigned int len, i;
609609
unsigned int max_gpios = pctrl->soc->ngpios;
610+
const int *reserved = pctrl->soc->reserved_gpios;
610611
u16 *tmp;
611612

613+
/* Driver provided reserved list overrides DT and ACPI */
614+
if (reserved) {
615+
bitmap_fill(chip->valid_mask, max_gpios);
616+
for (i = 0; reserved[i] >= 0; i++) {
617+
if (i >= max_gpios || reserved[i] >= max_gpios) {
618+
dev_err(pctrl->dev, "invalid list of reserved GPIOs\n");
619+
return -EINVAL;
620+
}
621+
clear_bit(reserved[i], chip->valid_mask);
622+
}
623+
624+
return 0;
625+
}
626+
612627
/* The number of GPIOs in the ACPI tables */
613628
len = ret = device_property_read_u16_array(pctrl->dev, "gpios", NULL,
614629
0);
@@ -964,6 +979,9 @@ static void msm_gpio_irq_handler(struct irq_desc *desc)
964979

965980
static bool msm_gpio_needs_valid_mask(struct msm_pinctrl *pctrl)
966981
{
982+
if (pctrl->soc->reserved_gpios)
983+
return true;
984+
967985
return device_property_read_u16_array(pctrl->dev, "gpios", NULL, 0) > 0;
968986
}
969987

drivers/pinctrl/qcom/pinctrl-msm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct msm_pinctrl_soc_data {
121121
bool pull_no_keeper;
122122
const char *const *tiles;
123123
unsigned int ntiles;
124+
const int *reserved_gpios;
124125
};
125126

126127
extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;

0 commit comments

Comments
 (0)