2 * dw_spi.c - Designware SPI core controller driver (refer pxa2xx_spi.c)
4 * Copyright (c) 2009, Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <linux/dma-mapping.h>
21 #include <linux/interrupt.h>
22 #include <linux/highmem.h>
23 #include <linux/delay.h>
24 #include <linux/slab.h>
25 #include <linux/spi/spi.h>
29 #ifdef CONFIG_DEBUG_FS
30 #include <linux/debugfs.h>
33 #define START_STATE ((void *)0)
34 #define RUNNING_STATE ((void *)1)
35 #define DONE_STATE ((void *)2)
36 #define ERROR_STATE ((void *)-1)
38 #define QUEUE_RUNNING 0
39 #define QUEUE_STOPPED 1
41 #define MRST_SPI_DEASSERT 0
42 #define MRST_SPI_ASSERT 1
44 /* Slave spi_dev related */
47 u8 cs; /* chip select pin */
48 u8 n_bytes; /* current is a 1/2/4 byte op */
49 u8 tmode; /* TR/TO/RO/EEPROM */
50 u8 type; /* SPI/SSP/MicroWire */
52 u8 poll_mode; /* 1 means use poll mode */
59 u16 clk_div; /* baud rate divider */
60 u32 speed_hz; /* baud rate */
61 void (*cs_control)(u32 command);
64 #ifdef CONFIG_DEBUG_FS
65 static int spi_show_regs_open(struct inode *inode, struct file *file)
67 file->private_data = inode->i_private;
71 #define SPI_REGS_BUFSIZE 1024
72 static ssize_t spi_show_regs(struct file *file, char __user *user_buf,
73 size_t count, loff_t *ppos)
80 dws = file->private_data;
82 buf = kzalloc(SPI_REGS_BUFSIZE, GFP_KERNEL);
86 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
87 "MRST SPI0 registers:\n");
88 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
89 "=================================\n");
90 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
91 "CTRL0: \t\t0x%08x\n", dw_readl(dws, ctrl0));
92 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
93 "CTRL1: \t\t0x%08x\n", dw_readl(dws, ctrl1));
94 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
95 "SSIENR: \t0x%08x\n", dw_readl(dws, ssienr));
96 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
97 "SER: \t\t0x%08x\n", dw_readl(dws, ser));
98 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
99 "BAUDR: \t\t0x%08x\n", dw_readl(dws, baudr));
100 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
101 "TXFTLR: \t0x%08x\n", dw_readl(dws, txfltr));
102 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
103 "RXFTLR: \t0x%08x\n", dw_readl(dws, rxfltr));
104 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
105 "TXFLR: \t\t0x%08x\n", dw_readl(dws, txflr));
106 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
107 "RXFLR: \t\t0x%08x\n", dw_readl(dws, rxflr));
108 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
109 "SR: \t\t0x%08x\n", dw_readl(dws, sr));
110 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
111 "IMR: \t\t0x%08x\n", dw_readl(dws, imr));
112 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
113 "ISR: \t\t0x%08x\n", dw_readl(dws, isr));
114 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
115 "DMACR: \t\t0x%08x\n", dw_readl(dws, dmacr));
116 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
117 "DMATDLR: \t0x%08x\n", dw_readl(dws, dmatdlr));
118 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
119 "DMARDLR: \t0x%08x\n", dw_readl(dws, dmardlr));
120 len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
121 "=================================\n");
123 ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
128 static const struct file_operations mrst_spi_regs_ops = {
129 .owner = THIS_MODULE,
130 .open = spi_show_regs_open,
131 .read = spi_show_regs,
132 .llseek = default_llseek,
135 static int mrst_spi_debugfs_init(struct dw_spi *dws)
137 dws->debugfs = debugfs_create_dir("mrst_spi", NULL);
141 debugfs_create_file("registers", S_IFREG | S_IRUGO,
142 dws->debugfs, (void *)dws, &mrst_spi_regs_ops);
146 static void mrst_spi_debugfs_remove(struct dw_spi *dws)
149 debugfs_remove_recursive(dws->debugfs);
153 static inline int mrst_spi_debugfs_init(struct dw_spi *dws)
158 static inline void mrst_spi_debugfs_remove(struct dw_spi *dws)
161 #endif /* CONFIG_DEBUG_FS */
163 static void wait_till_not_busy(struct dw_spi *dws)
165 unsigned long end = jiffies + 1 + usecs_to_jiffies(5000);
167 while (time_before(jiffies, end)) {
168 if (!(dw_readw(dws, sr) & SR_BUSY))
172 dev_err(&dws->master->dev,
173 "DW SPI: Status keeps busy for 5000us after a read/write!\n");
176 static void flush(struct dw_spi *dws)
178 while (dw_readw(dws, sr) & SR_RF_NOT_EMPT) {
183 wait_till_not_busy(dws);
187 static int dw_writer(struct dw_spi *dws)
191 if (!(dw_readw(dws, sr) & SR_TF_NOT_FULL)
192 || (dws->tx == dws->tx_end))
195 /* Set the tx word if the transfer's original "tx" is not null */
196 if (dws->tx_end - dws->len) {
197 if (dws->n_bytes == 1)
198 txw = *(u8 *)(dws->tx);
200 txw = *(u16 *)(dws->tx);
203 dw_writew(dws, dr, txw);
204 dws->tx += dws->n_bytes;
206 wait_till_not_busy(dws);
210 static int dw_reader(struct dw_spi *dws)
214 while ((dw_readw(dws, sr) & SR_RF_NOT_EMPT)
215 && (dws->rx < dws->rx_end)) {
216 rxw = dw_readw(dws, dr);
217 /* Care rx only if the transfer's original "rx" is not null */
218 if (dws->rx_end - dws->len) {
219 if (dws->n_bytes == 1)
220 *(u8 *)(dws->rx) = rxw;
222 *(u16 *)(dws->rx) = rxw;
224 dws->rx += dws->n_bytes;
227 wait_till_not_busy(dws);
228 return dws->rx == dws->rx_end;
231 static void *next_transfer(struct dw_spi *dws)
233 struct spi_message *msg = dws->cur_msg;
234 struct spi_transfer *trans = dws->cur_transfer;
236 /* Move to next transfer */
237 if (trans->transfer_list.next != &msg->transfers) {
239 list_entry(trans->transfer_list.next,
242 return RUNNING_STATE;
248 * Note: first step is the protocol driver prepares
249 * a dma-capable memory, and this func just need translate
250 * the virt addr to physical
252 static int map_dma_buffers(struct dw_spi *dws)
254 if (!dws->cur_msg->is_dma_mapped
256 || !dws->cur_chip->enable_dma
260 if (dws->cur_transfer->tx_dma)
261 dws->tx_dma = dws->cur_transfer->tx_dma;
263 if (dws->cur_transfer->rx_dma)
264 dws->rx_dma = dws->cur_transfer->rx_dma;
269 /* Caller already set message->status; dma and pio irqs are blocked */
270 static void giveback(struct dw_spi *dws)
272 struct spi_transfer *last_transfer;
274 struct spi_message *msg;
276 spin_lock_irqsave(&dws->lock, flags);
279 dws->cur_transfer = NULL;
280 dws->prev_chip = dws->cur_chip;
281 dws->cur_chip = NULL;
283 queue_work(dws->workqueue, &dws->pump_messages);
284 spin_unlock_irqrestore(&dws->lock, flags);
286 last_transfer = list_entry(msg->transfers.prev,
290 if (!last_transfer->cs_change && dws->cs_control)
291 dws->cs_control(MRST_SPI_DEASSERT);
295 msg->complete(msg->context);
298 static void int_error_stop(struct dw_spi *dws, const char *msg)
300 /* Stop and reset hw */
302 spi_enable_chip(dws, 0);
304 dev_err(&dws->master->dev, "%s\n", msg);
305 dws->cur_msg->state = ERROR_STATE;
306 tasklet_schedule(&dws->pump_transfers);
309 void dw_spi_xfer_done(struct dw_spi *dws)
311 /* Update total byte transfered return count actual bytes read */
312 dws->cur_msg->actual_length += dws->len;
314 /* Move to next transfer */
315 dws->cur_msg->state = next_transfer(dws);
317 /* Handle end of message */
318 if (dws->cur_msg->state == DONE_STATE) {
319 dws->cur_msg->status = 0;
322 tasklet_schedule(&dws->pump_transfers);
324 EXPORT_SYMBOL_GPL(dw_spi_xfer_done);
326 static irqreturn_t interrupt_transfer(struct dw_spi *dws)
328 u16 irq_status, irq_mask = 0x3f;
329 u32 int_level = dws->fifo_len / 2;
332 irq_status = dw_readw(dws, isr) & irq_mask;
334 if (irq_status & (SPI_INT_TXOI | SPI_INT_RXOI | SPI_INT_RXUI)) {
335 dw_readw(dws, txoicr);
336 dw_readw(dws, rxoicr);
337 dw_readw(dws, rxuicr);
338 int_error_stop(dws, "interrupt_transfer: fifo overrun");
342 if (irq_status & SPI_INT_TXEI) {
343 spi_mask_intr(dws, SPI_INT_TXEI);
345 left = (dws->tx_end - dws->tx) / dws->n_bytes;
346 left = (left > int_level) ? int_level : left;
352 /* Re-enable the IRQ if there is still data left to tx */
353 if (dws->tx_end > dws->tx)
354 spi_umask_intr(dws, SPI_INT_TXEI);
356 dw_spi_xfer_done(dws);
362 static irqreturn_t dw_spi_irq(int irq, void *dev_id)
364 struct dw_spi *dws = dev_id;
365 u16 irq_status, irq_mask = 0x3f;
367 irq_status = dw_readw(dws, isr) & irq_mask;
372 spi_mask_intr(dws, SPI_INT_TXEI);
377 return dws->transfer_handler(dws);
380 /* Must be called inside pump_transfers() */
381 static void poll_transfer(struct dw_spi *dws)
383 while (dw_writer(dws))
386 * There is a possibility that the last word of a transaction
387 * will be lost if data is not ready. Re-read to solve this issue.
391 dw_spi_xfer_done(dws);
394 static void pump_transfers(unsigned long data)
396 struct dw_spi *dws = (struct dw_spi *)data;
397 struct spi_message *message = NULL;
398 struct spi_transfer *transfer = NULL;
399 struct spi_transfer *previous = NULL;
400 struct spi_device *spi = NULL;
401 struct chip_data *chip = NULL;
410 /* Get current state information */
411 message = dws->cur_msg;
412 transfer = dws->cur_transfer;
413 chip = dws->cur_chip;
416 if (unlikely(!chip->clk_div))
417 chip->clk_div = dws->max_freq / chip->speed_hz;
419 if (message->state == ERROR_STATE) {
420 message->status = -EIO;
424 /* Handle end of message */
425 if (message->state == DONE_STATE) {
430 /* Delay if requested at end of transfer*/
431 if (message->state == RUNNING_STATE) {
432 previous = list_entry(transfer->transfer_list.prev,
435 if (previous->delay_usecs)
436 udelay(previous->delay_usecs);
439 dws->n_bytes = chip->n_bytes;
440 dws->dma_width = chip->dma_width;
441 dws->cs_control = chip->cs_control;
443 dws->rx_dma = transfer->rx_dma;
444 dws->tx_dma = transfer->tx_dma;
445 dws->tx = (void *)transfer->tx_buf;
446 dws->tx_end = dws->tx + transfer->len;
447 dws->rx = transfer->rx_buf;
448 dws->rx_end = dws->rx + transfer->len;
449 dws->cs_change = transfer->cs_change;
450 dws->len = dws->cur_transfer->len;
451 if (chip != dws->prev_chip)
456 /* Handle per transfer options for bpw and speed */
457 if (transfer->speed_hz) {
458 speed = chip->speed_hz;
460 if (transfer->speed_hz != speed) {
461 speed = transfer->speed_hz;
462 if (speed > dws->max_freq) {
463 printk(KERN_ERR "MRST SPI0: unsupported"
464 "freq: %dHz\n", speed);
465 message->status = -EIO;
469 /* clk_div doesn't support odd number */
470 clk_div = dws->max_freq / speed;
471 clk_div = (clk_div + 1) & 0xfffe;
473 chip->speed_hz = speed;
474 chip->clk_div = clk_div;
477 if (transfer->bits_per_word) {
478 bits = transfer->bits_per_word;
490 printk(KERN_ERR "MRST SPI0: unsupported bits:"
492 message->status = -EIO;
497 | (chip->type << SPI_FRF_OFFSET)
498 | (spi->mode << SPI_MODE_OFFSET)
499 | (chip->tmode << SPI_TMOD_OFFSET);
501 message->state = RUNNING_STATE;
504 * Adjust transfer mode if necessary. Requires platform dependent
505 * chipselect mechanism.
507 if (dws->cs_control) {
508 if (dws->rx && dws->tx)
509 chip->tmode = SPI_TMOD_TR;
511 chip->tmode = SPI_TMOD_RO;
513 chip->tmode = SPI_TMOD_TO;
515 cr0 &= ~SPI_TMOD_MASK;
516 cr0 |= (chip->tmode << SPI_TMOD_OFFSET);
519 /* Check if current transfer is a DMA transaction */
520 dws->dma_mapped = map_dma_buffers(dws);
524 * we only need set the TXEI IRQ, as TX/RX always happen syncronizely
526 if (!dws->dma_mapped && !chip->poll_mode) {
527 int templen = dws->len / dws->n_bytes;
528 txint_level = dws->fifo_len / 2;
529 txint_level = (templen > txint_level) ? txint_level : templen;
531 imask |= SPI_INT_TXEI;
532 dws->transfer_handler = interrupt_transfer;
536 * Reprogram registers only if
537 * 1. chip select changes
538 * 2. clk_div is changed
539 * 3. control value changes
541 if (dw_readw(dws, ctrl0) != cr0 || cs_change || clk_div || imask) {
542 spi_enable_chip(dws, 0);
544 if (dw_readw(dws, ctrl0) != cr0)
545 dw_writew(dws, ctrl0, cr0);
547 spi_set_clk(dws, clk_div ? clk_div : chip->clk_div);
548 spi_chip_sel(dws, spi->chip_select);
550 /* Set the interrupt mask, for poll mode just disable all int */
551 spi_mask_intr(dws, 0xff);
553 spi_umask_intr(dws, imask);
555 dw_writew(dws, txfltr, txint_level);
557 spi_enable_chip(dws, 1);
559 dws->prev_chip = chip;
563 dws->dma_ops->dma_transfer(dws, cs_change);
575 static void pump_messages(struct work_struct *work)
578 container_of(work, struct dw_spi, pump_messages);
581 /* Lock queue and check for queue work */
582 spin_lock_irqsave(&dws->lock, flags);
583 if (list_empty(&dws->queue) || dws->run == QUEUE_STOPPED) {
585 spin_unlock_irqrestore(&dws->lock, flags);
589 /* Make sure we are not already running a message */
591 spin_unlock_irqrestore(&dws->lock, flags);
595 /* Extract head of queue */
596 dws->cur_msg = list_entry(dws->queue.next, struct spi_message, queue);
597 list_del_init(&dws->cur_msg->queue);
599 /* Initial message state*/
600 dws->cur_msg->state = START_STATE;
601 dws->cur_transfer = list_entry(dws->cur_msg->transfers.next,
604 dws->cur_chip = spi_get_ctldata(dws->cur_msg->spi);
606 /* Mark as busy and launch transfers */
607 tasklet_schedule(&dws->pump_transfers);
610 spin_unlock_irqrestore(&dws->lock, flags);
613 /* spi_device use this to queue in their spi_msg */
614 static int dw_spi_transfer(struct spi_device *spi, struct spi_message *msg)
616 struct dw_spi *dws = spi_master_get_devdata(spi->master);
619 spin_lock_irqsave(&dws->lock, flags);
621 if (dws->run == QUEUE_STOPPED) {
622 spin_unlock_irqrestore(&dws->lock, flags);
626 msg->actual_length = 0;
627 msg->status = -EINPROGRESS;
628 msg->state = START_STATE;
630 list_add_tail(&msg->queue, &dws->queue);
632 if (dws->run == QUEUE_RUNNING && !dws->busy) {
634 if (dws->cur_transfer || dws->cur_msg)
635 queue_work(dws->workqueue,
636 &dws->pump_messages);
638 /* If no other data transaction in air, just go */
639 spin_unlock_irqrestore(&dws->lock, flags);
640 pump_messages(&dws->pump_messages);
645 spin_unlock_irqrestore(&dws->lock, flags);
649 /* This may be called twice for each spi dev */
650 static int dw_spi_setup(struct spi_device *spi)
652 struct dw_spi_chip *chip_info = NULL;
653 struct chip_data *chip;
655 if (spi->bits_per_word != 8 && spi->bits_per_word != 16)
658 /* Only alloc on first setup */
659 chip = spi_get_ctldata(spi);
661 chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
667 * Protocol drivers may change the chip settings, so...
668 * if chip_info exists, use it
670 chip_info = spi->controller_data;
672 /* chip_info doesn't always exist */
674 if (chip_info->cs_control)
675 chip->cs_control = chip_info->cs_control;
677 chip->poll_mode = chip_info->poll_mode;
678 chip->type = chip_info->type;
680 chip->rx_threshold = 0;
681 chip->tx_threshold = 0;
683 chip->enable_dma = chip_info->enable_dma;
686 if (spi->bits_per_word <= 8) {
689 } else if (spi->bits_per_word <= 16) {
693 /* Never take >16b case for MRST SPIC */
694 dev_err(&spi->dev, "invalid wordsize\n");
697 chip->bits_per_word = spi->bits_per_word;
699 if (!spi->max_speed_hz) {
700 dev_err(&spi->dev, "No max speed HZ parameter\n");
703 chip->speed_hz = spi->max_speed_hz;
705 chip->tmode = 0; /* Tx & Rx */
706 /* Default SPI mode is SCPOL = 0, SCPH = 0 */
707 chip->cr0 = (chip->bits_per_word - 1)
708 | (chip->type << SPI_FRF_OFFSET)
709 | (spi->mode << SPI_MODE_OFFSET)
710 | (chip->tmode << SPI_TMOD_OFFSET);
712 spi_set_ctldata(spi, chip);
716 static void dw_spi_cleanup(struct spi_device *spi)
718 struct chip_data *chip = spi_get_ctldata(spi);
722 static int __devinit init_queue(struct dw_spi *dws)
724 INIT_LIST_HEAD(&dws->queue);
725 spin_lock_init(&dws->lock);
727 dws->run = QUEUE_STOPPED;
730 tasklet_init(&dws->pump_transfers,
731 pump_transfers, (unsigned long)dws);
733 INIT_WORK(&dws->pump_messages, pump_messages);
734 dws->workqueue = create_singlethread_workqueue(
735 dev_name(dws->master->dev.parent));
736 if (dws->workqueue == NULL)
742 static int start_queue(struct dw_spi *dws)
746 spin_lock_irqsave(&dws->lock, flags);
748 if (dws->run == QUEUE_RUNNING || dws->busy) {
749 spin_unlock_irqrestore(&dws->lock, flags);
753 dws->run = QUEUE_RUNNING;
755 dws->cur_transfer = NULL;
756 dws->cur_chip = NULL;
757 dws->prev_chip = NULL;
758 spin_unlock_irqrestore(&dws->lock, flags);
760 queue_work(dws->workqueue, &dws->pump_messages);
765 static int stop_queue(struct dw_spi *dws)
771 spin_lock_irqsave(&dws->lock, flags);
772 dws->run = QUEUE_STOPPED;
773 while (!list_empty(&dws->queue) && dws->busy && limit--) {
774 spin_unlock_irqrestore(&dws->lock, flags);
776 spin_lock_irqsave(&dws->lock, flags);
779 if (!list_empty(&dws->queue) || dws->busy)
781 spin_unlock_irqrestore(&dws->lock, flags);
786 static int destroy_queue(struct dw_spi *dws)
790 status = stop_queue(dws);
793 destroy_workqueue(dws->workqueue);
797 /* Restart the controller, disable all interrupts, clean rx fifo */
798 static void spi_hw_init(struct dw_spi *dws)
800 spi_enable_chip(dws, 0);
801 spi_mask_intr(dws, 0xff);
802 spi_enable_chip(dws, 1);
806 * Try to detect the FIFO depth if not set by interface driver,
807 * the depth could be from 2 to 256 from HW spec
809 if (!dws->fifo_len) {
811 for (fifo = 2; fifo <= 257; fifo++) {
812 dw_writew(dws, txfltr, fifo);
813 if (fifo != dw_readw(dws, txfltr))
817 dws->fifo_len = (fifo == 257) ? 0 : fifo;
818 dw_writew(dws, txfltr, 0);
822 int __devinit dw_spi_add_host(struct dw_spi *dws)
824 struct spi_master *master;
829 master = spi_alloc_master(dws->parent_dev, 0);
835 dws->master = master;
836 dws->type = SSI_MOTO_SPI;
837 dws->prev_chip = NULL;
839 dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60);
841 ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED,
844 dev_err(&master->dev, "can not get IRQ\n");
845 goto err_free_master;
848 master->mode_bits = SPI_CPOL | SPI_CPHA;
849 master->bus_num = dws->bus_num;
850 master->num_chipselect = dws->num_cs;
851 master->cleanup = dw_spi_cleanup;
852 master->setup = dw_spi_setup;
853 master->transfer = dw_spi_transfer;
858 if (dws->dma_ops && dws->dma_ops->dma_init) {
859 ret = dws->dma_ops->dma_init(dws);
861 dev_warn(&master->dev, "DMA init failed\n");
866 /* Initial and start queue */
867 ret = init_queue(dws);
869 dev_err(&master->dev, "problem initializing queue\n");
872 ret = start_queue(dws);
874 dev_err(&master->dev, "problem starting queue\n");
878 spi_master_set_devdata(master, dws);
879 ret = spi_register_master(master);
881 dev_err(&master->dev, "problem registering spi master\n");
882 goto err_queue_alloc;
885 mrst_spi_debugfs_init(dws);
890 if (dws->dma_ops && dws->dma_ops->dma_exit)
891 dws->dma_ops->dma_exit(dws);
893 spi_enable_chip(dws, 0);
894 free_irq(dws->irq, dws);
896 spi_master_put(master);
900 EXPORT_SYMBOL_GPL(dw_spi_add_host);
902 void __devexit dw_spi_remove_host(struct dw_spi *dws)
908 mrst_spi_debugfs_remove(dws);
910 /* Remove the queue */
911 status = destroy_queue(dws);
913 dev_err(&dws->master->dev, "dw_spi_remove: workqueue will not "
914 "complete, message memory not freed\n");
916 if (dws->dma_ops && dws->dma_ops->dma_exit)
917 dws->dma_ops->dma_exit(dws);
918 spi_enable_chip(dws, 0);
921 free_irq(dws->irq, dws);
923 /* Disconnect from the SPI framework */
924 spi_unregister_master(dws->master);
926 EXPORT_SYMBOL_GPL(dw_spi_remove_host);
928 int dw_spi_suspend_host(struct dw_spi *dws)
932 ret = stop_queue(dws);
935 spi_enable_chip(dws, 0);
939 EXPORT_SYMBOL_GPL(dw_spi_suspend_host);
941 int dw_spi_resume_host(struct dw_spi *dws)
946 ret = start_queue(dws);
948 dev_err(&dws->master->dev, "fail to start queue (%d)\n", ret);
951 EXPORT_SYMBOL_GPL(dw_spi_resume_host);
953 MODULE_AUTHOR("Feng Tang <feng.tang@intel.com>");
954 MODULE_DESCRIPTION("Driver for DesignWare SPI controller core");
955 MODULE_LICENSE("GPL v2");