Patchwork [U-Boot,v3,08/16] dm: Set up driver model after relocation

login
register
mail settings
Submitter Simon Glass
Date June 19, 2013, 3:52 a.m.
Message ID <1371613960-28678-9-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/252469/
State Superseded
Delegated to: Tom Rini
Headers show

Comments

Simon Glass - June 19, 2013, 3:52 a.m.
Make driver model available after relocation, by setting up data structures
and scanning for devices using compiled-in platform_data and (when available)
the device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v3: None
Changes in v2: None

 common/board_r.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
Marek Vasut - June 28, 2013, 8:53 p.m.
Dear Simon Glass,

> Make driver model available after relocation, by setting up data structures
> and scanning for devices using compiled-in platform_data and (when
> available) the device tree.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> Changes in v3: None
> Changes in v2: None
> 
>  common/board_r.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/common/board_r.c b/common/board_r.c
> index f5649c9..5fe86ef 100644
> --- a/common/board_r.c
> +++ b/common/board_r.c
> @@ -34,6 +34,7 @@
>  #ifdef CONFIG_HAS_DATAFLASH
>  #include <dataflash.h>
>  #endif
> +#include <dm.h>
>  #include <environment.h>
>  #include <fdtdec.h>
>  #if defined(CONFIG_CMD_IDE)
> @@ -66,7 +67,9 @@
>  #ifdef CONFIG_X86
>  #include <asm/init_helpers.h>
>  #endif
> +#include <dm/root.h>
>  #include <linux/compiler.h>
> +#include <linux/err.h>
> 
>  DECLARE_GLOBAL_DATA_PTR;
> 
> @@ -269,6 +272,33 @@ static int initr_malloc(void)
>  	return 0;
>  }
> 
> +#ifdef CONFIG_DM
> +static int initr_dm(void)
> +{
> +	int ret;
> +
> +	ret = dm_init();
> +	if (ret) {
> +		debug("dm_init() failed: %d\n", ret);
> +		return ret;
> +	}
> +	ret = dm_scan_platform_data();
> +	if (ret) {
> +		debug("dm_scan_platform_data() failed: %d\n", ret);
> +		return ret;
> +	}
> +#ifdef CONFIG_OF_CONTROL
> +	ret = dm_scan_fdt(gd->fdt_blob);

This part is _very_ nice!

> +	if (ret) {
> +		debug("dm_scan_fdt() failed: %d\n", ret);
> +		return ret;
> +	}
> +#endif
> +
> +	return 0;
> +}
> +#endif
> +
>  __weak int power_init_board(void)
>  {
>  	return 0;
> @@ -766,6 +796,9 @@ init_fnc_t init_sequence_r[] = {
>  	initr_barrier,
>  	initr_malloc,
>  	bootstage_relocate,
> +#ifdef CONFIG_DM
> +	initr_dm,
> +#endif
>  #ifdef CONFIG_ARCH_EARLY_INIT_R
>  	arch_early_init_r,
>  #endif

Best regards,
Marek Vasut
Simon Glass - Oct. 18, 2013, 4:45 p.m.
Hi Marek,

On Fri, Jun 28, 2013 at 2:53 PM, Marek Vasut <marex@denx.de> wrote:

> Dear Simon Glass,
>
> > Make driver model available after relocation, by setting up data
> structures
> > and scanning for devices using compiled-in platform_data and (when
> > available) the device tree.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> > Changes in v3: None
> > Changes in v2: None
> >
> >  common/board_r.c | 33 +++++++++++++++++++++++++++++++++
> >  1 file changed, 33 insertions(+)
> >
> > diff --git a/common/board_r.c b/common/board_r.c
> > index f5649c9..5fe86ef 100644
> > --- a/common/board_r.c
> > +++ b/common/board_r.c
> > @@ -34,6 +34,7 @@
> >  #ifdef CONFIG_HAS_DATAFLASH
> >  #include <dataflash.h>
> >  #endif
> > +#include <dm.h>
> >  #include <environment.h>
> >  #include <fdtdec.h>
> >  #if defined(CONFIG_CMD_IDE)
> > @@ -66,7 +67,9 @@
> >  #ifdef CONFIG_X86
> >  #include <asm/init_helpers.h>
> >  #endif
> > +#include <dm/root.h>
> >  #include <linux/compiler.h>
> > +#include <linux/err.h>
> >
> >  DECLARE_GLOBAL_DATA_PTR;
> >
> > @@ -269,6 +272,33 @@ static int initr_malloc(void)
> >       return 0;
> >  }
> >
> > +#ifdef CONFIG_DM
> > +static int initr_dm(void)
> > +{
> > +     int ret;
> > +
> > +     ret = dm_init();
> > +     if (ret) {
> > +             debug("dm_init() failed: %d\n", ret);
> > +             return ret;
> > +     }
> > +     ret = dm_scan_platform_data();
> > +     if (ret) {
> > +             debug("dm_scan_platform_data() failed: %d\n", ret);
> > +             return ret;
> > +     }
> > +#ifdef CONFIG_OF_CONTROL
> > +     ret = dm_scan_fdt(gd->fdt_blob);
>
> This part is _very_ nice!
>

Yes, it's great - it will provide automated availability of device
instances just from the device tree.

Regards,
Simon
Marek Vasut - Oct. 19, 2013, 12:45 a.m.
Hi Simon,

> Hi Marek,
> 
> On Fri, Jun 28, 2013 at 2:53 PM, Marek Vasut <marex@denx.de> wrote:
> > Dear Simon Glass,
> > 
> > > Make driver model available after relocation, by setting up data
> > 
> > structures
> > 
> > > and scanning for devices using compiled-in platform_data and (when
> > > available) the device tree.
> > > 
> > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > ---
> > > Changes in v3: None
> > > Changes in v2: None
> > > 
> > >  common/board_r.c | 33 +++++++++++++++++++++++++++++++++
> > >  1 file changed, 33 insertions(+)
> > > 
> > > diff --git a/common/board_r.c b/common/board_r.c
> > > index f5649c9..5fe86ef 100644
> > > --- a/common/board_r.c
> > > +++ b/common/board_r.c
> > > @@ -34,6 +34,7 @@
> > > 
> > >  #ifdef CONFIG_HAS_DATAFLASH
> > >  #include <dataflash.h>
> > >  #endif
> > > 
> > > +#include <dm.h>
> > > 
> > >  #include <environment.h>
> > >  #include <fdtdec.h>
> > >  #if defined(CONFIG_CMD_IDE)
> > > 
> > > @@ -66,7 +67,9 @@
> > > 
> > >  #ifdef CONFIG_X86
> > >  #include <asm/init_helpers.h>
> > >  #endif
> > > 
> > > +#include <dm/root.h>
> > > 
> > >  #include <linux/compiler.h>
> > > 
> > > +#include <linux/err.h>
> > > 
> > >  DECLARE_GLOBAL_DATA_PTR;
> > > 
> > > @@ -269,6 +272,33 @@ static int initr_malloc(void)
> > > 
> > >       return 0;
> > >  
> > >  }
> > > 
> > > +#ifdef CONFIG_DM
> > > +static int initr_dm(void)
> > > +{
> > > +     int ret;
> > > +
> > > +     ret = dm_init();
> > > +     if (ret) {
> > > +             debug("dm_init() failed: %d\n", ret);
> > > +             return ret;
> > > +     }
> > > +     ret = dm_scan_platform_data();
> > > +     if (ret) {
> > > +             debug("dm_scan_platform_data() failed: %d\n", ret);
> > > +             return ret;
> > > +     }
> > > +#ifdef CONFIG_OF_CONTROL
> > > +     ret = dm_scan_fdt(gd->fdt_blob);
> > 
> > This part is _very_ nice!
> 
> Yes, it's great - it will provide automated availability of device
> instances just from the device tree.

Let us meet at the ELCE and discuss this. I'll not be half-asleep this time.

Patch

diff --git a/common/board_r.c b/common/board_r.c
index f5649c9..5fe86ef 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -34,6 +34,7 @@ 
 #ifdef CONFIG_HAS_DATAFLASH
 #include <dataflash.h>
 #endif
+#include <dm.h>
 #include <environment.h>
 #include <fdtdec.h>
 #if defined(CONFIG_CMD_IDE)
@@ -66,7 +67,9 @@ 
 #ifdef CONFIG_X86
 #include <asm/init_helpers.h>
 #endif
+#include <dm/root.h>
 #include <linux/compiler.h>
+#include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -269,6 +272,33 @@  static int initr_malloc(void)
 	return 0;
 }
 
+#ifdef CONFIG_DM
+static int initr_dm(void)
+{
+	int ret;
+
+	ret = dm_init();
+	if (ret) {
+		debug("dm_init() failed: %d\n", ret);
+		return ret;
+	}
+	ret = dm_scan_platform_data();
+	if (ret) {
+		debug("dm_scan_platform_data() failed: %d\n", ret);
+		return ret;
+	}
+#ifdef CONFIG_OF_CONTROL
+	ret = dm_scan_fdt(gd->fdt_blob);
+	if (ret) {
+		debug("dm_scan_fdt() failed: %d\n", ret);
+		return ret;
+	}
+#endif
+
+	return 0;
+}
+#endif
+
 __weak int power_init_board(void)
 {
 	return 0;
@@ -766,6 +796,9 @@  init_fnc_t init_sequence_r[] = {
 	initr_barrier,
 	initr_malloc,
 	bootstage_relocate,
+#ifdef CONFIG_DM
+	initr_dm,
+#endif
 #ifdef CONFIG_ARCH_EARLY_INIT_R
 	arch_early_init_r,
 #endif