summaryrefslogtreecommitdiff
path: root/board/ti/common
diff options
context:
space:
mode:
authorCooper Jr., Franklin <fcooper@ti.com>2017-04-20 15:25:44 (GMT)
committerHeiko Schocher <hs@denx.de>2017-05-09 07:04:29 (GMT)
commitc6b80b13924adc9b72fb03c368c2e39b85131a91 (patch)
treee7da8149306b213e92aab9b64fdff75251f07b2c /board/ti/common
parent70f6f94c773550faf955e852854ed07519dae8de (diff)
downloadu-boot-c6b80b13924adc9b72fb03c368c2e39b85131a91.tar.xz
ti: common: board_detect: Introduce function to set the address length.
Reading from the I2C EEPROM used typically requires using an address length of 2. However, when using DM for I2C the default address length used is 1. To fix this introduce a new function that allows the address length to be changed. The logic to do so was copied from cmd/i2c.c. Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'board/ti/common')
-rw-r--r--board/ti/common/board_detect.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index c55e24e..1e695f4 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -10,10 +10,47 @@
#include <common.h>
#include <asm/omap_common.h>
+#include <dm/uclass.h>
#include <i2c.h>
#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
+
/**
* ti_i2c_eeprom_init - Initialize an i2c bus and probe for a device
* @i2c_bus: i2c bus number to initialize