From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EF8BC47258 for ; Mon, 4 May 2020 06:25:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF40620735 for ; Mon, 4 May 2020 06:25:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726885AbgEDGZB (ORCPT ); Mon, 4 May 2020 02:25:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726330AbgEDGZA (ORCPT ); Mon, 4 May 2020 02:25:00 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A480DC061A0E for ; Sun, 3 May 2020 23:25:00 -0700 (PDT) Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jVUX7-0004OA-T3; Mon, 04 May 2020 08:24:53 +0200 Received: from mfe by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1jVUWx-0000TK-96; Mon, 04 May 2020 08:24:43 +0200 Date: Mon, 4 May 2020 08:24:43 +0200 From: Marco Felsch To: Robert Foss Cc: Sakari Ailus , Andy Shevchenko , Maxime Ripard , linux-media , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-kernel , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , Dongchun Zhu , Fabio Estevam , Tomasz Figa Subject: Re: [PATCH v6 2/3] media: ov8856: Add devicetree support Message-ID: <20200504062443.qgme3pnhzugqeqhk@pengutronix.de> References: <20200429162437.2025699-1-robert.foss@linaro.org> <20200429162437.2025699-3-robert.foss@linaro.org> <20200430093524.GB2188@pengutronix.de> <20200430094549.GF867@valkosipuli.retiisi.org.uk> <20200430095332.GC2188@pengutronix.de> <20200430095907.GG867@valkosipuli.retiisi.org.uk> <20200430101157.GD2188@pengutronix.de> <20200430102018.GI867@valkosipuli.retiisi.org.uk> <20200430120740.GG2188@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 08:13:17 up 170 days, 21:31, 171 users, load average: 0.06, 0.04, 0.05 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robert, On 20-04-30 18:11, Robert Foss wrote: > Hey Marco, > > On Thu, 30 Apr 2020 at 14:07, Marco Felsch wrote: > > > > On 20-04-30 13:20, Sakari Ailus wrote: > > > On Thu, Apr 30, 2020 at 12:11:57PM +0200, Marco Felsch wrote: > > > > On 20-04-30 12:59, Sakari Ailus wrote: > > > > > Hi Marco, > > > > > > > > > > On Thu, Apr 30, 2020 at 11:53:32AM +0200, Marco Felsch wrote: > > > > > > Hi Sakari, > > > > > > > > > > > > On 20-04-30 12:45, Sakari Ailus wrote: > > > > > > > Hi Marco, > > > > > > > > > > > > > > On Thu, Apr 30, 2020 at 11:35:24AM +0200, Marco Felsch wrote: > > > > > > > > ... > > > > > > > > > > > > > - if (mclk != OV8856_MCLK) { > > > > > > > > > - dev_err(dev, "external clock %d is not supported", mclk); > > > > > > > > > - return -EINVAL; > > > > > > > > > + if (!is_acpi_node(fwnode)) { > > > > > > > > > + ov8856->xvclk = devm_clk_get(dev, "xvclk"); > > > > > > > > > + if (IS_ERR(ov8856->xvclk)) { > > > > > > > > > + dev_err(dev, "could not get xvclk clock (%pe)\n", > > > > > > > > > + ov8856->xvclk); > > > > > > > > > + return PTR_ERR(ov8856->xvclk); > > > > > > > > > + } > > > > > > > > > + > > > > > > > > > + clk_set_rate(ov8856->xvclk, xvclk_rate); > > > > > > > > > + xvclk_rate = clk_get_rate(ov8856->xvclk); > > > > > > > > > } > > > > > > > > > > > > > > > > Why do we handle the clock only in DT case? Is there a problem with the > > > > > > > > clock handling and ACPI? > > > > > > > > > > > > > > Not really, it's just that ACPI does not provide an interface to the clocks > > > > > > > as such. > > > > > > > > > > > > But you will get a clk by devm_clk_get()? > > > > > > > > > > No, because ACPI does not expose one to drivers. Effectively the entire > > > > > power sequences are implemented in ACPI, not in the driver. > > > > > > > > > > > > > Ah okay, thanks for the explanation. I'm really not into the ACPI > > > > stuff.. So this means the __power_off / power_on should only be done if > > > > we are using DT's? > > > > > > Correct. That's why it bails out early. It could be yet earlier though, > > > without doing anything. > > > > Yes I see. For easier and error less prone handling I would prefer: > > > > if (is_acpi_node()) > > return 0; > > > > as first instruction for __power_off/on(). > > __ov8856_power_on() does make a check like that, albeit only after > having run clk_prepare_enable() which won't do anything due to > ov8856->xvclk==NULL. So this should be fixed and be moved to after the > ACPI check. Yep, I saw that. I didn't checked the clk_prepare_enable() function and just saw that we don't request the clk for the acpi case and enable it in both cases. This doesn't sound right to me. > __ov8856_power_off() has no ACPI check, but all of the calls it makes > are going to do nothing due to v8856->reset_gpio / v8856->reset_gpio / > ov8856->xvclk all being NULL or dummies. For the sake of clarity an > early ACPI check+return could be added, but if clarity is the goal a > comment would work too. Thanks god that most of the library functions taking NULL into account =) But I think we have to take the regulator count into account. Again I don't know how the ACPI part is working. What happens if we request regulators which aren't listed within the ACPI table? In case of DT there will be added dummy-regulator. If this is the case for ACPI too we are ending in an unbalanced regulator enable/disable count since you enable it for the DT case and disable it in both cases. > > > > Also I would refactor the ov8856_check_hwcfg() so the common part can be > > used by this function and by a ov8856_parse_of() function. But thats > > only my opinion. > > I'm trying to grok the above paragraph. You'd like to see something in > the style of tc358743_probe_of()? You don't have to if Saki is fine with the current patch. Just saying that it would be a bit easier for the patch review. Regards, Marco > > > > Regards, > > Marco > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF999C3A5A9 for ; Mon, 4 May 2020 06:25:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD8DF206EB for ; Mon, 4 May 2020 06:25:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FeRHUX2+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD8DF206EB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CHb4LLW9O1P1MudK/OovT3lBaB2+PWv2p2I1QW7/nBU=; b=FeRHUX2+cH29bO JvCnAyjJxzGA8dopUtD0CHIRwecokWE2r62sRJeePaLjwd45+H5Ty+YykD2CBa91Abg0vURdG08UZ G8SG7uLDmNbUfZmlqq7qWh8nz2Nyh6UzigxJ6l0w9YB4TvLP8TssMSXQ5b2cfV9kbA4JwrL3t+rue qJtskQloUl2frWg901FyDKFBMnCA7i4zOFxBxEvu4WvsOgDYq84nNdTs77skyX6MZE21jKfhVX6RB qCiNG3410DKZmwy7bcExLf0j9zACP/UORE2dutbo41JqxCf5MRUnG4MAujBXFBH3VQ4S2RyyZOVEL zsKnf1UPcKSeF3xA4ncg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jVUXK-0002r8-RX; Mon, 04 May 2020 06:25:06 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jVUXG-0001ns-Lm for linux-arm-kernel@lists.infradead.org; Mon, 04 May 2020 06:25:04 +0000 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jVUX7-0004OA-T3; Mon, 04 May 2020 08:24:53 +0200 Received: from mfe by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1jVUWx-0000TK-96; Mon, 04 May 2020 08:24:43 +0200 Date: Mon, 4 May 2020 08:24:43 +0200 From: Marco Felsch To: Robert Foss Subject: Re: [PATCH v6 2/3] media: ov8856: Add devicetree support Message-ID: <20200504062443.qgme3pnhzugqeqhk@pengutronix.de> References: <20200429162437.2025699-1-robert.foss@linaro.org> <20200429162437.2025699-3-robert.foss@linaro.org> <20200430093524.GB2188@pengutronix.de> <20200430094549.GF867@valkosipuli.retiisi.org.uk> <20200430095332.GC2188@pengutronix.de> <20200430095907.GG867@valkosipuli.retiisi.org.uk> <20200430101157.GD2188@pengutronix.de> <20200430102018.GI867@valkosipuli.retiisi.org.uk> <20200430120740.GG2188@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 08:13:17 up 170 days, 21:31, 171 users, load average: 0.06, 0.04, 0.05 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200503_232502_732021_6773D2FE X-CRM114-Status: GOOD ( 29.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Dongchun Zhu , linux-kernel , Tomasz Figa , Sakari Ailus , Maxime Ripard , Andy Shevchenko , Fabio Estevam , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linux-media Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Robert, On 20-04-30 18:11, Robert Foss wrote: > Hey Marco, > > On Thu, 30 Apr 2020 at 14:07, Marco Felsch wrote: > > > > On 20-04-30 13:20, Sakari Ailus wrote: > > > On Thu, Apr 30, 2020 at 12:11:57PM +0200, Marco Felsch wrote: > > > > On 20-04-30 12:59, Sakari Ailus wrote: > > > > > Hi Marco, > > > > > > > > > > On Thu, Apr 30, 2020 at 11:53:32AM +0200, Marco Felsch wrote: > > > > > > Hi Sakari, > > > > > > > > > > > > On 20-04-30 12:45, Sakari Ailus wrote: > > > > > > > Hi Marco, > > > > > > > > > > > > > > On Thu, Apr 30, 2020 at 11:35:24AM +0200, Marco Felsch wrote: > > > > > > > > ... > > > > > > > > > > > > > - if (mclk != OV8856_MCLK) { > > > > > > > > > - dev_err(dev, "external clock %d is not supported", mclk); > > > > > > > > > - return -EINVAL; > > > > > > > > > + if (!is_acpi_node(fwnode)) { > > > > > > > > > + ov8856->xvclk = devm_clk_get(dev, "xvclk"); > > > > > > > > > + if (IS_ERR(ov8856->xvclk)) { > > > > > > > > > + dev_err(dev, "could not get xvclk clock (%pe)\n", > > > > > > > > > + ov8856->xvclk); > > > > > > > > > + return PTR_ERR(ov8856->xvclk); > > > > > > > > > + } > > > > > > > > > + > > > > > > > > > + clk_set_rate(ov8856->xvclk, xvclk_rate); > > > > > > > > > + xvclk_rate = clk_get_rate(ov8856->xvclk); > > > > > > > > > } > > > > > > > > > > > > > > > > Why do we handle the clock only in DT case? Is there a problem with the > > > > > > > > clock handling and ACPI? > > > > > > > > > > > > > > Not really, it's just that ACPI does not provide an interface to the clocks > > > > > > > as such. > > > > > > > > > > > > But you will get a clk by devm_clk_get()? > > > > > > > > > > No, because ACPI does not expose one to drivers. Effectively the entire > > > > > power sequences are implemented in ACPI, not in the driver. > > > > > > > > > > > > > Ah okay, thanks for the explanation. I'm really not into the ACPI > > > > stuff.. So this means the __power_off / power_on should only be done if > > > > we are using DT's? > > > > > > Correct. That's why it bails out early. It could be yet earlier though, > > > without doing anything. > > > > Yes I see. For easier and error less prone handling I would prefer: > > > > if (is_acpi_node()) > > return 0; > > > > as first instruction for __power_off/on(). > > __ov8856_power_on() does make a check like that, albeit only after > having run clk_prepare_enable() which won't do anything due to > ov8856->xvclk==NULL. So this should be fixed and be moved to after the > ACPI check. Yep, I saw that. I didn't checked the clk_prepare_enable() function and just saw that we don't request the clk for the acpi case and enable it in both cases. This doesn't sound right to me. > __ov8856_power_off() has no ACPI check, but all of the calls it makes > are going to do nothing due to v8856->reset_gpio / v8856->reset_gpio / > ov8856->xvclk all being NULL or dummies. For the sake of clarity an > early ACPI check+return could be added, but if clarity is the goal a > comment would work too. Thanks god that most of the library functions taking NULL into account =) But I think we have to take the regulator count into account. Again I don't know how the ACPI part is working. What happens if we request regulators which aren't listed within the ACPI table? In case of DT there will be added dummy-regulator. If this is the case for ACPI too we are ending in an unbalanced regulator enable/disable count since you enable it for the DT case and disable it in both cases. > > > > Also I would refactor the ov8856_check_hwcfg() so the common part can be > > used by this function and by a ov8856_parse_of() function. But thats > > only my opinion. > > I'm trying to grok the above paragraph. You'd like to see something in > the style of tc358743_probe_of()? You don't have to if Saki is fine with the current patch. Just saying that it would be a bit easier for the patch review. Regards, Marco > > > > Regards, > > Marco > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel