diff options
| author | Chen-Yu Tsai <wens@csie.org> | 2016-10-19 23:43:39 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-04-12 06:41:15 -0400 |
| commit | 06a2bb472f71c6e2ed2a51c06608680dc20eb327 (patch) | |
| tree | d75d732c7456b9afecf92e721247a89fae0764a1 /drivers/gpu | |
| parent | 7c03613344663982a27c49d5951c80c575714ab8 (diff) | |
drm/sun4i: tcon: Move SoC specific quirks to a DT matched data structure
commit 91ea2f29cba6a7fe035ea232e4f981211a9fce5d upstream.
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 <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/gpu')
| -rw-r--r-- | drivers/gpu/drm/sun4i/sun4i_tcon.c | 33 | ||||
| -rw-r--r-- | 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/sun4i_tcon.c index cadacb517f95..7658f0337e0b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/component.h> | 20 | #include <linux/component.h> |
| 21 | #include <linux/ioport.h> | 21 | #include <linux/ioport.h> |
| 22 | #include <linux/of_address.h> | 22 | #include <linux/of_address.h> |
| 23 | #include <linux/of_device.h> | ||
| 23 | #include <linux/of_graph.h> | 24 | #include <linux/of_graph.h> |
| 24 | #include <linux/of_irq.h> | 25 | #include <linux/of_irq.h> |
| 25 | #include <linux/regmap.h> | 26 | #include <linux/regmap.h> |
| @@ -62,7 +63,7 @@ void sun4i_tcon_channel_disable(struct sun4i_tcon *tcon, int channel) | |||
| 62 | return; | 63 | return; |
| 63 | } | 64 | } |
| 64 | 65 | ||
| 65 | WARN_ON(!tcon->has_channel_1); | 66 | WARN_ON(!tcon->quirks->has_channel_1); |
| 66 | regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG, | 67 | regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG, |
| 67 | SUN4I_TCON1_CTL_TCON_ENABLE, 0); | 68 | SUN4I_TCON1_CTL_TCON_ENABLE, 0); |
| 68 | clk_disable_unprepare(tcon->sclk1); | 69 | clk_disable_unprepare(tcon->sclk1); |
| @@ -80,7 +81,7 @@ void sun4i_tcon_channel_enable(struct sun4i_tcon *tcon, int channel) | |||
| 80 | return; | 81 | return; |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | WARN_ON(!tcon->has_channel_1); | 84 | WARN_ON(!tcon->quirks->has_channel_1); |
| 84 | regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG, | 85 | regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG, |
| 85 | SUN4I_TCON1_CTL_TCON_ENABLE, | 86 | SUN4I_TCON1_CTL_TCON_ENABLE, |
| 86 | SUN4I_TCON1_CTL_TCON_ENABLE); | 87 | SUN4I_TCON1_CTL_TCON_ENABLE); |
| @@ -202,7 +203,7 @@ void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon, | |||
| 202 | u8 clk_delay; | 203 | u8 clk_delay; |
| 203 | u32 val; | 204 | u32 val; |
| 204 | 205 | ||
| 205 | WARN_ON(!tcon->has_channel_1); | 206 | WARN_ON(!tcon->quirks->has_channel_1); |
| 206 | 207 | ||
| 207 | /* Adjust clock delay */ | 208 | /* Adjust clock delay */ |
| 208 | clk_delay = sun4i_tcon_get_clk_delay(mode, 1); | 209 | clk_delay = sun4i_tcon_get_clk_delay(mode, 1); |
| @@ -266,7 +267,7 @@ void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon, | |||
| 266 | /* | 267 | /* |
| 267 | * FIXME: Undocumented bits | 268 | * FIXME: Undocumented bits |
| 268 | */ | 269 | */ |
| 269 | if (tcon->has_mux) | 270 | if (tcon->quirks->has_unknown_mux) |
| 270 | regmap_write(tcon->regs, SUN4I_TCON_MUX_CTRL_REG, 1); | 271 | regmap_write(tcon->regs, SUN4I_TCON_MUX_CTRL_REG, 1); |
| 271 | } | 272 | } |
| 272 | EXPORT_SYMBOL(sun4i_tcon1_mode_set); | 273 | EXPORT_SYMBOL(sun4i_tcon1_mode_set); |
| @@ -327,7 +328,7 @@ static int sun4i_tcon_init_clocks(struct device *dev, | |||
| 327 | return PTR_ERR(tcon->sclk0); | 328 | return PTR_ERR(tcon->sclk0); |
| 328 | } | 329 | } |
| 329 | 330 | ||
| 330 | if (tcon->has_channel_1) { | 331 | if (tcon->quirks->has_channel_1) { |
| 331 | tcon->sclk1 = devm_clk_get(dev, "tcon-ch1"); | 332 | tcon->sclk1 = devm_clk_get(dev, "tcon-ch1"); |
| 332 | if (IS_ERR(tcon->sclk1)) { | 333 | if (IS_ERR(tcon->sclk1)) { |
| 333 | dev_err(dev, "Couldn't get the TCON channel 1 clock\n"); | 334 | 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, | |||
| 487 | drv->tcon = tcon; | 488 | drv->tcon = tcon; |
| 488 | tcon->drm = drm; | 489 | tcon->drm = drm; |
| 489 | tcon->dev = dev; | 490 | tcon->dev = dev; |
| 490 | 491 | tcon->quirks = of_device_get_match_data(dev); | |
| 491 | if (of_device_is_compatible(dev->of_node, "allwinner,sun5i-a13-tcon")) { | ||
| 492 | tcon->has_mux = true; | ||
| 493 | tcon->has_channel_1 = true; | ||
| 494 | } else { | ||
| 495 | tcon->has_mux = false; | ||
| 496 | tcon->has_channel_1 = false; | ||
| 497 | } | ||
| 498 | 492 | ||
| 499 | tcon->lcd_rst = devm_reset_control_get(dev, "lcd"); | 493 | tcon->lcd_rst = devm_reset_control_get(dev, "lcd"); |
| 500 | if (IS_ERR(tcon->lcd_rst)) { | 494 | if (IS_ERR(tcon->lcd_rst)) { |
| @@ -588,9 +582,18 @@ static int sun4i_tcon_remove(struct platform_device *pdev) | |||
| 588 | return 0; | 582 | return 0; |
| 589 | } | 583 | } |
| 590 | 584 | ||
| 585 | static const struct sun4i_tcon_quirks sun5i_a13_quirks = { | ||
| 586 | .has_unknown_mux = true, | ||
| 587 | .has_channel_1 = true, | ||
| 588 | }; | ||
| 589 | |||
| 590 | static const struct sun4i_tcon_quirks sun8i_a33_quirks = { | ||
| 591 | /* nothing is supported */ | ||
| 592 | }; | ||
| 593 | |||
| 591 | static const struct of_device_id sun4i_tcon_of_table[] = { | 594 | static const struct of_device_id sun4i_tcon_of_table[] = { |
| 592 | { .compatible = "allwinner,sun5i-a13-tcon" }, | 595 | { .compatible = "allwinner,sun5i-a13-tcon", .data = &sun5i_a13_quirks }, |
| 593 | { .compatible = "allwinner,sun8i-a33-tcon" }, | 596 | { .compatible = "allwinner,sun8i-a33-tcon", .data = &sun8i_a33_quirks }, |
| 594 | { } | 597 | { } |
| 595 | }; | 598 | }; |
| 596 | MODULE_DEVICE_TABLE(of, sun4i_tcon_of_table); | 599 | MODULE_DEVICE_TABLE(of, sun4i_tcon_of_table); |
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h index 12bd48925f4d..166064bafe2e 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h | |||
| @@ -142,6 +142,11 @@ | |||
| 142 | 142 | ||
| 143 | #define SUN4I_TCON_MAX_CHANNELS 2 | 143 | #define SUN4I_TCON_MAX_CHANNELS 2 |
| 144 | 144 | ||
| 145 | struct sun4i_tcon_quirks { | ||
| 146 | bool has_unknown_mux; /* sun5i has undocumented mux */ | ||
| 147 | bool has_channel_1; /* a33 does not have channel 1 */ | ||
| 148 | }; | ||
| 149 | |||
| 145 | struct sun4i_tcon { | 150 | struct sun4i_tcon { |
| 146 | struct device *dev; | 151 | struct device *dev; |
| 147 | struct drm_device *drm; | 152 | struct drm_device *drm; |
| @@ -160,12 +165,10 @@ struct sun4i_tcon { | |||
| 160 | /* Reset control */ | 165 | /* Reset control */ |
| 161 | struct reset_control *lcd_rst; | 166 | struct reset_control *lcd_rst; |
| 162 | 167 | ||
| 163 | /* Platform adjustments */ | ||
| 164 | bool has_mux; | ||
| 165 | |||
| 166 | struct drm_panel *panel; | 168 | struct drm_panel *panel; |
| 167 | 169 | ||
| 168 | bool has_channel_1; | 170 | /* Platform adjustments */ |
| 171 | const struct sun4i_tcon_quirks *quirks; | ||
| 169 | }; | 172 | }; |
| 170 | 173 | ||
| 171 | struct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node); | 174 | struct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node); |
