mspi 51 drivers/spi/spi-fsl-cpm.c void fsl_spi_cpm_reinit_txrx(struct mpc8xxx_spi *mspi) mspi 53 drivers/spi/spi-fsl-cpm.c if (mspi->flags & SPI_QE) { mspi 54 drivers/spi/spi-fsl-cpm.c qe_issue_cmd(QE_INIT_TX_RX, mspi->subblock, mspi 57 drivers/spi/spi-fsl-cpm.c if (mspi->flags & SPI_CPM1) { mspi 58 drivers/spi/spi-fsl-cpm.c out_be32(&mspi->pram->rstate, 0); mspi 59 drivers/spi/spi-fsl-cpm.c out_be16(&mspi->pram->rbptr, mspi 60 drivers/spi/spi-fsl-cpm.c in_be16(&mspi->pram->rbase)); mspi 61 drivers/spi/spi-fsl-cpm.c out_be32(&mspi->pram->tstate, 0); mspi 62 drivers/spi/spi-fsl-cpm.c out_be16(&mspi->pram->tbptr, mspi 63 drivers/spi/spi-fsl-cpm.c in_be16(&mspi->pram->tbase)); mspi 71 drivers/spi/spi-fsl-cpm.c static void fsl_spi_cpm_bufs_start(struct mpc8xxx_spi *mspi) mspi 73 drivers/spi/spi-fsl-cpm.c struct cpm_buf_desc __iomem *tx_bd = mspi->tx_bd; mspi 74 drivers/spi/spi-fsl-cpm.c struct cpm_buf_desc __iomem *rx_bd = mspi->rx_bd; mspi 75 drivers/spi/spi-fsl-cpm.c unsigned int xfer_len = min(mspi->count, SPI_MRBLR); mspi 77 drivers/spi/spi-fsl-cpm.c struct fsl_spi_reg *reg_base = mspi->reg_base; mspi 79 drivers/spi/spi-fsl-cpm.c xfer_ofs = mspi->xfer_in_progress->len - mspi->count; mspi 81 drivers/spi/spi-fsl-cpm.c if (mspi->rx_dma == mspi->dma_dummy_rx) mspi 82 drivers/spi/spi-fsl-cpm.c out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma); mspi 84 drivers/spi/spi-fsl-cpm.c out_be32(&rx_bd->cbd_bufaddr, mspi->rx_dma + xfer_ofs); mspi 88 drivers/spi/spi-fsl-cpm.c if (mspi->tx_dma == mspi->dma_dummy_tx) mspi 89 drivers/spi/spi-fsl-cpm.c out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma); mspi 91 drivers/spi/spi-fsl-cpm.c out_be32(&tx_bd->cbd_bufaddr, mspi->tx_dma + xfer_ofs); mspi 100 drivers/spi/spi-fsl-cpm.c int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, mspi 103 drivers/spi/spi-fsl-cpm.c struct device *dev = mspi->dev; mspi 104 drivers/spi/spi-fsl-cpm.c struct fsl_spi_reg *reg_base = mspi->reg_base; mspi 107 drivers/spi/spi-fsl-cpm.c mspi->map_tx_dma = 0; mspi 108 drivers/spi/spi-fsl-cpm.c mspi->map_rx_dma = 0; mspi 110 drivers/spi/spi-fsl-cpm.c mspi->map_tx_dma = 1; mspi 111 drivers/spi/spi-fsl-cpm.c mspi->map_rx_dma = 1; mspi 115 drivers/spi/spi-fsl-cpm.c mspi->tx_dma = mspi->dma_dummy_tx; mspi 116 drivers/spi/spi-fsl-cpm.c mspi->map_tx_dma = 0; mspi 120 drivers/spi/spi-fsl-cpm.c mspi->rx_dma = mspi->dma_dummy_rx; mspi 121 drivers/spi/spi-fsl-cpm.c mspi->map_rx_dma = 0; mspi 124 drivers/spi/spi-fsl-cpm.c if (mspi->map_tx_dma) { mspi 125 drivers/spi/spi-fsl-cpm.c void *nonconst_tx = (void *)mspi->tx; /* shut up gcc */ mspi 127 drivers/spi/spi-fsl-cpm.c mspi->tx_dma = dma_map_single(dev, nonconst_tx, t->len, mspi 129 drivers/spi/spi-fsl-cpm.c if (dma_mapping_error(dev, mspi->tx_dma)) { mspi 134 drivers/spi/spi-fsl-cpm.c mspi->tx_dma = t->tx_dma; mspi 137 drivers/spi/spi-fsl-cpm.c if (mspi->map_rx_dma) { mspi 138 drivers/spi/spi-fsl-cpm.c mspi->rx_dma = dma_map_single(dev, mspi->rx, t->len, mspi 140 drivers/spi/spi-fsl-cpm.c if (dma_mapping_error(dev, mspi->rx_dma)) { mspi 145 drivers/spi/spi-fsl-cpm.c mspi->rx_dma = t->rx_dma; mspi 151 drivers/spi/spi-fsl-cpm.c mspi->xfer_in_progress = t; mspi 152 drivers/spi/spi-fsl-cpm.c mspi->count = t->len; mspi 155 drivers/spi/spi-fsl-cpm.c fsl_spi_cpm_bufs_start(mspi); mspi 160 drivers/spi/spi-fsl-cpm.c if (mspi->map_tx_dma) mspi 161 drivers/spi/spi-fsl-cpm.c dma_unmap_single(dev, mspi->tx_dma, t->len, DMA_TO_DEVICE); mspi 166 drivers/spi/spi-fsl-cpm.c void fsl_spi_cpm_bufs_complete(struct mpc8xxx_spi *mspi) mspi 168 drivers/spi/spi-fsl-cpm.c struct device *dev = mspi->dev; mspi 169 drivers/spi/spi-fsl-cpm.c struct spi_transfer *t = mspi->xfer_in_progress; mspi 171 drivers/spi/spi-fsl-cpm.c if (mspi->map_tx_dma) mspi 172 drivers/spi/spi-fsl-cpm.c dma_unmap_single(dev, mspi->tx_dma, t->len, DMA_TO_DEVICE); mspi 173 drivers/spi/spi-fsl-cpm.c if (mspi->map_rx_dma) mspi 174 drivers/spi/spi-fsl-cpm.c dma_unmap_single(dev, mspi->rx_dma, t->len, DMA_FROM_DEVICE); mspi 175 drivers/spi/spi-fsl-cpm.c mspi->xfer_in_progress = NULL; mspi 179 drivers/spi/spi-fsl-cpm.c void fsl_spi_cpm_irq(struct mpc8xxx_spi *mspi, u32 events) mspi 182 drivers/spi/spi-fsl-cpm.c struct fsl_spi_reg *reg_base = mspi->reg_base; mspi 184 drivers/spi/spi-fsl-cpm.c dev_dbg(mspi->dev, "%s: bd datlen %d, count %d\n", __func__, mspi 185 drivers/spi/spi-fsl-cpm.c in_be16(&mspi->rx_bd->cbd_datlen), mspi->count); mspi 187 drivers/spi/spi-fsl-cpm.c len = in_be16(&mspi->rx_bd->cbd_datlen); mspi 188 drivers/spi/spi-fsl-cpm.c if (len > mspi->count) { mspi 190 drivers/spi/spi-fsl-cpm.c len = mspi->count; mspi 196 drivers/spi/spi-fsl-cpm.c mspi->count -= len; mspi 197 drivers/spi/spi-fsl-cpm.c if (mspi->count) mspi 198 drivers/spi/spi-fsl-cpm.c fsl_spi_cpm_bufs_start(mspi); mspi 200 drivers/spi/spi-fsl-cpm.c complete(&mspi->done); mspi 238 drivers/spi/spi-fsl-cpm.c static unsigned long fsl_spi_cpm_get_pram(struct mpc8xxx_spi *mspi) mspi 240 drivers/spi/spi-fsl-cpm.c struct device *dev = mspi->dev; mspi 251 drivers/spi/spi-fsl-cpm.c if (mspi->flags & SPI_QE && iprop && size == sizeof(*iprop) * 4) mspi 255 drivers/spi/spi-fsl-cpm.c if (mspi->flags & SPI_QE) { mspi 257 drivers/spi/spi-fsl-cpm.c qe_issue_cmd(QE_ASSIGN_PAGE_TO_DEVICE, mspi->subblock, mspi 266 drivers/spi/spi-fsl-cpm.c if (mspi->flags & SPI_CPM2) { mspi 275 drivers/spi/spi-fsl-cpm.c int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi) mspi 277 drivers/spi/spi-fsl-cpm.c struct device *dev = mspi->dev; mspi 283 drivers/spi/spi-fsl-cpm.c if (!(mspi->flags & SPI_CPM_MODE)) mspi 289 drivers/spi/spi-fsl-cpm.c if (mspi->flags & SPI_QE) { mspi 292 drivers/spi/spi-fsl-cpm.c mspi->subblock = *iprop; mspi 294 drivers/spi/spi-fsl-cpm.c switch (mspi->subblock) { mspi 299 drivers/spi/spi-fsl-cpm.c mspi->subblock = QE_CR_SUBBLOCK_SPI1; mspi 302 drivers/spi/spi-fsl-cpm.c mspi->subblock = QE_CR_SUBBLOCK_SPI2; mspi 307 drivers/spi/spi-fsl-cpm.c if (mspi->flags & SPI_CPM1) { mspi 313 drivers/spi/spi-fsl-cpm.c mspi->pram = NULL; mspi 315 drivers/spi/spi-fsl-cpm.c mspi->pram = pram; mspi 317 drivers/spi/spi-fsl-cpm.c unsigned long pram_ofs = fsl_spi_cpm_get_pram(mspi); mspi 320 drivers/spi/spi-fsl-cpm.c mspi->pram = NULL; mspi 322 drivers/spi/spi-fsl-cpm.c mspi->pram = cpm_muram_addr(pram_ofs); mspi 324 drivers/spi/spi-fsl-cpm.c if (mspi->pram == NULL) { mspi 329 drivers/spi/spi-fsl-cpm.c bds_ofs = cpm_muram_alloc(sizeof(*mspi->tx_bd) + mspi 330 drivers/spi/spi-fsl-cpm.c sizeof(*mspi->rx_bd), 8); mspi 336 drivers/spi/spi-fsl-cpm.c mspi->dma_dummy_tx = dma_map_single(dev, empty_zero_page, PAGE_SIZE, mspi 338 drivers/spi/spi-fsl-cpm.c if (dma_mapping_error(dev, mspi->dma_dummy_tx)) { mspi 343 drivers/spi/spi-fsl-cpm.c mspi->dma_dummy_rx = dma_map_single(dev, fsl_dummy_rx, SPI_MRBLR, mspi 345 drivers/spi/spi-fsl-cpm.c if (dma_mapping_error(dev, mspi->dma_dummy_rx)) { mspi 350 drivers/spi/spi-fsl-cpm.c mspi->tx_bd = cpm_muram_addr(bds_ofs); mspi 351 drivers/spi/spi-fsl-cpm.c mspi->rx_bd = cpm_muram_addr(bds_ofs + sizeof(*mspi->tx_bd)); mspi 354 drivers/spi/spi-fsl-cpm.c out_be16(&mspi->pram->tbase, cpm_muram_offset(mspi->tx_bd)); mspi 355 drivers/spi/spi-fsl-cpm.c out_be16(&mspi->pram->rbase, cpm_muram_offset(mspi->rx_bd)); mspi 356 drivers/spi/spi-fsl-cpm.c out_8(&mspi->pram->tfcr, CPMFCR_EB | CPMFCR_GBL); mspi 357 drivers/spi/spi-fsl-cpm.c out_8(&mspi->pram->rfcr, CPMFCR_EB | CPMFCR_GBL); mspi 358 drivers/spi/spi-fsl-cpm.c out_be16(&mspi->pram->mrblr, SPI_MRBLR); mspi 359 drivers/spi/spi-fsl-cpm.c out_be32(&mspi->pram->rstate, 0); mspi 360 drivers/spi/spi-fsl-cpm.c out_be32(&mspi->pram->rdp, 0); mspi 361 drivers/spi/spi-fsl-cpm.c out_be16(&mspi->pram->rbptr, 0); mspi 362 drivers/spi/spi-fsl-cpm.c out_be16(&mspi->pram->rbc, 0); mspi 363 drivers/spi/spi-fsl-cpm.c out_be32(&mspi->pram->rxtmp, 0); mspi 364 drivers/spi/spi-fsl-cpm.c out_be32(&mspi->pram->tstate, 0); mspi 365 drivers/spi/spi-fsl-cpm.c out_be32(&mspi->pram->tdp, 0); mspi 366 drivers/spi/spi-fsl-cpm.c out_be16(&mspi->pram->tbptr, 0); mspi 367 drivers/spi/spi-fsl-cpm.c out_be16(&mspi->pram->tbc, 0); mspi 368 drivers/spi/spi-fsl-cpm.c out_be32(&mspi->pram->txtmp, 0); mspi 373 drivers/spi/spi-fsl-cpm.c dma_unmap_single(dev, mspi->dma_dummy_tx, PAGE_SIZE, DMA_TO_DEVICE); mspi 377 drivers/spi/spi-fsl-cpm.c if (!(mspi->flags & SPI_CPM1)) mspi 378 drivers/spi/spi-fsl-cpm.c cpm_muram_free(cpm_muram_offset(mspi->pram)); mspi 385 drivers/spi/spi-fsl-cpm.c void fsl_spi_cpm_free(struct mpc8xxx_spi *mspi) mspi 387 drivers/spi/spi-fsl-cpm.c struct device *dev = mspi->dev; mspi 389 drivers/spi/spi-fsl-cpm.c if (!(mspi->flags & SPI_CPM_MODE)) mspi 392 drivers/spi/spi-fsl-cpm.c dma_unmap_single(dev, mspi->dma_dummy_rx, SPI_MRBLR, DMA_FROM_DEVICE); mspi 393 drivers/spi/spi-fsl-cpm.c dma_unmap_single(dev, mspi->dma_dummy_tx, PAGE_SIZE, DMA_TO_DEVICE); mspi 394 drivers/spi/spi-fsl-cpm.c cpm_muram_free(cpm_muram_offset(mspi->tx_bd)); mspi 395 drivers/spi/spi-fsl-cpm.c cpm_muram_free(cpm_muram_offset(mspi->pram)); mspi 21 drivers/spi/spi-fsl-cpm.h extern void fsl_spi_cpm_reinit_txrx(struct mpc8xxx_spi *mspi); mspi 22 drivers/spi/spi-fsl-cpm.h extern int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, mspi 24 drivers/spi/spi-fsl-cpm.h extern void fsl_spi_cpm_bufs_complete(struct mpc8xxx_spi *mspi); mspi 25 drivers/spi/spi-fsl-cpm.h extern void fsl_spi_cpm_irq(struct mpc8xxx_spi *mspi, u32 events); mspi 26 drivers/spi/spi-fsl-cpm.h extern int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi); mspi 27 drivers/spi/spi-fsl-cpm.h extern void fsl_spi_cpm_free(struct mpc8xxx_spi *mspi); mspi 29 drivers/spi/spi-fsl-cpm.h static inline void fsl_spi_cpm_reinit_txrx(struct mpc8xxx_spi *mspi) { } mspi 30 drivers/spi/spi-fsl-cpm.h static inline int fsl_spi_cpm_bufs(struct mpc8xxx_spi *mspi, mspi 33 drivers/spi/spi-fsl-cpm.h static inline void fsl_spi_cpm_bufs_complete(struct mpc8xxx_spi *mspi) { } mspi 34 drivers/spi/spi-fsl-cpm.h static inline void fsl_spi_cpm_irq(struct mpc8xxx_spi *mspi, u32 events) { } mspi 35 drivers/spi/spi-fsl-cpm.h static inline int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi) { return 0; } mspi 36 drivers/spi/spi-fsl-cpm.h static inline void fsl_spi_cpm_free(struct mpc8xxx_spi *mspi) { } mspi 106 drivers/spi/spi-fsl-lib.h extern int mpc8xxx_spi_bufs(struct mpc8xxx_spi *mspi, mspi 91 drivers/spi/spi-fsl-spi.c struct mpc8xxx_spi *mspi = spi_master_get_devdata(spi->master); mspi 93 drivers/spi/spi-fsl-spi.c struct fsl_spi_reg *reg_base = mspi->reg_base; mspi 107 drivers/spi/spi-fsl-spi.c if (mspi->flags & SPI_CPM_MODE) { mspi 108 drivers/spi/spi-fsl-spi.c fsl_spi_cpm_reinit_txrx(mspi); mspi 290 drivers/spi/spi-fsl-spi.c static int fsl_spi_cpu_bufs(struct mpc8xxx_spi *mspi, mspi 294 drivers/spi/spi-fsl-spi.c struct fsl_spi_reg *reg_base = mspi->reg_base; mspi 296 drivers/spi/spi-fsl-spi.c mspi->count = len; mspi 302 drivers/spi/spi-fsl-spi.c word = mspi->get_tx(mspi); mspi 497 drivers/spi/spi-fsl-spi.c static void fsl_spi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events) mspi 499 drivers/spi/spi-fsl-spi.c struct fsl_spi_reg *reg_base = mspi->reg_base; mspi 505 drivers/spi/spi-fsl-spi.c if (mspi->rx) mspi 506 drivers/spi/spi-fsl-spi.c mspi->get_rx(rx_data, mspi); mspi 519 drivers/spi/spi-fsl-spi.c mspi->count -= 1; mspi 520 drivers/spi/spi-fsl-spi.c if (mspi->count) { mspi 521 drivers/spi/spi-fsl-spi.c u32 word = mspi->get_tx(mspi); mspi 525 drivers/spi/spi-fsl-spi.c complete(&mspi->done); mspi 531 drivers/spi/spi-fsl-spi.c struct mpc8xxx_spi *mspi = context_data; mspi 534 drivers/spi/spi-fsl-spi.c struct fsl_spi_reg *reg_base = mspi->reg_base; mspi 541 drivers/spi/spi-fsl-spi.c dev_dbg(mspi->dev, "%s: events %x\n", __func__, events); mspi 543 drivers/spi/spi-fsl-spi.c if (mspi->flags & SPI_CPM_MODE) mspi 544 drivers/spi/spi-fsl-spi.c fsl_spi_cpm_irq(mspi, events); mspi 546 drivers/spi/spi-fsl-spi.c fsl_spi_cpu_irq(mspi, events);