pdata-quirks.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Legacy platform_data quirks
  4. *
  5. * Copyright (C) 2016 BayLibre, Inc
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/of_platform.h>
  9. #include <media/i2c/tvp514x.h>
  10. #include <media/i2c/adv7343.h>
  11. #include "common.h"
  12. #include "da8xx.h"
  13. struct pdata_init {
  14. const char *compatible;
  15. void (*fn)(void);
  16. };
  17. #define TVP5147_CH0 "tvp514x-0"
  18. #define TVP5147_CH1 "tvp514x-1"
  19. /* VPIF capture configuration */
  20. static struct tvp514x_platform_data tvp5146_pdata = {
  21. .clk_polarity = 0,
  22. .hs_polarity = 1,
  23. .vs_polarity = 1,
  24. };
  25. #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
  26. static struct vpif_input da850_ch0_inputs[] = {
  27. {
  28. .input = {
  29. .index = 0,
  30. .name = "Composite",
  31. .type = V4L2_INPUT_TYPE_CAMERA,
  32. .capabilities = V4L2_IN_CAP_STD,
  33. .std = TVP514X_STD_ALL,
  34. },
  35. .input_route = INPUT_CVBS_VI2B,
  36. .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  37. .subdev_name = TVP5147_CH0,
  38. },
  39. };
  40. static struct vpif_input da850_ch1_inputs[] = {
  41. {
  42. .input = {
  43. .index = 0,
  44. .name = "S-Video",
  45. .type = V4L2_INPUT_TYPE_CAMERA,
  46. .capabilities = V4L2_IN_CAP_STD,
  47. .std = TVP514X_STD_ALL,
  48. },
  49. .input_route = INPUT_SVIDEO_VI2C_VI1C,
  50. .output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,
  51. .subdev_name = TVP5147_CH1,
  52. },
  53. };
  54. static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
  55. {
  56. .name = TVP5147_CH0,
  57. .board_info = {
  58. I2C_BOARD_INFO("tvp5146", 0x5d),
  59. .platform_data = &tvp5146_pdata,
  60. },
  61. },
  62. {
  63. .name = TVP5147_CH1,
  64. .board_info = {
  65. I2C_BOARD_INFO("tvp5146", 0x5c),
  66. .platform_data = &tvp5146_pdata,
  67. },
  68. },
  69. };
  70. static struct vpif_capture_config da850_vpif_capture_config = {
  71. .subdev_info = da850_vpif_capture_sdev_info,
  72. .subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
  73. .chan_config[0] = {
  74. .inputs = da850_ch0_inputs,
  75. .input_count = ARRAY_SIZE(da850_ch0_inputs),
  76. .vpif_if = {
  77. .if_type = VPIF_IF_BT656,
  78. .hd_pol = 1,
  79. .vd_pol = 1,
  80. .fid_pol = 0,
  81. },
  82. },
  83. .chan_config[1] = {
  84. .inputs = da850_ch1_inputs,
  85. .input_count = ARRAY_SIZE(da850_ch1_inputs),
  86. .vpif_if = {
  87. .if_type = VPIF_IF_BT656,
  88. .hd_pol = 1,
  89. .vd_pol = 1,
  90. .fid_pol = 0,
  91. },
  92. },
  93. .card_name = "DA850/OMAP-L138 Video Capture",
  94. };
  95. static void __init da850_vpif_legacy_register_capture(void)
  96. {
  97. int ret;
  98. ret = da850_register_vpif_capture(&da850_vpif_capture_config);
  99. if (ret)
  100. pr_warn("%s: VPIF capture setup failed: %d\n",
  101. __func__, ret);
  102. }
  103. static void __init da850_vpif_capture_legacy_init_lcdk(void)
  104. {
  105. da850_vpif_capture_config.subdev_count = 1;
  106. da850_vpif_legacy_register_capture();
  107. }
  108. static void __init da850_vpif_capture_legacy_init_evm(void)
  109. {
  110. da850_vpif_legacy_register_capture();
  111. }
  112. static struct adv7343_platform_data adv7343_pdata = {
  113. .mode_config = {
  114. .dac = { 1, 1, 1 },
  115. },
  116. .sd_config = {
  117. .sd_dac_out = { 1 },
  118. },
  119. };
  120. static struct vpif_subdev_info da850_vpif_subdev[] = {
  121. {
  122. .name = "adv7343",
  123. .board_info = {
  124. I2C_BOARD_INFO("adv7343", 0x2a),
  125. .platform_data = &adv7343_pdata,
  126. },
  127. },
  128. };
  129. static const struct vpif_output da850_ch0_outputs[] = {
  130. {
  131. .output = {
  132. .index = 0,
  133. .name = "Composite",
  134. .type = V4L2_OUTPUT_TYPE_ANALOG,
  135. .capabilities = V4L2_OUT_CAP_STD,
  136. .std = V4L2_STD_ALL,
  137. },
  138. .subdev_name = "adv7343",
  139. .output_route = ADV7343_COMPOSITE_ID,
  140. },
  141. {
  142. .output = {
  143. .index = 1,
  144. .name = "S-Video",
  145. .type = V4L2_OUTPUT_TYPE_ANALOG,
  146. .capabilities = V4L2_OUT_CAP_STD,
  147. .std = V4L2_STD_ALL,
  148. },
  149. .subdev_name = "adv7343",
  150. .output_route = ADV7343_SVIDEO_ID,
  151. },
  152. };
  153. static struct vpif_display_config da850_vpif_display_config = {
  154. .subdevinfo = da850_vpif_subdev,
  155. .subdev_count = ARRAY_SIZE(da850_vpif_subdev),
  156. .chan_config[0] = {
  157. .outputs = da850_ch0_outputs,
  158. .output_count = ARRAY_SIZE(da850_ch0_outputs),
  159. },
  160. .card_name = "DA850/OMAP-L138 Video Display",
  161. };
  162. static void __init da850_vpif_display_legacy_init_evm(void)
  163. {
  164. int ret;
  165. ret = da850_register_vpif_display(&da850_vpif_display_config);
  166. if (ret)
  167. pr_warn("%s: VPIF display setup failed: %d\n",
  168. __func__, ret);
  169. }
  170. static void pdata_quirks_check(struct pdata_init *quirks)
  171. {
  172. while (quirks->compatible) {
  173. if (of_machine_is_compatible(quirks->compatible)) {
  174. if (quirks->fn)
  175. quirks->fn();
  176. }
  177. quirks++;
  178. }
  179. }
  180. static struct pdata_init pdata_quirks[] __initdata = {
  181. { "ti,da850-lcdk", da850_vpif_capture_legacy_init_lcdk, },
  182. { "ti,da850-evm", da850_vpif_display_legacy_init_evm, },
  183. { "ti,da850-evm", da850_vpif_capture_legacy_init_evm, },
  184. { /* sentinel */ },
  185. };
  186. void __init pdata_quirks_init(void)
  187. {
  188. pdata_quirks_check(pdata_quirks);
  189. }