summaryrefslogtreecommitdiff
path: root/board/ti
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-12-10 07:16:33 -0500
committerTom Rini <trini@konsulko.com>2018-12-10 07:16:33 -0500
commit7ff485c68b7e5573e5a4a877066e98398283a24f (patch)
tree8070ad8de0b18240ee67e1c8b847afc37bdb2d5d /board/ti
parent7504e9e75f76a5101b47cd32851ad7bd4ea8ff70 (diff)
parent19f8c4dfb6e744a31da59bdd23b24d144152f1dc (diff)
Merge branch 'master' of git://git.denx.de/u-boot-i2c
- DM_I2C_COMPAT removal for all ti platforms from Jean-Jacques Hiblot - Fix in i2c command help output from Chirstoph Muellner.
Diffstat (limited to 'board/ti')
-rw-r--r--board/ti/am335x/board.c17
-rw-r--r--board/ti/am335x/mux.c11
-rw-r--r--board/ti/am43xx/board.c46
-rw-r--r--board/ti/am57xx/board.c25
-rw-r--r--board/ti/common/board_detect.c110
-rw-r--r--board/ti/ks2_evm/board_k2g.c11
6 files changed, 136 insertions, 84 deletions
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 13845251af..d67f94ad47 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -70,8 +70,9 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
void do_board_detect(void)
{
enable_i2c0_pin_mux();
+#ifndef CONFIG_DM_I2C
i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
-
+#endif
if (ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
CONFIG_EEPROM_CHIP_ADDRESS))
printf("ti_i2c_eeprom_init failed\n");
@@ -328,8 +329,14 @@ static void scale_vcores_bone(int freq)
if (board_is_bone() && !strncmp(board_ti_get_rev(), "00A1", 4))
return;
+#ifndef CONFIG_DM_I2C
if (i2c_probe(TPS65217_CHIP_PM))
return;
+#else
+ if (power_tps65217_init(0))
+ return;
+#endif
+
/*
* On Beaglebone White we need to ensure we have AC power
@@ -421,9 +428,13 @@ void scale_vcores_generic(int freq)
* 1.10V. For MPU voltage we need to switch based on
* the frequency we are running at.
*/
+#ifndef CONFIG_DM_I2C
if (i2c_probe(TPS65910_CTRL_I2C_ADDR))
return;
-
+#else
+ if (power_tps65910_init(0))
+ return;
+#endif
/*
* Depending on MPU clock and PG we will need a different
* VDD to drive at that speed.
@@ -451,8 +462,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;
}
}
diff --git a/board/ti/am335x/mux.c b/board/ti/am335x/mux.c
index 41333f93f4..04f4b8e693 100644
--- a/board/ti/am335x/mux.c
+++ b/board/ti/am335x/mux.c
@@ -329,12 +329,23 @@ static unsigned short detect_daughter_board_profile(void)
{
unsigned short val;
+#ifndef CONFIG_DM_I2C
if (i2c_probe(I2C_CPLD_ADDR))
return PROFILE_NONE;
if (i2c_read(I2C_CPLD_ADDR, CFG_REG, 1, (unsigned char *)(&val), 2))
return PROFILE_NONE;
+#else
+ struct udevice *dev = NULL;
+ int rc;
+ rc = i2c_get_chip_for_busnum(0, I2C_CPLD_ADDR, 1, &dev);
+ if (rc)
+ return PROFILE_NONE;
+ rc = dm_i2c_read(dev, CFG_REG, (unsigned char *)(&val), 2);
+ if (rc)
+ return PROFILE_NONE;
+#endif
return (1 << (val & PROFILE_MASK));
}
diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index 2a59b06035..31bc0f49a4 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -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;
}
diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 8dfb2eea43..7063345dcc 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -623,7 +623,7 @@ void am57x_idk_lcd_detect(void)
{
int r = -ENODEV;
char *idk_lcd = "no";
- uint8_t buf = 0;
+ struct udevice *dev;
/* Only valid for IDKs */
if (board_is_x15() || board_is_am572x_evm())
@@ -633,32 +633,29 @@ void am57x_idk_lcd_detect(void)
if (board_is_am571x_idk() && !am571x_idk_needs_lcd())
goto out;
- r = i2c_set_bus_num(OSD_TS_FT_BUS_ADDRESS);
- if (r) {
- printf("%s: Failed to set bus address to %d: %d\n",
- __func__, OSD_TS_FT_BUS_ADDRESS, r);
- goto out;
- }
- r = i2c_probe(OSD_TS_FT_CHIP_ADDRESS);
+ 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()) {
+ if (board_is_am571x_idk())
printf("%s: Touch screen detect failed: %d!\n",
__func__, r);
- }
goto out;
}
/* Read FT ID */
- r = i2c_read(OSD_TS_FT_CHIP_ADDRESS, OSD_TS_FT_REG_ID, 1, &buf, 1);
- if (r) {
+ 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;
}
- switch (buf) {
+ switch (r) {
case OSD_TS_FT_ID_5606:
idk_lcd = "osd101t2045";
break;
@@ -667,7 +664,7 @@ void am57x_idk_lcd_detect(void)
break;
default:
printf("%s: Unidentifed Touch screen ID 0x%02x\n",
- __func__, buf);
+ __func__, r);
/* we will let default be "no lcd" */
}
out:
diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index c475f106b2..e258e22f37 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -14,42 +14,7 @@
#include "board_detect.h"
-#if defined(CONFIG_DM_I2C_COMPAT)
-/**
- * ti_i2c_set_alen - Set chip's i2c address length
- * @bus_addr - I2C bus number
- * @dev_addr - I2C eeprom id
- * @alen - I2C address length in bytes
- *
- * DM_I2C by default sets the address length to be used to 1. This
- * function allows this address length to be changed to match the
- * eeprom used for board detection.
- */
-int __maybe_unused ti_i2c_set_alen(int bus_addr, int dev_addr, int alen)
-{
- struct udevice *dev;
- struct udevice *bus;
- int rc;
-
- rc = uclass_get_device_by_seq(UCLASS_I2C, bus_addr, &bus);
- if (rc)
- return rc;
- rc = i2c_get_chip(bus, dev_addr, 1, &dev);
- if (rc)
- return rc;
- rc = i2c_set_chip_offset_len(dev, alen);
- if (rc)
- return rc;
-
- return 0;
-}
-#else
-int __maybe_unused ti_i2c_set_alen(int bus_addr, int dev_addr, int alen)
-{
- return 0;
-}
-#endif
-
+#if !defined(CONFIG_DM_I2C)
/**
* ti_i2c_eeprom_init - Initialize an i2c bus and probe for a device
* @i2c_bus: i2c bus number to initialize
@@ -82,18 +47,9 @@ static int __maybe_unused ti_i2c_eeprom_init(int i2c_bus, int dev_addr)
static int __maybe_unused ti_i2c_eeprom_read(int dev_addr, int offset,
uchar *ep, int epsize)
{
- int bus_num, rc, alen;
-
- bus_num = i2c_get_bus_num();
-
- alen = 2;
-
- rc = ti_i2c_set_alen(bus_num, dev_addr, alen);
- if (rc)
- return rc;
-
- return i2c_read(dev_addr, offset, alen, ep, epsize);
+ return i2c_read(dev_addr, offset, 2, ep, epsize);
}
+#endif
/**
* ti_eeprom_string_cleanup() - Handle eeprom programming errors
@@ -122,23 +78,67 @@ __weak void gpi2c_init(void)
static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
u32 header, u32 size, uint8_t *ep)
{
- u32 byte, hdr_read;
+ u32 hdr_read;
int rc;
- gpi2c_init();
- rc = ti_i2c_eeprom_init(bus_addr, dev_addr);
+#if defined(CONFIG_DM_I2C)
+ struct udevice *dev;
+ struct udevice *bus;
+
+ rc = uclass_get_device_by_seq(UCLASS_I2C, bus_addr, &bus);
+ if (rc)
+ return rc;
+ rc = i2c_get_chip(bus, dev_addr, 1, &dev);
if (rc)
return rc;
/*
* Read the header first then only read the other contents.
*/
- byte = 2;
+ rc = i2c_set_chip_offset_len(dev, 2);
+ if (rc)
+ return rc;
+
+ rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4);
+ if (rc)
+ return rc;
+
+ /* Corrupted data??? */
+ if (hdr_read != header) {
+ rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4);
+ /*
+ * read the eeprom header using i2c again, but use only a
+ * 1 byte address (some legacy boards need this..)
+ */
+ if (rc) {
+ rc = i2c_set_chip_offset_len(dev, 1);
+ if (rc)
+ return rc;
+
+ rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4);
+ }
+ if (rc)
+ return rc;
+ }
+ if (hdr_read != header)
+ return -1;
+
+ rc = dm_i2c_read(dev, 0, ep, size);
+ if (rc)
+ return rc;
+#else
+ u32 byte;
- rc = ti_i2c_set_alen(bus_addr, dev_addr, byte);
+ gpi2c_init();
+ rc = ti_i2c_eeprom_init(bus_addr, dev_addr);
if (rc)
return rc;
+ /*
+ * Read the header first then only read the other contents.
+ */
+ byte = 2;
+
rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4);
if (rc)
return rc;
@@ -152,10 +152,6 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
*/
byte = 1;
if (rc) {
- rc = ti_i2c_set_alen(bus_addr, dev_addr, byte);
- if (rc)
- return rc;
-
rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read,
4);
}
@@ -168,7 +164,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
rc = i2c_read(dev_addr, 0x0, byte, ep, size);
if (rc)
return rc;
-
+#endif
return 0;
}
diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 87dc4d009e..39a782e479 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -251,6 +251,7 @@ int board_fit_config_name_match(const char *name)
#if defined(CONFIG_DTB_RESELECT)
static int k2g_alt_board_detect(void)
{
+#ifndef CONFIG_DM_I2C
int rc;
rc = i2c_set_bus_num(1);
@@ -260,7 +261,17 @@ static int k2g_alt_board_detect(void)
rc = i2c_probe(K2G_GP_AUDIO_CODEC_ADDRESS);
if (rc)
return rc;
+#else
+ struct udevice *bus, *dev;
+ int rc;
+ rc = uclass_get_device_by_seq(UCLASS_I2C, 1, &bus);
+ if (rc)
+ return rc;
+ rc = dm_i2c_probe(bus, K2G_GP_AUDIO_CODEC_ADDRESS, 0, &dev);
+ if (rc)
+ return rc;
+#endif
ti_i2c_eeprom_am_set("66AK2GGP", "1.0X");
return 0;