Merge tag 'drm-intel-fixes-2016-03-11' of git://anongit.freedesktop.org/drm-intel...
[deliverable/linux.git] / drivers / gpu / drm / msm / hdmi / hdmi_phy_8x74.c
1 /*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "hdmi.h"
19
20 struct hdmi_phy_8x74 {
21 struct hdmi_phy base;
22 void __iomem *mmio;
23 };
24 #define to_hdmi_phy_8x74(x) container_of(x, struct hdmi_phy_8x74, base)
25
26
27 static void phy_write(struct hdmi_phy_8x74 *phy, u32 reg, u32 data)
28 {
29 msm_writel(data, phy->mmio + reg);
30 }
31
32 //static u32 phy_read(struct hdmi_phy_8x74 *phy, u32 reg)
33 //{
34 // return msm_readl(phy->mmio + reg);
35 //}
36
37 static void hdmi_phy_8x74_destroy(struct hdmi_phy *phy)
38 {
39 struct hdmi_phy_8x74 *phy_8x74 = to_hdmi_phy_8x74(phy);
40 kfree(phy_8x74);
41 }
42
43 static void hdmi_phy_8x74_powerup(struct hdmi_phy *phy,
44 unsigned long int pixclock)
45 {
46 struct hdmi_phy_8x74 *phy_8x74 = to_hdmi_phy_8x74(phy);
47
48 phy_write(phy_8x74, REG_HDMI_8x74_ANA_CFG0, 0x1b);
49 phy_write(phy_8x74, REG_HDMI_8x74_ANA_CFG1, 0xf2);
50 phy_write(phy_8x74, REG_HDMI_8x74_BIST_CFG0, 0x0);
51 phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN0, 0x0);
52 phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN1, 0x0);
53 phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN2, 0x0);
54 phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN3, 0x0);
55 phy_write(phy_8x74, REG_HDMI_8x74_PD_CTRL1, 0x20);
56 }
57
58 static void hdmi_phy_8x74_powerdown(struct hdmi_phy *phy)
59 {
60 struct hdmi_phy_8x74 *phy_8x74 = to_hdmi_phy_8x74(phy);
61 phy_write(phy_8x74, REG_HDMI_8x74_PD_CTRL0, 0x7f);
62 }
63
64 static const struct hdmi_phy_funcs hdmi_phy_8x74_funcs = {
65 .destroy = hdmi_phy_8x74_destroy,
66 .powerup = hdmi_phy_8x74_powerup,
67 .powerdown = hdmi_phy_8x74_powerdown,
68 };
69
70 struct hdmi_phy *hdmi_phy_8x74_init(struct hdmi *hdmi)
71 {
72 struct hdmi_phy_8x74 *phy_8x74;
73 struct hdmi_phy *phy = NULL;
74 int ret;
75
76 phy_8x74 = kzalloc(sizeof(*phy_8x74), GFP_KERNEL);
77 if (!phy_8x74) {
78 ret = -ENOMEM;
79 goto fail;
80 }
81
82 phy = &phy_8x74->base;
83
84 phy->funcs = &hdmi_phy_8x74_funcs;
85
86 /* for 8x74, the phy mmio is mapped separately: */
87 phy_8x74->mmio = msm_ioremap(hdmi->pdev,
88 "phy_physical", "HDMI_8x74");
89 if (IS_ERR(phy_8x74->mmio)) {
90 ret = PTR_ERR(phy_8x74->mmio);
91 goto fail;
92 }
93
94 return phy;
95
96 fail:
97 if (phy)
98 hdmi_phy_8x74_destroy(phy);
99 return ERR_PTR(ret);
100 }
This page took 0.034997 seconds and 5 git commands to generate.