omap_ssi.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* OMAP SSI internal interface.
  2. *
  3. * Copyright (C) 2010 Nokia Corporation. All rights reserved.
  4. * Copyright (C) 2013 Sebastian Reichel
  5. *
  6. * Contact: Carlos Chinea <carlos.chinea@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #ifndef __LINUX_HSI_OMAP_SSI_H__
  23. #define __LINUX_HSI_OMAP_SSI_H__
  24. #include <linux/device.h>
  25. #include <linux/module.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/hsi/hsi.h>
  28. #include <linux/gpio.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/io.h>
  31. #define SSI_MAX_CHANNELS 8
  32. #define SSI_MAX_GDD_LCH 8
  33. #define SSI_BYTES_TO_FRAMES(x) ((((x) - 1) >> 2) + 1)
  34. /**
  35. * struct omap_ssm_ctx - OMAP synchronous serial module (TX/RX) context
  36. * @mode: Bit transmission mode
  37. * @channels: Number of channels
  38. * @framesize: Frame size in bits
  39. * @timeout: RX frame timeout
  40. * @divisor: TX divider
  41. * @arb_mode: Arbitration mode for TX frame (Round robin, priority)
  42. */
  43. struct omap_ssm_ctx {
  44. u32 mode;
  45. u32 channels;
  46. u32 frame_size;
  47. union {
  48. u32 timeout; /* Rx Only */
  49. struct {
  50. u32 arb_mode;
  51. u32 divisor;
  52. }; /* Tx only */
  53. };
  54. };
  55. /**
  56. * struct omap_ssi_port - OMAP SSI port data
  57. * @dev: device associated to the port (HSI port)
  58. * @pdev: platform device associated to the port
  59. * @sst_dma: SSI transmitter physical base address
  60. * @ssr_dma: SSI receiver physical base address
  61. * @sst_base: SSI transmitter base address
  62. * @ssr_base: SSI receiver base address
  63. * @wk_lock: spin lock to serialize access to the wake lines
  64. * @lock: Spin lock to serialize access to the SSI port
  65. * @channels: Current number of channels configured (1,2,4 or 8)
  66. * @txqueue: TX message queues
  67. * @rxqueue: RX message queues
  68. * @brkqueue: Queue of incoming HWBREAK requests (FRAME mode)
  69. * @irq: IRQ number
  70. * @wake_irq: IRQ number for incoming wake line (-1 if none)
  71. * @wake_gpio: GPIO number for incoming wake line (-1 if none)
  72. * @pio_tasklet: Bottom half for PIO transfers and events
  73. * @wake_tasklet: Bottom half for incoming wake events
  74. * @wkin_cken: Keep track of clock references due to the incoming wake line
  75. * @wk_refcount: Reference count for output wake line
  76. * @sys_mpu_enable: Context for the interrupt enable register for irq 0
  77. * @sst: Context for the synchronous serial transmitter
  78. * @ssr: Context for the synchronous serial receiver
  79. */
  80. struct omap_ssi_port {
  81. struct device *dev;
  82. struct device *pdev;
  83. dma_addr_t sst_dma;
  84. dma_addr_t ssr_dma;
  85. void __iomem *sst_base;
  86. void __iomem *ssr_base;
  87. spinlock_t wk_lock;
  88. spinlock_t lock;
  89. unsigned int channels;
  90. struct list_head txqueue[SSI_MAX_CHANNELS];
  91. struct list_head rxqueue[SSI_MAX_CHANNELS];
  92. struct list_head brkqueue;
  93. unsigned int irq;
  94. int wake_irq;
  95. int wake_gpio;
  96. struct tasklet_struct pio_tasklet;
  97. struct tasklet_struct wake_tasklet;
  98. bool wktest:1; /* FIXME: HACK to be removed */
  99. bool wkin_cken:1; /* Workaround */
  100. unsigned int wk_refcount;
  101. /* OMAP SSI port context */
  102. u32 sys_mpu_enable; /* We use only one irq */
  103. struct omap_ssm_ctx sst;
  104. struct omap_ssm_ctx ssr;
  105. u32 loss_count;
  106. u32 port_id;
  107. #ifdef CONFIG_DEBUG_FS
  108. struct dentry *dir;
  109. #endif
  110. };
  111. /**
  112. * struct gdd_trn - GDD transaction data
  113. * @msg: Pointer to the HSI message being served
  114. * @sg: Pointer to the current sg entry being served
  115. */
  116. struct gdd_trn {
  117. struct hsi_msg *msg;
  118. struct scatterlist *sg;
  119. };
  120. /**
  121. * struct omap_ssi_controller - OMAP SSI controller data
  122. * @dev: device associated to the controller (HSI controller)
  123. * @sys: SSI I/O base address
  124. * @gdd: GDD I/O base address
  125. * @fck: SSI functional clock
  126. * @gdd_irq: IRQ line for GDD
  127. * @gdd_tasklet: bottom half for DMA transfers
  128. * @gdd_trn: Array of GDD transaction data for ongoing GDD transfers
  129. * @lock: lock to serialize access to GDD
  130. * @loss_count: To follow if we need to restore context or not
  131. * @max_speed: Maximum TX speed (Kb/s) set by the clients.
  132. * @sysconfig: SSI controller saved context
  133. * @gdd_gcr: SSI GDD saved context
  134. * @get_loss: Pointer to omap_pm_get_dev_context_loss_count, if any
  135. * @port: Array of pointers of the ports of the controller
  136. * @dir: Debugfs SSI root directory
  137. */
  138. struct omap_ssi_controller {
  139. struct device *dev;
  140. void __iomem *sys;
  141. void __iomem *gdd;
  142. struct clk *fck;
  143. unsigned int gdd_irq;
  144. struct tasklet_struct gdd_tasklet;
  145. struct gdd_trn gdd_trn[SSI_MAX_GDD_LCH];
  146. spinlock_t lock;
  147. unsigned long fck_rate;
  148. u32 loss_count;
  149. u32 max_speed;
  150. /* OMAP SSI Controller context */
  151. u32 sysconfig;
  152. u32 gdd_gcr;
  153. int (*get_loss)(struct device *dev);
  154. struct omap_ssi_port **port;
  155. #ifdef CONFIG_DEBUG_FS
  156. struct dentry *dir;
  157. #endif
  158. };
  159. #endif /* __LINUX_HSI_OMAP_SSI_H__ */