summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-06-08 10:00:46 -0400
committerTom Rini <trini@konsulko.com>2018-06-08 10:00:46 -0400
commit8da19df5b504f1cbe79e13f859bc229c042aded5 (patch)
tree004759c6f07482af3f62ad086f1b1e10e16bb2ae
parent8f48cf9f1758a2c5cef05381401184959af64a69 (diff)
parentd78ecc733988d07a87c97f7f1c19171c437a8712 (diff)
Merge branch 'master' of git://git.denx.de/u-boot-i2c
-rw-r--r--board/CZ.NIC/turris_omnia/turris_omnia.c6
-rw-r--r--drivers/i2c/mvtwsi.c24
2 files changed, 28 insertions, 2 deletions
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
index da663cf1bb0..160d30cd795 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -321,7 +321,11 @@ int board_early_init_f(void)
writel(OMNIA_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04);
writel(OMNIA_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04);
- /* Disable I2C debug mode blocking 0x64 I2C address */
+ /*
+ * Disable I2C debug mode blocking 0x64 I2C address.
+ * Note: that would be redundant once Turris Omnia migrates to DM_I2C,
+ * because the mvtwsi driver includes equivalent code.
+ */
i2c_debug_reg = readl(MVEBU_TWSI_BASE + MVTWSI_ARMADA_DEBUG_REG);
i2c_debug_reg &= ~(1<<18);
writel(i2c_debug_reg, MVEBU_TWSI_BASE + MVTWSI_ARMADA_DEBUG_REG);
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index f9822e56b89..74ac0a4aa78 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -11,6 +11,7 @@
#include <i2c.h>
#include <linux/errno.h>
#include <asm/io.h>
+#include <linux/bitops.h>
#include <linux/compat.h>
#ifdef CONFIG_DM_I2C
#include <dm.h>
@@ -57,6 +58,7 @@ struct mvtwsi_registers {
u32 status;
u32 baudrate;
u32 soft_reset;
+ u32 debug; /* Dummy field for build compatibility with mvebu */
};
#else
@@ -70,8 +72,10 @@ struct mvtwsi_registers {
u32 baudrate; /* When writing */
};
u32 xtnd_slave_addr;
- u32 reserved[2];
+ u32 reserved0[2];
u32 soft_reset;
+ u32 reserved1[27];
+ u32 debug;
};
#endif
@@ -795,6 +799,23 @@ static int mvtwsi_i2c_ofdata_to_platdata(struct udevice *bus)
return 0;
}
+static void twsi_disable_i2c_slave(struct mvtwsi_registers *twsi)
+{
+ clrbits_le32(&twsi->debug, BIT(18));
+}
+
+static int mvtwsi_i2c_bind(struct udevice *bus)
+{
+ struct mvtwsi_registers *twsi = devfdt_get_addr_ptr(bus);
+
+ /* Disable the hidden slave in i2c0 of these platforms */
+ if ((IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_KIRKWOOD))
+ && bus->req_seq == 0)
+ twsi_disable_i2c_slave(twsi);
+
+ return 0;
+}
+
static int mvtwsi_i2c_probe(struct udevice *bus)
{
struct mvtwsi_i2c_dev *dev = dev_get_priv(bus);
@@ -850,6 +871,7 @@ U_BOOT_DRIVER(i2c_mvtwsi) = {
.name = "i2c_mvtwsi",
.id = UCLASS_I2C,
.of_match = mvtwsi_i2c_ids,
+ .bind = mvtwsi_i2c_bind,
.probe = mvtwsi_i2c_probe,
.ofdata_to_platdata = mvtwsi_i2c_ofdata_to_platdata,
.priv_auto_alloc_size = sizeof(struct mvtwsi_i2c_dev),