Lines Matching refs:tve
106 struct imx_tve *tve; member
126 return container_of(c, struct imx_tve_encoder, connector)->tve; in con_to_tve()
131 return container_of(e, struct imx_tve_encoder, encoder)->tve; in enc_to_tve()
134 static void tve_enable(struct imx_tve *tve) in tve_enable() argument
136 clk_prepare_enable(tve->clk); in tve_enable()
137 regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, TVE_EN); in tve_enable()
140 regmap_write(tve->regmap, TVE_STAT_REG, 0xffffffff); in tve_enable()
143 if (tve->mode == TVE_MODE_VGA) in tve_enable()
144 regmap_write(tve->regmap, TVE_INT_CONT_REG, 0); in tve_enable()
146 regmap_write(tve->regmap, TVE_INT_CONT_REG, in tve_enable()
152 static void tve_disable(struct imx_tve *tve) in tve_disable() argument
154 regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, 0); in tve_disable()
155 clk_disable_unprepare(tve->clk); in tve_disable()
158 static int tve_setup_tvout(struct imx_tve *tve) in tve_setup_tvout() argument
163 static int tve_setup_vga(struct imx_tve *tve) in tve_setup_vga() argument
170 ret = regmap_update_bits(tve->regmap, TVE_TVDAC0_CONT_REG, in tve_setup_vga()
175 ret = regmap_update_bits(tve->regmap, TVE_TVDAC1_CONT_REG, in tve_setup_vga()
180 ret = regmap_update_bits(tve->regmap, TVE_TVDAC2_CONT_REG, in tve_setup_vga()
192 ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, mask, val); in tve_setup_vga()
197 return regmap_update_bits(tve->regmap, TVE_TST_MODE_REG, in tve_setup_vga()
203 struct imx_tve *tve = con_to_tve(connector); in imx_tve_connector_get_modes() local
207 if (!tve->ddc) in imx_tve_connector_get_modes()
210 drm_edid = drm_edid_read_ddc(connector, tve->ddc); in imx_tve_connector_get_modes()
222 struct imx_tve *tve = con_to_tve(connector); in imx_tve_connector_mode_valid() local
226 rate = clk_round_rate(tve->clk, 2000UL * mode->clock) / 2000; in imx_tve_connector_mode_valid()
231 rate = clk_round_rate(tve->clk, 1000UL * mode->clock) / 1000; in imx_tve_connector_mode_valid()
235 dev_warn(tve->dev, "ignoring mode %dx%d\n", in imx_tve_connector_mode_valid()
245 struct imx_tve *tve = enc_to_tve(encoder); in imx_tve_encoder_mode_set() local
257 clk_set_rate(tve->clk, rate); in imx_tve_encoder_mode_set()
258 rounded_rate = clk_get_rate(tve->clk); in imx_tve_encoder_mode_set()
261 clk_set_rate(tve->di_clk, rounded_rate / div); in imx_tve_encoder_mode_set()
263 ret = clk_set_parent(tve->di_sel_clk, tve->di_clk); in imx_tve_encoder_mode_set()
265 dev_err(tve->dev, "failed to set di_sel parent to tve_di: %d\n", in imx_tve_encoder_mode_set()
269 regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, in imx_tve_encoder_mode_set()
272 if (tve->mode == TVE_MODE_VGA) in imx_tve_encoder_mode_set()
273 ret = tve_setup_vga(tve); in imx_tve_encoder_mode_set()
275 ret = tve_setup_tvout(tve); in imx_tve_encoder_mode_set()
277 dev_err(tve->dev, "failed to set configuration: %d\n", ret); in imx_tve_encoder_mode_set()
282 struct imx_tve *tve = enc_to_tve(encoder); in imx_tve_encoder_enable() local
284 tve_enable(tve); in imx_tve_encoder_enable()
289 struct imx_tve *tve = enc_to_tve(encoder); in imx_tve_encoder_disable() local
291 tve_disable(tve); in imx_tve_encoder_disable()
299 struct imx_tve *tve = enc_to_tve(encoder); in imx_tve_atomic_check() local
302 imx_crtc_state->di_hsync_pin = tve->di_hsync_pin; in imx_tve_atomic_check()
303 imx_crtc_state->di_vsync_pin = tve->di_vsync_pin; in imx_tve_atomic_check()
330 struct imx_tve *tve = data; in imx_tve_irq_handler() local
333 regmap_read(tve->regmap, TVE_STAT_REG, &val); in imx_tve_irq_handler()
336 regmap_write(tve->regmap, TVE_STAT_REG, 0xffffffff); in imx_tve_irq_handler()
344 struct imx_tve *tve = container_of(hw, struct imx_tve, clk_hw_di); in clk_tve_di_recalc_rate() local
348 ret = regmap_read(tve->regmap, TVE_COM_CONF_REG, &val); in clk_tve_di_recalc_rate()
381 struct imx_tve *tve = container_of(hw, struct imx_tve, clk_hw_di); in clk_tve_di_set_rate() local
394 ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, in clk_tve_di_set_rate()
398 dev_err(tve->dev, "failed to set divider: %d\n", ret); in clk_tve_di_set_rate()
411 static int tve_clk_init(struct imx_tve *tve, void __iomem *base) in tve_clk_init() argument
421 tve_di_parent[0] = __clk_get_name(tve->clk); in tve_clk_init()
424 tve->clk_hw_di.init = &init; in tve_clk_init()
425 tve->di_clk = devm_clk_register(tve->dev, &tve->clk_hw_di); in tve_clk_init()
426 if (IS_ERR(tve->di_clk)) { in tve_clk_init()
427 dev_err(tve->dev, "failed to register TVE output clock: %ld\n", in tve_clk_init()
428 PTR_ERR(tve->di_clk)); in tve_clk_init()
429 return PTR_ERR(tve->di_clk); in tve_clk_init()
437 struct imx_tve *tve = data; in imx_tve_disable_regulator() local
439 regulator_disable(tve->dac_reg); in imx_tve_disable_regulator()
483 struct imx_tve *tve = dev_get_drvdata(dev); in imx_tve_bind() local
490 encoder_type = tve->mode == TVE_MODE_VGA ? in imx_tve_bind()
498 tvee->tve = tve; in imx_tve_bind()
502 ret = imx_drm_encoder_parse_of(drm, encoder, tve->dev->of_node); in imx_tve_bind()
511 DRM_MODE_CONNECTOR_VGA, tve->ddc); in imx_tve_bind()
527 struct imx_tve *tve; in imx_tve_probe() local
533 tve = devm_kzalloc(dev, sizeof(*tve), GFP_KERNEL); in imx_tve_probe()
534 if (!tve) in imx_tve_probe()
537 tve->dev = dev; in imx_tve_probe()
541 tve->ddc = of_find_i2c_adapter_by_node(ddc_node); in imx_tve_probe()
545 tve->mode = of_get_tve_mode(np); in imx_tve_probe()
546 if (tve->mode != TVE_MODE_VGA) { in imx_tve_probe()
551 if (tve->mode == TVE_MODE_VGA) { in imx_tve_probe()
553 &tve->di_hsync_pin); in imx_tve_probe()
561 &tve->di_vsync_pin); in imx_tve_probe()
573 tve_regmap_config.lock_arg = tve; in imx_tve_probe()
574 tve->regmap = devm_regmap_init_mmio_clk(dev, "tve", base, in imx_tve_probe()
576 if (IS_ERR(tve->regmap)) { in imx_tve_probe()
578 PTR_ERR(tve->regmap)); in imx_tve_probe()
579 return PTR_ERR(tve->regmap); in imx_tve_probe()
588 "imx-tve", tve); in imx_tve_probe()
594 tve->dac_reg = devm_regulator_get(dev, "dac"); in imx_tve_probe()
595 if (!IS_ERR(tve->dac_reg)) { in imx_tve_probe()
596 if (regulator_get_voltage(tve->dac_reg) != IMX_TVE_DAC_VOLTAGE) in imx_tve_probe()
598 ret = regulator_enable(tve->dac_reg); in imx_tve_probe()
601 ret = devm_add_action_or_reset(dev, imx_tve_disable_regulator, tve); in imx_tve_probe()
606 tve->clk = devm_clk_get(dev, "tve"); in imx_tve_probe()
607 if (IS_ERR(tve->clk)) { in imx_tve_probe()
609 PTR_ERR(tve->clk)); in imx_tve_probe()
610 return PTR_ERR(tve->clk); in imx_tve_probe()
614 tve->di_sel_clk = devm_clk_get(dev, "di_sel"); in imx_tve_probe()
615 if (IS_ERR(tve->di_sel_clk)) { in imx_tve_probe()
617 PTR_ERR(tve->di_sel_clk)); in imx_tve_probe()
618 return PTR_ERR(tve->di_sel_clk); in imx_tve_probe()
621 ret = tve_clk_init(tve, base); in imx_tve_probe()
625 ret = regmap_read(tve->regmap, TVE_COM_CONF_REG, &val); in imx_tve_probe()
637 ret = regmap_write(tve->regmap, TVE_CD_CONT_REG, 0); in imx_tve_probe()
641 platform_set_drvdata(pdev, tve); in imx_tve_probe()