mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-25 11:55:37 +00:00
Merge branch 'net-phy-micrel-add-coma-mode-support'
Michael Walle says: ==================== net: phy: micrel: add coma mode support Add support to disable coma mode by a GPIO line. ==================== Link: https://lore.kernel.org/r/20220427214406.1348872-1-michael@walle.cc Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
a41c653dc5
2 changed files with 37 additions and 4 deletions
|
@ -45,3 +45,12 @@ Optional properties:
|
|||
|
||||
In fiber mode, auto-negotiation is disabled and the PHY can only work in
|
||||
100base-fx (full and half duplex) modes.
|
||||
|
||||
- coma-mode-gpios: If present the given gpio will be deasserted when the
|
||||
PHY is probed.
|
||||
|
||||
Some PHYs have a COMA mode input pin which puts the PHY into
|
||||
isolate and power-down mode. On some boards this input is connected
|
||||
to a GPIO of the SoC.
|
||||
|
||||
Supported on the LAN8814.
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <linux/ptp_clock.h>
|
||||
#include <linux/ptp_classify.h>
|
||||
#include <linux/net_tstamp.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
|
||||
/* Operation Mode Strap Override */
|
||||
#define MII_KSZPHY_OMSO 0x16
|
||||
|
@ -2729,6 +2730,10 @@ static void lan8814_ptp_init(struct phy_device *phydev)
|
|||
struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv;
|
||||
u32 temp;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK) ||
|
||||
!IS_ENABLED(CONFIG_NETWORK_PHY_TIMESTAMPING))
|
||||
return;
|
||||
|
||||
lanphy_write_page_reg(phydev, 5, TSU_HARD_RESET, TSU_HARD_RESET_);
|
||||
|
||||
temp = lanphy_read_page_reg(phydev, 5, PTP_TX_MOD);
|
||||
|
@ -2767,6 +2772,10 @@ static int lan8814_ptp_probe_once(struct phy_device *phydev)
|
|||
{
|
||||
struct lan8814_shared_priv *shared = phydev->shared->priv;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK) ||
|
||||
!IS_ENABLED(CONFIG_NETWORK_PHY_TIMESTAMPING))
|
||||
return 0;
|
||||
|
||||
/* Initialise shared lock for clock*/
|
||||
mutex_init(&shared->shared_lock);
|
||||
|
||||
|
@ -2829,6 +2838,21 @@ static int lan8814_config_init(struct phy_device *phydev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lan8814_release_coma_mode(struct phy_device *phydev)
|
||||
{
|
||||
struct gpio_desc *gpiod;
|
||||
|
||||
gpiod = devm_gpiod_get_optional(&phydev->mdio.dev, "coma-mode",
|
||||
GPIOD_OUT_HIGH_OPEN_DRAIN);
|
||||
if (IS_ERR(gpiod))
|
||||
return PTR_ERR(gpiod);
|
||||
|
||||
gpiod_set_consumer_name(gpiod, "LAN8814 coma mode");
|
||||
gpiod_set_value_cansleep(gpiod, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lan8814_probe(struct phy_device *phydev)
|
||||
{
|
||||
struct kszphy_priv *priv;
|
||||
|
@ -2843,10 +2867,6 @@ static int lan8814_probe(struct phy_device *phydev)
|
|||
|
||||
phydev->priv = priv;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK) ||
|
||||
!IS_ENABLED(CONFIG_NETWORK_PHY_TIMESTAMPING))
|
||||
return 0;
|
||||
|
||||
/* Strap-in value for PHY address, below register read gives starting
|
||||
* phy address value
|
||||
*/
|
||||
|
@ -2855,6 +2875,10 @@ static int lan8814_probe(struct phy_device *phydev)
|
|||
addr, sizeof(struct lan8814_shared_priv));
|
||||
|
||||
if (phy_package_init_once(phydev)) {
|
||||
err = lan8814_release_coma_mode(phydev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = lan8814_ptp_probe_once(phydev);
|
||||
if (err)
|
||||
return err;
|
||||
|
|
Loading…
Reference in a new issue