summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-10-03 13:10:33 -0700
committerSimon Glass <sjg@chromium.org>2011-10-07 10:00:41 -0700
commit3ded9c10e32eb780070ca8412fb57818b73d3b50 (patch)
treec58ab10dcb8453b535412ce092c632e2caf6cd91
parent817affa29cafc5d901183eea2484fc3b88baa60d (diff)
tegra3: i2c: Add low level functions for T30
We need these functions to set up the power chip during low-level init. BUG=chromium-os:21033 TEST=build and boot on Seaboard Change-Id: I69b9d3c12581e0a71db39b031b9ea2ef4ec184bf Reviewed-on: http://gerrit.chromium.org/gerrit/8696 Reviewed-by: Che-Liang Chiou <clchiou@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
-rw-r--r--arch/arm/include/asm/arch-tegra/i2c.h24
-rw-r--r--drivers/i2c/tegra_i2c.c30
2 files changed, 54 insertions, 0 deletions
diff --git a/arch/arm/include/asm/arch-tegra/i2c.h b/arch/arm/include/asm/arch-tegra/i2c.h
index 25fb21d3fc8..458cd5ef60b 100644
--- a/arch/arm/include/asm/arch-tegra/i2c.h
+++ b/arch/arm/include/asm/arch-tegra/i2c.h
@@ -168,4 +168,28 @@ struct i2c_ctlr {
#define I2C_INT_NO_ACK_RANGE 3 : 3
#define I2C_INT_ARBITRATION_LOST_RANGE 2 : 2
+/**
+ * Low level, hopefully temporary, functions to write values to the
+ * Tegra DVC I2C controller. These are used by T30 init, when running
+ * on the AVP CPU, before the Cortex-A9s are up. It is not easy to
+ * have the i2c infrastructure up that early, but we still want to put
+ * this code in the driver
+ */
+
+/**
+ * Write an address (with config) to the DVC I2C
+ *
+ * @param addr Address to write
+ * @param config Config to write
+ */
+void tegra_i2c_ll_write_addr(uint addr, uint config);
+
+/**
+ * Write a data word (with config) to the DVC I2C
+ *
+ * @param data Data to write
+ * @param config Config to write
+ */
+void tegra_i2c_ll_write_data(uint data, uint config);
+
#endif
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index c51dd906927..3a94116831b 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -32,6 +32,9 @@
#include <asm/arch/pinmux.h>
#include <fdt_decode.h>
+/* TODO(sjg): This driver has not been tested with Tegra3 yet */
+#ifdef CONFIG_TEGRA2
+
DECLARE_GLOBAL_DATA_PTR;
static unsigned int i2c_bus_num;
@@ -623,3 +626,30 @@ int i2c_set_bus_num(unsigned int bus)
return 0;
}
#endif
+
+#else /* not CONFIG_TEGRA2 */
+
+/* Not implemented for now */
+int i2c_init_board(void)
+{
+ printf("i2c support is not available on T30\n");
+ return -1;
+}
+
+#endif /* CONFIG_TEGRA2 */
+
+void tegra_i2c_ll_write_addr(uint addr, uint config)
+{
+ struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+
+ writel(addr, &reg->cmd_addr0);
+ writel(config, &reg->cnfg);
+}
+
+void tegra_i2c_ll_write_data(uint data, uint config)
+{
+ struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+
+ writel(data, &reg->cmd_data1);
+ writel(config, &reg->cnfg);
+}