From: Heiner Kallweit <hkallweit1@gmail.com>
To: Horatiu Vultur <horatiu.vultur@microchip.com>,
andrew@lunn.ch, linux@armlinux.org.uk, davem@davemloft.net,
kuba@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: phy: micrel: Add config_init for LAN8814
Date: Fri, 26 Nov 2021 12:57:33 +0100 [thread overview]
Message-ID: <402780af-9d12-45dd-e435-e7279f1b9263@gmail.com> (raw)
In-Reply-To: <20211126103833.3609945-1-horatiu.vultur@microchip.com>
On 26.11.2021 11:38, Horatiu Vultur wrote:
> Add config_init for LAN8814. This function is required for the following
> reasons:
> - we need to make sure that the PHY is reset,
> - disable ANEG with QSGMII PCS Host side
> - swap the MDI-X A,B transmit so that there will not be any link flip-flaps
> when the PHY gets a link.
>
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---
> drivers/net/phy/micrel.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 44a24b99c894..f080312032cf 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -1565,6 +1565,14 @@ static int ksz886x_cable_test_get_status(struct phy_device *phydev,
> #define LAN_EXT_PAGE_ACCESS_ADDRESS_DATA 0x17
> #define LAN_EXT_PAGE_ACCESS_CTRL_EP_FUNC 0x4000
>
> +#define LAN8814_QSGMII_SOFT_RESET 0x43
> +#define LAN8814_QSGMII_SOFT_RESET_BIT BIT(0)
> +#define LAN8814_QSGMII_PCS1G_ANEG_CONFIG 0x13
> +#define LAN8814_QSGMII_PCS1G_ANEG_CONFIG_ANEG_ENA BIT(3)
> +#define LAN8814_ALIGN_SWAP 0x4a
> +#define LAN8814_ALIGN_TX_A_B_SWAP 0x1
> +#define LAN8814_ALIGN_TX_A_B_SWAP_MASK GENMASK(2, 0)
> +
> #define LAN8804_ALIGN_SWAP 0x4a
> #define LAN8804_ALIGN_TX_A_B_SWAP 0x1
> #define LAN8804_ALIGN_TX_A_B_SWAP_MASK GENMASK(2, 0)
> @@ -1601,6 +1609,29 @@ static int lanphy_write_page_reg(struct phy_device *phydev, int page, u16 addr,
> return 0;
> }
>
> +static int lan8814_config_init(struct phy_device *phydev)
> +{
> + int val;
> +
> + /* Reset the PHY */
> + val = lanphy_read_page_reg(phydev, 4, LAN8814_QSGMII_SOFT_RESET);
> + val |= LAN8814_QSGMII_SOFT_RESET_BIT;
> + lanphy_write_page_reg(phydev, 4, LAN8814_QSGMII_SOFT_RESET, val);
> +
> + /* Disable ANEG with QSGMII PCS Host side */
> + val = lanphy_read_page_reg(phydev, 5, LAN8814_QSGMII_PCS1G_ANEG_CONFIG);
> + val &= ~LAN8814_QSGMII_PCS1G_ANEG_CONFIG_ANEG_ENA;
> + lanphy_write_page_reg(phydev, 5, LAN8814_QSGMII_PCS1G_ANEG_CONFIG, val);
> +
> + /* MDI-X setting for swap A,B transmit */
> + val = lanphy_read_page_reg(phydev, 2, LAN8814_ALIGN_SWAP);
> + val &= ~LAN8814_ALIGN_TX_A_B_SWAP_MASK;
> + val |= LAN8814_ALIGN_TX_A_B_SWAP;
> + lanphy_write_page_reg(phydev, 2, LAN8814_ALIGN_SWAP, val);
> +
Not directly related to just this patch:
Did you consider implementing the read_page and write_page PHY driver
callbacks? Then you could use phylib functions like phy_modify_paged et al
and you wouldn't have to open-code the paged register operations.
I think write_page would just be
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));
and read_page
phy_read(phydev, LAN_EXT_PAGE_ACCESS_CONTROL);
> + return 0;
> +}
> +
> static int lan8804_config_init(struct phy_device *phydev)
> {
> int val;
> @@ -1793,6 +1824,7 @@ static struct phy_driver ksphy_driver[] = {
> .phy_id = PHY_ID_LAN8814,
> .phy_id_mask = MICREL_PHY_ID_MASK,
> .name = "Microchip INDY Gigabit Quad PHY",
> + .config_init = lan8814_config_init,
> .driver_data = &ksz9021_type,
> .probe = kszphy_probe,
> .soft_reset = genphy_soft_reset,
>
next prev parent reply other threads:[~2021-11-26 12:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-26 10:38 [PATCH net-next] net: phy: micrel: Add config_init for LAN8814 Horatiu Vultur
2021-11-26 11:57 ` Heiner Kallweit [this message]
2021-11-26 12:09 ` Russell King (Oracle)
2021-11-29 8:29 ` Horatiu Vultur
2021-11-29 17:07 ` Heiner Kallweit
2021-11-26 15:15 ` Andrew Lunn
2021-11-29 9:01 ` Horatiu Vultur
2021-12-22 11:48 ` Horatiu Vultur
2021-12-22 15:23 ` 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=402780af-9d12-45dd-e435-e7279f1b9263@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=horatiu.vultur@microchip.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).