ifx6x60.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /****************************************************************************
  2. *
  3. * Driver for the IFX spi modem.
  4. *
  5. * Copyright (C) 2009, 2010 Intel Corp
  6. * Jim Stanley <jim.stanley@intel.com>
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  21. * USA
  22. *
  23. *
  24. *
  25. *****************************************************************************/
  26. #ifndef _IFX6X60_H
  27. #define _IFX6X60_H
  28. #define DRVNAME "ifx6x60"
  29. #define TTYNAME "ttyIFX"
  30. #define IFX_SPI_MAX_MINORS 1
  31. #define IFX_SPI_TRANSFER_SIZE 2048
  32. #define IFX_SPI_FIFO_SIZE 4096
  33. #define IFX_SPI_HEADER_OVERHEAD 4
  34. #define IFX_RESET_TIMEOUT msecs_to_jiffies(50)
  35. /* device flags bitfield definitions */
  36. #define IFX_SPI_STATE_PRESENT 0
  37. #define IFX_SPI_STATE_IO_IN_PROGRESS 1
  38. #define IFX_SPI_STATE_IO_READY 2
  39. #define IFX_SPI_STATE_TIMER_PENDING 3
  40. #define IFX_SPI_STATE_IO_AVAILABLE 4
  41. /* flow control bitfields */
  42. #define IFX_SPI_DCD 0
  43. #define IFX_SPI_CTS 1
  44. #define IFX_SPI_DSR 2
  45. #define IFX_SPI_RI 3
  46. #define IFX_SPI_DTR 4
  47. #define IFX_SPI_RTS 5
  48. #define IFX_SPI_TX_FC 6
  49. #define IFX_SPI_RX_FC 7
  50. #define IFX_SPI_UPDATE 8
  51. #define IFX_SPI_PAYLOAD_SIZE (IFX_SPI_TRANSFER_SIZE - \
  52. IFX_SPI_HEADER_OVERHEAD)
  53. #define IFX_SPI_IRQ_TYPE DETECT_EDGE_RISING
  54. #define IFX_SPI_GPIO_TARGET 0
  55. #define IFX_SPI_GPIO0 0x105
  56. #define IFX_SPI_STATUS_TIMEOUT (2000*HZ)
  57. /* values for bits in power status byte */
  58. #define IFX_SPI_POWER_DATA_PENDING 1
  59. #define IFX_SPI_POWER_SRDY 2
  60. struct ifx_spi_device {
  61. /* Our SPI device */
  62. struct spi_device *spi_dev;
  63. /* Port specific data */
  64. struct kfifo tx_fifo;
  65. spinlock_t fifo_lock;
  66. unsigned long signal_state;
  67. /* TTY Layer logic */
  68. struct tty_port tty_port;
  69. struct device *tty_dev;
  70. int minor;
  71. /* Low level I/O work */
  72. struct tasklet_struct io_work_tasklet;
  73. unsigned long flags;
  74. dma_addr_t rx_dma;
  75. dma_addr_t tx_dma;
  76. int modem; /* Modem type */
  77. int use_dma; /* provide dma-able addrs in SPI msg */
  78. long max_hz; /* max SPI frequency */
  79. spinlock_t write_lock;
  80. int write_pending;
  81. spinlock_t power_lock;
  82. unsigned char power_status;
  83. unsigned char *rx_buffer;
  84. unsigned char *tx_buffer;
  85. dma_addr_t rx_bus;
  86. dma_addr_t tx_bus;
  87. unsigned char spi_more;
  88. unsigned char spi_slave_cts;
  89. struct timer_list spi_timer;
  90. struct spi_message spi_msg;
  91. struct spi_transfer spi_xfer;
  92. struct {
  93. /* gpio lines */
  94. unsigned short srdy; /* slave-ready gpio */
  95. unsigned short mrdy; /* master-ready gpio */
  96. unsigned short reset; /* modem-reset gpio */
  97. unsigned short po; /* modem-on gpio */
  98. unsigned short reset_out; /* modem-in-reset gpio */
  99. /* state/stats */
  100. int unack_srdy_int_nb;
  101. } gpio;
  102. /* modem reset */
  103. unsigned long mdm_reset_state;
  104. #define MR_START 0
  105. #define MR_INPROGRESS 1
  106. #define MR_COMPLETE 2
  107. wait_queue_head_t mdm_reset_wait;
  108. void (*swap_buf)(unsigned char *buf, int len, void *end);
  109. };
  110. #endif /* _IFX6X60_H */