Lines Matching refs:lt
50 static int lt8912_write_init_config(struct lt8912 *lt) in lt8912_write_init_config() argument
87 return regmap_multi_reg_write(lt->regmap[I2C_MAIN], seq, ARRAY_SIZE(seq)); in lt8912_write_init_config()
90 static int lt8912_write_mipi_basic_config(struct lt8912 *lt) in lt8912_write_mipi_basic_config() argument
100 return regmap_multi_reg_write(lt->regmap[I2C_CEC_DSI], seq, ARRAY_SIZE(seq)); in lt8912_write_mipi_basic_config()
103 static int lt8912_write_dds_config(struct lt8912 *lt) in lt8912_write_dds_config() argument
153 return regmap_multi_reg_write(lt->regmap[I2C_CEC_DSI], seq, ARRAY_SIZE(seq)); in lt8912_write_dds_config()
156 static int lt8912_write_rxlogicres_config(struct lt8912 *lt) in lt8912_write_rxlogicres_config() argument
160 ret = regmap_write(lt->regmap[I2C_MAIN], 0x03, 0x7f); in lt8912_write_rxlogicres_config()
162 ret |= regmap_write(lt->regmap[I2C_MAIN], 0x03, 0xff); in lt8912_write_rxlogicres_config()
168 static int lt8912_write_lvds_config(struct lt8912 *lt) in lt8912_write_lvds_config() argument
198 return regmap_multi_reg_write(lt->regmap[I2C_MAIN], seq, ARRAY_SIZE(seq)); in lt8912_write_lvds_config()
217 static int lt8912_init_i2c(struct lt8912 *lt, struct i2c_client *client) in lt8912_init_i2c() argument
229 if (!lt) in lt8912_init_i2c()
234 lt->i2c_client[i] = i2c_new_dummy_device(client->adapter, in lt8912_init_i2c()
236 if (IS_ERR(lt->i2c_client[i])) in lt8912_init_i2c()
237 return PTR_ERR(lt->i2c_client[i]); in lt8912_init_i2c()
240 lt->regmap[i] = devm_regmap_init_i2c(lt->i2c_client[i], in lt8912_init_i2c()
242 if (IS_ERR(lt->regmap[i])) in lt8912_init_i2c()
243 return PTR_ERR(lt->regmap[i]); in lt8912_init_i2c()
248 static int lt8912_free_i2c(struct lt8912 *lt) in lt8912_free_i2c() argument
253 i2c_unregister_device(lt->i2c_client[i]); in lt8912_free_i2c()
258 static int lt8912_hard_power_on(struct lt8912 *lt) in lt8912_hard_power_on() argument
260 gpiod_set_value_cansleep(lt->gp_reset, 0); in lt8912_hard_power_on()
266 static void lt8912_hard_power_off(struct lt8912 *lt) in lt8912_hard_power_off() argument
268 gpiod_set_value_cansleep(lt->gp_reset, 1); in lt8912_hard_power_off()
270 lt->is_power_on = false; in lt8912_hard_power_off()
273 static int lt8912_video_setup(struct lt8912 *lt) in lt8912_video_setup() argument
280 if (!lt) in lt8912_video_setup()
283 hactive = lt->mode.hactive; in lt8912_video_setup()
284 hfp = lt->mode.hfront_porch; in lt8912_video_setup()
285 hpw = lt->mode.hsync_len; in lt8912_video_setup()
286 hbp = lt->mode.hback_porch; in lt8912_video_setup()
288 hsync_activehigh = lt->mode.flags & DISPLAY_FLAGS_HSYNC_HIGH; in lt8912_video_setup()
290 vactive = lt->mode.vactive; in lt8912_video_setup()
291 vfp = lt->mode.vfront_porch; in lt8912_video_setup()
292 vpw = lt->mode.vsync_len; in lt8912_video_setup()
293 vbp = lt->mode.vback_porch; in lt8912_video_setup()
295 vsync_activehigh = lt->mode.flags & DISPLAY_FLAGS_VSYNC_HIGH; in lt8912_video_setup()
302 ret = regmap_write(lt->regmap[I2C_CEC_DSI], 0x10, 0x01); in lt8912_video_setup()
303 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x11, settle); in lt8912_video_setup()
304 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x18, hpw); in lt8912_video_setup()
305 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x19, vpw); in lt8912_video_setup()
306 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x1c, hactive & 0xff); in lt8912_video_setup()
307 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x1d, hactive >> 8); in lt8912_video_setup()
309 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x2f, 0x0c); in lt8912_video_setup()
311 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x34, h_total & 0xff); in lt8912_video_setup()
312 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x35, h_total >> 8); in lt8912_video_setup()
314 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x36, v_total & 0xff); in lt8912_video_setup()
315 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x37, v_total >> 8); in lt8912_video_setup()
317 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x38, vbp & 0xff); in lt8912_video_setup()
318 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x39, vbp >> 8); in lt8912_video_setup()
320 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3a, vfp & 0xff); in lt8912_video_setup()
321 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3b, vfp >> 8); in lt8912_video_setup()
323 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3c, hbp & 0xff); in lt8912_video_setup()
324 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3d, hbp >> 8); in lt8912_video_setup()
326 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3e, hfp & 0xff); in lt8912_video_setup()
327 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3f, hfp >> 8); in lt8912_video_setup()
329 ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(0), in lt8912_video_setup()
331 ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(1), in lt8912_video_setup()
333 ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xb2, BIT(0), in lt8912_video_setup()
334 lt->connector.display_info.is_hdmi ? BIT(0) : 0); in lt8912_video_setup()
339 static int lt8912_soft_power_on(struct lt8912 *lt) in lt8912_soft_power_on() argument
341 if (!lt->is_power_on) { in lt8912_soft_power_on()
342 u32 lanes = lt->data_lanes; in lt8912_soft_power_on()
344 lt8912_write_init_config(lt); in lt8912_soft_power_on()
345 regmap_write(lt->regmap[I2C_CEC_DSI], 0x13, lanes & 3); in lt8912_soft_power_on()
347 lt8912_write_mipi_basic_config(lt); in lt8912_soft_power_on()
349 lt->is_power_on = true; in lt8912_soft_power_on()
355 static int lt8912_video_on(struct lt8912 *lt) in lt8912_video_on() argument
359 ret = lt8912_video_setup(lt); in lt8912_video_on()
363 ret = lt8912_write_dds_config(lt); in lt8912_video_on()
367 ret = lt8912_write_rxlogicres_config(lt); in lt8912_video_on()
371 ret = lt8912_write_lvds_config(lt); in lt8912_video_on()
379 static enum drm_connector_status lt8912_check_cable_status(struct lt8912 *lt) in lt8912_check_cable_status() argument
384 ret = regmap_read(lt->regmap[I2C_MAIN], 0xC1, ®_val); in lt8912_check_cable_status()
397 struct lt8912 *lt = connector_to_lt8912(connector); in lt8912_connector_detect() local
399 if (lt->hdmi_port->ops & DRM_BRIDGE_OP_DETECT) in lt8912_connector_detect()
400 return drm_bridge_detect(lt->hdmi_port); in lt8912_connector_detect()
402 return lt8912_check_cable_status(lt); in lt8912_connector_detect()
435 struct lt8912 *lt = connector_to_lt8912(connector); in lt8912_connector_get_modes() local
438 edid = drm_bridge_get_edid(lt->hdmi_port, connector); in lt8912_connector_get_modes()
464 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_mode_set() local
466 drm_display_mode_to_videomode(adj, <->mode); in lt8912_bridge_mode_set()
471 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_enable() local
473 lt8912_video_on(lt); in lt8912_bridge_enable()
476 static int lt8912_attach_dsi(struct lt8912 *lt) in lt8912_attach_dsi() argument
478 struct device *dev = lt->dev; in lt8912_attach_dsi()
487 host = of_find_mipi_dsi_host_by_node(lt->host_node); in lt8912_attach_dsi()
500 lt->dsi = dsi; in lt8912_attach_dsi()
502 dsi->lanes = lt->data_lanes; in lt8912_attach_dsi()
520 struct lt8912 *lt = data; in lt8912_bridge_hpd_cb() local
522 if (lt->bridge.dev) in lt8912_bridge_hpd_cb()
523 drm_helper_hpd_irq_event(lt->bridge.dev); in lt8912_bridge_hpd_cb()
529 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_connector_init() local
530 struct drm_connector *connector = <->connector; in lt8912_bridge_connector_init()
532 if (lt->hdmi_port->ops & DRM_BRIDGE_OP_HPD) { in lt8912_bridge_connector_init()
533 drm_bridge_hpd_enable(lt->hdmi_port, lt8912_bridge_hpd_cb, lt); in lt8912_bridge_connector_init()
542 lt->hdmi_port->type); in lt8912_bridge_connector_init()
558 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_attach() local
561 ret = drm_bridge_attach(bridge->encoder, lt->hdmi_port, bridge, in lt8912_bridge_attach()
564 dev_err(lt->dev, "Failed to attach next bridge (%d)\n", ret); in lt8912_bridge_attach()
571 dev_err(lt->dev, "Failed to init bridge ! (%d)\n", ret); in lt8912_bridge_attach()
576 ret = lt8912_hard_power_on(lt); in lt8912_bridge_attach()
580 ret = lt8912_soft_power_on(lt); in lt8912_bridge_attach()
587 lt8912_hard_power_off(lt); in lt8912_bridge_attach()
593 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_detach() local
595 lt8912_hard_power_off(lt); in lt8912_bridge_detach()
597 if (lt->connector.dev && lt->hdmi_port->ops & DRM_BRIDGE_OP_HPD) in lt8912_bridge_detach()
598 drm_bridge_hpd_disable(lt->hdmi_port); in lt8912_bridge_detach()
604 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_detect() local
606 if (lt->hdmi_port->ops & DRM_BRIDGE_OP_DETECT) in lt8912_bridge_detect()
607 return drm_bridge_detect(lt->hdmi_port); in lt8912_bridge_detect()
609 return lt8912_check_cable_status(lt); in lt8912_bridge_detect()
615 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_get_edid() local
621 if (lt->hdmi_port->ops & DRM_BRIDGE_OP_EDID) in lt8912_bridge_get_edid()
622 return drm_bridge_get_edid(lt->hdmi_port, connector); in lt8912_bridge_get_edid()
624 dev_warn(lt->dev, "The connected bridge does not supports DRM_BRIDGE_OP_EDID\n"); in lt8912_bridge_get_edid()
637 static int lt8912_parse_dt(struct lt8912 *lt) in lt8912_parse_dt() argument
640 struct device *dev = lt->dev; in lt8912_parse_dt()
652 lt->gp_reset = gp_reset; in lt8912_parse_dt()
656 dev_err(lt->dev, "%s: Bad data-lanes property\n", __func__); in lt8912_parse_dt()
660 lt->data_lanes = data_lanes; in lt8912_parse_dt()
662 lt->host_node = of_graph_get_remote_node(dev->of_node, 0, -1); in lt8912_parse_dt()
663 if (!lt->host_node) { in lt8912_parse_dt()
664 dev_err(lt->dev, "%s: Failed to get remote port\n", __func__); in lt8912_parse_dt()
670 dev_err(lt->dev, "%s: Failed to get connector port\n", __func__); in lt8912_parse_dt()
675 lt->hdmi_port = of_drm_find_bridge(port_node); in lt8912_parse_dt()
676 if (!lt->hdmi_port) { in lt8912_parse_dt()
678 dev_err_probe(lt->dev, ret, "%s: Failed to get hdmi port\n", __func__); in lt8912_parse_dt()
683 dev_err(lt->dev, "%s: Failed to get hdmi port\n", __func__); in lt8912_parse_dt()
693 of_node_put(lt->host_node); in lt8912_parse_dt()
697 static int lt8912_put_dt(struct lt8912 *lt) in lt8912_put_dt() argument
699 of_node_put(lt->host_node); in lt8912_put_dt()
705 static struct lt8912 *lt; in lt8912_probe() local
709 lt = devm_kzalloc(dev, sizeof(struct lt8912), GFP_KERNEL); in lt8912_probe()
710 if (!lt) in lt8912_probe()
713 lt->dev = dev; in lt8912_probe()
714 lt->i2c_client[0] = client; in lt8912_probe()
716 ret = lt8912_parse_dt(lt); in lt8912_probe()
720 ret = lt8912_init_i2c(lt, client); in lt8912_probe()
724 i2c_set_clientdata(client, lt); in lt8912_probe()
726 lt->bridge.funcs = <8912_bridge_funcs; in lt8912_probe()
727 lt->bridge.of_node = dev->of_node; in lt8912_probe()
728 lt->bridge.ops = (DRM_BRIDGE_OP_EDID | in lt8912_probe()
731 drm_bridge_add(<->bridge); in lt8912_probe()
733 ret = lt8912_attach_dsi(lt); in lt8912_probe()
740 drm_bridge_remove(<->bridge); in lt8912_probe()
741 lt8912_free_i2c(lt); in lt8912_probe()
743 lt8912_put_dt(lt); in lt8912_probe()
750 struct lt8912 *lt = i2c_get_clientdata(client); in lt8912_remove() local
752 drm_bridge_remove(<->bridge); in lt8912_remove()
753 lt8912_free_i2c(lt); in lt8912_remove()
754 lt8912_put_dt(lt); in lt8912_remove()