mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stanley Chang <stanley_chang@realtek.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Stanley Chang" <stanley_chang@realtek.com>,
	"Vinod Koul" <vkoul@kernel.org>,
	"Johan Hovold" <johan@kernel.org>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Jinjie Ruan" <ruanjinjie@huawei.com>,
	"Alan Stern" <stern@rowland.harvard.edu>,
	"Yang Yingliang" <yangyingliang@huawei.com>,
	"Ricardo Cañuelo" <ricardo.canuelo@collabora.com>,
	"Ray Chi" <raychi@google.com>, "Roy Luo" <royluo@google.com>,
	linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org
Subject: [PATCH v1 3/4] phy: realtek: usb3: Remove the legacy usb phy implementation
Date: Tue, 7 Nov 2023 14:33:46 +0800	[thread overview]
Message-ID: <20231107063518.27824-3-stanley_chang@realtek.com> (raw)
In-Reply-To: <20231107063518.27824-1-stanley_chang@realtek.com>

Same as phy-rtk-usb2.c

Remove the port status notification on legacy USB PHY.
Use the generic PHY to notify the usb device connect and disconnect.

To avoid using these PHYs would require describing the very same
PHY using both the generic "phy" property and the deprecated "usb-phy"
property.

Signed-off-by: Stanley Chang <stanley_chang@realtek.com>
---
 drivers/phy/realtek/phy-rtk-usb3.c | 56 ++++++++++++------------------
 1 file changed, 22 insertions(+), 34 deletions(-)

diff --git a/drivers/phy/realtek/phy-rtk-usb3.c b/drivers/phy/realtek/phy-rtk-usb3.c
index 67446a85e968..d992a21243e1 100644
--- a/drivers/phy/realtek/phy-rtk-usb3.c
+++ b/drivers/phy/realtek/phy-rtk-usb3.c
@@ -18,8 +18,6 @@
 #include <linux/mfd/syscon.h>
 #include <linux/phy/phy.h>
 #include <linux/usb.h>
-#include <linux/usb/hcd.h>
-#include <linux/usb/phy.h>
 
 #define USB_MDIO_CTRL_PHY_BUSY BIT(7)
 #define USB_MDIO_CTRL_PHY_WRITE BIT(0)
@@ -85,7 +83,6 @@ struct phy_parameter {
 };
 
 struct rtk_phy {
-	struct usb_phy phy;
 	struct device *dev;
 
 	struct phy_cfg *phy_cfg;
@@ -303,18 +300,9 @@ static int rtk_phy_exit(struct phy *phy)
 	return 0;
 }
 
-static const struct phy_ops ops = {
-	.init		= rtk_phy_init,
-	.exit		= rtk_phy_exit,
-	.owner		= THIS_MODULE,
-};
-
-static void rtk_phy_toggle(struct usb_phy *usb3_phy, bool connect, int port)
+static void rtk_phy_toggle(struct rtk_phy *rtk_phy, bool connect, int port)
 {
 	int index = port;
-	struct rtk_phy *rtk_phy = NULL;
-
-	rtk_phy = dev_get_drvdata(usb3_phy->dev);
 
 	if (index > rtk_phy->num_phy) {
 		dev_err(rtk_phy->dev, "%s: The port=%d is not in usb phy (num_phy=%d)\n",
@@ -325,22 +313,34 @@ static void rtk_phy_toggle(struct usb_phy *usb3_phy, bool connect, int port)
 	do_rtk_usb3_phy_toggle(rtk_phy, index, connect);
 }
 
-static int rtk_phy_notify_port_status(struct usb_phy *x, int port,
-				      u16 portstatus, u16 portchange)
+static int rtk_phy_connect(struct phy *phy, int port)
 {
-	bool connect = false;
+	struct rtk_phy *rtk_phy = phy_get_drvdata(phy);
+
+	dev_dbg(rtk_phy->dev, "%s port=%d\n", __func__, port);
+	rtk_phy_toggle(rtk_phy, true, port);
+
+	return 0;
+}
 
-	pr_debug("%s port=%d portstatus=0x%x portchange=0x%x\n",
-		 __func__, port, (int)portstatus, (int)portchange);
-	if (portstatus & USB_PORT_STAT_CONNECTION)
-		connect = true;
+static int rtk_phy_disconnect(struct phy *phy, int port)
+{
+	struct rtk_phy *rtk_phy = phy_get_drvdata(phy);
 
-	if (portchange & USB_PORT_STAT_C_CONNECTION)
-		rtk_phy_toggle(x, connect, port);
+	dev_dbg(rtk_phy->dev, "%s port=%d\n", __func__, port);
+	rtk_phy_toggle(rtk_phy, false, port);
 
 	return 0;
 }
 
+static const struct phy_ops ops = {
+	.init		= rtk_phy_init,
+	.exit		= rtk_phy_exit,
+	.connect	= rtk_phy_connect,
+	.disconnect	= rtk_phy_disconnect,
+	.owner		= THIS_MODULE,
+};
+
 #ifdef CONFIG_DEBUG_FS
 static struct dentry *create_phy_debug_root(void)
 {
@@ -419,8 +419,6 @@ static inline void create_debug_files(struct rtk_phy *rtk_phy)
 
 	debugfs_create_file("parameter", 0444, rtk_phy->debug_dir, rtk_phy,
 			    &rtk_usb3_parameter_fops);
-
-	return;
 }
 
 static inline void remove_debug_files(struct rtk_phy *rtk_phy)
@@ -578,10 +576,6 @@ static int rtk_usb3phy_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	rtk_phy->dev			= &pdev->dev;
-	rtk_phy->phy.dev		= rtk_phy->dev;
-	rtk_phy->phy.label		= "rtk-usb3phy";
-	rtk_phy->phy.notify_port_status = rtk_phy_notify_port_status;
-
 	rtk_phy->phy_cfg = devm_kzalloc(dev, sizeof(*phy_cfg), GFP_KERNEL);
 
 	memcpy(rtk_phy->phy_cfg, phy_cfg, sizeof(*phy_cfg));
@@ -604,10 +598,6 @@ static int rtk_usb3phy_probe(struct platform_device *pdev)
 	if (IS_ERR(phy_provider))
 		return PTR_ERR(phy_provider);
 
-	ret = usb_add_phy_dev(&rtk_phy->phy);
-	if (ret)
-		goto err;
-
 	create_debug_files(rtk_phy);
 
 err:
@@ -619,8 +609,6 @@ static void rtk_usb3phy_remove(struct platform_device *pdev)
 	struct rtk_phy *rtk_phy = platform_get_drvdata(pdev);
 
 	remove_debug_files(rtk_phy);
-
-	usb_remove_phy(&rtk_phy->phy);
 }
 
 static const struct phy_cfg rtd1295_phy_cfg = {
-- 
2.34.1


  parent reply	other threads:[~2023-11-07  6:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-07  6:33 [PATCH v1 1/4] phy: core: add notify_connect and notify_disconnect callback Stanley Chang
2023-11-07  6:33 ` [PATCH v1 2/4] phy: realtek: usb2: Remove the legacy usb phy implementation Stanley Chang
2023-11-07  6:33 ` Stanley Chang [this message]
2023-11-07  6:33 ` [PATCH v1 4/4] usb: core: add phy notify connect and disconnect Stanley Chang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231107063518.27824-3-stanley_chang@realtek.com \
    --to=stanley_chang@realtek.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=kishon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=raychi@google.com \
    --cc=ricardo.canuelo@collabora.com \
    --cc=robh@kernel.org \
    --cc=royluo@google.com \
    --cc=ruanjinjie@huawei.com \
    --cc=stern@rowland.harvard.edu \
    --cc=vkoul@kernel.org \
    --cc=yangyingliang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®