Lines Matching +full:dvdd25 +full:- +full:supply

1 /* SPDX-License-Identifier: GPL-2.0-only */
32 #include "analogix-i2c-dptx.h"
33 #include "analogix-i2c-txcommon.h"
55 struct regulator *dvdd25; member
94 return anx_dp_aux_transfer(anx6345->map[I2C_IDX_DPTX], msg); in anx6345_aux_transfer()
103 err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], in anx6345_dp_link_training()
109 err = drm_dp_dpcd_readb(&anx6345->aux, DP_MAX_LINK_RATE, &dp_bw); in anx6345_dp_link_training()
120 return -EINVAL; in anx6345_dp_link_training()
123 err = anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL1_REG, in anx6345_dp_link_training()
128 err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], in anx6345_dp_link_training()
134 err = drm_dp_dpcd_read(&anx6345->aux, DP_DPCD_REV, in anx6345_dp_link_training()
135 &anx6345->dpcd, DP_RECEIVER_CAP_SIZE); in anx6345_dp_link_training()
142 err = anx6345_clear_bits(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
151 if (anx6345->dpcd[DP_DPCD_REV] >= 0x11) { in anx6345_dp_link_training()
152 err = drm_dp_dpcd_readb(&anx6345->aux, DP_SET_POWER, &dpcd[0]); in anx6345_dp_link_training()
162 err = drm_dp_dpcd_writeb(&anx6345->aux, DP_SET_POWER, dpcd[0]); in anx6345_dp_link_training()
172 * Table 5-52, "Sink Control Field" (register 0x600). in anx6345_dp_link_training()
178 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
183 if (anx6345->dpcd[DP_MAX_DOWNSPREAD] & DP_MAX_DOWNSPREAD_0_5) { in anx6345_dp_link_training()
186 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
191 err = drm_dp_dpcd_writeb(&anx6345->aux, DP_DOWNSPREAD_CTRL, in anx6345_dp_link_training()
196 err = drm_dp_dpcd_writeb(&anx6345->aux, DP_DOWNSPREAD_CTRL, 0); in anx6345_dp_link_training()
202 if (drm_dp_enhanced_frame_cap(anx6345->dpcd)) in anx6345_dp_link_training()
203 err = anx6345_set_bits(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
207 err = anx6345_clear_bits(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
214 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
219 dpcd[1] = drm_dp_max_lane_count(anx6345->dpcd); in anx6345_dp_link_training()
221 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
226 if (drm_dp_enhanced_frame_cap(anx6345->dpcd)) in anx6345_dp_link_training()
229 err = drm_dp_dpcd_write(&anx6345->aux, DP_LINK_BW_SET, dpcd, in anx6345_dp_link_training()
238 err = regmap_write(anx6345->map[I2C_IDX_DPTX], SP_DP_LT_CTRL_REG, in anx6345_dp_link_training()
243 return regmap_read_poll_timeout(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
254 err = regmap_write(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL2_REG, in anx6345_tx_initialization()
259 err = regmap_write(anx6345->map[I2C_IDX_DPTX], SP_DP_PLL_CTRL_REG, 0); in anx6345_tx_initialization()
263 err = regmap_write(anx6345->map[I2C_IDX_TXCOM], in anx6345_tx_initialization()
268 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_tx_initialization()
274 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_tx_initialization()
280 err = anx6345_set_bits(anx6345->map[I2C_IDX_DPTX], in anx6345_tx_initialization()
288 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_tx_initialization()
295 err = anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], in anx6345_tx_initialization()
300 return anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], in anx6345_tx_initialization()
309 gpiod_set_value_cansleep(anx6345->gpiod_reset, 1); in anx6345_poweron()
312 err = regulator_enable(anx6345->dvdd12); in anx6345_poweron()
319 /* T1 - delay between VDD12 and VDD25 should be 0-2ms */ in anx6345_poweron()
322 err = regulator_enable(anx6345->dvdd25); in anx6345_poweron()
324 DRM_ERROR("Failed to enable dvdd25 regulator: %d\n", in anx6345_poweron()
329 /* T2 - delay between RESETN and all power rail stable, in anx6345_poweron()
330 * should be 2-5ms in anx6345_poweron()
334 gpiod_set_value_cansleep(anx6345->gpiod_reset, 0); in anx6345_poweron()
337 anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_POWERDOWN_CTRL_REG, in anx6345_poweron()
339 anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], SP_POWERDOWN_CTRL_REG, in anx6345_poweron()
342 if (anx6345->panel) in anx6345_poweron()
343 drm_panel_prepare(anx6345->panel); in anx6345_poweron()
345 anx6345->powered = true; in anx6345_poweron()
352 gpiod_set_value_cansleep(anx6345->gpiod_reset, 1); in anx6345_poweroff()
355 if (anx6345->panel) in anx6345_poweroff()
356 drm_panel_unprepare(anx6345->panel); in anx6345_poweroff()
358 err = regulator_disable(anx6345->dvdd25); in anx6345_poweroff()
360 DRM_ERROR("Failed to disable dvdd25 regulator: %d\n", in anx6345_poweroff()
367 err = regulator_disable(anx6345->dvdd12); in anx6345_poweroff()
376 anx6345->powered = false; in anx6345_poweroff()
383 if (!anx6345->powered) in anx6345_start()
387 err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], in anx6345_start()
418 err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL1_REG, in anx6345_config_dp_output()
424 err = anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL1_REG, in anx6345_config_dp_output()
430 return anx6345_set_bits(anx6345->map[I2C_IDX_DPTX], in anx6345_config_dp_output()
440 err = drm_dp_dpcd_readb(&anx6345->aux, DP_SINK_COUNT, &value); in anx6345_get_downstream_info()
448 return -EIO; in anx6345_get_downstream_info()
460 mutex_lock(&anx6345->lock); in anx6345_get_modes()
462 if (!anx6345->edid) { in anx6345_get_modes()
463 if (!anx6345->powered) { in anx6345_get_modes()
474 anx6345->edid = drm_get_edid(connector, &anx6345->aux.ddc); in anx6345_get_modes()
475 if (!anx6345->edid) in anx6345_get_modes()
479 anx6345->edid); in anx6345_get_modes()
486 num_modes += drm_add_edid_modes(connector, anx6345->edid); in anx6345_get_modes()
489 connector->display_info.bpc = 6; in anx6345_get_modes()
495 mutex_unlock(&anx6345->lock); in anx6345_get_modes()
497 if (!num_modes && anx6345->panel) in anx6345_get_modes()
498 num_modes += drm_panel_get_modes(anx6345->panel, connector); in anx6345_get_modes()
529 return -EINVAL; in anx6345_bridge_attach()
532 if (!bridge->encoder) { in anx6345_bridge_attach()
534 return -ENODEV; in anx6345_bridge_attach()
538 anx6345->aux.name = "DP-AUX"; in anx6345_bridge_attach()
539 anx6345->aux.dev = &anx6345->client->dev; in anx6345_bridge_attach()
540 anx6345->aux.transfer = anx6345_aux_transfer; in anx6345_bridge_attach()
542 err = drm_dp_aux_register(&anx6345->aux); in anx6345_bridge_attach()
548 err = drm_connector_init(bridge->dev, &anx6345->connector, in anx6345_bridge_attach()
556 drm_connector_helper_add(&anx6345->connector, in anx6345_bridge_attach()
559 err = drm_connector_register(&anx6345->connector); in anx6345_bridge_attach()
565 anx6345->connector.polled = DRM_CONNECTOR_POLL_HPD; in anx6345_bridge_attach()
567 err = drm_connector_attach_encoder(&anx6345->connector, in anx6345_bridge_attach()
568 bridge->encoder); in anx6345_bridge_attach()
582 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in anx6345_bridge_mode_valid()
586 if (mode->clock > 154000) in anx6345_bridge_mode_valid()
597 anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_POWERDOWN_CTRL_REG, in anx6345_bridge_disable()
599 if (anx6345->panel) in anx6345_bridge_disable()
600 drm_panel_disable(anx6345->panel); in anx6345_bridge_disable()
602 if (anx6345->powered) in anx6345_bridge_disable()
611 if (anx6345->panel) in anx6345_bridge_enable()
612 drm_panel_enable(anx6345->panel); in anx6345_bridge_enable()
636 for (i = 1; i < ARRAY_SIZE(anx6345->i2c_clients); i++) in unregister_i2c_dummy_clients()
637 if (anx6345->i2c_clients[i] && in unregister_i2c_dummy_clients()
638 anx6345->i2c_clients[i]->addr != anx6345->client->addr) in unregister_i2c_dummy_clients()
639 i2c_unregister_device(anx6345->i2c_clients[i]); in unregister_i2c_dummy_clients()
657 if (regmap_read(anx6345->map[I2C_IDX_TXCOM], SP_DEVICE_IDL_REG, &idl)) in anx6345_get_chip_id()
660 if (regmap_read(anx6345->map[I2C_IDX_TXCOM], SP_DEVICE_IDH_REG, &idh)) in anx6345_get_chip_id()
663 anx6345->chipid = (u8)idl | ((u8)idh << 8); in anx6345_get_chip_id()
665 if (regmap_read(anx6345->map[I2C_IDX_TXCOM], SP_DEVICE_VERSION_REG, in anx6345_get_chip_id()
670 if (anx6345->chipid == anx6345_chipid_list[i]) { in anx6345_get_chip_id()
672 anx6345->chipid, version); in anx6345_get_chip_id()
678 anx6345->chipid, version); in anx6345_get_chip_id()
690 anx6345 = devm_kzalloc(&client->dev, sizeof(*anx6345), GFP_KERNEL); in anx6345_i2c_probe()
692 return -ENOMEM; in anx6345_i2c_probe()
694 mutex_init(&anx6345->lock); in anx6345_i2c_probe()
696 anx6345->bridge.of_node = client->dev.of_node; in anx6345_i2c_probe()
698 anx6345->client = client; in anx6345_i2c_probe()
701 dev = &anx6345->client->dev; in anx6345_i2c_probe()
703 err = drm_of_find_panel_or_bridge(client->dev.of_node, 1, 0, in anx6345_i2c_probe()
704 &anx6345->panel, NULL); in anx6345_i2c_probe()
705 if (err == -EPROBE_DEFER) in anx6345_i2c_probe()
712 anx6345->dvdd12 = devm_regulator_get(dev, "dvdd12"); in anx6345_i2c_probe()
713 if (IS_ERR(anx6345->dvdd12)) { in anx6345_i2c_probe()
714 if (PTR_ERR(anx6345->dvdd12) != -EPROBE_DEFER) in anx6345_i2c_probe()
715 DRM_ERROR("Failed to get dvdd12 supply (%ld)\n", in anx6345_i2c_probe()
716 PTR_ERR(anx6345->dvdd12)); in anx6345_i2c_probe()
717 return PTR_ERR(anx6345->dvdd12); in anx6345_i2c_probe()
721 anx6345->dvdd25 = devm_regulator_get(dev, "dvdd25"); in anx6345_i2c_probe()
722 if (IS_ERR(anx6345->dvdd25)) { in anx6345_i2c_probe()
723 if (PTR_ERR(anx6345->dvdd25) != -EPROBE_DEFER) in anx6345_i2c_probe()
724 DRM_ERROR("Failed to get dvdd25 supply (%ld)\n", in anx6345_i2c_probe()
725 PTR_ERR(anx6345->dvdd25)); in anx6345_i2c_probe()
726 return PTR_ERR(anx6345->dvdd25); in anx6345_i2c_probe()
730 anx6345->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in anx6345_i2c_probe()
731 if (IS_ERR(anx6345->gpiod_reset)) { in anx6345_i2c_probe()
733 return PTR_ERR(anx6345->gpiod_reset); in anx6345_i2c_probe()
738 if (anx6345_i2c_addresses[i] >> 1 != client->addr) in anx6345_i2c_probe()
739 anx6345->i2c_clients[i] = i2c_new_dummy_device(client->adapter, in anx6345_i2c_probe()
742 anx6345->i2c_clients[i] = client; in anx6345_i2c_probe()
744 if (IS_ERR(anx6345->i2c_clients[i])) { in anx6345_i2c_probe()
745 err = PTR_ERR(anx6345->i2c_clients[i]); in anx6345_i2c_probe()
751 anx6345->map[i] = devm_regmap_init_i2c(anx6345->i2c_clients[i], in anx6345_i2c_probe()
753 if (IS_ERR(anx6345->map[i])) { in anx6345_i2c_probe()
754 err = PTR_ERR(anx6345->map[i]); in anx6345_i2c_probe()
764 anx6345->bridge.funcs = &anx6345_bridge_funcs; in anx6345_i2c_probe()
765 drm_bridge_add(&anx6345->bridge); in anx6345_i2c_probe()
770 err = -ENODEV; in anx6345_i2c_probe()
782 drm_bridge_remove(&anx6345->bridge); in anx6345_i2c_remove()
786 kfree(anx6345->edid); in anx6345_i2c_remove()
788 mutex_destroy(&anx6345->lock); in anx6345_i2c_remove()