devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] phy: phy-bcm-ns-usb3: drop support for deprecated DT binding
@ 2020-11-13 11:34 Rafał Miłecki
  2020-11-13 23:13 ` Florian Fainelli
  2020-11-19  6:27 ` Vinod Koul
  0 siblings, 2 replies; 5+ messages in thread
From: Rafał Miłecki @ 2020-11-13 11:34 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul
  Cc: linux-kernel, devicetree, Hauke Mehrtens,
	bcm-kernel-feedback-list, Rafał Miłecki

From: Rafał Miłecki <rafal@milecki.pl>

Initially this PHY driver was implementing MDIO access on its own. It
was caused by lack of proper hardware design understanding.

It has been changed back in 2017. DT bindings were changed and driver
was updated to use MDIO layer.

It should be really safe now to drop the old deprecated code. All Linux
stored DT files don't use it for 3,5 year. There is close to 0 chance
there is any bootloader with its own DTB using old the binding.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/phy/broadcom/phy-bcm-ns-usb3.c | 159 +------------------------
 1 file changed, 5 insertions(+), 154 deletions(-)

diff --git a/drivers/phy/broadcom/phy-bcm-ns-usb3.c b/drivers/phy/broadcom/phy-bcm-ns-usb3.c
index 47b029fbebbd..eb10ffa13a62 100644
--- a/drivers/phy/broadcom/phy-bcm-ns-usb3.c
+++ b/drivers/phy/broadcom/phy-bcm-ns-usb3.c
@@ -22,8 +22,6 @@
 #include <linux/phy/phy.h>
 #include <linux/slab.h>
 
-#define BCM_NS_USB3_MII_MNG_TIMEOUT_US	1000	/* usecs */
-
 #define BCM_NS_USB3_PHY_BASE_ADDR_REG	0x1f
 #define BCM_NS_USB3_PHY_PLL30_BLOCK	0x8000
 #define BCM_NS_USB3_PHY_TX_PMD_BLOCK	0x8040
@@ -51,11 +49,8 @@ struct bcm_ns_usb3 {
 	struct device *dev;
 	enum bcm_ns_family family;
 	void __iomem *dmp;
-	void __iomem *ccb_mii;
 	struct mdio_device *mdiodev;
 	struct phy *phy;
-
-	int (*phy_write)(struct bcm_ns_usb3 *usb3, u16 reg, u16 value);
 };
 
 static const struct of_device_id bcm_ns_usb3_id_table[] = {
@@ -69,13 +64,9 @@ static const struct of_device_id bcm_ns_usb3_id_table[] = {
 	},
 	{},
 };
-MODULE_DEVICE_TABLE(of, bcm_ns_usb3_id_table);
 
 static int bcm_ns_usb3_mdio_phy_write(struct bcm_ns_usb3 *usb3, u16 reg,
-				      u16 value)
-{
-	return usb3->phy_write(usb3, reg, value);
-}
+				      u16 value);
 
 static int bcm_ns_usb3_phy_init_ns_bx(struct bcm_ns_usb3 *usb3)
 {
@@ -187,8 +178,8 @@ static const struct phy_ops ops = {
  * MDIO driver code
  **************************************************/
 
-static int bcm_ns_usb3_mdiodev_phy_write(struct bcm_ns_usb3 *usb3, u16 reg,
-					 u16 value)
+static int bcm_ns_usb3_mdio_phy_write(struct bcm_ns_usb3 *usb3, u16 reg,
+				      u16 value)
 {
 	struct mdio_device *mdiodev = usb3->mdiodev;
 
@@ -229,8 +220,6 @@ static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev)
 		return PTR_ERR(usb3->dmp);
 	}
 
-	usb3->phy_write = bcm_ns_usb3_mdiodev_phy_write;
-
 	usb3->phy = devm_phy_create(dev, NULL, &ops);
 	if (IS_ERR(usb3->phy)) {
 		dev_err(dev, "Failed to create PHY\n");
@@ -254,145 +243,7 @@ static struct mdio_driver bcm_ns_usb3_mdio_driver = {
 	.probe = bcm_ns_usb3_mdio_probe,
 };
 
-/**************************************************
- * Platform driver code
- **************************************************/
-
-static int bcm_ns_usb3_wait_reg(struct bcm_ns_usb3 *usb3, void __iomem *addr,
-				u32 mask, u32 value, int usec)
-{
-	u32 val;
-	int ret;
-
-	ret = readl_poll_timeout_atomic(addr, val, ((val & mask) == value),
-					10, usec);
-	if (ret)
-		dev_err(usb3->dev, "Timeout waiting for register %p\n", addr);
-
-	return ret;
-}
-
-static inline int bcm_ns_usb3_mii_mng_wait_idle(struct bcm_ns_usb3 *usb3)
-{
-	return bcm_ns_usb3_wait_reg(usb3, usb3->ccb_mii + BCMA_CCB_MII_MNG_CTL,
-				    0x0100, 0x0000,
-				    BCM_NS_USB3_MII_MNG_TIMEOUT_US);
-}
-
-static int bcm_ns_usb3_platform_phy_write(struct bcm_ns_usb3 *usb3, u16 reg,
-					  u16 value)
-{
-	u32 tmp = 0;
-	int err;
-
-	err = bcm_ns_usb3_mii_mng_wait_idle(usb3);
-	if (err < 0) {
-		dev_err(usb3->dev, "Couldn't write 0x%08x value\n", value);
-		return err;
-	}
-
-	/* TODO: Use a proper MDIO bus layer */
-	tmp |= 0x58020000; /* Magic value for MDIO PHY write */
-	tmp |= reg << 18;
-	tmp |= value;
-	writel(tmp, usb3->ccb_mii + BCMA_CCB_MII_MNG_CMD_DATA);
-
-	return bcm_ns_usb3_mii_mng_wait_idle(usb3);
-}
-
-static int bcm_ns_usb3_probe(struct platform_device *pdev)
-{
-	struct device *dev = &pdev->dev;
-	const struct of_device_id *of_id;
-	struct bcm_ns_usb3 *usb3;
-	struct resource *res;
-	struct phy_provider *phy_provider;
-
-	usb3 = devm_kzalloc(dev, sizeof(*usb3), GFP_KERNEL);
-	if (!usb3)
-		return -ENOMEM;
-
-	usb3->dev = dev;
-
-	of_id = of_match_device(bcm_ns_usb3_id_table, dev);
-	if (!of_id)
-		return -EINVAL;
-	usb3->family = (enum bcm_ns_family)of_id->data;
-
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmp");
-	usb3->dmp = devm_ioremap_resource(dev, res);
-	if (IS_ERR(usb3->dmp)) {
-		dev_err(dev, "Failed to map DMP regs\n");
-		return PTR_ERR(usb3->dmp);
-	}
-
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ccb-mii");
-	usb3->ccb_mii = devm_ioremap_resource(dev, res);
-	if (IS_ERR(usb3->ccb_mii)) {
-		dev_err(dev, "Failed to map ChipCommon B MII regs\n");
-		return PTR_ERR(usb3->ccb_mii);
-	}
-
-	/* Enable MDIO. Setting MDCDIV as 26  */
-	writel(0x0000009a, usb3->ccb_mii + BCMA_CCB_MII_MNG_CTL);
-
-	/* Wait for MDIO? */
-	udelay(2);
-
-	usb3->phy_write = bcm_ns_usb3_platform_phy_write;
-
-	usb3->phy = devm_phy_create(dev, NULL, &ops);
-	if (IS_ERR(usb3->phy)) {
-		dev_err(dev, "Failed to create PHY\n");
-		return PTR_ERR(usb3->phy);
-	}
-
-	phy_set_drvdata(usb3->phy, usb3);
-	platform_set_drvdata(pdev, usb3);
-
-	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
-	if (!IS_ERR(phy_provider))
-		dev_info(dev, "Registered Broadcom Northstar USB 3.0 PHY driver\n");
-
-	return PTR_ERR_OR_ZERO(phy_provider);
-}
-
-static struct platform_driver bcm_ns_usb3_driver = {
-	.probe		= bcm_ns_usb3_probe,
-	.driver = {
-		.name = "bcm_ns_usb3",
-		.of_match_table = bcm_ns_usb3_id_table,
-	},
-};
-
-static int __init bcm_ns_usb3_module_init(void)
-{
-	int err;
-
-	/*
-	 * For backward compatibility we register as MDIO and platform driver.
-	 * After getting MDIO binding commonly used (e.g. switching all DT files
-	 * to use it) we should deprecate the old binding and eventually drop
-	 * support for it.
-	 */
-
-	err = mdio_driver_register(&bcm_ns_usb3_mdio_driver);
-	if (err)
-		return err;
-
-	err = platform_driver_register(&bcm_ns_usb3_driver);
-	if (err)
-		mdio_driver_unregister(&bcm_ns_usb3_mdio_driver);
-
-	return err;
-}
-module_init(bcm_ns_usb3_module_init);
-
-static void __exit bcm_ns_usb3_module_exit(void)
-{
-	platform_driver_unregister(&bcm_ns_usb3_driver);
-	mdio_driver_unregister(&bcm_ns_usb3_mdio_driver);
-}
-module_exit(bcm_ns_usb3_module_exit)
+mdio_module_driver(bcm_ns_usb3_mdio_driver);
 
 MODULE_LICENSE("GPL v2");
+MODULE_DEVICE_TABLE(of, bcm_ns_usb3_id_table);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] phy: phy-bcm-ns-usb3: drop support for deprecated DT binding
  2020-11-13 11:34 [PATCH] phy: phy-bcm-ns-usb3: drop support for deprecated DT binding Rafał Miłecki
@ 2020-11-13 23:13 ` Florian Fainelli
  2020-11-19  6:27 ` Vinod Koul
  1 sibling, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2020-11-13 23:13 UTC (permalink / raw)
  To: Rafał Miłecki, Kishon Vijay Abraham I, Vinod Koul
  Cc: linux-kernel, devicetree, Hauke Mehrtens,
	bcm-kernel-feedback-list, Rafał Miłecki

On 11/13/20 3:34 AM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> Initially this PHY driver was implementing MDIO access on its own. It
> was caused by lack of proper hardware design understanding.
> 
> It has been changed back in 2017. DT bindings were changed and driver
> was updated to use MDIO layer.
> 
> It should be really safe now to drop the old deprecated code. All Linux
> stored DT files don't use it for 3,5 year. There is close to 0 chance
> there is any bootloader with its own DTB using old the binding.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] phy: phy-bcm-ns-usb3: drop support for deprecated DT binding
  2020-11-13 11:34 [PATCH] phy: phy-bcm-ns-usb3: drop support for deprecated DT binding Rafał Miłecki
  2020-11-13 23:13 ` Florian Fainelli
@ 2020-11-19  6:27 ` Vinod Koul
  2020-11-19  7:55   ` Rafał Miłecki
  2020-11-19  8:24   ` Rafał Miłecki
  1 sibling, 2 replies; 5+ messages in thread
From: Vinod Koul @ 2020-11-19  6:27 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Kishon Vijay Abraham I, linux-kernel, devicetree, Hauke Mehrtens,
	bcm-kernel-feedback-list, Rafał Miłecki

On 13-11-20, 12:34, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> Initially this PHY driver was implementing MDIO access on its own. It
> was caused by lack of proper hardware design understanding.
> 
> It has been changed back in 2017. DT bindings were changed and driver
> was updated to use MDIO layer.
> 
> It should be really safe now to drop the old deprecated code. All Linux
> stored DT files don't use it for 3,5 year. There is close to 0 chance
> there is any bootloader with its own DTB using old the binding.

Applied, thanks

While applying, it gave me a minor conflict, please do check the
resolution

-- 
~Vinod

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] phy: phy-bcm-ns-usb3: drop support for deprecated DT binding
  2020-11-19  6:27 ` Vinod Koul
@ 2020-11-19  7:55   ` Rafał Miłecki
  2020-11-19  8:24   ` Rafał Miłecki
  1 sibling, 0 replies; 5+ messages in thread
From: Rafał Miłecki @ 2020-11-19  7:55 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Kishon Vijay Abraham I, Linux Kernel Mailing List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Hauke Mehrtens, bcm-kernel-feedback-list,
	Rafał Miłecki

On Thu, 19 Nov 2020 at 07:27, Vinod Koul <vkoul@kernel.org> wrote:
> On 13-11-20, 12:34, Rafał Miłecki wrote:
> > From: Rafał Miłecki <rafal@milecki.pl>
> >
> > Initially this PHY driver was implementing MDIO access on its own. It
> > was caused by lack of proper hardware design understanding.
> >
> > It has been changed back in 2017. DT bindings were changed and driver
> > was updated to use MDIO layer.
> >
> > It should be really safe now to drop the old deprecated code. All Linux
> > stored DT files don't use it for 3,5 year. There is close to 0 chance
> > there is any bootloader with its own DTB using old the binding.
>
> Applied, thanks
>
> While applying, it gave me a minor conflict, please do check the
> resolution

Oops, I used your master branch instead of next. Waiting for your push :)

-- 
Rafał

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] phy: phy-bcm-ns-usb3: drop support for deprecated DT binding
  2020-11-19  6:27 ` Vinod Koul
  2020-11-19  7:55   ` Rafał Miłecki
@ 2020-11-19  8:24   ` Rafał Miłecki
  1 sibling, 0 replies; 5+ messages in thread
From: Rafał Miłecki @ 2020-11-19  8:24 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Kishon Vijay Abraham I, Linux Kernel Mailing List,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Hauke Mehrtens, bcm-kernel-feedback-list,
	Rafał Miłecki

On Thu, 19 Nov 2020 at 07:27, Vinod Koul <vkoul@kernel.org> wrote:
>
> On 13-11-20, 12:34, Rafał Miłecki wrote:
> > From: Rafał Miłecki <rafal@milecki.pl>
> >
> > Initially this PHY driver was implementing MDIO access on its own. It
> > was caused by lack of proper hardware design understanding.
> >
> > It has been changed back in 2017. DT bindings were changed and driver
> > was updated to use MDIO layer.
> >
> > It should be really safe now to drop the old deprecated code. All Linux
> > stored DT files don't use it for 3,5 year. There is close to 0 chance
> > there is any bootloader with its own DTB using old the binding.
>
> Applied, thanks
>
> While applying, it gave me a minor conflict, please do check the
> resolution

Looks good, thank you!

-- 
Rafał

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-19  8:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 11:34 [PATCH] phy: phy-bcm-ns-usb3: drop support for deprecated DT binding Rafał Miłecki
2020-11-13 23:13 ` Florian Fainelli
2020-11-19  6:27 ` Vinod Koul
2020-11-19  7:55   ` Rafał Miłecki
2020-11-19  8:24   ` Rafał Miłecki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).