• Linus Walleij's avatar
    i2c: gpio: Convert to use descriptors · b2e63555
    Linus Walleij authored
    This converts the GPIO-based I2C-driver to using GPIO
    descriptors instead of the old global numberspace-based
    GPIO interface. We:
    
    - Convert the driver to unconditionally grab two GPIOs
      from the device by index 0 (SDA) and 1 (SCL) which
      will work fine with device tree and descriptor tables.
      The existing device trees will continue to work just
      like before, but without any roundtrip through the
      global numberspace.
    
    - Brutally convert all boardfiles still passing global
      GPIOs by registering descriptor tables associated with
      the devices instead so this driver does not need to keep
      supporting passing any GPIO numbers as platform data.
    
    There is no stepwise approach as elegant as this, I
    strongly prefer this big hammer over any antsteps for this
    conversion. This way the old GPIO numbers go away and
    NEVER COME BACK.
    
    Special conversion for the different boards utilizing
    I2C-GPIO:
    
    - EP93xx (arch/arm/mach-ep93xx): pretty straight forward as
      all boards were using the same two GPIO lines, just define
      these two in a lookup table for "i2c-gpio" and register
      these along with the device. None of them define any
      other platform data so just pass NULL as platform data.
      This platform selects GPIOLIB so all should be smooth.
      The pins appear on a gpiochip for bank "G" as pins 1 (SDA)
      and 0 (SCL).
    
    - IXP4 (arch/arm/mach-ixp4): descriptor tables have to
      be registered for each board separately. They all use
      "IXP4XX_GPIO_CHIP" so it is pretty straight forward.
      Most board define no other platform data than SCL/SDA
      so they can drop the #include of <linux/i2c-gpio.h> and
      assign NULL to platform data.
    
      The "goramo_mlr" (Goramo Multilink Router) board is a bit
      worrisome: it implements its own I2C bit-banging in the
      board file, and optionally registers an I2C serial port,
      but claims the same GPIO lines for itself in the board file.
      This is not going to work: there will be competition for the
      GPIO lines, so delete the optional extra I2C bus instead, no
      I2C devices are registered on it anyway, there are just hints
      that it may contain an EEPROM that may be accessed from
      userspace. This needs to be fixed up properly by the serial
      clock using I2C emulation so drop a note in the code.
    
    - KS8695 board acs5k (arch/arm/mach-ks8695/board-acs5.c)
      has some platform data in addition to the pins so it needs to
      be kept around sans GPIO lines. Its GPIO chip is named
      "KS8695" and the arch selects GPIOLIB.
    
    - PXA boards (arch/arm/mach-pxa/*) use some of the platform
      data so it needs to be preserved here. The viper board even
      registers two GPIO I2Cs. The gpiochip is named "gpio-pxa" and
      the arch selects GPIOLIB.
    
    - SA1100 Simpad (arch/arm/mach-sa1100/simpad.c) defines a GPIO
      I2C bus, and the arch selects GPIOLIB.
    
    - Blackfin boards (arch/blackfin/bf533 etc) for these I assume
      their I2C GPIOs refer to the local gpiochip defined in
      arch/blackfin/kernel/bfin_gpio.c names "BFIN-GPIO".
      The arch selects GPIOLIB. The boards get spiked with
      IF_ENABLED(I2C_GPIO) but that is a side effect of it
      being like that already (I would just have Kconfig select
      I2C_GPIO and get rid of them all.) I also delete any
      platform data set to 0 as it will get that value anyway
      from static declartions of platform data.
    
    - The MIPS selects GPIOLIB and the Alchemy machine is using
      two local GPIO chips, one of them has a GPIO I2C. We need
      to adjust the local offset from the global number space here.
      The ATH79 has a proper GPIO driver in drivers/gpio/gpio-ath79.c
      and AFAICT the chip is named "ath79-gpio" and the PB44
      PCF857x expander spawns from this on GPIO 1 and 0. The latter
      board only use the platform data to specify pins so it can be
      cut altogether after this.
    
    - The MFD Silicon Motion SM501 is a special case. It dynamically
      spawns an I2C bus off the MFD using sm501_create_subdev().
      We use an approach to dynamically create a machine descriptor
      table and attach this to the "SM501-LOW" or "SM501-HIGH"
      gpiochip. We use chip-local offsets to grab the right lines.
      We can get rid of two local static inline helpers as part
      of this refactoring.
    
    Cc: Steven Miao <realmz6@gmail.com>
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: Guenter Roeck <linux@roeck-us.net>
    Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Cc: Magnus Damm <magnus.damm@gmail.com>
    Cc: Ben Dooks <ben.dooks@codethink.co.uk>
    Cc: Heiko Schocher <hs@denx.de>
    Acked-by: default avatarWu, Aaron <Aaron.Wu@analog.com>
    Acked-by: default avatarOlof Johansson <olof@lixom.net>
    Acked-by: default avatarLee Jones <lee.jones@linaro.org>
    Acked-by: default avatarRalf Baechle <ralf@linux-mips.org>
    Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    b2e63555
Name
Last commit
Last update
..
boot Loading commit data...
common Loading commit data...
configs Loading commit data...
crypto Loading commit data...
firmware Loading commit data...
include Loading commit data...
kernel Loading commit data...
kvm Loading commit data...
lib Loading commit data...
mach-actions Loading commit data...
mach-alpine Loading commit data...
mach-artpec Loading commit data...
mach-asm9260 Loading commit data...
mach-aspeed Loading commit data...
mach-at91 Loading commit data...
mach-axxia Loading commit data...
mach-bcm Loading commit data...
mach-berlin Loading commit data...
mach-clps711x Loading commit data...
mach-cns3xxx Loading commit data...
mach-davinci Loading commit data...
mach-digicolor Loading commit data...
mach-dove Loading commit data...
mach-ebsa110 Loading commit data...
mach-efm32 Loading commit data...
mach-ep93xx Loading commit data...
mach-exynos Loading commit data...
mach-footbridge Loading commit data...
mach-gemini Loading commit data...
mach-highbank Loading commit data...
mach-hisi Loading commit data...
mach-imx Loading commit data...
mach-integrator Loading commit data...
mach-iop13xx Loading commit data...
mach-iop32x Loading commit data...
mach-iop33x Loading commit data...
mach-ixp4xx Loading commit data...
mach-keystone Loading commit data...
mach-ks8695 Loading commit data...
mach-lpc18xx Loading commit data...
mach-lpc32xx Loading commit data...
mach-mediatek Loading commit data...
mach-meson Loading commit data...
mach-mmp Loading commit data...
mach-moxart Loading commit data...
mach-mv78xx0 Loading commit data...
mach-mvebu Loading commit data...
mach-mxs Loading commit data...
mach-netx Loading commit data...
mach-nomadik Loading commit data...
mach-nspire Loading commit data...
mach-omap1 Loading commit data...
mach-omap2 Loading commit data...
mach-orion5x Loading commit data...
mach-oxnas Loading commit data...
mach-picoxcell Loading commit data...
mach-prima2 Loading commit data...
mach-pxa Loading commit data...
mach-qcom Loading commit data...
mach-realview Loading commit data...
mach-rockchip Loading commit data...
mach-rpc Loading commit data...
mach-s3c24xx Loading commit data...
mach-s3c64xx Loading commit data...
mach-s5pv210 Loading commit data...
mach-sa1100 Loading commit data...
mach-shmobile Loading commit data...
mach-socfpga Loading commit data...
mach-spear Loading commit data...
mach-sti Loading commit data...
mach-stm32 Loading commit data...
mach-sunxi Loading commit data...
mach-tango Loading commit data...
mach-tegra Loading commit data...
mach-u300 Loading commit data...
mach-uniphier Loading commit data...
mach-ux500 Loading commit data...
mach-versatile Loading commit data...
mach-vexpress Loading commit data...
mach-vt8500 Loading commit data...
mach-w90x900 Loading commit data...
mach-zx Loading commit data...
mach-zynq Loading commit data...
mm Loading commit data...
net Loading commit data...
nwfpe Loading commit data...
oprofile Loading commit data...
plat-iop Loading commit data...
plat-omap Loading commit data...
plat-orion Loading commit data...
plat-pxa Loading commit data...
plat-samsung Loading commit data...
plat-versatile Loading commit data...
probes Loading commit data...
tools Loading commit data...
vdso Loading commit data...
vfp Loading commit data...
xen Loading commit data...
Kconfig Loading commit data...
Kconfig-nommu Loading commit data...
Kconfig.debug Loading commit data...
Makefile Loading commit data...