Lines Matching full:spi

5  * Internal SPI driver for NetUP Universal Dual DVB-CI
13 #include <linux/spi/spi.h>
14 #include <linux/spi/flash.h>
69 irqreturn_t netup_spi_interrupt(struct netup_spi *spi) in netup_spi_interrupt() argument
74 if (!spi) in netup_spi_interrupt()
77 spin_lock_irqsave(&spi->lock, flags); in netup_spi_interrupt()
78 reg = readw(&spi->regs->control_stat); in netup_spi_interrupt()
80 spin_unlock_irqrestore(&spi->lock, flags); in netup_spi_interrupt()
81 dev_dbg(&spi->master->dev, in netup_spi_interrupt()
85 writew(reg | NETUP_SPI_CTRL_IRQ, &spi->regs->control_stat); in netup_spi_interrupt()
86 reg = readw(&spi->regs->control_stat); in netup_spi_interrupt()
87 writew(reg & ~NETUP_SPI_CTRL_IMASK, &spi->regs->control_stat); in netup_spi_interrupt()
88 spi->state = SPI_STATE_DONE; in netup_spi_interrupt()
89 wake_up(&spi->waitq); in netup_spi_interrupt()
90 spin_unlock_irqrestore(&spi->lock, flags); in netup_spi_interrupt()
91 dev_dbg(&spi->master->dev, in netup_spi_interrupt()
92 "%s(): SPI interrupt handled\n", __func__); in netup_spi_interrupt()
99 struct netup_spi *spi = spi_master_get_devdata(master); in netup_spi_transfer() local
105 writew(NETUP_SPI_CTRL_LAST_CS, &spi->regs->control_stat); in netup_spi_transfer()
106 writew(0, &spi->regs->control_stat); in netup_spi_transfer()
111 u32 frag_size = (tr_size > sizeof(spi->regs->data)) ? in netup_spi_transfer()
112 sizeof(spi->regs->data) : tr_size; in netup_spi_transfer()
121 memcpy_toio(spi->regs->data, in netup_spi_transfer()
125 memset_io(spi->regs->data, in netup_spi_transfer()
128 spi->state = SPI_STATE_START; in netup_spi_transfer()
133 &spi->regs->control_stat); in netup_spi_transfer()
134 dev_dbg(&spi->master->dev, in netup_spi_transfer()
136 __func__, readw(&spi->regs->control_stat)); in netup_spi_transfer()
137 wait_event_timeout(spi->waitq, in netup_spi_transfer()
138 spi->state != SPI_STATE_START, in netup_spi_transfer()
140 if (spi->state == SPI_STATE_DONE) { in netup_spi_transfer()
143 spi->regs->data, frag_size); in netup_spi_transfer()
146 if (spi->state == SPI_STATE_START) { in netup_spi_transfer()
147 dev_dbg(&spi->master->dev, in netup_spi_transfer()
151 dev_dbg(&spi->master->dev, in netup_spi_transfer()
153 __func__, spi->state); in netup_spi_transfer()
168 static int netup_spi_setup(struct spi_device *spi) in netup_spi_setup() argument
182 "%s(): unable to alloc SPI master\n", __func__); in netup_spi_init()
197 ndev->spi = nspi; in netup_spi_init()
199 ndev->spi = NULL; in netup_spi_init()
201 "%s(): unable to register SPI bus\n", __func__); in netup_spi_init()
212 ndev->spi = NULL; in netup_spi_init()
214 "%s(): unable to create SPI device\n", __func__); in netup_spi_init()
217 dev_dbg(&ndev->pci_dev->dev, "%s(): SPI init OK\n", __func__); in netup_spi_init()
225 struct netup_spi *spi = ndev->spi; in netup_spi_release() local
227 if (!spi) in netup_spi_release()
230 spi_unregister_master(spi->master); in netup_spi_release()
231 spin_lock_irqsave(&spi->lock, flags); in netup_spi_release()
232 reg = readw(&spi->regs->control_stat); in netup_spi_release()
233 writew(reg | NETUP_SPI_CTRL_IRQ, &spi->regs->control_stat); in netup_spi_release()
234 reg = readw(&spi->regs->control_stat); in netup_spi_release()
235 writew(reg & ~NETUP_SPI_CTRL_IMASK, &spi->regs->control_stat); in netup_spi_release()
236 spin_unlock_irqrestore(&spi->lock, flags); in netup_spi_release()
237 ndev->spi = NULL; in netup_spi_release()