1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/module.h>
3 #include <linux/delay.h>
4 #include <linux/err.h>
5 #include <linux/hdmi.h>
6 #include <linux/mutex.h>
7 #include <linux/nvmem-consumer.h>
8 #include <linux/of_device.h>
9 #include <linux/pm_runtime.h>
10
11 #include <drm/drmP.h>
12 #include <drm/drm_atomic_helper.h>
13 #include <drm/drm_crtc_helper.h>
14 #include <drm/drm_of.h>
15
16 #include <uapi/linux/videodev2.h>
17
18 #include "rockchip_drm_drv.h"
19 #include "rockchip_drm_tve.h"
20 #include "rockchip_drm_vop.h"
21
22 #define RK322X_VDAC_STANDARD 0x15
23
24 static const struct drm_display_mode cvbs_mode[] = {
25 { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 13500, 720, 753,
26 816, 864, 0, 576, 580, 586, 625, 0,
27 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
28 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
29 .vrefresh = 50, 0, },
30
31 { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 13500, 720, 753,
32 815, 858, 0, 480, 480, 486, 525, 0,
33 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
34 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
35 .vrefresh = 60, 0, },
36 };
37
38 #define tve_writel(offset, v) writel_relaxed(v, tve->regbase + (offset))
39 #define tve_readl(offset) readl_relaxed(tve->regbase + (offset))
40
41 #define tve_dac_writel(offset, v) writel_relaxed(v, tve->vdacbase + (offset))
42 #define tve_dac_readl(offset) readl_relaxed(tve->vdacbase + (offset))
43
44 #define connector_to_tve(x) container_of(x, struct rockchip_tve, connector)
45 #define encoder_to_tve(x) container_of(x, struct rockchip_tve, encoder)
46
47 static int
rockchip_tve_get_modes(struct drm_connector * connector)48 rockchip_tve_get_modes(struct drm_connector *connector)
49 {
50 int count;
51 struct rockchip_tve *tve = connector_to_tve(connector);
52
53 for (count = 0; count < ARRAY_SIZE(cvbs_mode); count++) {
54 struct drm_display_mode *mode_ptr;
55
56 mode_ptr = drm_mode_duplicate(connector->dev,
57 &cvbs_mode[count]);
58 if (tve->preferred_mode == count)
59 mode_ptr->type |= DRM_MODE_TYPE_PREFERRED;
60 drm_mode_probed_add(connector, mode_ptr);
61 }
62
63 return count;
64 }
65
66 static enum drm_mode_status
rockchip_tve_mode_valid(struct drm_connector * connector,struct drm_display_mode * mode)67 rockchip_tve_mode_valid(struct drm_connector *connector,
68 struct drm_display_mode *mode)
69 {
70 return MODE_OK;
71 }
72
rockchip_tve_best_encoder(struct drm_connector * connector)73 static struct drm_encoder *rockchip_tve_best_encoder(struct drm_connector
74 *connector)
75 {
76 struct rockchip_tve *tve = connector_to_tve(connector);
77
78 return &tve->encoder;
79 }
80
rockchip_encoder_destroy(struct drm_encoder * encoder)81 static void rockchip_encoder_destroy(struct drm_encoder *encoder)
82 {
83 drm_encoder_cleanup(encoder);
84 }
85
86 static enum drm_connector_status
rockchip_tve_connector_detect(struct drm_connector * connector,bool force)87 rockchip_tve_connector_detect(struct drm_connector *connector, bool force)
88 {
89 return connector_status_connected;
90 }
91
rockchip_tve_connector_destroy(struct drm_connector * connector)92 static void rockchip_tve_connector_destroy(struct drm_connector *connector)
93 {
94 drm_connector_cleanup(connector);
95 }
96
tve_set_mode(struct rockchip_tve * tve)97 static void tve_set_mode(struct rockchip_tve *tve)
98 {
99 int mode = tve->tv_format;
100
101 dev_dbg(tve->dev, "tve set mode:%d\n", mode);
102 if (tve->inputformat == INPUT_FORMAT_RGB)
103 tve_writel(TV_CTRL, v_CVBS_MODE(mode) | v_CLK_UPSTREAM_EN(2) |
104 v_TIMING_EN(2) | v_LUMA_FILTER_GAIN(0) |
105 v_LUMA_FILTER_UPSAMPLE(1) | v_CSC_PATH(0));
106 else
107 tve_writel(TV_CTRL, v_CVBS_MODE(mode) | v_CLK_UPSTREAM_EN(2) |
108 v_TIMING_EN(2) | v_LUMA_FILTER_GAIN(0) |
109 v_LUMA_FILTER_UPSAMPLE(1) | v_CSC_PATH(3));
110
111 tve_writel(TV_LUMA_FILTER0, tve->lumafilter0);
112 tve_writel(TV_LUMA_FILTER1, tve->lumafilter1);
113 tve_writel(TV_LUMA_FILTER2, tve->lumafilter2);
114
115 if (mode == TVOUT_CVBS_NTSC) {
116 dev_dbg(tve->dev, "NTSC MODE\n");
117 tve_writel(TV_ROUTING, v_DAC_SENSE_EN(0) | v_Y_IRE_7_5(1) |
118 v_Y_AGC_PULSE_ON(0) | v_Y_VIDEO_ON(1) |
119 v_YPP_MODE(1) | v_Y_SYNC_ON(1) | v_PIC_MODE(mode));
120 tve_writel(TV_BW_CTRL, v_CHROMA_BW(BP_FILTER_NTSC) |
121 v_COLOR_DIFF_BW(COLOR_DIFF_FILTER_BW_1_3));
122 tve_writel(TV_SATURATION, 0x0042543C);
123 if (tve->test_mode)
124 tve_writel(TV_BRIGHTNESS_CONTRAST, 0x00008300);
125 else
126 tve_writel(TV_BRIGHTNESS_CONTRAST, 0x00007900);
127
128 tve_writel(TV_FREQ_SC, 0x21F07BD7);
129 tve_writel(TV_SYNC_TIMING, 0x00C07a81);
130 tve_writel(TV_ADJ_TIMING, 0x96B40000 | 0x70);
131 tve_writel(TV_ACT_ST, 0x001500D6);
132 tve_writel(TV_ACT_TIMING, 0x069800FC | (1 << 12) | (1 << 28));
133
134 } else if (mode == TVOUT_CVBS_PAL) {
135 dev_dbg(tve->dev, "PAL MODE\n");
136 tve_writel(TV_ROUTING, v_DAC_SENSE_EN(0) | v_Y_IRE_7_5(0) |
137 v_Y_AGC_PULSE_ON(0) | v_Y_VIDEO_ON(1) |
138 v_YPP_MODE(1) | v_Y_SYNC_ON(1) | v_PIC_MODE(mode));
139 tve_writel(TV_BW_CTRL, v_CHROMA_BW(BP_FILTER_PAL) |
140 v_COLOR_DIFF_BW(COLOR_DIFF_FILTER_BW_1_3));
141
142 tve_writel(TV_SATURATION, tve->saturation);
143 tve_writel(TV_BRIGHTNESS_CONTRAST, tve->brightcontrast);
144
145 tve_writel(TV_FREQ_SC, 0x2A098ACB);
146 tve_writel(TV_SYNC_TIMING, 0x00C28381);
147 tve_writel(TV_ADJ_TIMING, (0xc << 28) | 0x06c00800 | 0x80);
148 tve_writel(TV_ACT_ST, 0x001500F6);
149 tve_writel(TV_ACT_TIMING, 0x0694011D | (1 << 12) | (2 << 28));
150
151 tve_writel(TV_ADJ_TIMING, tve->adjtiming);
152 tve_writel(TV_ACT_TIMING, 0x0694011D |
153 (1 << 12) | (2 << 28));
154 }
155 }
156
dac_init(struct rockchip_tve * tve)157 static void dac_init(struct rockchip_tve *tve)
158 {
159 tve_dac_writel(VDAC_VDAC1, v_CUR_REG(tve->dac1level) |
160 m_DR_PWR_DOWN | m_BG_PWR_DOWN);
161 tve_dac_writel(VDAC_VDAC2, v_CUR_CTR(tve->daclevel));
162 tve_dac_writel(VDAC_VDAC3, v_CAB_EN(0));
163 }
164
dac_enable(struct rockchip_tve * tve,bool enable)165 static void dac_enable(struct rockchip_tve *tve, bool enable)
166 {
167 u32 val;
168
169 if (enable) {
170 dev_dbg(tve->dev, "dac enable\n");
171 val = 0x70;
172 } else {
173 dev_dbg(tve->dev, "dac disable\n");
174 val = v_CUR_REG(0x7) | m_DR_PWR_DOWN | m_BG_PWR_DOWN;
175 }
176
177 if (tve->vdacbase)
178 tve_dac_writel(VDAC_VDAC1, val);
179 }
180
cvbs_set_disable(struct rockchip_tve * tve)181 static int cvbs_set_disable(struct rockchip_tve *tve)
182 {
183 int ret = 0;
184
185 dev_dbg(tve->dev, "%s\n", __func__);
186 if (!tve->enable)
187 return 0;
188
189 ret = pm_runtime_put(tve->dev);
190 if (ret < 0) {
191 dev_err(tve->dev, "failed to put pm runtime: %d\n", ret);
192 return ret;
193 }
194 dac_enable(tve, false);
195 tve->enable = 0;
196
197 return 0;
198 }
199
cvbs_set_enable(struct rockchip_tve * tve)200 static int cvbs_set_enable(struct rockchip_tve *tve)
201 {
202 int ret = 0;
203
204 dev_dbg(tve->dev, "%s\n", __func__);
205 if (tve->enable)
206 return 0;
207
208 ret = pm_runtime_get_sync(tve->dev);
209 if (ret < 0) {
210 dev_err(tve->dev, "failed to get pm runtime: %d\n", ret);
211 return ret;
212 }
213 dac_enable(tve, true);
214 tve_set_mode(tve);
215 tve->enable = 1;
216
217 return 0;
218 }
219
rockchip_tve_encoder_enable(struct drm_encoder * encoder)220 static void rockchip_tve_encoder_enable(struct drm_encoder *encoder)
221 {
222 struct rockchip_tve *tve = encoder_to_tve(encoder);
223
224 mutex_lock(&tve->suspend_lock);
225
226 dev_dbg(tve->dev, "tve encoder enable\n");
227 cvbs_set_enable(tve);
228
229 mutex_unlock(&tve->suspend_lock);
230 }
231
rockchip_tve_encoder_disable(struct drm_encoder * encoder)232 static void rockchip_tve_encoder_disable(struct drm_encoder *encoder)
233 {
234 struct rockchip_tve *tve = encoder_to_tve(encoder);
235
236 mutex_lock(&tve->suspend_lock);
237
238 dev_dbg(tve->dev, "tve encoder enable\n");
239 cvbs_set_disable(tve);
240
241 mutex_unlock(&tve->suspend_lock);
242 }
243
rockchip_tve_encoder_mode_set(struct drm_encoder * encoder,struct drm_display_mode * mode,struct drm_display_mode * adjusted_mode)244 static void rockchip_tve_encoder_mode_set(struct drm_encoder *encoder,
245 struct drm_display_mode *mode,
246 struct drm_display_mode *adjusted_mode)
247 {
248 struct rockchip_tve *tve = encoder_to_tve(encoder);
249
250 dev_dbg(tve->dev, "encoder mode set:%s\n", adjusted_mode->name);
251
252 if (adjusted_mode->vdisplay == 576)
253 tve->tv_format = TVOUT_CVBS_PAL;
254 else
255 tve->tv_format = TVOUT_CVBS_NTSC;
256
257 if (tve->enable) {
258 dac_enable(tve, false);
259 msleep(200);
260
261 tve_set_mode(tve);
262 dac_enable(tve, true);
263 }
264 }
265
266 static bool
rockchip_tve_encoder_mode_fixup(struct drm_encoder * encoder,const struct drm_display_mode * mode,struct drm_display_mode * adjusted_mode)267 rockchip_tve_encoder_mode_fixup(struct drm_encoder *encoder,
268 const struct drm_display_mode *mode,
269 struct drm_display_mode *adjusted_mode)
270 {
271 return true;
272 }
273
274 static int
rockchip_tve_encoder_atomic_check(struct drm_encoder * encoder,struct drm_crtc_state * crtc_state,struct drm_connector_state * conn_state)275 rockchip_tve_encoder_atomic_check(struct drm_encoder *encoder,
276 struct drm_crtc_state *crtc_state,
277 struct drm_connector_state *conn_state)
278 {
279 struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc_state);
280 struct drm_connector *connector = conn_state->connector;
281 struct drm_display_info *info = &connector->display_info;
282
283 s->output_mode = ROCKCHIP_OUT_MODE_P888;
284 s->output_type = DRM_MODE_CONNECTOR_TV;
285 if (info->num_bus_formats)
286 s->bus_format = info->bus_formats[0];
287 else
288 s->bus_format = MEDIA_BUS_FMT_YUV8_1X24;
289
290 s->color_space = V4L2_COLORSPACE_SMPTE170M;
291 s->tv_state = &conn_state->tv;
292
293 return 0;
294 }
295
296 static const struct drm_connector_helper_funcs
297 rockchip_tve_connector_helper_funcs = {
298 .mode_valid = rockchip_tve_mode_valid,
299 .get_modes = rockchip_tve_get_modes,
300 .best_encoder = rockchip_tve_best_encoder,
301 };
302
303 static const struct drm_encoder_funcs rockchip_tve_encoder_funcs = {
304 .destroy = rockchip_encoder_destroy,
305 };
306
307 static const struct drm_connector_funcs rockchip_tve_connector_funcs = {
308 .detect = rockchip_tve_connector_detect,
309 .fill_modes = drm_helper_probe_single_connector_modes,
310 .destroy = rockchip_tve_connector_destroy,
311 .reset = drm_atomic_helper_connector_reset,
312 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
313 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
314 };
315
316 static const struct drm_encoder_helper_funcs
317 rockchip_tve_encoder_helper_funcs = {
318 .mode_fixup = rockchip_tve_encoder_mode_fixup,
319 .mode_set = rockchip_tve_encoder_mode_set,
320 .enable = rockchip_tve_encoder_enable,
321 .disable = rockchip_tve_encoder_disable,
322 .atomic_check = rockchip_tve_encoder_atomic_check,
323 };
324
tve_parse_dt(struct device_node * np,struct rockchip_tve * tve)325 static int tve_parse_dt(struct device_node *np,
326 struct rockchip_tve *tve)
327 {
328 int ret, val;
329 u32 getdac = 0;
330 size_t len;
331 struct nvmem_cell *cell;
332 unsigned char *efuse_buf;
333
334 ret = of_property_read_u32(np, "rockchip,tvemode", &val);
335 if (ret < 0) {
336 tve->preferred_mode = 0;
337 } else if (val > 1) {
338 dev_err(tve->dev, "tve mode value invalid\n");
339 return -EINVAL;
340 }
341 tve->preferred_mode = val;
342
343 ret = of_property_read_u32(np, "rockchip,saturation", &val);
344 if (val == 0 || ret < 0)
345 return -EINVAL;
346 tve->saturation = val;
347
348 ret = of_property_read_u32(np, "rockchip,brightcontrast", &val);
349 if (val == 0 || ret < 0)
350 return -EINVAL;
351 tve->brightcontrast = val;
352
353 ret = of_property_read_u32(np, "rockchip,adjtiming", &val);
354 if (val == 0 || ret < 0)
355 return -EINVAL;
356 tve->adjtiming = val;
357
358 ret = of_property_read_u32(np, "rockchip,lumafilter0", &val);
359 if (val == 0 || ret < 0)
360 return -EINVAL;
361 tve->lumafilter0 = val;
362
363 ret = of_property_read_u32(np, "rockchip,lumafilter1", &val);
364 if (val == 0 || ret < 0)
365 return -EINVAL;
366 tve->lumafilter1 = val;
367
368 ret = of_property_read_u32(np, "rockchip,lumafilter2", &val);
369 if (val == 0 || ret < 0)
370 return -EINVAL;
371 tve->lumafilter2 = val;
372
373 ret = of_property_read_u32(np, "rockchip,daclevel", &val);
374 if (val == 0 || ret < 0) {
375 return -EINVAL;
376 } else {
377 tve->daclevel = val;
378 cell = nvmem_cell_get(tve->dev, "tve_dac_adj");
379 if (IS_ERR(cell)) {
380 dev_dbg(tve->dev,
381 "failed to get id cell: %ld\n", PTR_ERR(cell));
382 } else {
383 efuse_buf = nvmem_cell_read(cell, &len);
384 nvmem_cell_put(cell);
385 if (len == 1)
386 getdac = efuse_buf[0];
387 kfree(efuse_buf);
388
389 if (getdac > 0) {
390 tve->daclevel =
391 getdac + 5 + val - RK322X_VDAC_STANDARD;
392 if (tve->daclevel > 0x3f) {
393 dev_err(tve->dev,
394 "rk322x daclevel error!\n");
395 tve->daclevel = val;
396 }
397 }
398 }
399 }
400
401 ret = of_property_read_u32(np, "rockchip,dac1level", &val);
402 if ((val == 0) || (ret < 0))
403 return -EINVAL;
404 tve->dac1level = val;
405
406 return 0;
407 }
408
check_uboot_logo(struct rockchip_tve * tve)409 static void check_uboot_logo(struct rockchip_tve *tve)
410 {
411 int lumafilter0, lumafilter1, lumafilter2, vdac;
412
413 vdac = tve_dac_readl(VDAC_VDAC1);
414 /* Whether the dac power has been turned down. */
415 if (vdac & m_DR_PWR_DOWN) {
416 tve->connector.dpms = DRM_MODE_DPMS_OFF;
417 return;
418 }
419
420 lumafilter0 = tve_readl(TV_LUMA_FILTER0);
421 lumafilter1 = tve_readl(TV_LUMA_FILTER1);
422 lumafilter2 = tve_readl(TV_LUMA_FILTER2);
423
424 /*
425 * The default lumafilter value is 0. If lumafilter value
426 * is equal to the dts value, uboot logo is enabled.
427 */
428 if (lumafilter0 == tve->lumafilter0 &&
429 lumafilter1 == tve->lumafilter1 &&
430 lumafilter2 == tve->lumafilter2) {
431 tve->connector.dpms = DRM_MODE_DPMS_ON;
432 return;
433 }
434
435 dac_init(tve);
436 tve->connector.dpms = DRM_MODE_DPMS_OFF;
437 }
438
439 static const struct of_device_id rockchip_tve_dt_ids[] = {
440 {
441 .compatible = "rockchip,rk3328-tve",
442 },
443 {}
444 };
445
446 MODULE_DEVICE_TABLE(of, rockchip_tve_dt_ids);
447
rockchip_tve_bind(struct device * dev,struct device * master,void * data)448 static int rockchip_tve_bind(struct device *dev, struct device *master,
449 void *data)
450 {
451 struct platform_device *pdev = to_platform_device(dev);
452 struct drm_device *drm_dev = data;
453 struct device_node *np = dev->of_node;
454 const struct of_device_id *match;
455 struct rockchip_tve *tve;
456 struct resource *res;
457 struct drm_encoder *encoder;
458 struct drm_connector *connector;
459 int ret;
460
461 tve = devm_kzalloc(dev, sizeof(*tve), GFP_KERNEL);
462 if (!tve)
463 return -ENOMEM;
464
465 match = of_match_node(rockchip_tve_dt_ids, np);
466 if (!match) {
467 dev_err(tve->dev, "tve can't match node\n");
468 return -EINVAL;
469 }
470
471 tve->dev = &pdev->dev;
472 if (!strcmp(match->compatible, "rockchip,rk3328-tve")) {
473 tve->inputformat = INPUT_FORMAT_YUV;
474 } else {
475 dev_err(tve->dev, "It is not a valid tv encoder! ");
476 return -ENOMEM;
477 }
478
479 ret = tve_parse_dt(np, tve);
480 if (ret) {
481 dev_err(tve->dev, "TVE parse dts error!");
482 return -EINVAL;
483 }
484
485 tve->enable = 0;
486 platform_set_drvdata(pdev, tve);
487 tve->drm_dev = drm_dev;
488 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
489 tve->reg_phy_base = res->start;
490 tve->len = resource_size(res);
491 tve->regbase = devm_ioremap(tve->dev, res->start, tve->len);
492 if (IS_ERR(tve->regbase)) {
493 dev_err(tve->dev,
494 "rk3328 tv encoder device map registers failed!");
495 return PTR_ERR(tve->regbase);
496 }
497
498 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
499 tve->len = resource_size(res);
500 tve->vdacbase = devm_ioremap(tve->dev, res->start, tve->len);
501 if (IS_ERR(tve->vdacbase)) {
502 dev_err(tve->dev,
503 "rk3328 tv encoder device dac map registers failed!");
504 return PTR_ERR(tve->vdacbase);
505 }
506
507 mutex_init(&tve->suspend_lock);
508 check_uboot_logo(tve);
509 tve->tv_format = TVOUT_CVBS_PAL;
510 encoder = &tve->encoder;
511 encoder->possible_crtcs = rockchip_drm_of_find_possible_crtcs(drm_dev,
512 dev->of_node);
513 dev_dbg(tve->dev, "possible_crtc:%d\n", encoder->possible_crtcs);
514
515 ret = drm_encoder_init(drm_dev, encoder, &rockchip_tve_encoder_funcs,
516 DRM_MODE_ENCODER_TVDAC, NULL);
517 if (ret < 0) {
518 dev_err(tve->dev, "failed to initialize encoder with drm\n");
519 return ret;
520 }
521
522 drm_encoder_helper_add(encoder, &rockchip_tve_encoder_helper_funcs);
523
524 connector = &tve->connector;
525 connector->interlace_allowed = 1;
526 ret = drm_connector_init(drm_dev, connector,
527 &rockchip_tve_connector_funcs,
528 DRM_MODE_CONNECTOR_TV);
529 if (ret < 0) {
530 dev_dbg(tve->dev, "failed to initialize connector with drm\n");
531 goto err_free_encoder;
532 }
533
534 drm_connector_helper_add(connector,
535 &rockchip_tve_connector_helper_funcs);
536
537 ret = drm_connector_attach_encoder(connector, encoder);
538 if (ret < 0) {
539 dev_dbg(tve->dev, "failed to attach connector and encoder\n");
540 goto err_free_connector;
541 }
542 tve->sub_dev.connector = &tve->connector;
543 tve->sub_dev.of_node = tve->dev->of_node;
544 rockchip_drm_register_sub_dev(&tve->sub_dev);
545
546 pm_runtime_enable(dev);
547 dev_dbg(tve->dev, "%s tv encoder probe ok\n", match->compatible);
548
549 return 0;
550
551 err_free_connector:
552 drm_connector_cleanup(connector);
553 err_free_encoder:
554 drm_encoder_cleanup(encoder);
555 return ret;
556 }
557
rockchip_tve_unbind(struct device * dev,struct device * master,void * data)558 static void rockchip_tve_unbind(struct device *dev, struct device *master,
559 void *data)
560 {
561 struct rockchip_tve *tve = dev_get_drvdata(dev);
562
563 rockchip_drm_unregister_sub_dev(&tve->sub_dev);
564 rockchip_tve_encoder_disable(&tve->encoder);
565
566 drm_connector_cleanup(&tve->connector);
567 drm_encoder_cleanup(&tve->encoder);
568
569 pm_runtime_disable(dev);
570 }
571
572 static const struct component_ops rockchip_tve_component_ops = {
573 .bind = rockchip_tve_bind,
574 .unbind = rockchip_tve_unbind,
575 };
576
rockchip_tve_probe(struct platform_device * pdev)577 static int rockchip_tve_probe(struct platform_device *pdev)
578 {
579 component_add(&pdev->dev, &rockchip_tve_component_ops);
580
581 return 0;
582 }
583
rockchip_tve_shutdown(struct platform_device * pdev)584 static void rockchip_tve_shutdown(struct platform_device *pdev)
585 {
586 struct rockchip_tve *tve = dev_get_drvdata(&pdev->dev);
587
588 mutex_lock(&tve->suspend_lock);
589
590 dev_dbg(tve->dev, "tve shutdown\n");
591 cvbs_set_disable(tve);
592
593 mutex_unlock(&tve->suspend_lock);
594 }
595
rockchip_tve_remove(struct platform_device * pdev)596 static int rockchip_tve_remove(struct platform_device *pdev)
597 {
598 component_del(&pdev->dev, &rockchip_tve_component_ops);
599
600 return 0;
601 }
602
603 struct platform_driver rockchip_tve_driver = {
604 .probe = rockchip_tve_probe,
605 .remove = rockchip_tve_remove,
606 .shutdown = rockchip_tve_shutdown,
607 .driver = {
608 .name = "rockchip-tve",
609 .of_match_table = of_match_ptr(rockchip_tve_dt_ids),
610 },
611 };
612
613 MODULE_AUTHOR("Algea Cao <Algea.cao@rock-chips.com>");
614 MODULE_DESCRIPTION("ROCKCHIP TVE Driver");
615 MODULE_LICENSE("GPL v2");
616