ti: remove usage of DM_I2C_COMPAT and don't disable DM_I2C in SPL
[oweals/u-boot.git] / board / ti / am57xx / board.c
index 177a3246c3dbc2d7b35b57415cddc42546b4e1c6..355ea55609fa9c19b0841b3c875e41495c928a4e 100644 (file)
@@ -623,7 +623,7 @@ void am57x_idk_lcd_detect(void)
 {
        int r = -ENODEV;
        char *idk_lcd = "no";
-       uint8_t buf = 0;
+       u8 buf = 0;
 
        /* Only valid for IDKs */
        if (board_is_x15() || board_is_am572x_evm())
@@ -633,6 +633,7 @@ void am57x_idk_lcd_detect(void)
        if (board_is_am571x_idk() && !am571x_idk_needs_lcd())
                goto out;
 
+#ifndef CONFIG_DM_I2C
        r = i2c_set_bus_num(OSD_TS_FT_BUS_ADDRESS);
        if (r) {
                printf("%s: Failed to set bus address to %d: %d\n",
@@ -657,6 +658,32 @@ void am57x_idk_lcd_detect(void)
                       OSD_TS_FT_REG_ID, r);
                goto out;
        }
+#else
+       struct udevice *dev;
+
+       r = i2c_get_chip_for_busnum(OSD_TS_FT_BUS_ADDRESS,
+                                   OSD_TS_FT_CHIP_ADDRESS, 1, &dev);
+       if (r) {
+               printf("%s: Failed to get I2C device %d/%d (ret %d)\n",
+                      __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
+                      r);
+               /* AM572x IDK has no explicit settings for optional LCD kit */
+               if (board_is_am571x_idk())
+                       printf("%s: Touch screen detect failed: %d!\n",
+                              __func__, r);
+               goto out;
+       }
+
+       /* Read FT ID */
+       r = dm_i2c_reg_read(dev, OSD_TS_FT_REG_ID);
+       if (r < 0) {
+               printf("%s: Touch screen ID read %d:0x%02x[0x%02x] failed:%d\n",
+                      __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
+                      OSD_TS_FT_REG_ID, r);
+               goto out;
+       }
+       buf = (u8)r;
+#endif
 
        switch (buf) {
        case OSD_TS_FT_ID_5606: