2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
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.
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
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/>.
20 struct hdmi_phy_8960
{
24 #define to_hdmi_phy_8960(x) container_of(x, struct hdmi_phy_8960, base)
26 static void hdmi_phy_8960_destroy(struct hdmi_phy
*phy
)
28 struct hdmi_phy_8960
*phy_8960
= to_hdmi_phy_8960(phy
);
32 static void hdmi_phy_8960_reset(struct hdmi_phy
*phy
)
34 struct hdmi_phy_8960
*phy_8960
= to_hdmi_phy_8960(phy
);
35 struct hdmi
*hdmi
= phy_8960
->hdmi
;
38 val
= hdmi_read(hdmi
, REG_HDMI_PHY_CTRL
);
40 if (val
& HDMI_PHY_CTRL_SW_RESET_LOW
) {
42 hdmi_write(hdmi
, REG_HDMI_PHY_CTRL
,
43 val
& ~HDMI_PHY_CTRL_SW_RESET
);
46 hdmi_write(hdmi
, REG_HDMI_PHY_CTRL
,
47 val
| HDMI_PHY_CTRL_SW_RESET
);
50 if (val
& HDMI_PHY_CTRL_SW_RESET_PLL_LOW
) {
52 hdmi_write(hdmi
, REG_HDMI_PHY_CTRL
,
53 val
& ~HDMI_PHY_CTRL_SW_RESET_PLL
);
56 hdmi_write(hdmi
, REG_HDMI_PHY_CTRL
,
57 val
| HDMI_PHY_CTRL_SW_RESET_PLL
);
62 if (val
& HDMI_PHY_CTRL_SW_RESET_LOW
) {
64 hdmi_write(hdmi
, REG_HDMI_PHY_CTRL
,
65 val
| HDMI_PHY_CTRL_SW_RESET
);
68 hdmi_write(hdmi
, REG_HDMI_PHY_CTRL
,
69 val
& ~HDMI_PHY_CTRL_SW_RESET
);
72 if (val
& HDMI_PHY_CTRL_SW_RESET_PLL_LOW
) {
74 hdmi_write(hdmi
, REG_HDMI_PHY_CTRL
,
75 val
| HDMI_PHY_CTRL_SW_RESET_PLL
);
78 hdmi_write(hdmi
, REG_HDMI_PHY_CTRL
,
79 val
& ~HDMI_PHY_CTRL_SW_RESET_PLL
);
83 static void hdmi_phy_8960_powerup(struct hdmi_phy
*phy
,
84 unsigned long int pixclock
)
86 struct hdmi_phy_8960
*phy_8960
= to_hdmi_phy_8960(phy
);
87 struct hdmi
*hdmi
= phy_8960
->hdmi
;
89 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG0
, 0x1b);
90 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG1
, 0xf2);
91 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG4
, 0x00);
92 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG5
, 0x00);
93 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG6
, 0x00);
94 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG7
, 0x00);
95 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG8
, 0x00);
96 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG9
, 0x00);
97 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG10
, 0x00);
98 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG11
, 0x00);
99 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG3
, 0x20);
102 static void hdmi_phy_8960_powerdown(struct hdmi_phy
*phy
)
104 struct hdmi_phy_8960
*phy_8960
= to_hdmi_phy_8960(phy
);
105 struct hdmi
*hdmi
= phy_8960
->hdmi
;
107 hdmi_write(hdmi
, REG_HDMI_8960_PHY_REG2
, 0x7f);
110 static const struct hdmi_phy_funcs hdmi_phy_8960_funcs
= {
111 .destroy
= hdmi_phy_8960_destroy
,
112 .reset
= hdmi_phy_8960_reset
,
113 .powerup
= hdmi_phy_8960_powerup
,
114 .powerdown
= hdmi_phy_8960_powerdown
,
117 struct hdmi_phy
*hdmi_phy_8960_init(struct hdmi
*hdmi
)
119 struct hdmi_phy_8960
*phy_8960
;
120 struct hdmi_phy
*phy
= NULL
;
123 phy_8960
= kzalloc(sizeof(*phy_8960
), GFP_KERNEL
);
129 phy
= &phy_8960
->base
;
131 phy
->funcs
= &hdmi_phy_8960_funcs
;
133 phy_8960
->hdmi
= hdmi
;
139 hdmi_phy_8960_destroy(phy
);