Lines Matching +full:cts +full:- +full:rts +full:- +full:swap
1 // SPDX-License-Identifier: GPL-2.0
19 * o The driver is intended to be big-endian safe but has never been
26 #include <linux/dma-mapping.h>
60 #define IFX_SPI_HEADER_0 (-1)
61 #define IFX_SPI_HEADER_F (-2)
83 gpiod_set_value(ifx_dev->gpio.pmu_reset, 1); in ifx_modem_power_off()
103 * mrdy_set_high - set MRDY GPIO
109 gpiod_set_value(ifx->gpio.mrdy, 1); in mrdy_set_high()
113 * mrdy_set_low - clear MRDY GPIO
119 gpiod_set_value(ifx->gpio.mrdy, 0); in mrdy_set_low()
127 * Set bit in power status and signal power system if status becomes non-0
134 spin_lock_irqsave(&ifx_dev->power_lock, flags); in ifx_spi_power_state_set()
137 * if power status is already non-0, just update, else in ifx_spi_power_state_set()
140 if (!ifx_dev->power_status) in ifx_spi_power_state_set()
141 pm_runtime_get(&ifx_dev->spi_dev->dev); in ifx_spi_power_state_set()
142 ifx_dev->power_status |= val; in ifx_spi_power_state_set()
144 spin_unlock_irqrestore(&ifx_dev->power_lock, flags); in ifx_spi_power_state_set()
148 * ifx_spi_power_state_clear - clear power bit
159 spin_lock_irqsave(&ifx_dev->power_lock, flags); in ifx_spi_power_state_clear()
161 if (ifx_dev->power_status) { in ifx_spi_power_state_clear()
162 ifx_dev->power_status &= ~val; in ifx_spi_power_state_clear()
163 if (!ifx_dev->power_status) in ifx_spi_power_state_clear()
164 pm_runtime_put(&ifx_dev->spi_dev->dev); in ifx_spi_power_state_clear()
167 spin_unlock_irqrestore(&ifx_dev->power_lock, flags); in ifx_spi_power_state_clear()
176 * Swap the contents of a buffer into big endian format
180 /* don't swap buffer if SPI word width is 8 bits */ in swap_buf_8()
190 * Swap the contents of a buffer into big endian format
199 pr_err("swap_buf_16: swap exceeds boundary (%p > %p)!", in swap_buf_16()
215 * Swap the contents of a buffer into big endian format
225 pr_err("swap_buf_32: swap exceeds boundary (%p > %p)!\n", in swap_buf_32()
236 * mrdy_assert - assert MRDY line
246 int val = gpiod_get_value(ifx_dev->gpio.srdy); in mrdy_assert()
249 &ifx_dev->flags)) { in mrdy_assert()
250 mod_timer(&ifx_dev->spi_timer,jiffies + IFX_SPI_TIMEOUT_SEC*HZ); in mrdy_assert()
259 * ifx_spi_timeout - SPI timeout
269 dev_warn(&ifx_dev->spi_dev->dev, "*** SPI Timeout ***"); in ifx_spi_timeout()
270 tty_port_tty_hangup(&ifx_dev->tty_port, false); in ifx_spi_timeout()
272 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags); in ifx_spi_timeout()
278 * ifx_spi_tiocmget - get modem lines
287 struct ifx_spi_device *ifx_dev = tty->driver_data; in ifx_spi_tiocmget()
290 (test_bit(IFX_SPI_RTS, &ifx_dev->signal_state) ? TIOCM_RTS : 0) | in ifx_spi_tiocmget()
291 (test_bit(IFX_SPI_DTR, &ifx_dev->signal_state) ? TIOCM_DTR : 0) | in ifx_spi_tiocmget()
292 (test_bit(IFX_SPI_CTS, &ifx_dev->signal_state) ? TIOCM_CTS : 0) | in ifx_spi_tiocmget()
293 (test_bit(IFX_SPI_DSR, &ifx_dev->signal_state) ? TIOCM_DSR : 0) | in ifx_spi_tiocmget()
294 (test_bit(IFX_SPI_DCD, &ifx_dev->signal_state) ? TIOCM_CAR : 0) | in ifx_spi_tiocmget()
295 (test_bit(IFX_SPI_RI, &ifx_dev->signal_state) ? TIOCM_RNG : 0); in ifx_spi_tiocmget()
300 * ifx_spi_tiocmset - set modem bits
305 * The IFX6x60 only supports DTR and RTS. Set them accordingly
313 struct ifx_spi_device *ifx_dev = tty->driver_data; in ifx_spi_tiocmset()
316 set_bit(IFX_SPI_RTS, &ifx_dev->signal_state); in ifx_spi_tiocmset()
318 set_bit(IFX_SPI_DTR, &ifx_dev->signal_state); in ifx_spi_tiocmset()
320 clear_bit(IFX_SPI_RTS, &ifx_dev->signal_state); in ifx_spi_tiocmset()
322 clear_bit(IFX_SPI_DTR, &ifx_dev->signal_state); in ifx_spi_tiocmset()
324 set_bit(IFX_SPI_UPDATE, &ifx_dev->signal_state); in ifx_spi_tiocmset()
329 * ifx_spi_open - called on tty open
340 return tty_port_open(&saved_ifx_dev->tty_port, tty, filp); in ifx_spi_open()
344 * ifx_spi_close - called when our tty closes
353 struct ifx_spi_device *ifx_dev = tty->driver_data; in ifx_spi_close()
354 tty_port_close(&ifx_dev->tty_port, tty, filp); in ifx_spi_close()
359 * ifx_decode_spi_header - decode received header
363 * @received_cts: status of cts we received
365 * Note how received_cts is handled -- if header is all F it is left
398 * ifx_setup_spi_header - set header fields
416 * ifx_spi_prepare_tx_buffer - prepare transmit frame
422 * ifx_dev->tx_buffer
424 * FIXME: performance - should we wake the tty when the queue is half
434 tx_buffer = ifx_dev->tx_buffer; in ifx_spi_prepare_tx_buffer()
442 ifx_dev->spi_more = 0; in ifx_spi_prepare_tx_buffer()
444 /* if modem cts is set, just send empty buffer */ in ifx_spi_prepare_tx_buffer()
445 if (!ifx_dev->spi_slave_cts) { in ifx_spi_prepare_tx_buffer()
447 queue_length = kfifo_len(&ifx_dev->tx_fifo); in ifx_spi_prepare_tx_buffer()
449 /* data to mux -- see if there's room for it */ in ifx_spi_prepare_tx_buffer()
451 temp_count = kfifo_out_locked(&ifx_dev->tx_fifo, in ifx_spi_prepare_tx_buffer()
453 &ifx_dev->fifo_lock); in ifx_spi_prepare_tx_buffer()
460 tty_port_tty_wakeup(&ifx_dev->tty_port); in ifx_spi_prepare_tx_buffer()
462 ifx_dev->spi_more = 1; in ifx_spi_prepare_tx_buffer()
465 /* have data and info for header -- set up SPI header in buffer */ in ifx_spi_prepare_tx_buffer()
467 ifx_spi_setup_spi_header(ifx_dev->tx_buffer, in ifx_spi_prepare_tx_buffer()
468 tx_count-IFX_SPI_HEADER_OVERHEAD, in ifx_spi_prepare_tx_buffer()
469 ifx_dev->spi_more); in ifx_spi_prepare_tx_buffer()
470 /* swap actual data in the buffer */ in ifx_spi_prepare_tx_buffer()
471 ifx_dev->swap_buf((ifx_dev->tx_buffer), tx_count, in ifx_spi_prepare_tx_buffer()
472 &ifx_dev->tx_buffer[IFX_SPI_TRANSFER_SIZE]); in ifx_spi_prepare_tx_buffer()
477 * ifx_spi_write - line discipline write
489 struct ifx_spi_device *ifx_dev = tty->driver_data; in ifx_spi_write()
495 spin_lock_irqsave(&ifx_dev->fifo_lock, flags); in ifx_spi_write()
496 is_fifo_empty = kfifo_is_empty(&ifx_dev->tx_fifo); in ifx_spi_write()
497 tx_count = kfifo_in(&ifx_dev->tx_fifo, tmp_buf, count); in ifx_spi_write()
498 spin_unlock_irqrestore(&ifx_dev->fifo_lock, flags); in ifx_spi_write()
506 * ifx_spi_chars_in_buffer - line discipline helper
514 struct ifx_spi_device *ifx_dev = tty->driver_data; in ifx_spi_write_room()
515 return IFX_SPI_FIFO_SIZE - kfifo_len(&ifx_dev->tx_fifo); in ifx_spi_write_room()
519 * ifx_spi_chars_in_buffer - line discipline helper
527 struct ifx_spi_device *ifx_dev = tty->driver_data; in ifx_spi_chars_in_buffer()
528 return kfifo_len(&ifx_dev->tx_fifo); in ifx_spi_chars_in_buffer()
541 struct ifx_spi_device *ifx_dev = tty->driver_data; in ifx_spi_hangup()
542 tty_port_hangup(&ifx_dev->tty_port); in ifx_spi_hangup()
549 * tty port activate method - called for first open. Serialized
558 kfifo_reset(&ifx_dev->tx_fifo); in ifx_port_activate()
561 clear_bit(IFX_SPI_STATE_IO_IN_PROGRESS, &ifx_dev->flags); in ifx_port_activate()
562 clear_bit(IFX_SPI_STATE_IO_READY, &ifx_dev->flags); in ifx_port_activate()
565 tty->driver_data = ifx_dev; in ifx_port_activate()
568 port->low_latency = 1; in ifx_port_activate()
571 set_bit(IFX_SPI_STATE_IO_AVAILABLE, &ifx_dev->flags); in ifx_port_activate()
580 * tty port shutdown method - called for last port close. Serialized
588 clear_bit(IFX_SPI_STATE_IO_AVAILABLE, &ifx_dev->flags); in ifx_port_shutdown()
590 del_timer(&ifx_dev->spi_timer); in ifx_port_shutdown()
591 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags); in ifx_port_shutdown()
592 tasklet_kill(&ifx_dev->io_work_tasklet); in ifx_port_shutdown()
612 * ifx_spi_insert_fip_string - queue received data
623 tty_insert_flip_string(&ifx_dev->tty_port, chars, size); in ifx_spi_insert_flip_string()
624 tty_flip_buffer_push(&ifx_dev->tty_port); in ifx_spi_insert_flip_string()
628 * ifx_spi_complete - SPI transfer completed
640 unsigned char cts; in ifx_spi_complete() local
648 if (!ifx_dev->spi_msg.status) { in ifx_spi_complete()
650 ifx_dev->swap_buf(ifx_dev->rx_buffer, IFX_SPI_HEADER_OVERHEAD, in ifx_spi_complete()
651 &ifx_dev->rx_buffer[IFX_SPI_HEADER_OVERHEAD]); in ifx_spi_complete()
652 decode_result = ifx_spi_decode_spi_header(ifx_dev->rx_buffer, in ifx_spi_complete()
653 &length, &more, &cts); in ifx_spi_complete()
655 dev_dbg(&ifx_dev->spi_dev->dev, in ifx_spi_complete()
657 ifx_dev->spi_slave_cts = 0; in ifx_spi_complete()
660 dev_dbg(&ifx_dev->spi_dev->dev, in ifx_spi_complete()
665 ifx_dev->spi_slave_cts = cts; in ifx_spi_complete()
668 ifx_dev->spi_msg.actual_length); in ifx_spi_complete()
669 ifx_dev->swap_buf( in ifx_spi_complete()
670 (ifx_dev->rx_buffer + IFX_SPI_HEADER_OVERHEAD), in ifx_spi_complete()
672 &ifx_dev->rx_buffer[IFX_SPI_TRANSFER_SIZE]); in ifx_spi_complete()
675 ifx_dev->rx_buffer + IFX_SPI_HEADER_OVERHEAD, in ifx_spi_complete()
679 dev_dbg(&ifx_dev->spi_dev->dev, "SPI transfer error %d", in ifx_spi_complete()
680 ifx_dev->spi_msg.status); in ifx_spi_complete()
684 if (ifx_dev->write_pending) { in ifx_spi_complete()
685 ifx_dev->write_pending = 0; in ifx_spi_complete()
689 clear_bit(IFX_SPI_STATE_IO_IN_PROGRESS, &(ifx_dev->flags)); in ifx_spi_complete()
691 queue_length = kfifo_len(&ifx_dev->tx_fifo); in ifx_spi_complete()
692 srdy = gpiod_get_value(ifx_dev->gpio.srdy); in ifx_spi_complete()
697 if (test_and_clear_bit(IFX_SPI_STATE_IO_READY, &ifx_dev->flags)) in ifx_spi_complete()
698 tasklet_schedule(&ifx_dev->io_work_tasklet); in ifx_spi_complete()
700 if (more || ifx_dev->spi_more || queue_length > 0 || in ifx_spi_complete()
702 if (ifx_dev->spi_slave_cts) { in ifx_spi_complete()
715 tty_port_tty_wakeup(&ifx_dev->tty_port); in ifx_spi_complete()
721 * ifx_spio_io - I/O tasklet
733 if (!test_and_set_bit(IFX_SPI_STATE_IO_IN_PROGRESS, &ifx_dev->flags) && in ifx_spi_io()
734 test_bit(IFX_SPI_STATE_IO_AVAILABLE, &ifx_dev->flags)) { in ifx_spi_io()
735 if (ifx_dev->gpio.unack_srdy_int_nb > 0) in ifx_spi_io()
736 ifx_dev->gpio.unack_srdy_int_nb--; in ifx_spi_io()
740 spi_message_init(&ifx_dev->spi_msg); in ifx_spi_io()
741 INIT_LIST_HEAD(&ifx_dev->spi_msg.queue); in ifx_spi_io()
743 ifx_dev->spi_msg.context = ifx_dev; in ifx_spi_io()
744 ifx_dev->spi_msg.complete = ifx_spi_complete; in ifx_spi_io()
748 ifx_dev->spi_xfer.len = IFX_SPI_TRANSFER_SIZE; in ifx_spi_io()
749 ifx_dev->spi_xfer.cs_change = 0; in ifx_spi_io()
750 ifx_dev->spi_xfer.speed_hz = ifx_dev->spi_dev->max_speed_hz; in ifx_spi_io()
751 /* ifx_dev->spi_xfer.speed_hz = 390625; */ in ifx_spi_io()
752 ifx_dev->spi_xfer.bits_per_word = in ifx_spi_io()
753 ifx_dev->spi_dev->bits_per_word; in ifx_spi_io()
755 ifx_dev->spi_xfer.tx_buf = ifx_dev->tx_buffer; in ifx_spi_io()
756 ifx_dev->spi_xfer.rx_buf = ifx_dev->rx_buffer; in ifx_spi_io()
761 if (ifx_dev->use_dma) { in ifx_spi_io()
762 ifx_dev->spi_msg.is_dma_mapped = 1; in ifx_spi_io()
763 ifx_dev->tx_dma = ifx_dev->tx_bus; in ifx_spi_io()
764 ifx_dev->rx_dma = ifx_dev->rx_bus; in ifx_spi_io()
765 ifx_dev->spi_xfer.tx_dma = ifx_dev->tx_dma; in ifx_spi_io()
766 ifx_dev->spi_xfer.rx_dma = ifx_dev->rx_dma; in ifx_spi_io()
768 ifx_dev->spi_msg.is_dma_mapped = 0; in ifx_spi_io()
769 ifx_dev->tx_dma = (dma_addr_t)0; in ifx_spi_io()
770 ifx_dev->rx_dma = (dma_addr_t)0; in ifx_spi_io()
771 ifx_dev->spi_xfer.tx_dma = (dma_addr_t)0; in ifx_spi_io()
772 ifx_dev->spi_xfer.rx_dma = (dma_addr_t)0; in ifx_spi_io()
775 spi_message_add_tail(&ifx_dev->spi_xfer, &ifx_dev->spi_msg); in ifx_spi_io()
782 retval = spi_async(ifx_dev->spi_dev, &ifx_dev->spi_msg); in ifx_spi_io()
785 &ifx_dev->flags); in ifx_spi_io()
786 tasklet_schedule(&ifx_dev->io_work_tasklet); in ifx_spi_io()
790 ifx_dev->write_pending = 1; in ifx_spi_io()
794 * ifx_spi_free_port - free up the tty side
801 if (ifx_dev->tty_dev) in ifx_spi_free_port()
802 tty_unregister_device(tty_drv, ifx_dev->minor); in ifx_spi_free_port()
803 tty_port_destroy(&ifx_dev->tty_port); in ifx_spi_free_port()
804 kfifo_free(&ifx_dev->tx_fifo); in ifx_spi_free_port()
808 * ifx_spi_create_port - create a new port
817 struct tty_port *pport = &ifx_dev->tty_port; in ifx_spi_create_port()
819 spin_lock_init(&ifx_dev->fifo_lock); in ifx_spi_create_port()
820 lockdep_set_class_and_subclass(&ifx_dev->fifo_lock, in ifx_spi_create_port()
823 if (kfifo_alloc(&ifx_dev->tx_fifo, IFX_SPI_FIFO_SIZE, GFP_KERNEL)) { in ifx_spi_create_port()
824 ret = -ENOMEM; in ifx_spi_create_port()
829 pport->ops = &ifx_tty_port_ops; in ifx_spi_create_port()
830 ifx_dev->minor = IFX_SPI_TTY_ID; in ifx_spi_create_port()
831 ifx_dev->tty_dev = tty_port_register_device(pport, tty_drv, in ifx_spi_create_port()
832 ifx_dev->minor, &ifx_dev->spi_dev->dev); in ifx_spi_create_port()
833 if (IS_ERR(ifx_dev->tty_dev)) { in ifx_spi_create_port()
834 dev_dbg(&ifx_dev->spi_dev->dev, in ifx_spi_create_port()
836 ret = PTR_ERR(ifx_dev->tty_dev); in ifx_spi_create_port()
849 * ifx_spi_handle_srdy - handle SRDY
858 if (test_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags)) { in ifx_spi_handle_srdy()
859 del_timer(&ifx_dev->spi_timer); in ifx_spi_handle_srdy()
860 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags); in ifx_spi_handle_srdy()
865 if (!test_bit(IFX_SPI_STATE_IO_IN_PROGRESS, &ifx_dev->flags)) in ifx_spi_handle_srdy()
866 tasklet_schedule(&ifx_dev->io_work_tasklet); in ifx_spi_handle_srdy()
868 set_bit(IFX_SPI_STATE_IO_READY, &ifx_dev->flags); in ifx_spi_handle_srdy()
872 * ifx_spi_srdy_interrupt - SRDY asserted
881 ifx_dev->gpio.unack_srdy_int_nb++; in ifx_spi_srdy_interrupt()
887 * ifx_spi_reset_interrupt - Modem has changed reset state
900 int val = gpiod_get_value(ifx_dev->gpio.reset_out); in ifx_spi_reset_interrupt()
901 int solreset = test_bit(MR_START, &ifx_dev->mdm_reset_state); in ifx_spi_reset_interrupt()
905 set_bit(MR_INPROGRESS, &ifx_dev->mdm_reset_state); in ifx_spi_reset_interrupt()
908 tty_port_tty_hangup(&ifx_dev->tty_port, false); in ifx_spi_reset_interrupt()
912 clear_bit(MR_INPROGRESS, &ifx_dev->mdm_reset_state); in ifx_spi_reset_interrupt()
914 set_bit(MR_COMPLETE, &ifx_dev->mdm_reset_state); in ifx_spi_reset_interrupt()
915 wake_up(&ifx_dev->mdm_reset_wait); in ifx_spi_reset_interrupt()
922 * ifx_spi_free_device - free device
930 dma_free_coherent(&ifx_dev->spi_dev->dev, in ifx_spi_free_device()
932 ifx_dev->tx_buffer, in ifx_spi_free_device()
933 ifx_dev->tx_bus); in ifx_spi_free_device()
934 dma_free_coherent(&ifx_dev->spi_dev->dev, in ifx_spi_free_device()
936 ifx_dev->rx_buffer, in ifx_spi_free_device()
937 ifx_dev->rx_bus); in ifx_spi_free_device()
941 * ifx_spi_reset - reset modem
955 set_bit(MR_START, &ifx_dev->mdm_reset_state); in ifx_spi_reset()
956 gpiod_set_value(ifx_dev->gpio.po, 0); in ifx_spi_reset()
957 gpiod_set_value(ifx_dev->gpio.reset, 0); in ifx_spi_reset()
959 gpiod_set_value(ifx_dev->gpio.reset, 1); in ifx_spi_reset()
961 gpiod_set_value(ifx_dev->gpio.po, 1); in ifx_spi_reset()
963 gpiod_set_value(ifx_dev->gpio.po, 0); in ifx_spi_reset()
964 ret = wait_event_timeout(ifx_dev->mdm_reset_wait, in ifx_spi_reset()
966 &ifx_dev->mdm_reset_state), in ifx_spi_reset()
969 dev_warn(&ifx_dev->spi_dev->dev, "Modem reset timeout: (state:%lx)", in ifx_spi_reset()
970 ifx_dev->mdm_reset_state); in ifx_spi_reset()
972 ifx_dev->mdm_reset_state = 0; in ifx_spi_reset()
977 * ifx_spi_spi_probe - probe callback
984 * - Support for multiple devices
985 * - Split out MID specific GPIO handling eventually
994 struct device *dev = &spi->dev; in ifx_spi_spi_probe()
998 return -ENODEV; in ifx_spi_spi_probe()
1004 return -ENODEV; in ifx_spi_spi_probe()
1011 return -ENOMEM; in ifx_spi_spi_probe()
1014 ifx_dev->spi_dev = spi; in ifx_spi_spi_probe()
1015 clear_bit(IFX_SPI_STATE_IO_IN_PROGRESS, &ifx_dev->flags); in ifx_spi_spi_probe()
1016 spin_lock_init(&ifx_dev->write_lock); in ifx_spi_spi_probe()
1017 spin_lock_init(&ifx_dev->power_lock); in ifx_spi_spi_probe()
1018 ifx_dev->power_status = 0; in ifx_spi_spi_probe()
1019 timer_setup(&ifx_dev->spi_timer, ifx_spi_timeout, 0); in ifx_spi_spi_probe()
1020 ifx_dev->modem = pl_data->modem_type; in ifx_spi_spi_probe()
1021 ifx_dev->use_dma = pl_data->use_dma; in ifx_spi_spi_probe()
1022 ifx_dev->max_hz = pl_data->max_hz; in ifx_spi_spi_probe()
1024 spi->max_speed_hz = ifx_dev->max_hz; in ifx_spi_spi_probe()
1025 spi->mode = IFX_SPI_MODE | (SPI_LOOP & spi->mode); in ifx_spi_spi_probe()
1026 spi->bits_per_word = spi_bpw; in ifx_spi_spi_probe()
1031 return -ENODEV; in ifx_spi_spi_probe()
1035 if (spi->bits_per_word == 32) in ifx_spi_spi_probe()
1036 ifx_dev->swap_buf = swap_buf_32; in ifx_spi_spi_probe()
1037 else if (spi->bits_per_word == 16) in ifx_spi_spi_probe()
1038 ifx_dev->swap_buf = swap_buf_16; in ifx_spi_spi_probe()
1040 ifx_dev->swap_buf = swap_buf_8; in ifx_spi_spi_probe()
1043 ifx_dev->spi_more = 0; in ifx_spi_spi_probe()
1044 ifx_dev->spi_slave_cts = 0; in ifx_spi_spi_probe()
1047 ifx_dev->tx_buffer = dma_alloc_coherent(ifx_dev->spi_dev->dev.parent, in ifx_spi_spi_probe()
1049 &ifx_dev->tx_bus, in ifx_spi_spi_probe()
1051 if (!ifx_dev->tx_buffer) { in ifx_spi_spi_probe()
1052 dev_err(dev, "DMA-TX buffer allocation failed"); in ifx_spi_spi_probe()
1053 ret = -ENOMEM; in ifx_spi_spi_probe()
1056 ifx_dev->rx_buffer = dma_alloc_coherent(ifx_dev->spi_dev->dev.parent, in ifx_spi_spi_probe()
1058 &ifx_dev->rx_bus, in ifx_spi_spi_probe()
1060 if (!ifx_dev->rx_buffer) { in ifx_spi_spi_probe()
1061 dev_err(dev, "DMA-RX buffer allocation failed"); in ifx_spi_spi_probe()
1062 ret = -ENOMEM; in ifx_spi_spi_probe()
1067 init_waitqueue_head(&ifx_dev->mdm_reset_wait); in ifx_spi_spi_probe()
1070 tasklet_setup(&ifx_dev->io_work_tasklet, ifx_spi_io); in ifx_spi_spi_probe()
1072 set_bit(IFX_SPI_STATE_PRESENT, &ifx_dev->flags); in ifx_spi_spi_probe()
1081 ifx_dev->gpio.reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in ifx_spi_spi_probe()
1082 if (IS_ERR(ifx_dev->gpio.reset)) { in ifx_spi_spi_probe()
1084 ret = PTR_ERR(ifx_dev->gpio.reset); in ifx_spi_spi_probe()
1087 gpiod_set_consumer_name(ifx_dev->gpio.reset, "ifxModem reset"); in ifx_spi_spi_probe()
1088 ifx_dev->gpio.po = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW); in ifx_spi_spi_probe()
1089 if (IS_ERR(ifx_dev->gpio.po)) { in ifx_spi_spi_probe()
1091 ret = PTR_ERR(ifx_dev->gpio.po); in ifx_spi_spi_probe()
1094 gpiod_set_consumer_name(ifx_dev->gpio.po, "ifxModem power"); in ifx_spi_spi_probe()
1095 ifx_dev->gpio.mrdy = devm_gpiod_get(dev, "mrdy", GPIOD_OUT_LOW); in ifx_spi_spi_probe()
1096 if (IS_ERR(ifx_dev->gpio.mrdy)) { in ifx_spi_spi_probe()
1098 ret = PTR_ERR(ifx_dev->gpio.mrdy); in ifx_spi_spi_probe()
1101 gpiod_set_consumer_name(ifx_dev->gpio.mrdy, "ifxModem mrdy"); in ifx_spi_spi_probe()
1102 ifx_dev->gpio.srdy = devm_gpiod_get(dev, "srdy", GPIOD_IN); in ifx_spi_spi_probe()
1103 if (IS_ERR(ifx_dev->gpio.srdy)) { in ifx_spi_spi_probe()
1105 ret = PTR_ERR(ifx_dev->gpio.srdy); in ifx_spi_spi_probe()
1108 gpiod_set_consumer_name(ifx_dev->gpio.srdy, "ifxModem srdy"); in ifx_spi_spi_probe()
1109 ifx_dev->gpio.reset_out = devm_gpiod_get(dev, "rst_out", GPIOD_IN); in ifx_spi_spi_probe()
1110 if (IS_ERR(ifx_dev->gpio.reset_out)) { in ifx_spi_spi_probe()
1112 ret = PTR_ERR(ifx_dev->gpio.reset_out); in ifx_spi_spi_probe()
1115 gpiod_set_consumer_name(ifx_dev->gpio.reset_out, "ifxModem reset out"); in ifx_spi_spi_probe()
1116 ifx_dev->gpio.pmu_reset = devm_gpiod_get(dev, "pmu_reset", GPIOD_ASIS); in ifx_spi_spi_probe()
1117 if (IS_ERR(ifx_dev->gpio.pmu_reset)) { in ifx_spi_spi_probe()
1119 ret = PTR_ERR(ifx_dev->gpio.pmu_reset); in ifx_spi_spi_probe()
1122 gpiod_set_consumer_name(ifx_dev->gpio.pmu_reset, "ifxModem PMU reset"); in ifx_spi_spi_probe()
1124 ret = request_irq(gpiod_to_irq(ifx_dev->gpio.reset_out), in ifx_spi_spi_probe()
1130 gpiod_to_irq(ifx_dev->gpio.reset_out)); in ifx_spi_spi_probe()
1136 ret = request_irq(gpiod_to_irq(ifx_dev->gpio.srdy), in ifx_spi_spi_probe()
1141 gpiod_to_irq(ifx_dev->gpio.srdy)); in ifx_spi_spi_probe()
1153 srdy = gpiod_get_value(ifx_dev->gpio.srdy); in ifx_spi_spi_probe()
1163 free_irq(gpiod_to_irq(ifx_dev->gpio.reset_out), ifx_dev); in ifx_spi_spi_probe()
1171 * ifx_spi_spi_remove - SPI device was removed
1182 tasklet_kill(&ifx_dev->io_work_tasklet); in ifx_spi_spi_remove()
1184 pm_runtime_disable(&spi->dev); in ifx_spi_spi_remove()
1187 free_irq(gpiod_to_irq(ifx_dev->gpio.reset_out), ifx_dev); in ifx_spi_spi_remove()
1188 free_irq(gpiod_to_irq(ifx_dev->gpio.srdy), ifx_dev); in ifx_spi_spi_remove()
1198 * ifx_spi_spi_shutdown - called on SPI shutdown
1217 * ifx_spi_pm_suspend - suspend modem on system suspend
1229 * ifx_spi_pm_resume - resume modem on system resume
1242 * ifx_spi_pm_runtime_resume - suspend modem
1253 * ifx_spi_pm_runtime_suspend - suspend modem
1265 * ifx_spi_pm_runtime_idle - check if modem idle
1275 if (!ifx_dev->power_status) in ifx_spi_pm_runtime_idle()
1309 * ifx_spi_exit - module exit
1324 * ifx_spi_init - module entry point
1327 * We need to initialize upper-edge spi driver after the tty
1338 return -ENOMEM; in ifx_spi_init()
1341 tty_drv->driver_name = DRVNAME; in ifx_spi_init()
1342 tty_drv->name = TTYNAME; in ifx_spi_init()
1343 tty_drv->minor_start = IFX_SPI_TTY_ID; in ifx_spi_init()
1344 tty_drv->type = TTY_DRIVER_TYPE_SERIAL; in ifx_spi_init()
1345 tty_drv->subtype = SERIAL_TYPE_NORMAL; in ifx_spi_init()
1346 tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; in ifx_spi_init()
1347 tty_drv->init_termios = tty_std_termios; in ifx_spi_init()
1389 MODULE_INFO(Version, "0.1-IFX6x60");