Commit 528a25d0 authored by Julien Masson's avatar Julien Masson Committed by Neil Armstrong
Browse files

drm: meson: use match data to detect vpu compatibility



This patch introduce new enum which contains all VPU family (GXBB,
GXL, GXM and G12A).
This enum is used to detect the VPU compatible with the device.

We only need to set .data to the corresponding enum in the device
table, no need to check .compatible string anymore.

Signed-off-by: default avatarJulien Masson <jmasson@baylibre.com>
Tested-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Acked-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Signed-off-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/87imqpz21w.fsf@masson.i-did-not-set--mail-host-address--so-tickle-me
parent ade92599
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -575,7 +575,7 @@ int meson_crtc_create(struct meson_drm *priv)
		return ret;
	}

	if (meson_vpu_is_compatible(priv, "amlogic,meson-g12a-vpu")) {
	if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
		meson_crtc->enable_osd1 = meson_g12a_crtc_enable_osd1;
		meson_crtc->enable_vd1 = meson_g12a_crtc_enable_vd1;
		meson_crtc->viu_offset = MESON_G12A_VIU_OFFSET;
+10 −4
Original line number Diff line number Diff line
@@ -209,6 +209,8 @@ static int meson_drv_bind_master(struct device *dev, bool has_components)
	priv->drm = drm;
	priv->dev = dev;

	priv->compat = (enum vpu_compatible)of_device_get_match_data(priv->dev);

	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vpu");
	regs = devm_ioremap_resource(dev, res);
	if (IS_ERR(regs)) {
@@ -453,10 +455,14 @@ static int meson_drv_probe(struct platform_device *pdev)
};

static const struct of_device_id dt_match[] = {
	{ .compatible = "amlogic,meson-gxbb-vpu" },
	{ .compatible = "amlogic,meson-gxl-vpu" },
	{ .compatible = "amlogic,meson-gxm-vpu" },
	{ .compatible = "amlogic,meson-g12a-vpu" },
	{ .compatible = "amlogic,meson-gxbb-vpu",
	  .data       = (void *)VPU_COMPATIBLE_GXBB },
	{ .compatible = "amlogic,meson-gxl-vpu",
	  .data       = (void *)VPU_COMPATIBLE_GXL },
	{ .compatible = "amlogic,meson-gxm-vpu",
	  .data       = (void *)VPU_COMPATIBLE_GXM },
	{ .compatible = "amlogic,meson-g12a-vpu",
	  .data       = (void *)VPU_COMPATIBLE_G12A },
	{}
};
MODULE_DEVICE_TABLE(of, dt_match);
+11 −2
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@

#include <linux/device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/regmap.h>

struct drm_crtc;
@@ -16,8 +17,16 @@ struct drm_device;
struct drm_plane;
struct meson_drm;

enum vpu_compatible {
	VPU_COMPATIBLE_GXBB = 0,
	VPU_COMPATIBLE_GXL  = 1,
	VPU_COMPATIBLE_GXM  = 2,
	VPU_COMPATIBLE_G12A = 3,
};

struct meson_drm {
	struct device *dev;
	enum vpu_compatible compat;
	void __iomem *io_base;
	struct regmap *hhi;
	int vsync_irq;
@@ -116,9 +125,9 @@ struct meson_drm {
};

static inline int meson_vpu_is_compatible(struct meson_drm *priv,
					  const char *compat)
					  enum vpu_compatible family)
{
	return of_device_is_compatible(priv->dev->of_node, compat);
	return priv->compat == family;
}

#endif /* __MESON_DRV_H */
+1 −1
Original line number Diff line number Diff line
@@ -937,7 +937,7 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master,
	reset_control_reset(meson_dw_hdmi->hdmitx_phy);

	/* Enable APB3 fail on error */
	if (!meson_vpu_is_compatible(priv, "amlogic,meson-g12a-vpu")) {
	if (!meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
		writel_bits_relaxed(BIT(15), BIT(15),
				    meson_dw_hdmi->hdmitx + HDMITX_TOP_CTRL_REG);
		writel_bits_relaxed(BIT(15), BIT(15),
+1 −1
Original line number Diff line number Diff line
@@ -513,7 +513,7 @@ static void meson_overlay_atomic_disable(struct drm_plane *plane,
	priv->viu.vd1_enabled = false;

	/* Disable VD1 */
	if (meson_vpu_is_compatible(priv, "amlogic,meson-g12a-vpu")) {
	if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
		writel_relaxed(0, priv->io_base + _REG(VD1_BLEND_SRC_CTRL));
		writel_relaxed(0, priv->io_base + _REG(VD2_BLEND_SRC_CTRL));
		writel_relaxed(0, priv->io_base + _REG(VD1_IF0_GEN_REG + 0x17b0));
Loading