Lines Matching +full:vdd12 +full:- +full:supply

1 /* SPDX-License-Identifier: GPL-2.0-only */
31 #include "analogix-i2c-dptx.h"
32 #include "analogix-i2c-txcommon.h"
93 return anx_dp_aux_transfer(anx6345->map[I2C_IDX_DPTX], msg); in anx6345_aux_transfer()
102 err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], in anx6345_dp_link_training()
108 err = drm_dp_dpcd_readb(&anx6345->aux, DP_MAX_LINK_RATE, &dp_bw); in anx6345_dp_link_training()
119 return -EINVAL; in anx6345_dp_link_training()
122 err = anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL1_REG, in anx6345_dp_link_training()
127 err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], in anx6345_dp_link_training()
133 err = drm_dp_dpcd_read(&anx6345->aux, DP_DPCD_REV, in anx6345_dp_link_training()
134 &anx6345->dpcd, DP_RECEIVER_CAP_SIZE); in anx6345_dp_link_training()
141 err = anx6345_clear_bits(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
150 if (anx6345->dpcd[DP_DPCD_REV] >= 0x11) { in anx6345_dp_link_training()
151 err = drm_dp_dpcd_readb(&anx6345->aux, DP_SET_POWER, &dpcd[0]); in anx6345_dp_link_training()
161 err = drm_dp_dpcd_writeb(&anx6345->aux, DP_SET_POWER, dpcd[0]); in anx6345_dp_link_training()
171 * Table 5-52, "Sink Control Field" (register 0x600). in anx6345_dp_link_training()
177 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
182 if (anx6345->dpcd[DP_MAX_DOWNSPREAD] & DP_MAX_DOWNSPREAD_0_5) { in anx6345_dp_link_training()
185 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
190 err = drm_dp_dpcd_writeb(&anx6345->aux, DP_DOWNSPREAD_CTRL, in anx6345_dp_link_training()
195 err = drm_dp_dpcd_writeb(&anx6345->aux, DP_DOWNSPREAD_CTRL, 0); in anx6345_dp_link_training()
201 if (drm_dp_enhanced_frame_cap(anx6345->dpcd)) in anx6345_dp_link_training()
202 err = anx6345_set_bits(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
206 err = anx6345_clear_bits(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
213 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
218 dpcd[1] = drm_dp_max_lane_count(anx6345->dpcd); in anx6345_dp_link_training()
220 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
225 if (drm_dp_enhanced_frame_cap(anx6345->dpcd)) in anx6345_dp_link_training()
228 err = drm_dp_dpcd_write(&anx6345->aux, DP_LINK_BW_SET, dpcd, in anx6345_dp_link_training()
237 err = regmap_write(anx6345->map[I2C_IDX_DPTX], SP_DP_LT_CTRL_REG, in anx6345_dp_link_training()
242 return regmap_read_poll_timeout(anx6345->map[I2C_IDX_DPTX], in anx6345_dp_link_training()
253 err = regmap_write(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL2_REG, in anx6345_tx_initialization()
258 err = regmap_write(anx6345->map[I2C_IDX_DPTX], SP_DP_PLL_CTRL_REG, 0); in anx6345_tx_initialization()
262 err = regmap_write(anx6345->map[I2C_IDX_TXCOM], in anx6345_tx_initialization()
267 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_tx_initialization()
273 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_tx_initialization()
279 err = anx6345_set_bits(anx6345->map[I2C_IDX_DPTX], in anx6345_tx_initialization()
287 err = regmap_write(anx6345->map[I2C_IDX_DPTX], in anx6345_tx_initialization()
294 err = anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], in anx6345_tx_initialization()
299 return anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], in anx6345_tx_initialization()
308 gpiod_set_value_cansleep(anx6345->gpiod_reset, 1); in anx6345_poweron()
311 err = regulator_enable(anx6345->dvdd12); in anx6345_poweron()
318 /* T1 - delay between VDD12 and VDD25 should be 0-2ms */ in anx6345_poweron()
321 err = regulator_enable(anx6345->dvdd25); in anx6345_poweron()
328 /* T2 - delay between RESETN and all power rail stable, in anx6345_poweron()
329 * should be 2-5ms in anx6345_poweron()
333 gpiod_set_value_cansleep(anx6345->gpiod_reset, 0); in anx6345_poweron()
336 anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_POWERDOWN_CTRL_REG, in anx6345_poweron()
338 anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], SP_POWERDOWN_CTRL_REG, in anx6345_poweron()
341 if (anx6345->panel) in anx6345_poweron()
342 drm_panel_prepare(anx6345->panel); in anx6345_poweron()
344 anx6345->powered = true; in anx6345_poweron()
351 gpiod_set_value_cansleep(anx6345->gpiod_reset, 1); in anx6345_poweroff()
354 if (anx6345->panel) in anx6345_poweroff()
355 drm_panel_unprepare(anx6345->panel); in anx6345_poweroff()
357 err = regulator_disable(anx6345->dvdd25); in anx6345_poweroff()
366 err = regulator_disable(anx6345->dvdd12); in anx6345_poweroff()
375 anx6345->powered = false; in anx6345_poweroff()
382 if (!anx6345->powered) in anx6345_start()
386 err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], in anx6345_start()
417 err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL1_REG, in anx6345_config_dp_output()
423 err = anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL1_REG, in anx6345_config_dp_output()
429 return anx6345_set_bits(anx6345->map[I2C_IDX_DPTX], in anx6345_config_dp_output()
439 err = drm_dp_dpcd_readb(&anx6345->aux, DP_SINK_COUNT, &value); in anx6345_get_downstream_info()
447 return -EIO; in anx6345_get_downstream_info()
459 mutex_lock(&anx6345->lock); in anx6345_get_modes()
461 if (!anx6345->edid) { in anx6345_get_modes()
462 if (!anx6345->powered) { in anx6345_get_modes()
473 anx6345->edid = drm_get_edid(connector, &anx6345->aux.ddc); in anx6345_get_modes()
474 if (!anx6345->edid) in anx6345_get_modes()
478 anx6345->edid); in anx6345_get_modes()
485 num_modes += drm_add_edid_modes(connector, anx6345->edid); in anx6345_get_modes()
488 connector->display_info.bpc = 6; in anx6345_get_modes()
494 mutex_unlock(&anx6345->lock); in anx6345_get_modes()
496 if (!num_modes && anx6345->panel) in anx6345_get_modes()
497 num_modes += drm_panel_get_modes(anx6345->panel, connector); in anx6345_get_modes()
528 return -EINVAL; in anx6345_bridge_attach()
531 if (!bridge->encoder) { in anx6345_bridge_attach()
533 return -ENODEV; in anx6345_bridge_attach()
537 anx6345->aux.name = "DP-AUX"; in anx6345_bridge_attach()
538 anx6345->aux.dev = &anx6345->client->dev; in anx6345_bridge_attach()
539 anx6345->aux.drm_dev = bridge->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 anx6345->connector.polled = DRM_CONNECTOR_POLL_HPD; in anx6345_bridge_attach()
561 err = drm_connector_attach_encoder(&anx6345->connector, in anx6345_bridge_attach()
562 bridge->encoder); in anx6345_bridge_attach()
568 err = drm_connector_register(&anx6345->connector); in anx6345_bridge_attach()
576 drm_connector_cleanup(&anx6345->connector); in anx6345_bridge_attach()
578 drm_dp_aux_unregister(&anx6345->aux); in anx6345_bridge_attach()
584 drm_dp_aux_unregister(&bridge_to_anx6345(bridge)->aux); in anx6345_bridge_detach()
592 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in anx6345_bridge_mode_valid()
596 if (mode->clock > 154000) in anx6345_bridge_mode_valid()
607 anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_POWERDOWN_CTRL_REG, in anx6345_bridge_disable()
609 if (anx6345->panel) in anx6345_bridge_disable()
610 drm_panel_disable(anx6345->panel); in anx6345_bridge_disable()
612 if (anx6345->powered) in anx6345_bridge_disable()
621 if (anx6345->panel) in anx6345_bridge_enable()
622 drm_panel_enable(anx6345->panel); in anx6345_bridge_enable()
647 for (i = 1; i < ARRAY_SIZE(anx6345->i2c_clients); i++) in unregister_i2c_dummy_clients()
648 if (anx6345->i2c_clients[i] && in unregister_i2c_dummy_clients()
649 anx6345->i2c_clients[i]->addr != anx6345->client->addr) in unregister_i2c_dummy_clients()
650 i2c_unregister_device(anx6345->i2c_clients[i]); in unregister_i2c_dummy_clients()
668 if (regmap_read(anx6345->map[I2C_IDX_TXCOM], SP_DEVICE_IDL_REG, &idl)) in anx6345_get_chip_id()
671 if (regmap_read(anx6345->map[I2C_IDX_TXCOM], SP_DEVICE_IDH_REG, &idh)) in anx6345_get_chip_id()
674 anx6345->chipid = (u8)idl | ((u8)idh << 8); in anx6345_get_chip_id()
676 if (regmap_read(anx6345->map[I2C_IDX_TXCOM], SP_DEVICE_VERSION_REG, in anx6345_get_chip_id()
681 if (anx6345->chipid == anx6345_chipid_list[i]) { in anx6345_get_chip_id()
683 anx6345->chipid, version); in anx6345_get_chip_id()
689 anx6345->chipid, version); in anx6345_get_chip_id()
700 anx6345 = devm_kzalloc(&client->dev, sizeof(*anx6345), GFP_KERNEL); in anx6345_i2c_probe()
702 return -ENOMEM; in anx6345_i2c_probe()
704 mutex_init(&anx6345->lock); in anx6345_i2c_probe()
706 anx6345->bridge.of_node = client->dev.of_node; in anx6345_i2c_probe()
708 anx6345->client = client; in anx6345_i2c_probe()
711 dev = &anx6345->client->dev; in anx6345_i2c_probe()
713 err = drm_of_find_panel_or_bridge(client->dev.of_node, 1, 0, in anx6345_i2c_probe()
714 &anx6345->panel, NULL); in anx6345_i2c_probe()
715 if (err == -EPROBE_DEFER) in anx6345_i2c_probe()
722 anx6345->dvdd12 = devm_regulator_get(dev, "dvdd12"); in anx6345_i2c_probe()
723 if (IS_ERR(anx6345->dvdd12)) { in anx6345_i2c_probe()
724 if (PTR_ERR(anx6345->dvdd12) != -EPROBE_DEFER) in anx6345_i2c_probe()
725 DRM_ERROR("Failed to get dvdd12 supply (%ld)\n", in anx6345_i2c_probe()
726 PTR_ERR(anx6345->dvdd12)); in anx6345_i2c_probe()
727 return PTR_ERR(anx6345->dvdd12); in anx6345_i2c_probe()
731 anx6345->dvdd25 = devm_regulator_get(dev, "dvdd25"); in anx6345_i2c_probe()
732 if (IS_ERR(anx6345->dvdd25)) { in anx6345_i2c_probe()
733 if (PTR_ERR(anx6345->dvdd25) != -EPROBE_DEFER) in anx6345_i2c_probe()
734 DRM_ERROR("Failed to get dvdd25 supply (%ld)\n", in anx6345_i2c_probe()
735 PTR_ERR(anx6345->dvdd25)); in anx6345_i2c_probe()
736 return PTR_ERR(anx6345->dvdd25); in anx6345_i2c_probe()
740 anx6345->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in anx6345_i2c_probe()
741 if (IS_ERR(anx6345->gpiod_reset)) { in anx6345_i2c_probe()
743 return PTR_ERR(anx6345->gpiod_reset); in anx6345_i2c_probe()
748 if (anx6345_i2c_addresses[i] >> 1 != client->addr) in anx6345_i2c_probe()
749 anx6345->i2c_clients[i] = i2c_new_dummy_device(client->adapter, in anx6345_i2c_probe()
752 anx6345->i2c_clients[i] = client; in anx6345_i2c_probe()
754 if (IS_ERR(anx6345->i2c_clients[i])) { in anx6345_i2c_probe()
755 err = PTR_ERR(anx6345->i2c_clients[i]); in anx6345_i2c_probe()
761 anx6345->map[i] = devm_regmap_init_i2c(anx6345->i2c_clients[i], in anx6345_i2c_probe()
763 if (IS_ERR(anx6345->map[i])) { in anx6345_i2c_probe()
764 err = PTR_ERR(anx6345->map[i]); in anx6345_i2c_probe()
774 anx6345->bridge.funcs = &anx6345_bridge_funcs; in anx6345_i2c_probe()
775 drm_bridge_add(&anx6345->bridge); in anx6345_i2c_probe()
780 err = -ENODEV; in anx6345_i2c_probe()
792 drm_bridge_remove(&anx6345->bridge); in anx6345_i2c_remove()
796 kfree(anx6345->edid); in anx6345_i2c_remove()
798 mutex_destroy(&anx6345->lock); in anx6345_i2c_remove()