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

source code of linux/arch/arm/mach-davinci/pdata-quirks.c