mirror of
https://xff.cz/git/u-boot/
synced 2025-09-04 18:22:02 +02:00
gpio: rockchip: Get pinctrl device from gpio-ranges prop
Get pinctrl device from gpio-ranges phandle when the property exists, fallback to get the first pinctrl device. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
committed by
Ondrej Jirman
parent
75fd5d0117
commit
eaae156799
@@ -181,12 +181,6 @@ static int rockchip_gpio_probe(struct udevice *dev)
|
|||||||
|
|
||||||
priv->regs = dev_read_addr_ptr(dev);
|
priv->regs = dev_read_addr_ptr(dev);
|
||||||
|
|
||||||
if (CONFIG_IS_ENABLED(PINCTRL)) {
|
|
||||||
ret = uclass_first_device_err(UCLASS_PINCTRL, &priv->pinctrl);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If "gpio-ranges" is present in the devicetree use it to parse
|
* If "gpio-ranges" is present in the devicetree use it to parse
|
||||||
* the GPIO bank ID, otherwise use the legacy method.
|
* the GPIO bank ID, otherwise use the legacy method.
|
||||||
@@ -194,16 +188,33 @@ static int rockchip_gpio_probe(struct udevice *dev)
|
|||||||
ret = ofnode_parse_phandle_with_args(dev_ofnode(dev),
|
ret = ofnode_parse_phandle_with_args(dev_ofnode(dev),
|
||||||
"gpio-ranges", NULL, 3,
|
"gpio-ranges", NULL, 3,
|
||||||
0, &args);
|
0, &args);
|
||||||
if (!ret || ret != -ENOENT) {
|
if (!ret) {
|
||||||
uc_priv->gpio_count = args.args[2];
|
uc_priv->gpio_count = args.args[2];
|
||||||
priv->bank = args.args[1] / ROCKCHIP_GPIOS_PER_BANK;
|
priv->bank = args.args[1] / ROCKCHIP_GPIOS_PER_BANK;
|
||||||
} else {
|
|
||||||
|
if (CONFIG_IS_ENABLED(PINCTRL)) {
|
||||||
|
ret = uclass_get_device_by_ofnode(UCLASS_PINCTRL,
|
||||||
|
args.node,
|
||||||
|
&priv->pinctrl);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
} else if (ret == -ENOENT || !CONFIG_IS_ENABLED(PINCTRL)) {
|
||||||
uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK;
|
uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK;
|
||||||
ret = dev_read_alias_seq(dev, &priv->bank);
|
ret = dev_read_alias_seq(dev, &priv->bank);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
end = strrchr(dev->name, '@');
|
end = strrchr(dev->name, '@');
|
||||||
priv->bank = trailing_strtoln(dev->name, end);
|
priv->bank = trailing_strtoln(dev->name, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CONFIG_IS_ENABLED(PINCTRL)) {
|
||||||
|
ret = uclass_first_device_err(UCLASS_PINCTRL,
|
||||||
|
&priv->pinctrl);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->name[0] = 'A' + priv->bank;
|
priv->name[0] = 'A' + priv->bank;
|
||||||
|
Reference in New Issue
Block a user