mcpdm.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * mcpdm.h -- Defines for McPDM driver
  3. *
  4. * Author: Jorge Eduardo Candelaria <x0107209@ti.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  18. * 02110-1301 USA
  19. *
  20. */
  21. /* McPDM registers */
  22. #define MCPDM_REVISION 0x00
  23. #define MCPDM_SYSCONFIG 0x10
  24. #define MCPDM_IRQSTATUS_RAW 0x24
  25. #define MCPDM_IRQSTATUS 0x28
  26. #define MCPDM_IRQENABLE_SET 0x2C
  27. #define MCPDM_IRQENABLE_CLR 0x30
  28. #define MCPDM_IRQWAKE_EN 0x34
  29. #define MCPDM_DMAENABLE_SET 0x38
  30. #define MCPDM_DMAENABLE_CLR 0x3C
  31. #define MCPDM_DMAWAKEEN 0x40
  32. #define MCPDM_CTRL 0x44
  33. #define MCPDM_DN_DATA 0x48
  34. #define MCPDM_UP_DATA 0x4C
  35. #define MCPDM_FIFO_CTRL_DN 0x50
  36. #define MCPDM_FIFO_CTRL_UP 0x54
  37. #define MCPDM_DN_OFFSET 0x58
  38. /*
  39. * MCPDM_IRQ bit fields
  40. * IRQSTATUS_RAW, IRQSTATUS, IRQENABLE_SET, IRQENABLE_CLR
  41. */
  42. #define MCPDM_DN_IRQ (1 << 0)
  43. #define MCPDM_DN_IRQ_EMPTY (1 << 1)
  44. #define MCPDM_DN_IRQ_ALMST_EMPTY (1 << 2)
  45. #define MCPDM_DN_IRQ_FULL (1 << 3)
  46. #define MCPDM_UP_IRQ (1 << 8)
  47. #define MCPDM_UP_IRQ_EMPTY (1 << 9)
  48. #define MCPDM_UP_IRQ_ALMST_FULL (1 << 10)
  49. #define MCPDM_UP_IRQ_FULL (1 << 11)
  50. #define MCPDM_DOWNLINK_IRQ_MASK 0x00F
  51. #define MCPDM_UPLINK_IRQ_MASK 0xF00
  52. /*
  53. * MCPDM_DMAENABLE bit fields
  54. */
  55. #define DMA_DN_ENABLE 0x1
  56. #define DMA_UP_ENABLE 0x2
  57. /*
  58. * MCPDM_CTRL bit fields
  59. */
  60. #define PDM_UP1_EN 0x0001
  61. #define PDM_UP2_EN 0x0002
  62. #define PDM_UP3_EN 0x0004
  63. #define PDM_DN1_EN 0x0008
  64. #define PDM_DN2_EN 0x0010
  65. #define PDM_DN3_EN 0x0020
  66. #define PDM_DN4_EN 0x0040
  67. #define PDM_DN5_EN 0x0080
  68. #define PDMOUTFORMAT 0x0100
  69. #define CMD_INT 0x0200
  70. #define STATUS_INT 0x0400
  71. #define SW_UP_RST 0x0800
  72. #define SW_DN_RST 0x1000
  73. #define PDM_UP_MASK 0x007
  74. #define PDM_DN_MASK 0x0F8
  75. #define PDM_CMD_MASK 0x200
  76. #define PDM_STATUS_MASK 0x400
  77. #define PDMOUTFORMAT_LJUST (0 << 8)
  78. #define PDMOUTFORMAT_RJUST (1 << 8)
  79. /*
  80. * MCPDM_FIFO_CTRL bit fields
  81. */
  82. #define UP_THRES_MAX 0xF
  83. #define DN_THRES_MAX 0xF
  84. /*
  85. * MCPDM_DN_OFFSET bit fields
  86. */
  87. #define DN_OFST_RX1_EN 0x0001
  88. #define DN_OFST_RX2_EN 0x0100
  89. #define DN_OFST_RX1 1
  90. #define DN_OFST_RX2 9
  91. #define DN_OFST_MAX 0x1F
  92. #define MCPDM_UPLINK 1
  93. #define MCPDM_DOWNLINK 2
  94. struct omap_mcpdm_link {
  95. int irq_mask;
  96. int threshold;
  97. int format;
  98. int channels;
  99. };
  100. struct omap_mcpdm_platform_data {
  101. unsigned long phys_base;
  102. u16 irq;
  103. };
  104. struct omap_mcpdm {
  105. struct device *dev;
  106. unsigned long phys_base;
  107. void __iomem *io_base;
  108. u8 free;
  109. int irq;
  110. spinlock_t lock;
  111. struct omap_mcpdm_platform_data *pdata;
  112. struct clk *clk;
  113. struct omap_mcpdm_link *downlink;
  114. struct omap_mcpdm_link *uplink;
  115. struct completion irq_completion;
  116. int dn_channels;
  117. int up_channels;
  118. };
  119. extern void omap_mcpdm_start(int stream);
  120. extern void omap_mcpdm_stop(int stream);
  121. extern int omap_mcpdm_capture_open(struct omap_mcpdm_link *uplink);
  122. extern int omap_mcpdm_playback_open(struct omap_mcpdm_link *downlink);
  123. extern int omap_mcpdm_capture_close(struct omap_mcpdm_link *uplink);
  124. extern int omap_mcpdm_playback_close(struct omap_mcpdm_link *downlink);
  125. extern int omap_mcpdm_request(void);
  126. extern void omap_mcpdm_free(void);
  127. extern int omap_mcpdm_set_offset(int offset1, int offset2);
  128. int __devinit omap_mcpdm_probe(struct platform_device *pdev);
  129. int __devexit omap_mcpdm_remove(struct platform_device *pdev);