linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Add support to the mmsys driver to be a reset controller
@ 2021-06-30 14:46 Enric Balletbo i Serra
  2021-06-30 14:46 ` [PATCH 1/6] arm64: dts: mediatek: Move reset controller constants into common location Enric Balletbo i Serra
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Enric Balletbo i Serra @ 2021-06-30 14:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: jitao.shi, chunkuang.hu, matthias.bgg, drinkcat, eizan, kernel,
	linux-mediatek, hsinyi, Crystal Guo, Daniel Vetter, David Airlie,
	Fabien Parent, Guenter Roeck, Philipp Zabel, Rob Herring,
	Wim Van Sebroeck, devicetree, dri-devel, linux-arm-kernel

Dear all,

The following patchset is a reimplementation of the patch sent by Jitao
Shi [1] some time ago. As suggested by Chun-Kuang Hu, this time the
reset is done using the reset API, where the mmsys driver is the reset
controller and the mtk_dsi driver is the reset consumer.

Note that the first patch is kind of unrelated change, it's just a
cleanup but is needed if you want to apply all the following patches
cleanly.

This patchset is important in order to have the DSI panel working on some
kukui MT8183 Chromebooks (i.e Lenovo IdeaPad Duet). Without it, you just
get a black screen.

Best regards,
  Enric

[1] https://lore.kernel.org/linux-arm-kernel/20210420132614.150242-4-jitao.shi@mediatek.com/

Enric Balletbo i Serra (6):
  arm64: dts: mediatek: Move reset controller constants into common
    location
  dt-bindings: mediatek: Add #reset-cells to mmsys system controller
  arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0
  arm64: dts: mt8183: Add the mmsys reset bit to reset the dsi0
  soc: mediatek: mmsys: Add reset controller support
  drm/mediatek: mtk_dsi: Reset the dsi0 hardware

 .../bindings/arm/mediatek/mediatek,mmsys.txt  |  2 +
 arch/arm64/boot/dts/mediatek/mt8173.dtsi      |  2 +
 arch/arm64/boot/dts/mediatek/mt8183.dtsi      |  5 +-
 drivers/gpu/drm/mediatek/mtk_dsi.c            |  5 +-
 drivers/soc/mediatek/mtk-mmsys.c              | 69 +++++++++++++++++++
 drivers/soc/mediatek/mtk-mmsys.h              |  2 +
 .../mt2712-resets.h                           |  0
 include/dt-bindings/reset/mt8173-resets.h     |  2 +
 .../mt8183-resets.h                           |  3 +
 .../mt8192-resets.h                           |  0
 10 files changed, 87 insertions(+), 3 deletions(-)
 rename include/dt-bindings/{reset-controller => reset}/mt2712-resets.h (100%)
 rename include/dt-bindings/{reset-controller => reset}/mt8183-resets.h (98%)
 rename include/dt-bindings/{reset-controller => reset}/mt8192-resets.h (100%)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/6] arm64: dts: mediatek: Move reset controller constants into common location
  2021-06-30 14:46 [PATCH 0/6] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
@ 2021-06-30 14:46 ` Enric Balletbo i Serra
  2021-06-30 17:52   ` kernel test robot
  2021-07-01  1:06   ` kernel test robot
  2021-06-30 14:46 ` [PATCH 2/6] dt-bindings: mediatek: Add #reset-cells to mmsys system controller Enric Balletbo i Serra
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 11+ messages in thread
From: Enric Balletbo i Serra @ 2021-06-30 14:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: jitao.shi, chunkuang.hu, matthias.bgg, drinkcat, eizan, kernel,
	linux-mediatek, hsinyi, Crystal Guo, Guenter Roeck,
	Philipp Zabel, Rob Herring, Wim Van Sebroeck, devicetree,
	linux-arm-kernel

The DT binding includes for reset controllers are located in
include/dt-bindings/reset/. Move the Mediatek reset constants in there.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---

 arch/arm64/boot/dts/mediatek/mt8183.dtsi                        | 2 +-
 include/dt-bindings/{reset-controller => reset}/mt2712-resets.h | 0
 include/dt-bindings/{reset-controller => reset}/mt8183-resets.h | 0
 include/dt-bindings/{reset-controller => reset}/mt8192-resets.h | 0
 4 files changed, 1 insertion(+), 1 deletion(-)
 rename include/dt-bindings/{reset-controller => reset}/mt2712-resets.h (100%)
 rename include/dt-bindings/{reset-controller => reset}/mt8183-resets.h (100%)
 rename include/dt-bindings/{reset-controller => reset}/mt8192-resets.h (100%)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 27b4947b609f..085e2c96b5f4 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -11,7 +11,7 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/memory/mt8183-larb-port.h>
 #include <dt-bindings/power/mt8183-power.h>
-#include <dt-bindings/reset-controller/mt8183-resets.h>
+#include <dt-bindings/reset/mt8183-resets.h>
 #include <dt-bindings/phy/phy.h>
 #include <dt-bindings/thermal/thermal.h>
 #include "mt8183-pinfunc.h"
diff --git a/include/dt-bindings/reset-controller/mt2712-resets.h b/include/dt-bindings/reset/mt2712-resets.h
similarity index 100%
rename from include/dt-bindings/reset-controller/mt2712-resets.h
rename to include/dt-bindings/reset/mt2712-resets.h
diff --git a/include/dt-bindings/reset-controller/mt8183-resets.h b/include/dt-bindings/reset/mt8183-resets.h
similarity index 100%
rename from include/dt-bindings/reset-controller/mt8183-resets.h
rename to include/dt-bindings/reset/mt8183-resets.h
diff --git a/include/dt-bindings/reset-controller/mt8192-resets.h b/include/dt-bindings/reset/mt8192-resets.h
similarity index 100%
rename from include/dt-bindings/reset-controller/mt8192-resets.h
rename to include/dt-bindings/reset/mt8192-resets.h
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/6] dt-bindings: mediatek: Add #reset-cells to mmsys system controller
  2021-06-30 14:46 [PATCH 0/6] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
  2021-06-30 14:46 ` [PATCH 1/6] arm64: dts: mediatek: Move reset controller constants into common location Enric Balletbo i Serra
@ 2021-06-30 14:46 ` Enric Balletbo i Serra
  2021-06-30 14:46 ` [PATCH 3/6] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0 Enric Balletbo i Serra
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Enric Balletbo i Serra @ 2021-06-30 14:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: jitao.shi, chunkuang.hu, matthias.bgg, drinkcat, eizan, kernel,
	linux-mediatek, hsinyi, Fabien Parent, Rob Herring, devicetree,
	linux-arm-kernel

The mmsys system controller exposes a set of memory client resets and
needs to specify the #reset-cells property in order to advertise the
number of cells needed to describe each of the resets.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---

 .../devicetree/bindings/arm/mediatek/mediatek,mmsys.txt         | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
index 78c50733985c..ce958446558e 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
@@ -17,6 +17,7 @@ Required Properties:
 	- "mediatek,mt8173-mmsys", "syscon"
 	- "mediatek,mt8183-mmsys", "syscon"
 - #clock-cells: Must be 1
+- #reset-cells: Must be 1
 
 For the clock control, the mmsys controller uses the common clk binding from
 Documentation/devicetree/bindings/clock/clock-bindings.txt
@@ -28,4 +29,5 @@ mmsys: syscon@14000000 {
 	compatible = "mediatek,mt8173-mmsys", "syscon";
 	reg = <0 0x14000000 0 0x1000>;
 	#clock-cells = <1>;
+	#reset-cells = <1>;
 };
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/6] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0
  2021-06-30 14:46 [PATCH 0/6] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
  2021-06-30 14:46 ` [PATCH 1/6] arm64: dts: mediatek: Move reset controller constants into common location Enric Balletbo i Serra
  2021-06-30 14:46 ` [PATCH 2/6] dt-bindings: mediatek: Add #reset-cells to mmsys system controller Enric Balletbo i Serra
@ 2021-06-30 14:46 ` Enric Balletbo i Serra
  2021-06-30 22:48   ` Chun-Kuang Hu
  2021-06-30 14:46 ` [PATCH 4/6] arm64: dts: mt8183: " Enric Balletbo i Serra
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Enric Balletbo i Serra @ 2021-06-30 14:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: jitao.shi, chunkuang.hu, matthias.bgg, drinkcat, eizan, kernel,
	linux-mediatek, hsinyi, Philipp Zabel, Rob Herring, devicetree,
	linux-arm-kernel

Reset the DSI hardware is needed to prevent different settings between
the bootloader and the kernel.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---

 arch/arm64/boot/dts/mediatek/mt8173.dtsi  | 2 ++
 include/dt-bindings/reset/mt8173-resets.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index e5596fe01a1d..36c3998eb7f1 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -1036,6 +1036,7 @@ mmsys: syscon@14000000 {
 			assigned-clocks = <&topckgen CLK_TOP_MM_SEL>;
 			assigned-clock-rates = <400000000>;
 			#clock-cells = <1>;
+			#reset-cells = <1>;
 			mboxes = <&gce 0 CMDQ_THR_PRIO_HIGHEST>,
 				 <&gce 1 CMDQ_THR_PRIO_HIGHEST>;
 			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0 0x1000>;
@@ -1262,6 +1263,7 @@ dsi0: dsi@1401b000 {
 				 <&mmsys CLK_MM_DSI0_DIGITAL>,
 				 <&mipi_tx0>;
 			clock-names = "engine", "digital", "hs";
+			resets = <&mmsys MT8173_MMSYS_SW0_RST_B_DISP_DSI0>;
 			phys = <&mipi_tx0>;
 			phy-names = "dphy";
 			status = "disabled";
diff --git a/include/dt-bindings/reset/mt8173-resets.h b/include/dt-bindings/reset/mt8173-resets.h
index ba8636eda5ae..6a60c7cecc4c 100644
--- a/include/dt-bindings/reset/mt8173-resets.h
+++ b/include/dt-bindings/reset/mt8173-resets.h
@@ -27,6 +27,8 @@
 #define MT8173_INFRA_GCE_FAXI_RST       40
 #define MT8173_INFRA_MMIOMMURST         47
 
+/* MMSYS resets */
+#define MT8173_MMSYS_SW0_RST_B_DISP_DSI0	25
 
 /*  PERICFG resets */
 #define MT8173_PERI_UART0_SW_RST        0
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/6] arm64: dts: mt8183: Add the mmsys reset bit to reset the dsi0
  2021-06-30 14:46 [PATCH 0/6] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
                   ` (2 preceding siblings ...)
  2021-06-30 14:46 ` [PATCH 3/6] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0 Enric Balletbo i Serra
@ 2021-06-30 14:46 ` Enric Balletbo i Serra
  2021-06-30 14:46 ` [PATCH 5/6] soc: mediatek: mmsys: Add reset controller support Enric Balletbo i Serra
  2021-06-30 14:46 ` [PATCH 6/6] drm/mediatek: mtk_dsi: Reset the dsi0 hardware Enric Balletbo i Serra
  5 siblings, 0 replies; 11+ messages in thread
From: Enric Balletbo i Serra @ 2021-06-30 14:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: jitao.shi, chunkuang.hu, matthias.bgg, drinkcat, eizan, kernel,
	linux-mediatek, hsinyi, Philipp Zabel, Rob Herring, devicetree,
	linux-arm-kernel

Reset the DSI hardware is needed to prevent different settings between
the bootloader and the kernel.

While here, also remove the undocumented and also not used
'mediatek,syscon-dsi' property.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---

 arch/arm64/boot/dts/mediatek/mt8183.dtsi  | 3 ++-
 include/dt-bindings/reset/mt8183-resets.h | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 085e2c96b5f4..2d02365633c3 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -1286,6 +1286,7 @@ mmsys: syscon@14000000 {
 			compatible = "mediatek,mt8183-mmsys", "syscon";
 			reg = <0 0x14000000 0 0x1000>;
 			#clock-cells = <1>;
+			#reset-cells = <1>;
 			mboxes = <&gce 0 CMDQ_THR_PRIO_HIGHEST>,
 				 <&gce 1 CMDQ_THR_PRIO_HIGHEST>;
 			mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0 0x1000>;
@@ -1400,11 +1401,11 @@ dsi0: dsi@14014000 {
 			reg = <0 0x14014000 0 0x1000>;
 			interrupts = <GIC_SPI 236 IRQ_TYPE_LEVEL_LOW>;
 			power-domains = <&spm MT8183_POWER_DOMAIN_DISP>;
-			mediatek,syscon-dsi = <&mmsys 0x140>;
 			clocks = <&mmsys CLK_MM_DSI0_MM>,
 				 <&mmsys CLK_MM_DSI0_IF>,
 				 <&mipi_tx0>;
 			clock-names = "engine", "digital", "hs";
+			resets = <&mmsys MT8183_MMSYS_SW0_RST_B_DISP_DSI0>;
 			phys = <&mipi_tx0>;
 			phy-names = "dphy";
 		};
diff --git a/include/dt-bindings/reset/mt8183-resets.h b/include/dt-bindings/reset/mt8183-resets.h
index a1bbd41e0d12..48c5d2de0a38 100644
--- a/include/dt-bindings/reset/mt8183-resets.h
+++ b/include/dt-bindings/reset/mt8183-resets.h
@@ -80,6 +80,9 @@
 
 #define MT8183_INFRACFG_SW_RST_NUM				128
 
+/* MMSYS resets */
+#define MT8183_MMSYS_SW0_RST_B_DISP_DSI0			25
+
 #define MT8183_TOPRGU_MM_SW_RST					1
 #define MT8183_TOPRGU_MFG_SW_RST				2
 #define MT8183_TOPRGU_VENC_SW_RST				3
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/6] soc: mediatek: mmsys: Add reset controller support
  2021-06-30 14:46 [PATCH 0/6] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
                   ` (3 preceding siblings ...)
  2021-06-30 14:46 ` [PATCH 4/6] arm64: dts: mt8183: " Enric Balletbo i Serra
@ 2021-06-30 14:46 ` Enric Balletbo i Serra
  2021-06-30 14:46 ` [PATCH 6/6] drm/mediatek: mtk_dsi: Reset the dsi0 hardware Enric Balletbo i Serra
  5 siblings, 0 replies; 11+ messages in thread
From: Enric Balletbo i Serra @ 2021-06-30 14:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: jitao.shi, chunkuang.hu, matthias.bgg, drinkcat, eizan, kernel,
	linux-mediatek, hsinyi, Philipp Zabel, linux-arm-kernel

Among other features the mmsys driver should implement a reset
controller to be able to reset different bits from their space.

Cc: Jitao Shi <jitao.shi@mediatek.com>
Suggested-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---

 drivers/soc/mediatek/mtk-mmsys.c | 69 ++++++++++++++++++++++++++++++++
 drivers/soc/mediatek/mtk-mmsys.h |  2 +
 2 files changed, 71 insertions(+)

diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c
index 080660ef11bf..c4ed99d92d1a 100644
--- a/drivers/soc/mediatek/mtk-mmsys.c
+++ b/drivers/soc/mediatek/mtk-mmsys.c
@@ -4,10 +4,12 @@
  * Author: James Liao <jamesjj.liao@mediatek.com>
  */
 
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/io.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
+#include <linux/reset-controller.h>
 #include <linux/soc/mediatek/mtk-mmsys.h>
 
 #include "mtk-mmsys.h"
@@ -55,6 +57,8 @@ static const struct mtk_mmsys_driver_data mt8183_mmsys_driver_data = {
 struct mtk_mmsys {
 	void __iomem *regs;
 	const struct mtk_mmsys_driver_data *data;
+	spinlock_t lock; /* protects mmsys_sw_rst_b reg */
+	struct reset_controller_dev rcdev;
 };
 
 void mtk_mmsys_ddp_connect(struct device *dev,
@@ -91,6 +95,59 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
 
+static int mtk_mmsys_reset_update(struct reset_controller_dev *rcdev, unsigned long id,
+				  bool assert)
+{
+	struct mtk_mmsys *mmsys = container_of(rcdev, struct mtk_mmsys, rcdev);
+	unsigned long flags;
+	u32 reg;
+	int i;
+
+	spin_lock_irqsave(&mmsys->lock, flags);
+
+	reg = readl_relaxed(mmsys->regs + MMSYS_SW0_RST_B);
+
+	if (assert)
+		reg &= ~BIT(id);
+	else
+		reg |= BIT(id);
+
+	writel_relaxed(reg, mmsys->regs + MMSYS_SW0_RST_B);
+
+	spin_unlock_irqrestore(&mmsys->lock, flags);
+
+	return 0;
+}
+
+static int mtk_mmsys_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	return mtk_mmsys_reset_update(rcdev, id, true);
+}
+
+static int mtk_mmsys_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	return mtk_mmsys_reset_update(rcdev, id, false);
+}
+
+static int mtk_mmsys_reset(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	int ret;
+
+	ret = mtk_mmsys_reset_assert(rcdev, id);
+	if (ret)
+		return ret;
+
+	usleep_range(1000, 1100);
+
+	return mtk_mmsys_reset_deassert(rcdev, id);
+}
+
+static const struct reset_control_ops mtk_mmsys_reset_ops = {
+	.assert = mtk_mmsys_reset_assert,
+	.deassert = mtk_mmsys_reset_deassert,
+	.reset = mtk_mmsys_reset,
+};
+
 static int mtk_mmsys_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -110,6 +167,18 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	spin_lock_init(&mmsys->lock);
+
+	mmsys->rcdev.owner = THIS_MODULE;
+	mmsys->rcdev.nr_resets = 32;
+	mmsys->rcdev.ops = &mtk_mmsys_reset_ops;
+	mmsys->rcdev.of_node = pdev->dev.of_node;
+	ret = devm_reset_controller_register(&pdev->dev, &mmsys->rcdev);
+	if (ret) {
+		dev_err(&pdev->dev, "Couldn't register mmsys reset controller: %d\n", ret);
+		return ret;
+	}
+
 	mmsys->data = of_device_get_match_data(&pdev->dev);
 	platform_set_drvdata(pdev, mmsys);
 
diff --git a/drivers/soc/mediatek/mtk-mmsys.h b/drivers/soc/mediatek/mtk-mmsys.h
index 11388961dded..f9f9e12ceab8 100644
--- a/drivers/soc/mediatek/mtk-mmsys.h
+++ b/drivers/soc/mediatek/mtk-mmsys.h
@@ -66,6 +66,8 @@
 #define DPI_SEL_IN_BLS				0x0
 #define DSI_SEL_IN_RDMA				0x1
 
+#define MMSYS_SW0_RST_B				0x140
+
 struct mtk_mmsys_routes {
 	u32 from_comp;
 	u32 to_comp;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 6/6] drm/mediatek: mtk_dsi: Reset the dsi0 hardware
  2021-06-30 14:46 [PATCH 0/6] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
                   ` (4 preceding siblings ...)
  2021-06-30 14:46 ` [PATCH 5/6] soc: mediatek: mmsys: Add reset controller support Enric Balletbo i Serra
@ 2021-06-30 14:46 ` Enric Balletbo i Serra
  5 siblings, 0 replies; 11+ messages in thread
From: Enric Balletbo i Serra @ 2021-06-30 14:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: jitao.shi, chunkuang.hu, matthias.bgg, drinkcat, eizan, kernel,
	linux-mediatek, hsinyi, Daniel Vetter, David Airlie,
	Philipp Zabel, dri-devel, linux-arm-kernel

Reset dsi0 HW to default when power on. This prevents to have different
settingbetween the bootloader and the kernel.

As not all Mediatek boards have the reset consumer configured in their
board description, also is not needed on all of them, the reset is optional,
so the change is compatible with all boards.

Cc: Jitao Shi <jitao.shi@mediatek.com>
Suggested-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---

 drivers/gpu/drm/mediatek/mtk_dsi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index ae403c67cbd9..d8b81e2ab841 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -11,6 +11,7 @@
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/reset.h>
 
 #include <video/mipi_display.h>
 #include <video/videomode.h>
@@ -980,8 +981,10 @@ static int mtk_dsi_bind(struct device *dev, struct device *master, void *data)
 	struct mtk_dsi *dsi = dev_get_drvdata(dev);
 
 	ret = mtk_dsi_encoder_init(drm, dsi);
+	if (ret)
+		return ret;
 
-	return ret;
+	return device_reset_optional(dev);
 }
 
 static void mtk_dsi_unbind(struct device *dev, struct device *master,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/6] arm64: dts: mediatek: Move reset controller constants into common location
  2021-06-30 14:46 ` [PATCH 1/6] arm64: dts: mediatek: Move reset controller constants into common location Enric Balletbo i Serra
@ 2021-06-30 17:52   ` kernel test robot
  2021-07-01  1:06   ` kernel test robot
  1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-06-30 17:52 UTC (permalink / raw)
  To: Enric Balletbo i Serra, linux-kernel
  Cc: kbuild-all, jitao.shi, chunkuang.hu, matthias.bgg, drinkcat,
	eizan, kernel, linux-mediatek, hsinyi, Crystal Guo

[-- Attachment #1: Type: text/plain, Size: 3369 bytes --]

Hi Enric,

I love your patch! Yet something to improve:

[auto build test ERROR on robh/for-next]
[also build test ERROR on pza/reset/next linux/master linus/master v5.13 next-20210630]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Enric-Balletbo-i-Serra/Add-support-to-the-mmsys-driver-to-be-a-reset-controller/20210630-224837
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: nds32-randconfig-r036-20210630 (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d379d95430210479407b6123a1f2f39b5c116475
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Enric-Balletbo-i-Serra/Add-support-to-the-mmsys-driver-to-be-a-reset-controller/20210630-224837
        git checkout d379d95430210479407b6123a1f2f39b5c116475
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross O=build_dir ARCH=nds32 SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/watchdog/mtk_wdt.c:12:10: fatal error: dt-bindings/reset-controller/mt2712-resets.h: No such file or directory
      12 | #include <dt-bindings/reset-controller/mt2712-resets.h>
         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   compilation terminated.


vim +12 drivers/watchdog/mtk_wdt.c

9e5236e7cec1106 yong.liang       2020-01-15 @12  #include <dt-bindings/reset-controller/mt2712-resets.h>
c254e103082b74e yong.liang       2020-01-15  13  #include <dt-bindings/reset-controller/mt8183-resets.h>
adc318a34066817 Crystal Guo      2020-10-14  14  #include <dt-bindings/reset-controller/mt8192-resets.h>
c254e103082b74e yong.liang       2020-01-15  15  #include <linux/delay.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  16  #include <linux/err.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  17  #include <linux/init.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  18  #include <linux/io.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  19  #include <linux/kernel.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  20  #include <linux/module.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  21  #include <linux/moduleparam.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  22  #include <linux/of.h>
c254e103082b74e yong.liang       2020-01-15  23  #include <linux/of_device.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  24  #include <linux/platform_device.h>
c254e103082b74e yong.liang       2020-01-15  25  #include <linux/reset-controller.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  26  #include <linux/types.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  27  #include <linux/watchdog.h>
a44a45536f7bc2a Matthias Brugger 2015-01-13  28  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30331 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/6] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0
  2021-06-30 14:46 ` [PATCH 3/6] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0 Enric Balletbo i Serra
@ 2021-06-30 22:48   ` Chun-Kuang Hu
  2021-07-14  8:41     ` Enric Balletbo i Serra
  0 siblings, 1 reply; 11+ messages in thread
From: Chun-Kuang Hu @ 2021-06-30 22:48 UTC (permalink / raw)
  To: Enric Balletbo i Serra
  Cc: linux-kernel, Jitao Shi, Chun-Kuang Hu, Matthias Brugger,
	Nicolas Boichat, Eizan Miyamoto, Collabora Kernel ML,
	moderated list:ARM/Mediatek SoC support, Hsin-Yi Wang,
	Philipp Zabel, Rob Herring, DTML, Linux ARM

HI, Enric:

Enric Balletbo i Serra <enric.balletbo@collabora.com> 於 2021年6月30日 週三 下午10:47寫道:
>
> Reset the DSI hardware is needed to prevent different settings between
> the bootloader and the kernel.
>
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> ---
>
>  arch/arm64/boot/dts/mediatek/mt8173.dtsi  | 2 ++
>  include/dt-bindings/reset/mt8173-resets.h | 2 ++
>  2 files changed, 4 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> index e5596fe01a1d..36c3998eb7f1 100644
> --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> @@ -1036,6 +1036,7 @@ mmsys: syscon@14000000 {
>                         assigned-clocks = <&topckgen CLK_TOP_MM_SEL>;
>                         assigned-clock-rates = <400000000>;
>                         #clock-cells = <1>;
> +                       #reset-cells = <1>;
>                         mboxes = <&gce 0 CMDQ_THR_PRIO_HIGHEST>,
>                                  <&gce 1 CMDQ_THR_PRIO_HIGHEST>;
>                         mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0 0x1000>;
> @@ -1262,6 +1263,7 @@ dsi0: dsi@1401b000 {
>                                  <&mmsys CLK_MM_DSI0_DIGITAL>,
>                                  <&mipi_tx0>;
>                         clock-names = "engine", "digital", "hs";
> +                       resets = <&mmsys MT8173_MMSYS_SW0_RST_B_DISP_DSI0>;

Add this in binding document. It would be good if the binding document
is in yaml format.

Regards,
Chun-Kuang.

>                         phys = <&mipi_tx0>;
>                         phy-names = "dphy";
>                         status = "disabled";
> diff --git a/include/dt-bindings/reset/mt8173-resets.h b/include/dt-bindings/reset/mt8173-resets.h
> index ba8636eda5ae..6a60c7cecc4c 100644
> --- a/include/dt-bindings/reset/mt8173-resets.h
> +++ b/include/dt-bindings/reset/mt8173-resets.h
> @@ -27,6 +27,8 @@
>  #define MT8173_INFRA_GCE_FAXI_RST       40
>  #define MT8173_INFRA_MMIOMMURST         47
>
> +/* MMSYS resets */
> +#define MT8173_MMSYS_SW0_RST_B_DISP_DSI0       25
>
>  /*  PERICFG resets */
>  #define MT8173_PERI_UART0_SW_RST        0
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/6] arm64: dts: mediatek: Move reset controller constants into common location
  2021-06-30 14:46 ` [PATCH 1/6] arm64: dts: mediatek: Move reset controller constants into common location Enric Balletbo i Serra
  2021-06-30 17:52   ` kernel test robot
@ 2021-07-01  1:06   ` kernel test robot
  1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-07-01  1:06 UTC (permalink / raw)
  To: Enric Balletbo i Serra, linux-kernel
  Cc: clang-built-linux, kbuild-all, jitao.shi, chunkuang.hu,
	matthias.bgg, drinkcat, eizan, kernel, linux-mediatek, hsinyi,
	Crystal Guo

[-- Attachment #1: Type: text/plain, Size: 3513 bytes --]

Hi Enric,

I love your patch! Yet something to improve:

[auto build test ERROR on robh/for-next]
[also build test ERROR on pza/reset/next linux/master linus/master v5.13 next-20210630]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Enric-Balletbo-i-Serra/Add-support-to-the-mmsys-driver-to-be-a-reset-controller/20210630-224837
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: x86_64-randconfig-a012-20210630 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8d21d5472501460933e78aead04cf59579025ba4)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/d379d95430210479407b6123a1f2f39b5c116475
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Enric-Balletbo-i-Serra/Add-support-to-the-mmsys-driver-to-be-a-reset-controller/20210630-224837
        git checkout d379d95430210479407b6123a1f2f39b5c116475
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/watchdog/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/watchdog/mtk_wdt.c:12:10: fatal error: 'dt-bindings/reset-controller/mt2712-resets.h' file not found
   #include <dt-bindings/reset-controller/mt2712-resets.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1 error generated.


vim +12 drivers/watchdog/mtk_wdt.c

9e5236e7cec110 yong.liang       2020-01-15 @12  #include <dt-bindings/reset-controller/mt2712-resets.h>
c254e103082b74 yong.liang       2020-01-15  13  #include <dt-bindings/reset-controller/mt8183-resets.h>
adc318a3406681 Crystal Guo      2020-10-14  14  #include <dt-bindings/reset-controller/mt8192-resets.h>
c254e103082b74 yong.liang       2020-01-15  15  #include <linux/delay.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  16  #include <linux/err.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  17  #include <linux/init.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  18  #include <linux/io.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  19  #include <linux/kernel.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  20  #include <linux/module.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  21  #include <linux/moduleparam.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  22  #include <linux/of.h>
c254e103082b74 yong.liang       2020-01-15  23  #include <linux/of_device.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  24  #include <linux/platform_device.h>
c254e103082b74 yong.liang       2020-01-15  25  #include <linux/reset-controller.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  26  #include <linux/types.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  27  #include <linux/watchdog.h>
a44a45536f7bc2 Matthias Brugger 2015-01-13  28  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 38396 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/6] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0
  2021-06-30 22:48   ` Chun-Kuang Hu
@ 2021-07-14  8:41     ` Enric Balletbo i Serra
  0 siblings, 0 replies; 11+ messages in thread
From: Enric Balletbo i Serra @ 2021-07-14  8:41 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: linux-kernel, Jitao Shi, Matthias Brugger, Nicolas Boichat,
	Eizan Miyamoto, Collabora Kernel ML,
	moderated list:ARM/Mediatek SoC support, Hsin-Yi Wang,
	Philipp Zabel, Rob Herring, DTML, Linux ARM

Hi Chun-Kuang,

Thank you for the review.

On 1/7/21 0:48, Chun-Kuang Hu wrote:
> HI, Enric:
> 
> Enric Balletbo i Serra <enric.balletbo@collabora.com> 於 2021年6月30日 週三 下午10:47寫道:
>>
>> Reset the DSI hardware is needed to prevent different settings between
>> the bootloader and the kernel.
>>
>> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
>> ---
>>
>>  arch/arm64/boot/dts/mediatek/mt8173.dtsi  | 2 ++
>>  include/dt-bindings/reset/mt8173-resets.h | 2 ++
>>  2 files changed, 4 insertions(+)
>>
>> diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
>> index e5596fe01a1d..36c3998eb7f1 100644
>> --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
>> +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
>> @@ -1036,6 +1036,7 @@ mmsys: syscon@14000000 {
>>                         assigned-clocks = <&topckgen CLK_TOP_MM_SEL>;
>>                         assigned-clock-rates = <400000000>;
>>                         #clock-cells = <1>;
>> +                       #reset-cells = <1>;
>>                         mboxes = <&gce 0 CMDQ_THR_PRIO_HIGHEST>,
>>                                  <&gce 1 CMDQ_THR_PRIO_HIGHEST>;
>>                         mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0 0x1000>;
>> @@ -1262,6 +1263,7 @@ dsi0: dsi@1401b000 {
>>                                  <&mmsys CLK_MM_DSI0_DIGITAL>,
>>                                  <&mipi_tx0>;
>>                         clock-names = "engine", "digital", "hs";
>> +                       resets = <&mmsys MT8173_MMSYS_SW0_RST_B_DISP_DSI0>;
> 
> Add this in binding document. It would be good if the binding document
> is in yaml format.
> 

Ack, will add this optional property in the mediatek,dsi.txt binding.

I can try to translate it to yaml but IMO would be better if someone that really
knows the hardware and has access to the datasheet could do it. From the current
.txt file I can deduce most of the things, but still I can lack some kind of
information, i.e I know that there are three clocks, but don't know if all three
are needed (from .txt yes, are all needed but not sure), also I know that the
names of the clocks are "engine", "digital", and "hs", but I don't know the
description of these clocks.

IMHO would be nice if someone from Mediatek can take care of all the binding
migration to yaml.

Cheers,
  Enric

> Regards,
> Chun-Kuang.
> 
>>                         phys = <&mipi_tx0>;
>>                         phy-names = "dphy";
>>                         status = "disabled";
>> diff --git a/include/dt-bindings/reset/mt8173-resets.h b/include/dt-bindings/reset/mt8173-resets.h
>> index ba8636eda5ae..6a60c7cecc4c 100644
>> --- a/include/dt-bindings/reset/mt8173-resets.h
>> +++ b/include/dt-bindings/reset/mt8173-resets.h
>> @@ -27,6 +27,8 @@
>>  #define MT8173_INFRA_GCE_FAXI_RST       40
>>  #define MT8173_INFRA_MMIOMMURST         47
>>
>> +/* MMSYS resets */
>> +#define MT8173_MMSYS_SW0_RST_B_DISP_DSI0       25
>>
>>  /*  PERICFG resets */
>>  #define MT8173_PERI_UART0_SW_RST        0
>> --
>> 2.30.2
>>

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-07-14  8:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30 14:46 [PATCH 0/6] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
2021-06-30 14:46 ` [PATCH 1/6] arm64: dts: mediatek: Move reset controller constants into common location Enric Balletbo i Serra
2021-06-30 17:52   ` kernel test robot
2021-07-01  1:06   ` kernel test robot
2021-06-30 14:46 ` [PATCH 2/6] dt-bindings: mediatek: Add #reset-cells to mmsys system controller Enric Balletbo i Serra
2021-06-30 14:46 ` [PATCH 3/6] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0 Enric Balletbo i Serra
2021-06-30 22:48   ` Chun-Kuang Hu
2021-07-14  8:41     ` Enric Balletbo i Serra
2021-06-30 14:46 ` [PATCH 4/6] arm64: dts: mt8183: " Enric Balletbo i Serra
2021-06-30 14:46 ` [PATCH 5/6] soc: mediatek: mmsys: Add reset controller support Enric Balletbo i Serra
2021-06-30 14:46 ` [PATCH 6/6] drm/mediatek: mtk_dsi: Reset the dsi0 hardware Enric Balletbo i Serra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).