Accessing registers from another driver

Luca Ellero lroluk at gmail.com
Wed Sep 27 05:58:12 EDT 2017


Hi,

in a watchdog driver on an ARM platform, I have the need to write a hw 
register managed by another driver (system reset controller).

I'm wondering what is the correct/clean way of doing that.

What I've done until now is adding a second couple in the "reg" property 
of the device-tree

&wdog1 {
         pinctrl-names = "default";
         pinctrl-0 = <&pinctrl_wdog>;
reg = <0x30280000 0x10000>, <0x30390000 0x10000>;
         fsl,wdog_b;
  };

and then in the wdog driver adding the following code:


static void __iomem *src_base;

...

res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
src_base = devm_ioremap(&pdev->dev, res->start, res->end - res->start + 1);
if (IS_ERR(src_base))
         return PTR_ERR(src_base);

...

writel(0x3, src_base + 4);


In this way it works as expected, but I'm not sure if this is correct?

Thanks

Best regards

Luca





More information about the Kernelnewbies mailing list