From: Guillaume Ranquet <granquet@baylibre.com>
To: Chunfeng Yun <chunfeng.yun@mediatek.com>,
David Airlie <airlied@gmail.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Jitao shi <jitao.shi@mediatek.com>, CK Hu <ck.hu@mediatek.com>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Vinod Koul <vkoul@kernel.org>,
Kishon Vijay Abraham I <kishon@ti.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Daniel Vetter <daniel@ffwll.ch>,
Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Guillaume Ranquet <granquet@baylibre.com>,
stuart.lee@mediatek.com, linux-phy@lists.infradead.org,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-kernel@vger.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
mac.shen@mediatek.com, linux-mediatek@lists.infradead.org,
dri-devel@lists.freedesktop.org
Subject: [PATCH v2 05/12] drm/mediatek: hdmi: make the cec dev optional
Date: Fri, 14 Oct 2022 17:15:58 +0200 [thread overview]
Message-ID: <20220919-v2-5-8419dcf4f09d@baylibre.com> (raw)
In-Reply-To: <20220919-v2-0-8419dcf4f09d@baylibre.com>
Make cec device optional in order to support newer versions of the
hdmi IP which doesn't require it
Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
---
drivers/gpu/drm/mediatek/mtk_hdmi.c | 8 +++--
drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 54 ++++++++++++++++++++----------
drivers/gpu/drm/mediatek/mtk_hdmi_common.h | 1 +
3 files changed, 42 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 73bda2849196..85c6ebca36dd 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -927,10 +927,11 @@ void mtk_hdmi_clk_disable_audio_mt8183(struct mtk_hdmi *hdmi)
static enum drm_connector_status
mtk_hdmi_update_plugged_status(struct mtk_hdmi *hdmi)
{
- bool connected;
+ bool connected = true;
mutex_lock(&hdmi->update_plugged_status_lock);
- connected = mtk_cec_hpd_high(hdmi->cec_dev);
+ if (hdmi->cec_dev)
+ connected = mtk_cec_hpd_high(hdmi->cec_dev);
if (hdmi->plugged_cb && hdmi->codec_dev)
hdmi->plugged_cb(hdmi->codec_dev, connected);
mutex_unlock(&hdmi->update_plugged_status_lock);
@@ -1025,7 +1026,8 @@ static int mtk_hdmi_bridge_attach(struct drm_bridge *bridge,
return ret;
}
- mtk_cec_set_hpd_event(hdmi->cec_dev, mtk_hdmi_hpd_event, hdmi->dev);
+ if (hdmi->cec_dev)
+ mtk_cec_set_hpd_event(hdmi->cec_dev, mtk_hdmi_hpd_event, hdmi->dev);
return 0;
}
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_common.c b/drivers/gpu/drm/mediatek/mtk_hdmi_common.c
index 3f08d37b1af0..3635ca66817b 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi_common.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi_common.c
@@ -137,28 +137,18 @@ void mtk_hdmi_send_infoframe(struct mtk_hdmi *hdmi, u8 *buffer_spd, size_t bufsz
mtk_hdmi_setup_spd_infoframe(hdmi, buffer_spd, bufsz_spd, "mediatek", "On-chip HDMI");
}
-int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, struct platform_device *pdev,
- const char *const *clk_names, size_t num_clocks)
+static int mtk_hdmi_get_cec_dev(struct mtk_hdmi *hdmi, struct device *dev, struct device_node *np)
{
- struct device *dev = &pdev->dev;
- struct device_node *np = dev->of_node;
- struct device_node *cec_np, *remote, *i2c_np;
+ int ret;
+ struct device_node *cec_np;
struct platform_device *cec_pdev;
struct regmap *regmap;
- struct resource *mem;
- int ret;
-
- ret = mtk_hdmi_get_all_clk(hdmi, np, clk_names, num_clocks);
- if (ret) {
- dev_err(dev, "Failed to get all clks\n");
- return ret;
- }
/* The CEC module handles HDMI hotplug detection */
cec_np = of_get_compatible_child(np->parent, "mediatek,mt8173-cec");
if (!cec_np) {
dev_err(dev, "Failed to find CEC node\n");
- return -EINVAL;
+ return -ENOTSUPP;
}
cec_pdev = of_find_device_by_node(cec_np);
@@ -168,7 +158,6 @@ int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, struct platform_device *pdev,
return -EPROBE_DEFER;
}
of_node_put(cec_np);
- hdmi->cec_dev = &cec_pdev->dev;
/*
* The mediatek,syscon-hdmi property contains a phandle link to the
* MMSYS_CONFIG device and the register offset of the HDMI_SYS_CFG
@@ -177,12 +166,41 @@ int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, struct platform_device *pdev,
regmap = syscon_regmap_lookup_by_phandle(np, "mediatek,syscon-hdmi");
ret = of_property_read_u32_index(np, "mediatek,syscon-hdmi", 1, &hdmi->sys_offset);
if (IS_ERR(regmap))
- ret = PTR_ERR(regmap);
+ return PTR_ERR(regmap);
if (ret) {
- dev_err(dev, "Failed to get system configuration registers: %d\n", ret);
- goto put_device;
+ dev_err(dev,
+ "Failed to get system configuration registers: %d\n", ret);
+ return ret;
}
+
hdmi->sys_regmap = regmap;
+ hdmi->cec_dev = &cec_pdev->dev;
+
+ return 0;
+}
+
+int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, struct platform_device *pdev,
+ const char *const *clk_names, size_t num_clocks)
+{
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+ struct device_node *remote, *i2c_np;
+ struct resource *mem;
+ int ret;
+
+ ret = mtk_hdmi_get_all_clk(hdmi, np, clk_names, num_clocks);
+ if (ret) {
+ dev_err(dev, "Failed to get all clks\n");
+ return ret;
+ }
+
+ ret = mtk_hdmi_get_cec_dev(hdmi, dev, np);
+ if (ret) {
+ if (ret == -ENOTSUPP)
+ dev_info(dev, "No CEC node found, continuing without");
+ else
+ goto put_device;
+ }
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) {
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_common.h b/drivers/gpu/drm/mediatek/mtk_hdmi_common.h
index 7452bea91f9e..921bde150e11 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi_common.h
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi_common.h
@@ -31,6 +31,7 @@
struct mtk_hdmi_conf {
bool tz_disabled;
bool cea_modes_only;
+ bool has_cec;
unsigned long max_mode_clock;
const struct drm_bridge_funcs *bridge_funcs;
void (*mtk_hdmi_output_init)(struct mtk_hdmi *hdmi);
--
b4 0.11.0-dev
next prev parent reply other threads:[~2022-10-14 15:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 15:15 [PATCH v2 00/12] Add MT8195 HDMI support Guillaume Ranquet
2022-10-14 15:15 ` [PATCH v2 01/12] dt-bindings: phy: mediatek: hdmi-phy: Add mt8195 compatible Guillaume Ranquet
2022-10-14 15:15 ` [PATCH v2 02/12] dt-bindings: display: mediatek: add MT8195 hdmi bindings Guillaume Ranquet
2022-10-14 16:08 ` Krzysztof Kozlowski
2022-11-02 13:31 ` Guillaume Ranquet
2022-11-03 12:45 ` Krzysztof Kozlowski
2022-11-03 15:17 ` Guillaume Ranquet
2022-11-03 15:24 ` Krzysztof Kozlowski
2022-10-14 15:15 ` [PATCH v2 03/12] drm/mediatek: hdmi: use a regmap instead of iomem Guillaume Ranquet
2022-10-14 15:15 ` [PATCH v2 04/12] drm/mediatek: extract common functions from the mtk hdmi driver Guillaume Ranquet
2022-10-14 15:15 ` Guillaume Ranquet [this message]
2022-10-14 15:15 ` [PATCH v2 06/12] drm/mediatek: hdmi: add frame_colorimetry flag Guillaume Ranquet
2022-10-14 15:16 ` [PATCH v2 07/12] drm/mediatek: hdmi: add v2 support Guillaume Ranquet
2022-10-14 15:16 ` [PATCH v2 08/12] drm/mediatek: hdmi: v2: add audio support Guillaume Ranquet
2022-10-14 15:16 ` [PATCH v2 09/12] phy: phy-mtk-hdmi: Add generic phy configure callback Guillaume Ranquet
2022-10-14 15:16 ` [PATCH v2 10/12] phy: mediatek: add support for phy-mtk-hdmi-mt8195 Guillaume Ranquet
2022-10-21 7:44 ` Chunfeng Yun
2022-11-02 9:40 ` Guillaume Ranquet
2022-10-14 15:16 ` [PATCH v2 11/12] dt-bindings: display: mediatek: dpi: Add compatible for MediaTek MT8195 Guillaume Ranquet
2022-10-14 15:16 ` [PATCH v2 12/12] drm/mediatek: dpi: Add mt8195 hdmi to DPI driver Guillaume Ranquet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220919-v2-5-8419dcf4f09d@baylibre.com \
--to=granquet@baylibre.com \
--cc=airlied@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunfeng.yun@mediatek.com \
--cc=chunkuang.hu@kernel.org \
--cc=ck.hu@mediatek.com \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jitao.shi@mediatek.com \
--cc=kishon@ti.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-phy@lists.infradead.org \
--cc=mac.shen@mediatek.com \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=stuart.lee@mediatek.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).