This series aims to add support for the DesignWare MIPI DSI controller and
the Innoslicon D-PHY found in RK3128 SoCs. The code additions are rather
tiny: It only need some code in the Rockchip dw-mipi-dsi glue layer for
this SoC, add support for an additional clock and do some changes in the
SoC's clock driver. Support for the phy was already added when the
Innosilicon D-PHY driver was initially submitted. I tested it with a
800x1280 DSI panel where all 4 lanes that are supported are used.
changes in v2:
To improve power-efficiency when the DSI controller is not in use, I
dropped the patch which made hclk_vio_h2p a critical clock and instead
added support for an AHB clock to the DSI controller driver and updated
the bindings and the addition to the SoC DT accordingly.
Link to v1:
https://lore.kernel.org/linux-kernel/[email protected]/
Please see individual patches for details about the changes.
Alex Bee (7):
dt-bindings: display: rockchip,dw-mipi-dsi: Document RK3128 DSI
dt-bindings: clock: rk3128: Add PCLK_MIPIPHY
clk: rockchip: rk3128: Export PCLK_MIPIPHY
drm/rockchip: dsi: Support optional AHB clock
drm/rockchip: dsi: Add support for RK3128
ARM: dts: rockchip: Add D-PHY for RK3128
ARM: dts: rockchip: Add DSI for RK3128
.../rockchip/rockchip,dw-mipi-dsi.yaml | 25 +++++++++-
arch/arm/boot/dts/rockchip/rk3128.dtsi | 50 +++++++++++++++++++
drivers/clk/rockchip/clk-rk3128.c | 2 +-
.../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 45 +++++++++++++++++
include/dt-bindings/clock/rk3128-cru.h | 1 +
5 files changed, 121 insertions(+), 2 deletions(-)
--
2.43.2
The DPHY's APB clock is required to be exposed in order to be able to
enable it and access the phy's registers.
Signed-off-by: Alex Bee <[email protected]>
Acked-by: Conor Dooley <[email protected]>
---
changes since v1:
- none
include/dt-bindings/clock/rk3128-cru.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/dt-bindings/clock/rk3128-cru.h b/include/dt-bindings/clock/rk3128-cru.h
index 6a47825dac5d..1be455ba4985 100644
--- a/include/dt-bindings/clock/rk3128-cru.h
+++ b/include/dt-bindings/clock/rk3128-cru.h
@@ -116,6 +116,7 @@
#define PCLK_GMAC 367
#define PCLK_PMU_PRE 368
#define PCLK_SIM_CARD 369
+#define PCLK_MIPIPHY 370
/* hclk gates */
#define HCLK_SPDIF 440
--
2.43.2
Export the D-DHY's APB clock for usage in the DT. Also drop the
CLK_IGNORE_UNUSED-flag, as the clock will be enabled on demand.
Signed-off-by: Alex Bee <[email protected]>
---
changes since v1:
- reword commit message
drivers/clk/rockchip/clk-rk3128.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/rockchip/clk-rk3128.c b/drivers/clk/rockchip/clk-rk3128.c
index 75071e0cd321..a20d1fd25e2a 100644
--- a/drivers/clk/rockchip/clk-rk3128.c
+++ b/drivers/clk/rockchip/clk-rk3128.c
@@ -526,7 +526,7 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = {
GATE(PCLK_ACODEC, "pclk_acodec", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 14, GFLAGS),
GATE(0, "pclk_ddrupctl", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 7, GFLAGS),
GATE(0, "pclk_grf", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 4, GFLAGS),
- GATE(0, "pclk_mipiphy", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 0, GFLAGS),
+ GATE(PCLK_MIPIPHY, "pclk_mipiphy", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 0, GFLAGS),
GATE(0, "pclk_pmu", "pclk_pmu_pre", 0, RK2928_CLKGATE_CON(9), 2, GFLAGS),
GATE(0, "pclk_pmu_niu", "pclk_pmu_pre", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(9), 3, GFLAGS),
--
2.43.2
Document the MIPI DSI controller for Rockchip RK3128. The integration is
very similar to PX30, but it has an additional AHB clock.
Signed-off-by: Alex Bee <[email protected]>
---
changes since v1:
- added ahb clock
.../rockchip/rockchip,dw-mipi-dsi.yaml | 25 ++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-mipi-dsi.yaml b/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-mipi-dsi.yaml
index ccf79e738fa1..fdd1c8ad6045 100644
--- a/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-mipi-dsi.yaml
+++ b/Documentation/devicetree/bindings/display/rockchip/rockchip,dw-mipi-dsi.yaml
@@ -15,6 +15,7 @@ properties:
items:
- enum:
- rockchip,px30-mipi-dsi
+ - rockchip,rk3128-mipi-dsi
- rockchip,rk3288-mipi-dsi
- rockchip,rk3399-mipi-dsi
- rockchip,rk3568-mipi-dsi
@@ -36,7 +37,10 @@ properties:
- const: pclk
- const: phy_cfg
- const: grf
- - const: pclk
+ - minItems: 1
+ items:
+ - const: pclk
+ - const: ahb
rockchip,grf:
$ref: /schemas/types.yaml#/definitions/phandle
@@ -120,6 +124,25 @@ allOf:
clock-names:
minItems: 4
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - rockchip,rk3128-mipi-dsi
+
+ then:
+ properties:
+ clocks:
+ minItems: 2
+
+ clock-names:
+ minItems: 2
+
+ required:
+ - phys
+ - phy-names
+
unevaluatedProperties: false
examples:
--
2.43.2
Some integrations of the IP additionally have an AHB clock which has to be
enabled before accessing the registers is possible.
Add support for it as an optional clock.
Signed-off-by: Alex Bee <[email protected]>
---
changes since v1:
- new patch
.../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
index 4cc8ed8f4fbd..6ed64cc35275 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
@@ -265,6 +265,7 @@ struct dw_mipi_dsi_rockchip {
struct clk *pllref_clk;
struct clk *grf_clk;
struct clk *phy_cfg_clk;
+ struct clk *ahb_clk;
/* dual-channel */
bool is_slave;
@@ -1153,7 +1154,15 @@ static int dw_mipi_dsi_dphy_init(struct phy *phy)
goto err_init;
}
+ ret = clk_prepare_enable(dsi->ahb_clk);
+ if (ret) {
+ clk_disable_unprepare(dsi->grf_clk);
+ clk_disable_unprepare(dsi->pclk);
+ goto err_init;
+ }
+
ret = dsi->cdata->dphy_rx_init(phy);
+ clk_disable_unprepare(dsi->ahb_clk);
clk_disable_unprepare(dsi->grf_clk);
clk_disable_unprepare(dsi->pclk);
if (ret < 0)
@@ -1240,6 +1249,12 @@ static int dw_mipi_dsi_dphy_power_on(struct phy *phy)
goto err_phy_cfg_clk;
}
+ ret = clk_prepare_enable(dsi->ahb_clk);
+ if (ret) {
+ DRM_DEV_ERROR(dsi->dev, "Failed to enable ahb_clk: %d\n", ret);
+ goto err_ahb_clk;
+ }
+
/* do soc-variant specific init */
if (dsi->cdata->dphy_rx_power_on) {
ret = dsi->cdata->dphy_rx_power_on(phy);
@@ -1269,6 +1284,8 @@ static int dw_mipi_dsi_dphy_power_on(struct phy *phy)
return ret;
err_pwr_on:
+ clk_disable_unprepare(dsi->ahb_clk);
+err_ahb_clk:
clk_disable_unprepare(dsi->phy_cfg_clk);
err_phy_cfg_clk:
clk_disable_unprepare(dsi->grf_clk);
@@ -1296,6 +1313,7 @@ static int dw_mipi_dsi_dphy_power_off(struct phy *phy)
DRM_DEV_ERROR(dsi->dev, "hardware-specific phy shutdown failed: %d\n", ret);
}
+ clk_disable_unprepare(dsi->ahb_clk);
clk_disable_unprepare(dsi->grf_clk);
clk_disable_unprepare(dsi->pclk);
@@ -1429,6 +1447,13 @@ static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev)
}
}
+ dsi->ahb_clk = devm_clk_get_optional(dev, "ahb");
+ if (IS_ERR(dsi->ahb_clk)) {
+ ret = PTR_ERR(dsi->ahb_clk);
+ DRM_DEV_ERROR(dev, "Unable to get ahb_clk: %d\n", ret);
+ return ret;
+ }
+
dsi->grf_regmap = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
if (IS_ERR(dsi->grf_regmap)) {
DRM_DEV_ERROR(dev, "Unable to get rockchip,grf\n");
--
2.43.2
The InnoSilicon D-PHY found in RK3128 SoCs supports DSI/LVDS/TTL with a
maximum transfer rate of 1 Gbps per lane. While adding it, also add it's
clocks to RK3128_PD_VIO powerdomain as the phy is part of it.
Signed-off-by: Alex Bee <[email protected]>
---
changes since v1:
- also added SCLK_MIPI_24M to powerdomain
- reword commit message
arch/arm/boot/dts/rockchip/rk3128.dtsi | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/arm/boot/dts/rockchip/rk3128.dtsi b/arch/arm/boot/dts/rockchip/rk3128.dtsi
index fb98873fd94e..fbd95bb08cd3 100644
--- a/arch/arm/boot/dts/rockchip/rk3128.dtsi
+++ b/arch/arm/boot/dts/rockchip/rk3128.dtsi
@@ -216,6 +216,8 @@ power-domain@RK3128_PD_VIO {
<&cru ACLK_LCDC0>,
<&cru HCLK_LCDC0>,
<&cru PCLK_MIPI>,
+ <&cru PCLK_MIPIPHY>,
+ <&cru SCLK_MIPI_24M>,
<&cru ACLK_RGA>,
<&cru HCLK_RGA>,
<&cru ACLK_VIO0>,
@@ -496,6 +498,18 @@ hdmi_out: port@1 {
};
};
+ dphy: phy@20038000 {
+ compatible = "rockchip,rk3128-dsi-dphy";
+ reg = <0x20038000 0x4000>;
+ clocks = <&cru SCLK_MIPI_24M>, <&cru PCLK_MIPIPHY>;
+ clock-names = "ref", "pclk";
+ resets = <&cru SRST_MIPIPHY_P>;
+ reset-names = "apb";
+ power-domains = <&power RK3128_PD_VIO>;
+ #phy-cells = <0>;
+ status = "disabled";
+ };
+
timer0: timer@20044000 {
compatible = "rockchip,rk3128-timer", "rockchip,rk3288-timer";
reg = <0x20044000 0x20>;
--
2.43.2
The DesignWare MIPI DSI controller found RK3128 SoCs supports up to 4 DSI
data lanes. Similar to PX30/RK356x/RV1126 it uses an external D-PHY.
Signed-off-by: Alex Bee <[email protected]>
---
changes since v1:
- none
.../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
index 6ed64cc35275..17fd5260218a 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
@@ -153,6 +153,11 @@
#define PX30_DSI_TURNDISABLE BIT(5)
#define PX30_DSI_LCDC_SEL BIT(0)
+#define RK3128_GRF_LVDS_CON0 0x0150
+#define RK3128_DSI_FORCETXSTOPMODE GENMASK(13, 10)
+#define RK3128_DSI_FORCERXMODE BIT(9)
+#define RK3128_DSI_TURNDISABLE BIT(8)
+
#define RK3288_GRF_SOC_CON6 0x025c
#define RK3288_DSI0_LCDC_SEL BIT(6)
#define RK3288_DSI1_LCDC_SEL BIT(9)
@@ -1518,6 +1523,18 @@ static const struct rockchip_dw_dsi_chip_data px30_chip_data[] = {
{ /* sentinel */ }
};
+static const struct rockchip_dw_dsi_chip_data rk3128_chip_data[] = {
+ {
+ .reg = 0x10110000,
+ .lanecfg1_grf_reg = RK3128_GRF_LVDS_CON0,
+ .lanecfg1 = HIWORD_UPDATE(0, RK3128_DSI_TURNDISABLE |
+ RK3128_DSI_FORCERXMODE |
+ RK3128_DSI_FORCETXSTOPMODE),
+ .max_data_lanes = 4,
+ },
+ { /* sentinel */ }
+};
+
static const struct rockchip_dw_dsi_chip_data rk3288_chip_data[] = {
{
.reg = 0xff960000,
@@ -1695,6 +1712,9 @@ static const struct of_device_id dw_mipi_dsi_rockchip_dt_ids[] = {
{
.compatible = "rockchip,px30-mipi-dsi",
.data = &px30_chip_data,
+ }, {
+ .compatible = "rockchip,rk3128-mipi-dsi",
+ .data = &rk3128_chip_data,
}, {
.compatible = "rockchip,rk3288-mipi-dsi",
.data = &rk3288_chip_data,
--
2.43.2
Add the Designware MIPI DSI controller and it's port nodes.
Signed-off-by: Alex Bee <[email protected]>
---
changes since v1:
- added HCLK_VIO_H2P as ahb clock
arch/arm/boot/dts/rockchip/rk3128.dtsi | 36 ++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/arch/arm/boot/dts/rockchip/rk3128.dtsi b/arch/arm/boot/dts/rockchip/rk3128.dtsi
index fbd95bb08cd3..1ed4436549ee 100644
--- a/arch/arm/boot/dts/rockchip/rk3128.dtsi
+++ b/arch/arm/boot/dts/rockchip/rk3128.dtsi
@@ -277,6 +277,42 @@ vop_out_hdmi: endpoint@0 {
reg = <0>;
remote-endpoint = <&hdmi_in_vop>;
};
+
+ vop_out_dsi: endpoint@1 {
+ reg = <1>;
+ remote-endpoint = <&dsi_in_vop>;
+ };
+ };
+ };
+
+ dsi: dsi@10110000 {
+ compatible = "rockchip,rk3128-mipi-dsi", "snps,dw-mipi-dsi";
+ reg = <0x10110000 0x4000>;
+ interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cru PCLK_MIPI>, <&cru HCLK_VIO_H2P>;
+ clock-names = "pclk", "ahb";
+ phys = <&dphy>;
+ phy-names = "dphy";
+ resets = <&cru SRST_VIO_MIPI_DSI>;
+ reset-names = "apb";
+ rockchip,grf = <&grf>;
+ power-domains = <&power RK3128_PD_VIO>;
+ status = "disabled";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ dsi_in: port@0 {
+ reg = <0>;
+ dsi_in_vop: endpoint {
+ remote-endpoint = <&vop_out_dsi>;
+ };
+ };
+
+ dsi_out: port@1 {
+ reg = <1>;
+ };
};
};
--
2.43.2
Hi Alex,
Am Donnerstag, 9. Mai 2024, 14:07:08 CEST schrieb Alex Bee:
> This series aims to add support for the DesignWare MIPI DSI controller and
> the Innoslicon D-PHY found in RK3128 SoCs. The code additions are rather
> tiny: It only need some code in the Rockchip dw-mipi-dsi glue layer for
> this SoC, add support for an additional clock and do some changes in the
> SoC's clock driver. Support for the phy was already added when the
> Innosilicon D-PHY driver was initially submitted. I tested it with a
> 800x1280 DSI panel where all 4 lanes that are supported are used.
>
> changes in v2:
> To improve power-efficiency when the DSI controller is not in use, I
> dropped the patch which made hclk_vio_h2p a critical clock and instead
> added support for an AHB clock to the DSI controller driver and updated
> the bindings and the addition to the SoC DT accordingly.
The naming already suggests that hclk_vio_h2p is not a clock-part of
the actual dsi controller, but more an internal thing inside the clock
controller.
At least naming and perceived functionality would suggest a chain of
hclk_vio -> hclk_vio_h2p -> pclk_mipi
In any case, I really don't see hclk_vio_h2p to be in the realm of the
actual DSI controller, but more a part of clock-controller / interconnect.
Similar to the NIU clocks for the interconnect.
rk3588 actually tries to implement this already and while the
gate-link clocks are described as "recent", I think this definitly the same
concept used a most/all older Rockchip SoCs, just nobody cared about that
till now ;-) [0] .
So TL;DR I'd really prefer to not leak CRU-details into the DSI controller.
Heiko
[0] Which reminds me that I should look at Sebastian's make GATE-LINK
actually-work-patch.
Hi Heiko
Am 09.05.24 um 14:21 schrieb Heiko Stübner:
> Hi Alex,
>
> Am Donnerstag, 9. Mai 2024, 14:07:08 CEST schrieb Alex Bee:
>> This series aims to add support for the DesignWare MIPI DSI controller and
>> the Innoslicon D-PHY found in RK3128 SoCs. The code additions are rather
>> tiny: It only need some code in the Rockchip dw-mipi-dsi glue layer for
>> this SoC, add support for an additional clock and do some changes in the
>> SoC's clock driver. Support for the phy was already added when the
>> Innosilicon D-PHY driver was initially submitted. I tested it with a
>> 800x1280 DSI panel where all 4 lanes that are supported are used.
>>
>> changes in v2:
>> To improve power-efficiency when the DSI controller is not in use, I
>> dropped the patch which made hclk_vio_h2p a critical clock and instead
>> added support for an AHB clock to the DSI controller driver and updated
>> the bindings and the addition to the SoC DT accordingly.
> The naming already suggests that hclk_vio_h2p is not a clock-part of
> the actual dsi controller, but more an internal thing inside the clock
> controller.
>
> At least naming and perceived functionality would suggest a chain of
> hclk_vio -> hclk_vio_h2p -> pclk_mipi
I personally wouldn't give to much on naming when it comes to Rockchip
CRUs. Actually looking at "Fig. 2-5 Chip Clock Architecture Diagram 4" of
RK312x its:
.. -> hclk_vio
-> hclk_h2p (clock in question)
-> pclk_mipi (DSI APB clock)
-> hclk_rga
-> hclk_vop
....
Also there is no other display output path (HDMI, LVDS) which requires this
clock to be enabled. They all work when it's disabled. That really makes me
think it's just the AHB clock line for the DSI controller. Maybe Andy can
share some details?
Alex
> In any case, I really don't see hclk_vio_h2p to be in the realm of the
> actual DSI controller, but more a part of clock-controller / interconnect.
> Similar to the NIU clocks for the interconnect.
>
> rk3588 actually tries to implement this already and while the
> gate-link clocks are described as "recent", I think this definitly the same
> concept used a most/all older Rockchip SoCs, just nobody cared about that
> till now ;-) [0] .
>
> So TL;DR I'd really prefer to not leak CRU-details into the DSI controller.
>
>
> Heiko
>
> [0] Which reminds me that I should look at Sebastian's make GATE-LINK
> actually-work-patch.
>
>
>
>
Am 09.05.24 um 14:43 schrieb Alex Bee:
> Hi Heiko
>
> Am 09.05.24 um 14:21 schrieb Heiko Stübner:
>> Hi Alex,
>>
>> Am Donnerstag, 9. Mai 2024, 14:07:08 CEST schrieb Alex Bee:
>>> This series aims to add support for the DesignWare MIPI DSI
>>> controller and
>>> the Innoslicon D-PHY found in RK3128 SoCs. The code additions are
>>> rather
>>> tiny: It only need some code in the Rockchip dw-mipi-dsi glue layer for
>>> this SoC, add support for an additional clock and do some changes in
>>> the
>>> SoC's clock driver. Support for the phy was already added when the
>>> Innosilicon D-PHY driver was initially submitted. I tested it with a
>>> 800x1280 DSI panel where all 4 lanes that are supported are used.
>>>
>>> changes in v2:
>>> To improve power-efficiency when the DSI controller is not in use, I
>>> dropped the patch which made hclk_vio_h2p a critical clock and
>>> instead
>>> added support for an AHB clock to the DSI controller driver and
>>> updated
>>> the bindings and the addition to the SoC DT accordingly.
>> The naming already suggests that hclk_vio_h2p is not a clock-part of
>> the actual dsi controller, but more an internal thing inside the clock
>> controller.
>>
>> At least naming and perceived functionality would suggest a chain of
>> hclk_vio -> hclk_vio_h2p -> pclk_mipi
> I personally wouldn't give to much on naming when it comes to Rockchip
> CRUs. Actually looking at "Fig. 2-5 Chip Clock Architecture Diagram 4" of
> RK312x its:
>
>
> ... -> hclk_vio
>
> -> hclk_h2p (clock in question)
> -> pclk_mipi (DSI APB clock)
> -> hclk_rga
> -> hclk_vop
> ....
>
> Also there is no other display output path (HDMI, LVDS) which requires
> this
> clock to be enabled. They all work when it's disabled. That really
> makes me
> think it's just the AHB clock line for the DSI controller. Maybe Andy can
> share some details?
Anyway: I just looked at the "MIPI Controller architecture" part of the
TRM - there is not even AHB clock line, only APB. So I revert the change
with the additional clock, make the h2p-clock critical again and resend.
Alex
>> In any case, I really don't see hclk_vio_h2p to be in the realm of the
>> actual DSI controller, but more a part of clock-controller /
>> interconnect.
>> Similar to the NIU clocks for the interconnect.
>>
>> rk3588 actually tries to implement this already and while the
>> gate-link clocks are described as "recent", I think this definitly
>> the same
>> concept used a most/all older Rockchip SoCs, just nobody cared about
>> that
>> till now ;-) [0] .
>>
>> So TL;DR I'd really prefer to not leak CRU-details into the DSI
>> controller.
>>
>>
>> Heiko
>>
>> [0] Which reminds me that I should look at Sebastian's make GATE-LINK
>> actually-work-patch.
>>
>>
>>
>>