wl1273-core.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. * include/linux/mfd/wl1273-core.h
  3. *
  4. * Some definitions for the wl1273 radio receiver/transmitter chip.
  5. *
  6. * Copyright (C) 2010 Nokia Corporation
  7. * Author: Matti J. Aaltonen <matti.j.aaltonen@nokia.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * 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 St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. */
  23. #ifndef WL1273_CORE_H
  24. #define WL1273_CORE_H
  25. #include <linux/i2c.h>
  26. #include <linux/mfd/core.h>
  27. #define WL1273_FM_DRIVER_NAME "wl1273-fm"
  28. #define RX71_FM_I2C_ADDR 0x22
  29. #define WL1273_STEREO_GET 0
  30. #define WL1273_RSSI_LVL_GET 1
  31. #define WL1273_IF_COUNT_GET 2
  32. #define WL1273_FLAG_GET 3
  33. #define WL1273_RDS_SYNC_GET 4
  34. #define WL1273_RDS_DATA_GET 5
  35. #define WL1273_FREQ_SET 10
  36. #define WL1273_AF_FREQ_SET 11
  37. #define WL1273_MOST_MODE_SET 12
  38. #define WL1273_MOST_BLEND_SET 13
  39. #define WL1273_DEMPH_MODE_SET 14
  40. #define WL1273_SEARCH_LVL_SET 15
  41. #define WL1273_BAND_SET 16
  42. #define WL1273_MUTE_STATUS_SET 17
  43. #define WL1273_RDS_PAUSE_LVL_SET 18
  44. #define WL1273_RDS_PAUSE_DUR_SET 19
  45. #define WL1273_RDS_MEM_SET 20
  46. #define WL1273_RDS_BLK_B_SET 21
  47. #define WL1273_RDS_MSK_B_SET 22
  48. #define WL1273_RDS_PI_MASK_SET 23
  49. #define WL1273_RDS_PI_SET 24
  50. #define WL1273_RDS_SYSTEM_SET 25
  51. #define WL1273_INT_MASK_SET 26
  52. #define WL1273_SEARCH_DIR_SET 27
  53. #define WL1273_VOLUME_SET 28
  54. #define WL1273_AUDIO_ENABLE 29
  55. #define WL1273_PCM_MODE_SET 30
  56. #define WL1273_I2S_MODE_CONFIG_SET 31
  57. #define WL1273_POWER_SET 32
  58. #define WL1273_INTX_CONFIG_SET 33
  59. #define WL1273_PULL_EN_SET 34
  60. #define WL1273_HILO_SET 35
  61. #define WL1273_SWITCH2FREF 36
  62. #define WL1273_FREQ_DRIFT_REPORT 37
  63. #define WL1273_PCE_GET 40
  64. #define WL1273_FIRM_VER_GET 41
  65. #define WL1273_ASIC_VER_GET 42
  66. #define WL1273_ASIC_ID_GET 43
  67. #define WL1273_MAN_ID_GET 44
  68. #define WL1273_TUNER_MODE_SET 45
  69. #define WL1273_STOP_SEARCH 46
  70. #define WL1273_RDS_CNTRL_SET 47
  71. #define WL1273_WRITE_HARDWARE_REG 100
  72. #define WL1273_CODE_DOWNLOAD 101
  73. #define WL1273_RESET 102
  74. #define WL1273_FM_POWER_MODE 254
  75. #define WL1273_FM_INTERRUPT 255
  76. /* Transmitter API */
  77. #define WL1273_CHANL_SET 55
  78. #define WL1273_SCAN_SPACING_SET 56
  79. #define WL1273_REF_SET 57
  80. #define WL1273_POWER_ENB_SET 90
  81. #define WL1273_POWER_ATT_SET 58
  82. #define WL1273_POWER_LEV_SET 59
  83. #define WL1273_AUDIO_DEV_SET 60
  84. #define WL1273_PILOT_DEV_SET 61
  85. #define WL1273_RDS_DEV_SET 62
  86. #define WL1273_PUPD_SET 91
  87. #define WL1273_AUDIO_IO_SET 63
  88. #define WL1273_PREMPH_SET 64
  89. #define WL1273_MONO_SET 66
  90. #define WL1273_MUTE 92
  91. #define WL1273_MPX_LMT_ENABLE 67
  92. #define WL1273_PI_SET 93
  93. #define WL1273_ECC_SET 69
  94. #define WL1273_PTY 70
  95. #define WL1273_AF 71
  96. #define WL1273_DISPLAY_MODE 74
  97. #define WL1273_RDS_REP_SET 77
  98. #define WL1273_RDS_CONFIG_DATA_SET 98
  99. #define WL1273_RDS_DATA_SET 99
  100. #define WL1273_RDS_DATA_ENB 94
  101. #define WL1273_TA_SET 78
  102. #define WL1273_TP_SET 79
  103. #define WL1273_DI_SET 80
  104. #define WL1273_MS_SET 81
  105. #define WL1273_PS_SCROLL_SPEED 82
  106. #define WL1273_TX_AUDIO_LEVEL_TEST 96
  107. #define WL1273_TX_AUDIO_LEVEL_TEST_THRESHOLD 73
  108. #define WL1273_TX_AUDIO_INPUT_LEVEL_RANGE_SET 54
  109. #define WL1273_RX_ANTENNA_SELECT 87
  110. #define WL1273_I2C_DEV_ADDR_SET 86
  111. #define WL1273_REF_ERR_CALIB_PARAM_SET 88
  112. #define WL1273_REF_ERR_CALIB_PERIODICITY_SET 89
  113. #define WL1273_SOC_INT_TRIGGER 52
  114. #define WL1273_SOC_AUDIO_PATH_SET 83
  115. #define WL1273_SOC_PCMI_OVERRIDE 84
  116. #define WL1273_SOC_I2S_OVERRIDE 85
  117. #define WL1273_RSSI_BLOCK_SCAN_FREQ_SET 95
  118. #define WL1273_RSSI_BLOCK_SCAN_START 97
  119. #define WL1273_RSSI_BLOCK_SCAN_DATA_GET 5
  120. #define WL1273_READ_FMANT_TUNE_VALUE 104
  121. #define WL1273_RDS_OFF 0
  122. #define WL1273_RDS_ON 1
  123. #define WL1273_RDS_RESET 2
  124. #define WL1273_AUDIO_DIGITAL 0
  125. #define WL1273_AUDIO_ANALOG 1
  126. #define WL1273_MODE_RX BIT(0)
  127. #define WL1273_MODE_TX BIT(1)
  128. #define WL1273_MODE_OFF BIT(2)
  129. #define WL1273_MODE_SUSPENDED BIT(3)
  130. #define WL1273_RADIO_CHILD BIT(0)
  131. #define WL1273_CODEC_CHILD BIT(1)
  132. #define WL1273_RX_MONO 1
  133. #define WL1273_RX_STEREO 0
  134. #define WL1273_TX_MONO 0
  135. #define WL1273_TX_STEREO 1
  136. #define WL1273_MAX_VOLUME 0xffff
  137. #define WL1273_DEFAULT_VOLUME 0x78b8
  138. /* I2S protocol, left channel first, data width 16 bits */
  139. #define WL1273_PCM_DEF_MODE 0x00
  140. /* Rx */
  141. #define WL1273_AUDIO_ENABLE_I2S BIT(0)
  142. #define WL1273_AUDIO_ENABLE_ANALOG BIT(1)
  143. /* Tx */
  144. #define WL1273_AUDIO_IO_SET_ANALOG 0
  145. #define WL1273_AUDIO_IO_SET_I2S 1
  146. #define WL1273_PUPD_SET_OFF 0x00
  147. #define WL1273_PUPD_SET_ON 0x01
  148. #define WL1273_PUPD_SET_RETENTION 0x10
  149. /* I2S mode */
  150. #define WL1273_IS2_WIDTH_32 0x0
  151. #define WL1273_IS2_WIDTH_40 0x1
  152. #define WL1273_IS2_WIDTH_22_23 0x2
  153. #define WL1273_IS2_WIDTH_23_22 0x3
  154. #define WL1273_IS2_WIDTH_48 0x4
  155. #define WL1273_IS2_WIDTH_50 0x5
  156. #define WL1273_IS2_WIDTH_60 0x6
  157. #define WL1273_IS2_WIDTH_64 0x7
  158. #define WL1273_IS2_WIDTH_80 0x8
  159. #define WL1273_IS2_WIDTH_96 0x9
  160. #define WL1273_IS2_WIDTH_128 0xa
  161. #define WL1273_IS2_WIDTH 0xf
  162. #define WL1273_IS2_FORMAT_STD (0x0 << 4)
  163. #define WL1273_IS2_FORMAT_LEFT (0x1 << 4)
  164. #define WL1273_IS2_FORMAT_RIGHT (0x2 << 4)
  165. #define WL1273_IS2_FORMAT_USER (0x3 << 4)
  166. #define WL1273_IS2_MASTER (0x0 << 6)
  167. #define WL1273_IS2_SLAVEW (0x1 << 6)
  168. #define WL1273_IS2_TRI_AFTER_SENDING (0x0 << 7)
  169. #define WL1273_IS2_TRI_ALWAYS_ACTIVE (0x1 << 7)
  170. #define WL1273_IS2_SDOWS_RR (0x0 << 8)
  171. #define WL1273_IS2_SDOWS_RF (0x1 << 8)
  172. #define WL1273_IS2_SDOWS_FR (0x2 << 8)
  173. #define WL1273_IS2_SDOWS_FF (0x3 << 8)
  174. #define WL1273_IS2_TRI_OPT (0x0 << 10)
  175. #define WL1273_IS2_TRI_ALWAYS (0x1 << 10)
  176. #define WL1273_IS2_RATE_48K (0x0 << 12)
  177. #define WL1273_IS2_RATE_44_1K (0x1 << 12)
  178. #define WL1273_IS2_RATE_32K (0x2 << 12)
  179. #define WL1273_IS2_RATE_22_05K (0x4 << 12)
  180. #define WL1273_IS2_RATE_16K (0x5 << 12)
  181. #define WL1273_IS2_RATE_12K (0x8 << 12)
  182. #define WL1273_IS2_RATE_11_025 (0x9 << 12)
  183. #define WL1273_IS2_RATE_8K (0xa << 12)
  184. #define WL1273_IS2_RATE (0xf << 12)
  185. #define WL1273_I2S_DEF_MODE (WL1273_IS2_WIDTH_32 | \
  186. WL1273_IS2_FORMAT_STD | \
  187. WL1273_IS2_MASTER | \
  188. WL1273_IS2_TRI_AFTER_SENDING | \
  189. WL1273_IS2_SDOWS_RR | \
  190. WL1273_IS2_TRI_OPT | \
  191. WL1273_IS2_RATE_48K)
  192. #define SCHAR_MIN (-128)
  193. #define SCHAR_MAX 127
  194. #define WL1273_FR_EVENT BIT(0)
  195. #define WL1273_BL_EVENT BIT(1)
  196. #define WL1273_RDS_EVENT BIT(2)
  197. #define WL1273_BBLK_EVENT BIT(3)
  198. #define WL1273_LSYNC_EVENT BIT(4)
  199. #define WL1273_LEV_EVENT BIT(5)
  200. #define WL1273_IFFR_EVENT BIT(6)
  201. #define WL1273_PI_EVENT BIT(7)
  202. #define WL1273_PD_EVENT BIT(8)
  203. #define WL1273_STIC_EVENT BIT(9)
  204. #define WL1273_MAL_EVENT BIT(10)
  205. #define WL1273_POW_ENB_EVENT BIT(11)
  206. #define WL1273_SCAN_OVER_EVENT BIT(12)
  207. #define WL1273_ERROR_EVENT BIT(13)
  208. #define TUNER_MODE_STOP_SEARCH 0
  209. #define TUNER_MODE_PRESET 1
  210. #define TUNER_MODE_AUTO_SEEK 2
  211. #define TUNER_MODE_AF 3
  212. #define TUNER_MODE_AUTO_SEEK_PI 4
  213. #define TUNER_MODE_AUTO_SEEK_BULK 5
  214. #define RDS_BLOCK_SIZE 3
  215. struct wl1273_fm_platform_data {
  216. int (*request_resources) (struct i2c_client *client);
  217. void (*free_resources) (void);
  218. void (*enable) (void);
  219. void (*disable) (void);
  220. u8 forbidden_modes;
  221. unsigned int children;
  222. };
  223. #define WL1273_FM_CORE_CELLS 2
  224. #define WL1273_BAND_OTHER 0
  225. #define WL1273_BAND_JAPAN 1
  226. #define WL1273_BAND_JAPAN_LOW 76000
  227. #define WL1273_BAND_JAPAN_HIGH 90000
  228. #define WL1273_BAND_OTHER_LOW 87500
  229. #define WL1273_BAND_OTHER_HIGH 108000
  230. #define WL1273_BAND_TX_LOW 76000
  231. #define WL1273_BAND_TX_HIGH 108000
  232. struct wl1273_core {
  233. struct mfd_cell cells[WL1273_FM_CORE_CELLS];
  234. struct wl1273_fm_platform_data *pdata;
  235. unsigned int mode;
  236. unsigned int i2s_mode;
  237. unsigned int volume;
  238. unsigned int audio_mode;
  239. unsigned int channel_number;
  240. struct mutex lock; /* for serializing fm radio operations */
  241. struct i2c_client *client;
  242. int (*read)(struct wl1273_core *core, u8, u16 *);
  243. int (*write)(struct wl1273_core *core, u8, u16);
  244. int (*write_data)(struct wl1273_core *core, u8 *, u16);
  245. int (*set_audio)(struct wl1273_core *core, unsigned int);
  246. int (*set_volume)(struct wl1273_core *core, unsigned int);
  247. };
  248. #endif /* ifndef WL1273_CORE_H */