diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-09-25 18:04:06 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-09-25 18:04:06 -0400 |
| commit | 12df9f376d895011fb667980c8e204e050122772 (patch) | |
| tree | 4b9715a8b44b91cf58aa26df1e4f8d4d6887dc8f | |
| parent | d671e42457e1fef70ad0df07084207078633a9e8 (diff) | |
| parent | 0aef44e84ad16cd87a88df78773fd81ecca34f11 (diff) | |
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang:
"This is probably not the kind of pull request you want to see that
late in the cycle. Yet, the ACPI refactorization was problematic
again and caused another two issues which need fixing. My holidays
with limited internet (plus travelling) and the developer's illness
didn't help either :(
The details:
- ACPI code was refactored out into a seperate file and as a
side-effect, the i2c-core module got renamed. Jean Delvare
rightfully complained about the rename being problematic for
distributions. So, Mika and I thought the least problematic way to
deal with it is to move all the code back into the main i2c core
source file. This is mainly a huge code move with some #ifdeffery
applied. No functional code changes. Our personal tests and the
testbots did not find problems. (I was thinking about reverting,
too, yet that would also have ~800 lines changed)
- The new ACPI code also had a NULL pointer exception, thanks to
Peter for finding and fixing it.
- Mikko fixed a locking problem by decoupling clock_prepare and
clock_enable.
- Addy learnt that the datasheet was wrong and reimplemented the
frequency setup according to the new algorithm.
- Fan fixed an off-by-one error when copying data
- Janusz fixed a copy'n'paste bug which gave a wrong error message
- Sergei made sure that "don't touch" bits are not accessed"
* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: acpi: Fix NULL Pointer dereference
i2c: move acpi code back into the core
i2c: rk3x: fix divisor calculation for SCL frequency
i2c: mxs: fix error message in pio transfer
i2c: ismt: use correct length when copy buffer
i2c: rcar: fix RCAR_IRQ_ACK_{RECV|SEND}
i2c: tegra: Move clk_prepare/clk_set_rate to probe
| -rw-r--r-- | MAINTAINERS | 1 | ||||
| -rw-r--r-- | drivers/i2c/Makefile | 5 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-ismt.c | 4 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-mxs.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-rcar.c | 4 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-rk3x.c | 11 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-tegra.c | 57 | ||||
| -rw-r--r-- | drivers/i2c/i2c-acpi.c | 364 | ||||
| -rw-r--r-- | drivers/i2c/i2c-core.c | 364 | ||||
| -rw-r--r-- | include/linux/i2c.h | 16 |
10 files changed, 420 insertions, 408 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 839f36761f2c..37054306dc9f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -4476,7 +4476,6 @@ M: Mika Westerberg <mika.westerberg@linux.intel.com> | |||
| 4476 | L: linux-i2c@vger.kernel.org | 4476 | L: linux-i2c@vger.kernel.org |
| 4477 | L: linux-acpi@vger.kernel.org | 4477 | L: linux-acpi@vger.kernel.org |
| 4478 | S: Maintained | 4478 | S: Maintained |
| 4479 | F: drivers/i2c/i2c-acpi.c | ||
| 4480 | 4479 | ||
| 4481 | I2C-TAOS-EVM DRIVER | 4480 | I2C-TAOS-EVM DRIVER |
| 4482 | M: Jean Delvare <jdelvare@suse.de> | 4481 | M: Jean Delvare <jdelvare@suse.de> |
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index e0228b228256..1722f50f2473 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile | |||
| @@ -2,11 +2,8 @@ | |||
| 2 | # Makefile for the i2c core. | 2 | # Makefile for the i2c core. |
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | i2ccore-y := i2c-core.o | ||
| 6 | i2ccore-$(CONFIG_ACPI) += i2c-acpi.o | ||
| 7 | |||
| 8 | obj-$(CONFIG_I2C_BOARDINFO) += i2c-boardinfo.o | 5 | obj-$(CONFIG_I2C_BOARDINFO) += i2c-boardinfo.o |
| 9 | obj-$(CONFIG_I2C) += i2ccore.o | 6 | obj-$(CONFIG_I2C) += i2c-core.o |
| 10 | obj-$(CONFIG_I2C_SMBUS) += i2c-smbus.o | 7 | obj-$(CONFIG_I2C_SMBUS) += i2c-smbus.o |
| 11 | obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o | 8 | obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o |
| 12 | obj-$(CONFIG_I2C_MUX) += i2c-mux.o | 9 | obj-$(CONFIG_I2C_MUX) += i2c-mux.o |
diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c index 984492553e95..d9ee43c80cde 100644 --- a/drivers/i2c/busses/i2c-ismt.c +++ b/drivers/i2c/busses/i2c-ismt.c | |||
| @@ -497,7 +497,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr, | |||
| 497 | desc->wr_len_cmd = dma_size; | 497 | desc->wr_len_cmd = dma_size; |
| 498 | desc->control |= ISMT_DESC_BLK; | 498 | desc->control |= ISMT_DESC_BLK; |
| 499 | priv->dma_buffer[0] = command; | 499 | priv->dma_buffer[0] = command; |
| 500 | memcpy(&priv->dma_buffer[1], &data->block[1], dma_size); | 500 | memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1); |
| 501 | } else { | 501 | } else { |
| 502 | /* Block Read */ | 502 | /* Block Read */ |
| 503 | dev_dbg(dev, "I2C_SMBUS_BLOCK_DATA: READ\n"); | 503 | dev_dbg(dev, "I2C_SMBUS_BLOCK_DATA: READ\n"); |
| @@ -525,7 +525,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr, | |||
| 525 | desc->wr_len_cmd = dma_size; | 525 | desc->wr_len_cmd = dma_size; |
| 526 | desc->control |= ISMT_DESC_I2C; | 526 | desc->control |= ISMT_DESC_I2C; |
| 527 | priv->dma_buffer[0] = command; | 527 | priv->dma_buffer[0] = command; |
| 528 | memcpy(&priv->dma_buffer[1], &data->block[1], dma_size); | 528 | memcpy(&priv->dma_buffer[1], &data->block[1], dma_size - 1); |
| 529 | } else { | 529 | } else { |
| 530 | /* i2c Block Read */ | 530 | /* i2c Block Read */ |
| 531 | dev_dbg(dev, "I2C_SMBUS_I2C_BLOCK_DATA: READ\n"); | 531 | dev_dbg(dev, "I2C_SMBUS_I2C_BLOCK_DATA: READ\n"); |
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c index 7170fc892829..65a21fed08b5 100644 --- a/drivers/i2c/busses/i2c-mxs.c +++ b/drivers/i2c/busses/i2c-mxs.c | |||
| @@ -429,7 +429,7 @@ static int mxs_i2c_pio_setup_xfer(struct i2c_adapter *adap, | |||
| 429 | ret = mxs_i2c_pio_wait_xfer_end(i2c); | 429 | ret = mxs_i2c_pio_wait_xfer_end(i2c); |
| 430 | if (ret) { | 430 | if (ret) { |
| 431 | dev_err(i2c->dev, | 431 | dev_err(i2c->dev, |
| 432 | "PIO: Failed to send SELECT command!\n"); | 432 | "PIO: Failed to send READ command!\n"); |
| 433 | goto cleanup; | 433 | goto cleanup; |
| 434 | } | 434 | } |
| 435 | 435 | ||
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 1cc146cfc1f3..e506fcd3ca04 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c | |||
| @@ -76,8 +76,8 @@ | |||
| 76 | #define RCAR_IRQ_RECV (MNR | MAL | MST | MAT | MDR) | 76 | #define RCAR_IRQ_RECV (MNR | MAL | MST | MAT | MDR) |
| 77 | #define RCAR_IRQ_STOP (MST) | 77 | #define RCAR_IRQ_STOP (MST) |
| 78 | 78 | ||
| 79 | #define RCAR_IRQ_ACK_SEND (~(MAT | MDE)) | 79 | #define RCAR_IRQ_ACK_SEND (~(MAT | MDE) & 0xFF) |
| 80 | #define RCAR_IRQ_ACK_RECV (~(MAT | MDR)) | 80 | #define RCAR_IRQ_ACK_RECV (~(MAT | MDR) & 0xFF) |
| 81 | 81 | ||
| 82 | #define ID_LAST_MSG (1 << 0) | 82 | #define ID_LAST_MSG (1 << 0) |
| 83 | #define ID_IOERROR (1 << 1) | 83 | #define ID_IOERROR (1 << 1) |
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index e637c32ae517..93cfc837200b 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c | |||
| @@ -433,12 +433,11 @@ static void rk3x_i2c_set_scl_rate(struct rk3x_i2c *i2c, unsigned long scl_rate) | |||
| 433 | unsigned long i2c_rate = clk_get_rate(i2c->clk); | 433 | unsigned long i2c_rate = clk_get_rate(i2c->clk); |
| 434 | unsigned int div; | 434 | unsigned int div; |
| 435 | 435 | ||
| 436 | /* SCL rate = (clk rate) / (8 * DIV) */ | 436 | /* set DIV = DIVH = DIVL |
| 437 | div = DIV_ROUND_UP(i2c_rate, scl_rate * 8); | 437 | * SCL rate = (clk rate) / (8 * (DIVH + 1 + DIVL + 1)) |
| 438 | 438 | * = (clk rate) / (16 * (DIV + 1)) | |
| 439 | /* The lower and upper half of the CLKDIV reg describe the length of | 439 | */ |
| 440 | * SCL low & high periods. */ | 440 | div = DIV_ROUND_UP(i2c_rate, scl_rate * 16) - 1; |
| 441 | div = DIV_ROUND_UP(div, 2); | ||
| 442 | 441 | ||
| 443 | i2c_writel(i2c, (div << 16) | (div & 0xffff), REG_CLKDIV); | 442 | i2c_writel(i2c, (div << 16) | (div & 0xffff), REG_CLKDIV); |
| 444 | } | 443 | } |
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 87d0371cebb7..efba1ebe16ba 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c | |||
| @@ -380,34 +380,33 @@ static inline int tegra_i2c_clock_enable(struct tegra_i2c_dev *i2c_dev) | |||
| 380 | { | 380 | { |
| 381 | int ret; | 381 | int ret; |
| 382 | if (!i2c_dev->hw->has_single_clk_source) { | 382 | if (!i2c_dev->hw->has_single_clk_source) { |
| 383 | ret = clk_prepare_enable(i2c_dev->fast_clk); | 383 | ret = clk_enable(i2c_dev->fast_clk); |
| 384 | if (ret < 0) { | 384 | if (ret < 0) { |
| 385 | dev_err(i2c_dev->dev, | 385 | dev_err(i2c_dev->dev, |
| 386 | "Enabling fast clk failed, err %d\n", ret); | 386 | "Enabling fast clk failed, err %d\n", ret); |
| 387 | return ret; | 387 | return ret; |
| 388 | } | 388 | } |
| 389 | } | 389 | } |
| 390 | ret = clk_prepare_enable(i2c_dev->div_clk); | 390 | ret = clk_enable(i2c_dev->div_clk); |
| 391 | if (ret < 0) { | 391 | if (ret < 0) { |
| 392 | dev_err(i2c_dev->dev, | 392 | dev_err(i2c_dev->dev, |
| 393 | "Enabling div clk failed, err %d\n", ret); | 393 | "Enabling div clk failed, err %d\n", ret); |
| 394 | clk_disable_unprepare(i2c_dev->fast_clk); | 394 | clk_disable(i2c_dev->fast_clk); |
| 395 | } | 395 | } |
| 396 | return ret; | 396 | return ret; |
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | static inline void tegra_i2c_clock_disable(struct tegra_i2c_dev *i2c_dev) | 399 | static inline void tegra_i2c_clock_disable(struct tegra_i2c_dev *i2c_dev) |
| 400 | { | 400 | { |
| 401 | clk_disable_unprepare(i2c_dev->div_clk); | 401 | clk_disable(i2c_dev->div_clk); |
| 402 | if (!i2c_dev->hw->has_single_clk_source) | 402 | if (!i2c_dev->hw->has_single_clk_source) |
| 403 | clk_disable_unprepare(i2c_dev->fast_clk); | 403 | clk_disable(i2c_dev->fast_clk); |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) | 406 | static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) |
| 407 | { | 407 | { |
| 408 | u32 val; | 408 | u32 val; |
| 409 | int err = 0; | 409 | int err = 0; |
| 410 | int clk_multiplier = I2C_CLK_MULTIPLIER_STD_FAST_MODE; | ||
| 411 | u32 clk_divisor; | 410 | u32 clk_divisor; |
| 412 | 411 | ||
| 413 | err = tegra_i2c_clock_enable(i2c_dev); | 412 | err = tegra_i2c_clock_enable(i2c_dev); |
| @@ -428,9 +427,6 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) | |||
| 428 | i2c_writel(i2c_dev, val, I2C_CNFG); | 427 | i2c_writel(i2c_dev, val, I2C_CNFG); |
| 429 | i2c_writel(i2c_dev, 0, I2C_INT_MASK); | 428 | i2c_writel(i2c_dev, 0, I2C_INT_MASK); |
| 430 | 429 | ||
| 431 | clk_multiplier *= (i2c_dev->hw->clk_divisor_std_fast_mode + 1); | ||
| 432 | clk_set_rate(i2c_dev->div_clk, i2c_dev->bus_clk_rate * clk_multiplier); | ||
| 433 | |||
| 434 | /* Make sure clock divisor programmed correctly */ | 430 | /* Make sure clock divisor programmed correctly */ |
| 435 | clk_divisor = | ||
