Lines Matching refs:mdata
98 static void mtk_spi_slave_disable_dma(struct mtk_spi_slave *mdata) in mtk_spi_slave_disable_dma() argument
102 reg_val = readl(mdata->base + SPIS_DMA_CFG_REG); in mtk_spi_slave_disable_dma()
105 writel(reg_val, mdata->base + SPIS_DMA_CFG_REG); in mtk_spi_slave_disable_dma()
108 static void mtk_spi_slave_disable_xfer(struct mtk_spi_slave *mdata) in mtk_spi_slave_disable_xfer() argument
112 reg_val = readl(mdata->base + SPIS_CFG_REG); in mtk_spi_slave_disable_xfer()
115 writel(reg_val, mdata->base + SPIS_CFG_REG); in mtk_spi_slave_disable_xfer()
118 static int mtk_spi_slave_wait_for_completion(struct mtk_spi_slave *mdata) in mtk_spi_slave_wait_for_completion() argument
120 if (wait_for_completion_interruptible(&mdata->xfer_done) || in mtk_spi_slave_wait_for_completion()
121 mdata->slave_aborted) { in mtk_spi_slave_wait_for_completion()
122 dev_err(mdata->dev, "interrupted\n"); in mtk_spi_slave_wait_for_completion()
132 struct mtk_spi_slave *mdata = spi_controller_get_devdata(ctlr); in mtk_spi_slave_prepare_message() local
140 reg_val = readl(mdata->base + SPIS_CFG_REG); in mtk_spi_slave_prepare_message()
157 writel(reg_val, mdata->base + SPIS_CFG_REG); in mtk_spi_slave_prepare_message()
166 struct mtk_spi_slave *mdata = spi_controller_get_devdata(ctlr); in mtk_spi_slave_fifo_transfer() local
169 writel(SPIS_SOFT_RST, mdata->base + SPIS_SOFT_RST_REG); in mtk_spi_slave_fifo_transfer()
171 reg_val = readl(mdata->base + SPIS_CFG_REG); in mtk_spi_slave_fifo_transfer()
176 writel(reg_val, mdata->base + SPIS_CFG_REG); in mtk_spi_slave_fifo_transfer()
180 iowrite32_rep(mdata->base + SPIS_TX_DATA_REG, in mtk_spi_slave_fifo_transfer()
187 writel(reg_val, mdata->base + SPIS_TX_DATA_REG); in mtk_spi_slave_fifo_transfer()
190 ret = mtk_spi_slave_wait_for_completion(mdata); in mtk_spi_slave_fifo_transfer()
192 mtk_spi_slave_disable_xfer(mdata); in mtk_spi_slave_fifo_transfer()
193 writel(SPIS_SOFT_RST, mdata->base + SPIS_SOFT_RST_REG); in mtk_spi_slave_fifo_transfer()
203 struct mtk_spi_slave *mdata = spi_controller_get_devdata(ctlr); in mtk_spi_slave_dma_transfer() local
204 struct device *dev = mdata->dev; in mtk_spi_slave_dma_transfer()
207 writel(SPIS_SOFT_RST, mdata->base + SPIS_SOFT_RST_REG); in mtk_spi_slave_dma_transfer()
232 writel(xfer->tx_dma, mdata->base + SPIS_TX_SRC_REG); in mtk_spi_slave_dma_transfer()
233 writel(xfer->rx_dma, mdata->base + SPIS_RX_DST_REG); in mtk_spi_slave_dma_transfer()
235 writel(SPIS_DMA_ADDR_EN, mdata->base + SPIS_SOFT_RST_REG); in mtk_spi_slave_dma_transfer()
238 reg_val = readl(mdata->base + SPIS_CFG_REG); in mtk_spi_slave_dma_transfer()
243 writel(reg_val, mdata->base + SPIS_CFG_REG); in mtk_spi_slave_dma_transfer()
248 writel(reg_val, mdata->base + SPIS_DMA_CFG_REG); in mtk_spi_slave_dma_transfer()
250 reg_val = readl(mdata->base + SPIS_DMA_CFG_REG); in mtk_spi_slave_dma_transfer()
256 writel(reg_val, mdata->base + SPIS_DMA_CFG_REG); in mtk_spi_slave_dma_transfer()
258 ret = mtk_spi_slave_wait_for_completion(mdata); in mtk_spi_slave_dma_transfer()
275 mtk_spi_slave_disable_dma(mdata); in mtk_spi_slave_dma_transfer()
276 mtk_spi_slave_disable_xfer(mdata); in mtk_spi_slave_dma_transfer()
277 writel(SPIS_SOFT_RST, mdata->base + SPIS_SOFT_RST_REG); in mtk_spi_slave_dma_transfer()
286 struct mtk_spi_slave *mdata = spi_controller_get_devdata(ctlr); in mtk_spi_slave_transfer_one() local
288 reinit_completion(&mdata->xfer_done); in mtk_spi_slave_transfer_one()
289 mdata->slave_aborted = false; in mtk_spi_slave_transfer_one()
290 mdata->cur_transfer = xfer; in mtk_spi_slave_transfer_one()
292 if (xfer->len > mdata->dev_comp->max_fifo_size) in mtk_spi_slave_transfer_one()
300 struct mtk_spi_slave *mdata = spi_controller_get_devdata(spi->master); in mtk_spi_slave_setup() local
305 writel(reg_val, mdata->base + SPIS_IRQ_EN_REG); in mtk_spi_slave_setup()
309 writel(reg_val, mdata->base + SPIS_IRQ_MASK_REG); in mtk_spi_slave_setup()
311 mtk_spi_slave_disable_dma(mdata); in mtk_spi_slave_setup()
312 mtk_spi_slave_disable_xfer(mdata); in mtk_spi_slave_setup()
319 struct mtk_spi_slave *mdata = spi_controller_get_devdata(ctlr); in mtk_slave_abort() local
321 mdata->slave_aborted = true; in mtk_slave_abort()
322 complete(&mdata->xfer_done); in mtk_slave_abort()
330 struct mtk_spi_slave *mdata = spi_controller_get_devdata(ctlr); in mtk_spi_slave_interrupt() local
331 struct spi_transfer *trans = mdata->cur_transfer; in mtk_spi_slave_interrupt()
334 int_status = readl(mdata->base + SPIS_IRQ_ST_REG); in mtk_spi_slave_interrupt()
335 writel(int_status, mdata->base + SPIS_IRQ_CLR_REG); in mtk_spi_slave_interrupt()
343 writel(SPIS_SOFT_RST, mdata->base + SPIS_SOFT_RST_REG); in mtk_spi_slave_interrupt()
346 dma_unmap_single(mdata->dev, trans->tx_dma, in mtk_spi_slave_interrupt()
349 dma_unmap_single(mdata->dev, trans->rx_dma, in mtk_spi_slave_interrupt()
352 mtk_spi_slave_disable_dma(mdata); in mtk_spi_slave_interrupt()
353 mtk_spi_slave_disable_xfer(mdata); in mtk_spi_slave_interrupt()
361 ioread32_rep(mdata->base + SPIS_RX_DATA_REG, in mtk_spi_slave_interrupt()
365 reg_val = readl(mdata->base + SPIS_RX_DATA_REG); in mtk_spi_slave_interrupt()
370 mtk_spi_slave_disable_xfer(mdata); in mtk_spi_slave_interrupt()
378 mdata->cur_transfer = NULL; in mtk_spi_slave_interrupt()
379 complete(&mdata->xfer_done); in mtk_spi_slave_interrupt()
387 struct mtk_spi_slave *mdata; in mtk_spi_slave_probe() local
391 ctlr = spi_alloc_slave(&pdev->dev, sizeof(*mdata)); in mtk_spi_slave_probe()
413 mdata = spi_controller_get_devdata(ctlr); in mtk_spi_slave_probe()
414 mdata->dev_comp = of_id->data; in mtk_spi_slave_probe()
416 if (mdata->dev_comp->must_rx) in mtk_spi_slave_probe()
421 init_completion(&mdata->xfer_done); in mtk_spi_slave_probe()
422 mdata->dev = &pdev->dev; in mtk_spi_slave_probe()
423 mdata->base = devm_platform_ioremap_resource(pdev, 0); in mtk_spi_slave_probe()
424 if (IS_ERR(mdata->base)) { in mtk_spi_slave_probe()
425 ret = PTR_ERR(mdata->base); in mtk_spi_slave_probe()
442 mdata->spi_clk = devm_clk_get(&pdev->dev, "spi"); in mtk_spi_slave_probe()
443 if (IS_ERR(mdata->spi_clk)) { in mtk_spi_slave_probe()
444 ret = PTR_ERR(mdata->spi_clk); in mtk_spi_slave_probe()
449 ret = clk_prepare_enable(mdata->spi_clk); in mtk_spi_slave_probe()
461 clk_disable_unprepare(mdata->spi_clk); in mtk_spi_slave_probe()
465 clk_disable_unprepare(mdata->spi_clk); in mtk_spi_slave_probe()
488 struct mtk_spi_slave *mdata = spi_controller_get_devdata(ctlr); in mtk_spi_slave_suspend() local
496 clk_disable_unprepare(mdata->spi_clk); in mtk_spi_slave_suspend()
504 struct mtk_spi_slave *mdata = spi_controller_get_devdata(ctlr); in mtk_spi_slave_resume() local
508 ret = clk_prepare_enable(mdata->spi_clk); in mtk_spi_slave_resume()
517 clk_disable_unprepare(mdata->spi_clk); in mtk_spi_slave_resume()
527 struct mtk_spi_slave *mdata = spi_controller_get_devdata(ctlr); in mtk_spi_slave_runtime_suspend() local
529 clk_disable_unprepare(mdata->spi_clk); in mtk_spi_slave_runtime_suspend()
537 struct mtk_spi_slave *mdata = spi_controller_get_devdata(ctlr); in mtk_spi_slave_runtime_resume() local
540 ret = clk_prepare_enable(mdata->spi_clk); in mtk_spi_slave_runtime_resume()