blob: 615a84c8ccdac9e588cf65a86953b961118f475f [file] [log] [blame]
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -07001/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright (C) 2008 Juergen Beisert
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation
17 * 51 Franklin Street, Fifth Floor
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include <linux/clk.h>
22#include <linux/completion.h>
23#include <linux/delay.h>
24#include <linux/err.h>
25#include <linux/gpio.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/io.h>
29#include <linux/irq.h>
30#include <linux/kernel.h>
31#include <linux/module.h>
32#include <linux/platform_device.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090033#include <linux/slab.h>
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -070034#include <linux/spi/spi.h>
35#include <linux/spi/spi_bitbang.h>
36#include <linux/types.h>
37
38#include <mach/spi.h>
39
40#define DRIVER_NAME "spi_imx"
41
42#define MXC_CSPIRXDATA 0x00
43#define MXC_CSPITXDATA 0x04
44#define MXC_CSPICTRL 0x08
45#define MXC_CSPIINT 0x0c
46#define MXC_RESET 0x1c
47
48/* generic defines to abstract from the different register layouts */
49#define MXC_INT_RR (1 << 0) /* Receive data ready interrupt */
50#define MXC_INT_TE (1 << 1) /* Transmit FIFO empty interrupt */
51
52struct spi_imx_config {
53 unsigned int speed_hz;
54 unsigned int bpw;
55 unsigned int mode;
Uwe Kleine-König3b2aa892010-09-10 09:42:29 +020056 u8 cs;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -070057};
58
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +020059enum spi_imx_devtype {
60 SPI_IMX_VER_IMX1,
61 SPI_IMX_VER_0_0,
62 SPI_IMX_VER_0_4,
Uwe Kleine-König0b599602010-09-09 21:02:48 +020063 SPI_IMX_VER_2_3,
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +020064};
65
66struct spi_imx_data;
67
68struct spi_imx_devtype_data {
69 void (*intctrl)(struct spi_imx_data *, int);
70 int (*config)(struct spi_imx_data *, struct spi_imx_config *);
71 void (*trigger)(struct spi_imx_data *);
72 int (*rx_available)(struct spi_imx_data *);
Uwe Kleine-König1723e662010-09-10 09:19:18 +020073 void (*reset)(struct spi_imx_data *);
David Jander6ff554e2010-10-08 11:24:01 +020074 unsigned int fifosize;
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +020075};
76
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -070077struct spi_imx_data {
78 struct spi_bitbang bitbang;
79
80 struct completion xfer_done;
81 void *base;
82 int irq;
83 struct clk *clk;
84 unsigned long spi_clk;
85 int *chipselect;
86
87 unsigned int count;
88 void (*tx)(struct spi_imx_data *);
89 void (*rx)(struct spi_imx_data *);
90 void *rx_buf;
91 const void *tx_buf;
92 unsigned int txfifo; /* number of words pushed in tx FIFO */
93
Shawn Guoedd501bb2011-07-10 01:16:35 +080094 struct spi_imx_devtype_data *devtype_data;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -070095};
96
97#define MXC_SPI_BUF_RX(type) \
98static void spi_imx_buf_rx_##type(struct spi_imx_data *spi_imx) \
99{ \
100 unsigned int val = readl(spi_imx->base + MXC_CSPIRXDATA); \
101 \
102 if (spi_imx->rx_buf) { \
103 *(type *)spi_imx->rx_buf = val; \
104 spi_imx->rx_buf += sizeof(type); \
105 } \
106}
107
108#define MXC_SPI_BUF_TX(type) \
109static void spi_imx_buf_tx_##type(struct spi_imx_data *spi_imx) \
110{ \
111 type val = 0; \
112 \
113 if (spi_imx->tx_buf) { \
114 val = *(type *)spi_imx->tx_buf; \
115 spi_imx->tx_buf += sizeof(type); \
116 } \
117 \
118 spi_imx->count -= sizeof(type); \
119 \
120 writel(val, spi_imx->base + MXC_CSPITXDATA); \
121}
122
123MXC_SPI_BUF_RX(u8)
124MXC_SPI_BUF_TX(u8)
125MXC_SPI_BUF_RX(u16)
126MXC_SPI_BUF_TX(u16)
127MXC_SPI_BUF_RX(u32)
128MXC_SPI_BUF_TX(u32)
129
130/* First entry is reserved, second entry is valid only if SDHC_SPIEN is set
131 * (which is currently not the case in this driver)
132 */
133static int mxc_clkdivs[] = {0, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192,
134 256, 384, 512, 768, 1024};
135
136/* MX21, MX27 */
137static unsigned int spi_imx_clkdiv_1(unsigned int fin,
138 unsigned int fspi)
139{
140 int i, max;
141
142 if (cpu_is_mx21())
143 max = 18;
144 else
145 max = 16;
146
147 for (i = 2; i < max; i++)
148 if (fspi * mxc_clkdivs[i] >= fin)
149 return i;
150
151 return max;
152}
153
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200154/* MX1, MX31, MX35, MX51 CSPI */
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700155static unsigned int spi_imx_clkdiv_2(unsigned int fin,
156 unsigned int fspi)
157{
158 int i, div = 4;
159
160 for (i = 0; i < 7; i++) {
161 if (fspi * div >= fin)
162 return i;
163 div <<= 1;
164 }
165
166 return 7;
167}
168
Shawn Guo66de7572011-07-10 01:16:37 +0800169#define MX51_ECSPI_CTRL 0x08
170#define MX51_ECSPI_CTRL_ENABLE (1 << 0)
171#define MX51_ECSPI_CTRL_XCH (1 << 2)
172#define MX51_ECSPI_CTRL_MODE_MASK (0xf << 4)
173#define MX51_ECSPI_CTRL_POSTDIV_OFFSET 8
174#define MX51_ECSPI_CTRL_PREDIV_OFFSET 12
175#define MX51_ECSPI_CTRL_CS(cs) ((cs) << 18)
176#define MX51_ECSPI_CTRL_BL_OFFSET 20
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200177
Shawn Guo66de7572011-07-10 01:16:37 +0800178#define MX51_ECSPI_CONFIG 0x0c
179#define MX51_ECSPI_CONFIG_SCLKPHA(cs) (1 << ((cs) + 0))
180#define MX51_ECSPI_CONFIG_SCLKPOL(cs) (1 << ((cs) + 4))
181#define MX51_ECSPI_CONFIG_SBBCTRL(cs) (1 << ((cs) + 8))
182#define MX51_ECSPI_CONFIG_SSBPOL(cs) (1 << ((cs) + 12))
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200183
Shawn Guo66de7572011-07-10 01:16:37 +0800184#define MX51_ECSPI_INT 0x10
185#define MX51_ECSPI_INT_TEEN (1 << 0)
186#define MX51_ECSPI_INT_RREN (1 << 3)
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200187
Shawn Guo66de7572011-07-10 01:16:37 +0800188#define MX51_ECSPI_STAT 0x18
189#define MX51_ECSPI_STAT_RR (1 << 3)
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200190
191/* MX51 eCSPI */
Shawn Guo66de7572011-07-10 01:16:37 +0800192static unsigned int mx51_ecspi_clkdiv(unsigned int fin, unsigned int fspi)
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200193{
194 /*
195 * there are two 4-bit dividers, the pre-divider divides by
196 * $pre, the post-divider by 2^$post
197 */
198 unsigned int pre, post;
199
200 if (unlikely(fspi > fin))
201 return 0;
202
203 post = fls(fin) - fls(fspi);
204 if (fin > fspi << post)
205 post++;
206
207 /* now we have: (fin <= fspi << post) with post being minimal */
208
209 post = max(4U, post) - 4;
210 if (unlikely(post > 0xf)) {
211 pr_err("%s: cannot set clock freq: %u (base freq: %u)\n",
212 __func__, fspi, fin);
213 return 0xff;
214 }
215
216 pre = DIV_ROUND_UP(fin, fspi << post) - 1;
217
218 pr_debug("%s: fin: %u, fspi: %u, post: %u, pre: %u\n",
219 __func__, fin, fspi, post, pre);
Shawn Guo66de7572011-07-10 01:16:37 +0800220 return (pre << MX51_ECSPI_CTRL_PREDIV_OFFSET) |
221 (post << MX51_ECSPI_CTRL_POSTDIV_OFFSET);
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200222}
223
Shawn Guo66de7572011-07-10 01:16:37 +0800224static void __maybe_unused mx51_ecspi_intctrl(struct spi_imx_data *spi_imx, int enable)
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200225{
226 unsigned val = 0;
227
228 if (enable & MXC_INT_TE)
Shawn Guo66de7572011-07-10 01:16:37 +0800229 val |= MX51_ECSPI_INT_TEEN;
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200230
231 if (enable & MXC_INT_RR)
Shawn Guo66de7572011-07-10 01:16:37 +0800232 val |= MX51_ECSPI_INT_RREN;
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200233
Shawn Guo66de7572011-07-10 01:16:37 +0800234 writel(val, spi_imx->base + MX51_ECSPI_INT);
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200235}
236
Shawn Guo66de7572011-07-10 01:16:37 +0800237static void __maybe_unused mx51_ecspi_trigger(struct spi_imx_data *spi_imx)
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200238{
239 u32 reg;
240
Shawn Guo66de7572011-07-10 01:16:37 +0800241 reg = readl(spi_imx->base + MX51_ECSPI_CTRL);
242 reg |= MX51_ECSPI_CTRL_XCH;
243 writel(reg, spi_imx->base + MX51_ECSPI_CTRL);
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200244}
245
Shawn Guo66de7572011-07-10 01:16:37 +0800246static int __maybe_unused mx51_ecspi_config(struct spi_imx_data *spi_imx,
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200247 struct spi_imx_config *config)
248{
Shawn Guo66de7572011-07-10 01:16:37 +0800249 u32 ctrl = MX51_ECSPI_CTRL_ENABLE, cfg = 0;
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200250
Sascha Hauerf020c392011-02-08 21:08:59 +0100251 /*
252 * The hardware seems to have a race condition when changing modes. The
253 * current assumption is that the selection of the channel arrives
254 * earlier in the hardware than the mode bits when they are written at
255 * the same time.
256 * So set master mode for all channels as we do not support slave mode.
257 */
Shawn Guo66de7572011-07-10 01:16:37 +0800258 ctrl |= MX51_ECSPI_CTRL_MODE_MASK;
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200259
260 /* set clock speed */
Shawn Guo66de7572011-07-10 01:16:37 +0800261 ctrl |= mx51_ecspi_clkdiv(spi_imx->spi_clk, config->speed_hz);
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200262
263 /* set chip select to use */
Shawn Guo66de7572011-07-10 01:16:37 +0800264 ctrl |= MX51_ECSPI_CTRL_CS(config->cs);
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200265
Shawn Guo66de7572011-07-10 01:16:37 +0800266 ctrl |= (config->bpw - 1) << MX51_ECSPI_CTRL_BL_OFFSET;
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200267
Shawn Guo66de7572011-07-10 01:16:37 +0800268 cfg |= MX51_ECSPI_CONFIG_SBBCTRL(config->cs);
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200269
270 if (config->mode & SPI_CPHA)
Shawn Guo66de7572011-07-10 01:16:37 +0800271 cfg |= MX51_ECSPI_CONFIG_SCLKPHA(config->cs);
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200272
273 if (config->mode & SPI_CPOL)
Shawn Guo66de7572011-07-10 01:16:37 +0800274 cfg |= MX51_ECSPI_CONFIG_SCLKPOL(config->cs);
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200275
276 if (config->mode & SPI_CS_HIGH)
Shawn Guo66de7572011-07-10 01:16:37 +0800277 cfg |= MX51_ECSPI_CONFIG_SSBPOL(config->cs);
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200278
Shawn Guo66de7572011-07-10 01:16:37 +0800279 writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL);
280 writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG);
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200281
282 return 0;
283}
284
Shawn Guo66de7572011-07-10 01:16:37 +0800285static int __maybe_unused mx51_ecspi_rx_available(struct spi_imx_data *spi_imx)
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200286{
Shawn Guo66de7572011-07-10 01:16:37 +0800287 return readl(spi_imx->base + MX51_ECSPI_STAT) & MX51_ECSPI_STAT_RR;
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200288}
289
Shawn Guo66de7572011-07-10 01:16:37 +0800290static void __maybe_unused mx51_ecspi_reset(struct spi_imx_data *spi_imx)
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200291{
292 /* drain receive buffer */
Shawn Guo66de7572011-07-10 01:16:37 +0800293 while (mx51_ecspi_rx_available(spi_imx))
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200294 readl(spi_imx->base + MXC_CSPIRXDATA);
295}
296
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700297#define MX31_INTREG_TEEN (1 << 0)
298#define MX31_INTREG_RREN (1 << 3)
299
300#define MX31_CSPICTRL_ENABLE (1 << 0)
301#define MX31_CSPICTRL_MASTER (1 << 1)
302#define MX31_CSPICTRL_XCH (1 << 2)
303#define MX31_CSPICTRL_POL (1 << 4)
304#define MX31_CSPICTRL_PHA (1 << 5)
305#define MX31_CSPICTRL_SSCTL (1 << 6)
306#define MX31_CSPICTRL_SSPOL (1 << 7)
307#define MX31_CSPICTRL_BC_SHIFT 8
308#define MX35_CSPICTRL_BL_SHIFT 20
309#define MX31_CSPICTRL_CS_SHIFT 24
310#define MX35_CSPICTRL_CS_SHIFT 12
311#define MX31_CSPICTRL_DR_SHIFT 16
312
313#define MX31_CSPISTATUS 0x14
314#define MX31_STATUS_RR (1 << 3)
315
316/* These functions also work for the i.MX35, but be aware that
317 * the i.MX35 has a slightly different register layout for bits
318 * we do not use here.
319 */
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200320static void __maybe_unused mx31_intctrl(struct spi_imx_data *spi_imx, int enable)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700321{
322 unsigned int val = 0;
323
324 if (enable & MXC_INT_TE)
325 val |= MX31_INTREG_TEEN;
326 if (enable & MXC_INT_RR)
327 val |= MX31_INTREG_RREN;
328
329 writel(val, spi_imx->base + MXC_CSPIINT);
330}
331
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200332static void __maybe_unused mx31_trigger(struct spi_imx_data *spi_imx)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700333{
334 unsigned int reg;
335
336 reg = readl(spi_imx->base + MXC_CSPICTRL);
337 reg |= MX31_CSPICTRL_XCH;
338 writel(reg, spi_imx->base + MXC_CSPICTRL);
339}
340
Shawn Guo2a64a902011-07-10 01:16:38 +0800341static int __maybe_unused mx31_config(struct spi_imx_data *spi_imx,
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700342 struct spi_imx_config *config)
343{
344 unsigned int reg = MX31_CSPICTRL_ENABLE | MX31_CSPICTRL_MASTER;
Uwe Kleine-König3b2aa892010-09-10 09:42:29 +0200345 int cs = spi_imx->chipselect[config->cs];
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700346
347 reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, config->speed_hz) <<
348 MX31_CSPICTRL_DR_SHIFT;
349
Shawn Guo2a64a902011-07-10 01:16:38 +0800350 if (cpu_is_mx35()) {
351 reg |= (config->bpw - 1) << MX35_CSPICTRL_BL_SHIFT;
352 reg |= MX31_CSPICTRL_SSCTL;
353 } else {
354 reg |= (config->bpw - 1) << MX31_CSPICTRL_BC_SHIFT;
355 }
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700356
357 if (config->mode & SPI_CPHA)
358 reg |= MX31_CSPICTRL_PHA;
359 if (config->mode & SPI_CPOL)
360 reg |= MX31_CSPICTRL_POL;
361 if (config->mode & SPI_CS_HIGH)
362 reg |= MX31_CSPICTRL_SSPOL;
Uwe Kleine-König3b2aa892010-09-10 09:42:29 +0200363 if (cs < 0)
Shawn Guo2a64a902011-07-10 01:16:38 +0800364 reg |= (cs + 32) <<
365 (cpu_is_mx35() ? MX35_CSPICTRL_CS_SHIFT :
366 MX31_CSPICTRL_CS_SHIFT);
Uwe Kleine-König1723e662010-09-10 09:19:18 +0200367
368 writel(reg, spi_imx->base + MXC_CSPICTRL);
369
370 return 0;
371}
372
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200373static int __maybe_unused mx31_rx_available(struct spi_imx_data *spi_imx)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700374{
375 return readl(spi_imx->base + MX31_CSPISTATUS) & MX31_STATUS_RR;
376}
377
Shawn Guo2a64a902011-07-10 01:16:38 +0800378static void __maybe_unused mx31_reset(struct spi_imx_data *spi_imx)
Uwe Kleine-König1723e662010-09-10 09:19:18 +0200379{
380 /* drain receive buffer */
Shawn Guo2a64a902011-07-10 01:16:38 +0800381 while (readl(spi_imx->base + MX31_CSPISTATUS) & MX31_STATUS_RR)
Uwe Kleine-König1723e662010-09-10 09:19:18 +0200382 readl(spi_imx->base + MXC_CSPIRXDATA);
383}
384
Shawn Guo3451fb12011-07-10 01:16:36 +0800385#define MX21_INTREG_RR (1 << 4)
386#define MX21_INTREG_TEEN (1 << 9)
387#define MX21_INTREG_RREN (1 << 13)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700388
Shawn Guo3451fb12011-07-10 01:16:36 +0800389#define MX21_CSPICTRL_POL (1 << 5)
390#define MX21_CSPICTRL_PHA (1 << 6)
391#define MX21_CSPICTRL_SSPOL (1 << 8)
392#define MX21_CSPICTRL_XCH (1 << 9)
393#define MX21_CSPICTRL_ENABLE (1 << 10)
394#define MX21_CSPICTRL_MASTER (1 << 11)
395#define MX21_CSPICTRL_DR_SHIFT 14
396#define MX21_CSPICTRL_CS_SHIFT 19
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700397
Shawn Guo3451fb12011-07-10 01:16:36 +0800398static void __maybe_unused mx21_intctrl(struct spi_imx_data *spi_imx, int enable)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700399{
400 unsigned int val = 0;
401
402 if (enable & MXC_INT_TE)
Shawn Guo3451fb12011-07-10 01:16:36 +0800403 val |= MX21_INTREG_TEEN;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700404 if (enable & MXC_INT_RR)
Shawn Guo3451fb12011-07-10 01:16:36 +0800405 val |= MX21_INTREG_RREN;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700406
407 writel(val, spi_imx->base + MXC_CSPIINT);
408}
409
Shawn Guo3451fb12011-07-10 01:16:36 +0800410static void __maybe_unused mx21_trigger(struct spi_imx_data *spi_imx)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700411{
412 unsigned int reg;
413
414 reg = readl(spi_imx->base + MXC_CSPICTRL);
Shawn Guo3451fb12011-07-10 01:16:36 +0800415 reg |= MX21_CSPICTRL_XCH;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700416 writel(reg, spi_imx->base + MXC_CSPICTRL);
417}
418
Shawn Guo3451fb12011-07-10 01:16:36 +0800419static int __maybe_unused mx21_config(struct spi_imx_data *spi_imx,
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700420 struct spi_imx_config *config)
421{
Shawn Guo3451fb12011-07-10 01:16:36 +0800422 unsigned int reg = MX21_CSPICTRL_ENABLE | MX21_CSPICTRL_MASTER;
Uwe Kleine-König3b2aa892010-09-10 09:42:29 +0200423 int cs = spi_imx->chipselect[config->cs];
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700424
425 reg |= spi_imx_clkdiv_1(spi_imx->spi_clk, config->speed_hz) <<
Shawn Guo3451fb12011-07-10 01:16:36 +0800426 MX21_CSPICTRL_DR_SHIFT;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700427 reg |= config->bpw - 1;
428
429 if (config->mode & SPI_CPHA)
Shawn Guo3451fb12011-07-10 01:16:36 +0800430 reg |= MX21_CSPICTRL_PHA;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700431 if (config->mode & SPI_CPOL)
Shawn Guo3451fb12011-07-10 01:16:36 +0800432 reg |= MX21_CSPICTRL_POL;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700433 if (config->mode & SPI_CS_HIGH)
Shawn Guo3451fb12011-07-10 01:16:36 +0800434 reg |= MX21_CSPICTRL_SSPOL;
Uwe Kleine-König3b2aa892010-09-10 09:42:29 +0200435 if (cs < 0)
Shawn Guo3451fb12011-07-10 01:16:36 +0800436 reg |= (cs + 32) << MX21_CSPICTRL_CS_SHIFT;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700437
438 writel(reg, spi_imx->base + MXC_CSPICTRL);
439
440 return 0;
441}
442
Shawn Guo3451fb12011-07-10 01:16:36 +0800443static int __maybe_unused mx21_rx_available(struct spi_imx_data *spi_imx)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700444{
Shawn Guo3451fb12011-07-10 01:16:36 +0800445 return readl(spi_imx->base + MXC_CSPIINT) & MX21_INTREG_RR;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700446}
447
Shawn Guo3451fb12011-07-10 01:16:36 +0800448static void __maybe_unused mx21_reset(struct spi_imx_data *spi_imx)
Uwe Kleine-König1723e662010-09-10 09:19:18 +0200449{
450 writel(1, spi_imx->base + MXC_RESET);
451}
452
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700453#define MX1_INTREG_RR (1 << 3)
454#define MX1_INTREG_TEEN (1 << 8)
455#define MX1_INTREG_RREN (1 << 11)
456
457#define MX1_CSPICTRL_POL (1 << 4)
458#define MX1_CSPICTRL_PHA (1 << 5)
459#define MX1_CSPICTRL_XCH (1 << 8)
460#define MX1_CSPICTRL_ENABLE (1 << 9)
461#define MX1_CSPICTRL_MASTER (1 << 10)
462#define MX1_CSPICTRL_DR_SHIFT 13
463
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200464static void __maybe_unused mx1_intctrl(struct spi_imx_data *spi_imx, int enable)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700465{
466 unsigned int val = 0;
467
468 if (enable & MXC_INT_TE)
469 val |= MX1_INTREG_TEEN;
470 if (enable & MXC_INT_RR)
471 val |= MX1_INTREG_RREN;
472
473 writel(val, spi_imx->base + MXC_CSPIINT);
474}
475
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200476static void __maybe_unused mx1_trigger(struct spi_imx_data *spi_imx)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700477{
478 unsigned int reg;
479
480 reg = readl(spi_imx->base + MXC_CSPICTRL);
481 reg |= MX1_CSPICTRL_XCH;
482 writel(reg, spi_imx->base + MXC_CSPICTRL);
483}
484
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200485static int __maybe_unused mx1_config(struct spi_imx_data *spi_imx,
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700486 struct spi_imx_config *config)
487{
488 unsigned int reg = MX1_CSPICTRL_ENABLE | MX1_CSPICTRL_MASTER;
489
490 reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, config->speed_hz) <<
491 MX1_CSPICTRL_DR_SHIFT;
492 reg |= config->bpw - 1;
493
494 if (config->mode & SPI_CPHA)
495 reg |= MX1_CSPICTRL_PHA;
496 if (config->mode & SPI_CPOL)
497 reg |= MX1_CSPICTRL_POL;
498
499 writel(reg, spi_imx->base + MXC_CSPICTRL);
500
501 return 0;
502}
503
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200504static int __maybe_unused mx1_rx_available(struct spi_imx_data *spi_imx)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700505{
506 return readl(spi_imx->base + MXC_CSPIINT) & MX1_INTREG_RR;
507}
508
Uwe Kleine-König1723e662010-09-10 09:19:18 +0200509static void __maybe_unused mx1_reset(struct spi_imx_data *spi_imx)
510{
511 writel(1, spi_imx->base + MXC_RESET);
512}
513
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200514/*
515 * These version numbers are taken from the Freescale driver. Unfortunately it
516 * doesn't support i.MX1, so this entry doesn't match the scheme. :-(
517 */
Shawn Guoedd501bb2011-07-10 01:16:35 +0800518static struct spi_imx_devtype_data spi_imx_devtype_data[] = {
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200519#ifdef CONFIG_SPI_IMX_VER_IMX1
520 [SPI_IMX_VER_IMX1] = {
521 .intctrl = mx1_intctrl,
522 .config = mx1_config,
523 .trigger = mx1_trigger,
524 .rx_available = mx1_rx_available,
Uwe Kleine-König1723e662010-09-10 09:19:18 +0200525 .reset = mx1_reset,
David Jander6ff554e2010-10-08 11:24:01 +0200526 .fifosize = 8,
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200527 },
528#endif
529#ifdef CONFIG_SPI_IMX_VER_0_0
530 [SPI_IMX_VER_0_0] = {
Shawn Guo3451fb12011-07-10 01:16:36 +0800531 .intctrl = mx21_intctrl,
532 .config = mx21_config,
533 .trigger = mx21_trigger,
534 .rx_available = mx21_rx_available,
535 .reset = mx21_reset,
David Jander6ff554e2010-10-08 11:24:01 +0200536 .fifosize = 8,
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200537 },
538#endif
539#ifdef CONFIG_SPI_IMX_VER_0_4
540 [SPI_IMX_VER_0_4] = {
541 .intctrl = mx31_intctrl,
Shawn Guo2a64a902011-07-10 01:16:38 +0800542 .config = mx31_config,
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200543 .trigger = mx31_trigger,
544 .rx_available = mx31_rx_available,
Shawn Guo2a64a902011-07-10 01:16:38 +0800545 .reset = mx31_reset,
David Jander6ff554e2010-10-08 11:24:01 +0200546 .fifosize = 8,
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200547 },
548#endif
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200549#ifdef CONFIG_SPI_IMX_VER_2_3
550 [SPI_IMX_VER_2_3] = {
Shawn Guo66de7572011-07-10 01:16:37 +0800551 .intctrl = mx51_ecspi_intctrl,
552 .config = mx51_ecspi_config,
553 .trigger = mx51_ecspi_trigger,
554 .rx_available = mx51_ecspi_rx_available,
555 .reset = mx51_ecspi_reset,
David Jander6ff554e2010-10-08 11:24:01 +0200556 .fifosize = 64,
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200557 },
558#endif
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200559};
560
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700561static void spi_imx_chipselect(struct spi_device *spi, int is_active)
562{
563 struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700564 int gpio = spi_imx->chipselect[spi->chip_select];
Uwe Kleine-Könige6a0a8b2009-10-01 15:44:33 -0700565 int active = is_active != BITBANG_CS_INACTIVE;
566 int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH);
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700567
Uwe Kleine-Könige6a0a8b2009-10-01 15:44:33 -0700568 if (gpio < 0)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700569 return;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700570
Uwe Kleine-Könige6a0a8b2009-10-01 15:44:33 -0700571 gpio_set_value(gpio, dev_is_lowactive ^ active);
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700572}
573
574static void spi_imx_push(struct spi_imx_data *spi_imx)
575{
Shawn Guoedd501bb2011-07-10 01:16:35 +0800576 while (spi_imx->txfifo < spi_imx->devtype_data->fifosize) {
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700577 if (!spi_imx->count)
578 break;
579 spi_imx->tx(spi_imx);
580 spi_imx->txfifo++;
581 }
582
Shawn Guoedd501bb2011-07-10 01:16:35 +0800583 spi_imx->devtype_data->trigger(spi_imx);
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700584}
585
586static irqreturn_t spi_imx_isr(int irq, void *dev_id)
587{
588 struct spi_imx_data *spi_imx = dev_id;
589
Shawn Guoedd501bb2011-07-10 01:16:35 +0800590 while (spi_imx->devtype_data->rx_available(spi_imx)) {
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700591 spi_imx->rx(spi_imx);
592 spi_imx->txfifo--;
593 }
594
595 if (spi_imx->count) {
596 spi_imx_push(spi_imx);
597 return IRQ_HANDLED;
598 }
599
600 if (spi_imx->txfifo) {
601 /* No data left to push, but still waiting for rx data,
602 * enable receive data available interrupt.
603 */
Shawn Guoedd501bb2011-07-10 01:16:35 +0800604 spi_imx->devtype_data->intctrl(
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200605 spi_imx, MXC_INT_RR);
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700606 return IRQ_HANDLED;
607 }
608
Shawn Guoedd501bb2011-07-10 01:16:35 +0800609 spi_imx->devtype_data->intctrl(spi_imx, 0);
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700610 complete(&spi_imx->xfer_done);
611
612 return IRQ_HANDLED;
613}
614
615static int spi_imx_setupxfer(struct spi_device *spi,
616 struct spi_transfer *t)
617{
618 struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
619 struct spi_imx_config config;
620
621 config.bpw = t ? t->bits_per_word : spi->bits_per_word;
622 config.speed_hz = t ? t->speed_hz : spi->max_speed_hz;
623 config.mode = spi->mode;
Uwe Kleine-König3b2aa892010-09-10 09:42:29 +0200624 config.cs = spi->chip_select;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700625
Sascha Hauer462d26b2009-10-01 15:44:29 -0700626 if (!config.speed_hz)
627 config.speed_hz = spi->max_speed_hz;
628 if (!config.bpw)
629 config.bpw = spi->bits_per_word;
630 if (!config.speed_hz)
631 config.speed_hz = spi->max_speed_hz;
632
Uwe Kleine-Könige6a0a8b2009-10-01 15:44:33 -0700633 /* Initialize the functions for transfer */
634 if (config.bpw <= 8) {
635 spi_imx->rx = spi_imx_buf_rx_u8;
636 spi_imx->tx = spi_imx_buf_tx_u8;
637 } else if (config.bpw <= 16) {
638 spi_imx->rx = spi_imx_buf_rx_u16;
639 spi_imx->tx = spi_imx_buf_tx_u16;
640 } else if (config.bpw <= 32) {
641 spi_imx->rx = spi_imx_buf_rx_u32;
642 spi_imx->tx = spi_imx_buf_tx_u32;
643 } else
644 BUG();
645
Shawn Guoedd501bb2011-07-10 01:16:35 +0800646 spi_imx->devtype_data->config(spi_imx, &config);
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700647
648 return 0;
649}
650
651static int spi_imx_transfer(struct spi_device *spi,
652 struct spi_transfer *transfer)
653{
654 struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
655
656 spi_imx->tx_buf = transfer->tx_buf;
657 spi_imx->rx_buf = transfer->rx_buf;
658 spi_imx->count = transfer->len;
659 spi_imx->txfifo = 0;
660
661 init_completion(&spi_imx->xfer_done);
662
663 spi_imx_push(spi_imx);
664
Shawn Guoedd501bb2011-07-10 01:16:35 +0800665 spi_imx->devtype_data->intctrl(spi_imx, MXC_INT_TE);
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700666
667 wait_for_completion(&spi_imx->xfer_done);
668
669 return transfer->len;
670}
671
672static int spi_imx_setup(struct spi_device *spi)
673{
Sascha Hauer6c23e5d2009-10-01 15:44:29 -0700674 struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
675 int gpio = spi_imx->chipselect[spi->chip_select];
676
Alberto Panizzof4d4ecf2010-01-20 13:49:45 -0700677 dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__,
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700678 spi->mode, spi->bits_per_word, spi->max_speed_hz);
679
Sascha Hauer6c23e5d2009-10-01 15:44:29 -0700680 if (gpio >= 0)
681 gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1);
682
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700683 spi_imx_chipselect(spi, BITBANG_CS_INACTIVE);
684
685 return 0;
686}
687
688static void spi_imx_cleanup(struct spi_device *spi)
689{
690}
691
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200692static struct platform_device_id spi_imx_devtype[] = {
693 {
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200694 .name = "imx1-cspi",
695 .driver_data = SPI_IMX_VER_IMX1,
696 }, {
697 .name = "imx21-cspi",
698 .driver_data = SPI_IMX_VER_0_0,
699 }, {
700 .name = "imx25-cspi",
Shawn Guo2a64a902011-07-10 01:16:38 +0800701 .driver_data = SPI_IMX_VER_0_4,
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200702 }, {
703 .name = "imx27-cspi",
704 .driver_data = SPI_IMX_VER_0_0,
705 }, {
706 .name = "imx31-cspi",
707 .driver_data = SPI_IMX_VER_0_4,
708 }, {
709 .name = "imx35-cspi",
Shawn Guo2a64a902011-07-10 01:16:38 +0800710 .driver_data = SPI_IMX_VER_0_4,
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200711 }, {
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200712 .name = "imx51-cspi",
Shawn Guo2a64a902011-07-10 01:16:38 +0800713 .driver_data = SPI_IMX_VER_0_4,
Uwe Kleine-König0b599602010-09-09 21:02:48 +0200714 }, {
715 .name = "imx51-ecspi",
716 .driver_data = SPI_IMX_VER_2_3,
717 }, {
Yong Shen77e7bc62011-01-11 17:21:53 +0800718 .name = "imx53-cspi",
Shawn Guo2a64a902011-07-10 01:16:38 +0800719 .driver_data = SPI_IMX_VER_0_4,
Yong Shen77e7bc62011-01-11 17:21:53 +0800720 }, {
721 .name = "imx53-ecspi",
722 .driver_data = SPI_IMX_VER_2_3,
723 }, {
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200724 /* sentinel */
725 }
726};
727
Grant Likely965346e2009-12-13 01:03:12 -0700728static int __devinit spi_imx_probe(struct platform_device *pdev)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700729{
730 struct spi_imx_master *mxc_platform_info;
731 struct spi_master *master;
732 struct spi_imx_data *spi_imx;
733 struct resource *res;
734 int i, ret;
735
Uwe Kleine-König980f3be2009-12-13 01:02:09 -0700736 mxc_platform_info = dev_get_platdata(&pdev->dev);
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700737 if (!mxc_platform_info) {
738 dev_err(&pdev->dev, "can't get the platform data\n");
739 return -EINVAL;
740 }
741
742 master = spi_alloc_master(&pdev->dev, sizeof(struct spi_imx_data));
743 if (!master)
744 return -ENOMEM;
745
746 platform_set_drvdata(pdev, master);
747
748 master->bus_num = pdev->id;
749 master->num_chipselect = mxc_platform_info->num_chipselect;
750
751 spi_imx = spi_master_get_devdata(master);
752 spi_imx->bitbang.master = spi_master_get(master);
753 spi_imx->chipselect = mxc_platform_info->chipselect;
754
755 for (i = 0; i < master->num_chipselect; i++) {
756 if (spi_imx->chipselect[i] < 0)
757 continue;
758 ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);
759 if (ret) {
John Ognessbbd050a2009-11-24 16:53:07 +0000760 while (i > 0) {
761 i--;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700762 if (spi_imx->chipselect[i] >= 0)
John Ognessbbd050a2009-11-24 16:53:07 +0000763 gpio_free(spi_imx->chipselect[i]);
764 }
765 dev_err(&pdev->dev, "can't get cs gpios\n");
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700766 goto out_master_put;
767 }
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700768 }
769
770 spi_imx->bitbang.chipselect = spi_imx_chipselect;
771 spi_imx->bitbang.setup_transfer = spi_imx_setupxfer;
772 spi_imx->bitbang.txrx_bufs = spi_imx_transfer;
773 spi_imx->bitbang.master->setup = spi_imx_setup;
774 spi_imx->bitbang.master->cleanup = spi_imx_cleanup;
Sascha Hauer3910f2c2009-10-01 15:44:30 -0700775 spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700776
777 init_completion(&spi_imx->xfer_done);
778
Uwe Kleine-König89342172010-11-24 10:05:46 +0100779 spi_imx->devtype_data =
Shawn Guoedd501bb2011-07-10 01:16:35 +0800780 &spi_imx_devtype_data[pdev->id_entry->driver_data];
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200781
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700782 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
783 if (!res) {
784 dev_err(&pdev->dev, "can't get platform resource\n");
785 ret = -ENOMEM;
786 goto out_gpio_free;
787 }
788
789 if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
790 dev_err(&pdev->dev, "request_mem_region failed\n");
791 ret = -EBUSY;
792 goto out_gpio_free;
793 }
794
795 spi_imx->base = ioremap(res->start, resource_size(res));
796 if (!spi_imx->base) {
797 ret = -EINVAL;
798 goto out_release_mem;
799 }
800
801 spi_imx->irq = platform_get_irq(pdev, 0);
Richard Genoud73575932011-01-07 15:26:01 +0100802 if (spi_imx->irq < 0) {
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700803 ret = -EINVAL;
804 goto out_iounmap;
805 }
806
807 ret = request_irq(spi_imx->irq, spi_imx_isr, 0, DRIVER_NAME, spi_imx);
808 if (ret) {
809 dev_err(&pdev->dev, "can't get irq%d: %d\n", spi_imx->irq, ret);
810 goto out_iounmap;
811 }
812
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700813 spi_imx->clk = clk_get(&pdev->dev, NULL);
814 if (IS_ERR(spi_imx->clk)) {
815 dev_err(&pdev->dev, "unable to get clock\n");
816 ret = PTR_ERR(spi_imx->clk);
817 goto out_free_irq;
818 }
819
820 clk_enable(spi_imx->clk);
821 spi_imx->spi_clk = clk_get_rate(spi_imx->clk);
822
Shawn Guoedd501bb2011-07-10 01:16:35 +0800823 spi_imx->devtype_data->reset(spi_imx);
Daniel Mackce1807b2009-11-19 19:01:42 +0000824
Shawn Guoedd501bb2011-07-10 01:16:35 +0800825 spi_imx->devtype_data->intctrl(spi_imx, 0);
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700826
827 ret = spi_bitbang_start(&spi_imx->bitbang);
828 if (ret) {
829 dev_err(&pdev->dev, "bitbang start failed with %d\n", ret);
830 goto out_clk_put;
831 }
832
833 dev_info(&pdev->dev, "probed\n");
834
835 return ret;
836
837out_clk_put:
838 clk_disable(spi_imx->clk);
839 clk_put(spi_imx->clk);
840out_free_irq:
841 free_irq(spi_imx->irq, spi_imx);
842out_iounmap:
843 iounmap(spi_imx->base);
844out_release_mem:
845 release_mem_region(res->start, resource_size(res));
846out_gpio_free:
847 for (i = 0; i < master->num_chipselect; i++)
848 if (spi_imx->chipselect[i] >= 0)
849 gpio_free(spi_imx->chipselect[i]);
850out_master_put:
851 spi_master_put(master);
852 kfree(master);
853 platform_set_drvdata(pdev, NULL);
854 return ret;
855}
856
Grant Likely965346e2009-12-13 01:03:12 -0700857static int __devexit spi_imx_remove(struct platform_device *pdev)
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700858{
859 struct spi_master *master = platform_get_drvdata(pdev);
860 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
861 struct spi_imx_data *spi_imx = spi_master_get_devdata(master);
862 int i;
863
864 spi_bitbang_stop(&spi_imx->bitbang);
865
866 writel(0, spi_imx->base + MXC_CSPICTRL);
867 clk_disable(spi_imx->clk);
868 clk_put(spi_imx->clk);
869 free_irq(spi_imx->irq, spi_imx);
870 iounmap(spi_imx->base);
871
872 for (i = 0; i < master->num_chipselect; i++)
873 if (spi_imx->chipselect[i] >= 0)
874 gpio_free(spi_imx->chipselect[i]);
875
876 spi_master_put(master);
877
878 release_mem_region(res->start, resource_size(res));
879
880 platform_set_drvdata(pdev, NULL);
881
882 return 0;
883}
884
885static struct platform_driver spi_imx_driver = {
886 .driver = {
887 .name = DRIVER_NAME,
888 .owner = THIS_MODULE,
889 },
Uwe Kleine-Königf4ba6312010-09-09 15:29:01 +0200890 .id_table = spi_imx_devtype,
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700891 .probe = spi_imx_probe,
Grant Likely965346e2009-12-13 01:03:12 -0700892 .remove = __devexit_p(spi_imx_remove),
Uwe Kleine-König6cdeb002009-10-01 15:44:28 -0700893};
894
895static int __init spi_imx_init(void)
896{
897 return platform_driver_register(&spi_imx_driver);
898}
899
900static void __exit spi_imx_exit(void)
901{
902 platform_driver_unregister(&spi_imx_driver);
903}
904
905module_init(spi_imx_init);
906module_exit(spi_imx_exit);
907
908MODULE_DESCRIPTION("SPI Master Controller driver");
909MODULE_AUTHOR("Sascha Hauer, Pengutronix");
910MODULE_LICENSE("GPL");