Initial support Cadence MHDP8501(HDMI/DP) for i.MX8MQ
Subsystems (6)
v10 cover Initial support Cadence MHDP8501(HDMI/DP) for i.MX8MQ
The patch set initial support Cadence MHDP8501(HDMI/DP) DRM bridge drivers 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 patche #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
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: Creat 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 | 306 ++++++ .../drm/bridge/cadence/cdns-mhdp8501-core.c | 316 ++++++ .../drm/bridge/cadence/cdns-mhdp8501-core.h | 365 +++++++ .../gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c | 708 +++++++++++++ .../drm/bridge/cadence/cdns-mhdp8501-hdmi.c | 673 ++++++++++++ .../drm/bridge/cadence/cdns-mhdp8546-core.c | 383 ++----- .../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 | 720 +++++++++++++ drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c | 961 ++++++++++++++++++ include/drm/bridge/cdns-mhdp-helper.h | 96 ++ include/linux/phy/phy-hdmi.h | 24 + include/linux/phy/phy.h | 7 +- 18 files changed, 4443 insertions(+), 362 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 v10 1/7 drm: bridge: Cadence: Creat 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.
---v9->v10:
*use mhdp helper driver to replace macro functions, move maibox access function and mhdp hdmi/dp common API functions into the driver.
drivers/gpu/drm/bridge/cadence/Kconfig | 4 drivers/gpu/drm/bridge/cadence/Makefile | 1 + .../gpu/drm/bridge/cadence/cdns-mhdp-helper.c | 306 ++++++++++++++ .../drm/bridge/cadence/cdns-mhdp8546-core.c | 383 +++--------------- .../drm/bridge/cadence/cdns-mhdp8546-core.h | 44 +- include/drm/bridge/cdns-mhdp-helper.h | 96 +++++ 6 files changed, 473 insertions(+), 361 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
@@ -20,6 +20,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
@@ -27,6 +30,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 +306 -0
306 lines not on this page · raw message
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +62 -321
649 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 +96 -0
96 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v10 1/7] drm: bridge: Cadence: Creat mhdp helper driver
Hi Sandor,
thanks for the updated series.
Am Freitag, 13. Oktober 2023, 05:24:20 CEST schrieb Sandor Yu:
Quoted 84 lines
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 tocdns_mhdp_dp_reg_write(), because it use the DPTX command IDDPTX_WRITE_REGISTER.New
cdns_mhdp_reg_write()is created with the general command IDGENERAL_REGISTER_WRITE.Signed-off-by Sandor Yu <[email protected]>---
v9->v10:
*use mhdp helper driver to replace macro functions, move maibox access function and mhdp hdmi/dp common API functions into the driver.drivers/gpu/drm/bridge/cadence/Kconfig | 4 drivers/gpu/drm/bridge/cadence/Makefile | 1 + .../gpu/drm/bridge/cadence/cdns-mhdp-helper.c | 306 ++++++++++++++ .../drm/bridge/cadence/cdns-mhdp8546-core.c | 383 +++--------------- .../drm/bridge/cadence/cdns-mhdp8546-core.h | 44 +- include/drm/bridge/cdns-mhdp-helper.h | 96 +++++ 6 files changed, 473 insertions(+), 361 deletions(-) create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c create mode 100644 include/drm/bridge/cdns-mhdp-helper.h(quoted diff) +0
-0b/drivers/gpu/drm/bridge/cadence/Kconfig index
ec35215a20034..0b7b4626a7af0100644drivers/gpu/drm/bridge/cadence/Kconfig +4
-0@@ -20,6 +20,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@@ -27,6 +30,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(quoted diff) +0
-0b/drivers/gpu/drm/bridge/cadence/Makefile index
c95fd5b81d137..087dc074820d7100644drivers/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(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.cnew file mode 100644 index 0000000000000..2e3eee40494f0drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +15
-0@@ -0,0 +1,306 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023 NXP Semiconductor, Inc. +* +*/ +#include <drm/bridge/cdns-mhdp-helper.h> +#include <linux/dev_printk.h> +#include <linux/module.h> + +/* Mailbox helper functions */ +int cdns_mhdp_mailbox_read (struct cdns_mhdp_base *base) +{ +int ret, empty; + +WARN_ON (!mutex_is_locked (base->mbox_mutex));
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 25
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ + ret =readx_poll_timeout (readl, base->regs +CDNS_MAILBOX_EMPTY , + empty, !empty,MAILBOX_RETRY_US , +MAILBOX_TIMEOUT_US ); +if (ret <0 ) +return ret; + +return readl (base->regs +CDNS_MAILBOX_RX_DATA ) &0xff ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_read);
No need to export this. You can make this function actually static.
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +8
-0+ +int cdns_mhdp_mailbox_write (struct cdns_mhdp_base *base,u8 val) +{ +int ret, full; + +WARN_ON (!mutex_is_locked (base->mbox_mutex)); + + ret = readx_poll_timeout(readl, base->regs + CDNS_MAILBOX_FULL,
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 43
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ full, !full,MAILBOX_RETRY_US , + MAILBOX_TIMEOUT_US); +if (ret <0 ) +return ret; + +writel (val, base->regs +CDNS_MAILBOX_TX_DATA ); + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_write);
No need to export that one as well. You can make this function actually static as these two functions are only called from the helper itself.
Quoted 14 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +14
-0+ +int cdns_mhdp_mailbox_recv_header (struct cdns_mhdp_base *base, +u8 module_id,u8 opcode, +u16 req_size) +{ +u32 mbox_size, i; +u8 header[4 ]; +int ret; + +/* read the header of the message */ +for (i =0 ; i <sizeof (header); i++) { + ret =cdns_mhdp_mailbox_read (base); +if (ret <0 ) +return ret;
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ + header[i] = ret; + } + + mbox_size =get_unaligned_be16 (header +2 ); + +if (opcode != header[0 ] || module_id != header[1 ] || + req_size != mbox_size) { +/* +* If the message in mailbox is not what we want, we need
to
Quoted 125 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +125
-0+* clear the mailbox by reading its contents. +*/ +for (i =0 ; i < mbox_size; i++) +if (cdns_mhdp_mailbox_read (base) <0 ) +break ; + +return -EINVAL ; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_recv_header); + +int cdns_mhdp_mailbox_recv_data (struct cdns_mhdp_base *base, +u8 *buff,u16 buff_size) +{ +u32 i; +int ret; + +for (i =0 ; i < buff_size; i++) { + ret =cdns_mhdp_mailbox_read (base); +if (ret <0 ) +return ret; + + buff[i] = ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_recv_data); + +int cdns_mhdp_mailbox_send (struct cdns_mhdp_base *base,u8 module_id, +u8 opcode,u16 size,u8 *message) +{ +u8 header[4 ]; +int ret, i; + + header[0 ] = opcode; + header[1 ] = module_id; +put_unaligned_be16 (size, header +2 ); + +for (i =0 ; i <sizeof (header); i++) { + ret =cdns_mhdp_mailbox_write (base, header[i]); +if (ret) +return ret; + } + +for (i =0 ; i < size; i++) { + ret =cdns_mhdp_mailbox_write (base, message[i]); +if (ret) +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_send); + +/* General helper functions */ +int cdns_mhdp_reg_read (struct cdns_mhdp_base *base,u32 addr,u32 *value) +{ +u8 msg[4 ], resp[8 ]; +int ret; + +put_unaligned_be32 (addr, msg); + +mutex_lock (base->mbox_mutex); + + ret =cdns_mhdp_mailbox_send (base,MB_MODULE_ID_GENERAL , +GENERAL_REGISTER_READ , +sizeof (msg), msg); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_header (base,MB_MODULE_ID_GENERAL , +GENERAL_REGISTER_READ , +sizeof (resp)); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, resp,sizeof (resp)); +if (ret) + goto out; + +/* Returned address value should be the same as requested */ +if (memcmp (msg, resp,sizeof (msg))) { + ret = -EINVAL ; + goto out; + } + + *value =get_unaligned_be32 (resp +4 ); + +out: +mutex_unlock (base->mbox_mutex); +if (ret) { +dev_err (base->dev,"Failed to read register\n" ); + *value =0 ; + } + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_reg_read); + +int cdns_mhdp_reg_write (struct cdns_mhdp_base *base,u32 addr,u32 val) +{ +u8 msg[8 ]; +int ret; + +put_unaligned_be32 (addr, msg); +put_unaligned_be32 (val, msg +4 ); + +mutex_lock (base->mbox_mutex); + + ret =cdns_mhdp_mailbox_send (base,MB_MODULE_ID_GENERAL , +GENERAL_REGISTER_WRITE , +sizeof (msg), msg); + +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_reg_write); + +/* DPTX helper functions */ +int cdns_mhdp_dp_reg_write (struct cdns_mhdp_base *base,u16 addr,u32 val) +{
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+u8 msg[6 ]; +int ret; + +put_unaligned_be16 (addr, msg); +put_unaligned_be32 (val, msg +2 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_REGISTER, sizeof(msg),
msg);
Quoted 12 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +12
-0+ +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dp_reg_write); + +int cdns_mhdp_dp_reg_write_bit (struct cdns_mhdp_base *base,u16 addr, +u8 start_bit,u8 bits_no,u32 val) +{ +u8 field[8 ]; +int ret;
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ +put_unaligned_be16 (addr, field); + field[2 ] = start_bit; + field[3 ] = bits_no; +put_unaligned_be32 (val, field +4 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_FIELD, sizeof(field),
field);
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dp_reg_write_bit); + +int cdns_mhdp_dpcd_read (struct cdns_mhdp_base *base, +u32 addr,u8 *data,u16 len) +{
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+u8 msg[5 ], reg[5 ]; +int ret; + +put_unaligned_be16 (len, msg); +put_unaligned_be24 (addr, msg +2 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_READ_DPCD, sizeof(msg),
msg);
Quoted 25 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +25
-0+if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_header (base,MB_MODULE_ID_DP_TX , +DPTX_READ_DPCD , +sizeof (reg) + len); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, reg,sizeof (reg)); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, data, len); + +out: +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dpcd_read); + +int cdns_mhdp_dpcd_write (struct cdns_mhdp_base *base,u32 addr,u8 value) +{ +u8 msg[6 ], reg[5 ];
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+int ret; + +put_unaligned_be16 (1 , msg); +put_unaligned_be24 (addr, msg +2 ); + msg[5 ] = value; + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_DPCD, sizeof(msg),
msg);
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 5 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +5
-0+if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_DPCD,
sizeof(reg));
Quoted 95 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +22
-0+if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, reg,sizeof (reg)); +if (ret) + goto out; + +if (addr !=get_unaligned_be24 (reg +2 )) + ret = -EINVAL ; + +out: +mutex_unlock (base->mbox_mutex); + +if (ret) +dev_err (base->dev,"dpcd write failed: %d\n" , ret); +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dpcd_write); + +MODULE_DESCRIPTION ("Cadence MHDP Helper driver" ); +MODULE_AUTHOR ("Sandor Yu <[email protected]>" ); +MODULE_LICENSE ("GPL" );(quoted diff) +0
-0
b/include/drm/bridge/cdns-mhdp-helper.hnew file mode 100644 index 0000000000000..b89db9e842266include/drm/bridge/cdns-mhdp-helper.h new file +66
-0@@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023 NXP Semiconductor, Inc. +*/ +#ifndef __CDNS_MHDP_HELPER_H__ +#define __CDNS_MHDP_HELPER_H__ + +#include <asm/unaligned.h> +#include <linux/iopoll.h> + +/* mailbox regs offset */ +#define CDNS_MAILBOX_FULL 0x00008 +#define CDNS_MAILBOX_EMPTY 0x0000c +#define CDNS_MAILBOX_TX_DATA 0x00010 +#define CDNS_MAILBOX_RX_DATA 0x00014 + +#define MAILBOX_RETRY_US 1000 +#define MAILBOX_TIMEOUT_US 2000000 + +/* Module ID Code */ +#define MB_MODULE_ID_DP_TX 0x01 +#define MB_MODULE_ID_HDMI_TX 0x03 +#define MB_MODULE_ID_HDCP_TX 0x07 +#define MB_MODULE_ID_HDCP_RX 0x08 +#define MB_MODULE_ID_HDCP_GENERAL 0x09 +#define MB_MODULE_ID_GENERAL 0x0A + +/* General Commands */ +#define GENERAL_MAIN_CONTROL 0x01 +#define GENERAL_TEST_ECHO 0x02 +#define GENERAL_BUS_SETTINGS 0x03 +#define GENERAL_TEST_ACCESS 0x04 +#define GENERAL_REGISTER_WRITE 0x05 +#define GENERAL_WRITE_FIELD 0x06 +#define GENERAL_REGISTER_READ 0x07 +#define GENERAL_GET_HPD_STATE 0x11 + +/* DPTX Commands */ +#define DPTX_SET_POWER_MNG 0x00 +#define DPTX_SET_HOST_CAPABILITIES 0x01 +#define DPTX_GET_EDID 0x02 +#define DPTX_READ_DPCD 0x03 +#define DPTX_WRITE_DPCD 0x04 +#define DPTX_ENABLE_EVENT 0x05 +#define DPTX_WRITE_REGISTER 0x06 +#define DPTX_READ_REGISTER 0x07 +#define DPTX_WRITE_FIELD 0x08 +#define DPTX_TRAINING_CONTROL 0x09 +#define DPTX_READ_EVENT 0x0a +#define DPTX_READ_LINK_STAT 0x0b +#define DPTX_SET_VIDEO 0x0c +#define DPTX_SET_AUDIO 0x0d +#define DPTX_GET_LAST_AUX_STAUS 0x0e +#define DPTX_SET_LINK_BREAK_POINT 0x0f +#define DPTX_FORCE_LANES 0x10 +#define DPTX_HPD_STATE 0x11 +#define DPTX_ADJUST_LT 0x12 + +/* HDMI TX Commands */ +#define HDMI_TX_READ 0x00 +#define HDMI_TX_WRITE 0x01 +#define HDMI_TX_UPDATE_READ 0x02 +#define HDMI_TX_EDID 0x03 +#define HDMI_TX_EVENTS 0x04 +#define HDMI_TX_HPD_STATUS 0x05 +
include/drm/bridge/cdns-mhdp-helper.h line 76
Quoted 10 lines
include/drm/bridge/cdns-mhdp-helper.h new file +10
-0+struct cdns_mhdp_base { +struct device *dev; +void __iomem *regs; +/* protect mailbox communications with the firmware */ +struct mutex *mbox_mutex; +}; + +/* Mailbox helper functions */ +int cdns_mhdp_mailbox_read (struct cdns_mhdp_base *base); +int cdns_mhdp_mailbox_write (struct cdns_mhdp_base *base,u8 val);
You can remove these two declarations.
Best regards,
Alexander
Best regards,
include/drm/bridge/cdns-mhdp-helper.h line 78
Quoted 2 lines
include/drm/bridge/cdns-mhdp-helper.h new file +2
-0+int cdns_mhdp_mailbox_recv_header (struct cdns_mhdp_base *base, + u8 module_id, u8 opcode, u16
req_size);
Quoted 9 lines
include/drm/bridge/cdns-mhdp-helper.h new file +9
-0+int cdns_mhdp_mailbox_recv_data (struct cdns_mhdp_base *base, +u8 *buff,u16 buff_size); +int cdns_mhdp_mailbox_send (struct cdns_mhdp_base *base,u8 module_id, +u8 opcode,u16 size,u8 *message); + +/* General commands helper functions */ +int cdns_mhdp_reg_read (struct cdns_mhdp_base *base,u32 addr,u32 *value); +int cdns_mhdp_reg_write (struct cdns_mhdp_base *base,u32 addr,u32 val); +
include/drm/bridge/cdns-mhdp-helper.h line 96
Quoted 10 lines
include/drm/bridge/cdns-mhdp-helper.h new file +8
-0+/* DPTX commands helper functions */ +int cdns_mhdp_dp_reg_write (struct cdns_mhdp_base *base,u16 addr,u32 val); +int cdns_mhdp_dp_reg_write_bit(struct cdns_mhdp_base *base, u16 addr, +u8 start_bit,u8 bits_no,u32 val); +int cdns_mhdp_dpcd_read (struct cdns_mhdp_base *base, +u32 addr,u8 *data,u16 len); +int cdns_mhdp_dpcd_write (struct cdns_mhdp_base *base,u32 addr,u8 value); + +#endif /* __CDNS_MHDP_HELPER_H__ */
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
RE: [EXT] Re: [PATCH v10 1/7] drm: bridge: Cadence: Creat mhdp helper driver
Hi Alexander,
Thanks your comments,
Quoted 94 lines
Hi Sandor,
thanks for the updated series.
Am Freitag, 13. Oktober 2023, 05:24:20 CEST schrieb Sandor Yu:
Quoted 58 lines
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 tocdns_mhdp_dp_reg_write(), because it use the DPTX command IDDPTX_WRITE_REGISTER.New
cdns_mhdp_reg_write()is created with the general command IDGENERAL_REGISTER_WRITE.Signed-off-by Sandor Yu <[email protected]>---
v9->v10:
*use mhdp helper driver to replace macro functions, move maibox
access function and mhdp hdmi/dp common API functions into the driver.drivers/gpu/drm/bridge/cadence/Kconfig | 4 drivers/gpu/drm/bridge/cadence/Makefile | 1 + .../gpu/drm/bridge/cadence/cdns-mhdp-helper.c | 306 ++++++++++++++ .../drm/bridge/cadence/cdns-mhdp8546-core.c | 383 +++--------------- .../drm/bridge/cadence/cdns-mhdp8546-core.h | 44 +- include/drm/bridge/cdns-mhdp-helper.h | 96 +++++ 6 files changed, 473 insertions(+), 361 deletions(-) create mode 100644 drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c create mode 100644 include/drm/bridge/cdns-mhdp-helper.h(quoted diff) +0
-0b/drivers/gpu/drm/bridge/cadence/Kconfig index
ec35215a20034..0b7b4626a7af0
100644drivers/gpu/drm/bridge/cadence/Kconfig +4
-1@@ -20,6 +20,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@@ -27,6 +30,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 diff --git a/drivers/gpu/drm/bridge/cadence/Makefileb/drivers/gpu/drm/bridge/cadence/Makefile index
c95fd5b81d137..087dc074820d7100644drivers/gpu/drm/bridge/cadence/Makefile +0
-0@@ -2,6 +2,7 @@ obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o cdns-dsi-y :=Quoted 4 lines
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.ocdns-mhdp8546-y
Quoted 14 lines
:= cdns-mhdp8546-core.o cdns-mhdp8546-hdcp.o
cdns-mhdp8546-$(CONFIG_DRM_CDNS_MHDP8546_J721E) +=
cdns-mhdp8546-j721e.o diff --gita/drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.cb/drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.cnew file mode 100644 index 0000000000000..2e3eee40494f0drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +5
-0@@ -0,0 +1,306 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023 NXP Semiconductor, Inc. +* +*/ drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 15
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+#include <drm/bridge/cdns-mhdp-helper.h> #include +<linux/dev_printk.h> #include <linux/module.h> + +/* Mailbox helper functions */ +int cdns_mhdp_mailbox_read (struct cdns_mhdp_base *base) { +int ret, empty; + +WARN_ON (!mutex_is_locked (base->mbox_mutex)); + + ret = readx_poll_timeout(readl, base->regs +
CDNS_MAILBOX_EMPTY,
Quoted 9 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 25
Quoted 7 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +7
-0+ empty, !empty,MAILBOX_RETRY_US , + MAILBOX_TIMEOUT_US); +if (ret <0 ) +return ret; + +return readl (base->regs +CDNS_MAILBOX_RX_DATA ) &0xff ; } +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_read);No need to export this. You can make this function actually static.
OK, I will change it to static in the next version.
Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +12
-0+ +int cdns_mhdp_mailbox_write (struct cdns_mhdp_base *base,u8 val) { +int ret, full; + +WARN_ON (!mutex_is_locked (base->mbox_mutex)); + + ret =readx_poll_timeout (readl, base->regs +CDNS_MAILBOX_FULL , + full, !full,MAILBOX_RETRY_US , +MAILBOX_TIMEOUT_US ); +if (ret <0 ) +return ret; +
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 43
Quoted 5 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +5
-0+writel (val, base->regs +CDNS_MAILBOX_TX_DATA ); + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_write);No need to export that one as well. You can make this function actually static as these two functions are only called from the helper itself.
mhdp8546 driver need this function.
Quoted 352 lines
Quoted 15 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +14
-0+ +int cdns_mhdp_mailbox_recv_header (struct cdns_mhdp_base *base, +u8 module_id,u8 opcode, +u16 req_size) { +u32 mbox_size, i; +u8 header[4 ]; +int ret; + +/* read the header of the message */ +for (i =0 ; i <sizeof (header); i++) { + ret =cdns_mhdp_mailbox_read (base); +if (ret <0 ) +return ret; +drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ header[i] = ret; + } + + mbox_size =get_unaligned_be16 (header +2 ); + +if (opcode != header[0 ] || module_id != header[1 ] || + req_size != mbox_size) { +/* +* If the message in mailbox is not what we want, we +need to
Quoted 21 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +21
-0+* clear the mailbox by reading its contents. +*/ +for (i =0 ; i < mbox_size; i++) +if (cdns_mhdp_mailbox_read (base) <0 ) +break ; + +return -EINVAL ; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_recv_header); + +int cdns_mhdp_mailbox_recv_data (struct cdns_mhdp_base *base, +u8 *buff,u16 buff_size) { +u32 i; +int ret; + +for (i =0 ; i < buff_size; i++) { + ret =cdns_mhdp_mailbox_read (base); +if (ret <0 )drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+return ret; + + buff[i] = ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_recv_data); + +int cdns_mhdp_mailbox_send(struct cdns_mhdp_base *base, u8
module_id,Quoted 31 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +31
-0+ u8 opcode, u16 size, u8 *message) { + u8 header[4]; +int ret, i; + + header[0 ] = opcode; + header[1 ] = module_id; +put_unaligned_be16 (size, header +2 ); + +for (i =0 ; i <sizeof (header); i++) { + ret =cdns_mhdp_mailbox_write (base, header[i]); +if (ret) +return ret; + } + +for (i =0 ; i < size; i++) { + ret =cdns_mhdp_mailbox_write (base, message[i]); +if (ret) +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_send); + +/* General helper functions */ +int cdns_mhdp_reg_read (struct cdns_mhdp_base *base,u32 addr,u32 +*value) { +u8 msg[4 ], resp[8 ]; +int ret; + +put_unaligned_be32 (addr, msg);drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ +mutex_lock (base->mbox_mutex); + + ret =cdns_mhdp_mailbox_send (base,MB_MODULE_ID_GENERAL , +GENERAL_REGISTER_READ , +sizeof (msg), msg); +if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(base,
MB_MODULE_ID_GENERAL,drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 136
Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +1
-0+
GENERAL_REGISTER_READ,Quoted 39 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +39
-0+ sizeof(resp)); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, resp,sizeof (resp)); +if (ret) + goto out; + +/* Returned address value should be the same as requested */ +if (memcmp (msg, resp,sizeof (msg))) { + ret = -EINVAL ; + goto out; + } + + *value =get_unaligned_be32 (resp +4 ); + +out: +mutex_unlock (base->mbox_mutex); +if (ret) { +dev_err (base->dev,"Failed to read register\n" ); + *value =0 ; + } + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_reg_read); + +int cdns_mhdp_reg_write (struct cdns_mhdp_base *base,u32 addr,u32 +val) { +u8 msg[8 ]; +int ret; + +put_unaligned_be32 (addr, msg); +put_unaligned_be32 (val, msg +4 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_GENERAL, + GENERAL_REGISTER_WRITE,drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ sizeof(msg), msg); + +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_reg_write); + +/* DPTX helper functions */ +int cdns_mhdp_dp_reg_write(struct cdns_mhdp_base *base, u16 addr,u32
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 11 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +11
-0+val) { +u8 msg[6 ]; +int ret; + +put_unaligned_be16 (addr, msg); +put_unaligned_be32 (val, msg +2 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_REGISTER,sizeof(msg),
msg);Quoted 11 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +11
-0+ +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dp_reg_write); + +int cdns_mhdp_dp_reg_write_bit (struct cdns_mhdp_base *base,u16 addr, +u8 start_bit,u8 bits_no,u32 val) { +u8 field[8 ]; +int ret;drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ +put_unaligned_be16 (addr, field); + field[2 ] = start_bit; + field[3 ] = bits_no; +put_unaligned_be32 (val, field +4 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_FIELD,sizeof(field),
field);Quoted 9 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +9
-0+ +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dp_reg_write_bit); + +int cdns_mhdp_dpcd_read (struct cdns_mhdp_base *base, +u32 addr,u8 *data,u16 len) {drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+u8 msg[5 ], reg[5 ]; +int ret; + +put_unaligned_be16 (len, msg); +put_unaligned_be24 (addr, msg +2 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_READ_DPCD, sizeof(msg),msg);
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 4 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +4
-0+if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(base,
MB_MODULE_ID_DP_TX,Quoted 21 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +21
-0+DPTX_READ_DPCD , + sizeof(reg) + len); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, reg,sizeof (reg)); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, data, len); + +out: +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dpcd_read); + +int cdns_mhdp_dpcd_write (struct cdns_mhdp_base *base,u32 addr,u8 +value) { +u8 msg[6 ], reg[5 ];drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+int ret; + +put_unaligned_be16 (1 , msg); +put_unaligned_be24 (addr, msg +2 ); + msg[5 ] = value; + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_DPCD,sizeof(msg),
msg);drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c
Quoted 4 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +4
-0+if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(base,
MB_MODULE_ID_DP_TX,drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 276
Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +1
-0+ DPTX_WRITE_DPCD,sizeof(reg));
Quoted 99 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +22
-0+if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, reg,sizeof (reg)); +if (ret) + goto out; + +if (addr !=get_unaligned_be24 (reg +2 )) + ret = -EINVAL ; + +out: +mutex_unlock (base->mbox_mutex); + +if (ret) +dev_err (base->dev,"dpcd write failed: %d\n" , ret); +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dpcd_write); + +MODULE_DESCRIPTION ("Cadence MHDP Helper driver" ); +MODULE_AUTHOR ("Sandor Yu <[email protected]>" ); +MODULE_LICENSE ("GPL" );(quoted diff) +0
-0
b/include/drm/bridge/cdns-mhdp-helper.hnew file mode 100644 index 0000000000000..b89db9e842266include/drm/bridge/cdns-mhdp-helper.h new file +70
-0@@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023 NXP Semiconductor, Inc. +*/ +#ifndef __CDNS_MHDP_HELPER_H__ +#define __CDNS_MHDP_HELPER_H__ + +#include <asm/unaligned.h> +#include <linux/iopoll.h> + +/* mailbox regs offset */ +#define CDNS_MAILBOX_FULL 0x00008 +#define CDNS_MAILBOX_EMPTY 0x0000c +#define CDNS_MAILBOX_TX_DATA 0x00010 +#define CDNS_MAILBOX_RX_DATA 0x00014 + +#define MAILBOX_RETRY_US 1000 +#define MAILBOX_TIMEOUT_US 2000000 + +/* Module ID Code */ +#define MB_MODULE_ID_DP_TX 0x01 +#define MB_MODULE_ID_HDMI_TX 0x03 +#define MB_MODULE_ID_HDCP_TX 0x07 +#define MB_MODULE_ID_HDCP_RX 0x08 +#define MB_MODULE_ID_HDCP_GENERAL 0x09 +#define MB_MODULE_ID_GENERAL 0x0A + +/* General Commands */ +#define GENERAL_MAIN_CONTROL 0x01 +#define GENERAL_TEST_ECHO 0x02 +#define GENERAL_BUS_SETTINGS 0x03 +#define GENERAL_TEST_ACCESS 0x04 +#define GENERAL_REGISTER_WRITE 0x05 +#define GENERAL_WRITE_FIELD 0x06 +#define GENERAL_REGISTER_READ 0x07 +#define GENERAL_GET_HPD_STATE 0x11 + +/* DPTX Commands */ +#define DPTX_SET_POWER_MNG 0x00 +#define DPTX_SET_HOST_CAPABILITIES 0x01 +#define DPTX_GET_EDID 0x02 +#define DPTX_READ_DPCD 0x03 +#define DPTX_WRITE_DPCD 0x04 +#define DPTX_ENABLE_EVENT 0x05 +#define DPTX_WRITE_REGISTER 0x06 +#define DPTX_READ_REGISTER 0x07 +#define DPTX_WRITE_FIELD 0x08 +#define DPTX_TRAINING_CONTROL 0x09 +#define DPTX_READ_EVENT 0x0a +#define DPTX_READ_LINK_STAT 0x0b +#define DPTX_SET_VIDEO 0x0c +#define DPTX_SET_AUDIO 0x0d +#define DPTX_GET_LAST_AUX_STAUS 0x0e +#define DPTX_SET_LINK_BREAK_POINT 0x0f +#define DPTX_FORCE_LANES 0x10 +#define DPTX_HPD_STATE 0x11 +#define DPTX_ADJUST_LT 0x12 + +/* HDMI TX Commands */ +#define HDMI_TX_READ 0x00 +#define HDMI_TX_WRITE 0x01 +#define HDMI_TX_UPDATE_READ 0x02 +#define HDMI_TX_EDID 0x03 +#define HDMI_TX_EVENTS 0x04 +#define HDMI_TX_HPD_STATUS 0x05 + +struct cdns_mhdp_base { + struct device *dev; + void __iomem *regs; + /* protect mailbox communications with the firmware */
Quoted 8 lines
include/drm/bridge/cdns-mhdp-helper.h
Quoted 6 lines
include/drm/bridge/cdns-mhdp-helper.h new file +6
-0+struct mutex *mbox_mutex; +}; + +/* Mailbox helper functions */ +int cdns_mhdp_mailbox_read (struct cdns_mhdp_base *base);int +cdns_mhdp_mailbox_write (struct cdns_mhdp_base *base,u8 val);You can remove these two declarations.
cdns_mhdp_mailbox_read will be removed. Thanks!
B.R
Sandor
Quoted 36 lines
Best regards,
AlexanderBest regards,
include/drm/bridge/cdns-mhdp-helper.h line 78
Quoted 2 lines
include/drm/bridge/cdns-mhdp-helper.h new file +2
-0+int cdns_mhdp_mailbox_recv_header (struct cdns_mhdp_base *base, + u8 module_id, u8 opcode, u16
req_size);include/drm/bridge/cdns-mhdp-helper.h line 89
Quoted 11 lines
include/drm/bridge/cdns-mhdp-helper.h new file +11
-0+int cdns_mhdp_mailbox_recv_data (struct cdns_mhdp_base *base, +u8 *buff,u16 buff_size);int +cdns_mhdp_mailbox_send (struct cdns_mhdp_base *base,u8 module_id, +u8 opcode,u16 size,u8 *message); + +/* General commands helper functions */ int cdns_mhdp_reg_read (struct +cdns_mhdp_base *base,u32 addr,u32 *value);int +cdns_mhdp_reg_write (struct cdns_mhdp_base *base,u32 addr,u32 val); + +/* DPTX commands helper functions */ +int cdns_mhdp_dp_reg_write(struct cdns_mhdp_base *base, u16 addr,u32
include/drm/bridge/cdns-mhdp-helper.h
Quoted 10 lines
include/drm/bridge/cdns-mhdp-helper.h new file +8
-0+val); int cdns_mhdp_dp_reg_write_bit(struct cdns_mhdp_base *base, u16 +addr, +u8 start_bit,u8 bits_no,u32 val); +int cdns_mhdp_dpcd_read (struct cdns_mhdp_base *base, +u32 addr,u8 *data,u16 len);int +cdns_mhdp_dpcd_write (struct cdns_mhdp_base *base,u32 addr,u8 +value); + +#endif /* __CDNS_MHDP_HELPER_H__ */ 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
Re: [PATCH v10 1/7] drm: bridge: Cadence: Creat mhdp helper driver
Hi Sandor,
Am Montag, 16. Oktober 2023, 05:05:54 CEST schrieb Sandor Yu:
Quoted 155 lines
Hi Alexander,
Thanks your comments,
Quoted 118 lines
Hi Sandor,
thanks for the updated series.
Am Freitag, 13. Oktober 2023, 05:24:20 CEST schrieb Sandor Yu:
Quoted 76 lines
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 tocdns_mhdp_dp_reg_write(), because it use the DPTX command IDDPTX_WRITE_REGISTER.New
cdns_mhdp_reg_write()is created with the general command IDGENERAL_REGISTER_WRITE.Signed-off-by Sandor Yu <[email protected]>---
v9->v10:
*use mhdp helper driver to replace macro functions, move maiboxaccess function and mhdp hdmi/dp common API functions into the driver.
drivers/gpu/drm/bridge/cadence/Kconfig | 4 drivers/gpu/drm/bridge/cadence/Makefile | 1 + .../gpu/drm/bridge/cadence/cdns-mhdp-helper.c | 306 ++++++++++++++ .../drm/bridge/cadence/cdns-mhdp8546-core.c | 383 +++--------------- .../drm/bridge/cadence/cdns-mhdp8546-core.h | 44 +- include/drm/bridge/cdns-mhdp-helper.h | 96 +++++ 6 files changed, 473 insertions(+), 361 deletions(-) create mode100644
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.ccreate mode 100644 include/drm/bridge/cdns-mhdp-helper.h(quoted diff) +0
-0b/drivers/gpu/drm/bridge/cadence/Kconfig index
ec35215a20034..0b7b4626a7af0
100644drivers/gpu/drm/bridge/cadence/Kconfig +3
-0@@ -20,6 +20,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_MHDP8546tristate "Cadence DPI/DP bridge"
selectDRM_DISPLAY_DP_HELPERdrivers/gpu/drm/bridge/cadence/Kconfig +1
-0@@ -27,6 +30,7 @@ config DRM_CDNS_MHDP8546 select DRM_DISPLAY_HELPER select DRM_KMS_HELPER select DRM_PANEL_BRIDGE + select CDNS_MHDP_HELPERdepends on OF
helpSupport Cadence DPI to DP bridge. This is an internal diff
--git a/drivers/gpu/drm/bridge/cadence/Makefile
b/drivers/gpu/drm/bridge/cadence/Makefile indexc95fd5b81d137..087dc074820d7100644drivers/gpu/drm/bridge/cadence/Makefile +0
-0@@ -2,6 +2,7 @@ obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o cdns-dsi-y :=cdns-dsi-core.o
Quoted 5 lines
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
Quoted 16 lines
:= cdns-mhdp8546-core.o cdns-mhdp8546-hdcp.o :
cdns-mhdp8546-$(CONFIG_DRM_CDNS_MHDP8546_J721E) +=cdns-mhdp8546-j721e.o diff --git
a/drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.cb/drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.cnew file mode 100644 index 0000000000000..2e3eee40494f0drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +5
-0@@ -0,0 +1,306 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023 NXP Semiconductor, Inc. +* +*/ drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 15
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+#include <drm/bridge/cdns-mhdp-helper.h> #include +<linux/dev_printk.h> #include <linux/module.h> + +/* Mailbox helper functions */ +int cdns_mhdp_mailbox_read (struct cdns_mhdp_base *base) { +int ret, empty; + +WARN_ON (!mutex_is_locked (base->mbox_mutex)); + + ret = readx_poll_timeout(readl, base->regs +
CDNS_MAILBOX_EMPTY,Quoted 9 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 22
Quoted 7 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +7
-0+ empty, !empty,MAILBOX_RETRY_US , + MAILBOX_TIMEOUT_US); +if (ret <0 ) +return ret; + +return readl (base->regs +CDNS_MAILBOX_RX_DATA ) &0xff ; } +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_read);No need to export this. You can make this function actually static.
OK, I will change it to static in the next version.
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +12
-0+ +int cdns_mhdp_mailbox_write (struct cdns_mhdp_base *base,u8 val) { +int ret, full; + +WARN_ON (!mutex_is_locked (base->mbox_mutex)); + + ret =readx_poll_timeout (readl, base->regs +CDNS_MAILBOX_FULL , + full, !full,MAILBOX_RETRY_US , +MAILBOX_TIMEOUT_US ); +if (ret <0 ) +return ret; +Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 39
Quoted 5 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +5
-0+writel (val, base->regs +CDNS_MAILBOX_TX_DATA ); + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_write);No need to export that one as well. You can make this function actually static as these two functions are only called from the helper itself.
Quoted 1 line
mhdp8546 driver need this function.
True, cdns_mhdp_set_firmware_active() needs this. But this call seems a bit fishy. Couldn't this be written as follow?
---8<--
drivers/ renamed from drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +0 -0
gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index 0582a5e42763f..c0364d05406cd 100644
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +0 -0
@@ -78,22 +78,16 @@ static void cdns_mhdp_bridge_hpd_disable(struct drm_bridge
*bridge)
static
int cdns_mhdp_set_firmware_active(struct cdns_mhdp_device *mhdp, bool enable) {
- u8 msg[5];
+ u8 msg[1];
int ret, i;- msg[0] = GENERAL_MAIN_CONTROL; - msg[1] = MB_MODULE_ID_GENERAL; - msg[2] = 0; - msg[3] = 1; - msg[4] = enable ? FW_ACTIVE : FW_STANDBY; + msg[0] = enable ? FW_ACTIVE : FW_STANDBY;
mutex_lock(&mhdp->mbox_mutex);
- for (i = 0; i < sizeof(msg); i++) {
- ret = cdns_mhdp_mailbox_write(&mhdp->base, msg[i]);
- if (ret)
- goto out;
- }
+ ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_GENERAL,
+ GENERAL_MAIN_CONTROL,
+ sizeof(msg), msg);
/* read the firmware state */
ret = cdns_mhdp_mailbox_recv_data(&mhdp->base, msg, sizeof(msg));---8<--
AFAICS cdns_mhdp_mailbox_send() is only a sequence of writes, writing 4 byte header and 1 byte data in this case.
Best regards,
Alexander
Quoted 429 lines
Quoted 376 lines
Quoted 15 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +14
-0+ +int cdns_mhdp_mailbox_recv_header (struct cdns_mhdp_base *base, +u8 module_id,u8 opcode, +u16 req_size) { +u32 mbox_size, i; +u8 header[4 ]; +int ret; + +/* read the header of the message */ +for (i =0 ; i <sizeof (header); i++) { + ret =cdns_mhdp_mailbox_read (base); +if (ret <0 ) +return ret; +drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 63
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ header[i] = ret; + } + + mbox_size =get_unaligned_be16 (header +2 ); + +if (opcode != header[0 ] || module_id != header[1 ] || + req_size != mbox_size) { +/* +* If the message in mailbox is not what we want, we +need to
Quoted 21 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +21
-0+* clear the mailbox by reading its contents. +*/ +for (i =0 ; i < mbox_size; i++) +if (cdns_mhdp_mailbox_read (base) <0 ) +break ; + +return -EINVAL ; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_recv_header); + +int cdns_mhdp_mailbox_recv_data (struct cdns_mhdp_base *base, +u8 *buff,u16 buff_size) { +u32 i; +int ret; + +for (i =0 ; i < buff_size; i++) { + ret =cdns_mhdp_mailbox_read (base); +if (ret <0 )drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 94
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+return ret; + + buff[i] = ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_recv_data); + +int cdns_mhdp_mailbox_send(struct cdns_mhdp_base *base, u8
module_id,Quoted 31 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +31
-0+ u8 opcode, u16 size, u8 *message) { + u8 header[4]; +int ret, i; + + header[0 ] = opcode; + header[1 ] = module_id; +put_unaligned_be16 (size, header +2 ); + +for (i =0 ; i <sizeof (header); i++) { + ret =cdns_mhdp_mailbox_write (base, header[i]); +if (ret) +return ret; + } + +for (i =0 ; i < size; i++) { + ret =cdns_mhdp_mailbox_write (base, message[i]); +if (ret) +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_send); + +/* General helper functions */ +int cdns_mhdp_reg_read (struct cdns_mhdp_base *base,u32 addr,u32 +*value) { +u8 msg[4 ], resp[8 ]; +int ret; + +put_unaligned_be32 (addr, msg);drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 135
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ +mutex_lock (base->mbox_mutex); + + ret =cdns_mhdp_mailbox_send (base,MB_MODULE_ID_GENERAL , +GENERAL_REGISTER_READ , +sizeof (msg), msg); +if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(base,
MB_MODULE_ID_GENERAL,drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 136
Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +1
-0+
GENERAL_REGISTER_READ,Quoted 39 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +39
-0+ sizeof(resp)); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, resp,sizeof (resp)); +if (ret) + goto out; + +/* Returned address value should be the same as requested */ +if (memcmp (msg, resp,sizeof (msg))) { + ret = -EINVAL ; + goto out; + } + + *value =get_unaligned_be32 (resp +4 ); + +out: +mutex_unlock (base->mbox_mutex); +if (ret) { +dev_err (base->dev,"Failed to read register\n" ); + *value =0 ; + } + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_reg_read); + +int cdns_mhdp_reg_write (struct cdns_mhdp_base *base,u32 addr,u32 +val) { +u8 msg[8 ]; +int ret; + +put_unaligned_be32 (addr, msg); +put_unaligned_be32 (val, msg +4 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_GENERAL, + GENERAL_REGISTER_WRITE,drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 185
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ sizeof(msg), msg); + +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_reg_write); + +/* DPTX helper functions */ +int cdns_mhdp_dp_reg_write(struct cdns_mhdp_base *base, u16 addr,u32
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 196
Quoted 11 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +11
-0+val) { +u8 msg[6 ]; +int ret; + +put_unaligned_be16 (addr, msg); +put_unaligned_be32 (val, msg +2 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_REGISTER,sizeof(msg),
msg);Quoted 11 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +11
-0+ +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dp_reg_write); + +int cdns_mhdp_dp_reg_write_bit (struct cdns_mhdp_base *base,u16 addr, +u8 start_bit,u8 bits_no,u32 val) { +u8 field[8 ]; +int ret;drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 217
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ +put_unaligned_be16 (addr, field); + field[2 ] = start_bit; + field[3 ] = bits_no; +put_unaligned_be32 (val, field +4 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_FIELD,sizeof(field),
field);Quoted 9 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +9
-0+ +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dp_reg_write_bit); + +int cdns_mhdp_dpcd_read (struct cdns_mhdp_base *base, +u32 addr,u8 *data,u16 len) {drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 236
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+u8 msg[5 ], reg[5 ]; +int ret; + +put_unaligned_be16 (len, msg); +put_unaligned_be24 (addr, msg +2 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_READ_DPCD, sizeof(msg),msg);
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 240
Quoted 4 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +4
-0+if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(base,
MB_MODULE_ID_DP_TX,Quoted 21 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +21
-0+DPTX_READ_DPCD , + sizeof(reg) + len); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, reg,sizeof (reg)); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, data, len); + +out: +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dpcd_read); + +int cdns_mhdp_dpcd_write (struct cdns_mhdp_base *base,u32 addr,u8 +value) { +u8 msg[6 ], reg[5 ];drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 271
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+int ret; + +put_unaligned_be16 (1 , msg); +put_unaligned_be24 (addr, msg +2 ); + msg[5 ] = value; + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_DPCD,sizeof(msg),
msg);drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 275
Quoted 4 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +4
-0+if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(base,
MB_MODULE_ID_DP_TX,drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 276
Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +1
-0+ DPTX_WRITE_DPCD,sizeof(reg));
Quoted 99 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +22
-0+if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, reg,sizeof (reg)); +if (ret) + goto out; + +if (addr !=get_unaligned_be24 (reg +2 )) + ret = -EINVAL ; + +out: +mutex_unlock (base->mbox_mutex); + +if (ret) +dev_err (base->dev,"dpcd write failed: %d\n" , ret); +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dpcd_write); + +MODULE_DESCRIPTION ("Cadence MHDP Helper driver" ); +MODULE_AUTHOR ("Sandor Yu <[email protected]>" ); +MODULE_LICENSE ("GPL" );(quoted diff) +0
-0
b/include/drm/bridge/cdns-mhdp-helper.hnew file mode 100644 index 0000000000000..b89db9e842266include/drm/bridge/cdns-mhdp-helper.h new file +70
-0@@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023 NXP Semiconductor, Inc. +*/ +#ifndef __CDNS_MHDP_HELPER_H__ +#define __CDNS_MHDP_HELPER_H__ + +#include <asm/unaligned.h> +#include <linux/iopoll.h> + +/* mailbox regs offset */ +#define CDNS_MAILBOX_FULL 0x00008 +#define CDNS_MAILBOX_EMPTY 0x0000c +#define CDNS_MAILBOX_TX_DATA 0x00010 +#define CDNS_MAILBOX_RX_DATA 0x00014 + +#define MAILBOX_RETRY_US 1000 +#define MAILBOX_TIMEOUT_US 2000000 + +/* Module ID Code */ +#define MB_MODULE_ID_DP_TX 0x01 +#define MB_MODULE_ID_HDMI_TX 0x03 +#define MB_MODULE_ID_HDCP_TX 0x07 +#define MB_MODULE_ID_HDCP_RX 0x08 +#define MB_MODULE_ID_HDCP_GENERAL 0x09 +#define MB_MODULE_ID_GENERAL 0x0A + +/* General Commands */ +#define GENERAL_MAIN_CONTROL 0x01 +#define GENERAL_TEST_ECHO 0x02 +#define GENERAL_BUS_SETTINGS 0x03 +#define GENERAL_TEST_ACCESS 0x04 +#define GENERAL_REGISTER_WRITE 0x05 +#define GENERAL_WRITE_FIELD 0x06 +#define GENERAL_REGISTER_READ 0x07 +#define GENERAL_GET_HPD_STATE 0x11 + +/* DPTX Commands */ +#define DPTX_SET_POWER_MNG 0x00 +#define DPTX_SET_HOST_CAPABILITIES 0x01 +#define DPTX_GET_EDID 0x02 +#define DPTX_READ_DPCD 0x03 +#define DPTX_WRITE_DPCD 0x04 +#define DPTX_ENABLE_EVENT 0x05 +#define DPTX_WRITE_REGISTER 0x06 +#define DPTX_READ_REGISTER 0x07 +#define DPTX_WRITE_FIELD 0x08 +#define DPTX_TRAINING_CONTROL 0x09 +#define DPTX_READ_EVENT 0x0a +#define DPTX_READ_LINK_STAT 0x0b +#define DPTX_SET_VIDEO 0x0c +#define DPTX_SET_AUDIO 0x0d +#define DPTX_GET_LAST_AUX_STAUS 0x0e +#define DPTX_SET_LINK_BREAK_POINT 0x0f +#define DPTX_FORCE_LANES 0x10 +#define DPTX_HPD_STATE 0x11 +#define DPTX_ADJUST_LT 0x12 + +/* HDMI TX Commands */ +#define HDMI_TX_READ 0x00 +#define HDMI_TX_WRITE 0x01 +#define HDMI_TX_UPDATE_READ 0x02 +#define HDMI_TX_EDID 0x03 +#define HDMI_TX_EVENTS 0x04 +#define HDMI_TX_HPD_STATUS 0x05 + +struct cdns_mhdp_base { + struct device *dev; + void __iomem *regs; + /* protect mailbox communications with the firmware */Quoted 8 lines
include/drm/bridge/cdns-mhdp-helper.h line 76
Quoted 6 lines
include/drm/bridge/cdns-mhdp-helper.h new file +6
-0+struct mutex *mbox_mutex; +}; + +/* Mailbox helper functions */ +int cdns_mhdp_mailbox_read (struct cdns_mhdp_base *base);int +cdns_mhdp_mailbox_write (struct cdns_mhdp_base *base,u8 val);You can remove these two declarations.
cdns_mhdp_mailbox_readwill be removed. Thanks!B.R
SandorQuoted 39 lines
Best regards,
AlexanderBest regards,
include/drm/bridge/cdns-mhdp-helper.h line 78
Quoted 2 lines
include/drm/bridge/cdns-mhdp-helper.h new file +2
-0+int cdns_mhdp_mailbox_recv_header (struct cdns_mhdp_base *base, + u8 module_id, u8 opcode, u16
req_size);include/drm/bridge/cdns-mhdp-helper.h line 89
Quoted 11 lines
include/drm/bridge/cdns-mhdp-helper.h new file +11
-0+int cdns_mhdp_mailbox_recv_data (struct cdns_mhdp_base *base, +u8 *buff,u16 buff_size);int +cdns_mhdp_mailbox_send (struct cdns_mhdp_base *base,u8 module_id, +u8 opcode,u16 size,u8 *message); + +/* General commands helper functions */ int cdns_mhdp_reg_read (struct +cdns_mhdp_base *base,u32 addr,u32 *value);int +cdns_mhdp_reg_write (struct cdns_mhdp_base *base,u32 addr,u32 val); + +/* DPTX commands helper functions */ +int cdns_mhdp_dp_reg_write(struct cdns_mhdp_base *base, u16 addr,u32
include/drm/bridge/cdns-mhdp-helper.h
Quoted 11 lines
include/drm/bridge/cdns-mhdp-helper.h new file +8
-0+val); int cdns_mhdp_dp_reg_write_bit(struct cdns_mhdp_base *base, u16 +addr, +u8 start_bit,u8 bits_no,u32 val); +int cdns_mhdp_dpcd_read (struct cdns_mhdp_base *base, +u32 addr,u8 *data,u16 len);int +cdns_mhdp_dpcd_write (struct cdns_mhdp_base *base,u32 addr,u8 +value); + +#endif /* __CDNS_MHDP_HELPER_H__ */ 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
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 v10 1/7] drm: bridge: Cadence: Creat mhdp helper driver
Hi Alexander,
Quoted 207 lines
Hi Sandor,
Am Montag, 16. Oktober 2023, 05:05:54 CEST schrieb Sandor Yu:
Quoted 31 lines
Hi Alexander,
Thanks your comments,
Quoted 27 lines
Hi Sandor,
thanks for the updated series.
Am Freitag, 13. Oktober 2023, 05:24:20 CEST schrieb Sandor Yu:
Quoted 22 lines
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 tocdns_mhdp_dp_reg_write(), because it use the DPTX command IDDPTX_WRITE_REGISTER.New
cdns_mhdp_reg_write()is created with the general command IDGENERAL_REGISTER_WRITE.Signed-off-by Sandor Yu <[email protected]>---
v9->v10:
*use mhdp helper driver to replace macro functions, move maiboxaccess function and mhdp hdmi/dp common API functions into the driver.
drivers/gpu/drm/bridge/cadence/Kconfig | 4 drivers/gpu/drm/bridge/cadence/Makefile | 1 + .../gpu/drm/bridge/cadence/cdns-mhdp-helper.c | 306++++++++++++++
Quoted 1 line
Quoted 1 line
Quoted 1 line
.../drm/bridge/cadence/cdns-mhdp8546-core.c | 383+++---------------
Quoted 90 lines
Quoted 90 lines
Quoted 53 lines
.../drm/bridge/cadence/cdns-mhdp8546-core.h | 44 +- include/drm/bridge/cdns-mhdp-helper.h | 96 +++++ 6 files changed, 473 insertions(+), 361 deletions(-) create mode100644
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.ccreate mode 100644 include/drm/bridge/cdns-mhdp-helper.h(quoted diff) +0
-0b/drivers/gpu/drm/bridge/cadence/Kconfig index
ec35215a20034..0b7b4626a7af0
100644drivers/gpu/drm/bridge/cadence/Kconfig +3
-0@@ -20,6 +20,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_MHDP8546tristate "Cadence DPI/DP bridge"
selectDRM_DISPLAY_DP_HELPERdrivers/gpu/drm/bridge/cadence/Kconfig +1
-0@@ -27,6 +30,7 @@ config DRM_CDNS_MHDP8546 select DRM_DISPLAY_HELPER select DRM_KMS_HELPER select DRM_PANEL_BRIDGE + select CDNS_MHDP_HELPERdepends on OF
helpSupport Cadence DPI to DP bridge. This is an internal diff
--git a/drivers/gpu/drm/bridge/cadence/Makefile
b/drivers/gpu/drm/bridge/cadence/Makefile indexc95fd5b81d137..087dc074820d7100644drivers/gpu/drm/bridge/cadence/Makefile +0
-0@@ -2,6 +2,7 @@ obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o cdns-dsi-y :=cdns-dsi-core.o
Quoted 5 lines
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
Quoted 16 lines
:= cdns-mhdp8546-core.o cdns-mhdp8546-hdcp.o :
cdns-mhdp8546-$(CONFIG_DRM_CDNS_MHDP8546_J721E) +=cdns-mhdp8546-j721e.o diff --git
a/drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.cb/drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.cnew file mode 100644 index 0000000000000..2e3eee40494f0drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +5
-0@@ -0,0 +1,306 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023 NXP Semiconductor, Inc. +* +*/ drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 15
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+#include <drm/bridge/cdns-mhdp-helper.h> #include +<linux/dev_printk.h> #include <linux/module.h> + +/* Mailbox helper functions */ +int cdns_mhdp_mailbox_read (struct cdns_mhdp_base *base) { +int ret, empty; + +WARN_ON (!mutex_is_locked (base->mbox_mutex)); + + ret = readx_poll_timeout(readl, base->regs +
CDNS_MAILBOX_EMPTY,Quoted 1 line
Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 16
Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +1
-0+ empty, !empty,
MAILBOX_RETRY_US,Quoted 11 lines
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 22
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +6
-0+ MAILBOX_TIMEOUT_US); +if (ret <0 ) +return ret; + +return readl (base->regs +CDNS_MAILBOX_RX_DATA ) &0xff ; } +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_read);No need to export this. You can make this function actually static.
OK, I will change it to static in the next version.
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 29
Quoted 7 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +7
-0+ +int cdns_mhdp_mailbox_write (struct cdns_mhdp_base *base,u8 val) { +int ret, full; + +WARN_ON (!mutex_is_locked (base->mbox_mutex)); + + ret = readx_poll_timeout(readl, base->regs +
CDNS_MAILBOX_FULL,Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +5
-0+ full, !full,MAILBOX_RETRY_US , + MAILBOX_TIMEOUT_US); +if (ret <0 ) +return ret; +Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 39
Quoted 5 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +5
-0+writel (val, base->regs +CDNS_MAILBOX_TX_DATA ); + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_write);No need to export that one as well. You can make this function actually static as these two functions are only called from the helper itself.
Quoted 1 line
mhdp8546 driver need this function.
True,
cdns_mhdp_set_firmware_active()needs this. But this call seems a bit fishy. Couldn't this be written as follow?---8<--
(quoted diff) +0
-0b/drivers/
gpu/drm/bridge/cadence/cdns-mhdp8546-core.cindex0582a5e42763f..c0364d05406cd100644drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +0
-0@@ -78,22 +78,16 @@ static void cdns_mhdp_bridge_hpd_disable(struct
drm_bridge
*bridge)
static
int cdns_mhdp_set_firmware_active(structcdns_mhdp_device*mhdp, bool
enable) {drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +5
-11-u8 msg[5 ]; +u8 msg[1 ];int ret, i; - msg[0 ] =GENERAL_MAIN_CONTROL ; - msg[1 ] =MB_MODULE_ID_GENERAL ; - msg[2 ] =0 ; - msg[3 ] =1 ; - msg[4 ] = enable ?FW_ACTIVE :FW_STANDBY ; + msg[0 ] = enable ?FW_ACTIVE :FW_STANDBY ;mutex_lock (&mhdp->mbox_mutex); -for (i =0 ; i <sizeof (msg); i++) { - ret =cdns_mhdp_mailbox_write (&mhdp->base, msg[i]); -if (ret) - goto out; - } + ret =cdns_mhdp_mailbox_send (base,MB_MODULE_ID_GENERAL , +GENERAL_MAIN_CONTROL , +sizeof (msg), msg);/* read the firmware state */ ret = cdns_mhdp_mailbox_recv_data(&mhdp->base, msg,sizeof(msg));
---8<--
Quoted 3 lines
AFAICS
cdns_mhdp_mailbox_send()is only a sequence of writes, writing 4 byte header and 1 byte data in this case.
Yes, cdns_mhdp_mailbox_send() could be use to replace cdns_mhdp_mailbox_write() in the function. OK, I will add the change into this patch in the next version, thanks.
B.R
Sandor
Quoted 456 lines
Best regards,
AlexanderQuoted 89 lines
Quoted 89 lines
Quoted 15 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +14
-0+ +int cdns_mhdp_mailbox_recv_header (struct cdns_mhdp_base *base, +u8 module_id,u8 opcode, +u16 req_size) { +u32 mbox_size, i; +u8 header[4 ]; +int ret; + +/* read the header of the message */ +for (i =0 ; i <sizeof (header); i++) { + ret =cdns_mhdp_mailbox_read (base); +if (ret <0 ) +return ret; +drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 63
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ header[i] = ret; + } + + mbox_size =get_unaligned_be16 (header +2 ); + +if (opcode != header[0 ] || module_id != header[1 ] || + req_size != mbox_size) { +/* +* If the message in mailbox is not what we want, we +need to
Quoted 21 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +21
-0+* clear the mailbox by reading its contents. +*/ +for (i =0 ; i < mbox_size; i++) +if (cdns_mhdp_mailbox_read (base) <0 ) +break ; + +return -EINVAL ; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_recv_header); + +int cdns_mhdp_mailbox_recv_data (struct cdns_mhdp_base *base, +u8 *buff,u16 buff_size) { +u32 i; +int ret; + +for (i =0 ; i < buff_size; i++) { + ret =cdns_mhdp_mailbox_read (base); +if (ret <0 )drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 94
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+return ret; + + buff[i] = ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_recv_data); + +int cdns_mhdp_mailbox_send(struct cdns_mhdp_base *base, u8
module_id,Quoted 27 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +27
-0+ u8 opcode, u16 size, u8 *message) { + u8 header[4]; +int ret, i; + + header[0 ] = opcode; + header[1 ] = module_id; +put_unaligned_be16 (size, header +2 ); + +for (i =0 ; i <sizeof (header); i++) { + ret =cdns_mhdp_mailbox_write (base, header[i]); +if (ret) +return ret; + } + +for (i =0 ; i < size; i++) { + ret =cdns_mhdp_mailbox_write (base, message[i]); +if (ret) +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_mailbox_send); + +/* General helper functions */ +int cdns_mhdp_reg_read (struct cdns_mhdp_base *base,u32 addr,u32 +*value) {Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 129
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +8
-0+u8 msg[4 ], resp[8 ]; +int ret; + +put_unaligned_be32 (addr, msg); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base,
MB_MODULE_ID_GENERAL,Quoted 44 lines
Quoted 44 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 135
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +6
-0+GENERAL_REGISTER_READ , + sizeof(msg), msg); +if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(base,
MB_MODULE_ID_GENERAL,drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 136
Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +1
-0+
GENERAL_REGISTER_READ,Quoted 31 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +31
-0+ sizeof(resp)); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, resp,sizeof (resp)); +if (ret) + goto out; + +/* Returned address value should be the same as requested */ +if (memcmp (msg, resp,sizeof (msg))) { + ret = -EINVAL ; + goto out; + } + + *value =get_unaligned_be32 (resp +4 ); + +out: +mutex_unlock (base->mbox_mutex); +if (ret) { +dev_err (base->dev,"Failed to read register\n" ); + *value =0 ; + } + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_reg_read); + +int cdns_mhdp_reg_write (struct cdns_mhdp_base *base,u32 addr, +u32 +val) { +u8 msg[8 ];Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 175
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +8
-0+int ret; + +put_unaligned_be32 (addr, msg); +put_unaligned_be32 (val, msg +4 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base,
MB_MODULE_ID_GENERAL,Quoted 1 line
Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 176
Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +1
-0+
GENERAL_REGISTER_WRITE,Quoted 28 lines
Quoted 28 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 186
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+ sizeof(msg), msg); + +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_reg_write); + +/* DPTX helper functions */ +int cdns_mhdp_dp_reg_write(struct cdns_mhdp_base *base, u16 addr,u32
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 197
Quoted 11 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +11
-0+val) { +u8 msg[6 ]; +int ret; + +put_unaligned_be16 (addr, msg); +put_unaligned_be32 (val, msg +2 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_REGISTER,sizeof(msg),
msg);Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 205
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +8
-0+ +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dp_reg_write); + +int cdns_mhdp_dp_reg_write_bit(struct cdns_mhdp_base *base, u16addr,
Quoted 28 lines
Quoted 28 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 218
Quoted 13 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +13
-0+ u8 start_bit, u8 bits_no, u32 val) { + u8 field[8]; +int ret; + +put_unaligned_be16 (addr, field); + field[2 ] = start_bit; + field[3 ] = bits_no; +put_unaligned_be32 (val, field +4 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_FIELD,sizeof(field),
field);Quoted 11 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +11
-0+ +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dp_reg_write_bit); + +int cdns_mhdp_dpcd_read (struct cdns_mhdp_base *base, +u32 addr,u8 *data,u16 len) { +u8 msg[5 ], reg[5 ]; +int ret;Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 237
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +8
-0+ +put_unaligned_be16 (len, msg); +put_unaligned_be24 (addr, msg +2 ); + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_READ_DPCD,sizeof(msg),
Quoted 46 lines
Quoted 46 lines
msg);
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 241
Quoted 4 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +4
-0+if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(base,
MB_MODULE_ID_DP_TX,Quoted 22 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +22
-0+DPTX_READ_DPCD , + sizeof(reg) + len); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, reg,sizeof (reg)); +if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, data, len); + +out: +mutex_unlock (base->mbox_mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dpcd_read); + +int cdns_mhdp_dpcd_write (struct cdns_mhdp_base *base,u32 addr, +u8 +value) { +u8 msg[6 ], reg[5 ];drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 273
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +10
-0+int ret; + +put_unaligned_be16 (1 , msg); +put_unaligned_be24 (addr, msg +2 ); + msg[5 ] = value; + +mutex_lock (base->mbox_mutex); + + ret = cdns_mhdp_mailbox_send(base, MB_MODULE_ID_DP_TX, + DPTX_WRITE_DPCD,sizeof(msg),
msg);Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c line 277
Quoted 4 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +4
-0+if (ret) + goto out; + + ret = cdns_mhdp_mailbox_recv_header(base,
MB_MODULE_ID_DP_TX,Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +1
-0+
DPTX_WRITE_DPCD,Quoted 121 lines
Quoted 102 lines
sizeof(reg));
Quoted 99 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp-helper.c new file +22
-0+if (ret) + goto out; + + ret =cdns_mhdp_mailbox_recv_data (base, reg,sizeof (reg)); +if (ret) + goto out; + +if (addr !=get_unaligned_be24 (reg +2 )) + ret = -EINVAL ; + +out: +mutex_unlock (base->mbox_mutex); + +if (ret) +dev_err (base->dev,"dpcd write failed: %d\n" , ret); +return ret; +} +EXPORT_SYMBOL_GPL (cdns_mhdp_dpcd_write); + +MODULE_DESCRIPTION ("Cadence MHDP Helper driver" ); +MODULE_AUTHOR ("Sandor Yu <[email protected]>" ); +MODULE_LICENSE ("GPL" );(quoted diff) +0
-0
b/include/drm/bridge/cdns-mhdp-helper.hnew file mode 100644 index 0000000000000..b89db9e842266include/drm/bridge/cdns-mhdp-helper.h new file +70
-0@@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023 NXP Semiconductor, Inc. +*/ +#ifndef __CDNS_MHDP_HELPER_H__ +#define __CDNS_MHDP_HELPER_H__ + +#include <asm/unaligned.h> +#include <linux/iopoll.h> + +/* mailbox regs offset */ +#define CDNS_MAILBOX_FULL 0x00008 +#define CDNS_MAILBOX_EMPTY 0x0000c +#define CDNS_MAILBOX_TX_DATA 0x00010 +#define CDNS_MAILBOX_RX_DATA 0x00014 + +#define MAILBOX_RETRY_US 1000 +#define MAILBOX_TIMEOUT_US 2000000 + +/* Module ID Code */ +#define MB_MODULE_ID_DP_TX 0x01 +#define MB_MODULE_ID_HDMI_TX 0x03 +#define MB_MODULE_ID_HDCP_TX 0x07 +#define MB_MODULE_ID_HDCP_RX 0x08 +#define MB_MODULE_ID_HDCP_GENERAL 0x09 +#define MB_MODULE_ID_GENERAL 0x0A + +/* General Commands */ +#define GENERAL_MAIN_CONTROL 0x01 +#define GENERAL_TEST_ECHO 0x02 +#define GENERAL_BUS_SETTINGS 0x03 +#define GENERAL_TEST_ACCESS 0x04 +#define GENERAL_REGISTER_WRITE 0x05 +#define GENERAL_WRITE_FIELD 0x06 +#define GENERAL_REGISTER_READ 0x07 +#define GENERAL_GET_HPD_STATE 0x11 + +/* DPTX Commands */ +#define DPTX_SET_POWER_MNG 0x00 +#define DPTX_SET_HOST_CAPABILITIES 0x01 +#define DPTX_GET_EDID 0x02 +#define DPTX_READ_DPCD 0x03 +#define DPTX_WRITE_DPCD 0x04 +#define DPTX_ENABLE_EVENT 0x05 +#define DPTX_WRITE_REGISTER 0x06 +#define DPTX_READ_REGISTER 0x07 +#define DPTX_WRITE_FIELD 0x08 +#define DPTX_TRAINING_CONTROL 0x09 +#define DPTX_READ_EVENT 0x0a +#define DPTX_READ_LINK_STAT 0x0b +#define DPTX_SET_VIDEO 0x0c +#define DPTX_SET_AUDIO 0x0d +#define DPTX_GET_LAST_AUX_STAUS 0x0e +#define DPTX_SET_LINK_BREAK_POINT 0x0f +#define DPTX_FORCE_LANES 0x10 +#define DPTX_HPD_STATE 0x11 +#define DPTX_ADJUST_LT 0x12 + +/* HDMI TX Commands */ +#define HDMI_TX_READ 0x00 +#define HDMI_TX_WRITE 0x01 +#define HDMI_TX_UPDATE_READ 0x02 +#define HDMI_TX_EDID 0x03 +#define HDMI_TX_EVENTS 0x04 +#define HDMI_TX_HPD_STATUS 0x05 + +struct cdns_mhdp_base { + struct device *dev; + void __iomem *regs; + /* protect mailbox communications with the firmware */Quoted 8 lines
include/drm/bridge/cdns-mhdp-helper.h line 76
Quoted 6 lines
include/drm/bridge/cdns-mhdp-helper.h new file +6
-0+struct mutex *mbox_mutex; +}; + +/* Mailbox helper functions */ +int cdns_mhdp_mailbox_read (struct cdns_mhdp_base *base);int +cdns_mhdp_mailbox_write (struct cdns_mhdp_base *base,u8 val);You can remove these two declarations.
cdns_mhdp_mailbox_readwill be removed. Thanks!B.R
SandorQuoted 5 lines
Best regards,
AlexanderBest regards,
Quoted 8 lines
Quoted 8 lines
include/drm/bridge/cdns-mhdp-helper.h line 78
Quoted 2 lines
include/drm/bridge/cdns-mhdp-helper.h new file +2
-0+int cdns_mhdp_mailbox_recv_header (struct cdns_mhdp_base *base, + u8 module_id, u8 opcode, u16
req_size);include/drm/bridge/cdns-mhdp-helper.h line 81
Quoted 3 lines
include/drm/bridge/cdns-mhdp-helper.h new file +3
-0+int cdns_mhdp_mailbox_recv_data (struct cdns_mhdp_base *base, +u8 *buff,u16 buff_size);int +cdns_mhdp_mailbox_send(struct cdns_mhdp_base *base, u8
module_id,Quoted 17 lines
Quoted 17 lines
include/drm/bridge/cdns-mhdp-helper.h line 90
Quoted 9 lines
include/drm/bridge/cdns-mhdp-helper.h new file +9
-0+ u8 opcode, u16 size, u8 *message); + +/* General commands helper functions */ int +cdns_mhdp_reg_read (struct cdns_mhdp_base *base,u32 addr,u32 +*value);int cdns_mhdp_reg_write (struct cdns_mhdp_base *base,u32 +addr,u32 val); + +/* DPTX commands helper functions */ int +cdns_mhdp_dp_reg_write(struct cdns_mhdp_base *base, u16 addr,u32
Quoted 5 lines
include/drm/bridge/cdns-mhdp-helper.h new file +2
-0+val); int cdns_mhdp_dp_reg_write_bit(struct cdns_mhdp_base *base, +u16 addr, +u8 start_bit,u8 bits_no,u32 val);Quoted 10 lines
Quoted 10 lines
include/drm/bridge/cdns-mhdp-helper.h
Quoted 6 lines
include/drm/bridge/cdns-mhdp-helper.h new file +6
-0+int cdns_mhdp_dpcd_read (struct cdns_mhdp_base *base, +u32 addr,u8 *data,u16 len);int +cdns_mhdp_dpcd_write (struct cdns_mhdp_base *base,u32 addr,u8 +value); + +#endif /* __CDNS_MHDP_HELPER_H__ */ 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--
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%7C01%7Csandor.yu%40nxp.com%7C2cd8764806d c476182da08dbce22347e%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7 C0%7C638330418532038510%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4 wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000% 7C%7C%7C&sdata=0d9o40bvznT6Ef1Ugg6m%2F6Ca8odJtl80js6X17rUWzA%3 D&reserved=0
PATCH v10 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->v10:
*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 v10 3/7 dt-bindings: display: bridge: Add Cadence MHDP8501
In reply to Sandor YuAdd bindings for Cadence MHDP8501 DisplayPort/HDMI bridge.
---v9->v10:
*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 v10 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.
---v9->v10:
- struct cdns_mhdp_device is renamed to cdns_mhdp8501_device.
- update for mhdp helper driver is introduced.
Remove head file cdns-mhdp-mailbox.h and add cdns-mhdp-helper.h Add struct cdns_mhdp_base base to struct cdns_mhdp8501_device. Init struct cdns_mhdp_base base when driver probe.
drivers/gpu/drm/bridge/cadence/Kconfig | 16 + drivers/gpu/drm/bridge/cadence/Makefile | 2 + .../drm/bridge/cadence/cdns-mhdp8501-core.c | 316 ++++++++ .../drm/bridge/cadence/cdns-mhdp8501-core.h | 365 +++++++++ .../gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c | 708 ++++++++++++++++++ .../drm/bridge/cadence/cdns-mhdp8501-hdmi.c | 673 +++++++++++++++++ 6 files changed, 2080 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
@@ -50,3 +50,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 +316 -0
316 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 +708 -0
708 lines not on this page · raw message
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +673 -0
673 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v10 4/7] drm: bridge: Cadence: Add MHDP8501 DP/HDMI driver
Hi Sandor,
thanks for the updated series.
Am Freitag, 13. Oktober 2023, 05:24:23 CEST schrieb Sandor Yu:
Quoted 74 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]>---
v9->v10:
- structcdns_mhdp_deviceis renamed tocdns_mhdp8501_device.
- update for mhdp helper driver is introduced.
Remove head filecdns-mhdp-mailbox.hand addcdns-mhdp-helper.hAdd structcdns_mhdp_basebase to structcdns_mhdp8501_device. Init structcdns_mhdp_basebase when driver probe.drivers/gpu/drm/bridge/cadence/Kconfig | 16 + drivers/gpu/drm/bridge/cadence/Makefile | 2 + .../drm/bridge/cadence/cdns-mhdp8501-core.c | 316 ++++++++ .../drm/bridge/cadence/cdns-mhdp8501-core.h | 365 +++++++++ .../gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c | 708 ++++++++++++++++++ .../drm/bridge/cadence/cdns-mhdp8501-hdmi.c | 673 +++++++++++++++++ 6 files changed, 2080 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
-0
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.cnew file mode 100644 index 0000000000000..73d1c35a74599drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +34
-0@@ -0,0 +1,673 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Cadence MHDP8501 HDMI bridge driver +* +* Copyright (C) 2019-2023 NXP Semiconductor, Inc. +* +*/ +#include <drm/display/drm_hdmi_helper.h> +#include <drm/display/drm_scdc_helper.h> +#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-hdmi.h> + +#include "cdns-mhdp8501-core.h" + +/** +* cdns_hdmi_infoframe_set() - fill the HDMI AVI infoframe +* @mhdp: phandle to mhdp device. +* @entry_id: The packet memory address in which the data is written. +* @packet_len: 32, only 32 bytes now. +* @packet: point to InfoFrame Packet. +* packet[0] = 0 +* packet[1-3] = HB[0-2] InfoFrame Packet Header +* packet[4-31 = PB[0-27] InfoFrame Packet Contents +* @packet_type: Packet Type of InfoFrame in HDMI Specification. +* +*/ +static void cdns_hdmi_infoframe_set (struct cdns_mhdp8501_device *mhdp, +u8 entry_id,u8 packet_len, +u8 *packet,u8 packet_type) +{ +u32 packet32, len32;
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c line 44
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +10
-0+u32 val, i; + +/* only support 32 bytes now */ +if (packet_len !=32 ) +return ; + +/* invalidate entry */ + val =F_ACTIVE_IDLE_TYPE (1 ) |F_PKT_ALLOC_ADDRESS (entry_id); +writel (val, mhdp->regs +SOURCE_PIF_PKT_ALLOC_REG ); + writel(F_PKT_ALLOC_WR_EN(1), mhdp->regs +
SOURCE_PIF_PKT_ALLOC_WR_EN);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 9 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +9
-0+ +/* flush fifo 1 */ +writel (F_FIFO1_FLUSH (1 ), mhdp->regs +SOURCE_PIF_FIFO1_FLUSH ); + +/* write packet into memory */ + len32 = packet_len /4 ; +for (i =0 ; i < len32; i++) { + packet32 =get_unaligned_le32 (packet +4 * i); + writel(F_DATA_WR(packet32), mhdp->regs +
SOURCE_PIF_DATA_WR);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 11 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +11
-0+ } + +/* write entry id */ +writel (F_WR_ADDR (entry_id), mhdp->regs +SOURCE_PIF_WR_ADDR ); + +/* write request */ +writel (F_HOST_WR (1 ), mhdp->regs +SOURCE_PIF_WR_REQ ); + +/* update entry */ + val =F_ACTIVE_IDLE_TYPE (1 ) |F_TYPE_VALID (1 ) | + F_PACKET_TYPE(packet_type) |
F_PKT_ALLOC_ADDRESS(entry_id);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 3 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +3
-0+writel (val, mhdp->regs +SOURCE_PIF_PKT_ALLOC_REG ); + + writel(F_PKT_ALLOC_WR_EN(1), mhdp->regs +
SOURCE_PIF_PKT_ALLOC_WR_EN);
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +6
-0+} + +static int cdns_hdmi_get_edid_block (void *data,u8 *edid, +u32 block,size_t length) +{ +struct cdns_mhdp8501_device *mhdp = data;
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+u8 msg[2 ], reg[5 ], i; +int ret; + +mutex_lock (&mhdp->mbox_mutex); + +for (i =0 ; i <4 ; i++) { + msg[0 ] = block /2 ; + msg[1 ] = block %2 ; + + ret = cdns_mhdp_mailbox_send(&mhdp->base,
MB_MODULE_ID_HDMI_TX,
Quoted 1 line
HDMI_TX_EDID, + sizeof(msg),
msg);
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 (ret) +continue ; + + ret = cdns_mhdp_mailbox_recv_header(&mhdp->base,
MB_MODULE_ID_HDMI_TX,
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 1 line
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +1
-0+ HDMI_TX_EDID,
sizeof(reg) + length);
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 (ret) +continue ; + + ret = cdns_mhdp_mailbox_recv_data(&mhdp->base, reg,
sizeof(reg));
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 (ret) +continue ; + + ret = cdns_mhdp_mailbox_recv_data(&mhdp->base, edid,
length);
Quoted 16 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +15
-0+if (ret) +continue ; + +if ((reg[3 ] <<8 | reg[4 ]) == length) +break ; + } + +mutex_unlock (&mhdp->mbox_mutex); + +if (ret) +DRM_ERROR ("get block[%d] edid failed: %d\n" , block, ret); +return ret; +} + +static int cdns_hdmi_scdc_write(struct cdns_mhdp8501_device *mhdp, u8 addr,u8 value) +{
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c line 123
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +10
-0+u8 msg[5 ], reg[5 ]; +int ret; + + msg[0 ] =0x54 ; + msg[1 ] = addr; + msg[2 ] =0 ; + msg[3 ] =1 ; + msg[4 ] = value; + +mutex_lock (&mhdp->mbox_mutex);
I don't like that locking. Sometimes the mutex is locked by HDMI driver, sometimes within the helper.
What is this mutex actually protecting? Concurrent access to the mailbox or a programming sequence which must not be interrupted aka critical section? When 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
RE: [EXT] Re: [PATCH v10 4/7] drm: bridge: Cadence: Add MHDP8501 DP/HDMI driver
Hi Alexander,
Thanks your comments,
Quoted 190 lines
Hi Sandor,
thanks for the updated series.
Am Freitag, 13. Oktober 2023, 05:24:23 CEST schrieb Sandor Yu:
Quoted 1 line
Add a new DRM DisplayPort and HDMI bridge driver for Candence
MHDP8501
Quoted 20 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]>---
v9->v10:
- structcdns_mhdp_deviceis renamed tocdns_mhdp8501_device.
- update for mhdp helper driver is introduced.
Remove head filecdns-mhdp-mailbox.hand addcdns-mhdp-helper.hAdd structcdns_mhdp_basebase to structcdns_mhdp8501_device. Init structcdns_mhdp_basebase when driver probe.Quoted 5 lines
drivers/gpu/drm/bridge/cadence/Kconfig | 16 + drivers/gpu/drm/bridge/cadence/Makefile | 2 + .../drm/bridge/cadence/cdns-mhdp8501-core.c | 316 ++++++++ .../drm/bridge/cadence/cdns-mhdp8501-core.h | 365 +++++++++ .../gpu/drm/bridge/cadence/cdns-mhdp8501-dp.c | 708++++++++++++++++++
Quoted 1 line
.../drm/bridge/cadence/cdns-mhdp8501-hdmi.c | 673+++++++++++++++++
Quoted 6 lines
6 files changed, 2080 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.cQuoted 27 lines
create mode 100644
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c[...]
(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.cnew file mode 100644 index 0000000000000..73d1c35a74599drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +17
-0@@ -0,0 +1,673 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Cadence MHDP8501 HDMI bridge driver +* +* Copyright (C) 2019-2023 NXP Semiconductor, Inc. +* +*/ +#include <drm/display/drm_hdmi_helper.h> #include +<drm/display/drm_scdc_helper.h> #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-hdmi.h> + +#include "cdns-mhdp8501-core.h" + +/** +* cdns_hdmi_infoframe_set() - fill the HDMI AVI infoframe +* @mhdp: phandle to mhdp device. drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c line 27
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +10
-0+* @entry_id: The packet memory address in which the data is written. +* @packet_len: 32, only 32 bytes now. +* @packet: point to InfoFrame Packet. +* packet[0] = 0 +* packet[1-3] = HB[0-2] InfoFrame Packet Header +* packet[4-31 = PB[0-27] InfoFrame Packet Contents +* @packet_type: Packet Type of InfoFrame in HDMI Specification. +* +*/ +static void cdns_hdmi_infoframe_set(struct cdns_mhdp8501_device*mhdp,
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+ u8 entry_id, u8 packet_len, + u8 *packet, u8 packet_type) { + u32 packet32, len32; +u32 val, i; + +/* only support 32 bytes now */ +if (packet_len !=32 ) +return ; + +/* invalidate entry */ + val =F_ACTIVE_IDLE_TYPE (1 ) |F_PKT_ALLOC_ADDRESS (entry_id); +writel (val, mhdp->regs +SOURCE_PIF_PKT_ALLOC_REG ); + writel(F_PKT_ALLOC_WR_EN(1), mhdp->regs +
SOURCE_PIF_PKT_ALLOC_WR_EN);drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 3 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +3
-0+ +/* flush fifo 1 */ + writel(F_FIFO1_FLUSH(1), mhdp->regs +
SOURCE_PIF_FIFO1_FLUSH);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+ +/* write packet into memory */ + len32 = packet_len /4 ; +for (i =0 ; i < len32; i++) { + packet32 =get_unaligned_le32 (packet +4 * i); + writel(F_DATA_WR(packet32), mhdp->regs +
SOURCE_PIF_DATA_WR);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+ } + +/* write entry id */ + writel(F_WR_ADDR(entry_id), mhdp->regs +
SOURCE_PIF_WR_ADDR);drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 7 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +7
-0+ +/* write request */ +writel (F_HOST_WR (1 ), mhdp->regs +SOURCE_PIF_WR_REQ ); + +/* update entry */ + val =F_ACTIVE_IDLE_TYPE (1 ) |F_TYPE_VALID (1 ) | + F_PACKET_TYPE(packet_type) |
F_PKT_ALLOC_ADDRESS(entry_id);drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 3 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +3
-0+writel (val, mhdp->regs +SOURCE_PIF_PKT_ALLOC_REG ); + + writel(F_PKT_ALLOC_WR_EN(1), mhdp->regs +
SOURCE_PIF_PKT_ALLOC_WR_EN);Quoted 5 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +5
-0+} + +static int cdns_hdmi_get_edid_block (void *data,u8 *edid, +u32 block,size_t length) { +struct cdns_mhdp8501_device *mhdp = data;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+u8 msg[2 ], reg[5 ], i; +int ret; + +mutex_lock (&mhdp->mbox_mutex); + +for (i =0 ; i <4 ; i++) { + msg[0 ] = block /2 ; + msg[1 ] = block %2 ; + + ret = cdns_mhdp_mailbox_send(&mhdp->base,
MB_MODULE_ID_HDMI_TX,Quoted 1 line
HDMI_TX_EDID, +sizeof(msg),
msg);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 (ret) +continue ; + + ret = cdns_mhdp_mailbox_recv_header(&mhdp->base,
MB_MODULE_ID_HDMI_TX,Quoted 1 line
+
HDMI_TX_EDID,
sizeof(reg) + length);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 (ret) +continue ; + + ret = cdns_mhdp_mailbox_recv_data(&mhdp->base, reg,sizeof(reg));
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 (ret) +continue ; + + ret = cdns_mhdp_mailbox_recv_data(&mhdp->base, edid,length);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c
Quoted 11 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +11
-0+if (ret) +continue ; + +if ((reg[3 ] <<8 | reg[4 ]) == length) +break ; + } + +mutex_unlock (&mhdp->mbox_mutex); + +if (ret) + DRM_ERROR("get block[%d] edid failed: %d\n", block,ret);
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +5
-0+return ret; +} + +static int cdns_hdmi_scdc_write(struct cdns_mhdp8501_device *mhdp, u8 +addr,u8 value) +{
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c line 123
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-hdmi.c new file +10
-0+u8 msg[5 ], reg[5 ]; +int ret; + + msg[0 ] =0x54 ; + msg[1 ] = addr; + msg[2 ] =0 ; + msg[3 ] =1 ; + msg[4 ] = value; + +mutex_lock (&mhdp->mbox_mutex);
Quoted 8 lines
I don't like that locking. Sometimes the mutex is locked by HDMI driver, sometimes within the helper.
What is this mutex actually protecting? Concurrent access to the mailbox or a programming sequence which must not be interrupted aka critical section? When 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
There are two types of command carried over the mailbox channel, with respond and w/o respond. mutex is used to protect a full cycle command over the mailbox channel.
In helper driver, those commands could be share by different mhdp drivers.
In HDMI driver, for example the cdns_hdmi_scdc_write function is only be called by HDMI driver, so I keep the function in MHDP8501 HDMI driver,
if the other mhdp want to reused it later, it should be move to helper driver.
B.R
Sandor
Re: [PATCH v10 4/7] drm: bridge: Cadence: Add MHDP8501 DP/HDMI driver
In reply to Sandor YuQuoted 3 lines · Sandor Yu
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.
...
Quoted 6 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +6
-0+ +static struct platform_driver cdns_mhdp8501_driver = { + .probe = cdns_mhdp8501_probe, + .remove = cdns_mhdp8501_remove, + .driver = { + .name ="cdns-mhdp8501" ,
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c line 316
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +10
-0+ .of_match_table = cdns_mhdp8501_dt_ids, + }, +}; + +module_platform_driver (cdns_mhdp8501_driver); + +MODULE_AUTHOR ("Sandor Yu <[email protected]>" ); +MODULE_DESCRIPTION ("Cadence MHDP8501 bridge driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:cdns-mhdp8501" );
You should not need MODULE_ALIAS() in normal cases. If you need it, usually it means your device ID table is wrong.
This applies everywhere, to all your patches.
Best regards,
Krzysztof
RE: [EXT] Re: [PATCH v10 4/7] drm: bridge: Cadence: Add MHDP8501 DP/HDMI driver
Quoted 29 lines · Sandor Yu
Quoted 1 line
Add a new DRM DisplayPort and HDMI bridge driver for Candence
MHDP8501
Quoted 2 lines
used in i.MX8MQ SOC. MHDP8501 could support HDMI or DisplayPort standards according embedded Firmware running in the uCPU.
...
Quoted 5 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +5
-0+ +static struct platform_driver cdns_mhdp8501_driver = { + .probe = cdns_mhdp8501_probe, + .remove = cdns_mhdp8501_remove, + .driver = {drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c
Quoted 10 lines
drivers/gpu/drm/bridge/cadence/cdns-mhdp8501-core.c new file +10
-0+ .name = "cdns-mhdp8501", + .of_match_table = cdns_mhdp8501_dt_ids, + }, +}; + +module_platform_driver (cdns_mhdp8501_driver); + +MODULE_AUTHOR ("Sandor Yu <[email protected]>" ); +MODULE_DESCRIPTION ("Cadence MHDP8501 bridge driver" ); +MODULE_LICENSE ("GPL" );MODULE_ALIAS ("platform:cdns-mhdp8501" );You should not need
MODULE_ALIAS()in normal cases. If you need it, usually it means your device ID table is wrong.
Quoted 2 lines
This applies everywhere, to all your patches.
Thanks, I will remove them from my patch set.
B.R
Sandor
Quoted 2 lines
Best regards,
Krzysztof
PATCH v10 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->v10:
*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 v10 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.
---v9->v10:
- update for mhdp helper driver is introduced.
Remove head file cdns-mhdp-mailbox.h and add cdns-mhdp-helper.h Add struct cdns_mhdp_base base to struct cdns_hdptx_dp_phy. Init struct cdns_mhdp_base base when driver probe.
drivers/phy/freescale/Kconfig | 10 + drivers/phy/freescale/Makefile | 1 + drivers/phy/freescale/phy-fsl-imx8mq-dp.c | 720 ++++++++++++++++++++++ 3 files changed, 731 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 +720 -0
720 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v10 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.
---v9->v10:
- update for mhdp helper driver is introduced.
Remove head file cdns-mhdp-mailbox.h and add cdns-mhdp-helper.h Add struct cdns_mhdp_base base to struct cdns_hdptx_hdmi_phy. Init struct cdns_mhdp_base base when driver probe.
drivers/phy/freescale/Kconfig | 10 + drivers/phy/freescale/Makefile | 1 + drivers/phy/freescale/phy-fsl-imx8mq-hdmi.c | 961 ++++++++++++++++++++ 3 files changed, 972 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 +961 -0
961 lines not on this page · raw message
Signature · 1 line
2.34.1