]> Git Repo - linux.git/commitdiff
Merge branch 'i2c/for-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
authorLinus Torvalds <[email protected]>
Fri, 14 Aug 2020 01:41:00 +0000 (18:41 -0700)
committerLinus Torvalds <[email protected]>
Fri, 14 Aug 2020 01:41:00 +0000 (18:41 -0700)
Pull i2c updates from Wolfram Sang:

 - bus recovery can now be given a pinctrl handle and the I2C core will
   do all the steps to switch to/from GPIO which can save quite some
   boilerplate code from drivers

 - "fallthrough" conversion

 - driver updates, mostly ID additions

* 'i2c/for-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (32 commits)
  i2c: iproc: fix race between client unreg and isr
  i2c: eg20t: use generic power management
  i2c: eg20t: Drop PCI wakeup calls from .suspend/.resume
  i2c: mediatek: Fix i2c_spec_values description
  i2c: mediatek: Add i2c compatible for MediaTek MT8192
  dt-bindings: i2c: update bindings for MT8192 SoC
  i2c: mediatek: Add access to more than 8GB dram in i2c driver
  i2c: mediatek: Add apdma sync in i2c driver
  i2c: i801: Add support for Intel Tiger Lake PCH-H
  i2c: i801: Add support for Intel Emmitsburg PCH
  i2c: bcm2835: Replace HTTP links with HTTPS ones
  Documentation: i2c: dev: 'block process call' is supported
  i2c: at91: Move to generic GPIO bus recovery
  i2c: core: treat EPROBE_DEFER when acquiring SCL/SDA GPIOs
  i2c: core: add generic I2C GPIO recovery
  dt-bindings: i2c: add generic properties for GPIO bus recovery
  i2c: rcar: avoid race when unregistering slave
  i2c: tegra: Avoid tegra_i2c_init_dma() for Tegra210 vi i2c
  i2c: tegra: Fix runtime resume to re-init VI I2C
  i2c: tegra: Fix the error path in tegra_i2c_runtime_resume
  ...

1  2 
drivers/i2c/busses/Kconfig
drivers/i2c/busses/i2c-rk3x.c
include/linux/i2c.h

index 88639e52c73a450701888555767a0b05c1357403,085ca9b009ed351d46b07d1b367a2f50e005f142..293e7a0760e7732be765f7b90c464ed27e994d36
@@@ -146,6 -146,7 +146,7 @@@ config I2C_I80
            Elkhart Lake (PCH)
            Tiger Lake (PCH)
            Jasper Lake (SOC)
+           Emmitsburg (PCH)
  
          This driver can also be built as a module.  If so, the module
          will be called i2c-i801.
@@@ -866,6 -867,17 +867,6 @@@ config I2C_PN
          This driver can also be built as a module.  If so, the module
          will be called i2c-pnx.
  
 -config I2C_PUV3
 -      tristate "PKUnity v3 I2C bus support"
 -      depends on UNICORE32 && ARCH_PUV3
 -      select I2C_ALGOBIT
 -      help
 -        This driver supports the I2C IP inside the PKUnity-v3 SoC.
 -        This I2C bus controller is under AMBA/AXI bus.
 -
 -        This driver can also be built as a module.  If so, the module
 -        will be called i2c-puv3.
 -
  config I2C_PXA
        tristate "Intel PXA2XX I2C adapter"
        depends on ARCH_PXA || ARCH_MMP || ARCH_MVEBU || (X86_32 && PCI && OF) || COMPILE_TEST
index 15324bfbc6cbf0a3b6fa965c3a00c8548a9be847,b67bb54caf272d048149b91e62a5f45e7f06380c..8e3cc85d19215d4fdd6d9e02486f3b76ef4c5ce2
@@@ -10,6 -10,7 +10,7 @@@
  #include <linux/module.h>
  #include <linux/i2c.h>
  #include <linux/interrupt.h>
+ #include <linux/iopoll.h>
  #include <linux/errno.h>
  #include <linux/err.h>
  #include <linux/platform_device.h>
@@@ -415,7 -416,7 +416,7 @@@ static void rk3x_i2c_handle_read(struc
  {
        unsigned int i;
        unsigned int len = i2c->msg->len - i2c->processed;
 -      u32 uninitialized_var(val);
 +      u32 val;
        u8 byte;
  
        /* we only care for MBRF here. */
@@@ -1040,8 -1041,21 +1041,21 @@@ static int rk3x_i2c_setup(struct rk3x_i
        return ret;
  }
  
- static int rk3x_i2c_xfer(struct i2c_adapter *adap,
-                        struct i2c_msg *msgs, int num)
+ static int rk3x_i2c_wait_xfer_poll(struct rk3x_i2c *i2c)
+ {
+       ktime_t timeout = ktime_add_ms(ktime_get(), WAIT_TIMEOUT);
+       while (READ_ONCE(i2c->busy) &&
+              ktime_compare(ktime_get(), timeout) < 0) {
+               udelay(5);
+               rk3x_i2c_irq(0, i2c);
+       }
+       return !i2c->busy;
+ }
+ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap,
+                               struct i2c_msg *msgs, int num, bool polling)
  {
        struct rk3x_i2c *i2c = (struct rk3x_i2c *)adap->algo_data;
        unsigned long timeout, flags;
  
                rk3x_i2c_start(i2c);
  
-               timeout = wait_event_timeout(i2c->wait, !i2c->busy,
-                                            msecs_to_jiffies(WAIT_TIMEOUT));
+               if (!polling) {
+                       timeout = wait_event_timeout(i2c->wait, !i2c->busy,
+                                                    msecs_to_jiffies(WAIT_TIMEOUT));
+               } else {
+                       timeout = rk3x_i2c_wait_xfer_poll(i2c);
+               }
  
                spin_lock_irqsave(&i2c->lock, flags);
  
        return ret < 0 ? ret : num;
  }
  
+ static int rk3x_i2c_xfer(struct i2c_adapter *adap,
+                        struct i2c_msg *msgs, int num)
+ {
+       return rk3x_i2c_xfer_common(adap, msgs, num, false);
+ }
+ static int rk3x_i2c_xfer_polling(struct i2c_adapter *adap,
+                                struct i2c_msg *msgs, int num)
+ {
+       return rk3x_i2c_xfer_common(adap, msgs, num, true);
+ }
  static __maybe_unused int rk3x_i2c_resume(struct device *dev)
  {
        struct rk3x_i2c *i2c = dev_get_drvdata(dev);
@@@ -1126,6 -1156,7 +1156,7 @@@ static u32 rk3x_i2c_func(struct i2c_ada
  
  static const struct i2c_algorithm rk3x_i2c_algorithm = {
        .master_xfer            = rk3x_i2c_xfer,
+       .master_xfer_atomic     = rk3x_i2c_xfer_polling,
        .functionality          = rk3x_i2c_func,
  };
  
diff --combined include/linux/i2c.h
index 4e7714c88f95de5a443482061af71a84fe43371f,d387d3786429ad0b134818560b4e94dd4c5a2a05..fc55ea41d3237faacaeb9facb11bd88c961830e0
@@@ -231,7 -231,6 +231,6 @@@ enum i2c_alert_protocol 
   * @detect: Callback for device detection
   * @address_list: The I2C addresses to probe (for detect)
   * @clients: List of detected clients we created (for i2c-core use only)
-  * @disable_i2c_core_irq_mapping: Tell the i2c-core to not do irq-mapping
   *
   * The driver.owner field should be set to the module owner of this driver.
   * The driver.name field should be set to the name of this driver.
@@@ -290,8 -289,6 +289,6 @@@ struct i2c_driver 
        int (*detect)(struct i2c_client *client, struct i2c_board_info *info);
        const unsigned short *address_list;
        struct list_head clients;
-       bool disable_i2c_core_irq_mapping;
  };
  #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
  
@@@ -609,6 -606,14 +606,14 @@@ struct i2c_timings 
   *    may configure padmux here for SDA/SCL line or something else they want.
   * @scl_gpiod: gpiod of the SCL line. Only required for GPIO recovery.
   * @sda_gpiod: gpiod of the SDA line. Only required for GPIO recovery.
+  * @pinctrl: pinctrl used by GPIO recovery to change the state of the I2C pins.
+  *      Optional.
+  * @pins_default: default pinctrl state of SCL/SDA lines, when they are assigned
+  *      to the I2C bus. Optional. Populated internally for GPIO recovery, if
+  *      state with the name PINCTRL_STATE_DEFAULT is found and pinctrl is valid.
+  * @pins_gpio: recovery pinctrl state of SCL/SDA lines, when they are used as
+  *      GPIOs. Optional. Populated internally for GPIO recovery, if this state
+  *      is called "gpio" or "recovery" and pinctrl is valid.
   */
  struct i2c_bus_recovery_info {
        int (*recover_bus)(struct i2c_adapter *adap);
        /* gpio recovery */
        struct gpio_desc *scl_gpiod;
        struct gpio_desc *sda_gpiod;
+       struct pinctrl *pinctrl;
+       struct pinctrl_state *pins_default;
+       struct pinctrl_state *pins_gpio;
  };
  
  int i2c_recover_bus(struct i2c_adapter *adap);
@@@ -1001,7 -1009,7 +1009,7 @@@ static inline u32 i2c_acpi_find_bus_spe
  static inline struct i2c_client *i2c_acpi_new_device(struct device *dev,
                                        int index, struct i2c_board_info *info)
  {
 -      return NULL;
 +      return ERR_PTR(-ENODEV);
  }
  static inline struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
  {
This page took 0.107001 seconds and 4 git commands to generate.