Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branches 'spi/topic/pxa2xx', 'spi/topic/rockchip', 'spi/topic/s3c64xx', 'spi/topic/sh' and 'spi/topic/sh-msiof' into spi-next

+347 -362
+7 -4
Documentation/devicetree/bindings/spi/spi-rockchip.txt
··· 6 6 Required Properties: 7 7 8 8 - compatible: should be one of the following. 9 - "rockchip,rk3066-spi" for rk3066. 10 - "rockchip,rk3188-spi", "rockchip,rk3066-spi" for rk3188. 11 - "rockchip,rk3288-spi", "rockchip,rk3066-spi" for rk3288. 12 - "rockchip,rk3399-spi", "rockchip,rk3066-spi" for rk3399. 9 + "rockchip,rk3036-spi" for rk3036 SoCS. 10 + "rockchip,rk3066-spi" for rk3066 SoCs. 11 + "rockchip,rk3188-spi" for rk3188 SoCs. 12 + "rockchip,rk3228-spi" for rk3228 SoCS. 13 + "rockchip,rk3288-spi" for rk3288 SoCs. 14 + "rockchip,rk3368-spi" for rk3368 SoCs. 15 + "rockchip,rk3399-spi" for rk3399 SoCs. 13 16 - reg: physical base address of the controller and length of memory mapped 14 17 region. 15 18 - interrupts: The interrupt number to the cpu. The interrupt specifier format
+14 -1
Documentation/devicetree/bindings/spi/spi-samsung.txt
··· 9 9 - samsung,s3c2443-spi: for s3c2443, s3c2416 and s3c2450 platforms 10 10 - samsung,s3c6410-spi: for s3c6410 platforms 11 11 - samsung,s5pv210-spi: for s5pv210 and s5pc110 platforms 12 - - samsung,exynos7-spi: for exynos7 platforms 12 + - samsung,exynos5433-spi: for exynos5433 compatible controllers 13 + - samsung,exynos7-spi: for exynos7 platforms <DEPRECATED> 13 14 14 15 - reg: physical base address of the controller and length of memory mapped 15 16 region. ··· 23 22 24 23 - dma-names: Names for the dma channels. There must be at least one channel 25 24 named "tx" for transmit and named "rx" for receive. 25 + 26 + - clocks: specifies the clock IDs provided to the SPI controller; they are 27 + required for interacting with the controller itself, for synchronizing the bus 28 + and as I/O clock (the latter is required by exynos5433 and exynos7). 29 + 30 + - clock-names: string names of the clocks in the 'clocks' property; for all the 31 + the devices the names must be "spi", "spi_busclkN" (where N is determined by 32 + "samsung,spi-src-clk"), while Exynos5433 should specify a third clock 33 + "spi_ioclk" for the I/O clock. 26 34 27 35 Required Board Specific Properties: 28 36 ··· 49 39 not specified, the default number of chip select lines is set to 1. 50 40 51 41 - cs-gpios: should specify GPIOs used for chipselects (see spi-bus.txt) 42 + 43 + - no-cs-readback: the CS line is disconnected, therefore the device should not 44 + operate based on CS signalling. 52 45 53 46 SPI Controller specific data in SPI slave nodes: 54 47
+29 -141
drivers/spi/spi-pxa2xx-dma.c
··· 20 20 21 21 #include "spi-pxa2xx.h" 22 22 23 - static int pxa2xx_spi_map_dma_buffer(struct driver_data *drv_data, 24 - enum dma_data_direction dir) 25 - { 26 - int i, nents, len = drv_data->len; 27 - struct scatterlist *sg; 28 - struct device *dmadev; 29 - struct sg_table *sgt; 30 - void *buf, *pbuf; 31 - 32 - if (dir == DMA_TO_DEVICE) { 33 - dmadev = drv_data->tx_chan->device->dev; 34 - sgt = &drv_data->tx_sgt; 35 - buf = drv_data->tx; 36 - } else { 37 - dmadev = drv_data->rx_chan->device->dev; 38 - sgt = &drv_data->rx_sgt; 39 - buf = drv_data->rx; 40 - } 41 - 42 - nents = DIV_ROUND_UP(len, SZ_2K); 43 - if (nents != sgt->nents) { 44 - int ret; 45 - 46 - sg_free_table(sgt); 47 - ret = sg_alloc_table(sgt, nents, GFP_ATOMIC); 48 - if (ret) 49 - return ret; 50 - } 51 - 52 - pbuf = buf; 53 - for_each_sg(sgt->sgl, sg, sgt->nents, i) { 54 - size_t bytes = min_t(size_t, len, SZ_2K); 55 - 56 - sg_set_buf(sg, pbuf, bytes); 57 - pbuf += bytes; 58 - len -= bytes; 59 - } 60 - 61 - nents = dma_map_sg(dmadev, sgt->sgl, sgt->nents, dir); 62 - if (!nents) 63 - return -ENOMEM; 64 - 65 - return nents; 66 - } 67 - 68 - static void pxa2xx_spi_unmap_dma_buffer(struct driver_data *drv_data, 69 - enum dma_data_direction dir) 70 - { 71 - struct device *dmadev; 72 - struct sg_table *sgt; 73 - 74 - if (dir == DMA_TO_DEVICE) { 75 - dmadev = drv_data->tx_chan->device->dev; 76 - sgt = &drv_data->tx_sgt; 77 - } else { 78 - dmadev = drv_data->rx_chan->device->dev; 79 - sgt = &drv_data->rx_sgt; 80 - } 81 - 82 - dma_unmap_sg(dmadev, sgt->sgl, sgt->nents, dir); 83 - } 84 - 85 - static void pxa2xx_spi_unmap_dma_buffers(struct driver_data *drv_data) 86 - { 87 - if (!drv_data->dma_mapped) 88 - return; 89 - 90 - pxa2xx_spi_unmap_dma_buffer(drv_data, DMA_FROM_DEVICE); 91 - pxa2xx_spi_unmap_dma_buffer(drv_data, DMA_TO_DEVICE); 92 - 93 - drv_data->dma_mapped = 0; 94 - } 95 - 96 23 static void pxa2xx_spi_dma_transfer_complete(struct driver_data *drv_data, 97 24 bool error) 98 25 { ··· 52 125 pxa2xx_spi_write(drv_data, SSTO, 0); 53 126 54 127 if (!error) { 55 - pxa2xx_spi_unmap_dma_buffers(drv_data); 56 - 57 128 msg->actual_length += drv_data->len; 58 129 msg->state = pxa2xx_spi_next_transfer(drv_data); 59 130 } else { ··· 77 152 enum dma_transfer_direction dir) 78 153 { 79 154 struct chip_data *chip = drv_data->cur_chip; 155 + struct spi_transfer *xfer = drv_data->cur_transfer; 80 156 enum dma_slave_buswidth width; 81 157 struct dma_slave_config cfg; 82 158 struct dma_chan *chan; 83 159 struct sg_table *sgt; 84 - int nents, ret; 160 + int ret; 85 161 86 162 switch (drv_data->n_bytes) { 87 163 case 1: ··· 104 178 cfg.dst_addr_width = width; 105 179 cfg.dst_maxburst = chip->dma_burst_size; 106 180 107 - sgt = &drv_data->tx_sgt; 108 - nents = drv_data->tx_nents; 109 - chan = drv_data->tx_chan; 181 + sgt = &xfer->tx_sg; 182 + chan = drv_data->master->dma_tx; 110 183 } else { 111 184 cfg.src_addr = drv_data->ssdr_physical; 112 185 cfg.src_addr_width = width; 113 186 cfg.src_maxburst = chip->dma_burst_size; 114 187 115 - sgt = &drv_data->rx_sgt; 116 - nents = drv_data->rx_nents; 117 - chan = drv_data->rx_chan; 188 + sgt = &xfer->rx_sg; 189 + chan = drv_data->master->dma_rx; 118 190 } 119 191 120 192 ret = dmaengine_slave_config(chan, &cfg); ··· 121 197 return NULL; 122 198 } 123 199 124 - return dmaengine_prep_slave_sg(chan, sgt->sgl, nents, dir, 200 + return dmaengine_prep_slave_sg(chan, sgt->sgl, sgt->nents, dir, 125 201 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 126 - } 127 - 128 - bool pxa2xx_spi_dma_is_possible(size_t len) 129 - { 130 - return len <= MAX_DMA_LEN; 131 - } 132 - 133 - int pxa2xx_spi_map_dma_buffers(struct driver_data *drv_data) 134 - { 135 - const struct chip_data *chip = drv_data->cur_chip; 136 - int ret; 137 - 138 - if (!chip->enable_dma) 139 - return 0; 140 - 141 - /* Don't bother with DMA if we can't do even a single burst */ 142 - if (drv_data->len < chip->dma_burst_size) 143 - return 0; 144 - 145 - ret = pxa2xx_spi_map_dma_buffer(drv_data, DMA_TO_DEVICE); 146 - if (ret <= 0) { 147 - dev_warn(&drv_data->pdev->dev, "failed to DMA map TX\n"); 148 - return 0; 149 - } 150 - 151 - drv_data->tx_nents = ret; 152 - 153 - ret = pxa2xx_spi_map_dma_buffer(drv_data, DMA_FROM_DEVICE); 154 - if (ret <= 0) { 155 - pxa2xx_spi_unmap_dma_buffer(drv_data, DMA_TO_DEVICE); 156 - dev_warn(&drv_data->pdev->dev, "failed to DMA map RX\n"); 157 - return 0; 158 - } 159 - 160 - drv_data->rx_nents = ret; 161 - return 1; 162 202 } 163 203 164 204 irqreturn_t pxa2xx_spi_dma_transfer(struct driver_data *drv_data) ··· 133 245 if (status & SSSR_ROR) { 134 246 dev_err(&drv_data->pdev->dev, "FIFO overrun\n"); 135 247 136 - dmaengine_terminate_async(drv_data->rx_chan); 137 - dmaengine_terminate_async(drv_data->tx_chan); 248 + dmaengine_terminate_async(drv_data->master->dma_rx); 249 + dmaengine_terminate_async(drv_data->master->dma_tx); 138 250 139 251 pxa2xx_spi_dma_transfer_complete(drv_data, true); 140 252 return IRQ_HANDLED; ··· 173 285 return 0; 174 286 175 287 err_rx: 176 - dmaengine_terminate_async(drv_data->tx_chan); 288 + dmaengine_terminate_async(drv_data->master->dma_tx); 177 289 err_tx: 178 - pxa2xx_spi_unmap_dma_buffers(drv_data); 179 290 return err; 180 291 } 181 292 182 293 void pxa2xx_spi_dma_start(struct driver_data *drv_data) 183 294 { 184 - dma_async_issue_pending(drv_data->rx_chan); 185 - dma_async_issue_pending(drv_data->tx_chan); 295 + dma_async_issue_pending(drv_data->master->dma_rx); 296 + dma_async_issue_pending(drv_data->master->dma_tx); 186 297 187 298 atomic_set(&drv_data->dma_running, 1); 188 299 } ··· 190 303 { 191 304 struct pxa2xx_spi_master *pdata = drv_data->master_info; 192 305 struct device *dev = &drv_data->pdev->dev; 306 + struct spi_master *master = drv_data->master; 193 307 dma_cap_mask_t mask; 194 308 195 309 dma_cap_zero(mask); 196 310 dma_cap_set(DMA_SLAVE, mask); 197 311 198 - drv_data->tx_chan = dma_request_slave_channel_compat(mask, 312 + master->dma_tx = dma_request_slave_channel_compat(mask, 199 313 pdata->dma_filter, pdata->tx_param, dev, "tx"); 200 - if (!drv_data->tx_chan) 314 + if (!master->dma_tx) 201 315 return -ENODEV; 202 316 203 - drv_data->rx_chan = dma_request_slave_channel_compat(mask, 317 + master->dma_rx = dma_request_slave_channel_compat(mask, 204 318 pdata->dma_filter, pdata->rx_param, dev, "rx"); 205 - if (!drv_data->rx_chan) { 206 - dma_release_channel(drv_data->tx_chan); 207 - drv_data->tx_chan = NULL; 319 + if (!master->dma_rx) { 320 + dma_release_channel(master->dma_tx); 321 + master->dma_tx = NULL; 208 322 return -ENODEV; 209 323 } 210 324 ··· 214 326 215 327 void pxa2xx_spi_dma_release(struct driver_data *drv_data) 216 328 { 217 - if (drv_data->rx_chan) { 218 - dmaengine_terminate_sync(drv_data->rx_chan); 219 - dma_release_channel(drv_data->rx_chan); 220 - sg_free_table(&drv_data->rx_sgt); 221 - drv_data->rx_chan = NULL; 329 + struct spi_master *master = drv_data->master; 330 + 331 + if (master->dma_rx) { 332 + dmaengine_terminate_sync(master->dma_rx); 333 + dma_release_channel(master->dma_rx); 334 + master->dma_rx = NULL; 222 335 } 223 - if (drv_data->tx_chan) { 224 - dmaengine_terminate_sync(drv_data->tx_chan); 225 - dma_release_channel(drv_data->tx_chan); 226 - sg_free_table(&drv_data->tx_sgt); 227 - drv_data->tx_chan = NULL; 336 + if (master->dma_tx) { 337 + dmaengine_terminate_sync(master->dma_tx); 338 + dma_release_channel(master->dma_tx); 339 + master->dma_tx = NULL; 228 340 } 229 341 } 230 342
+124 -88
drivers/spi/spi-pxa2xx-pci.c
··· 1 1 /* 2 2 * CE4100's SPI device is more or less the same one as found on PXA 3 3 * 4 + * Copyright (C) 2016, Intel Corporation 4 5 */ 6 + #include <linux/clk-provider.h> 7 + #include <linux/module.h> 8 + #include <linux/of_device.h> 5 9 #include <linux/pci.h> 6 10 #include <linux/platform_device.h> 7 - #include <linux/of_device.h> 8 - #include <linux/module.h> 9 11 #include <linux/spi/pxa2xx_spi.h> 10 - #include <linux/clk-provider.h> 11 12 12 13 #include <linux/dmaengine.h> 13 14 #include <linux/platform_data/dma-dw.h> 14 15 15 16 enum { 16 - PORT_CE4100, 17 + PORT_QUARK_X1000, 17 18 PORT_BYT, 19 + PORT_MRFLD, 18 20 PORT_BSW0, 19 21 PORT_BSW1, 20 22 PORT_BSW2, 21 - PORT_QUARK_X1000, 23 + PORT_CE4100, 22 24 PORT_LPT, 23 25 }; 24 26 ··· 31 29 unsigned long max_clk_rate; 32 30 33 31 /* DMA channel request parameters */ 32 + bool (*dma_filter)(struct dma_chan *chan, void *param); 34 33 void *tx_param; 35 34 void *rx_param; 35 + 36 + int (*setup)(struct pci_dev *pdev, struct pxa_spi_info *c); 36 37 }; 37 38 38 39 static struct dw_dma_slave byt_tx_param = { .dst_id = 0 }; ··· 62 57 return true; 63 58 } 64 59 65 - static struct pxa_spi_info spi_info_configs[] = { 66 - [PORT_CE4100] = { 67 - .type = PXA25x_SSP, 68 - .port_id = -1, 69 - .num_chipselect = -1, 70 - .max_clk_rate = 3686400, 71 - }, 72 - [PORT_BYT] = { 73 - .type = LPSS_BYT_SSP, 74 - .port_id = 0, 75 - .num_chipselect = 1, 76 - .max_clk_rate = 50000000, 77 - .tx_param = &byt_tx_param, 78 - .rx_param = &byt_rx_param, 79 - }, 80 - [PORT_BSW0] = { 81 - .type = LPSS_BYT_SSP, 82 - .port_id = 0, 83 - .num_chipselect = 1, 84 - .max_clk_rate = 50000000, 85 - .tx_param = &bsw0_tx_param, 86 - .rx_param = &bsw0_rx_param, 87 - }, 88 - [PORT_BSW1] = { 89 - .type = LPSS_BYT_SSP, 90 - .port_id = 1, 91 - .num_chipselect = 1, 92 - .max_clk_rate = 50000000, 93 - .tx_param = &bsw1_tx_param, 94 - .rx_param = &bsw1_rx_param, 95 - }, 96 - [PORT_BSW2] = { 97 - .type = LPSS_BYT_SSP, 98 - .port_id = 2, 99 - .num_chipselect = 1, 100 - .max_clk_rate = 50000000, 101 - .tx_param = &bsw2_tx_param, 102 - .rx_param = &bsw2_rx_param, 103 - }, 104 - [PORT_QUARK_X1000] = { 105 - .type = QUARK_X1000_SSP, 106 - .port_id = -1, 107 - .num_chipselect = 1, 108 - .max_clk_rate = 50000000, 109 - }, 110 - [PORT_LPT] = { 111 - .type = LPSS_LPT_SSP, 112 - .port_id = 0, 113 - .num_chipselect = 1, 114 - .max_clk_rate = 50000000, 115 - .tx_param = &lpt_tx_param, 116 - .rx_param = &lpt_rx_param, 117 - }, 118 - }; 119 - 120 - static int pxa2xx_spi_pci_probe(struct pci_dev *dev, 121 - const struct pci_device_id *ent) 60 + static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) 122 61 { 123 - struct platform_device_info pi; 124 - int ret; 125 - struct platform_device *pdev; 126 - struct pxa2xx_spi_master spi_pdata; 127 - struct ssp_device *ssp; 128 - struct pxa_spi_info *c; 129 - char buf[40]; 130 62 struct pci_dev *dma_dev; 131 63 132 - ret = pcim_enable_device(dev); 133 - if (ret) 134 - return ret; 135 - 136 - ret = pcim_iomap_regions(dev, 1 << 0, "PXA2xx SPI"); 137 - if (ret) 138 - return ret; 139 - 140 - c = &spi_info_configs[ent->driver_data]; 141 - 142 - memset(&spi_pdata, 0, sizeof(spi_pdata)); 143 - spi_pdata.num_chipselect = (c->num_chipselect > 0) ? 144 - c->num_chipselect : dev->devfn; 64 + c->num_chipselect = 1; 65 + c->max_clk_rate = 50000000; 145 66 146 67 dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); 147 68 ··· 87 156 slave->p_master = 1; 88 157 } 89 158 90 - spi_pdata.dma_filter = lpss_dma_filter; 159 + c->dma_filter = lpss_dma_filter; 160 + return 0; 161 + } 162 + 163 + static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c) 164 + { 165 + switch (PCI_FUNC(dev->devfn)) { 166 + case 0: 167 + c->port_id = 3; 168 + c->num_chipselect = 1; 169 + break; 170 + case 1: 171 + c->port_id = 5; 172 + c->num_chipselect = 4; 173 + break; 174 + case 2: 175 + c->port_id = 6; 176 + c->num_chipselect = 1; 177 + break; 178 + default: 179 + return -ENODEV; 180 + } 181 + return 0; 182 + } 183 + 184 + static struct pxa_spi_info spi_info_configs[] = { 185 + [PORT_CE4100] = { 186 + .type = PXA25x_SSP, 187 + .port_id = -1, 188 + .num_chipselect = -1, 189 + .max_clk_rate = 3686400, 190 + }, 191 + [PORT_BYT] = { 192 + .type = LPSS_BYT_SSP, 193 + .port_id = 0, 194 + .setup = lpss_spi_setup, 195 + .tx_param = &byt_tx_param, 196 + .rx_param = &byt_rx_param, 197 + }, 198 + [PORT_BSW0] = { 199 + .type = LPSS_BSW_SSP, 200 + .port_id = 0, 201 + .setup = lpss_spi_setup, 202 + .tx_param = &bsw0_tx_param, 203 + .rx_param = &bsw0_rx_param, 204 + }, 205 + [PORT_BSW1] = { 206 + .type = LPSS_BSW_SSP, 207 + .port_id = 1, 208 + .setup = lpss_spi_setup, 209 + .tx_param = &bsw1_tx_param, 210 + .rx_param = &bsw1_rx_param, 211 + }, 212 + [PORT_BSW2] = { 213 + .type = LPSS_BSW_SSP, 214 + .port_id = 2, 215 + .setup = lpss_spi_setup, 216 + .tx_param = &bsw2_tx_param, 217 + .rx_param = &bsw2_rx_param, 218 + }, 219 + [PORT_MRFLD] = { 220 + .type = PXA27x_SSP, 221 + .max_clk_rate = 25000000, 222 + .setup = mrfld_spi_setup, 223 + }, 224 + [PORT_QUARK_X1000] = { 225 + .type = QUARK_X1000_SSP, 226 + .port_id = -1, 227 + .num_chipselect = 1, 228 + .max_clk_rate = 50000000, 229 + }, 230 + [PORT_LPT] = { 231 + .type = LPSS_LPT_SSP, 232 + .port_id = 0, 233 + .setup = lpss_spi_setup, 234 + .tx_param = &lpt_tx_param, 235 + .rx_param = &lpt_rx_param, 236 + }, 237 + }; 238 + 239 + static int pxa2xx_spi_pci_probe(struct pci_dev *dev, 240 + const struct pci_device_id *ent) 241 + { 242 + struct platform_device_info pi; 243 + int ret; 244 + struct platform_device *pdev; 245 + struct pxa2xx_spi_master spi_pdata; 246 + struct ssp_device *ssp; 247 + struct pxa_spi_info *c; 248 + char buf[40]; 249 + 250 + ret = pcim_enable_device(dev); 251 + if (ret) 252 + return ret; 253 + 254 + ret = pcim_iomap_regions(dev, 1 << 0, "PXA2xx SPI"); 255 + if (ret) 256 + return ret; 257 + 258 + c = &spi_info_configs[ent->driver_data]; 259 + if (c->setup) { 260 + ret = c->setup(dev, c); 261 + if (ret) 262 + return ret; 263 + } 264 + 265 + memset(&spi_pdata, 0, sizeof(spi_pdata)); 266 + spi_pdata.num_chipselect = (c->num_chipselect > 0) ? c->num_chipselect : dev->devfn; 267 + spi_pdata.dma_filter = c->dma_filter; 91 268 spi_pdata.tx_param = c->tx_param; 92 269 spi_pdata.rx_param = c->rx_param; 93 270 spi_pdata.enable_dma = c->rx_param && c->tx_param; ··· 203 164 ssp = &spi_pdata.ssp; 204 165 ssp->phys_base = pci_resource_start(dev, 0); 205 166 ssp->mmio_base = pcim_iomap_table(dev)[0]; 206 - if (!ssp->mmio_base) { 207 - dev_err(&dev->dev, "failed to ioremap() registers\n"); 208 - return -EIO; 209 - } 210 167 ssp->irq = dev->irq; 211 168 ssp->port_id = (c->port_id >= 0) ? c->port_id : dev->devfn; 212 169 ssp->type = c->type; ··· 243 208 } 244 209 245 210 static const struct pci_device_id pxa2xx_spi_pci_devices[] = { 246 - { PCI_VDEVICE(INTEL, 0x2e6a), PORT_CE4100 }, 247 211 { PCI_VDEVICE(INTEL, 0x0935), PORT_QUARK_X1000 }, 248 212 { PCI_VDEVICE(INTEL, 0x0f0e), PORT_BYT }, 213 + { PCI_VDEVICE(INTEL, 0x1194), PORT_MRFLD }, 249 214 { PCI_VDEVICE(INTEL, 0x228e), PORT_BSW0 }, 250 215 { PCI_VDEVICE(INTEL, 0x2290), PORT_BSW1 }, 251 216 { PCI_VDEVICE(INTEL, 0x22ac), PORT_BSW2 }, 217 + { PCI_VDEVICE(INTEL, 0x2e6a), PORT_CE4100 }, 252 218 { PCI_VDEVICE(INTEL, 0x9ce6), PORT_LPT }, 253 219 { }, 254 220 };
+28 -18
drivers/spi/spi-pxa2xx.c
··· 919 919 return clk_div << 8; 920 920 } 921 921 922 + static bool pxa2xx_spi_can_dma(struct spi_master *master, 923 + struct spi_device *spi, 924 + struct spi_transfer *xfer) 925 + { 926 + struct chip_data *chip = spi_get_ctldata(spi); 927 + 928 + return chip->enable_dma && 929 + xfer->len <= MAX_DMA_LEN && 930 + xfer->len >= chip->dma_burst_size; 931 + } 932 + 922 933 static void pump_transfers(unsigned long data) 923 934 { 924 935 struct driver_data *drv_data = (struct driver_data *)data; 936 + struct spi_master *master = drv_data->master; 925 937 struct spi_message *message = NULL; 926 938 struct spi_transfer *transfer = NULL; 927 939 struct spi_transfer *previous = NULL; ··· 947 935 u32 dma_burst = drv_data->cur_chip->dma_burst_size; 948 936 u32 change_mask = pxa2xx_spi_get_ssrc1_change_mask(drv_data); 949 937 int err; 938 + int dma_mapped; 950 939 951 940 /* Get current state information */ 952 941 message = drv_data->cur_msg; ··· 982 969 } 983 970 984 971 /* Check if we can DMA this transfer */ 985 - if (!pxa2xx_spi_dma_is_possible(transfer->len) && chip->enable_dma) { 972 + if (transfer->len > MAX_DMA_LEN && chip->enable_dma) { 986 973 987 974 /* reject already-mapped transfers; PIO won't always work */ 988 975 if (message->is_dma_mapped ··· 1059 1046 1060 1047 message->state = RUNNING_STATE; 1061 1048 1062 - drv_data->dma_mapped = 0; 1063 - if (pxa2xx_spi_dma_is_possible(drv_data->len)) 1064 - drv_data->dma_mapped = pxa2xx_spi_map_dma_buffers(drv_data); 1065 - if (drv_data->dma_mapped) { 1049 + dma_mapped = master->can_dma && 1050 + master->can_dma(master, message->spi, transfer) && 1051 + master->cur_msg_mapped; 1052 + if (dma_mapped) { 1066 1053 1067 1054 /* Ensure we have the correct interrupt handler */ 1068 1055 drv_data->transfer_handler = pxa2xx_spi_dma_transfer; ··· 1092 1079 cr0 = pxa2xx_configure_sscr0(drv_data, clk_div, bits); 1093 1080 if (!pxa25x_ssp_comp(drv_data)) 1094 1081 dev_dbg(&message->spi->dev, "%u Hz actual, %s\n", 1095 - drv_data->master->max_speed_hz 1082 + master->max_speed_hz 1096 1083 / (1 + ((cr0 & SSCR0_SCR(0xfff)) >> 8)), 1097 - drv_data->dma_mapped ? "DMA" : "PIO"); 1084 + dma_mapped ? "DMA" : "PIO"); 1098 1085 else 1099 1086 dev_dbg(&message->spi->dev, "%u Hz actual, %s\n", 1100 - drv_data->master->max_speed_hz / 2 1087 + master->max_speed_hz / 2 1101 1088 / (1 + ((cr0 & SSCR0_SCR(0x0ff)) >> 8)), 1102 - drv_data->dma_mapped ? "DMA" : "PIO"); 1089 + dma_mapped ? "DMA" : "PIO"); 1103 1090 1104 1091 if (is_lpss_ssp(drv_data)) { 1105 1092 if ((pxa2xx_spi_read(drv_data, SSIRF) & 0xff) ··· 1260 1247 chip->frm = spi->chip_select; 1261 1248 } else 1262 1249 chip->gpio_cs = -1; 1263 - chip->enable_dma = 0; 1250 + chip->enable_dma = drv_data->master_info->enable_dma; 1264 1251 chip->timeout = TIMOUT_DFLT; 1265 1252 } 1266 1253 ··· 1279 1266 tx_hi_thres = chip_info->tx_hi_threshold; 1280 1267 if (chip_info->rx_threshold) 1281 1268 rx_thres = chip_info->rx_threshold; 1282 - chip->enable_dma = drv_data->master_info->enable_dma; 1283 1269 chip->dma_threshold = 0; 1284 1270 if (chip_info->enable_loopback) 1285 1271 chip->cr1 = SSCR1_LBM; 1286 - } else if (ACPI_HANDLE(&spi->dev)) { 1287 - /* 1288 - * Slave devices enumerated from ACPI namespace don't 1289 - * usually have chip_info but we still might want to use 1290 - * DMA with them. 1291 - */ 1292 - chip->enable_dma = drv_data->master_info->enable_dma; 1293 1272 } 1294 1273 1295 1274 chip->lpss_rx_threshold = SSIRF_RxThresh(rx_thres); ··· 1401 1396 /* SPT-H */ 1402 1397 { PCI_VDEVICE(INTEL, 0xa129), LPSS_SPT_SSP }, 1403 1398 { PCI_VDEVICE(INTEL, 0xa12a), LPSS_SPT_SSP }, 1399 + /* KBL-H */ 1400 + { PCI_VDEVICE(INTEL, 0xa2a9), LPSS_SPT_SSP }, 1401 + { PCI_VDEVICE(INTEL, 0xa2aa), LPSS_SPT_SSP }, 1404 1402 /* BXT A-Step */ 1405 1403 { PCI_VDEVICE(INTEL, 0x0ac2), LPSS_BXT_SSP }, 1406 1404 { PCI_VDEVICE(INTEL, 0x0ac4), LPSS_BXT_SSP }, ··· 1616 1608 if (status) { 1617 1609 dev_dbg(dev, "no DMA channels available, using PIO\n"); 1618 1610 platform_info->enable_dma = false; 1611 + } else { 1612 + master->can_dma = pxa2xx_spi_can_dma; 1619 1613 } 1620 1614 } 1621 1615
-9
drivers/spi/spi-pxa2xx.h
··· 50 50 struct tasklet_struct pump_transfers; 51 51 52 52 /* DMA engine support */ 53 - struct dma_chan *rx_chan; 54 - struct dma_chan *tx_chan; 55 - struct sg_table rx_sgt; 56 - struct sg_table tx_sgt; 57 - int rx_nents; 58 - int tx_nents; 59 53 atomic_t dma_running; 60 54 61 55 /* Current message transfer state info */ ··· 61 67 void *tx_end; 62 68 void *rx; 63 69 void *rx_end; 64 - int dma_mapped; 65 70 u8 n_bytes; 66 71 int (*write)(struct driver_data *drv_data); 67 72 int (*read)(struct driver_data *drv_data); ··· 138 145 #define MAX_DMA_LEN SZ_64K 139 146 #define DEFAULT_DMA_CR1 (SSCR1_TSRE | SSCR1_RSRE | SSCR1_TRAIL) 140 147 141 - extern bool pxa2xx_spi_dma_is_possible(size_t len); 142 - extern int pxa2xx_spi_map_dma_buffers(struct driver_data *drv_data); 143 148 extern irqreturn_t pxa2xx_spi_dma_transfer(struct driver_data *drv_data); 144 149 extern int pxa2xx_spi_dma_prepare(struct driver_data *drv_data, u32 dma_burst); 145 150 extern void pxa2xx_spi_dma_start(struct driver_data *drv_data);
+3
drivers/spi/spi-rockchip.c
··· 911 911 }; 912 912 913 913 static const struct of_device_id rockchip_spi_dt_match[] = { 914 + { .compatible = "rockchip,rk3036-spi", }, 914 915 { .compatible = "rockchip,rk3066-spi", }, 915 916 { .compatible = "rockchip,rk3188-spi", }, 917 + { .compatible = "rockchip,rk3228-spi", }, 916 918 { .compatible = "rockchip,rk3288-spi", }, 919 + { .compatible = "rockchip,rk3368-spi", }, 917 920 { .compatible = "rockchip,rk3399-spi", }, 918 921 { }, 919 922 };
+129 -79
drivers/spi/spi-s3c64xx.c
··· 156 156 int quirks; 157 157 bool high_speed; 158 158 bool clk_from_cmu; 159 + bool clk_ioclk; 159 160 }; 160 161 161 162 /** 162 163 * struct s3c64xx_spi_driver_data - Runtime info holder for SPI driver. 163 164 * @clk: Pointer to the spi clock. 164 165 * @src_clk: Pointer to the clock used to generate SPI signals. 166 + * @ioclk: Pointer to the i/o clock between master and slave 165 167 * @master: Pointer to the SPI Protocol master. 166 168 * @cntrlr_info: Platform specific data for the controller this driver manages. 167 169 * @tgl_spi: Pointer to the last CS left untoggled by the cs_change hint. ··· 183 181 void __iomem *regs; 184 182 struct clk *clk; 185 183 struct clk *src_clk; 184 + struct clk *ioclk; 186 185 struct platform_device *pdev; 187 186 struct spi_master *master; 188 187 struct s3c64xx_spi_info *cntrlr_info; ··· 313 310 dma_async_issue_pending(dma->ch); 314 311 } 315 312 313 + static void s3c64xx_spi_set_cs(struct spi_device *spi, bool enable) 314 + { 315 + struct s3c64xx_spi_driver_data *sdd = 316 + spi_master_get_devdata(spi->master); 317 + 318 + if (sdd->cntrlr_info->no_cs) 319 + return; 320 + 321 + if (enable) { 322 + if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) { 323 + writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 324 + } else { 325 + u32 ssel = readl(sdd->regs + S3C64XX_SPI_SLAVE_SEL); 326 + 327 + ssel |= (S3C64XX_SPI_SLAVE_AUTO | 328 + S3C64XX_SPI_SLAVE_NSC_CNT_2); 329 + writel(ssel, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 330 + } 331 + } else { 332 + if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) 333 + writel(S3C64XX_SPI_SLAVE_SIG_INACT, 334 + sdd->regs + S3C64XX_SPI_SLAVE_SEL); 335 + } 336 + } 337 + 316 338 static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) 317 339 { 318 340 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); 319 341 dma_filter_fn filter = sdd->cntrlr_info->filter; 320 342 struct device *dev = &sdd->pdev->dev; 321 343 dma_cap_mask_t mask; 322 - int ret; 323 344 324 - if (!is_polling(sdd)) { 325 - dma_cap_zero(mask); 326 - dma_cap_set(DMA_SLAVE, mask); 345 + if (is_polling(sdd)) 346 + return 0; 327 347 328 - /* Acquire DMA channels */ 329 - sdd->rx_dma.ch = dma_request_slave_channel_compat(mask, filter, 330 - sdd->cntrlr_info->dma_rx, dev, "rx"); 331 - if (!sdd->rx_dma.ch) { 332 - dev_err(dev, "Failed to get RX DMA channel\n"); 333 - ret = -EBUSY; 334 - goto out; 335 - } 336 - spi->dma_rx = sdd->rx_dma.ch; 348 + dma_cap_zero(mask); 349 + dma_cap_set(DMA_SLAVE, mask); 337 350 338 - sdd->tx_dma.ch = dma_request_slave_channel_compat(mask, filter, 339 - sdd->cntrlr_info->dma_tx, dev, "tx"); 340 - if (!sdd->tx_dma.ch) { 341 - dev_err(dev, "Failed to get TX DMA channel\n"); 342 - ret = -EBUSY; 343 - goto out_rx; 344 - } 345 - spi->dma_tx = sdd->tx_dma.ch; 351 + /* Acquire DMA channels */ 352 + sdd->rx_dma.ch = dma_request_slave_channel_compat(mask, filter, 353 + sdd->cntrlr_info->dma_rx, dev, "rx"); 354 + if (!sdd->rx_dma.ch) { 355 + dev_err(dev, "Failed to get RX DMA channel\n"); 356 + return -EBUSY; 346 357 } 358 + spi->dma_rx = sdd->rx_dma.ch; 359 + 360 + sdd->tx_dma.ch = dma_request_slave_channel_compat(mask, filter, 361 + sdd->cntrlr_info->dma_tx, dev, "tx"); 362 + if (!sdd->tx_dma.ch) { 363 + dev_err(dev, "Failed to get TX DMA channel\n"); 364 + dma_release_channel(sdd->rx_dma.ch); 365 + return -EBUSY; 366 + } 367 + spi->dma_tx = sdd->tx_dma.ch; 347 368 348 369 return 0; 349 - 350 - out_rx: 351 - dma_release_channel(sdd->rx_dma.ch); 352 - out: 353 - return ret; 354 370 } 355 371 356 372 static int s3c64xx_spi_unprepare_transfer(struct spi_master *spi) ··· 599 577 u32 val; 600 578 601 579 /* Disable Clock */ 602 - if (sdd->port_conf->clk_from_cmu) { 603 - clk_disable_unprepare(sdd->src_clk); 604 - } else { 580 + if (!sdd->port_conf->clk_from_cmu) { 605 581 val = readl(regs + S3C64XX_SPI_CLK_CFG); 606 582 val &= ~S3C64XX_SPI_ENCLK_ENABLE; 607 583 writel(val, regs + S3C64XX_SPI_CLK_CFG); ··· 642 622 writel(val, regs + S3C64XX_SPI_MODE_CFG); 643 623 644 624 if (sdd->port_conf->clk_from_cmu) { 645 - /* Configure Clock */ 646 - /* There is half-multiplier before the SPI */ 625 + /* The src_clk clock is divided internally by 2 */ 647 626 clk_set_rate(sdd->src_clk, sdd->cur_speed * 2); 648 - /* Enable Clock */ 649 - clk_prepare_enable(sdd->src_clk); 650 627 } else { 651 628 /* Configure Clock */ 652 629 val = readl(regs + S3C64XX_SPI_CLK_CFG); ··· 667 650 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); 668 651 struct spi_device *spi = msg->spi; 669 652 struct s3c64xx_spi_csinfo *cs = spi->controller_data; 670 - 671 - /* If Master's(controller) state differs from that needed by Slave */ 672 - if (sdd->cur_speed != spi->max_speed_hz 673 - || sdd->cur_mode != spi->mode 674 - || sdd->cur_bpw != spi->bits_per_word) { 675 - sdd->cur_bpw = spi->bits_per_word; 676 - sdd->cur_speed = spi->max_speed_hz; 677 - sdd->cur_mode = spi->mode; 678 - s3c64xx_spi_config(sdd); 679 - } 680 653 681 654 /* Configure feedback delay */ 682 655 writel(cs->fb_delay & 0x3, sdd->regs + S3C64XX_SPI_FB_CLK); ··· 694 687 if (bpw != sdd->cur_bpw || speed != sdd->cur_speed) { 695 688 sdd->cur_bpw = bpw; 696 689 sdd->cur_speed = speed; 690 + sdd->cur_mode = spi->mode; 697 691 s3c64xx_spi_config(sdd); 698 692 } 699 693 ··· 714 706 enable_datapath(sdd, spi, xfer, use_dma); 715 707 716 708 /* Start the signals */ 717 - if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) 718 - writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 719 - else 720 - writel(readl(sdd->regs + S3C64XX_SPI_SLAVE_SEL) 721 - | S3C64XX_SPI_SLAVE_AUTO | S3C64XX_SPI_SLAVE_NSC_CNT_2, 722 - sdd->regs + S3C64XX_SPI_SLAVE_SEL); 709 + s3c64xx_spi_set_cs(spi, true); 723 710 724 711 spin_unlock_irqrestore(&sdd->lock, flags); 725 712 ··· 864 861 865 862 pm_runtime_mark_last_busy(&sdd->pdev->dev); 866 863 pm_runtime_put_autosuspend(&sdd->pdev->dev); 867 - if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) 868 - writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 864 + s3c64xx_spi_set_cs(spi, false); 865 + 869 866 return 0; 870 867 871 868 setup_exit: 872 869 pm_runtime_mark_last_busy(&sdd->pdev->dev); 873 870 pm_runtime_put_autosuspend(&sdd->pdev->dev); 874 871 /* setup() returns with device de-selected */ 875 - if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) 876 - writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 872 + s3c64xx_spi_set_cs(spi, false); 877 873 878 874 if (gpio_is_valid(spi->cs_gpio)) 879 875 gpio_free(spi->cs_gpio); ··· 946 944 947 945 sdd->cur_speed = 0; 948 946 949 - if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) 947 + if (sci->no_cs) 948 + writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 949 + else if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) 950 950 writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); 951 951 952 952 /* Disable Interrupts - we use Polling if not DMA mode */ ··· 1002 998 } else { 1003 999 sci->num_cs = temp; 1004 1000 } 1001 + 1002 + sci->no_cs = of_property_read_bool(dev->of_node, "broken-cs"); 1005 1003 1006 1004 return sci; 1007 1005 } ··· 1082 1076 if (ret < 0) { 1083 1077 dev_err(&pdev->dev, "failed to get alias id, errno %d\n", 1084 1078 ret); 1085 - goto err0; 1079 + goto err_deref_master; 1086 1080 } 1087 1081 sdd->port_id = ret; 1088 1082 } else { ··· 1120 1114 sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res); 1121 1115 if (IS_ERR(sdd->regs)) { 1122 1116 ret = PTR_ERR(sdd->regs); 1123 - goto err0; 1117 + goto err_deref_master; 1124 1118 } 1125 1119 1126 1120 if (sci->cfg_gpio && sci->cfg_gpio()) { 1127 1121 dev_err(&pdev->dev, "Unable to config gpio\n"); 1128 1122 ret = -EBUSY; 1129 - goto err0; 1123 + goto err_deref_master; 1130 1124 } 1131 1125 1132 1126 /* Setup clocks */ ··· 1134 1128 if (IS_ERR(sdd->clk)) { 1135 1129 dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n"); 1136 1130 ret = PTR_ERR(sdd->clk); 1137 - goto err0; 1131 + goto err_deref_master; 1138 1132 } 1139 1133 1140 - if (clk_prepare_enable(sdd->clk)) { 1134 + ret = clk_prepare_enable(sdd->clk); 1135 + if (ret) { 1141 1136 dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n"); 1142 - ret = -EBUSY; 1143 - goto err0; 1137 + goto err_deref_master; 1144 1138 } 1145 1139 1146 1140 sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr); ··· 1149 1143 dev_err(&pdev->dev, 1150 1144 "Unable to acquire clock '%s'\n", clk_name); 1151 1145 ret = PTR_ERR(sdd->src_clk); 1152 - goto err2; 1146 + goto err_disable_clk; 1153 1147 } 1154 1148 1155 - if (clk_prepare_enable(sdd->src_clk)) { 1149 + ret = clk_prepare_enable(sdd->src_clk); 1150 + if (ret) { 1156 1151 dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name); 1157 - ret = -EBUSY; 1158 - goto err2; 1152 + goto err_disable_clk; 1153 + } 1154 + 1155 + if (sdd->port_conf->clk_ioclk) { 1156 + sdd->ioclk = devm_clk_get(&pdev->dev, "spi_ioclk"); 1157 + if (IS_ERR(sdd->ioclk)) { 1158 + dev_err(&pdev->dev, "Unable to acquire 'ioclk'\n"); 1159 + ret = PTR_ERR(sdd->ioclk); 1160 + goto err_disable_src_clk; 1161 + } 1162 + 1163 + ret = clk_prepare_enable(sdd->ioclk); 1164 + if (ret) { 1165 + dev_err(&pdev->dev, "Couldn't enable clock 'ioclk'\n"); 1166 + goto err_disable_src_clk; 1167 + } 1159 1168 } 1160 1169 1161 1170 pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT); ··· 1190 1169 if (ret != 0) { 1191 1170 dev_err(&pdev->dev, "Failed to request IRQ %d: %d\n", 1192 1171 irq, ret); 1193 - goto err3; 1172 + goto err_pm_put; 1194 1173 } 1195 1174 1196 1175 writel(S3C64XX_SPI_INT_RX_OVERRUN_EN | S3C64XX_SPI_INT_RX_UNDERRUN_EN | ··· 1200 1179 ret = devm_spi_register_master(&pdev->dev, master); 1201 1180 if (ret != 0) { 1202 1181 dev_err(&pdev->dev, "cannot register SPI master: %d\n", ret); 1203 - goto err3; 1182 + goto err_pm_put; 1204 1183 } 1205 1184 1206 1185 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n", ··· 1214 1193 1215 1194 return 0; 1216 1195 1217 - err3: 1196 + err_pm_put: 1218 1197 pm_runtime_put_noidle(&pdev->dev); 1219 1198 pm_runtime_disable(&pdev->dev); 1220 1199 pm_runtime_set_suspended(&pdev->dev); 1221 1200 1201 + clk_disable_unprepare(sdd->ioclk); 1202 + err_disable_src_clk: 1222 1203 clk_disable_unprepare(sdd->src_clk); 1223 - err2: 1204 + err_disable_clk: 1224 1205 clk_disable_unprepare(sdd->clk); 1225 - err0: 1206 + err_deref_master: 1226 1207 spi_master_put(master); 1227 1208 1228 1209 return ret; ··· 1232 1209 1233 1210 static int s3c64xx_spi_remove(struct platform_device *pdev) 1234 1211 { 1235 - struct spi_master *master = spi_master_get(platform_get_drvdata(pdev)); 1212 + struct spi_master *master = platform_get_drvdata(pdev); 1236 1213 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); 1237 1214 1238 1215 pm_runtime_get_sync(&pdev->dev); 1239 1216 1240 1217 writel(0, sdd->regs + S3C64XX_SPI_INT_EN); 1218 + 1219 + clk_disable_unprepare(sdd->ioclk); 1241 1220 1242 1221 clk_disable_unprepare(sdd->src_clk); 1243 1222 ··· 1299 1274 1300 1275 clk_disable_unprepare(sdd->clk); 1301 1276 clk_disable_unprepare(sdd->src_clk); 1277 + clk_disable_unprepare(sdd->ioclk); 1302 1278 1303 1279 return 0; 1304 1280 } ··· 1310 1284 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); 1311 1285 int ret; 1312 1286 1313 - ret = clk_prepare_enable(sdd->src_clk); 1314 - if (ret != 0) 1315 - return ret; 1316 - 1317 - ret = clk_prepare_enable(sdd->clk); 1318 - if (ret != 0) { 1319 - clk_disable_unprepare(sdd->src_clk); 1320 - return ret; 1287 + if (sdd->port_conf->clk_ioclk) { 1288 + ret = clk_prepare_enable(sdd->ioclk); 1289 + if (ret != 0) 1290 + return ret; 1321 1291 } 1322 1292 1293 + ret = clk_prepare_enable(sdd->src_clk); 1294 + if (ret != 0) 1295 + goto err_disable_ioclk; 1296 + 1297 + ret = clk_prepare_enable(sdd->clk); 1298 + if (ret != 0) 1299 + goto err_disable_src_clk; 1300 + 1323 1301 return 0; 1302 + 1303 + err_disable_src_clk: 1304 + clk_disable_unprepare(sdd->src_clk); 1305 + err_disable_ioclk: 1306 + clk_disable_unprepare(sdd->ioclk); 1307 + 1308 + return ret; 1324 1309 } 1325 1310 #endif /* CONFIG_PM */ 1326 1311 ··· 1387 1350 .quirks = S3C64XX_SPI_QUIRK_CS_AUTO, 1388 1351 }; 1389 1352 1353 + static struct s3c64xx_spi_port_config exynos5433_spi_port_config = { 1354 + .fifo_lvl_mask = { 0x1ff, 0x7f, 0x7f, 0x7f, 0x7f, 0x1ff}, 1355 + .rx_lvl_offset = 15, 1356 + .tx_st_done = 25, 1357 + .high_speed = true, 1358 + .clk_from_cmu = true, 1359 + .clk_ioclk = true, 1360 + .quirks = S3C64XX_SPI_QUIRK_CS_AUTO, 1361 + }; 1362 + 1390 1363 static const struct platform_device_id s3c64xx_spi_driver_ids[] = { 1391 1364 { 1392 1365 .name = "s3c2443-spi", ··· 1426 1379 }, 1427 1380 { .compatible = "samsung,exynos7-spi", 1428 1381 .data = (void *)&exynos7_spi_port_config, 1382 + }, 1383 + { .compatible = "samsung,exynos5433-spi", 1384 + .data = (void *)&exynos5433_spi_port_config, 1429 1385 }, 1430 1386 { }, 1431 1387 };
+9 -9
drivers/spi/spi-sh-msiof.c
··· 45 45 void __iomem *mapbase; 46 46 struct clk *clk; 47 47 struct platform_device *pdev; 48 - const struct sh_msiof_chipdata *chipdata; 49 48 struct sh_msiof_spi_info *info; 50 49 struct completion done; 51 50 unsigned int tx_fifo_size; ··· 270 271 271 272 scr = sh_msiof_spi_div_table[k].brdv | SCR_BRPS(brps); 272 273 sh_msiof_write(p, TSCR, scr); 273 - if (!(p->chipdata->master_flags & SPI_MASTER_MUST_TX)) 274 + if (!(p->master->flags & SPI_MASTER_MUST_TX)) 274 275 sh_msiof_write(p, RSCR, scr); 275 276 } 276 277 ··· 335 336 tmp |= lsb_first << MDR1_BITLSB_SHIFT; 336 337 tmp |= sh_msiof_spi_get_dtdl_and_syncdl(p); 337 338 sh_msiof_write(p, TMDR1, tmp | MDR1_TRMD | TMDR1_PCON); 338 - if (p->chipdata->master_flags & SPI_MASTER_MUST_TX) { 339 + if (p->master->flags & SPI_MASTER_MUST_TX) { 339 340 /* These bits are reserved if RX needs TX */ 340 341 tmp &= ~0x0000ffff; 341 342 } ··· 359 360 { 360 361 u32 dr2 = MDR2_BITLEN1(bits) | MDR2_WDLEN1(words); 361 362 362 - if (tx_buf || (p->chipdata->master_flags & SPI_MASTER_MUST_TX)) 363 + if (tx_buf || (p->master->flags & SPI_MASTER_MUST_TX)) 363 364 sh_msiof_write(p, TMDR2, dr2); 364 365 else 365 366 sh_msiof_write(p, TMDR2, dr2 | MDR2_GRPMASK1); ··· 1151 1152 { 1152 1153 struct resource *r; 1153 1154 struct spi_master *master; 1155 + const struct sh_msiof_chipdata *chipdata; 1154 1156 const struct of_device_id *of_id; 1155 1157 struct sh_msiof_spi_priv *p; 1156 1158 int i; ··· 1170 1170 1171 1171 of_id = of_match_device(sh_msiof_match, &pdev->dev); 1172 1172 if (of_id) { 1173 - p->chipdata = of_id->data; 1173 + chipdata = of_id->data; 1174 1174 p->info = sh_msiof_spi_parse_dt(&pdev->dev); 1175 1175 } else { 1176 - p->chipdata = (const void *)pdev->id_entry->driver_data; 1176 + chipdata = (const void *)pdev->id_entry->driver_data; 1177 1177 p->info = dev_get_platdata(&pdev->dev); 1178 1178 } 1179 1179 ··· 1217 1217 pm_runtime_enable(&pdev->dev); 1218 1218 1219 1219 /* Platform data may override FIFO sizes */ 1220 - p->tx_fifo_size = p->chipdata->tx_fifo_size; 1221 - p->rx_fifo_size = p->chipdata->rx_fifo_size; 1220 + p->tx_fifo_size = chipdata->tx_fifo_size; 1221 + p->rx_fifo_size = chipdata->rx_fifo_size; 1222 1222 if (p->info->tx_fifo_override) 1223 1223 p->tx_fifo_size = p->info->tx_fifo_override; 1224 1224 if (p->info->rx_fifo_override) ··· 1227 1227 /* init master code */ 1228 1228 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 1229 1229 master->mode_bits |= SPI_LSB_FIRST | SPI_3WIRE; 1230 - master->flags = p->chipdata->master_flags; 1230 + master->flags = chipdata->master_flags; 1231 1231 master->bus_num = pdev->id; 1232 1232 master->dev.of_node = pdev->dev.of_node; 1233 1233 master->num_chipselect = p->info->num_chipselect;
+3 -13
drivers/spi/spi-sh.c
··· 82 82 int irq; 83 83 struct spi_master *master; 84 84 struct list_head queue; 85 - struct workqueue_struct *workqueue; 86 85 struct work_struct ws; 87 86 unsigned long cr1; 88 87 wait_queue_head_t wait; ··· 379 380 spi_sh_clear_bit(ss, SPI_SH_SSA, SPI_SH_CR1); 380 381 381 382 list_add_tail(&mesg->queue, &ss->queue); 382 - queue_work(ss->workqueue, &ss->ws); 383 + schedule_work(&ss->ws); 383 384 384 385 spin_unlock_irqrestore(&ss->lock, flags); 385 386 ··· 424 425 struct spi_sh_data *ss = platform_get_drvdata(pdev); 425 426 426 427 spi_unregister_master(ss->master); 427 - destroy_workqueue(ss->workqueue); 428 + flush_work(&ss->ws); 428 429 free_irq(ss->irq, ss); 429 430 430 431 return 0; ··· 483 484 spin_lock_init(&ss->lock); 484 485 INIT_WORK(&ss->ws, spi_sh_work); 485 486 init_waitqueue_head(&ss->wait); 486 - ss->workqueue = create_singlethread_workqueue( 487 - dev_name(master->dev.parent)); 488 - if (ss->workqueue == NULL) { 489 - dev_err(&pdev->dev, "create workqueue error\n"); 490 - ret = -EBUSY; 491 - goto error1; 492 - } 493 487 494 488 ret = request_irq(irq, spi_sh_irq, 0, "spi_sh", ss); 495 489 if (ret < 0) { 496 490 dev_err(&pdev->dev, "request_irq error\n"); 497 - goto error2; 491 + goto error1; 498 492 } 499 493 500 494 master->num_chipselect = 2; ··· 506 514 507 515 error3: 508 516 free_irq(irq, ss); 509 - error2: 510 - destroy_workqueue(ss->workqueue); 511 517 error1: 512 518 spi_master_put(master); 513 519
+1
include/linux/platform_data/spi-s3c64xx.h
··· 38 38 struct s3c64xx_spi_info { 39 39 int src_clk_nr; 40 40 int num_cs; 41 + bool no_cs; 41 42 int (*cfg_gpio)(void); 42 43 dma_filter_fn filter; 43 44 void *dma_tx;