ODROID-COMMON: drivers/spi: Set the 64 bits per word by default
authorDeokgyu Yang <secugyu@gmail.com>
Fri, 30 Oct 2020 06:46:07 +0000 (15:46 +0900)
committerDeokgyu Yang <secugyu@gmail.com>
Fri, 30 Oct 2020 07:09:06 +0000 (16:09 +0900)
The existing force64b routine might not work properly under specific
conditions. This patch fixes that bug of 64 bits per word and forces
use that option. It will improve SPI performance significantly.

Signed-off-by: Deokgyu Yang <secugyu@gmail.com>
Change-Id: I85a58d425303ea1765b7b83ee5dd5f0a7f4203fc

drivers/spi/spi-meson-spicc.c

index fd5e9f42c834305ac684eee885dc425be00d7527..ee3f26ff4633578482a960494180751505c9b7d6 100644 (file)
  *   to have a CS go down over the full transfer
  */
 
-#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
-static unsigned int force64b;
-module_param(force64b, uint, 0000);
-MODULE_PARM_DESC(force64b, "force 64bits fb data");
-#endif
-
 /* Register Map */
 #define SPICC_RXDATA   0x00
 
@@ -485,22 +479,10 @@ static inline void meson_spicc_tx(struct meson_spicc_device *spicc)
 
 static void meson_spicc_setup_pio_burst(struct meson_spicc_device *spicc)
 {
-       unsigned int burst_len;
-
-#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
-       if (force64b)
-               burst_len = min_t(unsigned int,
-                         spicc->xfer_remain / spicc->bytes_per_word,
-                         spicc->data->fifo_size << 1);
-       else
-               burst_len = min_t(unsigned int,
-                         spicc->xfer_remain / spicc->bytes_per_word,
-                         spicc->data->fifo_size);
-#else
-       burst_len = min_t(unsigned int,
+       unsigned int burst_len = min_t(unsigned int,
                  spicc->xfer_remain / spicc->bytes_per_word,
                  spicc->data->fifo_size);
-#endif
+
        /* Setup Xfer variables */
        spicc->tx_remain = burst_len;
        spicc->rx_remain = burst_len;
@@ -606,9 +588,15 @@ static int meson_spicc_transfer_one(struct spi_master *master,
        spicc->xfer_remain = xfer->len;
 
 #if defined(CONFIG_ARCH_MESON64_ODROID_COMMON)
-       if (force64b && (xfer->len >= 64)) {
-               if ((xfer->bits_per_word == 8) && ((xfer->len % 8) == 0))
-                       xfer->bits_per_word = 64;
+       if ((xfer->len >= 64) && (xfer->bits_per_word == 8) && ((xfer->len % 8) == 0)) {
+               int cnt = xfer->len / 8;
+               int i;
+
+               u64 *tx_buf = (u64 *) &spicc->tx_buf[0];
+               for (i = 0; i < cnt; i++)
+                       tx_buf[i] = __swab64p((__u64 *) &spicc->tx_buf[i * 8]);
+
+               xfer->bits_per_word = 64;
        }
 #endif
        /* Pre-calculate word size */
@@ -1118,8 +1106,6 @@ static int meson_spicc_probe(struct platform_device *pdev)
                spicc->pinctrl = NULL;
                dev_err(&pdev->dev, "spi pinmux : can't get spicc_pins\n");
        }
-       if (force64b)
-               dev_info(&pdev->dev, "*** force64b flags is true ***\n");
 #endif
 
        device_reset_optional(&pdev->dev);