1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /**************************************************************************** 3 * 4 * Driver for the IFX spi modem. 5 * 6 * Copyright (C) 2009, 2010 Intel Corp 7 * Jim Stanley <jim.stanley@intel.com> 8 * 9 *****************************************************************************/ 10 #ifndef _IFX6X60_H 11 #define _IFX6X60_H 12 13 struct gpio_desc; 14 15 #define DRVNAME "ifx6x60" 16 #define TTYNAME "ttyIFX" 17 18 #define IFX_SPI_MAX_MINORS 1 19 #define IFX_SPI_TRANSFER_SIZE 2048 20 #define IFX_SPI_FIFO_SIZE 4096 21 22 #define IFX_SPI_HEADER_OVERHEAD 4 23 #define IFX_RESET_TIMEOUT msecs_to_jiffies(50) 24 25 /* device flags bitfield definitions */ 26 #define IFX_SPI_STATE_PRESENT 0 27 #define IFX_SPI_STATE_IO_IN_PROGRESS 1 28 #define IFX_SPI_STATE_IO_READY 2 29 #define IFX_SPI_STATE_TIMER_PENDING 3 30 #define IFX_SPI_STATE_IO_AVAILABLE 4 31 32 /* flow control bitfields */ 33 #define IFX_SPI_DCD 0 34 #define IFX_SPI_CTS 1 35 #define IFX_SPI_DSR 2 36 #define IFX_SPI_RI 3 37 #define IFX_SPI_DTR 4 38 #define IFX_SPI_RTS 5 39 #define IFX_SPI_TX_FC 6 40 #define IFX_SPI_RX_FC 7 41 #define IFX_SPI_UPDATE 8 42 43 #define IFX_SPI_PAYLOAD_SIZE (IFX_SPI_TRANSFER_SIZE - \ 44 IFX_SPI_HEADER_OVERHEAD) 45 46 #define IFX_SPI_IRQ_TYPE DETECT_EDGE_RISING 47 #define IFX_SPI_GPIO_TARGET 0 48 #define IFX_SPI_GPIO0 0x105 49 50 #define IFX_SPI_STATUS_TIMEOUT (2000*HZ) 51 52 /* values for bits in power status byte */ 53 #define IFX_SPI_POWER_DATA_PENDING 1 54 #define IFX_SPI_POWER_SRDY 2 55 56 struct ifx_spi_device { 57 /* Our SPI device */ 58 struct spi_device *spi_dev; 59 60 /* Port specific data */ 61 struct kfifo tx_fifo; 62 spinlock_t fifo_lock; 63 unsigned long signal_state; 64 65 /* TTY Layer logic */ 66 struct tty_port tty_port; 67 struct device *tty_dev; 68 int minor; 69 70 /* Low level I/O work */ 71 struct tasklet_struct io_work_tasklet; 72 unsigned long flags; 73 dma_addr_t rx_dma; 74 dma_addr_t tx_dma; 75 76 int modem; /* Modem type */ 77 int use_dma; /* provide dma-able addrs in SPI msg */ 78 long max_hz; /* max SPI frequency */ 79 80 spinlock_t write_lock; 81 int write_pending; 82 spinlock_t power_lock; 83 unsigned char power_status; 84 85 unsigned char *rx_buffer; 86 unsigned char *tx_buffer; 87 dma_addr_t rx_bus; 88 dma_addr_t tx_bus; 89 unsigned char spi_more; 90 unsigned char spi_slave_cts; 91 92 struct timer_list spi_timer; 93 94 struct spi_message spi_msg; 95 struct spi_transfer spi_xfer; 96 97 struct { 98 /* gpio lines */ 99 struct gpio_desc *srdy; /* slave-ready gpio */ 100 struct gpio_desc *mrdy; /* master-ready gpio */ 101 struct gpio_desc *reset; /* modem-reset gpio */ 102 struct gpio_desc *po; /* modem-on gpio */ 103 struct gpio_desc *reset_out; /* modem-in-reset gpio */ 104 struct gpio_desc *pmu_reset; /* PMU reset gpio */ 105 /* state/stats */ 106 int unack_srdy_int_nb; 107 } gpio; 108 109 /* modem reset */ 110 unsigned long mdm_reset_state; 111 #define MR_START 0 112 #define MR_INPROGRESS 1 113 #define MR_COMPLETE 2 114 wait_queue_head_t mdm_reset_wait; 115 void (*swap_buf)(unsigned char *buf, int len, void *end); 116 }; 117 118 #endif /* _IFX6X60_H */ 119