Lines Matching refs:mcfqspi
59 struct mcfqspi { struct
68 static void mcfqspi_wr_qmr(struct mcfqspi *mcfqspi, u16 val) in mcfqspi_wr_qmr() argument
70 writew(val, mcfqspi->iobase + MCFQSPI_QMR); in mcfqspi_wr_qmr()
73 static void mcfqspi_wr_qdlyr(struct mcfqspi *mcfqspi, u16 val) in mcfqspi_wr_qdlyr() argument
75 writew(val, mcfqspi->iobase + MCFQSPI_QDLYR); in mcfqspi_wr_qdlyr()
78 static u16 mcfqspi_rd_qdlyr(struct mcfqspi *mcfqspi) in mcfqspi_rd_qdlyr() argument
80 return readw(mcfqspi->iobase + MCFQSPI_QDLYR); in mcfqspi_rd_qdlyr()
83 static void mcfqspi_wr_qwr(struct mcfqspi *mcfqspi, u16 val) in mcfqspi_wr_qwr() argument
85 writew(val, mcfqspi->iobase + MCFQSPI_QWR); in mcfqspi_wr_qwr()
88 static void mcfqspi_wr_qir(struct mcfqspi *mcfqspi, u16 val) in mcfqspi_wr_qir() argument
90 writew(val, mcfqspi->iobase + MCFQSPI_QIR); in mcfqspi_wr_qir()
93 static void mcfqspi_wr_qar(struct mcfqspi *mcfqspi, u16 val) in mcfqspi_wr_qar() argument
95 writew(val, mcfqspi->iobase + MCFQSPI_QAR); in mcfqspi_wr_qar()
98 static void mcfqspi_wr_qdr(struct mcfqspi *mcfqspi, u16 val) in mcfqspi_wr_qdr() argument
100 writew(val, mcfqspi->iobase + MCFQSPI_QDR); in mcfqspi_wr_qdr()
103 static u16 mcfqspi_rd_qdr(struct mcfqspi *mcfqspi) in mcfqspi_rd_qdr() argument
105 return readw(mcfqspi->iobase + MCFQSPI_QDR); in mcfqspi_rd_qdr()
108 static void mcfqspi_cs_select(struct mcfqspi *mcfqspi, u8 chip_select, in mcfqspi_cs_select() argument
111 mcfqspi->cs_control->select(mcfqspi->cs_control, chip_select, cs_high); in mcfqspi_cs_select()
114 static void mcfqspi_cs_deselect(struct mcfqspi *mcfqspi, u8 chip_select, in mcfqspi_cs_deselect() argument
117 mcfqspi->cs_control->deselect(mcfqspi->cs_control, chip_select, cs_high); in mcfqspi_cs_deselect()
120 static int mcfqspi_cs_setup(struct mcfqspi *mcfqspi) in mcfqspi_cs_setup() argument
122 return (mcfqspi->cs_control->setup) ? in mcfqspi_cs_setup()
123 mcfqspi->cs_control->setup(mcfqspi->cs_control) : 0; in mcfqspi_cs_setup()
126 static void mcfqspi_cs_teardown(struct mcfqspi *mcfqspi) in mcfqspi_cs_teardown() argument
128 if (mcfqspi->cs_control->teardown) in mcfqspi_cs_teardown()
129 mcfqspi->cs_control->teardown(mcfqspi->cs_control); in mcfqspi_cs_teardown()
137 static bool mcfqspi_qdlyr_spe(struct mcfqspi *mcfqspi) in mcfqspi_qdlyr_spe() argument
139 return mcfqspi_rd_qdlyr(mcfqspi) & MCFQSPI_QDLYR_SPE; in mcfqspi_qdlyr_spe()
144 struct mcfqspi *mcfqspi = dev_id; in mcfqspi_irq_handler() local
147 mcfqspi_wr_qir(mcfqspi, MCFQSPI_QIR_SPIFE | MCFQSPI_QIR_SPIF); in mcfqspi_irq_handler()
148 wake_up(&mcfqspi->waitq); in mcfqspi_irq_handler()
153 static void mcfqspi_transfer_msg8(struct mcfqspi *mcfqspi, unsigned count, in mcfqspi_transfer_msg8() argument
160 mcfqspi_wr_qar(mcfqspi, MCFQSPI_QAR_CMDBUF); in mcfqspi_transfer_msg8()
162 mcfqspi_wr_qdr(mcfqspi, MCFQSPI_QCR_BITSE); in mcfqspi_transfer_msg8()
164 mcfqspi_wr_qar(mcfqspi, MCFQSPI_QAR_TXBUF); in mcfqspi_transfer_msg8()
167 mcfqspi_wr_qdr(mcfqspi, *txbuf++); in mcfqspi_transfer_msg8()
170 mcfqspi_wr_qdr(mcfqspi, 0); in mcfqspi_transfer_msg8()
175 mcfqspi_wr_qwr(mcfqspi, 0x700); in mcfqspi_transfer_msg8()
176 mcfqspi_wr_qdlyr(mcfqspi, MCFQSPI_QDLYR_SPE); in mcfqspi_transfer_msg8()
179 wait_event(mcfqspi->waitq, !mcfqspi_qdlyr_spe(mcfqspi)); in mcfqspi_transfer_msg8()
180 mcfqspi_wr_qwr(mcfqspi, qwr); in mcfqspi_transfer_msg8()
181 mcfqspi_wr_qdlyr(mcfqspi, MCFQSPI_QDLYR_SPE); in mcfqspi_transfer_msg8()
183 mcfqspi_wr_qar(mcfqspi, in mcfqspi_transfer_msg8()
186 *rxbuf++ = mcfqspi_rd_qdr(mcfqspi); in mcfqspi_transfer_msg8()
190 mcfqspi_wr_qar(mcfqspi, in mcfqspi_transfer_msg8()
193 mcfqspi_wr_qdr(mcfqspi, *txbuf++); in mcfqspi_transfer_msg8()
199 wait_event(mcfqspi->waitq, !mcfqspi_qdlyr_spe(mcfqspi)); in mcfqspi_transfer_msg8()
200 mcfqspi_wr_qwr(mcfqspi, qwr); in mcfqspi_transfer_msg8()
201 mcfqspi_wr_qdlyr(mcfqspi, MCFQSPI_QDLYR_SPE); in mcfqspi_transfer_msg8()
203 mcfqspi_wr_qar(mcfqspi, MCFQSPI_QAR_RXBUF + offset); in mcfqspi_transfer_msg8()
205 *rxbuf++ = mcfqspi_rd_qdr(mcfqspi); in mcfqspi_transfer_msg8()
209 mcfqspi_wr_qwr(mcfqspi, (n - 1) << 8); in mcfqspi_transfer_msg8()
210 mcfqspi_wr_qdlyr(mcfqspi, MCFQSPI_QDLYR_SPE); in mcfqspi_transfer_msg8()
212 wait_event(mcfqspi->waitq, !mcfqspi_qdlyr_spe(mcfqspi)); in mcfqspi_transfer_msg8()
214 mcfqspi_wr_qar(mcfqspi, MCFQSPI_QAR_RXBUF + offset); in mcfqspi_transfer_msg8()
216 *rxbuf++ = mcfqspi_rd_qdr(mcfqspi); in mcfqspi_transfer_msg8()
220 static void mcfqspi_transfer_msg16(struct mcfqspi *mcfqspi, unsigned count, in mcfqspi_transfer_msg16() argument
227 mcfqspi_wr_qar(mcfqspi, MCFQSPI_QAR_CMDBUF); in mcfqspi_transfer_msg16()
229 mcfqspi_wr_qdr(mcfqspi, MCFQSPI_QCR_BITSE); in mcfqspi_transfer_msg16()
231 mcfqspi_wr_qar(mcfqspi, MCFQSPI_QAR_TXBUF); in mcfqspi_transfer_msg16()
234 mcfqspi_wr_qdr(mcfqspi, *txbuf++); in mcfqspi_transfer_msg16()
237 mcfqspi_wr_qdr(mcfqspi, 0); in mcfqspi_transfer_msg16()
242 mcfqspi_wr_qwr(mcfqspi, 0x700); in mcfqspi_transfer_msg16()
243 mcfqspi_wr_qdlyr(mcfqspi, MCFQSPI_QDLYR_SPE); in mcfqspi_transfer_msg16()
246 wait_event(mcfqspi->waitq, !mcfqspi_qdlyr_spe(mcfqspi)); in mcfqspi_transfer_msg16()
247 mcfqspi_wr_qwr(mcfqspi, qwr); in mcfqspi_transfer_msg16()
248 mcfqspi_wr_qdlyr(mcfqspi, MCFQSPI_QDLYR_SPE); in mcfqspi_transfer_msg16()
250 mcfqspi_wr_qar(mcfqspi, in mcfqspi_transfer_msg16()
253 *rxbuf++ = mcfqspi_rd_qdr(mcfqspi); in mcfqspi_transfer_msg16()
257 mcfqspi_wr_qar(mcfqspi, in mcfqspi_transfer_msg16()
260 mcfqspi_wr_qdr(mcfqspi, *txbuf++); in mcfqspi_transfer_msg16()
266 wait_event(mcfqspi->waitq, !mcfqspi_qdlyr_spe(mcfqspi)); in mcfqspi_transfer_msg16()
267 mcfqspi_wr_qwr(mcfqspi, qwr); in mcfqspi_transfer_msg16()
268 mcfqspi_wr_qdlyr(mcfqspi, MCFQSPI_QDLYR_SPE); in mcfqspi_transfer_msg16()
270 mcfqspi_wr_qar(mcfqspi, MCFQSPI_QAR_RXBUF + offset); in mcfqspi_transfer_msg16()
272 *rxbuf++ = mcfqspi_rd_qdr(mcfqspi); in mcfqspi_transfer_msg16()
276 mcfqspi_wr_qwr(mcfqspi, (n - 1) << 8); in mcfqspi_transfer_msg16()
277 mcfqspi_wr_qdlyr(mcfqspi, MCFQSPI_QDLYR_SPE); in mcfqspi_transfer_msg16()
279 wait_event(mcfqspi->waitq, !mcfqspi_qdlyr_spe(mcfqspi)); in mcfqspi_transfer_msg16()
281 mcfqspi_wr_qar(mcfqspi, MCFQSPI_QAR_RXBUF + offset); in mcfqspi_transfer_msg16()
283 *rxbuf++ = mcfqspi_rd_qdr(mcfqspi); in mcfqspi_transfer_msg16()
289 struct mcfqspi *mcfqspi = spi_controller_get_devdata(spi->controller); in mcfqspi_set_cs() local
293 mcfqspi_cs_select(mcfqspi, spi_get_chipselect(spi, 0), cs_high); in mcfqspi_set_cs()
295 mcfqspi_cs_deselect(mcfqspi, spi_get_chipselect(spi, 0), cs_high); in mcfqspi_set_cs()
302 struct mcfqspi *mcfqspi = spi_controller_get_devdata(host); in mcfqspi_transfer_one() local
311 mcfqspi_wr_qmr(mcfqspi, qmr); in mcfqspi_transfer_one()
313 mcfqspi_wr_qir(mcfqspi, MCFQSPI_QIR_SPIFE); in mcfqspi_transfer_one()
315 mcfqspi_transfer_msg8(mcfqspi, t->len, t->tx_buf, t->rx_buf); in mcfqspi_transfer_one()
317 mcfqspi_transfer_msg16(mcfqspi, t->len / 2, t->tx_buf, in mcfqspi_transfer_one()
319 mcfqspi_wr_qir(mcfqspi, 0); in mcfqspi_transfer_one()
341 struct mcfqspi *mcfqspi; in mcfqspi_probe() local
356 host = spi_alloc_host(&pdev->dev, sizeof(*mcfqspi)); in mcfqspi_probe()
362 mcfqspi = spi_controller_get_devdata(host); in mcfqspi_probe()
364 mcfqspi->iobase = devm_platform_ioremap_resource(pdev, 0); in mcfqspi_probe()
365 if (IS_ERR(mcfqspi->iobase)) { in mcfqspi_probe()
366 status = PTR_ERR(mcfqspi->iobase); in mcfqspi_probe()
370 mcfqspi->irq = platform_get_irq(pdev, 0); in mcfqspi_probe()
371 if (mcfqspi->irq < 0) { in mcfqspi_probe()
377 status = devm_request_irq(&pdev->dev, mcfqspi->irq, mcfqspi_irq_handler, in mcfqspi_probe()
378 0, pdev->name, mcfqspi); in mcfqspi_probe()
384 mcfqspi->clk = devm_clk_get_enabled(&pdev->dev, "qspi_clk"); in mcfqspi_probe()
385 if (IS_ERR(mcfqspi->clk)) { in mcfqspi_probe()
387 status = PTR_ERR(mcfqspi->clk); in mcfqspi_probe()
394 mcfqspi->cs_control = pdata->cs_control; in mcfqspi_probe()
395 status = mcfqspi_cs_setup(mcfqspi); in mcfqspi_probe()
401 init_waitqueue_head(&mcfqspi->waitq); in mcfqspi_probe()
425 mcfqspi_cs_teardown(mcfqspi); in mcfqspi_probe()
437 struct mcfqspi *mcfqspi = spi_controller_get_devdata(host); in mcfqspi_remove() local
441 mcfqspi_wr_qmr(mcfqspi, MCFQSPI_QMR_MSTR); in mcfqspi_remove()
443 mcfqspi_cs_teardown(mcfqspi); in mcfqspi_remove()
450 struct mcfqspi *mcfqspi = spi_controller_get_devdata(host); in mcfqspi_suspend() local
457 clk_disable(mcfqspi->clk); in mcfqspi_suspend()
465 struct mcfqspi *mcfqspi = spi_controller_get_devdata(host); in mcfqspi_resume() local
467 clk_enable(mcfqspi->clk); in mcfqspi_resume()
477 struct mcfqspi *mcfqspi = spi_controller_get_devdata(host); in mcfqspi_runtime_suspend() local
479 clk_disable(mcfqspi->clk); in mcfqspi_runtime_suspend()
487 struct mcfqspi *mcfqspi = spi_controller_get_devdata(host); in mcfqspi_runtime_resume() local
489 clk_enable(mcfqspi->clk); in mcfqspi_runtime_resume()