spi: s3c64xx: straightforward cleanup
authorMark Brown <broonie@kernel.org>
Thu, 8 Feb 2024 20:26:15 +0000 (20:26 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 8 Feb 2024 20:26:15 +0000 (20:26 +0000)
Merge series from Tudor Ambarus <tudor.ambarus@linaro.org>:

Various simple cleanups for the s3c64xx driver.  Tested with gs101-spi.

1  2 
drivers/spi/spi-s3c64xx.c

index 7ab3f3c2e9aab54da6db921fdadfb87f946b2340,c15ca6a910dcfb15e295bd1f2fbe8f1fd2a06285..6f29dca68491169d155db2b04f00613ad27c4ba8
  #include <linux/platform_device.h>
  #include <linux/pm_runtime.h>
  #include <linux/spi/spi.h>
- #include <linux/of.h>
- #include <linux/platform_data/spi-s3c64xx.h>
+ #include <linux/types.h>
  
 -#define MAX_SPI_PORTS         12
 +#define MAX_SPI_PORTS         16
  #define S3C64XX_SPI_QUIRK_CS_AUTO     (1 << 1)
  #define AUTOSUSPEND_TIMEOUT   2000
  
@@@ -408,64 -406,12 +408,62 @@@ static bool s3c64xx_spi_can_dma(struct 
  {
        struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host);
  
-       if (sdd->rx_dma.ch && sdd->tx_dma.ch) {
+       if (sdd->rx_dma.ch && sdd->tx_dma.ch)
                return xfer->len > FIFO_DEPTH(sdd);
-       } else {
-               return false;
-       }
  
+       return false;
  }
  
 +static void s3c64xx_iowrite8_32_rep(volatile void __iomem *addr,
 +                                  const void *buffer, unsigned int count)
 +{
 +      if (count) {
 +              const u8 *buf = buffer;
 +
 +              do {
 +                      __raw_writel(*buf++, addr);
 +              } while (--count);
 +      }
 +}
 +
 +static void s3c64xx_iowrite16_32_rep(volatile void __iomem *addr,
 +                                   const void *buffer, unsigned int count)
 +{
 +      if (count) {
 +              const u16 *buf = buffer;
 +
 +              do {
 +                      __raw_writel(*buf++, addr);
 +              } while (--count);
 +      }
 +}
 +
 +static void s3c64xx_iowrite_rep(const struct s3c64xx_spi_driver_data *sdd,
 +                              struct spi_transfer *xfer)
 +{
 +      void __iomem *addr = sdd->regs + S3C64XX_SPI_TX_DATA;
 +      const void *buf = xfer->tx_buf;
 +      unsigned int len = xfer->len;
 +
 +      switch (sdd->cur_bpw) {
 +      case 32:
 +              iowrite32_rep(addr, buf, len / 4);
 +              break;
 +      case 16:
 +              if (sdd->port_conf->use_32bit_io)
 +                      s3c64xx_iowrite16_32_rep(addr, buf, len / 2);
 +              else
 +                      iowrite16_rep(addr, buf, len / 2);
 +              break;
 +      default:
 +              if (sdd->port_conf->use_32bit_io)
 +                      s3c64xx_iowrite8_32_rep(addr, buf, len);
 +              else
 +                      iowrite8_rep(addr, buf, len);
 +              break;
 +      }
 +}
 +
  static int s3c64xx_enable_datapath(struct s3c64xx_spi_driver_data *sdd,
                                    struct spi_transfer *xfer, int dma_mode)
  {
                chcfg |= S3C64XX_SPI_CH_TXCH_ON;
                if (dma_mode) {
                        modecfg |= S3C64XX_SPI_MODE_TXDMA_ON;
-                       ret = prepare_dma(&sdd->tx_dma, &xfer->tx_sg);
+                       ret = s3c64xx_prepare_dma(&sdd->tx_dma, &xfer->tx_sg);
                } else {
 -                      switch (sdd->cur_bpw) {
 -                      case 32:
 -                              iowrite32_rep(regs + S3C64XX_SPI_TX_DATA,
 -                                      xfer->tx_buf, xfer->len / 4);
 -                              break;
 -                      case 16:
 -                              iowrite16_rep(regs + S3C64XX_SPI_TX_DATA,
 -                                      xfer->tx_buf, xfer->len / 2);
 -                              break;
 -                      default:
 -                              iowrite8_rep(regs + S3C64XX_SPI_TX_DATA,
 -                                      xfer->tx_buf, xfer->len);
 -                              break;
 -                      }
 +                      s3c64xx_iowrite_rep(sdd, xfer);
                }
        }
  
@@@ -1559,35 -1508,32 +1560,35 @@@ static const struct platform_device_id 
  };
  
  static const struct of_device_id s3c64xx_spi_dt_match[] = {
 +      { .compatible = "google,gs101-spi",
 +                      .data = &gs101_spi_port_config,
 +      },
        { .compatible = "samsung,s3c2443-spi",
-                       .data = (void *)&s3c2443_spi_port_config,
+                       .data = &s3c2443_spi_port_config,
        },
        { .compatible = "samsung,s3c6410-spi",
-                       .data = (void *)&s3c6410_spi_port_config,
+                       .data = &s3c6410_spi_port_config,
        },
        { .compatible = "samsung,s5pv210-spi",
-                       .data = (void *)&s5pv210_spi_port_config,
+                       .data = &s5pv210_spi_port_config,
        },
        { .compatible = "samsung,exynos4210-spi",
-                       .data = (void *)&exynos4_spi_port_config,
+                       .data = &exynos4_spi_port_config,
        },
        { .compatible = "samsung,exynos7-spi",
-                       .data = (void *)&exynos7_spi_port_config,
+                       .data = &exynos7_spi_port_config,
        },
        { .compatible = "samsung,exynos5433-spi",
-                       .data = (void *)&exynos5433_spi_port_config,
+                       .data = &exynos5433_spi_port_config,
        },
        { .compatible = "samsung,exynos850-spi",
-                       .data = (void *)&exynos850_spi_port_config,
+                       .data = &exynos850_spi_port_config,
        },
        { .compatible = "samsung,exynosautov9-spi",
-                       .data = (void *)&exynosautov9_spi_port_config,
+                       .data = &exynosautov9_spi_port_config,
        },
        { .compatible = "tesla,fsd-spi",
-                       .data = (void *)&fsd_spi_port_config,
+                       .data = &fsd_spi_port_config,
        },
        { },
  };