Upgrade to 4.4.50-rt62
[kvmfornfv.git] / kernel / drivers / spi / spi-sh-msiof.c
index bcc7c63..d22de4c 100644 (file)
@@ -48,8 +48,8 @@ struct sh_msiof_spi_priv {
        const struct sh_msiof_chipdata *chipdata;
        struct sh_msiof_spi_info *info;
        struct completion done;
-       int tx_fifo_size;
-       int rx_fifo_size;
+       unsigned int tx_fifo_size;
+       unsigned int rx_fifo_size;
        void *tx_dma_page;
        void *rx_dma_page;
        dma_addr_t tx_dma_addr;
@@ -95,8 +95,6 @@ struct sh_msiof_spi_priv {
 #define MDR2_WDLEN1(i) (((i) - 1) << 16) /* Word Count (1-64/256 (SH, A1))) */
 #define MDR2_GRPMASK1  0x00000001 /* Group Output Mask 1 (SH, A1) */
 
-#define MAX_WDLEN      256U
-
 /* TSCR and RSCR */
 #define SCR_BRPS_MASK      0x1f00 /* Prescaler Setting (1-32) */
 #define SCR_BRPS(i)    (((i) - 1) << 8)
@@ -265,6 +263,9 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
 
        for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) {
                brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div);
+               /* SCR_BRDV_DIV_1 is valid only if BRPS is x 1/1 or x 1/2 */
+               if (sh_msiof_spi_div_table[k].div == 1 && brps > 2)
+                       continue;
                if (brps <= 32) /* max of brdv is 32 */
                        break;
        }
@@ -850,7 +851,12 @@ static int sh_msiof_transfer_one(struct spi_master *master,
                 *  DMA supports 32-bit words only, hence pack 8-bit and 16-bit
                 *  words, with byte resp. word swapping.
                 */
-               unsigned int l = min(len, MAX_WDLEN * 4);
+               unsigned int l = 0;
+
+               if (tx_buf)
+                       l = min(len, p->tx_fifo_size * 4);
+               if (rx_buf)
+                       l = min(len, p->rx_fifo_size * 4);
 
                if (bits <= 8) {
                        if (l & 3)
@@ -963,7 +969,7 @@ static const struct sh_msiof_chipdata sh_data = {
 
 static const struct sh_msiof_chipdata r8a779x_data = {
        .tx_fifo_size = 64,
-       .rx_fifo_size = 256,
+       .rx_fifo_size = 64,
        .master_flags = SPI_MASTER_MUST_TX,
 };
 
@@ -1263,13 +1269,8 @@ static int sh_msiof_spi_remove(struct platform_device *pdev)
        return 0;
 }
 
-static struct platform_device_id spi_driver_ids[] = {
+static const struct platform_device_id spi_driver_ids[] = {
        { "spi_sh_msiof",       (kernel_ulong_t)&sh_data },
-       { "spi_r8a7790_msiof",  (kernel_ulong_t)&r8a779x_data },
-       { "spi_r8a7791_msiof",  (kernel_ulong_t)&r8a779x_data },
-       { "spi_r8a7792_msiof",  (kernel_ulong_t)&r8a779x_data },
-       { "spi_r8a7793_msiof",  (kernel_ulong_t)&r8a779x_data },
-       { "spi_r8a7794_msiof",  (kernel_ulong_t)&r8a779x_data },
        {},
 };
 MODULE_DEVICE_TABLE(platform, spi_driver_ids);