disp: msm: dp: Move required drm_dp_link functions to downstream
On the latest kernel, several drm_dp_link functions were removed. This change moves the functions needed downstream. Change-Id: I0a76c52edff450d8bd33edffb9da41c1933b9681 Signed-off-by: Samantha Tran <samtran@codeaurora.org> Signed-off-by: Nilaan Gunabalachandran <ngunabal@codeaurora.org>
This commit is contained in:

committed by
Nilaan Gunabalachandran

parent
edc49ec57e
commit
c53a07ee48
46
NOTICE
46
NOTICE
@@ -24,6 +24,52 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 Keith Packard
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
* documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
* the above copyright notice appear in all copies and that both that copyright
|
||||||
|
* notice and this permission notice appear in supporting documentation, and
|
||||||
|
* that the name of the copyright holders not be used in advertising or
|
||||||
|
* publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission. The copyright holders make no representations
|
||||||
|
* about the suitability of this software for any purpose. It is provided "as
|
||||||
|
* is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||||
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||||
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2008 Keith Packard
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
* documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
* the above copyright notice appear in all copies and that both that copyright
|
||||||
|
* notice and this permission notice appear in supporting documentation, and
|
||||||
|
* that the name of the copyright holders not be used in advertising or
|
||||||
|
* publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission. The copyright holders make no representations
|
||||||
|
* about the suitability of this software for any purpose. It is provided "as
|
||||||
|
* is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||||
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||||
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright © 2014 Red Hatt.
|
* Copyright © 2014 Red Hatt.
|
||||||
*
|
*
|
||||||
|
@@ -544,7 +544,7 @@ static int dp_ctrl_link_train(struct dp_ctrl_private *ctrl)
|
|||||||
ctrl->link->link_params.bw_code);
|
ctrl->link->link_params.bw_code);
|
||||||
link_info.capabilities = ctrl->panel->link_info.capabilities;
|
link_info.capabilities = ctrl->panel->link_info.capabilities;
|
||||||
|
|
||||||
ret = drm_dp_link_configure(ctrl->aux->drm_aux, &link_info);
|
ret = dp_link_configure(ctrl->aux->drm_aux, &link_info);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
148
msm/dp/dp_link.c
148
msm/dp/dp_link.c
@@ -1,6 +1,26 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
|
* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009 Keith Packard
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
* documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
* the above copyright notice appear in all copies and that both that copyright
|
||||||
|
* notice and this permission notice appear in supporting documentation, and
|
||||||
|
* that the name of the copyright holders not be used in advertising or
|
||||||
|
* publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission. The copyright holders make no representations
|
||||||
|
* about the suitability of this software for any purpose. It is provided "as
|
||||||
|
* is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||||
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||||
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dp_link.h"
|
#include "dp_link.h"
|
||||||
@@ -947,9 +967,9 @@ static int dp_link_psm_config(struct dp_link *dp_link,
|
|||||||
link = container_of(dp_link, struct dp_link_private, dp_link);
|
link = container_of(dp_link, struct dp_link_private, dp_link);
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
ret = drm_dp_link_power_down(link->aux->drm_aux, link_info);
|
ret = dp_link_power_down(link->aux->drm_aux, link_info);
|
||||||
else
|
else
|
||||||
ret = drm_dp_link_power_up(link->aux->drm_aux, link_info);
|
ret = dp_link_power_up(link->aux->drm_aux, link_info);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
DP_ERR("Failed to %s low power mode\n",
|
DP_ERR("Failed to %s low power mode\n",
|
||||||
@@ -1475,6 +1495,130 @@ static u32 dp_link_get_test_bits_depth(struct dp_link *dp_link, u32 bpp)
|
|||||||
return tbd;
|
return tbd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dp_link_probe() - probe a DisplayPort link for capabilities
|
||||||
|
* @aux: DisplayPort AUX channel
|
||||||
|
* @link: pointer to structure in which to return link capabilities
|
||||||
|
*
|
||||||
|
* The structure filled in by this function can usually be passed directly
|
||||||
|
* into dp_link_power_up() and dp_link_configure() to power up and
|
||||||
|
* configure the link based on the link's capabilities.
|
||||||
|
*
|
||||||
|
* Returns 0 on success or a negative error code on failure.
|
||||||
|
*/
|
||||||
|
int dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link)
|
||||||
|
{
|
||||||
|
u8 values[3];
|
||||||
|
int err;
|
||||||
|
|
||||||
|
memset(link, 0, sizeof(*link));
|
||||||
|
|
||||||
|
err = drm_dp_dpcd_read(aux, DP_DPCD_REV, values, sizeof(values));
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
link->revision = values[0];
|
||||||
|
link->rate = drm_dp_bw_code_to_link_rate(values[1]);
|
||||||
|
link->num_lanes = values[2] & DP_MAX_LANE_COUNT_MASK;
|
||||||
|
|
||||||
|
if (values[2] & DP_ENHANCED_FRAME_CAP)
|
||||||
|
link->capabilities |= DP_LINK_CAP_ENHANCED_FRAMING;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dp_link_power_up() - power up a DisplayPort link
|
||||||
|
* @aux: DisplayPort AUX channel
|
||||||
|
* @link: pointer to a structure containing the link configuration
|
||||||
|
*
|
||||||
|
* Returns 0 on success or a negative error code on failure.
|
||||||
|
*/
|
||||||
|
int dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link)
|
||||||
|
{
|
||||||
|
u8 value;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
/* DP_SET_POWER register is only available on DPCD v1.1 and later */
|
||||||
|
if (link->revision < 0x11)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err = drm_dp_dpcd_readb(aux, DP_SET_POWER, &value);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
value &= ~DP_SET_POWER_MASK;
|
||||||
|
value |= DP_SET_POWER_D0;
|
||||||
|
|
||||||
|
err = drm_dp_dpcd_writeb(aux, DP_SET_POWER, value);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* According to the DP 1.1 specification, a "Sink Device must exit the
|
||||||
|
* power saving state within 1 ms" (Section 2.5.3.1, Table 5-52, "Sink
|
||||||
|
* Control Field" (register 0x600).
|
||||||
|
*/
|
||||||
|
usleep_range(1000, 2000);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dp_link_power_down() - power down a DisplayPort link
|
||||||
|
* @aux: DisplayPort AUX channel
|
||||||
|
* @link: pointer to a structure containing the link configuration
|
||||||
|
*
|
||||||
|
* Returns 0 on success or a negative error code on failure.
|
||||||
|
*/
|
||||||
|
int dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link)
|
||||||
|
{
|
||||||
|
u8 value;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
/* DP_SET_POWER register is only available on DPCD v1.1 and later */
|
||||||
|
if (link->revision < 0x11)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err = drm_dp_dpcd_readb(aux, DP_SET_POWER, &value);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
value &= ~DP_SET_POWER_MASK;
|
||||||
|
value |= DP_SET_POWER_D3;
|
||||||
|
|
||||||
|
err = drm_dp_dpcd_writeb(aux, DP_SET_POWER, value);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dp_link_configure() - configure a DisplayPort link
|
||||||
|
* @aux: DisplayPort AUX channel
|
||||||
|
* @link: pointer to a structure containing the link configuration
|
||||||
|
*
|
||||||
|
* Returns 0 on success or a negative error code on failure.
|
||||||
|
*/
|
||||||
|
int dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link)
|
||||||
|
{
|
||||||
|
u8 values[2];
|
||||||
|
int err;
|
||||||
|
|
||||||
|
values[0] = drm_dp_link_rate_to_bw_code(link->rate);
|
||||||
|
values[1] = link->num_lanes;
|
||||||
|
|
||||||
|
if (link->capabilities & DP_LINK_CAP_ENHANCED_FRAMING)
|
||||||
|
values[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
|
||||||
|
|
||||||
|
err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, values, sizeof(values));
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct dp_link *dp_link_get(struct device *dev, struct dp_aux *aux)
|
struct dp_link *dp_link_get(struct device *dev, struct dp_aux *aux)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
@@ -1,6 +1,26 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
|
* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008 Keith Packard
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
* documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
* the above copyright notice appear in all copies and that both that copyright
|
||||||
|
* notice and this permission notice appear in supporting documentation, and
|
||||||
|
* that the name of the copyright holders not be used in advertising or
|
||||||
|
* publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission. The copyright holders make no representations
|
||||||
|
* about the suitability of this software for any purpose. It is provided "as
|
||||||
|
* is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||||
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||||
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||||
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||||
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DP_LINK_H_
|
#ifndef _DP_LINK_H_
|
||||||
@@ -15,6 +35,22 @@
|
|||||||
#define DP_PHY_TEST_PATTERN_CP2520_2 0x6
|
#define DP_PHY_TEST_PATTERN_CP2520_2 0x6
|
||||||
#define DP_PHY_TEST_PATTERN_CP2520_3 0x7
|
#define DP_PHY_TEST_PATTERN_CP2520_3 0x7
|
||||||
|
|
||||||
|
struct drm_dp_aux;
|
||||||
|
|
||||||
|
#define DP_LINK_CAP_ENHANCED_FRAMING (1 << 0)
|
||||||
|
|
||||||
|
struct drm_dp_link {
|
||||||
|
unsigned char revision;
|
||||||
|
unsigned int rate;
|
||||||
|
unsigned int num_lanes;
|
||||||
|
unsigned long capabilities;
|
||||||
|
};
|
||||||
|
|
||||||
|
int dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link);
|
||||||
|
int dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link);
|
||||||
|
int dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link);
|
||||||
|
int dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link);
|
||||||
|
|
||||||
enum dp_link_voltage_level {
|
enum dp_link_voltage_level {
|
||||||
DP_LINK_VOLTAGE_LEVEL_0,
|
DP_LINK_VOLTAGE_LEVEL_0,
|
||||||
DP_LINK_VOLTAGE_LEVEL_1,
|
DP_LINK_VOLTAGE_LEVEL_1,
|
||||||
|
Reference in New Issue
Block a user