[PATCH rtems 3/3] mvme3100: Initialize libi2c at device driver order

Vijay Kumar Banerjee vijay at rtems.org
Thu Jul 20 01:10:03 UTC 2023


To use the libi2c, application needs to be configured with

 #define CONFIGURE_APPLICATION_NEEDS_LIBI2C_DRIVER
---
 bsps/powerpc/mvme3100/i2c/i2c_init.c   | 11 ++++++-----
 bsps/powerpc/mvme3100/start/bspstart.c |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/bsps/powerpc/mvme3100/i2c/i2c_init.c b/bsps/powerpc/mvme3100/i2c/i2c_init.c
index 9e242baf20..7e6fb50020 100644
--- a/bsps/powerpc/mvme3100/i2c/i2c_init.c
+++ b/bsps/powerpc/mvme3100/i2c/i2c_init.c
@@ -86,13 +86,14 @@ BSP_i2c_initialize(void)
 {
 int busno, succ = 0;
 
-	/* Initialize the library */
-	if ( rtems_libi2c_initialize() ) {
-		safe_printf("Initializing I2C library failed\n");
-		return -1;
-	}
+	/* Library initialize by io module */
 
 	/* Register our bus driver */
+    if (!rtems_libi2c_is_initialized){
+        safe_printf("LIBI2C NOT INITIALIZED\n");
+        return -1;
+    }
+
 	if ( (busno=rtems_libi2c_register_bus(
 					BSP_I2C_BUS0_NAME,
 					BSP_I2C_BUS_DESCRIPTOR) ) < 0 ) {
diff --git a/bsps/powerpc/mvme3100/start/bspstart.c b/bsps/powerpc/mvme3100/start/bspstart.c
index f27304c144..97faefed35 100644
--- a/bsps/powerpc/mvme3100/start/bspstart.c
+++ b/bsps/powerpc/mvme3100/start/bspstart.c
@@ -436,7 +436,7 @@ static void mvme3100_i2c_initialize(void)
 
 RTEMS_SYSINIT_ITEM(
   mvme3100_i2c_initialize,
-  RTEMS_SYSINIT_BSP_PRE_DRIVERS,
+  RTEMS_SYSINIT_DEVICE_DRIVERS,
   RTEMS_SYSINIT_ORDER_MIDDLE
 );
 
-- 
2.34.3



More information about the devel mailing list