[PATCH 3/9] ARM: boards: protonic-rk356x: Use devicetree alias for saradc
Robin van der Gracht
robin.van.der.gracht at protonic.nl
Wed Mar 4 03:00:07 PST 2026
Using an alias in the device tree is cleaner and more flexible than a
hard coded address. This change paves the way for adding support for a
chip with the saradc at a different address (i.e. RK3562) later on.
Signed-off-by: Robin van der Gracht <robin.van.der.gracht at protonic.nl>
---
arch/arm/boards/protonic-rk356x/board.c | 18 ++++++++++--------
arch/arm/dts/rk3568-mecsbc.dts | 1 +
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/arch/arm/boards/protonic-rk356x/board.c b/arch/arm/boards/protonic-rk356x/board.c
index c01438847a..aec0303e94 100644
--- a/arch/arm/boards/protonic-rk356x/board.c
+++ b/arch/arm/boards/protonic-rk356x/board.c
@@ -40,7 +40,7 @@ static int saradc_get_value(const char *chan)
static bool prt_rk356x_get_usb_boot(void)
{
- return saradc_get_value("aiodev0.in_value0_mV") < 74;
+ return saradc_get_value("saradc.in_value0_mV") < 74;
}
static int prt_rk356x_adc_id_values[] = {
@@ -64,8 +64,8 @@ static int prt_rk356x_get_adc_id(const char *chan)
static void prt_rk356x_process_adc(struct device *dev)
{
- prt_priv.hw_id = prt_rk356x_get_adc_id("aiodev0.in_value1_mV");
- prt_priv.hw_rev = prt_rk356x_get_adc_id("aiodev0.in_value3_mV");
+ prt_priv.hw_id = prt_rk356x_get_adc_id("saradc.in_value1_mV");
+ prt_priv.hw_rev = prt_rk356x_get_adc_id("saradc.in_value3_mV");
dev_add_param_uint32_ro(dev, "boardrev", &prt_priv.hw_rev, "%u");
dev_add_param_uint32_ro(dev, "boardid", &prt_priv.hw_id, "%u");
@@ -123,14 +123,16 @@ static int prt_rk356x_of_fixup_hwrev(struct device *dev)
static int prt_rk356x_probe(struct device *dev)
{
- int ret = 0;
+ int error;
enum bootsource bootsource = bootsource_get();
int instance = bootsource_get_instance();
const struct prt_rk356x_model *model;
- struct device_node *np;
- np = of_find_node_by_name_address(NULL, "saradc at fe720000");
- of_device_ensure_probed(np);
+ error = of_device_ensure_probed_by_alias("saradc");
+ if (error) {
+ pr_err("saradc is not available\n");
+ return error;
+ }
model = device_get_match_data(dev);
@@ -148,7 +150,7 @@ static int prt_rk356x_probe(struct device *dev)
prt_rk356x_process_adc(dev);
prt_rk356x_of_fixup_hwrev(dev);
- return ret;
+ return 0;
}
static const struct prt_rk356x_model mecsbc = {
diff --git a/arch/arm/dts/rk3568-mecsbc.dts b/arch/arm/dts/rk3568-mecsbc.dts
index 1beea32f03..7407f59f9e 100644
--- a/arch/arm/dts/rk3568-mecsbc.dts
+++ b/arch/arm/dts/rk3568-mecsbc.dts
@@ -10,6 +10,7 @@ / {
aliases {
state = &state_emmc;
+ saradc = &saradc;
};
chosen: chosen {
--
2.43.0
More information about the barebox
mailing list