Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
"Two driver bugfixes, a documentation fix, and a removal of a spec
violation for the bus recovery algorithm in the core"

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: fix bus recovery stop mode timing
i2c: bcm2835: Store pointer to bus clock
dt-bindings: i2c: at91: fix i2c-sda-hold-time-ns documentation for sam9x60
i2c: at91: fix clk_offset for sam9x60

Changed files
+23 -15
Documentation
devicetree
bindings
drivers
+4 -2
Documentation/devicetree/bindings/i2c/i2c-at91.txt
··· 18 18 - dma-names: should contain "tx" and "rx". 19 19 - atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO 20 20 capable I2C controllers. 21 - - i2c-sda-hold-time-ns: TWD hold time, only available for "atmel,sama5d4-i2c" 22 - and "atmel,sama5d2-i2c". 21 + - i2c-sda-hold-time-ns: TWD hold time, only available for: 22 + "atmel,sama5d4-i2c", 23 + "atmel,sama5d2-i2c", 24 + "microchip,sam9x60-i2c". 23 25 - Child nodes conforming to i2c bus binding 24 26 25 27 Examples :
+1 -1
drivers/i2c/busses/i2c-at91-core.c
··· 174 174 175 175 static struct at91_twi_pdata sam9x60_config = { 176 176 .clk_max_div = 7, 177 - .clk_offset = 4, 177 + .clk_offset = 3, 178 178 .has_unre_flag = true, 179 179 .has_alt_cmd = true, 180 180 .has_hold_field = true,
+8 -9
drivers/i2c/busses/i2c-bcm2835.c
··· 58 58 struct i2c_adapter adapter; 59 59 struct completion completion; 60 60 struct i2c_msg *curr_msg; 61 + struct clk *bus_clk; 61 62 int num_msgs; 62 63 u32 msg_err; 63 64 u8 *msg_buf; ··· 405 404 struct resource *mem, *irq; 406 405 int ret; 407 406 struct i2c_adapter *adap; 408 - struct clk *bus_clk; 409 407 struct clk *mclk; 410 408 u32 bus_clk_rate; 411 409 ··· 427 427 return PTR_ERR(mclk); 428 428 } 429 429 430 - bus_clk = bcm2835_i2c_register_div(&pdev->dev, mclk, i2c_dev); 430 + i2c_dev->bus_clk = bcm2835_i2c_register_div(&pdev->dev, mclk, i2c_dev); 431 431 432 - if (IS_ERR(bus_clk)) { 432 + if (IS_ERR(i2c_dev->bus_clk)) { 433 433 dev_err(&pdev->dev, "Could not register clock\n"); 434 - return PTR_ERR(bus_clk); 434 + return PTR_ERR(i2c_dev->bus_clk); 435 435 } 436 436 437 437 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", ··· 442 442 bus_clk_rate = 100000; 443 443 } 444 444 445 - ret = clk_set_rate_exclusive(bus_clk, bus_clk_rate); 445 + ret = clk_set_rate_exclusive(i2c_dev->bus_clk, bus_clk_rate); 446 446 if (ret < 0) { 447 447 dev_err(&pdev->dev, "Could not set clock frequency\n"); 448 448 return ret; 449 449 } 450 450 451 - ret = clk_prepare_enable(bus_clk); 451 + ret = clk_prepare_enable(i2c_dev->bus_clk); 452 452 if (ret) { 453 453 dev_err(&pdev->dev, "Couldn't prepare clock"); 454 454 return ret; ··· 491 491 static int bcm2835_i2c_remove(struct platform_device *pdev) 492 492 { 493 493 struct bcm2835_i2c_dev *i2c_dev = platform_get_drvdata(pdev); 494 - struct clk *bus_clk = devm_clk_get(i2c_dev->dev, "div"); 495 494 496 - clk_rate_exclusive_put(bus_clk); 497 - clk_disable_unprepare(bus_clk); 495 + clk_rate_exclusive_put(i2c_dev->bus_clk); 496 + clk_disable_unprepare(i2c_dev->bus_clk); 498 497 499 498 free_irq(i2c_dev->irq, i2c_dev); 500 499 i2c_del_adapter(&i2c_dev->adapter);
+10 -3
drivers/i2c/i2c-core-base.c
··· 186 186 * If we can set SDA, we will always create a STOP to ensure additional 187 187 * pulses will do no harm. This is achieved by letting SDA follow SCL 188 188 * half a cycle later. Check the 'incomplete_write_byte' fault injector 189 - * for details. 189 + * for details. Note that we must honour tsu:sto, 4us, but lets use 5us 190 + * here for simplicity. 190 191 */ 191 192 bri->set_scl(adap, scl); 192 - ndelay(RECOVERY_NDELAY / 2); 193 + ndelay(RECOVERY_NDELAY); 193 194 if (bri->set_sda) 194 195 bri->set_sda(adap, scl); 195 196 ndelay(RECOVERY_NDELAY / 2); ··· 212 211 scl = !scl; 213 212 bri->set_scl(adap, scl); 214 213 /* Creating STOP again, see above */ 215 - ndelay(RECOVERY_NDELAY / 2); 214 + if (scl) { 215 + /* Honour minimum tsu:sto */ 216 + ndelay(RECOVERY_NDELAY); 217 + } else { 218 + /* Honour minimum tf and thd:dat */ 219 + ndelay(RECOVERY_NDELAY / 2); 220 + } 216 221 if (bri->set_sda) 217 222 bri->set_sda(adap, scl); 218 223 ndelay(RECOVERY_NDELAY / 2);