Lines Matching refs:lt
51 static int lt8912_write_init_config(struct lt8912 *lt) in lt8912_write_init_config() argument
88 return regmap_multi_reg_write(lt->regmap[I2C_MAIN], seq, ARRAY_SIZE(seq)); in lt8912_write_init_config()
91 static int lt8912_write_mipi_basic_config(struct lt8912 *lt) in lt8912_write_mipi_basic_config() argument
101 return regmap_multi_reg_write(lt->regmap[I2C_CEC_DSI], seq, ARRAY_SIZE(seq)); in lt8912_write_mipi_basic_config()
104 static int lt8912_write_dds_config(struct lt8912 *lt) in lt8912_write_dds_config() argument
154 return regmap_multi_reg_write(lt->regmap[I2C_CEC_DSI], seq, ARRAY_SIZE(seq)); in lt8912_write_dds_config()
157 static int lt8912_write_rxlogicres_config(struct lt8912 *lt) in lt8912_write_rxlogicres_config() argument
161 ret = regmap_write(lt->regmap[I2C_MAIN], 0x03, 0x7f); in lt8912_write_rxlogicres_config()
163 ret |= regmap_write(lt->regmap[I2C_MAIN], 0x03, 0xff); in lt8912_write_rxlogicres_config()
169 static int lt8912_write_lvds_config(struct lt8912 *lt) in lt8912_write_lvds_config() argument
199 return regmap_multi_reg_write(lt->regmap[I2C_MAIN], seq, ARRAY_SIZE(seq)); in lt8912_write_lvds_config()
218 static int lt8912_init_i2c(struct lt8912 *lt, struct i2c_client *client) in lt8912_init_i2c() argument
230 if (!lt) in lt8912_init_i2c()
235 lt->i2c_client[i] = i2c_new_dummy_device(client->adapter, in lt8912_init_i2c()
237 if (IS_ERR(lt->i2c_client[i])) in lt8912_init_i2c()
238 return PTR_ERR(lt->i2c_client[i]); in lt8912_init_i2c()
241 lt->regmap[i] = devm_regmap_init_i2c(lt->i2c_client[i], in lt8912_init_i2c()
243 if (IS_ERR(lt->regmap[i])) in lt8912_init_i2c()
244 return PTR_ERR(lt->regmap[i]); in lt8912_init_i2c()
249 static int lt8912_free_i2c(struct lt8912 *lt) in lt8912_free_i2c() argument
254 i2c_unregister_device(lt->i2c_client[i]); in lt8912_free_i2c()
259 static int lt8912_hard_power_on(struct lt8912 *lt) in lt8912_hard_power_on() argument
261 gpiod_set_value_cansleep(lt->gp_reset, 0); in lt8912_hard_power_on()
267 static void lt8912_hard_power_off(struct lt8912 *lt) in lt8912_hard_power_off() argument
269 gpiod_set_value_cansleep(lt->gp_reset, 1); in lt8912_hard_power_off()
271 lt->is_power_on = false; in lt8912_hard_power_off()
274 static int lt8912_video_setup(struct lt8912 *lt) in lt8912_video_setup() argument
281 if (!lt) in lt8912_video_setup()
284 hactive = lt->mode.hactive; in lt8912_video_setup()
285 hfp = lt->mode.hfront_porch; in lt8912_video_setup()
286 hpw = lt->mode.hsync_len; in lt8912_video_setup()
287 hbp = lt->mode.hback_porch; in lt8912_video_setup()
289 hsync_activehigh = lt->mode.flags & DISPLAY_FLAGS_HSYNC_HIGH; in lt8912_video_setup()
291 vactive = lt->mode.vactive; in lt8912_video_setup()
292 vfp = lt->mode.vfront_porch; in lt8912_video_setup()
293 vpw = lt->mode.vsync_len; in lt8912_video_setup()
294 vbp = lt->mode.vback_porch; in lt8912_video_setup()
296 vsync_activehigh = lt->mode.flags & DISPLAY_FLAGS_VSYNC_HIGH; in lt8912_video_setup()
303 ret = regmap_write(lt->regmap[I2C_CEC_DSI], 0x10, 0x01); in lt8912_video_setup()
304 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x11, settle); in lt8912_video_setup()
305 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x18, hpw); in lt8912_video_setup()
306 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x19, vpw); in lt8912_video_setup()
307 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x1c, hactive & 0xff); in lt8912_video_setup()
308 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x1d, hactive >> 8); in lt8912_video_setup()
310 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x2f, 0x0c); in lt8912_video_setup()
312 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x34, h_total & 0xff); in lt8912_video_setup()
313 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x35, h_total >> 8); in lt8912_video_setup()
315 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x36, v_total & 0xff); in lt8912_video_setup()
316 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x37, v_total >> 8); in lt8912_video_setup()
318 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x38, vbp & 0xff); in lt8912_video_setup()
319 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x39, vbp >> 8); in lt8912_video_setup()
321 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3a, vfp & 0xff); in lt8912_video_setup()
322 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3b, vfp >> 8); in lt8912_video_setup()
324 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3c, hbp & 0xff); in lt8912_video_setup()
325 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3d, hbp >> 8); in lt8912_video_setup()
327 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3e, hfp & 0xff); in lt8912_video_setup()
328 ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3f, hfp >> 8); in lt8912_video_setup()
330 ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(0), in lt8912_video_setup()
332 ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(1), in lt8912_video_setup()
334 ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xb2, BIT(0), in lt8912_video_setup()
335 lt->connector.display_info.is_hdmi ? BIT(0) : 0); in lt8912_video_setup()
340 static int lt8912_soft_power_on(struct lt8912 *lt) in lt8912_soft_power_on() argument
342 if (!lt->is_power_on) { in lt8912_soft_power_on()
343 u32 lanes = lt->data_lanes; in lt8912_soft_power_on()
345 lt8912_write_init_config(lt); in lt8912_soft_power_on()
346 regmap_write(lt->regmap[I2C_CEC_DSI], 0x13, lanes & 3); in lt8912_soft_power_on()
348 lt8912_write_mipi_basic_config(lt); in lt8912_soft_power_on()
350 lt->is_power_on = true; in lt8912_soft_power_on()
356 static int lt8912_video_on(struct lt8912 *lt) in lt8912_video_on() argument
360 ret = lt8912_video_setup(lt); in lt8912_video_on()
364 ret = lt8912_write_dds_config(lt); in lt8912_video_on()
368 ret = lt8912_write_rxlogicres_config(lt); in lt8912_video_on()
372 ret = lt8912_write_lvds_config(lt); in lt8912_video_on()
380 static enum drm_connector_status lt8912_check_cable_status(struct lt8912 *lt) in lt8912_check_cable_status() argument
385 ret = regmap_read(lt->regmap[I2C_MAIN], 0xC1, ®_val); in lt8912_check_cable_status()
398 struct lt8912 *lt = connector_to_lt8912(connector); in lt8912_connector_detect() local
400 if (lt->hdmi_port->ops & DRM_BRIDGE_OP_DETECT) in lt8912_connector_detect()
401 return drm_bridge_detect(lt->hdmi_port); in lt8912_connector_detect()
403 return lt8912_check_cable_status(lt); in lt8912_connector_detect()
436 struct lt8912 *lt = connector_to_lt8912(connector); in lt8912_connector_get_modes() local
439 edid = drm_bridge_get_edid(lt->hdmi_port, connector); in lt8912_connector_get_modes()
465 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_mode_set() local
467 drm_display_mode_to_videomode(adj, <->mode); in lt8912_bridge_mode_set()
472 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_enable() local
474 lt8912_video_on(lt); in lt8912_bridge_enable()
477 static int lt8912_attach_dsi(struct lt8912 *lt) in lt8912_attach_dsi() argument
479 struct device *dev = lt->dev; in lt8912_attach_dsi()
488 host = of_find_mipi_dsi_host_by_node(lt->host_node); in lt8912_attach_dsi()
501 lt->dsi = dsi; in lt8912_attach_dsi()
503 dsi->lanes = lt->data_lanes; in lt8912_attach_dsi()
523 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_connector_init() local
524 struct drm_connector *connector = <->connector; in lt8912_bridge_connector_init()
531 lt->hdmi_port->type); in lt8912_bridge_connector_init()
547 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_attach() local
553 dev_err(lt->dev, "Failed to init bridge ! (%d)\n", ret); in lt8912_bridge_attach()
558 ret = lt8912_hard_power_on(lt); in lt8912_bridge_attach()
562 ret = lt8912_soft_power_on(lt); in lt8912_bridge_attach()
566 lt->is_attached = true; in lt8912_bridge_attach()
571 lt8912_hard_power_off(lt); in lt8912_bridge_attach()
577 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_detach() local
579 if (lt->is_attached) { in lt8912_bridge_detach()
580 lt8912_hard_power_off(lt); in lt8912_bridge_detach()
581 drm_connector_unregister(<->connector); in lt8912_bridge_detach()
582 drm_connector_cleanup(<->connector); in lt8912_bridge_detach()
589 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_detect() local
591 if (lt->hdmi_port->ops & DRM_BRIDGE_OP_DETECT) in lt8912_bridge_detect()
592 return drm_bridge_detect(lt->hdmi_port); in lt8912_bridge_detect()
594 return lt8912_check_cable_status(lt); in lt8912_bridge_detect()
600 struct lt8912 *lt = bridge_to_lt8912(bridge); in lt8912_bridge_get_edid() local
606 if (lt->hdmi_port->ops & DRM_BRIDGE_OP_EDID) in lt8912_bridge_get_edid()
607 return drm_bridge_get_edid(lt->hdmi_port, connector); in lt8912_bridge_get_edid()
609 dev_warn(lt->dev, "The connected bridge does not supports DRM_BRIDGE_OP_EDID\n"); in lt8912_bridge_get_edid()
622 static int lt8912_parse_dt(struct lt8912 *lt) in lt8912_parse_dt() argument
625 struct device *dev = lt->dev; in lt8912_parse_dt()
637 lt->gp_reset = gp_reset; in lt8912_parse_dt()
641 dev_err(lt->dev, "%s: Bad data-lanes property\n", __func__); in lt8912_parse_dt()
645 lt->data_lanes = data_lanes; in lt8912_parse_dt()
647 lt->host_node = of_graph_get_remote_node(dev->of_node, 0, -1); in lt8912_parse_dt()
648 if (!lt->host_node) { in lt8912_parse_dt()
649 dev_err(lt->dev, "%s: Failed to get remote port\n", __func__); in lt8912_parse_dt()
655 dev_err(lt->dev, "%s: Failed to get connector port\n", __func__); in lt8912_parse_dt()
660 lt->hdmi_port = of_drm_find_bridge(port_node); in lt8912_parse_dt()
661 if (!lt->hdmi_port) { in lt8912_parse_dt()
662 dev_err(lt->dev, "%s: Failed to get hdmi port\n", __func__); in lt8912_parse_dt()
668 dev_err(lt->dev, "%s: Failed to get hdmi port\n", __func__); in lt8912_parse_dt()
678 of_node_put(lt->host_node); in lt8912_parse_dt()
682 static int lt8912_put_dt(struct lt8912 *lt) in lt8912_put_dt() argument
684 of_node_put(lt->host_node); in lt8912_put_dt()
691 static struct lt8912 *lt; in lt8912_probe() local
695 lt = devm_kzalloc(dev, sizeof(struct lt8912), GFP_KERNEL); in lt8912_probe()
696 if (!lt) in lt8912_probe()
699 lt->dev = dev; in lt8912_probe()
700 lt->i2c_client[0] = client; in lt8912_probe()
702 ret = lt8912_parse_dt(lt); in lt8912_probe()
706 ret = lt8912_init_i2c(lt, client); in lt8912_probe()
710 i2c_set_clientdata(client, lt); in lt8912_probe()
712 lt->bridge.funcs = <8912_bridge_funcs; in lt8912_probe()
713 lt->bridge.of_node = dev->of_node; in lt8912_probe()
714 lt->bridge.ops = (DRM_BRIDGE_OP_EDID | in lt8912_probe()
717 drm_bridge_add(<->bridge); in lt8912_probe()
719 ret = lt8912_attach_dsi(lt); in lt8912_probe()
726 drm_bridge_remove(<->bridge); in lt8912_probe()
727 lt8912_free_i2c(lt); in lt8912_probe()
729 lt8912_put_dt(lt); in lt8912_probe()
736 struct lt8912 *lt = i2c_get_clientdata(client); in lt8912_remove() local
738 lt8912_bridge_detach(<->bridge); in lt8912_remove()
739 drm_bridge_remove(<->bridge); in lt8912_remove()
740 lt8912_free_i2c(lt); in lt8912_remove()
741 lt8912_put_dt(lt); in lt8912_remove()