Add MT8195 HDMI support
Subsystems (7)
v2 cover Add MT8195 HDMI support
Add support for HDMI Tx on MT8195.
This includes a split of the current "legacy" hdmi driver into a common library of functions and a two dedicated compilation units with specific code for mt8167 and another for the "new" mt8195 SoC.
Support for the new mt8195 hdmi phy and the dpi/drm_drv adjustements to support hdmi.
Based on next-20221014
test branch with dts and various "in flight" patches available here:
https://gitlab.com/granquet/linux/-/tree/granquet/linux-next_HDMI
I haven't updated the vdosys/mmsys/ethdr and mutex patches in a while in that test branch, they might be outdated..
To: Chunfeng Yun <[email protected]>
To: Kishon Vijay Abraham I <[email protected]>
To: Vinod Koul <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Matthias Brugger <[email protected]>
To: Chun-Kuang Hu <[email protected]>
To: Philipp Zabel <[email protected]>
To: David Airlie <[email protected]>
To: Daniel Vetter <[email protected]>
To: CK Hu <[email protected]>
To: Jitao shi <[email protected]>
---
Changes in v2:
- Removed syscon requirement from the hdmi node
- Use as much as possible bit FIELD_PREP/FIELD_GET macros across all the patches
- Make cec optional dynamically instead of hardcoded with a flag
- Renamed hdmi variants to v1 (legacy) and v2 (mt8195) while waiting for a better name
- Rework hdmi v2 code to use a connector (same as v1)
- Remove "magic" 0x43 addr special handling in hdmi ddc code
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Guillaume Ranquet (12):
dt-bindings: phy: mediatek: hdmi-phy: Add mt8195 compatible
dt-bindings: display: mediatek: add MT8195 hdmi bindings drm/mediatek: hdmi: use a regmap instead of iomem drm/mediatek: extract common functions from the mtk hdmi driver drm/mediatek: hdmi: make the cec dev optional
drm/mediatek: hdmi: add frame_colorimetry flag drm/mediatek: hdmi: add v2 support
drm/mediatek: hdmi: v2: add audio support
phy: phy-mtk-hdmi: Add generic phy configure callback
phy: mediatek: add support for phy-mtk-hdmi-mt8195
dt-bindings: display: mediatek: dpi: Add compatible for MediaTek MT8195 drm/mediatek: dpi: Add mt8195 hdmi to DPI driver
.../bindings/display/mediatek/mediatek,dpi.yaml | 1 + .../bindings/display/mediatek/mediatek,hdmi.yaml | 67 +- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 51 + .../devicetree/bindings/phy/mediatek,hdmi-phy.yaml | 1 + drivers/gpu/drm/mediatek/Makefile | 5 +- drivers/gpu/drm/mediatek/mtk_dpi.c | 143 +- drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 5 + drivers/gpu/drm/mediatek/mtk_hdmi.c | 655 +------- drivers/gpu/drm/mediatek/mtk_hdmi.h | 16 + drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 477 ++++++ drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 224 +++ drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c | 367 +++++ drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h | 309 ++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.c | 1592 ++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.h | 31 + drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 546 +++++++ drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h | 131 ++ drivers/phy/mediatek/phy-mtk-hdmi.c | 15 + drivers/phy/mediatek/phy-mtk-hdmi.h | 2 + 20 files changed, 4004 insertions(+), 635 deletions(-)
---
base-commit: 98035e7c0bb29bf68a2f4b650656f3a3dd07a494
change-id: 20220919-hdmi_mtk
Best regards,
Signature · 1 line
Guillaume Ranquet <[email protected]>
PATCH v2 1/12 dt-bindings: phy: mediatek: hdmi-phy: Add mt8195 compatible
Add a compatible for the HDMI PHY on MT8195
--- Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml +1 -0
@@ -28,6 +28,7 @@ properties: - const: mediatek,mt2701-hdmi-phy - const: mediatek,mt2701-hdmi-phy - const: mediatek,mt8173-hdmi-phy + - const: mediatek,mt8195-hdmi-phy reg: maxItems: 1
Signature · 1 line
b4 0.11.0-dev
PATCH v2 2/12 dt-bindings: display: mediatek: add MT8195 hdmi bindings
In reply to Guillaume RanquetAdd mt8195 SoC bindings for hdmi and hdmi-ddc
--- .../bindings/display/mediatek/mediatek,hdmi.yaml | 67 +++++++++++++++++----- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 51 ++++++++++++++++ 2 files changed, 104 insertions(+), 14 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +53 -14
@@ -21,26 +21,21 @@ properties: - mediatek,mt7623-hdmi - mediatek,mt8167-hdmi - mediatek,mt8173-hdmi + - mediatek,mt8195-hdmi reg: maxItems: 1 - interrupts: - maxItems: 1 - clocks: - items: - - description: Pixel Clock - - description: HDMI PLL - - description: Bit Clock - - description: S/PDIF Clock + minItems: 4 + maxItems: 4 clock-names: - items: - - const: pixel - - const: pll - - const: bclk - - const: spdif + minItems: 4 + maxItems: 4 + + interrupts: + maxItems: 1 phys: maxItems: 1
@@ -58,6 +53,9 @@ properties: description: | phandle link and register offset to the system configuration registers. + power-domains: + maxItems: 1 + ports: $ref: /schemas/graph.yaml#/properties/ports
@@ -86,9 +84,50 @@ required: - clock-names - phys - phy-names - - mediatek,syscon-hdmi - ports +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt8195-hdmi + then: + properties: + clocks: + items: + - description: APB + - description: HDCP + - description: HDCP 24M + - description: Split HDMI + clock-names: + items: + - const: hdmi_apb_sel + - const: hdcp_sel + - const: hdcp24_sel + - const: split_hdmi + + required: + - power-domains + else: + properties: + clocks: + items: + - description: Pixel Clock + - description: HDMI PLL + - description: Bit Clock + - description: S/PDIF Clock + + clock-names: + items: + - const: pixel + - const: pll + - const: bclk + - const: spdif + + required: + - mediatek,syscon-hdmi + additionalProperties: false examples:
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +51 -0
51 lines not on this page · raw message
Signature · 1 line
b4 0.11.0-dev
PATCH v2 3/12 drm/mediatek: hdmi: use a regmap instead of iomem
In reply to Guillaume RanquetTo prepare support for newer chips that need to share their address range with a dedicated ddc driver, use a regmap.
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 43 +++++++++++-------------------------- 1 file changed, 13 insertions(+), 30 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi.c +13 -30
@@ -171,7 +171,7 @@ struct mtk_hdmi {u32 ibias_up;struct regmap *sys_regmap;unsigned int sys_offset; -void __iomem *regs; +struct regmap *regs;enum hdmi_colorspace csp;struct hdmi_audio_param aud_param;bool audio_enable;
@@ -187,44 +187,29 @@ static inline struct mtk_hdmi *hdmi_ctx_from_bridge(struct drm_bridge *b) return container_of(b, struct mtk_hdmi, bridge); } -static u32 mtk_hdmi_read (struct mtk_hdmi *hdmi,u32 offset) +static int mtk_hdmi_read (struct mtk_hdmi *hdmi,u32 offset,u32 *val) { -return readl (hdmi->regs + offset); +return regmap_read (hdmi->regs, offset, val); }static void mtk_hdmi_write (struct mtk_hdmi *hdmi,u32 offset,u32 val) { -writel (val, hdmi->regs + offset); +regmap_write (hdmi->regs, offset, val); }static void mtk_hdmi_clear_bits (struct mtk_hdmi *hdmi,u32 offset,u32 bits) { -void __iomem *reg = hdmi->regs + offset; -u32 tmp; - - tmp =readl (reg); - tmp &= ~bits; -writel (tmp, reg); +regmap_clear_bits (hdmi->regs, offset, bits); }static void mtk_hdmi_set_bits (struct mtk_hdmi *hdmi,u32 offset,u32 bits) { -void __iomem *reg = hdmi->regs + offset; -u32 tmp; - - tmp =readl (reg); - tmp |= bits; -writel (tmp, reg); +regmap_set_bits (hdmi->regs, offset, bits); }static void mtk_hdmi_mask (struct mtk_hdmi *hdmi,u32 offset,u32 val,u32 mask) { -void __iomem *reg = hdmi->regs + offset; -u32 tmp; - - tmp =readl (reg); - tmp = (tmp & ~mask) | (val & mask); -writel (tmp, reg); +regmap_update_bits (hdmi->regs, offset, mask, val); }static void mtk_hdmi_hw_vid_black (struct mtk_hdmi *hdmi,bool black)
@@ -473,7 +458,7 @@ static void mtk_hdmi_hw_aud_set_i2s_fmt(struct mtk_hdmi *hdmi, {u32 val; - val =mtk_hdmi_read (hdmi,GRL_CFG0 ); +mtk_hdmi_read (hdmi,GRL_CFG0 , &val); val &= ~(CFG0_W_LENGTH_MASK |CFG0_I2S_MODE_MASK );switch (i2s_fmt) {
@@ -565,7 +550,7 @@ static void mtk_hdmi_hw_aud_set_input_type(struct mtk_hdmi *hdmi, {u32 val; - val =mtk_hdmi_read (hdmi,GRL_CFG1 ); +mtk_hdmi_read (hdmi,GRL_CFG1 , &val);if (input_type ==HDMI_AUD_INPUT_I2S && (val &CFG1_SPDIF ) ==CFG1_SPDIF ) { val &= ~CFG1_SPDIF ;
@@ -596,7 +581,7 @@ static void mtk_hdmi_hw_aud_src_reenable(struct mtk_hdmi *hdmi) {u32 val; - val =mtk_hdmi_read (hdmi,GRL_MIX_CTRL ); +mtk_hdmi_read (hdmi,GRL_MIX_CTRL , &val);if (val &MIX_CTRL_SRC_EN ) { val &= ~MIX_CTRL_SRC_EN ;mtk_hdmi_write (hdmi,GRL_MIX_CTRL , val);
@@ -610,7 +595,7 @@ static void mtk_hdmi_hw_aud_src_disable(struct mtk_hdmi *hdmi) {u32 val; - val =mtk_hdmi_read (hdmi,GRL_MIX_CTRL ); +mtk_hdmi_read (hdmi,GRL_MIX_CTRL , &val); val &= ~MIX_CTRL_SRC_EN ;mtk_hdmi_write (hdmi,GRL_MIX_CTRL , val);mtk_hdmi_write (hdmi,GRL_SHIFT_L1 ,0x00 );
@@ -621,7 +606,7 @@ static void mtk_hdmi_hw_aud_set_mclk(struct mtk_hdmi *hdmi, {u32 val; - val =mtk_hdmi_read (hdmi,GRL_CFG5 ); +mtk_hdmi_read (hdmi,GRL_CFG5 , &val); val &=CFG5_CD_RATIO_MASK ;switch (mclk) {
@@ -1427,7 +1412,6 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,struct device_node *cec_np, *remote, *i2c_np;struct platform_device *cec_pdev;struct regmap *regmap; -struct resource *mem;int ret; ret =mtk_hdmi_get_all_clk (hdmi, np);
@@ -1473,8 +1457,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, } hdmi->sys_regmap = regmap; - mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - hdmi->regs =devm_ioremap_resource (dev, mem); + hdmi->regs =device_node_to_regmap (dev->of_node);if (IS_ERR (hdmi->regs)) { ret =PTR_ERR (hdmi->regs); goto put_device;
Signature · 1 line
b4 0.11.0-dev
PATCH v2 4/12 drm/mediatek: extract common functions from the mtk hdmi driver
In reply to Guillaume RanquetCreate a common "framework" that can be used to add support for different hdmi IPs within the mediatek range of products.
--- drivers/gpu/drm/mediatek/Makefile | 3 +- drivers/gpu/drm/mediatek/mtk_hdmi.c | 620 ++--------------------------- drivers/gpu/drm/mediatek/mtk_hdmi.h | 16 + drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 433 ++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 221 ++++++++++ 5 files changed, 704 insertions(+), 589 deletions(-)
drivers/gpu/drm/mediatek/Makefile +2 -1
@@ -22,7 +22,8 @@ obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o mediatek-drm-hdmi-objs := mtk_cec.o \ mtk_hdmi.o \ - mtk_hdmi_ddc.o + mtk_hdmi_common.o \ + mtk_hdmi_ddc.o \ obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o
drivers/gpu/drm/mediatek/mtk_hdmi.c +32 -588
746 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi.h +16 -0
@@ -6,9 +6,25 @@#ifndef _MTK_HDMI_CTRL_H#define _MTK_HDMI_CTRL_H +struct mtk_hdmi ;struct platform_driver ;extern struct platform_driver mtk_cec_driver;extern struct platform_driver mtk_hdmi_ddc_driver; +extern const struct drm_bridge_funcs mtk_mt8183_hdmi_bridge_funcs; +void mtk_hdmi_output_init_mt8183 (struct mtk_hdmi *hdmi); +void mtk_hdmi_clk_disable_audio_mt8183 (struct mtk_hdmi *hdmi); +int mtk_hdmi_clk_enable_audio_mt8183 (struct mtk_hdmi *hdmi); +void set_hdmi_codec_pdata_mt8183 (struct hdmi_codec_pdata *codec_data); + +enum mtk_hdmi_clk_id_mt8183 { +MTK_HDMIV1_CLK_HDMI_PIXEL , +MTK_HDMIV1_CLK_HDMI_PLL , +MTK_HDMIV1_CLK_AUD_BCLK , +MTK_HDMIV1_CLK_AUD_SPDIF , +MTK_HDMIV1_CLK_COUNT , +}; + +extern const char *const mtk_hdmi_clk_names_v1[MTK_HDMIV1_CLK_COUNT ];#endif /* _MTK_HDMI_CTRL_H */
drivers/gpu/drm/mediatek/mtk_hdmi_common.c new file +433 -0
433 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_common.h new file +221 -0
221 lines not on this page · raw message
Signature · 1 line
b4 0.11.0-dev
PATCH v2 6/12 drm/mediatek: hdmi: add frame_colorimetry flag
In reply to Guillaume RanquetAdd a flag to indicate support for frame colorimetry.
--- drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 11 +++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 1 + 2 files changed, 12 insertions(+)
drivers/gpu/drm/mediatek/mtk_hdmi_common.c +11 -0
@@ -120,6 +120,17 @@ int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi, u8 *buffer, size_t bufszreturn err; } +if (hdmi->conf->has_frame_colorimetry) { + frame.colorimetry = hdmi->colorimtery; +if (frame.colorimetry ==HDMI_COLORIMETRY_EXTENDED ) + frame.extended_colorimetry = hdmi->extended_colorimetry; + +/* quantiation range:limited or full */ +if (frame.colorspace ==HDMI_COLORSPACE_RGB ) + frame.quantization_range = hdmi->quantization_range; +else + frame.ycc_quantization_range = hdmi->ycc_quantization_range; + } err =hdmi_avi_infoframe_pack (&frame, buffer, bufsz);if (err <0 ) {
drivers/gpu/drm/mediatek/mtk_hdmi_common.h +1 -0
@@ -32,6 +32,7 @@ struct mtk_hdmi_conf {bool tz_disabled;bool cea_modes_only;bool has_cec; +bool has_frame_colorimetry;unsigned long max_mode_clock;const struct drm_bridge_funcs *bridge_funcs;void (*mtk_hdmi_output_init)(struct mtk_hdmi *hdmi);
Signature · 1 line
b4 0.11.0-dev
PATCH v2 9/12 phy: phy-mtk-hdmi: Add generic phy configure callback
In reply to Guillaume RanquetSome phys, such as mt8195, needs to have a configure callback defined.
--- drivers/phy/mediatek/phy-mtk-hdmi.c | 12 ++++++++++++ drivers/phy/mediatek/phy-mtk-hdmi.h | 1 + 2 files changed, 13 insertions(+)
drivers/phy/mediatek/phy-mtk-hdmi.c +12 -0
@@ -8,10 +8,12 @@static int mtk_hdmi_phy_power_on (struct phy *phy);static int mtk_hdmi_phy_power_off (struct phy *phy); +static int mtk_hdmi_phy_configure (struct phy *phy,union phy_configure_opts *opts);static const struct phy_ops mtk_hdmi_phy_dev_ops = { .power_on = mtk_hdmi_phy_power_on, .power_off = mtk_hdmi_phy_power_off, + .configure = mtk_hdmi_phy_configure, .owner =THIS_MODULE , };
@@ -43,6 +45,16 @@ static int mtk_hdmi_phy_power_off(struct phy *phy)return 0 ; } +static int mtk_hdmi_phy_configure (struct phy *phy,union phy_configure_opts *opts) +{ +struct mtk_hdmi_phy *hdmi_phy =phy_get_drvdata (phy); + +if (hdmi_phy->conf->hdmi_phy_configure) +return hdmi_phy->conf->hdmi_phy_configure (phy, opts); + +return 0 ; +} +static const struct phy_ops *mtk_hdmi_phy_dev_get_ops (const struct mtk_hdmi_phy *hdmi_phy) {
drivers/phy/mediatek/phy-mtk-hdmi.h +1 -0
@@ -24,6 +24,7 @@ struct mtk_hdmi_phy_conf {const struct clk_ops *hdmi_phy_clk_ops;void (*hdmi_phy_enable_tmds)(struct mtk_hdmi_phy *hdmi_phy);void (*hdmi_phy_disable_tmds)(struct mtk_hdmi_phy *hdmi_phy); +int (*hdmi_phy_configure)(struct phy *phy,union phy_configure_opts *opts); };struct mtk_hdmi_phy {
Signature · 1 line
b4 0.11.0-dev
PATCH v2 5/12 drm/mediatek: hdmi: make the cec dev optional
In reply to Guillaume RanquetMake cec device optional in order to support newer versions of the hdmi IP which doesn't require it
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 8 +++-- drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 54 ++++++++++++++++++++---------- drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 1 + 3 files changed, 42 insertions(+), 21 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi.c +5 -3
@@ -927,10 +927,11 @@ void mtk_hdmi_clk_disable_audio_mt8183(struct mtk_hdmi *hdmi)static enum drm_connector_status mtk_hdmi_update_plugged_status (struct mtk_hdmi *hdmi) { -bool connected; +bool connected = true;mutex_lock (&hdmi->update_plugged_status_lock); - connected =mtk_cec_hpd_high (hdmi->cec_dev); +if (hdmi->cec_dev) + connected =mtk_cec_hpd_high (hdmi->cec_dev);if (hdmi->plugged_cb && hdmi->codec_dev) hdmi->plugged_cb (hdmi->codec_dev, connected);mutex_unlock (&hdmi->update_plugged_status_lock);
@@ -1025,7 +1026,8 @@ static int mtk_hdmi_bridge_attach(struct drm_bridge *bridge,return ret; } -mtk_cec_set_hpd_event (hdmi->cec_dev, mtk_hdmi_hpd_event, hdmi->dev); +if (hdmi->cec_dev) +mtk_cec_set_hpd_event (hdmi->cec_dev, mtk_hdmi_hpd_event, hdmi->dev);return 0 ; }
drivers/gpu/drm/mediatek/mtk_hdmi_common.c +36 -18
83 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_common.h +1 -0
@@ -31,6 +31,7 @@struct mtk_hdmi_conf {bool tz_disabled;bool cea_modes_only; +bool has_cec;unsigned long max_mode_clock;const struct drm_bridge_funcs *bridge_funcs;void (*mtk_hdmi_output_init)(struct mtk_hdmi *hdmi);
Signature · 1 line
b4 0.11.0-dev
PATCH v2 8/12 drm/mediatek: hdmi: v2: add audio support
In reply to Guillaume RanquetAdd HDMI audio support for v2
--- drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 1 + drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c | 2 +- drivers/gpu/drm/mediatek/mtk_hdmi_v2.c | 213 +++++++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.h | 2 + 4 files changed, 217 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_hdmi_common.c +1 -0
@@ -386,6 +386,7 @@ static const struct mtk_hdmi_conf mtk_hdmi_conf_v2 = { .mtk_hdmi_output_init = mtk_hdmi_output_init_v2, .mtk_hdmi_clk_disable = mtk_hdmi_clk_disable_v2, .mtk_hdmi_clk_enable = mtk_hdmi_clk_enable_v2, + .set_hdmi_codec_pdata = set_hdmi_codec_pdata_v2, .mtk_hdmi_clock_names = mtk_hdmi_clk_names_v2, .num_clocks = MTK_HDMIV2_CLK_COUNT, };
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c +1 -1
@@ -309,7 +309,7 @@ static int mtk_hdmi_ddc_probe(struct platform_device *pdev) ddc->regs =device_node_to_regmap (hdmi);of_node_put (hdmi);if (IS_ERR (ddc->regs)) -return dev_err_probe (dev,PTR_ERR (ddc->regs),"Unable to get mt8195-hdmi syscon" ); +return dev_err_probe (dev,PTR_ERR (ddc->regs),"Unable to get hdmi syscon" ); ddc->clk =devm_clk_get_enabled (dev,"ddc" );if (IS_ERR (ddc->clk))
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c +213 -0
270 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_v2.h +2 -0
@@ -9,6 +9,7 @@#include <linux/hdmi.h> #include <drm/drm_bridge.h> +#include <sound/hdmi-codec.h> struct mtk_hdmi ;
@@ -17,6 +18,7 @@ extern const struct drm_bridge_funcs mtk_v2_hdmi_bridge_funcs;void mtk_hdmi_output_init_v2 (struct mtk_hdmi *hdmi);int mtk_hdmi_clk_enable_v2 (struct mtk_hdmi *hdmi);void mtk_hdmi_clk_disable_v2 (struct mtk_hdmi *hdmi); +void set_hdmi_codec_pdata_v2 (struct hdmi_codec_pdata *codec_data);enum mtk_hdmi_clk_id_v2 {MTK_HDMIV2_HDCP_SEL ,
Signature · 1 line
b4 0.11.0-dev
PATCH v2 7/12 drm/mediatek: hdmi: add v2 support
In reply to Guillaume RanquetAdds hdmi and hdmi-ddc support for v2 IP.
--- drivers/gpu/drm/mediatek/Makefile | 2 + drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 14 + drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 1 + drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c | 367 +++++++ drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h | 309 ++++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.c | 1379 +++++++++++++++++++++++++++ drivers/gpu/drm/mediatek/mtk_hdmi_v2.h | 29 + 7 files changed, 2101 insertions(+)
drivers/gpu/drm/mediatek/Makefile +2 -0
@@ -24,6 +24,8 @@ mediatek-drm-hdmi-objs := mtk_cec.o \ mtk_hdmi.o \ mtk_hdmi_common.o \ mtk_hdmi_ddc.o \ + mtk_hdmi_ddc_v2.o \ + mtk_hdmi_v2.o \ obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o
drivers/gpu/drm/mediatek/mtk_hdmi_common.c +14 -0
@@ -380,6 +380,16 @@ static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8173 = { .num_clocks = MTK_HDMIV1_CLK_COUNT, }; +static const struct mtk_hdmi_conf mtk_hdmi_conf_v2 = { + .has_frame_colorimetry = true, + .bridge_funcs = &mtk_v2_hdmi_bridge_funcs, + .mtk_hdmi_output_init = mtk_hdmi_output_init_v2, + .mtk_hdmi_clk_disable = mtk_hdmi_clk_disable_v2, + .mtk_hdmi_clk_enable = mtk_hdmi_clk_enable_v2, + .mtk_hdmi_clock_names = mtk_hdmi_clk_names_v2, + .num_clocks =MTK_HDMIV2_CLK_COUNT , +}; +static const struct of_device_id mtk_drm_hdmi_of_ids[] = { { .compatible ="mediatek,mt2701-hdmi" , .data = &mtk_hdmi_conf_mt2701,
@@ -390,6 +400,9 @@ static const struct of_device_id mtk_drm_hdmi_of_ids[] = { { .compatible = "mediatek,mt8173-hdmi", .data = &mtk_hdmi_conf_mt8173, }, + { .compatible = "mediatek,mt8195-hdmi", + .data = &mtk_hdmi_conf_v2, + }, {} };MODULE_DEVICE_TABLE (of, mtk_drm_hdmi_of_ids);
@@ -438,6 +451,7 @@ static struct platform_driver mtk_hdmi_driver = {static struct platform_driver *const mtk_hdmi_drivers[] = { &mtk_hdmi_ddc_driver, &mtk_cec_driver, + &mtk_hdmi_ddc_v2_driver, &mtk_hdmi_driver, };
drivers/gpu/drm/mediatek/mtk_hdmi_common.h +1 -0
@@ -27,6 +27,7 @@#include "mtk_cec.h" #include "mtk_hdmi.h" +#include "mtk_hdmi_v2.h" struct mtk_hdmi_conf {bool tz_disabled;
drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c new file +367 -0
367 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h new file +309 -0
309 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c new file +1379 -0
1,379 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_hdmi_v2.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2022 MediaTek Inc. +* Copyright (c) 2022 BayLibre, SAS +*/ + +#ifndef _MTK_HDMI_V2_CTRL_H +#define _MTK_HDMI_V2_CTRL_H + +#include <linux/hdmi.h> +#include <drm/drm_bridge.h> + +struct mtk_hdmi ; + +extern struct platform_driver mtk_hdmi_ddc_v2_driver; +extern const struct drm_bridge_funcs mtk_v2_hdmi_bridge_funcs; +void mtk_hdmi_output_init_v2 (struct mtk_hdmi *hdmi); +int mtk_hdmi_clk_enable_v2 (struct mtk_hdmi *hdmi); +void mtk_hdmi_clk_disable_v2 (struct mtk_hdmi *hdmi); + +enum mtk_hdmi_clk_id_v2 { +MTK_HDMIV2_HDCP_SEL , +MTK_HDMIV2_HDCP_24M_SEL , +MTK_HDMIV2_VPP_SPLIT_HDMI , +MTK_HDMIV2_CLK_COUNT , +}; + +extern const char *const mtk_hdmi_clk_names_v2[MTK_HDMIV2_CLK_COUNT ]; +#endif /* _MTK_HDMI_V2_CTRL_H */
Signature · 1 line
b4 0.11.0-dev
PATCH v2 12/12 drm/mediatek: dpi: Add mt8195 hdmi to DPI driver
In reply to Guillaume RanquetAdd the DPI1 hdmi path support in mtk dpi driver
--- drivers/gpu/drm/mediatek/mtk_dpi.c | 143 ++++++++++++++++++++++++++++++-- drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 5 ++ 2 files changed, 141 insertions(+), 7 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +136 -7
@@ -14,7 +14,10 @@#include <linux/of_graph.h> #include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> +#include <linux/reset.h> #include <linux/types.h> +#include <linux/regmap.h> +#include <linux/mfd/syscon.h> #include <video/videomode.h>
@@ -65,10 +68,14 @@ struct mtk_dpi {struct drm_bridge *next_bridge;struct drm_connector *connector;void __iomem *regs; +struct reset_control *reset_ctl;struct device *dev;struct clk *engine_clk; +struct clk *dpi_ck_cg;struct clk *pixel_clk; +struct clk *dpi_sel_clk;struct clk *tvd_clk; +struct clk *hdmi_cg;int irq;struct drm_display_mode mode;const struct mtk_dpi_conf *conf;
@@ -134,6 +141,7 @@ struct mtk_dpi_yc_limit {* @yuv422_en_bit: Enable bit of yuv422. * @csc_enable_bit: Enable bit of CSC. * @pixels_per_iter: Quantity of transferred pixels per iteration. +* @is_internal_hdmi: True if this DPI block is directly connected to SoC internal HDMI block */ struct mtk_dpi_conf {unsigned int (*cal_factor)(int clock);
@@ -152,6 +160,7 @@ struct mtk_dpi_conf {u32 yuv422_en_bit;u32 csc_enable_bit;u32 pixels_per_iter; +bool is_internal_hdmi; };static void mtk_dpi_mask (struct mtk_dpi *dpi,u32 offset,u32 val,u32 mask)
@@ -465,8 +474,15 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi)pinctrl_select_state (dpi->pinctrl, dpi->pins_gpio);mtk_dpi_disable (dpi); + +reset_control_rearm (dpi->reset_ctl); +clk_disable_unprepare (dpi->pixel_clk);clk_disable_unprepare (dpi->engine_clk); +clk_disable_unprepare (dpi->dpi_sel_clk); +clk_disable_unprepare (dpi->dpi_ck_cg); +clk_disable_unprepare (dpi->hdmi_cg); +clk_disable_unprepare (dpi->tvd_clk); }static int mtk_dpi_power_on (struct mtk_dpi *dpi)
@@ -482,12 +498,44 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) goto err_refcount; } + ret =clk_prepare_enable (dpi->dpi_sel_clk); +if (ret) { +dev_err (dpi->dev,"failed to enable dpi_sel clock: %d\n" , ret); + goto err_refcount; + } + + ret =clk_prepare_enable (dpi->tvd_clk); +if (ret) { +dev_err (dpi->dev,"Failed to enable tvd pll: %d\n" , ret); + goto err_tvd; + } + + ret =clk_prepare_enable (dpi->engine_clk); +if (ret) { +dev_err (dpi->dev,"Failed to enable engine clock: %d\n" , ret); + goto err_engine; + } + + ret =clk_prepare_enable (dpi->hdmi_cg); +if (ret) { +dev_err (dpi->dev,"Failed to enable hdmi_cg clock: %d\n" , ret); + goto err_hdmi_cg; + } + + ret =clk_prepare_enable (dpi->dpi_ck_cg); +if (ret) { +dev_err (dpi->dev,"Failed to enable dpi_ck_cg clock: %d\n" , ret); + goto err_ck_cg; + } + ret =clk_prepare_enable (dpi->pixel_clk);if (ret) {dev_err (dpi->dev,"Failed to enable pixel clock: %d\n" , ret); goto err_pixel; } +reset_control_reset (dpi->reset_ctl); +if (dpi->pinctrl && dpi->pins_dpi)pinctrl_select_state (dpi->pinctrl, dpi->pins_dpi);
@@ -495,6 +543,15 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) err_pixel:clk_disable_unprepare (dpi->engine_clk); +clk_disable_unprepare (dpi->dpi_ck_cg); +err_ck_cg: +clk_disable_unprepare (dpi->hdmi_cg); +err_hdmi_cg: +clk_disable_unprepare (dpi->engine_clk); +err_engine: +clk_disable_unprepare (dpi->tvd_clk); +err_tvd: +clk_disable_unprepare (dpi->dpi_sel_clk); err_refcount: dpi->refcount--;return ret;
@@ -538,7 +595,6 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,else clk_set_rate (dpi->pixel_clk, vm.pixelclock); - vm.pixelclock =clk_get_rate (dpi->pixel_clk); dev_dbg(dpi->dev, "Got PLL %lu Hz, pixel clock %lu Hz\n",
@@ -605,7 +661,16 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,if (dpi->conf->support_direct_pin) {mtk_dpi_config_yc_map (dpi, dpi->yc_map);mtk_dpi_config_2n_h_fre (dpi); -mtk_dpi_dual_edge (dpi); +/* DPI could be connecting to external bridge +* or internal HDMI encoder. */ +if (dpi->conf->is_internal_hdmi) { +mtk_dpi_mask (dpi,DPI_CON ,DPI_OUTPUT_1T1P_EN , +DPI_OUTPUT_1T1P_EN ); +mtk_dpi_mask (dpi,DPI_CON ,DPI_INPUT_2P_EN , +DPI_INPUT_2P_EN ); + }else { +mtk_dpi_dual_edge (dpi); + }mtk_dpi_config_disable_edge (dpi); }if (dpi->conf->input_2pixel) {
@@ -720,7 +785,10 @@ static void mtk_dpi_bridge_disable(struct drm_bridge *bridge) {struct mtk_dpi *dpi =bridge_to_dpi (bridge); -mtk_dpi_power_off (dpi); +if (dpi->conf->is_internal_hdmi) +mtk_dpi_power_off (dpi); +else +mtk_dpi_disable (dpi); }static void mtk_dpi_bridge_enable (struct drm_bridge *bridge)
@@ -763,14 +831,16 @@ void mtk_dpi_start(struct device *dev) {struct mtk_dpi *dpi =dev_get_drvdata (dev); -mtk_dpi_power_on (dpi); +if (!dpi->conf->is_internal_hdmi) +mtk_dpi_power_on (dpi); }void mtk_dpi_stop (struct device *dev) {struct mtk_dpi *dpi =dev_get_drvdata (dev); -mtk_dpi_power_off (dpi); +if (!dpi->conf->is_internal_hdmi) +mtk_dpi_power_off (dpi); }static int mtk_dpi_bind (struct device *dev,struct device *master,void *data)
@@ -853,6 +923,11 @@ static unsigned int mt8183_calculate_factor(int clock)return 2 ; } +static unsigned int mt8195_calculate_factor (int clock) +{ +return 1 ; +} +static unsigned int mt8195_dpintf_calculate_factor (int clock) {if (clock <70000 )
@@ -946,6 +1021,24 @@ static const struct mtk_dpi_conf mt8192_conf = { .csc_enable_bit = CSC_ENABLE, }; +static const struct mtk_dpi_conf mt8195_conf = { + .cal_factor = mt8195_calculate_factor, + .max_clock_khz =594000 , + .reg_h_fre_con =0xe0 , + .output_fmts = mt8183_output_fmts, + .num_output_fmts =ARRAY_SIZE (mt8183_output_fmts), + .pixels_per_iter =1 , + .is_ck_de_pol = true, + .swap_input_support = true, + .dimension_mask =HPW_MASK , + .hvsize_mask =HSIZE_MASK , + .channel_swap_shift =CH_SWAP , + .yuv422_en_bit =YUV422_EN , + .csc_enable_bit =CSC_ENABLE , + .is_internal_hdmi = true, + .support_direct_pin = true, +}; +static const struct mtk_dpi_conf mt8195_dpintf_conf = { .cal_factor = mt8195_dpintf_calculate_factor, .max_clock_khz =600000 ,
@@ -1003,6 +1096,12 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } + dpi->reset_ctl =devm_reset_control_get_optional_exclusive (dev,"dpi_on" ); +if (IS_ERR (dpi->reset_ctl)) { +dev_err (dev,"Failed to get reset_ctl: %ld\n" ,PTR_ERR (dpi->reset_ctl)); +return PTR_ERR (dpi->reset_ctl); + } + dpi->engine_clk =devm_clk_get (dev,"engine" );if (IS_ERR (dpi->engine_clk)) { ret =PTR_ERR (dpi->engine_clk);
@@ -1012,7 +1111,26 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } - dpi->pixel_clk =devm_clk_get (dev,"pixel" ); + dpi->hdmi_cg =devm_clk_get_optional (dev,"hdmi_cg" ); +if (IS_ERR (dpi->hdmi_cg)) { + ret =PTR_ERR (dpi->hdmi_cg); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get hdmi_cg clock: %d\n" , ret); + +return ret; + } + + dpi->dpi_ck_cg =devm_clk_get_optional (dev,"ck_cg" ); +if (IS_ERR (dpi->dpi_ck_cg)) { + ret =PTR_ERR (dpi->dpi_ck_cg); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get dpi ck cg clock: %d\n" , + ret); + +return ret; + } + + dpi->pixel_clk =devm_clk_get_optional (dev,"pixel" );if (IS_ERR (dpi->pixel_clk)) { ret =PTR_ERR (dpi->pixel_clk);if (ret != -EPROBE_DEFER )
@@ -1021,7 +1139,7 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } - dpi->tvd_clk =devm_clk_get (dev,"pll" ); + dpi->tvd_clk =devm_clk_get_optional (dev,"pll" );if (IS_ERR (dpi->tvd_clk)) { ret =PTR_ERR (dpi->tvd_clk);if (ret != -EPROBE_DEFER )
@@ -1030,6 +1148,14 @@ static int mtk_dpi_probe(struct platform_device *pdev)return ret; } + dpi->dpi_sel_clk =devm_clk_get_optional (dev,"dpi_sel" ); +if (IS_ERR (dpi->dpi_sel_clk)) { + ret =PTR_ERR (dpi->dpi_sel_clk); +dev_err_probe (dev, ret,"Failed to get dpi_Sel_clk clock: %d\n" , ret); + +return ret; + } + dpi->irq =platform_get_irq (pdev,0 );if (dpi->irq <=0 )return -EINVAL ;
@@ -1085,6 +1211,9 @@ static const struct of_device_id mtk_dpi_of_ids[] = { { .compatible = "mediatek,mt8195-dp-intf", .data = &mt8195_dpintf_conf, }, + { .compatible = "mediatek,mt8195-dpi", + .data = &mt8195_conf, + }, { }, };MODULE_DEVICE_TABLE (of, mtk_dpi_of_ids);
drivers/gpu/drm/mediatek/mtk_dpi_regs.h +5 -0
@@ -43,6 +43,11 @@#define DPINTF_YUV422_EN BIT(24)#define DPINTF_CSC_ENABLE BIT(26)#define DPINTF_INPUT_2P_EN BIT(29) +#define DPI_OUTPUT_1T1P_EN BIT(24) +#define DPI_INPUT_2P_EN BIT(25) +#define DPI_EXT_VSYNC_EN BIT(26) +#define DPI_RGB565_EN BIT(27) +#define DPI_RGB880_EN BIT(28)#define DPI_OUTPUT_SETTING 0x14#define CH_SWAP 0
Signature · 1 line
b4 0.11.0-dev
PATCH v2 10/12 phy: mediatek: add support for phy-mtk-hdmi-mt8195
In reply to Guillaume RanquetAdd basic support for the mediatek hdmi phy on MT8195 SoC
--- drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 546 +++++++++++++++++++++++++++++ drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h | 131 +++++++ drivers/phy/mediatek/phy-mtk-hdmi.c | 3 + drivers/phy/mediatek/phy-mtk-hdmi.h | 1 + 5 files changed, 682 insertions(+)
drivers/phy/mediatek/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_PHY_MTK_XSPHY) += phy-mtk-xsphy.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-mt8173.o +phy-mtk-hdmi-drv-y += phy-mtk-hdmi-mt8195.o obj-$(CONFIG_PHY_MTK_HDMI) += phy-mtk-hdmi-drv.o phy-mtk-mipi-dsi-drv-y := phy-mtk-mipi-dsi.o
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +546 -0
546 lines not on this page · raw message
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +131 -0
131 lines not on this page · raw message
drivers/phy/mediatek/phy-mtk-hdmi.c +3 -0
@@ -161,6 +161,9 @@ static const struct of_device_id mtk_hdmi_phy_match[] = { { .compatible = "mediatek,mt8173-hdmi-phy", .data = &mtk_hdmi_phy_8173_conf, }, + { .compatible = "mediatek,mt8195-hdmi-phy", + .data = &mtk_hdmi_phy_8195_conf, + }, {}, };MODULE_DEVICE_TABLE (of, mtk_hdmi_phy_match);
drivers/phy/mediatek/phy-mtk-hdmi.h +1 -0
@@ -44,6 +44,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_8173_conf;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf;
Signature · 1 line
b4 0.11.0-dev
PATCH v2 11/12 dt-bindings: display: mediatek: dpi: Add compatible for MediaTek MT8195
In reply to Guillaume RanquetAdd dt-binding documentation of dpi for MediaTek MT8195 SoC.
--- Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.yaml +1 -0
@@ -24,6 +24,7 @@ properties: - mediatek,mt8183-dpi - mediatek,mt8186-dpi - mediatek,mt8192-dpi + - mediatek,mt8195-dpi - mediatek,mt8195-dp-intf reg:
Signature · 1 line
b4 0.11.0-dev
Re: [PATCH v2 02/12] dt-bindings: display: mediatek: add MT8195 hdmi bindings
In reply to Guillaume RanquetQuoted 14 lines · Guillaume Ranquet
Add mt8195 SoC bindings for hdmi and hdmi-ddc
Signed-off-by Guillaume Ranquet <[email protected]>--- .../bindings/display/mediatek/mediatek,hdmi.yaml | 67 +++++++++++++++++----- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 51 ++++++++++++++++ 2 files changed, 104 insertions(+), 14 deletions(-)Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +0
-0@@ -21,26 +21,21 @@ properties: - mediatek,mt7623-hdmi
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml properties: · line 30
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +1
-3- mediatek,mt8167-hdmi - mediatek,mt8173-hdmi + - mediatek,mt8195-hdmi reg: maxItems: 1 - interrupts: - maxItems: 1 -
This change is not really explained in commit msg...
Quoted 100 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +52
-11clocks: - items: - - description: Pixel Clock - - description: HDMI PLL - - description: Bit Clock - - description: S/PDIF Clock + minItems: 4 + maxItems: 4 clock-names: - items: - - const: pixel - - const: pll - - const: bclk - - const: spdif + minItems: 4 + maxItems: 4 + + interrupts: + maxItems: 1 phys: maxItems: 1@@ -58,6 +53,9 @@ properties: description: | phandle link and register offset to the system configuration registers. + power-domains: + maxItems: 1 + ports: $ref: /schemas/graph.yaml#/properties/ports@@ -86,9 +84,50 @@ required: - clock-names - phys - phy-names - - mediatek,syscon-hdmi - ports +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt8195-hdmi + then: + properties: + clocks: + items: + - description: APB + - description: HDCP + - description: HDCP 24M + - description: Split HDMI + clock-names: + items: + - const: hdmi_apb_sel + - const: hdcp_sel + - const: hdcp24_sel + - const: split_hdmi + + required: + - power-domains + else: + properties: + clocks: + items: + - description: Pixel Clock + - description: HDMI PLL + - description: Bit Clock + - description: S/PDIF Clock + + clock-names: + items: + - const: pixel + - const: pll + - const: bclk + - const: spdif + + required: + - mediatek,syscon-hdmi + additionalProperties: false examples:Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +9
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek HDMI DDC for mt8195 + +maintainers:
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 19
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +10
-0+ - CK Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + The HDMI DDC i2c controller is used to interface with the HDMI DDC pins. + +properties: + compatible: + enum: + - mediatek,mt8195-hdmi-ddc
I think I wrote it - you already have bindings for HDMI DDC. I doubt that these are different and it looks like you model the bindings according to your driver. That's not the way.
Quoted 15 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +15
-0+ + clocks: + maxItems: 1 + + clock-names: + items: + - const: ddc + + mediatek,hdmi: + $ref: /schemas/types.yaml#/definitions/phandle + description: + A phandle to the mt8195 hdmi controller + +required: + - compatible
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +10
-0+ - clocks + - clock-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + hdmiddc0: ddc_i2c {
Node names should be generic - ddc.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
No underscores in node names.
Additionally I2C devices have addresses on the bus. Why this one doesn't?
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 51
Quoted 8 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +7
-0+ compatible = "mediatek,mt8195-hdmi-ddc"; + mediatek,hdmi = <&hdmi0>; + clocks = <&clk26m>; + clock-names = "ddc"; + }; + +...
Best regards,
Krzysztof
Chunfeng Yun
maintainerRe: [PATCH v2 10/12] phy: mediatek: add support for phy-mtk-hdmi-mt8195
In reply to Guillaume RanquetQuoted 33 lines · Guillaume Ranquet
Add basic support for the mediatek hdmi phy on MT8195 SoC
Signed-off-by Guillaume Ranquet <[email protected]>--- drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 546 +++++++++++++++++++++++++++++ drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h | 131 +++++++ drivers/phy/mediatek/phy-mtk-hdmi.c | 3 + drivers/phy/mediatek/phy-mtk-hdmi.h | 1 + 5 files changed, 682 insertions(+)drivers/phy/mediatek/Makefile +0
-0@@ -12,6 +12,7 @@ obj-$(CONFIG_PHY_MTK_XSPHY) += phy-mtk-xsphy.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-mt8173.odrivers/phy/mediatek/Makefile +1
-0+phy-mtk-hdmi-drv-y += phy-mtk-hdmi-mt8195.o obj-$(CONFIG_PHY_MTK_HDMI) += phy-mtk-hdmi-drv.o phy-mtk-mipi-dsi-drv-y := phy-mtk-mipi-dsi.odrivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +0
-0
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 4
Quoted 4 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +4
-0@@ -0,0 +1,546 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2021 MediaTek Inc. +* Copyright (c) 2021 BayLibre, SAS
2022?
Quoted 152 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +18
-0+*/ +#include <linux/delay.h> +#include <linux/io.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/types.h> +#include <linux/nvmem-consumer.h> + +#include "phy-mtk-io.h" +#include "phy-mtk-hdmi.h" +#include "phy-mtk-hdmi-mt8195.h" + +static void mtk_hdmi_ana_fifo_en (struct mtk_hdmi_phy *hdmi_phy) +{ +/* make data fifo writable for hdmi2.0 */ + mtk_phy_set_bits(hdmi_phy->regs + HDMI_ANA_CTL,
REG_ANA_HDMI20_FIFO_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +4
-0+} + +static void +mtk_mt8195_phy_tmds_high_bit_clk_ratio(struct mtk_hdmi_phy
*hdmi_phy,drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +11
-0+ bool enable) +{ +void __iomem *regs = hdmi_phy->regs; + +mtk_hdmi_ana_fifo_en (hdmi_phy); + +/* HDMI 2.0 specification, 3.4Gbps <= TMDS Bit Rate <= 6G, +* clock bit ratio 1:40, under 3.4Gbps, clock bit ratio 1:10 +*/ +if (enable) + mtk_phy_update_field(regs + HDMI20_CLK_CFG,
REG_TXC_DIV,REG_TXC_DIV);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +11
-0+else +mtk_phy_clear_bits (regs +HDMI20_CLK_CFG ,REG_TXC_DIV ); +} + +static void mtk_hdmi_pll_select_source (struct clk_hw *hw) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +void __iomem *regs = hdmi_phy->regs; + +mtk_phy_clear_bits (regs +HDMI_CTL_3 ,REG_HDMITX_REF_XTAL_SEL ); + mtk_phy_clear_bits(regs + HDMI_CTL_3,
REG_HDMITX_REF_RESPLL_SEL);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* DA_HDMITX21_REF_CK for TXPLL input source */ + mtk_phy_clear_bits(regs + HDMI_1_CFG_10,
RG_HDMITXPLL_REF_CK_SEL);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +15
-0+} + +static int mtk_hdmi_pll_performance_setting (struct clk_hw *hw) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +void __iomem *regs = hdmi_phy->regs; + +/* BP2 */ +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_0 ,RG_HDMITXPLL_BP2 ); + +/* BC */ +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_2 ,RG_HDMITXPLL_BC ); + +/* IC */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_2, RG_HDMITXPLL_IC,
0x1);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* BR */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_2, RG_HDMITXPLL_BR,
0x2);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* IR */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_2, RG_HDMITXPLL_IR,
0x2);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +6
-0+ +/* BP */ +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_2 ,RG_HDMITXPLL_BP ); + +/* IBAND_FIX_EN, RESERVE[14] */ + mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_0,
RG_HDMITXPLL_IBAND_FIX_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT14);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* HIKVCO */ + mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_2,
RG_HDMITXPLL_HIKVCO);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* HREN */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_0,
RG_HDMITXPLL_HREN,0x1);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* LVR_SEL */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_0,
RG_HDMITXPLL_LVR_SEL,0x1);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* RG_HDMITXPLL_RESERVE[12:11] */ + mtk_phy_set_bits(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT12_11);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +8
-0+ +/* TCL_EN */ +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_0 ,RG_HDMITXPLL_TCL_EN ); + +return 0 ; +} + +static int mtk_hdmi_pll_set_hw(struct clk_hw *hw, unsigned charprediv,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+unsigned char fbkdiv_high, + unsigned long fbkdiv_low, + unsigned char fbkdiv_hs3, unsigned charposdiv1,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ unsigned char posdiv2, unsigned chartxprediv,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +18
-0+unsigned char txposdiv, + unsigned char digital_div) +{ + unsigned char txposdiv_value = 0; +unsigned char div3_ctrl_value =0 ; +unsigned char posdiv_vallue =0 ; +unsigned char div_ctrl_value =0 ; +unsigned char reserve_3_2_value =0 ; +unsigned char prediv_value =0 ; +unsigned char reserve13_value =0 ; +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +void __iomem *regs = hdmi_phy->regs; + +mtk_hdmi_pll_select_source (hw); + +mtk_hdmi_pll_performance_setting (hw); + + mtk_phy_update_field(regs + HDMI_1_CFG_10,
RG_HDMITX21_BIAS_PE_BG_VREF_SEL,0x2);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +2
-0+mtk_phy_clear_bits (regs +HDMI_1_CFG_10 ,RG_HDMITX21_VREF_SEL ); + mtk_phy_update_field(regs + HDMI_1_CFG_9,
RG_HDMITX21_SLDO_VREF_SEL,0x2);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_clear_bits(regs + HDMI_1_CFG_10,
RG_HDMITX21_BIAS_PE_VREF_SELB);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +2
-0+mtk_phy_set_bits (regs +HDMI_1_CFG_3 ,RG_HDMITX21_SLDOLPF_EN ); + mtk_phy_update_field(regs + HDMI_1_CFG_6, RG_HDMITX21_INTR_CAL,
0x11);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +6
-0+mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_2 ,RG_HDMITXPLL_PWD ); + +/* TXPOSDIV */ + txposdiv_value =ilog2 (txposdiv); + + mtk_phy_update_field(regs + HDMI_1_CFG_6,
RG_HDMITX21_TX_POSDIV,txposdiv_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_TX_POSDIV_EN);
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 138
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +5
-0+mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_FRL_EN ); + +/* TXPREDIV */ +switch (txprediv) { +case 2 :
'case' is aligned with 'switch'
Quoted 113 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +20
-0+ div3_ctrl_value =0x0 ; + posdiv_vallue =0x0 ; +break ; +case 4 : + div3_ctrl_value =0x0 ; + posdiv_vallue =0x1 ; +break ; +case 6 : + div3_ctrl_value =0x1 ; + posdiv_vallue =0x0 ; +break ; +case 12 : + div3_ctrl_value =0x1 ; + posdiv_vallue =0x1 ; +break ; +default : +return -EINVAL ; + } + + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_4,
RG_HDMITXPLL_POSDIV_DIV3_CTRL,div3_ctrl_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_PLL_CFG_4,
RG_HDMITXPLL_POSDIV,posdiv_vallue);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +20
-0+ +/* POSDIV1 */ +switch (posdiv1) { +case 5 : + div_ctrl_value =0x0 ; +break ; +case 10 : + div_ctrl_value =0x1 ; +break ; +case 12 : + div_ctrl_value =0x2 ; +break ; +case 15 : + div_ctrl_value =0x3 ; +break ; +default : +return -EINVAL ; + } + + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_4,
RG_HDMITXPLL_DIV_CTRL,div_ctrl_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* DE add new setting */ + mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT14);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +20
-0+ +/* POSDIV2 */ +switch (posdiv2) { +case 1 : + reserve_3_2_value =0x0 ; +break ; +case 2 : + reserve_3_2_value =0x1 ; +break ; +case 4 : + reserve_3_2_value =0x2 ; +break ; +case 6 : + reserve_3_2_value =0x3 ; +break ; +default : +return -EINVAL ; + } + + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT3_2,reserve_3_2_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* DE add new setting */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT1_0,0x2);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +5
-0+ +/* PREDIV */ + prediv_value =ilog2 (prediv); + + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_4,
RG_HDMITXPLL_PREDIV,prediv_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +5
-0+ +/* FBKDIV_HS3 */ + reserve13_value =ilog2 (fbkdiv_hs3); + + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT13,reserve13_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* FBDIV */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_4,
RG_HDMITXPLL_FBKDIV_HIGH,fbkdiv_high);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_PLL_CFG_3,
RG_HDMITXPLL_FBKDIV_LOW,fbkdiv_low);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +7
-0+ + +/* Digital DIVIDER */ +mtk_phy_clear_bits (regs +HDMI_CTL_3 ,REG_PIXEL_CLOCK_SEL ); + +if (digital_div ==1 ) { + mtk_phy_clear_bits(regs + HDMI_CTL_3,
REG_HDMITX_PIXEL_CLOCK);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +2
-0+ }else { + mtk_phy_set_bits(regs + HDMI_CTL_3,
REG_HDMITX_PIXEL_CLOCK);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_CTL_3,
REG_HDMITXPLL_DIV,digital_div- 1);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +8
-0+ } + +return 0 ; +} + +#define PCW_DECIMAL_WIDTH 24 + +static int mtk_hdmi_pll_calculate_params(struct clk_hw *hw, unsignedlong rate,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 243
Quoted 6 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +6
-0+ unsigned long parent_rate) +{ +int ret; +unsigned long long tmds_clk =0 ; +unsigned long long pixel_clk =0 ; +//pll input source frequency
prefer to use '/* */' instead '//'
Quoted 241 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +54
-0+unsigned long long da_hdmitx21_ref_ck =0 ; +unsigned long long ns_hdmipll_ck =0 ;//ICO output clk +//source clk for Display digital +unsigned long long ad_hdmipll_pixel_ck =0 ; +unsigned char digital_div =0 ; +unsigned long long pcw =0 ;//FBDIV +unsigned char txprediv =0 ; +unsigned char txposdiv =0 ; +unsigned char fbkdiv_high =0 ; +unsigned long fbkdiv_low =0 ; +unsigned char posdiv1 =0 ; +unsigned char posdiv2 =0 ; +unsigned char prediv =1 ;//prediv is always 1 +unsigned char fbkdiv_hs3 =1 ;//fbkdiv_hs3 is always 1 +int i =0 ; +unsigned char txpredivs[4 ] = {2 ,4 ,6 ,12 }; + + pixel_clk = rate; + tmds_clk = pixel_clk; + +if (tmds_clk <25000000 || tmds_clk >594000000 ) +return -EINVAL ; + + da_hdmitx21_ref_ck =26000000UL ;//in HZ + +/* TXPOSDIV stage treatment: +* 0M < TMDS clk < 54M /8 +* 54M <= TMDS clk < 148.35M /4 +* 148.35M <=TMDS clk < 296.7M /2 +* 296.7 <=TMDS clk <= 594M /1 +*/ +if (tmds_clk <54000000UL ) + txposdiv =8 ; +else if (tmds_clk >=54000000UL && tmds_clk <148350000UL ) + txposdiv =4 ; +else if (tmds_clk >=148350000UL && tmds_clk <296700000UL ) + txposdiv =2 ; +else if (tmds_clk >=296700000UL && tmds_clk <=594000000UL ) + txposdiv =1 ; +else +return -EINVAL ; + +/* calculate txprediv: can be 2, 4, 6, 12 +* ICO clk = 5*TMDS_CLK*TXPOSDIV*TXPREDIV +* ICO clk constraint: 5G =< ICO clk <= 12G +*/ +for (i =0 ; i <ARRAY_SIZE (txpredivs); i++) { + ns_hdmipll_ck =5 * tmds_clk * txposdiv * txpredivs[i]; +if (ns_hdmipll_ck >=5000000000UL && + ns_hdmipll_ck <=12000000000UL ) +break ; + } + if (i == (ARRAY_SIZE(txpredivs) - 1) && + (ns_hdmipll_ck < 5000000000UL || ns_hdmipll_ck >12000000000UL)) {
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +9
-0+return -EINVAL ; + } +if (i ==ARRAY_SIZE (txpredivs)) +return -EINVAL ; + + txprediv = txpredivs[i]; + +/* PCW calculation: FBKDIV +* formula: pcw=(frequency_out*2^pcw_bit) / frequency_in /
FBKDIV_HS3;drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +34
-0+* RG_HDMITXPLL_FBKDIV[32:0]: +* [32,24] 9bit integer, [23,0]:24bit fraction +*/ + pcw = ns_hdmipll_ck; + pcw = pcw <<PCW_DECIMAL_WIDTH ; + pcw = pcw / da_hdmitx21_ref_ck; + pcw = pcw / fbkdiv_hs3; + +if ((pcw /BIT (32 )) >1 ) { +return -EINVAL ; + }else if ((pcw /BIT (32 )) ==1 ) { + fbkdiv_high =1 ; + fbkdiv_low = pcw %BIT (32 ); + }else { + fbkdiv_high =0 ; + fbkdiv_low = pcw; + } + +/* posdiv1: +* posdiv1 stage treatment according to color_depth: +* 24bit -> posdiv1 /10, 30bit -> posdiv1 /12.5, +* 36bit -> posdiv1 /15, 48bit -> posdiv1 /10 +*/ + posdiv1 =10 ;// div 10 + posdiv2 =1 ; + ad_hdmipll_pixel_ck = (ns_hdmipll_ck /10 ) /1 ; + +/* Digital clk divider, max /32 */ + digital_div = ad_hdmipll_pixel_ck / pixel_clk; +if (!(digital_div <=32 && digital_div >=1 )) +return -EINVAL ; + + ret = mtk_hdmi_pll_set_hw(hw, prediv, fbkdiv_high, fbkdiv_low, + fbkdiv_hs3, posdiv1, posdiv2,txprediv,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +35
-0+ txposdiv, digital_div); +if (ret) +return -EINVAL ; + +return 0 ; +} + +static int mtk_hdmi_pll_drv_setting (struct clk_hw *hw) +{ +unsigned char data_channel_bias, clk_channel_bias; +unsigned char impedance, impedance_en; +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +unsigned long tmds_clk; +unsigned long pixel_clk = hdmi_phy->pll_rate; +void __iomem *regs = hdmi_phy->regs; + + tmds_clk = pixel_clk; + +/* bias & impedance setting: +* 3G < data rate <= 6G: enable impedance 100ohm, +* data channel bias 24mA, clock channel bias 20mA +* pixel clk >= HD, 74.175MHZ <= pixel clk <= 300MHZ: +* enalbe impedance 100ohm +* data channel 20mA, clock channel 16mA +* 27M =< pixel clk < 74.175: disable impedance +* data channel & clock channel bias 10mA +*/ + +/* 3G < data rate <= 6G, 300M < tmds rate <= 594M */ +if (tmds_clk >300000000UL && tmds_clk <=594000000UL ) { + data_channel_bias =0x3c ;//24mA + clk_channel_bias =0x34 ;//20mA + impedance_en =0xf ; + impedance =0x36 ;//100ohm + }else if (pixel_clk >=74175000UL && pixel_clk <=300000000UL ){
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +15
-0+ data_channel_bias =0x34 ;//20mA + clk_channel_bias =0x2c ;//16mA + impedance_en =0xf ; + impedance =0x36 ;//100ohm + }else if (pixel_clk >=27000000UL && pixel_clk <74175000UL ) { + data_channel_bias =0x14 ;//10mA + clk_channel_bias =0x14 ;//10mA + impedance_en =0x0 ; + impedance =0x0 ; + }else { +return -EINVAL ; + } + +/* bias */ + mtk_phy_update_field(regs + HDMI_1_CFG_1,
RG_HDMITX21_DRV_IBIAS_D0,data_channel_bias);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_1,
RG_HDMITX21_DRV_IBIAS_D1,data_channel_bias);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_1,
RG_HDMITX21_DRV_IBIAS_D2,data_channel_bias);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_0,
RG_HDMITX21_DRV_IBIAS_CLK,clk_channel_bias);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* impedance */ + mtk_phy_update_field(regs + HDMI_1_CFG_0,
RG_HDMITX21_DRV_IMP_EN,impedance_en);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_2,
RG_HDMITX21_DRV_IMP_D0_EN1, impedance);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_2,
RG_HDMITX21_DRV_IMP_D1_EN1, impedance);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_2,
RG_HDMITX21_DRV_IMP_D2_EN1, impedance);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_2,
RG_HDMITX21_DRV_IMP_CLK_EN1, impedance);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +10
-0+ +return 0 ; +} + +static int mtk_hdmi_pll_prepare (struct clk_hw *hw) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +void __iomem *regs = hdmi_phy->regs; + + mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_TX_POSDIV_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +mtk_phy_set_bits (regs +HDMI_1_CFG_0 ,RG_HDMITX21_SER_EN ); + mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_D0_DRV_OP_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_D1_DRV_OP_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_D2_DRV_OP_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_CK_DRV_OP_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +16
-0+ +mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_FRL_D0_EN ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_FRL_D1_EN ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_FRL_D2_EN ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_FRL_CK_EN ); + +mtk_hdmi_pll_drv_setting (hw); + +mtk_phy_clear_bits (regs +HDMI_1_CFG_10 ,RG_HDMITX21_BG_PWD ); +mtk_phy_set_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_BIAS_EN ); +mtk_phy_set_bits (regs +HDMI_1_CFG_3 ,RG_HDMITX21_CKLDO_EN ); +mtk_phy_set_bits (regs +HDMI_1_CFG_3 ,RG_HDMITX21_SLDO_EN ); + +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_4 ,DA_HDMITXPLL_PWR_ON ); +usleep_range (5 ,10 ); + mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_4,
DA_HDMITXPLL_ISO_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +21
-0+usleep_range (5 ,10 ); +mtk_phy_clear_bits (regs +HDMI_1_PLL_CFG_2 ,RG_HDMITXPLL_PWD ); +usleep_range (30 ,50 ); +return 0 ; +} + +static void mtk_hdmi_pll_unprepare (struct clk_hw *hw) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +void __iomem *regs = hdmi_phy->regs; + +mtk_phy_set_bits (regs +HDMI_1_CFG_10 ,RG_HDMITX21_BG_PWD ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_BIAS_EN ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_3 ,RG_HDMITX21_CKLDO_EN ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_3 ,RG_HDMITX21_SLDO_EN ); + +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_2 ,RG_HDMITXPLL_PWD ); +usleep_range (10 ,20 ); +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_4 ,DA_HDMITXPLL_ISO_EN ); +usleep_range (10 ,20 ); + mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_4,
DA_HDMITXPLL_PWR_ON);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+} + +static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned longrate,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +6
-0+ unsigned long parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +int ret; + + dev_dbg(hdmi_phy->dev, "%s: %lu Hz, parent: %lu Hz\n",
__func__, rate,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 469
Quoted 7 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +7
-0+ parent_rate); + + ret =mtk_hdmi_pll_calculate_params (hw, rate, parent_rate); +if (ret !=0 ) +return -EINVAL ; + +return 0 ;
return mtk_hdmi_pll_calculate_params(hw, rate, parent_rate);
Quoted 54 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+} + +static long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned longrate,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +10
-0+ unsigned long *parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); + + hdmi_phy->pll_rate = rate; +return rate; +} + +static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, + unsigned long
parent_rate)drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +20
-0+{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); + +return hdmi_phy->pll_rate; +} + +static const struct clk_ops mtk_hdmi_pll_ops = { + .prepare = mtk_hdmi_pll_prepare, + .unprepare = mtk_hdmi_pll_unprepare, + .set_rate = mtk_hdmi_pll_set_rate, + .round_rate = mtk_hdmi_pll_round_rate, + .recalc_rate = mtk_hdmi_pll_recalc_rate, +}; + +static void vtx_signal_en (struct mtk_hdmi_phy *hdmi_phy,bool on) +{ +void __iomem *regs = hdmi_phy->regs; + +if (on) + mtk_phy_set_bits(regs + HDMI_1_CFG_0,
RG_HDMITX21_DRV_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +2
-0+else + mtk_phy_clear_bits(regs + HDMI_1_CFG_0,
RG_HDMITX21_DRV_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +14
-0+} + +static void mtk_hdmi_phy_enable_tmds (struct mtk_hdmi_phy *hdmi_phy) +{ +vtx_signal_en (hdmi_phy, true); +usleep_range (100 ,150 ); +} + +static void mtk_hdmi_phy_disable_tmds (struct mtk_hdmi_phy *hdmi_phy) +{ +vtx_signal_en (hdmi_phy, false); +} + +static int mtk_hdmi_phy_configure(struct phy *phy, union
phy_configure_opts*opts)
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 523
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +5
-0+{ +struct phy_configure_opts_dp *dp_opts = &opts->dp; +struct mtk_hdmi_phy *hdmi_phy =phy_get_drvdata (phy); +int ret =0 ; +bool enable =0 ;
Seems no need local variable "enable"
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 528
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +5
-0+ + ret =clk_set_rate (hdmi_phy->pll, dp_opts->link_rate); + +if (ret) + goto out;
return ret directly?
Quoted 25 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +18
-0+ +mtk_mt8195_phy_tmds_high_bit_clk_ratio (hdmi_phy, enable); + +out: +return ret; +} + +struct mtk_hdmi_phy_conf mtk_hdmi_phy_8195_conf = { + .flags =CLK_SET_RATE_PARENT |CLK_SET_RATE_GATE , + .hdmi_phy_clk_ops = &mtk_hdmi_pll_ops, + .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds, + .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds, + .hdmi_phy_configure = mtk_hdmi_phy_configure, +}; + +MODULE_AUTHOR ("Can Zeng <[email protected]>" ); +MODULE_DESCRIPTION ("MediaTek MT8195 HDMI PHY Driver" ); +MODULE_LICENSE ("GPL v2" );drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +0
-0
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h line 4
Quoted 4 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +4
-0@@ -0,0 +1,131 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2021 MediaTek Inc. +* Copyright (c) 2021 BayLibre, SAS
2022?
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h line 10
Quoted 6 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +6
-0+*/ + +#ifndef _MTK_HDMI_PHY_8195_H +#define _MTK_HDMI_PHY_8195_H + +#include <linux/types.h>
move it after <linux/clk-provider.h>?
Quoted 89 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +89
-0+#include <linux/clk.h> +#include <linux/clk-provider.h> + +#define DA_HDMITXPLL_ISO_EN BIT(1) +#define DA_HDMITXPLL_PWR_ON BIT(2) + +#define HDMI20_CLK_CFG 0x70 + +#define HDMI_1_CFG_0 0x00 +#define HDMI_1_CFG_1 0x04 +#define HDMI_1_CFG_10 0x40 +#define HDMI_1_CFG_2 0x08 +#define HDMI_1_CFG_21 0x84 +#define HDMI_1_CFG_22 0x88 +#define HDMI_1_CFG_3 0x0c +#define HDMI_1_CFG_6 0x18 +#define HDMI_1_CFG_9 0x24 +#define HDMI_1_PLL_CFG_0 0x44 +#define HDMI_1_PLL_CFG_1 0x48 +#define HDMI_1_PLL_CFG_2 0x4c +#define HDMI_1_PLL_CFG_3 0x50 +#define HDMI_1_PLL_CFG_4 0x54 + +#define HDMI_ANA_CTL 0x7c + +#define HDMI_CTL_1 0xc4 +#define HDMI_CTL_3 0xcc + +#define REG_ANA_HDMI20_FIFO_EN BIT(16) + +#define REG_HDMITXPLL_DIV GENMASK(4, 0) +#define REG_HDMITX_PIXEL_CLOCK BIT(23) +#define REG_HDMITX_REF_RESPLL_SEL BIT(9) +#define REG_HDMITX_REF_XTAL_SEL BIT(7) + +#define REG_PIXEL_CLOCK_SEL BIT(10) + +#define REG_TXC_DIV GENMASK(31, 30) + +#define RG_HDMITX21_BG_PWD BIT(20) + +#define RG_HDMITX21_BIAS_EN BIT(29) +#define RG_HDMITX21_BIAS_PE_BG_VREF_SEL GENMASK(16, 15) +#define RG_HDMITX21_BIAS_PE_VREF_SELB BIT(10) + +#define RG_HDMITX21_CKLDO_EN BIT(3) + +#define RG_HDMITX21_CK_DRV_OP_EN BIT(11) + +#define RG_HDMITX21_D0_DRV_OP_EN BIT(10) + +#define RG_HDMITX21_D1_DRV_OP_EN BIT(9) + +#define RG_HDMITX21_D2_DRV_OP_EN BIT(8) + +#define RG_HDMITX21_DRV_EN GENMASK(27, 24) +#define RG_HDMITX21_DRV_IBIAS_CLK GENMASK(10, 5) +#define RG_HDMITX21_DRV_IBIAS_D0 GENMASK(19, 14) +#define RG_HDMITX21_DRV_IBIAS_D0_FFE1 GENMASK(21, 17) +#define RG_HDMITX21_DRV_IBIAS_D0_FFE2 GENMASK(23, 20) +#define RG_HDMITX21_DRV_IBIAS_D1 GENMASK(25, 20) +#define RG_HDMITX21_DRV_IBIAS_D1_FFE1 GENMASK(26, 22) +#define RG_HDMITX21_DRV_IBIAS_D1_FFE2 GENMASK(27, 24) +#define RG_HDMITX21_DRV_IBIAS_D2 GENMASK(31, 26) +#define RG_HDMITX21_DRV_IBIAS_D2_FFE1 GENMASK(31, 27) +#define RG_HDMITX21_DRV_IBIAS_D2_FFE2 GENMASK(31, 28) +#define RG_HDMITX21_DRV_IMP_CLK_EN1 GENMASK(31, 26) +#define RG_HDMITX21_DRV_IMP_D0_EN1 GENMASK(13, 8) +#define RG_HDMITX21_DRV_IMP_D1_EN1 GENMASK(19, 14) +#define RG_HDMITX21_DRV_IMP_D2_EN1 GENMASK(25, 20) +#define RG_HDMITX21_DRV_IMP_EN GENMASK(23, 20) + +#define RG_HDMITX21_FRL_CK_EN BIT(13) +#define RG_HDMITX21_FRL_D0_EN BIT(14) +#define RG_HDMITX21_FRL_D1_EN BIT(15) +#define RG_HDMITX21_FRL_D2_EN BIT(16) +#define RG_HDMITX21_FRL_EN BIT(12) + +#define RG_HDMITX21_INTR_CAL GENMASK(22, 18) +#define RG_HDMITX21_INTR_CAL_READOUT GENMASK(22, 18) + +#define RG_HDMITX21_SER_EN GENMASK(31, 28) + +#define RG_HDMITX21_SLDOLPF_EN BIT(7) +#define RG_HDMITX21_SLDO_EN GENMASK(11, 8) +#define RG_HDMITX21_SLDO_VREF_SEL GENMASK(5, 4) + +#define RG_HDMITX21_TX_POSDIV GENMASK(27, 26) +#define RG_HDMITX21_TX_POSDIV_EN BIT(28)
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h line 109
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +10
-0+ +#define RG_HDMITX21_VREF_SEL BIT(4) + +#define RG_HDMITXPLL_BC GENMASK(28, 27) +#define RG_HDMITXPLL_BP GENMASK(13, 10) +#define RG_HDMITXPLL_BP2 BIT(30) +#define RG_HDMITXPLL_BR GENMASK(21, 19) +#define RG_HDMITXPLL_DIV_CTRL GENMASK(25, 24) +#define RG_HDMITXPLL_FBKDIV_HIGH BIT(31) +#define RG_HDMITXPLL_FBKDIV_LOW (0xffffffff)
make sure it includes bit 31? use GENMASK()?
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +10
-0+#define RG_HDMITXPLL_HIKVCO BIT(29) +#define RG_HDMITXPLL_HREN GENMASK(13, 12) +#define RG_HDMITXPLL_IBAND_FIX_EN BIT(24) +#define RG_HDMITXPLL_IC GENMASK(26, 22) +#define RG_HDMITXPLL_IR GENMASK(18, 14) +#define RG_HDMITXPLL_LVR_SEL GENMASK(27, 26) +#define RG_HDMITXPLL_POSDIV GENMASK(23, 22) +#define RG_HDMITXPLL_POSDIV_DIV3_CTRL BIT(21) +#define RG_HDMITXPLL_PREDIV GENMASK(29, 28) +#define RG_HDMITXPLL_PWD BIT(31)
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h line 129
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +10
-0+#define RG_HDMITXPLL_REF_CK_SEL GENMASK(2, 1) +#define RG_HDMITXPLL_RESERVE GENMASK(15, 0) +#define RG_HDMITXPLL_RESERVE_BIT12_11 GENMASK(12, 11) +#define RG_HDMITXPLL_RESERVE_BIT13 BIT(13) +#define RG_HDMITXPLL_RESERVE_BIT14 BIT(14) +#define RG_HDMITXPLL_RESERVE_BIT1_0 GENMASK(1, 0) +#define RG_HDMITXPLL_RESERVE_BIT3_2 GENMASK(3, 2) +#define RG_HDMITXPLL_TCL_EN BIT(31) + +#define RG_INTR_IMP_RG_MODE GENMASK(7, 3)
It's difficult to distinguish the bits/mask which the register it belongs to.
Do you define it according to the bits sequence in register?
Thanks
Quoted 32 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +2
-0+ +#endif /* MTK_HDMI_PHY_8195_H */ drivers/phy/mediatek/phy-mtk-hdmi.c +3
-0@@ -161,6 +161,9 @@ static const struct of_device_id mtk_hdmi_phy_match[] = { { .compatible ="mediatek,mt8173-hdmi-phy" , .data = &mtk_hdmi_phy_8173_conf, }, + { .compatible ="mediatek,mt8195-hdmi-phy" , + .data = &mtk_hdmi_phy_8195_conf, + }, {}, };
MODULE_DEVICE_TABLE(of, mtk_hdmi_phy_match);drivers/phy/mediatek/phy-mtk-hdmi.h +1
-0@@ -44,6 +44,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_8173_conf;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf;
Re: [PATCH v2 10/12] phy: mediatek: add support for phy-mtk-hdmi-mt8195
Quoted 801 lines · Chunfeng Yun
Quoted 33 lines · Guillaume Ranquet
Add basic support for the mediatek hdmi phy on MT8195 SoC
Signed-off-by Guillaume Ranquet <[email protected]>--- drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 546 +++++++++++++++++++++++++++++ drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h | 131 +++++++ drivers/phy/mediatek/phy-mtk-hdmi.c | 3 + drivers/phy/mediatek/phy-mtk-hdmi.h | 1 + 5 files changed, 682 insertions(+)drivers/phy/mediatek/Makefile +0
-0@@ -12,6 +12,7 @@ obj-$(CONFIG_PHY_MTK_XSPHY) += phy-mtk-xsphy.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-mt8173.odrivers/phy/mediatek/Makefile +1
-0+phy-mtk-hdmi-drv-y += phy-mtk-hdmi-mt8195.o obj-$(CONFIG_PHY_MTK_HDMI) += phy-mtk-hdmi-drv.o phy-mtk-mipi-dsi-drv-y := phy-mtk-mipi-dsi.odrivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +0
-0drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 4
Quoted 4 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +4
-0@@ -0,0 +1,546 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2021 MediaTek Inc. +* Copyright (c) 2021 BayLibre, SAS 2022?
Quoted 152 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +18
-0+*/ +#include <linux/delay.h> +#include <linux/io.h> +#include <linux/mfd/syscon.h> +#include <linux/module.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/types.h> +#include <linux/nvmem-consumer.h> + +#include "phy-mtk-io.h" +#include "phy-mtk-hdmi.h" +#include "phy-mtk-hdmi-mt8195.h" + +static void mtk_hdmi_ana_fifo_en (struct mtk_hdmi_phy *hdmi_phy) +{ +/* make data fifo writable for hdmi2.0 */ + mtk_phy_set_bits(hdmi_phy->regs + HDMI_ANA_CTL,
REG_ANA_HDMI20_FIFO_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +4
-0+} + +static void +mtk_mt8195_phy_tmds_high_bit_clk_ratio(struct mtk_hdmi_phy
*hdmi_phy,drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +11
-0+ bool enable) +{ +void __iomem *regs = hdmi_phy->regs; + +mtk_hdmi_ana_fifo_en (hdmi_phy); + +/* HDMI 2.0 specification, 3.4Gbps <= TMDS Bit Rate <= 6G, +* clock bit ratio 1:40, under 3.4Gbps, clock bit ratio 1:10 +*/ +if (enable) + mtk_phy_update_field(regs + HDMI20_CLK_CFG,
REG_TXC_DIV,REG_TXC_DIV);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +11
-0+else +mtk_phy_clear_bits (regs +HDMI20_CLK_CFG ,REG_TXC_DIV ); +} + +static void mtk_hdmi_pll_select_source (struct clk_hw *hw) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +void __iomem *regs = hdmi_phy->regs; + +mtk_phy_clear_bits (regs +HDMI_CTL_3 ,REG_HDMITX_REF_XTAL_SEL ); + mtk_phy_clear_bits(regs + HDMI_CTL_3,
REG_HDMITX_REF_RESPLL_SEL);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* DA_HDMITX21_REF_CK for TXPLL input source */ + mtk_phy_clear_bits(regs + HDMI_1_CFG_10,
RG_HDMITXPLL_REF_CK_SEL);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +15
-0+} + +static int mtk_hdmi_pll_performance_setting (struct clk_hw *hw) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +void __iomem *regs = hdmi_phy->regs; + +/* BP2 */ +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_0 ,RG_HDMITXPLL_BP2 ); + +/* BC */ +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_2 ,RG_HDMITXPLL_BC ); + +/* IC */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_2, RG_HDMITXPLL_IC,
0x1);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* BR */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_2, RG_HDMITXPLL_BR,
0x2);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* IR */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_2, RG_HDMITXPLL_IR,
0x2);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +6
-0+ +/* BP */ +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_2 ,RG_HDMITXPLL_BP ); + +/* IBAND_FIX_EN, RESERVE[14] */ + mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_0,
RG_HDMITXPLL_IBAND_FIX_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT14);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* HIKVCO */ + mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_2,
RG_HDMITXPLL_HIKVCO);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* HREN */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_0,
RG_HDMITXPLL_HREN,0x1);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* LVR_SEL */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_0,
RG_HDMITXPLL_LVR_SEL,0x1);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* RG_HDMITXPLL_RESERVE[12:11] */ + mtk_phy_set_bits(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT12_11);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +8
-0+ +/* TCL_EN */ +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_0 ,RG_HDMITXPLL_TCL_EN ); + +return 0 ; +} + +static int mtk_hdmi_pll_set_hw(struct clk_hw *hw, unsigned charprediv,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+unsigned char fbkdiv_high, + unsigned long fbkdiv_low, + unsigned char fbkdiv_hs3, unsigned charposdiv1,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ unsigned char posdiv2, unsigned chartxprediv,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +18
-0+unsigned char txposdiv, + unsigned char digital_div) +{ + unsigned char txposdiv_value = 0; +unsigned char div3_ctrl_value =0 ; +unsigned char posdiv_vallue =0 ; +unsigned char div_ctrl_value =0 ; +unsigned char reserve_3_2_value =0 ; +unsigned char prediv_value =0 ; +unsigned char reserve13_value =0 ; +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +void __iomem *regs = hdmi_phy->regs; + +mtk_hdmi_pll_select_source (hw); + +mtk_hdmi_pll_performance_setting (hw); + + mtk_phy_update_field(regs + HDMI_1_CFG_10,
RG_HDMITX21_BIAS_PE_BG_VREF_SEL,0x2);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +2
-0+mtk_phy_clear_bits (regs +HDMI_1_CFG_10 ,RG_HDMITX21_VREF_SEL ); + mtk_phy_update_field(regs + HDMI_1_CFG_9,
RG_HDMITX21_SLDO_VREF_SEL,0x2);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_clear_bits(regs + HDMI_1_CFG_10,
RG_HDMITX21_BIAS_PE_VREF_SELB);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +2
-0+mtk_phy_set_bits (regs +HDMI_1_CFG_3 ,RG_HDMITX21_SLDOLPF_EN ); + mtk_phy_update_field(regs + HDMI_1_CFG_6, RG_HDMITX21_INTR_CAL,
0x11);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +6
-0+mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_2 ,RG_HDMITXPLL_PWD ); + +/* TXPOSDIV */ + txposdiv_value =ilog2 (txposdiv); + + mtk_phy_update_field(regs + HDMI_1_CFG_6,
RG_HDMITX21_TX_POSDIV,txposdiv_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_TX_POSDIV_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 138
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +5
-0+mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_FRL_EN ); + +/* TXPREDIV */ +switch (txprediv) { +case 2 :'case' is aligned with 'switch'
Quoted 113 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +20
-0+ div3_ctrl_value =0x0 ; + posdiv_vallue =0x0 ; +break ; +case 4 : + div3_ctrl_value =0x0 ; + posdiv_vallue =0x1 ; +break ; +case 6 : + div3_ctrl_value =0x1 ; + posdiv_vallue =0x0 ; +break ; +case 12 : + div3_ctrl_value =0x1 ; + posdiv_vallue =0x1 ; +break ; +default : +return -EINVAL ; + } + + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_4,
RG_HDMITXPLL_POSDIV_DIV3_CTRL,div3_ctrl_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_PLL_CFG_4,
RG_HDMITXPLL_POSDIV,posdiv_vallue);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +20
-0+ +/* POSDIV1 */ +switch (posdiv1) { +case 5 : + div_ctrl_value =0x0 ; +break ; +case 10 : + div_ctrl_value =0x1 ; +break ; +case 12 : + div_ctrl_value =0x2 ; +break ; +case 15 : + div_ctrl_value =0x3 ; +break ; +default : +return -EINVAL ; + } + + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_4,
RG_HDMITXPLL_DIV_CTRL,div_ctrl_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* DE add new setting */ + mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT14);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +20
-0+ +/* POSDIV2 */ +switch (posdiv2) { +case 1 : + reserve_3_2_value =0x0 ; +break ; +case 2 : + reserve_3_2_value =0x1 ; +break ; +case 4 : + reserve_3_2_value =0x2 ; +break ; +case 6 : + reserve_3_2_value =0x3 ; +break ; +default : +return -EINVAL ; + } + + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT3_2,reserve_3_2_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* DE add new setting */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT1_0,0x2);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +5
-0+ +/* PREDIV */ + prediv_value =ilog2 (prediv); + + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_4,
RG_HDMITXPLL_PREDIV,prediv_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +5
-0+ +/* FBKDIV_HS3 */ + reserve13_value =ilog2 (fbkdiv_hs3); + + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_1,
RG_HDMITXPLL_RESERVE_BIT13,reserve13_value);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* FBDIV */ + mtk_phy_update_field(regs + HDMI_1_PLL_CFG_4,
RG_HDMITXPLL_FBKDIV_HIGH,fbkdiv_high);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_PLL_CFG_3,
RG_HDMITXPLL_FBKDIV_LOW,fbkdiv_low);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +7
-0+ + +/* Digital DIVIDER */ +mtk_phy_clear_bits (regs +HDMI_CTL_3 ,REG_PIXEL_CLOCK_SEL ); + +if (digital_div ==1 ) { + mtk_phy_clear_bits(regs + HDMI_CTL_3,
REG_HDMITX_PIXEL_CLOCK);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +2
-0+ }else { + mtk_phy_set_bits(regs + HDMI_CTL_3,
REG_HDMITX_PIXEL_CLOCK);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_CTL_3,
REG_HDMITXPLL_DIV,digital_div- 1);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +8
-0+ } + +return 0 ; +} + +#define PCW_DECIMAL_WIDTH 24 + +static int mtk_hdmi_pll_calculate_params(struct clk_hw *hw, unsignedlong rate,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 243
Quoted 6 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +6
-0+ unsigned long parent_rate) +{ +int ret; +unsigned long long tmds_clk =0 ; +unsigned long long pixel_clk =0 ; +//pll input source frequency prefer to use '/* */' instead '//'
Quoted 241 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +54
-0+unsigned long long da_hdmitx21_ref_ck =0 ; +unsigned long long ns_hdmipll_ck =0 ;//ICO output clk +//source clk for Display digital +unsigned long long ad_hdmipll_pixel_ck =0 ; +unsigned char digital_div =0 ; +unsigned long long pcw =0 ;//FBDIV +unsigned char txprediv =0 ; +unsigned char txposdiv =0 ; +unsigned char fbkdiv_high =0 ; +unsigned long fbkdiv_low =0 ; +unsigned char posdiv1 =0 ; +unsigned char posdiv2 =0 ; +unsigned char prediv =1 ;//prediv is always 1 +unsigned char fbkdiv_hs3 =1 ;//fbkdiv_hs3 is always 1 +int i =0 ; +unsigned char txpredivs[4 ] = {2 ,4 ,6 ,12 }; + + pixel_clk = rate; + tmds_clk = pixel_clk; + +if (tmds_clk <25000000 || tmds_clk >594000000 ) +return -EINVAL ; + + da_hdmitx21_ref_ck =26000000UL ;//in HZ + +/* TXPOSDIV stage treatment: +* 0M < TMDS clk < 54M /8 +* 54M <= TMDS clk < 148.35M /4 +* 148.35M <=TMDS clk < 296.7M /2 +* 296.7 <=TMDS clk <= 594M /1 +*/ +if (tmds_clk <54000000UL ) + txposdiv =8 ; +else if (tmds_clk >=54000000UL && tmds_clk <148350000UL ) + txposdiv =4 ; +else if (tmds_clk >=148350000UL && tmds_clk <296700000UL ) + txposdiv =2 ; +else if (tmds_clk >=296700000UL && tmds_clk <=594000000UL ) + txposdiv =1 ; +else +return -EINVAL ; + +/* calculate txprediv: can be 2, 4, 6, 12 +* ICO clk = 5*TMDS_CLK*TXPOSDIV*TXPREDIV +* ICO clk constraint: 5G =< ICO clk <= 12G +*/ +for (i =0 ; i <ARRAY_SIZE (txpredivs); i++) { + ns_hdmipll_ck =5 * tmds_clk * txposdiv * txpredivs[i]; +if (ns_hdmipll_ck >=5000000000UL && + ns_hdmipll_ck <=12000000000UL ) +break ; + } + if (i == (ARRAY_SIZE(txpredivs) - 1) && + (ns_hdmipll_ck < 5000000000UL || ns_hdmipll_ck >12000000000UL)) {
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +9
-0+return -EINVAL ; + } +if (i ==ARRAY_SIZE (txpredivs)) +return -EINVAL ; + + txprediv = txpredivs[i]; + +/* PCW calculation: FBKDIV +* formula: pcw=(frequency_out*2^pcw_bit) / frequency_in /
FBKDIV_HS3;drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +34
-0+* RG_HDMITXPLL_FBKDIV[32:0]: +* [32,24] 9bit integer, [23,0]:24bit fraction +*/ + pcw = ns_hdmipll_ck; + pcw = pcw <<PCW_DECIMAL_WIDTH ; + pcw = pcw / da_hdmitx21_ref_ck; + pcw = pcw / fbkdiv_hs3; + +if ((pcw /BIT (32 )) >1 ) { +return -EINVAL ; + }else if ((pcw /BIT (32 )) ==1 ) { + fbkdiv_high =1 ; + fbkdiv_low = pcw %BIT (32 ); + }else { + fbkdiv_high =0 ; + fbkdiv_low = pcw; + } + +/* posdiv1: +* posdiv1 stage treatment according to color_depth: +* 24bit -> posdiv1 /10, 30bit -> posdiv1 /12.5, +* 36bit -> posdiv1 /15, 48bit -> posdiv1 /10 +*/ + posdiv1 =10 ;// div 10 + posdiv2 =1 ; + ad_hdmipll_pixel_ck = (ns_hdmipll_ck /10 ) /1 ; + +/* Digital clk divider, max /32 */ + digital_div = ad_hdmipll_pixel_ck / pixel_clk; +if (!(digital_div <=32 && digital_div >=1 )) +return -EINVAL ; + + ret = mtk_hdmi_pll_set_hw(hw, prediv, fbkdiv_high, fbkdiv_low, + fbkdiv_hs3, posdiv1, posdiv2,txprediv,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +35
-0+ txposdiv, digital_div); +if (ret) +return -EINVAL ; + +return 0 ; +} + +static int mtk_hdmi_pll_drv_setting (struct clk_hw *hw) +{ +unsigned char data_channel_bias, clk_channel_bias; +unsigned char impedance, impedance_en; +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +unsigned long tmds_clk; +unsigned long pixel_clk = hdmi_phy->pll_rate; +void __iomem *regs = hdmi_phy->regs; + + tmds_clk = pixel_clk; + +/* bias & impedance setting: +* 3G < data rate <= 6G: enable impedance 100ohm, +* data channel bias 24mA, clock channel bias 20mA +* pixel clk >= HD, 74.175MHZ <= pixel clk <= 300MHZ: +* enalbe impedance 100ohm +* data channel 20mA, clock channel 16mA +* 27M =< pixel clk < 74.175: disable impedance +* data channel & clock channel bias 10mA +*/ + +/* 3G < data rate <= 6G, 300M < tmds rate <= 594M */ +if (tmds_clk >300000000UL && tmds_clk <=594000000UL ) { + data_channel_bias =0x3c ;//24mA + clk_channel_bias =0x34 ;//20mA + impedance_en =0xf ; + impedance =0x36 ;//100ohm + }else if (pixel_clk >=74175000UL && pixel_clk <=300000000UL ){
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +15
-0+ data_channel_bias =0x34 ;//20mA + clk_channel_bias =0x2c ;//16mA + impedance_en =0xf ; + impedance =0x36 ;//100ohm + }else if (pixel_clk >=27000000UL && pixel_clk <74175000UL ) { + data_channel_bias =0x14 ;//10mA + clk_channel_bias =0x14 ;//10mA + impedance_en =0x0 ; + impedance =0x0 ; + }else { +return -EINVAL ; + } + +/* bias */ + mtk_phy_update_field(regs + HDMI_1_CFG_1,
RG_HDMITX21_DRV_IBIAS_D0,data_channel_bias);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_1,
RG_HDMITX21_DRV_IBIAS_D1,data_channel_bias);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_1,
RG_HDMITX21_DRV_IBIAS_D2,data_channel_bias);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_0,
RG_HDMITX21_DRV_IBIAS_CLK,clk_channel_bias);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +/* impedance */ + mtk_phy_update_field(regs + HDMI_1_CFG_0,
RG_HDMITX21_DRV_IMP_EN,impedance_en);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_2,
RG_HDMITX21_DRV_IMP_D0_EN1, impedance);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_2,
RG_HDMITX21_DRV_IMP_D1_EN1, impedance);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_2,
RG_HDMITX21_DRV_IMP_D2_EN1, impedance);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_update_field(regs + HDMI_1_CFG_2,
RG_HDMITX21_DRV_IMP_CLK_EN1, impedance);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +10
-0+ +return 0 ; +} + +static int mtk_hdmi_pll_prepare (struct clk_hw *hw) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +void __iomem *regs = hdmi_phy->regs; + + mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_TX_POSDIV_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+ +mtk_phy_set_bits (regs +HDMI_1_CFG_0 ,RG_HDMITX21_SER_EN ); + mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_D0_DRV_OP_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_D1_DRV_OP_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_D2_DRV_OP_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +1
-0+ mtk_phy_set_bits(regs + HDMI_1_CFG_6,
RG_HDMITX21_CK_DRV_OP_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +16
-0+ +mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_FRL_D0_EN ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_FRL_D1_EN ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_FRL_D2_EN ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_FRL_CK_EN ); + +mtk_hdmi_pll_drv_setting (hw); + +mtk_phy_clear_bits (regs +HDMI_1_CFG_10 ,RG_HDMITX21_BG_PWD ); +mtk_phy_set_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_BIAS_EN ); +mtk_phy_set_bits (regs +HDMI_1_CFG_3 ,RG_HDMITX21_CKLDO_EN ); +mtk_phy_set_bits (regs +HDMI_1_CFG_3 ,RG_HDMITX21_SLDO_EN ); + +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_4 ,DA_HDMITXPLL_PWR_ON ); +usleep_range (5 ,10 ); + mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_4,
DA_HDMITXPLL_ISO_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +21
-0+usleep_range (5 ,10 ); +mtk_phy_clear_bits (regs +HDMI_1_PLL_CFG_2 ,RG_HDMITXPLL_PWD ); +usleep_range (30 ,50 ); +return 0 ; +} + +static void mtk_hdmi_pll_unprepare (struct clk_hw *hw) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +void __iomem *regs = hdmi_phy->regs; + +mtk_phy_set_bits (regs +HDMI_1_CFG_10 ,RG_HDMITX21_BG_PWD ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_6 ,RG_HDMITX21_BIAS_EN ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_3 ,RG_HDMITX21_CKLDO_EN ); +mtk_phy_clear_bits (regs +HDMI_1_CFG_3 ,RG_HDMITX21_SLDO_EN ); + +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_2 ,RG_HDMITXPLL_PWD ); +usleep_range (10 ,20 ); +mtk_phy_set_bits (regs +HDMI_1_PLL_CFG_4 ,DA_HDMITXPLL_ISO_EN ); +usleep_range (10 ,20 ); + mtk_phy_clear_bits(regs + HDMI_1_PLL_CFG_4,
DA_HDMITXPLL_PWR_ON);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+} + +static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned longrate,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +6
-0+ unsigned long parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); +int ret; + + dev_dbg(hdmi_phy->dev, "%s: %lu Hz, parent: %lu Hz\n",
__func__, rate,drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 469
Quoted 7 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +7
-0+ parent_rate); + + ret =mtk_hdmi_pll_calculate_params (hw, rate, parent_rate); +if (ret !=0 ) +return -EINVAL ; + +return 0 ;return
mtk_hdmi_pll_calculate_params(hw, rate, parent_rate);Quoted 54 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +3
-0+} + +static long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned longrate,
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +10
-0+ unsigned long *parent_rate) +{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); + + hdmi_phy->pll_rate = rate; +return rate; +} + +static unsigned long mtk_hdmi_pll_recalc_rate (struct clk_hw *hw, + unsigned long
parent_rate)drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +20
-0+{ +struct mtk_hdmi_phy *hdmi_phy =to_mtk_hdmi_phy (hw); + +return hdmi_phy->pll_rate; +} + +static const struct clk_ops mtk_hdmi_pll_ops = { + .prepare = mtk_hdmi_pll_prepare, + .unprepare = mtk_hdmi_pll_unprepare, + .set_rate = mtk_hdmi_pll_set_rate, + .round_rate = mtk_hdmi_pll_round_rate, + .recalc_rate = mtk_hdmi_pll_recalc_rate, +}; + +static void vtx_signal_en (struct mtk_hdmi_phy *hdmi_phy,bool on) +{ +void __iomem *regs = hdmi_phy->regs; + +if (on) + mtk_phy_set_bits(regs + HDMI_1_CFG_0,
RG_HDMITX21_DRV_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +2
-0+else + mtk_phy_clear_bits(regs + HDMI_1_CFG_0,
RG_HDMITX21_DRV_EN);drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +14
-0+} + +static void mtk_hdmi_phy_enable_tmds (struct mtk_hdmi_phy *hdmi_phy) +{ +vtx_signal_en (hdmi_phy, true); +usleep_range (100 ,150 ); +} + +static void mtk_hdmi_phy_disable_tmds (struct mtk_hdmi_phy *hdmi_phy) +{ +vtx_signal_en (hdmi_phy, false); +} + +static int mtk_hdmi_phy_configure(struct phy *phy, union
phy_configure_opts*opts)drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 523
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +5
-0+{ +struct phy_configure_opts_dp *dp_opts = &opts->dp; +struct mtk_hdmi_phy *hdmi_phy =phy_get_drvdata (phy); +int ret =0 ; +bool enable =0 ;Seems no need local variable "enable"
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c line 528
Quoted 5 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +5
-0+ + ret =clk_set_rate (hdmi_phy->pll, dp_opts->link_rate); + +if (ret) + goto out;return ret directly?
Quoted 25 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c new file +18
-0+ +mtk_mt8195_phy_tmds_high_bit_clk_ratio (hdmi_phy, enable); + +out: +return ret; +} + +struct mtk_hdmi_phy_conf mtk_hdmi_phy_8195_conf = { + .flags =CLK_SET_RATE_PARENT |CLK_SET_RATE_GATE , + .hdmi_phy_clk_ops = &mtk_hdmi_pll_ops, + .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds, + .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds, + .hdmi_phy_configure = mtk_hdmi_phy_configure, +}; + +MODULE_AUTHOR ("Can Zeng <[email protected]>" ); +MODULE_DESCRIPTION ("MediaTek MT8195 HDMI PHY Driver" ); +MODULE_LICENSE ("GPL v2" );drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +0
-0drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h line 4
Quoted 4 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +4
-0@@ -0,0 +1,131 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2021 MediaTek Inc. +* Copyright (c) 2021 BayLibre, SAS 2022?
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h line 10
Quoted 6 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +6
-0+*/ + +#ifndef _MTK_HDMI_PHY_8195_H +#define _MTK_HDMI_PHY_8195_H + +#include <linux/types.h> move it after <
linux/clk-provider.h>?Quoted 89 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +89
-0+#include <linux/clk.h> +#include <linux/clk-provider.h> + +#define DA_HDMITXPLL_ISO_EN BIT(1) +#define DA_HDMITXPLL_PWR_ON BIT(2) + +#define HDMI20_CLK_CFG 0x70 + +#define HDMI_1_CFG_0 0x00 +#define HDMI_1_CFG_1 0x04 +#define HDMI_1_CFG_10 0x40 +#define HDMI_1_CFG_2 0x08 +#define HDMI_1_CFG_21 0x84 +#define HDMI_1_CFG_22 0x88 +#define HDMI_1_CFG_3 0x0c +#define HDMI_1_CFG_6 0x18 +#define HDMI_1_CFG_9 0x24 +#define HDMI_1_PLL_CFG_0 0x44 +#define HDMI_1_PLL_CFG_1 0x48 +#define HDMI_1_PLL_CFG_2 0x4c +#define HDMI_1_PLL_CFG_3 0x50 +#define HDMI_1_PLL_CFG_4 0x54 + +#define HDMI_ANA_CTL 0x7c + +#define HDMI_CTL_1 0xc4 +#define HDMI_CTL_3 0xcc + +#define REG_ANA_HDMI20_FIFO_EN BIT(16) + +#define REG_HDMITXPLL_DIV GENMASK(4, 0) +#define REG_HDMITX_PIXEL_CLOCK BIT(23) +#define REG_HDMITX_REF_RESPLL_SEL BIT(9) +#define REG_HDMITX_REF_XTAL_SEL BIT(7) + +#define REG_PIXEL_CLOCK_SEL BIT(10) + +#define REG_TXC_DIV GENMASK(31, 30) + +#define RG_HDMITX21_BG_PWD BIT(20) + +#define RG_HDMITX21_BIAS_EN BIT(29) +#define RG_HDMITX21_BIAS_PE_BG_VREF_SEL GENMASK(16, 15) +#define RG_HDMITX21_BIAS_PE_VREF_SELB BIT(10) + +#define RG_HDMITX21_CKLDO_EN BIT(3) + +#define RG_HDMITX21_CK_DRV_OP_EN BIT(11) + +#define RG_HDMITX21_D0_DRV_OP_EN BIT(10) + +#define RG_HDMITX21_D1_DRV_OP_EN BIT(9) + +#define RG_HDMITX21_D2_DRV_OP_EN BIT(8) + +#define RG_HDMITX21_DRV_EN GENMASK(27, 24) +#define RG_HDMITX21_DRV_IBIAS_CLK GENMASK(10, 5) +#define RG_HDMITX21_DRV_IBIAS_D0 GENMASK(19, 14) +#define RG_HDMITX21_DRV_IBIAS_D0_FFE1 GENMASK(21, 17) +#define RG_HDMITX21_DRV_IBIAS_D0_FFE2 GENMASK(23, 20) +#define RG_HDMITX21_DRV_IBIAS_D1 GENMASK(25, 20) +#define RG_HDMITX21_DRV_IBIAS_D1_FFE1 GENMASK(26, 22) +#define RG_HDMITX21_DRV_IBIAS_D1_FFE2 GENMASK(27, 24) +#define RG_HDMITX21_DRV_IBIAS_D2 GENMASK(31, 26) +#define RG_HDMITX21_DRV_IBIAS_D2_FFE1 GENMASK(31, 27) +#define RG_HDMITX21_DRV_IBIAS_D2_FFE2 GENMASK(31, 28) +#define RG_HDMITX21_DRV_IMP_CLK_EN1 GENMASK(31, 26) +#define RG_HDMITX21_DRV_IMP_D0_EN1 GENMASK(13, 8) +#define RG_HDMITX21_DRV_IMP_D1_EN1 GENMASK(19, 14) +#define RG_HDMITX21_DRV_IMP_D2_EN1 GENMASK(25, 20) +#define RG_HDMITX21_DRV_IMP_EN GENMASK(23, 20) + +#define RG_HDMITX21_FRL_CK_EN BIT(13) +#define RG_HDMITX21_FRL_D0_EN BIT(14) +#define RG_HDMITX21_FRL_D1_EN BIT(15) +#define RG_HDMITX21_FRL_D2_EN BIT(16) +#define RG_HDMITX21_FRL_EN BIT(12) + +#define RG_HDMITX21_INTR_CAL GENMASK(22, 18) +#define RG_HDMITX21_INTR_CAL_READOUT GENMASK(22, 18) + +#define RG_HDMITX21_SER_EN GENMASK(31, 28) + +#define RG_HDMITX21_SLDOLPF_EN BIT(7) +#define RG_HDMITX21_SLDO_EN GENMASK(11, 8) +#define RG_HDMITX21_SLDO_VREF_SEL GENMASK(5, 4) + +#define RG_HDMITX21_TX_POSDIV GENMASK(27, 26) +#define RG_HDMITX21_TX_POSDIV_EN BIT(28)drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h line 109
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +10
-0+ +#define RG_HDMITX21_VREF_SEL BIT(4) + +#define RG_HDMITXPLL_BC GENMASK(28, 27) +#define RG_HDMITXPLL_BP GENMASK(13, 10) +#define RG_HDMITXPLL_BP2 BIT(30) +#define RG_HDMITXPLL_BR GENMASK(21, 19) +#define RG_HDMITXPLL_DIV_CTRL GENMASK(25, 24) +#define RG_HDMITXPLL_FBKDIV_HIGH BIT(31) +#define RG_HDMITXPLL_FBKDIV_LOW (0xffffffff)make sure it includes bit 31? use
GENMASK()?Quoted 10 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +10
-0+#define RG_HDMITXPLL_HIKVCO BIT(29) +#define RG_HDMITXPLL_HREN GENMASK(13, 12) +#define RG_HDMITXPLL_IBAND_FIX_EN BIT(24) +#define RG_HDMITXPLL_IC GENMASK(26, 22) +#define RG_HDMITXPLL_IR GENMASK(18, 14) +#define RG_HDMITXPLL_LVR_SEL GENMASK(27, 26) +#define RG_HDMITXPLL_POSDIV GENMASK(23, 22) +#define RG_HDMITXPLL_POSDIV_DIV3_CTRL BIT(21) +#define RG_HDMITXPLL_PREDIV GENMASK(29, 28) +#define RG_HDMITXPLL_PWD BIT(31)drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h line 129
Quoted 10 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +10
-0+#define RG_HDMITXPLL_REF_CK_SEL GENMASK(2, 1) +#define RG_HDMITXPLL_RESERVE GENMASK(15, 0) +#define RG_HDMITXPLL_RESERVE_BIT12_11 GENMASK(12, 11) +#define RG_HDMITXPLL_RESERVE_BIT13 BIT(13) +#define RG_HDMITXPLL_RESERVE_BIT14 BIT(14) +#define RG_HDMITXPLL_RESERVE_BIT1_0 GENMASK(1, 0) +#define RG_HDMITXPLL_RESERVE_BIT3_2 GENMASK(3, 2) +#define RG_HDMITXPLL_TCL_EN BIT(31) + +#define RG_INTR_IMP_RG_MODE GENMASK(7, 3)It's difficult to distinguish the bits/mask which the register it belongs to.
Quoted 3 lines
Do you define it according to the bits sequence in register?
Thanks
Hi Chunfeng,
Thx for your review.
I don't have access to the mt8195 hdmi phy documentation sadly.
I'm basing my work on an old version of this driver submitted by mediatek for ChromeOs on a 5.10 kernel [1]
I can try to group the bit defines with their register in V3 by looking at the implementation.
Thx,
Guillaume.
[1] https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2781485/177
Quoted 34 lines
Quoted 33 lines
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h new file +2
-0+ +#endif /* MTK_HDMI_PHY_8195_H */ drivers/phy/mediatek/phy-mtk-hdmi.c +3
-0@@ -161,6 +161,9 @@ static const struct of_device_id mtk_hdmi_phy_match[] = { { .compatible ="mediatek,mt8173-hdmi-phy" , .data = &mtk_hdmi_phy_8173_conf, }, + { .compatible ="mediatek,mt8195-hdmi-phy" , + .data = &mtk_hdmi_phy_8195_conf, + }, {}, };
MODULE_DEVICE_TABLE(of, mtk_hdmi_phy_match);drivers/phy/mediatek/phy-mtk-hdmi.h +1
-0@@ -44,6 +44,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_8173_conf;extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf;
Re: [PATCH v2 02/12] dt-bindings: display: mediatek: add MT8195 hdmi bindings
In reply to Krzysztof KozlowskiQuoted 134 lines · Krzysztof Kozlowski
Quoted 14 lines · Guillaume Ranquet
Add mt8195 SoC bindings for hdmi and hdmi-ddc
Signed-off-by Guillaume Ranquet <[email protected]>--- .../bindings/display/mediatek/mediatek,hdmi.yaml | 67 +++++++++++++++++----- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 51 ++++++++++++++++ 2 files changed, 104 insertions(+), 14 deletions(-)Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +0
-0@@ -21,26 +21,21 @@ properties: - mediatek,mt7623-hdmiDocumentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml properties: · line 30
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +1
-3- mediatek,mt8167-hdmi - mediatek,mt8173-hdmi + - mediatek,mt8195-hdmi reg: maxItems: 1 - interrupts: - maxItems: 1 -This change is not really explained in commit msg...
Quoted 106 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +52
-11clocks: - items: - - description: Pixel Clock - - description: HDMI PLL - - description: Bit Clock - - description: S/PDIF Clock + minItems: 4 + maxItems: 4 clock-names: - items: - - const: pixel - - const: pll - - const: bclk - - const: spdif + minItems: 4 + maxItems: 4 + + interrupts: + maxItems: 1 phys: maxItems: 1@@ -58,6 +53,9 @@ properties: description: | phandle link and register offset to the system configuration registers. + power-domains: + maxItems: 1 + ports: $ref: /schemas/graph.yaml#/properties/ports@@ -86,9 +84,50 @@ required: - clock-names - phys - phy-names - - mediatek,syscon-hdmi - ports +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt8195-hdmi + then: + properties: + clocks: + items: + - description: APB + - description: HDCP + - description: HDCP 24M + - description: Split HDMI + clock-names: + items: + - const: hdmi_apb_sel + - const: hdcp_sel + - const: hdcp24_sel + - const: split_hdmi + + required: + - power-domains + else: + properties: + clocks: + items: + - description: Pixel Clock + - description: HDMI PLL + - description: Bit Clock + - description: S/PDIF Clock + + clock-names: + items: + - const: pixel + - const: pll + - const: bclk + - const: spdif + + required: + - mediatek,syscon-hdmi + additionalProperties: false examples:Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +15
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek HDMI DDC for mt8195 + +maintainers: + - CK Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + The HDMI DDC i2c controller is used to interface with the HDMI DDC pins. +
Quoted 8 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 19
Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +4
-0+properties: + compatible: + enum: + - mediatek,mt8195-hdmi-ddcI think I wrote it - you already have bindings for HDMI DDC. I doubt that these are different and it looks like you model the bindings according to your driver. That's not the way.
Hi Krzysztof,
I've made a separate binding as this new IP is integrated into the HDMI hw block.
The difference it makes is that the hw is slightly simpler to describe as the IP doesn't
have it's own range of registers or an interrupt line.
I can use the "legacy mediatek mtk ddc binding" if I modify it to have the reg and
interrupt properties not being required for mt8195.
Would that work better for you?
Quoted 30 lines
Quoted 16 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +15
-0+ + clocks: + maxItems: 1 + + clock-names: + items: + - const: ddc + + mediatek,hdmi: + $ref: /schemas/types.yaml#/definitions/phandle + description: + A phandle to the mt8195 hdmi controller + +required: + - compatibleDocumentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +10
-0+ - clocks + - clock-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + hdmiddc0: ddc_i2c {Node names should be generic - ddc.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
Quoted 4 lines
No underscores in node names.
Additionally I2C devices have addresses on the bus. Why this one doesn't?
This is an i2c adapter, not a device.
And as it lives inside the HDMI hw block, I've omitted using an address here.
Is this valid? or should this be expressed differently?
Thx,
Guillaume.
Quoted 12 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 51
Quoted 8 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +7
-0+ compatible = "mediatek,mt8195-hdmi-ddc"; + mediatek,hdmi = <&hdmi0>; + clocks = <&clk26m>; + clock-names = "ddc"; + }; + +...Best regards,
Krzysztof
Re: [PATCH v2 02/12] dt-bindings: display: mediatek: add MT8195 hdmi bindings
Quoted 153 lines · Guillaume Ranquet
Quoted 134 lines · Krzysztof Kozlowski
Quoted 14 lines · Guillaume Ranquet
Add mt8195 SoC bindings for hdmi and hdmi-ddc
Signed-off-by Guillaume Ranquet <[email protected]>--- .../bindings/display/mediatek/mediatek,hdmi.yaml | 67 +++++++++++++++++----- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 51 ++++++++++++++++ 2 files changed, 104 insertions(+), 14 deletions(-)Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +0
-0@@ -21,26 +21,21 @@ properties: - mediatek,mt7623-hdmiDocumentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml properties: · line 30
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +1
-3- mediatek,mt8167-hdmi - mediatek,mt8173-hdmi + - mediatek,mt8195-hdmi reg: maxItems: 1 - interrupts: - maxItems: 1 -This change is not really explained in commit msg...
Quoted 106 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +52
-11clocks: - items: - - description: Pixel Clock - - description: HDMI PLL - - description: Bit Clock - - description: S/PDIF Clock + minItems: 4 + maxItems: 4 clock-names: - items: - - const: pixel - - const: pll - - const: bclk - - const: spdif + minItems: 4 + maxItems: 4 + + interrupts: + maxItems: 1 phys: maxItems: 1@@ -58,6 +53,9 @@ properties: description: | phandle link and register offset to the system configuration registers. + power-domains: + maxItems: 1 + ports: $ref: /schemas/graph.yaml#/properties/ports@@ -86,9 +84,50 @@ required: - clock-names - phys - phy-names - - mediatek,syscon-hdmi - ports +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt8195-hdmi + then: + properties: + clocks: + items: + - description: APB + - description: HDCP + - description: HDCP 24M + - description: Split HDMI + clock-names: + items: + - const: hdmi_apb_sel + - const: hdcp_sel + - const: hdcp24_sel + - const: split_hdmi + + required: + - power-domains + else: + properties: + clocks: + items: + - description: Pixel Clock + - description: HDMI PLL + - description: Bit Clock + - description: S/PDIF Clock + + clock-names: + items: + - const: pixel + - const: pll + - const: bclk + - const: spdif + + required: + - mediatek,syscon-hdmi + additionalProperties: false examples:Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +15
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek HDMI DDC for mt8195 + +maintainers: + - CK Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + The HDMI DDC i2c controller is used to interface with the HDMI DDC pins. +Quoted 8 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 19
Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +4
-0+properties: + compatible: + enum: + - mediatek,mt8195-hdmi-ddcI think I wrote it - you already have bindings for HDMI DDC. I doubt that these are different and it looks like you model the bindings according to your driver. That's not the way.
Hi Krzysztof,
I've made a separate binding as this new IP is integrated into the HDMI hw block.
The difference it makes is that the hw is slightly simpler to describe as the IP doesn't
have it's own range of registers or an interrupt line.
Quoted 3 lines
I can use the "legacy mediatek mtk ddc binding" if I modify it to have the reg and
interrupt properties not being required for mt8195.
OK, it is reasonable - such stuff should be in commit msg, so we won't keep asking.
Quoted 35 lines
Would that work better for you?
Quoted 32 lines
Quoted 16 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +15
-0+ + clocks: + maxItems: 1 + + clock-names: + items: + - const: ddc + + mediatek,hdmi: + $ref: /schemas/types.yaml#/definitions/phandle + description: + A phandle to the mt8195 hdmi controller + +required: + - compatibleDocumentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +10
-0+ - clocks + - clock-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + hdmiddc0: ddc_i2c {Node names should be generic - ddc.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendationNo underscores in node names.
Quoted 7 lines
Quoted 2 lines
Additionally I2C devices have addresses on the bus. Why this one doesn't?
This is an i2c adapter, not a device.
And as it lives inside the HDMI hw block, I've omitted using an address here.Is this valid? or should this be expressed differently?
What is an I2C adapter? Did you mean I2C controller (master)?
Best regards,
Krzysztof
Re: [PATCH v2 02/12] dt-bindings: display: mediatek: add MT8195 hdmi bindings
Quoted 154 lines · Krzysztof Kozlowski
Quoted 153 lines · Guillaume Ranquet
Quoted 134 lines · Krzysztof Kozlowski
Quoted 14 lines · Guillaume Ranquet
Add mt8195 SoC bindings for hdmi and hdmi-ddc
Signed-off-by Guillaume Ranquet <[email protected]>--- .../bindings/display/mediatek/mediatek,hdmi.yaml | 67 +++++++++++++++++----- .../display/mediatek/mediatek,mt8195-hdmi-ddc.yaml | 51 ++++++++++++++++ 2 files changed, 104 insertions(+), 14 deletions(-)Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +0
-0@@ -21,26 +21,21 @@ properties: - mediatek,mt7623-hdmiDocumentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml properties: · line 30
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +1
-3- mediatek,mt8167-hdmi - mediatek,mt8173-hdmi + - mediatek,mt8195-hdmi reg: maxItems: 1 - interrupts: - maxItems: 1 -This change is not really explained in commit msg...
Quoted 106 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.yaml +52
-11clocks: - items: - - description: Pixel Clock - - description: HDMI PLL - - description: Bit Clock - - description: S/PDIF Clock + minItems: 4 + maxItems: 4 clock-names: - items: - - const: pixel - - const: pll - - const: bclk - - const: spdif + minItems: 4 + maxItems: 4 + + interrupts: + maxItems: 1 phys: maxItems: 1@@ -58,6 +53,9 @@ properties: description: | phandle link and register offset to the system configuration registers. + power-domains: + maxItems: 1 + ports: $ref: /schemas/graph.yaml#/properties/ports@@ -86,9 +84,50 @@ required: - clock-names - phys - phy-names - - mediatek,syscon-hdmi - ports +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt8195-hdmi + then: + properties: + clocks: + items: + - description: APB + - description: HDCP + - description: HDCP 24M + - description: Split HDMI + clock-names: + items: + - const: hdmi_apb_sel + - const: hdcp_sel + - const: hdcp24_sel + - const: split_hdmi + + required: + - power-domains + else: + properties: + clocks: + items: + - description: Pixel Clock + - description: HDMI PLL + - description: Bit Clock + - description: S/PDIF Clock + + clock-names: + items: + - const: pixel + - const: pll + - const: bclk + - const: spdif + + required: + - mediatek,syscon-hdmi + additionalProperties: false examples:Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +15
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek HDMI DDC for mt8195 + +maintainers: + - CK Hu <[email protected]> + - Jitao shi <[email protected]> + +description: | + The HDMI DDC i2c controller is used to interface with the HDMI DDC pins. +Quoted 8 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 19
Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +4
-0+properties: + compatible: + enum: + - mediatek,mt8195-hdmi-ddcI think I wrote it - you already have bindings for HDMI DDC. I doubt that these are different and it looks like you model the bindings according to your driver. That's not the way.
Hi Krzysztof,
I've made a separate binding as this new IP is integrated into the HDMI hw block.
The difference it makes is that the hw is slightly simpler to describe as the IP doesn't
have it's own range of registers or an interrupt line.
Quoted 7 lines
Quoted 3 lines
I can use the "legacy mediatek mtk ddc binding" if I modify it to have the reg and
interrupt properties not being required for mt8195.OK, it is reasonable - such stuff should be in commit msg, so we won't keep asking.
I'll sum this up in the commit msg for V3 then.
Quoted 38 lines
Quoted 38 lines
Would that work better for you?
Quoted 34 lines
Quoted 16 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +15
-0+ + clocks: + maxItems: 1 + + clock-names: + items: + - const: ddc + + mediatek,hdmi: + $ref: /schemas/types.yaml#/definitions/phandle + description: + A phandle to the mt8195 hdmi controller + +required: + - compatibleDocumentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mt8195-hdmi-ddc.yaml new file +10
-0+ - clocks + - clock-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + hdmiddc0: ddc_i2c {Node names should be generic - ddc.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendationNo underscores in node names.
Additionally I2C devices have addresses on the bus. Why this one doesn't?
Quoted 6 lines
Quoted 4 lines
This is an i2c adapter, not a device.
And as it lives inside the HDMI hw block, I've omitted using an address here.Is this valid? or should this be expressed differently?
What is an I2C adapter? Did you mean I2C controller (master)?
Yes, a controller.
This is an I2C controller connected to the HDMI connector, it is used to exchange data on the Display Data Channel with
the display (such as EDID).
Thx,
Guillaume.
Quoted 4 lines
Best regards,
Krzysztof
Re: [PATCH v2 02/12] dt-bindings: display: mediatek: add MT8195 hdmi bindings
Quoted 4 lines · Guillaume Ranquet
On Thu, 03 Nov 2022 13:45, Krzysztof Kozlowski
Quoted 3 lines
Quoted 3 lines
This is an i2c adapter, not a device.
And as it lives inside the HDMI hw block, I've omitted using an address here.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Is this valid? or should this be expressed differently?
What is an I2C adapter? Did you mean I2C controller (master)?
Yes, a controller.
This is an I2C controller connected to the HDMI connector, it is used to exchange data on the Display Data Channel with
the display (such as EDID).
OK, then the node name is "i2c".
Best regards,
Krzysztof