diff options
author | Shardar Shariff Md <smohammed@nvidia.com> | 2017-07-12 12:20:42 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-07-17 05:35:57 -0400 |
commit | cae8223d55718bb883bc52582c15cf2d9521c1f0 (patch) | |
tree | 84e9b3066ca039c09ae2ec4270ac20c3ef2f0f13 /drivers/i2c | |
parent | df82f244c1ba8319ad213abc50832f81d7cce882 (diff) |
i2c: tegra-slave: add 10-bit slave address support
Add 10-bit slave address support
JIRA TKIP-134
Change-Id: I4da9bd5b481193686152614cc892c548de5f3fe4
Signed-off-by: Shardar Shariff Md <smohammed@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1518058
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-tegra194-slave.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-tegra194-slave.c b/drivers/i2c/busses/i2c-tegra194-slave.c index a99cbd005..a4ab03d64 100644 --- a/drivers/i2c/busses/i2c-tegra194-slave.c +++ b/drivers/i2c/busses/i2c-tegra194-slave.c | |||
@@ -52,8 +52,12 @@ | |||
52 | 52 | ||
53 | #define I2C_SL_ADDR1 0x2c | 53 | #define I2C_SL_ADDR1 0x2c |
54 | #define I2C_SL_ADDR2 0x30 | 54 | #define I2C_SL_ADDR2 0x30 |
55 | #define I2C_SL_ADDR2_TEN_BIT_ADDR_MODE BIT(0) | ||
56 | #define I2C_SL_ADDR2_HI_ADDR_SHIFT 1 | ||
55 | #define I2C_SL_ADDR2_MASK 0x1FFFF | 57 | #define I2C_SL_ADDR2_MASK 0x1FFFF |
56 | #define I2C_7BIT_ADDR_MASK 0x7F | 58 | #define I2C_7BIT_ADDR_MASK 0xFF |
59 | #define I2C_10BIT_ADDR_MASK 0x3FF | ||
60 | #define I2C_10BIT_HI_ADDR_SHIFT 8 | ||
57 | 61 | ||
58 | #define I2C_TLOW_SEXT 0x34 | 62 | #define I2C_TLOW_SEXT 0x34 |
59 | #define I2C_SL_DELAY_COUNT 0x3c | 63 | #define I2C_SL_DELAY_COUNT 0x3c |
@@ -430,6 +434,7 @@ static void tegra_i2cslv_handle_stop(struct tegra_i2cslv_dev *i2cslv_dev, | |||
430 | static int tegra_i2cslv_init(struct tegra_i2cslv_dev *i2cslv_dev) | 434 | static int tegra_i2cslv_init(struct tegra_i2cslv_dev *i2cslv_dev) |
431 | { | 435 | { |
432 | u32 reg; | 436 | u32 reg; |
437 | u32 hi_addr; | ||
433 | 438 | ||
434 | i2cslv_dev->buffer_size = i2cslv_dev->slave->buffer_size; | 439 | i2cslv_dev->buffer_size = i2cslv_dev->slave->buffer_size; |
435 | i2cslv_dev->rx_count = 0; | 440 | i2cslv_dev->rx_count = 0; |
@@ -437,14 +442,23 @@ static int tegra_i2cslv_init(struct tegra_i2cslv_dev *i2cslv_dev) | |||
437 | /* Reset the controller */ | 442 | /* Reset the controller */ |
438 | reset_control_reset(i2cslv_dev->rstc); | 443 | reset_control_reset(i2cslv_dev->rstc); |
439 | 444 | ||
440 | /* Program the 7-bit slave address */ | 445 | if (i2cslv_dev->slave->flags & I2C_CLIENT_TEN) { |
441 | tegra_i2cslv_writel(i2cslv_dev, i2cslv_dev->slave->addr & | 446 | /* Program the 10-bit slave address */ |
442 | I2C_7BIT_ADDR_MASK, I2C_SL_ADDR1); | 447 | tegra_i2cslv_writel(i2cslv_dev, i2cslv_dev->slave->addr & |
443 | 448 | I2C_7BIT_ADDR_MASK, I2C_SL_ADDR1); | |
444 | /* Specify its 7-bit address mode */ | 449 | hi_addr = ((i2cslv_dev->slave->addr & I2C_10BIT_ADDR_MASK) >> |
445 | reg = tegra_i2cslv_readl(i2cslv_dev, I2C_SL_ADDR2); | 450 | I2C_10BIT_HI_ADDR_SHIFT); |
446 | reg &= ~(I2C_SL_ADDR2_MASK); | 451 | reg = I2C_SL_ADDR2_TEN_BIT_ADDR_MODE | |
447 | tegra_i2cslv_writel(i2cslv_dev, reg, I2C_SL_ADDR2); | 452 | (hi_addr << I2C_SL_ADDR2_HI_ADDR_SHIFT); |
453 | tegra_i2cslv_writel(i2cslv_dev, reg, I2C_SL_ADDR2); | ||
454 | } else { | ||
455 | /* Program the 7-bit slave address */ | ||
456 | tegra_i2cslv_writel(i2cslv_dev, i2cslv_dev->slave->addr & | ||
457 | I2C_7BIT_ADDR_MASK, I2C_SL_ADDR1); | ||
458 | reg = tegra_i2cslv_readl(i2cslv_dev, I2C_SL_ADDR2); | ||
459 | reg &= ~(I2C_SL_ADDR2_MASK); | ||
460 | tegra_i2cslv_writel(i2cslv_dev, reg, I2C_SL_ADDR2); | ||
461 | } | ||
448 | 462 | ||
449 | /* Configure FIFO controls */ | 463 | /* Configure FIFO controls */ |
450 | reg = I2C_SLV_FIFO_RX_FIFO_TRIG_1 | I2C_SLV_FIFO_TX_FIFO_TRIG_4; | 464 | reg = I2C_SLV_FIFO_RX_FIFO_TRIG_1 | I2C_SLV_FIFO_TX_FIFO_TRIG_4; |
@@ -535,8 +549,6 @@ static int tegra_reg_slave(struct i2c_client *slave) | |||
535 | if (i2cslv_dev->slave) | 549 | if (i2cslv_dev->slave) |
536 | return -EBUSY; | 550 | return -EBUSY; |
537 | 551 | ||
538 | if (slave->flags & I2C_CLIENT_TEN) | ||
539 | return -EAFNOSUPPORT; | ||
540 | i2cslv_dev->slave = slave; | 552 | i2cslv_dev->slave = slave; |
541 | 553 | ||
542 | i2cslv_dev->rx_buffer = devm_kzalloc(i2cslv_dev->dev, 0xFF, GFP_KERNEL); | 554 | i2cslv_dev->rx_buffer = devm_kzalloc(i2cslv_dev->dev, 0xFF, GFP_KERNEL); |