gpio-test updated for interrupt tests
[pub/spi-gpio-pp.git] / spi_parport.c
1 /*
2 * spi_parport.c - SPI master controller driver based on the parallel port adapter
3 *
4 * Copyright (C) 2008 Peter Henn <Peter.Henn@web.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * The spi_parport find its beginning in the spi_butterfly driver, but with the
21 * idea to isolate the SPI master controller part and move all additional SPI
22 * protocoll stuff into separate drivers.
23 * The most important settings can be given to the driver by module load parameter.
24 * Also the SPI-protocol driver can be configured by module load parameter. Make
25 * sure that all related SPI-protocol drivers are load before you load this SPI
26 * controller module!
27 * The SPI parport driver supports more than one SPI device. Therefore all module
28 * parameter can be given as an ARRAY with ',' as a delimiter. Starting from the
29 * first entry up to SPI_DEV_MAX devices will be handled. Therefore a successive
30 * chip selects will be reserved in the parport settings.
31 *
32 * Naturally this driver should normally use its gpio_parport base driver. But just
33 * to prevent additional performace issues I decice to finish this spi_parport.
34 * Both drivers may gives you also the possibility to use them hardware shared on
35 * one parport device, as long as you never use GPIO outputs in the gpio_parport from
36 * the parport data port and move the SPI control signals in the spi_parport driver
37 * to the parport control port - and visa verse, although its not a real software
38 * shared functionality.
39 */
40 #include <linux/kernel.h>
41 #include <linux/init.h>
42 #include <linux/interrupt.h>
43 #include <linux/device.h>
44 #include <linux/parport.h>
45 #include <linux/spinlock.h>
46
47 #include <linux/sched.h>
48 #include <linux/spi/spi.h>
49 #include <linux/spi/spi_bitbang.h>
50
51 #ifdef CONFIG_SPI_PARPORT_EXCLUSIVE
52 #define sCONFIG_SPI_PARPORT_EXCLUSIVE " CONFIG_SPI_PARPORT_EXCLUSIVE"
53 #else
54 #define sCONFIG_SPI_PARPORT_EXCLUSIVE ""
55 #endif
56
57 /* ToDo
58 * 0. Setup of the parport mode must be done. Therefore we read the
59 * supported modes: dev->dev->port->modes; Depending on the mode flags we change
60 * the mode value in the dev->dev->port->base_hi+0x02; Register, which is the ECR
61 * (extended control register). So first set to SPP (standard parport mode)
62 * 1. first setup all CS, because spi_new_device or spi_add_device will call
63 * probe fkt of the SPI protocoll driver. This might initiate a SPI transfer
64 * and triggers the SCLK, which is worse for other chips on the SPI-BUS using
65 * the wrong CS polarity
66 * 2. use spi_add_device instead of spi_new_device. That's the only chance
67 * to setup the also the SPI bits per word value, just before any transaction
68 * might be initiated with the SPI probe fkt of the SPI protocol driver.
69 * Setting this spi->bits_per_word value afterwards might be here too late.
70 * Note that bits_per_word is normally has to be set normally by the protocoll
71 * driver (e.g. a bad style of the lm70.c driver, which guess that the value is
72 * setup afterwards)
73 * Therefore we MUST support a mode, where NOTHING will be changed!
74 * 3. support better irq via array load parameter and values like AUTO, NONE. Additionally
75 * don't free any interrupt, if no interrupt might be requested
76 * 4. output warning, if open mode, bits values after finish init
77 * 5. test spi modes
78 *
79 * Note: - SPI_LSB_FIRST is not yet supported and would need own txrx functions
80 * - SPI_LOOP is supported, but requires tx before rx in own transfer functions
81 * - SPI_3WIRE depends on signal routing, but is in principle possible
82 * and therefore supported.
83 * - SPI_CS_HIGH is supported
84 * - Slow CPU frequencies are currently not supported. The
85 * maximum Bit rate may be around 200 kBit/sec
86 *
87 * ToDo: - support also bits of the Control port
88 * - support more than one SPI controller
89 *
90 * Parallel
91 * Port Direction Register Name Signal
92 * ----------- --------- -------- ---------------------- ------
93 * nStrobe 1 --> nC0 PARPORT_CONTROL_STROBE
94 * D0 2 --> D0 (1 << 0) SCLK
95 * D1 3 --> D1 (1 << 1) MOSI
96 * D2 4 --> D2 (1 << 2) nCS0
97 * D3 5 --> D3 (1 << 3) nCS1
98 * D4 6 --> D4 (1 << 4) --
99 * D5 7 --> D5 (1 << 5) --
100 * D6 8 --> D6 (1 << 6) --
101 * D7 9 --> D7 (1 << 7) --
102 * nAckn 10 <-- S6 PARPORT_STATUS_ACK
103 * Busy 11 <-- nS7 PARPORT_STATUS_BUSY MISO
104 * Paper 12 <-- S5 PARPORT_STATUS_PAPEROUT --
105 * Sel 13 <-- S4 PARPORT_STATUS_SELECT --
106 * nFeed 14 --> nC1 PARPORT_CONTROL_AUTOFD --
107 * nError 15 <-- S3 PARPORT_STATUS_ERROR --
108 * nInit 16 --> C2 PARPORT_CONTROL_INIT --
109 * nSelIn 17 --> nC3 PARPORT_CONTROL_SELECT --
110 * GND 25 -- -- GND
111 *
112 * Signal:
113 * - SCLK : SPI Master Clock
114 * - MOSI : SPI Master Data Output, Slave Data Input
115 * - MISO : SPI Master Date Input, Slave Data Output
116 * - nCSx : SPI Chip Select x, default low active
117 * Note: nCSx must be in consecutive bit order!
118 */
119
120 //*****************************************************************************
121 // MODULE PARAMETERS
122 //*****************************************************************************
123 #define DRVNAME "spi_parport" /* name of the driver */
124 #define DRIVER_VERSION "0.2" /* helps identifing different versions of that driver */
125
126 #define SPI_PARPORT_SCLK (1 << 0) /* SPI Clock on parport D0 or pin 2 */
127 #define SPI_PARPORT_MOSI (1 << 1) /* SPI MOSI on parport D1 or pin 3 */
128 #define SPI_PARPORT_CS0 (1 << 2) /* first SPI chipselet on parport D2 or pin 4 */
129 #define SPI_PARPORT_MISO PARPORT_STATUS_BUSY /* SPI MISO on parport Status Busy or pin 11 */
130
131 #define SPI_PARPORT_STATUS_INV 0x80 /* invert internal bit 7 of status parport bit (Busy) */
132 #define SPI_PARPORT_CONTROL_INV 0x0b /* invert internal bit 0, 1 and 3 of control parport bits
133 (Strobe, Autofd, Select) */
134
135 #define SPI_PARPORT_MAX_SPEED 1*1000*1000 /* maximum allowed speed for any SPI device, currently not used */
136 #define SPI_DEV_MAX 4 /* maximum number of supported SPI devices and CS */
137 #define SPI_MODALIAS_LEN 32 /* spi protocol module alias name length, not defined in spi.h */
138
139 /* Module load parameter */
140 static int irq=-1; /* force irq for parport pin 10 */
141 static char spi_modalias[SPI_DEV_MAX*(SPI_MODALIAS_LEN+1)]="";
142 static unsigned int spi_mode[SPI_DEV_MAX] = {SPI_MODE_0, SPI_MODE_0, SPI_MODE_0, SPI_MODE_0};
143 static int spi_mode_cnt = SPI_DEV_MAX;
144 static unsigned int spi_bits[SPI_DEV_MAX] = {8, 8, 8, 8};
145 static int spi_bits_cnt = SPI_DEV_MAX;
146
147 struct spi_parport {
148 struct spi_bitbang bitbang; /* SPI bitbang controller data, must be the first item */
149 struct pardevice *dev; /* parport device entry */
150 struct parport *port; /* parport port entry */
151 u8 dcache; /* parport data port mirror bits */
152 int irq; /* parport interrupt */
153 struct list_head list; /* spi_parport host controller list */
154 };
155
156 /* helps accessing the spi controller stucture */
157 static inline struct spi_parport *spidev_to_pp(struct spi_device *spi)
158 {
159 return spi->controller_data;
160 }
161 /*----------------------------------------------------------------------*/
162 /* spi_parport to spi_bitbang interface functions */
163
164 /*
165 ** parport data bit output function
166 */
167 static inline void spi_parport_data_set(struct spi_parport *pp, unsigned mask, int value)
168 {
169 u8 byte = pp->dcache; // use old value from cache
170 if (value)
171 byte |= mask;
172 else
173 byte &= ~mask;
174 pp->dcache = byte; // restore cache
175 return parport_write_data(pp->port, byte);
176 }
177
178 /*
179 ** set clock signal
180 */
181 static inline void setsck(struct spi_device *spi, int value)
182 {
183 struct spi_parport *pp = spidev_to_pp(spi);
184 return spi_parport_data_set(pp, SPI_PARPORT_SCLK, value);
185 }
186
187 /*
188 ** set MOSI signal
189 */
190 static inline void setmosi(struct spi_device *spi, int value)
191 {
192 struct spi_parport *pp = spidev_to_pp(spi);
193 return spi_parport_data_set(pp, SPI_PARPORT_MOSI, value);
194 }
195
196 /*----------------------------------------------------------------------*/
197 /*
198 ** parport status bit input function
199 */
200 static inline int spi_parport_status_get(struct spi_parport *pp, unsigned mask)
201 {
202 u8 byte = SPI_PARPORT_STATUS_INV ^ parport_read_status(pp->port);
203 return ((byte & mask) != 0);
204 }
205
206 /*
207 ** parport data bit input function, only need for loop back mode
208 ** Note: Neiter the dcache is here updated nor the value is read from that dcache
209 ** to ensure similar system timing bahaviour as in standard MISO read mode.
210 */
211 static inline int spi_parport_data_get(struct spi_parport *pp, unsigned mask)
212 {
213 u8 byte = parport_read_data(pp->port);
214 return ((byte & mask) != 0);
215 }
216
217 /*
218 ** get MISO signal
219 ** supports also loop back mode in master controller
220 */
221 static inline int getmiso(struct spi_device *spi)
222 {
223 int value;
224 struct spi_parport *pp = spidev_to_pp(spi);
225 if (spi->mode & SPI_LOOP) {
226 /* Loop back mode, read direct from output port is possible, */
227 /* because setmosi will be done before getmiso in txrx */
228 value = spi_parport_data_get(pp, SPI_PARPORT_MOSI);
229 } else {
230 /* default MISO read */
231 value = spi_parport_status_get(pp, SPI_PARPORT_MISO);
232 }
233 return value;
234 }
235
236 /*
237 ** set chipselects
238 ** sets corresponding CSx and CLK, depending on its polarity and mode
239 */
240 static void spi_parport_chipselect(struct spi_device *spi, int value)
241 {
242 struct spi_parport *pp = spidev_to_pp(spi);
243 /* set default clock polarity */
244 if (value == BITBANG_CS_INACTIVE) {
245 /* Deselect the slaves on the SPI bus by programming CS to inactive state */
246 spi_parport_data_set(pp, SPI_PARPORT_CS0 << spi->chip_select, (spi->mode & SPI_CS_HIGH)==0);
247 } else if (value == BITBANG_CS_ACTIVE) {
248 /* Set the SPI clock phase and polarity */
249 setsck(spi, (spi->mode & SPI_CPOL)!=0);
250 /* Activate the chip select by programming CS to active state */
251 if ((spi->chip_select >= 0) && (spi->chip_select < SPI_DEV_MAX)) {
252 spi_parport_data_set(pp, SPI_PARPORT_CS0 << spi->chip_select, (spi->mode & SPI_CS_HIGH)!=0);
253 } else {
254 pr_err("%s: Use chip %sCS%d select out of range CS0 - CS%d\n",
255 DRVNAME, ((spi->mode & SPI_CS_HIGH)!=0)?"":"/", spi->chip_select, SPI_DEV_MAX);
256 }
257 }
258 }
259
260 /* use default TXRX bitbang interface functions from header file */
261 #define EXPAND_BITBANG_TXRX
262
263 /* currently we omit any additional delay, because parport is even slow.
264 Naturally for X > 10000, a delay would become more important */
265 #define spidelay(X) do{}while(0)
266
267 #include <linux/spi/spi_bitbang.h>
268
269 static u32 spi_parport_txrx_word_mode0(struct spi_device *spi,
270 unsigned nsecs,
271 u32 word, u8 bits)
272 {
273 return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits);
274 }
275
276 static u32 spi_parport_txrx_word_mode1(struct spi_device *spi,
277 unsigned nsecs,
278 u32 word, u8 bits)
279 {
280 return bitbang_txrx_be_cpha1(spi, nsecs, 0, word, bits);
281 }
282
283 static u32 spi_parport_txrx_word_mode2(struct spi_device *spi,
284 unsigned nsecs,
285 u32 word, u8 bits)
286 {
287 return bitbang_txrx_be_cpha0(spi, nsecs, 1, word, bits);
288 }
289
290 static u32 spi_parport_txrx_word_mode3(struct spi_device *spi,
291 unsigned nsecs,
292 u32 word, u8 bits)
293 {
294 return bitbang_txrx_be_cpha1(spi, nsecs, 1, word, bits);
295 }
296
297
298 /*----------------------------------------------------------------------*/
299 /*
300 ** copies src to dest string up to count characters or until a character is found
301 ** which matches the delim string set. As the return value will be returned the next
302 ** address of src, which can be used for the next stnarr of NULL if the found string
303 ** was longer than count.
304 */
305 const char *strnarr(char *dst, const char *src, const char *dlim, size_t count)
306 {
307 int i;
308 for(i=0; i<count; i++) {
309 if (*src == '\0') {
310 *dst='\0';
311 return src;
312 }
313 if (strchr(dlim, *src)!=NULL) {
314 *dst='\0';
315 return ++src;
316 }
317 *dst++=*src++;
318 }
319 *--dst='\0'; /* add missing line end */
320 return NULL;
321 }
322
323
324 #if 0
325 void parse_irqs(int nports, const char *irqstr, int irqval[])
326 {
327 unsigned int i;
328 for (i=0; i<nports && irgstr; i++){
329 if (!strncmp(irqstr, "auto", 4))
330 irqval[i] = AUTO;
331 else if (!strncmp(irqstr, "none", 4))
332 irqval[i] = NONE;
333 else {
334 char *ep;
335 unsigned long r = simple_strtoul(irqstr, &ep, 0);
336 if (ep != irqstr)
337 irqval[i] = r;
338 else {
339 printk("... bad irq specifier '%s'\n", irqstr);
340 return;
341 }
342 }
343 irqstr = strchr(irqstr, ',');
344 if (irqstr) irqstr++;
345 }
346 }
347 #endif
348
349
350 /*
351 ** spi parport registers SPI devices, defined by the given module load parameters.
352 */
353 static int spi_parport_register_spi_devices(struct spi_parport *pp)
354 {
355 const char *modalias_param=spi_modalias;
356 int i=0;
357
358 /* loop over all SPI device informations found in module parameter settings */
359 while ((modalias_param[0]!='\0') && (i<SPI_DEV_MAX)) {
360 struct spi_board_info chip; /* parport SPI board description placeholder*/
361 struct spi_device *proxy; /* just need to check spi device result and add additional settings */
362 modalias_param=strnarr(chip.modalias, modalias_param, " ,", sizeof(chip.modalias));
363 if (modalias_param==NULL) {
364 pr_err("%s: %d given modalias name is too long! See only that '%s'!\n", DRVNAME, i, chip.modalias);
365 return -EINVAL;
366 }
367
368 /*
369 * The modalias name MUST match the device_driver name
370 * for the bus glue code to match and subsequently bind them.
371 */
372 chip.max_speed_hz = SPI_PARPORT_MAX_SPEED;
373 chip.chip_select = i;
374 chip.mode = spi_mode[i];
375 chip.irq = pp->irq;
376 chip.controller_data = pp; /* enable access to primary controller data */
377 chip.platform_data = NULL; /* data area of SPI protocol driver */
378 /* chip.bus_num = master->bus_num; // not needed for spi_new_device */
379 i++; /* found new SPI protocol driver */
380
381 if (spi_mode_cnt < i) {
382 pr_warning("%s: No spi mode parameter given for device %d with driver '%s'. "
383 "Will use default setting: %d\n",
384 DRVNAME, i, chip.modalias, chip.mode);
385 }
386 pr_info("%s: Will load protocol driver: '%s' on CS%d with mode 0x%02x!\n",
387 DRVNAME, chip.modalias, chip.chip_select, chip.mode);
388
389 /*
390 * Register spi device from board info settings.
391 * Note that this will also call the probe inside the SPI protocall driver
392 */
393 proxy = spi_new_device(pp->bitbang.master, &chip);
394 if (!proxy) {
395 pr_err("%s: spi_new_device failed!\n", DRVNAME);
396 return -ENODEV;
397 }
398 if (spi_bits_cnt < i) {
399 pr_warning("%s: No spi bits per word parameter given for device %d with driver '%s'. "
400 "Will use default setting: %d\n",
401 DRVNAME, i, chip.modalias, spi_bits[i-1]);
402 }
403 proxy->bits_per_word=spi_bits[i-1];
404 pr_info("%s: SPI device successfully registered at bus %s as device %s with %d bits/word\n", DRVNAME,
405 proxy->dev.bus_id, chip.modalias, proxy->bits_per_word);
406 }
407 if (modalias_param[0]!='\0'){
408 pr_warning("%s: Found more modalias parameters of SPI devices than allowed (max: %d)!\n",
409 DRVNAME, SPI_DEV_MAX);
410 }
411 return i;
412 }
413
414 /***************************************************************************
415 * Parallel port attaching and detaching routines *
416 ***************************************************************************/
417
418 static LIST_HEAD(spi_parport_hosts);
419
420 /*
421 ** If attaching the driver to parport is done with exclusive access, the driver
422 ** is still loaded, although the attach might not be done successful.
423 ** If you have already registered e.g. the lp driver, please unload any drivers
424 ** first as long as you use exclusive access.
425 */
426 static int __spi_parport_attach(struct parport *pb)
427 {
428 struct spi_master *master; /* is only temporary need */
429 struct device *dev = pb->physport->dev;
430 struct spi_parport *pp;
431 int err;
432
433 if (dev == NULL) {
434 return -ENODEV;
435 }
436
437 /* spi_alloc_master gives zero initialized structure */
438 master = spi_alloc_master(dev, sizeof *pp);
439 if (master == NULL) {
440 return -ENOMEM;
441 }
442 master->bus_num = -1; /* dynamic allocation of a bus number */
443 master->num_chipselect = SPI_DEV_MAX; /* setup maximum capability */
444
445 /* call the container_of fkt */
446 pp = spi_master_get_devdata(master);
447
448 if (pp == NULL) {
449 err = -ENOMEM;
450 goto err_release_mem;
451 }
452
453 /* ----------------- SPI BitBang Hook ---------------- */
454 /* use default setup(), cleanup(), and transfer() methods */
455 pp->bitbang.master = spi_master_get(master); /* now pp->bitbang.master = master */
456 pp->bitbang.chipselect = spi_parport_chipselect;
457 pp->bitbang.txrx_word[SPI_MODE_0] = spi_parport_txrx_word_mode0;
458 pp->bitbang.txrx_word[SPI_MODE_1] = spi_parport_txrx_word_mode1;
459 pp->bitbang.txrx_word[SPI_MODE_2] = spi_parport_txrx_word_mode2;
460 pp->bitbang.txrx_word[SPI_MODE_3] = spi_parport_txrx_word_mode3;
461 pp->bitbang.flags = SPI_CS_HIGH | SPI_3WIRE | SPI_LOOP; /* setup supported mode flags */
462
463 /* ----------------- ParPort Hook -------------------- */
464 /* REVISIT: no probe, just think it is there */
465 pp->port = pb;
466
467 //ToDo: share parport with other device, but may need a mutex lock!
468 //ToDo: check supported modes are ok
469 //ToDo: PM support, e.g. Suspend and Resume
470 pp->dev = parport_register_device(pb, /* port */
471 DRVNAME, /* driver name */
472 NULL, /* preemption fkt */
473 NULL, /* wake-up fkt */
474 NULL, /* no interrupt handler used */
475 #ifdef CONFIG_SPI_PARPORT_EXCLUSIVE
476 PARPORT_FLAG_EXCL, /* flags */
477 #else
478 0, /* flags, 0 means used port shared */
479 #endif
480 pp /* handle */ );
481 if (pp->dev == NULL) {
482 pr_err("%s: unable to register with parport\n", DRVNAME);
483 err = -ENOMEM;
484 goto err_release_mem;
485 }
486
487 err = parport_claim(pp->dev);
488 if (err < 0) {
489 pr_err("%s: unable to claim parport\n", DRVNAME);
490 err = -ENODEV;
491 goto err_unregister_parport;
492 }
493
494 /* ----------------- SPI ParPort init ---------------- */
495 /* cache initialisation just preventing changing unused bits */
496 pp->dcache = parport_read_data(pp->port);
497
498 if(irq >= 0) {
499 pp->irq = irq;
500 pr_info("%s: force usage IRQ %d\n", DRVNAME, pp->irq);
501 if(pp->port->irq == pp->irq) {
502 /* we free the standard parport handler, because we want to use our own later */
503 free_irq(pp->irq, pp->port);
504 pr_info("%s: Note parport driver will claim later irq as already freed during its module unload\n",
505 DRVNAME);
506 }
507 } else if(pp->port->irq != PARPORT_IRQ_NONE) {
508 pp->irq = pp->port->irq;
509 /* we free the standard parport handler, because we want to use our own later */
510 free_irq(pp->irq, pp->port);
511 pr_info("%s: will use IRQ %d exclusive\n", DRVNAME, pp->irq);
512 pr_info("%s: Note parport driver will claim later irq as already freed during its module unload\n", DRVNAME);
513 } else {
514 pp->irq = -ENXIO;
515 }
516
517 err = spi_bitbang_start(&pp->bitbang);
518 if (err < 0) {
519 pr_warning("%s: spi_bitbang_start failed with status %d\n",
520 DRVNAME, err);
521 goto err_release_parport;
522 }
523
524 /* ----------------- SPI BoardInfo init -------------- */
525 err = spi_parport_register_spi_devices(pp);
526 if (err == 0) {
527 pr_err("%s: at least one protocol driver name is needed, non found!\n", DRVNAME);
528 err = -ENODEV;
529 goto err_spi_controller_stop;
530 } else if (err < 0) {
531 goto err_spi_controller_stop;
532 }
533 list_add_tail(&pp->list, &spi_parport_hosts);
534 return 0;
535
536 err_spi_controller_stop:
537 /* this will unregister child SPI devices too, if there any */
538 spi_bitbang_stop(&pp->bitbang);
539 err_release_parport:
540 parport_release(pp->dev);
541 err_unregister_parport:
542 parport_unregister_device(pp->dev);
543 err_release_mem:
544 spi_master_put(master); /* will release memory */
545 return err;
546 }
547
548
549 static void spi_parport_attach(struct parport *pb)
550 {
551 (void)__spi_parport_attach(pb);
552 }
553
554
555 static int spi_parport_remove(struct spi_parport *pp)
556 {
557 int err;
558
559 /* stop and unregisters child devices too */
560 err = spi_bitbang_stop(&pp->bitbang);
561 if (err < 0) {
562 pr_err("%s: bitbang stop error: %d\n", DRVNAME, err);
563 }
564 parport_release(pp->dev);
565 parport_unregister_device(pp->dev);
566 /* this frees also the pp struct */
567 spi_master_put(pp->bitbang.master);
568 return err;
569 }
570
571 static void spi_parport_detach(struct parport *pb)
572 {
573 struct spi_parport *pp;
574
575 list_for_each_entry(pp, &spi_parport_hosts, list) {
576 if (pp->port == pb) {
577 list_del_init(&pp->list);
578 (void)spi_parport_remove(pp);
579 break;
580 }
581 }
582 }
583
584 static struct parport_driver spi_parport_driver = {
585 .name = DRVNAME,
586 .attach = spi_parport_attach,
587 .detach = spi_parport_detach,
588 };
589
590
591 static int __init spi_parport_init(void)
592 {
593 return parport_register_driver(&spi_parport_driver);
594 }
595 device_initcall(spi_parport_init);
596
597 static void __exit spi_parport_exit(void)
598 {
599 parport_unregister_driver(&spi_parport_driver);
600 }
601 module_exit(spi_parport_exit);
602
603 MODULE_AUTHOR("Option Wireless");
604 MODULE_DESCRIPTION("SPI master controller driver for Parport Adapter");
605 MODULE_LICENSE("GPL");
606
607 module_param(irq, uint, S_IRUGO);
608 MODULE_PARM_DESC(irq, "Force IRQ for parport pin 10");
609
610 module_param_string(pdrv, spi_modalias, sizeof(spi_modalias), S_IRUGO);
611 MODULE_PARM_DESC(pdrv, "array of spi protocol driver names");
612
613 module_param_array_named(mode, spi_mode, uint, &spi_mode_cnt, S_IRUGO);
614 MODULE_PARM_DESC(mode, "array of spi modes for each driver");
615
616 module_param_array_named(bits, spi_bits, uint, &spi_bits_cnt, S_IRUGO);
617 MODULE_PARM_DESC(bits, "array of spi bits per word for each driver");
618
619 MODULE_INFO(Flags, sCONFIG_SPI_PARPORT_EXCLUSIVE);
620 MODULE_INFO(Version, DRIVER_VERSION);