diff mbox

[10/10] boot-mode-reg: Convert to device tree

Message ID 1462778041-19595-11-git-send-email-dirk.behme@de.bosch.com (mailing list archive)
State Superseded
Delegated to: Simon Horman
Headers show

Commit Message

Dirk Behme May 9, 2016, 7:14 a.m. UTC
From: Dirk Behme <dirk.behme@gmail.com>

Instead of using a hard coded address in the driver for the boot mode
register, optain it from the device tree.

Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
---
 drivers/misc/boot-mode-reg/rcar.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Geert Uytterhoeven May 9, 2016, 7:46 a.m. UTC | #1
On Mon, May 9, 2016 at 9:14 AM, Dirk Behme <dirk.behme@de.bosch.com> wrote:
> --- a/drivers/misc/boot-mode-reg/rcar.c
> +++ b/drivers/misc/boot-mode-reg/rcar.c
> @@ -16,24 +16,32 @@
>  #include <linux/io.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/of_address.h>
>
>  #include <misc/boot-mode-reg.h>
>
> -#define MODEMR 0xe6160060
> -
>  static int __init rcar_read_mode_pins(void)
>  {
>         void __iomem *modemr;
> +       struct device_node *np;
>         int err = -ENOMEM;
>         static u32 mode;
>
> -       modemr = ioremap_nocache(MODEMR, 4);
> +       np = of_find_compatible_node(NULL, NULL, "renesas,modemr");
> +       if (!np) {
> +               pr_err("can't find renesas,modemr device node");
> +               goto err;

At least for R-Car Gen2, we need to preserve compatibility with old DTBs that
don't have the node in DT.

> +       }
> +
> +       modemr = of_iomap(np, 0);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
diff mbox

Patch

diff --git a/drivers/misc/boot-mode-reg/rcar.c b/drivers/misc/boot-mode-reg/rcar.c
index e994980..2cfbf9c 100644
--- a/drivers/misc/boot-mode-reg/rcar.c
+++ b/drivers/misc/boot-mode-reg/rcar.c
@@ -16,24 +16,32 @@ 
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 
 #include <misc/boot-mode-reg.h>
 
-#define MODEMR 0xe6160060
-
 static int __init rcar_read_mode_pins(void)
 {
 	void __iomem *modemr;
+	struct device_node *np;
 	int err = -ENOMEM;
 	static u32 mode;
 
-	modemr = ioremap_nocache(MODEMR, 4);
+	np = of_find_compatible_node(NULL, NULL, "renesas,modemr");
+	if (!np) {
+		pr_err("can't find renesas,modemr device node");
+		goto err;
+	}
+
+	modemr = of_iomap(np, 0);
 	if (!modemr) {
 		pr_err("failed to map boot mode register");
+		of_node_put(np);
 		goto err;
 	}
 	mode = ioread32(modemr);
 	iounmap(modemr);
+	of_node_put(np);
 
 	err = boot_mode_reg_set(mode);
 err: