blob: 55233f19eeb423e6158f8f94159cf3a6df29c0f3 [file] [log] [blame]
Jagan Tekif2c2a692024-01-17 13:21:50 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (c) 2023 Edgeble AI Technologies Pvt. Ltd.
4 */
5
6#include <dm.h>
7#include <video.h>
8#include <asm/io.h>
9#include "rk_vop.h"
10
11DECLARE_GLOBAL_DATA_PTR;
12
13static void rk3328_set_pin_polarity(struct udevice *dev,
14 enum vop_modes mode, u32 polarity)
15{
16 struct rk_vop_priv *priv = dev_get_priv(dev);
17 struct rk3288_vop *regs = priv->regs;
18
19 switch (mode) {
20 case VOP_MODE_HDMI:
21 clrsetbits_le32(&regs->dsp_ctrl1,
22 M_RK3399_DSP_HDMI_POL,
23 V_RK3399_DSP_HDMI_POL(polarity));
24 break;
25 default:
26 debug("%s: unsupported output mode %x\n", __func__, mode);
27 }
28}
29
30static int rk3328_vop_probe(struct udevice *dev)
31{
32 /* Before relocation we don't need to do anything */
33 if (!(gd->flags & GD_FLG_RELOC))
34 return 0;
35
36 return rk_vop_probe(dev);
37}
38
39static int rk3328_vop_remove(struct udevice *dev)
40{
41 struct rk_vop_priv *priv = dev_get_priv(dev);
42 struct rk3288_vop *regs = priv->regs;
43 struct rk3288_vop *win_regs = priv->regs + priv->win_offset;
44
45 /* FIXME: Explicit disabling of WIN0 is needed to avoid iommu
46 * page-fault in Linux, better handling of iommu-address in
47 * Linux might drop this.
48 */
49 clrbits_le32(&win_regs->win0_ctrl0, M_WIN0_EN);
50 writel(0x01, &regs->reg_cfg_done);
51
52 return 0;
53}
54
55struct rkvop_driverdata rk3328_driverdata = {
56 .dsp_offset = 0x490,
57 .win_offset = 0xd0,
58 .features = VOP_FEATURE_OUTPUT_10BIT,
59 .set_pin_polarity = rk3328_set_pin_polarity,
60};
61
62static const struct udevice_id rk3328_vop_ids[] = {
63 {
64 .compatible = "rockchip,rk3328-vop",
65 .data = (ulong)&rk3328_driverdata
66 },
67 { /* sentile */ }
68};
69
70static const struct video_ops rk3328_vop_ops = {
71};
72
73U_BOOT_DRIVER(rk3328_vop) = {
74 .name = "rk3328_vop",
75 .id = UCLASS_VIDEO,
76 .of_match = rk3328_vop_ids,
77 .ops = &rk3328_vop_ops,
78 .bind = rk_vop_bind,
79 .probe = rk3328_vop_probe,
80 .remove = rk3328_vop_remove,
81 .priv_auto = sizeof(struct rk_vop_priv),
82 .flags = DM_FLAG_PRE_RELOC | DM_FLAG_OS_PREPARE,
83};