mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2] net: phy: add driver for MotorComm PHY
@ 2023-06-06  8:17 yegorslists
  2023-06-06  8:21 ` Yegor Yefremov
  2023-06-06  9:57 ` Sascha Hauer
  0 siblings, 2 replies; 7+ messages in thread
From: yegorslists @ 2023-06-06  8:17 UTC (permalink / raw)
  To: barebox

From: Yegor Yefremov <yegorslists@googlemail.com>

The driver corresponds to the kernel 6.1.27.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
Changes:
	v1 -> v2: add the related kernel version

 drivers/net/phy/Kconfig     |   5 ++
 drivers/net/phy/Makefile    |   1 +
 drivers/net/phy/motorcomm.c | 128 ++++++++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+)
 create mode 100644 drivers/net/phy/motorcomm.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index cd20e1de27..e95e2a3228 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -50,6 +50,11 @@ config MICREL_PHY
 	help
 	  Supports the KSZ9021, VSC8201, KS8001 PHYs.
 
+config MOTORCOMM_PHY
+	bool "Driver for Motorcomm PHYs"
+	help
+	  Currently supports the YT8511 PHY.
+
 config NATIONAL_PHY
 	bool "Driver for National Semiconductor PHYs"
 	help
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 83f46f11d3..26e4ad884d 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_DAVICOM_PHY)	+= davicom.o
 obj-$(CONFIG_LXT_PHY)		+= lxt.o
 obj-$(CONFIG_MARVELL_PHY)	+= marvell.o
 obj-$(CONFIG_MICREL_PHY)	+= micrel.o
+obj-$(CONFIG_MOTORCOMM_PHY)	+= motorcomm.o
 obj-$(CONFIG_NATIONAL_PHY)	+= national.o
 obj-$(CONFIG_REALTEK_PHY)	+= realtek.o
 obj-$(CONFIG_SMSC_PHY)		+= smsc.o
diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
new file mode 100644
index 0000000000..4bcd84342c
--- /dev/null
+++ b/drivers/net/phy/motorcomm.c
@@ -0,0 +1,128 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * drivers/net/phy/motorcomm.c
+ *
+ * Driver for Motorcomm PHYs
+ *
+ * Author: Peter Geis <pgwipeout@gmail.com>
+ */
+
+#include <common.h>
+#include <init.h>
+#include <linux/phy.h>
+#include <linux/mdio.h>
+
+#define PHY_ID_YT8511		0x0000010a
+
+#define YT8511_PAGE_SELECT	0x1e
+#define YT8511_PAGE		0x1f
+#define YT8511_EXT_CLK_GATE	0x0c
+#define YT8511_EXT_DELAY_DRIVE	0x0d
+#define YT8511_EXT_SLEEP_CTRL	0x27
+
+/* 2b00 25m from pll
+ * 2b01 25m from xtl *default*
+ * 2b10 62.m from pll
+ * 2b11 125m from pll
+ */
+#define YT8511_CLK_125M		(BIT(2) | BIT(1))
+#define YT8511_PLLON_SLP	BIT(14)
+
+/* RX Delay enabled = 1.8ns 1000T, 8ns 10/100T */
+#define YT8511_DELAY_RX		BIT(0)
+
+/* TX Gig-E Delay is bits 7:4, default 0x5
+ * TX Fast-E Delay is bits 15:12, default 0xf
+ * Delay = 150ps * N - 250ps
+ * On = 2000ps, off = 50ps
+ */
+#define YT8511_DELAY_GE_TX_EN	(0xf << 4)
+#define YT8511_DELAY_GE_TX_DIS	(0x2 << 4)
+#define YT8511_DELAY_FE_TX_EN	(0xf << 12)
+#define YT8511_DELAY_FE_TX_DIS	(0x2 << 12)
+
+static int yt8511_read_page(struct phy_device *phydev)
+{
+	return phy_read(phydev, YT8511_PAGE_SELECT);
+};
+
+static int yt8511_write_page(struct phy_device *phydev, int page)
+{
+	return phy_write(phydev, YT8511_PAGE_SELECT, page);
+};
+
+static int yt8511_config_init(struct phy_device *phydev)
+{
+	int oldpage, ret = 0;
+	unsigned int ge, fe;
+
+	oldpage = phy_select_page(phydev, YT8511_EXT_CLK_GATE);
+	if (oldpage < 0)
+		goto err_restore_page;
+
+	/* set rgmii delay mode */
+	switch (phydev->interface) {
+	case PHY_INTERFACE_MODE_RGMII:
+		ge = YT8511_DELAY_GE_TX_DIS;
+		fe = YT8511_DELAY_FE_TX_DIS;
+		break;
+	case PHY_INTERFACE_MODE_RGMII_RXID:
+		ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_DIS;
+		fe = YT8511_DELAY_FE_TX_DIS;
+		break;
+	case PHY_INTERFACE_MODE_RGMII_TXID:
+		ge = YT8511_DELAY_GE_TX_EN;
+		fe = YT8511_DELAY_FE_TX_EN;
+		break;
+	case PHY_INTERFACE_MODE_RGMII_ID:
+		ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN;
+		fe = YT8511_DELAY_FE_TX_EN;
+		break;
+	default: /* do not support other modes */
+		ret = -EOPNOTSUPP;
+		goto err_restore_page;
+	}
+
+	ret = phy_modify(phydev, YT8511_PAGE, (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* set clock mode to 125mhz */
+	ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_CLK_125M);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* fast ethernet delay is in a separate page */
+	ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_DELAY_DRIVE);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret = phy_modify(phydev, YT8511_PAGE, YT8511_DELAY_FE_TX_EN, fe);
+	if (ret < 0)
+		goto err_restore_page;
+
+	/* leave pll enabled in sleep */
+	ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_SLEEP_CTRL);
+	if (ret < 0)
+		goto err_restore_page;
+
+	ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_PLLON_SLP);
+	if (ret < 0)
+		goto err_restore_page;
+
+err_restore_page:
+	return phy_restore_page(phydev, oldpage, ret);
+}
+
+static struct phy_driver motorcomm_phy_drvs[] = {
+	{
+		.phy_id		= PHY_ID_YT8511,
+		.drv.name	= "YT8511 Gigabit Ethernet",
+		.config_init	= yt8511_config_init,
+		.features	= PHY_GBIT_FEATURES,
+		.read_page	= yt8511_read_page,
+		.write_page	= yt8511_write_page,
+	},
+};
+
+device_phy_drivers(motorcomm_phy_drvs);
-- 
2.34.1




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

* Re: [PATCH v2] net: phy: add driver for MotorComm PHY
  2023-06-06  8:17 [PATCH v2] net: phy: add driver for MotorComm PHY yegorslists
@ 2023-06-06  8:21 ` Yegor Yefremov
  2023-06-06  9:58   ` Sascha Hauer
  2023-06-06  9:57 ` Sascha Hauer
  1 sibling, 1 reply; 7+ messages in thread
From: Yegor Yefremov @ 2023-06-06  8:21 UTC (permalink / raw)
  To: barebox

Hi Sascha,


On Tue, Jun 6, 2023 at 10:17 AM <yegorslists@googlemail.com> wrote:
>
> From: Yegor Yefremov <yegorslists@googlemail.com>
>
> The driver corresponds to the kernel 6.1.27.
>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
> Changes:
>         v1 -> v2: add the related kernel version
>
>  drivers/net/phy/Kconfig     |   5 ++
>  drivers/net/phy/Makefile    |   1 +
>  drivers/net/phy/motorcomm.c | 128 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 134 insertions(+)
>  create mode 100644 drivers/net/phy/motorcomm.c
>
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index cd20e1de27..e95e2a3228 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -50,6 +50,11 @@ config MICREL_PHY
>         help
>           Supports the KSZ9021, VSC8201, KS8001 PHYs.
>
> +config MOTORCOMM_PHY
> +       bool "Driver for Motorcomm PHYs"
> +       help
> +         Currently supports the YT8511 PHY.
> +
>  config NATIONAL_PHY
>         bool "Driver for National Semiconductor PHYs"
>         help
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index 83f46f11d3..26e4ad884d 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -6,6 +6,7 @@ obj-$(CONFIG_DAVICOM_PHY)       += davicom.o
>  obj-$(CONFIG_LXT_PHY)          += lxt.o
>  obj-$(CONFIG_MARVELL_PHY)      += marvell.o
>  obj-$(CONFIG_MICREL_PHY)       += micrel.o
> +obj-$(CONFIG_MOTORCOMM_PHY)    += motorcomm.o
>  obj-$(CONFIG_NATIONAL_PHY)     += national.o
>  obj-$(CONFIG_REALTEK_PHY)      += realtek.o
>  obj-$(CONFIG_SMSC_PHY)         += smsc.o
> diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
> new file mode 100644
> index 0000000000..4bcd84342c
> --- /dev/null
> +++ b/drivers/net/phy/motorcomm.c
> @@ -0,0 +1,128 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * drivers/net/phy/motorcomm.c
> + *
> + * Driver for Motorcomm PHYs
> + *
> + * Author: Peter Geis <pgwipeout@gmail.com>
> + */
> +
> +#include <common.h>
> +#include <init.h>
> +#include <linux/phy.h>
> +#include <linux/mdio.h>
> +
> +#define PHY_ID_YT8511          0x0000010a
> +
> +#define YT8511_PAGE_SELECT     0x1e
> +#define YT8511_PAGE            0x1f
> +#define YT8511_EXT_CLK_GATE    0x0c
> +#define YT8511_EXT_DELAY_DRIVE 0x0d
> +#define YT8511_EXT_SLEEP_CTRL  0x27
> +
> +/* 2b00 25m from pll
> + * 2b01 25m from xtl *default*
> + * 2b10 62.m from pll
> + * 2b11 125m from pll
> + */
> +#define YT8511_CLK_125M                (BIT(2) | BIT(1))
> +#define YT8511_PLLON_SLP       BIT(14)
> +
> +/* RX Delay enabled = 1.8ns 1000T, 8ns 10/100T */
> +#define YT8511_DELAY_RX                BIT(0)
> +
> +/* TX Gig-E Delay is bits 7:4, default 0x5
> + * TX Fast-E Delay is bits 15:12, default 0xf
> + * Delay = 150ps * N - 250ps
> + * On = 2000ps, off = 50ps
> + */
> +#define YT8511_DELAY_GE_TX_EN  (0xf << 4)
> +#define YT8511_DELAY_GE_TX_DIS (0x2 << 4)
> +#define YT8511_DELAY_FE_TX_EN  (0xf << 12)
> +#define YT8511_DELAY_FE_TX_DIS (0x2 << 12)
> +
> +static int yt8511_read_page(struct phy_device *phydev)
> +{
> +       return phy_read(phydev, YT8511_PAGE_SELECT);
> +};
> +
> +static int yt8511_write_page(struct phy_device *phydev, int page)
> +{
> +       return phy_write(phydev, YT8511_PAGE_SELECT, page);
> +};
> +
> +static int yt8511_config_init(struct phy_device *phydev)
> +{
> +       int oldpage, ret = 0;
> +       unsigned int ge, fe;
> +
> +       oldpage = phy_select_page(phydev, YT8511_EXT_CLK_GATE);
> +       if (oldpage < 0)
> +               goto err_restore_page;
> +
> +       /* set rgmii delay mode */
> +       switch (phydev->interface) {
> +       case PHY_INTERFACE_MODE_RGMII:
> +               ge = YT8511_DELAY_GE_TX_DIS;
> +               fe = YT8511_DELAY_FE_TX_DIS;
> +               break;
> +       case PHY_INTERFACE_MODE_RGMII_RXID:
> +               ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_DIS;
> +               fe = YT8511_DELAY_FE_TX_DIS;
> +               break;
> +       case PHY_INTERFACE_MODE_RGMII_TXID:
> +               ge = YT8511_DELAY_GE_TX_EN;
> +               fe = YT8511_DELAY_FE_TX_EN;
> +               break;
> +       case PHY_INTERFACE_MODE_RGMII_ID:
> +               ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN;
> +               fe = YT8511_DELAY_FE_TX_EN;
> +               break;
> +       default: /* do not support other modes */
> +               ret = -EOPNOTSUPP;
> +               goto err_restore_page;
> +       }
> +
> +       ret = phy_modify(phydev, YT8511_PAGE, (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge);
> +       if (ret < 0)
> +               goto err_restore_page;
> +
> +       /* set clock mode to 125mhz */
> +       ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_CLK_125M);
> +       if (ret < 0)
> +               goto err_restore_page;
> +
> +       /* fast ethernet delay is in a separate page */
> +       ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_DELAY_DRIVE);
> +       if (ret < 0)
> +               goto err_restore_page;
> +
> +       ret = phy_modify(phydev, YT8511_PAGE, YT8511_DELAY_FE_TX_EN, fe);
> +       if (ret < 0)
> +               goto err_restore_page;
> +
> +       /* leave pll enabled in sleep */
> +       ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_SLEEP_CTRL);
> +       if (ret < 0)
> +               goto err_restore_page;
> +
> +       ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_PLLON_SLP);
> +       if (ret < 0)
> +               goto err_restore_page;
> +
> +err_restore_page:
> +       return phy_restore_page(phydev, oldpage, ret);

As for this approach, it is also used by some other drivers in the Linux kernel:

drivers/net/phy/realtek.c
drivers/net/phy/icplus.c

Regards,
Yegor

> +}
> +
> +static struct phy_driver motorcomm_phy_drvs[] = {
> +       {
> +               .phy_id         = PHY_ID_YT8511,
> +               .drv.name       = "YT8511 Gigabit Ethernet",
> +               .config_init    = yt8511_config_init,
> +               .features       = PHY_GBIT_FEATURES,
> +               .read_page      = yt8511_read_page,
> +               .write_page     = yt8511_write_page,
> +       },
> +};
> +
> +device_phy_drivers(motorcomm_phy_drvs);
> --
> 2.34.1
>



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

* Re: [PATCH v2] net: phy: add driver for MotorComm PHY
  2023-06-06  8:17 [PATCH v2] net: phy: add driver for MotorComm PHY yegorslists
  2023-06-06  8:21 ` Yegor Yefremov
@ 2023-06-06  9:57 ` Sascha Hauer
  1 sibling, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2023-06-06  9:57 UTC (permalink / raw)
  To: yegorslists; +Cc: barebox

On Tue, Jun 06, 2023 at 10:17:18AM +0200, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> The driver corresponds to the kernel 6.1.27.
> 
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
> Changes:
> 	v1 -> v2: add the related kernel version
> 
>  drivers/net/phy/Kconfig     |   5 ++
>  drivers/net/phy/Makefile    |   1 +
>  drivers/net/phy/motorcomm.c | 128 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 134 insertions(+)
>  create mode 100644 drivers/net/phy/motorcomm.c

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH v2] net: phy: add driver for MotorComm PHY
  2023-06-06  8:21 ` Yegor Yefremov
@ 2023-06-06  9:58   ` Sascha Hauer
  2023-06-08 10:48     ` Yegor Yefremov
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2023-06-06  9:58 UTC (permalink / raw)
  To: Yegor Yefremov; +Cc: barebox

Hi Yegor,

On Tue, Jun 06, 2023 at 10:21:39AM +0200, Yegor Yefremov wrote:
> Hi Sascha,
> 
> 
> > +       ret = phy_modify(phydev, YT8511_PAGE, YT8511_DELAY_FE_TX_EN, fe);
> > +       if (ret < 0)
> > +               goto err_restore_page;
> > +
> > +       /* leave pll enabled in sleep */
> > +       ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_SLEEP_CTRL);
> > +       if (ret < 0)
> > +               goto err_restore_page;
> > +
> > +       ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_PLLON_SLP);
> > +       if (ret < 0)
> > +               goto err_restore_page;
> > +
> > +err_restore_page:
> > +       return phy_restore_page(phydev, oldpage, ret);
> 
> As for this approach, it is also used by some other drivers in the Linux kernel:
> 
> drivers/net/phy/realtek.c
> drivers/net/phy/icplus.c

It's ok like this. I didn't realize phy_restore_page() takes ret as
argument and returns it.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH v2] net: phy: add driver for MotorComm PHY
  2023-06-06  9:58   ` Sascha Hauer
@ 2023-06-08 10:48     ` Yegor Yefremov
  2023-06-09  6:15       ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: Yegor Yefremov @ 2023-06-08 10:48 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi Sascha,

On Tue, Jun 6, 2023 at 11:58 AM Sascha Hauer <sha@pengutronix.de> wrote:
>
> Hi Yegor,
>
> On Tue, Jun 06, 2023 at 10:21:39AM +0200, Yegor Yefremov wrote:
> > Hi Sascha,
> >
> >
> > > +       ret = phy_modify(phydev, YT8511_PAGE, YT8511_DELAY_FE_TX_EN, fe);
> > > +       if (ret < 0)
> > > +               goto err_restore_page;
> > > +
> > > +       /* leave pll enabled in sleep */
> > > +       ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_SLEEP_CTRL);
> > > +       if (ret < 0)
> > > +               goto err_restore_page;
> > > +
> > > +       ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_PLLON_SLP);
> > > +       if (ret < 0)
> > > +               goto err_restore_page;
> > > +
> > > +err_restore_page:
> > > +       return phy_restore_page(phydev, oldpage, ret);
> >
> > As for this approach, it is also used by some other drivers in the Linux kernel:
> >
> > drivers/net/phy/realtek.c
> > drivers/net/phy/icplus.c
>
> It's ok like this. I didn't realize phy_restore_page() takes ret as
> argument and returns it.

The driver doesn't use a phy_id_mask for now and it causes problems
that unknown PHY will be assigned to MotorComm. What mask should I
use? 0xfffffff or 0x00000fff?

Regards,
Yegor



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

* Re: [PATCH v2] net: phy: add driver for MotorComm PHY
  2023-06-08 10:48     ` Yegor Yefremov
@ 2023-06-09  6:15       ` Sascha Hauer
  2023-06-09  6:17         ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2023-06-09  6:15 UTC (permalink / raw)
  To: Yegor Yefremov; +Cc: barebox

On Thu, Jun 08, 2023 at 12:48:47PM +0200, Yegor Yefremov wrote:
> Hi Sascha,
> 
> On Tue, Jun 6, 2023 at 11:58 AM Sascha Hauer <sha@pengutronix.de> wrote:
> >
> > Hi Yegor,
> >
> > On Tue, Jun 06, 2023 at 10:21:39AM +0200, Yegor Yefremov wrote:
> > > Hi Sascha,
> > >
> > >
> > > > +       ret = phy_modify(phydev, YT8511_PAGE, YT8511_DELAY_FE_TX_EN, fe);
> > > > +       if (ret < 0)
> > > > +               goto err_restore_page;
> > > > +
> > > > +       /* leave pll enabled in sleep */
> > > > +       ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_SLEEP_CTRL);
> > > > +       if (ret < 0)
> > > > +               goto err_restore_page;
> > > > +
> > > > +       ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_PLLON_SLP);
> > > > +       if (ret < 0)
> > > > +               goto err_restore_page;
> > > > +
> > > > +err_restore_page:
> > > > +       return phy_restore_page(phydev, oldpage, ret);
> > >
> > > As for this approach, it is also used by some other drivers in the Linux kernel:
> > >
> > > drivers/net/phy/realtek.c
> > > drivers/net/phy/icplus.c
> >
> > It's ok like this. I didn't realize phy_restore_page() takes ret as
> > argument and returns it.
> 
> The driver doesn't use a phy_id_mask for now and it causes problems
> that unknown PHY will be assigned to MotorComm. What mask should I
> use? 0xfffffff or 0x00000fff?

It is PHY_ID_MATCH_EXACT() in the kernel, so should be 0xffffffff.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH v2] net: phy: add driver for MotorComm PHY
  2023-06-09  6:15       ` Sascha Hauer
@ 2023-06-09  6:17         ` Sascha Hauer
  0 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2023-06-09  6:17 UTC (permalink / raw)
  To: Yegor Yefremov; +Cc: barebox

On Fri, Jun 09, 2023 at 08:15:21AM +0200, Sascha Hauer wrote:
> On Thu, Jun 08, 2023 at 12:48:47PM +0200, Yegor Yefremov wrote:
> > Hi Sascha,
> > 
> > On Tue, Jun 6, 2023 at 11:58 AM Sascha Hauer <sha@pengutronix.de> wrote:
> > >
> > > Hi Yegor,
> > >
> > > On Tue, Jun 06, 2023 at 10:21:39AM +0200, Yegor Yefremov wrote:
> > > > Hi Sascha,
> > > >
> > > >
> > > > > +       ret = phy_modify(phydev, YT8511_PAGE, YT8511_DELAY_FE_TX_EN, fe);
> > > > > +       if (ret < 0)
> > > > > +               goto err_restore_page;
> > > > > +
> > > > > +       /* leave pll enabled in sleep */
> > > > > +       ret = phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_SLEEP_CTRL);
> > > > > +       if (ret < 0)
> > > > > +               goto err_restore_page;
> > > > > +
> > > > > +       ret = phy_modify(phydev, YT8511_PAGE, 0, YT8511_PLLON_SLP);
> > > > > +       if (ret < 0)
> > > > > +               goto err_restore_page;
> > > > > +
> > > > > +err_restore_page:
> > > > > +       return phy_restore_page(phydev, oldpage, ret);
> > > >
> > > > As for this approach, it is also used by some other drivers in the Linux kernel:
> > > >
> > > > drivers/net/phy/realtek.c
> > > > drivers/net/phy/icplus.c
> > >
> > > It's ok like this. I didn't realize phy_restore_page() takes ret as
> > > argument and returns it.
> > 
> > The driver doesn't use a phy_id_mask for now and it causes problems
> > that unknown PHY will be assigned to MotorComm. What mask should I
> > use? 0xfffffff or 0x00000fff?
> 
> It is PHY_ID_MATCH_EXACT() in the kernel, so should be 0xffffffff.

I fixed up the patch

Regards,
 Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2023-06-09  6:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06  8:17 [PATCH v2] net: phy: add driver for MotorComm PHY yegorslists
2023-06-06  8:21 ` Yegor Yefremov
2023-06-06  9:58   ` Sascha Hauer
2023-06-08 10:48     ` Yegor Yefremov
2023-06-09  6:15       ` Sascha Hauer
2023-06-09  6:17         ` Sascha Hauer
2023-06-06  9:57 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox