1 /****************************************************************************
3 * Driver for the IFX 6x60 spi modem.
5 * Copyright (C) 2008 Option International
6 * Copyright (C) 2008 Filip Aben <f.aben@option.com>
7 * Denis Joseph Barrow <d.barow@option.com>
8 * Jan Dumon <j.dumon@option.com>
10 * Copyright (C) 2009, 2010 Intel Corp
11 * Russ Gorby <russ.gorby@intel.com>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
27 * Driver modified by Intel from Option gtm501l_spi.c
30 * o The driver currently assumes a single device only. If you need to
31 * change this then look for saved_ifx_dev and add a device lookup
32 * o The driver is intended to be big-endian safe but has never been
33 * tested that way (no suitable hardware). There are a couple of FIXME
34 * notes by areas that may need addressing
35 * o Some of the GPIO naming/setup assumptions may need revisiting if
36 * you need to use this driver for another platform.
38 *****************************************************************************/
39 #include <linux/dma-mapping.h>
40 #include <linux/module.h>
41 #include <linux/termios.h>
42 #include <linux/tty.h>
43 #include <linux/device.h>
44 #include <linux/spi/spi.h>
45 #include <linux/kfifo.h>
46 #include <linux/tty_flip.h>
47 #include <linux/timer.h>
48 #include <linux/serial.h>
49 #include <linux/interrupt.h>
50 #include <linux/irq.h>
51 #include <linux/rfkill.h>
54 #include <linux/dmapool.h>
55 #include <linux/gpio.h>
56 #include <linux/sched.h>
57 #include <linux/time.h>
58 #include <linux/wait.h>
60 #include <linux/pm_runtime.h>
61 #include <linux/spi/ifx_modem.h>
62 #include <linux/delay.h>
63 #include <linux/reboot.h>
67 #define IFX_SPI_MORE_MASK 0x10
68 #define IFX_SPI_MORE_BIT 4 /* bit position in u8 */
69 #define IFX_SPI_CTS_BIT 6 /* bit position in u8 */
70 #define IFX_SPI_MODE SPI_MODE_1
71 #define IFX_SPI_TTY_ID 0
72 #define IFX_SPI_TIMEOUT_SEC 2
73 #define IFX_SPI_HEADER_0 (-1)
74 #define IFX_SPI_HEADER_F (-2)
76 #define PO_POST_DELAY 200
77 #define IFX_MDM_RST_PMU 4
79 /* forward reference */
80 static void ifx_spi_handle_srdy(struct ifx_spi_device
*ifx_dev
);
81 static int ifx_modem_reboot_callback(struct notifier_block
*nfb
,
82 unsigned long event
, void *data
);
83 static int ifx_modem_power_off(struct ifx_spi_device
*ifx_dev
);
86 static int spi_bpw
= 16; /* 8, 16 or 32 bit word length */
87 static struct tty_driver
*tty_drv
;
88 static struct ifx_spi_device
*saved_ifx_dev
;
89 static struct lock_class_key ifx_spi_key
;
91 static struct notifier_block ifx_modem_reboot_notifier_block
= {
92 .notifier_call
= ifx_modem_reboot_callback
,
95 static int ifx_modem_power_off(struct ifx_spi_device
*ifx_dev
)
97 gpio_set_value(IFX_MDM_RST_PMU
, 1);
98 msleep(PO_POST_DELAY
);
103 static int ifx_modem_reboot_callback(struct notifier_block
*nfb
,
104 unsigned long event
, void *data
)
107 ifx_modem_power_off(saved_ifx_dev
);
109 pr_warn("no ifx modem active;\n");
114 /* GPIO/GPE settings */
117 * mrdy_set_high - set MRDY GPIO
118 * @ifx: device we are controlling
121 static inline void mrdy_set_high(struct ifx_spi_device
*ifx
)
123 gpio_set_value(ifx
->gpio
.mrdy
, 1);
127 * mrdy_set_low - clear MRDY GPIO
128 * @ifx: device we are controlling
131 static inline void mrdy_set_low(struct ifx_spi_device
*ifx
)
133 gpio_set_value(ifx
->gpio
.mrdy
, 0);
137 * ifx_spi_power_state_set
138 * @ifx_dev: our SPI device
141 * Set bit in power status and signal power system if status becomes non-0
144 ifx_spi_power_state_set(struct ifx_spi_device
*ifx_dev
, unsigned char val
)
148 spin_lock_irqsave(&ifx_dev
->power_lock
, flags
);
151 * if power status is already non-0, just update, else
154 if (!ifx_dev
->power_status
)
155 pm_runtime_get(&ifx_dev
->spi_dev
->dev
);
156 ifx_dev
->power_status
|= val
;
158 spin_unlock_irqrestore(&ifx_dev
->power_lock
, flags
);
162 * ifx_spi_power_state_clear - clear power bit
163 * @ifx_dev: our SPI device
164 * @val: bits to clear
166 * clear bit in power status and signal power system if status becomes 0
169 ifx_spi_power_state_clear(struct ifx_spi_device
*ifx_dev
, unsigned char val
)
173 spin_lock_irqsave(&ifx_dev
->power_lock
, flags
);
175 if (ifx_dev
->power_status
) {
176 ifx_dev
->power_status
&= ~val
;
177 if (!ifx_dev
->power_status
)
178 pm_runtime_put(&ifx_dev
->spi_dev
->dev
);
181 spin_unlock_irqrestore(&ifx_dev
->power_lock
, flags
);
187 * @len : number of bytes (not words) in the buffer
188 * @end: end of buffer
190 * Swap the contents of a buffer into big endian format
192 static inline void swap_buf_8(unsigned char *buf
, int len
, void *end
)
194 /* don't swap buffer if SPI word width is 8 bits */
201 * @len : number of bytes (not words) in the buffer
202 * @end: end of buffer
204 * Swap the contents of a buffer into big endian format
206 static inline void swap_buf_16(unsigned char *buf
, int len
, void *end
)
210 u16
*buf_16
= (u16
*)buf
;
211 len
= ((len
+ 1) >> 1);
212 if ((void *)&buf_16
[len
] > end
) {
213 pr_err("swap_buf_16: swap exceeds boundary (%p > %p)!",
217 for (n
= 0; n
< len
; n
++) {
218 *buf_16
= cpu_to_be16(*buf_16
);
226 * @len : number of bytes (not words) in the buffer
227 * @end: end of buffer
229 * Swap the contents of a buffer into big endian format
231 static inline void swap_buf_32(unsigned char *buf
, int len
, void *end
)
235 u32
*buf_32
= (u32
*)buf
;
236 len
= (len
+ 3) >> 2;
238 if ((void *)&buf_32
[len
] > end
) {
239 pr_err("swap_buf_32: swap exceeds boundary (%p > %p)!\n",
243 for (n
= 0; n
< len
; n
++) {
244 *buf_32
= cpu_to_be32(*buf_32
);
250 * mrdy_assert - assert MRDY line
251 * @ifx_dev: our SPI device
253 * Assert mrdy and set timer to wait for SRDY interrupt, if SRDY is low
256 * FIXME: Can SRDY even go high as we are running this code ?
258 static void mrdy_assert(struct ifx_spi_device
*ifx_dev
)
260 int val
= gpio_get_value(ifx_dev
->gpio
.srdy
);
262 if (!test_and_set_bit(IFX_SPI_STATE_TIMER_PENDING
,
264 mod_timer(&ifx_dev
->spi_timer
,jiffies
+ IFX_SPI_TIMEOUT_SEC
*HZ
);
268 ifx_spi_power_state_set(ifx_dev
, IFX_SPI_POWER_DATA_PENDING
);
269 mrdy_set_high(ifx_dev
);
273 * ifx_spi_hangup - hang up an IFX device
274 * @ifx_dev: our SPI device
276 * Hang up the tty attached to the IFX device if one is currently
277 * open. If not take no action
279 static void ifx_spi_ttyhangup(struct ifx_spi_device
*ifx_dev
)
281 struct tty_port
*pport
= &ifx_dev
->tty_port
;
282 struct tty_struct
*tty
= tty_port_tty_get(pport
);
290 * ifx_spi_timeout - SPI timeout
291 * @arg: our SPI device
293 * The SPI has timed out: hang up the tty. Users will then see a hangup
296 static void ifx_spi_timeout(unsigned long arg
)
298 struct ifx_spi_device
*ifx_dev
= (struct ifx_spi_device
*)arg
;
300 dev_warn(&ifx_dev
->spi_dev
->dev
, "*** SPI Timeout ***");
301 ifx_spi_ttyhangup(ifx_dev
);
302 mrdy_set_low(ifx_dev
);
303 clear_bit(IFX_SPI_STATE_TIMER_PENDING
, &ifx_dev
->flags
);
306 /* char/tty operations */
309 * ifx_spi_tiocmget - get modem lines
310 * @tty: our tty device
311 * @filp: file handle issuing the request
313 * Map the signal state into Linux modem flags and report the value
316 static int ifx_spi_tiocmget(struct tty_struct
*tty
)
319 struct ifx_spi_device
*ifx_dev
= tty
->driver_data
;
322 (test_bit(IFX_SPI_RTS
, &ifx_dev
->signal_state
) ? TIOCM_RTS
: 0) |
323 (test_bit(IFX_SPI_DTR
, &ifx_dev
->signal_state
) ? TIOCM_DTR
: 0) |
324 (test_bit(IFX_SPI_CTS
, &ifx_dev
->signal_state
) ? TIOCM_CTS
: 0) |
325 (test_bit(IFX_SPI_DSR
, &ifx_dev
->signal_state
) ? TIOCM_DSR
: 0) |
326 (test_bit(IFX_SPI_DCD
, &ifx_dev
->signal_state
) ? TIOCM_CAR
: 0) |
327 (test_bit(IFX_SPI_RI
, &ifx_dev
->signal_state
) ? TIOCM_RNG
: 0);
332 * ifx_spi_tiocmset - set modem bits
333 * @tty: the tty structure
335 * @clear: bits to clear
337 * The IFX6x60 only supports DTR and RTS. Set them accordingly
338 * and flag that an update to the modem is needed.
340 * FIXME: do we need to kick the tranfers when we do this ?
342 static int ifx_spi_tiocmset(struct tty_struct
*tty
,
343 unsigned int set
, unsigned int clear
)
345 struct ifx_spi_device
*ifx_dev
= tty
->driver_data
;
348 set_bit(IFX_SPI_RTS
, &ifx_dev
->signal_state
);
350 set_bit(IFX_SPI_DTR
, &ifx_dev
->signal_state
);
351 if (clear
& TIOCM_RTS
)
352 clear_bit(IFX_SPI_RTS
, &ifx_dev
->signal_state
);
353 if (clear
& TIOCM_DTR
)
354 clear_bit(IFX_SPI_DTR
, &ifx_dev
->signal_state
);
356 set_bit(IFX_SPI_UPDATE
, &ifx_dev
->signal_state
);
361 * ifx_spi_open - called on tty open
362 * @tty: our tty device
363 * @filp: file handle being associated with the tty
365 * Open the tty interface. We let the tty_port layer do all the work
368 * FIXME: Remove single device assumption and saved_ifx_dev
370 static int ifx_spi_open(struct tty_struct
*tty
, struct file
*filp
)
372 return tty_port_open(&saved_ifx_dev
->tty_port
, tty
, filp
);
376 * ifx_spi_close - called when our tty closes
377 * @tty: the tty being closed
378 * @filp: the file handle being closed
380 * Perform the close of the tty. We use the tty_port layer to do all
383 static void ifx_spi_close(struct tty_struct
*tty
, struct file
*filp
)
385 struct ifx_spi_device
*ifx_dev
= tty
->driver_data
;
386 tty_port_close(&ifx_dev
->tty_port
, tty
, filp
);
387 /* FIXME: should we do an ifx_spi_reset here ? */
391 * ifx_decode_spi_header - decode received header
392 * @buffer: the received data
393 * @length: decoded length
394 * @more: decoded more flag
395 * @received_cts: status of cts we received
397 * Note how received_cts is handled -- if header is all F it is left
398 * the same as it was, if header is all 0 it is set to 0 otherwise it is
399 * taken from the incoming header.
403 static int ifx_spi_decode_spi_header(unsigned char *buffer
, int *length
,
404 unsigned char *more
, unsigned char *received_cts
)
408 u16
*in_buffer
= (u16
*)buffer
;
413 if (h1
== 0 && h2
== 0) {
415 return IFX_SPI_HEADER_0
;
416 } else if (h1
== 0xffff && h2
== 0xffff) {
417 /* spi_slave_cts remains as it was */
418 return IFX_SPI_HEADER_F
;
421 *length
= h1
& 0xfff; /* upper bits of byte are flags */
422 *more
= (buffer
[1] >> IFX_SPI_MORE_BIT
) & 1;
423 *received_cts
= (buffer
[3] >> IFX_SPI_CTS_BIT
) & 1;
428 * ifx_setup_spi_header - set header fields
429 * @txbuffer: pointer to start of SPI buffer
431 * @more: indicate if more to follow
433 * Format up an SPI header for a transfer
437 static void ifx_spi_setup_spi_header(unsigned char *txbuffer
, int tx_count
,
440 *(u16
*)(txbuffer
) = tx_count
;
441 *(u16
*)(txbuffer
+2) = IFX_SPI_PAYLOAD_SIZE
;
442 txbuffer
[1] |= (more
<< IFX_SPI_MORE_BIT
) & IFX_SPI_MORE_MASK
;
446 * ifx_spi_wakeup_serial - SPI space made
447 * @port_data: our SPI device
449 * We have emptied the FIFO enough that we want to get more data
450 * queued into it. Poke the line discipline via tty_wakeup so that
451 * it will feed us more bits
453 static void ifx_spi_wakeup_serial(struct ifx_spi_device
*ifx_dev
)
455 struct tty_struct
*tty
;
457 tty
= tty_port_tty_get(&ifx_dev
->tty_port
);
465 * ifx_spi_prepare_tx_buffer - prepare transmit frame
466 * @ifx_dev: our SPI device
468 * The transmit buffr needs a header and various other bits of
469 * information followed by as much data as we can pull from the FIFO
470 * and transfer. This function formats up a suitable buffer in the
473 * FIXME: performance - should we wake the tty when the queue is half
476 static int ifx_spi_prepare_tx_buffer(struct ifx_spi_device
*ifx_dev
)
481 unsigned char *tx_buffer
;
483 tx_buffer
= ifx_dev
->tx_buffer
;
485 /* make room for required SPI header */
486 tx_buffer
+= IFX_SPI_HEADER_OVERHEAD
;
487 tx_count
= IFX_SPI_HEADER_OVERHEAD
;
489 /* clear to signal no more data if this turns out to be the
490 * last buffer sent in a sequence */
491 ifx_dev
->spi_more
= 0;
493 /* if modem cts is set, just send empty buffer */
494 if (!ifx_dev
->spi_slave_cts
) {
495 /* see if there's tx data */
496 queue_length
= kfifo_len(&ifx_dev
->tx_fifo
);
497 if (queue_length
!= 0) {
498 /* data to mux -- see if there's room for it */
499 temp_count
= min(queue_length
, IFX_SPI_PAYLOAD_SIZE
);
500 temp_count
= kfifo_out_locked(&ifx_dev
->tx_fifo
,
501 tx_buffer
, temp_count
,
502 &ifx_dev
->fifo_lock
);
504 /* update buffer pointer and data count in message */
505 tx_buffer
+= temp_count
;
506 tx_count
+= temp_count
;
507 if (temp_count
== queue_length
)
508 /* poke port to get more data */
509 ifx_spi_wakeup_serial(ifx_dev
);
510 else /* more data in port, use next SPI message */
511 ifx_dev
->spi_more
= 1;
514 /* have data and info for header -- set up SPI header in buffer */
515 /* spi header needs payload size, not entire buffer size */
516 ifx_spi_setup_spi_header(ifx_dev
->tx_buffer
,
517 tx_count
-IFX_SPI_HEADER_OVERHEAD
,
519 /* swap actual data in the buffer */
520 ifx_dev
->swap_buf((ifx_dev
->tx_buffer
), tx_count
,
521 &ifx_dev
->tx_buffer
[IFX_SPI_TRANSFER_SIZE
]);
526 * ifx_spi_write - line discipline write
527 * @tty: our tty device
528 * @buf: pointer to buffer to write (kernel space)
529 * @count: size of buffer
531 * Write the characters we have been given into the FIFO. If the device
532 * is not active then activate it, when the SRDY line is asserted back
533 * this will commence I/O
535 static int ifx_spi_write(struct tty_struct
*tty
, const unsigned char *buf
,
538 struct ifx_spi_device
*ifx_dev
= tty
->driver_data
;
539 unsigned char *tmp_buf
= (unsigned char *)buf
;
544 spin_lock_irqsave(&ifx_dev
->fifo_lock
, flags
);
545 is_fifo_empty
= kfifo_is_empty(&ifx_dev
->tx_fifo
);
546 tx_count
= kfifo_in(&ifx_dev
->tx_fifo
, tmp_buf
, count
);
547 spin_unlock_irqrestore(&ifx_dev
->fifo_lock
, flags
);
549 mrdy_assert(ifx_dev
);
555 * ifx_spi_chars_in_buffer - line discipline helper
556 * @tty: our tty device
558 * Report how much data we can accept before we drop bytes. As we use
559 * a simple FIFO this is nice and easy.
561 static int ifx_spi_write_room(struct tty_struct
*tty
)
563 struct ifx_spi_device
*ifx_dev
= tty
->driver_data
;
564 return IFX_SPI_FIFO_SIZE
- kfifo_len(&ifx_dev
->tx_fifo
);
568 * ifx_spi_chars_in_buffer - line discipline helper
569 * @tty: our tty device
571 * Report how many characters we have buffered. In our case this is the
572 * number of bytes sitting in our transmit FIFO.
574 static int ifx_spi_chars_in_buffer(struct tty_struct
*tty
)
576 struct ifx_spi_device
*ifx_dev
= tty
->driver_data
;
577 return kfifo_len(&ifx_dev
->tx_fifo
);
582 * @port: our tty port
584 * tty port hang up. Called when tty_hangup processing is invoked either
585 * by loss of carrier, or by software (eg vhangup). Serialized against
586 * activate/shutdown by the tty layer.
588 static void ifx_spi_hangup(struct tty_struct
*tty
)
590 struct ifx_spi_device
*ifx_dev
= tty
->driver_data
;
591 tty_port_hangup(&ifx_dev
->tty_port
);
596 * @port: our tty port
598 * tty port activate method - called for first open. Serialized
599 * with hangup and shutdown by the tty layer.
601 static int ifx_port_activate(struct tty_port
*port
, struct tty_struct
*tty
)
603 struct ifx_spi_device
*ifx_dev
=
604 container_of(port
, struct ifx_spi_device
, tty_port
);
606 /* clear any old data; can't do this in 'close' */
607 kfifo_reset(&ifx_dev
->tx_fifo
);
609 /* clear any flag which may be set in port shutdown procedure */
610 clear_bit(IFX_SPI_STATE_IO_IN_PROGRESS
, &ifx_dev
->flags
);
611 clear_bit(IFX_SPI_STATE_IO_READY
, &ifx_dev
->flags
);
613 /* put port data into this tty */
614 tty
->driver_data
= ifx_dev
;
616 /* allows flip string push from int context */
617 port
->low_latency
= 1;
619 /* set flag to allows data transfer */
620 set_bit(IFX_SPI_STATE_IO_AVAILABLE
, &ifx_dev
->flags
);
627 * @port: our tty port
629 * tty port shutdown method - called for last port close. Serialized
630 * with hangup and activate by the tty layer.
632 static void ifx_port_shutdown(struct tty_port
*port
)
634 struct ifx_spi_device
*ifx_dev
=
635 container_of(port
, struct ifx_spi_device
, tty_port
);
637 clear_bit(IFX_SPI_STATE_IO_AVAILABLE
, &ifx_dev
->flags
);
638 mrdy_set_low(ifx_dev
);
639 del_timer(&ifx_dev
->spi_timer
);
640 clear_bit(IFX_SPI_STATE_TIMER_PENDING
, &ifx_dev
->flags
);
641 tasklet_kill(&ifx_dev
->io_work_tasklet
);
644 static const struct tty_port_operations ifx_tty_port_ops
= {
645 .activate
= ifx_port_activate
,
646 .shutdown
= ifx_port_shutdown
,
649 static const struct tty_operations ifx_spi_serial_ops
= {
650 .open
= ifx_spi_open
,
651 .close
= ifx_spi_close
,
652 .write
= ifx_spi_write
,
653 .hangup
= ifx_spi_hangup
,
654 .write_room
= ifx_spi_write_room
,
655 .chars_in_buffer
= ifx_spi_chars_in_buffer
,
656 .tiocmget
= ifx_spi_tiocmget
,
657 .tiocmset
= ifx_spi_tiocmset
,
661 * ifx_spi_insert_fip_string - queue received data
662 * @ifx_ser: our SPI device
663 * @chars: buffer we have received
664 * @size: number of chars reeived
666 * Queue bytes to the tty assuming the tty side is currently open. If
667 * not the discard the data.
669 static void ifx_spi_insert_flip_string(struct ifx_spi_device
*ifx_dev
,
670 unsigned char *chars
, size_t size
)
672 tty_insert_flip_string(&ifx_dev
->tty_port
, chars
, size
);
673 tty_flip_buffer_push(&ifx_dev
->tty_port
);
677 * ifx_spi_complete - SPI transfer completed
678 * @ctx: our SPI device
680 * An SPI transfer has completed. Process any received data and kick off
681 * any further transmits we can commence.
683 static void ifx_spi_complete(void *ctx
)
685 struct ifx_spi_device
*ifx_dev
= ctx
;
686 struct tty_struct
*tty
;
687 struct tty_ldisc
*ldisc
= NULL
;
692 int local_write_pending
= 0;
697 mrdy_set_low(ifx_dev
);
699 if (!ifx_dev
->spi_msg
.status
) {
700 /* check header validity, get comm flags */
701 ifx_dev
->swap_buf(ifx_dev
->rx_buffer
, IFX_SPI_HEADER_OVERHEAD
,
702 &ifx_dev
->rx_buffer
[IFX_SPI_HEADER_OVERHEAD
]);
703 decode_result
= ifx_spi_decode_spi_header(ifx_dev
->rx_buffer
,
704 &length
, &more
, &cts
);
705 if (decode_result
== IFX_SPI_HEADER_0
) {
706 dev_dbg(&ifx_dev
->spi_dev
->dev
,
707 "ignore input: invalid header 0");
708 ifx_dev
->spi_slave_cts
= 0;
710 } else if (decode_result
== IFX_SPI_HEADER_F
) {
711 dev_dbg(&ifx_dev
->spi_dev
->dev
,
712 "ignore input: invalid header F");
716 ifx_dev
->spi_slave_cts
= cts
;
718 actual_length
= min((unsigned int)length
,
719 ifx_dev
->spi_msg
.actual_length
);
721 (ifx_dev
->rx_buffer
+ IFX_SPI_HEADER_OVERHEAD
),
723 &ifx_dev
->rx_buffer
[IFX_SPI_TRANSFER_SIZE
]);
724 ifx_spi_insert_flip_string(
726 ifx_dev
->rx_buffer
+ IFX_SPI_HEADER_OVERHEAD
,
727 (size_t)actual_length
);
729 dev_dbg(&ifx_dev
->spi_dev
->dev
, "SPI transfer error %d",
730 ifx_dev
->spi_msg
.status
);
734 if (ifx_dev
->write_pending
) {
735 ifx_dev
->write_pending
= 0;
736 local_write_pending
= 1;
739 clear_bit(IFX_SPI_STATE_IO_IN_PROGRESS
, &(ifx_dev
->flags
));
741 queue_length
= kfifo_len(&ifx_dev
->tx_fifo
);
742 srdy
= gpio_get_value(ifx_dev
->gpio
.srdy
);
744 ifx_spi_power_state_clear(ifx_dev
, IFX_SPI_POWER_SRDY
);
746 /* schedule output if there is more to do */
747 if (test_and_clear_bit(IFX_SPI_STATE_IO_READY
, &ifx_dev
->flags
))
748 tasklet_schedule(&ifx_dev
->io_work_tasklet
);
750 if (more
|| ifx_dev
->spi_more
|| queue_length
> 0 ||
751 local_write_pending
) {
752 if (ifx_dev
->spi_slave_cts
) {
754 mrdy_assert(ifx_dev
);
756 mrdy_assert(ifx_dev
);
759 * poke line discipline driver if any for more data
760 * may or may not get more data to write
761 * for now, say not busy
763 ifx_spi_power_state_clear(ifx_dev
,
764 IFX_SPI_POWER_DATA_PENDING
);
765 tty
= tty_port_tty_get(&ifx_dev
->tty_port
);
767 ldisc
= tty_ldisc_ref(tty
);
769 ldisc
->ops
->write_wakeup(tty
);
770 tty_ldisc_deref(ldisc
);
779 * ifx_spio_io - I/O tasklet
780 * @data: our SPI device
782 * Queue data for transmission if possible and then kick off the
785 static void ifx_spi_io(unsigned long data
)
788 struct ifx_spi_device
*ifx_dev
= (struct ifx_spi_device
*) data
;
790 if (!test_and_set_bit(IFX_SPI_STATE_IO_IN_PROGRESS
, &ifx_dev
->flags
) &&
791 test_bit(IFX_SPI_STATE_IO_AVAILABLE
, &ifx_dev
->flags
)) {
792 if (ifx_dev
->gpio
.unack_srdy_int_nb
> 0)
793 ifx_dev
->gpio
.unack_srdy_int_nb
--;
795 ifx_spi_prepare_tx_buffer(ifx_dev
);
797 spi_message_init(&ifx_dev
->spi_msg
);
798 INIT_LIST_HEAD(&ifx_dev
->spi_msg
.queue
);
800 ifx_dev
->spi_msg
.context
= ifx_dev
;
801 ifx_dev
->spi_msg
.complete
= ifx_spi_complete
;
803 /* set up our spi transfer */
804 /* note len is BYTES, not transfers */
805 ifx_dev
->spi_xfer
.len
= IFX_SPI_TRANSFER_SIZE
;
806 ifx_dev
->spi_xfer
.cs_change
= 0;
807 ifx_dev
->spi_xfer
.speed_hz
= ifx_dev
->spi_dev
->max_speed_hz
;
808 /* ifx_dev->spi_xfer.speed_hz = 390625; */
809 ifx_dev
->spi_xfer
.bits_per_word
=
810 ifx_dev
->spi_dev
->bits_per_word
;
812 ifx_dev
->spi_xfer
.tx_buf
= ifx_dev
->tx_buffer
;
813 ifx_dev
->spi_xfer
.rx_buf
= ifx_dev
->rx_buffer
;
818 if (ifx_dev
->use_dma
) {
819 ifx_dev
->spi_msg
.is_dma_mapped
= 1;
820 ifx_dev
->tx_dma
= ifx_dev
->tx_bus
;
821 ifx_dev
->rx_dma
= ifx_dev
->rx_bus
;
822 ifx_dev
->spi_xfer
.tx_dma
= ifx_dev
->tx_dma
;
823 ifx_dev
->spi_xfer
.rx_dma
= ifx_dev
->rx_dma
;
825 ifx_dev
->spi_msg
.is_dma_mapped
= 0;
826 ifx_dev
->tx_dma
= (dma_addr_t
)0;
827 ifx_dev
->rx_dma
= (dma_addr_t
)0;
828 ifx_dev
->spi_xfer
.tx_dma
= (dma_addr_t
)0;
829 ifx_dev
->spi_xfer
.rx_dma
= (dma_addr_t
)0;
832 spi_message_add_tail(&ifx_dev
->spi_xfer
, &ifx_dev
->spi_msg
);
834 /* Assert MRDY. This may have already been done by the write
837 mrdy_assert(ifx_dev
);
839 retval
= spi_async(ifx_dev
->spi_dev
, &ifx_dev
->spi_msg
);
841 clear_bit(IFX_SPI_STATE_IO_IN_PROGRESS
,
843 tasklet_schedule(&ifx_dev
->io_work_tasklet
);
847 ifx_dev
->write_pending
= 1;
851 * ifx_spi_free_port - free up the tty side
852 * @ifx_dev: IFX device going away
854 * Unregister and free up a port when the device goes away
856 static void ifx_spi_free_port(struct ifx_spi_device
*ifx_dev
)
858 if (ifx_dev
->tty_dev
)
859 tty_unregister_device(tty_drv
, ifx_dev
->minor
);
860 tty_port_destroy(&ifx_dev
->tty_port
);
861 kfifo_free(&ifx_dev
->tx_fifo
);
865 * ifx_spi_create_port - create a new port
866 * @ifx_dev: our spi device
868 * Allocate and initialise the tty port that goes with this interface
869 * and add it to the tty layer so that it can be opened.
871 static int ifx_spi_create_port(struct ifx_spi_device
*ifx_dev
)
874 struct tty_port
*pport
= &ifx_dev
->tty_port
;
876 spin_lock_init(&ifx_dev
->fifo_lock
);
877 lockdep_set_class_and_subclass(&ifx_dev
->fifo_lock
,
880 if (kfifo_alloc(&ifx_dev
->tx_fifo
, IFX_SPI_FIFO_SIZE
, GFP_KERNEL
)) {
885 tty_port_init(pport
);
886 pport
->ops
= &ifx_tty_port_ops
;
887 ifx_dev
->minor
= IFX_SPI_TTY_ID
;
888 ifx_dev
->tty_dev
= tty_port_register_device(pport
, tty_drv
,
889 ifx_dev
->minor
, &ifx_dev
->spi_dev
->dev
);
890 if (IS_ERR(ifx_dev
->tty_dev
)) {
891 dev_dbg(&ifx_dev
->spi_dev
->dev
,
892 "%s: registering tty device failed", __func__
);
893 ret
= PTR_ERR(ifx_dev
->tty_dev
);
899 tty_port_destroy(pport
);
901 ifx_spi_free_port(ifx_dev
);
906 * ifx_spi_handle_srdy - handle SRDY
907 * @ifx_dev: device asserting SRDY
909 * Check our device state and see what we need to kick off when SRDY
910 * is asserted. This usually means killing the timer and firing off the
913 static void ifx_spi_handle_srdy(struct ifx_spi_device
*ifx_dev
)
915 if (test_bit(IFX_SPI_STATE_TIMER_PENDING
, &ifx_dev
->flags
)) {
916 del_timer(&ifx_dev
->spi_timer
);
917 clear_bit(IFX_SPI_STATE_TIMER_PENDING
, &ifx_dev
->flags
);
920 ifx_spi_power_state_set(ifx_dev
, IFX_SPI_POWER_SRDY
);
922 if (!test_bit(IFX_SPI_STATE_IO_IN_PROGRESS
, &ifx_dev
->flags
))
923 tasklet_schedule(&ifx_dev
->io_work_tasklet
);
925 set_bit(IFX_SPI_STATE_IO_READY
, &ifx_dev
->flags
);
929 * ifx_spi_srdy_interrupt - SRDY asserted
930 * @irq: our IRQ number
931 * @dev: our ifx device
933 * The modem asserted SRDY. Handle the srdy event
935 static irqreturn_t
ifx_spi_srdy_interrupt(int irq
, void *dev
)
937 struct ifx_spi_device
*ifx_dev
= dev
;
938 ifx_dev
->gpio
.unack_srdy_int_nb
++;
939 ifx_spi_handle_srdy(ifx_dev
);
944 * ifx_spi_reset_interrupt - Modem has changed reset state
945 * @irq: interrupt number
946 * @dev: our device pointer
948 * The modem has either entered or left reset state. Check the GPIO
951 * FIXME: review locking on MR_INPROGRESS versus
952 * parallel unsolicited reset/solicited reset
954 static irqreturn_t
ifx_spi_reset_interrupt(int irq
, void *dev
)
956 struct ifx_spi_device
*ifx_dev
= dev
;
957 int val
= gpio_get_value(ifx_dev
->gpio
.reset_out
);
958 int solreset
= test_bit(MR_START
, &ifx_dev
->mdm_reset_state
);
962 set_bit(MR_INPROGRESS
, &ifx_dev
->mdm_reset_state
);
964 /* unsolicited reset */
965 ifx_spi_ttyhangup(ifx_dev
);
969 clear_bit(MR_INPROGRESS
, &ifx_dev
->mdm_reset_state
);
971 set_bit(MR_COMPLETE
, &ifx_dev
->mdm_reset_state
);
972 wake_up(&ifx_dev
->mdm_reset_wait
);
979 * ifx_spi_free_device - free device
980 * @ifx_dev: device to free
982 * Free the IFX device
984 static void ifx_spi_free_device(struct ifx_spi_device
*ifx_dev
)
986 ifx_spi_free_port(ifx_dev
);
987 dma_free_coherent(&ifx_dev
->spi_dev
->dev
,
988 IFX_SPI_TRANSFER_SIZE
,
991 dma_free_coherent(&ifx_dev
->spi_dev
->dev
,
992 IFX_SPI_TRANSFER_SIZE
,
998 * ifx_spi_reset - reset modem
999 * @ifx_dev: modem to reset
1001 * Perform a reset on the modem
1003 static int ifx_spi_reset(struct ifx_spi_device
*ifx_dev
)
1007 * set up modem power, reset
1009 * delays are required on some platforms for the modem
1012 set_bit(MR_START
, &ifx_dev
->mdm_reset_state
);
1013 gpio_set_value(ifx_dev
->gpio
.po
, 0);
1014 gpio_set_value(ifx_dev
->gpio
.reset
, 0);
1016 gpio_set_value(ifx_dev
->gpio
.reset
, 1);
1018 gpio_set_value(ifx_dev
->gpio
.po
, 1);
1020 gpio_set_value(ifx_dev
->gpio
.po
, 0);
1021 ret
= wait_event_timeout(ifx_dev
->mdm_reset_wait
,
1022 test_bit(MR_COMPLETE
,
1023 &ifx_dev
->mdm_reset_state
),
1026 dev_warn(&ifx_dev
->spi_dev
->dev
, "Modem reset timeout: (state:%lx)",
1027 ifx_dev
->mdm_reset_state
);
1029 ifx_dev
->mdm_reset_state
= 0;
1034 * ifx_spi_spi_probe - probe callback
1035 * @spi: our possible matching SPI device
1037 * Probe for a 6x60 modem on SPI bus. Perform any needed device and
1041 * - Support for multiple devices
1042 * - Split out MID specific GPIO handling eventually
1045 static int ifx_spi_spi_probe(struct spi_device
*spi
)
1049 struct ifx_modem_platform_data
*pl_data
;
1050 struct ifx_spi_device
*ifx_dev
;
1052 if (saved_ifx_dev
) {
1053 dev_dbg(&spi
->dev
, "ignoring subsequent detection");
1057 pl_data
= (struct ifx_modem_platform_data
*)spi
->dev
.platform_data
;
1059 dev_err(&spi
->dev
, "missing platform data!");
1063 /* initialize structure to hold our device variables */
1064 ifx_dev
= kzalloc(sizeof(struct ifx_spi_device
), GFP_KERNEL
);
1066 dev_err(&spi
->dev
, "spi device allocation failed");
1069 saved_ifx_dev
= ifx_dev
;
1070 ifx_dev
->spi_dev
= spi
;
1071 clear_bit(IFX_SPI_STATE_IO_IN_PROGRESS
, &ifx_dev
->flags
);
1072 spin_lock_init(&ifx_dev
->write_lock
);
1073 spin_lock_init(&ifx_dev
->power_lock
);
1074 ifx_dev
->power_status
= 0;
1075 init_timer(&ifx_dev
->spi_timer
);
1076 ifx_dev
->spi_timer
.function
= ifx_spi_timeout
;
1077 ifx_dev
->spi_timer
.data
= (unsigned long)ifx_dev
;
1078 ifx_dev
->modem
= pl_data
->modem_type
;
1079 ifx_dev
->use_dma
= pl_data
->use_dma
;
1080 ifx_dev
->max_hz
= pl_data
->max_hz
;
1081 /* initialize spi mode, etc */
1082 spi
->max_speed_hz
= ifx_dev
->max_hz
;
1083 spi
->mode
= IFX_SPI_MODE
| (SPI_LOOP
& spi
->mode
);
1084 spi
->bits_per_word
= spi_bpw
;
1085 ret
= spi_setup(spi
);
1087 dev_err(&spi
->dev
, "SPI setup wasn't successful %d", ret
);
1091 /* init swap_buf function according to word width configuration */
1092 if (spi
->bits_per_word
== 32)
1093 ifx_dev
->swap_buf
= swap_buf_32
;
1094 else if (spi
->bits_per_word
== 16)
1095 ifx_dev
->swap_buf
= swap_buf_16
;
1097 ifx_dev
->swap_buf
= swap_buf_8
;
1099 /* ensure SPI protocol flags are initialized to enable transfer */
1100 ifx_dev
->spi_more
= 0;
1101 ifx_dev
->spi_slave_cts
= 0;
1103 /*initialize transfer and dma buffers */
1104 ifx_dev
->tx_buffer
= dma_alloc_coherent(ifx_dev
->spi_dev
->dev
.parent
,
1105 IFX_SPI_TRANSFER_SIZE
,
1108 if (!ifx_dev
->tx_buffer
) {
1109 dev_err(&spi
->dev
, "DMA-TX buffer allocation failed");
1113 ifx_dev
->rx_buffer
= dma_alloc_coherent(ifx_dev
->spi_dev
->dev
.parent
,
1114 IFX_SPI_TRANSFER_SIZE
,
1117 if (!ifx_dev
->rx_buffer
) {
1118 dev_err(&spi
->dev
, "DMA-RX buffer allocation failed");
1123 /* initialize waitq for modem reset */
1124 init_waitqueue_head(&ifx_dev
->mdm_reset_wait
);
1126 spi_set_drvdata(spi
, ifx_dev
);
1127 tasklet_init(&ifx_dev
->io_work_tasklet
, ifx_spi_io
,
1128 (unsigned long)ifx_dev
);
1130 set_bit(IFX_SPI_STATE_PRESENT
, &ifx_dev
->flags
);
1132 /* create our tty port */
1133 ret
= ifx_spi_create_port(ifx_dev
);
1135 dev_err(&spi
->dev
, "create default tty port failed");
1139 ifx_dev
->gpio
.reset
= pl_data
->rst_pmu
;
1140 ifx_dev
->gpio
.po
= pl_data
->pwr_on
;
1141 ifx_dev
->gpio
.mrdy
= pl_data
->mrdy
;
1142 ifx_dev
->gpio
.srdy
= pl_data
->srdy
;
1143 ifx_dev
->gpio
.reset_out
= pl_data
->rst_out
;
1145 dev_info(&spi
->dev
, "gpios %d, %d, %d, %d, %d",
1146 ifx_dev
->gpio
.reset
, ifx_dev
->gpio
.po
, ifx_dev
->gpio
.mrdy
,
1147 ifx_dev
->gpio
.srdy
, ifx_dev
->gpio
.reset_out
);
1149 /* Configure gpios */
1150 ret
= gpio_request(ifx_dev
->gpio
.reset
, "ifxModem");
1152 dev_err(&spi
->dev
, "Unable to allocate GPIO%d (RESET)",
1153 ifx_dev
->gpio
.reset
);
1156 ret
+= gpio_direction_output(ifx_dev
->gpio
.reset
, 0);
1157 ret
+= gpio_export(ifx_dev
->gpio
.reset
, 1);
1159 dev_err(&spi
->dev
, "Unable to configure GPIO%d (RESET)",
1160 ifx_dev
->gpio
.reset
);
1165 ret
= gpio_request(ifx_dev
->gpio
.po
, "ifxModem");
1166 ret
+= gpio_direction_output(ifx_dev
->gpio
.po
, 0);
1167 ret
+= gpio_export(ifx_dev
->gpio
.po
, 1);
1169 dev_err(&spi
->dev
, "Unable to configure GPIO%d (ON)",
1175 ret
= gpio_request(ifx_dev
->gpio
.mrdy
, "ifxModem");
1177 dev_err(&spi
->dev
, "Unable to allocate GPIO%d (MRDY)",
1178 ifx_dev
->gpio
.mrdy
);
1181 ret
+= gpio_export(ifx_dev
->gpio
.mrdy
, 1);
1182 ret
+= gpio_direction_output(ifx_dev
->gpio
.mrdy
, 0);
1184 dev_err(&spi
->dev
, "Unable to configure GPIO%d (MRDY)",
1185 ifx_dev
->gpio
.mrdy
);
1190 ret
= gpio_request(ifx_dev
->gpio
.srdy
, "ifxModem");
1192 dev_err(&spi
->dev
, "Unable to allocate GPIO%d (SRDY)",
1193 ifx_dev
->gpio
.srdy
);
1197 ret
+= gpio_export(ifx_dev
->gpio
.srdy
, 1);
1198 ret
+= gpio_direction_input(ifx_dev
->gpio
.srdy
);
1200 dev_err(&spi
->dev
, "Unable to configure GPIO%d (SRDY)",
1201 ifx_dev
->gpio
.srdy
);
1206 ret
= gpio_request(ifx_dev
->gpio
.reset_out
, "ifxModem");
1208 dev_err(&spi
->dev
, "Unable to allocate GPIO%d (RESET_OUT)",
1209 ifx_dev
->gpio
.reset_out
);
1212 ret
+= gpio_export(ifx_dev
->gpio
.reset_out
, 1);
1213 ret
+= gpio_direction_input(ifx_dev
->gpio
.reset_out
);
1215 dev_err(&spi
->dev
, "Unable to configure GPIO%d (RESET_OUT)",
1216 ifx_dev
->gpio
.reset_out
);
1221 ret
= request_irq(gpio_to_irq(ifx_dev
->gpio
.reset_out
),
1222 ifx_spi_reset_interrupt
,
1223 IRQF_TRIGGER_RISING
|IRQF_TRIGGER_FALLING
, DRVNAME
,
1226 dev_err(&spi
->dev
, "Unable to get irq %x\n",
1227 gpio_to_irq(ifx_dev
->gpio
.reset_out
));
1231 ret
= ifx_spi_reset(ifx_dev
);
1233 ret
= request_irq(gpio_to_irq(ifx_dev
->gpio
.srdy
),
1234 ifx_spi_srdy_interrupt
,
1235 IRQF_TRIGGER_RISING
, DRVNAME
,
1238 dev_err(&spi
->dev
, "Unable to get irq %x",
1239 gpio_to_irq(ifx_dev
->gpio
.srdy
));
1243 /* set pm runtime power state and register with power system */
1244 pm_runtime_set_active(&spi
->dev
);
1245 pm_runtime_enable(&spi
->dev
);
1247 /* handle case that modem is already signaling SRDY */
1248 /* no outgoing tty open at this point, this just satisfies the
1249 * modem's read and should reset communication properly
1251 srdy
= gpio_get_value(ifx_dev
->gpio
.srdy
);
1254 mrdy_assert(ifx_dev
);
1255 ifx_spi_handle_srdy(ifx_dev
);
1257 mrdy_set_low(ifx_dev
);
1261 free_irq(gpio_to_irq(ifx_dev
->gpio
.reset_out
), (void *)ifx_dev
);
1263 gpio_free(ifx_dev
->gpio
.srdy
);
1265 gpio_free(ifx_dev
->gpio
.mrdy
);
1267 gpio_free(ifx_dev
->gpio
.reset
);
1269 gpio_free(ifx_dev
->gpio
.po
);
1271 gpio_free(ifx_dev
->gpio
.reset_out
);
1273 ifx_spi_free_device(ifx_dev
);
1274 saved_ifx_dev
= NULL
;
1279 * ifx_spi_spi_remove - SPI device was removed
1282 * FIXME: We should be shutting the device down here not in
1283 * the module unload path.
1286 static int ifx_spi_spi_remove(struct spi_device
*spi
)
1288 struct ifx_spi_device
*ifx_dev
= spi_get_drvdata(spi
);
1290 tasklet_kill(&ifx_dev
->io_work_tasklet
);
1292 free_irq(gpio_to_irq(ifx_dev
->gpio
.reset_out
), (void *)ifx_dev
);
1293 free_irq(gpio_to_irq(ifx_dev
->gpio
.srdy
), (void *)ifx_dev
);
1295 gpio_free(ifx_dev
->gpio
.srdy
);
1296 gpio_free(ifx_dev
->gpio
.mrdy
);
1297 gpio_free(ifx_dev
->gpio
.reset
);
1298 gpio_free(ifx_dev
->gpio
.po
);
1299 gpio_free(ifx_dev
->gpio
.reset_out
);
1301 /* free allocations */
1302 ifx_spi_free_device(ifx_dev
);
1304 saved_ifx_dev
= NULL
;
1309 * ifx_spi_spi_shutdown - called on SPI shutdown
1312 * No action needs to be taken here
1315 static void ifx_spi_spi_shutdown(struct spi_device
*spi
)
1317 struct ifx_spi_device
*ifx_dev
= spi_get_drvdata(spi
);
1319 ifx_modem_power_off(ifx_dev
);
1323 * various suspends and resumes have nothing to do
1324 * no hardware to save state for
1328 * ifx_spi_spi_suspend - suspend SPI on system suspend
1329 * @dev: device being suspended
1331 * Suspend the SPI side. No action needed on Intel MID platforms, may
1332 * need extending for other systems.
1334 static int ifx_spi_spi_suspend(struct spi_device
*spi
, pm_message_t msg
)
1340 * ifx_spi_spi_resume - resume SPI side on system resume
1341 * @dev: device being suspended
1343 * Suspend the SPI side. No action needed on Intel MID platforms, may
1344 * need extending for other systems.
1346 static int ifx_spi_spi_resume(struct spi_device
*spi
)
1352 * ifx_spi_pm_suspend - suspend modem on system suspend
1353 * @dev: device being suspended
1355 * Suspend the modem. No action needed on Intel MID platforms, may
1356 * need extending for other systems.
1358 static int ifx_spi_pm_suspend(struct device
*dev
)
1364 * ifx_spi_pm_resume - resume modem on system resume
1365 * @dev: device being suspended
1367 * Allow the modem to resume. No action needed.
1369 * FIXME: do we need to reset anything here ?
1371 static int ifx_spi_pm_resume(struct device
*dev
)
1377 * ifx_spi_pm_runtime_resume - suspend modem
1378 * @dev: device being suspended
1380 * Allow the modem to resume. No action needed.
1382 static int ifx_spi_pm_runtime_resume(struct device
*dev
)
1388 * ifx_spi_pm_runtime_suspend - suspend modem
1389 * @dev: device being suspended
1391 * Allow the modem to suspend and thus suspend to continue up the
1394 static int ifx_spi_pm_runtime_suspend(struct device
*dev
)
1400 * ifx_spi_pm_runtime_idle - check if modem idle
1403 * Check conditions and queue runtime suspend if idle.
1405 static int ifx_spi_pm_runtime_idle(struct device
*dev
)
1407 struct spi_device
*spi
= to_spi_device(dev
);
1408 struct ifx_spi_device
*ifx_dev
= spi_get_drvdata(spi
);
1410 if (!ifx_dev
->power_status
)
1411 pm_runtime_suspend(dev
);
1416 static const struct dev_pm_ops ifx_spi_pm
= {
1417 .resume
= ifx_spi_pm_resume
,
1418 .suspend
= ifx_spi_pm_suspend
,
1419 .runtime_resume
= ifx_spi_pm_runtime_resume
,
1420 .runtime_suspend
= ifx_spi_pm_runtime_suspend
,
1421 .runtime_idle
= ifx_spi_pm_runtime_idle
1424 static const struct spi_device_id ifx_id_table
[] = {
1429 MODULE_DEVICE_TABLE(spi
, ifx_id_table
);
1431 /* spi operations */
1432 static struct spi_driver ifx_spi_driver
= {
1436 .owner
= THIS_MODULE
},
1437 .probe
= ifx_spi_spi_probe
,
1438 .shutdown
= ifx_spi_spi_shutdown
,
1439 .remove
= ifx_spi_spi_remove
,
1440 .suspend
= ifx_spi_spi_suspend
,
1441 .resume
= ifx_spi_spi_resume
,
1442 .id_table
= ifx_id_table
1446 * ifx_spi_exit - module exit
1448 * Unload the module.
1451 static void __exit
ifx_spi_exit(void)
1454 tty_unregister_driver(tty_drv
);
1455 put_tty_driver(tty_drv
);
1456 spi_unregister_driver((void *)&ifx_spi_driver
);
1457 unregister_reboot_notifier(&ifx_modem_reboot_notifier_block
);
1461 * ifx_spi_init - module entry point
1463 * Initialise the SPI and tty interfaces for the IFX SPI driver
1464 * We need to initialize upper-edge spi driver after the tty
1465 * driver because otherwise the spi probe will race
1468 static int __init
ifx_spi_init(void)
1472 tty_drv
= alloc_tty_driver(1);
1474 pr_err("%s: alloc_tty_driver failed", DRVNAME
);
1478 tty_drv
->driver_name
= DRVNAME
;
1479 tty_drv
->name
= TTYNAME
;
1480 tty_drv
->minor_start
= IFX_SPI_TTY_ID
;
1481 tty_drv
->type
= TTY_DRIVER_TYPE_SERIAL
;
1482 tty_drv
->subtype
= SERIAL_TYPE_NORMAL
;
1483 tty_drv
->flags
= TTY_DRIVER_REAL_RAW
| TTY_DRIVER_DYNAMIC_DEV
;
1484 tty_drv
->init_termios
= tty_std_termios
;
1486 tty_set_operations(tty_drv
, &ifx_spi_serial_ops
);
1488 result
= tty_register_driver(tty_drv
);
1490 pr_err("%s: tty_register_driver failed(%d)",
1495 result
= spi_register_driver((void *)&ifx_spi_driver
);
1497 pr_err("%s: spi_register_driver failed(%d)",
1502 result
= register_reboot_notifier(&ifx_modem_reboot_notifier_block
);
1504 pr_err("%s: register ifx modem reboot notifier failed(%d)",
1511 spi_unregister_driver((void *)&ifx_spi_driver
);
1513 tty_unregister_driver(tty_drv
);
1515 put_tty_driver(tty_drv
);
1520 module_init(ifx_spi_init
);
1521 module_exit(ifx_spi_exit
);
1523 MODULE_AUTHOR("Intel");
1524 MODULE_DESCRIPTION("IFX6x60 spi driver");
1525 MODULE_LICENSE("GPL");
1526 MODULE_INFO(Version
, "0.1-IFX6x60");