From patchwork Fri Nov 4 14:09:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Ranquet X-Patchwork-Id: 15570 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp429500wru; Fri, 4 Nov 2022 07:15:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7SEx8IYm5yHHxSLYrnOvJNQ1MUaEsvBd8SG9IJ/pu9vOnJeOyOpBIaUg7IGPUXX+khXokC X-Received: by 2002:a63:3147:0:b0:470:3d1:7bfb with SMTP id x68-20020a633147000000b0047003d17bfbmr13804539pgx.338.1667571341693; Fri, 04 Nov 2022 07:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667571341; cv=none; d=google.com; s=arc-20160816; b=eXMKotN2aS/3CHpjtDeZF8IH3nI/qei7B2RQw5ax5d2wRUPGkLje2LQ9Y3Ir6TXvFd CAw4POubriKK6qQQBPqy6iK9evYNFwAtPvbFKbERiMw2RrqD2y2EsWsSwecrG4mrJnHY EcmQu7Q2FpEdUNPbdlUB5L9mEgz7cb+3KrsJ3XMS3zeWSF/H03DkKoqVmHzsboatGMJQ THS4YMlIHxh7o9o2goInhbCZp7FojTeM24EHeiHDNcMndSerLoD7w+sZrK9WhfJG8ghe FCvA5FOgwjWc2Zl/m3oWONO13hUi46bSnyS76gZqm8WJQ4PFr7Z3DmDY7mMlfB5DJmVn Ku2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=DSYD3hSXr5dSGBwwFhgmPY+Jg1epD5ze6gJ/T99kUGE=; b=X7bxhsJdLacqM3PAqzuGR2eK365szFGmI3KdMZgW3R9+n0QW6cVXbUKnWD9iOxlp94 Ys6l8nKcTEbgI+U9w22wv0NSo3XB2j+U8bhZztzMO3jcBSnytLTyRL9J8/DLil+CZmfD ABS9fFFZTRcylA62mWuR/YlvdjEryFX+Ib7FAiv+6e+sEG9aEG5fQ/cnNYM45o/NETWr fEU67peGel9ok3kOlDX2ReL74i5jzqon4uspQwX+PcIhnrvpweyJEPiY9Xj/pAcWItlh 187i5epK6WXSvrQ1jVcH/Qr0FAgXPHITAb1VQRCfuNqmBont88rNP/YlE00BkMu+52ed qVSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=040vNEhN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e15-20020a62ee0f000000b0054568a55597si4468466pfi.96.2022.11.04.07.15.27; Fri, 04 Nov 2022 07:15:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=040vNEhN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231959AbiKDOOj (ORCPT + 99 others); Fri, 4 Nov 2022 10:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231391AbiKDOOU (ORCPT ); Fri, 4 Nov 2022 10:14:20 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 005732181 for ; Fri, 4 Nov 2022 07:14:17 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id bk15so7192158wrb.13 for ; Fri, 04 Nov 2022 07:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=DSYD3hSXr5dSGBwwFhgmPY+Jg1epD5ze6gJ/T99kUGE=; b=040vNEhNW3OrbFTChPGank19okMbiLYYMgV42UBZ6I9C05bIk7WUaY8lFlzIm5HyCd 2NWiGDBCCZlmyXKnrhPUcoFG8uiFePXcj4AjGBOLmxJ1UsGq0PFVnDkDf6M+gbeDbHPj xGH6RnLqnC7YUBFBtpFLbECenBuMnINhGMW13vOTKjVesrnohkpUWlMiFVfLbHQv0rhO LAmwoDnNJeyXXy9a/JKoFpvjPdTBsB2kH6zKTkHo/v9QyKnronI+NEl7g4WeJdWLxayz pGpzVJ2qqf33WjlVUWtGkQ8/GCVJThgDqgXVlAwar4qEVzxX7y0lzIhRABbvhcHfKLvX cDEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DSYD3hSXr5dSGBwwFhgmPY+Jg1epD5ze6gJ/T99kUGE=; b=coGPd8TpYllQ4dVgdoGzz+c6bU/8lP3rEeoHC8YXQvOCFdRVGrqShBYYT07qGcBsC3 6bXMf3+lHSlONbXYY0dTA7W5CTtUZs1unZecBdjp6UnJra7+GNwmGNlipTX7Y3ZrPNiD Pie/3KXTybRg5e4NS2KkoS00GIUS8yt0ikRontBljiG8KxYUKAZPZofgFrNf8qLzLdpX mYJ7ZvY1NdP+q0VYikscWWClbllxqPL21g5NlQznnbLG3TkA01hlb+HayulPLWsLk5s5 TOzuj88ih8W1VCQwYIiR1d4smB0UfOLHELs4JDMVmnrCWaMlhXvk9TUToqZdHboXsyEp y2Mw== X-Gm-Message-State: ACrzQf1ZqLK3JkCnn6QKK5Hn0G3K8R3idPJrZqwuYE1DdeX5qtUBmHmo NtsIaRzfnlHcYXDhSV5iKij4SQ== X-Received: by 2002:adf:e19e:0:b0:22e:64de:39fa with SMTP id az30-20020adfe19e000000b0022e64de39famr21896486wrb.369.1667571256470; Fri, 04 Nov 2022 07:14:16 -0700 (PDT) Received: from [127.0.0.1] (2a02-8440-6440-7fff-3074-96af-9642-0003.rev.sfr.net. [2a02:8440:6440:7fff:3074:96af:9642:3]) by smtp.gmail.com with ESMTPSA id bj9-20020a0560001e0900b002365cd93d05sm3594512wrb.102.2022.11.04.07.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 07:14:15 -0700 (PDT) From: Guillaume Ranquet Date: Fri, 04 Nov 2022 15:09:51 +0100 Subject: [PATCH v3 05/12] drm/mediatek: hdmi: make the cec dev optional MIME-Version: 1.0 Message-Id: <20220919-v3-5-a803f2660127@baylibre.com> References: <20220919-v3-0-a803f2660127@baylibre.com> In-Reply-To: <20220919-v3-0-a803f2660127@baylibre.com> To: Rob Herring , Chun-Kuang Hu , Chunfeng Yun , Jitao shi , Matthias Brugger , Vinod Koul , CK Hu , Daniel Vetter , David Airlie , Krzysztof Kozlowski , Philipp Zabel , Kishon Vijay Abraham I Cc: Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, stuart.lee@mediatek.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, Guillaume Ranquet , mac.shen@mediatek.com, linux-phy@lists.infradead.org X-Mailer: b4 0.11.0-dev X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748575286830587810?= X-GMAIL-MSGID: =?utf-8?q?1748575286830587810?= Make cec device optional in order to support newer versions of the hdmi IP which doesn't require it Signed-off-by: Guillaume Ranquet --- 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);