summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDoug Anderson <dianders@chromium.org>2011-10-18 18:13:22 -0700
committerDoug Anderson <dianders@chromium.org>2011-10-19 16:41:55 -0700
commitb166ce8bdde0a2b7c506a93d4d60f92e932c64d4 (patch)
tree5f82a8d17e84f0d35fd5b02d1485acb82cfbf075 /drivers
parent547a6442998ecf52fcccfe923a64ac81e1f374f2 (diff)
CHROMIUM: tegra3: i2c: Move DVC semantics choice to device tree
On the tegra30, it appears that the "DVC" i2c controller has been normalized and no longer requires special semantics for accessing it (it has also just been renamed to "i2c5"). This change makes it so that we don't pick DVC semantics based on the periperal ID, but instead allow the device tree to specify. BUG=chromium-os:21540 TEST=Compiled / booted on Kaen Change-Id: Idfd96d1193b5ac267c61416544c63cc03dab396d Signed-off-by: Doug Anderson <dianders@chromium.org> Reviewed-on: http://gerrit.chromium.org/gerrit/10279 Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/tegra_i2c.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 3a94116831..0f79509119 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -44,6 +44,15 @@ struct i2c_bus {
enum periph_id periph_id;
int speed;
int pinmux_config;
+
+ /*
+ * If non-zero, this I2C part has registers as described in
+ * 'struct dvc_ctlr' instead of 'struct i2c_ctlr'. On Tegra2, the
+ * "DVC" i2c controller has this. On Tegra3, none of the i2c
+ * controllers do.
+ */
+ int use_dvc_ctlr;
+
struct i2c_control *control;
struct i2c_ctlr *regs;
};
@@ -140,7 +149,7 @@ static void set_packet_mode(struct i2c_bus *i2c_bus)
config = bf_pack(I2C_CNFG_NEW_MASTER_FSM, 1) |
bf_pack(I2C_CNFG_PACKET_MODE, 1);
- if (i2c_bus->periph_id == PERIPH_ID_DVC_I2C) {
+ if (i2c_bus->use_dvc_ctlr) {
struct dvc_ctlr *dvc = (struct dvc_ctlr *)i2c_bus->regs;
writel(config, &dvc->cnfg);
@@ -173,7 +182,7 @@ static void i2c_init_controller(struct i2c_bus *i2c_bus)
i2c_reset_controller(i2c_bus);
/* Configure I2C controller. */
- if (i2c_bus->periph_id == PERIPH_ID_DVC_I2C) { /* only for DVC I2C */
+ if (i2c_bus->use_dvc_ctlr) { /* only for DVC I2C */
struct dvc_ctlr *dvc = (struct dvc_ctlr *)i2c_bus->regs;
bf_writel(DVC_CTRL_REG3_I2C_HW_SW_PROG, 1, &dvc->ctrl3);
@@ -422,6 +431,12 @@ static int i2c_get_config(int *index, struct i2c_bus *i2c_bus)
i2c_bus->regs = (struct i2c_ctlr *)i2c_bus_base[i];
i2c_bus->speed = I2CSPEED_KHZ * 1000;
+#ifdef CONFIG_TEGRA2
+ i2c_bus->use_dvc_ctlr = (periph_id == PERIPH_ID_DVC_I2C);
+#else
+ i2c_bus->use_dvc_ctlr = 0;
+#endif
+
*index = i + 1;
return 0;
@@ -445,6 +460,7 @@ static int i2c_get_config(int *index, struct i2c_bus *i2c_bus)
i2c_bus->pinmux_config = config.pinmux;
i2c_bus->regs = config.reg;
i2c_bus->speed = config.speed;
+ i2c_bus->use_dvc_ctlr = config.use_dvc_ctlr;
return 0;
}
@@ -463,7 +479,7 @@ int i2c_init_board(void)
i2c_get_config(&index, i2c_bus);
- if (i2c_bus->periph_id == PERIPH_ID_DVC_I2C)
+ if (i2c_bus->use_dvc_ctlr)
i2c_bus->control =
&((struct dvc_ctlr *)i2c_bus->regs)->control;
else