From patchwork Wed Mar 23 11:07:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Maselbas X-Patchwork-Id: 554014 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 DF834C433F5 for ; Wed, 23 Mar 2022 11:07:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239575AbiCWLI5 (ORCPT ); Wed, 23 Mar 2022 07:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbiCWLI5 (ORCPT ); Wed, 23 Mar 2022 07:08:57 -0400 Received: from fx601.security-mail.net (smtpout140.security-mail.net [85.31.212.146]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0351B4ECF8 for ; Wed, 23 Mar 2022 04:07:26 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by fx601.security-mail.net (Postfix) with ESMTP id F239C3AD034 for ; Wed, 23 Mar 2022 12:07:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1648033645; bh=dWN29bOnngar+VcnGORe9zqqjPYqTG5gblvp5Er3NTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=huH1RWAY9DlB7aFtlkkvie9NccxkTmxPXip8mgH8Cu5gEZ/XRpCc17u6CZ8Gm6/tJ JEGgO4pGwHJ5SfKxmq2QkLAaTrEuYUmGgPhiD98sVK9TBbKjLNjSql1efrUOc4bUdl tkKdabi+cKs8cauESPoAhhgJ2RBAsjxAO2x595Q4= Received: from fx601 (localhost [127.0.0.1]) by fx601.security-mail.net (Postfix) with ESMTP id AB5A13AD065; Wed, 23 Mar 2022 12:07:23 +0100 (CET) X-Virus-Scanned: E-securemail Secumail-id: <9bf5.623aff69.40ab5.0> Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx601.security-mail.net (Postfix) with ESMTPS id 41ACC3ACF3A; Wed, 23 Mar 2022 12:07:21 +0100 (CET) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 2361227E0444; Wed, 23 Mar 2022 12:07:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 0DA1D27E0443; Wed, 23 Mar 2022 12:07:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 0DA1D27E0443 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1648033641; bh=z97YwJXvaXhCXAar/RqNTITcuyij3jb/j46q/moCS3k=; h=From:To:Date:Message-Id; b=TEmvokObvEaG/TlBajRbY+oPdViklWhkBcUCcIpNvIDTIDxDXpUdePDKHq1WNYBMx yvd+q00QPr7yp1y8Y7FVIWQRlkDJ2IMWF4tty2qlpDkPSvLGBpxB/58OWhRP4/J6sF NXJLG41F0Ogg4+J338vqIDcv+hpEM9qSvwfKu6rs= 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 VLfzh0c1vaHz; Wed, 23 Mar 2022 12:07:21 +0100 (CET) Received: from tellis.lin.mbt.kalray.eu (unknown [192.168.36.206]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id E729427E0425; Wed, 23 Mar 2022 12:07: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 , Randy Dunlap , Arnd Bergmann , Jules Maselbas Subject: [PATCH v2 1/3] phy: core: Add documentation of phy operation order Date: Wed, 23 Mar 2022 12:07:06 +0100 Message-Id: <20220323110708.8254-2-jmaselbas@kalray.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220323110708.8254-1-jmaselbas@kalray.eu> References: <20220323110708.8254-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 Cc: Minas Harutyunyan Cc: Kishon Vijay Abraham I --- change in v2: - Update the documentation syntax for returned value 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..2f32f999445f 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(). + * + * Return: %0 if successful, a 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(). + * + * Return: %0 if successful, a 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(). + * + * Return: %0 if successful, a 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(). + * + * Return: %0 if successful, a negative error code otherwise + */ int phy_power_off(struct phy *phy) { int ret; From patchwork Wed Mar 23 11:07:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Maselbas X-Patchwork-Id: 554013 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 3BA01C433EF for ; Wed, 23 Mar 2022 11:07:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242752AbiCWLJN (ORCPT ); Wed, 23 Mar 2022 07:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230331AbiCWLJN (ORCPT ); Wed, 23 Mar 2022 07:09:13 -0400 Received: from fx308.security-mail.net (smtpout30.security-mail.net [85.31.212.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 951337806E for ; Wed, 23 Mar 2022 04:07:43 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by fx308.security-mail.net (Postfix) with ESMTP id 44AD181C50B for ; Wed, 23 Mar 2022 12:07:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1648033662; bh=cmxsWVENngI8AG3RFKrkxT2nJQtlNf9zKwwrZjY0kJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=5qhrcwRy+h/VlRLPoYo84MqbdKEesTXR8NX7AdE+9bTT1jYRqhZNi7cp9rhYBsH/Y enj0iVgZMgVR2yt9W0r4r3ammeRS+d9qyptXDPaFrYudoD9yoR/VvccJu3RJqN3ss/ spKFma+ylcm7eKwL1A1t2SeEi3YqvLKeOejPGZ3U= Received: from fx308 (localhost [127.0.0.1]) by fx308.security-mail.net (Postfix) with ESMTP id 1A66681C443; Wed, 23 Mar 2022 12:07:40 +0100 (CET) X-Virus-Scanned: E-securemail Secumail-id: Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx308.security-mail.net (Postfix) with ESMTPS id E762281C3CF; Wed, 23 Mar 2022 12:07:21 +0100 (CET) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id CB14F27E0444; Wed, 23 Mar 2022 12:07:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id B554127E0443; Wed, 23 Mar 2022 12:07:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu B554127E0443 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1648033641; bh=Is5Op+yf2jLp8LVzNyoyPvTTzZW0Vq4RhBV0HSyWYtg=; h=From:To:Date:Message-Id; b=Ph8yGGqbCORv4YWj0pOXU6ZeEy6TuDIBlzBQeHeQOSjqGfNx7bz1vi0mKx8/uejPy UefEYzlKyYgteYfOft3iPWIqhGgo2IpgzH9pMSbVOUPzw23fgSml7C/uh7ZeZbxLbR BrqnpOJ06Hp3hjf4ca4xx7SwP3RQOY146WXkJ4Fw= 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 utvgyQvDC_cS; Wed, 23 Mar 2022 12:07:21 +0100 (CET) Received: from tellis.lin.mbt.kalray.eu (unknown [192.168.36.206]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id A304F27E0425; Wed, 23 Mar 2022 12:07:21 +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 , Randy Dunlap , Arnd Bergmann , Jules Maselbas Subject: [PATCH v2 2/3] phy: core: Update documentation syntax Date: Wed, 23 Mar 2022 12:07:07 +0100 Message-Id: <20220323110708.8254-3-jmaselbas@kalray.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220323110708.8254-1-jmaselbas@kalray.eu> References: <20220323110708.8254-1-jmaselbas@kalray.eu> X-Virus-Scanned: by Secumail Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Update the syntax used by the documentation of phy operation functions. This is to unify the syntax with the newly added documentation. Signed-off-by: Jules Maselbas --- change in v2: - New patch drivers/phy/phy-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 2f32f999445f..cbdad65d2caa 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -467,7 +467,7 @@ EXPORT_SYMBOL_GPL(phy_reset); * runtime, which are otherwise lost after host controller reset and cannot * be applied in phy_init() or phy_power_on(). * - * Returns: 0 if successful, an negative error code otherwise + * Return: %0 if successful, a negative error code otherwise */ int phy_calibrate(struct phy *phy) { @@ -493,7 +493,7 @@ EXPORT_SYMBOL_GPL(phy_calibrate); * on the phy. The configuration will be applied on the current phy * mode, that can be changed using phy_set_mode(). * - * Returns: 0 if successful, an negative error code otherwise + * Return: %0 if successful, a negative error code otherwise */ int phy_configure(struct phy *phy, union phy_configure_opts *opts) { @@ -527,7 +527,7 @@ EXPORT_SYMBOL_GPL(phy_configure); * PHY, so calling it as many times as deemed fit will have no side * effect. * - * Returns: 0 if successful, an negative error code otherwise + * Return: %0 if successful, a negative error code otherwise */ int phy_validate(struct phy *phy, enum phy_mode mode, int submode, union phy_configure_opts *opts) From patchwork Wed Mar 23 11:07:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Maselbas X-Patchwork-Id: 553869 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 4E714C433EF for ; Wed, 23 Mar 2022 11:07:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243739AbiCWLI7 (ORCPT ); Wed, 23 Mar 2022 07:08:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235590AbiCWLI5 (ORCPT ); Wed, 23 Mar 2022 07:08:57 -0400 Received: from fx601.security-mail.net (smtpout140.security-mail.net [85.31.212.146]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7156678077 for ; Wed, 23 Mar 2022 04:07:27 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by fx601.security-mail.net (Postfix) with ESMTP id 11AD83AD0F5 for ; Wed, 23 Mar 2022 12:07:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalray.eu; s=sec-sig-email; t=1648033646; bh=69zZpxa6rBNXrUgok6kJ+TKqaxhS4oyp57/az67O4W8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sImvwxBjq6c/FGiAOl4UKHrlZU1jqAkqmVJusn58306XmoqE788E19YFZjYx5HTt0 UaIlSG9BEyga9fDJXCQ1RhVBlv9C4r2Mxczs3cRSWiehBofRbnwsWY/EjxdtH3cvji wVBb8XbhQWrUE7ISwbB0+QZCaZZa1mYXE3PbnLGI= Received: from fx601 (localhost [127.0.0.1]) by fx601.security-mail.net (Postfix) with ESMTP id BA9803AD04C; Wed, 23 Mar 2022 12:07:24 +0100 (CET) X-Virus-Scanned: E-securemail Secumail-id: <9ab4.623aff6a.98f3e.0> Received: from zimbra2.kalray.eu (unknown [217.181.231.53]) by fx601.security-mail.net (Postfix) with ESMTPS id 9A2FD3AD034; Wed, 23 Mar 2022 12:07:22 +0100 (CET) Received: from zimbra2.kalray.eu (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTPS id 7C7AD27E0444; Wed, 23 Mar 2022 12:07:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 66AF927E0443; Wed, 23 Mar 2022 12:07:22 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 66AF927E0443 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1648033642; bh=lkXmp8lv2v2HiLj/LZtFQoiXYObR1expOxg9dvyWFfo=; h=From:To:Date:Message-Id; b=D3/EWoIWOfLH52PaI873zcLsIBgSg54V93HL1oTICcogFX27728Wp9lYRrBq8KNsR r+gvGRGcaa+RlKDCAatR2KHypy/uwJcP2KZylmMliPSL5TR/5QnQ5pqFxHQmBanbEa jBn+kZknXQqdeILBmEJBsXc2gxTrvUa55fQxQq80= 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 x62y_ZpYuTpT; Wed, 23 Mar 2022 12:07:22 +0100 (CET) Received: from tellis.lin.mbt.kalray.eu (unknown [192.168.36.206]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 5487E27E0425; Wed, 23 Mar 2022 12:07:22 +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 , Randy Dunlap , Arnd Bergmann , Jules Maselbas Subject: [PATCH v2 3/3] phy: core: Warn when phy_power_on is called before phy_init Date: Wed, 23 Mar 2022 12:07:08 +0100 Message-Id: <20220323110708.8254-4-jmaselbas@kalray.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220323110708.8254-1-jmaselbas@kalray.eu> References: <20220323110708.8254-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. Signed-off-by: Jules Maselbas Cc: Ahmad Fatoum Cc: Amelie DELAUNAY Cc: Minas Harutyunyan Cc: Kishon Vijay Abraham I --- change in v2: - no changes 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 cbdad65d2caa..0cb4da62577e 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);