From: Andrew Lunn <andrew@lunn•ch>
To: Mengyuan Lou <mengyuanlou@net-swift•com>
Cc: netdev@vger•kernel.org, jiawenwu@trustnetic•com
Subject: Re: [PATCH net-next 4/5] net: ngbe: Initialize phy information
Date: Tue, 8 Nov 2022 22:10:57 +0100 [thread overview]
Message-ID: <Y2rF4bucPjOsYvra@lunn.ch> (raw)
In-Reply-To: <20221108111907.48599-5-mengyuanlou@net-swift.com>
> +/**
> + * ngbe_phy_read_reg_mdi - Reads a val from an external PHY register
> + * @hw: pointer to hardware structure
> + * @reg_addr: 32 bit address of PHY register to read
> + **/
> +static u16 ngbe_phy_read_reg_mdi(struct ngbe_hw *hw, u32 reg_addr)
> +{
> + u32 command = 0, device_type = 0;
> + struct wx_hw *wxhw = &hw->wxhw;
> + u32 phy_addr = 0;
> + u16 phy_data = 0;
> + u32 val = 0;
> + int ret = 0;
> +
> + /* setup and write the address cycle command */
> + command = NGBE_MSCA_RA(reg_addr) |
> + NGBE_MSCA_PA(phy_addr) |
> + NGBE_MSCA_DA(device_type);
> + wr32(wxhw, NGBE_MSCA, command);
> +
> + command = NGBE_MSCC_CMD(NGBE_MSCA_CMD_READ) |
> + NGBE_MSCC_BUSY |
> + NGBE_MDIO_CLK(6);
> + wr32(wxhw, NGBE_MSCC, command);
> +
> + /* wait to complete */
> + ret = read_poll_timeout(rd32, val, val & NGBE_MSCC_BUSY, 1000,
> + 20000, false, wxhw, NGBE_MSCC);
> + if (ret)
> + wx_dbg(wxhw, "PHY address command did not complete.\n");
> +
> + /* read data from MSCC */
> + phy_data = (u16)rd32(wxhw, NGBE_MSCC);
> +
> + return phy_data;
> +}
> +
> +/**
> + * ngbe_phy_write_reg_mdi - Writes a val to external PHY register
> + * @hw: pointer to hardware structure
> + * @reg_addr: 32 bit PHY register to write
> + * @phy_data: Data to write to the PHY register
> + **/
> +static void ngbe_phy_write_reg_mdi(struct ngbe_hw *hw, u32 reg_addr, u16 phy_data)
> +{
> + u32 command = 0, device_type = 0;
> + struct wx_hw *wxhw = &hw->wxhw;
> + u32 phy_addr = 0;
> + int ret = 0;
> + u16 val = 0;
> +
> + /* setup and write the address cycle command */
> + command = NGBE_MSCA_RA(reg_addr) |
> + NGBE_MSCA_PA(phy_addr) |
> + NGBE_MSCA_DA(device_type);
> + wr32(wxhw, NGBE_MSCA, command);
> +
> + command = phy_data |
> + NGBE_MSCC_CMD(NGBE_MSCA_CMD_WRITE) |
> + NGBE_MSCC_BUSY |
> + NGBE_MDIO_CLK(6);
> + wr32(wxhw, NGBE_MSCC, command);
> +
> + /* wait to complete */
> + ret = read_poll_timeout(rd32, val, val & NGBE_MSCC_BUSY, 1000,
> + 20000, false, wxhw, NGBE_MSCC);
> + if (ret)
> + wx_dbg(wxhw, "PHY address command did not complete.\n");
> +}
This appears to be an MDIO bus? Although you seem to be limited to
just 1 of the 32 addresses? Anyway, please create a standard Linux
MDIO bus driver. The Linux PHY drivers will then drive the PHYs for
you. You can throw most of this file away.
Andrew
next prev parent reply other threads:[~2022-11-08 21:11 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 11:19 [PATCH net-next 0/5] net: WangXun ethernet drivers Mengyuan Lou
2022-11-08 11:19 ` [PATCH net-next 1/5] net: txgbe: Identify PHY and SFP module Mengyuan Lou
2022-11-08 20:52 ` Andrew Lunn
2022-11-09 6:32 ` Jiawen Wu
2022-11-09 13:26 ` Andrew Lunn
2022-11-14 9:34 ` Jiawen Wu
2022-11-14 13:25 ` Andrew Lunn
2022-11-29 8:20 ` Jiawen Wu
2022-11-14 15:34 ` Alexander Lobakin
2022-11-14 20:18 ` Andrew Lunn
2022-11-08 11:19 ` [PATCH net-next 2/5] net: txgbe: Initialize service task Mengyuan Lou
2022-11-08 23:55 ` Jakub Kicinski
2022-11-09 2:16 ` Jiawen Wu
2022-11-09 2:36 ` Andrew Lunn
2022-11-14 15:39 ` Alexander Lobakin
2022-11-08 11:19 ` [PATCH net-next 3/5] net: txgbe: Support to setup link Mengyuan Lou
2022-11-08 21:03 ` Andrew Lunn
2022-11-14 15:48 ` Alexander Lobakin
2022-11-14 20:20 ` Andrew Lunn
2022-11-08 11:19 ` [PATCH net-next 4/5] net: ngbe: Initialize phy information Mengyuan Lou
2022-11-08 21:10 ` Andrew Lunn [this message]
2022-11-11 3:13 ` mengyuanlou
2022-11-11 3:28 ` Andrew Lunn
2022-11-14 16:16 ` Alexander Lobakin
2022-11-08 11:19 ` [PATCH net-next 5/5] net: ngbe: Initialize service task Mengyuan Lou
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=Y2rF4bucPjOsYvra@lunn.ch \
--to=andrew@lunn$(echo .)ch \
--cc=jiawenwu@trustnetic$(echo .)com \
--cc=mengyuanlou@net-swift$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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