diff mbox series

[03/13] ARM: imx27: Retrieve the SYSCTRL base address from devicetree

Message ID 20200916205522.8783-4-festevam@gmail.com
State New
Headers show
Series ARM: imx: Further cleanups due to dt-only conversion | expand

Commit Message

Fabio Estevam Sept. 16, 2020, 8:55 p.m. UTC
Now that imx27 has been converted to a devicetree-only platform,
retrieve the SYSCTRL base address from devicetree.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 arch/arm/mach-imx/cpu-imx27.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Arnd Bergmann Sept. 16, 2020, 9:30 p.m. UTC | #1
On Wed, Sep 16, 2020 at 10:55 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> Now that imx27 has been converted to a devicetree-only platform,
> retrieve the SYSCTRL base address from devicetree.
>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>

While this is nicer in theory, I don't like the way it breaks compatibility
with old dtb files that are lacking the device node.

What is the status of dtb stability otherwise on imx? My impression
was that it is actually quite good about not breaking this way.

      Arnd
Fabio Estevam Sept. 16, 2020, 9:36 p.m. UTC | #2
Hi Arnd,

On Wed, Sep 16, 2020 at 6:30 PM Arnd Bergmann <arnd@arndb.de> wrote:

> While this is nicer in theory, I don't like the way it breaks compatibility
> with old dtb files that are lacking the device node.

Good point. Let me access this SYSCTRL region via the CCM register space then.

In the current devicetree CCM region already overlaps with the SYSCTRL region.

This way we don't break dt compatibility.

> What is the status of dtb stability otherwise on imx? My impression
> was that it is actually quite good about not breaking this way.

Yes, we try to keep dt compatibility as much as possible.

Thanks
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/cpu-imx27.c b/arch/arm/mach-imx/cpu-imx27.c
index a969aa71b60f..2c8430f34556 100644
--- a/arch/arm/mach-imx/cpu-imx27.c
+++ b/arch/arm/mach-imx/cpu-imx27.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <linux/io.h>
+#include <linux/of_address.h>
 #include <linux/module.h>
 
 #include "hardware.h"
@@ -20,13 +21,19 @@  static int mx27_cpu_partnumber;
 
 static int mx27_read_cpu_rev(void)
 {
+	void __iomem *sysctrl_base;
+	struct device_node *np;
 	u32 val;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,imx27-sysctrl");
+	sysctrl_base = of_iomap(np, 0);
+	BUG_ON(!sysctrl_base);
 	/*
 	 * now we have access to the IO registers. As we need
 	 * the silicon revision very early we read it here to
 	 * avoid any further hooks
 	*/
-	val = imx_readl(MX27_IO_ADDRESS(MX27_SYSCTRL_BASE_ADDR + SYS_CHIP_ID));
+	val = imx_readl(sysctrl_base + SYS_CHIP_ID);
 
 	mx27_cpu_partnumber = (int)((val >> 12) & 0xFFFF);