Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __LINUX_MDIO_BITBANG_H
0003 #define __LINUX_MDIO_BITBANG_H
0004 
0005 #include <linux/phy.h>
0006 
0007 struct module;
0008 
0009 struct mdiobb_ctrl;
0010 
0011 struct mdiobb_ops {
0012     struct module *owner;
0013 
0014     /* Set the Management Data Clock high if level is one,
0015      * low if level is zero.
0016      */
0017     void (*set_mdc)(struct mdiobb_ctrl *ctrl, int level);
0018 
0019     /* Configure the Management Data I/O pin as an input if
0020      * "output" is zero, or an output if "output" is one.
0021      */
0022     void (*set_mdio_dir)(struct mdiobb_ctrl *ctrl, int output);
0023 
0024     /* Set the Management Data I/O pin high if value is one,
0025      * low if "value" is zero.  This may only be called
0026      * when the MDIO pin is configured as an output.
0027      */
0028     void (*set_mdio_data)(struct mdiobb_ctrl *ctrl, int value);
0029 
0030     /* Retrieve the state Management Data I/O pin. */
0031     int (*get_mdio_data)(struct mdiobb_ctrl *ctrl);
0032 };
0033 
0034 struct mdiobb_ctrl {
0035     const struct mdiobb_ops *ops;
0036     unsigned int override_op_c22;
0037     u8 op_c22_read;
0038     u8 op_c22_write;
0039 };
0040 
0041 int mdiobb_read(struct mii_bus *bus, int phy, int reg);
0042 int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val);
0043 
0044 /* The returned bus is not yet registered with the phy layer. */
0045 struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl);
0046 
0047 /* The bus must already have been unregistered. */
0048 void free_mdio_bitbang(struct mii_bus *bus);
0049 
0050 #endif