1. 30 Aug, 2018 1 commit
  2. 24 Aug, 2018 1 commit
  3. 08 Aug, 2018 1 commit
  4. 04 Aug, 2018 1 commit
  5. 20 Jul, 2018 1 commit
    • Peter Rosin's avatar
      i2c: smbus: add unlocked __i2c_smbus_xfer variant · eef5ba1a
      Peter Rosin authored
      Removes all locking from i2c_smbus_xfer and renames it to __i2c_smbus_xfer,
      then adds a new i2c_smbus_xfer function that simply grabs the lock while
      calling the unlocked variant.
      
      This is not perfectly equivalent, since i2c_smbus_xfer was callable from
      atomic/irq context if you happened to end up emulating SMBus with an I2C
      transfer, and that is no longer the case with this patch. It is unknown
      (to me) if anything depends on that quirk, but it seems fragile enough to
      simply break those cases and require them to call i2c_transfer directly
      instead.
      
      While at it, for consistency rename the 2nd to last argument (size) of
      the i2c_smbus_xfer declaration to protocol and remove the surplus extern
      marker.
      Signed-off-by: Peter Rosin's avatarPeter Rosin <peda@axentia.se>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      eef5ba1a
  6. 17 Jul, 2018 2 commits
  7. 12 Jul, 2018 1 commit
    • Peter Rosin's avatar
      i2c: remove i2c_lock_adapter and use i2c_lock_bus directly · 3f3a89e1
      Peter Rosin authored
      The i2c_lock_adapter name is ambiguous since it is unclear if it
      refers to the root adapter or the adapter you name in the argument.
      The natural interpretation is the adapter you name in the argument,
      but there are historical reasons for that not being the case; it
      in fact locks the root adapter. Just remove the function and force
      users to spell out the I2C_LOCK_ROOT_ADAPTER name to indicate what
      is really going on. Also remove i2c_unlock_adapter, of course.
      
      This patch was generated with
      
      git grep -l 'i2c_\(un\)\?lock_adapter' \
      | xargs sed -i 's/i2c_\(un\)\?lock_adapter(\([^)]*\))/'\
      'i2c_\1lock_bus(\2, I2C_LOCK_ROOT_ADAPTER)/g'
      
      followed by white-space touch-up.
      Signed-off-by: Peter Rosin's avatarPeter Rosin <peda@axentia.se>
      Acked-by: default avatarJonathan Cameron <jonathan.cameron@huawei.com>
      Tested-by: default avatarSekhar Nori <nsekhar@ti.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      3f3a89e1
  8. 03 Jul, 2018 1 commit
    • Peter Rosin's avatar
      i2c: smbus: add unlocked __i2c_smbus_xfer variant · 63453b59
      Peter Rosin authored
      Removes all locking from i2c_smbus_xfer and renames it to __i2c_smbus_xfer,
      then adds a new i2c_smbus_xfer function that simply grabs the lock while
      calling the unlocked variant.
      
      This is not perfectly equivalent, since i2c_smbus_xfer was callable from
      atomic/irq context if you happened to end up emulating SMBus with an I2C
      transfer, and that is no longer the case with this patch. It is unknown
      (to me) if anything depends on that quirk, but it seems fragile enough to
      simply break those cases and require them to call i2c_transfer directly
      instead.
      
      While at it, for consistency rename the 2nd to last argument (size) of
      the i2c_smbus_xfer declaration to protocol and remove the surplus extern
      marker.
      Signed-off-by: Peter Rosin's avatarPeter Rosin <peda@axentia.se>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      63453b59
  9. 22 May, 2018 1 commit
    • Boris Brezillon's avatar
      i2c: Export of_i2c_get_board_info() · da0086d0
      Boris Brezillon authored
      I3C busses have to know about all I2C devices connected on the I3C bus
      to properly initialize the I3C master, and I2C frames can't be sent on
      the bus until this initialization is done.
      
      We can't let the I2C core parse the DT and instantiate I2C devices as
      part of its i2c_add_adapter() procedure because, when done this way,
      I2C devices are directly registered to the device-model and might be
      attached to drivers which could in turn start sending frames on the bus,
      which won't work since, as said above, the bus is not yet initialized.
      
      Export of_i2c_register_device() in order to let the I3C core parse the
      I2C device nodes by itself and initialize the bus.
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      da0086d0
  10. 15 May, 2018 1 commit
  11. 06 Mar, 2018 1 commit
  12. 15 Jan, 2018 3 commits
  13. 03 Dec, 2017 3 commits
  14. 27 Nov, 2017 3 commits
  15. 27 Oct, 2017 1 commit
    • Hans de Goede's avatar
      i2c: Allow overriding dev_name through board_info · 728fe6ce
      Hans de Goede authored
      For devices not instantiated through ACPI the i2c-client's device-name
      gets set to <busnr>-<addr> by default, e.g. "0-0022" this means that
      the device-name is dependent on the order in which the i2c-busses are
      enumerated.
      
      In some cases having a predictable constant device-name is desirable,
      for example on non device-tree platforms the link between a regulator
      and its consumers is specified by the platform code by setting
      regulator_init_data.consumers. This array identifies the regulator's
      consumers by dev_name and supply(-name). Which requires a constant
      dev_name.
      
      This commit adds a dev_name field to i2c_board_info allowing
      platform code to set a contstant dev_name so that the device can
      be identified by its dev_name in other platform code.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Acked-by: Mark Brown <broonie@kernel.org> (live at ELCE17)
      Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> (live at ELCE17)
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      728fe6ce
  16. 31 Jul, 2017 1 commit
  17. 08 Jul, 2017 1 commit
  18. 16 Apr, 2017 2 commits
    • Hans de Goede's avatar
      i2c: core: Allow drivers to disable i2c-core irq mapping · d1d84bb9
      Hans de Goede authored
      By default the i2c-core will try to get an irq with index 0 on ACPI / of
      instantiated devices. This is troublesome on some ACPI systems where the
      irq info at index 0 in the CRS table may contain nonsense and/or point
      to an irqchip for which there is no Linux driver.
      
      If this happens then before this commit the driver's probe method would
      never get called because i2c_device_probe will try to get an irq by
      calling acpi_dev_gpio_irq_get which will always return -EPROBE in this
      case, as it waits for a matching irqchip driver to load. Thus causing
      the driver to not get a chance to bind.
      
      This commit adds a new disable_i2c_core_irq_mapping flag to struct
      i2c_driver which a driver can set to tell the core to skip irq mapping.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      d1d84bb9
    • Hans de Goede's avatar
      i2c: core: Add new i2c_acpi_new_device helper function · 605f8fc2
      Hans de Goede authored
      By default the i2c subsys creates an i2c-client for the first I2cSerialBus
      resource of an acpi_device, but some acpi_devices have multiple
      I2cSerialBus resources and we may want to instantiate i2c-clients for
      the others.
      
      This commit adds a new i2c_acpi_new_device function which can be used to
      create an i2c-client for any I2cSerialBus resource of an acpi_device.
      
      Note that the other resources may even be on a different i2c bus, so just
      retrieving the client address is not enough.
      
      Here is an example DSDT excerpt from such a device:
      
      Device (WIDR)
      {
          Name (_HID, "INT33FE" /* XPOWER Battery Device */)
          Name (_CID, "INT33FE" /* XPOWER Battery Device */)
          Name (_DDN, "WC PMIC Battery Device")
      <snip>
          Name (RBUF, ResourceTemplate ()
          {
              I2cSerialBusV2 (0x005E, ControllerInitiated, 0x000186A0,
                  AddressingMode7Bit, "\\_SB.PCI0.I2C7",
                  0x00, ResourceConsumer, , Exclusive,
                  )
              I2cSerialBusV2 (0x0036, ControllerInitiated, 0x000186A0,
                  AddressingMode7Bit, "\\_SB.PCI0.I2C1",
                  0x00, ResourceConsumer, , Exclusive,
                  )
              I2cSerialBusV2 (0x0022, ControllerInitiated, 0x00061A80,
                  AddressingMode7Bit, "\\_SB.PCI0.I2C1",
                  0x00, ResourceConsumer, , Exclusive,
                  )
              I2cSerialBusV2 (0x0054, ControllerInitiated, 0x00061A80,
                  AddressingMode7Bit, "\\_SB.PCI0.I2C1",
                  0x00, ResourceConsumer, , Exclusive,
                  )
              GpioInt (Level, ActiveLow, Exclusive, PullNone, 0x0000,
                  "\\_SB.PCI0.I2C7.PMI5", 0x00, ResourceConsumer, ,
                  )
                  {   // Pin list
              0x0012
                  }
              GpioInt (Edge, ActiveLow, ExclusiveAndWake, PullNone, 0x0000,
                  "\\_SB.GPO1", 0x00, ResourceConsumer, ,
                  )
                  {   // Pin list
              0x0005
                  }
              GpioInt (Level, ActiveLow, Exclusive, PullNone, 0x0000,
                  "\\_SB.PCI0.I2C7.PMI5", 0x00, ResourceConsumer, ,
                  )
                  {   // Pin list
              0x0013
                  }
          })
          Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
          {
              Return (RBUF) /* \_SB_.PCI0.I2C7.WIDR.RBUF */
          }
      <snip>
      }
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      605f8fc2
  19. 01 Apr, 2017 2 commits
  20. 02 Mar, 2017 1 commit
  21. 08 Feb, 2017 1 commit
  22. 28 Jan, 2017 1 commit
  23. 12 Jan, 2017 1 commit
  24. 24 Nov, 2016 1 commit
    • Benjamin Tissoires's avatar
      i2c: use an IRQ to report Host Notify events, not alert · 4d5538f5
      Benjamin Tissoires authored
      The current SMBus Host Notify implementation relies on .alert() to
      relay its notifications. However, the use cases where SMBus Host
      Notify is needed currently is to signal data ready on touchpads.
      
      This is closer to an IRQ than a custom API through .alert().
      Given that the 2 touchpad manufacturers (Synaptics and Elan) that
      use SMBus Host Notify don't put any data in the SMBus payload, the
      concept actually matches one to one.
      
      Benefits are multiple:
      - simpler code and API: the client will just have an IRQ, and
        nothing needs to be added in the adapter beside internally
        enabling it.
      - no more specific workqueue, the threading is handled by IRQ core
        directly (when required)
      - no more races when removing the device (the drivers are already
        required to disable irq on remove)
      - simpler handling for drivers: use plain regular IRQs
      - no more dependency on i2c-smbus for i2c-i801 (and any other adapter)
      - the IRQ domain is created automatically when the adapter exports
        the Host Notify capability
      - the IRQ are assign only if ACPI, OF and the caller did not assign
        one already
      - the domain is automatically destroyed on remove
      - fewer lines of code (minus 20, yeah!)
      Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      4d5538f5
  25. 17 Nov, 2016 3 commits
  26. 24 Sep, 2016 1 commit
  27. 30 Aug, 2016 1 commit
  28. 25 Aug, 2016 2 commits
    • Jarkko Nikula's avatar
      i2c: core: Add function for finding the bus speed from ACPI, take 2 · 5853b22d
      Jarkko Nikula authored
      ACPI 5 specification doesn't have property for the I2C bus speed but
      I2cSerialBus resource descriptor which define each controller-slave
      connection define the maximum speed supported by that connection.
      
      Thus finding the maximum safe speed for the bus is to walk through all
      I2cSerialBus resources that are associated to I2C controller and use the
      speed of slowest connection.
      
      Add function i2c_acpi_find_bus_speed() to the i2c-core that adapter
      drivers can call prior registering itself to core.
      
      This implies two-step walk through the I2cSerialBus resources: call to
      i2c_acpi_find_bus_speed() does the first scan and finds the safe bus
      speed that adapter drivers can set up. Adapter driver registration does
      the second scan when i2c-core creates the I2C slaves by calling the
      i2c_acpi_register_devices(). In that way the bus speed is set in case
      slave device probe gets called during registration and does communication.
      
      Previous version commit 55d38d06 ("i2c: core: Add function for finding
      the bus speed from ACPI") got reverted due merge conflicts from
      commit 525e6fab ("i2c / ACPI: add support for ACPI reconfigure
      notifications").
      
      This version is a bit bigger than previous version but is still sharing
      the lowest and complicated part of I2cSerialBus lookup routines with the
      existing code.
      Signed-off-by: default avatarJarkko Nikula <jarkko.nikula@linux.intel.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      5853b22d
    • Peter Rosin's avatar
      i2c: add i2c_trylock_bus wrapper, use it · fb79e09a
      Peter Rosin authored
      This unifies usage with i2c_lock_bus and i2c_unlock_bus, and paves the
      way for the next patch which looks a bit saner with this preparatory
      work taken care of beforehand.
      Signed-off-by: Peter Rosin's avatarPeter Rosin <peda@axentia.se>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      fb79e09a