Skip to contentSkip to conversation

using the same regmap by multiple device drivers

DISCUSSION Vitaly Andrianov 2 participants 3 messages Jun 29, 2016

lore
Share & tools
lore
#0 lore raw

Hello,

I'm working on two drivers "crypto" and "hwrng", which use the same hardware module and the same block of registers. Actually the drivers don't need to access the same registers except several common ones.

Here is fragment of dts.

sa_subsys: subsys@1234000 {
	compatible	= "syscon";
	reg		= <0x1234000 0x1000>;
};
crypto@1234000 {
	compatible = "ti,netcp-sa-crypto";
	syscon-subsys = <&sa_subsys>;
	clocks = <&clksa>;
	.....
};
rng@1234000 {
	compatible = "ti,keystone-rng";
	syscon-subsys = <&sa_subsys>;
	clocks = <&clksa>;
};

The both drivers use

regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,

				  	"syscon-subsys");

to get pointers to "struct regmap".

Unfortunately I can get the first driver working only. When the second driver tries to call regmap_read() kernel gives "Division by zero in kernel" error.

Here is my question. Is that actually possible to use in regmap framework the same registers in multiple different drivers?

Thank you,
-Vitaly

#1 lore raw
Quoted 2 lines · Vitaly Andrianov

Here is my question. Is that actually possible to use in regmap framework the same registers in multiple different drivers?

Of course, this is how the vast majority of MFDs work. The regmap has no idea what's calling it, it can't tell if a call comes from one driver or another.

#2 lore raw
Quoted 9 lines · Mark Brown
Quoted 2 lines · Vitaly Andrianov

Here is my question. Is that actually possible to use in regmap framework the same registers in multiple different drivers?

Of course, this is how the vast majority of MFDs work. The regmap has no idea what's calling it, it can't tell if a call comes from one driver or another.

Thank you.