syscon: update syscon_regmap_lookup_by_phandle
cover syscon: update syscon_regmap_lookup_by_phandle
Change the function syscon_regmap_lookup_by_phandle() introduced by commit 6c3af1f24e4b ("syscon: dm: Add a new method to get a regmap from DTS") to have Linux-compatible syscon API and add test for this case:
phandle to node with generic "syscon" compatible not bound as syscon UCLASS by default.
Without the patch the added test failed.
And I also update sysreset-syscon driver to use this function and simplify the code,
tested on my stm32mp1 board with:
rcc_reboot: rcc-reboot at 50000000 {
compatible = "syscon-reboot";
regmap = <&rcc>;
offset = <0x404>;
mask = <0x1>;
};
rcc: rcc at 50000000 {
compatible = "st,stm32mp1-rcc", "syscon";
reg = <0x50000000 0x1000>;
#clock-cells = <1>;
#reset-cells = <1>;
};PS: compatible st,stm32mp1-rcc is bound to driver
drivers/misc/stm32_rcc.c
Patrick Delaunay (2):
syscon: update syscon_regmap_lookup_by_phandle
sysreset: use syscon_regmap_lookup_by_phandle
arch/sandbox/dts/test.dts | 3 +- drivers/core/syscon-uclass.c | 83 +++++++++++++++++++++++++++----------- drivers/sysreset/sysreset_syscon.c | 15 +------ test/dm/syscon.c | 7 ++++ 4 files changed, 70 insertions(+), 38 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/2 syscon: update syscon_regmap_lookup_by_phandle
Change the function syscon_regmap_lookup_by_phandle() introduced by commit 6c3af1f24e4b ("syscon: dm: Add a new method to get a regmap from DTS") to have Linux-compatible syscon API.
Same modification than commit e151a1c288bd ("syscon: add Linux-compatible syscon API") solves issue when the node identified by the phandle has several compatibles and is already bound to a dedicated driver.
See Linux commit bdb0066df96e ("mfd: syscon: Decouple syscon interface from platform devices").
---
arch/sandbox/dts/test.dts | 3 +- drivers/core/syscon-uclass.c | 83 +++++++++++++++++++++++++++++++------------- test/dm/syscon.c | 7 ++++ 3 files changed, 68 insertions(+), 25 deletions(-)
arch/sandbox/dts/test.dts +2 -1
@@ -493,6 +493,7 @@ compatible = "denx,u-boot-probe-test"; first-syscon = <&syscon0>; second-sys-ctrl = <&another_system_controller>; + third-syscon = <&syscon2>; }; };
@@ -597,7 +598,7 @@ 0x38 8>; }; - syscon at 2 { + syscon2: syscon at 2 { compatible = "simple-mfd", "syscon"; reg = <0x40 5 0x48 6
drivers/core/syscon-uclass.c +59 -24
106 lines not on this page · raw message
test/dm/syscon.c +7 -0
@@ -67,6 +67,13 @@ static int dm_test_syscon_by_phandle(struct unit_test_state *uts)ut_assert (!IS_ERR (map));ut_asserteq (4 , map->range_count); +ut_assertok_ptr (syscon_regmap_lookup_by_phandle (dev, +"third-syscon" )); + map =syscon_regmap_lookup_by_phandle (dev,"third-syscon" ); +ut_assert (map); +ut_assert (!IS_ERR (map)); +ut_asserteq (4 , map->range_count); +ut_assert (IS_ERR (syscon_regmap_lookup_by_phandle (dev,"not-present" )));return 0 ;
Signature · 1 line
2.7.4
PATCH 1/2 syscon: update syscon_regmap_lookup_by_phandle
Quoted 14 lines · Patrick Delaunay
Change the function
syscon_regmap_lookup_by_phandle()introduced by commit6c3af1f24e4b("syscon: dm: Add a new method to get a regmap from DTS") to have Linux-compatible syscon API.Same modification than commit
e151a1c288bd("syscon: add Linux-compatible syscon API") solves issue when the node identified by the phandle has several compatibles and is already bound to a dedicated driver.See Linux commit
bdb0066df96e("mfd: syscon: Decouple syscon interface from platform devices").
Quoted 8 lines
Signed-off-by Patrick Delaunay <[email protected]>---
arch/sandbox/dts/test.dts | 3 +- drivers/core/syscon-uclass.c | 83 +++++++++++++++++++++++++++++++------------- test/dm/syscon.c | 7 ++++ 3 files changed, 68 insertions(+), 25 deletions(-)
PATCH 2/2 sysreset: use syscon_regmap_lookup_by_phandle
In reply to Patrick DelaunayUse the new function syscon_regmap_lookup_by_phandle() to simplify the code.
---
drivers/sysreset/sysreset_syscon.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/sysreset/sysreset_syscon.c +2 -13
@@ -36,20 +36,9 @@ static struct sysreset_ops syscon_reboot_ops = {int syscon_reboot_probe (struct udevice *dev) {struct syscon_reboot_priv *priv =dev_get_priv (dev); -int err; -u32 phandle; -ofnode node; - err =ofnode_read_u32 (dev_ofnode (dev),"regmap" , &phandle); -if (err) -return err; - - node =ofnode_get_by_phandle (phandle); -if (!ofnode_valid (node)) -return -EINVAL ; - - priv->regmap =syscon_node_to_regmap (node); -if (!priv->regmap) { + priv->regmap =syscon_regmap_lookup_by_phandle (dev,"regmap" ); +if (IS_ERR (priv->regmap)) {pr_err ("unable to find regmap\n" );return -ENODEV ; }
Signature · 1 line
2.7.4