Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull i2c fixes from Wolfram Sang:
"i2c has a bugfix and documentation improvements for you"

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
Documentation: i2c: mention ACPI method for instantiating devices
Documentation: i2c: describe devicetree method for instantiating devices
i2c: mv64xxx: refactor message start to ensure proper initialization

+53 -21
+39 -2
Documentation/i2c/instantiating-devices
··· 8 8 several ways to achieve this, depending on the context and requirements. 9 9 10 10 11 - Method 1: Declare the I2C devices by bus number 12 - ----------------------------------------------- 11 + Method 1a: Declare the I2C devices by bus number 12 + ------------------------------------------------ 13 13 14 14 This method is appropriate when the I2C bus is a system bus as is the case 15 15 for many embedded systems. On such systems, each I2C bus has a number ··· 49 49 50 50 The devices will be automatically unbound and destroyed when the I2C bus 51 51 they sit on goes away (if ever.) 52 + 53 + 54 + Method 1b: Declare the I2C devices via devicetree 55 + ------------------------------------------------- 56 + 57 + This method has the same implications as method 1a. The declaration of I2C 58 + devices is here done via devicetree as subnodes of the master controller. 59 + 60 + Example: 61 + 62 + i2c1: i2c@400a0000 { 63 + /* ... master properties skipped ... */ 64 + clock-frequency = <100000>; 65 + 66 + flash@50 { 67 + compatible = "atmel,24c256"; 68 + reg = <0x50>; 69 + }; 70 + 71 + pca9532: gpio@60 { 72 + compatible = "nxp,pca9532"; 73 + gpio-controller; 74 + #gpio-cells = <2>; 75 + reg = <0x60>; 76 + }; 77 + }; 78 + 79 + Here, two devices are attached to the bus using a speed of 100kHz. For 80 + additional properties which might be needed to set up the device, please refer 81 + to its devicetree documentation in Documentation/devicetree/bindings/. 82 + 83 + 84 + Method 1c: Declare the I2C devices via ACPI 85 + ------------------------------------------- 86 + 87 + ACPI can also describe I2C devices. There is special documentation for this 88 + which is currently located at Documentation/acpi/enumeration.txt. 52 89 53 90 54 91 Method 2: Instantiate the devices explicitly
+14 -19
drivers/i2c/busses/i2c-mv64xxx.c
··· 97 97 enum { 98 98 MV64XXX_I2C_ACTION_INVALID, 99 99 MV64XXX_I2C_ACTION_CONTINUE, 100 - MV64XXX_I2C_ACTION_OFFLOAD_SEND_START, 101 100 MV64XXX_I2C_ACTION_SEND_START, 102 101 MV64XXX_I2C_ACTION_SEND_RESTART, 103 102 MV64XXX_I2C_ACTION_OFFLOAD_RESTART, ··· 202 203 unsigned long data_reg_lo = 0; 203 204 unsigned long ctrl_reg; 204 205 struct i2c_msg *msg = drv_data->msgs; 206 + 207 + if (!drv_data->offload_enabled) 208 + return -EOPNOTSUPP; 205 209 206 210 drv_data->msg = msg; 207 211 drv_data->byte_posn = 0; ··· 435 433 436 434 drv_data->msgs++; 437 435 drv_data->num_msgs--; 438 - if (!(drv_data->offload_enabled && 439 - mv64xxx_i2c_offload_msg(drv_data))) { 436 + if (mv64xxx_i2c_offload_msg(drv_data) < 0) { 440 437 drv_data->cntl_bits |= MV64XXX_I2C_REG_CONTROL_START; 441 438 writel(drv_data->cntl_bits, 442 439 drv_data->reg_base + drv_data->reg_offsets.control); ··· 459 458 drv_data->reg_base + drv_data->reg_offsets.control); 460 459 break; 461 460 462 - case MV64XXX_I2C_ACTION_OFFLOAD_SEND_START: 463 - if (!mv64xxx_i2c_offload_msg(drv_data)) 464 - break; 465 - else 466 - drv_data->action = MV64XXX_I2C_ACTION_SEND_START; 467 - /* FALLTHRU */ 468 461 case MV64XXX_I2C_ACTION_SEND_START: 469 - writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_START, 470 - drv_data->reg_base + drv_data->reg_offsets.control); 462 + /* Can we offload this msg ? */ 463 + if (mv64xxx_i2c_offload_msg(drv_data) < 0) { 464 + /* No, switch to standard path */ 465 + mv64xxx_i2c_prepare_for_io(drv_data, drv_data->msgs); 466 + writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_START, 467 + drv_data->reg_base + drv_data->reg_offsets.control); 468 + } 471 469 break; 472 470 473 471 case MV64XXX_I2C_ACTION_SEND_ADDR_1: ··· 625 625 unsigned long flags; 626 626 627 627 spin_lock_irqsave(&drv_data->lock, flags); 628 - if (drv_data->offload_enabled) { 629 - drv_data->action = MV64XXX_I2C_ACTION_OFFLOAD_SEND_START; 630 - drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_START_COND; 631 - } else { 632 - mv64xxx_i2c_prepare_for_io(drv_data, msg); 633 628 634 - drv_data->action = MV64XXX_I2C_ACTION_SEND_START; 635 - drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_START_COND; 636 - } 629 + drv_data->action = MV64XXX_I2C_ACTION_SEND_START; 630 + drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_START_COND; 631 + 637 632 drv_data->send_stop = is_last; 638 633 drv_data->block = 1; 639 634 mv64xxx_i2c_do_action(drv_data);