[PATCH v2 01/10] pinctrl: rockchip: Use syscon_regmap_lookup_by_phandle()
Jonas Karlman
jonas at kwiboo.se
Sat Aug 3 00:56:43 CEST 2024
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>
---
v2: Collect r-b tag
---
.../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 d449d07d32e7..f6af22501c36 100644
--- a/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c
+++ b/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c
@@ -10,6 +10,7 @@
#include <syscon.h>
#include <fdtdec.h>
#include <linux/bitops.h>
+#include <linux/err.h>
#include <linux/libfdt.h>
#include "pinctrl-rockchip.h"
@@ -640,37 +641,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);
--
2.45.2
More information about the U-Boot
mailing list