Skip to content

Commit

Permalink
drm/sun4i: tcon: Add support for tcon-top
Browse files Browse the repository at this point in the history
If SoC has TCON TOP unit, it has to be configured from TCON, since it
has all information needed. Additionally, if it is TCON TV, it must also
enable bus gate inside TCON TOP unit.

Add support for such TCONs.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
  • Loading branch information
jernejsk committed Mar 28, 2018
1 parent 1e1e9db commit 724df52
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
28 changes: 28 additions & 0 deletions drivers/gpu/drm/sun4i/sun4i_tcon.c
Expand Up @@ -583,6 +583,16 @@ static int sun4i_tcon_init_clocks(struct device *dev,
dev_err(dev, "Couldn't get the TCON bus clock\n");
return PTR_ERR(tcon->clk);
}

if (tcon->quirks->needs_tcon_top && tcon->quirks->has_channel_1) {
tcon->top_clk = devm_clk_get(dev, "tcon-top");
if (IS_ERR(tcon->top_clk)) {
dev_err(dev, "Couldn't get the TCON TOP bus clock\n");
return PTR_ERR(tcon->top_clk);
}
clk_prepare_enable(tcon->top_clk);
}

clk_prepare_enable(tcon->clk);

if (tcon->quirks->has_channel_0) {
Expand All @@ -607,6 +617,7 @@ static int sun4i_tcon_init_clocks(struct device *dev,
static void sun4i_tcon_free_clocks(struct sun4i_tcon *tcon)
{
clk_disable_unprepare(tcon->clk);
clk_disable_unprepare(tcon->top_clk);
}

static int sun4i_tcon_init_irq(struct device *dev,
Expand Down Expand Up @@ -874,6 +885,23 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master,
tcon->id = engine->id;
tcon->quirks = of_device_get_match_data(dev);

if (tcon->quirks->needs_tcon_top) {
struct device_node *np;

np = of_parse_phandle(dev->of_node, "allwinner,tcon-top", 0);
if (np) {
struct platform_device *pdev;

pdev = of_find_device_by_node(np);
if (pdev)
tcon->tcon_top = platform_get_drvdata(pdev);
of_node_put(np);

if (!tcon->tcon_top)
return -EPROBE_DEFER;
}
}

tcon->lcd_rst = devm_reset_control_get(dev, "lcd");
if (IS_ERR(tcon->lcd_rst)) {
dev_err(dev, "Couldn't get our reset line\n");
Expand Down
8 changes: 8 additions & 0 deletions drivers/gpu/drm/sun4i/sun4i_tcon.h
Expand Up @@ -20,6 +20,8 @@
#include <linux/list.h>
#include <linux/reset.h>

#include "sun8i_tcon_top.h"

#define SUN4I_TCON_GCTL_REG 0x0
#define SUN4I_TCON_GCTL_TCON_ENABLE BIT(31)
#define SUN4I_TCON_GCTL_IOMAP_MASK BIT(0)
Expand Down Expand Up @@ -177,6 +179,7 @@ struct sun4i_tcon_quirks {
bool has_lvds_alt; /* Does the LVDS clock have a parent other than the TCON clock? */
bool needs_de_be_mux; /* sun6i needs mux to select backend */
bool supports_lvds; /* Does the TCON support an LVDS output? */
bool needs_tcon_top;

/* callback to handle tcon muxing options */
int (*set_mux)(struct sun4i_tcon *, const struct drm_encoder *);
Expand All @@ -202,6 +205,9 @@ struct sun4i_tcon {
u8 dclk_max_div;
u8 dclk_min_div;

/* TCON TOP clock */
struct clk *top_clk;

/* Reset control */
struct reset_control *lcd_rst;
struct reset_control *lvds_rst;
Expand All @@ -216,6 +222,8 @@ struct sun4i_tcon {

int id;

struct sun8i_tcon_top *tcon_top;

/* TCON list management */
struct list_head list;
};
Expand Down

0 comments on commit 724df52

Please sign in to comment.