linux/drivers/net/mdio/mdio-i2c.c

// SPDX-License-Identifier: GPL-2.0
/*
 * MDIO I2C bridge
 *
 * Copyright (C) 2015-2016 Russell King
 * Copyright (C) 2021 Marek Behun
 *
 * Network PHYs can appear on I2C buses when they are part of SFP module.
 * This driver exposes these PHYs to the networking PHY code, allowing
 * our PHY drivers access to these PHYs, and so allowing configuration
 * of their settings.
 */
#include <linux/i2c.h>
#include <linux/mdio/mdio-i2c.h>
#include <linux/phy.h>
#include <linux/sfp.h>

/*
 * I2C bus addresses 0x50 and 0x51 are normally an EEPROM, which is
 * specified to be present in SFP modules.  These correspond with PHY
 * addresses 16 and 17.  Disallow access to these "phy" addresses.
 */
static bool i2c_mii_valid_phy_id(int phy_id)
{}

static unsigned int i2c_mii_phy_addr(int phy_id)
{}

static int i2c_mii_read_default_c45(struct mii_bus *bus, int phy_id, int devad,
				    int reg)
{}

static int i2c_mii_write_default_c45(struct mii_bus *bus, int phy_id,
				     int devad, int reg, u16 val)
{}

static int i2c_mii_read_default_c22(struct mii_bus *bus, int phy_id, int reg)
{}

static int i2c_mii_write_default_c22(struct mii_bus *bus, int phy_id, int reg,
				     u16 val)
{}

/* RollBall SFPs do not access internal PHY via I2C address 0x56, but
 * instead via address 0x51, when SFP page is set to 0x03 and password to
 * 0xffffffff.
 *
 * address  size  contents  description
 * -------  ----  --------  -----------
 * 0x80     1     CMD       0x01/0x02/0x04 for write/read/done
 * 0x81     1     DEV       Clause 45 device
 * 0x82     2     REG       Clause 45 register
 * 0x84     2     VAL       Register value
 */
#define ROLLBALL_PHY_I2C_ADDR

#define ROLLBALL_PASSWORD

#define ROLLBALL_CMD_ADDR
#define ROLLBALL_DATA_ADDR

#define ROLLBALL_CMD_WRITE
#define ROLLBALL_CMD_READ
#define ROLLBALL_CMD_DONE

#define SFP_PAGE_ROLLBALL_MDIO

static int __i2c_transfer_err(struct i2c_adapter *i2c, struct i2c_msg *msgs,
			      int num)
{}

static int __i2c_rollball_get_page(struct i2c_adapter *i2c, int bus_addr,
				   u8 *page)
{}

static int __i2c_rollball_set_page(struct i2c_adapter *i2c, int bus_addr,
				   u8 page)
{}

/* In order to not interfere with other SFP code (which possibly may manipulate
 * SFP_PAGE), for every transfer we do this:
 *   1. lock the bus
 *   2. save content of SFP_PAGE
 *   3. set SFP_PAGE to 3
 *   4. do the transfer
 *   5. restore original SFP_PAGE
 *   6. unlock the bus
 * Note that one might think that steps 2 to 5 could be theoretically done all
 * in one call to i2c_transfer (by constructing msgs array in such a way), but
 * unfortunately tests show that this does not work :-( Changed SFP_PAGE does
 * not take into account until i2c_transfer() is done.
 */
static int i2c_transfer_rollball(struct i2c_adapter *i2c,
				 struct i2c_msg *msgs, int num)
{}

static int i2c_rollball_mii_poll(struct mii_bus *bus, int bus_addr, u8 *buf,
				 size_t len)
{}

static int i2c_rollball_mii_cmd(struct mii_bus *bus, int bus_addr, u8 cmd,
				u8 *data, size_t len)
{}

static int i2c_mii_read_rollball(struct mii_bus *bus, int phy_id, int devad,
				 int reg)
{}

static int i2c_mii_write_rollball(struct mii_bus *bus, int phy_id, int devad,
				  int reg, u16 val)
{}

static int i2c_mii_init_rollball(struct i2c_adapter *i2c)
{}

struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c,
			       enum mdio_i2c_proto protocol)
{}
EXPORT_SYMBOL_GPL();

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