Skip to contentSkip to conversation

mmc: power: convert ofnode API to dev_read API

PATCH In review Peng Fan (OSS) 3 participants 17 messages Jun 4 – Jun 5

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover mmc: power: convert ofnode API to dev_read API

Convert MMC and power drivers from using ofnode_read_*() / ofnode_get_property() / ofnode_for_each_subnode() / ofnode_find_subnode() to their dev_read_*() / dev_for_each_subnode() / dev_read_subnode() equivalents. The dev_read_*() functions are thin wrappers that internally call dev_ofnode(dev) and forward to the corresponding ofnode_*() function, so there is no functional change.

For the Meson power domain drivers (meson-ee-pwrc and meson-gx-pwrc-vpu), the manual ofnode_read_u32() + ofnode_get_by_phandle() + ofnode_valid() phandle resolution sequence is replaced with a single dev_read_phandle_with_args() call.

This cleanup removes intermediate 'ofnode node' local variables and the now-unused host->node field in octeontx_hsmmc, making the code more concise.

Drivers converted:
- mmc: fsl_esdhc_imx, msm_sdhci, octeontx_hsmmc
- power/domain: imx8m-power-domain, meson-ee-pwrc, meson-gx-pwrc-vpu
- power/pmic: pca9450, pmic_qcom
- power/regulator: anatop, qcom-rpmh, scmi

---
Peng Fan (11):
mmc: fsl_esdhc_imx: convert ofnode API to dev_read API
mmc: msm_sdhci: convert ofnode API to dev_read API
mmc: octeontx_hsmmc: convert ofnode API to dev_read API
power: domain: meson-ee-pwrc: use dev_read_phandle_with_args for ao-sysctrl
power: domain: meson-gx-pwrc-vpu: use dev_read_phandle_with_args for hhi-sysctrl
power: domain: imx8m: convert ofnode API to dev_read API
power: pmic: pca9450: convert ofnode API to dev_read API
power: pmic: qcom: convert ofnode API to dev_read API
power: regulator: anatop: convert ofnode API to dev_read API
power: regulator: qcom-rpmh: convert ofnode API to dev_read API
power: regulator: scmi: convert ofnode API to dev_read API

 drivers/mmc/fsl_esdhc_imx.c                   | 14 +++--
 drivers/mmc/msm_sdhci.c                       |  7 ++-
 drivers/mmc/octeontx_hsmmc.c                  | 74 +++++++++++----------------
 drivers/mmc/octeontx_hsmmc.h                  |  1 -
 drivers/power/domain/imx8m-power-domain.c     |  4 +-
 drivers/power/domain/meson-ee-pwrc.c          | 13 ++---
 drivers/power/domain/meson-gx-pwrc-vpu.c      | 13 ++---
 drivers/power/pmic/pca9450.c                  |  2 +-
 drivers/power/pmic/pmic_qcom.c                |  2 +-
 drivers/power/regulator/anatop_regulator.c    |  3 +-
 drivers/power/regulator/qcom-rpmh-regulator.c |  7 +--
 drivers/power/regulator/scmi_regulator.c      |  2 +-
 12 files changed, 57 insertions(+), 85 deletions(-)

---
base-commit: 31af00bdc6a3ab5d4ada83e08407f2ce289f0ec6
change-id: 20260604-devapi-05f934cfcc04

Best regards,

Signature · 1 line
Peng Fan <[email protected]>
#1 lore raw

PATCH 1/11 mmc: fsl_esdhc_imx: convert ofnode API to dev_read API

From: Peng Fan <[email protected]>

Replace ofnode_read_*() calls with their dev_read_*() equivalents in fsl_esdhc_of_to_plat(). Remove the intermediate 'ofnode node' local variable and the now-unnecessary <dm/ofnode.h> include.

No functional change.

---
 drivers/mmc/fsl_esdhc_imx.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/mmc/fsl_esdhc_imx.c +6 -8
index 87125493c0d..e718a17f94c 100644
@@ -36,7 +36,6 @@
 #include <dm/pinctrl.h>
 #include <dt-structs.h>
 #include <mapmem.h>
-#include <dm/ofnode.h>
 #include <linux/iopoll.h>
 #include <linux/dma-mapping.h>
 
@@ -1393,7 +1392,6 @@ static int fsl_esdhc_of_to_plat(struct udevice *dev)
 	struct udevice *vqmmc_dev;
 	int ret;
 
-	ofnode node = dev_ofnode(dev);
 	fdt_addr_t addr;
 	unsigned int val;
 
@@ -1407,15 +1405,15 @@ static int fsl_esdhc_of_to_plat(struct udevice *dev)
 	priv->dev = dev;
 	priv->mode = -1;
 
-	val = ofnode_read_u32_default(node, "fsl,tuning-step", 1);
+	val = dev_read_u32_default(dev, "fsl,tuning-step", 1);
 	priv->tuning_step = val;
-	val = ofnode_read_u32_default(node, "fsl,tuning-start-tap",
-				      ESDHC_TUNING_START_TAP_DEFAULT);
+	val = dev_read_u32_default(dev, "fsl,tuning-start-tap",
+				   ESDHC_TUNING_START_TAP_DEFAULT);
 	priv->tuning_start_tap = val;
-	val = ofnode_read_u32_default(node, "fsl,strobe-dll-delay-target",
-				      ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET_DEFAULT);
+	val = dev_read_u32_default(dev, "fsl,strobe-dll-delay-target",
+				   ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET_DEFAULT);
 	priv->strobe_dll_delay_target = val;
-	val = ofnode_read_u32_default(node, "fsl,signal-voltage-switch-extra-delay-ms", 0);
+	val = dev_read_u32_default(dev, "fsl,signal-voltage-switch-extra-delay-ms", 0);
 	priv->signal_voltage_switch_extra_delay_ms = val;
 
 	if (dev_read_bool(dev, "broken-cd"))
Signature · 1 line
2.51.0
#2 lore raw

PATCH 2/11 mmc: msm_sdhci: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace ofnode_read_u32(), ofnode_get_property() and ofnode_read_string_index() with their dev_read_*() equivalents in msm_sdc_clk_init(). Remove the intermediate 'ofnode node' local variable.

No functional change.

---
 drivers/mmc/msm_sdhci.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/mmc/msm_sdhci.c +3 -4
index aaa87923604..7bdb02142a2 100644
@@ -64,14 +64,13 @@ static int msm_sdc_clk_init(struct udevice *dev)
 {
 	struct msm_sdhc *prv = dev_get_priv(dev);
 	const struct msm_sdhc_variant_info *var_info;
-	ofnode node = dev_ofnode(dev);
 	ulong clk_rate;
 	int ret, i = 0, n_clks;
 	const char *clk_name;
 
 	var_info = (void *)dev_get_driver_data(dev);
 
-	if (ofnode_read_u32(node, "max-frequency", (uint *)(&clk_rate)))
+	if (dev_read_u32(dev, "max-frequency", (uint *)(&clk_rate)))
 		clk_rate = 201500000;
 
 	ret = clk_get_bulk(dev, &prv->clks);
@@ -87,7 +86,7 @@ static int msm_sdc_clk_init(struct udevice *dev)
 	}
 
 	/* If clock-names is unspecified, then the first clock is the core clock */
-	if (!ofnode_get_property(node, "clock-names", &n_clks)) {
+	if (!dev_read_prop(dev, "clock-names", &n_clks)) {
 		if (!clk_set_rate(&prv->clks.clks[0], clk_rate)) {
 			log_warning("Couldn't set core clock rate: %d\n", ret);
 			return -EINVAL;
@@ -96,7 +95,7 @@ static int msm_sdc_clk_init(struct udevice *dev)
 
 	/* Find the index of the "core" clock */
 	while (i < n_clks) {
-		ofnode_read_string_index(node, "clock-names", i, &clk_name);
+		dev_read_string_index(dev, "clock-names", i, &clk_name);
 		if (!strcmp(clk_name, "core"))
 			break;
 		i++;
Signature · 1 line
2.51.0
#4 lore raw

PATCH 3/11 mmc: octeontx_hsmmc: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace all ofnode_read_*() / ofnode_read_bool() / ofnode_get_property() calls with their dev_read_*() equivalents across octeontx_mmc_get_valid(), octeontx_mmc_get_config(), octeontx_mmc_host_probe() and octeontx_mmc_host_child_pre_probe().

Remove the intermediate 'ofnode node' local variables, the now-unused 'host->node' assignment in the probe function, and the corresponding 'ofnode node' field from struct octeontx_mmc_host.

No functional change.

---
 drivers/mmc/octeontx_hsmmc.c | 74 ++++++++++++++++++--------------------------
 drivers/mmc/octeontx_hsmmc.h |  1 -
 2 files changed, 30 insertions(+), 45 deletions(-)
drivers/mmc/octeontx_hsmmc.c +30 -44
index bb4fb29424b..b4942f99a52 100644
@@ -3514,7 +3514,7 @@ static u32 xlate_voltage(u32 voltage)
  */
 static bool octeontx_mmc_get_valid(struct udevice *dev)
 {
-	const char *stat = ofnode_read_string(dev_ofnode(dev), "status");
+	const char *stat = dev_read_string(dev, "status");
 
 	if (!stat || !strncmp(stat, "ok", 2))
 		return true;
@@ -3536,16 +3536,13 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 	uint low, high;
 	char env_name[32];
 	int err;
-	ofnode node = dev_ofnode(dev);
 	int bus_width = 1;
 	ulong new_max_freq;
 
 	debug("%s(%s)", __func__, dev->name);
 	slot->cfg.name = dev->name;
 
-	slot->cfg.f_max = ofnode_read_s32_default(dev_ofnode(dev),
-						  "max-frequency",
-						  26000000);
+	slot->cfg.f_max = dev_read_s32_default(dev, "max-frequency", 26000000);
 	snprintf(env_name, sizeof(env_name), "mmc_max_frequency%d",
 		 slot->bus_id);
 
@@ -3562,26 +3559,21 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 
 	if (IS_ENABLED(CONFIG_ARCH_OCTEONTX2)) {
 		slot->hs400_tuning_block =
-			ofnode_read_s32_default(dev_ofnode(dev),
-						"marvell,hs400-tuning-block",
-						-1);
+			dev_read_s32_default(dev, "marvell,hs400-tuning-block", -1);
 		debug("%s(%s): mmc HS400 tuning block: %d\n", __func__,
 		      dev->name, slot->hs400_tuning_block);
 
 		slot->hs200_tap_adj =
-			ofnode_read_s32_default(dev_ofnode(dev),
-						"marvell,hs200-tap-adjust", 0);
+			dev_read_s32_default(dev, "marvell,hs200-tap-adjust", 0);
 		debug("%s(%s): hs200-tap-adjust: %d\n", __func__, dev->name,
 		      slot->hs200_tap_adj);
 		slot->hs400_tap_adj =
-			ofnode_read_s32_default(dev_ofnode(dev),
-						"marvell,hs400-tap-adjust", 0);
+			dev_read_s32_default(dev, "marvell,hs400-tap-adjust", 0);
 		debug("%s(%s): hs400-tap-adjust: %d\n", __func__, dev->name,
 		      slot->hs400_tap_adj);
 	}
 
-	err = ofnode_read_u32_array(dev_ofnode(dev), "voltage-ranges",
-				    voltages, 2);
+	err = dev_read_u32_array(dev, "voltage-ranges", voltages, 2);
 	if (err) {
 		slot->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
 	} else {
@@ -3601,12 +3593,12 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 		} while (low <= high);
 	}
 	debug("%s: config voltages: 0x%x\n", __func__, slot->cfg.voltages);
-	slot->slew = ofnode_read_s32_default(node, "cavium,clk-slew", -1);
-	slot->drive = ofnode_read_s32_default(node, "cavium,drv-strength", -1);
+	slot->slew = dev_read_s32_default(dev, "cavium,clk-slew", -1);
+	slot->drive = dev_read_s32_default(dev, "cavium,drv-strength", -1);
 	gpio_request_by_name(dev, "cd-gpios", 0, &slot->cd_gpio, GPIOD_IS_IN);
-	slot->cd_inverted = ofnode_read_bool(node, "cd-inverted");
+	slot->cd_inverted = dev_read_bool(dev, "cd-inverted");
 	gpio_request_by_name(dev, "wp-gpios", 0, &slot->wp_gpio, GPIOD_IS_IN);
-	slot->wp_inverted = ofnode_read_bool(node, "wp-inverted");
+	slot->wp_inverted = dev_read_bool(dev, "wp-inverted");
 	if (slot->cfg.voltages & MMC_VDD_165_195) {
 		slot->is_1_8v = true;
 		slot->is_3_3v = false;
@@ -3617,7 +3609,7 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 		slot->is_3_3v = true;
 	}
 
-	bus_width = ofnode_read_u32_default(node, "bus-width", 1);
+	bus_width = dev_read_u32_default(dev, "bus-width", 1);
 	/* Note fall-through */
 	switch (bus_width) {
 	case 8:
@@ -3628,63 +3620,63 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 		slot->cfg.host_caps |= MMC_MODE_1BIT;
 		break;
 	}
-	if (ofnode_read_bool(node, "no-1-8-v")) {
+	if (dev_read_bool(dev, "no-1-8-v")) {
 		slot->is_3_3v = true;
 		slot->is_1_8v = false;
 		if (!(slot->cfg.voltages & (MMC_VDD_32_33 | MMC_VDD_33_34)))
 			pr_warn("%s(%s): voltages indicate 3.3v but 3.3v not supported\n",
 				__func__, dev->name);
 	}
-	if (ofnode_read_bool(node, "mmc-ddr-3-3v")) {
+	if (dev_read_bool(dev, "mmc-ddr-3-3v")) {
 		slot->is_3_3v = true;
 		slot->is_1_8v = false;
 		if (!(slot->cfg.voltages & (MMC_VDD_32_33 | MMC_VDD_33_34)))
 			pr_warn("%s(%s): voltages indicate 3.3v but 3.3v not supported\n",
 				__func__, dev->name);
 	}
-	if (ofnode_read_bool(node, "cap-sd-highspeed") ||
-	    ofnode_read_bool(node, "cap-mmc-highspeed") ||
-	    ofnode_read_bool(node, "sd-uhs-sdr25"))
+	if (dev_read_bool(dev, "cap-sd-highspeed") ||
+	    dev_read_bool(dev, "cap-mmc-highspeed") ||
+	    dev_read_bool(dev, "sd-uhs-sdr25"))
 		slot->cfg.host_caps |= MMC_MODE_HS;
 	if (slot->cfg.f_max >= 50000000 &&
 	    slot->cfg.host_caps & MMC_MODE_HS)
 		slot->cfg.host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
-	if (ofnode_read_bool(node, "sd-uhs-sdr50"))
+	if (dev_read_bool(dev, "sd-uhs-sdr50"))
 		slot->cfg.host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
-	if (ofnode_read_bool(node, "sd-uhs-ddr50"))
+	if (dev_read_bool(dev, "sd-uhs-ddr50"))
 		slot->cfg.host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz |
 				       MMC_MODE_DDR_52MHz;
 
 	if (IS_ENABLED(CONFIG_ARCH_OCTEONTX2)) {
 		if (!slot->is_asim && !slot->is_emul) {
-			if (ofnode_read_bool(node, "mmc-hs200-1_8v"))
+			if (dev_read_bool(dev, "mmc-hs200-1_8v"))
 				slot->cfg.host_caps |= MMC_MODE_HS200 |
 					MMC_MODE_HS_52MHz;
-			if (ofnode_read_bool(node, "mmc-hs400-1_8v"))
+			if (dev_read_bool(dev, "mmc-hs400-1_8v"))
 				slot->cfg.host_caps |= MMC_MODE_HS400 |
 					MMC_MODE_HS_52MHz |
 					MMC_MODE_HS200 |
 					MMC_MODE_DDR_52MHz;
 			slot->cmd_out_hs200_delay =
-				ofnode_read_u32_default(node,
+				dev_read_u32_default(dev,
 					"marvell,cmd-out-hs200-dly",
 					MMC_DEFAULT_HS200_CMD_OUT_DLY);
 			debug("%s(%s): HS200 cmd out delay: %d\n",
 			      __func__, dev->name, slot->cmd_out_hs200_delay);
 			slot->data_out_hs200_delay =
-				ofnode_read_u32_default(node,
+				dev_read_u32_default(dev,
 					"marvell,data-out-hs200-dly",
 					MMC_DEFAULT_HS200_DATA_OUT_DLY);
 			debug("%s(%s): HS200 data out delay: %d\n",
 			      __func__, dev->name, slot->data_out_hs200_delay);
 			slot->cmd_out_hs400_delay =
-				ofnode_read_u32_default(node,
+				dev_read_u32_default(dev,
 					"marvell,cmd-out-hs400-dly",
 					MMC_DEFAULT_HS400_CMD_OUT_DLY);
 			debug("%s(%s): HS400 cmd out delay: %d\n",
 			      __func__, dev->name, slot->cmd_out_hs400_delay);
 			slot->data_out_hs400_delay =
-				ofnode_read_u32_default(node,
+				dev_read_u32_default(dev,
 					"marvell,data-out-hs400-dly",
 					MMC_DEFAULT_HS400_DATA_OUT_DLY);
 			debug("%s(%s): HS400 data out delay: %d\n",
@@ -3692,12 +3684,10 @@ static int octeontx_mmc_get_config(struct udevice *dev)
 		}
 	}
 
-	slot->disable_ddr = ofnode_read_bool(node, "marvell,disable-ddr");
-	slot->non_removable = ofnode_read_bool(node, "non-removable");
-	slot->cmd_clk_skew = ofnode_read_u32_default(node,
-						     "cavium,cmd-clk-skew", 0);
-	slot->dat_clk_skew = ofnode_read_u32_default(node,
-						     "cavium,dat-clk-skew", 0);
+	slot->disable_ddr = dev_read_bool(dev, "marvell,disable-ddr");
+	slot->non_removable = dev_read_bool(dev, "non-removable");
+	slot->cmd_clk_skew = dev_read_u32_default(dev, "cavium,cmd-clk-skew", 0);
+	slot->dat_clk_skew = dev_read_u32_default(dev, "cavium,dat-clk-skew", 0);
 	debug("%s(%s): host caps: 0x%x\n", __func__,
 	      dev->name, slot->cfg.host_caps);
 	return 0;
@@ -3843,7 +3833,6 @@ static int octeontx_mmc_host_probe(struct udevice *dev)
 		pr_err("%s: No device tree information found\n", __func__);
 		return -1;
 	}
-	host->node = dev_ofnode(dev);
 	host->last_slotid = -1;
 #if !defined(CONFIG_ARCH_OCTEON)
 	if (otx_is_platform(PLATFORM_ASIM))
@@ -3851,9 +3840,7 @@ static int octeontx_mmc_host_probe(struct udevice *dev)
 	if (otx_is_platform(PLATFORM_EMULATOR))
 		host->is_emul = true;
 #endif
-	host->dma_wait_delay =
-		ofnode_read_u32_default(dev_ofnode(dev),
-					"marvell,dma-wait-delay", 1);
+	host->dma_wait_delay = dev_read_u32_default(dev, "marvell,dma-wait-delay", 1);
 	/* Force reset of eMMC */
 	writeq(0, host->base_addr + MIO_EMM_CFG());
 	debug("%s: Clearing MIO_EMM_CFG\n", __func__);
@@ -3922,13 +3909,12 @@ static int octeontx_mmc_host_child_pre_probe(struct udevice *dev)
 	struct octeontx_mmc_host *host = dev_get_priv(dev_get_parent(dev));
 	struct octeontx_mmc_slot *slot;
 	struct mmc_uclass_priv *upriv;
-	ofnode node = dev_ofnode(dev);
 	u32 bus_id;
 	char name[16];
 	int err;
 
 	debug("%s(%s) Pre-Probe\n", __func__, dev->name);
-	if (ofnode_read_u32(node, "reg", &bus_id)) {
+	if (dev_read_u32(dev, "reg", &bus_id)) {
 		pr_err("%s(%s): Error: \"reg\" not found in device tree\n",
 		       __func__, dev->name);
 		return -1;
drivers/mmc/octeontx_hsmmc.h +0 -1
index 9849121f174..c374ce18838 100644
@@ -123,7 +123,6 @@ struct octeontx_mmc_host {
 	union mio_emm_cfg emm_cfg;
 	u64		timing_taps;
 	struct mmc	*last_mmc;	/** Last mmc used */
-	ofnode		node;
 	int		cur_slotid;
 	int		last_slotid;
 	int		max_width;
Signature · 1 line
2.51.0
#5 lore raw

PATCH 4/11 power: domain: meson-ee-pwrc: use dev_read_phandle_with_args for ao-sysctrl

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace the manual ofnode_read_u32() + ofnode_get_by_phandle() sequence with a single dev_read_phandle_with_args() call to resolve the amlogic,ao-sysctrl phandle. This is cleaner and avoids the intermediate phandle value and ofnode_valid() check.

No functional change.

---
 drivers/power/domain/meson-ee-pwrc.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/power/domain/meson-ee-pwrc.c +4 -9
index 6361f3a6c59..882238f2937 100644
@@ -435,8 +435,7 @@ static const struct udevice_id meson_ee_pwrc_ids[] = {
 static int meson_ee_pwrc_probe(struct udevice *dev)
 {
 	struct meson_ee_pwrc_priv *priv = dev_get_priv(dev);
-	u32 ao_phandle;
-	ofnode ao_node;
+	struct ofnode_phandle_args args;
 	int ret;
 
 	priv->data = (void *)dev_get_driver_data(dev);
@@ -447,16 +446,12 @@ static int meson_ee_pwrc_probe(struct udevice *dev)
 	if (IS_ERR(priv->regmap_hhi))
 		return PTR_ERR(priv->regmap_hhi);
 
-	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,ao-sysctrl",
-			      &ao_phandle);
+	ret = dev_read_phandle_with_args(dev, "amlogic,ao-sysctrl", NULL, 0, 0,
+					 &args);
 	if (ret)
 		return ret;
 
-	ao_node = ofnode_get_by_phandle(ao_phandle);
-	if (!ofnode_valid(ao_node))
-		return -EINVAL;
-
-	priv->regmap_ao = syscon_node_to_regmap(ao_node);
+	priv->regmap_ao = syscon_node_to_regmap(args.node);
 	if (IS_ERR(priv->regmap_ao))
 		return PTR_ERR(priv->regmap_ao);
 
Signature · 1 line
2.51.0
#7 lore raw

PATCH 5/11 power: domain: meson-gx-pwrc-vpu: use dev_read_phandle_with_args for hhi-sysctrl

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace the manual ofnode_read_u32() + ofnode_get_by_phandle() sequence with a single dev_read_phandle_with_args() call to resolve the amlogic,hhi-sysctrl phandle. This is cleaner and avoids the intermediate phandle value and ofnode_valid() check.

No functional change.

---
 drivers/power/domain/meson-gx-pwrc-vpu.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/power/domain/meson-gx-pwrc-vpu.c +4 -9
index 325296b0dd7..e08c0fac49a 100644
@@ -283,24 +283,19 @@ static const struct udevice_id meson_gx_pwrc_vpu_ids[] = {
 static int meson_gx_pwrc_vpu_probe(struct udevice *dev)
 {
 	struct meson_gx_pwrc_vpu_priv *priv = dev_get_priv(dev);
-	u32 hhi_phandle;
-	ofnode hhi_node;
+	struct ofnode_phandle_args args;
 	int ret;
 
 	priv->regmap_ao = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
 	if (IS_ERR(priv->regmap_ao))
 		return PTR_ERR(priv->regmap_ao);
 
-	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,hhi-sysctrl",
-			      &hhi_phandle);
+	ret = dev_read_phandle_with_args(dev, "amlogic,hhi-sysctrl", NULL, 0, 0,
+					 &args);
 	if (ret)
 		return ret;
 
-	hhi_node = ofnode_get_by_phandle(hhi_phandle);
-	if (!ofnode_valid(hhi_node))
-		return -EINVAL;
-
-	priv->regmap_hhi = syscon_node_to_regmap(hhi_node);
+	priv->regmap_hhi = syscon_node_to_regmap(args.node);
 	if (IS_ERR(priv->regmap_hhi))
 		return PTR_ERR(priv->regmap_hhi);
 
Signature · 1 line
2.51.0
#9 lore raw

PATCH 6/11 power: domain: imx8m: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace ofnode_for_each_subnode(subnode, dev_ofnode(dev)) with dev_for_each_subnode(subnode, dev) and ofnode_read_u32_default( dev_ofnode(dev), ...) with dev_read_u32_default(dev, ...).

No functional change.

---
 drivers/power/domain/imx8m-power-domain.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/domain/imx8m-power-domain.c +2 -2
index 5fdb95fb6a7..a3ef49aa67c 100644
@@ -476,7 +476,7 @@ static int imx8m_power_domain_bind(struct udevice *dev)
 	const char *name;
 	int ret = 0;
 
-	ofnode_for_each_subnode(subnode, dev_ofnode(dev)) {
+	dev_for_each_subnode(subnode, dev) {
 		/* Bind the subnode to this driver */
 		name = ofnode_get_name(subnode);
 
@@ -531,7 +531,7 @@ static int imx8m_power_domain_of_to_plat(struct udevice *dev)
 	struct imx_pgc_domain_data *domain_data =
 		(struct imx_pgc_domain_data *)dev_get_driver_data(dev);
 
-	pdata->resource_id = ofnode_read_u32_default(dev_ofnode(dev), "reg", -1);
+	pdata->resource_id = dev_read_u32_default(dev, "reg", -1);
 	pdata->domain = &domain_data->domains[pdata->resource_id];
 	pdata->regs = domain_data->pgc_regs;
 	pdata->base = dev_read_addr_ptr(dev->parent);
Signature · 1 line
2.51.0
#10 lore raw

PATCH 7/11 power: pmic: pca9450: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace ofnode_read_bool(dev_ofnode(dev), ...) with dev_read_bool(dev, ...).

No functional change.

---
 drivers/power/pmic/pca9450.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/pmic/pca9450.c +1 -1
index c95e6357ee8..cbe8cd05be7 100644
@@ -90,7 +90,7 @@ static int pca9450_probe(struct udevice *dev)
 			return ret;
 	}
 
-	if (ofnode_read_bool(dev_ofnode(dev), "nxp,wdog_b-warm-reset"))
+	if (dev_read_bool(dev, "nxp,wdog_b-warm-reset"))
 		reset_ctrl = PCA9450_PMIC_RESET_WDOG_B_CFG_WARM;
 	else
 		reset_ctrl = PCA9450_PMIC_RESET_WDOG_B_CFG_COLD_LDO12;
Signature · 1 line
2.51.0
#11 lore raw

PATCH 8/11 power: pmic: qcom: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace ofnode_read_u32_index(dev_ofnode(dev), ...) with dev_read_u32_index(dev, ...).

No functional change.

---
 drivers/power/pmic/pmic_qcom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/pmic/pmic_qcom.c +1 -1
index 92d0a95859b..4b8dcc6104c 100644
@@ -72,7 +72,7 @@ static int pmic_qcom_probe(struct udevice *dev)
 	 * contains two discrete values, not a single 64-bit address.
 	 * The address is the first value.
 	 */
-	ret = ofnode_read_u32_index(dev_ofnode(dev), "reg", 0, &priv->usid);
+	ret = dev_read_u32_index(dev, "reg", 0, &priv->usid);
 	if (ret < 0)
 		return -EINVAL;
 
Signature · 1 line
2.51.0
#13 lore raw

PATCH 9/11 power: regulator: anatop: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace ofnode_read_string(dev_ofnode(dev), ...) with dev_read_string(dev, ...).

No functional change.

---
 drivers/power/regulator/anatop_regulator.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/power/regulator/anatop_regulator.c +1 -2
index 824a753db16..88570a1f624 100644
@@ -170,8 +170,7 @@ static int anatop_regulator_probe(struct udevice *dev)
 	anatop_reg = dev_get_plat(dev);
 	uc_pdata = dev_get_uclass_plat(dev);
 
-	anatop_reg->name = ofnode_read_string(dev_ofnode(dev),
-					      "regulator-name");
+	anatop_reg->name = dev_read_string(dev, "regulator-name");
 	if (!anatop_reg->name)
 		return log_msg_ret("regulator-name", -EINVAL);
 
Signature · 1 line
2.51.0
#14 lore raw

PATCH 10/11 power: regulator: qcom-rpmh: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace ofnode_read_u32(dev_ofnode(dev), ...) with dev_read_u32(dev, ...), ofnode_read_string(dev_ofnode(dev), ...) with dev_read_string(dev, ...), and ofnode_for_each_subnode(node, dev_ofnode(dev)) with dev_for_each_subnode(node, dev).

No functional change.

---
 drivers/power/regulator/qcom-rpmh-regulator.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/power/regulator/qcom-rpmh-regulator.c +4 -3
index 4d65aae1690..f1de660c3a0 100644
@@ -5,6 +5,7 @@
 #define pr_fmt(fmt) "%s: " fmt, __func__
 
 #include <linux/err.h>
+#include <dm.h>
 #include <dm/device_compat.h>
 #include <dm/device.h>
 #include <dm/devres.h>
@@ -882,7 +883,7 @@ static int rpmh_regulator_probe(struct udevice *dev)
 	priv->hw_data = init_data->hw_data;
 	priv->enabled = -EINVAL;
 	priv->uv = -ENOTRECOVERABLE;
-	if (ofnode_read_u32(dev_ofnode(dev), "regulator-initial-mode", &priv->mode))
+	if (dev_read_u32(dev, "regulator-initial-mode", &priv->mode))
 		priv->mode = -EINVAL;
 
 	plat_data->mode = priv->hw_data->pmic_mode_map;
@@ -933,7 +934,7 @@ static int rpmh_regulators_bind(struct udevice *dev)
 		return -ENODEV;
 	}
 
-	pmic_id = ofnode_read_string(dev_ofnode(dev), "qcom,pmic-id");
+	pmic_id = dev_read_string(dev, "qcom,pmic-id");
 	if (!pmic_id) {
 		dev_err(dev, "No PMIC ID\n");
 		return -ENODEV;
@@ -941,7 +942,7 @@ static int rpmh_regulators_bind(struct udevice *dev)
 
 	drv = lists_driver_lookup_name("rpmh_regulator_drm");
 
-	ofnode_for_each_subnode(node, dev_ofnode(dev)) {
+	dev_for_each_subnode(node, dev) {
 		data = vreg_get_init_data(init_data, node);
 		if (!data)
 			continue;
Signature · 1 line
2.51.0
#16 lore raw

PATCH 11/11 power: regulator: scmi: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace ofnode_find_subnode(dev_ofnode(dev), ...) with dev_read_subnode(dev, ...).

No functional change.

---
 drivers/power/regulator/scmi_regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/regulator/scmi_regulator.c +1 -1
index 7d2db1e2bee..aa7b4278260 100644
@@ -180,7 +180,7 @@ static int scmi_regulator_bind(struct udevice *dev)
 	ofnode node;
 	int ret;
 
-	regul_node = ofnode_find_subnode(dev_ofnode(dev), "regulators");
+	regul_node = dev_read_subnode(dev, "regulators");
 	if (!ofnode_valid(regul_node)) {
 		dev_err(dev, "no regulators node\n");
 		return -ENXIO;
Signature · 1 line
2.51.0
Reviewed-by on v1 8/11
#12 lore raw

Re: [PATCH 08/11] power: pmic: qcom: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)
Quoted 8 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace ofnode_read_u32_index(dev_ofnode(dev), ...) with dev_read_u32_index(dev, ...).

No functional change.

Quoted 18 lines
---
  drivers/power/pmic/pmic_qcom.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/pmic/pmic_qcom.c +1 -1
index 92d0a95859b..4b8dcc6104c 100644
@@ -72,7 +72,7 @@ static int pmic_qcom_probe(struct udevice *dev)
  	 * contains two discrete values, not a single 64-bit address.
  	 * The address is the first value.
  	 */
-	ret = ofnode_read_u32_index(dev_ofnode(dev), "reg", 0, &priv->usid);
+	ret = dev_read_u32_index(dev, "reg", 0, &priv->usid);
  	if (ret < 0)
  		return -EINVAL;
 
Reviewed-by on v1 10/11
#15 lore raw

Re: [PATCH 10/11] power: regulator: qcom-rpmh: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)
Quoted 10 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace ofnode_read_u32(dev_ofnode(dev), ...) with dev_read_u32(dev, ...), ofnode_read_string(dev_ofnode(dev), ...) with dev_read_string(dev, ...), and ofnode_for_each_subnode(node, dev_ofnode(dev)) with dev_for_each_subnode(node, dev).

No functional change.

Quoted 44 lines
---
  drivers/power/regulator/qcom-rpmh-regulator.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/power/regulator/qcom-rpmh-regulator.c +4 -3
index 4d65aae1690..f1de660c3a0 100644
@@ -5,6 +5,7 @@
  #define pr_fmt(fmt) "%s: " fmt, __func__
 
  #include <linux/err.h>
+#include <dm.h>
  #include <dm/device_compat.h>
  #include <dm/device.h>
  #include <dm/devres.h>
@@ -882,7 +883,7 @@ static int rpmh_regulator_probe(struct udevice *dev)
  	priv->hw_data = init_data->hw_data;
  	priv->enabled = -EINVAL;
  	priv->uv = -ENOTRECOVERABLE;
-	if (ofnode_read_u32(dev_ofnode(dev), "regulator-initial-mode", &priv->mode))
+	if (dev_read_u32(dev, "regulator-initial-mode", &priv->mode))
  		priv->mode = -EINVAL;
 
  	plat_data->mode = priv->hw_data->pmic_mode_map;
@@ -933,7 +934,7 @@ static int rpmh_regulators_bind(struct udevice *dev)
  		return -ENODEV;
  	}
 
-	pmic_id = ofnode_read_string(dev_ofnode(dev), "qcom,pmic-id");
+	pmic_id = dev_read_string(dev, "qcom,pmic-id");
  	if (!pmic_id) {
  		dev_err(dev, "No PMIC ID\n");
  		return -ENODEV;
@@ -941,7 +942,7 @@ static int rpmh_regulators_bind(struct udevice *dev)
 
  	drv = lists_driver_lookup_name("rpmh_regulator_drm");
 
-	ofnode_for_each_subnode(node, dev_ofnode(dev)) {
+	dev_for_each_subnode(node, dev) {
  		data = vreg_get_init_data(init_data, node);
  		if (!data)
  			continue;
Reviewed-by on v1 2/11
#3 lore raw

Re: [PATCH 02/11] mmc: msm_sdhci: convert ofnode API to dev_read API

In reply to Peng Fan (OSS)
Quoted 10 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace ofnode_read_u32(), ofnode_get_property() and ofnode_read_string_index() with their dev_read_*() equivalents in msm_sdc_clk_init(). Remove the intermediate 'ofnode node' local variable.

No functional change.

Quoted 43 lines
---
  drivers/mmc/msm_sdhci.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
drivers/mmc/msm_sdhci.c +3 -4
index aaa87923604..7bdb02142a2 100644
@@ -64,14 +64,13 @@ static int msm_sdc_clk_init(struct udevice *dev)
  {
  	struct msm_sdhc *prv = dev_get_priv(dev);
  	const struct msm_sdhc_variant_info *var_info;
-	ofnode node = dev_ofnode(dev);
  	ulong clk_rate;
  	int ret, i = 0, n_clks;
  	const char *clk_name;
 
  	var_info = (void *)dev_get_driver_data(dev);
 
-	if (ofnode_read_u32(node, "max-frequency", (uint *)(&clk_rate)))
+	if (dev_read_u32(dev, "max-frequency", (uint *)(&clk_rate)))
  		clk_rate = 201500000;
 
  	ret = clk_get_bulk(dev, &prv->clks);
@@ -87,7 +86,7 @@ static int msm_sdc_clk_init(struct udevice *dev)
  	}
 
  	/* If clock-names is unspecified, then the first clock is the core clock */
-	if (!ofnode_get_property(node, "clock-names", &n_clks)) {
+	if (!dev_read_prop(dev, "clock-names", &n_clks)) {
  		if (!clk_set_rate(&prv->clks.clks[0], clk_rate)) {
  			log_warning("Couldn't set core clock rate: %d\n", ret);
  			return -EINVAL;
@@ -96,7 +95,7 @@ static int msm_sdc_clk_init(struct udevice *dev)
 
  	/* Find the index of the "core" clock */
  	while (i < n_clks) {
-		ofnode_read_string_index(node, "clock-names", i, &clk_name);
+		dev_read_string_index(dev, "clock-names", i, &clk_name);
  		if (!strcmp(clk_name, "core"))
  			break;
  		i++;
maintainer Reviewed-by on v1 5/11
#8 lore raw

Re: [PATCH 05/11] power: domain: meson-gx-pwrc-vpu: use dev_read_phandle_with_args for hhi-sysctrl

In reply to Peng Fan (OSS)
Quoted 38 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace the manual ofnode_read_u32() + ofnode_get_by_phandle() sequence with a single dev_read_phandle_with_args() call to resolve the amlogic,hhi-sysctrl phandle. This is cleaner and avoids the intermediate phandle value and ofnode_valid() check.

No functional change.

---
  drivers/power/domain/meson-gx-pwrc-vpu.c | 13 ++++---------
  1 file changed, 4 insertions(+), 9 deletions(-)
drivers/power/domain/meson-gx-pwrc-vpu.c +3 -4
index 325296b0dd7..e08c0fac49a 100644
@@ -283,24 +283,19 @@ static const struct udevice_id meson_gx_pwrc_vpu_ids[] = {
  static int meson_gx_pwrc_vpu_probe(struct udevice *dev)
  {
  	struct meson_gx_pwrc_vpu_priv *priv = dev_get_priv(dev);
-	u32 hhi_phandle;
-	ofnode hhi_node;
+	struct ofnode_phandle_args args;
  	int ret;
 
  	priv->regmap_ao = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
  	if (IS_ERR(priv->regmap_ao))
  		return PTR_ERR(priv->regmap_ao);
 
-	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,hhi-sysctrl",
-			      &hhi_phandle);
+	ret = dev_read_phandle_with_args(dev, "amlogic,hhi-sysctrl", NULL, 0, 0,
+					 &args);
  	if (ret)
  		return ret;

drivers/power/domain/meson-gx-pwrc-vpu.c static const struct udevice_id meson_gx_pwrc_vpu_ids[] = { · line 301

Quoted 10 lines
drivers/power/domain/meson-gx-pwrc-vpu.c +1 -5
 
-	hhi_node = ofnode_get_by_phandle(hhi_phandle);
-	if (!ofnode_valid(hhi_node))
-		return -EINVAL;
-
-	priv->regmap_hhi = syscon_node_to_regmap(hhi_node);
+	priv->regmap_hhi = syscon_node_to_regmap(args.node);
  	if (IS_ERR(priv->regmap_hhi))
  		return PTR_ERR(priv->regmap_hhi);
 

Thanks,
Neil

maintainer Reviewed-by on v1 4/11
#6 lore raw

Re: [PATCH 04/11] power: domain: meson-ee-pwrc: use dev_read_phandle_with_args for ao-sysctrl

In reply to Peng Fan (OSS)
Quoted 39 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Replace the manual ofnode_read_u32() + ofnode_get_by_phandle() sequence with a single dev_read_phandle_with_args() call to resolve the amlogic,ao-sysctrl phandle. This is cleaner and avoids the intermediate phandle value and ofnode_valid() check.

No functional change.

---
  drivers/power/domain/meson-ee-pwrc.c | 13 ++++---------
  1 file changed, 4 insertions(+), 9 deletions(-)
drivers/power/domain/meson-ee-pwrc.c +3 -4
index 6361f3a6c59..882238f2937 100644
@@ -435,8 +435,7 @@ static const struct udevice_id meson_ee_pwrc_ids[] = {
  static int meson_ee_pwrc_probe(struct udevice *dev)
  {
  	struct meson_ee_pwrc_priv *priv = dev_get_priv(dev);
-	u32 ao_phandle;
-	ofnode ao_node;
+	struct ofnode_phandle_args args;
  	int ret;
 
  	priv->data = (void *)dev_get_driver_data(dev);
@@ -447,16 +446,12 @@ static int meson_ee_pwrc_probe(struct udevice *dev)
  	if (IS_ERR(priv->regmap_hhi))
  		return PTR_ERR(priv->regmap_hhi);
 
-	ret = ofnode_read_u32(dev_ofnode(dev), "amlogic,ao-sysctrl",
-			      &ao_phandle);
+	ret = dev_read_phandle_with_args(dev, "amlogic,ao-sysctrl", NULL, 0, 0,
+					 &args);
  	if (ret)
  		return ret;

drivers/power/domain/meson-ee-pwrc.c static int meson_ee_pwrc_probe(struct udevice *dev) · line 457

Quoted 10 lines
drivers/power/domain/meson-ee-pwrc.c +1 -5
 
-	ao_node = ofnode_get_by_phandle(ao_phandle);
-	if (!ofnode_valid(ao_node))
-		return -EINVAL;
-
-	priv->regmap_ao = syscon_node_to_regmap(ao_node);
+	priv->regmap_ao = syscon_node_to_regmap(args.node);
  	if (IS_ERR(priv->regmap_ao))
  		return PTR_ERR(priv->regmap_ao);
 

Thanks,
Neil