aboutsummaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authorSamuel Holland <samuel.holland@sifive.com>2024-09-03 19:09:39 -0700
committerAnup Patel <anup@brainfault.org>2024-11-05 17:54:41 +0530
commit9782b8847dabe910d1584d79a6e1701111951354 (patch)
tree6392bf1cf1c0908f2a002f04ef55e84df55be9c5 /lib/utils
parentd71150ee7047c4d7ad67525731cc6271939d782c (diff)
downloadopensbi-9782b8847dabe910d1584d79a6e1701111951354.zip
opensbi-9782b8847dabe910d1584d79a6e1701111951354.tar.gz
opensbi-9782b8847dabe910d1584d79a6e1701111951354.tar.bz2
lib: utils/regmap: Use FDT node offset as regmap ID
Since the FDT is not modified during driver initialization, node offsets are just as suitable as phandles for use as identifiers: they are stable and unique. With this change, it is no longer necessary to pass the phandle to the driver init functions, so these init functions now use the same prototype as other kinds of drivers. This matches what is already done for I2C adapters. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/regmap/fdt_regmap.c14
-rw-r--r--lib/utils/regmap/fdt_regmap_syscon.c4
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/utils/regmap/fdt_regmap.c b/lib/utils/regmap/fdt_regmap.c
index f02d2f0..933938f 100644
--- a/lib/utils/regmap/fdt_regmap.c
+++ b/lib/utils/regmap/fdt_regmap.c
@@ -16,7 +16,7 @@
extern struct fdt_regmap *fdt_regmap_drivers[];
extern unsigned long fdt_regmap_drivers_size;
-static int fdt_regmap_init(const void *fdt, int nodeoff, u32 phandle)
+static int fdt_regmap_init(const void *fdt, int nodeoff)
{
int pos, rc;
struct fdt_regmap *drv;
@@ -27,7 +27,7 @@ static int fdt_regmap_init(const void *fdt, int nodeoff, u32 phandle)
drv = fdt_regmap_drivers[pos];
match = fdt_match_node(fdt, nodeoff, drv->match_table);
if (match && drv->init) {
- rc = drv->init(fdt, nodeoff, phandle, match);
+ rc = drv->init(fdt, nodeoff, match);
if (rc == SBI_ENODEV)
continue;
if (rc)
@@ -39,20 +39,20 @@ static int fdt_regmap_init(const void *fdt, int nodeoff, u32 phandle)
return SBI_ENOSYS;
}
-static int fdt_regmap_find(const void *fdt, int nodeoff, u32 phandle,
+static int fdt_regmap_find(const void *fdt, int nodeoff,
struct regmap **out_rmap)
{
int rc;
- struct regmap *rmap = regmap_find(phandle);
+ struct regmap *rmap = regmap_find(nodeoff);
if (!rmap) {
/* Regmap not found so initialize matching driver */
- rc = fdt_regmap_init(fdt, nodeoff, phandle);
+ rc = fdt_regmap_init(fdt, nodeoff);
if (rc)
return rc;
/* Try to find regmap again */
- rmap = regmap_find(phandle);
+ rmap = regmap_find(nodeoff);
if (!rmap)
return SBI_ENOSYS;
}
@@ -75,7 +75,7 @@ int fdt_regmap_get_by_phandle(const void *fdt, u32 phandle,
if (pnodeoff < 0)
return pnodeoff;
- return fdt_regmap_find(fdt, pnodeoff, phandle, out_rmap);
+ return fdt_regmap_find(fdt, pnodeoff, out_rmap);
}
int fdt_regmap_get(const void *fdt, int nodeoff, struct regmap **out_rmap)
diff --git a/lib/utils/regmap/fdt_regmap_syscon.c b/lib/utils/regmap/fdt_regmap_syscon.c
index a95f251..ba55908 100644
--- a/lib/utils/regmap/fdt_regmap_syscon.c
+++ b/lib/utils/regmap/fdt_regmap_syscon.c
@@ -159,7 +159,7 @@ static int regmap_syscon_write_be32(struct regmap *rmap, unsigned int reg,
return 0;
}
-static int regmap_syscon_init(const void *fdt, int nodeoff, u32 phandle,
+static int regmap_syscon_init(const void *fdt, int nodeoff,
const struct fdt_match *match)
{
struct syscon_regmap *srm;
@@ -188,7 +188,7 @@ static int regmap_syscon_init(const void *fdt, int nodeoff, u32 phandle,
goto fail_free_syscon;
srm->addr = addr;
- srm->rmap.id = phandle;
+ srm->rmap.id = nodeoff;
srm->rmap.reg_shift = 0;
srm->rmap.reg_stride = srm->reg_io_width * 8;
srm->rmap.reg_base = 0;