linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: linux-kernel@vger.kernel.org, kernel@pengutronix.de,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v3 7/7] net: phy: dp83td510: Add support for the DP83TD510 Ethernet PHY
Date: Thu, 5 May 2022 14:12:41 +0200	[thread overview]
Message-ID: <20220505121241.GA19896@pengutronix.de> (raw)
In-Reply-To: <20220505063318.296280-8-o.rempel@pengutronix.de>

On Thu, May 05, 2022 at 08:33:18AM +0200, Oleksij Rempel wrote:
> The DP83TD510E is an ultra-low power Ethernet physical layer transceiver
> that supports 10M single pair cable.
> 
> This driver was tested with NXP SJA1105, STMMAC and ASIX AX88772B USB Ethernet
> controller.
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/phy/Kconfig     |   6 ++
>  drivers/net/phy/Makefile    |   1 +
>  drivers/net/phy/dp83td510.c | 210 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 217 insertions(+)
>  create mode 100644 drivers/net/phy/dp83td510.c
> 
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index bbbf6c07ea53..9fee639ee5c8 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -342,6 +342,12 @@ config DP83869_PHY
>  	  Currently supports the DP83869 PHY.  This PHY supports copper and
>  	  fiber connections.
>  
> +config DP83TD510_PHY
> +	tristate "Texas Instruments DP83TD510 Ethernet 10Base-T1L PHY"
> +	help
> +	  Support for the DP83TD510 Ethernet 10Base-T1L PHY. This PHY supports
> +	  a 10M single pair Ethernet connection for up to 1000 meter cable.
> +
>  config VITESSE_PHY
>  	tristate "Vitesse PHYs"
>  	help
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index b82651b57043..b12b1d86fc99 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -57,6 +57,7 @@ obj-$(CONFIG_DP83848_PHY)	+= dp83848.o
>  obj-$(CONFIG_DP83867_PHY)	+= dp83867.o
>  obj-$(CONFIG_DP83869_PHY)	+= dp83869.o
>  obj-$(CONFIG_DP83TC811_PHY)	+= dp83tc811.o
> +obj-$(CONFIG_DP83TD510_PHY)	+= dp83td510.o
>  obj-$(CONFIG_FIXED_PHY)		+= fixed_phy.o
>  obj-$(CONFIG_ICPLUS_PHY)	+= icplus.o
>  obj-$(CONFIG_INTEL_XWAY_PHY)	+= intel-xway.o
> diff --git a/drivers/net/phy/dp83td510.c b/drivers/net/phy/dp83td510.c
> new file mode 100644
> index 000000000000..5c3251602e4a
> --- /dev/null
> +++ b/drivers/net/phy/dp83td510.c
> @@ -0,0 +1,210 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Driver for the Texas Instruments DP83TD510 PHY
> + * Copyright (c) 2022 Pengutronix, Oleksij Rempel <kernel@pengutronix.de>
> + */
> +
> +#include <linux/bitfield.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/phy.h>
> +
> +#define DP83TD510E_PHY_ID			0x20000181
> +
> +/* MDIO_MMD_VEND2 registers */
> +#define DP83TD510E_PHY_STS			0x10
> +#define DP83TD510E_STS_MII_INT			BIT(7)
> +#define DP83TD510E_LINK_STATUS			BIT(0)
> +
> +#define DP83TD510E_GEN_CFG			0x11
> +#define DP83TD510E_GENCFG_INT_POLARITY		BIT(3)
> +#define DP83TD510E_GENCFG_INT_EN		BIT(1)
> +#define DP83TD510E_GENCFG_INT_OE		BIT(0)
> +
> +#define DP83TD510E_INTERRUPT_REG_1		0x12
> +#define DP83TD510E_INT1_LINK			BIT(13)
> +#define DP83TD510E_INT1_LINK_EN			BIT(5)
> +
> +#define DP83TD510E_AN_STAT_1			0x60c
> +#define DP83TD510E_MASTER_SLAVE_RESOL_FAIL	BIT(15)
> +
> +static int dp83td510_config_intr(struct phy_device *phydev)
> +{
> +	int ret;
> +
> +	if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
> +		/* Clear any pending interrupts */
> +		ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, DP83TD510E_PHY_STS,
> +				    0x0);
> +		if (ret)
> +			return ret;
> +
> +		ret = phy_write_mmd(phydev, MDIO_MMD_VEND2,
> +				    DP83TD510E_INTERRUPT_REG_1,
> +				    DP83TD510E_INT1_LINK_EN);
> +		if (ret)
> +			return ret;
> +
> +		ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND2,
> +				       DP83TD510E_GEN_CFG,
> +				       DP83TD510E_GENCFG_INT_POLARITY |
> +				       DP83TD510E_GENCFG_INT_EN |
> +				       DP83TD510E_GENCFG_INT_OE);
> +	} else {
> +		ret = phy_write_mmd(phydev, MDIO_MMD_VEND2,
> +				    DP83TD510E_INTERRUPT_REG_1, 0x0);
> +		if (ret)
> +			return ret;
> +
> +		ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2,
> +					 DP83TD510E_GEN_CFG,
> +					 DP83TD510E_GENCFG_INT_EN);
> +		if (ret)
> +			return ret;
> +
> +		/* Clear any pending interrupts */
> +		ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, DP83TD510E_PHY_STS,
> +				    0x0);
> +	}
> +
> +	return ret;
> +}
> +
> +static irqreturn_t dp83td510_handle_interrupt(struct phy_device *phydev)
> +{
> +	int  ret;
> +
> +	ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, DP83TD510E_PHY_STS);
> +	if (ret < 0) {
> +		phy_error(phydev);
> +		return IRQ_NONE;
> +	} else if (!(ret & DP83TD510E_STS_MII_INT)) {
> +		return IRQ_NONE;
> +	}
> +
> +	/* Read the current enabled interrupts */
> +	ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, DP83TD510E_INTERRUPT_REG_1);
> +	if (ret < 0) {
> +		phy_error(phydev);
> +		return IRQ_NONE;
> +	} else if (!(ret & DP83TD510E_INT1_LINK_EN) ||
> +		   !(ret & DP83TD510E_INT1_LINK)) {
> +		return IRQ_NONE;
> +	}
> +
> +	phy_trigger_machine(phydev);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static int dp83td510_read_status(struct phy_device *phydev)
> +{
> +	u16 phy_sts;
> +	int ret, cfg;

Heh, here is unused variable. Need to fix it.

Regards,
Oleksij
-- 
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 |

  reply	other threads:[~2022-05-05 12:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05  6:33 [PATCH net-next v3 0/7] add ti dp83td510 support Oleksij Rempel
2022-05-05  6:33 ` [PATCH net-next v3 1/7] net: phy: genphy_c45_baset1_an_config_aneg: do no set unknown configuration Oleksij Rempel
2022-05-05  6:33 ` [PATCH net-next v3 2/7] net: phy: introduce genphy_c45_pma_base1_setup_master_slave() Oleksij Rempel
2022-05-05 12:29   ` Andrew Lunn
2022-05-05  6:33 ` [PATCH net-next v3 3/7] net: phy: genphy_c45_pma_base1_setup_master_slave: do no set unknown configuration Oleksij Rempel
2022-05-05 12:30   ` Andrew Lunn
2022-05-05  6:33 ` [PATCH net-next v3 4/7] net: phy: introduce genphy_c45_pma_baset1_read_master_slave() Oleksij Rempel
2022-05-05 12:31   ` Andrew Lunn
2022-05-05 13:41   ` kernel test robot
2022-05-05 20:42   ` kernel test robot
2022-05-05  6:33 ` [PATCH net-next v3 5/7] net: phy: genphy_c45_pma_baset1_read_master_slave: read actual configuration Oleksij Rempel
2022-05-05 12:33   ` Andrew Lunn
2022-05-05  6:33 ` [PATCH net-next v3 6/7] net: phy: export genphy_c45_baset1_read_status() Oleksij Rempel
2022-05-05 12:33   ` Andrew Lunn
2022-05-05  6:33 ` [PATCH net-next v3 7/7] net: phy: dp83td510: Add support for the DP83TD510 Ethernet PHY Oleksij Rempel
2022-05-05 12:12   ` Oleksij Rempel [this message]
2022-05-05 12:36     ` Andrew Lunn

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=20220505121241.GA19896@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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: 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).