diff options
author | Caleb Connolly <caleb.connolly@linaro.org> | 2023-12-05 13:46:50 +0000 |
---|---|---|
committer | Caleb Connolly <caleb.connolly@linaro.org> | 2024-01-16 12:26:53 +0000 |
commit | ab4214333d900bf68a202c988528ec6b553d00ff (patch) | |
tree | 41551e52802d2688d57ea8b5644d5d3dc529601b | |
parent | 5415d5f0e70f4786d474f7870018213fcce0fd52 (diff) | |
download | u-boot-ab4214333d900bf68a202c988528ec6b553d00ff.zip u-boot-ab4214333d900bf68a202c988528ec6b553d00ff.tar.gz u-boot-ab4214333d900bf68a202c988528ec6b553d00ff.tar.bz2 |
gpio: qcom_pmic: support upstream DT
Upstream uses the gpio-ranges property to define the number of GPIOs,
support for parsing this when gpio-count is unspecified
Additionally, drop the bank-name property as it isn't used in upstream,
and we can just hardcode the bank name instead.
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Tested-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
-rw-r--r-- | drivers/gpio/qcom_pmic_gpio.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 7b83c67..5221bd2 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -245,14 +245,39 @@ static int qcom_gpio_probe(struct udevice *dev) return 0; } +/* + * Parse basic GPIO count specified via the gpio-ranges property + * as specified in Linux devicetrees + * Returns < 0 on error, otherwise gpio count + */ +static int qcom_gpio_of_parse_ranges(struct udevice *dev) +{ + int ret; + struct ofnode_phandle_args args; + + ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), "gpio-ranges", + NULL, 3, 0, &args); + if (ret) + return log_msg_ret("gpio-ranges", ret); + + return args.args[2]; +} + static int qcom_gpio_of_to_plat(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + int ret; uc_priv->gpio_count = dev_read_u32_default(dev, "gpio-count", 0); - uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name"); - if (uc_priv->bank_name == NULL) - uc_priv->bank_name = "qcom_pmic"; + if (!uc_priv->gpio_count) { + ret = qcom_gpio_of_parse_ranges(dev); + if (ret > 0) + uc_priv->gpio_count = ret; + else + return ret; + } + + uc_priv->bank_name = "pmic"; return 0; } |