using the same regmap by multiple device drivers

From: Vitaly Andrianov
Date: Wed Jun 29 2016 - 13:18:53 EST


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