From 006efbdf396e3b4e01f3d5acfb4952c787dd9339 Mon Sep 17 00:00:00 2001 From: Yakir Yang Date: Fri, 24 Jun 2016 15:18:45 +0800 Subject: [PATCH] FIXUP: drm/bridge: analogix_dp: misc update to upstream version This misc update would try to fix below comments from my eDP thread[0], and lucky to say this version is stable, and i'm start to perpare the pull request to David with this version. So i guess it's time to create a misc FIXUP patch to address the comments. [0]: https://patchwork.kernel.org/patch/9175613/ - Correct the misspell of "marcos" in commit message (Dominik, reviewed at Google Gerrit) - Write a kerneldoc-style comment explaining the chips data fields (Tomasz, reviewed at Google Gerrit) - Drop the '.lcdcsel_mask' number in chips data field (Tomasz, reviewed at Google Gerrit) - Make this hack code more clear (Tomasz, reviewed at Google Gerrit) reg = ~reg & REF_CLK_MASK; ---> reg ^= REF_CLK_MASK; - Give the "rk3399-edp" a separate line for clarity in document (Tomasz, reviewed at Google Gerrit) - Move 'output_type' setting before the return statement (Tomasz, reviewed at Google Gerrit) - Avoid to change any internal driver state in .mode_valid interface. (Tomasz, reviewed at Google Gerrit) - Hook the connector's color_formats in .get_modes directly. (Tomasz, reviewed at Google Gerrit) Change-Id: Ic35f166ebac04e417ff3d135e7bf4573bbca2004 Signed-off-by: Yakir Yang --- .../drm/bridge/analogix/analogix_dp_core.c | 19 +----- .../drm/bridge/analogix/analogix_dp_core.h | 8 +-- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 6 +- .../gpu/drm/bridge/analogix/analogix_dp_reg.h | 1 + .../gpu/drm/rockchip/analogix_dp-rockchip.c | 60 ++++++++----------- include/drm/bridge/analogix_dp.h | 13 ++-- 6 files changed, 45 insertions(+), 62 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index 92804016a5cd..1a890fac97bc 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -938,25 +938,11 @@ int analogix_dp_get_modes(struct drm_connector *connector) num_modes += drm_panel_get_modes(dp->plat_data->panel); if (dp->plat_data->get_modes) - num_modes += dp->plat_data->get_modes(dp->plat_data); + num_modes += dp->plat_data->get_modes(dp->plat_data, connector); return num_modes; } -static enum drm_mode_status -analogix_dp_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) -{ - struct analogix_dp_device *dp = to_dp(connector); - enum drm_mode_status status = MODE_OK; - - if (dp->plat_data->mode_valid) - status = dp->plat_data->mode_valid(dp->plat_data, connector, - mode); - - return status; -} - static struct drm_encoder * analogix_dp_best_encoder(struct drm_connector *connector) { @@ -968,7 +954,6 @@ analogix_dp_best_encoder(struct drm_connector *connector) static const struct drm_connector_helper_funcs analogix_dp_connector_helper_funcs = { .get_modes = analogix_dp_get_modes, .best_encoder = analogix_dp_best_encoder, - .mode_valid = analogix_dp_mode_valid, }; enum drm_connector_status @@ -1224,7 +1209,7 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) switch (dp->plat_data->dev_type) { case ROCKCHIP_DP: /* - * Like ROCKCHIP DisplayPort TRM indicate that "Main link + * Like Rockchip DisplayPort TRM indicate that "Main link * containing 4 physical lanes of 2.7/1.62 Gbps/lane". */ video_info->max_link_rate = 0x0A; diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h index f09275d40f70..b45638043ec4 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h @@ -127,10 +127,10 @@ enum analog_power_block { }; enum dp_irq_type { - DP_IRQ_TYPE_HP_CABLE_IN, - DP_IRQ_TYPE_HP_CABLE_OUT, - DP_IRQ_TYPE_HP_CHANGE, - DP_IRQ_TYPE_UNKNOWN, + DP_IRQ_TYPE_HP_CABLE_IN = BIT(0), + DP_IRQ_TYPE_HP_CABLE_OUT = BIT(1), + DP_IRQ_TYPE_HP_CHANGE = BIT(2), + DP_IRQ_TYPE_UNKNOWN = BIT(3), }; struct video_info { diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c index 931a76caf739..97ced6b24c5a 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c @@ -75,7 +75,11 @@ void analogix_dp_init_analog_param(struct analogix_dp_device *dp) writel(reg, dp->reg_base + ANALOGIX_DP_ANALOG_CTL_2); if (dp->plat_data && (dp->plat_data->dev_type == ROCKCHIP_DP)) { - writel(REF_CLK_24M, dp->reg_base + ANALOGIX_DP_PLL_REG_1); + reg = REF_CLK_24M; + if (dp->plat_data->subdev_type == RK3288_DP) + reg ^= REF_CLK_MASK; + + writel(reg, dp->reg_base + ANALOGIX_DP_PLL_REG_1); writel(0x95, dp->reg_base + ANALOGIX_DP_PLL_REG_2); writel(0x40, dp->reg_base + ANALOGIX_DP_PLL_REG_3); writel(0x58, dp->reg_base + ANALOGIX_DP_PLL_REG_4); diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.h index 88d56ad5c010..cdcc6c5add5e 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.h +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.h @@ -165,6 +165,7 @@ /* ANALOGIX_DP_PLL_REG_1 */ #define REF_CLK_24M (0x1 << 0) #define REF_CLK_27M (0x0 << 0) +#define REF_CLK_MASK (0x1 << 0) /* ANALOGIX_DP_LANE_MAP */ #define LANE3_MAP_LOGIC_LANE_0 (0x0 << 6) diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index c5b87d470010..5375df350223 100644 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c @@ -36,16 +36,16 @@ #define to_dp(nm) container_of(nm, struct rockchip_dp_device, nm) -enum rockchip_dp_chip_type { - RK3288_DP, - RK3399_EDP, -}; - +/** + * struct rockchip_dp_chip_data - splite the grf setting of kind of chips + * @lcdsel_grf_reg: grf register offset of lcdc select + * @lcdsel_big: reg value of selecting vop big for eDP + * @lcdsel_lit: reg value of selecting vop little for eDP + */ struct rockchip_dp_chip_data { u32 lcdsel_grf_reg; u32 lcdsel_big; u32 lcdsel_lit; - u32 lcdsel_mask; u32 chip_type; }; @@ -102,10 +102,8 @@ static int rockchip_dp_powerdown(struct analogix_dp_plat_data *plat_data) return 0; } -static enum drm_mode_status -rockchip_dp_mode_valid(struct analogix_dp_plat_data *plat_data, - struct drm_connector *connector, - struct drm_display_mode *mode) +static int rockchip_dp_get_modes(struct analogix_dp_plat_data *plat_data, + struct drm_connector *connector) { struct drm_display_info *di = &connector->display_info; @@ -117,7 +115,7 @@ rockchip_dp_mode_valid(struct analogix_dp_plat_data *plat_data, di->bpc = 8; } - return MODE_OK; + return 0; } static bool @@ -125,6 +123,7 @@ rockchip_dp_drm_encoder_mode_fixup(struct drm_encoder *encoder, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { + /* do nothing */ return true; } @@ -146,9 +145,9 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder) return; if (ret) - val = dp->data->lcdsel_lit | dp->data->lcdsel_mask; + val = dp->data->lcdsel_lit; else - val = dp->data->lcdsel_big | dp->data->lcdsel_mask; + val = dp->data->lcdsel_big; dev_dbg(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG"); @@ -166,11 +165,11 @@ static void rockchip_dp_drm_encoder_nop(struct drm_encoder *encoder) static int rockchip_dp_drm_encoder_atomic_check(struct drm_encoder *encoder, - struct drm_crtc_state *crtc_state, - struct drm_connector_state *conn_state) + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) { - struct rockchip_dp_device *dp = to_dp(encoder); struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc_state); + struct rockchip_dp_device *dp = to_dp(encoder); int ret; /* @@ -201,6 +200,7 @@ rockchip_dp_drm_encoder_atomic_check(struct drm_encoder *encoder, s->output_mode = ROCKCHIP_OUT_MODE_AAAA; break; } + s->output_type = DRM_MODE_CONNECTOR_eDP; return 0; @@ -320,9 +320,10 @@ static int rockchip_dp_bind(struct device *dev, struct device *master, dp->plat_data.encoder = &dp->encoder; dp->plat_data.dev_type = ROCKCHIP_DP; + dp->plat_data.subdev_type = dp_data->chip_type; dp->plat_data.power_on = rockchip_dp_poweron; dp->plat_data.power_off = rockchip_dp_powerdown; - dp->plat_data.mode_valid = rockchip_dp_mode_valid; + dp->plat_data.get_modes = rockchip_dp_get_modes; return analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data); } @@ -395,35 +396,24 @@ static int rockchip_dp_remove(struct platform_device *pdev) return 0; } +static const struct dev_pm_ops rockchip_dp_pm_ops = { #ifdef CONFIG_PM_SLEEP -static int rockchip_dp_suspend(struct device *dev) -{ - return analogix_dp_suspend(dev); -} - -static int rockchip_dp_resume(struct device *dev) -{ - return analogix_dp_resume(dev); -} + .suspend = analogix_dp_suspend, + .resume_early = analogix_dp_resume, #endif - -static const struct dev_pm_ops rockchip_dp_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(rockchip_dp_suspend, rockchip_dp_resume) }; static const struct rockchip_dp_chip_data rk3399_edp = { .lcdsel_grf_reg = 0x6250, - .lcdsel_big = 0, - .lcdsel_lit = BIT(5), - .lcdsel_mask = BIT(21), + .lcdsel_big = 0 | BIT(21), + .lcdsel_lit = BIT(5) | BIT(21), .chip_type = RK3399_EDP, }; static const struct rockchip_dp_chip_data rk3288_dp = { .lcdsel_grf_reg = 0x025c, - .lcdsel_big = 0, - .lcdsel_lit = BIT(5), - .lcdsel_mask = BIT(21), + .lcdsel_big = 0 | BIT(21), + .lcdsel_lit = BIT(5) | BIT(21), .chip_type = RK3288_DP, }; diff --git a/include/drm/bridge/analogix_dp.h b/include/drm/bridge/analogix_dp.h index f5348e6a76a2..181db097c12a 100644 --- a/include/drm/bridge/analogix_dp.h +++ b/include/drm/bridge/analogix_dp.h @@ -18,8 +18,14 @@ enum analogix_dp_devtype { ROCKCHIP_DP, }; +enum analogix_dp_sub_devtype { + RK3288_DP, + RK3399_EDP, +}; + struct analogix_dp_plat_data { enum analogix_dp_devtype dev_type; + enum analogix_dp_sub_devtype subdev_type; struct drm_panel *panel; struct drm_encoder *encoder; struct drm_connector *connector; @@ -28,11 +34,8 @@ struct analogix_dp_plat_data { int (*power_off)(struct analogix_dp_plat_data *); int (*attach)(struct analogix_dp_plat_data *, struct drm_bridge *, struct drm_connector *); - int (*get_modes)(struct analogix_dp_plat_data *); - - enum drm_mode_status (*mode_valid)(struct analogix_dp_plat_data *, - struct drm_connector *, - struct drm_display_mode *); + int (*get_modes)(struct analogix_dp_plat_data *, + struct drm_connector *); }; int analogix_dp_resume(struct device *dev); -- 2.34.1