Lines Matching +full:aux +full:- +full:bus

1 // SPDX-License-Identifier: GPL-2.0-only
99 struct drm_dp_aux aux; member
151 static inline struct ps8640 *aux_to_ps8640(struct drm_dp_aux *aux) in aux_to_ps8640() argument
153 return container_of(aux, struct ps8640, aux); in aux_to_ps8640()
158 struct device_node *bus, *panel; in ps8640_of_panel_on_aux_bus() local
160 bus = of_get_child_by_name(dev->of_node, "aux-bus"); in ps8640_of_panel_on_aux_bus()
161 if (!bus) in ps8640_of_panel_on_aux_bus()
164 panel = of_get_child_by_name(bus, "panel"); in ps8640_of_panel_on_aux_bus()
165 of_node_put(bus); in ps8640_of_panel_on_aux_bus()
175 struct regmap *map = ps_bridge->regmap[PAGE2_TOP_CNTL]; in _ps8640_wait_hpd_asserted()
196 if (!ret && ps_bridge->need_post_hpd_delay) { in _ps8640_wait_hpd_asserted()
197 ps_bridge->need_post_hpd_delay = false; in _ps8640_wait_hpd_asserted()
204 static int ps8640_wait_hpd_asserted(struct drm_dp_aux *aux, unsigned long wait_us) in ps8640_wait_hpd_asserted() argument
206 struct ps8640 *ps_bridge = aux_to_ps8640(aux); in ps8640_wait_hpd_asserted()
207 struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; in ps8640_wait_hpd_asserted()
223 static ssize_t ps8640_aux_transfer_msg(struct drm_dp_aux *aux, in ps8640_aux_transfer_msg() argument
226 struct ps8640 *ps_bridge = aux_to_ps8640(aux); in ps8640_aux_transfer_msg()
227 struct regmap *map = ps_bridge->regmap[PAGE0_DP_CNTL]; in ps8640_aux_transfer_msg()
228 struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; in ps8640_aux_transfer_msg()
229 unsigned int len = msg->size; in ps8640_aux_transfer_msg()
233 u8 request = msg->request & in ps8640_aux_transfer_msg()
235 u8 *buf = msg->buffer; in ps8640_aux_transfer_msg()
236 u8 addr_len[PAGE0_SWAUX_LENGTH + 1 - PAGE0_SWAUX_ADDR_7_0]; in ps8640_aux_transfer_msg()
241 return -EINVAL; in ps8640_aux_transfer_msg()
243 if (msg->address & ~SWAUX_ADDR_MASK) in ps8640_aux_transfer_msg()
244 return -EINVAL; in ps8640_aux_transfer_msg()
255 return -EINVAL; in ps8640_aux_transfer_msg()
266 msg->reply = 0; in ps8640_aux_transfer_msg()
269 addr_len[PAGE0_SWAUX_ADDR_7_0 - base] = msg->address; in ps8640_aux_transfer_msg()
270 addr_len[PAGE0_SWAUX_ADDR_15_8 - base] = msg->address >> 8; in ps8640_aux_transfer_msg()
271 addr_len[PAGE0_SWAUX_ADDR_23_16 - base] = (msg->address >> 16) | in ps8640_aux_transfer_msg()
272 (msg->request << 4); in ps8640_aux_transfer_msg()
273 addr_len[PAGE0_SWAUX_LENGTH - base] = (len == 0) ? SWAUX_NO_PAYLOAD : in ps8640_aux_transfer_msg()
274 ((len - 1) & SWAUX_LENGTH_MASK); in ps8640_aux_transfer_msg()
316 msg->reply |= DP_AUX_NATIVE_REPLY_NACK; in ps8640_aux_transfer_msg()
318 msg->reply |= DP_AUX_I2C_REPLY_NACK; in ps8640_aux_transfer_msg()
325 return -EOPNOTSUPP; in ps8640_aux_transfer_msg()
327 return -ETIMEDOUT; in ps8640_aux_transfer_msg()
349 static ssize_t ps8640_aux_transfer(struct drm_dp_aux *aux, in ps8640_aux_transfer() argument
352 struct ps8640 *ps_bridge = aux_to_ps8640(aux); in ps8640_aux_transfer()
353 struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; in ps8640_aux_transfer()
357 ret = ps8640_aux_transfer_msg(aux, msg); in ps8640_aux_transfer()
367 struct regmap *map = ps_bridge->regmap[PAGE3_DSI_CNTL1]; in ps8640_bridge_vdo_control()
368 struct device *dev = &ps_bridge->page[PAGE3_DSI_CNTL1]->dev; in ps8640_bridge_vdo_control()
385 ret = regulator_bulk_enable(ARRAY_SIZE(ps_bridge->supplies), in ps8640_resume()
386 ps_bridge->supplies); in ps8640_resume()
392 gpiod_set_value(ps_bridge->gpio_powerdown, 0); in ps8640_resume()
393 gpiod_set_value(ps_bridge->gpio_reset, 1); in ps8640_resume()
395 gpiod_set_value(ps_bridge->gpio_reset, 0); in ps8640_resume()
398 gpiod_set_value(ps_bridge->gpio_reset, 1); in ps8640_resume()
400 gpiod_set_value(ps_bridge->gpio_reset, 0); in ps8640_resume()
403 ps_bridge->need_post_hpd_delay = true; in ps8640_resume()
422 gpiod_set_value(ps_bridge->gpio_reset, 1); in ps8640_suspend()
423 gpiod_set_value(ps_bridge->gpio_powerdown, 1); in ps8640_suspend()
424 ret = regulator_bulk_disable(ARRAY_SIZE(ps_bridge->supplies), in ps8640_suspend()
425 ps_bridge->supplies); in ps8640_suspend()
441 struct regmap *map = ps_bridge->regmap[PAGE2_TOP_CNTL]; in ps8640_pre_enable()
442 struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; in ps8640_pre_enable()
469 ps_bridge->pre_enabled = true; in ps8640_pre_enable()
476 ps_bridge->pre_enabled = false; in ps8640_post_disable()
479 pm_runtime_put_sync_suspend(&ps_bridge->page[PAGE0_DP_CNTL]->dev); in ps8640_post_disable()
486 struct device *dev = &ps_bridge->page[0]->dev; in ps8640_bridge_attach()
490 return -EINVAL; in ps8640_bridge_attach()
492 ps_bridge->aux.drm_dev = bridge->dev; in ps8640_bridge_attach()
493 ret = drm_dp_aux_register(&ps_bridge->aux); in ps8640_bridge_attach()
495 dev_err(dev, "failed to register DP AUX channel: %d\n", ret); in ps8640_bridge_attach()
499 ps_bridge->link = device_link_add(bridge->dev->dev, dev, DL_FLAG_STATELESS); in ps8640_bridge_attach()
500 if (!ps_bridge->link) { in ps8640_bridge_attach()
502 ret = -EINVAL; in ps8640_bridge_attach()
506 /* Attach the panel-bridge to the dsi bridge */ in ps8640_bridge_attach()
507 ret = drm_bridge_attach(bridge->encoder, ps_bridge->panel_bridge, in ps8640_bridge_attach()
508 &ps_bridge->bridge, flags); in ps8640_bridge_attach()
515 device_link_del(ps_bridge->link); in ps8640_bridge_attach()
517 drm_dp_aux_unregister(&ps_bridge->aux); in ps8640_bridge_attach()
526 drm_dp_aux_unregister(&ps_bridge->aux); in ps8640_bridge_detach()
527 if (ps_bridge->link) in ps8640_bridge_detach()
528 device_link_del(ps_bridge->link); in ps8640_bridge_detach()
535 bool poweroff = !ps_bridge->pre_enabled; in ps8640_bridge_get_edid()
542 * -> drm_helper_probe_single_connector_modes in ps8640_bridge_get_edid()
543 * -> drm_bridge_connector_get_modes in ps8640_bridge_get_edid()
544 * -> ps8640_bridge_get_edid in ps8640_bridge_get_edid()
553 ps_bridge->page[PAGE0_DP_CNTL]->adapter); in ps8640_bridge_get_edid()
590 in_ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); in ps8640_bridge_get_dsi_resources()
592 return -ENODEV; in ps8640_bridge_get_dsi_resources()
597 return -ENODEV; in ps8640_bridge_get_dsi_resources()
602 return -EPROBE_DEFER; in ps8640_bridge_get_dsi_resources()
610 ps_bridge->dsi = dsi; in ps8640_bridge_get_dsi_resources()
612 dsi->host = host; in ps8640_bridge_get_dsi_resources()
613 dsi->mode_flags = MIPI_DSI_MODE_VIDEO | in ps8640_bridge_get_dsi_resources()
615 dsi->format = MIPI_DSI_FMT_RGB888; in ps8640_bridge_get_dsi_resources()
616 dsi->lanes = NUM_MIPI_LANES; in ps8640_bridge_get_dsi_resources()
621 static int ps8640_bridge_link_panel(struct drm_dp_aux *aux) in ps8640_bridge_link_panel() argument
623 struct ps8640 *ps_bridge = aux_to_ps8640(aux); in ps8640_bridge_link_panel()
624 struct device *dev = aux->dev; in ps8640_bridge_link_panel()
625 struct device_node *np = dev->of_node; in ps8640_bridge_link_panel()
629 * NOTE about returning -EPROBE_DEFER from this function: if we in ps8640_bridge_link_panel()
630 * return an error (most relevant to -EPROBE_DEFER) it will only in ps8640_bridge_link_panel()
632 * panel isn't under the "aux-bus" node). That should be fine because in ps8640_bridge_link_panel()
633 * if the panel is under "aux-bus" it's guaranteed to have probed by in ps8640_bridge_link_panel()
638 ps_bridge->panel_bridge = devm_drm_of_get_bridge(dev, np, 1, 0); in ps8640_bridge_link_panel()
639 if (IS_ERR(ps_bridge->panel_bridge)) in ps8640_bridge_link_panel()
640 return PTR_ERR(ps_bridge->panel_bridge); in ps8640_bridge_link_panel()
642 ret = devm_drm_bridge_add(dev, &ps_bridge->bridge); in ps8640_bridge_link_panel()
646 return devm_mipi_dsi_attach(dev, ps_bridge->dsi); in ps8640_bridge_link_panel()
651 struct device *dev = &client->dev; in ps8640_probe()
658 return -ENOMEM; in ps8640_probe()
660 ps_bridge->supplies[0].supply = "vdd12"; in ps8640_probe()
661 ps_bridge->supplies[1].supply = "vdd33"; in ps8640_probe()
662 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ps_bridge->supplies), in ps8640_probe()
663 ps_bridge->supplies); in ps8640_probe()
667 ps_bridge->gpio_powerdown = devm_gpiod_get(&client->dev, "powerdown", in ps8640_probe()
669 if (IS_ERR(ps_bridge->gpio_powerdown)) in ps8640_probe()
670 return PTR_ERR(ps_bridge->gpio_powerdown); in ps8640_probe()
675 ps_bridge->gpio_reset = devm_gpiod_get(&client->dev, "reset", in ps8640_probe()
677 if (IS_ERR(ps_bridge->gpio_reset)) in ps8640_probe()
678 return PTR_ERR(ps_bridge->gpio_reset); in ps8640_probe()
680 ps_bridge->bridge.funcs = &ps8640_bridge_funcs; in ps8640_probe()
681 ps_bridge->bridge.of_node = dev->of_node; in ps8640_probe()
682 ps_bridge->bridge.type = DRM_MODE_CONNECTOR_eDP; in ps8640_probe()
685 * In the device tree, if panel is listed under aux-bus of the bridge in ps8640_probe()
687 * aux-bus. So let's not set DRM_BRIDGE_OP_EDID here. in ps8640_probe()
689 if (!ps8640_of_panel_on_aux_bus(&client->dev)) in ps8640_probe()
690 ps_bridge->bridge.ops = DRM_BRIDGE_OP_EDID; in ps8640_probe()
693 * Get MIPI DSI resources early. These can return -EPROBE_DEFER so in ps8640_probe()
696 ret = ps8640_bridge_get_dsi_resources(&client->dev, ps_bridge); in ps8640_probe()
700 ps_bridge->page[PAGE0_DP_CNTL] = client; in ps8640_probe()
702 ps_bridge->regmap[PAGE0_DP_CNTL] = devm_regmap_init_i2c(client, ps8640_regmap_config); in ps8640_probe()
703 if (IS_ERR(ps_bridge->regmap[PAGE0_DP_CNTL])) in ps8640_probe()
704 return PTR_ERR(ps_bridge->regmap[PAGE0_DP_CNTL]); in ps8640_probe()
706 for (i = 1; i < ARRAY_SIZE(ps_bridge->page); i++) { in ps8640_probe()
707 ps_bridge->page[i] = devm_i2c_new_dummy_device(&client->dev, in ps8640_probe()
708 client->adapter, in ps8640_probe()
709 client->addr + i); in ps8640_probe()
710 if (IS_ERR(ps_bridge->page[i])) in ps8640_probe()
711 return PTR_ERR(ps_bridge->page[i]); in ps8640_probe()
713 ps_bridge->regmap[i] = devm_regmap_init_i2c(ps_bridge->page[i], in ps8640_probe()
715 if (IS_ERR(ps_bridge->regmap[i])) in ps8640_probe()
716 return PTR_ERR(ps_bridge->regmap[i]); in ps8640_probe()
721 ps_bridge->aux.name = "parade-ps8640-aux"; in ps8640_probe()
722 ps_bridge->aux.dev = dev; in ps8640_probe()
723 ps_bridge->aux.transfer = ps8640_aux_transfer; in ps8640_probe()
724 ps_bridge->aux.wait_hpd_asserted = ps8640_wait_hpd_asserted; in ps8640_probe()
725 drm_dp_aux_init(&ps_bridge->aux); in ps8640_probe()
743 ret = devm_of_dp_aux_populate_bus(&ps_bridge->aux, ps8640_bridge_link_panel); in ps8640_probe()
746 * If devm_of_dp_aux_populate_bus() returns -ENODEV then it's up to in ps8640_probe()
748 * the function is allowed to -EPROBE_DEFER. in ps8640_probe()
750 if (ret == -ENODEV) in ps8640_probe()
751 return ps8640_bridge_link_panel(&ps_bridge->aux); in ps8640_probe()
775 MODULE_DESCRIPTION("PARADE ps8640 DSI-eDP converter driver");