Commit c0acb5c5 authored by Thomas Zimmermann's avatar Thomas Zimmermann
Browse files

drm/ast: astdp: Replace power_on helpers



Replace the helper for controlling power on the physical connector,
ast_dp_power_on_off(), with ast_dp_set_phy_sleep(). The new name
reflects the effect of the operation. Simplify the implementation.
The call now controls sleeping, hence semantics are inversed. Each
'on' becomes an 'off' operation and vice versa.

Do the same for ast_dp_power_is_on() and also align naming of the
register constant with the rest of the code.

Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240911115347.899148-4-tzimmermann@suse.de
parent 2fc2d1ad
Loading
Loading
Loading
Loading
+17 −22
Original line number Diff line number Diff line
@@ -149,27 +149,22 @@ int ast_dp_launch(struct ast_device *ast)
	return 0;
}

static bool ast_dp_power_is_on(struct ast_device *ast)
static bool ast_dp_get_phy_sleep(struct ast_device *ast)
{
	u8 vgacre3;
	u8 vgacre3 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xe3);

	vgacre3 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xe3);

	return !(vgacre3 & AST_DP_PHY_SLEEP);
	return (vgacre3 & AST_IO_VGACRE3_DP_PHY_SLEEP);
}

static void ast_dp_power_on_off(struct ast_device *ast, bool on)
static void ast_dp_set_phy_sleep(struct ast_device *ast, bool sleep)
{
	// Read and Turn off DP PHY sleep
	u8 bE3 = ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, AST_DP_VIDEO_ENABLE);

	// Turn on DP PHY sleep
	if (!on)
		bE3 |= AST_DP_PHY_SLEEP;
	u8 vgacre3 = 0x00;

	// DP Power on/off
	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_PHY_SLEEP, bE3);
	if (sleep)
		vgacre3 |= AST_IO_VGACRE3_DP_PHY_SLEEP;

	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xe3, (u8)~AST_IO_VGACRE3_DP_PHY_SLEEP,
			       vgacre3);
	msleep(50);
}

@@ -319,7 +314,7 @@ static void ast_astdp_encoder_helper_atomic_enable(struct drm_encoder *encoder,
	struct ast_connector *ast_connector = &ast->output.astdp.connector;

	if (ast_connector->physical_status == connector_status_connected) {
		ast_dp_power_on_off(ast, AST_DP_POWER_ON);
		ast_dp_set_phy_sleep(ast, false);
		ast_dp_link_training(ast);

		ast_wait_for_vretrace(ast);
@@ -333,7 +328,7 @@ static void ast_astdp_encoder_helper_atomic_disable(struct drm_encoder *encoder,
	struct ast_device *ast = to_ast_device(encoder->dev);

	ast_dp_set_on_off(ast, 0);
	ast_dp_power_on_off(ast, AST_DP_POWER_OFF);
	ast_dp_set_phy_sleep(ast, true);
}

static const struct drm_encoder_helper_funcs ast_astdp_encoder_helper_funcs = {
@@ -382,19 +377,19 @@ static int ast_astdp_connector_helper_detect_ctx(struct drm_connector *connector
	struct ast_connector *ast_connector = to_ast_connector(connector);
	struct ast_device *ast = to_ast_device(connector->dev);
	enum drm_connector_status status = connector_status_disconnected;
	bool power_is_on;
	bool phy_sleep;

	mutex_lock(&ast->modeset_lock);

	power_is_on = ast_dp_power_is_on(ast);
	if (!power_is_on)
		ast_dp_power_on_off(ast, true);
	phy_sleep = ast_dp_get_phy_sleep(ast);
	if (phy_sleep)
		ast_dp_set_phy_sleep(ast, false);

	if (ast_astdp_is_connected(ast))
		status = connector_status_connected;

	if (!power_is_on && status == connector_status_disconnected)
		ast_dp_power_on_off(ast, false);
	if (phy_sleep && status == connector_status_disconnected)
		ast_dp_set_phy_sleep(ast, true);

	mutex_unlock(&ast->modeset_lock);

+0 −3
Original line number Diff line number Diff line
@@ -403,9 +403,6 @@ int ast_mode_config_init(struct ast_device *ast);
#define AST_DP501_LINKRATE	0xf014
#define AST_DP501_EDID_DATA	0xf020

#define AST_DP_POWER_ON			true
#define AST_DP_POWER_OFF			false

/*
 * ASTDP resoultion table:
 * EX:	ASTDP_A_B_C:
+1 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#define AST_IO_VGACRD7_EDID_VALID_FLAG	BIT(0)
#define AST_IO_VGACRDC_LINK_SUCCESS	BIT(0)
#define AST_IO_VGACRDF_HPD		BIT(0)
#define AST_IO_VGACRE3_DP_PHY_SLEEP	BIT(4)
#define AST_IO_VGACRE5_EDID_READ_DONE	BIT(0)

#define AST_IO_VGAIR1_R			(0x5A)
@@ -69,7 +70,6 @@
 */

/* Define for Soc scratched reg used on ASTDP */
#define AST_DP_PHY_SLEEP		BIT(4)
#define AST_DP_VIDEO_ENABLE		BIT(0)

/*