sh_fsi.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef __SOUND_FSI_H
  2. #define __SOUND_FSI_H
  3. /*
  4. * Fifo-attached Serial Interface (FSI) support for SH7724
  5. *
  6. * Copyright (C) 2009 Renesas Solutions Corp.
  7. * Kuninori Morimoto <morimoto.kuninori@renesas.com>
  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. #define FSI_PORT_A 0
  14. #define FSI_PORT_B 1
  15. /* flags format
  16. * 0xABCDEEFF
  17. *
  18. * A: channel size for TDM (input)
  19. * B: channel size for TDM (ooutput)
  20. * C: inversion
  21. * D: mode
  22. * E: input format
  23. * F: output format
  24. */
  25. #include <linux/clk.h>
  26. #include <sound/soc.h>
  27. /* TDM channel */
  28. #define SH_FSI_SET_CH_I(x) ((x & 0xF) << 28)
  29. #define SH_FSI_SET_CH_O(x) ((x & 0xF) << 24)
  30. #define SH_FSI_CH_IMASK 0xF0000000
  31. #define SH_FSI_CH_OMASK 0x0F000000
  32. #define SH_FSI_GET_CH_I(x) ((x & SH_FSI_CH_IMASK) >> 28)
  33. #define SH_FSI_GET_CH_O(x) ((x & SH_FSI_CH_OMASK) >> 24)
  34. /* clock inversion */
  35. #define SH_FSI_INVERSION_MASK 0x00F00000
  36. #define SH_FSI_LRM_INV (1 << 20)
  37. #define SH_FSI_BRM_INV (1 << 21)
  38. #define SH_FSI_LRS_INV (1 << 22)
  39. #define SH_FSI_BRS_INV (1 << 23)
  40. /* mode */
  41. #define SH_FSI_MODE_MASK 0x000F0000
  42. #define SH_FSI_IN_SLAVE_MODE (1 << 16) /* default master mode */
  43. #define SH_FSI_OUT_SLAVE_MODE (1 << 17) /* default master mode */
  44. /* DI format */
  45. #define SH_FSI_FMT_MASK 0x000000FF
  46. #define SH_FSI_IFMT(x) (((SH_FSI_FMT_ ## x) & SH_FSI_FMT_MASK) << 8)
  47. #define SH_FSI_OFMT(x) (((SH_FSI_FMT_ ## x) & SH_FSI_FMT_MASK) << 0)
  48. #define SH_FSI_GET_IFMT(x) ((x >> 8) & SH_FSI_FMT_MASK)
  49. #define SH_FSI_GET_OFMT(x) ((x >> 0) & SH_FSI_FMT_MASK)
  50. #define SH_FSI_FMT_MONO 0
  51. #define SH_FSI_FMT_MONO_DELAY 1
  52. #define SH_FSI_FMT_PCM 2
  53. #define SH_FSI_FMT_I2S 3
  54. #define SH_FSI_FMT_TDM 4
  55. #define SH_FSI_FMT_TDM_DELAY 5
  56. #define SH_FSI_FMT_SPDIF 6
  57. #define SH_FSI_IFMT_TDM_CH(x) \
  58. (SH_FSI_IFMT(TDM) | SH_FSI_SET_CH_I(x))
  59. #define SH_FSI_IFMT_TDM_DELAY_CH(x) \
  60. (SH_FSI_IFMT(TDM_DELAY) | SH_FSI_SET_CH_I(x))
  61. #define SH_FSI_OFMT_TDM_CH(x) \
  62. (SH_FSI_OFMT(TDM) | SH_FSI_SET_CH_O(x))
  63. #define SH_FSI_OFMT_TDM_DELAY_CH(x) \
  64. (SH_FSI_OFMT(TDM_DELAY) | SH_FSI_SET_CH_O(x))
  65. /*
  66. * set_rate return value
  67. *
  68. * see ACKMD/BPFMD on
  69. * ACK_MD (FSI2)
  70. * CKG1 (FSI)
  71. *
  72. * err: return value < 0
  73. *
  74. * 0x-00000AB
  75. *
  76. * A: ACKMD value
  77. * B: BPFMD value
  78. */
  79. #define SH_FSI_ACKMD_MASK (0xF << 0)
  80. #define SH_FSI_ACKMD_512 (1 << 0)
  81. #define SH_FSI_ACKMD_256 (2 << 0)
  82. #define SH_FSI_ACKMD_128 (3 << 0)
  83. #define SH_FSI_ACKMD_64 (4 << 0)
  84. #define SH_FSI_ACKMD_32 (5 << 0)
  85. #define SH_FSI_BPFMD_MASK (0xF << 4)
  86. #define SH_FSI_BPFMD_512 (1 << 4)
  87. #define SH_FSI_BPFMD_256 (2 << 4)
  88. #define SH_FSI_BPFMD_128 (3 << 4)
  89. #define SH_FSI_BPFMD_64 (4 << 4)
  90. #define SH_FSI_BPFMD_32 (5 << 4)
  91. #define SH_FSI_BPFMD_16 (6 << 4)
  92. struct sh_fsi_platform_info {
  93. unsigned long porta_flags;
  94. unsigned long portb_flags;
  95. int (*set_rate)(int is_porta, int rate); /* for master mode */
  96. };
  97. extern struct snd_soc_dai fsi_soc_dai[2];
  98. extern struct snd_soc_platform fsi_soc_platform;
  99. #endif /* __SOUND_FSI_H */