diff options
author | Nitin Kumbhar <nkumbhar@nvidia.com> | 2011-04-01 19:38:30 +0530 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2011-04-04 17:59:06 -0700 |
commit | bdf0b4ce59907edd0523c5fb29a02e53a8e66a13 (patch) | |
tree | b011991b311d69721bfe37e9d772882fedae41c4 | |
parent | 8b81c1c918c289328df61b1e325a8019f9814d98 (diff) |
i2c: buses: tegra: assign unused address to i2c slave
New i2c slave should be configured with a non-zero i2c address.
Configure i2c slave with an i2c address assigned by platform
data for an i2c dev.
BUG 788286
Reviewed-on: http://git-master/r/25100
(cherry picked from commit e6e0610c72ffce3b734e079faf88fad3f0468d07)
Change-Id: I440aa2cc72007d2835b2027c0b26089d0aad9263
Reviewed-on: http://git-master/r/25223
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
-rw-r--r-- | drivers/i2c/busses/i2c-tegra.c | 15 | ||||
-rw-r--r-- | include/linux/i2c-tegra.h | 1 |
2 files changed, 15 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 2f38170bb178..0a6b21f8f077 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -44,7 +44,8 @@ #define I2C_SL_CNFG 0x020 #define I2C_SL_CNFG_NACK (1<<1) #define I2C_SL_CNFG_NEWSL (1<<2) -#define I2C_SL_ADDR1 0x02c +#define I2C_SL_ADDR1 0x02c +#define I2C_SL_ADDR2 0x030 #define I2C_TX_FIFO 0x050 #define I2C_RX_FIFO 0x054 #define I2C_PACKET_TRANSFER_STATUS 0x058 @@ -100,6 +101,9 @@ #define I2C_HEADER_MASTER_ADDR_SHIFT 12 #define I2C_HEADER_SLAVE_ADDR_SHIFT 1 +#define SL_ADDR1(addr) (addr & 0xff) +#define SL_ADDR2(addr) ((addr >> 8) & 0xff) + struct tegra_i2c_dev; struct tegra_i2c_bus { @@ -138,6 +142,7 @@ struct tegra_i2c_dev { const struct tegra_pingroup_config *last_mux; int last_mux_len; unsigned long last_bus_clk; + u16 slave_addr; struct tegra_i2c_bus busses[1]; }; @@ -314,6 +319,13 @@ static void tegra_i2c_slave_init(struct tegra_i2c_dev *i2c_dev) u32 val = I2C_SL_CNFG_NEWSL | I2C_SL_CNFG_NACK; i2c_writel(i2c_dev, val, I2C_SL_CNFG); + + if (i2c_dev->slave_addr) { + u16 addr = i2c_dev->slave_addr; + + i2c_writel(i2c_dev, SL_ADDR1(addr), I2C_SL_ADDR1); + i2c_writel(i2c_dev, SL_ADDR2(addr), I2C_SL_ADDR2); + } } static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) @@ -697,6 +709,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) i2c_dev->msgs_num = 0; rt_mutex_init(&i2c_dev->dev_lock); + i2c_dev->slave_addr = plat->slave_addr; i2c_dev->is_dvc = plat->is_dvc; init_completion(&i2c_dev->msg_complete); diff --git a/include/linux/i2c-tegra.h b/include/linux/i2c-tegra.h index f92fe26c7535..b104504c0b9c 100644 --- a/include/linux/i2c-tegra.h +++ b/include/linux/i2c-tegra.h @@ -31,6 +31,7 @@ struct tegra_i2c_platform_data { bool is_dvc; int retries; int timeout; /* in jiffies */ + u16 slave_addr; }; #endif /* _LINUX_I2C_TEGRA_H */ |