From: Alex Marginean <alexm.osslist@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 06/11] drivers: net: aquantia: set MDI reversal based on DT property
Date: Fri, 9 Aug 2019 16:17:07 +0300 [thread overview]
Message-ID: <91037c1b-da4b-773e-98bf-238e92d9cc71@gmail.com> (raw)
In-Reply-To: <20190808164520.32600-7-alexandru.marginean@nxp.com>
On 8/8/2019 7:45 PM, Alex Marginean wrote:
> MDI pins up to the RJ45 connector may be reversed on the board and the
> default PHY configuration applied by firmware may or may not match that.
> Add an optional DT property to configure MDI reversal for this case.
>
> Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
> ---
> drivers/net/phy/aquantia.c | 39 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/drivers/net/phy/aquantia.c b/drivers/net/phy/aquantia.c
> index ab165e76f5..62a4d1ea6e 100644
> --- a/drivers/net/phy/aquantia.c
> +++ b/drivers/net/phy/aquantia.c
> @@ -64,6 +64,13 @@
> #define UP_RUN_STALL_OVERRIDE BIT(6)
> #define UP_RUN_STALL BIT(0)
>
> +#define AQUANTIA_PMA_RX_VENDOR_P1 0xe400
> +#define AQUANTIA_PMA_RX_VENDOR_P1_MDI_MSK GENMASK(1, 0)
> +/* MDI reversal configured through registers */
> +#define AQUANTIA_PMA_RX_VENDOR_P1_MDI_CFG BIT(1)
> +/* MDI reversal enabled */
> +#define AQUANTIA_PMA_RX_VENDOR_P1_MDI_REV BIT(0)
> +
> /*
> * global start rate, the protocol associated with this speed is used by default
> * on SI.
> @@ -324,6 +331,36 @@ static int aquantia_set_proto(struct phy_device *phydev, int if_type)
> return 0;
> }
>
> +static int aquantia_dts_config(struct phy_device *phydev)
> +{
> +#ifdef CONFIG_OF_CONTROL
^ This should be CONFIG_DM_ETH
> + ofnode node = phydev->node;
> + u32 prop;
> + u16 reg;
> +
> + /* this code only works on gen2 and gen3 PHYs */
> + if (phydev->drv->data != AQUANTIA_GEN2 &&
> + phydev->drv->data != AQUANTIA_GEN3)
> + return -ENOTSUPP;
> +
> + if (!ofnode_valid(node))
> + return 0;
> +
> + if (!ofnode_read_u32(node, "mdi-reversal", &prop)) {
> + debug("mdi-reversal = %d\n", (int)prop);
> + reg = phy_read(phydev, MDIO_MMD_PMAPMD,
> + AQUANTIA_PMA_RX_VENDOR_P1);
> + reg &= ~AQUANTIA_PMA_RX_VENDOR_P1_MDI_MSK;
> + reg |= AQUANTIA_PMA_RX_VENDOR_P1_MDI_CFG;
> + reg |= prop ? AQUANTIA_PMA_RX_VENDOR_P1_MDI_REV : 0;
> + phy_write(phydev, MDIO_MMD_PMAPMD, AQUANTIA_PMA_RX_VENDOR_P1,
> + reg);
> + }
> +
> +#endif
> + return 0;
> +}
> +
> static bool aquantia_link_is_up(struct phy_device *phydev)
> {
> u16 reg, regmask;
> @@ -403,6 +440,8 @@ int aquantia_config(struct phy_device *phydev)
>
> /* configure protocol based on phydev->interface */
> aquantia_set_proto(phydev, if_type);
> + /* apply custom configuration based on DT */
> + aquantia_dts_config(phydev);
>
> /* wake PHY back up */
> phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, 0);
>
next prev parent reply other threads:[~2019-08-09 13:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-08 16:45 [U-Boot] [PATCH 00/11] Aquantia PHY driver updates to reduce FW dependency Alex Marginean
2019-08-08 16:45 ` [U-Boot] [PATCH 01/11] include: phy: define XFI and USXGMII interface types Alex Marginean
2019-08-08 16:45 ` [U-Boot] [PATCH 02/11] include: phy: add data field for private driver data Alex Marginean
2019-08-08 16:45 ` [U-Boot] [PATCH 03/11] drivers: net: aquantia: use XFI, USXGMII interface types Alex Marginean
2019-08-08 16:45 ` [U-Boot] [PATCH 04/11] drivers: net: aquantia: add PHY generation information Alex Marginean
2019-08-08 16:45 ` [U-Boot] [PATCH 05/11] drivers: net: aquantia: set up SI protocol based on interface type Alex Marginean
2019-08-08 16:45 ` [U-Boot] [PATCH 06/11] drivers: net: aquantia: set MDI reversal based on DT property Alex Marginean
2019-08-09 13:17 ` Alex Marginean [this message]
2019-08-08 16:45 ` [U-Boot] [PATCH 07/11] drivers: net: aquantia: set SMBus addr " Alex Marginean
2019-08-08 16:45 ` [U-Boot] [PATCH 08/11] drivers: net: aquantia: use SI and LI status in loop waiting for link up Alex Marginean
2019-08-08 16:45 ` [U-Boot] [PATCH 09/11] doc: bindings: add bindings document for PHY nodes Alex Marginean
2019-08-08 16:45 ` [U-Boot] [PATCH 10/11] doc: bindings: Aquantia PHY node binding Alex Marginean
2019-08-08 16:45 ` [U-Boot] [PATCH 11/11] drivers: net: fsl_enetc: use XFI, USXGMII interface type macros Alex Marginean
2019-08-08 19:21 ` [U-Boot] [PATCH 00/11] Aquantia PHY driver updates to reduce FW dependency Alex Marginean
2019-08-12 13:38 ` Alex Marginean
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=91037c1b-da4b-773e-98bf-238e92d9cc71@gmail.com \
--to=alexm.osslist@gmail.com \
--cc=u-boot@lists.denx.de \
/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