blob: cf7d8175bf79911562046380c0c953abf53902db [file] [log] [blame]
Mika Westerberg011f23a2010-05-06 04:47:04 +00001/*
2 * Driver for Cirrus Logic EP93xx SPI controller.
3 *
Mika Westerberg626a96d2011-05-29 13:10:06 +03004 * Copyright (C) 2010-2011 Mika Westerberg
Mika Westerberg011f23a2010-05-06 04:47:04 +00005 *
6 * Explicit FIFO handling code was inspired by amba-pl022 driver.
7 *
8 * Chip select support using other than built-in GPIOs by H. Hartley Sweeten.
9 *
10 * For more information about the SPI controller see documentation on Cirrus
11 * Logic web site:
12 * http://www.cirrus.com/en/pubs/manual/EP93xx_Users_Guide_UM1.pdf
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 */
18
19#include <linux/io.h>
20#include <linux/clk.h>
21#include <linux/err.h>
22#include <linux/delay.h>
23#include <linux/device.h>
Mika Westerberg626a96d2011-05-29 13:10:06 +030024#include <linux/dmaengine.h>
Mika Westerberg011f23a2010-05-06 04:47:04 +000025#include <linux/bitops.h>
26#include <linux/interrupt.h>
Mika Westerberg5bdb76132011-10-15 21:40:09 +030027#include <linux/module.h>
Mika Westerberg011f23a2010-05-06 04:47:04 +000028#include <linux/platform_device.h>
Mika Westerberg011f23a2010-05-06 04:47:04 +000029#include <linux/sched.h>
Mika Westerberg626a96d2011-05-29 13:10:06 +030030#include <linux/scatterlist.h>
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -070031#include <linux/gpio.h>
Mika Westerberg011f23a2010-05-06 04:47:04 +000032#include <linux/spi/spi.h>
33
Arnd Bergmanna3b29242012-08-24 15:12:11 +020034#include <linux/platform_data/dma-ep93xx.h>
35#include <linux/platform_data/spi-ep93xx.h>
Mika Westerberg011f23a2010-05-06 04:47:04 +000036
37#define SSPCR0 0x0000
38#define SSPCR0_MODE_SHIFT 6
39#define SSPCR0_SCR_SHIFT 8
40
41#define SSPCR1 0x0004
42#define SSPCR1_RIE BIT(0)
43#define SSPCR1_TIE BIT(1)
44#define SSPCR1_RORIE BIT(2)
45#define SSPCR1_LBM BIT(3)
46#define SSPCR1_SSE BIT(4)
47#define SSPCR1_MS BIT(5)
48#define SSPCR1_SOD BIT(6)
49
50#define SSPDR 0x0008
51
52#define SSPSR 0x000c
53#define SSPSR_TFE BIT(0)
54#define SSPSR_TNF BIT(1)
55#define SSPSR_RNE BIT(2)
56#define SSPSR_RFF BIT(3)
57#define SSPSR_BSY BIT(4)
58#define SSPCPSR 0x0010
59
60#define SSPIIR 0x0014
61#define SSPIIR_RIS BIT(0)
62#define SSPIIR_TIS BIT(1)
63#define SSPIIR_RORIS BIT(2)
64#define SSPICR SSPIIR
65
66/* timeout in milliseconds */
67#define SPI_TIMEOUT 5
68/* maximum depth of RX/TX FIFO */
69#define SPI_FIFO_SIZE 8
70
71/**
72 * struct ep93xx_spi - EP93xx SPI controller structure
Mika Westerberg011f23a2010-05-06 04:47:04 +000073 * @clk: clock for the controller
H Hartley Sweeten12329782017-08-09 08:51:25 +120074 * @mmio: pointer to ioremap()'d registers
Mika Westerberg626a96d2011-05-29 13:10:06 +030075 * @sspdr_phys: physical address of the SSPDR register
Mika Westerberg011f23a2010-05-06 04:47:04 +000076 * @wait: wait here until given transfer is completed
Mika Westerberg011f23a2010-05-06 04:47:04 +000077 * @tx: current byte in transfer to transmit
78 * @rx: current byte in transfer to receive
79 * @fifo_level: how full is FIFO (%0..%SPI_FIFO_SIZE - %1). Receiving one
80 * frame decreases this level and sending one frame increases it.
Mika Westerberg626a96d2011-05-29 13:10:06 +030081 * @dma_rx: RX DMA channel
82 * @dma_tx: TX DMA channel
83 * @dma_rx_data: RX parameters passed to the DMA engine
84 * @dma_tx_data: TX parameters passed to the DMA engine
85 * @rx_sgt: sg table for RX transfers
86 * @tx_sgt: sg table for TX transfers
87 * @zeropage: dummy page used as RX buffer when only TX buffer is passed in by
88 * the client
Mika Westerberg011f23a2010-05-06 04:47:04 +000089 */
90struct ep93xx_spi {
Mika Westerberg011f23a2010-05-06 04:47:04 +000091 struct clk *clk;
H Hartley Sweeten12329782017-08-09 08:51:25 +120092 void __iomem *mmio;
Mika Westerberg626a96d2011-05-29 13:10:06 +030093 unsigned long sspdr_phys;
Mika Westerberg011f23a2010-05-06 04:47:04 +000094 struct completion wait;
Mika Westerberg011f23a2010-05-06 04:47:04 +000095 size_t tx;
96 size_t rx;
97 size_t fifo_level;
Mika Westerberg626a96d2011-05-29 13:10:06 +030098 struct dma_chan *dma_rx;
99 struct dma_chan *dma_tx;
100 struct ep93xx_dma_data dma_rx_data;
101 struct ep93xx_dma_data dma_tx_data;
102 struct sg_table rx_sgt;
103 struct sg_table tx_sgt;
104 void *zeropage;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000105};
106
Mika Westerberg011f23a2010-05-06 04:47:04 +0000107/* converts bits per word to CR0.DSS value */
108#define bits_per_word_to_dss(bpw) ((bpw) - 1)
109
Mika Westerberg011f23a2010-05-06 04:47:04 +0000110/**
111 * ep93xx_spi_calc_divisors() - calculates SPI clock divisors
H Hartley Sweeten48738832017-08-09 08:51:29 +1200112 * @master: SPI master
Mika Westerberg011f23a2010-05-06 04:47:04 +0000113 * @rate: desired SPI output clock rate
H Hartley Sweetenf7ef1da2013-07-02 10:10:29 -0700114 * @div_cpsr: pointer to return the cpsr (pre-scaler) divider
115 * @div_scr: pointer to return the scr divider
Mika Westerberg011f23a2010-05-06 04:47:04 +0000116 */
H Hartley Sweeten48738832017-08-09 08:51:29 +1200117static int ep93xx_spi_calc_divisors(struct spi_master *master,
Axel Lin56fc0b42014-02-08 23:52:26 +0800118 u32 rate, u8 *div_cpsr, u8 *div_scr)
Mika Westerberg011f23a2010-05-06 04:47:04 +0000119{
H Hartley Sweeten48738832017-08-09 08:51:29 +1200120 struct ep93xx_spi *espi = spi_master_get_devdata(master);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000121 unsigned long spi_clk_rate = clk_get_rate(espi->clk);
122 int cpsr, scr;
123
124 /*
125 * Make sure that max value is between values supported by the
126 * controller. Note that minimum value is already checked in
H Hartley Sweeten84ddb3c2013-07-08 09:12:37 -0700127 * ep93xx_spi_transfer_one_message().
Mika Westerberg011f23a2010-05-06 04:47:04 +0000128 */
Axel Lin56fc0b42014-02-08 23:52:26 +0800129 rate = clamp(rate, master->min_speed_hz, master->max_speed_hz);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000130
131 /*
132 * Calculate divisors so that we can get speed according the
133 * following formula:
134 * rate = spi_clock_rate / (cpsr * (1 + scr))
135 *
136 * cpsr must be even number and starts from 2, scr can be any number
137 * between 0 and 255.
138 */
139 for (cpsr = 2; cpsr <= 254; cpsr += 2) {
140 for (scr = 0; scr <= 255; scr++) {
141 if ((spi_clk_rate / (cpsr * (scr + 1))) <= rate) {
H Hartley Sweetenf7ef1da2013-07-02 10:10:29 -0700142 *div_scr = (u8)scr;
143 *div_cpsr = (u8)cpsr;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000144 return 0;
145 }
146 }
147 }
148
149 return -EINVAL;
150}
151
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700152static void ep93xx_spi_cs_control(struct spi_device *spi, bool enable)
Mika Westerberg011f23a2010-05-06 04:47:04 +0000153{
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700154 if (spi->mode & SPI_CS_HIGH)
155 enable = !enable;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000156
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700157 if (gpio_is_valid(spi->cs_gpio))
158 gpio_set_value(spi->cs_gpio, !enable);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000159}
160
H Hartley Sweeten48738832017-08-09 08:51:29 +1200161static int ep93xx_spi_chip_setup(struct spi_master *master,
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700162 struct spi_device *spi,
163 struct spi_transfer *xfer)
Mika Westerberg011f23a2010-05-06 04:47:04 +0000164{
H Hartley Sweeten48738832017-08-09 08:51:29 +1200165 struct ep93xx_spi *espi = spi_master_get_devdata(master);
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700166 u8 dss = bits_per_word_to_dss(xfer->bits_per_word);
H Hartley Sweetenf7ef1da2013-07-02 10:10:29 -0700167 u8 div_cpsr = 0;
168 u8 div_scr = 0;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000169 u16 cr0;
H Hartley Sweetenf7ef1da2013-07-02 10:10:29 -0700170 int err;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000171
H Hartley Sweeten48738832017-08-09 08:51:29 +1200172 err = ep93xx_spi_calc_divisors(master, xfer->speed_hz,
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700173 &div_cpsr, &div_scr);
H Hartley Sweetenf7ef1da2013-07-02 10:10:29 -0700174 if (err)
175 return err;
176
177 cr0 = div_scr << SSPCR0_SCR_SHIFT;
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700178 cr0 |= (spi->mode & (SPI_CPHA | SPI_CPOL)) << SSPCR0_MODE_SHIFT;
H Hartley Sweetend9b65df2013-07-02 10:09:29 -0700179 cr0 |= dss;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000180
H Hartley Sweeten48738832017-08-09 08:51:29 +1200181 dev_dbg(&master->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700182 spi->mode, div_cpsr, div_scr, dss);
H Hartley Sweeten48738832017-08-09 08:51:29 +1200183 dev_dbg(&master->dev, "setup: cr0 %#x\n", cr0);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000184
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200185 writel(div_cpsr, espi->mmio + SSPCPSR);
186 writel(cr0, espi->mmio + SSPCR0);
H Hartley Sweetenf7ef1da2013-07-02 10:10:29 -0700187
188 return 0;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000189}
190
Mika Westerberg011f23a2010-05-06 04:47:04 +0000191static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t)
192{
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200193 u32 val = 0;
194
H Hartley Sweeten701c3582013-07-02 10:07:01 -0700195 if (t->bits_per_word > 8) {
Mika Westerberg011f23a2010-05-06 04:47:04 +0000196 if (t->tx_buf)
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200197 val = ((u16 *)t->tx_buf)[espi->tx];
198 espi->tx += 2;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000199 } else {
Mika Westerberg011f23a2010-05-06 04:47:04 +0000200 if (t->tx_buf)
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200201 val = ((u8 *)t->tx_buf)[espi->tx];
202 espi->tx += 1;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000203 }
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200204 writel(val, espi->mmio + SSPDR);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000205}
206
207static void ep93xx_do_read(struct ep93xx_spi *espi, struct spi_transfer *t)
208{
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200209 u32 val;
210
211 val = readl(espi->mmio + SSPDR);
H Hartley Sweeten701c3582013-07-02 10:07:01 -0700212 if (t->bits_per_word > 8) {
Mika Westerberg011f23a2010-05-06 04:47:04 +0000213 if (t->rx_buf)
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200214 ((u16 *)t->rx_buf)[espi->rx] = val;
215 espi->rx += 2;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000216 } else {
Mika Westerberg011f23a2010-05-06 04:47:04 +0000217 if (t->rx_buf)
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200218 ((u8 *)t->rx_buf)[espi->rx] = val;
219 espi->rx += 1;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000220 }
221}
222
223/**
224 * ep93xx_spi_read_write() - perform next RX/TX transfer
225 * @espi: ep93xx SPI controller struct
226 *
227 * This function transfers next bytes (or half-words) to/from RX/TX FIFOs. If
228 * called several times, the whole transfer will be completed. Returns
229 * %-EINPROGRESS when current transfer was not yet completed otherwise %0.
230 *
231 * When this function is finished, RX FIFO should be empty and TX FIFO should be
232 * full.
233 */
H Hartley Sweeten48738832017-08-09 08:51:29 +1200234static int ep93xx_spi_read_write(struct spi_master *master)
Mika Westerberg011f23a2010-05-06 04:47:04 +0000235{
H Hartley Sweeten48738832017-08-09 08:51:29 +1200236 struct ep93xx_spi *espi = spi_master_get_devdata(master);
H Hartley Sweetenc7a909c2017-08-09 08:51:30 +1200237 struct spi_transfer *t = master->cur_msg->state;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000238
239 /* read as long as RX FIFO has frames in it */
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200240 while ((readl(espi->mmio + SSPSR) & SSPSR_RNE)) {
Mika Westerberg011f23a2010-05-06 04:47:04 +0000241 ep93xx_do_read(espi, t);
242 espi->fifo_level--;
243 }
244
245 /* write as long as TX FIFO has room */
246 while (espi->fifo_level < SPI_FIFO_SIZE && espi->tx < t->len) {
247 ep93xx_do_write(espi, t);
248 espi->fifo_level++;
249 }
250
Mika Westerberg626a96d2011-05-29 13:10:06 +0300251 if (espi->rx == t->len)
Mika Westerberg011f23a2010-05-06 04:47:04 +0000252 return 0;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000253
254 return -EINPROGRESS;
255}
256
H Hartley Sweeten48738832017-08-09 08:51:29 +1200257static void ep93xx_spi_pio_transfer(struct spi_master *master)
Mika Westerberg626a96d2011-05-29 13:10:06 +0300258{
H Hartley Sweeten48738832017-08-09 08:51:29 +1200259 struct ep93xx_spi *espi = spi_master_get_devdata(master);
260
Mika Westerberg626a96d2011-05-29 13:10:06 +0300261 /*
262 * Now everything is set up for the current transfer. We prime the TX
263 * FIFO, enable interrupts, and wait for the transfer to complete.
264 */
H Hartley Sweeten48738832017-08-09 08:51:29 +1200265 if (ep93xx_spi_read_write(master)) {
H Hartley Sweetenac8d06d2017-08-09 08:51:28 +1200266 u32 val;
267
268 val = readl(espi->mmio + SSPCR1);
269 val |= (SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
270 writel(val, espi->mmio + SSPCR1);
271
Mika Westerberg626a96d2011-05-29 13:10:06 +0300272 wait_for_completion(&espi->wait);
273 }
274}
275
276/**
277 * ep93xx_spi_dma_prepare() - prepares a DMA transfer
H Hartley Sweeten48738832017-08-09 08:51:29 +1200278 * @master: SPI master
Mika Westerberg626a96d2011-05-29 13:10:06 +0300279 * @dir: DMA transfer direction
280 *
281 * Function configures the DMA, maps the buffer and prepares the DMA
282 * descriptor. Returns a valid DMA descriptor in case of success and ERR_PTR
283 * in case of failure.
284 */
285static struct dma_async_tx_descriptor *
H Hartley Sweeten48738832017-08-09 08:51:29 +1200286ep93xx_spi_dma_prepare(struct spi_master *master,
287 enum dma_transfer_direction dir)
Mika Westerberg626a96d2011-05-29 13:10:06 +0300288{
H Hartley Sweeten48738832017-08-09 08:51:29 +1200289 struct ep93xx_spi *espi = spi_master_get_devdata(master);
H Hartley Sweetenc7a909c2017-08-09 08:51:30 +1200290 struct spi_transfer *t = master->cur_msg->state;
Mika Westerberg626a96d2011-05-29 13:10:06 +0300291 struct dma_async_tx_descriptor *txd;
292 enum dma_slave_buswidth buswidth;
293 struct dma_slave_config conf;
294 struct scatterlist *sg;
295 struct sg_table *sgt;
296 struct dma_chan *chan;
297 const void *buf, *pbuf;
298 size_t len = t->len;
299 int i, ret, nents;
300
H Hartley Sweeten701c3582013-07-02 10:07:01 -0700301 if (t->bits_per_word > 8)
Mika Westerberg626a96d2011-05-29 13:10:06 +0300302 buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
303 else
304 buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
305
306 memset(&conf, 0, sizeof(conf));
307 conf.direction = dir;
308
H Hartley Sweetend4b9b572012-04-17 18:46:36 -0700309 if (dir == DMA_DEV_TO_MEM) {
Mika Westerberg626a96d2011-05-29 13:10:06 +0300310 chan = espi->dma_rx;
311 buf = t->rx_buf;
312 sgt = &espi->rx_sgt;
313
314 conf.src_addr = espi->sspdr_phys;
315 conf.src_addr_width = buswidth;
316 } else {
317 chan = espi->dma_tx;
318 buf = t->tx_buf;
319 sgt = &espi->tx_sgt;
320
321 conf.dst_addr = espi->sspdr_phys;
322 conf.dst_addr_width = buswidth;
323 }
324
325 ret = dmaengine_slave_config(chan, &conf);
326 if (ret)
327 return ERR_PTR(ret);
328
329 /*
330 * We need to split the transfer into PAGE_SIZE'd chunks. This is
331 * because we are using @espi->zeropage to provide a zero RX buffer
332 * for the TX transfers and we have only allocated one page for that.
333 *
334 * For performance reasons we allocate a new sg_table only when
335 * needed. Otherwise we will re-use the current one. Eventually the
336 * last sg_table is released in ep93xx_spi_release_dma().
337 */
338
339 nents = DIV_ROUND_UP(len, PAGE_SIZE);
340 if (nents != sgt->nents) {
341 sg_free_table(sgt);
342
343 ret = sg_alloc_table(sgt, nents, GFP_KERNEL);
344 if (ret)
345 return ERR_PTR(ret);
346 }
347
348 pbuf = buf;
349 for_each_sg(sgt->sgl, sg, sgt->nents, i) {
350 size_t bytes = min_t(size_t, len, PAGE_SIZE);
351
352 if (buf) {
353 sg_set_page(sg, virt_to_page(pbuf), bytes,
354 offset_in_page(pbuf));
355 } else {
356 sg_set_page(sg, virt_to_page(espi->zeropage),
357 bytes, 0);
358 }
359
360 pbuf += bytes;
361 len -= bytes;
362 }
363
364 if (WARN_ON(len)) {
H Hartley Sweeten48738832017-08-09 08:51:29 +1200365 dev_warn(&master->dev, "len = %zu expected 0!\n", len);
Mika Westerberg626a96d2011-05-29 13:10:06 +0300366 return ERR_PTR(-EINVAL);
367 }
368
369 nents = dma_map_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
370 if (!nents)
371 return ERR_PTR(-ENOMEM);
372
H Hartley Sweetend4b9b572012-04-17 18:46:36 -0700373 txd = dmaengine_prep_slave_sg(chan, sgt->sgl, nents, dir, DMA_CTRL_ACK);
Mika Westerberg626a96d2011-05-29 13:10:06 +0300374 if (!txd) {
375 dma_unmap_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
376 return ERR_PTR(-ENOMEM);
377 }
378 return txd;
379}
380
381/**
382 * ep93xx_spi_dma_finish() - finishes with a DMA transfer
H Hartley Sweeten48738832017-08-09 08:51:29 +1200383 * @master: SPI master
Mika Westerberg626a96d2011-05-29 13:10:06 +0300384 * @dir: DMA transfer direction
385 *
386 * Function finishes with the DMA transfer. After this, the DMA buffer is
387 * unmapped.
388 */
H Hartley Sweeten48738832017-08-09 08:51:29 +1200389static void ep93xx_spi_dma_finish(struct spi_master *master,
H Hartley Sweetend4b9b572012-04-17 18:46:36 -0700390 enum dma_transfer_direction dir)
Mika Westerberg626a96d2011-05-29 13:10:06 +0300391{
H Hartley Sweeten48738832017-08-09 08:51:29 +1200392 struct ep93xx_spi *espi = spi_master_get_devdata(master);
Mika Westerberg626a96d2011-05-29 13:10:06 +0300393 struct dma_chan *chan;
394 struct sg_table *sgt;
395
H Hartley Sweetend4b9b572012-04-17 18:46:36 -0700396 if (dir == DMA_DEV_TO_MEM) {
Mika Westerberg626a96d2011-05-29 13:10:06 +0300397 chan = espi->dma_rx;
398 sgt = &espi->rx_sgt;
399 } else {
400 chan = espi->dma_tx;
401 sgt = &espi->tx_sgt;
402 }
403
404 dma_unmap_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
405}
406
407static void ep93xx_spi_dma_callback(void *callback_param)
408{
409 complete(callback_param);
410}
411
H Hartley Sweeten48738832017-08-09 08:51:29 +1200412static void ep93xx_spi_dma_transfer(struct spi_master *master)
Mika Westerberg626a96d2011-05-29 13:10:06 +0300413{
H Hartley Sweeten48738832017-08-09 08:51:29 +1200414 struct ep93xx_spi *espi = spi_master_get_devdata(master);
Mika Westerberg626a96d2011-05-29 13:10:06 +0300415 struct dma_async_tx_descriptor *rxd, *txd;
416
H Hartley Sweeten48738832017-08-09 08:51:29 +1200417 rxd = ep93xx_spi_dma_prepare(master, DMA_DEV_TO_MEM);
Mika Westerberg626a96d2011-05-29 13:10:06 +0300418 if (IS_ERR(rxd)) {
H Hartley Sweeten48738832017-08-09 08:51:29 +1200419 dev_err(&master->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd));
H Hartley Sweetenc7a909c2017-08-09 08:51:30 +1200420 master->cur_msg->status = PTR_ERR(rxd);
Mika Westerberg626a96d2011-05-29 13:10:06 +0300421 return;
422 }
423
H Hartley Sweeten48738832017-08-09 08:51:29 +1200424 txd = ep93xx_spi_dma_prepare(master, DMA_MEM_TO_DEV);
Mika Westerberg626a96d2011-05-29 13:10:06 +0300425 if (IS_ERR(txd)) {
H Hartley Sweeten48738832017-08-09 08:51:29 +1200426 ep93xx_spi_dma_finish(master, DMA_DEV_TO_MEM);
427 dev_err(&master->dev, "DMA TX failed: %ld\n", PTR_ERR(txd));
H Hartley Sweetenc7a909c2017-08-09 08:51:30 +1200428 master->cur_msg->status = PTR_ERR(txd);
Mika Westerberg626a96d2011-05-29 13:10:06 +0300429 return;
430 }
431
432 /* We are ready when RX is done */
433 rxd->callback = ep93xx_spi_dma_callback;
434 rxd->callback_param = &espi->wait;
435
436 /* Now submit both descriptors and wait while they finish */
437 dmaengine_submit(rxd);
438 dmaengine_submit(txd);
439
440 dma_async_issue_pending(espi->dma_rx);
441 dma_async_issue_pending(espi->dma_tx);
442
443 wait_for_completion(&espi->wait);
444
H Hartley Sweeten48738832017-08-09 08:51:29 +1200445 ep93xx_spi_dma_finish(master, DMA_MEM_TO_DEV);
446 ep93xx_spi_dma_finish(master, DMA_DEV_TO_MEM);
Mika Westerberg626a96d2011-05-29 13:10:06 +0300447}
448
Mika Westerberg011f23a2010-05-06 04:47:04 +0000449/**
450 * ep93xx_spi_process_transfer() - processes one SPI transfer
H Hartley Sweeten48738832017-08-09 08:51:29 +1200451 * @master: SPI master
Mika Westerberg011f23a2010-05-06 04:47:04 +0000452 * @msg: current message
453 * @t: transfer to process
454 *
455 * This function processes one SPI transfer given in @t. Function waits until
456 * transfer is complete (may sleep) and updates @msg->status based on whether
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300457 * transfer was successfully processed or not.
Mika Westerberg011f23a2010-05-06 04:47:04 +0000458 */
H Hartley Sweeten48738832017-08-09 08:51:29 +1200459static void ep93xx_spi_process_transfer(struct spi_master *master,
Mika Westerberg011f23a2010-05-06 04:47:04 +0000460 struct spi_message *msg,
461 struct spi_transfer *t)
462{
H Hartley Sweeten48738832017-08-09 08:51:29 +1200463 struct ep93xx_spi *espi = spi_master_get_devdata(master);
H Hartley Sweeten4870c212013-06-28 11:43:34 -0700464 int err;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000465
466 msg->state = t;
467
H Hartley Sweeten48738832017-08-09 08:51:29 +1200468 err = ep93xx_spi_chip_setup(master, msg->spi, t);
H Hartley Sweeten4870c212013-06-28 11:43:34 -0700469 if (err) {
H Hartley Sweeten48738832017-08-09 08:51:29 +1200470 dev_err(&master->dev,
H Hartley Sweetenf7ef1da2013-07-02 10:10:29 -0700471 "failed to setup chip for transfer\n");
H Hartley Sweeten4870c212013-06-28 11:43:34 -0700472 msg->status = err;
473 return;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000474 }
475
476 espi->rx = 0;
477 espi->tx = 0;
478
479 /*
Mika Westerberg626a96d2011-05-29 13:10:06 +0300480 * There is no point of setting up DMA for the transfers which will
481 * fit into the FIFO and can be transferred with a single interrupt.
482 * So in these cases we will be using PIO and don't bother for DMA.
Mika Westerberg011f23a2010-05-06 04:47:04 +0000483 */
Mika Westerberg626a96d2011-05-29 13:10:06 +0300484 if (espi->dma_rx && t->len > SPI_FIFO_SIZE)
H Hartley Sweeten48738832017-08-09 08:51:29 +1200485 ep93xx_spi_dma_transfer(master);
Mika Westerberg626a96d2011-05-29 13:10:06 +0300486 else
H Hartley Sweeten48738832017-08-09 08:51:29 +1200487 ep93xx_spi_pio_transfer(master);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000488
489 /*
490 * In case of error during transmit, we bail out from processing
491 * the message.
492 */
493 if (msg->status)
494 return;
495
Mika Westerberg626a96d2011-05-29 13:10:06 +0300496 msg->actual_length += t->len;
497
Mika Westerberg011f23a2010-05-06 04:47:04 +0000498 /*
499 * After this transfer is finished, perform any possible
500 * post-transfer actions requested by the protocol driver.
501 */
502 if (t->delay_usecs) {
503 set_current_state(TASK_UNINTERRUPTIBLE);
504 schedule_timeout(usecs_to_jiffies(t->delay_usecs));
505 }
506 if (t->cs_change) {
507 if (!list_is_last(&t->transfer_list, &msg->transfers)) {
508 /*
509 * In case protocol driver is asking us to drop the
510 * chipselect briefly, we let the scheduler to handle
511 * any "delay" here.
512 */
513 ep93xx_spi_cs_control(msg->spi, false);
514 cond_resched();
515 ep93xx_spi_cs_control(msg->spi, true);
516 }
517 }
Mika Westerberg011f23a2010-05-06 04:47:04 +0000518}
519
520/*
521 * ep93xx_spi_process_message() - process one SPI message
H Hartley Sweeten48738832017-08-09 08:51:29 +1200522 * @master: SPI master
Mika Westerberg011f23a2010-05-06 04:47:04 +0000523 * @msg: message to process
524 *
525 * This function processes a single SPI message. We go through all transfers in
526 * the message and pass them to ep93xx_spi_process_transfer(). Chipselect is
527 * asserted during the whole message (unless per transfer cs_change is set).
528 *
529 * @msg->status contains %0 in case of success or negative error code in case of
530 * failure.
531 */
H Hartley Sweeten48738832017-08-09 08:51:29 +1200532static void ep93xx_spi_process_message(struct spi_master *master,
Mika Westerberg011f23a2010-05-06 04:47:04 +0000533 struct spi_message *msg)
534{
H Hartley Sweeten48738832017-08-09 08:51:29 +1200535 struct ep93xx_spi *espi = spi_master_get_devdata(master);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000536 unsigned long timeout;
537 struct spi_transfer *t;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000538
539 /*
540 * Just to be sure: flush any data from RX FIFO.
541 */
542 timeout = jiffies + msecs_to_jiffies(SPI_TIMEOUT);
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200543 while (readl(espi->mmio + SSPSR) & SSPSR_RNE) {
Mika Westerberg011f23a2010-05-06 04:47:04 +0000544 if (time_after(jiffies, timeout)) {
H Hartley Sweeten48738832017-08-09 08:51:29 +1200545 dev_warn(&master->dev,
Mika Westerberg011f23a2010-05-06 04:47:04 +0000546 "timeout while flushing RX FIFO\n");
547 msg->status = -ETIMEDOUT;
548 return;
549 }
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200550 readl(espi->mmio + SSPDR);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000551 }
552
553 /*
554 * We explicitly handle FIFO level. This way we don't have to check TX
555 * FIFO status using %SSPSR_TNF bit which may cause RX FIFO overruns.
556 */
557 espi->fifo_level = 0;
558
559 /*
H Hartley Sweeten4870c212013-06-28 11:43:34 -0700560 * Assert the chipselect.
Mika Westerberg011f23a2010-05-06 04:47:04 +0000561 */
Mika Westerberg011f23a2010-05-06 04:47:04 +0000562 ep93xx_spi_cs_control(msg->spi, true);
563
564 list_for_each_entry(t, &msg->transfers, transfer_list) {
H Hartley Sweeten48738832017-08-09 08:51:29 +1200565 ep93xx_spi_process_transfer(master, msg, t);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000566 if (msg->status)
567 break;
568 }
569
570 /*
571 * Now the whole message is transferred (or failed for some reason). We
572 * deselect the device and disable the SPI controller.
573 */
574 ep93xx_spi_cs_control(msg->spi, false);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000575}
576
H Hartley Sweeten84ddb3c2013-07-08 09:12:37 -0700577static int ep93xx_spi_transfer_one_message(struct spi_master *master,
578 struct spi_message *msg)
Mika Westerberg011f23a2010-05-06 04:47:04 +0000579{
H Hartley Sweeten84ddb3c2013-07-08 09:12:37 -0700580 struct ep93xx_spi *espi = spi_master_get_devdata(master);
H Hartley Sweeten84ddb3c2013-07-08 09:12:37 -0700581
582 msg->state = NULL;
583 msg->status = 0;
584 msg->actual_length = 0;
585
H Hartley Sweeten48738832017-08-09 08:51:29 +1200586 ep93xx_spi_process_message(master, msg);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000587
H Hartley Sweeten84ddb3c2013-07-08 09:12:37 -0700588 spi_finalize_current_message(master);
589
590 return 0;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000591}
592
593static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
594{
H Hartley Sweeten48738832017-08-09 08:51:29 +1200595 struct spi_master *master = dev_id;
596 struct ep93xx_spi *espi = spi_master_get_devdata(master);
H Hartley Sweetenac8d06d2017-08-09 08:51:28 +1200597 u32 val;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000598
599 /*
600 * If we got ROR (receive overrun) interrupt we know that something is
601 * wrong. Just abort the message.
602 */
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200603 if (readl(espi->mmio + SSPIIR) & SSPIIR_RORIS) {
Mika Westerberg011f23a2010-05-06 04:47:04 +0000604 /* clear the overrun interrupt */
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200605 writel(0, espi->mmio + SSPICR);
H Hartley Sweeten48738832017-08-09 08:51:29 +1200606 dev_warn(&master->dev,
Mika Westerberg011f23a2010-05-06 04:47:04 +0000607 "receive overrun, aborting the message\n");
H Hartley Sweetenc7a909c2017-08-09 08:51:30 +1200608 master->cur_msg->status = -EIO;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000609 } else {
610 /*
611 * Interrupt is either RX (RIS) or TX (TIS). For both cases we
612 * simply execute next data transfer.
613 */
H Hartley Sweeten48738832017-08-09 08:51:29 +1200614 if (ep93xx_spi_read_write(master)) {
Mika Westerberg011f23a2010-05-06 04:47:04 +0000615 /*
616 * In normal case, there still is some processing left
617 * for current transfer. Let's wait for the next
618 * interrupt then.
619 */
620 return IRQ_HANDLED;
621 }
622 }
623
624 /*
625 * Current transfer is finished, either with error or with success. In
626 * any case we disable interrupts and notify the worker to handle
627 * any post-processing of the message.
628 */
H Hartley Sweetenac8d06d2017-08-09 08:51:28 +1200629 val = readl(espi->mmio + SSPCR1);
630 val &= ~(SSPCR1_RORIE | SSPCR1_TIE | SSPCR1_RIE);
631 writel(val, espi->mmio + SSPCR1);
632
Mika Westerberg011f23a2010-05-06 04:47:04 +0000633 complete(&espi->wait);
H Hartley Sweetenac8d06d2017-08-09 08:51:28 +1200634
Mika Westerberg011f23a2010-05-06 04:47:04 +0000635 return IRQ_HANDLED;
636}
637
H Hartley Sweeten16779622017-08-09 08:51:27 +1200638static int ep93xx_spi_prepare_hardware(struct spi_master *master)
639{
640 struct ep93xx_spi *espi = spi_master_get_devdata(master);
641 u32 val;
642 int ret;
643
644 ret = clk_enable(espi->clk);
645 if (ret)
646 return ret;
647
648 val = readl(espi->mmio + SSPCR1);
649 val |= SSPCR1_SSE;
650 writel(val, espi->mmio + SSPCR1);
651
652 return 0;
653}
654
655static int ep93xx_spi_unprepare_hardware(struct spi_master *master)
656{
657 struct ep93xx_spi *espi = spi_master_get_devdata(master);
658 u32 val;
659
660 val = readl(espi->mmio + SSPCR1);
661 val &= ~SSPCR1_SSE;
662 writel(val, espi->mmio + SSPCR1);
663
664 clk_disable(espi->clk);
665
666 return 0;
667}
668
Mika Westerberg626a96d2011-05-29 13:10:06 +0300669static bool ep93xx_spi_dma_filter(struct dma_chan *chan, void *filter_param)
670{
671 if (ep93xx_dma_chan_is_m2p(chan))
672 return false;
673
674 chan->private = filter_param;
675 return true;
676}
677
678static int ep93xx_spi_setup_dma(struct ep93xx_spi *espi)
679{
680 dma_cap_mask_t mask;
681 int ret;
682
683 espi->zeropage = (void *)get_zeroed_page(GFP_KERNEL);
684 if (!espi->zeropage)
685 return -ENOMEM;
686
687 dma_cap_zero(mask);
688 dma_cap_set(DMA_SLAVE, mask);
689
690 espi->dma_rx_data.port = EP93XX_DMA_SSP;
Vinod Koula485df42011-10-14 10:47:38 +0530691 espi->dma_rx_data.direction = DMA_DEV_TO_MEM;
Mika Westerberg626a96d2011-05-29 13:10:06 +0300692 espi->dma_rx_data.name = "ep93xx-spi-rx";
693
694 espi->dma_rx = dma_request_channel(mask, ep93xx_spi_dma_filter,
695 &espi->dma_rx_data);
696 if (!espi->dma_rx) {
697 ret = -ENODEV;
698 goto fail_free_page;
699 }
700
701 espi->dma_tx_data.port = EP93XX_DMA_SSP;
Vinod Koula485df42011-10-14 10:47:38 +0530702 espi->dma_tx_data.direction = DMA_MEM_TO_DEV;
Mika Westerberg626a96d2011-05-29 13:10:06 +0300703 espi->dma_tx_data.name = "ep93xx-spi-tx";
704
705 espi->dma_tx = dma_request_channel(mask, ep93xx_spi_dma_filter,
706 &espi->dma_tx_data);
707 if (!espi->dma_tx) {
708 ret = -ENODEV;
709 goto fail_release_rx;
710 }
711
712 return 0;
713
714fail_release_rx:
715 dma_release_channel(espi->dma_rx);
716 espi->dma_rx = NULL;
717fail_free_page:
718 free_page((unsigned long)espi->zeropage);
719
720 return ret;
721}
722
723static void ep93xx_spi_release_dma(struct ep93xx_spi *espi)
724{
725 if (espi->dma_rx) {
726 dma_release_channel(espi->dma_rx);
727 sg_free_table(&espi->rx_sgt);
728 }
729 if (espi->dma_tx) {
730 dma_release_channel(espi->dma_tx);
731 sg_free_table(&espi->tx_sgt);
732 }
733
734 if (espi->zeropage)
735 free_page((unsigned long)espi->zeropage);
736}
737
Grant Likelyfd4a3192012-12-07 16:57:14 +0000738static int ep93xx_spi_probe(struct platform_device *pdev)
Mika Westerberg011f23a2010-05-06 04:47:04 +0000739{
740 struct spi_master *master;
741 struct ep93xx_spi_info *info;
742 struct ep93xx_spi *espi;
743 struct resource *res;
Hannu Heikkinen6d6467e2012-05-09 17:26:26 +0300744 int irq;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000745 int error;
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700746 int i;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000747
Jingoo Han8074cf02013-07-30 16:58:59 +0900748 info = dev_get_platdata(&pdev->dev);
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700749 if (!info) {
750 dev_err(&pdev->dev, "missing platform data\n");
751 return -EINVAL;
752 }
Mika Westerberg011f23a2010-05-06 04:47:04 +0000753
H Hartley Sweeten48a77762013-07-02 10:07:53 -0700754 irq = platform_get_irq(pdev, 0);
755 if (irq < 0) {
756 dev_err(&pdev->dev, "failed to get irq resources\n");
757 return -EBUSY;
758 }
759
760 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
761 if (!res) {
762 dev_err(&pdev->dev, "unable to get iomem resource\n");
763 return -ENODEV;
764 }
765
Mika Westerberg011f23a2010-05-06 04:47:04 +0000766 master = spi_alloc_master(&pdev->dev, sizeof(*espi));
H Hartley Sweetenb2d185e2013-07-02 10:08:59 -0700767 if (!master)
Mika Westerberg011f23a2010-05-06 04:47:04 +0000768 return -ENOMEM;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000769
H Hartley Sweeten16779622017-08-09 08:51:27 +1200770 master->prepare_transfer_hardware = ep93xx_spi_prepare_hardware;
771 master->unprepare_transfer_hardware = ep93xx_spi_unprepare_hardware;
H Hartley Sweeten84ddb3c2013-07-08 09:12:37 -0700772 master->transfer_one_message = ep93xx_spi_transfer_one_message;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000773 master->bus_num = pdev->id;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000774 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
Stephen Warren24778be2013-05-21 20:36:35 -0600775 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000776
H Hartley Sweeten55f0cd3f2017-02-16 13:07:37 -0700777 master->num_chipselect = info->num_chipselect;
778 master->cs_gpios = devm_kzalloc(&master->dev,
779 sizeof(int) * master->num_chipselect,
780 GFP_KERNEL);
781 if (!master->cs_gpios) {
782 error = -ENOMEM;
783 goto fail_release_master;
784 }
785
786 for (i = 0; i < master->num_chipselect; i++) {
787 master->cs_gpios[i] = info->chipselect[i];
788
789 if (!gpio_is_valid(master->cs_gpios[i]))
790 continue;
791
792 error = devm_gpio_request_one(&pdev->dev, master->cs_gpios[i],
793 GPIOF_OUT_INIT_HIGH,
794 "ep93xx-spi");
795 if (error) {
796 dev_err(&pdev->dev, "could not request cs gpio %d\n",
797 master->cs_gpios[i]);
798 goto fail_release_master;
799 }
800 }
801
Mika Westerberg011f23a2010-05-06 04:47:04 +0000802 platform_set_drvdata(pdev, master);
803
804 espi = spi_master_get_devdata(master);
805
H Hartley Sweetene6eb8d92013-07-02 10:08:21 -0700806 espi->clk = devm_clk_get(&pdev->dev, NULL);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000807 if (IS_ERR(espi->clk)) {
808 dev_err(&pdev->dev, "unable to get spi clock\n");
809 error = PTR_ERR(espi->clk);
810 goto fail_release_master;
811 }
812
Mika Westerberg011f23a2010-05-06 04:47:04 +0000813 init_completion(&espi->wait);
814
815 /*
816 * Calculate maximum and minimum supported clock rates
817 * for the controller.
818 */
Axel Lin56fc0b42014-02-08 23:52:26 +0800819 master->max_speed_hz = clk_get_rate(espi->clk) / 2;
820 master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000821
Mika Westerberg626a96d2011-05-29 13:10:06 +0300822 espi->sspdr_phys = res->start + SSPDR;
Hannu Heikkinen6d6467e2012-05-09 17:26:26 +0300823
H Hartley Sweeten12329782017-08-09 08:51:25 +1200824 espi->mmio = devm_ioremap_resource(&pdev->dev, res);
825 if (IS_ERR(espi->mmio)) {
826 error = PTR_ERR(espi->mmio);
H Hartley Sweetene6eb8d92013-07-02 10:08:21 -0700827 goto fail_release_master;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000828 }
829
Hannu Heikkinen6d6467e2012-05-09 17:26:26 +0300830 error = devm_request_irq(&pdev->dev, irq, ep93xx_spi_interrupt,
H Hartley Sweeten48738832017-08-09 08:51:29 +1200831 0, "ep93xx-spi", master);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000832 if (error) {
833 dev_err(&pdev->dev, "failed to request irq\n");
H Hartley Sweetene6eb8d92013-07-02 10:08:21 -0700834 goto fail_release_master;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000835 }
836
Mika Westerberg626a96d2011-05-29 13:10:06 +0300837 if (info->use_dma && ep93xx_spi_setup_dma(espi))
838 dev_warn(&pdev->dev, "DMA setup failed. Falling back to PIO\n");
839
Mika Westerberg011f23a2010-05-06 04:47:04 +0000840 /* make sure that the hardware is disabled */
H Hartley Sweeten8447e472017-08-09 08:51:26 +1200841 writel(0, espi->mmio + SSPCR1);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000842
Jingoo Han434eaf32013-09-24 13:30:41 +0900843 error = devm_spi_register_master(&pdev->dev, master);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000844 if (error) {
845 dev_err(&pdev->dev, "failed to register SPI master\n");
H Hartley Sweeten84ddb3c2013-07-08 09:12:37 -0700846 goto fail_free_dma;
Mika Westerberg011f23a2010-05-06 04:47:04 +0000847 }
848
849 dev_info(&pdev->dev, "EP93xx SPI Controller at 0x%08lx irq %d\n",
Hannu Heikkinen6d6467e2012-05-09 17:26:26 +0300850 (unsigned long)res->start, irq);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000851
852 return 0;
853
Mika Westerberg626a96d2011-05-29 13:10:06 +0300854fail_free_dma:
855 ep93xx_spi_release_dma(espi);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000856fail_release_master:
857 spi_master_put(master);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000858
859 return error;
860}
861
Grant Likelyfd4a3192012-12-07 16:57:14 +0000862static int ep93xx_spi_remove(struct platform_device *pdev)
Mika Westerberg011f23a2010-05-06 04:47:04 +0000863{
864 struct spi_master *master = platform_get_drvdata(pdev);
865 struct ep93xx_spi *espi = spi_master_get_devdata(master);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000866
Mika Westerberg626a96d2011-05-29 13:10:06 +0300867 ep93xx_spi_release_dma(espi);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000868
Mika Westerberg011f23a2010-05-06 04:47:04 +0000869 return 0;
870}
871
872static struct platform_driver ep93xx_spi_driver = {
873 .driver = {
874 .name = "ep93xx-spi",
Mika Westerberg011f23a2010-05-06 04:47:04 +0000875 },
Grant Likely940ab882011-10-05 11:29:49 -0600876 .probe = ep93xx_spi_probe,
Grant Likelyfd4a3192012-12-07 16:57:14 +0000877 .remove = ep93xx_spi_remove,
Mika Westerberg011f23a2010-05-06 04:47:04 +0000878};
Grant Likely940ab882011-10-05 11:29:49 -0600879module_platform_driver(ep93xx_spi_driver);
Mika Westerberg011f23a2010-05-06 04:47:04 +0000880
881MODULE_DESCRIPTION("EP93xx SPI Controller driver");
882MODULE_AUTHOR("Mika Westerberg <mika.westerberg@iki.fi>");
883MODULE_LICENSE("GPL");
884MODULE_ALIAS("platform:ep93xx-spi");