Lines Matching +full:dsi +full:- +full:to +full:- +full:edp

1 // SPDX-License-Identifier: GPL-2.0-only
74 * page[3]: for DSI Link Control1
77 * page[6]: for DSI Link Control2
101 struct mipi_dsi_device *dsi; member
160 struct regmap *map = ps_bridge->regmap[PAGE2_TOP_CNTL]; in _ps8640_wait_hpd_asserted()
167 * actually connected to GPIO9). in _ps8640_wait_hpd_asserted()
175 * time (maybe talking to the panel) and we don't want to interrupt it. in _ps8640_wait_hpd_asserted()
181 if (!ret && ps_bridge->need_post_hpd_delay) { in _ps8640_wait_hpd_asserted()
182 ps_bridge->need_post_hpd_delay = false; in _ps8640_wait_hpd_asserted()
192 struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; in ps8640_wait_hpd_asserted()
197 * the panel. We have to power ourselves up but we don't need to worry in ps8640_wait_hpd_asserted()
212 struct regmap *map = ps_bridge->regmap[PAGE0_DP_CNTL]; in ps8640_aux_transfer_msg()
213 struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; in ps8640_aux_transfer_msg()
214 size_t len = msg->size; in ps8640_aux_transfer_msg()
218 u8 request = msg->request & in ps8640_aux_transfer_msg()
220 u8 *buf = msg->buffer; in ps8640_aux_transfer_msg()
221 u8 addr_len[PAGE0_SWAUX_LENGTH + 1 - PAGE0_SWAUX_ADDR_7_0]; in ps8640_aux_transfer_msg()
226 return -EINVAL; in ps8640_aux_transfer_msg()
228 if (msg->address & ~SWAUX_ADDR_MASK) in ps8640_aux_transfer_msg()
229 return -EINVAL; in ps8640_aux_transfer_msg()
240 return -EINVAL; in ps8640_aux_transfer_msg()
245 DRM_DEV_ERROR(dev, "failed to write PAGE0_AUXCH_CFG3: %d\n", in ps8640_aux_transfer_msg()
251 msg->reply = 0; in ps8640_aux_transfer_msg()
254 addr_len[PAGE0_SWAUX_ADDR_7_0 - base] = msg->address; in ps8640_aux_transfer_msg()
255 addr_len[PAGE0_SWAUX_ADDR_15_8 - base] = msg->address >> 8; in ps8640_aux_transfer_msg()
256 addr_len[PAGE0_SWAUX_ADDR_23_16 - base] = (msg->address >> 16) | in ps8640_aux_transfer_msg()
257 (msg->request << 4); in ps8640_aux_transfer_msg()
258 addr_len[PAGE0_SWAUX_LENGTH - base] = (len == 0) ? SWAUX_NO_PAYLOAD : in ps8640_aux_transfer_msg()
259 ((len - 1) & SWAUX_LENGTH_MASK); in ps8640_aux_transfer_msg()
266 /* Write to the internal FIFO buffer */ in ps8640_aux_transfer_msg()
271 "failed to write WDATA: %d\n", in ps8640_aux_transfer_msg()
286 DRM_DEV_ERROR(dev, "failed to read PAGE0_SWAUX_STATUS: %d\n", in ps8640_aux_transfer_msg()
300 msg->reply |= DP_AUX_NATIVE_REPLY_NACK; in ps8640_aux_transfer_msg()
302 msg->reply |= DP_AUX_I2C_REPLY_NACK; in ps8640_aux_transfer_msg()
311 msg->reply |= DP_AUX_NATIVE_REPLY_DEFER; in ps8640_aux_transfer_msg()
313 msg->reply |= DP_AUX_I2C_REPLY_DEFER; in ps8640_aux_transfer_msg()
317 return -EOPNOTSUPP; in ps8640_aux_transfer_msg()
319 return -ETIMEDOUT; in ps8640_aux_transfer_msg()
329 "failed to read RDATA: %d\n", in ps8640_aux_transfer_msg()
334 if (i < msg->size) in ps8640_aux_transfer_msg()
339 return min(len, msg->size); in ps8640_aux_transfer_msg()
346 struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; in ps8640_aux_transfer()
349 mutex_lock(&ps_bridge->aux_lock); in ps8640_aux_transfer()
361 mutex_unlock(&ps_bridge->aux_lock); in ps8640_aux_transfer()
369 struct regmap *map = ps_bridge->regmap[PAGE3_DSI_CNTL1]; in ps8640_bridge_vdo_control()
370 struct device *dev = &ps_bridge->page[PAGE3_DSI_CNTL1]->dev; in ps8640_bridge_vdo_control()
378 dev_err(dev, "failed to %sable VDO: %d\n", in ps8640_bridge_vdo_control()
387 ret = regulator_bulk_enable(ARRAY_SIZE(ps_bridge->supplies), in ps8640_resume()
388 ps_bridge->supplies); in ps8640_resume()
394 gpiod_set_value(ps_bridge->gpio_powerdown, 0); in ps8640_resume()
395 gpiod_set_value(ps_bridge->gpio_reset, 1); in ps8640_resume()
397 gpiod_set_value(ps_bridge->gpio_reset, 0); in ps8640_resume()
400 gpiod_set_value(ps_bridge->gpio_reset, 1); in ps8640_resume()
402 gpiod_set_value(ps_bridge->gpio_reset, 0); in ps8640_resume()
405 ps_bridge->need_post_hpd_delay = true; in ps8640_resume()
408 * Mystery 200 ms delay for the "MCU to be ready". It's unclear if in ps8640_resume()
410 * things are "good to go" by signaling HPD on "gpio 9". See in ps8640_resume()
424 gpiod_set_value(ps_bridge->gpio_reset, 1); in ps8640_suspend()
425 gpiod_set_value(ps_bridge->gpio_powerdown, 1); in ps8640_suspend()
426 ret = regulator_bulk_disable(ARRAY_SIZE(ps_bridge->supplies), in ps8640_suspend()
427 ps_bridge->supplies); in ps8640_suspend()
444 struct regmap *map = ps_bridge->regmap[PAGE2_TOP_CNTL]; in ps8640_atomic_pre_enable()
445 struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; in ps8640_atomic_pre_enable()
465 /* Switch access edp panel's edid through i2c */ in ps8640_atomic_pre_enable()
472 ps_bridge->pre_enabled = true; in ps8640_atomic_pre_enable()
480 ps_bridge->pre_enabled = false; in ps8640_atomic_post_disable()
485 * The bridge seems to expect everything to be power cycled at the in ps8640_atomic_post_disable()
486 * disable process, so grab a lock here to make sure in ps8640_atomic_post_disable()
490 mutex_lock(&ps_bridge->aux_lock); in ps8640_atomic_post_disable()
492 pm_runtime_put_sync_suspend(&ps_bridge->page[PAGE0_DP_CNTL]->dev); in ps8640_atomic_post_disable()
494 mutex_unlock(&ps_bridge->aux_lock); in ps8640_atomic_post_disable()
501 struct device *dev = &ps_bridge->page[0]->dev; in ps8640_bridge_attach()
505 return -EINVAL; in ps8640_bridge_attach()
507 ps_bridge->aux.drm_dev = bridge->dev; in ps8640_bridge_attach()
508 ret = drm_dp_aux_register(&ps_bridge->aux); in ps8640_bridge_attach()
510 dev_err(dev, "failed to register DP AUX channel: %d\n", ret); in ps8640_bridge_attach()
514 ps_bridge->link = device_link_add(bridge->dev->dev, dev, DL_FLAG_STATELESS); in ps8640_bridge_attach()
515 if (!ps_bridge->link) { in ps8640_bridge_attach()
516 dev_err(dev, "failed to create device link"); in ps8640_bridge_attach()
517 ret = -EINVAL; in ps8640_bridge_attach()
521 /* Attach the panel-bridge to the dsi bridge */ in ps8640_bridge_attach()
522 ret = drm_bridge_attach(bridge->encoder, ps_bridge->panel_bridge, in ps8640_bridge_attach()
523 &ps_bridge->bridge, flags); in ps8640_bridge_attach()
530 device_link_del(ps_bridge->link); in ps8640_bridge_attach()
532 drm_dp_aux_unregister(&ps_bridge->aux); in ps8640_bridge_attach()
541 drm_dp_aux_unregister(&ps_bridge->aux); in ps8640_bridge_detach()
542 if (ps_bridge->link) in ps8640_bridge_detach()
543 device_link_del(ps_bridge->link); in ps8640_bridge_detach()
565 struct mipi_dsi_device *dsi; in ps8640_bridge_get_dsi_resources() local
572 /* port@0 is ps8640 dsi input port */ in ps8640_bridge_get_dsi_resources()
573 in_ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); in ps8640_bridge_get_dsi_resources()
575 return -ENODEV; in ps8640_bridge_get_dsi_resources()
580 return -ENODEV; in ps8640_bridge_get_dsi_resources()
585 return -EPROBE_DEFER; in ps8640_bridge_get_dsi_resources()
587 dsi = devm_mipi_dsi_device_register_full(dev, host, &info); in ps8640_bridge_get_dsi_resources()
588 if (IS_ERR(dsi)) { in ps8640_bridge_get_dsi_resources()
589 dev_err(dev, "failed to create dsi device\n"); in ps8640_bridge_get_dsi_resources()
590 return PTR_ERR(dsi); in ps8640_bridge_get_dsi_resources()
593 ps_bridge->dsi = dsi; in ps8640_bridge_get_dsi_resources()
595 dsi->host = host; in ps8640_bridge_get_dsi_resources()
596 dsi->mode_flags = MIPI_DSI_MODE_VIDEO | in ps8640_bridge_get_dsi_resources()
598 dsi->format = MIPI_DSI_FMT_RGB888; in ps8640_bridge_get_dsi_resources()
599 dsi->lanes = NUM_MIPI_LANES; in ps8640_bridge_get_dsi_resources()
607 struct device *dev = aux->dev; in ps8640_bridge_link_panel()
608 struct device_node *np = dev->of_node; in ps8640_bridge_link_panel()
612 * NOTE about returning -EPROBE_DEFER from this function: if we in ps8640_bridge_link_panel()
613 * return an error (most relevant to -EPROBE_DEFER) it will only in ps8640_bridge_link_panel()
614 * be passed out to ps8640_probe() if it called this directly (AKA the in ps8640_bridge_link_panel()
615 * panel isn't under the "aux-bus" node). That should be fine because in ps8640_bridge_link_panel()
616 * if the panel is under "aux-bus" it's guaranteed to have probed by in ps8640_bridge_link_panel()
621 ps_bridge->panel_bridge = devm_drm_of_get_bridge(dev, np, 1, 0); in ps8640_bridge_link_panel()
622 if (IS_ERR(ps_bridge->panel_bridge)) in ps8640_bridge_link_panel()
623 return PTR_ERR(ps_bridge->panel_bridge); in ps8640_bridge_link_panel()
625 ret = devm_drm_bridge_add(dev, &ps_bridge->bridge); in ps8640_bridge_link_panel()
629 return devm_mipi_dsi_attach(dev, ps_bridge->dsi); in ps8640_bridge_link_panel()
634 struct device *dev = &client->dev; in ps8640_probe()
641 return -ENOMEM; in ps8640_probe()
643 mutex_init(&ps_bridge->aux_lock); in ps8640_probe()
645 ps_bridge->supplies[0].supply = "vdd12"; in ps8640_probe()
646 ps_bridge->supplies[1].supply = "vdd33"; in ps8640_probe()
647 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ps_bridge->supplies), in ps8640_probe()
648 ps_bridge->supplies); in ps8640_probe()
652 ps_bridge->gpio_powerdown = devm_gpiod_get(&client->dev, "powerdown", in ps8640_probe()
654 if (IS_ERR(ps_bridge->gpio_powerdown)) in ps8640_probe()
655 return PTR_ERR(ps_bridge->gpio_powerdown); in ps8640_probe()
658 * Assert the reset to avoid the bridge being initialized prematurely in ps8640_probe()
660 ps_bridge->gpio_reset = devm_gpiod_get(&client->dev, "reset", in ps8640_probe()
662 if (IS_ERR(ps_bridge->gpio_reset)) in ps8640_probe()
663 return PTR_ERR(ps_bridge->gpio_reset); in ps8640_probe()
665 ps_bridge->bridge.funcs = &ps8640_bridge_funcs; in ps8640_probe()
666 ps_bridge->bridge.of_node = dev->of_node; in ps8640_probe()
667 ps_bridge->bridge.type = DRM_MODE_CONNECTOR_eDP; in ps8640_probe()
670 * Get MIPI DSI resources early. These can return -EPROBE_DEFER so in ps8640_probe()
671 * we want to get them out of the way sooner. in ps8640_probe()
673 ret = ps8640_bridge_get_dsi_resources(&client->dev, ps_bridge); in ps8640_probe()
677 ps_bridge->page[PAGE0_DP_CNTL] = client; in ps8640_probe()
679 ps_bridge->regmap[PAGE0_DP_CNTL] = devm_regmap_init_i2c(client, ps8640_regmap_config); in ps8640_probe()
680 if (IS_ERR(ps_bridge->regmap[PAGE0_DP_CNTL])) in ps8640_probe()
681 return PTR_ERR(ps_bridge->regmap[PAGE0_DP_CNTL]); in ps8640_probe()
683 for (i = 1; i < ARRAY_SIZE(ps_bridge->page); i++) { in ps8640_probe()
684 ps_bridge->page[i] = devm_i2c_new_dummy_device(&client->dev, in ps8640_probe()
685 client->adapter, in ps8640_probe()
686 client->addr + i); in ps8640_probe()
687 if (IS_ERR(ps_bridge->page[i])) in ps8640_probe()
688 return PTR_ERR(ps_bridge->page[i]); in ps8640_probe()
690 ps_bridge->regmap[i] = devm_regmap_init_i2c(ps_bridge->page[i], in ps8640_probe()
692 if (IS_ERR(ps_bridge->regmap[i])) in ps8640_probe()
693 return PTR_ERR(ps_bridge->regmap[i]); in ps8640_probe()
698 ps_bridge->aux.name = "parade-ps8640-aux"; in ps8640_probe()
699 ps_bridge->aux.dev = dev; in ps8640_probe()
700 ps_bridge->aux.transfer = ps8640_aux_transfer; in ps8640_probe()
701 ps_bridge->aux.wait_hpd_asserted = ps8640_wait_hpd_asserted; in ps8640_probe()
702 drm_dp_aux_init(&ps_bridge->aux); in ps8640_probe()
706 * Powering on ps8640 takes ~300ms. To avoid wasting time on power in ps8640_probe()
707 * cycling ps8640 too often, set autosuspend_delay to 2000ms to ensure in ps8640_probe()
720 ret = devm_of_dp_aux_populate_bus(&ps_bridge->aux, ps8640_bridge_link_panel); in ps8640_probe()
723 * If devm_of_dp_aux_populate_bus() returns -ENODEV then it's up to in ps8640_probe()
724 * usa to call ps8640_bridge_link_panel() directly. NOTE: in this case in ps8640_probe()
725 * the function is allowed to -EPROBE_DEFER. in ps8640_probe()
727 if (ret == -ENODEV) in ps8640_probe()
728 return ps8640_bridge_link_panel(&ps_bridge->aux); in ps8640_probe()
752 MODULE_DESCRIPTION("PARADE ps8640 DSI-eDP converter driver");