ifx6x60.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #define DRVNAME "ifx6x60"
  13. #define TTYNAME "ttyIFX"
  14. #define IFX_SPI_MAX_MINORS 1
  15. #define IFX_SPI_TRANSFER_SIZE 2048
  16. #define IFX_SPI_FIFO_SIZE 4096
  17. #define IFX_SPI_HEADER_OVERHEAD 4
  18. #define IFX_RESET_TIMEOUT msecs_to_jiffies(50)
  19. /* device flags bitfield definitions */
  20. #define IFX_SPI_STATE_PRESENT 0
  21. #define IFX_SPI_STATE_IO_IN_PROGRESS 1
  22. #define IFX_SPI_STATE_IO_READY 2
  23. #define IFX_SPI_STATE_TIMER_PENDING 3
  24. #define IFX_SPI_STATE_IO_AVAILABLE 4
  25. /* flow control bitfields */
  26. #define IFX_SPI_DCD 0
  27. #define IFX_SPI_CTS 1
  28. #define IFX_SPI_DSR 2
  29. #define IFX_SPI_RI 3
  30. #define IFX_SPI_DTR 4
  31. #define IFX_SPI_RTS 5
  32. #define IFX_SPI_TX_FC 6
  33. #define IFX_SPI_RX_FC 7
  34. #define IFX_SPI_UPDATE 8
  35. #define IFX_SPI_PAYLOAD_SIZE (IFX_SPI_TRANSFER_SIZE - \
  36. IFX_SPI_HEADER_OVERHEAD)
  37. #define IFX_SPI_IRQ_TYPE DETECT_EDGE_RISING
  38. #define IFX_SPI_GPIO_TARGET 0
  39. #define IFX_SPI_GPIO0 0x105
  40. #define IFX_SPI_STATUS_TIMEOUT (2000*HZ)
  41. /* values for bits in power status byte */
  42. #define IFX_SPI_POWER_DATA_PENDING 1
  43. #define IFX_SPI_POWER_SRDY 2
  44. struct ifx_spi_device {
  45. /* Our SPI device */
  46. struct spi_device *spi_dev;
  47. /* Port specific data */
  48. struct kfifo tx_fifo;
  49. spinlock_t fifo_lock;
  50. unsigned long signal_state;
  51. /* TTY Layer logic */
  52. struct tty_port tty_port;
  53. struct device *tty_dev;
  54. int minor;
  55. /* Low level I/O work */
  56. struct tasklet_struct io_work_tasklet;
  57. unsigned long flags;
  58. dma_addr_t rx_dma;
  59. dma_addr_t tx_dma;
  60. int modem; /* Modem type */
  61. int use_dma; /* provide dma-able addrs in SPI msg */
  62. long max_hz; /* max SPI frequency */
  63. spinlock_t write_lock;
  64. int write_pending;
  65. spinlock_t power_lock;
  66. unsigned char power_status;
  67. unsigned char *rx_buffer;
  68. unsigned char *tx_buffer;
  69. dma_addr_t rx_bus;
  70. dma_addr_t tx_bus;
  71. unsigned char spi_more;
  72. unsigned char spi_slave_cts;
  73. struct timer_list spi_timer;
  74. struct spi_message spi_msg;
  75. struct spi_transfer spi_xfer;
  76. struct {
  77. /* gpio lines */
  78. unsigned short srdy; /* slave-ready gpio */
  79. unsigned short mrdy; /* master-ready gpio */
  80. unsigned short reset; /* modem-reset gpio */
  81. unsigned short po; /* modem-on gpio */
  82. unsigned short reset_out; /* modem-in-reset gpio */
  83. /* state/stats */
  84. int unack_srdy_int_nb;
  85. } gpio;
  86. /* modem reset */
  87. unsigned long mdm_reset_state;
  88. #define MR_START 0
  89. #define MR_INPROGRESS 1
  90. #define MR_COMPLETE 2
  91. wait_queue_head_t mdm_reset_wait;
  92. void (*swap_buf)(unsigned char *buf, int len, void *end);
  93. };
  94. #endif /* _IFX6X60_H */