LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v3 0/7] Add support to the mmsys driver to be a reset controller
@ 2021-08-25 10:26 Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 1/7] arm64: dts: mediatek: Move reset controller constants into common location Enric Balletbo i Serra
` (6 more replies)
0 siblings, 7 replies; 14+ messages in thread
From: Enric Balletbo i Serra @ 2021-08-25 10:26 UTC (permalink / raw)
To: linux-kernel
Cc: matthias.bgg, hsinyi, linux-mediatek, jitao.shi, eizan, drinkcat,
chunkuang.hu, kernel, Crystal Guo, Daniel Vetter, David Airlie,
Fabien Parent, Guenter Roeck, Philipp Zabel, Rob Herring,
Wim Van Sebroeck, devicetree, dri-devel, linux-arm-kernel,
linux-watchdog
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/
Changes in v3:
- Based on top of the patch that converts mmsys to schema
- Fix typo in the commit description
Changes in v2:
- Fix build test ERROR Reported-by: kernel test robot <lkp@intel.com>
- Added a new patch to describe the dsi reset optional property.
Enric Balletbo i Serra (7):
arm64: dts: mediatek: Move reset controller constants into common
location
dt-bindings: mediatek: Add #reset-cells to mmsys system controller
dt-bindings: display: mediatek: add dsi reset optional property
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.yaml | 4 ++
.../display/mediatek/mediatek,dsi.txt | 6 ++
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 +
drivers/watchdog/mtk_wdt.c | 6 +-
.../mt2712-resets.h | 0
include/dt-bindings/reset/mt8173-resets.h | 2 +
.../mt8183-resets.h | 3 +
.../mt8192-resets.h | 0
12 files changed, 98 insertions(+), 6 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] 14+ messages in thread
* [PATCH v3 1/7] arm64: dts: mediatek: Move reset controller constants into common location
2021-08-25 10:26 [PATCH v3 0/7] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
@ 2021-08-25 10:26 ` Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 2/7] dt-bindings: mediatek: Add #reset-cells to mmsys system controller Enric Balletbo i Serra
` (5 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Enric Balletbo i Serra @ 2021-08-25 10:26 UTC (permalink / raw)
To: linux-kernel
Cc: matthias.bgg, hsinyi, linux-mediatek, jitao.shi, eizan, drinkcat,
chunkuang.hu, kernel, Guenter Roeck, Crystal Guo, Philipp Zabel,
Rob Herring, Wim Van Sebroeck, devicetree, linux-arm-kernel,
linux-watchdog
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>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
---
(no changes since v2)
Changes in v2:
- Fix build test ERROR Reported-by: kernel test robot <lkp@intel.com>
arch/arm64/boot/dts/mediatek/mt8183.dtsi | 2 +-
drivers/watchdog/mtk_wdt.c | 6 +++---
.../dt-bindings/{reset-controller => reset}/mt2712-resets.h | 0
.../dt-bindings/{reset-controller => reset}/mt8183-resets.h | 0
.../dt-bindings/{reset-controller => reset}/mt8192-resets.h | 0
5 files changed, 4 insertions(+), 4 deletions(-)
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 d1efc4a38a41..9f72701a3b2e 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/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
index 16b6aff324a7..6986bc740465 100644
--- a/drivers/watchdog/mtk_wdt.c
+++ b/drivers/watchdog/mtk_wdt.c
@@ -9,9 +9,9 @@
* Based on sunxi_wdt.c
*/
-#include <dt-bindings/reset-controller/mt2712-resets.h>
-#include <dt-bindings/reset-controller/mt8183-resets.h>
-#include <dt-bindings/reset-controller/mt8192-resets.h>
+#include <dt-bindings/reset/mt2712-resets.h>
+#include <dt-bindings/reset/mt8183-resets.h>
+#include <dt-bindings/reset/mt8192-resets.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/init.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 [flat|nested] 14+ messages in thread
* [PATCH v3 2/7] dt-bindings: mediatek: Add #reset-cells to mmsys system controller
2021-08-25 10:26 [PATCH v3 0/7] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 1/7] arm64: dts: mediatek: Move reset controller constants into common location Enric Balletbo i Serra
@ 2021-08-25 10:26 ` Enric Balletbo i Serra
2021-08-25 16:31 ` Rob Herring
2021-08-25 10:26 ` [PATCH v3 3/7] dt-bindings: display: mediatek: add dsi reset optional property Enric Balletbo i Serra
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Enric Balletbo i Serra @ 2021-08-25 10:26 UTC (permalink / raw)
To: linux-kernel
Cc: matthias.bgg, hsinyi, linux-mediatek, jitao.shi, eizan, drinkcat,
chunkuang.hu, kernel, 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>
---
Changes in v3:
- Based on top of the patch that converts mmsys to schema
.../devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml
index 2d4ff0ce387b..96ca16927a06 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml
@@ -42,6 +42,9 @@ properties:
"#clock-cells":
const: 1
+ '#reset-cells':
+ const: 1
+
required:
- compatible
- reg
@@ -55,4 +58,5 @@ examples:
compatible = "mediatek,mt8173-mmsys", "syscon";
reg = <0x14000000 0x1000>;
#clock-cells = <1>;
+ #reset-cells = <1>;
};
--
2.30.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 3/7] dt-bindings: display: mediatek: add dsi reset optional property
2021-08-25 10:26 [PATCH v3 0/7] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 1/7] arm64: dts: mediatek: Move reset controller constants into common location Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 2/7] dt-bindings: mediatek: Add #reset-cells to mmsys system controller Enric Balletbo i Serra
@ 2021-08-25 10:26 ` Enric Balletbo i Serra
2021-08-26 0:31 ` Chun-Kuang Hu
2021-08-25 10:26 ` [PATCH v3 4/7] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0 Enric Balletbo i Serra
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Enric Balletbo i Serra @ 2021-08-25 10:26 UTC (permalink / raw)
To: linux-kernel
Cc: matthias.bgg, hsinyi, linux-mediatek, jitao.shi, eizan, drinkcat,
chunkuang.hu, kernel, Rob Herring, Daniel Vetter, David Airlie,
Philipp Zabel, Rob Herring, devicetree, dri-devel,
linux-arm-kernel
Update device tree binding documentation for the dsi to add the optional
property to reset the dsi controller.
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Rob Herring <robh@kernel.org>
---
(no changes since v2)
Changes in v2:
- Added a new patch to describe the dsi reset optional property.
.../devicetree/bindings/display/mediatek/mediatek,dsi.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt b/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
index 8238a86686be..3209b700ded6 100644
--- a/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
@@ -19,6 +19,11 @@ Required properties:
Documentation/devicetree/bindings/graph.txt. This port should be connected
to the input port of an attached DSI panel or DSI-to-eDP encoder chip.
+Optional properties:
+- resets: list of phandle + reset specifier pair, as described in [1].
+
+[1] Documentation/devicetree/bindings/reset/reset.txt
+
MIPI TX Configuration Module
============================
@@ -45,6 +50,7 @@ dsi0: dsi@1401b000 {
clocks = <&mmsys MM_DSI0_ENGINE>, <&mmsys 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";
--
2.30.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 4/7] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0
2021-08-25 10:26 [PATCH v3 0/7] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
` (2 preceding siblings ...)
2021-08-25 10:26 ` [PATCH v3 3/7] dt-bindings: display: mediatek: add dsi reset optional property Enric Balletbo i Serra
@ 2021-08-25 10:26 ` Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 5/7] arm64: dts: mt8183: " Enric Balletbo i Serra
` (2 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Enric Balletbo i Serra @ 2021-08-25 10:26 UTC (permalink / raw)
To: linux-kernel
Cc: matthias.bgg, hsinyi, linux-mediatek, jitao.shi, eizan, drinkcat,
chunkuang.hu, kernel, Rob Herring, 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>
Acked-by: Rob Herring <robh@kernel.org>
---
(no changes since v1)
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 17d70e2f5394..97ea3f9960b1 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 [flat|nested] 14+ messages in thread
* [PATCH v3 5/7] arm64: dts: mt8183: Add the mmsys reset bit to reset the dsi0
2021-08-25 10:26 [PATCH v3 0/7] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
` (3 preceding siblings ...)
2021-08-25 10:26 ` [PATCH v3 4/7] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0 Enric Balletbo i Serra
@ 2021-08-25 10:26 ` Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 6/7] soc: mediatek: mmsys: Add reset controller support Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 7/7] drm/mediatek: mtk_dsi: Reset the dsi0 hardware Enric Balletbo i Serra
6 siblings, 0 replies; 14+ messages in thread
From: Enric Balletbo i Serra @ 2021-08-25 10:26 UTC (permalink / raw)
To: linux-kernel
Cc: matthias.bgg, hsinyi, linux-mediatek, jitao.shi, eizan, drinkcat,
chunkuang.hu, kernel, Rob Herring, 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>
Acked-by: Rob Herring <robh@kernel.org>
---
(no changes since v1)
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 9f72701a3b2e..7c47a76b3d02 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -1251,6 +1251,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>;
@@ -1365,11 +1366,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 [flat|nested] 14+ messages in thread
* [PATCH v3 6/7] soc: mediatek: mmsys: Add reset controller support
2021-08-25 10:26 [PATCH v3 0/7] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
` (4 preceding siblings ...)
2021-08-25 10:26 ` [PATCH v3 5/7] arm64: dts: mt8183: " Enric Balletbo i Serra
@ 2021-08-25 10:26 ` Enric Balletbo i Serra
2021-08-25 10:46 ` Philipp Zabel
2021-09-16 6:05 ` Hsin-Yi Wang
2021-08-25 10:26 ` [PATCH v3 7/7] drm/mediatek: mtk_dsi: Reset the dsi0 hardware Enric Balletbo i Serra
6 siblings, 2 replies; 14+ messages in thread
From: Enric Balletbo i Serra @ 2021-08-25 10:26 UTC (permalink / raw)
To: linux-kernel
Cc: matthias.bgg, hsinyi, linux-mediatek, jitao.shi, eizan, drinkcat,
chunkuang.hu, kernel, 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>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
---
(no changes since v1)
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 a78e88f27b62..855a3a50840c 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"
@@ -62,6 +64,8 @@ static const struct mtk_mmsys_driver_data mt8365_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,
@@ -101,6 +105,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;
@@ -120,6 +177,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 9e2b81bd38db..8b0ed05117ea 100644
--- a/drivers/soc/mediatek/mtk-mmsys.h
+++ b/drivers/soc/mediatek/mtk-mmsys.h
@@ -78,6 +78,8 @@
#define DSI_SEL_IN_RDMA 0x1
#define DSI_SEL_IN_MASK 0x1
+#define MMSYS_SW0_RST_B 0x140
+
struct mtk_mmsys_routes {
u32 from_comp;
u32 to_comp;
--
2.30.2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 7/7] drm/mediatek: mtk_dsi: Reset the dsi0 hardware
2021-08-25 10:26 [PATCH v3 0/7] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
` (5 preceding siblings ...)
2021-08-25 10:26 ` [PATCH v3 6/7] soc: mediatek: mmsys: Add reset controller support Enric Balletbo i Serra
@ 2021-08-25 10:26 ` Enric Balletbo i Serra
6 siblings, 0 replies; 14+ messages in thread
From: Enric Balletbo i Serra @ 2021-08-25 10:26 UTC (permalink / raw)
To: linux-kernel
Cc: matthias.bgg, hsinyi, linux-mediatek, jitao.shi, eizan, drinkcat,
chunkuang.hu, kernel, Daniel Vetter, David Airlie, Philipp Zabel,
dri-devel, linux-arm-kernel
Reset dsi0 HW to default when power on. This prevents to have different
settingis between 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>
Acked-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
---
Changes in v3:
- Fix typo in the commit description
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 [flat|nested] 14+ messages in thread
* Re: [PATCH v3 6/7] soc: mediatek: mmsys: Add reset controller support
2021-08-25 10:26 ` [PATCH v3 6/7] soc: mediatek: mmsys: Add reset controller support Enric Balletbo i Serra
@ 2021-08-25 10:46 ` Philipp Zabel
2021-08-26 0:33 ` Chun-Kuang Hu
2021-09-16 6:05 ` Hsin-Yi Wang
1 sibling, 1 reply; 14+ messages in thread
From: Philipp Zabel @ 2021-08-25 10:46 UTC (permalink / raw)
To: Enric Balletbo i Serra, linux-kernel, Nancy.Lin
Cc: matthias.bgg, hsinyi, linux-mediatek, jitao.shi, eizan, drinkcat,
chunkuang.hu, kernel, linux-arm-kernel
On Wed, 2021-08-25 at 12:26 +0200, Enric Balletbo i Serra wrote:
> 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>
> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>
> (no changes since v1)
>
> drivers/soc/mediatek/mtk-mmsys.c | 69 ++++++++++++++++++++++++++++++++
> drivers/soc/mediatek/mtk-mmsys.h | 2 +
Cc: Nancy - this patch clashes with [1], please coordinate.
[1] https://lore.kernel.org/linux-arm-kernel/20210825100531.5653-11-nancy.lin@mediatek.com/
regards
Philipp
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 2/7] dt-bindings: mediatek: Add #reset-cells to mmsys system controller
2021-08-25 10:26 ` [PATCH v3 2/7] dt-bindings: mediatek: Add #reset-cells to mmsys system controller Enric Balletbo i Serra
@ 2021-08-25 16:31 ` Rob Herring
0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2021-08-25 16:31 UTC (permalink / raw)
To: Enric Balletbo i Serra
Cc: linux-kernel, kernel, jitao.shi, eizan, linux-arm-kernel,
matthias.bgg, Fabien Parent, Rob Herring, chunkuang.hu, hsinyi,
devicetree, linux-mediatek, drinkcat
On Wed, 25 Aug 2021 12:26:27 +0200, Enric Balletbo i Serra wrote:
> 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>
> ---
>
> Changes in v3:
> - Based on top of the patch that converts mmsys to schema
>
> .../devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml | 4 ++++
> 1 file changed, 4 insertions(+)
>
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/7] dt-bindings: display: mediatek: add dsi reset optional property
2021-08-25 10:26 ` [PATCH v3 3/7] dt-bindings: display: mediatek: add dsi reset optional property Enric Balletbo i Serra
@ 2021-08-26 0:31 ` Chun-Kuang Hu
0 siblings, 0 replies; 14+ messages in thread
From: Chun-Kuang Hu @ 2021-08-26 0:31 UTC (permalink / raw)
To: Enric Balletbo i Serra
Cc: linux-kernel, Matthias Brugger, Hsin-Yi Wang,
moderated list:ARM/Mediatek SoC support, Jitao Shi,
Eizan Miyamoto, Nicolas Boichat, Chun-Kuang Hu,
Collabora Kernel ML, Rob Herring, Daniel Vetter, David Airlie,
Philipp Zabel, Rob Herring, DTML, DRI Development, Linux ARM
Hi, Enric:
Enric Balletbo i Serra <enric.balletbo@collabora.com> 於 2021年8月25日 週三 下午6:26寫道:
>
> Update device tree binding documentation for the dsi to add the optional
> property to reset the dsi controller.
Reviewed-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
>
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> Acked-by: Rob Herring <robh@kernel.org>
> ---
>
> (no changes since v2)
>
> Changes in v2:
> - Added a new patch to describe the dsi reset optional property.
>
> .../devicetree/bindings/display/mediatek/mediatek,dsi.txt | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt b/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
> index 8238a86686be..3209b700ded6 100644
> --- a/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
> +++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt
> @@ -19,6 +19,11 @@ Required properties:
> Documentation/devicetree/bindings/graph.txt. This port should be connected
> to the input port of an attached DSI panel or DSI-to-eDP encoder chip.
>
> +Optional properties:
> +- resets: list of phandle + reset specifier pair, as described in [1].
> +
> +[1] Documentation/devicetree/bindings/reset/reset.txt
> +
> MIPI TX Configuration Module
> ============================
>
> @@ -45,6 +50,7 @@ dsi0: dsi@1401b000 {
> clocks = <&mmsys MM_DSI0_ENGINE>, <&mmsys 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";
>
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 6/7] soc: mediatek: mmsys: Add reset controller support
2021-08-25 10:46 ` Philipp Zabel
@ 2021-08-26 0:33 ` Chun-Kuang Hu
2021-09-03 14:10 ` Enric Balletbo i Serra
0 siblings, 1 reply; 14+ messages in thread
From: Chun-Kuang Hu @ 2021-08-26 0:33 UTC (permalink / raw)
To: Philipp Zabel
Cc: Enric Balletbo i Serra, linux-kernel, Nancy.Lin,
Matthias Brugger, Hsin-Yi Wang,
moderated list:ARM/Mediatek SoC support, Jitao Shi,
Eizan Miyamoto, Nicolas Boichat, Chun-Kuang Hu,
Collabora Kernel ML, Linux ARM
Philipp Zabel <p.zabel@pengutronix.de> 於 2021年8月25日 週三 下午6:46寫道:
>
> On Wed, 2021-08-25 at 12:26 +0200, Enric Balletbo i Serra wrote:
> > 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>
> > Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
> > ---
> >
> > (no changes since v1)
> >
> > drivers/soc/mediatek/mtk-mmsys.c | 69 ++++++++++++++++++++++++++++++++
> > drivers/soc/mediatek/mtk-mmsys.h | 2 +
>
> Cc: Nancy - this patch clashes with [1], please coordinate.
>
> [1] https://lore.kernel.org/linux-arm-kernel/20210825100531.5653-11-nancy.lin@mediatek.com/
Enric's series is all reviewed or acked, so I think Nancy's series
should base on Enric's series.
Regards,
Chun-Kuang.
>
> regards
> Philipp
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 6/7] soc: mediatek: mmsys: Add reset controller support
2021-08-26 0:33 ` Chun-Kuang Hu
@ 2021-09-03 14:10 ` Enric Balletbo i Serra
0 siblings, 0 replies; 14+ messages in thread
From: Enric Balletbo i Serra @ 2021-09-03 14:10 UTC (permalink / raw)
To: Chun-Kuang Hu, Philipp Zabel
Cc: linux-kernel, Nancy.Lin, Matthias Brugger, Hsin-Yi Wang,
moderated list:ARM/Mediatek SoC support, Jitao Shi,
Eizan Miyamoto, Nicolas Boichat, Collabora Kernel ML, Linux ARM
Hi Nancy,
(again in plain text, sorry for the noise)
On 26/8/21 2:33, Chun-Kuang Hu wrote:
> Philipp Zabel <p.zabel@pengutronix.de> 於 2021年8月25日 週三 下午6:46寫道:
>>
>> On Wed, 2021-08-25 at 12:26 +0200, Enric Balletbo i Serra wrote:
>>> 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>
>>> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
>>> ---
>>>
>>> (no changes since v1)
>>>
>>> drivers/soc/mediatek/mtk-mmsys.c | 69 ++++++++++++++++++++++++++++++++
>>> drivers/soc/mediatek/mtk-mmsys.h | 2 +
>>
>> Cc: Nancy - this patch clashes with [1], please coordinate.
>>
>> [1] https://lore.kernel.org/linux-arm-kernel/20210825100531.5653-11-nancy.lin@mediatek.com/
>
> Enric's series is all reviewed or acked, so I think Nancy's series
> should base on Enric's series.
>
Is it fine with you to base you patches on top of this patchset?
Thanks,
Enric
> Regards,
> Chun-Kuang.
>
>>
>> regards
>> Philipp
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 6/7] soc: mediatek: mmsys: Add reset controller support
2021-08-25 10:26 ` [PATCH v3 6/7] soc: mediatek: mmsys: Add reset controller support Enric Balletbo i Serra
2021-08-25 10:46 ` Philipp Zabel
@ 2021-09-16 6:05 ` Hsin-Yi Wang
1 sibling, 0 replies; 14+ messages in thread
From: Hsin-Yi Wang @ 2021-09-16 6:05 UTC (permalink / raw)
To: Enric Balletbo i Serra
Cc: lkml, Matthias Brugger, moderated list:ARM/Mediatek SoC support,
Jitao Shi, Eizan Miyamoto, Nicolas Boichat, Chun-Kuang Hu,
Collabora Kernel ML, Philipp Zabel,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
On Wed, Aug 25, 2021 at 6:26 PM Enric Balletbo i Serra
<enric.balletbo@collabora.com> wrote:
>
> 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>
> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>
> (no changes since v1)
>
<snip>
> +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;
This variable is not used.
> +
> + 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;
> +}
> +
<snip>
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2021-09-16 6:05 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 10:26 [PATCH v3 0/7] Add support to the mmsys driver to be a reset controller Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 1/7] arm64: dts: mediatek: Move reset controller constants into common location Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 2/7] dt-bindings: mediatek: Add #reset-cells to mmsys system controller Enric Balletbo i Serra
2021-08-25 16:31 ` Rob Herring
2021-08-25 10:26 ` [PATCH v3 3/7] dt-bindings: display: mediatek: add dsi reset optional property Enric Balletbo i Serra
2021-08-26 0:31 ` Chun-Kuang Hu
2021-08-25 10:26 ` [PATCH v3 4/7] arm64: dts: mt8173: Add the mmsys reset bit to reset the dsi0 Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 5/7] arm64: dts: mt8183: " Enric Balletbo i Serra
2021-08-25 10:26 ` [PATCH v3 6/7] soc: mediatek: mmsys: Add reset controller support Enric Balletbo i Serra
2021-08-25 10:46 ` Philipp Zabel
2021-08-26 0:33 ` Chun-Kuang Hu
2021-09-03 14:10 ` Enric Balletbo i Serra
2021-09-16 6:05 ` Hsin-Yi Wang
2021-08-25 10:26 ` [PATCH v3 7/7] 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).