2018-05-06 22:27:01 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 OR IBM-pibs */
|
2013-07-28 20:12:45 +00:00
|
|
|
/*
|
|
|
|
* Additions (C) Copyright 2009 Industrie Dial Face S.p.A.
|
|
|
|
*/
|
2001-10-08 19:18:17 +00:00
|
|
|
/*----------------------------------------------------------------------------+
|
|
|
|
|
|
2003-09-18 10:45:21 +00:00
|
|
|
| File Name: miiphy.h
|
2001-10-08 19:18:17 +00:00
|
|
|
|
|
2003-09-18 10:45:21 +00:00
|
|
|
| Function: Include file defining PHY registers.
|
2001-10-08 19:18:17 +00:00
|
|
|
|
|
2003-09-18 10:45:21 +00:00
|
|
|
| Author: Mark Wisner
|
2001-10-08 19:18:17 +00:00
|
|
|
|
|
|
|
|
+----------------------------------------------------------------------------*/
|
|
|
|
#ifndef _miiphy_h_
|
|
|
|
#define _miiphy_h_
|
|
|
|
|
Create PHY Lib for U-Boot
Extends the mii_dev structure to participate in a full-blown MDIO and
PHY driver scheme. The mii_dev structure and miiphy calls are modified
in such a way to allow the original mii command and miiphy
infrastructure to work as before, but also to support a new set of APIs
which allow (among other things) sharing of PHY driver code and 10G support
The mii command will continue to support normal PHY management functions
(Clause 22 of 802.3), but will not be changed to support 10G
(Clause 45).
The basic design is similar to PHY Lib from Linux, but simplified for
U-Boot's network and driver infrastructure.
We now have MDIO drivers and PHY drivers
An MDIO driver provides:
read
write
reset
A PHY driver provides:
(optionally): probe
config - initial setup, starting of auto-negotiation
startup - waiting for AN, and reading link state
shutdown - any cleanup needed
The ethernet drivers interact with the PHY Lib using these functions:
phy_connect()
phy_config()
phy_startup()
phy_shutdown()
Each PHY driver can be configured separately, or all at once using
config_phylib_all_drivers.h (added in the patch which adds the drivers)
We also provide generic drivers for Clause 22 (10/100/1000), and
Clause 45 (10G) PHYs.
We also implement phy_reset(), and call it in phy_connect(). Because
phy_reset() is essentially the same as miiphy_reset, but:
a) must support 10G PHYs, and
b) should use the phylib primitives,
we implement miiphy_reset, using phy_reset(), but only when
CONFIG_PHYLIB is set. Otherwise, we just use the old version. In this
way, we save on compile size, even if we don't manage to save code size.
Pulled ethtool.h and mdio.h from:
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
782d640afd15af7a1faf01cfe566ca4ac511319d
With many, many deletions so as to enable compilation under u-boot
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-04-08 07:10:27 +00:00
|
|
|
#include <common.h>
|
2010-12-23 20:40:12 +00:00
|
|
|
#include <linux/mii.h>
|
Create PHY Lib for U-Boot
Extends the mii_dev structure to participate in a full-blown MDIO and
PHY driver scheme. The mii_dev structure and miiphy calls are modified
in such a way to allow the original mii command and miiphy
infrastructure to work as before, but also to support a new set of APIs
which allow (among other things) sharing of PHY driver code and 10G support
The mii command will continue to support normal PHY management functions
(Clause 22 of 802.3), but will not be changed to support 10G
(Clause 45).
The basic design is similar to PHY Lib from Linux, but simplified for
U-Boot's network and driver infrastructure.
We now have MDIO drivers and PHY drivers
An MDIO driver provides:
read
write
reset
A PHY driver provides:
(optionally): probe
config - initial setup, starting of auto-negotiation
startup - waiting for AN, and reading link state
shutdown - any cleanup needed
The ethernet drivers interact with the PHY Lib using these functions:
phy_connect()
phy_config()
phy_startup()
phy_shutdown()
Each PHY driver can be configured separately, or all at once using
config_phylib_all_drivers.h (added in the patch which adds the drivers)
We also provide generic drivers for Clause 22 (10/100/1000), and
Clause 45 (10G) PHYs.
We also implement phy_reset(), and call it in phy_connect(). Because
phy_reset() is essentially the same as miiphy_reset, but:
a) must support 10G PHYs, and
b) should use the phylib primitives,
we implement miiphy_reset, using phy_reset(), but only when
CONFIG_PHYLIB is set. Otherwise, we just use the old version. In this
way, we save on compile size, even if we don't manage to save code size.
Pulled ethtool.h and mdio.h from:
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
782d640afd15af7a1faf01cfe566ca4ac511319d
With many, many deletions so as to enable compilation under u-boot
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-04-08 07:10:27 +00:00
|
|
|
#include <linux/list.h>
|
2005-10-28 20:30:33 +00:00
|
|
|
#include <net.h>
|
Create PHY Lib for U-Boot
Extends the mii_dev structure to participate in a full-blown MDIO and
PHY driver scheme. The mii_dev structure and miiphy calls are modified
in such a way to allow the original mii command and miiphy
infrastructure to work as before, but also to support a new set of APIs
which allow (among other things) sharing of PHY driver code and 10G support
The mii command will continue to support normal PHY management functions
(Clause 22 of 802.3), but will not be changed to support 10G
(Clause 45).
The basic design is similar to PHY Lib from Linux, but simplified for
U-Boot's network and driver infrastructure.
We now have MDIO drivers and PHY drivers
An MDIO driver provides:
read
write
reset
A PHY driver provides:
(optionally): probe
config - initial setup, starting of auto-negotiation
startup - waiting for AN, and reading link state
shutdown - any cleanup needed
The ethernet drivers interact with the PHY Lib using these functions:
phy_connect()
phy_config()
phy_startup()
phy_shutdown()
Each PHY driver can be configured separately, or all at once using
config_phylib_all_drivers.h (added in the patch which adds the drivers)
We also provide generic drivers for Clause 22 (10/100/1000), and
Clause 45 (10G) PHYs.
We also implement phy_reset(), and call it in phy_connect(). Because
phy_reset() is essentially the same as miiphy_reset, but:
a) must support 10G PHYs, and
b) should use the phylib primitives,
we implement miiphy_reset, using phy_reset(), but only when
CONFIG_PHYLIB is set. Otherwise, we just use the old version. In this
way, we save on compile size, even if we don't manage to save code size.
Pulled ethtool.h and mdio.h from:
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
782d640afd15af7a1faf01cfe566ca4ac511319d
With many, many deletions so as to enable compilation under u-boot
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-04-08 07:10:27 +00:00
|
|
|
#include <phy.h>
|
|
|
|
|
2011-12-07 07:35:14 +00:00
|
|
|
int miiphy_read(const char *devname, unsigned char addr, unsigned char reg,
|
2007-10-31 16:21:29 +00:00
|
|
|
unsigned short *value);
|
2011-12-07 07:35:14 +00:00
|
|
|
int miiphy_write(const char *devname, unsigned char addr, unsigned char reg,
|
2007-10-31 16:21:29 +00:00
|
|
|
unsigned short value);
|
2011-04-07 19:38:35 +00:00
|
|
|
int miiphy_info(const char *devname, unsigned char addr, unsigned int *oui,
|
2007-10-31 16:21:29 +00:00
|
|
|
unsigned char *model, unsigned char *rev);
|
2011-04-07 19:38:35 +00:00
|
|
|
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);
|
2008-10-16 13:01:15 +00:00
|
|
|
#ifdef CONFIG_SYS_FAULT_ECHO_LINK_DOWN
|
2011-04-07 19:38:35 +00:00
|
|
|
int miiphy_link(const char *devname, unsigned char addr);
|
2003-10-08 22:33:00 +00:00
|
|
|
#endif
|
2001-10-08 19:18:17 +00:00
|
|
|
|
2011-04-07 19:38:35 +00:00
|
|
|
void miiphy_init(void);
|
2005-11-30 17:06:04 +00:00
|
|
|
|
2011-04-07 19:38:35 +00:00
|
|
|
int miiphy_set_current_dev(const char *devname);
|
|
|
|
const char *miiphy_get_current_dev(void);
|
Create PHY Lib for U-Boot
Extends the mii_dev structure to participate in a full-blown MDIO and
PHY driver scheme. The mii_dev structure and miiphy calls are modified
in such a way to allow the original mii command and miiphy
infrastructure to work as before, but also to support a new set of APIs
which allow (among other things) sharing of PHY driver code and 10G support
The mii command will continue to support normal PHY management functions
(Clause 22 of 802.3), but will not be changed to support 10G
(Clause 45).
The basic design is similar to PHY Lib from Linux, but simplified for
U-Boot's network and driver infrastructure.
We now have MDIO drivers and PHY drivers
An MDIO driver provides:
read
write
reset
A PHY driver provides:
(optionally): probe
config - initial setup, starting of auto-negotiation
startup - waiting for AN, and reading link state
shutdown - any cleanup needed
The ethernet drivers interact with the PHY Lib using these functions:
phy_connect()
phy_config()
phy_startup()
phy_shutdown()
Each PHY driver can be configured separately, or all at once using
config_phylib_all_drivers.h (added in the patch which adds the drivers)
We also provide generic drivers for Clause 22 (10/100/1000), and
Clause 45 (10G) PHYs.
We also implement phy_reset(), and call it in phy_connect(). Because
phy_reset() is essentially the same as miiphy_reset, but:
a) must support 10G PHYs, and
b) should use the phylib primitives,
we implement miiphy_reset, using phy_reset(), but only when
CONFIG_PHYLIB is set. Otherwise, we just use the old version. In this
way, we save on compile size, even if we don't manage to save code size.
Pulled ethtool.h and mdio.h from:
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
782d640afd15af7a1faf01cfe566ca4ac511319d
With many, many deletions so as to enable compilation under u-boot
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-04-08 07:10:27 +00:00
|
|
|
struct mii_dev *mdio_get_current_dev(void);
|
|
|
|
struct mii_dev *miiphy_get_dev_by_name(const char *devname);
|
|
|
|
struct phy_device *mdio_phydev_for_ethname(const char *devname);
|
2005-10-28 20:30:33 +00:00
|
|
|
|
2011-04-07 19:38:35 +00:00
|
|
|
void miiphy_listdev(void);
|
2005-10-28 20:30:33 +00:00
|
|
|
|
Create PHY Lib for U-Boot
Extends the mii_dev structure to participate in a full-blown MDIO and
PHY driver scheme. The mii_dev structure and miiphy calls are modified
in such a way to allow the original mii command and miiphy
infrastructure to work as before, but also to support a new set of APIs
which allow (among other things) sharing of PHY driver code and 10G support
The mii command will continue to support normal PHY management functions
(Clause 22 of 802.3), but will not be changed to support 10G
(Clause 45).
The basic design is similar to PHY Lib from Linux, but simplified for
U-Boot's network and driver infrastructure.
We now have MDIO drivers and PHY drivers
An MDIO driver provides:
read
write
reset
A PHY driver provides:
(optionally): probe
config - initial setup, starting of auto-negotiation
startup - waiting for AN, and reading link state
shutdown - any cleanup needed
The ethernet drivers interact with the PHY Lib using these functions:
phy_connect()
phy_config()
phy_startup()
phy_shutdown()
Each PHY driver can be configured separately, or all at once using
config_phylib_all_drivers.h (added in the patch which adds the drivers)
We also provide generic drivers for Clause 22 (10/100/1000), and
Clause 45 (10G) PHYs.
We also implement phy_reset(), and call it in phy_connect(). Because
phy_reset() is essentially the same as miiphy_reset, but:
a) must support 10G PHYs, and
b) should use the phylib primitives,
we implement miiphy_reset, using phy_reset(), but only when
CONFIG_PHYLIB is set. Otherwise, we just use the old version. In this
way, we save on compile size, even if we don't manage to save code size.
Pulled ethtool.h and mdio.h from:
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
782d640afd15af7a1faf01cfe566ca4ac511319d
With many, many deletions so as to enable compilation under u-boot
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-04-08 07:10:27 +00:00
|
|
|
struct mii_dev *mdio_alloc(void);
|
2015-10-08 04:32:37 +00:00
|
|
|
void mdio_free(struct mii_dev *bus);
|
Create PHY Lib for U-Boot
Extends the mii_dev structure to participate in a full-blown MDIO and
PHY driver scheme. The mii_dev structure and miiphy calls are modified
in such a way to allow the original mii command and miiphy
infrastructure to work as before, but also to support a new set of APIs
which allow (among other things) sharing of PHY driver code and 10G support
The mii command will continue to support normal PHY management functions
(Clause 22 of 802.3), but will not be changed to support 10G
(Clause 45).
The basic design is similar to PHY Lib from Linux, but simplified for
U-Boot's network and driver infrastructure.
We now have MDIO drivers and PHY drivers
An MDIO driver provides:
read
write
reset
A PHY driver provides:
(optionally): probe
config - initial setup, starting of auto-negotiation
startup - waiting for AN, and reading link state
shutdown - any cleanup needed
The ethernet drivers interact with the PHY Lib using these functions:
phy_connect()
phy_config()
phy_startup()
phy_shutdown()
Each PHY driver can be configured separately, or all at once using
config_phylib_all_drivers.h (added in the patch which adds the drivers)
We also provide generic drivers for Clause 22 (10/100/1000), and
Clause 45 (10G) PHYs.
We also implement phy_reset(), and call it in phy_connect(). Because
phy_reset() is essentially the same as miiphy_reset, but:
a) must support 10G PHYs, and
b) should use the phylib primitives,
we implement miiphy_reset, using phy_reset(), but only when
CONFIG_PHYLIB is set. Otherwise, we just use the old version. In this
way, we save on compile size, even if we don't manage to save code size.
Pulled ethtool.h and mdio.h from:
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
782d640afd15af7a1faf01cfe566ca4ac511319d
With many, many deletions so as to enable compilation under u-boot
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-04-08 07:10:27 +00:00
|
|
|
int mdio_register(struct mii_dev *bus);
|
2016-12-08 09:06:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
2015-10-08 04:32:37 +00:00
|
|
|
int mdio_unregister(struct mii_dev *bus);
|
Create PHY Lib for U-Boot
Extends the mii_dev structure to participate in a full-blown MDIO and
PHY driver scheme. The mii_dev structure and miiphy calls are modified
in such a way to allow the original mii command and miiphy
infrastructure to work as before, but also to support a new set of APIs
which allow (among other things) sharing of PHY driver code and 10G support
The mii command will continue to support normal PHY management functions
(Clause 22 of 802.3), but will not be changed to support 10G
(Clause 45).
The basic design is similar to PHY Lib from Linux, but simplified for
U-Boot's network and driver infrastructure.
We now have MDIO drivers and PHY drivers
An MDIO driver provides:
read
write
reset
A PHY driver provides:
(optionally): probe
config - initial setup, starting of auto-negotiation
startup - waiting for AN, and reading link state
shutdown - any cleanup needed
The ethernet drivers interact with the PHY Lib using these functions:
phy_connect()
phy_config()
phy_startup()
phy_shutdown()
Each PHY driver can be configured separately, or all at once using
config_phylib_all_drivers.h (added in the patch which adds the drivers)
We also provide generic drivers for Clause 22 (10/100/1000), and
Clause 45 (10G) PHYs.
We also implement phy_reset(), and call it in phy_connect(). Because
phy_reset() is essentially the same as miiphy_reset, but:
a) must support 10G PHYs, and
b) should use the phylib primitives,
we implement miiphy_reset, using phy_reset(), but only when
CONFIG_PHYLIB is set. Otherwise, we just use the old version. In this
way, we save on compile size, even if we don't manage to save code size.
Pulled ethtool.h and mdio.h from:
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
782d640afd15af7a1faf01cfe566ca4ac511319d
With many, many deletions so as to enable compilation under u-boot
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Detlev Zundel <dzu@denx.de>
2011-04-08 07:10:27 +00:00
|
|
|
void mdio_list_devices(void);
|
|
|
|
|
Rewrite the miiphybb (Bit-banged MII bus driver) in order to support an arbitrary number of mii buses.
This feature is useful when your board uses different mii buses for different
phys and all (or a part) of these buses are implemented via bit-banging mode.
The driver requires that the following macros should be defined into the board
configuration file:
CONFIG_BITBANGMII - Enable the miiphybb driver
CONFIG_BITBANGMII_MULTI - Enable the multi bus support
If the CONFIG_BITBANGMII_MULTI is not defined, the board's config file needs
to define at least the following macros:
MII_INIT - Generic code to enable the MII bus (optional)
MDIO_DECLARE - Declaration needed to access to the MDIO pin (optional)
MDIO_ACTIVE - Activate the MDIO pin as out pin
MDIO_TRISTATE - Activate the MDIO pin as input/tristate pin
MDIO_READ - Read the MDIO pin
MDIO(v) - Write v on the MDIO pin
MDC_DECLARE - Declaration needed to access to the MDC pin (optional)
MDC(v) - Write v on the MDC pin
The previous macros make the driver compatible with the previous version
(that didn't support the multi-bus).
When the CONFIG_BITBANGMII_MULTI is also defined, the board code needs to fill
the bb_miiphy_buses[] array with a record for each required bus and declare
the bb_miiphy_buses_num variable with the number of mii buses.
The record (struct bb_miiphy_bus) has the following fields/callbacks (see
miiphy.h for details):
char name[] - The symbolic name that must be equal to the MII bus
registered name
int (*init)() - Initialization function called at startup time (just
before the Ethernet initialization)
int (*mdio_active)() - Activate the MDIO pin as output
int (*mdio_tristate)() - Activate the MDIO pin as input/tristate pin
int (*set_mdio)() - Write the MDIO pin
int (*get_mdio)() - Read the MDIO pin
int (*set_mdc)() - Write the MDC pin
int (*delay)() - Delay function
void *priv - Private data used by board specific code
The board code will look like:
struct bb_miiphy_bus bb_miiphy_buses[] = {
{ .name = miibus#1, .init = b1_init, .mdio_active = b1_mdio_active, ... },
{ .name = miibus#2, .init = b2_init, .mdio_active = b2_mdio_active, ... },
...
int bb_miiphy_buses_num = sizeof(bb_miiphy_buses) /
sizeof(bb_miiphy_buses[0]);
Signed-off-by: Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2009-10-10 10:42:20 +00:00
|
|
|
#ifdef CONFIG_BITBANGMII
|
|
|
|
|
|
|
|
#define BB_MII_DEVNAME "bb_miiphy"
|
|
|
|
|
|
|
|
struct bb_miiphy_bus {
|
2011-11-10 14:11:04 +00:00
|
|
|
char name[16];
|
Rewrite the miiphybb (Bit-banged MII bus driver) in order to support an arbitrary number of mii buses.
This feature is useful when your board uses different mii buses for different
phys and all (or a part) of these buses are implemented via bit-banging mode.
The driver requires that the following macros should be defined into the board
configuration file:
CONFIG_BITBANGMII - Enable the miiphybb driver
CONFIG_BITBANGMII_MULTI - Enable the multi bus support
If the CONFIG_BITBANGMII_MULTI is not defined, the board's config file needs
to define at least the following macros:
MII_INIT - Generic code to enable the MII bus (optional)
MDIO_DECLARE - Declaration needed to access to the MDIO pin (optional)
MDIO_ACTIVE - Activate the MDIO pin as out pin
MDIO_TRISTATE - Activate the MDIO pin as input/tristate pin
MDIO_READ - Read the MDIO pin
MDIO(v) - Write v on the MDIO pin
MDC_DECLARE - Declaration needed to access to the MDC pin (optional)
MDC(v) - Write v on the MDC pin
The previous macros make the driver compatible with the previous version
(that didn't support the multi-bus).
When the CONFIG_BITBANGMII_MULTI is also defined, the board code needs to fill
the bb_miiphy_buses[] array with a record for each required bus and declare
the bb_miiphy_buses_num variable with the number of mii buses.
The record (struct bb_miiphy_bus) has the following fields/callbacks (see
miiphy.h for details):
char name[] - The symbolic name that must be equal to the MII bus
registered name
int (*init)() - Initialization function called at startup time (just
before the Ethernet initialization)
int (*mdio_active)() - Activate the MDIO pin as output
int (*mdio_tristate)() - Activate the MDIO pin as input/tristate pin
int (*set_mdio)() - Write the MDIO pin
int (*get_mdio)() - Read the MDIO pin
int (*set_mdc)() - Write the MDC pin
int (*delay)() - Delay function
void *priv - Private data used by board specific code
The board code will look like:
struct bb_miiphy_bus bb_miiphy_buses[] = {
{ .name = miibus#1, .init = b1_init, .mdio_active = b1_mdio_active, ... },
{ .name = miibus#2, .init = b2_init, .mdio_active = b2_mdio_active, ... },
...
int bb_miiphy_buses_num = sizeof(bb_miiphy_buses) /
sizeof(bb_miiphy_buses[0]);
Signed-off-by: Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2009-10-10 10:42:20 +00:00
|
|
|
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;
|
2005-10-28 20:30:33 +00:00
|
|
|
|
2011-04-07 19:38:35 +00:00
|
|
|
void bb_miiphy_init(void);
|
2016-08-08 16:28:39 +00:00
|
|
|
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);
|
Rewrite the miiphybb (Bit-banged MII bus driver) in order to support an arbitrary number of mii buses.
This feature is useful when your board uses different mii buses for different
phys and all (or a part) of these buses are implemented via bit-banging mode.
The driver requires that the following macros should be defined into the board
configuration file:
CONFIG_BITBANGMII - Enable the miiphybb driver
CONFIG_BITBANGMII_MULTI - Enable the multi bus support
If the CONFIG_BITBANGMII_MULTI is not defined, the board's config file needs
to define at least the following macros:
MII_INIT - Generic code to enable the MII bus (optional)
MDIO_DECLARE - Declaration needed to access to the MDIO pin (optional)
MDIO_ACTIVE - Activate the MDIO pin as out pin
MDIO_TRISTATE - Activate the MDIO pin as input/tristate pin
MDIO_READ - Read the MDIO pin
MDIO(v) - Write v on the MDIO pin
MDC_DECLARE - Declaration needed to access to the MDC pin (optional)
MDC(v) - Write v on the MDC pin
The previous macros make the driver compatible with the previous version
(that didn't support the multi-bus).
When the CONFIG_BITBANGMII_MULTI is also defined, the board code needs to fill
the bb_miiphy_buses[] array with a record for each required bus and declare
the bb_miiphy_buses_num variable with the number of mii buses.
The record (struct bb_miiphy_bus) has the following fields/callbacks (see
miiphy.h for details):
char name[] - The symbolic name that must be equal to the MII bus
registered name
int (*init)() - Initialization function called at startup time (just
before the Ethernet initialization)
int (*mdio_active)() - Activate the MDIO pin as output
int (*mdio_tristate)() - Activate the MDIO pin as input/tristate pin
int (*set_mdio)() - Write the MDIO pin
int (*get_mdio)() - Read the MDIO pin
int (*set_mdc)() - Write the MDC pin
int (*delay)() - Delay function
void *priv - Private data used by board specific code
The board code will look like:
struct bb_miiphy_bus bb_miiphy_buses[] = {
{ .name = miibus#1, .init = b1_init, .mdio_active = b1_mdio_active, ... },
{ .name = miibus#2, .init = b2_init, .mdio_active = b2_mdio_active, ... },
...
int bb_miiphy_buses_num = sizeof(bb_miiphy_buses) /
sizeof(bb_miiphy_buses[0]);
Signed-off-by: Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
2009-10-10 10:42:20 +00:00
|
|
|
#endif
|
2001-10-08 19:18:17 +00:00
|
|
|
|
|
|
|
/* phy seed setup */
|
2003-09-18 10:45:21 +00:00
|
|
|
#define AUTO 99
|
2007-10-31 16:21:29 +00:00
|
|
|
#define _1000BASET 1000
|
2003-09-18 10:45:21 +00:00
|
|
|
#define _100BASET 100
|
|
|
|
#define _10BASET 10
|
|
|
|
#define HALF 22
|
|
|
|
#define FULL 44
|
2001-10-08 19:18:17 +00:00
|
|
|
|
|
|
|
/* phy register offsets */
|
2010-12-23 20:40:12 +00:00
|
|
|
#define MII_MIPSCR 0x11
|
|
|
|
|
|
|
|
/* MII_LPA */
|
2007-10-31 16:21:29 +00:00
|
|
|
#define PHY_ANLPAR_PSB_802_3 0x0001
|
|
|
|
#define PHY_ANLPAR_PSB_802_9 0x0002
|
|
|
|
|
2010-12-23 20:40:12 +00:00
|
|
|
/* MII_CTRL1000 masks */
|
2007-11-01 13:46:50 +00:00
|
|
|
#define PHY_1000BTCR_1000FD 0x0200
|
|
|
|
#define PHY_1000BTCR_1000HD 0x0100
|
|
|
|
|
2010-12-23 20:40:12 +00:00
|
|
|
/* MII_STAT1000 masks */
|
2007-10-31 16:21:29 +00:00
|
|
|
#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
|
2004-03-14 18:23:55 +00:00
|
|
|
|
2007-11-01 13:46:50 +00:00
|
|
|
/* phy EXSR */
|
2010-12-23 20:40:12 +00:00
|
|
|
#define ESTATUS_1000XF 0x8000
|
|
|
|
#define ESTATUS_1000XH 0x4000
|
2007-11-01 13:46:50 +00:00
|
|
|
|
2001-10-08 19:18:17 +00:00
|
|
|
#endif
|