From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omzsmtpe03.verizonbusiness.com ([199.249.25.208]:19767 "EHLO omzsmtpe03.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753129AbdDDTcj (ORCPT ); Tue, 4 Apr 2017 15:32:39 -0400 From: alexander.levin@verizon.com To: "gregkh@linuxfoundation.org" CC: "stable@vger.kernel.org" Subject: [PATCH for 4.9 01/98] drm/sun4i: tcon: Move SoC specific quirks to a DT matched data structure Date: Tue, 4 Apr 2017 19:32:02 +0000 Message-ID: <20170404193158.19041-2-alexander.levin@verizon.com> References: <20170404193158.19041-1-alexander.levin@verizon.com> In-Reply-To: <20170404193158.19041-1-alexander.levin@verizon.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Chen-Yu Tsai [ Upstream commit 91ea2f29cba6a7fe035ea232e4f981211a9fce5d ] We already have some differences between the 2 supported SoCs. More will be added as we support other SoCs. To avoid bloating the probe function with even more conditionals, move the quirks to a separate data structure that's tied to the compatible string. Signed-off-by: Chen-Yu Tsai Signed-off-by: Maxime Ripard Signed-off-by: Sasha Levin --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 33 ++++++++++++++++++--------------- drivers/gpu/drm/sun4i/sun4i_tcon.h | 11 +++++++---- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun= 4i_tcon.c index cadacb5..7658f03 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,7 @@ void sun4i_tcon_channel_disable(struct sun4i_tcon *tcon, = int channel) return; } =20 - WARN_ON(!tcon->has_channel_1); + WARN_ON(!tcon->quirks->has_channel_1); regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG, SUN4I_TCON1_CTL_TCON_ENABLE, 0); clk_disable_unprepare(tcon->sclk1); @@ -80,7 +81,7 @@ void sun4i_tcon_channel_enable(struct sun4i_tcon *tcon, i= nt channel) return; } =20 - WARN_ON(!tcon->has_channel_1); + WARN_ON(!tcon->quirks->has_channel_1); regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG, SUN4I_TCON1_CTL_TCON_ENABLE, SUN4I_TCON1_CTL_TCON_ENABLE); @@ -202,7 +203,7 @@ void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon, u8 clk_delay; u32 val; =20 - WARN_ON(!tcon->has_channel_1); + WARN_ON(!tcon->quirks->has_channel_1); =20 /* Adjust clock delay */ clk_delay =3D sun4i_tcon_get_clk_delay(mode, 1); @@ -266,7 +267,7 @@ void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon, /* * FIXME: Undocumented bits */ - if (tcon->has_mux) + if (tcon->quirks->has_unknown_mux) regmap_write(tcon->regs, SUN4I_TCON_MUX_CTRL_REG, 1); } EXPORT_SYMBOL(sun4i_tcon1_mode_set); @@ -327,7 +328,7 @@ static int sun4i_tcon_init_clocks(struct device *dev, return PTR_ERR(tcon->sclk0); } =20 - if (tcon->has_channel_1) { + if (tcon->quirks->has_channel_1) { tcon->sclk1 =3D devm_clk_get(dev, "tcon-ch1"); if (IS_ERR(tcon->sclk1)) { dev_err(dev, "Couldn't get the TCON channel 1 clock\n"); @@ -487,14 +488,7 @@ static int sun4i_tcon_bind(struct device *dev, struct = device *master, drv->tcon =3D tcon; tcon->drm =3D drm; tcon->dev =3D dev; - - if (of_device_is_compatible(dev->of_node, "allwinner,sun5i-a13-tcon")) { - tcon->has_mux =3D true; - tcon->has_channel_1 =3D true; - } else { - tcon->has_mux =3D false; - tcon->has_channel_1 =3D false; - } + tcon->quirks =3D of_device_get_match_data(dev); =20 tcon->lcd_rst =3D devm_reset_control_get(dev, "lcd"); if (IS_ERR(tcon->lcd_rst)) { @@ -588,9 +582,18 @@ static int sun4i_tcon_remove(struct platform_device *p= dev) return 0; } =20 +static const struct sun4i_tcon_quirks sun5i_a13_quirks =3D { + .has_unknown_mux =3D true, + .has_channel_1 =3D true, +}; + +static const struct sun4i_tcon_quirks sun8i_a33_quirks =3D { + /* nothing is supported */ +}; + static const struct of_device_id sun4i_tcon_of_table[] =3D { - { .compatible =3D "allwinner,sun5i-a13-tcon" }, - { .compatible =3D "allwinner,sun8i-a33-tcon" }, + { .compatible =3D "allwinner,sun5i-a13-tcon", .data =3D &sun5i_a13_quirks= }, + { .compatible =3D "allwinner,sun8i-a33-tcon", .data =3D &sun8i_a33_quirks= }, { } }; MODULE_DEVICE_TABLE(of, sun4i_tcon_of_table); diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun= 4i_tcon.h index 12bd489..166064b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h @@ -142,6 +142,11 @@ =20 #define SUN4I_TCON_MAX_CHANNELS 2 =20 +struct sun4i_tcon_quirks { + bool has_unknown_mux; /* sun5i has undocumented mux */ + bool has_channel_1; /* a33 does not have channel 1 */ +}; + struct sun4i_tcon { struct device *dev; struct drm_device *drm; @@ -160,12 +165,10 @@ struct sun4i_tcon { /* Reset control */ struct reset_control *lcd_rst; =20 - /* Platform adjustments */ - bool has_mux; - struct drm_panel *panel; =20 - bool has_channel_1; + /* Platform adjustments */ + const struct sun4i_tcon_quirks *quirks; }; =20 struct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node); --=20 2.9.3