[PATCH 4/9] pinctrl: rockchip: Use syscon_regmap_lookup_by_phandle()

Kever Yang kever.yang at rock-chips.com
Fri Jun 7 12:27:37 CEST 2024


On 2024/5/12 20:16, Jonas Karlman wrote:
> Use syscon_regmap_lookup_by_phandle() to simplify the code.
>
> Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>

Thanks,
- Kever
> ---
>   .../pinctrl/rockchip/pinctrl-rockchip-core.c  | 39 ++++++-------------
>   1 file changed, 12 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c b/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c
> index efc2070d32d9..b7c08c23311f 100644
> --- a/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c
> +++ b/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c
> @@ -11,6 +11,7 @@
>   #include <syscon.h>
>   #include <fdtdec.h>
>   #include <linux/bitops.h>
> +#include <linux/err.h>
>   #include <linux/libfdt.h>
>   
>   #include "pinctrl-rockchip.h"
> @@ -672,37 +673,21 @@ int rockchip_pinctrl_probe(struct udevice *dev)
>   {
>   	struct rockchip_pinctrl_priv *priv = dev_get_priv(dev);
>   	struct rockchip_pin_ctrl *ctrl;
> -	struct udevice *syscon;
> -	struct regmap *regmap;
> -	int ret = 0;
>   
> -	/* get rockchip grf syscon phandle */
> -	ret = uclass_get_device_by_phandle(UCLASS_SYSCON, dev, "rockchip,grf",
> -					   &syscon);
> -	if (ret) {
> -		debug("unable to find rockchip,grf syscon device (%d)\n", ret);
> -		return ret;
> +	priv->regmap_base =
> +			syscon_regmap_lookup_by_phandle(dev, "rockchip,grf");
> +	if (IS_ERR(priv->regmap_base)) {
> +		debug("unable to find rockchip,grf regmap\n");
> +		return PTR_ERR(priv->regmap_base);
>   	}
>   
> -	/* get grf-reg base address */
> -	regmap = syscon_get_regmap(syscon);
> -	if (!regmap) {
> -		debug("unable to find rockchip grf regmap\n");
> -		return -ENODEV;
> -	}
> -	priv->regmap_base = regmap;
> -
> -	/* option: get pmu-reg base address */
> -	ret = uclass_get_device_by_phandle(UCLASS_SYSCON, dev, "rockchip,pmu",
> -					   &syscon);
> -	if (!ret) {
> -		/* get pmugrf-reg base address */
> -		regmap = syscon_get_regmap(syscon);
> -		if (!regmap) {
> -			debug("unable to find rockchip pmu regmap\n");
> -			return -ENODEV;
> +	if (dev_read_bool(dev, "rockchip,pmu")) {
> +		priv->regmap_pmu =
> +			syscon_regmap_lookup_by_phandle(dev, "rockchip,pmu");
> +		if (IS_ERR(priv->regmap_pmu)) {
> +			debug("unable to find rockchip,pmu regmap\n");
> +			return PTR_ERR(priv->regmap_pmu);
>   		}
> -		priv->regmap_pmu = regmap;
>   	}
>   
>   	ctrl = rockchip_pinctrl_get_soc_data(dev);


More information about the U-Boot mailing list