linux/drivers/net/phy/meson-gxl.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Amlogic Meson GXL Internal PHY Driver
 *
 * Copyright (C) 2015 Amlogic, Inc. All rights reserved.
 * Copyright (C) 2016 BayLibre, SAS. All rights reserved.
 * Author: Neil Armstrong <[email protected]>
 */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/phy.h>
#include <linux/netdevice.h>
#include <linux/bitfield.h>
#include <linux/smscphy.h>

#define TSTCNTL
#define TSTCNTL_READ
#define TSTCNTL_WRITE
#define TSTCNTL_REG_BANK_SEL
#define TSTCNTL_TEST_MODE
#define TSTCNTL_READ_ADDRESS
#define TSTCNTL_WRITE_ADDRESS
#define TSTREAD1
#define TSTWRITE

#define BANK_ANALOG_DSP
#define BANK_WOL
#define BANK_BIST

/* WOL Registers */
#define LPI_STATUS
#define LPI_STATUS_RSV12

/* BIST Registers */
#define FR_PLL_CONTROL
#define FR_PLL_DIV0
#define FR_PLL_DIV1

static int meson_gxl_open_banks(struct phy_device *phydev)
{}

static void meson_gxl_close_banks(struct phy_device *phydev)
{}

static int meson_gxl_read_reg(struct phy_device *phydev,
			      unsigned int bank, unsigned int reg)
{}

static int meson_gxl_write_reg(struct phy_device *phydev,
			       unsigned int bank, unsigned int reg,
			       uint16_t value)
{}

static int meson_gxl_config_init(struct phy_device *phydev)
{}

/* This function is provided to cope with the possible failures of this phy
 * during aneg process. When aneg fails, the PHY reports that aneg is done
 * but the value found in MII_LPA is wrong:
 *  - Early failures: MII_LPA is just 0x0001. if MII_EXPANSION reports that
 *    the link partner (LP) supports aneg but the LP never acked our base
 *    code word, it is likely that we never sent it to begin with.
 *  - Late failures: MII_LPA is filled with a value which seems to make sense
 *    but it actually is not what the LP is advertising. It seems that we
 *    can detect this using a magic bit in the WOL bank (reg 12 - bit 12).
 *    If this particular bit is not set when aneg is reported being done,
 *    it means MII_LPA is likely to be wrong.
 *
 * In both case, forcing a restart of the aneg process solve the problem.
 * When this failure happens, the first retry is usually successful but,
 * in some cases, it may take up to 6 retries to get a decent result
 */
static int meson_gxl_read_status(struct phy_device *phydev)
{}

static struct phy_driver meson_gxl_phy[] =;

static struct mdio_device_id __maybe_unused meson_gxl_tbl[] =;

module_phy_driver(meson_gxl_phy);

MODULE_DEVICE_TABLE(mdio, meson_gxl_tbl);

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_LICENSE();