From: Alexandre Belloni <alexandre.belloni@bootlin.com> To: Horatiu Vultur <horatiu.vultur@microchip.com> Cc: davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, andrew@lunn.ch, linux@armlinux.org.uk, f.fainelli@gmail.com, vladimir.oltean@nxp.com, UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-pm@vger.kernel.org Subject: Re: [RFC PATCH net-next 02/12] net: phy: mchp: Add support for LAN8804 PHY Date: Mon, 20 Sep 2021 12:00:19 +0200 [thread overview] Message-ID: <YUhbs4P9jHKBYpYK@piout.net> (raw) In-Reply-To: <20210920095218.1108151-3-horatiu.vultur@microchip.com> Hi, On 20/09/2021 11:52:08+0200, Horatiu Vultur wrote: > The LAN8804 SKY has same features as that of LAN8804 SKY except that it On of those part name should be different ;) > doesn't support 1588, SyncE or Q-USGMII. > > This PHY is found inside the LAN966X switches. > > Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> > --- > drivers/net/phy/micrel.c | 73 ++++++++++++++++++++++++++++++++++++++ > include/linux/micrel_phy.h | 1 + > 2 files changed, 74 insertions(+) > > diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c > index 5c928f827173..34800b547004 100644 > --- a/drivers/net/phy/micrel.c > +++ b/drivers/net/phy/micrel.c > @@ -1537,6 +1537,65 @@ static int ksz886x_cable_test_get_status(struct phy_device *phydev, > return ret; > } > > +#define LAN_EXT_PAGE_ACCESS_CONTROL 0x16 > +#define LAN_EXT_PAGE_ACCESS_ADDRESS_DATA 0x17 > +#define LAN_EXT_PAGE_ACCESS_CTRL_EP_FUNC 0x4000 > + > +#define LAN8804_ALIGN_SWAP 0x4a > +#define LAN8804_ALIGN_TX_A_B_SWAP 0x1 > +#define LAN8804_ALIGN_TX_A_B_SWAP_MASK GENMASK(2, 0) > +#define LAN8814_CLOCK_MANAGEMENT 0xd > +#define LAN8814_LINK_QUALITY 0x8e > + > +static int lanphy_read_page_reg(struct phy_device *phydev, int page, u32 addr) > +{ > + u32 data; > + > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, page); > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA, addr); > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, > + (page | LAN_EXT_PAGE_ACCESS_CTRL_EP_FUNC)); > + data = phy_read(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA); > + > + return data; > +} > + > +static int lanphy_write_page_reg(struct phy_device *phydev, int page, u16 addr, > + u16 val) > +{ > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, page); > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA, addr); > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, > + (page | LAN_EXT_PAGE_ACCESS_CTRL_EP_FUNC)); > + > + val = phy_write(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA, val); > + if (val) { > + phydev_err(phydev, "Error: phy_write has returned error %d\n", > + val); > + return val; > + } > + return 0; > +} > + > +static int lan8804_config_init(struct phy_device *phydev) > +{ > + int val; > + > + /* MDI-X setting for swap A,B transmit */ > + val = lanphy_read_page_reg(phydev, 2, LAN8804_ALIGN_SWAP); > + val &= ~LAN8804_ALIGN_TX_A_B_SWAP_MASK; > + val |= LAN8804_ALIGN_TX_A_B_SWAP; > + lanphy_write_page_reg(phydev, 2, LAN8804_ALIGN_SWAP, val); > + > + /* Make sure that the PHY will not stop generating the clock when the > + * link partner goes down > + */ > + lanphy_write_page_reg(phydev, 31, LAN8814_CLOCK_MANAGEMENT, 0x27e); > + lanphy_read_page_reg(phydev, 1, LAN8814_LINK_QUALITY); > + > + return 0; > +} > + > static struct phy_driver ksphy_driver[] = { > { > .phy_id = PHY_ID_KS8737, > @@ -1718,6 +1777,20 @@ static struct phy_driver ksphy_driver[] = { > .get_stats = kszphy_get_stats, > .suspend = genphy_suspend, > .resume = kszphy_resume, > +}, { > + .phy_id = PHY_ID_LAN8804, > + .phy_id_mask = MICREL_PHY_ID_MASK, > + .name = "Microchip LAN966X Gigabit PHY", > + .config_init = lan8804_config_init, > + .driver_data = &ksz9021_type, > + .probe = kszphy_probe, > + .soft_reset = genphy_soft_reset, > + .read_status = ksz9031_read_status, > + .get_sset_count = kszphy_get_sset_count, > + .get_strings = kszphy_get_strings, > + .get_stats = kszphy_get_stats, > + .suspend = genphy_suspend, > + .resume = kszphy_resume, > }, { > .phy_id = PHY_ID_KSZ9131, > .phy_id_mask = MICREL_PHY_ID_MASK, > diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h > index 3d43c60b49fa..1f7c33b2f5a3 100644 > --- a/include/linux/micrel_phy.h > +++ b/include/linux/micrel_phy.h > @@ -28,6 +28,7 @@ > #define PHY_ID_KSZ9031 0x00221620 > #define PHY_ID_KSZ9131 0x00221640 > #define PHY_ID_LAN8814 0x00221660 > +#define PHY_ID_LAN8804 0x00221670 > > #define PHY_ID_KSZ886X 0x00221430 > #define PHY_ID_KSZ8863 0x00221435 > -- > 2.31.1 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Belloni <alexandre.belloni@bootlin.com> To: Horatiu Vultur <horatiu.vultur@microchip.com> Cc: davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, andrew@lunn.ch, linux@armlinux.org.uk, f.fainelli@gmail.com, vladimir.oltean@nxp.com, UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-pm@vger.kernel.org Subject: Re: [RFC PATCH net-next 02/12] net: phy: mchp: Add support for LAN8804 PHY Date: Mon, 20 Sep 2021 12:00:19 +0200 [thread overview] Message-ID: <YUhbs4P9jHKBYpYK@piout.net> (raw) In-Reply-To: <20210920095218.1108151-3-horatiu.vultur@microchip.com> Hi, On 20/09/2021 11:52:08+0200, Horatiu Vultur wrote: > The LAN8804 SKY has same features as that of LAN8804 SKY except that it On of those part name should be different ;) > doesn't support 1588, SyncE or Q-USGMII. > > This PHY is found inside the LAN966X switches. > > Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> > --- > drivers/net/phy/micrel.c | 73 ++++++++++++++++++++++++++++++++++++++ > include/linux/micrel_phy.h | 1 + > 2 files changed, 74 insertions(+) > > diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c > index 5c928f827173..34800b547004 100644 > --- a/drivers/net/phy/micrel.c > +++ b/drivers/net/phy/micrel.c > @@ -1537,6 +1537,65 @@ static int ksz886x_cable_test_get_status(struct phy_device *phydev, > return ret; > } > > +#define LAN_EXT_PAGE_ACCESS_CONTROL 0x16 > +#define LAN_EXT_PAGE_ACCESS_ADDRESS_DATA 0x17 > +#define LAN_EXT_PAGE_ACCESS_CTRL_EP_FUNC 0x4000 > + > +#define LAN8804_ALIGN_SWAP 0x4a > +#define LAN8804_ALIGN_TX_A_B_SWAP 0x1 > +#define LAN8804_ALIGN_TX_A_B_SWAP_MASK GENMASK(2, 0) > +#define LAN8814_CLOCK_MANAGEMENT 0xd > +#define LAN8814_LINK_QUALITY 0x8e > + > +static int lanphy_read_page_reg(struct phy_device *phydev, int page, u32 addr) > +{ > + u32 data; > + > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, page); > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA, addr); > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, > + (page | LAN_EXT_PAGE_ACCESS_CTRL_EP_FUNC)); > + data = phy_read(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA); > + > + return data; > +} > + > +static int lanphy_write_page_reg(struct phy_device *phydev, int page, u16 addr, > + u16 val) > +{ > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, page); > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA, addr); > + phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, > + (page | LAN_EXT_PAGE_ACCESS_CTRL_EP_FUNC)); > + > + val = phy_write(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA, val); > + if (val) { > + phydev_err(phydev, "Error: phy_write has returned error %d\n", > + val); > + return val; > + } > + return 0; > +} > + > +static int lan8804_config_init(struct phy_device *phydev) > +{ > + int val; > + > + /* MDI-X setting for swap A,B transmit */ > + val = lanphy_read_page_reg(phydev, 2, LAN8804_ALIGN_SWAP); > + val &= ~LAN8804_ALIGN_TX_A_B_SWAP_MASK; > + val |= LAN8804_ALIGN_TX_A_B_SWAP; > + lanphy_write_page_reg(phydev, 2, LAN8804_ALIGN_SWAP, val); > + > + /* Make sure that the PHY will not stop generating the clock when the > + * link partner goes down > + */ > + lanphy_write_page_reg(phydev, 31, LAN8814_CLOCK_MANAGEMENT, 0x27e); > + lanphy_read_page_reg(phydev, 1, LAN8814_LINK_QUALITY); > + > + return 0; > +} > + > static struct phy_driver ksphy_driver[] = { > { > .phy_id = PHY_ID_KS8737, > @@ -1718,6 +1777,20 @@ static struct phy_driver ksphy_driver[] = { > .get_stats = kszphy_get_stats, > .suspend = genphy_suspend, > .resume = kszphy_resume, > +}, { > + .phy_id = PHY_ID_LAN8804, > + .phy_id_mask = MICREL_PHY_ID_MASK, > + .name = "Microchip LAN966X Gigabit PHY", > + .config_init = lan8804_config_init, > + .driver_data = &ksz9021_type, > + .probe = kszphy_probe, > + .soft_reset = genphy_soft_reset, > + .read_status = ksz9031_read_status, > + .get_sset_count = kszphy_get_sset_count, > + .get_strings = kszphy_get_strings, > + .get_stats = kszphy_get_stats, > + .suspend = genphy_suspend, > + .resume = kszphy_resume, > }, { > .phy_id = PHY_ID_KSZ9131, > .phy_id_mask = MICREL_PHY_ID_MASK, > diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h > index 3d43c60b49fa..1f7c33b2f5a3 100644 > --- a/include/linux/micrel_phy.h > +++ b/include/linux/micrel_phy.h > @@ -28,6 +28,7 @@ > #define PHY_ID_KSZ9031 0x00221620 > #define PHY_ID_KSZ9131 0x00221640 > #define PHY_ID_LAN8814 0x00221660 > +#define PHY_ID_LAN8804 0x00221670 > > #define PHY_ID_KSZ886X 0x00221430 > #define PHY_ID_KSZ8863 0x00221435 > -- > 2.31.1 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2021-09-20 10:00 UTC|newest] Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-20 9:52 [RFC PATCH net-next 00/12] Add lan966x driver Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 9:52 ` [RFC PATCH net-next 01/12] net: mdio: mscc-miim: Fix the mdio controller Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 11:52 ` Andrew Lunn 2021-09-20 11:52 ` Andrew Lunn 2021-09-22 8:24 ` Horatiu Vultur 2021-09-22 8:24 ` Horatiu Vultur 2021-09-20 9:52 ` [RFC PATCH net-next 02/12] net: phy: mchp: Add support for LAN8804 PHY Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 10:00 ` Alexandre Belloni [this message] 2021-09-20 10:00 ` Alexandre Belloni 2021-09-20 11:59 ` Andrew Lunn 2021-09-20 11:59 ` Andrew Lunn 2021-09-22 8:35 ` Horatiu Vultur 2021-09-22 8:35 ` Horatiu Vultur 2021-09-20 9:52 ` [RFC PATCH net-next 03/12] phy: Add lan966x ethernet serdes PHY driver Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 13:42 ` Russell King (Oracle) 2021-09-20 13:42 ` Russell King (Oracle) 2021-09-22 10:04 ` Horatiu Vultur 2021-09-22 10:04 ` Horatiu Vultur 2021-09-23 12:44 ` Rob Herring 2021-09-23 12:44 ` Rob Herring 2021-09-20 9:52 ` [RFC PATCH net-next 04/12] dt-bindings: reset: Add lan966x switch reset bindings Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-23 12:49 ` Rob Herring 2021-09-23 12:49 ` Rob Herring 2021-09-20 9:52 ` [RFC PATCH net-next 05/12] reset: lan966x: Add switch reset driver Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 12:11 ` Andrew Lunn 2021-09-20 12:11 ` Andrew Lunn 2021-09-22 9:59 ` Horatiu Vultur 2021-09-22 9:59 ` Horatiu Vultur 2021-09-20 9:52 ` [RFC PATCH net-next 06/12] dt-bindings: reset: Add lan966x power reset bindings Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 9:52 ` [RFC PATCH net-next 07/12] power: reset: Add lan966x power reset driver Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 12:15 ` Andrew Lunn 2021-09-20 12:15 ` Andrew Lunn 2021-09-20 9:52 ` [RFC PATCH net-next 08/12] dt-bindings: net: lan966x: Add lan966x-switch bindings Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-23 12:53 ` Rob Herring 2021-09-23 12:53 ` Rob Herring 2021-09-20 9:52 ` [RFC PATCH net-next 09/12] net: lan966x: add the basic lan966x driver Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 13:46 ` Russell King (Oracle) 2021-09-20 13:46 ` Russell King (Oracle) 2021-09-20 9:52 ` [RFC PATCH net-next 10/12] net: lan966x: add port module support Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 13:54 ` Russell King (Oracle) 2021-09-20 13:54 ` Russell King (Oracle) 2021-09-23 8:02 ` Horatiu Vultur 2021-09-23 8:02 ` Horatiu Vultur 2021-09-20 9:52 ` [RFC PATCH net-next 11/12] net: lan966x: add mactable support Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 9:52 ` [RFC PATCH net-next 12/12] net: lan966x: add ethtool configuration and statistics Horatiu Vultur 2021-09-20 9:52 ` Horatiu Vultur 2021-09-20 20:31 ` Jakub Kicinski 2021-09-20 20:31 ` Jakub Kicinski
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=YUhbs4P9jHKBYpYK@piout.net \ --to=alexandre.belloni@bootlin.com \ --cc=UNGLinuxDriver@microchip.com \ --cc=andrew@lunn.ch \ --cc=davem@davemloft.net \ --cc=devicetree@vger.kernel.org \ --cc=f.fainelli@gmail.com \ --cc=horatiu.vultur@microchip.com \ --cc=kuba@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-phy@lists.infradead.org \ --cc=linux-pm@vger.kernel.org \ --cc=linux@armlinux.org.uk \ --cc=netdev@vger.kernel.org \ --cc=robh+dt@kernel.org \ --cc=vladimir.oltean@nxp.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.