|
@@ -31,10 +31,11 @@
|
|
|
#include <sound/hdmi-codec.h>
|
|
#include <sound/hdmi-codec.h>
|
|
|
|
|
|
|
|
#include "cdn-dp-core.h"
|
|
#include "cdn-dp-core.h"
|
|
|
|
|
+#include "cdn-dp-reg.h"
|
|
|
#include "rockchip_drm_vop.h"
|
|
#include "rockchip_drm_vop.h"
|
|
|
|
|
|
|
|
#define connector_to_dp(c) \
|
|
#define connector_to_dp(c) \
|
|
|
- container_of(c, struct cdn_dp_device, mhdp.connector.base)
|
|
|
|
|
|
|
+ container_of(c, struct cdn_dp_device, connector)
|
|
|
|
|
|
|
|
#define encoder_to_dp(c) \
|
|
#define encoder_to_dp(c) \
|
|
|
container_of(c, struct cdn_dp_device, encoder)
|
|
container_of(c, struct cdn_dp_device, encoder)
|
|
@@ -69,18 +70,17 @@ MODULE_DEVICE_TABLE(of, cdn_dp_dt_ids);
|
|
|
static int cdn_dp_grf_write(struct cdn_dp_device *dp,
|
|
static int cdn_dp_grf_write(struct cdn_dp_device *dp,
|
|
|
unsigned int reg, unsigned int val)
|
|
unsigned int reg, unsigned int val)
|
|
|
{
|
|
{
|
|
|
- struct device *dev = dp->mhdp.dev;
|
|
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
ret = clk_prepare_enable(dp->grf_clk);
|
|
ret = clk_prepare_enable(dp->grf_clk);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "Failed to prepare_enable grf clock\n");
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Failed to prepare_enable grf clock\n");
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ret = regmap_write(dp->grf, reg, val);
|
|
ret = regmap_write(dp->grf, reg, val);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "Could not write to GRF: %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Could not write to GRF: %d\n", ret);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -91,25 +91,24 @@ static int cdn_dp_grf_write(struct cdn_dp_device *dp,
|
|
|
|
|
|
|
|
static int cdn_dp_clk_enable(struct cdn_dp_device *dp)
|
|
static int cdn_dp_clk_enable(struct cdn_dp_device *dp)
|
|
|
{
|
|
{
|
|
|
- struct device *dev = dp->mhdp.dev;
|
|
|
|
|
int ret;
|
|
int ret;
|
|
|
unsigned long rate;
|
|
unsigned long rate;
|
|
|
|
|
|
|
|
ret = clk_prepare_enable(dp->pclk);
|
|
ret = clk_prepare_enable(dp->pclk);
|
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
|
- DRM_DEV_ERROR(dev, "cannot enable dp pclk %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "cannot enable dp pclk %d\n", ret);
|
|
|
goto err_pclk;
|
|
goto err_pclk;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ret = clk_prepare_enable(dp->core_clk);
|
|
ret = clk_prepare_enable(dp->core_clk);
|
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
|
- DRM_DEV_ERROR(dev, "cannot enable core_clk %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "cannot enable core_clk %d\n", ret);
|
|
|
goto err_core_clk;
|
|
goto err_core_clk;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ret = pm_runtime_get_sync(dev);
|
|
|
|
|
|
|
+ ret = pm_runtime_get_sync(dp->dev);
|
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
|
- DRM_DEV_ERROR(dev, "cannot get pm runtime %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "cannot get pm runtime %d\n", ret);
|
|
|
goto err_pm_runtime_get;
|
|
goto err_pm_runtime_get;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -122,18 +121,18 @@ static int cdn_dp_clk_enable(struct cdn_dp_device *dp)
|
|
|
|
|
|
|
|
rate = clk_get_rate(dp->core_clk);
|
|
rate = clk_get_rate(dp->core_clk);
|
|
|
if (!rate) {
|
|
if (!rate) {
|
|
|
- DRM_DEV_ERROR(dev, "get clk rate failed\n");
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "get clk rate failed\n");
|
|
|
ret = -EINVAL;
|
|
ret = -EINVAL;
|
|
|
goto err_set_rate;
|
|
goto err_set_rate;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- cdns_mhdp_set_fw_clk(&dp->mhdp, rate);
|
|
|
|
|
- cdns_mhdp_clock_reset(&dp->mhdp);
|
|
|
|
|
|
|
+ cdn_dp_set_fw_clk(dp, rate);
|
|
|
|
|
+ cdn_dp_clock_reset(dp);
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
err_set_rate:
|
|
err_set_rate:
|
|
|
- pm_runtime_put(dev);
|
|
|
|
|
|
|
+ pm_runtime_put(dp->dev);
|
|
|
err_pm_runtime_get:
|
|
err_pm_runtime_get:
|
|
|
clk_disable_unprepare(dp->core_clk);
|
|
clk_disable_unprepare(dp->core_clk);
|
|
|
err_core_clk:
|
|
err_core_clk:
|
|
@@ -144,7 +143,7 @@ err_pclk:
|
|
|
|
|
|
|
|
static void cdn_dp_clk_disable(struct cdn_dp_device *dp)
|
|
static void cdn_dp_clk_disable(struct cdn_dp_device *dp)
|
|
|
{
|
|
{
|
|
|
- pm_runtime_put_sync(dp->mhdp.dev);
|
|
|
|
|
|
|
+ pm_runtime_put_sync(dp->dev);
|
|
|
clk_disable_unprepare(dp->pclk);
|
|
clk_disable_unprepare(dp->pclk);
|
|
|
clk_disable_unprepare(dp->core_clk);
|
|
clk_disable_unprepare(dp->core_clk);
|
|
|
}
|
|
}
|
|
@@ -177,7 +176,7 @@ static int cdn_dp_get_sink_count(struct cdn_dp_device *dp, u8 *sink_count)
|
|
|
u8 value;
|
|
u8 value;
|
|
|
|
|
|
|
|
*sink_count = 0;
|
|
*sink_count = 0;
|
|
|
- ret = cdns_mhdp_dpcd_read(&dp->mhdp, DP_SINK_COUNT, &value, 1);
|
|
|
|
|
|
|
+ ret = cdn_dp_dpcd_read(dp, DP_SINK_COUNT, &value, 1);
|
|
|
if (ret)
|
|
if (ret)
|
|
|
return ret;
|
|
return ret;
|
|
|
|
|
|
|
@@ -201,13 +200,12 @@ static struct cdn_dp_port *cdn_dp_connected_port(struct cdn_dp_device *dp)
|
|
|
|
|
|
|
|
static bool cdn_dp_check_sink_connection(struct cdn_dp_device *dp)
|
|
static bool cdn_dp_check_sink_connection(struct cdn_dp_device *dp)
|
|
|
{
|
|
{
|
|
|
- struct device *dev = dp->mhdp.dev;
|
|
|
|
|
unsigned long timeout = jiffies + msecs_to_jiffies(CDN_DPCD_TIMEOUT_MS);
|
|
unsigned long timeout = jiffies + msecs_to_jiffies(CDN_DPCD_TIMEOUT_MS);
|
|
|
struct cdn_dp_port *port;
|
|
struct cdn_dp_port *port;
|
|
|
u8 sink_count = 0;
|
|
u8 sink_count = 0;
|
|
|
|
|
|
|
|
if (dp->active_port < 0 || dp->active_port >= dp->ports) {
|
|
if (dp->active_port < 0 || dp->active_port >= dp->ports) {
|
|
|
- DRM_DEV_ERROR(dev, "active_port is wrong!\n");
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "active_port is wrong!\n");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -229,7 +227,7 @@ static bool cdn_dp_check_sink_connection(struct cdn_dp_device *dp)
|
|
|
usleep_range(5000, 10000);
|
|
usleep_range(5000, 10000);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- DRM_DEV_ERROR(dev, "Get sink capability timed out\n");
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Get sink capability timed out\n");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -271,8 +269,7 @@ static int cdn_dp_connector_get_modes(struct drm_connector *connector)
|
|
|
mutex_lock(&dp->lock);
|
|
mutex_lock(&dp->lock);
|
|
|
edid = dp->edid;
|
|
edid = dp->edid;
|
|
|
if (edid) {
|
|
if (edid) {
|
|
|
- DRM_DEV_DEBUG_KMS(dp->mhdp.dev,
|
|
|
|
|
- "got edid: width[%d] x height[%d]\n",
|
|
|
|
|
|
|
+ DRM_DEV_DEBUG_KMS(dp->dev, "got edid: width[%d] x height[%d]\n",
|
|
|
edid->width_cm, edid->height_cm);
|
|
edid->width_cm, edid->height_cm);
|
|
|
|
|
|
|
|
dp->sink_has_audio = drm_detect_monitor_audio(edid);
|
|
dp->sink_has_audio = drm_detect_monitor_audio(edid);
|
|
@@ -290,8 +287,7 @@ static int cdn_dp_connector_mode_valid(struct drm_connector *connector,
|
|
|
struct drm_display_mode *mode)
|
|
struct drm_display_mode *mode)
|
|
|
{
|
|
{
|
|
|
struct cdn_dp_device *dp = connector_to_dp(connector);
|
|
struct cdn_dp_device *dp = connector_to_dp(connector);
|
|
|
- struct drm_display_info *display_info =
|
|
|
|
|
- &dp->mhdp.connector.base.display_info;
|
|
|
|
|
|
|
+ struct drm_display_info *display_info = &dp->connector.display_info;
|
|
|
u32 requested, actual, rate, sink_max, source_max = 0;
|
|
u32 requested, actual, rate, sink_max, source_max = 0;
|
|
|
u8 lanes, bpc;
|
|
u8 lanes, bpc;
|
|
|
|
|
|
|
@@ -317,7 +313,7 @@ static int cdn_dp_connector_mode_valid(struct drm_connector *connector,
|
|
|
sink_max = drm_dp_max_lane_count(dp->dpcd);
|
|
sink_max = drm_dp_max_lane_count(dp->dpcd);
|
|
|
lanes = min(source_max, sink_max);
|
|
lanes = min(source_max, sink_max);
|
|
|
|
|
|
|
|
- source_max = drm_dp_bw_code_to_link_rate(CDNS_DP_MAX_LINK_RATE);
|
|
|
|
|
|
|
+ source_max = drm_dp_bw_code_to_link_rate(CDN_DP_MAX_LINK_RATE);
|
|
|
sink_max = drm_dp_max_link_rate(dp->dpcd);
|
|
sink_max = drm_dp_max_link_rate(dp->dpcd);
|
|
|
rate = min(source_max, sink_max);
|
|
rate = min(source_max, sink_max);
|
|
|
|
|
|
|
@@ -327,7 +323,7 @@ static int cdn_dp_connector_mode_valid(struct drm_connector *connector,
|
|
|
actual = actual * 8 / 10;
|
|
actual = actual * 8 / 10;
|
|
|
|
|
|
|
|
if (requested > actual) {
|
|
if (requested > actual) {
|
|
|
- DRM_DEV_DEBUG_KMS(dp->mhdp.dev,
|
|
|
|
|
|
|
+ DRM_DEV_DEBUG_KMS(dp->dev,
|
|
|
"requested=%d, actual=%d, clock=%d\n",
|
|
"requested=%d, actual=%d, clock=%d\n",
|
|
|
requested, actual, mode->clock);
|
|
requested, actual, mode->clock);
|
|
|
return MODE_CLOCK_HIGH;
|
|
return MODE_CLOCK_HIGH;
|
|
@@ -347,29 +343,28 @@ static int cdn_dp_firmware_init(struct cdn_dp_device *dp)
|
|
|
const u32 *iram_data, *dram_data;
|
|
const u32 *iram_data, *dram_data;
|
|
|
const struct firmware *fw = dp->fw;
|
|
const struct firmware *fw = dp->fw;
|
|
|
const struct cdn_firmware_header *hdr;
|
|
const struct cdn_firmware_header *hdr;
|
|
|
- struct device *dev = dp->mhdp.dev;
|
|
|
|
|
|
|
|
|
|
hdr = (struct cdn_firmware_header *)fw->data;
|
|
hdr = (struct cdn_firmware_header *)fw->data;
|
|
|
if (fw->size != le32_to_cpu(hdr->size_bytes)) {
|
|
if (fw->size != le32_to_cpu(hdr->size_bytes)) {
|
|
|
- DRM_DEV_ERROR(dev, "firmware is invalid\n");
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "firmware is invalid\n");
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
iram_data = (const u32 *)(fw->data + hdr->header_size);
|
|
iram_data = (const u32 *)(fw->data + hdr->header_size);
|
|
|
dram_data = (const u32 *)(fw->data + hdr->header_size + hdr->iram_size);
|
|
dram_data = (const u32 *)(fw->data + hdr->header_size + hdr->iram_size);
|
|
|
|
|
|
|
|
- ret = cdns_mhdp_load_firmware(&dp->mhdp, iram_data, hdr->iram_size,
|
|
|
|
|
- dram_data, hdr->dram_size);
|
|
|
|
|
|
|
+ ret = cdn_dp_load_firmware(dp, iram_data, hdr->iram_size,
|
|
|
|
|
+ dram_data, hdr->dram_size);
|
|
|
if (ret)
|
|
if (ret)
|
|
|
return ret;
|
|
return ret;
|
|
|
|
|
|
|
|
- ret = cdns_mhdp_set_firmware_active(&dp->mhdp, true);
|
|
|
|
|
|
|
+ ret = cdn_dp_set_firmware_active(dp, true);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "active ucpu failed: %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "active ucpu failed: %d\n", ret);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return cdns_mhdp_event_config(&dp->mhdp);
|
|
|
|
|
|
|
+ return cdn_dp_event_config(dp);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static int cdn_dp_get_sink_capability(struct cdn_dp_device *dp)
|
|
static int cdn_dp_get_sink_capability(struct cdn_dp_device *dp)
|
|
@@ -379,29 +374,28 @@ static int cdn_dp_get_sink_capability(struct cdn_dp_device *dp)
|
|
|
if (!cdn_dp_check_sink_connection(dp))
|
|
if (!cdn_dp_check_sink_connection(dp))
|
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
- ret = cdns_mhdp_dpcd_read(&dp->mhdp, DP_DPCD_REV, dp->dpcd,
|
|
|
|
|
- DP_RECEIVER_CAP_SIZE);
|
|
|
|
|
|
|
+ ret = cdn_dp_dpcd_read(dp, DP_DPCD_REV, dp->dpcd,
|
|
|
|
|
+ DP_RECEIVER_CAP_SIZE);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dp->mhdp.dev, "Failed to get caps %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Failed to get caps %d\n", ret);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
kfree(dp->edid);
|
|
kfree(dp->edid);
|
|
|
- dp->edid = drm_do_get_edid(&dp->mhdp.connector.base,
|
|
|
|
|
- cdns_mhdp_get_edid_block, &dp->mhdp);
|
|
|
|
|
|
|
+ dp->edid = drm_do_get_edid(&dp->connector,
|
|
|
|
|
+ cdn_dp_get_edid_block, dp);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct cdn_dp_port *port)
|
|
static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct cdn_dp_port *port)
|
|
|
{
|
|
{
|
|
|
- struct device *dev = dp->mhdp.dev;
|
|
|
|
|
union extcon_property_value property;
|
|
union extcon_property_value property;
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
if (!port->phy_enabled) {
|
|
if (!port->phy_enabled) {
|
|
|
ret = phy_power_on(port->phy);
|
|
ret = phy_power_on(port->phy);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "phy power on failed: %d\n",
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "phy power on failed: %d\n",
|
|
|
ret);
|
|
ret);
|
|
|
goto err_phy;
|
|
goto err_phy;
|
|
|
}
|
|
}
|
|
@@ -411,28 +405,28 @@ static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct cdn_dp_port *port)
|
|
|
ret = cdn_dp_grf_write(dp, GRF_SOC_CON26,
|
|
ret = cdn_dp_grf_write(dp, GRF_SOC_CON26,
|
|
|
DPTX_HPD_SEL_MASK | DPTX_HPD_SEL);
|
|
DPTX_HPD_SEL_MASK | DPTX_HPD_SEL);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "Failed to write HPD_SEL %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Failed to write HPD_SEL %d\n", ret);
|
|
|
goto err_power_on;
|
|
goto err_power_on;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ret = cdns_mhdp_get_hpd_status(&dp->mhdp);
|
|
|
|
|
|
|
+ ret = cdn_dp_get_hpd_status(dp);
|
|
|
if (ret <= 0) {
|
|
if (ret <= 0) {
|
|
|
if (!ret)
|
|
if (!ret)
|
|
|
- DRM_DEV_ERROR(dev, "hpd does not exist\n");
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "hpd does not exist\n");
|
|
|
goto err_power_on;
|
|
goto err_power_on;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ret = extcon_get_property(port->extcon, EXTCON_DISP_DP,
|
|
ret = extcon_get_property(port->extcon, EXTCON_DISP_DP,
|
|
|
EXTCON_PROP_USB_TYPEC_POLARITY, &property);
|
|
EXTCON_PROP_USB_TYPEC_POLARITY, &property);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "get property failed\n");
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "get property failed\n");
|
|
|
goto err_power_on;
|
|
goto err_power_on;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
port->lanes = cdn_dp_get_port_lanes(port);
|
|
port->lanes = cdn_dp_get_port_lanes(port);
|
|
|
- ret = cdns_mhdp_set_host_cap(&dp->mhdp, port->lanes, property.intval);
|
|
|
|
|
|
|
+ ret = cdn_dp_set_host_cap(dp, port->lanes, property.intval);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "set host capabilities failed: %d\n",
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "set host capabilities failed: %d\n",
|
|
|
ret);
|
|
ret);
|
|
|
goto err_power_on;
|
|
goto err_power_on;
|
|
|
}
|
|
}
|
|
@@ -442,7 +436,7 @@ static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct cdn_dp_port *port)
|
|
|
|
|
|
|
|
err_power_on:
|
|
err_power_on:
|
|
|
if (phy_power_off(port->phy))
|
|
if (phy_power_off(port->phy))
|
|
|
- DRM_DEV_ERROR(dev, "phy power off failed: %d", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "phy power off failed: %d", ret);
|
|
|
else
|
|
else
|
|
|
port->phy_enabled = false;
|
|
port->phy_enabled = false;
|
|
|
|
|
|
|
@@ -460,8 +454,7 @@ static int cdn_dp_disable_phy(struct cdn_dp_device *dp,
|
|
|
if (port->phy_enabled) {
|
|
if (port->phy_enabled) {
|
|
|
ret = phy_power_off(port->phy);
|
|
ret = phy_power_off(port->phy);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dp->mhdp.dev,
|
|
|
|
|
- "phy power off failed: %d", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "phy power off failed: %d", ret);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -485,16 +478,16 @@ static int cdn_dp_disable(struct cdn_dp_device *dp)
|
|
|
ret = cdn_dp_grf_write(dp, GRF_SOC_CON26,
|
|
ret = cdn_dp_grf_write(dp, GRF_SOC_CON26,
|
|
|
DPTX_HPD_SEL_MASK | DPTX_HPD_DEL);
|
|
DPTX_HPD_SEL_MASK | DPTX_HPD_DEL);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dp->mhdp.dev, "Failed to clear hpd sel %d\n",
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Failed to clear hpd sel %d\n",
|
|
|
ret);
|
|
ret);
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- cdns_mhdp_set_firmware_active(&dp->mhdp, false);
|
|
|
|
|
|
|
+ cdn_dp_set_firmware_active(dp, false);
|
|
|
cdn_dp_clk_disable(dp);
|
|
cdn_dp_clk_disable(dp);
|
|
|
dp->active = false;
|
|
dp->active = false;
|
|
|
- dp->mhdp.link.rate = 0;
|
|
|
|
|
- dp->mhdp.link.num_lanes = 0;
|
|
|
|
|
|
|
+ dp->link.rate = 0;
|
|
|
|
|
+ dp->link.num_lanes = 0;
|
|
|
if (!dp->connected) {
|
|
if (!dp->connected) {
|
|
|
kfree(dp->edid);
|
|
kfree(dp->edid);
|
|
|
dp->edid = NULL;
|
|
dp->edid = NULL;
|
|
@@ -507,11 +500,11 @@ static int cdn_dp_enable(struct cdn_dp_device *dp)
|
|
|
{
|
|
{
|
|
|
int ret, i, lanes;
|
|
int ret, i, lanes;
|
|
|
struct cdn_dp_port *port;
|
|
struct cdn_dp_port *port;
|
|
|
- struct device *dev = dp->mhdp.dev;
|
|
|
|
|
|
|
|
|
|
port = cdn_dp_connected_port(dp);
|
|
port = cdn_dp_connected_port(dp);
|
|
|
if (!port) {
|
|
if (!port) {
|
|
|
- DRM_DEV_ERROR(dev, "Can't enable without connection\n");
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev,
|
|
|
|
|
+ "Can't enable without connection\n");
|
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -524,7 +517,7 @@ static int cdn_dp_enable(struct cdn_dp_device *dp)
|
|
|
|
|
|
|
|
ret = cdn_dp_firmware_init(dp);
|
|
ret = cdn_dp_firmware_init(dp);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dp->mhdp.dev, "firmware init failed: %d", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "firmware init failed: %d", ret);
|
|
|
goto err_clk_disable;
|
|
goto err_clk_disable;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -558,9 +551,8 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder,
|
|
|
struct drm_display_mode *adjusted)
|
|
struct drm_display_mode *adjusted)
|
|
|
{
|
|
{
|
|
|
struct cdn_dp_device *dp = encoder_to_dp(encoder);
|
|
struct cdn_dp_device *dp = encoder_to_dp(encoder);
|
|
|
- struct drm_display_info *display_info =
|
|
|
|
|
- &dp->mhdp.connector.base.display_info;
|
|
|
|
|
- struct video_info *video = &dp->mhdp.video_info;
|
|
|
|
|
|
|
+ struct drm_display_info *display_info = &dp->connector.display_info;
|
|
|
|
|
+ struct video_info *video = &dp->video_info;
|
|
|
|
|
|
|
|
switch (display_info->bpc) {
|
|
switch (display_info->bpc) {
|
|
|
case 10:
|
|
case 10:
|
|
@@ -578,7 +570,7 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder,
|
|
|
video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC);
|
|
video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC);
|
|
|
video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC);
|
|
video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC);
|
|
|
|
|
|
|
|
- memcpy(&dp->mhdp.mode, adjusted, sizeof(*mode));
|
|
|
|
|
|
|
+ memcpy(&dp->mode, adjusted, sizeof(*mode));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
|
|
static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
|
|
@@ -587,11 +579,11 @@ static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
|
|
|
struct cdn_dp_port *port = cdn_dp_connected_port(dp);
|
|
struct cdn_dp_port *port = cdn_dp_connected_port(dp);
|
|
|
u8 sink_lanes = drm_dp_max_lane_count(dp->dpcd);
|
|
u8 sink_lanes = drm_dp_max_lane_count(dp->dpcd);
|
|
|
|
|
|
|
|
- if (!port || !dp->mhdp.link.rate || !dp->mhdp.link.num_lanes)
|
|
|
|
|
|
|
+ if (!port || !dp->link.rate || !dp->link.num_lanes)
|
|
|
return false;
|
|
return false;
|
|
|
|
|
|
|
|
- if (cdns_mhdp_dpcd_read(&dp->mhdp, DP_LANE0_1_STATUS, link_status,
|
|
|
|
|
- DP_LINK_STATUS_SIZE)) {
|
|
|
|
|
|
|
+ if (cdn_dp_dpcd_read(dp, DP_LANE0_1_STATUS, link_status,
|
|
|
|
|
+ DP_LINK_STATUS_SIZE)) {
|
|
|
DRM_ERROR("Failed to get link status\n");
|
|
DRM_ERROR("Failed to get link status\n");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
@@ -603,16 +595,15 @@ static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
|
|
|
static void cdn_dp_encoder_enable(struct drm_encoder *encoder)
|
|
static void cdn_dp_encoder_enable(struct drm_encoder *encoder)
|
|
|
{
|
|
{
|
|
|
struct cdn_dp_device *dp = encoder_to_dp(encoder);
|
|
struct cdn_dp_device *dp = encoder_to_dp(encoder);
|
|
|
- struct device *dev = dp->mhdp.dev;
|
|
|
|
|
int ret, val;
|
|
int ret, val;
|
|
|
|
|
|
|
|
- ret = drm_of_encoder_active_endpoint_id(dev->of_node, encoder);
|
|
|
|
|
|
|
+ ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, encoder);
|
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
|
- DRM_DEV_ERROR(dev, "Could not get vop id, %d", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Could not get vop id, %d", ret);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- DRM_DEV_DEBUG_KMS(dev, "vop %s output to cdn-dp\n",
|
|
|
|
|
|
|
+ DRM_DEV_DEBUG_KMS(dp->dev, "vop %s output to cdn-dp\n",
|
|
|
(ret) ? "LIT" : "BIG");
|
|
(ret) ? "LIT" : "BIG");
|
|
|
if (ret)
|
|
if (ret)
|
|
|
val = DP_SEL_VOP_LIT | (DP_SEL_VOP_LIT << 16);
|
|
val = DP_SEL_VOP_LIT | (DP_SEL_VOP_LIT << 16);
|
|
@@ -627,33 +618,33 @@ static void cdn_dp_encoder_enable(struct drm_encoder *encoder)
|
|
|
|
|
|
|
|
ret = cdn_dp_enable(dp);
|
|
ret = cdn_dp_enable(dp);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "Failed to enable encoder %d\n",
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Failed to enable encoder %d\n",
|
|
|
ret);
|
|
ret);
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
if (!cdn_dp_check_link_status(dp)) {
|
|
if (!cdn_dp_check_link_status(dp)) {
|
|
|
- ret = cdns_mhdp_train_link(&dp->mhdp);
|
|
|
|
|
|
|
+ ret = cdn_dp_train_link(dp);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "Failed link train %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Failed link train %d\n", ret);
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ret = cdns_mhdp_set_video_status(&dp->mhdp, CONTROL_VIDEO_IDLE);
|
|
|
|
|
|
|
+ ret = cdn_dp_set_video_status(dp, CONTROL_VIDEO_IDLE);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "Failed to idle video %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Failed to idle video %d\n", ret);
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ret = cdns_mhdp_config_video(&dp->mhdp);
|
|
|
|
|
|
|
+ ret = cdn_dp_config_video(dp);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "Failed to config video %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Failed to config video %d\n", ret);
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ret = cdns_mhdp_set_video_status(&dp->mhdp, CONTROL_VIDEO_VALID);
|
|
|
|
|
|
|
+ ret = cdn_dp_set_video_status(dp, CONTROL_VIDEO_VALID);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "Failed to valid video %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Failed to valid video %d\n", ret);
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
out:
|
|
out:
|
|
@@ -669,8 +660,7 @@ static void cdn_dp_encoder_disable(struct drm_encoder *encoder)
|
|
|
if (dp->active) {
|
|
if (dp->active) {
|
|
|
ret = cdn_dp_disable(dp);
|
|
ret = cdn_dp_disable(dp);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dp->mhdp.dev,
|
|
|
|
|
- "Failed to disable encoder %d\n",
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Failed to disable encoder %d\n",
|
|
|
ret);
|
|
ret);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -714,7 +704,7 @@ static const struct drm_encoder_funcs cdn_dp_encoder_funcs = {
|
|
|
|
|
|
|
|
static int cdn_dp_parse_dt(struct cdn_dp_device *dp)
|
|
static int cdn_dp_parse_dt(struct cdn_dp_device *dp)
|
|
|
{
|
|
{
|
|
|
- struct device *dev = dp->mhdp.dev;
|
|
|
|
|
|
|
+ struct device *dev = dp->dev;
|
|
|
struct device_node *np = dev->of_node;
|
|
struct device_node *np = dev->of_node;
|
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
|
struct resource *res;
|
|
struct resource *res;
|
|
@@ -726,10 +716,10 @@ static int cdn_dp_parse_dt(struct cdn_dp_device *dp)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
- dp->mhdp.regs = devm_ioremap_resource(dev, res);
|
|
|
|
|
- if (IS_ERR(dp->mhdp.regs)) {
|
|
|
|
|
|
|
+ dp->regs = devm_ioremap_resource(dev, res);
|
|
|
|
|
+ if (IS_ERR(dp->regs)) {
|
|
|
DRM_DEV_ERROR(dev, "ioremap reg failed\n");
|
|
DRM_DEV_ERROR(dev, "ioremap reg failed\n");
|
|
|
- return PTR_ERR(dp->mhdp.regs);
|
|
|
|
|
|
|
+ return PTR_ERR(dp->regs);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
dp->core_clk = devm_clk_get(dev, "core-clk");
|
|
dp->core_clk = devm_clk_get(dev, "core-clk");
|
|
@@ -744,10 +734,10 @@ static int cdn_dp_parse_dt(struct cdn_dp_device *dp)
|
|
|
return PTR_ERR(dp->pclk);
|
|
return PTR_ERR(dp->pclk);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- dp->mhdp.spdif_clk = devm_clk_get(dev, "spdif");
|
|
|
|
|
- if (IS_ERR(dp->mhdp.spdif_clk)) {
|
|
|
|
|
|
|
+ dp->spdif_clk = devm_clk_get(dev, "spdif");
|
|
|
|
|
+ if (IS_ERR(dp->spdif_clk)) {
|
|
|
DRM_DEV_ERROR(dev, "cannot get spdif_clk\n");
|
|
DRM_DEV_ERROR(dev, "cannot get spdif_clk\n");
|
|
|
- return PTR_ERR(dp->mhdp.spdif_clk);
|
|
|
|
|
|
|
+ return PTR_ERR(dp->spdif_clk);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
dp->grf_clk = devm_clk_get(dev, "grf");
|
|
dp->grf_clk = devm_clk_get(dev, "grf");
|
|
@@ -756,10 +746,10 @@ static int cdn_dp_parse_dt(struct cdn_dp_device *dp)
|
|
|
return PTR_ERR(dp->grf_clk);
|
|
return PTR_ERR(dp->grf_clk);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- dp->mhdp.spdif_rst = devm_reset_control_get(dev, "spdif");
|
|
|
|
|
- if (IS_ERR(dp->mhdp.spdif_rst)) {
|
|
|
|
|
|
|
+ dp->spdif_rst = devm_reset_control_get(dev, "spdif");
|
|
|
|
|
+ if (IS_ERR(dp->spdif_rst)) {
|
|
|
DRM_DEV_ERROR(dev, "no spdif reset control found\n");
|
|
DRM_DEV_ERROR(dev, "no spdif reset control found\n");
|
|
|
- return PTR_ERR(dp->mhdp.spdif_rst);
|
|
|
|
|
|
|
+ return PTR_ERR(dp->spdif_rst);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
dp->dptx_rst = devm_reset_control_get(dev, "dptx");
|
|
dp->dptx_rst = devm_reset_control_get(dev, "dptx");
|
|
@@ -814,9 +804,9 @@ static int cdn_dp_audio_hw_params(struct device *dev, void *data,
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ret = cdns_mhdp_audio_config(&dp->mhdp, &audio);
|
|
|
|
|
|
|
+ ret = cdn_dp_audio_config(dp, &audio);
|
|
|
if (!ret)
|
|
if (!ret)
|
|
|
- dp->mhdp.audio_info = audio;
|
|
|
|
|
|
|
+ dp->audio_info = audio;
|
|
|
|
|
|
|
|
out:
|
|
out:
|
|
|
mutex_unlock(&dp->lock);
|
|
mutex_unlock(&dp->lock);
|
|
@@ -832,9 +822,9 @@ static void cdn_dp_audio_shutdown(struct device *dev, void *data)
|
|
|
if (!dp->active)
|
|
if (!dp->active)
|
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
|
|
- ret = cdns_mhdp_audio_stop(&dp->mhdp, &dp->mhdp.audio_info);
|
|
|
|
|
|
|
+ ret = cdn_dp_audio_stop(dp, &dp->audio_info);
|
|
|
if (!ret)
|
|
if (!ret)
|
|
|
- dp->mhdp.audio_info.format = AFMT_UNUSED;
|
|
|
|
|
|
|
+ dp->audio_info.format = AFMT_UNUSED;
|
|
|
out:
|
|
out:
|
|
|
mutex_unlock(&dp->lock);
|
|
mutex_unlock(&dp->lock);
|
|
|
}
|
|
}
|
|
@@ -851,7 +841,7 @@ static int cdn_dp_audio_digital_mute(struct device *dev, void *data,
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ret = cdns_mhdp_audio_mute(&dp->mhdp, enable);
|
|
|
|
|
|
|
+ ret = cdn_dp_audio_mute(dp, enable);
|
|
|
|
|
|
|
|
out:
|
|
out:
|
|
|
mutex_unlock(&dp->lock);
|
|
mutex_unlock(&dp->lock);
|
|
@@ -863,8 +853,7 @@ static int cdn_dp_audio_get_eld(struct device *dev, void *data,
|
|
|
{
|
|
{
|
|
|
struct cdn_dp_device *dp = dev_get_drvdata(dev);
|
|
struct cdn_dp_device *dp = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
- memcpy(buf, dp->mhdp.connector.base.eld,
|
|
|
|
|
- min(sizeof(dp->mhdp.connector.base.eld), len));
|
|
|
|
|
|
|
+ memcpy(buf, dp->connector.eld, min(sizeof(dp->connector.eld), len));
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -886,11 +875,11 @@ static int cdn_dp_audio_codec_init(struct cdn_dp_device *dp,
|
|
|
.max_i2s_channels = 8,
|
|
.max_i2s_channels = 8,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- dp->mhdp.audio_pdev = platform_device_register_data(
|
|
|
|
|
- dev, HDMI_CODEC_DRV_NAME, PLATFORM_DEVID_AUTO,
|
|
|
|
|
- &codec_data, sizeof(codec_data));
|
|
|
|
|
|
|
+ dp->audio_pdev = platform_device_register_data(
|
|
|
|
|
+ dev, HDMI_CODEC_DRV_NAME, PLATFORM_DEVID_AUTO,
|
|
|
|
|
+ &codec_data, sizeof(codec_data));
|
|
|
|
|
|
|
|
- return PTR_ERR_OR_ZERO(dp->mhdp.audio_pdev);
|
|
|
|
|
|
|
+ return PTR_ERR_OR_ZERO(dp->audio_pdev);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static int cdn_dp_request_firmware(struct cdn_dp_device *dp)
|
|
static int cdn_dp_request_firmware(struct cdn_dp_device *dp)
|
|
@@ -898,7 +887,6 @@ static int cdn_dp_request_firmware(struct cdn_dp_device *dp)
|
|
|
int ret;
|
|
int ret;
|
|
|
unsigned long timeout = jiffies + msecs_to_jiffies(CDN_FW_TIMEOUT_MS);
|
|
unsigned long timeout = jiffies + msecs_to_jiffies(CDN_FW_TIMEOUT_MS);
|
|
|
unsigned long sleep = 1000;
|
|
unsigned long sleep = 1000;
|
|
|
- struct device *dev = dp->mhdp.dev;
|
|
|
|
|
|
|
|
|
|
WARN_ON(!mutex_is_locked(&dp->lock));
|
|
WARN_ON(!mutex_is_locked(&dp->lock));
|
|
|
|
|
|
|
@@ -909,13 +897,13 @@ static int cdn_dp_request_firmware(struct cdn_dp_device *dp)
|
|
|
mutex_unlock(&dp->lock);
|
|
mutex_unlock(&dp->lock);
|
|
|
|
|
|
|
|
while (time_before(jiffies, timeout)) {
|
|
while (time_before(jiffies, timeout)) {
|
|
|
- ret = request_firmware(&dp->fw, CDN_DP_FIRMWARE, dev);
|
|
|
|
|
|
|
+ ret = request_firmware(&dp->fw, CDN_DP_FIRMWARE, dp->dev);
|
|
|
if (ret == -ENOENT) {
|
|
if (ret == -ENOENT) {
|
|
|
msleep(sleep);
|
|
msleep(sleep);
|
|
|
sleep *= 2;
|
|
sleep *= 2;
|
|
|
continue;
|
|
continue;
|
|
|
} else if (ret) {
|
|
} else if (ret) {
|
|
|
- DRM_DEV_ERROR(dev,
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev,
|
|
|
"failed to request firmware: %d\n", ret);
|
|
"failed to request firmware: %d\n", ret);
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
@@ -925,7 +913,7 @@ static int cdn_dp_request_firmware(struct cdn_dp_device *dp)
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- DRM_DEV_ERROR(dev, "Timed out trying to load firmware\n");
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Timed out trying to load firmware\n");
|
|
|
ret = -ETIMEDOUT;
|
|
ret = -ETIMEDOUT;
|
|
|
out:
|
|
out:
|
|
|
mutex_lock(&dp->lock);
|
|
mutex_lock(&dp->lock);
|
|
@@ -936,9 +924,8 @@ static void cdn_dp_pd_event_work(struct work_struct *work)
|
|
|
{
|
|
{
|
|
|
struct cdn_dp_device *dp = container_of(work, struct cdn_dp_device,
|
|
struct cdn_dp_device *dp = container_of(work, struct cdn_dp_device,
|
|
|
event_work);
|
|
event_work);
|
|
|
- struct drm_connector *connector = &dp->mhdp.connector.base;
|
|
|
|
|
|
|
+ struct drm_connector *connector = &dp->connector;
|
|
|
enum drm_connector_status old_status;
|
|
enum drm_connector_status old_status;
|
|
|
- struct device *dev = dp->mhdp.dev;
|
|
|
|
|
|
|
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
@@ -955,45 +942,44 @@ static void cdn_dp_pd_event_work(struct work_struct *work)
|
|
|
|
|
|
|
|
/* Not connected, notify userspace to disable the block */
|
|
/* Not connected, notify userspace to disable the block */
|
|
|
if (!cdn_dp_connected_port(dp)) {
|
|
if (!cdn_dp_connected_port(dp)) {
|
|
|
- DRM_DEV_INFO(dev, "Not connected. Disabling cdn\n");
|
|
|
|
|
|
|
+ DRM_DEV_INFO(dp->dev, "Not connected. Disabling cdn\n");
|
|
|
dp->connected = false;
|
|
dp->connected = false;
|
|
|
|
|
|
|
|
/* Connected but not enabled, enable the block */
|
|
/* Connected but not enabled, enable the block */
|
|
|
} else if (!dp->active) {
|
|
} else if (!dp->active) {
|
|
|
- DRM_DEV_INFO(dev, "Connected, not enabled. Enabling cdn\n");
|
|
|
|
|
|
|
+ DRM_DEV_INFO(dp->dev, "Connected, not enabled. Enabling cdn\n");
|
|
|
ret = cdn_dp_enable(dp);
|
|
ret = cdn_dp_enable(dp);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
- DRM_DEV_ERROR(dev, "Enable dp failed %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Enable dp failed %d\n", ret);
|
|
|
dp->connected = false;
|
|
dp->connected = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Enabled and connected to a dongle without a sink, notify userspace */
|
|
/* Enabled and connected to a dongle without a sink, notify userspace */
|
|
|
} else if (!cdn_dp_check_sink_connection(dp)) {
|
|
} else if (!cdn_dp_check_sink_connection(dp)) {
|
|
|
- DRM_DEV_INFO(dev, "Connected without sink. Assert hpd\n");
|
|
|
|
|
|
|
+ DRM_DEV_INFO(dp->dev, "Connected without sink. Assert hpd\n");
|
|
|
dp->connected = false;
|
|
dp->connected = false;
|
|
|
|
|
|
|
|
/* Enabled and connected with a sink, re-train if requested */
|
|
/* Enabled and connected with a sink, re-train if requested */
|
|
|
} else if (!cdn_dp_check_link_status(dp)) {
|
|
} else if (!cdn_dp_check_link_status(dp)) {
|
|
|
- unsigned int rate = dp->mhdp.link.rate;
|
|
|
|
|
- unsigned int lanes = dp->mhdp.link.num_lanes;
|
|
|
|
|
- struct drm_display_mode *mode = &dp->mhdp.mode;
|
|
|
|
|
|
|
+ unsigned int rate = dp->link.rate;
|
|
|
|
|
+ unsigned int lanes = dp->link.num_lanes;
|
|
|
|
|
+ struct drm_display_mode *mode = &dp->mode;
|
|
|
|
|
|
|
|
- DRM_DEV_INFO(dev, "Connected with sink. Re-train link\n");
|
|
|
|
|
- ret = cdns_mhdp_train_link(&dp->mhdp);
|
|
|
|
|
|
|
+ DRM_DEV_INFO(dp->dev, "Connected with sink. Re-train link\n");
|
|
|
|
|
+ ret = cdn_dp_train_link(dp);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
dp->connected = false;
|
|
dp->connected = false;
|
|
|
- DRM_DEV_ERROR(dev, "Train link failed %d\n", ret);
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev, "Train link failed %d\n", ret);
|
|
|
goto out;
|
|
goto out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* If training result is changed, update the video config */
|
|
/* If training result is changed, update the video config */
|
|
|
if (mode->clock &&
|
|
if (mode->clock &&
|
|
|
- (rate != dp->mhdp.link.rate ||
|
|
|
|
|
- lanes != dp->mhdp.link.num_lanes)) {
|
|
|
|
|
- ret = cdns_mhdp_config_video(&dp->mhdp);
|
|
|
|
|
|
|
+ (rate != dp->link.rate || lanes != dp->link.num_lanes)) {
|
|
|
|
|
+ ret = cdn_dp_config_video(dp);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
dp->connected = false;
|
|
dp->connected = false;
|
|
|
- DRM_DEV_ERROR(dev,
|
|
|
|
|
|
|
+ DRM_DEV_ERROR(dp->dev,
|
|
|
"Failed to config video %d\n",
|
|
"Failed to config video %d\n",
|
|
|
ret);
|
|
ret);
|
|
|
}
|
|
}
|
|
@@ -1062,7 +1048,7 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
|
|
|
|
|
|
|
|
drm_encoder_helper_add(encoder, &cdn_dp_encoder_helper_funcs);
|
|
drm_encoder_helper_add(encoder, &cdn_dp_encoder_helper_funcs);
|
|
|
|
|
|
|
|
- connector = &dp->mhdp.connector.base;
|
|
|
|
|
|
|
+ connector = &dp->connector;
|
|
|
connector->polled = DRM_CONNECTOR_POLL_HPD;
|
|
connector->polled = DRM_CONNECTOR_POLL_HPD;
|
|
|
connector->dpms = DRM_MODE_DPMS_OFF;
|
|
connector->dpms = DRM_MODE_DPMS_OFF;
|
|
|
|
|
|
|
@@ -1086,7 +1072,7 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
|
|
|
port = dp->port[i];
|
|
port = dp->port[i];
|
|
|
|
|
|
|
|
port->event_nb.notifier_call = cdn_dp_pd_event;
|
|
port->event_nb.notifier_call = cdn_dp_pd_event;
|
|
|
- ret = devm_extcon_register_notifier(dp->mhdp.dev, port->extcon,
|
|
|
|
|
|
|
+ ret = devm_extcon_register_notifier(dp->dev, port->extcon,
|
|
|
EXTCON_DISP_DP,
|
|
EXTCON_DISP_DP,
|
|
|
&port->event_nb);
|
|
&port->event_nb);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
@@ -1113,7 +1099,7 @@ static void cdn_dp_unbind(struct device *dev, struct device *master, void *data)
|
|
|
{
|
|
{
|
|
|
struct cdn_dp_device *dp = dev_get_drvdata(dev);
|
|
struct cdn_dp_device *dp = dev_get_drvdata(dev);
|
|
|
struct drm_encoder *encoder = &dp->encoder;
|
|
struct drm_encoder *encoder = &dp->encoder;
|
|
|
- struct drm_connector *connector = &dp->mhdp.connector.base;
|
|
|
|
|
|
|
+ struct drm_connector *connector = &dp->connector;
|
|
|
|
|
|
|
|
cancel_work_sync(&dp->event_work);
|
|
cancel_work_sync(&dp->event_work);
|
|
|
cdn_dp_encoder_disable(encoder);
|
|
cdn_dp_encoder_disable(encoder);
|
|
@@ -1173,7 +1159,7 @@ static int cdn_dp_probe(struct platform_device *pdev)
|
|
|
dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
|
|
dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
|
|
|
if (!dp)
|
|
if (!dp)
|
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
- dp->mhdp.dev = dev;
|
|
|
|
|
|
|
+ dp->dev = dev;
|
|
|
|
|
|
|
|
match = of_match_node(cdn_dp_dt_ids, pdev->dev.of_node);
|
|
match = of_match_node(cdn_dp_dt_ids, pdev->dev.of_node);
|
|
|
dp_data = (struct cdn_dp_data *)match->data;
|
|
dp_data = (struct cdn_dp_data *)match->data;
|
|
@@ -1217,8 +1203,8 @@ static int cdn_dp_remove(struct platform_device *pdev)
|
|
|
{
|
|
{
|
|
|
struct cdn_dp_device *dp = platform_get_drvdata(pdev);
|
|
struct cdn_dp_device *dp = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
- platform_device_unregister(dp->mhdp.audio_pdev);
|
|
|
|
|
- cdn_dp_suspend(dp->mhdp.dev);
|
|
|
|
|
|
|
+ platform_device_unregister(dp->audio_pdev);
|
|
|
|
|
+ cdn_dp_suspend(dp->dev);
|
|
|
component_del(&pdev->dev, &cdn_dp_component_ops);
|
|
component_del(&pdev->dev, &cdn_dp_component_ops);
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -1228,7 +1214,7 @@ static void cdn_dp_shutdown(struct platform_device *pdev)
|
|
|
{
|
|
{
|
|
|
struct cdn_dp_device *dp = platform_get_drvdata(pdev);
|
|
struct cdn_dp_device *dp = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
- cdn_dp_suspend(dp->mhdp.dev);
|
|
|
|
|
|
|
+ cdn_dp_suspend(dp->dev);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static const struct dev_pm_ops cdn_dp_pm_ops = {
|
|
static const struct dev_pm_ops cdn_dp_pm_ops = {
|