i2c device initialization on MVME3100 RTEMS5 (presumably also in 6?)

Chris Johns chrisj at rtems.org
Thu Aug 4 01:31:35 UTC 2022


On 3/8/2022 9:52 pm, Heinz Junkes wrote:
> We had a problem initialising the i2c devices on the MVME3100.
> Unfortunately, I still don't understand the order of initialisation.
> 
> However, the direct driver initialisation from bspstart no longer worked as it did with older versions. 
> 
> My workaround therefore looks like this:
> 
> rtems at rtems-dev:~/MVME3100/kernel$ git diff bsps/powerpc/mvme3100/start/bspstart.c
> diff --git a/bsps/powerpc/mvme3100/start/bspstart.c b/bsps/powerpc/mvme3100/start/bspstart.c
> index 0ec215e33b..96d6e2f9cd 100644
> --- a/bsps/powerpc/mvme3100/start/bspstart.c
> +++ b/bsps/powerpc/mvme3100/start/bspstart.c
> @@ -52,6 +52,8 @@
>  extern unsigned long __rtems_end[];
>  extern unsigned      ppc_exc_lock_std, ppc_exc_gpr3_std;
> 
> +extern bool _IO_All_drivers_initialized;
> +
>  /*
>   * Copy Additional boot param passed by boot loader
>   */
> @@ -419,7 +421,14 @@ void bsp_start( void )
> 
>  static void mvme3100_i2c_initialize(void)
>  {
> +  printk("-------- call BSP_i2c_initialize() with _IO_All_drivers_initialized = true\n");
> +  /*
> +   * we need the drivers registered as they appear, due to get
> +   * the i2c devices ready
> +   */
> +  _IO_All_drivers_initialized = true;
>    BSP_i2c_initialize();
> +  _IO_All_drivers_initialized = false;
>  }

Where is this being called? I cannot see it in the patch. If it is BSP start I
think it is too early to make these calls.

>  RTEMS_SYSINIT_ITEM(
> 
> 
> You can find this in cpukit/sapi/src/ioregisterdriver.c:
> 
> 
>  if ( _IO_All_drivers_initialized ) {
>     /* Other drivers have already been initialized, we initialize
>      * the driver directly.
>      */
>     return rtems_io_initialize( major, 0, NULL );
>   } else {
>     /* The driver will be initialized together with all other drivers
>      * in a later stage by _IO_Initialize_all_drivers().
>      */
>     return RTEMS_SUCCESSFUL;
>   }
> 
> 
> I can imagine that this is not an elegant way, but it's the best I could do. Is there any idea how to do it "right"?
> Or should I submit this patch?
I suspect touching that internal variable is not great. That variable could go
away or be made static.

There maybe another BSP hook that could be used or a SYSINIT hook maybe be needed.

Chris


More information about the devel mailing list