// SPDX-License-Identifier: GPL-2.0+ /* * Software PHY emulation * * Code taken from fixed_phy.c by Russell King. * * Author: Vitaly Bordug <[email protected]> * Anton Vorontsov <[email protected]> * * Copyright (c) 2006-2007 MontaVista Software, Inc. */ #include <linux/export.h> #include <linux/mii.h> #include <linux/phy.h> #include <linux/phy_fixed.h> #include "swphy.h" #define MII_REGS_NUM … struct swmii_regs { … }; enum { … }; /* * These two tables get bitwise-anded together to produce the final result. * This means the speed table must contain both duplex settings, and the * duplex table must contain all speed settings. */ static const struct swmii_regs speed[] = …; static const struct swmii_regs duplex[] = …; static int swphy_decode_speed(int speed) { … } /** * swphy_validate_state - validate the software phy status * @state: software phy status * * This checks that we can represent the state stored in @state can be * represented in the emulated MII registers. Returns 0 if it can, * otherwise returns -EINVAL. */ int swphy_validate_state(const struct fixed_phy_status *state) { … } EXPORT_SYMBOL_GPL(…); /** * swphy_read_reg - return a MII register from the fixed phy state * @reg: MII register * @state: fixed phy status * * Return the MII @reg register generated from the fixed phy state @state. */ int swphy_read_reg(int reg, const struct fixed_phy_status *state) { … } EXPORT_SYMBOL_GPL(…);