Merge remote branch 'origin' into secretlab/next-spi
authorGrant Likely <grant.likely@secretlab.ca>
Tue, 25 May 2010 06:38:26 +0000 (00:38 -0600)
committerGrant Likely <grant.likely@secretlab.ca>
Tue, 25 May 2010 06:38:26 +0000 (00:38 -0600)
1  2 
drivers/serial/mpc52xx_uart.c
drivers/spi/Kconfig
drivers/spi/spi_mpc8xxx.c

@@@ -397,10 -397,34 +397,10 @@@ static unsigned long mpc512x_getuartclk
        return mpc5xxx_get_bus_frequency(p);
  }
  
 -#define DEFAULT_FIFO_SIZE 16
 -
 -static unsigned int __init get_fifo_size(struct device_node *np,
 -                                       char *fifo_name)
 -{
 -      const unsigned int *fp;
 -
 -      fp = of_get_property(np, fifo_name, NULL);
 -      if (fp)
 -              return *fp;
 -
 -      pr_warning("no %s property in %s node, defaulting to %d\n",
 -                 fifo_name, np->full_name, DEFAULT_FIFO_SIZE);
 -
 -      return DEFAULT_FIFO_SIZE;
 -}
 -
 -#define FIFOC(_base) ((struct mpc512x_psc_fifo __iomem *) \
 -                  ((u32)(_base) + sizeof(struct mpc52xx_psc)))
 -
  /* Init PSC FIFO Controller */
  static int __init mpc512x_psc_fifoc_init(void)
  {
        struct device_node *np;
 -      void __iomem *psc;
 -      unsigned int tx_fifo_size;
 -      unsigned int rx_fifo_size;
 -      int fifobase = 0; /* current fifo address in 32 bit words */
  
        np = of_find_compatible_node(NULL, NULL,
                                     "fsl,mpc5121-psc-fifo");
                return -ENODEV;
        }
  
 -      for_each_compatible_node(np, NULL, "fsl,mpc5121-psc-uart") {
 -              tx_fifo_size = get_fifo_size(np, "fsl,tx-fifo-size");
 -              rx_fifo_size = get_fifo_size(np, "fsl,rx-fifo-size");
 -
 -              /* size in register is in 4 byte units */
 -              tx_fifo_size /= 4;
 -              rx_fifo_size /= 4;
 -              if (!tx_fifo_size)
 -                      tx_fifo_size = 1;
 -              if (!rx_fifo_size)
 -                      rx_fifo_size = 1;
 -
 -              psc = of_iomap(np, 0);
 -              if (!psc) {
 -                      pr_err("%s: Can't map %s device\n",
 -                              __func__, np->full_name);
 -                      continue;
 -              }
 -
 -              /* FIFO space is 4KiB, check if requested size is available */
 -              if ((fifobase + tx_fifo_size + rx_fifo_size) > 0x1000) {
 -                      pr_err("%s: no fifo space available for %s\n",
 -                              __func__, np->full_name);
 -                      iounmap(psc);
 -                      /*
 -                       * chances are that another device requests less
 -                       * fifo space, so we continue.
 -                       */
 -                      continue;
 -              }
 -              /* set tx and rx fifo size registers */
 -              out_be32(&FIFOC(psc)->txsz, (fifobase << 16) | tx_fifo_size);
 -              fifobase += tx_fifo_size;
 -              out_be32(&FIFOC(psc)->rxsz, (fifobase << 16) | rx_fifo_size);
 -              fifobase += rx_fifo_size;
 -
 -              /* reset and enable the slices */
 -              out_be32(&FIFOC(psc)->txcmd, 0x80);
 -              out_be32(&FIFOC(psc)->txcmd, 0x01);
 -              out_be32(&FIFOC(psc)->rxcmd, 0x80);
 -              out_be32(&FIFOC(psc)->rxcmd, 0x01);
 -
 -              iounmap(psc);
 -      }
 -
        return 0;
  }
  
@@@ -1226,14 -1295,14 +1226,14 @@@ mpc52xx_uart_of_probe(struct of_device 
  
        /* Check validity & presence */
        for (idx = 0; idx < MPC52xx_PSC_MAXNUM; idx++)
-               if (mpc52xx_uart_nodes[idx] == op->node)
+               if (mpc52xx_uart_nodes[idx] == op->dev.of_node)
                        break;
        if (idx >= MPC52xx_PSC_MAXNUM)
                return -EINVAL;
        pr_debug("Found %s assigned to ttyPSC%x\n",
                 mpc52xx_uart_nodes[idx]->full_name, idx);
  
-       uartclk = psc_ops->getuartclk(op->node);
+       uartclk = psc_ops->getuartclk(op->dev.of_node);
        if (uartclk == 0) {
                dev_dbg(&op->dev, "Could not find uart clock frequency!\n");
                return -EINVAL;
        port->dev       = &op->dev;
  
        /* Search for IRQ and mapbase */
-       ret = of_address_to_resource(op->node, 0, &res);
+       ret = of_address_to_resource(op->dev.of_node, 0, &res);
        if (ret)
                return ret;
  
                return -EINVAL;
        }
  
-       psc_ops->get_irq(port, op->node);
+       psc_ops->get_irq(port, op->dev.of_node);
        if (port->irq == NO_IRQ) {
                dev_dbg(&op->dev, "Could not get irq\n");
                return -EINVAL;
@@@ -1362,15 -1431,16 +1362,16 @@@ mpc52xx_uart_of_enumerate(void
  MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match);
  
  static struct of_platform_driver mpc52xx_uart_of_driver = {
-       .match_table    = mpc52xx_uart_of_match,
        .probe          = mpc52xx_uart_of_probe,
        .remove         = mpc52xx_uart_of_remove,
  #ifdef CONFIG_PM
        .suspend        = mpc52xx_uart_of_suspend,
        .resume         = mpc52xx_uart_of_resume,
  #endif
-       .driver         = {
-               .name   = "mpc52xx-psc-uart",
+       .driver = {
+               .name = "mpc52xx-psc-uart",
+               .owner = THIS_MODULE,
+               .of_match_table = mpc52xx_uart_of_match,
        },
  };
  
diff --combined drivers/spi/Kconfig
@@@ -117,16 -117,6 +117,16 @@@ config SPI_DAVINC
        help
          SPI master controller for DaVinci and DA8xx SPI modules.
  
 +config SPI_EP93XX
 +      tristate "Cirrus Logic EP93xx SPI controller"
 +      depends on ARCH_EP93XX
 +      help
 +        This enables using the Cirrus EP93xx SPI controller in master
 +        mode.
 +
 +        To compile this driver as a module, choose M here. The module will be
 +        called ep93xx_spi.
 +
  config SPI_GPIO
        tristate "GPIO-based bitbanging SPI Master"
        depends on GENERIC_GPIO
@@@ -175,13 -165,6 +175,13 @@@ config SPI_MPC52xx_PS
          This enables using the Freescale MPC52xx Programmable Serial
          Controller in master SPI mode.
  
 +config SPI_MPC512x_PSC
 +      tristate "Freescale MPC512x PSC SPI controller"
 +      depends on SPI_MASTER && PPC_MPC512x
 +      help
 +        This enables using the Freescale MPC5121 Programmable Serial
 +        Controller in SPI master mode.
 +
  config SPI_MPC8xxx
        tristate "Freescale MPC8xxx SPI controller"
        depends on FSL_SOC
@@@ -197,10 -180,10 +197,10 @@@ config SPI_OMAP_UWIR
          This hooks up to the MicroWire controller on OMAP1 chips.
  
  config SPI_OMAP24XX
-       tristate "McSPI driver for OMAP24xx/OMAP34xx"
-       depends on ARCH_OMAP2 || ARCH_OMAP3
+       tristate "McSPI driver for OMAP"
+       depends on ARCH_OMAP2PLUS
        help
-         SPI master controller for OMAP24xx/OMAP34xx Multichannel SPI
+         SPI master controller for OMAP24XX and later Multichannel SPI
          (McSPI) modules.
  
  config SPI_OMAP_100K
@@@ -241,6 -241,7 +241,6 @@@ static void mpc8xxx_spi_change_mode(str
  
        /* Turn off SPI unit prior changing mode */
        mpc8xxx_spi_write_reg(mode, cs->hw_mode & ~SPMODE_ENABLE);
 -      mpc8xxx_spi_write_reg(mode, cs->hw_mode);
  
        /* When in CPM mode, we need to reinit tx and rx. */
        if (mspi->flags & SPI_CPM_MODE) {
                        }
                }
        }
 -
 +      mpc8xxx_spi_write_reg(mode, cs->hw_mode);
        local_irq_restore(flags);
  }
  
@@@ -286,12 -287,36 +286,12 @@@ static void mpc8xxx_spi_chipselect(stru
        }
  }
  
 -static
 -int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 +static int
 +mspi_apply_cpu_mode_quirks(struct spi_mpc8xxx_cs *cs,
 +                         struct spi_device *spi,
 +                         struct mpc8xxx_spi *mpc8xxx_spi,
 +                         int bits_per_word)
  {
 -      struct mpc8xxx_spi *mpc8xxx_spi;
 -      u8 bits_per_word, pm;
 -      u32 hz;
 -      struct spi_mpc8xxx_cs   *cs = spi->controller_state;
 -
 -      mpc8xxx_spi = spi_master_get_devdata(spi->master);
 -
 -      if (t) {
 -              bits_per_word = t->bits_per_word;
 -              hz = t->speed_hz;
 -      } else {
 -              bits_per_word = 0;
 -              hz = 0;
 -      }
 -
 -      /* spi_transfer level calls that work per-word */
 -      if (!bits_per_word)
 -              bits_per_word = spi->bits_per_word;
 -
 -      /* Make sure its a bit width we support [4..16, 32] */
 -      if ((bits_per_word < 4)
 -          || ((bits_per_word > 16) && (bits_per_word != 32)))
 -              return -EINVAL;
 -
 -      if (!hz)
 -              hz = spi->max_speed_hz;
 -
        cs->rx_shift = 0;
        cs->tx_shift = 0;
        if (bits_per_word <= 8) {
                return -EINVAL;
  
        if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE &&
 -                      spi->mode & SPI_LSB_FIRST) {
 +          spi->mode & SPI_LSB_FIRST) {
                cs->tx_shift = 0;
                if (bits_per_word <= 8)
                        cs->rx_shift = 8;
                else
                        cs->rx_shift = 0;
        }
 -
        mpc8xxx_spi->rx_shift = cs->rx_shift;
        mpc8xxx_spi->tx_shift = cs->tx_shift;
        mpc8xxx_spi->get_rx = cs->get_rx;
        mpc8xxx_spi->get_tx = cs->get_tx;
  
 +      return bits_per_word;
 +}
 +
 +static int
 +mspi_apply_qe_mode_quirks(struct spi_mpc8xxx_cs *cs,
 +                        struct spi_device *spi,
 +                        int bits_per_word)
 +{
 +      /* QE uses Little Endian for words > 8
 +       * so transform all words > 8 into 8 bits
 +       * Unfortnatly that doesn't work for LSB so
 +       * reject these for now */
 +      /* Note: 32 bits word, LSB works iff
 +       * tfcr/rfcr is set to CPMFCR_GBL */
 +      if (spi->mode & SPI_LSB_FIRST &&
 +          bits_per_word > 8)
 +              return -EINVAL;
 +      if (bits_per_word > 8)
 +              return 8; /* pretend its 8 bits */
 +      return bits_per_word;
 +}
 +
 +static
 +int mpc8xxx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 +{
 +      struct mpc8xxx_spi *mpc8xxx_spi;
 +      int bits_per_word;
 +      u8 pm;
 +      u32 hz;
 +      struct spi_mpc8xxx_cs   *cs = spi->controller_state;
 +
 +      mpc8xxx_spi = spi_master_get_devdata(spi->master);
 +
 +      if (t) {
 +              bits_per_word = t->bits_per_word;
 +              hz = t->speed_hz;
 +      } else {
 +              bits_per_word = 0;
 +              hz = 0;
 +      }
 +
 +      /* spi_transfer level calls that work per-word */
 +      if (!bits_per_word)
 +              bits_per_word = spi->bits_per_word;
 +
 +      /* Make sure its a bit width we support [4..16, 32] */
 +      if ((bits_per_word < 4)
 +          || ((bits_per_word > 16) && (bits_per_word != 32)))
 +              return -EINVAL;
 +
 +      if (!hz)
 +              hz = spi->max_speed_hz;
 +
 +      if (!(mpc8xxx_spi->flags & SPI_CPM_MODE))
 +              bits_per_word = mspi_apply_cpu_mode_quirks(cs, spi,
 +                                                         mpc8xxx_spi,
 +                                                         bits_per_word);
 +      else if (mpc8xxx_spi->flags & SPI_QE)
 +              bits_per_word = mspi_apply_qe_mode_quirks(cs, spi,
 +                                                        bits_per_word);
 +
 +      if (bits_per_word < 0)
 +              return bits_per_word;
 +
        if (bits_per_word == 32)
                bits_per_word = 0;
        else
@@@ -476,7 -438,7 +476,7 @@@ static int mpc8xxx_spi_cpm_bufs(struct 
                        dev_err(dev, "unable to map tx dma\n");
                        return -ENOMEM;
                }
 -      } else {
 +      } else if (t->tx_buf) {
                mspi->tx_dma = t->tx_dma;
        }
  
                        dev_err(dev, "unable to map rx dma\n");
                        goto err_rx_dma;
                }
 -      } else {
 +      } else if (t->rx_buf) {
                mspi->rx_dma = t->rx_dma;
        }
  
@@@ -515,7 -477,7 +515,7 @@@ static void mpc8xxx_spi_cpm_bufs_comple
  
        if (mspi->map_tx_dma)
                dma_unmap_single(dev, mspi->tx_dma, t->len, DMA_TO_DEVICE);
 -      if (mspi->map_tx_dma)
 +      if (mspi->map_rx_dma)
                dma_unmap_single(dev, mspi->rx_dma, t->len, DMA_FROM_DEVICE);
        mspi->xfer_in_progress = NULL;
  }
@@@ -678,7 -640,7 +678,7 @@@ static int mpc8xxx_spi_setup(struct spi
        }
        mpc8xxx_spi = spi_master_get_devdata(spi->master);
  
-       hw_mode = cs->hw_mode; /* Save orginal settings */
+       hw_mode = cs->hw_mode; /* Save original settings */
        cs->hw_mode = mpc8xxx_spi_read_reg(&mpc8xxx_spi->base->mode);
        /* mask out bits we are going to set */
        cs->hw_mode &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH
@@@ -835,7 -797,7 +835,7 @@@ static void mpc8xxx_spi_free_dummy_rx(v
  static unsigned long mpc8xxx_spi_cpm_get_pram(struct mpc8xxx_spi *mspi)
  {
        struct device *dev = mspi->dev;
-       struct device_node *np = dev_archdata_get_node(&dev->archdata);
+       struct device_node *np = dev->of_node;
        const u32 *iprop;
        int size;
        unsigned long spi_base_ofs;
  static int mpc8xxx_spi_cpm_init(struct mpc8xxx_spi *mspi)
  {
        struct device *dev = mspi->dev;
-       struct device_node *np = dev_archdata_get_node(&dev->archdata);
+       struct device_node *np = dev->of_node;
        const u32 *iprop;
        int size;
        unsigned long pram_ofs;
@@@ -1161,7 -1123,7 +1161,7 @@@ static void mpc8xxx_spi_cs_control(stru
  
  static int of_mpc8xxx_spi_get_chipselects(struct device *dev)
  {
-       struct device_node *np = dev_archdata_get_node(&dev->archdata);
+       struct device_node *np = dev->of_node;
        struct fsl_spi_platform_data *pdata = dev->platform_data;
        struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(pdata);
        unsigned int ngpios;
@@@ -1262,7 -1224,7 +1262,7 @@@ static int __devinit of_mpc8xxx_spi_pro
                                          const struct of_device_id *ofid)
  {
        struct device *dev = &ofdev->dev;
-       struct device_node *np = ofdev->node;
+       struct device_node *np = ofdev->dev.of_node;
        struct mpc8xxx_spi_probe_info *pinfo;
        struct fsl_spi_platform_data *pdata;
        struct spi_master *master;
@@@ -1350,8 -1312,11 +1350,11 @@@ static const struct of_device_id of_mpc
  MODULE_DEVICE_TABLE(of, of_mpc8xxx_spi_match);
  
  static struct of_platform_driver of_mpc8xxx_spi_driver = {
-       .name           = "mpc8xxx_spi",
-       .match_table    = of_mpc8xxx_spi_match,
+       .driver = {
+               .name = "mpc8xxx_spi",
+               .owner = THIS_MODULE,
+               .of_match_table = of_mpc8xxx_spi_match,
+       },
        .probe          = of_mpc8xxx_spi_probe,
        .remove         = __devexit_p(of_mpc8xxx_spi_remove),
  };