3 * Copyright (C) 2008 Christian Pellegrin <chripell@evolware.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
11 * Notes: the MAX3100 doesn't provide an interrupt on CTS so we have
12 * to use polling for flow control. TX empty IRQ is unusable, since
13 * writing conf clears FIFO buffer and we cannot have this interrupt
14 * always asking us for attention.
16 * Example platform data:
18 static struct plat_max3100 max3100_plat_data = {
24 static struct spi_board_info spi_board_info[] = {
26 .modalias = "max3100",
27 .platform_data = &max3100_plat_data,
29 .max_speed_hz = 5*1000*1000,
34 * The initial minor number is 209 in the low-density serial port:
35 * mknod /dev/ttyMAX0 c 204 209
38 #define MAX3100_MAJOR 204
39 #define MAX3100_MINOR 209
40 /* 4 MAX3100s should be enough for everyone */
43 #include <linux/delay.h>
44 #include <linux/slab.h>
45 #include <linux/device.h>
46 #include <linux/module.h>
47 #include <linux/serial_core.h>
48 #include <linux/serial.h>
49 #include <linux/spi/spi.h>
50 #include <linux/freezer.h>
52 #include <linux/serial_max3100.h>
54 #define MAX3100_C (1<<14)
55 #define MAX3100_D (0<<14)
56 #define MAX3100_W (1<<15)
57 #define MAX3100_RX (0<<15)
59 #define MAX3100_WC (MAX3100_W | MAX3100_C)
60 #define MAX3100_RC (MAX3100_RX | MAX3100_C)
61 #define MAX3100_WD (MAX3100_W | MAX3100_D)
62 #define MAX3100_RD (MAX3100_RX | MAX3100_D)
63 #define MAX3100_CMD (3 << 14)
65 #define MAX3100_T (1<<14)
66 #define MAX3100_R (1<<15)
68 #define MAX3100_FEN (1<<13)
69 #define MAX3100_SHDN (1<<12)
70 #define MAX3100_TM (1<<11)
71 #define MAX3100_RM (1<<10)
72 #define MAX3100_PM (1<<9)
73 #define MAX3100_RAM (1<<8)
74 #define MAX3100_IR (1<<7)
75 #define MAX3100_ST (1<<6)
76 #define MAX3100_PE (1<<5)
77 #define MAX3100_L (1<<4)
78 #define MAX3100_BAUD (0xf)
80 #define MAX3100_TE (1<<10)
81 #define MAX3100_RAFE (1<<10)
82 #define MAX3100_RTS (1<<9)
83 #define MAX3100_CTS (1<<9)
84 #define MAX3100_PT (1<<8)
85 #define MAX3100_DATA (0xff)
87 #define MAX3100_RT (MAX3100_R | MAX3100_T)
88 #define MAX3100_RTC (MAX3100_RT | MAX3100_CTS | MAX3100_RAFE)
90 /* the following simulate a status reg for ignore_status_mask */
91 #define MAX3100_STATUS_PE 1
92 #define MAX3100_STATUS_FE 2
93 #define MAX3100_STATUS_OE 4
96 struct uart_port port
;
97 struct spi_device
*spi
;
99 int cts
; /* last CTS received for flow ctrl */
100 int tx_empty
; /* last TX empty bit */
102 spinlock_t conf_lock
; /* shared data */
103 int conf_commit
; /* need to make changes */
104 int conf
; /* configuration for the MAX31000
105 * (bits 0-7, bits 8-11 are irqs) */
106 int rts_commit
; /* need to change rts */
107 int rts
; /* rts status */
108 int baud
; /* current baud rate */
110 int parity
; /* keeps track if we should send parity */
111 #define MAX3100_PARITY_ON 1
112 #define MAX3100_PARITY_ODD 2
113 #define MAX3100_7BIT 4
114 int rx_enabled
; /* if we should rx chars */
116 int irq
; /* irq assigned to the max3100 */
118 int minor
; /* minor number */
119 int crystal
; /* 1 if 3.6864Mhz crystal 0 for 1.8432 */
120 int loopback
; /* 1 if we are in loopback mode */
122 /* for handling irqs: need workqueue since we do spi_sync */
123 struct workqueue_struct
*workqueue
;
124 struct work_struct work
;
125 /* set to 1 to make the workhandler exit as soon as possible */
127 /* need to know we are suspending to avoid deadlock on workqueue */
130 /* hook for suspending MAX3100 via dedicated pin */
131 void (*max3100_hw_suspend
) (int suspend
);
133 /* poll time (in ms) for ctrl lines */
136 struct timer_list timer
;
139 static struct max3100_port
*max3100s
[MAX_MAX3100
]; /* the chips */
140 static DEFINE_MUTEX(max3100s_lock
); /* race on probe */
142 static int max3100_do_parity(struct max3100_port
*s
, u16 c
)
146 if (s
->parity
& MAX3100_PARITY_ODD
)
151 if (s
->parity
& MAX3100_7BIT
)
156 parity
= parity
^ (hweight8(c
) & 1);
160 static int max3100_check_parity(struct max3100_port
*s
, u16 c
)
162 return max3100_do_parity(s
, c
) == ((c
>> 8) & 1);
165 static void max3100_calc_parity(struct max3100_port
*s
, u16
*c
)
167 if (s
->parity
& MAX3100_7BIT
)
172 if (s
->parity
& MAX3100_PARITY_ON
)
173 *c
|= max3100_do_parity(s
, *c
) << 8;
176 static void max3100_work(struct work_struct
*w
);
178 static void max3100_dowork(struct max3100_port
*s
)
180 if (!s
->force_end_work
&& !work_pending(&s
->work
) &&
181 !freezing(current
) && !s
->suspending
)
182 queue_work(s
->workqueue
, &s
->work
);
185 static void max3100_timeout(unsigned long data
)
187 struct max3100_port
*s
= (struct max3100_port
*)data
;
191 mod_timer(&s
->timer
, jiffies
+ s
->poll_time
);
195 static int max3100_sr(struct max3100_port
*s
, u16 tx
, u16
*rx
)
197 struct spi_message message
;
200 struct spi_transfer tran
= {
206 etx
= cpu_to_be16(tx
);
207 spi_message_init(&message
);
208 spi_message_add_tail(&tran
, &message
);
209 status
= spi_sync(s
->spi
, &message
);
211 dev_warn(&s
->spi
->dev
, "error while calling spi_sync\n");
214 *rx
= be16_to_cpu(erx
);
215 s
->tx_empty
= (*rx
& MAX3100_T
) > 0;
216 dev_dbg(&s
->spi
->dev
, "%04x - %04x\n", tx
, *rx
);
220 static int max3100_handlerx(struct max3100_port
*s
, u16 rx
)
222 unsigned int ch
, flg
, status
= 0;
225 if (rx
& MAX3100_R
&& s
->rx_enabled
) {
226 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
227 ch
= rx
& (s
->parity
& MAX3100_7BIT
? 0x7f : 0xff);
228 if (rx
& MAX3100_RAFE
) {
229 s
->port
.icount
.frame
++;
231 status
|= MAX3100_STATUS_FE
;
233 if (s
->parity
& MAX3100_PARITY_ON
) {
234 if (max3100_check_parity(s
, rx
)) {
238 s
->port
.icount
.parity
++;
240 status
|= MAX3100_STATUS_PE
;
247 uart_insert_char(&s
->port
, status
, MAX3100_STATUS_OE
, ch
, flg
);
251 cts
= (rx
& MAX3100_CTS
) > 0;
254 uart_handle_cts_change(&s
->port
, cts
? TIOCM_CTS
: 0);
260 static void max3100_work(struct work_struct
*w
)
262 struct max3100_port
*s
= container_of(w
, struct max3100_port
, work
);
265 int conf
, cconf
, rts
, crts
;
266 struct circ_buf
*xmit
= &s
->port
.state
->xmit
;
268 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
272 spin_lock(&s
->conf_lock
);
274 cconf
= s
->conf_commit
;
277 crts
= s
->rts_commit
;
279 spin_unlock(&s
->conf_lock
);
281 max3100_sr(s
, MAX3100_WC
| conf
, &rx
);
283 max3100_sr(s
, MAX3100_WD
| MAX3100_TE
|
284 (s
->rts
? MAX3100_RTS
: 0), &rx
);
285 rxchars
+= max3100_handlerx(s
, rx
);
288 max3100_sr(s
, MAX3100_RD
, &rx
);
289 rxchars
+= max3100_handlerx(s
, rx
);
291 if (rx
& MAX3100_T
) {
293 if (s
->port
.x_char
) {
297 } else if (!uart_circ_empty(xmit
) &&
298 !uart_tx_stopped(&s
->port
)) {
299 tx
= xmit
->buf
[xmit
->tail
];
300 xmit
->tail
= (xmit
->tail
+ 1) &
301 (UART_XMIT_SIZE
- 1);
305 max3100_calc_parity(s
, &tx
);
306 tx
|= MAX3100_WD
| (s
->rts
? MAX3100_RTS
: 0);
307 max3100_sr(s
, tx
, &rx
);
308 rxchars
+= max3100_handlerx(s
, rx
);
312 if (rxchars
> 16 && s
->port
.state
->port
.tty
!= NULL
) {
313 tty_flip_buffer_push(s
->port
.state
->port
.tty
);
316 if (uart_circ_chars_pending(xmit
) < WAKEUP_CHARS
)
317 uart_write_wakeup(&s
->port
);
319 } while (!s
->force_end_work
&&
320 !freezing(current
) &&
322 (!uart_circ_empty(xmit
) &&
323 !uart_tx_stopped(&s
->port
))));
325 if (rxchars
> 0 && s
->port
.state
->port
.tty
!= NULL
)
326 tty_flip_buffer_push(s
->port
.state
->port
.tty
);
329 static irqreturn_t
max3100_irq(int irqno
, void *dev_id
)
331 struct max3100_port
*s
= dev_id
;
333 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
339 static void max3100_enable_ms(struct uart_port
*port
)
341 struct max3100_port
*s
= container_of(port
,
345 if (s
->poll_time
> 0)
346 mod_timer(&s
->timer
, jiffies
);
347 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
350 static void max3100_start_tx(struct uart_port
*port
)
352 struct max3100_port
*s
= container_of(port
,
356 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
361 static void max3100_stop_rx(struct uart_port
*port
)
363 struct max3100_port
*s
= container_of(port
,
367 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
370 spin_lock(&s
->conf_lock
);
371 s
->conf
&= ~MAX3100_RM
;
373 spin_unlock(&s
->conf_lock
);
377 static unsigned int max3100_tx_empty(struct uart_port
*port
)
379 struct max3100_port
*s
= container_of(port
,
383 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
385 /* may not be truly up-to-date */
390 static unsigned int max3100_get_mctrl(struct uart_port
*port
)
392 struct max3100_port
*s
= container_of(port
,
396 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
398 /* may not be truly up-to-date */
400 /* always assert DCD and DSR since these lines are not wired */
401 return (s
->cts
? TIOCM_CTS
: 0) | TIOCM_DSR
| TIOCM_CAR
;
404 static void max3100_set_mctrl(struct uart_port
*port
, unsigned int mctrl
)
406 struct max3100_port
*s
= container_of(port
,
411 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
413 rts
= (mctrl
& TIOCM_RTS
) > 0;
415 spin_lock(&s
->conf_lock
);
421 spin_unlock(&s
->conf_lock
);
425 max3100_set_termios(struct uart_port
*port
, struct ktermios
*termios
,
426 struct ktermios
*old
)
428 struct max3100_port
*s
= container_of(port
,
433 u32 param_new
, param_mask
, parity
= 0;
435 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
437 cflag
= termios
->c_cflag
;
441 baud
= tty_termios_baud_rate(termios
);
442 param_new
= s
->conf
& MAX3100_BAUD
;
451 param_new
= 14 + s
->crystal
;
454 param_new
= 13 + s
->crystal
;
457 param_new
= 12 + s
->crystal
;
460 param_new
= 11 + s
->crystal
;
463 param_new
= 10 + s
->crystal
;
466 param_new
= 9 + s
->crystal
;
469 param_new
= 8 + s
->crystal
;
472 param_new
= 1 + s
->crystal
;
475 param_new
= 0 + s
->crystal
;
486 tty_termios_encode_baud_rate(termios
, baud
, baud
);
488 param_mask
|= MAX3100_BAUD
;
490 if ((cflag
& CSIZE
) == CS8
) {
491 param_new
&= ~MAX3100_L
;
492 parity
&= ~MAX3100_7BIT
;
494 param_new
|= MAX3100_L
;
495 parity
|= MAX3100_7BIT
;
496 cflag
= (cflag
& ~CSIZE
) | CS7
;
498 param_mask
|= MAX3100_L
;
501 param_new
|= MAX3100_ST
;
503 param_new
&= ~MAX3100_ST
;
504 param_mask
|= MAX3100_ST
;
506 if (cflag
& PARENB
) {
507 param_new
|= MAX3100_PE
;
508 parity
|= MAX3100_PARITY_ON
;
510 param_new
&= ~MAX3100_PE
;
511 parity
&= ~MAX3100_PARITY_ON
;
513 param_mask
|= MAX3100_PE
;
516 parity
|= MAX3100_PARITY_ODD
;
518 parity
&= ~MAX3100_PARITY_ODD
;
520 /* mask termios capabilities we don't support */
522 termios
->c_cflag
= cflag
;
524 s
->port
.ignore_status_mask
= 0;
525 if (termios
->c_iflag
& IGNPAR
)
526 s
->port
.ignore_status_mask
|=
527 MAX3100_STATUS_PE
| MAX3100_STATUS_FE
|
530 /* we are sending char from a workqueue so enable */
531 s
->port
.state
->port
.tty
->low_latency
= 1;
533 if (s
->poll_time
> 0)
534 del_timer_sync(&s
->timer
);
536 uart_update_timeout(port
, termios
->c_cflag
, baud
);
538 spin_lock(&s
->conf_lock
);
539 s
->conf
= (s
->conf
& ~param_mask
) | (param_new
& param_mask
);
542 spin_unlock(&s
->conf_lock
);
545 if (UART_ENABLE_MS(&s
->port
, termios
->c_cflag
))
546 max3100_enable_ms(&s
->port
);
549 static void max3100_shutdown(struct uart_port
*port
)
551 struct max3100_port
*s
= container_of(port
,
555 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
560 s
->force_end_work
= 1;
562 if (s
->poll_time
> 0)
563 del_timer_sync(&s
->timer
);
566 flush_workqueue(s
->workqueue
);
567 destroy_workqueue(s
->workqueue
);
573 /* set shutdown mode to save power */
574 if (s
->max3100_hw_suspend
)
575 s
->max3100_hw_suspend(1);
579 tx
= MAX3100_WC
| MAX3100_SHDN
;
580 max3100_sr(s
, tx
, &rx
);
584 static int max3100_startup(struct uart_port
*port
)
586 struct max3100_port
*s
= container_of(port
,
591 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
593 s
->conf
= MAX3100_RM
;
594 s
->baud
= s
->crystal
? 230400 : 115200;
600 s
->force_end_work
= 0;
604 sprintf(b
, "max3100-%d", s
->minor
);
605 s
->workqueue
= create_freezable_workqueue(b
);
607 dev_warn(&s
->spi
->dev
, "cannot create workqueue\n");
610 INIT_WORK(&s
->work
, max3100_work
);
612 if (request_irq(s
->irq
, max3100_irq
,
613 IRQF_TRIGGER_FALLING
, "max3100", s
) < 0) {
614 dev_warn(&s
->spi
->dev
, "cannot allocate irq %d\n", s
->irq
);
616 destroy_workqueue(s
->workqueue
);
624 max3100_sr(s
, tx
, &rx
);
627 if (s
->max3100_hw_suspend
)
628 s
->max3100_hw_suspend(0);
631 /* wait for clock to settle */
634 max3100_enable_ms(&s
->port
);
639 static const char *max3100_type(struct uart_port
*port
)
641 struct max3100_port
*s
= container_of(port
,
645 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
647 return s
->port
.type
== PORT_MAX3100
? "MAX3100" : NULL
;
650 static void max3100_release_port(struct uart_port
*port
)
652 struct max3100_port
*s
= container_of(port
,
656 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
659 static void max3100_config_port(struct uart_port
*port
, int flags
)
661 struct max3100_port
*s
= container_of(port
,
665 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
667 if (flags
& UART_CONFIG_TYPE
)
668 s
->port
.type
= PORT_MAX3100
;
671 static int max3100_verify_port(struct uart_port
*port
,
672 struct serial_struct
*ser
)
674 struct max3100_port
*s
= container_of(port
,
679 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
681 if (ser
->type
== PORT_UNKNOWN
|| ser
->type
== PORT_MAX3100
)
686 static void max3100_stop_tx(struct uart_port
*port
)
688 struct max3100_port
*s
= container_of(port
,
692 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
695 static int max3100_request_port(struct uart_port
*port
)
697 struct max3100_port
*s
= container_of(port
,
701 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
705 static void max3100_break_ctl(struct uart_port
*port
, int break_state
)
707 struct max3100_port
*s
= container_of(port
,
711 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
714 static struct uart_ops max3100_ops
= {
715 .tx_empty
= max3100_tx_empty
,
716 .set_mctrl
= max3100_set_mctrl
,
717 .get_mctrl
= max3100_get_mctrl
,
718 .stop_tx
= max3100_stop_tx
,
719 .start_tx
= max3100_start_tx
,
720 .stop_rx
= max3100_stop_rx
,
721 .enable_ms
= max3100_enable_ms
,
722 .break_ctl
= max3100_break_ctl
,
723 .startup
= max3100_startup
,
724 .shutdown
= max3100_shutdown
,
725 .set_termios
= max3100_set_termios
,
726 .type
= max3100_type
,
727 .release_port
= max3100_release_port
,
728 .request_port
= max3100_request_port
,
729 .config_port
= max3100_config_port
,
730 .verify_port
= max3100_verify_port
,
733 static struct uart_driver max3100_uart_driver
= {
734 .owner
= THIS_MODULE
,
735 .driver_name
= "ttyMAX",
736 .dev_name
= "ttyMAX",
737 .major
= MAX3100_MAJOR
,
738 .minor
= MAX3100_MINOR
,
741 static int uart_driver_registered
;
743 static int __devinit
max3100_probe(struct spi_device
*spi
)
746 struct plat_max3100
*pdata
;
749 mutex_lock(&max3100s_lock
);
751 if (!uart_driver_registered
) {
752 uart_driver_registered
= 1;
753 retval
= uart_register_driver(&max3100_uart_driver
);
755 printk(KERN_ERR
"Couldn't register max3100 uart driver\n");
756 mutex_unlock(&max3100s_lock
);
761 for (i
= 0; i
< MAX_MAX3100
; i
++)
764 if (i
== MAX_MAX3100
) {
765 dev_warn(&spi
->dev
, "too many MAX3100 chips\n");
766 mutex_unlock(&max3100s_lock
);
770 max3100s
[i
] = kzalloc(sizeof(struct max3100_port
), GFP_KERNEL
);
773 "kmalloc for max3100 structure %d failed!\n", i
);
774 mutex_unlock(&max3100s_lock
);
777 max3100s
[i
]->spi
= spi
;
778 max3100s
[i
]->irq
= spi
->irq
;
779 spin_lock_init(&max3100s
[i
]->conf_lock
);
780 dev_set_drvdata(&spi
->dev
, max3100s
[i
]);
781 pdata
= spi
->dev
.platform_data
;
782 max3100s
[i
]->crystal
= pdata
->crystal
;
783 max3100s
[i
]->loopback
= pdata
->loopback
;
784 max3100s
[i
]->poll_time
= pdata
->poll_time
* HZ
/ 1000;
785 if (pdata
->poll_time
> 0 && max3100s
[i
]->poll_time
== 0)
786 max3100s
[i
]->poll_time
= 1;
787 max3100s
[i
]->max3100_hw_suspend
= pdata
->max3100_hw_suspend
;
788 max3100s
[i
]->minor
= i
;
789 init_timer(&max3100s
[i
]->timer
);
790 max3100s
[i
]->timer
.function
= max3100_timeout
;
791 max3100s
[i
]->timer
.data
= (unsigned long) max3100s
[i
];
793 dev_dbg(&spi
->dev
, "%s: adding port %d\n", __func__
, i
);
794 max3100s
[i
]->port
.irq
= max3100s
[i
]->irq
;
795 max3100s
[i
]->port
.uartclk
= max3100s
[i
]->crystal
? 3686400 : 1843200;
796 max3100s
[i
]->port
.fifosize
= 16;
797 max3100s
[i
]->port
.ops
= &max3100_ops
;
798 max3100s
[i
]->port
.flags
= UPF_SKIP_TEST
| UPF_BOOT_AUTOCONF
;
799 max3100s
[i
]->port
.line
= i
;
800 max3100s
[i
]->port
.type
= PORT_MAX3100
;
801 max3100s
[i
]->port
.dev
= &spi
->dev
;
802 retval
= uart_add_one_port(&max3100_uart_driver
, &max3100s
[i
]->port
);
805 "uart_add_one_port failed for line %d with error %d\n",
808 /* set shutdown mode to save power. Will be woken-up on open */
809 if (max3100s
[i
]->max3100_hw_suspend
)
810 max3100s
[i
]->max3100_hw_suspend(1);
812 tx
= MAX3100_WC
| MAX3100_SHDN
;
813 max3100_sr(max3100s
[i
], tx
, &rx
);
815 mutex_unlock(&max3100s_lock
);
819 static int __devexit
max3100_remove(struct spi_device
*spi
)
821 struct max3100_port
*s
= dev_get_drvdata(&spi
->dev
);
824 mutex_lock(&max3100s_lock
);
826 /* find out the index for the chip we are removing */
827 for (i
= 0; i
< MAX_MAX3100
; i
++)
828 if (max3100s
[i
] == s
)
831 dev_dbg(&spi
->dev
, "%s: removing port %d\n", __func__
, i
);
832 uart_remove_one_port(&max3100_uart_driver
, &max3100s
[i
]->port
);
836 /* check if this is the last chip we have */
837 for (i
= 0; i
< MAX_MAX3100
; i
++)
839 mutex_unlock(&max3100s_lock
);
842 pr_debug("removing max3100 driver\n");
843 uart_unregister_driver(&max3100_uart_driver
);
845 mutex_unlock(&max3100s_lock
);
851 static int max3100_suspend(struct spi_device
*spi
, pm_message_t state
)
853 struct max3100_port
*s
= dev_get_drvdata(&spi
->dev
);
855 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
860 uart_suspend_port(&max3100_uart_driver
, &s
->port
);
862 if (s
->max3100_hw_suspend
)
863 s
->max3100_hw_suspend(1);
865 /* no HW suspend, so do SW one */
868 tx
= MAX3100_WC
| MAX3100_SHDN
;
869 max3100_sr(s
, tx
, &rx
);
874 static int max3100_resume(struct spi_device
*spi
)
876 struct max3100_port
*s
= dev_get_drvdata(&spi
->dev
);
878 dev_dbg(&s
->spi
->dev
, "%s\n", __func__
);
880 if (s
->max3100_hw_suspend
)
881 s
->max3100_hw_suspend(0);
882 uart_resume_port(&max3100_uart_driver
, &s
->port
);
895 #define max3100_suspend NULL
896 #define max3100_resume NULL
899 static struct spi_driver max3100_driver
= {
902 .bus
= &spi_bus_type
,
903 .owner
= THIS_MODULE
,
906 .probe
= max3100_probe
,
907 .remove
= __devexit_p(max3100_remove
),
908 .suspend
= max3100_suspend
,
909 .resume
= max3100_resume
,
912 static int __init
max3100_init(void)
914 return spi_register_driver(&max3100_driver
);
916 module_init(max3100_init
);
918 static void __exit
max3100_exit(void)
920 spi_unregister_driver(&max3100_driver
);
922 module_exit(max3100_exit
);
924 MODULE_DESCRIPTION("MAX3100 driver");
925 MODULE_AUTHOR("Christian Pellegrin <chripell@evolware.org>");
926 MODULE_LICENSE("GPL");
927 MODULE_ALIAS("spi:max3100");