modem_variation.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Copyright (C) 2010 Google, Inc.
  3. * Copyright (C) 2010 Samsung Electronics.
  4. *
  5. * This software is licensed under the terms of the GNU General Public
  6. * License version 2, as published by the Free Software Foundation, and
  7. * may be copied, distributed, and modified under those terms.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #ifndef __MODEM_VARIATION_H__
  16. #define __MODEM_VARIATION_H__
  17. #include <linux/platform_data/modem.h>
  18. #define DECLARE_MODEM_INIT(type) \
  19. int type ## _init_modemctl_device(struct modem_ctl *mc, \
  20. struct modem_data *pdata)
  21. #define DECLARE_MODEM_INIT_DUMMY(type) \
  22. static DECLARE_MODEM_INIT(type) { return 0; }
  23. #define DECLARE_LINK_INIT(type) \
  24. struct link_device *type ## _create_link_device( \
  25. struct platform_device *pdev)
  26. #define DECLARE_LINK_INIT_DUMMY(type) \
  27. static DECLARE_LINK_INIT(type) { return NULL; }
  28. #define MODEM_INIT_CALL(type) type ## _init_modemctl_device
  29. #define LINK_INIT_CALL(type) type ## _create_link_device
  30. /* add declaration of modem & link type */
  31. /* modem device support */
  32. DECLARE_MODEM_INIT_DUMMY(dummy)
  33. #ifdef CONFIG_UMTS_MODEM_XMM6260
  34. DECLARE_MODEM_INIT(xmm6260);
  35. #else
  36. DECLARE_MODEM_INIT_DUMMY(xmm6260)
  37. #endif
  38. #ifdef CONFIG_UMTS_MODEM_XMM6262
  39. DECLARE_MODEM_INIT(xmm6262);
  40. #else
  41. DECLARE_MODEM_INIT_DUMMY(xmm6262)
  42. #endif
  43. #ifdef CONFIG_CDMA_MODEM_CBP71
  44. DECLARE_MODEM_INIT(cbp71);
  45. #else
  46. DECLARE_MODEM_INIT_DUMMY(cbp71)
  47. #endif
  48. #ifdef CONFIG_CDMA_MODEM_CBP72
  49. DECLARE_MODEM_INIT(cbp72);
  50. #else
  51. DECLARE_MODEM_INIT_DUMMY(cbp72)
  52. #endif
  53. #ifdef CONFIG_LTE_MODEM_CMC221
  54. DECLARE_MODEM_INIT(cmc221);
  55. #else
  56. DECLARE_MODEM_INIT_DUMMY(cmc221)
  57. #endif
  58. #ifdef CONFIG_CDMA_MODEM_MDM6600
  59. DECLARE_MODEM_INIT(mdm6600);
  60. #else
  61. DECLARE_MODEM_INIT_DUMMY(mdm6600)
  62. #endif
  63. #ifdef CONFIG_GSM_MODEM_ESC6270
  64. DECLARE_MODEM_INIT(esc6270);
  65. #else
  66. DECLARE_MODEM_INIT_DUMMY(esc6270)
  67. #endif
  68. #ifdef CONFIG_GSM_MODEM_SPRD6500
  69. DECLARE_MODEM_INIT(sprd6500);
  70. #else
  71. DECLARE_MODEM_INIT_DUMMY(sprd6500)
  72. #endif
  73. #ifdef CONFIG_CDMA_MODEM_MSM8x55
  74. DECLARE_MODEM_INIT(msm8x55);
  75. #else
  76. DECLARE_MODEM_INIT_DUMMY(msm8x55)
  77. #endif
  78. #ifdef CONFIG_UMTS_MODEM_MSM7x27
  79. DECLARE_MODEM_INIT(msm7x27);
  80. #else
  81. DECLARE_MODEM_INIT_DUMMY(msm7x27)
  82. #endif
  83. /* link device support */
  84. DECLARE_LINK_INIT_DUMMY(undefined)
  85. #ifdef CONFIG_LINK_DEVICE_MIPI
  86. DECLARE_LINK_INIT(mipi);
  87. #else
  88. DECLARE_LINK_INIT_DUMMY(mipi)
  89. #endif
  90. #ifdef CONFIG_LINK_DEVICE_DPRAM
  91. DECLARE_LINK_INIT(dpram);
  92. #else
  93. DECLARE_LINK_INIT_DUMMY(dpram)
  94. #endif
  95. #ifdef CONFIG_LINK_DEVICE_PLD
  96. DECLARE_LINK_INIT(pld);
  97. #else
  98. DECLARE_LINK_INIT_DUMMY(pld)
  99. #endif
  100. #ifdef CONFIG_LINK_DEVICE_SPI
  101. DECLARE_LINK_INIT(spi);
  102. #else
  103. DECLARE_LINK_INIT_DUMMY(spi)
  104. #endif
  105. #ifdef CONFIG_LINK_DEVICE_USB
  106. DECLARE_LINK_INIT(usb);
  107. #else
  108. DECLARE_LINK_INIT_DUMMY(usb)
  109. #endif
  110. #ifdef CONFIG_LINK_DEVICE_HSIC
  111. DECLARE_LINK_INIT(hsic);
  112. #else
  113. DECLARE_LINK_INIT_DUMMY(hsic)
  114. #endif
  115. #ifdef CONFIG_LINK_DEVICE_C2C
  116. DECLARE_LINK_INIT(c2c);
  117. #else
  118. DECLARE_LINK_INIT_DUMMY(c2c)
  119. #endif
  120. typedef int (*modem_init_call)(struct modem_ctl *, struct modem_data *);
  121. static modem_init_call modem_init_func[] = {
  122. MODEM_INIT_CALL(xmm6260),
  123. MODEM_INIT_CALL(xmm6262),
  124. MODEM_INIT_CALL(cbp71),
  125. MODEM_INIT_CALL(cbp72),
  126. MODEM_INIT_CALL(cmc221),
  127. MODEM_INIT_CALL(mdm6600),
  128. MODEM_INIT_CALL(esc6270),
  129. MODEM_INIT_CALL(msm8x55),
  130. MODEM_INIT_CALL(msm7x27),
  131. MODEM_INIT_CALL(sprd6500),
  132. MODEM_INIT_CALL(dummy),
  133. };
  134. typedef struct link_device *(*link_init_call)(struct platform_device *);
  135. static link_init_call link_init_func[] = {
  136. LINK_INIT_CALL(undefined),
  137. LINK_INIT_CALL(mipi),
  138. LINK_INIT_CALL(dpram),
  139. LINK_INIT_CALL(spi),
  140. LINK_INIT_CALL(usb),
  141. LINK_INIT_CALL(hsic),
  142. LINK_INIT_CALL(c2c),
  143. LINK_INIT_CALL(pld),
  144. };
  145. static int call_modem_init_func(struct modem_ctl *mc, struct modem_data *pdata)
  146. {
  147. if (modem_init_func[pdata->modem_type])
  148. return modem_init_func[pdata->modem_type](mc, pdata);
  149. else
  150. return -ENOTSUPP;
  151. }
  152. static struct link_device *call_link_init_func(struct platform_device *pdev,
  153. enum modem_link link_type)
  154. {
  155. if (link_init_func[link_type])
  156. return link_init_func[link_type](pdev);
  157. else
  158. return NULL;
  159. }
  160. #endif