linux/drivers/net/phy/mxl-gpy.c

// SPDX-License-Identifier: GPL-2.0+
/* Copyright (C) 2021 Maxlinear Corporation
 * Copyright (C) 2020 Intel Corporation
 *
 * Drivers for Maxlinear Ethernet GPY
 *
 */

#include <linux/module.h>
#include <linux/bitfield.h>
#include <linux/hwmon.h>
#include <linux/mutex.h>
#include <linux/phy.h>
#include <linux/polynomial.h>
#include <linux/property.h>
#include <linux/netdevice.h>

/* PHY ID */
#define PHY_ID_GPYx15B_MASK
#define PHY_ID_GPY21xB_MASK
#define PHY_ID_GPY2xx
#define PHY_ID_GPY115B
#define PHY_ID_GPY115C
#define PHY_ID_GPY211B
#define PHY_ID_GPY211C
#define PHY_ID_GPY212B
#define PHY_ID_GPY212C
#define PHY_ID_GPY215B
#define PHY_ID_GPY215C
#define PHY_ID_GPY241B
#define PHY_ID_GPY241BM
#define PHY_ID_GPY245B

#define PHY_CTL1
#define PHY_CTL1_MDICD
#define PHY_CTL1_MDIAB
#define PHY_CTL1_AMDIX
#define PHY_MIISTAT
#define PHY_IMASK
#define PHY_ISTAT
#define PHY_FWV

#define PHY_MIISTAT_SPD_MASK
#define PHY_MIISTAT_DPX
#define PHY_MIISTAT_LS

#define PHY_MIISTAT_SPD_10
#define PHY_MIISTAT_SPD_100
#define PHY_MIISTAT_SPD_1000
#define PHY_MIISTAT_SPD_2500

#define PHY_IMASK_WOL
#define PHY_IMASK_ANC
#define PHY_IMASK_ADSC
#define PHY_IMASK_DXMC
#define PHY_IMASK_LSPC
#define PHY_IMASK_LSTC
#define PHY_IMASK_MASK

#define PHY_FWV_REL_MASK
#define PHY_FWV_MAJOR_MASK
#define PHY_FWV_MINOR_MASK

#define PHY_PMA_MGBT_POLARITY
#define PHY_MDI_MDI_X_MASK
#define PHY_MDI_MDI_X_NORMAL
#define PHY_MDI_MDI_X_AB
#define PHY_MDI_MDI_X_CD
#define PHY_MDI_MDI_X_CROSS

/* SGMII */
#define VSPEC1_SGMII_CTRL
#define VSPEC1_SGMII_CTRL_ANEN
#define VSPEC1_SGMII_CTRL_ANRS
#define VSPEC1_SGMII_ANEN_ANRS

/* Temperature sensor */
#define VSPEC1_TEMP_STA
#define VSPEC1_TEMP_STA_DATA

/* Mailbox */
#define VSPEC1_MBOX_DATA
#define VSPEC1_MBOX_ADDRLO
#define VSPEC1_MBOX_CMD
#define VSPEC1_MBOX_CMD_ADDRHI
#define VSPEC1_MBOX_CMD_RD
#define VSPEC1_MBOX_CMD_READY

/* WoL */
#define VPSPEC2_WOL_CTL
#define VPSPEC2_WOL_AD01
#define VPSPEC2_WOL_AD23
#define VPSPEC2_WOL_AD45
#define WOL_EN

/* Internal registers, access via mbox */
#define REG_GPIO0_OUT

struct gpy_priv {};

static const struct {} ver_need_sgmii_reaneg[] =;

#if IS_ENABLED(CONFIG_HWMON)
/* The original translation formulae of the temperature (in degrees of Celsius)
 * are as follows:
 *
 *   T = -2.5761e-11*(N^4) + 9.7332e-8*(N^3) + -1.9165e-4*(N^2) +
 *       3.0762e-1*(N^1) + -5.2156e1
 *
 * where [-52.156, 137.961]C and N = [0, 1023].
 *
 * They must be accordingly altered to be suitable for the integer arithmetics.
 * The technique is called 'factor redistribution', which just makes sure the
 * multiplications and divisions are made so to have a result of the operations
 * within the integer numbers limit. In addition we need to translate the
 * formulae to accept millidegrees of Celsius. Here what it looks like after
 * the alterations:
 *
 *   T = -25761e-12*(N^4) + 97332e-9*(N^3) + -191650e-6*(N^2) +
 *       307620e-3*(N^1) + -52156
 *
 * where T = [-52156, 137961]mC and N = [0, 1023].
 */
static const struct polynomial poly_N_to_temp =;

static int gpy_hwmon_read(struct device *dev,
			  enum hwmon_sensor_types type,
			  u32 attr, int channel, long *value)
{}

static umode_t gpy_hwmon_is_visible(const void *data,
				    enum hwmon_sensor_types type,
				    u32 attr, int channel)
{}

static const struct hwmon_channel_info * const gpy_hwmon_info[] =;

static const struct hwmon_ops gpy_hwmon_hwmon_ops =;

static const struct hwmon_chip_info gpy_hwmon_chip_info =;

static int gpy_hwmon_register(struct phy_device *phydev)
{}
#else
static int gpy_hwmon_register(struct phy_device *phydev)
{
	return 0;
}
#endif

static int gpy_ack_interrupt(struct phy_device *phydev)
{}

static int gpy_mbox_read(struct phy_device *phydev, u32 addr)
{}

static int gpy_config_init(struct phy_device *phydev)
{}

static int gpy21x_config_init(struct phy_device *phydev)
{}

static int gpy_probe(struct phy_device *phydev)
{}

static bool gpy_sgmii_need_reaneg(struct phy_device *phydev)
{}

static bool gpy_2500basex_chk(struct phy_device *phydev)
{}

static bool gpy_sgmii_aneg_en(struct phy_device *phydev)
{}

static int gpy_config_mdix(struct phy_device *phydev, u8 ctrl)
{}

static int gpy_config_aneg(struct phy_device *phydev)
{}

static int gpy_update_mdix(struct phy_device *phydev)
{}

static int gpy_update_interface(struct phy_device *phydev)
{}

static int gpy_read_status(struct phy_device *phydev)
{}

static int gpy_config_intr(struct phy_device *phydev)
{}

static irqreturn_t gpy_handle_interrupt(struct phy_device *phydev)
{}

static int gpy_set_wol(struct phy_device *phydev,
		       struct ethtool_wolinfo *wol)
{}

static void gpy_get_wol(struct phy_device *phydev,
			struct ethtool_wolinfo *wol)
{}

static int gpy_loopback(struct phy_device *phydev, bool enable)
{}

static int gpy115_loopback(struct phy_device *phydev, bool enable)
{}

static struct phy_driver gpy_drivers[] =;
module_phy_driver(gpy_drivers);

static struct mdio_device_id __maybe_unused gpy_tbl[] =;
MODULE_DEVICE_TABLE(mdio, gpy_tbl);

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