ti: remove usage of DM_I2C_COMPAT and don't disable DM_I2C in SPL
[oweals/u-boot.git] / board / ti / am43xx / board.c
index 2a59b060351f6fec8a2f004e594937bcf904cf85..31bc0f49a48517f30845b3d143f9447fd4d0ea25 100644 (file)
@@ -43,6 +43,8 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 #ifdef CONFIG_TI_I2C_BOARD_DETECT
 void do_board_detect(void)
 {
+       /* Ensure I2C is initialized for EEPROM access*/
+       gpi2c_init();
        if (ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
                                 CONFIG_EEPROM_CHIP_ADDRESS))
                printf("ti_i2c_eeprom_init failed\n");
@@ -386,8 +388,13 @@ void scale_vcores_generic(u32 m)
 {
        int mpu_vdd, ddr_volt;
 
+#ifndef CONFIG_DM_I2C
        if (i2c_probe(TPS65218_CHIP_PM))
                return;
+#else
+       if (power_tps65218_init(0))
+               return;
+#endif
 
        switch (m) {
        case 1000:
@@ -439,8 +446,13 @@ void scale_vcores_idk(u32 m)
 {
        int mpu_vdd;
 
+#ifndef CONFIG_DM_I2C
        if (i2c_probe(TPS62362_I2C_ADDR))
                return;
+#else
+       if (power_tps62362_init(0))
+               return;
+#endif
 
        switch (m) {
        case 1000:
@@ -462,14 +474,12 @@ void scale_vcores_idk(u32 m)
                puts("Unknown MPU clock, not scaling\n");
                return;
        }
-
        /* Set VDD_MPU voltage */
        if (tps62362_voltage_update(TPS62362_SET3, mpu_vdd)) {
                printf("%s failure\n", __func__);
                return;
        }
 }
-
 void gpi2c_init(void)
 {
        /* When needed to be invoked prior to BSS initialization */
@@ -477,8 +487,10 @@ void gpi2c_init(void)
 
        if (first_time) {
                enable_i2c0_pin_mux();
+#ifndef CONFIG_DM_I2C
                i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED,
                         CONFIG_SYS_OMAP24_I2C_SLAVE);
+#endif
                first_time = false;
        }
 }
@@ -614,20 +626,32 @@ void sdram_init(void)
 /* setup board specific PMIC */
 int power_init_board(void)
 {
-       struct pmic *p;
-
+       int rc;
+#ifndef CONFIG_DM_I2C
+       struct pmic *p = NULL;
+#endif
        if (board_is_idk()) {
-               power_tps62362_init(I2C_PMIC);
+               rc = power_tps62362_init(0);
+               if (rc)
+                       goto done;
+#ifndef CONFIG_DM_I2C
                p = pmic_get("TPS62362");
-               if (p && !pmic_probe(p))
-                       puts("PMIC:  TPS62362\n");
+               if (!p || pmic_probe(p))
+                       goto done;
+#endif
+               puts("PMIC:  TPS62362\n");
        } else {
-               power_tps65218_init(I2C_PMIC);
+               rc = power_tps65218_init(0);
+               if (rc)
+                       goto done;
+#ifndef CONFIG_DM_I2C
                p = pmic_get("TPS65218_PMIC");
-               if (p && !pmic_probe(p))
-                       puts("PMIC:  TPS65218\n");
+               if (!p || pmic_probe(p))
+                       goto done;
+#endif
+               puts("PMIC:  TPS65218\n");
        }
-
+done:
        return 0;
 }