From patchwork Wed Dec 14 12:57:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 9474143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5BE62607EE for ; Wed, 14 Dec 2016 12:59:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D3C228725 for ; Wed, 14 Dec 2016 12:59:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 401E028729; Wed, 14 Dec 2016 12:59:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B391D28725 for ; Wed, 14 Dec 2016 12:59:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cH98T-0007Lb-3n; Wed, 14 Dec 2016 12:58:17 +0000 Received: from mail-wj0-x233.google.com ([2a00:1450:400c:c01::233]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cH97u-00073I-La for linux-arm-kernel@lists.infradead.org; Wed, 14 Dec 2016 12:57:45 +0000 Received: by mail-wj0-x233.google.com with SMTP id xy5so32281729wjc.0 for ; Wed, 14 Dec 2016 04:57:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ggqsk2Ym1jmDQxtxxPMX3/jBMqtmDYKYplJGTeBrZAU=; b=AWgzp9Mvr5wP95s6xj2EQ3IMBz26kJVUT0o+IV8/FOLJGz6c5LFxxJzJSxPTJO5qbO Star/XJEeH5PRLF0DhFUbnxIlj1rXHyusczBqdR4lsCo/l64yLCJzl2u+z2/cq+m2GnX 1/nhz7ZXxfiZuqKrEPkUbdhlwoyvTYK8nJ1ws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ggqsk2Ym1jmDQxtxxPMX3/jBMqtmDYKYplJGTeBrZAU=; b=ByoOknktSzT3gwbE435kmSHu1mXgGh0NkCOu67HnVYyu80csb3FkGDeuGeHUxKfe0C 9g0pKjz5Az/PzN0gxK0IgLl7C9l0h487cvZK0ngCeBTbNvv4dKMvFtRy7rTv0ZOz+Aog ZajwoYJjv7msW/XRpnIxSmxrhLdK1blexAfQ7+P2YeDXCs1Qat0Apxe8pQuEoohcQmxF g9zFZ/Spowmn+/+oQaMINpidEK7hMN93gKDtI9dcgYTuoqoshwg0RnuV61cQoQQK3+Vs RsxxueTiHyeYaQtxb+NEBfUaci06pHFeMV3wO83Oj7r4LZ4ij6Wj1YCssVJT4otKsCHH 4sZA== X-Gm-Message-State: AKaTC02Ye7FWf90WIQQWlpRlhvrlTgDZR/8G00aFjEvpb84LugGzYKIGpnyZYXBdxsmOPT9O X-Received: by 10.28.47.196 with SMTP id v187mr7165043wmv.75.1481720240241; Wed, 14 Dec 2016 04:57:20 -0800 (PST) Received: from lmenx321.st.com. ([80.214.114.255]) by smtp.gmail.com with ESMTPSA id j6sm67192579wjk.25.2016.12.14.04.57.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Dec 2016 04:57:19 -0800 (PST) From: Benjamin Gaignard To: linux-media@vger.kernel.org, hverkuil@xs4all.nl Subject: [PATCH 2/2] stih-cec: add hdmi-notifier support Date: Wed, 14 Dec 2016 13:57:09 +0100 Message-Id: <1481720229-7587-3-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1481720229-7587-1-git-send-email-benjamin.gaignard@linaro.org> References: <1481720229-7587-1-git-send-email-benjamin.gaignard@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161214_045742_953292_2B05BAE3 X-CRM114-Status: GOOD ( 18.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, linaro-kernel@lists.linaro.org, kernel@stlinux.com, linux@armlinux.org.uk, dri-devel@lists.freedesktop.org, Benjamin Gaignard , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP By using the HDMI notifier framework there is no longer any reason to manually set the physical address. This was the one blocking issue that prevented this driver from going out of staging, so do this move as well. Update the bindings documenting the new hdmi phandle and update stih410.dtsi and stih407-family.dtsi accordingly. Signed-off-by: Benjamin Gaignard --- .../devicetree/bindings/media/stih-cec.txt | 2 ++ arch/arm/boot/dts/stih407-family.dtsi | 12 --------- arch/arm/boot/dts/stih410.dtsi | 15 ++++++++++- drivers/staging/media/st-cec/Kconfig | 1 + drivers/staging/media/st-cec/stih-cec.c | 29 +++++++++++++++++++++- 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/Documentation/devicetree/bindings/media/stih-cec.txt b/Documentation/devicetree/bindings/media/stih-cec.txt index 71c4b2f..7d82121 100644 --- a/Documentation/devicetree/bindings/media/stih-cec.txt +++ b/Documentation/devicetree/bindings/media/stih-cec.txt @@ -9,6 +9,7 @@ Required properties: - pinctrl-names: Contains only one value - "default" - pinctrl-0: Specifies the pin control groups used for CEC hardware. - resets: Reference to a reset controller + - st,hdmi-handle: Phandle to the HMDI controller Example for STIH407: @@ -22,4 +23,5 @@ sti-cec@094a087c { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_cec0_default>; resets = <&softreset STIH407_LPM_SOFTRESET>; + st,hdmi-handle = <&hdmi>; }; diff --git a/arch/arm/boot/dts/stih407-family.dtsi b/arch/arm/boot/dts/stih407-family.dtsi index 8f79b41..ef7c79a 100644 --- a/arch/arm/boot/dts/stih407-family.dtsi +++ b/arch/arm/boot/dts/stih407-family.dtsi @@ -756,18 +756,6 @@ <&clk_s_c0_flexgen CLK_ETH_PHY>; }; - cec: sti-cec@094a087c { - compatible = "st,stih-cec"; - reg = <0x94a087c 0x64>; - clocks = <&clk_sysin>; - clock-names = "cec-clk"; - interrupts = ; - interrupt-names = "cec-irq"; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_cec0_default>; - resets = <&softreset STIH407_LPM_SOFTRESET>; - }; - rng10: rng@08a89000 { compatible = "st,rng"; reg = <0x08a89000 0x1000>; diff --git a/arch/arm/boot/dts/stih410.dtsi b/arch/arm/boot/dts/stih410.dtsi index a3ef734..c98d86e 100644 --- a/arch/arm/boot/dts/stih410.dtsi +++ b/arch/arm/boot/dts/stih410.dtsi @@ -193,7 +193,7 @@ <&clk_s_d2_quadfs 0>; }; - sti-hdmi@8d04000 { + hdmi: sti-hdmi@8d04000 { compatible = "st,stih407-hdmi"; reg = <0x8d04000 0x1000>; reg-names = "hdmi-reg"; @@ -259,5 +259,18 @@ clocks = <&clk_sysin>; interrupts = ; }; + + sti-cec@094a087c { + compatible = "st,stih-cec"; + reg = <0x94a087c 0x64>; + clocks = <&clk_sysin>; + clock-names = "cec-clk"; + interrupts = ; + interrupt-names = "cec-irq"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_cec0_default>; + resets = <&softreset STIH407_LPM_SOFTRESET>; + st,hdmi-handle = <&hdmi>; + }; }; }; diff --git a/drivers/staging/media/st-cec/Kconfig b/drivers/staging/media/st-cec/Kconfig index 784d2c6..3072387 100644 --- a/drivers/staging/media/st-cec/Kconfig +++ b/drivers/staging/media/st-cec/Kconfig @@ -1,6 +1,7 @@ config VIDEO_STI_HDMI_CEC tristate "STMicroelectronics STiH4xx HDMI CEC driver" depends on VIDEO_DEV && MEDIA_CEC && (ARCH_STI || COMPILE_TEST) + select HDMI_NOTIFIERS ---help--- This is a driver for STIH4xx HDMI CEC interface. It uses the generic CEC framework interface. diff --git a/drivers/staging/media/st-cec/stih-cec.c b/drivers/staging/media/st-cec/stih-cec.c index 2143448..ce94097 100644 --- a/drivers/staging/media/st-cec/stih-cec.c +++ b/drivers/staging/media/st-cec/stih-cec.c @@ -10,11 +10,13 @@ * (at your option) any later version. */ #include +#include #include #include #include #include #include +#include #include #include @@ -130,6 +132,7 @@ struct stih_cec { void __iomem *regs; int irq; u32 irq_status; + struct hdmi_notifier *notifier; }; static int stih_cec_adap_enable(struct cec_adapter *adap, bool enable) @@ -304,12 +307,29 @@ static int stih_cec_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct resource *res; struct stih_cec *cec; + struct device_node *np; + struct platform_device *hdmi_dev; int ret; cec = devm_kzalloc(dev, sizeof(*cec), GFP_KERNEL); if (!cec) return -ENOMEM; + np = of_parse_phandle(pdev->dev.of_node, "st,hdmi-handle", 0); + + if (!np) { + dev_err(&pdev->dev, "Failed to find hdmi node in device tree\n"); + return -ENODEV; + } + + hdmi_dev = of_find_device_by_node(np); + if (!hdmi_dev) + return -EPROBE_DEFER; + + cec->notifier = hdmi_notifier_get(&hdmi_dev->dev); + if (!cec->notifier) + return -ENOMEM; + cec->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -336,7 +356,7 @@ static int stih_cec_probe(struct platform_device *pdev) cec->adap = cec_allocate_adapter(&sti_cec_adap_ops, cec, CEC_NAME, CEC_CAP_LOG_ADDRS | CEC_CAP_PASSTHROUGH | - CEC_CAP_PHYS_ADDR | CEC_CAP_TRANSMIT, + CEC_CAP_TRANSMIT, 1, &pdev->dev); ret = PTR_ERR_OR_ZERO(cec->adap); if (ret) @@ -348,12 +368,19 @@ static int stih_cec_probe(struct platform_device *pdev) return ret; } + cec_register_hdmi_notifier(cec->adap, cec->notifier); + platform_set_drvdata(pdev, cec); return 0; } static int stih_cec_remove(struct platform_device *pdev) { + struct stih_cec *cec = platform_get_drvdata(pdev); + + cec_unregister_adapter(cec->adap); + hdmi_notifier_put(cec->notifier); + return 0; }