mirror of
https://github.com/Fishwaldo/build.git
synced 2025-05-25 08:22:04 +00:00
867 lines
26 KiB
Diff
867 lines
26 KiB
Diff
diff --git a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
|
|
index 5a9319ad8861..288b4cbc255e 100644
|
|
--- a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
|
|
+++ b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
|
|
@@ -399,6 +399,7 @@ Required properties:
|
|
* allwinner,sun8i-a33-display-engine
|
|
* allwinner,sun8i-a83t-display-engine
|
|
* allwinner,sun8i-h3-display-engine
|
|
+ * allwinner,sun8i-r40-display-engine
|
|
* allwinner,sun8i-v3s-display-engine
|
|
* allwinner,sun9i-a80-display-engine
|
|
|
|
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
|
|
index 6ddf4eaccb40..a15feb807393 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
|
|
@@ -417,6 +417,7 @@ static const struct of_device_id sun4i_drv_of_table[] = {
|
|
{ .compatible = "allwinner,sun8i-a33-display-engine" },
|
|
{ .compatible = "allwinner,sun8i-a83t-display-engine" },
|
|
{ .compatible = "allwinner,sun8i-h3-display-engine" },
|
|
+ { .compatible = "allwinner,sun8i-r40-display-engine" },
|
|
{ .compatible = "allwinner,sun8i-v3s-display-engine" },
|
|
{ .compatible = "allwinner,sun9i-a80-display-engine" },
|
|
{ }
|
|
diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
index c95a59aac48f..2afb079a3776 100644
|
|
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
@@ -102,8 +102,7 @@
|
|
};
|
|
|
|
de: display-engine {
|
|
- compatible = "allwinner,sun8i-r40-display-engine",
|
|
- "allwinner,sun8i-h3-display-engine";
|
|
+ compatible = "allwinner,sun8i-r40-display-engine";
|
|
allwinner,pipelines = <&mixer0>, <&mixer1>;
|
|
status = "disabled";
|
|
};
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
|
|
index 8da0460e0028..9fb51940156f 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
|
|
@@ -44,15 +44,20 @@ static int sun8i_tcon_top_get_connected_ep_id(struct device_node *node,
|
|
}
|
|
|
|
static struct clk_hw *sun8i_tcon_top_register_gate(struct device *dev,
|
|
- struct clk *parent,
|
|
+ const char *parent,
|
|
void __iomem *regs,
|
|
spinlock_t *lock,
|
|
u8 bit, int name_index)
|
|
{
|
|
const char *clk_name, *parent_name;
|
|
- int ret;
|
|
+ int ret, index;
|
|
+
|
|
+ index = of_property_match_string(dev->of_node, "clock-names", parent);
|
|
+ if (IS_ERR_VALUE(index))
|
|
+ return ERR_PTR(index);
|
|
+
|
|
+ parent_name = of_clk_get_parent_name(dev->of_node, index);
|
|
|
|
- parent_name = __clk_get_name(parent);
|
|
ret = of_property_read_string_index(dev->of_node,
|
|
"clock-output-names", name_index,
|
|
&clk_name);
|
|
@@ -69,7 +74,6 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
|
|
void *data)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
- struct clk *dsi, *tcon_tv0, *tcon_tv1, *tve0, *tve1;
|
|
struct clk_hw_onecell_data *clk_data;
|
|
struct sun8i_tcon_top *tcon_top;
|
|
bool mixer0_unused = false;
|
|
@@ -103,36 +107,6 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
|
|
return PTR_ERR(tcon_top->bus);
|
|
}
|
|
|
|
- dsi = devm_clk_get(dev, "dsi");
|
|
- if (IS_ERR(dsi)) {
|
|
- dev_err(dev, "Couldn't get the dsi clock\n");
|
|
- return PTR_ERR(dsi);
|
|
- }
|
|
-
|
|
- tcon_tv0 = devm_clk_get(dev, "tcon-tv0");
|
|
- if (IS_ERR(tcon_tv0)) {
|
|
- dev_err(dev, "Couldn't get the tcon-tv0 clock\n");
|
|
- return PTR_ERR(tcon_tv0);
|
|
- }
|
|
-
|
|
- tcon_tv1 = devm_clk_get(dev, "tcon-tv1");
|
|
- if (IS_ERR(tcon_tv1)) {
|
|
- dev_err(dev, "Couldn't get the tcon-tv1 clock\n");
|
|
- return PTR_ERR(tcon_tv1);
|
|
- }
|
|
-
|
|
- tve0 = devm_clk_get(dev, "tve0");
|
|
- if (IS_ERR(tve0)) {
|
|
- dev_err(dev, "Couldn't get the tve0 clock\n");
|
|
- return PTR_ERR(tve0);
|
|
- }
|
|
-
|
|
- tve1 = devm_clk_get(dev, "tve1");
|
|
- if (IS_ERR(tve1)) {
|
|
- dev_err(dev, "Couldn't get the tve1 clock\n");
|
|
- return PTR_ERR(tve1);
|
|
- }
|
|
-
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
regs = devm_ioremap_resource(dev, res);
|
|
if (IS_ERR(regs))
|
|
@@ -203,17 +177,17 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
|
|
* to TVE clock parent.
|
|
*/
|
|
clk_data->hws[CLK_TCON_TOP_TV0] =
|
|
- sun8i_tcon_top_register_gate(dev, tcon_tv0, regs,
|
|
+ sun8i_tcon_top_register_gate(dev, "tcon-tv0", regs,
|
|
&tcon_top->reg_lock,
|
|
TCON_TOP_TCON_TV0_GATE, 0);
|
|
|
|
clk_data->hws[CLK_TCON_TOP_TV1] =
|
|
- sun8i_tcon_top_register_gate(dev, tcon_tv1, regs,
|
|
+ sun8i_tcon_top_register_gate(dev, "tcon-tv1", regs,
|
|
&tcon_top->reg_lock,
|
|
TCON_TOP_TCON_TV1_GATE, 1);
|
|
|
|
clk_data->hws[CLK_TCON_TOP_DSI] =
|
|
- sun8i_tcon_top_register_gate(dev, dsi, regs,
|
|
+ sun8i_tcon_top_register_gate(dev, "dsi", regs,
|
|
&tcon_top->reg_lock,
|
|
TCON_TOP_TCON_DSI_GATE, 2);
|
|
|
|
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
|
|
index aacc841d3dc6..3fb084f802e2 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
|
|
@@ -811,6 +811,7 @@ sun4i_tcon_find_engine_traverse(struct sun4i_drv *drv,
|
|
* remote output id. If this for some reason can't be done, 0
|
|
* is used as input port id.
|
|
*/
|
|
+ of_node_put(port);
|
|
port = of_graph_get_remote_port(ep);
|
|
if (!of_property_read_u32(port, "reg", ®) && reg > 0)
|
|
reg -= 1;
|
|
diff --git a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
|
|
index 288b4cbc255e..7e2451396a28 100644
|
|
--- a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
|
|
+++ b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
|
|
@@ -147,6 +147,7 @@ Required properties:
|
|
* allwinner,sun8i-a33-tcon
|
|
* allwinner,sun8i-a83t-tcon-lcd
|
|
* allwinner,sun8i-a83t-tcon-tv
|
|
+ * allwinner,sun8i-r40-tcon-tv
|
|
* allwinner,sun8i-v3s-tcon
|
|
* allwinner,sun9i-a80-tcon-lcd
|
|
* allwinner,sun9i-a80-tcon-tv
|
|
@@ -181,7 +182,7 @@ For TCONs with channel 0, there is one more clock required:
|
|
For TCONs with channel 1, there is one more clock required:
|
|
- 'tcon-ch1': The clock driving the TCON channel 1
|
|
|
|
-When TCON support LVDS (all TCONs except TV TCON on A83T and those found
|
|
+When TCON support LVDS (all TCONs except TV TCONs on A83T, R40 and those found
|
|
in A13, H3, H5 and V3s SoCs), you need one more reset line:
|
|
- 'lvds': The reset line driving the LVDS logic
|
|
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
|
|
index 3459b9ec56c9..21dc9ebad0b4 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
|
|
@@ -53,22 +53,14 @@ static u32 sun8i_dw_hdmi_find_possible_crtcs(struct drm_device *drm,
|
|
struct device_node *port, *ep, *remote, *remote_port;
|
|
u32 crtcs = 0;
|
|
|
|
- port = of_graph_get_port_by_id(node, 0);
|
|
- if (!port)
|
|
- return 0;
|
|
-
|
|
- ep = of_get_next_available_child(port, NULL);
|
|
- if (!ep)
|
|
- return 0;
|
|
-
|
|
- remote = of_graph_get_remote_port_parent(ep);
|
|
+ remote = of_graph_get_remote_node(node, 0, -1);
|
|
if (!remote)
|
|
return 0;
|
|
|
|
if (sun8i_dw_hdmi_node_is_tcon_top(remote)) {
|
|
port = of_graph_get_port_by_id(remote, 4);
|
|
if (!port)
|
|
- return 0;
|
|
+ goto crtcs_exit;
|
|
|
|
for_each_child_of_node(port, ep) {
|
|
remote_port = of_graph_get_remote_port(ep);
|
|
@@ -81,6 +73,9 @@ static u32 sun8i_dw_hdmi_find_possible_crtcs(struct drm_device *drm,
|
|
crtcs = drm_of_find_possible_crtcs(drm, node);
|
|
}
|
|
|
|
+crtcs_exit:
|
|
+ of_node_put(remote);
|
|
+
|
|
return crtcs;
|
|
}
|
|
|
|
diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
index 2afb079a3776..1dd088d82773 100644
|
|
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
@@ -576,9 +576,12 @@
|
|
#size-cells = <0>;
|
|
|
|
tcon_top_mixer0_in: port@0 {
|
|
+ #address-cells = <1>;
|
|
+ #size-cells = <0>;
|
|
reg = <0>;
|
|
|
|
- tcon_top_mixer0_in_mixer0: endpoint {
|
|
+ tcon_top_mixer0_in_mixer0: endpoint@0 {
|
|
+ reg = <0>;
|
|
remote-endpoint = <&mixer0_out_tcon_top>;
|
|
};
|
|
};
|
|
@@ -606,9 +609,12 @@
|
|
};
|
|
|
|
tcon_top_mixer1_in: port@2 {
|
|
+ #address-cells = <1>;
|
|
+ #size-cells = <0>;
|
|
reg = <2>;
|
|
|
|
- tcon_top_mixer1_in_mixer1: endpoint {
|
|
+ tcon_top_mixer1_in_mixer1: endpoint@1 {
|
|
+ reg = <1>;
|
|
remote-endpoint = <&mixer1_out_tcon_top>;
|
|
};
|
|
};
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c
|
|
index ee8febb25903..11221f96746d 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
|
|
@@ -23,6 +23,7 @@
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/reset.h>
|
|
#include <linux/of_device.h>
|
|
+#include <linux/of_graph.h>
|
|
|
|
#include "sun4i_drv.h"
|
|
#include "sun8i_mixer.h"
|
|
@@ -322,6 +323,37 @@ static struct regmap_config sun8i_mixer_regmap_config = {
|
|
.max_register = 0xbfffc, /* guessed */
|
|
};
|
|
|
|
+static int sun8i_mixer_of_get_id(struct device_node *node)
|
|
+{
|
|
+ struct device_node *port, *ep;
|
|
+ int ret = -EINVAL;
|
|
+
|
|
+ /* output is port 1 */
|
|
+ port = of_graph_get_port_by_id(node, 1);
|
|
+ if (!port)
|
|
+ return -EINVAL;
|
|
+
|
|
+ /* try finding an upstream endpoint */
|
|
+ for_each_available_child_of_node(port, ep) {
|
|
+ struct device_node *remote;
|
|
+ u32 reg;
|
|
+
|
|
+ remote = of_graph_get_remote_endpoint(ep);
|
|
+ if (!remote)
|
|
+ continue;
|
|
+
|
|
+ ret = of_property_read_u32(remote, "reg", ®);
|
|
+ if (ret)
|
|
+ continue;
|
|
+
|
|
+ ret = reg;
|
|
+ }
|
|
+
|
|
+ of_node_put(port);
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+
|
|
static int sun8i_mixer_bind(struct device *dev, struct device *master,
|
|
void *data)
|
|
{
|
|
@@ -353,8 +385,7 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master,
|
|
dev_set_drvdata(dev, mixer);
|
|
mixer->engine.ops = &sun8i_engine_ops;
|
|
mixer->engine.node = dev->of_node;
|
|
- /* The ID of the mixer currently doesn't matter */
|
|
- mixer->engine.id = -1;
|
|
+ mixer->engine.id = sun8i_mixer_of_get_id(dev->of_node);
|
|
|
|
mixer->cfg = of_device_get_match_data(dev);
|
|
if (!mixer->cfg)
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
|
|
index 9fb51940156f..c09b15b64192 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
|
|
@@ -14,6 +14,79 @@
|
|
|
|
#include "sun8i_tcon_top.h"
|
|
|
|
+static bool sun8i_tcon_top_node_is_tcon_top(struct device_node *node)
|
|
+{
|
|
+ return !!of_match_node(sun8i_tcon_top_of_table, node);
|
|
+}
|
|
+
|
|
+int sun8i_tcon_top_set_hdmi_src(struct device *dev, int tcon)
|
|
+{
|
|
+ struct sun8i_tcon_top *tcon_top = dev_get_drvdata(dev);
|
|
+ unsigned long flags;
|
|
+ u32 val;
|
|
+
|
|
+ if (!sun8i_tcon_top_node_is_tcon_top(dev->of_node)) {
|
|
+ dev_err(dev, "Device is not TCON TOP!\n");
|
|
+ return -EINVAL;
|
|
+ }
|
|
+
|
|
+ if (tcon < 2 || tcon > 3) {
|
|
+ dev_err(dev, "TCON index must be 2 or 3!\n");
|
|
+ return -EINVAL;
|
|
+ }
|
|
+
|
|
+ spin_lock_irqsave(&tcon_top->reg_lock, flags);
|
|
+
|
|
+ val = readl(tcon_top->regs + TCON_TOP_GATE_SRC_REG);
|
|
+ val &= ~TCON_TOP_HDMI_SRC_MSK;
|
|
+ val |= FIELD_PREP(TCON_TOP_HDMI_SRC_MSK, tcon - 1);
|
|
+ writel(val, tcon_top->regs + TCON_TOP_GATE_SRC_REG);
|
|
+
|
|
+ spin_unlock_irqrestore(&tcon_top->reg_lock, flags);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+EXPORT_SYMBOL(sun8i_tcon_top_set_hdmi_src);
|
|
+
|
|
+int sun8i_tcon_top_de_config(struct device *dev, int mixer, int tcon)
|
|
+{
|
|
+ struct sun8i_tcon_top *tcon_top = dev_get_drvdata(dev);
|
|
+ unsigned long flags;
|
|
+ u32 reg;
|
|
+
|
|
+ if (!sun8i_tcon_top_node_is_tcon_top(dev->of_node)) {
|
|
+ dev_err(dev, "Device is not TCON TOP!\n");
|
|
+ return -EINVAL;
|
|
+ }
|
|
+
|
|
+ if (mixer > 1) {
|
|
+ dev_err(dev, "Mixer index is too high!\n");
|
|
+ return -EINVAL;
|
|
+ }
|
|
+
|
|
+ if (tcon > 3) {
|
|
+ dev_err(dev, "TCON index is too high!\n");
|
|
+ return -EINVAL;
|
|
+ }
|
|
+
|
|
+ spin_lock_irqsave(&tcon_top->reg_lock, flags);
|
|
+
|
|
+ reg = readl(tcon_top->regs + TCON_TOP_PORT_SEL_REG);
|
|
+ if (mixer == 0) {
|
|
+ reg &= ~TCON_TOP_PORT_DE0_MSK;
|
|
+ reg |= FIELD_PREP(TCON_TOP_PORT_DE0_MSK, tcon);
|
|
+ } else {
|
|
+ reg &= ~TCON_TOP_PORT_DE1_MSK;
|
|
+ reg |= FIELD_PREP(TCON_TOP_PORT_DE1_MSK, tcon);
|
|
+ }
|
|
+ writel(reg, tcon_top->regs + TCON_TOP_PORT_SEL_REG);
|
|
+
|
|
+ spin_unlock_irqrestore(&tcon_top->reg_lock, flags);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+EXPORT_SYMBOL(sun8i_tcon_top_de_config);
|
|
+
|
|
static int sun8i_tcon_top_get_connected_ep_id(struct device_node *node,
|
|
int port_id)
|
|
{
|
|
@@ -109,6 +182,7 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
regs = devm_ioremap_resource(dev, res);
|
|
+ tcon_top->regs = regs;
|
|
if (IS_ERR(regs))
|
|
return PTR_ERR(regs);
|
|
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.h b/drivers/gpu/drm/sun4i/sun8i_tcon_top.h
|
|
index 39838bbfeaee..0390584a330e 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.h
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.h
|
|
@@ -26,6 +26,7 @@
|
|
struct sun8i_tcon_top {
|
|
struct clk *bus;
|
|
struct clk_hw_onecell_data *clk_data;
|
|
+ void __iomem *regs;
|
|
struct reset_control *rst;
|
|
|
|
/*
|
|
@@ -37,4 +38,7 @@ struct sun8i_tcon_top {
|
|
|
|
extern const struct of_device_id sun8i_tcon_top_of_table[];
|
|
|
|
+int sun8i_tcon_top_set_hdmi_src(struct device *dev, int tcon);
|
|
+int sun8i_tcon_top_de_config(struct device *dev, int mixer, int tcon);
|
|
+
|
|
#endif /* _SUN8I_TCON_TOP_H_ */
|
|
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
|
|
index 3fb084f802e2..44ec3a3d4d64 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
|
|
@@ -35,6 +35,7 @@
|
|
#include "sun4i_rgb.h"
|
|
#include "sun4i_tcon.h"
|
|
#include "sun6i_mipi_dsi.h"
|
|
+#include "sun8i_tcon_top.h"
|
|
#include "sunxi_engine.h"
|
|
|
|
static struct drm_connector *sun4i_tcon_get_connector(const struct drm_encoder *encoder)
|
|
@@ -880,6 +881,36 @@ static struct sunxi_engine *sun4i_tcon_get_engine_by_id(struct sun4i_drv *drv,
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
+static bool sun4i_tcon_connected_to_tcon_top(struct device_node *node)
|
|
+{
|
|
+ struct device_node *remote;
|
|
+ bool ret = false;
|
|
+
|
|
+ remote = of_graph_get_remote_node(node, 0, -1);
|
|
+ if (remote) {
|
|
+ ret = !!of_match_node(sun8i_tcon_top_of_table, remote);
|
|
+ of_node_put(remote);
|
|
+ }
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static int sun4i_tcon_get_index(struct sun4i_drv *drv)
|
|
+{
|
|
+ struct list_head *pos;
|
|
+ int size = 0;
|
|
+
|
|
+ /*
|
|
+ * Because TCON is added to the list at the end of the probe
|
|
+ * (after this function is called), index of the current TCON
|
|
+ * will be same as current TCON list size.
|
|
+ */
|
|
+ list_for_each(pos, &drv->tcon_list)
|
|
+ ++size;
|
|
+
|
|
+ return size;
|
|
+}
|
|
+
|
|
/*
|
|
* On SoCs with the old display pipeline design (Display Engine 1.0),
|
|
* we assumed the TCON was always tied to just one backend. However
|
|
@@ -928,8 +959,24 @@ static struct sunxi_engine *sun4i_tcon_find_engine(struct sun4i_drv *drv,
|
|
* connections between the backend and TCON?
|
|
*/
|
|
if (of_get_child_count(port) > 1) {
|
|
- /* Get our ID directly from an upstream endpoint */
|
|
- int id = sun4i_tcon_of_get_id_from_port(port);
|
|
+ int id;
|
|
+
|
|
+ /*
|
|
+ * When pipeline has the same number of TCONs and engines which
|
|
+ * are represented by frontends/backends (DE1) or mixers (DE2),
|
|
+ * we match them by their respective IDs. However, if pipeline
|
|
+ * contains TCON TOP, chances are that there are either more
|
|
+ * TCONs than engines (R40) or TCONs with non-consecutive ids.
|
|
+ * (H6). In that case it's easier just use TCON index in list
|
|
+ * as an id. That means that on R40, any 2 TCONs can be enabled
|
|
+ * in DT out of 4 (there are 2 mixers). Due to the design of
|
|
+ * TCON TOP, remaining 2 TCONs can't be connected to anything
|
|
+ * anyway.
|
|
+ */
|
|
+ if (sun4i_tcon_connected_to_tcon_top(node))
|
|
+ id = sun4i_tcon_get_index(drv);
|
|
+ else
|
|
+ id = sun4i_tcon_of_get_id_from_port(port);
|
|
|
|
/* Get our engine by matching our ID */
|
|
engine = sun4i_tcon_get_engine_by_id(drv, id);
|
|
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
|
|
index 44ec3a3d4d64..5676b7faaca0 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
|
|
@@ -1291,6 +1291,40 @@ static int sun6i_tcon_set_mux(struct sun4i_tcon *tcon,
|
|
return 0;
|
|
}
|
|
|
|
+static int sun8i_r40_tcon_tv_set_mux(struct sun4i_tcon *tcon,
|
|
+ const struct drm_encoder *encoder)
|
|
+{
|
|
+ struct device_node *port, *remote;
|
|
+ struct platform_device *pdev;
|
|
+ int id, ret;
|
|
+
|
|
+ /* find TCON TOP platform device and TCON id */
|
|
+
|
|
+ port = of_graph_get_port_by_id(tcon->dev->of_node, 0);
|
|
+ if (!port)
|
|
+ return -EINVAL;
|
|
+
|
|
+ id = sun4i_tcon_of_get_id_from_port(port);
|
|
+ of_node_put(port);
|
|
+
|
|
+ remote = of_graph_get_remote_node(tcon->dev->of_node, 0, -1);
|
|
+ if (!remote)
|
|
+ return -EINVAL;
|
|
+
|
|
+ pdev = of_find_device_by_node(remote);
|
|
+ of_node_put(remote);
|
|
+ if (!pdev)
|
|
+ return -EINVAL;
|
|
+
|
|
+ if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) {
|
|
+ ret = sun8i_tcon_top_set_hdmi_src(&pdev->dev, id);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ return sun8i_tcon_top_de_config(&pdev->dev, tcon->id, id);
|
|
+}
|
|
+
|
|
static const struct sun4i_tcon_quirks sun4i_a10_quirks = {
|
|
.has_channel_0 = true,
|
|
.has_channel_1 = true,
|
|
@@ -1338,6 +1372,11 @@ static const struct sun4i_tcon_quirks sun8i_a83t_tv_quirks = {
|
|
.has_channel_1 = true,
|
|
};
|
|
|
|
+static const struct sun4i_tcon_quirks sun8i_r40_tv_quirks = {
|
|
+ .has_channel_1 = true,
|
|
+ .set_mux = sun8i_r40_tcon_tv_set_mux,
|
|
+};
|
|
+
|
|
static const struct sun4i_tcon_quirks sun8i_v3s_quirks = {
|
|
.has_channel_0 = true,
|
|
};
|
|
@@ -1362,6 +1401,7 @@ const struct of_device_id sun4i_tcon_of_table[] = {
|
|
{ .compatible = "allwinner,sun8i-a33-tcon", .data = &sun8i_a33_quirks },
|
|
{ .compatible = "allwinner,sun8i-a83t-tcon-lcd", .data = &sun8i_a83t_lcd_quirks },
|
|
{ .compatible = "allwinner,sun8i-a83t-tcon-tv", .data = &sun8i_a83t_tv_quirks },
|
|
+ { .compatible = "allwinner,sun8i-r40-tcon-tv", .data = &sun8i_r40_tv_quirks },
|
|
{ .compatible = "allwinner,sun8i-v3s-tcon", .data = &sun8i_v3s_quirks },
|
|
{ .compatible = "allwinner,sun9i-a80-tcon-lcd", .data = &sun9i_a80_tcon_lcd_quirks },
|
|
{ .compatible = "allwinner,sun9i-a80-tcon-tv", .data = &sun9i_a80_tcon_tv_quirks },
|
|
diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
index 1dd088d82773..6b4fe8eeee99 100644
|
|
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
@@ -666,8 +666,7 @@
|
|
};
|
|
|
|
tcon_tv0: lcd-controller@1c73000 {
|
|
- compatible = "allwinner,sun8i-r40-tcon-tv",
|
|
- "allwinner,sun8i-a83t-tcon-tv";
|
|
+ compatible = "allwinner,sun8i-r40-tcon-tv";
|
|
reg = <0x01c73000 0x1000>;
|
|
interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>;
|
|
clocks = <&ccu CLK_BUS_TCON_TV0>, <&tcon_top 0>;
|
|
@@ -690,8 +689,7 @@
|
|
};
|
|
|
|
tcon_tv1: lcd-controller@1c74000 {
|
|
- compatible = "allwinner,sun8i-r40-tcon-tv",
|
|
- "allwinner,sun8i-a83t-tcon-tv";
|
|
+ compatible = "allwinner,sun8i-r40-tcon-tv";
|
|
reg = <0x01c74000 0x1000>;
|
|
interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
|
|
clocks = <&ccu CLK_BUS_TCON_TV1>, <&tcon_top 1>;
|
|
diff --git a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
|
|
index 4f3d583183dc..737cf01b1acd 100644
|
|
--- a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
|
|
+++ b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
|
|
@@ -251,26 +251,6 @@
|
|
regulator-name = "vcc-wifi";
|
|
};
|
|
|
|
-&tcon_top_hdmi_in_tcon_tv0 {
|
|
- remote-endpoint = <&tcon_tv0_out_tcon_top>;
|
|
-};
|
|
-
|
|
-&tcon_top_mixer0_out_tcon_tv0 {
|
|
- remote-endpoint = <&tcon_tv0_in_tcon_top>;
|
|
-};
|
|
-
|
|
-&tcon_tv0_in {
|
|
- tcon_tv0_in_tcon_top: endpoint {
|
|
- remote-endpoint = <&tcon_top_mixer0_out_tcon_tv0>;
|
|
- };
|
|
-};
|
|
-
|
|
-&tcon_tv0_out {
|
|
- tcon_tv0_out_tcon_top: endpoint {
|
|
- remote-endpoint = <&tcon_top_hdmi_in_tcon_tv0>;
|
|
- };
|
|
-};
|
|
-
|
|
&uart0 {
|
|
pinctrl-names = "default";
|
|
pinctrl-0 = <&uart0_pb_pins>;
|
|
diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
index 6b4fe8eeee99..e5c7e4804384 100644
|
|
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
@@ -601,10 +601,12 @@
|
|
|
|
tcon_top_mixer0_out_tcon_tv0: endpoint@2 {
|
|
reg = <2>;
|
|
+ remote-endpoint = <&tcon_tv0_in_tcon_top_mixer0>;
|
|
};
|
|
|
|
tcon_top_mixer0_out_tcon_tv1: endpoint@3 {
|
|
reg = <3>;
|
|
+ remote-endpoint = <&tcon_tv1_in_tcon_top_mixer0>;
|
|
};
|
|
};
|
|
|
|
@@ -634,10 +636,12 @@
|
|
|
|
tcon_top_mixer1_out_tcon_tv0: endpoint@2 {
|
|
reg = <2>;
|
|
+ remote-endpoint = <&tcon_tv0_in_tcon_top_mixer1>;
|
|
};
|
|
|
|
tcon_top_mixer1_out_tcon_tv1: endpoint@3 {
|
|
reg = <3>;
|
|
+ remote-endpoint = <&tcon_tv1_in_tcon_top_mixer1>;
|
|
};
|
|
};
|
|
|
|
@@ -648,10 +652,12 @@
|
|
|
|
tcon_top_hdmi_in_tcon_tv0: endpoint@0 {
|
|
reg = <0>;
|
|
+ remote-endpoint = <&tcon_tv0_out_tcon_top>;
|
|
};
|
|
|
|
tcon_top_hdmi_in_tcon_tv1: endpoint@1 {
|
|
reg = <1>;
|
|
+ remote-endpoint = <&tcon_tv1_out_tcon_top>;
|
|
};
|
|
};
|
|
|
|
@@ -679,11 +685,30 @@
|
|
#size-cells = <0>;
|
|
|
|
tcon_tv0_in: port@0 {
|
|
+ #address-cells = <1>;
|
|
+ #size-cells = <0>;
|
|
reg = <0>;
|
|
+
|
|
+ tcon_tv0_in_tcon_top_mixer0: endpoint@0 {
|
|
+ reg = <0>;
|
|
+ remote-endpoint = <&tcon_top_mixer0_out_tcon_tv0>;
|
|
+ };
|
|
+
|
|
+ tcon_tv0_in_tcon_top_mixer1: endpoint@1 {
|
|
+ reg = <1>;
|
|
+ remote-endpoint = <&tcon_top_mixer1_out_tcon_tv0>;
|
|
+ };
|
|
};
|
|
|
|
tcon_tv0_out: port@1 {
|
|
+ #address-cells = <1>;
|
|
+ #size-cells = <0>;
|
|
reg = <1>;
|
|
+
|
|
+ tcon_tv0_out_tcon_top: endpoint@1 {
|
|
+ reg = <1>;
|
|
+ remote-endpoint = <&tcon_top_hdmi_in_tcon_tv0>;
|
|
+ };
|
|
};
|
|
};
|
|
};
|
|
@@ -702,11 +727,30 @@
|
|
#size-cells = <0>;
|
|
|
|
tcon_tv1_in: port@0 {
|
|
+ #address-cells = <1>;
|
|
+ #size-cells = <0>;
|
|
reg = <0>;
|
|
+
|
|
+ tcon_tv1_in_tcon_top_mixer0: endpoint@0 {
|
|
+ reg = <0>;
|
|
+ remote-endpoint = <&tcon_top_mixer0_out_tcon_tv1>;
|
|
+ };
|
|
+
|
|
+ tcon_tv1_in_tcon_top_mixer1: endpoint@1 {
|
|
+ reg = <1>;
|
|
+ remote-endpoint = <&tcon_top_mixer1_out_tcon_tv1>;
|
|
+ };
|
|
};
|
|
|
|
tcon_tv1_out: port@1 {
|
|
+ #address-cells = <1>;
|
|
+ #size-cells = <0>;
|
|
reg = <1>;
|
|
+
|
|
+ tcon_tv1_out_tcon_top: endpoint@1 {
|
|
+ reg = <1>;
|
|
+ remote-endpoint = <&tcon_top_hdmi_in_tcon_tv1>;
|
|
+ };
|
|
};
|
|
};
|
|
};
|
|
diff --git a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
|
|
index 737cf01b1acd..c39b9169ea64 100644
|
|
--- a/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
|
|
+++ b/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
|
|
@@ -251,6 +251,10 @@
|
|
regulator-name = "vcc-wifi";
|
|
};
|
|
|
|
+&tcon_tv0 {
|
|
+ status = "okay";
|
|
+};
|
|
+
|
|
&uart0 {
|
|
pinctrl-names = "default";
|
|
pinctrl-0 = <&uart0_pb_pins>;
|
|
diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
index e5c7e4804384..e2cbd4f645c5 100644
|
|
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
|
|
@@ -679,6 +679,7 @@
|
|
clock-names = "ahb", "tcon-ch1";
|
|
resets = <&ccu RST_BUS_TCON_TV0>;
|
|
reset-names = "lcd";
|
|
+ status = "disabled";
|
|
|
|
ports {
|
|
#address-cells = <1>;
|
|
@@ -721,6 +722,7 @@
|
|
clock-names = "ahb", "tcon-ch1";
|
|
resets = <&ccu RST_BUS_TCON_TV1>;
|
|
reset-names = "lcd";
|
|
+ status = "disabled";
|
|
|
|
ports {
|
|
#address-cells = <1>;
|
|
diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
|
|
index c09b15b64192..78795d6cb174 100644
|
|
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
|
|
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
|
|
@@ -87,34 +87,6 @@ int sun8i_tcon_top_de_config(struct device *dev, int mixer, int tcon)
|
|
}
|
|
EXPORT_SYMBOL(sun8i_tcon_top_de_config);
|
|
|
|
-static int sun8i_tcon_top_get_connected_ep_id(struct device_node *node,
|
|
- int port_id)
|
|
-{
|
|
- struct device_node *ep, *remote, *port;
|
|
- struct of_endpoint endpoint;
|
|
-
|
|
- port = of_graph_get_port_by_id(node, port_id);
|
|
- if (!port)
|
|
- return -ENOENT;
|
|
-
|
|
- for_each_available_child_of_node(port, ep) {
|
|
- remote = of_graph_get_remote_port_parent(ep);
|
|
- if (!remote)
|
|
- continue;
|
|
-
|
|
- if (of_device_is_available(remote)) {
|
|
- of_graph_parse_endpoint(ep, &endpoint);
|
|
-
|
|
- of_node_put(remote);
|
|
-
|
|
- return endpoint.id;
|
|
- }
|
|
-
|
|
- of_node_put(remote);
|
|
- }
|
|
-
|
|
- return -ENOENT;
|
|
-}
|
|
|
|
static struct clk_hw *sun8i_tcon_top_register_gate(struct device *dev,
|
|
const char *parent,
|
|
@@ -149,11 +121,9 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
|
|
struct platform_device *pdev = to_platform_device(dev);
|
|
struct clk_hw_onecell_data *clk_data;
|
|
struct sun8i_tcon_top *tcon_top;
|
|
- bool mixer0_unused = false;
|
|
struct resource *res;
|
|
void __iomem *regs;
|
|
- int ret, i, id;
|
|
- u32 val;
|
|
+ int ret, i;
|
|
|
|
tcon_top = devm_kzalloc(dev, sizeof(*tcon_top), GFP_KERNEL);
|
|
if (!tcon_top)
|
|
@@ -198,49 +168,12 @@ static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
|
|
goto err_assert_reset;
|
|
}
|
|
|
|
- val = 0;
|
|
-
|
|
- /* check if HDMI mux output is connected */
|
|
- if (sun8i_tcon_top_get_connected_ep_id(dev->of_node, 5) >= 0) {
|
|
- /* find HDMI input endpoint id, if it is connected at all*/
|
|
- id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 4);
|
|
- if (id >= 0)
|
|
- val = FIELD_PREP(TCON_TOP_HDMI_SRC_MSK, id + 1);
|
|
- else
|
|
- DRM_DEBUG_DRIVER("TCON TOP HDMI input is not connected\n");
|
|
- } else {
|
|
- DRM_DEBUG_DRIVER("TCON TOP HDMI output is not connected\n");
|
|
- }
|
|
-
|
|
- writel(val, regs + TCON_TOP_GATE_SRC_REG);
|
|
-
|
|
- val = 0;
|
|
-
|
|
- /* process mixer0 mux output */
|
|
- id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 1);
|
|
- if (id >= 0) {
|
|
- val = FIELD_PREP(TCON_TOP_PORT_DE0_MSK, id);
|
|
- } else {
|
|
- DRM_DEBUG_DRIVER("TCON TOP mixer0 output is not connected\n");
|
|
- mixer0_unused = true;
|
|
- }
|
|
-
|
|
- /* process mixer1 mux output */
|
|
- id = sun8i_tcon_top_get_connected_ep_id(dev->of_node, 3);
|
|
- if (id >= 0) {
|
|
- val |= FIELD_PREP(TCON_TOP_PORT_DE1_MSK, id);
|
|
-
|
|
- /*
|
|
- * mixer0 mux has priority over mixer1 mux. We have to
|
|
- * make sure mixer0 doesn't overtake TCON from mixer1.
|
|
- */
|
|
- if (mixer0_unused && id == 0)
|
|
- val |= FIELD_PREP(TCON_TOP_PORT_DE0_MSK, 1);
|
|
- } else {
|
|
- DRM_DEBUG_DRIVER("TCON TOP mixer1 output is not connected\n");
|
|
- }
|
|
-
|
|
- writel(val, regs + TCON_TOP_PORT_SEL_REG);
|
|
+ /*
|
|
+ * Default register values might have some reserved bits set, which
|
|
+ * prevents TCON TOP from working properly. Set them to 0 here.
|
|
+ */
|
|
+ writel(0, regs + TCON_TOP_GATE_SRC_REG);
|
|
+ writel(0, regs + TCON_TOP_PORT_SEL_REG);
|
|
|
|
/*
|
|
* TCON TOP has two muxes, which select parent clock for each TCON TV
|
|
diff --git a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
|
|
index 7e2451396a28..f8773ecb7525 100644
|
|
--- a/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
|
|
+++ b/Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt
|
|
@@ -101,9 +101,9 @@ DWC HDMI PHY
|
|
|
|
Required properties:
|
|
- compatible: value must be one of:
|
|
- * allwinner,sun50i-a64-hdmi-phy
|
|
* allwinner,sun8i-a83t-hdmi-phy
|
|
* allwinner,sun8i-h3-hdmi-phy
|
|
+ * allwinner,sun50i-a64-hdmi-phy
|
|
- reg: base address and size of memory-mapped region
|
|
- clocks: phandles to the clocks feeding the HDMI PHY
|
|
* bus: the HDMI PHY interface clock
|