Add support for Mediatek mt8167 HDMI display output
Subsystems (7)
cover Add support for Mediatek mt8167 HDMI display output
The MediaTek mt8167 SoC supports HDMI output via a dedicated HDMI PHY driven by the DPI1 display block.
Support for HDMI output was partially upstreamed in 2021, but is currently not functional as it's missing its HDMI PHY driver. The HDMI PHY is apparently similar to the mt2701 one, but some differences in timings and in the initialization sequence are better expressed with a separate driver.
* Patch 1, 2 add support for the HDMI PHY.
In addition to the HDMI PHY, a few fixes are required here and there to actually get HDMI output.
* Patch 3: Some of the HDMI registers are mapped into the apmixedsys syscon. Since they are manipulated inside the HDMI PHY driver, we change the apmixedsys memory map to non exclusive by switching it from devm_platform_ioremap_resource to of_iomap. This approach was copied from mt8173 apmixedsys syscon.
* Patch 4: Since the DPI1 interface is hardwired to the HDMI PHY, it is appropriate for the HDMI PHY to control the DPI1 clocks. There is no effect on DPI0 clocks as they're completely separate.
* Patch 5: Some MediaTek SoCs require a supervisor call to enable HDMI output. mt8167 is not one of those.
* Patch 6: In the common path for mt2701/mt8167, a register operation that is meant to enable the HDMI_PSECUR_EN bit is actually touching some other bits that are set by later operations anyway. The patch makes more explicit the intent of the operation by setting only the necessary bit.
* Patch 7: Adds the device tree nodes to the mt8167 dtsi. Since DPI1 is hardwired to HDMI it is possible to bind the input port of the HDMI node to the output port of DPI1, but the patch that adds the DPI nodes to the DTSI [1] has not been picked up yet, so we leave it disconnected for now.
The series was tested at all supported resolutions on the Sony PlayStation Classic Mini.
[1] https://lore.kernel.org/linux-mediatek/[email protected]/
Luca Leonardo Scorcia (7):
dt-bindings: mediatek: hdmi-phy: Add compatible for mt8167
phy: mediatek: hdmi: Add support for mt8167
clk: mediatek: mt8167: Map apmixedsys iomem as shared
clk: mediatek: mt8167: Correct HDMI-related clock definitions drm/mediatek: mtk_hdmi: Set tz_disabled for mt8167 drm/mediatek: mtk_hdmi: Improve the secure output bit toggle
arm64: dts: mediatek: mt8167: Add HDMI display nodes
.../bindings/phy/mediatek,hdmi-phy.yaml | 1 + arch/arm64/boot/dts/mediatek/mt8167.dtsi | 62 +++++ drivers/clk/mediatek/clk-mt8167-apmixedsys.c | 26 ++- drivers/clk/mediatek/clk-mt8167.c | 6 +- drivers/gpu/drm/mediatek/mtk_hdmi.c | 3 +- drivers/gpu/drm/mediatek/mtk_hdmi_regs.h | 1 + drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c | 217 ++++++++++++++++++ drivers/phy/mediatek/phy-mtk-hdmi.c | 3 + drivers/phy/mediatek/phy-mtk-hdmi.h | 1 + 10 files changed, 314 insertions(+), 7 deletions(-) create mode 100644 drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c
base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a
Signature · 1 line
2.43.0
PATCH 1/7 dt-bindings: mediatek: hdmi-phy: Add compatible for mt8167
The hdmi-phy for the MediaTek mt8167 SoC is not compatible with any of the existing hdmi-phy. Add a separate compatible to describe it.
--- Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml +1 -0
@@ -31,6 +31,7 @@ properties: - mediatek,mt8188-hdmi-phy - const: mediatek,mt8195-hdmi-phy - const: mediatek,mt2701-hdmi-phy + - const: mediatek,mt8167-hdmi-phy - const: mediatek,mt8173-hdmi-phy - const: mediatek,mt8195-hdmi-phy
Signature · 1 line
2.43.0
Re: [PATCH 1/7] dt-bindings: mediatek: hdmi-phy: Add compatible for mt8167
Quoted 5 lines · Luca Leonardo Scorcia
External email : Please do not click links or open attachments until you have verified the sender or the content.
The hdmi-phy for the MediaTek mt8167 SoC is not compatible with any of the existing hdmi-phy. Add a separate compatible to describe it.
Quoted 4 lines
Signed-off-by Luca Leonardo Scorcia <[email protected]>---
Re: [PATCH 1/7] dt-bindings: mediatek: hdmi-phy: Add compatible for mt8167
Quoted 8 lines · CK Hu (胡俊光)
Quoted 5 lines · Luca Leonardo Scorcia
External email : Please do not click links or open attachments until you have verified the sender or the content.
The hdmi-phy for the MediaTek mt8167 SoC is not compatible with any of the existing hdmi-phy. Add a separate compatible to describe it.
Reviewed-by CK Hu <[email protected]>
If you are going to review this, then review entire code, not just piece visible here while leaving the rest obviously incomplete.
Best regards,
Krzysztof
Re: [PATCH 1/7] dt-bindings: mediatek: hdmi-phy: Add compatible for mt8167
In reply to Luca Leonardo ScorciaQuoted 13 lines · Luca Leonardo Scorcia
The hdmi-phy for the MediaTek mt8167 SoC is not compatible with any of the existing hdmi-phy. Add a separate compatible to describe it.
Signed-off-by Luca Leonardo Scorcia <[email protected]>--- Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml +0
-0
Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml properties: · line 34
Quoted 4 lines
Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml +1
-0@@ -31,6 +31,7 @@ properties: - mediatek,mt8188-hdmi-phy - const: mediatek,mt8195-hdmi-phy - const: mediatek,mt2701-hdmi-phy + - const: mediatek,mt8167-hdmi-phy
Why do you have flexible clocks?
Best regards,
Krzysztof
Re: [PATCH 1/7] dt-bindings: mediatek: hdmi-phy: Add compatible for mt8167
Quoted 1 line
Why do you have flexible clocks?
Hi, I'm sorry but I need a little help in understanding your comment. If you meant "Why isn't there a constraint on the clocks' names", it is already provided by the existing conditional block [1].
If you meant "Why does clock-output-names have only the maxItems number and does not specify the clock name", it was there before [2]. It could probably be added back with another conditional expression. If you meant something else entirely I apologize and would appreciate some additional guidance.
Thank you,
Luca
[1] https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/phy/mediatek%2Chdmi-phy.yaml#L90-L102
[2] https://lore.kernel.org/all/20251217-mtk-genio-evk-hdmi-support-v2-1-a994976bb39a@collabora.com/
Krzysztof Kozlowski
Acked-byRe: [PATCH 1/7] dt-bindings: mediatek: hdmi-phy: Add compatible for mt8167
Quoted 5 lines · Luca Leonardo Scorcia
Quoted 1 line
Why do you have flexible clocks?
Hi, I'm sorry but I need a little help in understanding your comment. If you meant "Why isn't there a constraint on the clocks' names", it is already provided by the existing conditional block [1].
Ack
Best regards,
Krzysztof
PATCH 2/7 phy: mediatek: hdmi: Add support for mt8167
In reply to Luca Leonardo ScorciaAdd support for the HDMI PHY found in MediaTek mt8167.
--- drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c | 217 +++++++++++++++++++++ drivers/phy/mediatek/phy-mtk-hdmi.c | 3 + drivers/phy/mediatek/phy-mtk-hdmi.h | 1 + 4 files changed, 222 insertions(+) create mode 100644 drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c
drivers/phy/mediatek/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_PHY_MTK_XFI_TPHY) += phy-mtk-xfi-tphy.o phy-mtk-hdmi-drv-y := phy-mtk-hdmi.o phy-mtk-hdmi-drv-y += phy-mtk-hdmi-mt2701.o +phy-mtk-hdmi-drv-y += phy-mtk-hdmi-mt8167.o phy-mtk-hdmi-drv-y += phy-mtk-hdmi-mt8173.o phy-mtk-hdmi-drv-y += phy-mtk-hdmi-mt8195.o obj-$(CONFIG_PHY_MTK_HDMI) += phy-mtk-hdmi-drv.o
drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c new file +217 -0
217 lines not on this page · raw message
drivers/phy/mediatek/phy-mtk-hdmi.c +3 -0
@@ -186,6 +186,9 @@ static const struct of_device_id mtk_hdmi_phy_match[] = { { .compatible = "mediatek,mt2701-hdmi-phy", .data = &mtk_hdmi_phy_2701_conf, }, + { .compatible = "mediatek,mt8167-hdmi-phy", + .data = &mtk_hdmi_phy_8167_conf, + }, { .compatible = "mediatek,mt8173-hdmi-phy", .data = &mtk_hdmi_phy_8173_conf, },
drivers/phy/mediatek/phy-mtk-hdmi.h +1 -0
@@ -49,6 +49,7 @@ struct mtk_hdmi_phy {struct mtk_hdmi_phy *to_mtk_hdmi_phy (struct clk_hw *hw);extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8195_conf; +extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8167_conf;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 2/7] phy: mediatek: hdmi: Add support for mt8167
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] clk: determine_rate callback fails to propagate best_parent_rate and mutates persistent state…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] clk: determine_rate callback fails to propagate best_parent_rate and mutates persistent state
- [Medium] clk: phy-mtk-hdmi: recalc_rate returns internal rate instead of logical TMDS clock --
commit c9a6701a365f2268fb32f51141821ccc937de091
Author: Luca Leonardo Scorcia <[email protected]>
phy: mediatek: hdmi: Add support for mt8167
Add support for the HDMI PHY found in MediaTek mt8167.
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c new file +0
-0
[ ... ]
drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c line 94
Quoted 9 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c new file +9
-0+static int mtk_hdmi_pll_determine_rate (struct clk_hw *hw, +struct clk_rate_request *req) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); + + hdmi_phy->pll_rate = req->rate; + +return 0 ; +}
[Severity: High]
Does this callback fail to calculate and set req->best_parent_rate?
This clock is registered with the CLK_SET_RATE_PARENT flag set. Failing to update req->best_parent_rate means the parent clock's rate might never be adjusted to support required pixel clock frequencies, such as 148.5MHz or 108MHz. The hardware dividers configured in set_rate would be applied to an unscaled parent frequency, yielding an incorrect HDMI pixel clock.
Also, since determine_rate is a dry-run CCF query callback (e.g., invoked by clk_round_rate), is it safe to mutate persistent driver state (hdmi_phy->pll_rate) here?
[ ... ]
Quoted 7 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c new file +7
-0+static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); + +unsigned long out_rate, val; +u32 tmp;
[ ... ]
drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c line 181
Quoted 9 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8167.c new file +9
-0+ tmp =readl (hdmi_phy->regs +HDMI_CON2 ); + val =FIELD_GET (RG_HDMITX_TX_POSDIV , tmp); + out_rate >>= val; + +if (tmp &RG_HDMITX_EN_TX_POSDIV ) + out_rate /=5 ; + +return out_rate; +}
[Severity: Medium]
Does this mathematically compute the internal PHY output rate instead of the logical TMDS pixel clock requested by the HDMI controller?
It appears this calculates a fraction of the TMDS clock (e.g., 37.125MHz for a 74.25MHz clock). Since the HDMI controller driver requests the TMDS pixel clock rate, returning the internal rate could lead to CCF rate mismatches and warnings like "Want PLL 74250000 Hz, got 37125000 Hz".
Combined with mtk_hdmi_pll_determine_rate() failing to configure the appropriate scaled rate for the parent clock, could this cement the framework mismatch and violate the clock framework API contract?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH 3/7 clk: mediatek: mt8167: Map apmixedsys iomem as shared
In reply to Luca Leonardo ScorciaThe hdmi_phy for mt8167 and the apmixedsys clocks share the same IO memory region and they both map it using devm_platform_ioremap_resource, which implies exclusive access. Switch the apmixedsys driver to of_iomap, like it is done in the mt8173-apmixedsys driver. Also, implement the remove function while we're at it.
Fixes the following runtime error:
hdmi-phy: error -EBUSY: can't request region for resource [mem 0x10018300-0x1001831f]
--- drivers/clk/mediatek/clk-mt8167-apmixedsys.c | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/clk/mediatek/clk-mt8167-apmixedsys.c +20 -4
@@ -8,6 +8,7 @@#include <dt-bindings/clock/mt8167-clk.h> #include <linux/clk.h> #include <linux/of.h> +#include <linux/of_address.h> #include <linux/platform_device.h> #include "clk-pll.h"
@@ -97,17 +98,19 @@ static int clk_mt8167_apmixed_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;int ret; - base =devm_platform_ioremap_resource (pdev,0 ); + base =of_iomap (node,0 );if (IS_ERR (base))return PTR_ERR (base); clk_data =mtk_devm_alloc_clk_data (dev,MT8167_CLK_APMIXED_NR_CLK ); -if (!clk_data) -return -ENOMEM ; +if (IS_ERR_OR_NULL (clk_data)) { + ret = -ENOMEM ; + goto unmap_io; + } ret =mtk_clk_register_plls (dev, plls,ARRAY_SIZE (plls), clk_data);if (ret) -return ret; + goto unmap_io; ret =mtk_clk_register_dividers (dev, adj_divs,ARRAY_SIZE (adj_divs), base, &mt8167_apmixed_clk_lock, clk_data);
@@ -124,10 +127,22 @@ static int clk_mt8167_apmixed_probe(struct platform_device *pdev)mtk_clk_unregister_dividers (adj_divs,ARRAY_SIZE (adj_divs), clk_data); unregister_plls:mtk_clk_unregister_plls (plls,ARRAY_SIZE (plls), clk_data); +unmap_io: +iounmap (base);return ret; } +static void clk_mt8167_apmixed_remove (struct platform_device *pdev) +{ +struct device_node *node = pdev->dev.of_node; +struct clk_hw_onecell_data *clk_data =platform_get_drvdata (pdev); + +of_clk_del_provider (node); +mtk_clk_unregister_dividers (adj_divs,ARRAY_SIZE (adj_divs), clk_data); +mtk_clk_unregister_plls (plls,ARRAY_SIZE (plls), clk_data); +} +static const struct of_device_id of_match_clk_mt8167_apmixed[] = { { .compatible ="mediatek,mt8167-apmixedsys" }, {/* sentinel */ }
@@ -136,6 +151,7 @@ MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_apmixed);static struct platform_driver clk_mt8167_apmixed_drv = { .probe = clk_mt8167_apmixed_probe, + .remove = clk_mt8167_apmixed_remove, .driver = { .name ="clk-mt8167-apmixed" , .of_match_table = of_match_clk_mt8167_apmixed,
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 3/7] clk: mediatek: mt8167: Map apmixedsys iomem as shared
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] clk: mediatek: IS_ERR() used to check of_iomap() return value instead of NULL check - [High] clk…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] clk: mediatek: IS_ERR() used to check of_iomap() return value instead of NULL check
- [High] clk: mediatek: missing platform_set_drvdata() causes silent failure in remove()
- [Medium] clk: mediatek: missing iounmap() for driver base mapping in remove() --
commit 847eb51d406a77cda5e7387f55742129733ec7b6
Author: Luca Leonardo Scorcia <[email protected]>
clk: mediatek: mt8167: Map apmixedsys iomem as shared
The hdmi_phy for mt8167 and the apmixedsys clocks share the same IO memory region and they both map it using devm_platform_ioremap_resource, which implies exclusive access. Switch the apmixedsys driver to of_iomap, like it is done in the mt8173-apmixedsys driver. Also, implement the remove function while we're at it.
Quoted 4 lines
drivers/clk/mediatek/clk-mt8167-apmixedsys.c +0
-0
[ ... ]
drivers/clk/mediatek/clk-mt8167-apmixedsys.c static int clk_mt8167_apmixed_probe(struct platform_device *pdev) · line 102
Quoted 7 lines
drivers/clk/mediatek/clk-mt8167-apmixedsys.c +1
-1@@ -97,17 +98,19 @@ static int clk_mt8167_apmixed_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;int ret; - base =devm_platform_ioremap_resource (pdev,0 ); + base =of_iomap (node,0 );if (IS_ERR (base))
[Severity: High]
Does this code handle the of_iomap() return value correctly? of_iomap() returns NULL on failure, rather than an ERR_PTR. If it fails, base will be NULL, which bypasses this error check and propagates to the register functions.
drivers/clk/mediatek/clk-mt8167-apmixedsys.c static int clk_mt8167_apmixed_probe(struct platform_device *pdev) · line 106
Quoted 6 lines
drivers/clk/mediatek/clk-mt8167-apmixedsys.c +1
-2return PTR_ERR (base); clk_data =mtk_devm_alloc_clk_data (dev,MT8167_CLK_APMIXED_NR_CLK ); -if (!clk_data) -return -ENOMEM ; +if (IS_ERR_OR_NULL (clk_data)) {
[Severity: High]
Does this code need to save clk_data to the device's driver data? It looks like clk_mt8167_apmixed_probe() allocates clk_data but never calls platform_set_drvdata() to store it before returning.
Quoted 3 lines
drivers/clk/mediatek/clk-mt8167-apmixedsys.c +3
-0+ ret = -ENOMEM ; + goto unmap_io; + }
[ ... ]
Quoted 4 lines
drivers/clk/mediatek/clk-mt8167-apmixedsys.c +0
-0@@ -124,10 +127,22 @@ static int clk_mt8167_apmixed_probe(struct platform_device *pdev)mtk_clk_unregister_dividers (adj_divs,ARRAY_SIZE (adj_divs), clk_data); unregister_plls:mtk_clk_unregister_plls (plls,ARRAY_SIZE (plls), clk_data);
drivers/clk/mediatek/clk-mt8167-apmixedsys.c static int clk_mt8167_apmixed_probe(struct platform_device *pdev) · line 139
Quoted 10 lines
drivers/clk/mediatek/clk-mt8167-apmixedsys.c +6
-0+unmap_io: +iounmap (base);return ret; } +static void clk_mt8167_apmixed_remove (struct platform_device *pdev) +{ +struct device_node *node = pdev->dev.of_node; +struct clk_hw_onecell_data *clk_data =platform_get_drvdata (pdev);
[Severity: High]
Since platform_set_drvdata() was never called in the probe function, won't platform_get_drvdata() evaluate to NULL here? This would render the subsequent unregister calls as no-ops, failing to unregister the clocks.
[Severity: Medium]
Does this remove function leak the I/O memory mapping? The base mapping created by of_iomap() in clk_mt8167_apmixed_probe() doesn't appear to be unmapped via iounmap() here.
Since base is only a local variable in the probe function and isn't saved to a device context, there is no way for clk_mt8167_apmixed_remove() to retrieve the pointer to clean it up.
Quoted 5 lines
drivers/clk/mediatek/clk-mt8167-apmixedsys.c +5
-0+ +of_clk_del_provider (node); +mtk_clk_unregister_dividers (adj_divs,ARRAY_SIZE (adj_divs), clk_data); +mtk_clk_unregister_plls (plls,ARRAY_SIZE (plls), clk_data); +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH 4/7 clk: mediatek: mt8167: Correct HDMI-related clock definitions
In reply to Luca Leonardo ScorciaOn the mt8167 SoC, the tvdpll_ck clock is used to clock the DPI1 pixel signal that is hardwired to the HDMI interface.
The clocks used by those two blocks must match and they have to be changed according to the mode clock appropriate for the display resolution. Fix a couple of issues with the current HDMI clock definitions:
- The hdmi_ref divider references the same register and offset of its parent tvdpll. Make sure to flag it as a read only divider as its rate must be set by the DPI driver only.
- Both hdmi_ref and tvdpll_ck derive their clock from the same tvdpll parent clock, but its rate must be set by the DPI driver only. Unset the CLK_SET_RATE_PARENT flag that is implicitly set by the FACTOR() macro.
--- drivers/clk/mediatek/clk-mt8167-apmixedsys.c | 2 +- drivers/clk/mediatek/clk-mt8167.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/clk/mediatek/clk-mt8167-apmixedsys.c +1 -1
@@ -87,7 +87,7 @@ static const struct mtk_pll_data plls[] = {static const struct mtk_clk_divider adj_divs[] = {DIV_ADJ_FLAG (CLK_APMIXED_HDMI_REF ,"hdmi_ref" ,"tvdpll" , -0x1c4 ,24 ,3 ,CLK_DIVIDER_POWER_OF_TWO ), +0x1c4 ,24 ,3 ,CLK_DIVIDER_POWER_OF_TWO |CLK_DIVIDER_READ_ONLY ), };static int clk_mt8167_apmixed_probe (struct platform_device *pdev)
drivers/clk/mediatek/clk-mt8167.c +5 -1
@@ -75,7 +75,11 @@ static const struct mtk_fixed_factor top_divs[] = {FACTOR (CLK_TOP_CLK26M ,"clk26m_ck" ,"clk26m" ,1 ,1 ),FACTOR (CLK_TOP_CLK26M_D2 ,"clk26m_d2" ,"clk26m" ,1 ,2 ),FACTOR (CLK_TOP_MIPI_26M ,"mipi_26m" ,"clk26m" ,1 ,1 ), -FACTOR (CLK_TOP_TVDPLL ,"tvdpll_ck" ,"tvdpll" ,1 ,1 ), +/* +* The tvdpll_ck clock should not propagate rate changes to its parent +* clock so the dpi driver can have full control over PLL and divider. +*/ +FACTOR_FLAGS (CLK_TOP_TVDPLL ,"tvdpll_ck" ,"tvdpll" ,1 ,1 ,0 ),FACTOR (CLK_TOP_TVDPLL_D2 ,"tvdpll_d2" ,"tvdpll_ck" ,1 ,2 ),FACTOR (CLK_TOP_TVDPLL_D4 ,"tvdpll_d4" ,"tvdpll_ck" ,1 ,4 ), FACTOR(CLK_TOP_TVDPLL_D8, "tvdpll_d8", "tvdpll_ck", 1, 8),
Signature · 1 line
2.43.0
PATCH 5/7 drm/mediatek: mtk_hdmi: Set tz_disabled for mt8167
In reply to Luca Leonardo ScorciaJust like mt2701, MediaTek mt8167 does not require an ARM supervisor mode call to toggle HDMI output.
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/mediatek/mtk_hdmi.c +1 -0
@@ -1214,6 +1214,7 @@ static const struct mtk_hdmi_conf mtk_hdmi_conf_mt2701 = { };static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8167 = { + .tz_disabled = true, .cea_modes_only = true, .max_mode_clock =148500 , .ver_conf = &mtk_hdmi_v1_ver_conf
Signature · 1 line
2.43.0
Re: [PATCH 5/7] drm/mediatek: mtk_hdmi: Set tz_disabled for mt8167
Quoted 5 lines · Luca Leonardo Scorcia
External email : Please do not click links or open attachments until you have verified the sender or the content.
Just like mt2701, MediaTek mt8167 does not require an ARM supervisor mode call to toggle HDMI output.
Quoted 4 lines
Fixes 511cf7d12331 ("drm/mediatek: hdmi: Add MT8167 configuration")Signed-off-by Luca Leonardo Scorcia <[email protected]>---
PATCH 6/7 drm/mediatek: mtk_hdmi: Improve the secure output bit toggle
In reply to Luca Leonardo ScorciaThe secure output control bit toggle for mt2701/mt8167 currently sets bit 0 (DEEP_COLOR_EN), 1-2 (DEEP_COLOR_MODE), 15 (HDMI_PSECUR_EN) and 31 (HDMI_PCLK_FREE_RUN_EN) in the same operation, but only bit 15 is actually controlling the HDMI_PSECUR_EN bit, the rest of them are already being set in separate operations later. Add a define for bit 15 and clean up the bit update operation.
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 2 +- drivers/gpu/drm/mediatek/mtk_hdmi_regs.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_hdmi.c +1 -1
@@ -63,7 +63,7 @@ static void mtk_hdmi_hw_make_reg_writable(struct mtk_hdmi *hdmi, bool enable)if (hdmi->conf && hdmi->conf->tz_disabled)regmap_update_bits (hdmi->sys_regmap, hdmi->sys_offset +HDMI_SYS_CFG20 , -0x80008005 , enable ?0x80000005 :0x8000 ); +HDMI_PSECUR_EN , enable ?0 :HDMI_PSECUR_EN );else arm_smccc_smc (MTK_SIP_SET_AUTHORIZED_SECURE_REG ,0x14000904 ,0x80000000 ,0 ,0 ,0 ,0 ,0 , &res);
drivers/gpu/drm/mediatek/mtk_hdmi_regs.h +1 -0
@@ -219,6 +219,7 @@#define DEEP_COLOR_EN BIT(0)#define HDMI_AUDIO_TEST_SEL BIT(8)#define HDMI2P0_EN BIT(11) +#define HDMI_PSECUR_EN BIT(15)#define HDMI_OUT_FIFO_EN BIT(16)#define HDMI_OUT_FIFO_CLK_INV BIT(17)#define MHL_MODE_ON BIT(28)
Signature · 1 line
2.43.0
Re: [PATCH 6/7] drm/mediatek: mtk_hdmi: Improve the secure output bit toggle
Quoted 9 lines · Luca Leonardo Scorcia
External email : Please do not click links or open attachments until you have verified the sender or the content.
The secure output control bit toggle for mt2701/mt8167 currently sets bit 0 (
DEEP_COLOR_EN), 1-2 (DEEP_COLOR_MODE), 15 (HDMI_PSECUR_EN) and 31 (HDMI_PCLK_FREE_RUN_EN) in the same operation, but only bit 15 is actually controlling theHDMI_PSECUR_ENbit, the rest of them are already being set in separate operations later. Add a define for bit 15 and clean up the bit update operation.
Quoted 4 lines
Fixes 0fc721b2968e ("drm/mediatek: add hdmi driver for MT2701 and MT7623")Signed-off-by Luca Leonardo Scorcia <[email protected]>---
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
PATCH 7/7 arm64: dts: mediatek: mt8167: Add HDMI display nodes
In reply to Luca Leonardo ScorciaAdd the required nodes to drive HDMI output on the mt8167 SoC.
--- arch/arm64/boot/dts/mediatek/mt8167.dtsi | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
arch/arm64/boot/dts/mediatek/mt8167.dtsi +62 -0
@@ -112,6 +112,27 @@ apmixedsys: apmixedsys@10018000 { #clock-cells = <1>; }; + hdmi_phy: hdmi-phy@10018300 { + compatible = "mediatek,mt8167-hdmi-phy"; + reg = <0 0x10018300 0 0x20>; + clocks = <&apmixedsys CLK_APMIXED_HDMI_REF>; + clock-names = "pll_ref"; + clock-output-names = "hdmtx_dig_cts"; + mediatek,ibias = <0xa>; + mediatek,ibias_up = <0x1c>; + #clock-cells = <0>; + #phy-cells = <0>; + status = "disabled"; + }; + + cec: cec@1001a000 { + compatible = "mediatek,mt8167-cec", "mediatek,mt8173-cec"; + reg = <0 0x1001a000 0 0xbc>; + interrupts = <GIC_SPI 148 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_26M_CEC>; + status = "disabled"; + }; + iommu: m4u@10203000 { compatible = "mediatek,mt8167-m4u"; reg = <0 0x10203000 0 0x1000>;
@@ -120,6 +141,15 @@ iommu: m4u@10203000 { #iommu-cells = <1>; }; + hdmiddc: i2c@11011000 { + compatible = "mediatek,mt8167-hdmi-ddc", "mediatek,mt8173-hdmi-ddc"; + reg = <0 0x11011000 0 0x10>; + interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_26M_HDMI_SIFM>; + clock-names = "ddc-i2c"; + status = "disabled"; + }; + mmsys: syscon@14000000 { compatible = "mediatek,mt8167-mmsys", "syscon"; reg = <0 0x14000000 0 0x1000>;
@@ -145,6 +175,38 @@ smi_common: smi@14017000 { power-domains = <&spm MT8167_POWER_DOMAIN_MM>; }; + hdmi: hdmi@1401b000 { + compatible = "mediatek,mt8167-hdmi"; + reg = <0 0x1401b000 0 0x400>; + clocks = <&mmsys CLK_MM_HDMI_PXL>, + <&mmsys CLK_MM_HDMI_PLL>, + <&mmsys CLK_MM_HDMI_ADSP_BCK>, + <&mmsys CLK_MM_HDMI_SPDIF>; + clock-names = "pixel", "pll", "bclk", "spdif"; + interrupts = <GIC_SPI 148 IRQ_TYPE_LEVEL_LOW>; + phys = <&hdmi_phy>; + phy-names = "hdmi"; + mediatek,syscon-hdmi = <&mmsys 0x900>; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + hdmi0_in: endpoint { }; + }; + + port@1 { + reg = <1>; + + hdmi0_out: endpoint { }; + }; + }; + }; + imgsys: syscon@15000000 { compatible = "mediatek,mt8167-imgsys", "syscon"; reg = <0 0x15000000 0 0x1000>;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 7/7] arm64: dts: mediatek: mt8167: Add HDMI display nodes
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dts: mt8167: hdmiddc compatible array violates schema enum constraint --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dts: mt8167: hdmiddc compatible array violates schema enum constraint --
commit c20e20334411b75b4e2b444ca191ccb04b2ad0ef
Author: Luca Leonardo Scorcia <[email protected]>
arm64: dts: mediatek: mt8167: Add HDMI display nodes
This commit adds the required device tree nodes to enable HDMI output on the mt8167 SoC.
Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt8167.dtsi +0
-0
[ ... ]
arch/arm64/boot/dts/mediatek/mt8167.dtsi iommu: m4u@10203000 { · line 145
Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8167.dtsi +2
-0@@ -120,6 +141,15 @@ iommu: m4u@10203000 { #iommu-cells = <1>; }; + hdmiddc: i2c@11011000 { + compatible = "mediatek,mt8167-hdmi-ddc", "mediatek,mt8173-hdmi-ddc";
[Severity: Low]
Does this compatible array violate the devicetree schema constraints?
The mediatek,hdmi-ddc.yaml schema uses an enum constraint for the compatible property:
properties:
compatible:
enum:
- mediatek,mt7623-hdmi-ddc
- mediatek,mt8167-hdmi-ddc
- mediatek,mt8173-hdmi-ddc
This restricts the property to a single string and prevents fallback arrays.
Compiling the devicetree with make dtbs_check will throw a schema validation warning here.
Quoted 7 lines
arch/arm64/boot/dts/mediatek/mt8167.dtsi +7
-0+ reg = <0 0x11011000 0 0x10>; + interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_LOW>; + clocks = <&topckgen CLK_TOP_26M_HDMI_SIFM>; + clock-names = "ddc-i2c"; + status = "disabled"; + }; +
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7