Pull i2c fixes from Wolfram Sang: "Here are some driver bugfixes from I2C. Unusual this time are the two reverts. One because I accidently picked a patch from the list which I should have pulled from my co-maintainer instead ("missing of_node_put"). And one which I wrongly assumed to be an easy fix but it turned out already that it needs more iterations ("copy device properties")" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: Revert "i2c: copy device properties when using i2c_register_board_info()" Revert "i2c: add missing of_node_put in i2c_mux_del_adapters" i2c: exynos5: Avoid transaction timeouts due TRANSFER_DONE_AUTO not set i2c: designware: add reset interface i2c: meson: fix wrong variable usage in meson_i2c_put_data i2c: copy device properties when using i2c_register_board_info() i2c: m65xx: drop superfluous quirk structure i2c: brcmstb: Fix START and STOP conditions i2c: add missing of_node_put in i2c_mux_del_adapters i2c: riic: fix restart condition i2c: add missing of_node_put in i2c_mux_del_adapters
Unified · Split
| @@ -465,6 +465,7 @@ static int brcmstb_i2c_xfer(struct i2c_adapter *adapter, · 464 unmodified lines | ||
| 465 | 465 | u8 *tmp_buf; |
| 466 | 466 | int len = 0; |
| 467 | 467 | int xfersz = brcmstb_i2c_get_xfersz(dev); |
| 468 | + u32 cond, cond_per_msg; | |
| 468 | 469 | |
| 469 | 470 | if (dev->is_suspended) |
| 470 | 471 | return -EBUSY; |
| @@ -481,10 +482,11 @@ static int brcmstb_i2c_xfer(struct i2c_adapter *adapter, · 10 unmodified lines | ||
| 481 | 482 | pmsg->buf ? pmsg->buf[0] : '0', pmsg->len); |
| 482 | 483 | |
| 483 | 484 | if (i < (num - 1) && (msgs[i + 1].flags & I2C_M_NOSTART)) |
| 484 | − brcmstb_set_i2c_start_stop(dev, ~(COND_START_STOP)); | |
| 485 | + cond = ~COND_START_STOP; | |
| 485 | 486 | else |
| 486 | − brcmstb_set_i2c_start_stop(dev, | |
| 487 | − COND_RESTART | COND_NOSTOP); | |
| 487 | + cond = COND_RESTART | COND_NOSTOP; | |
| 488 | + | |
| 489 | + brcmstb_set_i2c_start_stop(dev, cond); | |
| 488 | 490 | |
| 489 | 491 | /* Send slave address */ |
| 490 | 492 | if (!(pmsg->flags & I2C_M_NOSTART)) { |
| @@ -497,13 +499,24 @@ static int brcmstb_i2c_xfer(struct i2c_adapter *adapter, · 6 unmodified lines | ||
| 497 | 499 | } |
| 498 | 500 | } |
| 499 | 501 | |
| 502 | + cond_per_msg = cond; | |
| 503 | + | |
| 500 | 504 | /* Perform data transfer */ |
| 501 | 505 | while (len) { |
| 502 | 506 | bytes_to_xfer = min(len, xfersz); |
| 503 | 507 | |
| 504 | − if (len <= xfersz && i == (num - 1)) | |
| 505 | − brcmstb_set_i2c_start_stop(dev, | |
| 506 | − ~(COND_START_STOP)); | |
| 508 | + if (len <= xfersz) { | |
| 509 | + if (i == (num - 1)) | |
| 510 | + cond_per_msg = cond_per_msg & | |
| 511 | + ~(COND_RESTART | COND_NOSTOP); | |
| 512 | + else | |
| 513 | + cond_per_msg = cond; | |
| 514 | + } else { | |
| 515 | + cond_per_msg = (cond_per_msg & ~COND_RESTART) | | |
| 516 | + COND_NOSTOP; | |
| 517 | + } | |
| 518 | + | |
| 519 | + brcmstb_set_i2c_start_stop(dev, cond_per_msg); | |
| 507 | 520 | |
| 508 | 521 | rc = brcmstb_i2c_xfer_bsc_data(dev, tmp_buf, |
| 509 | 522 | bytes_to_xfer, pmsg); |
| @@ -512,6 +525,8 @@ static int brcmstb_i2c_xfer(struct i2c_adapter *adapter, · 2 unmodified lines | ||
| 512 | 525 | |
| 513 | 526 | len -= bytes_to_xfer; |
| 514 | 527 | tmp_buf += bytes_to_xfer; |
| 528 | + | |
| 529 | + cond_per_msg = COND_NOSTART | COND_NOSTOP; | |
| 515 | 530 | } |
| 516 | 531 | } |
| 517 | 532 | |
| @@ -88,6 +88,7 @@ struct dw_i2c_dev { · 87 unmodified lines | ||
| 88 | 88 | void __iomem *base; |
| 89 | 89 | struct completion cmd_complete; |
| 90 | 90 | struct clk *clk; |
| 91 | + struct reset_control *rst; | |
| 91 | 92 | u32 (*get_clk_rate_khz) (struct dw_i2c_dev *dev); |
| 92 | 93 | struct dw_pci_controller *controller; |
| 93 | 94 | int cmd_err; |
| @@ -38,6 +38,7 @@ · 37 unmodified lines | ||
| 38 | 38 | #include <linux/pm_runtime.h> |
| 39 | 39 | #include <linux/property.h> |
| 40 | 40 | #include <linux/io.h> |
| 41 | +#include <linux/reset.h> | |
| 41 | 42 | #include <linux/slab.h> |
| 42 | 43 | #include <linux/acpi.h> |
| 43 | 44 | #include <linux/platform_data/i2c-designware.h> |
| @@ -199,6 +200,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) · 155 unmodified lines | ||
| 199 | 200 | dev->irq = irq; |
| 200 | 201 | platform_set_drvdata(pdev, dev); |
| 201 | 202 | |
| 203 | + dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); | |
| 204 | + if (IS_ERR(dev->rst)) { | |
| 205 | + if (PTR_ERR(dev->rst) == -EPROBE_DEFER) | |
| 206 | + return -EPROBE_DEFER; | |
| 207 | + } else { | |
| 208 | + reset_control_deassert(dev->rst); | |
| 209 | + } | |
| 210 | + | |
| 202 | 211 | if (pdata) { |
| 203 | 212 | dev->clk_freq = pdata->i2c_scl_freq; |
| 204 | 213 | } else { |
| @@ -235,12 +244,13 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) · 30 unmodified lines | ||
| 235 | 244 | && dev->clk_freq != 1000000 && dev->clk_freq != 3400000) { |
| 236 | 245 | dev_err(&pdev->dev, |
| 237 | 246 | "Only 100kHz, 400kHz, 1MHz and 3.4MHz supported"); |
| 238 | − return -EINVAL; | |
| 247 | + r = -EINVAL; | |
| 248 | + goto exit_reset; | |
| 239 | 249 | } |
| 240 | 250 | |
| 241 | 251 | r = i2c_dw_eval_lock_support(dev); |
| 242 | 252 | if (r) |
| 243 | − return r; | |
| 253 | + goto exit_reset; | |
| 244 | 254 | |
| 245 | 255 | dev->functionality = I2C_FUNC_10BIT_ADDR | DW_IC_DEFAULT_FUNCTIONALITY; |
| 246 | 256 | |
| @@ -286,10 +296,18 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) · 39 unmodified lines | ||
| 286 | 296 | } |
| 287 | 297 | |
| 288 | 298 | r = i2c_dw_probe(dev); |
| 289 | − if (r && !dev->pm_runtime_disabled) | |
| 290 | − pm_runtime_disable(&pdev->dev); | |
| 299 | + if (r) | |
| 300 | + goto exit_probe; | |
| 291 | 301 | |
| 292 | 302 | return r; |
| 303 | + | |
| 304 | +exit_probe: | |
| 305 | + if (!dev->pm_runtime_disabled) | |
| 306 | + pm_runtime_disable(&pdev->dev); | |
| 307 | +exit_reset: | |
| 308 | + if (!IS_ERR_OR_NULL(dev->rst)) | |
| 309 | + reset_control_assert(dev->rst); | |
| 310 | + return r; | |
| 293 | 311 | } |
| 294 | 312 | |
| 295 | 313 | static int dw_i2c_plat_remove(struct platform_device *pdev) |
| @@ -306,6 +324,8 @@ static int dw_i2c_plat_remove(struct platform_device *pdev) · 10 unmodified lines | ||
| 306 | 324 | pm_runtime_put_sync(&pdev->dev); |
| 307 | 325 | if (!dev->pm_runtime_disabled) |
| 308 | 326 | pm_runtime_disable(&pdev->dev); |
| 327 | + if (!IS_ERR_OR_NULL(dev->rst)) | |
| 328 | + reset_control_assert(dev->rst); | |
| 309 | 329 | |
| 310 | 330 | return 0; |
| 311 | 331 | } |
| @@ -457,7 +457,6 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) · 456 unmodified lines | ||
| 457 | 457 | |
| 458 | 458 | int_status = readl(i2c->regs + HSI2C_INT_STATUS); |
| 459 | 459 | writel(int_status, i2c->regs + HSI2C_INT_STATUS); |
| 460 | − trans_status = readl(i2c->regs + HSI2C_TRANS_STATUS); | |
| 461 | 460 | |
| 462 | 461 | /* handle interrupt related to the transfer status */ |
| 463 | 462 | if (i2c->variant->hw == HSI2C_EXYNOS7) { |
| @@ -482,11 +481,13 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) · 18 unmodified lines | ||
| 482 | 481 | goto stop; |
| 483 | 482 | } |
| 484 | 483 | |
| 484 | + trans_status = readl(i2c->regs + HSI2C_TRANS_STATUS); | |
| 485 | 485 | if ((trans_status & HSI2C_MASTER_ST_MASK) == HSI2C_MASTER_ST_LOSE) { |
| 486 | 486 | i2c->state = -EAGAIN; |
| 487 | 487 | goto stop; |
| 488 | 488 | } |
| 489 | 489 | } else if (int_status & HSI2C_INT_I2C) { |
| 490 | + trans_status = readl(i2c->regs + HSI2C_TRANS_STATUS); | |
| 490 | 491 | if (trans_status & HSI2C_NO_DEV_ACK) { |
| 491 | 492 | dev_dbg(i2c->dev, "No ACK from device\n"); |
| 492 | 493 | i2c->state = -ENXIO; |
| @@ -175,7 +175,7 @@ static void meson_i2c_put_data(struct meson_i2c *i2c, char *buf, int len) · 174 unmodified lines | ||
| 175 | 175 | wdata1 |= *buf++ << ((i - 4) * 8); |
| 176 | 176 | |
| 177 | 177 | writel(wdata0, i2c->regs + REG_TOK_WDATA0); |
| 178 | − writel(wdata0, i2c->regs + REG_TOK_WDATA1); | |
| 178 | + writel(wdata1, i2c->regs + REG_TOK_WDATA1); | |
| 179 | 179 | |
| 180 | 180 | dev_dbg(i2c->dev, "%s: data %08x %08x len %d\n", __func__, |
| 181 | 181 | wdata0, wdata1, len); |
| @@ -172,14 +172,6 @@ static const struct i2c_adapter_quirks mt6577_i2c_quirks = { · 171 unmodified lines | ||
| 172 | 172 | .max_comb_2nd_msg_len = 31, |
| 173 | 173 | }; |
| 174 | 174 | |
| 175 | −static const struct i2c_adapter_quirks mt8173_i2c_quirks = { | |
| 176 | − .max_num_msgs = 65535, | |
| 177 | − .max_write_len = 65535, | |
| 178 | − .max_read_len = 65535, | |
| 179 | − .max_comb_1st_msg_len = 65535, | |
| 180 | − .max_comb_2nd_msg_len = 65535, | |
| 181 | −}; | |
| 182 | − | |
| 183 | 175 | static const struct mtk_i2c_compatible mt6577_compat = { |
| 184 | 176 | .quirks = &mt6577_i2c_quirks, |
| 185 | 177 | .pmic_i2c = 0, |
| @@ -199,7 +191,6 @@ static const struct mtk_i2c_compatible mt6589_compat = { · 13 unmodified lines | ||
| 199 | 191 | }; |
| 200 | 192 | |
| 201 | 193 | static const struct mtk_i2c_compatible mt8173_compat = { |
| 202 | − .quirks = &mt8173_i2c_quirks, | |
| 203 | 194 | .pmic_i2c = 0, |
| 204 | 195 | .dcm = 1, |
| 205 | 196 | .auto_restart = 1, |
| @@ -218,8 +218,12 @@ static irqreturn_t riic_tend_isr(int irq, void *data) · 217 unmodified lines | ||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | if (riic->is_last || riic->err) { |
| 221 | − riic_clear_set_bit(riic, 0, ICIER_SPIE, RIIC_ICIER); | |
| 221 | + riic_clear_set_bit(riic, ICIER_TEIE, ICIER_SPIE, RIIC_ICIER); | |
| 222 | 222 | writeb(ICCR2_SP, riic->base + RIIC_ICCR2); |
| 223 | + } else { | |
| 224 | + /* Transfer is complete, but do not send STOP */ | |
| 225 | + riic_clear_set_bit(riic, ICIER_TEIE, 0, RIIC_ICIER); | |
| 226 | + complete(&riic->msg_done); | |
| 223 | 227 | } |
| 224 | 228 | |
| 225 | 229 | return IRQ_HANDLED; |
| @@ -429,6 +429,7 @@ void i2c_mux_del_adapters(struct i2c_mux_core *muxc) · 428 unmodified lines | ||
| 429 | 429 | while (muxc->num_adapters) { |
| 430 | 430 | struct i2c_adapter *adap = muxc->adapter[--muxc->num_adapters]; |
| 431 | 431 | struct i2c_mux_priv *priv = adap->algo_data; |
| 432 | + struct device_node *np = adap->dev.of_node; | |
| 432 | 433 | |
| 433 | 434 | muxc->adapter[muxc->num_adapters] = NULL; |
| 434 | 435 | |
| @@ -438,6 +439,7 @@ void i2c_mux_del_adapters(struct i2c_mux_core *muxc) · 3 unmodified lines | ||
| 438 | 439 | |
| 439 | 440 | sysfs_remove_link(&priv->adap.dev.kobj, "mux_device"); |
| 440 | 441 | i2c_del_adapter(adap); |
| 442 | + of_node_put(np); | |
| 441 | 443 | kfree(priv); |
| 442 | 444 | } |
| 443 | 445 | } |