From patchwork Tue Mar 22 14:30:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Maselbas X-Patchwork-Id: 12788593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCFC5C433F5 for ; Tue, 22 Mar 2022 14:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237654AbiCVOhF (ORCPT ); Tue, 22 Mar 2022 10:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237676AbiCVOhE (ORCPT ); Tue, 22 Mar 2022 10:37:04 -0400 Received: from fx303.security-mail.net (mxout.security-mail.net [85.31.212.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E896AA4E for ; Tue, 22 Mar 2022 07:35:35 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by fx303.security-mail.net (Postfix) with ESMTP id B426F323703 for ; Tue, 22 Mar 2022 15:30:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1647959425; bh=elxJrAz+Zk/meRRiCxSQeQbcoeyWOdWNvzT+OrowOPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KOvQSpDHBbLa2PZQAGHl4jHrXX+SsDHuPnElpZ9aBwjFsGC17EkOi19u6NFt6qvqx qLx74WDmYw4+PRm6sJf+MrmX7SjFEwDEW9JGN4qAJoc1ZOswnz4rlSbgijt4Jij3yi 4yf2iRLbGnQ+1i0g39WBY4R7DJ3TH1cGchu2eteA= Received: from fx303 (localhost [127.0.0.1]) by fx303.security-mail.net (Postfix) with ESMTP id EF60D3236AF; Tue, 22 Mar 2022 15:30:23 +0100 (CET) X-Virus-Scanned: E-securemail Secumail-id: <6fc4.6239dd7b.28d08.0> Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx303.security-mail.net (Postfix) with ESMTPS id 29C093238FA; Tue, 22 Mar 2022 15:30:19 +0100 (CET) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 0C96027E043B; Tue, 22 Mar 2022 15:30:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id EB2C527E0439; Tue, 22 Mar 2022 15:30:18 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu EB2C527E0439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1647959419; bh=Z0l2T9tngUqyX7eAMN75gwor/BZgu23DPHC25lj9eso=; h=From:To:Date:Message-Id; b=kdkN/Xm1knBIz/xaOmBYo2NRQtXGt+iItwnRs0u4oeNyzlzNlMRUeXfrlpWfEJfwS LZPLywvCnOTFggt2Qmw1S38m1lgqqXw/O9S0SFTFSDkLBQf16nRTFt6YJMb7p1WWCr OM0ahab8ZIN+f2vaSuM826k+VGSq06ahN/rP8NZg= Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QDtnADSIWBG4; Tue, 22 Mar 2022 15:30:18 +0100 (CET) Received: from tellis.lin.mbt.kalray.eu (unknown [192.168.36.206]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id D15F027E0436; Tue, 22 Mar 2022 15:30:18 +0100 (CET) From: Jules Maselbas To: linux-usb@vger.kernel.org Cc: Ahmad Fatoum , Minas Harutyunyan , Kishon Vijay Abraham I , Amelie DELAUNAY , Yann Sionneau , Michael Grzeschik , Jules Maselbas Subject: [PATCH 1/2] phy: core: Add documentation of phy operation order Date: Tue, 22 Mar 2022 15:30:10 +0100 Message-Id: <20220322143011.16580-2-jmaselbas@kalray.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220322143011.16580-1-jmaselbas@kalray.eu> References: <20220322143011.16580-1-jmaselbas@kalray.eu> X-Virus-Scanned: by Secumail Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add documentation on phy function usage: init function must be called before power_on; power_off must be called before exit. Signed-off-by: Jules Maselbas CC: Ahmad Fatoum CC: Amelie DELAUNAY --- drivers/phy/phy-core.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 91e28d6ce450..ed10cbb24b08 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -229,6 +229,17 @@ void phy_pm_runtime_forbid(struct phy *phy) } EXPORT_SYMBOL_GPL(phy_pm_runtime_forbid); +/** + * phy_init - phy internal initialization before phy operation + * @phy: the phy returned by phy_get() + * + * Used to allow phy's driver to perform phy internal initialization, + * such as PLL block powering, clock initialization or anything that's + * is required by the phy to perform the start of operation. + * Must be called before phy_power_on(). + * + * Returns: 0 if successful, an negative error code otherwise + */ int phy_init(struct phy *phy) { int ret; @@ -258,6 +269,14 @@ int phy_init(struct phy *phy) } EXPORT_SYMBOL_GPL(phy_init); +/** + * phy_exit - Phy internal un-initialization + * @phy: the phy returned by phy_get() + * + * Must be called after phy_power_off(). + * + * Returns: 0 if successful, an negative error code otherwise + */ int phy_exit(struct phy *phy) { int ret; @@ -287,6 +306,14 @@ int phy_exit(struct phy *phy) } EXPORT_SYMBOL_GPL(phy_exit); +/** + * phy_power_on - Enable the phy and enter proper operation + * @phy: the phy returned by phy_get() + * + * Must be called after phy_init(). + * + * Returns: 0 if successful, an negative error code otherwise + */ int phy_power_on(struct phy *phy) { int ret = 0; @@ -329,6 +356,14 @@ int phy_power_on(struct phy *phy) } EXPORT_SYMBOL_GPL(phy_power_on); +/** + * phy_power_off - Disable the phy. + * @phy: the phy returned by phy_get() + * + * Must be called before phy_exit(). + * + * Returns: 0 if successful, an negative error code otherwise + */ int phy_power_off(struct phy *phy) { int ret; From patchwork Tue Mar 22 14:30:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Maselbas X-Patchwork-Id: 12788591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74739C433F5 for ; Tue, 22 Mar 2022 14:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237637AbiCVOgn (ORCPT ); Tue, 22 Mar 2022 10:36:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237585AbiCVOgm (ORCPT ); Tue, 22 Mar 2022 10:36:42 -0400 X-Greylist: delayed 288 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 22 Mar 2022 07:35:10 PDT Received: from fx403.security-mail.net (smtpout140.security-mail.net [85.31.212.143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77C4E6A060 for ; Tue, 22 Mar 2022 07:35:10 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by fx403.security-mail.net (Postfix) with ESMTP id 93BF74FE6F9 for ; Tue, 22 Mar 2022 15:30:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1647959423; bh=6/vdjKdj3TBAacD39r/JYj7DZ/ZJcRrY8/Jra+61PTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=u3yHab9b++YiVwoxxmMfdFIC9f97gIF1w3yAg91I5af363HCUGoQ3Rgl2TfgTyNbg /T4tS6eNVxlNRL1Yx7MLyi4dd9SYwKOCy8tjQWnoSYVT/L5KscEDpXK1RfeimCQph3 PjiVBirtK9C8tUu13lhgZwIpv30lpLTBHmxFHapY= Received: from fx403 (localhost [127.0.0.1]) by fx403.security-mail.net (Postfix) with ESMTP id 383E14FE695; Tue, 22 Mar 2022 15:30:22 +0100 (CET) X-Virus-Scanned: E-securemail Secumail-id: <90bf.6239dd7c.7b214.0> Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx403.security-mail.net (Postfix) with ESMTPS id 2DD554FE638; Tue, 22 Mar 2022 15:30:20 +0100 (CET) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 448AE27E043B; Tue, 22 Mar 2022 15:30:20 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 2EAC627E0439; Tue, 22 Mar 2022 15:30:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 2EAC627E0439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1647959420; bh=xBNbec84HSSpoeLNL9eQD9nc7AhHGc6JxV8Ln5sjJUk=; h=From:To:Date:Message-Id; b=R6qfCWaaFuZ2xQAGLUKK8VyELAKqUdtu8vp062E3Dch26xKFFpLwkQxPV215/jj7Y BD+mkHpO4EC6wibc2uq8o69mQ0dxRf5WY197QgndP1X4rqpTt7QQwA97nvbXolMxtp hWUPexmmvwq6RjkbbpZlFWajVxLDzRV2VEUXpO00= Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id LkN_4kkowPbE; Tue, 22 Mar 2022 15:30:20 +0100 (CET) Received: from tellis.lin.mbt.kalray.eu (unknown [192.168.36.206]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 1D70827E0436; Tue, 22 Mar 2022 15:30:20 +0100 (CET) From: Jules Maselbas To: linux-usb@vger.kernel.org Cc: Ahmad Fatoum , Minas Harutyunyan , Kishon Vijay Abraham I , Amelie DELAUNAY , Yann Sionneau , Michael Grzeschik , Jules Maselbas Subject: [PATCH 2/2] phy: core: Warn when phy_power_on is called before phy_init Date: Tue, 22 Mar 2022 15:30:11 +0100 Message-Id: <20220322143011.16580-3-jmaselbas@kalray.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220322143011.16580-1-jmaselbas@kalray.eu> References: <20220322143011.16580-1-jmaselbas@kalray.eu> X-Virus-Scanned: by Secumail Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org A warning when the order of phy operation is mixed up by drivers, this is an atempt to make the phy usage more uniform across (usb) drivers. CC: Ahmad Fatoum CC: Amelie DELAUNAY Signed-off-by: Jules Maselbas --- drivers/phy/phy-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index ed10cbb24b08..2c2c0f073080 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -252,6 +252,9 @@ int phy_init(struct phy *phy) return ret; ret = 0; /* Override possible ret == -ENOTSUPP */ + if (phy->power_count > phy->init_count) + dev_warn(&phy->dev, "phy_power_on was called before phy_init\n"); + mutex_lock(&phy->mutex); if (phy->init_count == 0 && phy->ops->init) { ret = phy->ops->init(phy);