Initial support Cadence MHDP8501(HDMI/DP) for i.MX8MQ
Subsystems (6)
v12 cover Initial support Cadence MHDP8501(HDMI/DP) for i.MX8MQ
The patch set initial support Cadence MHDP8501(HDMI/DP) DRM bridge driver and Cadence HDP-TX PHY(HDMI/DP) drivers for Freescale i.MX8MQ.
The patch set compose of DRM bridge drivers and PHY drivers.
Both of them need patch #1 and #2 to pass build.
DRM bridges driver patches:
#1: drm: bridge: Cadence: Creat mhdp helper driver #2: phy: Add HDMI configuration options
#3: dt-bindings: display: bridge: Add Cadence MHDP8501 #4: drm: bridge: Cadence: Add MHDP8501 DP/HDMI driver
PHY driver patches:
#1: drm: bridge: Cadence: Creat mhdp helper driver #2: phy: Add HDMI configuration options
#5: dt-bindings: phy: Add Freescale iMX8MQ DP and HDMI PHY #6: phy: freescale: Add DisplayPort PHY driver for i.MX8MQ #7: phy: freescale: Add HDMI PHY driver for i.MX8MQ
v11->v12:
Patch #1:
- Move status initialize out of mbox_mutex.
- Reorder API functions in alphabetical.
- Add notes for malibox access functions.
- Add year 2024 to copyright.
Patch #4:
- Replace DRM_INFO with dev_info or dev_warn.
- Replace DRM_ERROR with dev_err.
- Return ret when cdns_mhdp_dpcd_read failed in function cdns_dp_aux_transferi().
- Remove unused parmeter in function cdns_dp_get_msa_misc
and use two separate variables for color space and bpc.
- Add year 2024 to copyright.
Patch #6:
- Return error code to replace -1 for function wait_for_ack().
- Set cdns_phy->power_up = false in phy_power_down function.
- Remove "RATE_8_1 = 810000", it is not used in driver.
- Add year 2024 to copyright.
Patch #7:
- Adjust clk disable order.
- Return error code to replace -1 for function wait_for_ack().
- Use bool for variable pclk_in.
- Add year 2024 to copyright.
v10->v11:
- rewrite cdns_mhdp_set_firmware_active() in mhdp8546 core driver, use cdns_mhdp_mailbox_send() to replace cdns_mhdp_mailbox_write() same as the other mailbox access functions.
- use static for cdns_mhdp_mailbox_write() and cdns_mhdp_mailbox_read() and remove them from EXPORT_SYMBOL_GPL().
- remove MODULE_ALIAS() from mhdp8501 driver.
v9->v10:
- Create mhdp helper driver to replace macro functions, move all mhdp mailbox access functions and common functions into the helper driver.
Patch #1:drm: bridge: Cadence: Creat mhdp helper driver it is totaly different with v9.
v8->v9:
- Remove compatible string "cdns,mhdp8501" that had removed from dt-bindings file in v8.
- Add Dmitry's R-b tag to patch #2
- Add Krzysztof's R-b tag to patch #3
v7->v8:
MHDP8501 HDMI/DP:
- Correct DT node name to "display-bridge".
- Remove "cdns,mhdp8501" from mhdp8501 dt-binding doc.
HDMI/DP PHY:
- Introduced functions wait_for_ack and wait_for_ack_clear to handle waiting with acknowledgment bits set and cleared respectively.
- Use FIELD_PRE() to set bitfields for both HDMI and DP PHY.
v6->v7:
MHDP8501 HDMI/DP:
- Combine HDMI and DP driver into one mhdp8501 driver. Use the connector type to load the corresponding functions.
- Remove connector init functions.
- Add <linux/hdmi.h> in phy_hdmi.h to reuse ‘enum hdmi_colorspace’.
HDMI/DP PHY:
- Lowercase hex values
- Fix parameters indent issue on some functions
- Replace ‘udelay’ with ‘usleep_range’
v5->v6:
HDMI/DP bridge driver
- 8501 is the part number of Cadence MHDP on i.MX8MQ.
Use MHDP8501 to name hdmi/dp drivers and files.
- Add compatible "fsl,imx8mq-mhdp8501-dp" for i.MX8MQ DP driver
- Add compatible "fsl,imx8mq-mhdp8501-hdmi" for i.MX8MQ HDMI driver
- Combine HDMI and DP dt-bindings into one file cdns,mhdp8501.yaml
- Fix HDMI scrambling is not enable issue when driver working in 4Kp60 mode.
- Add HDMI/DP PHY API mailbox protect.
HDMI/DP PHY driver:
- Rename DP and HDMI PHY files and move to folder phy/freescale/
- Remove properties num_lanes and link_rate from DP PHY driver.
- Combine HDMI and DP dt-bindings into one file fsl,imx8mq-dp-hdmi-phy.yaml
- Update compatible string to "fsl,imx8mq-dp-phy".
- Update compatible string to "fsl,imx8mq-hdmi-phy".
v4->v5:
- Drop "clk" suffix in clock name.
- Add output port property in the example of hdmi/dp.
v3->v4:
dt-bindings:
- Correct dt-bindings coding style and address review comments.
- Add apb_clk description.
- Add output port for HDMI/DP connector
PHY:
- Alphabetically sorted in Kconfig and Makefile for DP and HDMI PHY
- Remove unused registers define from HDMI and DP PHY drivers.
- More description in phy_hdmi.h.
- Add apb_clk to HDMI and DP phy driver.
HDMI/DP:
- Use get_unaligned_le32() to replace hardcode type conversion in HDMI AVI infoframe data fill function.
- Add mailbox mutex lock in HDMI/DP driver for phy functions to reslove race conditions between HDMI/DP and PHY drivers.
- Add apb_clk to both HDMI and DP driver.
- Rename some function names and add prefix with "cdns_hdmi/cdns_dp".
- Remove bpc 12 and 16 optional that not supported.
v2->v3:
Address comments for dt-bindings files.
- Correct dts-bindings file names
Rename phy-cadence-hdptx-dp.yaml to cdns,mhdp-imx8mq-dp.yaml Rename phy-cadence-hdptx-hdmi.yaml to cdns,mhdp-imx8mq-hdmi.yaml
- Drop redundant words and descriptions.
- Correct hdmi/dp node name.
v2 is a completely different version compared to v1. Previous v1 can be available here [1].
v1->v2:
- Reuse Cadence mailbox access functions from mhdp8546 instead of rockchip DP.
- Mailbox access functions be convert to marco functions that will be referenced by HDP-TX PHY(HDMI/DP) driver too.
- Plain bridge instead of component driver.
- Standalone Cadence HDP-TX PHY(HDMI/DP) driver.
- Audio driver are removed from the patch set, it will be add in another patch set later.
[1] https://patchwork.kernel.org/project/linux-rockchip/cover/[email protected]/
Sandor Yu (7):
drm: bridge: Cadence: Create mhdp helper driver
phy: Add HDMI configuration options
dt-bindings: display: bridge: Add Cadence MHDP8501
drm: bridge: Cadence: Add MHDP8501 DP/HDMI driver
dt-bindings: phy: Add Freescale iMX8MQ DP and HDMI PHY
phy: freescale: Add DisplayPort PHY driver for i.MX8MQ
phy: freescale: Add HDMI PHY driver for i.MX8MQ
.../display/bridge/cdns,mhdp8501.yaml | 104 ++ .../bindings/phy/fsl,imx8mq-dp-hdmi-phy.yaml | 53 + drivers/gpu/drm/bridge/cadence/Kconfig | 20 + drivers/gpu/drm/bridge/cadence/Makefile | 3 + .../gpu/drm/bridge/cadence/cdns-mhdp-helper.c | 304 ++++++ .../drm/bridge/cadence/cdns-mhdp8501-core.c | 315 ++++++ .../drm/bridge/cadence/cdns-mhdp8501-core.h | 365 +++++++ .../gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c | 699 +++++++++++++ .../drm/bridge/cadence/cdns-mhdp8501-hdmi.c | 678 +++++++++++++ .../drm/bridge/cadence/cdns-mhdp8546-core.c | 403 ++------ .../drm/bridge/cadence/cdns-mhdp8546-core.h | 44 +- drivers/phy/freescale/Kconfig | 20 + drivers/phy/freescale/Makefile | 2 + drivers/phy/freescale/phy-fsl-imx8mq-dp.c | 726 +++++++++++++ drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c | 959 ++++++++++++++++++ include/drm/bridge/cdns-mhdp-helper.h | 97 ++ include/linux/phy/phy-hdmi.h | 24 + include/linux/phy/phy.h | 7 +- 18 files changed, 4448 insertions(+), 375 deletions(-) create mode 100644 Documentation/devicetree/bindings/display/bridge/cdns,mhdp8501.yaml create mode 100644 Documentation/devicetree/bindings/phy/fsl,imx8mq-dp-hdmi-phy.yaml create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.h create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c create mode 100644 drivers/phy/freescale/phy-fsl-imx8mq-dp.c create mode 100644 drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c create mode 100644 include/drm/bridge/cdns-mhdp-helper.h create mode 100644 include/linux/phy/phy-hdmi.h
Signature · 1 line
2.34.1
PATCH v12 1/7 drm: bridge: Cadence: Create mhdp helper driver
MHDP8546 mailbox access functions will be share to other mhdp driver and Cadence HDP-TX HDMI/DP PHY drivers.
Create a new mhdp helper driver and move all those functions into.
cdns_mhdp_reg_write() is renamed to cdns_mhdp_dp_reg_write(), because it use the DPTX command ID DPTX_WRITE_REGISTER.
New cdns_mhdp_reg_write() is created with the general command ID GENERAL_REGISTER_WRITE.
rewrite cdns_mhdp_set_firmware_active() in mhdp8546 core driver, use cdns_mhdp_mailbox_send() to replace cdns_mhdp_mailbox_write() same as the other mailbox access functions.
---v11->v12:
- Move status initialize out of mbox_mutex.
- Reorder API functions in alphabetical.
- Add notes for malibox access functions.
- Add year 2024 to copyright.
drivers/gpu/drm/bridge/cadence/Kconfig | 4 + drivers/gpu/drm/bridge/cadence/Makefile | 1 + .../gpu/drm/bridge/cadence/cdns-mhdp-helper.c | 304 +++++++++++++ .../drm/bridge/cadence/cdns-mhdp8546-core.c | 403 +++--------------- .../drm/bridge/cadence/cdns-mhdp8546-core.h | 44 +- include/drm/bridge/cdns-mhdp-helper.h | 97 +++++ 6 files changed, 479 insertions(+), 374 deletions(-) create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c create mode 100644 include/drm/bridge/cdns-mhdp-helper.h
drivers/gpu/drm/bridge/cadence/Kconfig +4 -0
@@ -21,6 +21,9 @@ config DRM_CDNS_DSI_J721E the routing of the DSS DPI signal to the Cadence DSI. endif +config CDNS_MHDP_HELPER + tristate + config DRM_CDNS_MHDP8546 tristate "Cadence DPI/DP bridge" select DRM_DISPLAY_DP_HELPER
@@ -28,6 +31,7 @@ config DRM_CDNS_MHDP8546 select DRM_DISPLAY_HELPER select DRM_KMS_HELPER select DRM_PANEL_BRIDGE + select CDNS_MHDP_HELPER depends on OF help Support Cadence DPI to DP bridge. This is an internal
drivers/gpu/drm/bridge/cadence/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o cdns-dsi-y := cdns-dsi-core.o cdns-dsi-$(CONFIG_DRM_CDNS_DSI_J721E) += cdns-dsi-j721e.o +obj-$(CONFIG_CDNS_MHDP_HELPER) += cdns-mhdp-helper.o obj-$(CONFIG_DRM_CDNS_MHDP8546) += cdns-mhdp8546.o cdns-mhdp8546-y := cdns-mhdp8546-core.o cdns-mhdp8546-hdcp.o cdns-mhdp8546-$(CONFIG_DRM_CDNS_MHDP8546_J721E) += cdns-mhdp8546-j721e.o
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +304 -0
304 lines not on this page · raw message
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +69 -334
670 lines not on this page · raw message
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h +4 -40
71 lines not on this page · raw message
include/drm/bridge/cdns-mhdp-helper.h new file +97 -0
97 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v12 2/7 phy: Add HDMI configuration options
In reply to Sandor YuAllow HDMI PHYs to be configured through the generic functions through a custom structure added to the generic union.
The parameters added here are based on HDMI PHY implementation practices. The current set of parameters should cover the potential users.
---v9->v12:
*No change.
include/linux/phy/phy-hdmi.h | 24 ++++++++++++++++++++++++ include/linux/phy/phy.h | 7 ++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 include/linux/phy/phy-hdmi.h
include/linux/phy/phy-hdmi.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright 2022 NXP +*/ + +#ifndef __PHY_HDMI_H_ +#define __PHY_HDMI_H_ + +#include <linux/hdmi.h> +/** +* struct phy_configure_opts_hdmi - HDMI configuration set +* @pixel_clk_rate: Pixel clock of video modes in KHz. +* @bpc: Maximum bits per color channel. +* @color_space: Colorspace in enum hdmi_colorspace. +* +* This structure is used to represent the configuration state of a HDMI phy. +*/ +struct phy_configure_opts_hdmi { +unsigned int pixel_clk_rate; +unsigned int bpc; +enum hdmi_colorspace color_space; +}; + +#endif /* __PHY_HDMI_H_ */
include/linux/phy/phy.h +6 -1
@@ -17,6 +17,7 @@#include <linux/regulator/consumer.h> #include <linux/phy/phy-dp.h> +#include <linux/phy/phy-hdmi.h> #include <linux/phy/phy-lvds.h> #include <linux/phy/phy-mipi-dphy.h>
@@ -42,7 +43,8 @@ enum phy_mode {PHY_MODE_MIPI_DPHY ,PHY_MODE_SATA ,PHY_MODE_LVDS , -PHY_MODE_DP +PHY_MODE_DP , + PHY_MODE_HDMI, }; enum phy_media {
@@ -60,11 +62,14 @@ enum phy_media {* the DisplayPort protocol. * @lvds: Configuration set applicable for phys supporting * the LVDS phy mode. +* @hdmi: Configuration set applicable for phys supporting +* the HDMI phy mode. */ union phy_configure_opts {struct phy_configure_opts_mipi_dphy mipi_dphy;struct phy_configure_opts_dp dp;struct phy_configure_opts_lvds lvds; +struct phy_configure_opts_hdmi hdmi; };/**
Signature · 1 line
2.34.1
PATCH v12 3/7 dt-bindings: display: bridge: Add Cadence MHDP8501
In reply to Sandor YuAdd bindings for Cadence MHDP8501 DisplayPort/HDMI bridge.
---v9->v12:
*No change.
.../display/bridge/cdns,mhdp8501.yaml | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/bridge/cdns,mhdp8501.yaml
Documentation/devicetree/bindings/display/bridge/cdns,mhdp8501.yaml new file +104 -0
@@ -0,0 +1,104 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/bridge/cdns,mhdp8501.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cadence MHDP8501 DP/HDMI bridge + +maintainers: + - Sandor Yu <[email protected]> + +description: + Cadence MHDP8501 DisplayPort/HDMI interface. + +properties: + compatible: + enum: + - fsl,imx8mq-mhdp8501 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + description: MHDP8501 DP/HDMI APB clock. + + phys: + maxItems: 1 + description: + phandle to the DisplayPort or HDMI PHY + + interrupts: + items: + - description: Hotplug cable plugin. + - description: Hotplug cable plugout. + + interrupt-names: + items: + - const: plug_in + - const: plug_out + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Input port from display controller output. + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: + Output port to DisplayPort or HDMI connector. + + required: + - port@0 + - port@1 + +required: + - compatible + - reg + - clocks + - interrupts + - interrupt-names + - phys + - ports + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/imx8mq-clock.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + + mhdp: display-bridge@32c00000 { + compatible = "fsl,imx8mq-mhdp8501"; + reg = <0x32c00000 0x100000>; + interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "plug_in", "plug_out"; + clocks = <&clk IMX8MQ_CLK_DISP_APB_ROOT>; + phys = <&dp_phy>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + mhdp_in: endpoint { + remote-endpoint = <&dcss_out>; + }; + }; + + port@1 { + reg = <1>; + + mhdp_out: endpoint { + remote-endpoint = <&dp_connector>; + }; + }; + }; + };
Signature · 1 line
2.34.1
PATCH v12 4/7 drm: bridge: Cadence: Add MHDP8501 DP/HDMI driver
In reply to Sandor YuAdd a new DRM DisplayPort and HDMI bridge driver for Candence MHDP8501 used in i.MX8MQ SOC. MHDP8501 could support HDMI or DisplayPort standards according embedded Firmware running in the uCPU.
For iMX8MQ SOC, the DisplayPort/HDMI FW was loaded and activated by SOC's ROM code. Bootload binary included respective specific firmware is required.
Driver will check display connector type and
then load the corresponding driver.
---v11->v12:
- Replace DRM_INFO with dev_info or dev_warn.
- Replace DRM_ERROR with dev_err.
- Return ret when cdns_mhdp_dpcd_read failed in function cdns_dp_aux_transferi().
- Remove unused parmeter in function cdns_dp_get_msa_misc
and use two separate variables for color space and bpc.
- Add year 2024 to copyright.
drivers/gpu/drm/bridge/cadence/Kconfig | 16 + drivers/gpu/drm/bridge/cadence/Makefile | 2 + .../drm/bridge/cadence/cdns-mhdp8501-core.c | 315 ++++++++ .../drm/bridge/cadence/cdns-mhdp8501-core.h | 365 +++++++++ .../gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c | 699 ++++++++++++++++++ .../drm/bridge/cadence/cdns-mhdp8501-hdmi.c | 678 +++++++++++++++++ 6 files changed, 2075 insertions(+) create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.h create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
drivers/gpu/drm/bridge/cadence/Kconfig +16 -0
@@ -51,3 +51,19 @@ config DRM_CDNS_MHDP8546_J721E initializes the J721E Display Port and sets up the clock and data muxes. endif + +config DRM_CDNS_MHDP8501 + tristate "Cadence MHDP8501 DP/HDMI bridge" + select DRM_KMS_HELPER + select DRM_PANEL_BRIDGE + select DRM_DISPLAY_DP_HELPER + select DRM_DISPLAY_HELPER + select CDNS_MHDP_HELPER + select DRM_CDNS_AUDIO + depends on OF + help + Support Cadence MHDP8501 DisplayPort/HDMI bridge. + Cadence MHDP8501 support one or more protocols, + including DisplayPort and HDMI. + To use the DP and HDMI drivers, their respective + specific firmware is required.
drivers/gpu/drm/bridge/cadence/Makefile +2 -0
@@ -6,3 +6,5 @@ obj-$(CONFIG_CDNS_MHDP_HELPER) += cdns-mhdp-helper.o obj-$(CONFIG_DRM_CDNS_MHDP8546) += cdns-mhdp8546.o cdns-mhdp8546-y := cdns-mhdp8546-core.o cdns-mhdp8546-hdcp.o cdns-mhdp8546-$(CONFIG_DRM_CDNS_MHDP8546_J721E) += cdns-mhdp8546-j721e.o +obj-$(CONFIG_DRM_CDNS_MHDP8501) += cdns-mhdp8501.o +cdns-mhdp8501-y := cdns-mhdp8501-core.o cdns-mhdp8501-dp.o cdns-mhdp8501-hdmi.o
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +315 -0
315 lines not on this page · raw message
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.h new file +365 -0
365 lines not on this page · raw message
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +699 -0
699 lines not on this page · raw message
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +678 -0
678 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v12 4/7] drm: bridge: Cadence: Add MHDP8501 DP/HDMI driver
Hi Sandor,
thanks for the update.
Am Mittwoch, 10. Januar 2024, 02:08:45 CET schrieb Sandor Yu:
Quoted 81 lines
Add a new DRM DisplayPort and HDMI bridge driver for Candence MHDP8501 used in i.MX8MQ SOC. MHDP8501 could support HDMI or DisplayPort standards according embedded Firmware running in the uCPU.
For iMX8MQ SOC, the DisplayPort/HDMI FW was loaded and activated by SOC's ROM code. Bootload binary included respective specific firmware is required.
Driver will check display connector type and
then load the corresponding driver.Signed-off-by Sandor Yu <[email protected]>Tested-by Alexander Stein <[email protected]>---
v11->v12:
- ReplaceDRM_INFOwithdev_infoordev_warn.
- ReplaceDRM_ERRORwithdev_err.
- Return ret whencdns_mhdp_dpcd_readfailed in functioncdns_dp_aux_transferi(). - Remove unused parmeter in functioncdns_dp_get_msa_misc
and use two separate variables for color space and bpc.
- Add year 2024 to copyright.drivers/gpu/drm/bridge/cadence/Kconfig | 16 + drivers/gpu/drm/bridge/cadence/Makefile | 2 + .../drm/bridge/cadence/cdns-mhdp8501-core.c | 315 ++++++++ .../drm/bridge/cadence/cdns-mhdp8501-core.h | 365 +++++++++ .../gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c | 699 ++++++++++++++++++ .../drm/bridge/cadence/cdns-mhdp8501-hdmi.c | 678 +++++++++++++++++ 6 files changed, 2075 insertions(+) create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.h create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c(quoted diff) +0
-0b/drivers/gpu/drm/bridge/cadence/Kconfig index
e0973339e9e33..45848e741f5f4100644drivers/gpu/drm/bridge/cadence/Kconfig +16
-0@@ -51,3 +51,19 @@ config DRM_CDNS_MHDP8546_J721E initializes the J721E Display Port and sets up the clock and data muxes. endif + +config DRM_CDNS_MHDP8501 + tristate "Cadence MHDP8501 DP/HDMI bridge" + select DRM_KMS_HELPER + select DRM_PANEL_BRIDGE + select DRM_DISPLAY_DP_HELPER + select DRM_DISPLAY_HELPER + select CDNS_MHDP_HELPER + select DRM_CDNS_AUDIO + depends on OF + help + Support Cadence MHDP8501 DisplayPort/HDMI bridge. + Cadence MHDP8501 support one or more protocols, + including DisplayPort and HDMI. + To use the DP and HDMI drivers, their respective + specific firmware is required.(quoted diff) +0
-0b/drivers/gpu/drm/bridge/cadence/Makefile index
087dc074820d7..02c1a9f3cf6fc100644drivers/gpu/drm/bridge/cadence/Makefile +2
-0@@ -6,3 +6,5 @@ obj-$(CONFIG_CDNS_MHDP_HELPER) += cdns-mhdp-helper.o obj-$(CONFIG_DRM_CDNS_MHDP8546) += cdns-mhdp8546.o cdns-mhdp8546-y := cdns-mhdp8546-core.o cdns-mhdp8546-hdcp.o cdns-mhdp8546-$(CONFIG_DRM_CDNS_MHDP8546_J721E) += cdns-mhdp8546-j721e.o +obj-$(CONFIG_DRM_CDNS_MHDP8501) += cdns-mhdp8501.o +cdns-mhdp8501-y := cdns-mhdp8501-core.o cdns-mhdp8501-dp.ocdns-mhdp8501-hdmi.o diff --git
a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.cb/drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.cnew file mode 100644 index 0000000000000..3080c7507a012drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +3
-0@@ -0,0 +1,315 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Cadence Display Port Interface (DP) driver
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c line 13
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +10
-0+* +* Copyright (C) 2023, 2024 NXP Semiconductor, Inc. +* +*/ +#include <drm/drm_of.h> +#include <drm/drm_print.h> +#include <linux/clk.h> +#include <linux/irq.h> +#include <linux/mutex.h> +#include <linux/of_device.h>
Since commit d57d584ef69de ("of: Stop circularly including of_device.h and of_platform.h") you to explicitly include linux/platform_device.h here. Please compile against next tree.
Quoted 24 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +4
-0+#include <linux/phy/phy.h> + +#include "cdns-mhdp8501-core.h" +(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.cnew file mode 100644 index 0000000000000..6963c7143a3b0drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +13
-0@@ -0,0 +1,699 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Cadence MHDP8501 DisplayPort(DP) bridge driver +* +* Copyright (C) 2019-2024 NXP Semiconductor, Inc. +* +*/ +#include <drm/drm_atomic_helper.h> +#include <drm/drm_edid.h> +#include <drm/drm_print.h> +#include <linux/phy/phy.h> +#include <linux/phy/phy-dp.h> +
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c line 23
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +10
-0+#include "cdns-mhdp8501-core.h" + +#define LINK_TRAINING_TIMEOUT_MS 500 +#define LINK_TRAINING_RETRY_MS 20 + +ssize_t cdns_dp_aux_transfer (struct drm_dp_aux *aux, +struct drm_dp_aux_msg *msg) +{ +struct cdns_mhdp8501_device *mhdp =dev_get_drvdata (aux->dev); + bool native = msg->request & (DP_AUX_NATIVE_WRITE &
DP_AUX_NATIVE_READ);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 11 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +11
-0+int ret; + +/* Ignore address only message */ +if (!msg->size || !msg->buffer) { + msg->reply = native ? +DP_AUX_NATIVE_REPLY_ACK :DP_AUX_I2C_REPLY_ACK ; +return msg->size; + } + +if (!native) { + dev_err(mhdp->dev, "%s: only native messages supported\n",
__func__);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +6
-0+return -EINVAL ; + } + +/* msg sanity check */ +if (msg->size >DP_AUX_MAX_PAYLOAD_BYTES ) { + dev_err(mhdp->dev, "%s: invalid msg: size(%zu),
request(%x)\n",
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 12 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +1
-0+ __func__, msg->size, (unsigned int)msg-request);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +10
-0+return -EINVAL ; + } + +if (msg->request ==DP_AUX_NATIVE_WRITE ) { +const u8 *buf = msg->buffer; +int i; + +for (i =0 ; i < msg->size; ++i) { + ret = cdns_mhdp_dpcd_write(&mhdp->base, + msg->address +
i, buf[i]);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 2 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +2
-0+if (ret <0 ) { + dev_err(mhdp->dev, "Failed to write
DPCD\n");
Quoted 58 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +58
-0+return ret; + } + } + msg->reply =DP_AUX_NATIVE_REPLY_ACK ; +return msg->size; + } + +if (msg->request ==DP_AUX_NATIVE_READ ) { + ret =cdns_mhdp_dpcd_read (&mhdp->base, msg->address, + msg->buffer, msg->size); +if (ret <0 ) +return ret; + msg->reply =DP_AUX_NATIVE_REPLY_ACK ; +return msg->size; + } +return 0 ; +} + +int cdns_dp_aux_destroy (struct cdns_mhdp8501_device *mhdp) +{ +drm_dp_aux_unregister (&mhdp->dp.aux); + +return 0 ; +} + +static int cdns_dp_get_msa_misc (struct video_info *video) +{ +u32 msa_misc; +u8 color_space =0 ; +u8 bpc =0 ; + +switch (video->color_fmt) { +/* set YUV default color space conversion to BT601 */ +case DRM_COLOR_FORMAT_YCBCR444 : + color_space =6 +BT_601 *8 ; +break ; +case DRM_COLOR_FORMAT_YCBCR422 : + color_space =5 +BT_601 *8 ; +break ; +case DRM_COLOR_FORMAT_YCBCR420 : + color_space =5 ; +break ; +case DRM_COLOR_FORMAT_RGB444 : +default : + color_space =0 ; +break ; + }; + +switch (video->bpc) { +case 6 : + bpc =0 ; +break ; +case 10 : + bpc =2 ; +break ; +case 12 : + bpc =3 ; +break ;
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c line 121
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +10
-0+case 16 : + bpc =4 ; +break ; +case 8 : +default : + bpc =1 ; +break ; + }; + + msa_misc = (color_space <<1 ) | (bpc <<5 );
This looks much nicer, thanks. But please order them in descending shift
width: bpc first then color_space.
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +5
-0+ +return msa_misc; +} + +int cdns_dp_set_host_cap (struct cdns_mhdp8501_device *mhdp)
This can be made static.
Quoted 33 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +26
-0+{ +u8 msg[8 ]; +int ret; + + msg[0 ] =drm_dp_link_rate_to_bw_code (mhdp->dp.rate); + msg[1 ] = mhdp->dp.num_lanes |SCRAMBLER_EN ; + msg[2 ] =VOLTAGE_LEVEL_2 ; + msg[3 ] =PRE_EMPHASIS_LEVEL_3 ; + msg[4 ] =PTS1 |PTS2 |PTS3 |PTS4 ; + msg[5 ] =FAST_LT_NOT_SUPPORT ; + msg[6 ] = mhdp->lane_mapping; + msg[7 ] =ENHANCED ; + +mutex_lock (&mhdp->mbox_mutex); + + ret =cdns_mhdp_mailbox_send (&mhdp->base,MB_MODULE_ID_DP_TX , +DPTX_SET_HOST_CAPABILITIES , +sizeof (msg), msg); + +mutex_unlock (&mhdp->mbox_mutex); + +if (ret) +dev_err (mhdp->dev,"set host cap failed: %d\n" , ret); + +return ret; +}(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.cnew file mode 100644 index 0000000000000..ae21f7dfe5e94
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 4 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +3
-0@@ -0,0 +1,678 @@ +bool cdns_hdmi_bridge_mode_fixup (struct drm_bridge *bridge, +const struct drm_display_mode *mode, + struct drm_display_mode
*adjusted_mode)
This can be made static.
Thanks and best regards,
Alexander
Quoted 11 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +11
-0+{ +struct cdns_mhdp8501_device *mhdp = bridge->driver_private; +struct video_info *video = &mhdp->video_info; + +/* The only currently supported format */ + video->bpc =8 ; + video->color_fmt =DRM_COLOR_FORMAT_RGB444 ; + +return true; +} +
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +10
-0+static enum drm_connector_status +cdns_hdmi_bridge_detect (struct drm_bridge *bridge) +{ +struct cdns_mhdp8501_device *mhdp = bridge->driver_private; + +return cdns_mhdp8501_detect (mhdp); +} + +static struct edid *cdns_hdmi_bridge_get_edid (struct drm_bridge *bridge, + struct drm_connector
*connector)
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +8
-0+{ +struct cdns_mhdp8501_device *mhdp = bridge->driver_private; + +return drm_do_get_edid (connector, cdns_hdmi_get_edid_block, mhdp); +} + +static void cdns_hdmi_bridge_atomic_disable (struct drm_bridge *bridge, + struct drm_bridge_state
*old_state)
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 13 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +13
-0+{ +struct cdns_mhdp8501_device *mhdp = bridge->driver_private; + + mhdp->curr_conn =NULL ; + +/* Mailbox protect for HDMI PHY access */ +mutex_lock (&mhdp->mbox_mutex); +phy_power_off (mhdp->phy); +mutex_unlock (&mhdp->mbox_mutex); +} + +static void cdns_hdmi_bridge_atomic_enable (struct drm_bridge *bridge, + struct drm_bridge_state
*old_state)
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +10
-0+{ +struct cdns_mhdp8501_device *mhdp = bridge->driver_private; +struct drm_atomic_state *state = old_state->base.state; +struct drm_connector *connector; +struct drm_crtc_state *crtc_state; +struct drm_connector_state *conn_state; +const struct drm_display_mode *mode; + + connector = drm_atomic_get_new_connector_for_encoder(state, +
bridge->encoder);
Quoted 33 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +33
-0+if (WARN_ON (!connector)) +return ; + + mhdp->curr_conn = connector; + + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (WARN_ON (!conn_state)) +return ; + + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); +if (WARN_ON (!crtc_state)) +return ; + + mode = &crtc_state->adjusted_mode; +dev_dbg (mhdp->dev,"Mode: %dx%dp%d\n" , + mode->hdisplay, mode->vdisplay, mode->clock); +memcpy (&mhdp->mode, mode,sizeof (struct drm_display_mode )); + +cdns_hdmi_mode_set (mhdp); +} + +const struct drm_bridge_funcs cdns_hdmi_bridge_funcs = { + .attach = cdns_hdmi_bridge_attach, + .detect = cdns_hdmi_bridge_detect, + .get_edid = cdns_hdmi_bridge_get_edid, + .mode_valid = cdns_hdmi_bridge_mode_valid, + .mode_fixup = cdns_hdmi_bridge_mode_fixup, + .atomic_enable = cdns_hdmi_bridge_atomic_enable, + .atomic_disable = cdns_hdmi_bridge_atomic_disable, + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, +};
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/
RE: [EXT] Re: [PATCH v12 4/7] drm: bridge: Cadence: Add MHDP8501 DP/HDMI driver
Hi Alexander,
Thanks your comments,
Quoted 106 lines
Hi Sandor,
thanks for the update.
Am Mittwoch, 10. Januar 2024, 02:08:45 CET schrieb Sandor Yu:
Quoted 1 line
Add a new DRM DisplayPort and HDMI bridge driver for Candence
MHDP8501
Quoted 22 lines
used in i.MX8MQ SOC. MHDP8501 could support HDMI or DisplayPort standards according embedded Firmware running in the uCPU.
For iMX8MQ SOC, the DisplayPort/HDMI FW was loaded and activated by SOC's ROM code. Bootload binary included respective specific firmware is required.
Driver will check display connector type and then load the corresponding driver.
Signed-off-by Sandor Yu <[email protected]>Tested-by Alexander Stein <[email protected]>---
v11->v12:
- ReplaceDRM_INFOwithdev_infoordev_warn.
- ReplaceDRM_ERRORwithdev_err.
- Return ret whencdns_mhdp_dpcd_readfailed in functioncdns_dp_aux_transferi(). - Remove unused parmeter in functioncdns_dp_get_msa_misc
and use two separate variables for color space and bpc.
- Add year 2024 to copyright.Quoted 5 lines
drivers/gpu/drm/bridge/cadence/Kconfig | 16 + drivers/gpu/drm/bridge/cadence/Makefile | 2 + .../drm/bridge/cadence/cdns-mhdp8501-core.c | 315 ++++++++ .../drm/bridge/cadence/cdns-mhdp8501-core.h | 365 +++++++++ .../gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c | 699++++++++++++++++++
Quoted 1 line
.../drm/bridge/cadence/cdns-mhdp8501-hdmi.c | 678+++++++++++++++++
Quoted 6 lines
6 files changed, 2075 insertions(+) create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.h create mode 100644
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.cdrivers/gpu/drm/bridge/cadence/Makefile obj-$(CONFIG_CDNS_MHDP_HELPER) +=
Quoted 35 lines
create mode 100644
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c(quoted diff) +0
-0b/drivers/gpu/drm/bridge/cadence/Kconfig index
e0973339e9e33..45848e741f5f4
100644drivers/gpu/drm/bridge/cadence/Kconfig +16
-0@@ -51,3 +51,19 @@ config DRM_CDNS_MHDP8546_J721E initializes the J721E Display Port and sets up the clock and data muxes. endif + +config DRM_CDNS_MHDP8501 + tristate "Cadence MHDP8501 DP/HDMI bridge" + select DRM_KMS_HELPER + select DRM_PANEL_BRIDGE + select DRM_DISPLAY_DP_HELPER + select DRM_DISPLAY_HELPER + select CDNS_MHDP_HELPER + select DRM_CDNS_AUDIO + depends on OF + help + Support Cadence MHDP8501 DisplayPort/HDMI bridge. + Cadence MHDP8501 support one or more protocols, + including DisplayPort and HDMI. + To use the DP and HDMI drivers, their respective + specific firmware is required.(quoted diff) +0
-0b/drivers/gpu/drm/bridge/cadence/Makefile index
087dc074820d7..02c1a9f3cf6fc100644drivers/gpu/drm/bridge/cadence/Makefile +0
-0@@ -6,3 +6,5 @@ obj-$(CONFIG_CDNS_MHDP_HELPER) +=cdns-mhdp-helper.o
drivers/gpu/drm/bridge/cadence/Makefile obj-$(CONFIG_CDNS_MHDP_HELPER) += cdns-mhdp-helper.o · line 6
Quoted 1 line
drivers/gpu/drm/bridge/cadence/Makefile +0
-0obj-$(CONFIG_DRM_CDNS_MHDP8546) += cdns-mhdp8546.ocdns-mhdp8546-y
Quoted 4 lines
:= cdns-mhdp8546-core.o cdns-mhdp8546-hdcp.o
cdns-mhdp8546-$(CONFIG_DRM_CDNS_MHDP8546_J721E) +=
cdns-mhdp8546-j721e.o +obj-$(CONFIG_DRM_CDNS_MHDP8501) += cdns-mhdp8501.ocdns-mhdp8501-y :=
Quoted 17 lines
+cdns-mhdp8501-core.o cdns-mhdp8501-dp.o cdns-mhdp8501-hdmi.o diff --git
a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.cb/drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.cnew file mode 100644 index 0000000000000..3080c7507a012drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +9
-0@@ -0,0 +1,315 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Cadence Display Port Interface (DP) driver +* +* Copyright (C) 2023, 2024 NXP Semiconductor, Inc. +* +*/ +#include <drm/drm_of.h> +#include <drm/drm_print.h>
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c line 13
Quoted 4 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +4
-0+#include <linux/clk.h> +#include <linux/irq.h> +#include <linux/mutex.h> +#include <linux/of_device.h> Since commit
d57d584ef69de("of: Stop circularly includingof_device.handof_platform.h") you to explicitly includelinux/platform_device.hhere. Please compile against next tree.
OK, I will check it on next tree.
Quoted 133 lines
Quoted 24 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +4
-0+#include <linux/phy/phy.h> + +#include "cdns-mhdp8501-core.h" +(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.cnew file mode 100644 index 0000000000000..6963c7143a3b0drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +12
-0@@ -0,0 +1,699 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Cadence MHDP8501 DisplayPort(DP) bridge driver +* +* Copyright (C) 2019-2024 NXP Semiconductor, Inc. +* +*/ +#include <drm/drm_atomic_helper.h> +#include <drm/drm_edid.h> +#include <drm/drm_print.h> +#include <linux/phy/phy.h> +#include <linux/phy/phy-dp.h> drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c line 22
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +10
-0+ +#include "cdns-mhdp8501-core.h" + +#define LINK_TRAINING_TIMEOUT_MS 500 +#define LINK_TRAINING_RETRY_MS 20 + +ssize_t cdns_dp_aux_transfer (struct drm_dp_aux *aux, +struct drm_dp_aux_msg *msg) { +struct cdns_mhdp8501_device *mhdp =dev_get_drvdata (aux->dev); + bool native = msg->request & (DP_AUX_NATIVE_WRITE &
DP_AUX_NATIVE_READ);drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +6
-0+int ret; + +/* Ignore address only message */ +if (!msg->size || !msg->buffer) { + msg->reply = native ? + DP_AUX_NATIVE_REPLY_ACK :
DP_AUX_I2C_REPLY_ACK;drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +6
-0+return msg->size; + } + +if (!native) { + dev_err(mhdp->dev, "%s: only native messages + supported\n",
__func__);drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +6
-0+return -EINVAL ; + } + +/* msg sanity check */ +if (msg->size >DP_AUX_MAX_PAYLOAD_BYTES ) { + dev_err(mhdp->dev, "%s: invalid msg: size(%zu),request(%x)\n",
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 12 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +1
-0+ __func__, msg->size, (unsigned int)msg-request);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +10
-0+return -EINVAL ; + } + +if (msg->request ==DP_AUX_NATIVE_WRITE ) { +const u8 *buf = msg->buffer; +int i; + +for (i =0 ; i < msg->size; ++i) { + ret = cdns_mhdp_dpcd_write(&mhdp->base, + msg->address +i, buf[i]);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 2 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +2
-0+if (ret <0 ) { + dev_err(mhdp->dev, "Failed to writeDPCD\n");
Quoted 61 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +61
-0+return ret; + } + } + msg->reply =DP_AUX_NATIVE_REPLY_ACK ; +return msg->size; + } + +if (msg->request ==DP_AUX_NATIVE_READ ) { + ret =cdns_mhdp_dpcd_read (&mhdp->base, msg->address, + msg->buffer, msg->size); +if (ret <0 ) +return ret; + msg->reply =DP_AUX_NATIVE_REPLY_ACK ; +return msg->size; + } +return 0 ; +} + +int cdns_dp_aux_destroy (struct cdns_mhdp8501_device *mhdp) { +drm_dp_aux_unregister (&mhdp->dp.aux); + +return 0 ; +} + +static int cdns_dp_get_msa_misc (struct video_info *video) { +u32 msa_misc; +u8 color_space =0 ; +u8 bpc =0 ; + +switch (video->color_fmt) { +/* set YUV default color space conversion to BT601 */ +case DRM_COLOR_FORMAT_YCBCR444 : + color_space =6 +BT_601 *8 ; +break ; +case DRM_COLOR_FORMAT_YCBCR422 : + color_space =5 +BT_601 *8 ; +break ; +case DRM_COLOR_FORMAT_YCBCR420 : + color_space =5 ; +break ; +case DRM_COLOR_FORMAT_RGB444 : +default : + color_space =0 ; +break ; + }; + +switch (video->bpc) { +case 6 : + bpc =0 ; +break ; +case 10 : + bpc =2 ; +break ; +case 12 : + bpc =3 ; +break ; +case 16 : + bpc =4 ; +break ; +case 8 : +default :
Quoted 9 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c line 121
Quoted 5 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +5
-0+ bpc =1 ; +break ; + }; + + msa_misc = (color_space <<1 ) | (bpc <<5 );This looks much nicer, thanks. But please order them in descending shift
width: bpc first thencolor_space.
OK.
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +5
-0+ +return msa_misc; +} + +int cdns_dp_set_host_cap (struct cdns_mhdp8501_device *mhdp)This can be made static.
OK.
Quoted 39 lines
Quoted 7 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +6
-0+{ +u8 msg[8 ]; +int ret; + + msg[0 ] =drm_dp_link_rate_to_bw_code (mhdp->dp.rate); + msg[1 ] = mhdp->dp.num_lanes |SCRAMBLER_EN ;drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +10
-0+ msg[2 ] =VOLTAGE_LEVEL_2 ; + msg[3 ] =PRE_EMPHASIS_LEVEL_3 ; + msg[4 ] =PTS1 |PTS2 |PTS3 |PTS4 ; + msg[5 ] =FAST_LT_NOT_SUPPORT ; + msg[6 ] = mhdp->lane_mapping; + msg[7 ] =ENHANCED ; + +mutex_lock (&mhdp->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(&mhdp->base,
MB_MODULE_ID_DP_TX,Quoted 17 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c new file +10
-0+DPTX_SET_HOST_CAPABILITIES , + sizeof(msg), msg); + +mutex_unlock (&mhdp->mbox_mutex); + +if (ret) +dev_err (mhdp->dev,"set host cap failed: %d\n" , ret); + +return ret; +}(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.cnew file mode 100644 index 0000000000000..ae21f7dfe5e94drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 3 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +2
-0@@ -0,0 +1,678 @@ +bool cdns_hdmi_bridge_mode_fixup (struct drm_bridge *bridge, + const struct drm_display_mode*mode,
Quoted 4 lines
Quoted 1 line
+ struct
drm_display_mode
*adjusted_mode)This can be made static.
OK, thanks!
Sandor
Quoted 106 lines
Thanks and best regards,
AlexanderQuoted 9 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +9
-0+{ +struct cdns_mhdp8501_device *mhdp = bridge->driver_private; +struct video_info *video = &mhdp->video_info; + +/* The only currently supported format */ + video->bpc =8 ; + video->color_fmt =DRM_COLOR_FORMAT_RGB444 ; + +return true;drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +10
-0+} + +static enum drm_connector_status +cdns_hdmi_bridge_detect (struct drm_bridge *bridge) { +struct cdns_mhdp8501_device *mhdp = bridge->driver_private; + +return cdns_mhdp8501_detect (mhdp); } + +static struct edid *cdns_hdmi_bridge_get_edid (struct drm_bridge *bridge, + struct drm_connector*connector)
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +8
-0+{ +struct cdns_mhdp8501_device *mhdp = bridge->driver_private; + +return drm_do_get_edid (connector, cdns_hdmi_get_edid_block, +mhdp); } + +static void cdns_hdmi_bridge_atomic_disable (struct drm_bridge *bridge, + struct drm_bridge_state
*old_state)drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 12 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +12
-0+{ +struct cdns_mhdp8501_device *mhdp = bridge->driver_private; + + mhdp->curr_conn =NULL ; + +/* Mailbox protect for HDMI PHY access */ +mutex_lock (&mhdp->mbox_mutex); +phy_power_off (mhdp->phy); +mutex_unlock (&mhdp->mbox_mutex); } + +static void cdns_hdmi_bridge_atomic_enable (struct drm_bridge *bridge, + struct drm_bridge_state
*old_state)drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +10
-0+{ +struct cdns_mhdp8501_device *mhdp = bridge->driver_private; +struct drm_atomic_state *state = old_state->base.state; +struct drm_connector *connector; +struct drm_crtc_state *crtc_state; +struct drm_connector_state *conn_state; +const struct drm_display_mode *mode; + + connector = drm_atomic_get_new_connector_for_encoder(state, +
bridge->encoder);drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +6
-0+if (WARN_ON (!connector)) +return ; + + mhdp->curr_conn = connector; + + conn_state = drm_atomic_get_new_connector_state(state,connector);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 4 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +4
-0+if (WARN_ON (!conn_state)) +return ; + + crtc_state = drm_atomic_get_new_crtc_state(state,
conn_state->crtc);Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +10
-0+if (WARN_ON (!crtc_state)) +return ; + + mode = &crtc_state->adjusted_mode; +dev_dbg (mhdp->dev,"Mode: %dx%dp%d\n" , + mode->hdisplay, mode->vdisplay, mode->clock); +memcpy (&mhdp->mode, mode,sizeof (struct drm_display_mode )); + +cdns_hdmi_mode_set (mhdp); +}drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +10
-0+ +const struct drm_bridge_funcs cdns_hdmi_bridge_funcs = { + .attach = cdns_hdmi_bridge_attach, + .detect = cdns_hdmi_bridge_detect, + .get_edid = cdns_hdmi_bridge_get_edid, + .mode_valid = cdns_hdmi_bridge_mode_valid, + .mode_fixup = cdns_hdmi_bridge_mode_fixup, + .atomic_enable = cdns_hdmi_bridge_atomic_enable, + .atomic_disable = cdns_hdmi_bridge_atomic_disable, + .atomic_duplicate_state =
drm_atomic_helper_bridge_duplicate_state,drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 2 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +2
-0+ .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, };--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-/
group.com%2F&data=05%7C02%7CSandor.yu%40nxp.com%7Cb23e376f27494 9cdb46c08dc17413d46%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0 %7C638410816178929125%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjA wMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7 C%7C&sdata=tYc81WajNJAOmUvSD06cto0i%2FhVe%2BuLFxIeYm0uyMDM%3 D&reserved=0
PATCH v12 5/7 dt-bindings: phy: Add Freescale iMX8MQ DP and HDMI PHY
In reply to Sandor YuAdd bindings for Freescale iMX8MQ DP and HDMI PHY.
---v9->v12:
*No change.
.../bindings/phy/fsl,imx8mq-dp-hdmi-phy.yaml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/fsl,imx8mq-dp-hdmi-phy.yaml
Documentation/devicetree/bindings/phy/fsl,imx8mq-dp-hdmi-phy.yaml new file +53 -0
@@ -0,0 +1,53 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/fsl,imx8mq-dp-hdmi-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cadence HDP-TX DP/HDMI PHY for Freescale i.MX8MQ SoC + +maintainers: + - Sandor Yu <[email protected]> + +properties: + compatible: + enum: + - fsl,imx8mq-dp-phy + - fsl,imx8mq-hdmi-phy + + reg: + maxItems: 1 + + clocks: + items: + - description: PHY reference clock. + - description: APB clock. + + clock-names: + items: + - const: ref + - const: apb + + "#phy-cells": + const: 0 + +required: + - compatible + - reg + - clocks + - clock-names + - "#phy-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/imx8mq-clock.h> + #include <dt-bindings/phy/phy.h> + dp_phy: phy@32c00000 { + compatible = "fsl,imx8mq-dp-phy"; + reg = <0x32c00000 0x100000>; + #phy-cells = <0>; + clocks = <&hdmi_phy_27m>, <&clk IMX8MQ_CLK_DISP_APB_ROOT>; + clock-names = "ref", "apb"; + };
Signature · 1 line
2.34.1
PATCH v12 6/7 phy: freescale: Add DisplayPort PHY driver for i.MX8MQ
In reply to Sandor YuAdd Cadence HDP-TX DisplayPort PHY driver for i.MX8MQ
Cadence HDP-TX PHY could be put in either DP mode or HDMI mode base on the configuration chosen. DisplayPort PHY mode is configurated in the driver.
---v11->v12:
- Return error code to replace -1 for function wait_for_ack().
- Set cdns_phy->power_up = false in phy_power_down function.
- Remove "RATE_8_1 = 810000", it is not used in driver.
- Add year 2024 to copyright.
drivers/phy/freescale/Kconfig | 10 + drivers/phy/freescale/Makefile | 1 + drivers/phy/freescale/phy-fsl-imx8mq-dp.c | 726 ++++++++++++++++++++++ 3 files changed, 737 insertions(+) create mode 100644 drivers/phy/freescale/phy-fsl-imx8mq-dp.c
drivers/phy/freescale/Kconfig +10 -0
@@ -35,6 +35,16 @@ config PHY_FSL_IMX8M_PCIE Enable this to add support for the PCIE PHY as found on i.MX8M family of SOCs. +config PHY_FSL_IMX8MQ_DP + tristate "Freescale i.MX8MQ DP PHY support" + depends on OF && HAS_IOMEM + depends on COMMON_CLK + select GENERIC_PHY + select CDNS_MHDP_HELPER + help + Enable this to support the Cadence HDPTX DP PHY driver + on i.MX8MQ SOC. + endif config PHY_FSL_LYNX_28G
drivers/phy/freescale/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_PHY_FSL_IMX8MQ_DP) += phy-fsl-imx8mq-dp.o obj-$(CONFIG_PHY_FSL_IMX8MQ_USB) += phy-fsl-imx8mq-usb.o obj-$(CONFIG_PHY_MIXEL_LVDS_PHY) += phy-fsl-imx8qm-lvds-phy.o obj-$(CONFIG_PHY_MIXEL_MIPI_DPHY) += phy-fsl-imx8-mipi-dphy.o
drivers/phy/freescale/phy-fsl-imx8mq-dp.c new file +726 -0
726 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v12 7/7 phy: freescale: Add HDMI PHY driver for i.MX8MQ
In reply to Sandor YuAdd Cadence HDP-TX HDMI PHY driver for i.MX8MQ.
Cadence HDP-TX PHY could be put in either DP mode or HDMI mode base on the configuration chosen. HDMI PHY mode is configurated in the driver.
---v11->v12:
- Adjust clk disable order.
- Return error code to replace -1 for function wait_for_ack().
- Use bool for variable pclk_in.
- Add year 2024 to copyright.
drivers/phy/freescale/Kconfig | 10 + drivers/phy/freescale/Makefile | 1 + drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c | 959 ++++++++++++++++++++ 3 files changed, 970 insertions(+) create mode 100644 drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c
drivers/phy/freescale/Kconfig +10 -0
@@ -45,6 +45,16 @@ config PHY_FSL_IMX8MQ_DP Enable this to support the Cadence HDPTX DP PHY driver on i.MX8MQ SOC. +config PHY_FSL_IMX8MQ_HDMI + tristate "Freescale i.MX8MQ HDMI PHY support" + depends on OF && HAS_IOMEM + depends on COMMON_CLK + select GENERIC_PHY + select CDNS_MHDP_HELPER + help + Enable this to support the Cadence HDPTX HDMI PHY driver + on i.MX8MQ SOC. + endif config PHY_FSL_LYNX_28G
drivers/phy/freescale/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_PHY_FSL_IMX8MQ_DP) += phy-fsl-imx8mq-dp.o +obj-$(CONFIG_PHY_FSL_IMX8MQ_HDMI) += phy-fsl-imx8mq-hdmi.o obj-$(CONFIG_PHY_FSL_IMX8MQ_USB) += phy-fsl-imx8mq-usb.o obj-$(CONFIG_PHY_MIXEL_LVDS_PHY) += phy-fsl-imx8qm-lvds-phy.o obj-$(CONFIG_PHY_MIXEL_MIPI_DPHY) += phy-fsl-imx8-mipi-dphy.o
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +959 -0
959 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v12 7/7] phy: freescale: Add HDMI PHY driver for i.MX8MQ
Hi Sandor,
thanks for the update.
Am Mittwoch, 10. Januar 2024, 02:08:48 CET schrieb Sandor Yu:
Quoted 61 lines
Add Cadence HDP-TX HDMI PHY driver for i.MX8MQ.
Cadence HDP-TX PHY could be put in either DP mode or HDMI mode base on the configuration chosen. HDMI PHY mode is configurated in the driver.
Signed-off-by Sandor Yu <[email protected]>Tested-by Alexander Stein <[email protected]>---
v11->v12:
- Adjust clk disable order.
- Return error code to replace -1 for functionwait_for_ack().
- Use bool for variablepclk_in.
- Add year 2024 to copyright.drivers/phy/freescale/Kconfig | 10 + drivers/phy/freescale/Makefile | 1 + drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c | 959 ++++++++++++++++++++ 3 files changed, 970 insertions(+) create mode 100644 drivers/phy/freescale/phy-fsl-imx8mq-hdmi.cdrivers/phy/freescale/Kconfig +10
-0@@ -45,6 +45,16 @@ config PHY_FSL_IMX8MQ_DP Enable this to support the Cadence HDPTX DP PHY driver on i.MX8MQ SOC. +config PHY_FSL_IMX8MQ_HDMI + tristate "Freescale i.MX8MQ HDMI PHY support" + depends on OF && HAS_IOMEM + depends on COMMON_CLK + select GENERIC_PHY + select CDNS_MHDP_HELPER + help + Enable this to support the Cadence HDPTX HDMI PHY driver + on i.MX8MQ SOC. + endif config PHY_FSL_LYNX_28Gdrivers/phy/freescale/Makefile +1
-0@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_PHY_FSL_IMX8MQ_DP) += phy-fsl-imx8mq-dp.o +obj-$(CONFIG_PHY_FSL_IMX8MQ_HDMI) += phy-fsl-imx8mq-hdmi.o obj-$(CONFIG_PHY_FSL_IMX8MQ_USB) += phy-fsl-imx8mq-usb.o obj-$(CONFIG_PHY_MIXEL_LVDS_PHY) += phy-fsl-imx8qm-lvds-phy.o obj-$(CONFIG_PHY_MIXEL_MIPI_DPHY) += phy-fsl-imx8-mipi-dphy.o(quoted diff) +0
-0
b/drivers/phy/freescale/phy-fsl-imx8mq-hdmi.cnew file mode 100644 index 0000000000000..9e03c726f290cdrivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +1
-0@@ -0,0 +1,959 @@ +int cdns_hdptx_hdmi_phy_valid(struct phy *phy, enum phy_mode mode, int
Quoted 1 line
submode, + union
phy_configure_opts*opts)
This function can be made static.
Thanks and best regards,
Alexander
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c
Quoted 6 lines
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +6
-0+{ +u32 rate = opts->hdmi.pixel_clk_rate; +int i; + +for (i =0 ; i <ARRAY_SIZE (pixel_clk_output_ctrl_table); i++) + if (rate ==
pixel_clk_output_ctrl_table[i].pixel_clk_freq_min)
Quoted 87 lines
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +87
-0+return 0 ; + +return -EINVAL ; +} + +static int cdns_hdptx_hdmi_phy_init (struct phy *phy) +{ +return 0 ; +} + +static int cdns_hdptx_hdmi_configure (struct phy *phy, +union phy_configure_opts *opts) +{ +struct cdns_hdptx_hdmi_phy *cdns_phy =phy_get_drvdata (phy); +int ret; + + cdns_phy->pixel_clk_rate = opts->hdmi.pixel_clk_rate; + cdns_phy->color_space = opts->hdmi.color_space; + cdns_phy->bpc = opts->hdmi.bpc; + +/* Check HDMI FW alive before HDMI PHY init */ + ret =hdptx_phy_check_alive (cdns_phy); +if (!ret) { +dev_err (cdns_phy->dev,"NO HDMI FW running\n" ); +return -ENXIO ; + } + +/* Configure PHY */ +if (hdptx_hdmi_phy_cfg (cdns_phy, cdns_phy->pixel_clk_rate) <0 ) { +dev_err (cdns_phy->dev,"failed to set phy pclock\n" ); +return -EINVAL ; + } + + ret =hdptx_hdmi_phy_power_up (cdns_phy); +if (ret <0 ) +return ret; + +hdptx_hdmi_phy_set_vswing (cdns_phy); + +return 0 ; +} + +static const struct phy_ops cdns_hdptx_hdmi_phy_ops = { + .init = cdns_hdptx_hdmi_phy_init, + .configure = cdns_hdptx_hdmi_configure, + .power_on = cdns_hdptx_hdmi_phy_on, + .power_off = cdns_hdptx_hdmi_phy_off, + .validate = cdns_hdptx_hdmi_phy_valid, + .owner =THIS_MODULE , +}; + +static int cdns_hdptx_hdmi_phy_probe (struct platform_device *pdev) +{ +struct cdns_hdptx_hdmi_phy *cdns_phy; +struct device *dev = &pdev->dev; +struct device_node *node = dev->of_node; +struct phy_provider *phy_provider; +struct resource *res; +struct phy *phy; +int ret; + + cdns_phy =devm_kzalloc (dev,sizeof (*cdns_phy),GFP_KERNEL ); +if (!cdns_phy) +return -ENOMEM ; + +dev_set_drvdata (dev, cdns_phy); + cdns_phy->dev = dev; +mutex_init (&cdns_phy->mbox_mutex); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -ENODEV ; + cdns_phy->regs =devm_ioremap (dev, res->start,resource_size (res)); +if (IS_ERR (cdns_phy->regs)) +return PTR_ERR (cdns_phy->regs); + + phy =devm_phy_create (dev, node, &cdns_hdptx_hdmi_phy_ops); +if (IS_ERR (phy)) +return PTR_ERR (phy); + + phy->attrs.mode =PHY_MODE_HDMI ; + + cdns_phy->phy = phy; +phy_set_drvdata (phy, cdns_phy); + +/* init base struct for access mhdp mailbox */ + cdns_phy->base.dev = cdns_phy->dev;
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c
Quoted 10 lines
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +10
-0+ cdns_phy->base.regs = cdns_phy->regs; + cdns_phy->base.mbox_mutex = &cdns_phy->mbox_mutex; + + ret =hdptx_hdmi_clk_enable (cdns_phy); +if (ret) { +dev_err (dev,"Init clk fail\n" ); +return -EINVAL ; + } + + phy_provider = devm_of_phy_provider_register(dev,
of_phy_simple_xlate);
Quoted 43 lines
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +43
-0+if (IS_ERR (phy_provider)) { + ret =PTR_ERR (phy_provider); + goto clk_disable; + } + +dev_dbg (dev,"probe success!\n" ); + +return 0 ; + +clk_disable: +hdptx_hdmi_clk_disable (cdns_phy); + +return -EINVAL ; +} + +static int cdns_hdptx_hdmi_phy_remove (struct platform_device *pdev) +{ +struct cdns_hdptx_hdmi_phy *cdns_phy =platform_get_drvdata (pdev); + +hdptx_hdmi_clk_disable (cdns_phy); + +return 0 ; +} + +static const struct of_device_id cdns_hdptx_hdmi_phy_of_match[] = { + {.compatible ="fsl,imx8mq-hdmi-phy" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, cdns_hdptx_hdmi_phy_of_match); + +static struct platform_driver cdns_hdptx_hdmi_phy_driver = { + .probe = cdns_hdptx_hdmi_phy_probe, + .remove = cdns_hdptx_hdmi_phy_remove, + .driver = { + .name ="cdns-hdptx-hdmi-phy" , + .of_match_table = cdns_hdptx_hdmi_phy_of_match, + } +}; +module_platform_driver (cdns_hdptx_hdmi_phy_driver); + +MODULE_AUTHOR ("Sandor Yu <[email protected]>" ); +MODULE_DESCRIPTION ("Cadence HDP-TX HDMI PHY driver" ); +MODULE_LICENSE ("GPL" );
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/
RE: [EXT] Re: [PATCH v12 7/7] phy: freescale: Add HDMI PHY driver for i.MX8MQ
Hi Alexander,
Thanks your comments,
Quoted 99 lines
-----Original Message-----
From: Alexander Stein <[email protected]>
Sent: 2024年1月17日 17:47
To: [email protected]; [email protected]; [email protected]; Laurent Pinchart <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sandor Yu <[email protected]>
Cc: [email protected]; dl-linux-imx <[email protected]>; Sandor Yu <[email protected]>; Oliver Brown <[email protected]>; [email protected]
Subject: [EXT] Re: [PATCH v12 7/7] phy: freescale: Add HDMI PHY driver for i.MX8MQCaution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button
Hi Sandor,
thanks for the update.
Am Mittwoch, 10. Januar 2024, 02:08:48 CET schrieb Sandor Yu:
Quoted 3 lines
Add Cadence HDP-TX HDMI PHY driver for i.MX8MQ.
Cadence HDP-TX PHY could be put in either DP mode or HDMI mode base
on
Quoted 47 lines
the configuration chosen.
HDMI PHY mode is configurated in the driver.Signed-off-by Sandor Yu <[email protected]>Tested-by Alexander Stein <[email protected]>---
v11->v12:
- Adjust clk disable order.
- Return error code to replace -1 for functionwait_for_ack().
- Use bool for variablepclk_in.
- Add year 2024 to copyright.drivers/phy/freescale/Kconfig | 10 + drivers/phy/freescale/Makefile | 1 + drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c | 959 ++++++++++++++++++++ 3 files changed, 970 insertions(+) create mode 100644 drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c(quoted diff) +0
-0b/drivers/phy/freescale/Kconfig index
c39709fd700ac..14f47b7cc77ab100644drivers/phy/freescale/Kconfig +10
-0@@ -45,6 +45,16 @@ config PHY_FSL_IMX8MQ_DP Enable this to support the Cadence HDPTX DP PHY driver on i.MX8MQ SOC. +config PHY_FSL_IMX8MQ_HDMI + tristate "Freescale i.MX8MQ HDMI PHY support" + depends on OF && HAS_IOMEM + depends on COMMON_CLK + select GENERIC_PHY + select CDNS_MHDP_HELPER + help + Enable this to support the Cadence HDPTX HDMI PHY driver + on i.MX8MQ SOC. + endif config PHY_FSL_LYNX_28G(quoted diff) +0
-0b/drivers/phy/freescale/Makefile index
47e5285209fa8..1380ac31c2ead100644drivers/phy/freescale/Makefile line 2
Quoted 2 lines
drivers/phy/freescale/Makefile +0
-0@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_PHY_FSL_IMX8MQ_DP) +=phy-fsl-imx8mq-dp.o
Quoted 13 lines
drivers/phy/freescale/Makefile +1
-0+obj-$(CONFIG_PHY_FSL_IMX8MQ_HDMI) += phy-fsl-imx8mq-hdmi.o obj-$(CONFIG_PHY_FSL_IMX8MQ_USB) += phy-fsl-imx8mq-usb.o obj-$(CONFIG_PHY_MIXEL_LVDS_PHY) += phy-fsl-imx8qm-lvds-phy.o obj-$(CONFIG_PHY_MIXEL_MIPI_DPHY) += phy-fsl-imx8-mipi-dphy.o(quoted diff) +0
-0
b/drivers/phy/freescale/phy-fsl-imx8mq-hdmi.cnew file mode 100644 index 0000000000000..9e03c726f290cdrivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +2
-0@@ -0,0 +1,959 @@ +int cdns_hdptx_hdmi_phy_valid (struct phy *phy,enum phy_mode mode, +intQuoted 1 line
submode, + union
phy_configure_opts*opts)
Quoted 2 lines
This function can be made static.
OK, thanks!
B.R
Sandor
Quoted 163 lines
Thanks and best regards,
Alexanderdrivers/phy/freescale/phy-fsl-imx8mq-hdmi.c
Quoted 6 lines
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +6
-0+{ +u32 rate = opts->hdmi.pixel_clk_rate; +int i; + +for (i =0 ; i <ARRAY_SIZE (pixel_clk_output_ctrl_table); i++) + if (rate ==pixel_clk_output_ctrl_table[i].pixel_clk_freq_min)
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c line 831
Quoted 11 lines
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +11
-0+return 0 ; + +return -EINVAL ; +} + +static int cdns_hdptx_hdmi_phy_init (struct phy *phy) { +return 0 ; +} + +static int cdns_hdptx_hdmi_configure (struct phy *phy, +union phy_configure_opts *opts){
Quoted 73 lines
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +73
-0+struct cdns_hdptx_hdmi_phy *cdns_phy =phy_get_drvdata (phy); +int ret; + + cdns_phy->pixel_clk_rate = opts->hdmi.pixel_clk_rate; + cdns_phy->color_space = opts->hdmi.color_space; + cdns_phy->bpc = opts->hdmi.bpc; + +/* Check HDMI FW alive before HDMI PHY init */ + ret =hdptx_phy_check_alive (cdns_phy); +if (!ret) { +dev_err (cdns_phy->dev,"NO HDMI FW running\n" ); +return -ENXIO ; + } + +/* Configure PHY */ +if (hdptx_hdmi_phy_cfg (cdns_phy, cdns_phy->pixel_clk_rate) <0 ) { +dev_err (cdns_phy->dev,"failed to set phy pclock\n" ); +return -EINVAL ; + } + + ret =hdptx_hdmi_phy_power_up (cdns_phy); +if (ret <0 ) +return ret; + +hdptx_hdmi_phy_set_vswing (cdns_phy); + +return 0 ; +} + +static const struct phy_ops cdns_hdptx_hdmi_phy_ops = { + .init = cdns_hdptx_hdmi_phy_init, + .configure = cdns_hdptx_hdmi_configure, + .power_on = cdns_hdptx_hdmi_phy_on, + .power_off = cdns_hdptx_hdmi_phy_off, + .validate = cdns_hdptx_hdmi_phy_valid, + .owner =THIS_MODULE , +}; + +static int cdns_hdptx_hdmi_phy_probe (struct platform_device *pdev) { +struct cdns_hdptx_hdmi_phy *cdns_phy; +struct device *dev = &pdev->dev; +struct device_node *node = dev->of_node; +struct phy_provider *phy_provider; +struct resource *res; +struct phy *phy; +int ret; + + cdns_phy =devm_kzalloc (dev,sizeof (*cdns_phy),GFP_KERNEL ); +if (!cdns_phy) +return -ENOMEM ; + +dev_set_drvdata (dev, cdns_phy); + cdns_phy->dev = dev; +mutex_init (&cdns_phy->mbox_mutex); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -ENODEV ; + cdns_phy->regs =devm_ioremap (dev, res->start,resource_size (res)); +if (IS_ERR (cdns_phy->regs)) +return PTR_ERR (cdns_phy->regs); + + phy =devm_phy_create (dev, node, &cdns_hdptx_hdmi_phy_ops); +if (IS_ERR (phy)) +return PTR_ERR (phy); + + phy->attrs.mode =PHY_MODE_HDMI ; + + cdns_phy->phy = phy; +phy_set_drvdata (phy, cdns_phy); + +/* init base struct for access mhdp mailbox */ + cdns_phy->base.dev = cdns_phy->dev;drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c
Quoted 10 lines
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +10
-0+ cdns_phy->base.regs = cdns_phy->regs; + cdns_phy->base.mbox_mutex = &cdns_phy->mbox_mutex; + + ret =hdptx_hdmi_clk_enable (cdns_phy); +if (ret) { +dev_err (dev,"Init clk fail\n" ); +return -EINVAL ; + } + + phy_provider = devm_of_phy_provider_register(dev,
of_phy_simple_xlate);Quoted 33 lines
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +33
-0+if (IS_ERR (phy_provider)) { + ret =PTR_ERR (phy_provider); + goto clk_disable; + } + +dev_dbg (dev,"probe success!\n" ); + +return 0 ; + +clk_disable: +hdptx_hdmi_clk_disable (cdns_phy); + +return -EINVAL ; +} + +static int cdns_hdptx_hdmi_phy_remove (struct platform_device *pdev) { +struct cdns_hdptx_hdmi_phy *cdns_phy = +platform_get_drvdata (pdev); + +hdptx_hdmi_clk_disable (cdns_phy); + +return 0 ; +} + +static const struct of_device_id cdns_hdptx_hdmi_phy_of_match[] = { + {.compatible ="fsl,imx8mq-hdmi-phy" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, cdns_hdptx_hdmi_phy_of_match); + +static struct platform_driver cdns_hdptx_hdmi_phy_driver = { + .probe = cdns_hdptx_hdmi_phy_probe, + .remove = cdns_hdptx_hdmi_phy_remove,drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c line 959
Quoted 10 lines
drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c new file +10
-0+ .driver = { + .name = "cdns-hdptx-hdmi-phy", + .of_match_table = cdns_hdptx_hdmi_phy_of_match, + } +}; +module_platform_driver (cdns_hdptx_hdmi_phy_driver); + +MODULE_AUTHOR ("Sandor Yu <[email protected]>" ); +MODULE_DESCRIPTION ("Cadence HDP-TX HDMI PHY driver" ); +MODULE_LICENSE ("GPL" );--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-/
group.com%2F&data=05%7C02%7CSandor.yu%40nxp.com%7Cb17a4addce1e4 8b54f8a08dc17414379%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0 %7C638410816282055456%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjA wMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7 C%7C&sdata=YFO2ShpepVs%2B%2FTSDfzLdZjkPc7s0VHrqjX9jxsqSXok%3D&res erved=0