Merge remote-tracking branches 'spi/topic/falcon', 'spi/topic/fsf', 'spi/topic/fsl...
authorMark Brown <broonie@kernel.org>
Sun, 8 Feb 2015 03:16:46 +0000 (11:16 +0800)
committerMark Brown <broonie@kernel.org>
Sun, 8 Feb 2015 03:16:46 +0000 (11:16 +0800)
1  2  3  4  5  6 
drivers/spi/Kconfig
drivers/spi/spi-falcon.c
drivers/spi/spi-gpio.c
drivers/spi/spi-pxa2xx.c
drivers/spi/spi.c

diff --combined drivers/spi/Kconfig
index 49336a7c780f4ebe77184542ca0ca8afef43856f,99829985c1a194ebe6edc0e73912077bade693d3,99829985c1a194ebe6edc0e73912077bade693d3,468d13ce510b1be929bc098c9cb50f5d10db5757,6316d6de781efc8d4f64f86376df6d876676a1e2,99829985c1a194ebe6edc0e73912077bade693d3..5ade0b86a0be925c863c019c896ca8809d66e224
@@@@@@@ -185,16 -185,6 -185,6 -185,6 -185,6 -185,6 +185,16 @@@@@@@ config SPI_DAVINC
        help
          SPI master controller for DaVinci/DA8x/OMAP-L/AM1x SPI modules.
      
 +++++config SPI_DLN2
 +++++       tristate "Diolan DLN-2 USB SPI adapter"
 +++++       depends on MFD_DLN2
 +++++       help
 +++++         If you say yes to this option, support will be included for Diolan
 +++++         DLN2, a USB to SPI interface.
 +++++
 +++++         This driver can also be built as a module.  If so, the module
 +++++         will be called spi-dln2.
 +++++
      config SPI_EFM32
        tristate "EFM32 SPI controller"
        depends on OF && ARM && (ARCH_EFM32 || COMPILE_TEST)
@@@@@@@ -289,7 -279,7 -279,7 -279,7 -279,7 -279,7 +289,7 @@@@@@@ config SPI_FSL_CP
        depends on FSL_SOC
      
      config SPI_FSL_SPI
--- --  bool "Freescale SPI controller and Aeroflex Gaisler GRLIB SPI controller"
+++ ++  tristate "Freescale SPI controller and Aeroflex Gaisler GRLIB SPI controller"
        depends on OF
        select SPI_FSL_LIB
        select SPI_FSL_CPM if FSL_SOC
      
      config SPI_FSL_DSPI
        tristate "Freescale DSPI controller"
---- -  select SPI_BITBANG
        select REGMAP_MMIO
        depends on SOC_VF610 || COMPILE_TEST
        help
          mode. VF610 platform uses the controller.
      
      config SPI_FSL_ESPI
--- --  bool "Freescale eSPI controller"
+++ ++  tristate "Freescale eSPI controller"
        depends on FSL_SOC
        select SPI_FSL_LIB
        help
@@@@@@@ -605,6 -595,7 -595,7 -595,7 -594,7 -595,7 +604,6 @@@@@@@ config SPI_XTENSA_XTFPG
          16 bit words in SPI mode 0, automatically asserting CS on transfer
          start and deasserting on end.
      
 -----
      config SPI_NUC900
        tristate "Nuvoton NUC900 series SPI"
        depends on ARCH_W90X900
diff --combined drivers/spi/spi-falcon.c
index 912b9037e9cf511985ca15ce0364f64f2c57fbff,973ded3a398ff746d026969b85c1e5a10730b2c1,912b9037e9cf511985ca15ce0364f64f2c57fbff,912b9037e9cf511985ca15ce0364f64f2c57fbff,912b9037e9cf511985ca15ce0364f64f2c57fbff,912b9037e9cf511985ca15ce0364f64f2c57fbff..286b2c81fc6bb0d7500568df47753b47094da8a2
@@@@@@@ -353,16 -353,6 -353,16 -353,16 -353,16 -353,16 +353,6 @@@@@@@ static int falcon_sflash_setup(struct s
        return 0;
      }
      
- ----static int falcon_sflash_prepare_xfer(struct spi_master *master)
- ----{
- ----  return 0;
- ----}
- ----
- ----static int falcon_sflash_unprepare_xfer(struct spi_master *master)
- ----{
- ----  return 0;
- ----}
- ----
      static int falcon_sflash_xfer_one(struct spi_master *master,
                                        struct spi_message *m)
      {
@@@@@@@ -420,9 -410,7 -420,9 -420,9 -420,9 -420,9 +410,7 @@@@@@@ static int falcon_sflash_probe(struct p
        master->mode_bits = SPI_MODE_3;
        master->flags = SPI_MASTER_HALF_DUPLEX;
        master->setup = falcon_sflash_setup;
- ----  master->prepare_transfer_hardware = falcon_sflash_prepare_xfer;
        master->transfer_one_message = falcon_sflash_xfer_one;
- ----  master->unprepare_transfer_hardware = falcon_sflash_unprepare_xfer;
        master->dev.of_node = pdev->dev.of_node;
      
        ret = devm_spi_register_master(&pdev->dev, master);
@@@@@@@ -441,6 -429,7 -441,6 -441,6 -441,6 -441,6 +429,6 @@@@@@@ static struct platform_driver falcon_sf
        .probe  = falcon_sflash_probe,
        .driver = {
                .name   = DRV_NAME,
 -              .owner  = THIS_MODULE,
                .of_match_table = falcon_sflash_match,
        }
      };
diff --combined drivers/spi/spi-gpio.c
index aee4e7589568c7cb2e3f69c02e9f44db4ba3ffb5,4b600d4f8548d0c70cf059cae5c7d2bd5377a3cb,2b76492fe5c140cdde8821c7c41958c99413c797,aee4e7589568c7cb2e3f69c02e9f44db4ba3ffb5,aee4e7589568c7cb2e3f69c02e9f44db4ba3ffb5,702b0b8d2f937aa1662f4f0629df24b6defddfb2..1c34c9314c8a1fab3c5bae9948775467f66017a9
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       * GNU General Public License for more details.
-- --- *
-- --- * You should have received a copy of the GNU General Public License
-- --- * along with this program; if not, write to the Free Software
-- --- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
       */
      #include <linux/kernel.h>
      #include <linux/module.h>
@@@@@@@ -92,7 -92,7 -88,7 -92,7 -92,7 -92,7 +88,7 @@@@@@@ struct spi_gpio 
      
      /*----------------------------------------------------------------------*/
      
----- static inline struct spi_gpio * __pure
+++++ static inline struct spi_gpio *__pure
      spi_to_spi_gpio(const struct spi_device *spi)
      {
        const struct spi_bitbang        *bang;
        return spi_gpio;
      }
      
----- static inline struct spi_gpio_platform_data * __pure
+++++ static inline struct spi_gpio_platform_data *__pure
      spi_to_pdata(const struct spi_device *spi)
      {
        return &spi_to_spi_gpio(spi)->pdata;
@@@@@@@ -539,6 -539,7 -535,6 -539,6 -539,6 -539,6 +535,6 @@@@@@@ MODULE_ALIAS("platform:" DRIVER_NAME)
      static struct platform_driver spi_gpio_driver = {
        .driver = {
                .name   = DRIVER_NAME,
 -              .owner  = THIS_MODULE,
                .of_match_table = of_match_ptr(spi_gpio_dt_ids),
        },
        .probe          = spi_gpio_probe,
diff --combined drivers/spi/spi-pxa2xx.c
index 23822e7df6c1c6e1e2caa18ea19cfcb069c3796d,1a1df5092aca247dbb6c4f959eb581ba05e0593c,7a9a605d9bd2e5de1210d4f9eaee4432861134a8,05c623cfb078d6503bd6d501cc1e821f07784d9e,05c623cfb078d6503bd6d501cc1e821f07784d9e,05c623cfb078d6503bd6d501cc1e821f07784d9e..24a4951be46bf5d5e35dcd54f1b25728c612716d
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       * GNU General Public License for more details.
-- --- *
-- --- * You should have received a copy of the GNU General Public License
-- --- * along with this program; if not, write to the Free Software
-- --- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
       */
      
      #include <linux/init.h>
@@@@@@@ -546,8 -546,8 -542,8 -546,8 -546,8 -546,8 +542,8 @@@@@@@ static void giveback(struct driver_dat
                        cs_deassert(drv_data);
        }
      
 -----  spi_finalize_current_message(drv_data->master);
        drv_data->cur_chip = NULL;
 +++++  spi_finalize_current_message(drv_data->master);
      }
      
      static void reset_sccr1(struct driver_data *drv_data)
@@@@@@@ -1531,7 -1531,7 -1527,7 -1531,7 -1531,7 -1531,7 +1527,7 @@@@@@@ static int pxa2xx_spi_resume(struct dev
      }
      #endif
      
 -    #ifdef CONFIG_PM_RUNTIME
 +    #ifdef CONFIG_PM
      static int pxa2xx_spi_runtime_suspend(struct device *dev)
      {
        struct driver_data *drv_data = dev_get_drvdata(dev);
@@@@@@@ -1558,6 -1558,7 -1554,6 -1558,6 -1558,6 -1558,6 +1554,6 @@@@@@@ static const struct dev_pm_ops pxa2xx_s
      static struct platform_driver driver = {
        .driver = {
                .name   = "pxa2xx-spi",
 -              .owner  = THIS_MODULE,
                .pm     = &pxa2xx_spi_pm_ops,
                .acpi_match_table = ACPI_PTR(pxa2xx_spi_acpi_match),
        },
diff --combined drivers/spi/spi.c
index ba17929102aea314e7f234cbfaea43984a58d8ed,da7e6225b8f60533492fbdc3f8595d70b24f6bf6,c76cc7568639277d64489c5d678ff18ec6a49a55,66a70e9bc7438d0090b90a815ccea59812603110,66a70e9bc7438d0090b90a815ccea59812603110,66a70e9bc7438d0090b90a815ccea59812603110..59d761be41e605cb65e043c60ad0df1be708b90c
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       * GNU General Public License for more details.
-- --- *
-- --- * You should have received a copy of the GNU General Public License
-- --- * along with this program; if not, write to the Free Software
-- --- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
       */
      
      #include <linux/kernel.h>
@@@@@@@ -788,7 -788,7 -784,7 -788,7 -788,7 -788,7 +784,7 @@@@@@@ static int spi_transfer_one_message(str
        struct spi_transfer *xfer;
        bool keep_cs = false;
        int ret = 0;
 -----  int ms = 1;
 +++++  unsigned long ms = 1;
      
        spi_set_cs(msg->spi, true);
      
      /*-------------------------------------------------------------------------*/
      
      #if defined(CONFIG_OF)
 +    static struct spi_device *
 +    of_register_spi_device(struct spi_master *master, struct device_node *nc)
 +    {
 +      struct spi_device *spi;
 +      int rc;
 +      u32 value;
 +    
 +      /* Alloc an spi_device */
 +      spi = spi_alloc_device(master);
 +      if (!spi) {
 +              dev_err(&master->dev, "spi_device alloc error for %s\n",
 +                      nc->full_name);
 +              rc = -ENOMEM;
 +              goto err_out;
 +      }
 +    
 +      /* Select device driver */
 +      rc = of_modalias_node(nc, spi->modalias,
 +                              sizeof(spi->modalias));
 +      if (rc < 0) {
 +              dev_err(&master->dev, "cannot find modalias for %s\n",
 +                      nc->full_name);
 +              goto err_out;
 +      }
 +    
 +      /* Device address */
 +      rc = of_property_read_u32(nc, "reg", &value);
 +      if (rc) {
 +              dev_err(&master->dev, "%s has no valid 'reg' property (%d)\n",
 +                      nc->full_name, rc);
 +              goto err_out;
 +      }
 +      spi->chip_select = value;
 +    
 +      /* Mode (clock phase/polarity/etc.) */
 +      if (of_find_property(nc, "spi-cpha", NULL))
 +              spi->mode |= SPI_CPHA;
 +      if (of_find_property(nc, "spi-cpol", NULL))
 +              spi->mode |= SPI_CPOL;
 +      if (of_find_property(nc, "spi-cs-high", NULL))
 +              spi->mode |= SPI_CS_HIGH;
 +      if (of_find_property(nc, "spi-3wire", NULL))
 +              spi->mode |= SPI_3WIRE;
 +      if (of_find_property(nc, "spi-lsb-first", NULL))
 +              spi->mode |= SPI_LSB_FIRST;
 +    
 +      /* Device DUAL/QUAD mode */
 +      if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) {
 +              switch (value) {
 +              case 1:
 +                      break;
 +              case 2:
 +                      spi->mode |= SPI_TX_DUAL;
 +                      break;
 +              case 4:
 +                      spi->mode |= SPI_TX_QUAD;
 +                      break;
 +              default:
 +                      dev_warn(&master->dev,
 +                              "spi-tx-bus-width %d not supported\n",
 +                              value);
 +                      break;
 +              }
 +      }
 +    
 +      if (!of_property_read_u32(nc, "spi-rx-bus-width", &value)) {
 +              switch (value) {
 +              case 1:
 +                      break;
 +              case 2:
 +                      spi->mode |= SPI_RX_DUAL;
 +                      break;
 +              case 4:
 +                      spi->mode |= SPI_RX_QUAD;
 +                      break;
 +              default:
 +                      dev_warn(&master->dev,
 +                              "spi-rx-bus-width %d not supported\n",
 +                              value);
 +                      break;
 +              }
 +      }
 +    
 +      /* Device speed */
 +      rc = of_property_read_u32(nc, "spi-max-frequency", &value);
 +      if (rc) {
 +              dev_err(&master->dev, "%s has no valid 'spi-max-frequency' property (%d)\n",
 +                      nc->full_name, rc);
 +              goto err_out;
 +      }
 +      spi->max_speed_hz = value;
 +    
 +      /* IRQ */
 +      spi->irq = irq_of_parse_and_map(nc, 0);
 +    
 +      /* Store a pointer to the node in the device structure */
 +      of_node_get(nc);
 +      spi->dev.of_node = nc;
 +    
 +      /* Register the new device */
 +      request_module("%s%s", SPI_MODULE_PREFIX, spi->modalias);
 +      rc = spi_add_device(spi);
 +      if (rc) {
 +              dev_err(&master->dev, "spi_device register error %s\n",
 +                      nc->full_name);
 +              goto err_out;
 +      }
 +    
 +      return spi;
 +    
 +    err_out:
 +      spi_dev_put(spi);
 +      return ERR_PTR(rc);
 +    }
 +    
      /**
       * of_register_spi_devices() - Register child devices onto the SPI bus
       * @master:       Pointer to spi_master device
@@@@@@@ -1346,15 -1231,116 -1342,15 -1346,15 -1346,15 -1346,15 +1342,15 @@@@@@@ static void of_register_spi_devices(str
      {
        struct spi_device *spi;
        struct device_node *nc;
 -      int rc;
 -      u32 value;
      
        if (!master->dev.of_node)
                return;
      
        for_each_available_child_of_node(master->dev.of_node, nc) {
 -              /* Alloc an spi_device */
 -              spi = spi_alloc_device(master);
 -              if (!spi) {
 -                      dev_err(&master->dev, "spi_device alloc error for %s\n",
 -                              nc->full_name);
 -                      spi_dev_put(spi);
 -                      continue;
 -              }
 -    
 -              /* Select device driver */
 -              if (of_modalias_node(nc, spi->modalias,
 -                                   sizeof(spi->modalias)) < 0) {
 -                      dev_err(&master->dev, "cannot find modalias for %s\n",
 -                              nc->full_name);
 -                      spi_dev_put(spi);
 -                      continue;
 -              }
 -    
 -              /* Device address */
 -              rc = of_property_read_u32(nc, "reg", &value);
 -              if (rc) {
 -                      dev_err(&master->dev, "%s has no valid 'reg' property (%d)\n",
 -                              nc->full_name, rc);
 -                      spi_dev_put(spi);
 -                      continue;
 -              }
 -              spi->chip_select = value;
 -    
 -              /* Mode (clock phase/polarity/etc.) */
 -              if (of_find_property(nc, "spi-cpha", NULL))
 -                      spi->mode |= SPI_CPHA;
 -              if (of_find_property(nc, "spi-cpol", NULL))
 -                      spi->mode |= SPI_CPOL;
 -              if (of_find_property(nc, "spi-cs-high", NULL))
 -                      spi->mode |= SPI_CS_HIGH;
 -              if (of_find_property(nc, "spi-3wire", NULL))
 -                      spi->mode |= SPI_3WIRE;
 -              if (of_find_property(nc, "spi-lsb-first", NULL))
 -                      spi->mode |= SPI_LSB_FIRST;
 -    
 -              /* Device DUAL/QUAD mode */
 -              if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) {
 -                      switch (value) {
 -                      case 1:
 -                              break;
 -                      case 2:
 -                              spi->mode |= SPI_TX_DUAL;
 -                              break;
 -                      case 4:
 -                              spi->mode |= SPI_TX_QUAD;
 -                              break;
 -                      default:
 -                              dev_warn(&master->dev,
 -                                       "spi-tx-bus-width %d not supported\n",
 -                                       value);
 -                              break;
 -                      }
 -              }
 -    
 -              if (!of_property_read_u32(nc, "spi-rx-bus-width", &value)) {
 -                      switch (value) {
 -                      case 1:
 -                              break;
 -                      case 2:
 -                              spi->mode |= SPI_RX_DUAL;
 -                              break;
 -                      case 4:
 -                              spi->mode |= SPI_RX_QUAD;
 -                              break;
 -                      default:
 -                              dev_warn(&master->dev,
 -                                       "spi-rx-bus-width %d not supported\n",
 -                                       value);
 -                              break;
 -                      }
 -              }
 -    
 -              /* Device speed */
 -              rc = of_property_read_u32(nc, "spi-max-frequency", &value);
 -              if (rc) {
 -                      dev_err(&master->dev, "%s has no valid 'spi-max-frequency' property (%d)\n",
 -                              nc->full_name, rc);
 -                      spi_dev_put(spi);
 -                      continue;
 -              }
 -              spi->max_speed_hz = value;
 -    
 -              /* IRQ */
 -              spi->irq = irq_of_parse_and_map(nc, 0);
 -    
 -              /* Store a pointer to the node in the device structure */
 -              of_node_get(nc);
 -              spi->dev.of_node = nc;
 -    
 -              /* Register the new device */
 -              request_module("%s%s", SPI_MODULE_PREFIX, spi->modalias);
 -              rc = spi_add_device(spi);
 -              if (rc) {
 -                      dev_err(&master->dev, "spi_device register error %s\n",
 +              spi = of_register_spi_device(master, nc);
 +              if (IS_ERR(spi))
 +                      dev_warn(&master->dev, "Failed to create SPI device for %s\n",
                                nc->full_name);
 -                      spi_dev_put(spi);
 -              }
 -    
        }
      }
      #else
@@@@@@@ -2317,86 -2303,6 -2313,86 -2317,86 -2317,86 -2317,86 +2313,86 @@@@@@@ EXPORT_SYMBOL_GPL(spi_write_then_read)
      
      /*-------------------------------------------------------------------------*/
      
 +    #if IS_ENABLED(CONFIG_OF_DYNAMIC)
 +    static int __spi_of_device_match(struct device *dev, void *data)
 +    {
 +      return dev->of_node == data;
 +    }
 +    
 +    /* must call put_device() when done with returned spi_device device */
 +    static struct spi_device *of_find_spi_device_by_node(struct device_node *node)
 +    {
 +      struct device *dev = bus_find_device(&spi_bus_type, NULL, node,
 +                                              __spi_of_device_match);
 +      return dev ? to_spi_device(dev) : NULL;
 +    }
 +    
 +    static int __spi_of_master_match(struct device *dev, const void *data)
 +    {
 +      return dev->of_node == data;
 +    }
 +    
 +    /* the spi masters are not using spi_bus, so we find it with another way */
 +    static struct spi_master *of_find_spi_master_by_node(struct device_node *node)
 +    {
 +      struct device *dev;
 +    
 +      dev = class_find_device(&spi_master_class, NULL, node,
 +                              __spi_of_master_match);
 +      if (!dev)
 +              return NULL;
 +    
 +      /* reference got in class_find_device */
 +      return container_of(dev, struct spi_master, dev);
 +    }
 +    
 +    static int of_spi_notify(struct notifier_block *nb, unsigned long action,
 +                       void *arg)
 +    {
 +      struct of_reconfig_data *rd = arg;
 +      struct spi_master *master;
 +      struct spi_device *spi;
 +    
 +      switch (of_reconfig_get_state_change(action, arg)) {
 +      case OF_RECONFIG_CHANGE_ADD:
 +              master = of_find_spi_master_by_node(rd->dn->parent);
 +              if (master == NULL)
 +                      return NOTIFY_OK;       /* not for us */
 +    
 +              spi = of_register_spi_device(master, rd->dn);
 +              put_device(&master->dev);
 +    
 +              if (IS_ERR(spi)) {
 +                      pr_err("%s: failed to create for '%s'\n",
 +                                      __func__, rd->dn->full_name);
 +                      return notifier_from_errno(PTR_ERR(spi));
 +              }
 +              break;
 +    
 +      case OF_RECONFIG_CHANGE_REMOVE:
 +              /* find our device by node */
 +              spi = of_find_spi_device_by_node(rd->dn);
 +              if (spi == NULL)
 +                      return NOTIFY_OK;       /* no? not meant for us */
 +    
 +              /* unregister takes one ref away */
 +              spi_unregister_device(spi);
 +    
 +              /* and put the reference of the find */
 +              put_device(&spi->dev);
 +              break;
 +      }
 +    
 +      return NOTIFY_OK;
 +    }
 +    
 +    static struct notifier_block spi_of_notifier = {
 +      .notifier_call = of_spi_notify,
 +    };
 +    #else /* IS_ENABLED(CONFIG_OF_DYNAMIC) */
 +    extern struct notifier_block spi_of_notifier;
 +    #endif /* IS_ENABLED(CONFIG_OF_DYNAMIC) */
 +    
      static int __init spi_init(void)
      {
        int     status;
        status = class_register(&spi_master_class);
        if (status < 0)
                goto err2;
 +    
 +      if (IS_ENABLED(CONFIG_OF_DYNAMIC))
 +              WARN_ON(of_reconfig_notifier_register(&spi_of_notifier));
 +    
        return 0;
      
      err2: