Lines Matching +full:hdmi +full:- +full:out

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Maxime Ripard <maxime.ripard@free-electrons.com>
9 #include <linux/clk-provider.h>
16 struct sun4i_hdmi *hdmi; member
49 (rate - tmp_rate) < (rate - best_rate)) { in sun4i_tmds_calc_divider()
72 unsigned long rate = req->rate; in sun4i_tmds_determine_rate()
78 * clocked from it, and to have the same rate than our HDMI in sun4i_tmds_determine_rate()
88 for (j = tmds->div_offset ?: 1; in sun4i_tmds_determine_rate()
89 j < (16 + tmds->div_offset); j++) { in sun4i_tmds_determine_rate()
99 goto out; in sun4i_tmds_determine_rate()
103 abs(rate - rounded / i / j) < in sun4i_tmds_determine_rate()
104 abs(rate - best_parent / best_half / in sun4i_tmds_determine_rate()
115 return -EINVAL; in sun4i_tmds_determine_rate()
117 out: in sun4i_tmds_determine_rate()
118 req->rate = best_parent / best_half / best_div; in sun4i_tmds_determine_rate()
119 req->best_parent_rate = best_parent; in sun4i_tmds_determine_rate()
120 req->best_parent_hw = parent; in sun4i_tmds_determine_rate()
131 reg = readl(tmds->hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG); in sun4i_tmds_recalc_rate()
135 reg = readl(tmds->hdmi->base + SUN4I_HDMI_PLL_CTRL_REG); in sun4i_tmds_recalc_rate()
136 reg = ((reg >> 4) & 0xf) + tmds->div_offset; in sun4i_tmds_recalc_rate()
151 sun4i_tmds_calc_divider(rate, parent_rate, tmds->div_offset, in sun4i_tmds_set_rate()
154 reg = readl(tmds->hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG); in sun4i_tmds_set_rate()
158 writel(reg, tmds->hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG); in sun4i_tmds_set_rate()
160 reg = readl(tmds->hdmi->base + SUN4I_HDMI_PLL_CTRL_REG); in sun4i_tmds_set_rate()
162 writel(reg | SUN4I_HDMI_PLL_CTRL_DIV(div - tmds->div_offset), in sun4i_tmds_set_rate()
163 tmds->hdmi->base + SUN4I_HDMI_PLL_CTRL_REG); in sun4i_tmds_set_rate()
173 reg = readl(tmds->hdmi->base + SUN4I_HDMI_PLL_DBG0_REG); in sun4i_tmds_get_parent()
184 return -EINVAL; in sun4i_tmds_set_parent()
186 reg = readl(tmds->hdmi->base + SUN4I_HDMI_PLL_DBG0_REG); in sun4i_tmds_set_parent()
189 tmds->hdmi->base + SUN4I_HDMI_PLL_DBG0_REG); in sun4i_tmds_set_parent()
203 int sun4i_tmds_create(struct sun4i_hdmi *hdmi) in sun4i_tmds_create() argument
209 parents[0] = __clk_get_name(hdmi->pll0_clk); in sun4i_tmds_create()
211 return -ENODEV; in sun4i_tmds_create()
213 parents[1] = __clk_get_name(hdmi->pll1_clk); in sun4i_tmds_create()
215 return -ENODEV; in sun4i_tmds_create()
217 tmds = devm_kzalloc(hdmi->dev, sizeof(*tmds), GFP_KERNEL); in sun4i_tmds_create()
219 return -ENOMEM; in sun4i_tmds_create()
221 init.name = "hdmi-tmds"; in sun4i_tmds_create()
227 tmds->hdmi = hdmi; in sun4i_tmds_create()
228 tmds->hw.init = &init; in sun4i_tmds_create()
229 tmds->div_offset = hdmi->variant->tmds_clk_div_offset; in sun4i_tmds_create()
231 hdmi->tmds_clk = devm_clk_register(hdmi->dev, &tmds->hw); in sun4i_tmds_create()
232 if (IS_ERR(hdmi->tmds_clk)) in sun4i_tmds_create()
233 return PTR_ERR(hdmi->tmds_clk); in sun4i_tmds_create()