diff options
Diffstat (limited to 'drivers/spi/spi-dw.c')
-rw-r--r-- | drivers/spi/spi-dw.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index 33117fbbf689..729215885250 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c | |||
@@ -11,10 +11,6 @@ | |||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
13 | * more details. | 13 | * more details. |
14 | * | ||
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. | ||
18 | */ | 14 | */ |
19 | 15 | ||
20 | #include <linux/dma-mapping.h> | 16 | #include <linux/dma-mapping.h> |
@@ -59,22 +55,20 @@ struct chip_data { | |||
59 | 55 | ||
60 | #ifdef CONFIG_DEBUG_FS | 56 | #ifdef CONFIG_DEBUG_FS |
61 | #define SPI_REGS_BUFSIZE 1024 | 57 | #define SPI_REGS_BUFSIZE 1024 |
62 | static ssize_t spi_show_regs(struct file *file, char __user *user_buf, | 58 | static ssize_t dw_spi_show_regs(struct file *file, char __user *user_buf, |
63 | size_t count, loff_t *ppos) | 59 | size_t count, loff_t *ppos) |
64 | { | 60 | { |
65 | struct dw_spi *dws; | 61 | struct dw_spi *dws = file->private_data; |
66 | char *buf; | 62 | char *buf; |
67 | u32 len = 0; | 63 | u32 len = 0; |
68 | ssize_t ret; | 64 | ssize_t ret; |
69 | 65 | ||
70 | dws = file->private_data; | ||
71 | |||
72 | buf = kzalloc(SPI_REGS_BUFSIZE, GFP_KERNEL); | 66 | buf = kzalloc(SPI_REGS_BUFSIZE, GFP_KERNEL); |
73 | if (!buf) | 67 | if (!buf) |
74 | return 0; | 68 | return 0; |
75 | 69 | ||
76 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | 70 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
77 | "MRST SPI0 registers:\n"); | 71 | "%s registers:\n", dev_name(&dws->master->dev)); |
78 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | 72 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
79 | "=================================\n"); | 73 | "=================================\n"); |
80 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | 74 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
@@ -110,41 +104,41 @@ static ssize_t spi_show_regs(struct file *file, char __user *user_buf, | |||
110 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, | 104 | len += snprintf(buf + len, SPI_REGS_BUFSIZE - len, |
111 | "=================================\n"); | 105 | "=================================\n"); |
112 | 106 | ||
113 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); | 107 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); |
114 | kfree(buf); | 108 | kfree(buf); |
115 | return ret; | 109 | return ret; |
116 | } | 110 | } |
117 | 111 | ||
118 | static const struct file_operations mrst_spi_regs_ops = { | 112 | static const struct file_operations dw_spi_regs_ops = { |
119 | .owner = THIS_MODULE, | 113 | .owner = THIS_MODULE, |
120 | .open = simple_open, | 114 | .open = simple_open, |
121 | .read = spi_show_regs, | 115 | .read = dw_spi_show_regs, |
122 | .llseek = default_llseek, | 116 | .llseek = default_llseek, |
123 | }; | 117 | }; |
124 | 118 | ||
125 | static int mrst_spi_debugfs_init(struct dw_spi *dws) | 119 | static int dw_spi_debugfs_init(struct dw_spi *dws) |
126 | { | 120 | { |
127 | dws->debugfs = debugfs_create_dir("mrst_spi", NULL); | 121 | dws->debugfs = debugfs_create_dir("dw_spi", NULL); |
128 | if (!dws->debugfs) | 122 | if (!dws->debugfs) |
129 | return -ENOMEM; | 123 | return -ENOMEM; |
130 | 124 | ||
131 | debugfs_create_file("registers", S_IFREG | S_IRUGO, | 125 | debugfs_create_file("registers", S_IFREG | S_IRUGO, |
132 | dws->debugfs, (void *)dws, &mrst_spi_regs_ops); | 126 | dws->debugfs, (void *)dws, &dw_spi_regs_ops); |
133 | return 0; | 127 | return 0; |
134 | } | 128 | } |
135 | 129 | ||
136 | static void mrst_spi_debugfs_remove(struct dw_spi *dws) | 130 | static void dw_spi_debugfs_remove(struct dw_spi *dws) |
137 | { | 131 | { |
138 | debugfs_remove_recursive(dws->debugfs); | 132 | debugfs_remove_recursive(dws->debugfs); |
139 | } | 133 | } |
140 | 134 | ||
141 | #else | 135 | #else |
142 | static inline int mrst_spi_debugfs_init(struct dw_spi *dws) | 136 | static inline int dw_spi_debugfs_init(struct dw_spi *dws) |
143 | { | 137 | { |
144 | return 0; | 138 | return 0; |
145 | } | 139 | } |
146 | 140 | ||
147 | static inline void mrst_spi_debugfs_remove(struct dw_spi *dws) | 141 | static inline void dw_spi_debugfs_remove(struct dw_spi *dws) |
148 | { | 142 | { |
149 | } | 143 | } |
150 | #endif /* CONFIG_DEBUG_FS */ | 144 | #endif /* CONFIG_DEBUG_FS */ |
@@ -396,7 +390,7 @@ static void pump_transfers(unsigned long data) | |||
396 | goto early_exit; | 390 | goto early_exit; |
397 | } | 391 | } |
398 | 392 | ||
399 | /* Delay if requested at end of transfer*/ | 393 | /* Delay if requested at end of transfer */ |
400 | if (message->state == RUNNING_STATE) { | 394 | if (message->state == RUNNING_STATE) { |
401 | previous = list_entry(transfer->transfer_list.prev, | 395 | previous = list_entry(transfer->transfer_list.prev, |
402 | struct spi_transfer, | 396 | struct spi_transfer, |
@@ -525,7 +519,7 @@ static int dw_spi_transfer_one_message(struct spi_master *master, | |||
525 | struct dw_spi *dws = spi_master_get_devdata(master); | 519 | struct dw_spi *dws = spi_master_get_devdata(master); |
526 | 520 | ||
527 | dws->cur_msg = msg; | 521 | dws->cur_msg = msg; |
528 | /* Initial message state*/ | 522 | /* Initial message state */ |
529 | dws->cur_msg->state = START_STATE; | 523 | dws->cur_msg->state = START_STATE; |
530 | dws->cur_transfer = list_entry(dws->cur_msg->transfers.next, | 524 | dws->cur_transfer = list_entry(dws->cur_msg->transfers.next, |
531 | struct spi_transfer, | 525 | struct spi_transfer, |
@@ -596,6 +590,9 @@ static int dw_spi_setup(struct spi_device *spi) | |||
596 | | (spi->mode << SPI_MODE_OFFSET) | 590 | | (spi->mode << SPI_MODE_OFFSET) |
597 | | (chip->tmode << SPI_TMOD_OFFSET); | 591 | | (chip->tmode << SPI_TMOD_OFFSET); |
598 | 592 | ||
593 | if (spi->mode & SPI_LOOP) | ||
594 | chip->cr0 |= 1 << SPI_SRL_OFFSET; | ||
595 | |||
599 | if (gpio_is_valid(spi->cs_gpio)) { | 596 | if (gpio_is_valid(spi->cs_gpio)) { |
600 | ret = gpio_direction_output(spi->cs_gpio, | 597 | ret = gpio_direction_output(spi->cs_gpio, |
601 | !(spi->mode & SPI_CS_HIGH)); | 598 | !(spi->mode & SPI_CS_HIGH)); |
@@ -655,8 +652,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) | |||
655 | dws->prev_chip = NULL; | 652 | dws->prev_chip = NULL; |
656 | dws->dma_inited = 0; | 653 | dws->dma_inited = 0; |
657 | dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60); | 654 | dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60); |
658 | snprintf(dws->name, sizeof(dws->name), "dw_spi%d", | 655 | snprintf(dws->name, sizeof(dws->name), "dw_spi%d", dws->bus_num); |
659 | dws->bus_num); | ||
660 | 656 | ||
661 | ret = devm_request_irq(dev, dws->irq, dw_spi_irq, IRQF_SHARED, | 657 | ret = devm_request_irq(dev, dws->irq, dw_spi_irq, IRQF_SHARED, |
662 | dws->name, dws); | 658 | dws->name, dws); |
@@ -665,7 +661,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) | |||
665 | goto err_free_master; | 661 | goto err_free_master; |
666 | } | 662 | } |
667 | 663 | ||
668 | master->mode_bits = SPI_CPOL | SPI_CPHA; | 664 | master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP; |
669 | master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16); | 665 | master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16); |
670 | master->bus_num = dws->bus_num; | 666 | master->bus_num = dws->bus_num; |
671 | master->num_chipselect = dws->num_cs; | 667 | master->num_chipselect = dws->num_cs; |
@@ -694,7 +690,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) | |||
694 | goto err_dma_exit; | 690 | goto err_dma_exit; |
695 | } | 691 | } |
696 | 692 | ||
697 | mrst_spi_debugfs_init(dws); | 693 | dw_spi_debugfs_init(dws); |
698 | return 0; | 694 | return 0; |
699 | 695 | ||
700 | err_dma_exit: | 696 | err_dma_exit: |
@@ -711,7 +707,7 @@ void dw_spi_remove_host(struct dw_spi *dws) | |||
711 | { | 707 | { |
712 | if (!dws) | 708 | if (!dws) |
713 | return; | 709 | return; |
714 | mrst_spi_debugfs_remove(dws); | 710 | dw_spi_debugfs_remove(dws); |
715 | 711 | ||
716 | if (dws->dma_ops && dws->dma_ops->dma_exit) | 712 | if (dws->dma_ops && dws->dma_ops->dma_exit) |
717 | dws->dma_ops->dma_exit(dws); | 713 | dws->dma_ops->dma_exit(dws); |