Blame view
include/miiphy.h
5.39 KB
4549e789c
|
1 |
/* SPDX-License-Identifier: GPL-2.0 OR IBM-pibs */ |
46263f2de
|
2 |
/* |
46263f2de
|
3 4 |
* Additions (C) Copyright 2009 Industrie Dial Face S.p.A. */ |
214ec6bbd
|
5 6 |
/*----------------------------------------------------------------------------+ | |
65bd0e284
|
7 |
| File Name: miiphy.h |
214ec6bbd
|
8 |
| |
65bd0e284
|
9 |
| Function: Include file defining PHY registers. |
214ec6bbd
|
10 |
| |
65bd0e284
|
11 |
| Author: Mark Wisner |
214ec6bbd
|
12 |
| |
214ec6bbd
|
13 14 15 |
+----------------------------------------------------------------------------*/ #ifndef _miiphy_h_ #define _miiphy_h_ |
5f184715e
|
16 |
#include <common.h> |
8ef583a03
|
17 |
#include <linux/mii.h> |
5f184715e
|
18 |
#include <linux/list.h> |
63ff004c4
|
19 |
#include <net.h> |
5f184715e
|
20 |
#include <phy.h> |
f915c9316
|
21 |
int miiphy_read(const char *devname, unsigned char addr, unsigned char reg, |
298035df4
|
22 |
unsigned short *value); |
f915c9316
|
23 |
int miiphy_write(const char *devname, unsigned char addr, unsigned char reg, |
298035df4
|
24 |
unsigned short value); |
16a532383
|
25 |
int miiphy_info(const char *devname, unsigned char addr, unsigned int *oui, |
298035df4
|
26 |
unsigned char *model, unsigned char *rev); |
16a532383
|
27 28 29 30 |
int miiphy_reset(const char *devname, unsigned char addr); int miiphy_speed(const char *devname, unsigned char addr); int miiphy_duplex(const char *devname, unsigned char addr); int miiphy_is_1000base_x(const char *devname, unsigned char addr); |
6d0f6bcf3
|
31 |
#ifdef CONFIG_SYS_FAULT_ECHO_LINK_DOWN |
16a532383
|
32 |
int miiphy_link(const char *devname, unsigned char addr); |
fc3e2165e
|
33 |
#endif |
214ec6bbd
|
34 |
|
16a532383
|
35 |
void miiphy_init(void); |
d9785c14b
|
36 |
|
16a532383
|
37 38 |
int miiphy_set_current_dev(const char *devname); const char *miiphy_get_current_dev(void); |
5f184715e
|
39 |
struct mii_dev *mdio_get_current_dev(void); |
9215bb1f3
|
40 |
struct list_head *mdio_get_list_head(void); |
5f184715e
|
41 42 |
struct mii_dev *miiphy_get_dev_by_name(const char *devname); struct phy_device *mdio_phydev_for_ethname(const char *devname); |
63ff004c4
|
43 |
|
16a532383
|
44 |
void miiphy_listdev(void); |
63ff004c4
|
45 |
|
5f184715e
|
46 |
struct mii_dev *mdio_alloc(void); |
cb6baca77
|
47 |
void mdio_free(struct mii_dev *bus); |
5f184715e
|
48 |
int mdio_register(struct mii_dev *bus); |
79e2a6a04
|
49 50 51 52 53 54 55 56 57 |
/** * mdio_register_seq - Register mdio bus with sequence number * @bus: mii device structure * @seq: sequence number * * Return: 0 if success, negative value if error */ int mdio_register_seq(struct mii_dev *bus, int seq); |
cb6baca77
|
58 |
int mdio_unregister(struct mii_dev *bus); |
5f184715e
|
59 |
void mdio_list_devices(void); |
4ba31ab33
|
60 61 62 63 64 |
#ifdef CONFIG_BITBANGMII #define BB_MII_DEVNAME "bb_miiphy" struct bb_miiphy_bus { |
f6add132f
|
65 |
char name[16]; |
4ba31ab33
|
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
int (*init)(struct bb_miiphy_bus *bus); int (*mdio_active)(struct bb_miiphy_bus *bus); int (*mdio_tristate)(struct bb_miiphy_bus *bus); int (*set_mdio)(struct bb_miiphy_bus *bus, int v); int (*get_mdio)(struct bb_miiphy_bus *bus, int *v); int (*set_mdc)(struct bb_miiphy_bus *bus, int v); int (*delay)(struct bb_miiphy_bus *bus); #ifdef CONFIG_BITBANGMII_MULTI void *priv; #endif }; extern struct bb_miiphy_bus bb_miiphy_buses[]; extern int bb_miiphy_buses_num; |
63ff004c4
|
80 |
|
16a532383
|
81 |
void bb_miiphy_init(void); |
dfcc496ed
|
82 83 84 |
int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg); int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, u16 value); |
4ba31ab33
|
85 |
#endif |
214ec6bbd
|
86 87 |
/* phy seed setup */ |
65bd0e284
|
88 |
#define AUTO 99 |
298035df4
|
89 |
#define _1000BASET 1000 |
65bd0e284
|
90 91 92 93 |
#define _100BASET 100 #define _10BASET 10 #define HALF 22 #define FULL 44 |
214ec6bbd
|
94 95 |
/* phy register offsets */ |
8ef583a03
|
96 97 98 |
#define MII_MIPSCR 0x11 /* MII_LPA */ |
298035df4
|
99 100 |
#define PHY_ANLPAR_PSB_802_3 0x0001 #define PHY_ANLPAR_PSB_802_9 0x0002 |
8ef583a03
|
101 |
/* MII_CTRL1000 masks */ |
71bc6e647
|
102 103 |
#define PHY_1000BTCR_1000FD 0x0200 #define PHY_1000BTCR_1000HD 0x0100 |
8ef583a03
|
104 |
/* MII_STAT1000 masks */ |
298035df4
|
105 106 107 108 109 110 |
#define PHY_1000BTSR_MSCF 0x8000 #define PHY_1000BTSR_MSCR 0x4000 #define PHY_1000BTSR_LRS 0x2000 #define PHY_1000BTSR_RRS 0x1000 #define PHY_1000BTSR_1000FD 0x0800 #define PHY_1000BTSR_1000HD 0x0400 |
855a496fe
|
111 |
|
71bc6e647
|
112 |
/* phy EXSR */ |
8ef583a03
|
113 114 |
#define ESTATUS_1000XF 0x8000 #define ESTATUS_1000XH 0x4000 |
71bc6e647
|
115 |
|
c3452b50c
|
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
#ifdef CONFIG_DM_MDIO /** * struct mdio_perdev_priv - Per-device class data for MDIO DM * * @mii_bus: Supporting MII legacy bus */ struct mdio_perdev_priv { struct mii_dev *mii_bus; }; /** * struct mdio_ops - MDIO bus operations * * @read: Read from a PHY register * @write: Write to a PHY register * @reset: Reset the MDIO bus, NULL if not supported */ struct mdio_ops { int (*read)(struct udevice *mdio_dev, int addr, int devad, int reg); int (*write)(struct udevice *mdio_dev, int addr, int devad, int reg, u16 val); int (*reset)(struct udevice *mdio_dev); }; #define mdio_get_ops(dev) ((struct mdio_ops *)(dev)->driver->ops) /** * dm_mdio_probe_devices - Call probe on all MII devices, currently used for * MDIO console commands. */ void dm_mdio_probe_devices(void); /** * dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO * |
a5d32c37d
|
152 153 |
* @mdiodev: mdio device the PHY is accesible on * @phyaddr: PHY address on MDIO bus |
c3452b50c
|
154 155 156 157 158 |
* @ethdev: ethernet device to connect to the PHY * @interface: MAC-PHY protocol * * @return pointer to phy_device, or 0 on error */ |
a5d32c37d
|
159 |
struct phy_device *dm_mdio_phy_connect(struct udevice *mdiodev, int phyaddr, |
c3452b50c
|
160 161 |
struct udevice *ethdev, phy_interface_t interface); |
2f6245594
|
162 163 164 165 166 167 168 169 170 171 172 |
/** * dm_eth_phy_connect - Connect an Eth device to a PHY based on device tree * * Picks up the DT phy-handle and phy-mode from ethernet device node and * connects the ethernet device to the linked PHY. * * @ethdev: ethernet device * * @return pointer to phy_device, or 0 on error */ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev); |
c3452b50c
|
173 |
#endif |
8880edba0
|
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
#ifdef CONFIG_DM_MDIO_MUX /* indicates none of the child buses is selected */ #define MDIO_MUX_SELECT_NONE -1 /** * struct mdio_mux_ops - MDIO MUX operations * * @select: Selects a child bus * @deselect: Clean up selection. Optional, can be NULL */ struct mdio_mux_ops { int (*select)(struct udevice *mux, int cur, int sel); int (*deselect)(struct udevice *mux, int sel); }; #define mdio_mux_get_ops(dev) ((struct mdio_mux_ops *)(dev)->driver->ops) #endif |
214ec6bbd
|
193 |
#endif |