Skip to content

Commit 8976eee

Browse files
committed
drm/meson: add mode selection limits against specific SoC revisions
The Amlogic S805X/Y uses the same die as the S905X, but with more limited graphics capabilities. This adds a soc version detection adding specific limitations on the HDMI mode selections. Here, we limit to HDMI 1.2a max HDMI PHY clock frequency. Changes sinces v1: - Moved frequency check in the vclk code, and also checks DMT modes Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> [narmstrong: fixed commit message with HDMI 1.2a instead of HDMI 1.3a] Link: https://patchwork.freedesktop.org/patch/msgid/20200428092147.13698-1-narmstrong@baylibre.com
1 parent e7f1205 commit 8976eee

5 files changed

Lines changed: 52 additions & 4 deletions

File tree

‎drivers/gpu/drm/meson/meson_drv.c‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/component.h>
1212
#include <linux/module.h>
1313
#include <linux/of_graph.h>
14+
#include <linux/sys_soc.h>
1415
#include <linux/platform_device.h>
1516
#include <linux/soc/amlogic/meson-canvas.h>
1617

@@ -183,6 +184,24 @@ static void meson_remove_framebuffers(void)
183184
kfree(ap);
184185
}
185186

187+
struct meson_drm_soc_attr {
188+
struct meson_drm_soc_limits limits;
189+
const struct soc_device_attribute *attrs;
190+
};
191+
192+
static const struct meson_drm_soc_attr meson_drm_soc_attrs[] = {
193+
/* S805X/S805Y HDMI PLL won't lock for HDMI PHY freq > 1,65GHz */
194+
{
195+
.limits = {
196+
.max_hdmi_phy_freq = 1650000,
197+
},
198+
.attrs = (const struct soc_device_attribute []) {
199+
{ .soc_id = "GXL (S805*)", },
200+
{ /* sentinel */ },
201+
}
202+
},
203+
};
204+
186205
static int meson_drv_bind_master(struct device *dev, bool has_components)
187206
{
188207
struct platform_device *pdev = to_platform_device(dev);
@@ -191,7 +210,7 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
191210
struct drm_device *drm;
192211
struct resource *res;
193212
void __iomem *regs;
194-
int ret;
213+
int ret, i;
195214

196215
/* Checks if an output connector is available */
197216
if (!meson_vpu_has_available_connectors(dev)) {
@@ -281,6 +300,14 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
281300
if (ret)
282301
goto free_drm;
283302

303+
/* Assign limits per soc revision/package */
304+
for (i = 0 ; i < ARRAY_SIZE(meson_drm_soc_attrs) ; ++i) {
305+
if (soc_device_match(meson_drm_soc_attrs[i].attrs)) {
306+
priv->limits = &meson_drm_soc_attrs[i].limits;
307+
break;
308+
}
309+
}
310+
284311
/* Remove early framebuffers (ie. simplefb) */
285312
meson_remove_framebuffers();
286313

‎drivers/gpu/drm/meson/meson_drv.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ struct meson_drm_match_data {
3030
struct meson_afbcd_ops *afbcd_ops;
3131
};
3232

33+
struct meson_drm_soc_limits {
34+
unsigned int max_hdmi_phy_freq;
35+
};
36+
3337
struct meson_drm {
3438
struct device *dev;
3539
enum vpu_compatible compat;
@@ -48,6 +52,8 @@ struct meson_drm {
4852
struct drm_plane *primary_plane;
4953
struct drm_plane *overlay_plane;
5054

55+
const struct meson_drm_soc_limits *limits;
56+
5157
/* Components Data */
5258
struct {
5359
bool osd1_enabled;

‎drivers/gpu/drm/meson/meson_dw_hdmi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ dw_hdmi_mode_valid(struct drm_connector *connector,
695695
dev_dbg(connector->dev->dev, "%s: vclk:%d phy=%d venc=%d hdmi=%d\n",
696696
__func__, phy_freq, vclk_freq, venc_freq, hdmi_freq);
697697

698-
return meson_vclk_vic_supported_freq(phy_freq, vclk_freq);
698+
return meson_vclk_vic_supported_freq(priv, phy_freq, vclk_freq);
699699
}
700700

701701
/* Encoder */

‎drivers/gpu/drm/meson/meson_vclk.c‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,13 @@ meson_vclk_dmt_supported_freq(struct meson_drm *priv, unsigned int freq)
725725
/* In DMT mode, path after PLL is always /10 */
726726
freq *= 10;
727727

728+
/* Check against soc revision/package limits */
729+
if (priv->limits) {
730+
if (priv->limits->max_hdmi_phy_freq &&
731+
freq > priv->limits->max_hdmi_phy_freq)
732+
return MODE_CLOCK_HIGH;
733+
}
734+
728735
if (meson_hdmi_pll_find_params(priv, freq, &m, &frac, &od))
729736
return MODE_OK;
730737

@@ -762,14 +769,21 @@ static void meson_hdmi_pll_generic_set(struct meson_drm *priv,
762769
}
763770

764771
enum drm_mode_status
765-
meson_vclk_vic_supported_freq(unsigned int phy_freq,
772+
meson_vclk_vic_supported_freq(struct meson_drm *priv, unsigned int phy_freq,
766773
unsigned int vclk_freq)
767774
{
768775
int i;
769776

770777
DRM_DEBUG_DRIVER("phy_freq = %d vclk_freq = %d\n",
771778
phy_freq, vclk_freq);
772779

780+
/* Check against soc revision/package limits */
781+
if (priv->limits) {
782+
if (priv->limits->max_hdmi_phy_freq &&
783+
phy_freq > priv->limits->max_hdmi_phy_freq)
784+
return MODE_CLOCK_HIGH;
785+
}
786+
773787
for (i = 0 ; params[i].pixel_freq ; ++i) {
774788
DRM_DEBUG_DRIVER("i = %d pixel_freq = %d alt = %d\n",
775789
i, params[i].pixel_freq,

‎drivers/gpu/drm/meson/meson_vclk.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ enum {
2525
enum drm_mode_status
2626
meson_vclk_dmt_supported_freq(struct meson_drm *priv, unsigned int freq);
2727
enum drm_mode_status
28-
meson_vclk_vic_supported_freq(unsigned int phy_freq, unsigned int vclk_freq);
28+
meson_vclk_vic_supported_freq(struct meson_drm *priv, unsigned int phy_freq,
29+
unsigned int vclk_freq);
2930

3031
void meson_vclk_setup(struct meson_drm *priv, unsigned int target,
3132
unsigned int phy_freq, unsigned int vclk_freq,

0 commit comments

Comments
 (0)