1. 27 Apr, 2016 5 commits
    • Thomas Petazzoni's avatar
      i2c: mv64xxx: remove CONFIG_HAVE_CLK conditionals · f3a36fbd
      Thomas Petazzoni authored
      When clock support was added to the i2c-mv64xxx, not all clk functions
      had stubs when for !CONFIG_HAVE_CLK configurations. However, nowadays,
      both "struct clk" and all the clock framework functions have stubs
      when CONFIG_HAVE_CLK is not enabled, so it no longer makes sense to
      carry such compile-time conditionals in the driver.
      
      This commit was compile tested on both ARM64 (which has both
      CONFIG_OF=y and CONFIG_HAVE_CLK=y) and PowerPC c2k_defconfig (which
      has CONFIG_OF=y, CONFIG_HAVE_CLK disabled, and the i2c-mv64xxx driver
      enabled).
      
      The only non-trivial change is in the mv64xxx_of_config() function,
      which was returning -ENODEV unconditionally if CONFIG_HAVE_CLK was
      disabled. Simply removing this condition works fine because the first
      test done by the function is to verify if drv_data->clk points to a
      valid clock, and if it doesn't, we return -ENODEV. When
      CONFIG_HAVE_CLK is disabled, devm_clk_get() unconditionally returns
      NULL, so mv64xxx_of_config() will return -ENODEV when no clock is
      provided, which is the intended behavior.
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      f3a36fbd
    • Thomas Petazzoni's avatar
      i2c: mv64xxx: use clk_{prepare_enable,disable_unprepare} · 70719350
      Thomas Petazzoni authored
      Instead of separately calling clk_prepare()/clk_enable(), use
      clk_prepare_enable(), and instead of calling
      clk_disable()/clk_unprepare(), use clk_disable_unprepare(). Those
      handy shortcuts have been introduced specifically to simplify the
      numerous call sites were both functions were called in sequence.
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      70719350
    • Thomas Petazzoni's avatar
      i2c: mv64xxx: handle probe deferral for the clock · 9f4d6f16
      Thomas Petazzoni authored
      If a clock is registered by a platform driver and not by the
      OF_CLK_DECLARE() mechanism, it might show up after the first attempt
      to probe i2c-mv64xxx. In order to solve this, we need to handle
      -EPROBE_PREFER as a special return value of devm_clk_get(), and return
      the same error code from probe().
      
      This gives us three situations:
      
       - There is no reference to a clock in the DT. In this case,
         devm_clk_get() returns an error that is not -EPROBE_DEFER
         (something like -ENODEV), and we continue the probing without
         enabling the clock.
      
       - There is a reference to the clock in the DT, and the clock is
         ready. devm_clk_get() returns a valid reference to the clock, and
         we prepare/enable it.
      
       - There is a reference to the clock in the DT, but the clock is not
         ready. devm_clk_get() returns -EPROBE_DEFER, and we exit from
         probe() with the same error code so that probe() is tried again
         later.
      
      This is needed for Marvell Armada 7K/8K, where the clock driver is a
      platform driver.
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      9f4d6f16
    • Thomas Petazzoni's avatar
      i2c: mv64xxx: enable the driver on ARCH_MVEBU · 05872b80
      Thomas Petazzoni authored
      The new ARM64 Marvell Armada 7K/8K SoC family is using the same I2C
      controller as the 32-bits Marvell EBU SoCs, so this commit allows
      mv64xxx to be enabled when ARCH_MVEBU=y.
      Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      05872b80
    • David Daney's avatar
      i2c: octeon: Add workaround for broken irqs on CN3860 · fe600cf6
      David Daney authored
      CN3860 does not interrupt the CPU when the i2c status changes. If
      we get a timeout, and see the status has in fact changed, we know we
      have this problem, and drop back to polling.
      Signed-off-by: default avatarDavid Daney <ddaney@caviumnetworks.com>
      Signed-off-by: default avatarJan Glauber <jglauber@cavium.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      fe600cf6
  2. 26 Apr, 2016 4 commits
    • Javier Martinez Canillas's avatar
      i2c: nforce2: Use IS_ENABLED() instead of checking for built-in or module · dd485951
      Javier Martinez Canillas authored
      The IS_ENABLED() macro checks if a Kconfig symbol has been enabled either
      built-in or as a module, use that macro instead of open coding the same.
      Signed-off-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      dd485951
    • Oleksij Rempel's avatar
      i2c: imx: reduce load by using usleep_range instead of udelay · 2b899f34
      Oleksij Rempel authored
      Documentation/timers/timers-howto.txt recommends to use
      usleep_range on delays > 10usec. According to my test results
      with Neonode zForce touchscreen driver, usleep_range indeed
      reduces CPU load.
      
      Stats collected with "./perf record -a -g -F 1000 sleep 10"
      
      i2c-imx with udelay(50):
      34.19% 0.00% irq/220-Neonode [kernel.kallsyms] [k] irq_thread
          ---irq_thread
             |--33.75%--irq_thread_fn
             |    |--19.27%--0x7f08a878
             |    |     i2c_master_recv
             |    |     i2c_transfer
             |    |     __i2c_transfer
             |    |     i2c_imx_xfer
             |    |     |--11.71%--i2c_imx_trx_complete
             |    |     |--5.70%--i2c_imx_start <<<<----------------
             |    |     |     |--5.38%--__timer_const_udelay
             |    |     |     |      __timer_delay
             |    |     |     |      --5.07%--read_current_timer
      
      i2c-imx with usleep_range(50,100)
      29.08% 0.00% irq/220-Neonode  [kernel.kallsyms] [k] irq_thread
          ---irq_thread
             |--28.89%--irq_thread_fn
             |    |--17.21%--0x7f08a878
             |    |     i2c_master_recv
             |    |     |--17.14%--i2c_transfer
             |    |     |     __i2c_transfer
             |    |     |     i2c_imx_xfer
             |    |     |     |--14.29%--i2c_imx_trx_complete
             |    |     |     |--1.42%--i2c_imx_start <<<<----------
             |    |     |     |      |--0.71%--usleep_range
             |    |     |     |      |--0.53%--i2c_imx_bus_busy
      Signed-off-by: default avatarOleksij Rempel <linux@rempel-privat.de>
      Signed-off-by: default avatarDirk Behme <dirk.behme@de.bosch.com>
      Reviewed-by: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      2b899f34
    • Peter Swain's avatar
      i2c: octeon: Improve performance if interrupt is early · 1bb1ff3e
      Peter Swain authored
      There is a race between the TWSI interrupt and the condition
      that is required before proceeding:
      
      Low-level: interrupt flag bit must be set
      High-level controller: valid bit must be clear
      
      If the interrupt comes too early and the condition is not met
      the wait will time out, and the transfer is aborted leading
      to very poor performance.
      
      To avoid this race retry for the condition ~80 µs later.
      The retry is avoided on the very first invocation of
      wait_event_timeout() (which tests the condition before entering
      the wait and is therefore always wrong in this case).
      
      EEPROM reads on 100kHz i2c now measure ~5.2kB/s, about 1/2 what's
      achievable, and much better than the worst-case 100 bytes/sec before.
      
      While at it remove the debug print from the low-level wait function.
      Signed-off-by: default avatarPeter Swain <pswain@cavium.com>
      Signed-off-by: default avatarJan Glauber <jglauber@cavium.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      1bb1ff3e
    • Jan Glauber's avatar
      i2c: octeon: Remove zero-length message support · 392d01de
      Jan Glauber authored
      Zero-length message support (SMBUS QUICK or i2c) never worked with
      the Octeon hardware. Disable SMBUS QUICK support and bail out in
      case of a zero-length i2c request.
      
      After this change 'i2c-detect -q' will return an error on Octeon but
      the previously reported results were wrong anyway.
      Signed-off-by: default avatarJan Glauber <jglauber@cavium.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      392d01de
  3. 25 Apr, 2016 10 commits
  4. 24 Apr, 2016 5 commits
  5. 22 Apr, 2016 15 commits
  6. 16 Apr, 2016 1 commit