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: 9474131 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 DEBF1607EE for ; Wed, 14 Dec 2016 12:57:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1865286DF for ; Wed, 14 Dec 2016 12:57:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C59262872B; Wed, 14 Dec 2016 12:57:40 +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=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 36232286DF for ; Wed, 14 Dec 2016 12:57:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2464A6E7F4; Wed, 14 Dec 2016 12:57:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wj0-x22f.google.com (mail-wj0-x22f.google.com [IPv6:2a00:1450:400c:c01::22f]) by gabe.freedesktop.org (Postfix) with ESMTPS id F2A7D6E7EE for ; Wed, 14 Dec 2016 12:57:21 +0000 (UTC) Received: by mail-wj0-x22f.google.com with SMTP id tk12so32935532wjb.3 for ; Wed, 14 Dec 2016 04:57:21 -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=hycOtKFztKosBtN4APn5f+1/PTXbbMld02lmK4jZmzJ9HBKueK1K37P72sYCz19gDN pwkoZfFKgY2ZwXfnTSc2peeOwMtRKql4aY75dwhlV2shzgvHWLUI8jvoba4YFb8Z/v9n izhztMbtv21oBbxBUnfUZ5wUCrpsEt4mM9660jkWhfmru2zoT588QD/Fu9xSt97CofH9 EeSyrAPFvewIboU/VDvPxBcNAsfshEbWY9S/Gm+GMAvkxUqnu21g9NFgydlE8ImIPWJp sU0LhSyeAFaN2IrEl+8N8x1eHKAzP543g+uLZtvTlHGEnB44yOdFyPUMtUTE+Yko/lTQ Qxmw== X-Gm-Message-State: AKaTC03I2w5QCqEC9KwovBMDY8u1b4wBSAVnBDXZckNTK2RM3b2pUgjERog+HdO82R3XVLcy 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> Cc: linux-fbdev@vger.kernel.org, linaro-kernel@lists.linaro.org, kernel@stlinux.com, linux@armlinux.org.uk, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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; }