diff options
author | Kapil Juneja <Kapil.Juneja@freescale.com> | 2007-05-11 19:25:11 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-08 22:16:38 -0400 |
commit | d3c12873c36005263286cf5660663c8c10f9d2b5 (patch) | |
tree | 8b51ae1aec834ece23271e6b569d7c4189422ad5 /drivers/net/gianfar_mii.c | |
parent | 0cefeebaf3da39d768bffcf62460fe2088e824ef (diff) |
gianfar: add support for SGMII
Add code for initialising and configuring TBI interface and
programming it for connecting to on-chip SERDES (Lynx PHY)
in case of SGMII mode selected through HRCW at reset.
also add defines for TBI register configuration. TBI
interface is programmed towards the SERDES.
refactored mdio read/write functions to differentiate
programming local interface MII regs (e.g., for TBI) from
always programming the mdio master (TSEC1, for programming
the PHYs).
Signed-off-by: Kapil Juneja <Kapil.Juneja@freescale.com>
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/gianfar_mii.c')
-rw-r--r-- | drivers/net/gianfar_mii.c | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c index bcc6b82f4a33..5dd34a1a7b89 100644 --- a/drivers/net/gianfar_mii.c +++ b/drivers/net/gianfar_mii.c | |||
@@ -43,13 +43,18 @@ | |||
43 | #include "gianfar.h" | 43 | #include "gianfar.h" |
44 | #include "gianfar_mii.h" | 44 | #include "gianfar_mii.h" |
45 | 45 | ||
46 | /* Write value to the PHY at mii_id at register regnum, | 46 | /* |
47 | * on the bus, waiting until the write is done before returning. | 47 | * Write value to the PHY at mii_id at register regnum, |
48 | * All PHY configuration is done through the TSEC1 MIIM regs */ | 48 | * on the bus attached to the local interface, which may be different from the |
49 | int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value) | 49 | * generic mdio bus (tied to a single interface), waiting until the write is |
50 | * done before returning. This is helpful in programming interfaces like | ||
51 | * the TBI which control interfaces like onchip SERDES and are always tied to | ||
52 | * the local mdio pins, which may not be the same as system mdio bus, used for | ||
53 | * controlling the external PHYs, for example. | ||
54 | */ | ||
55 | int gfar_local_mdio_write(struct gfar_mii *regs, int mii_id, | ||
56 | int regnum, u16 value) | ||
50 | { | 57 | { |
51 | struct gfar_mii __iomem *regs = (void __iomem *)bus->priv; | ||
52 | |||
53 | /* Set the PHY address and the register address we want to write */ | 58 | /* Set the PHY address and the register address we want to write */ |
54 | gfar_write(®s->miimadd, (mii_id << 8) | regnum); | 59 | gfar_write(®s->miimadd, (mii_id << 8) | regnum); |
55 | 60 | ||
@@ -63,12 +68,19 @@ int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value) | |||
63 | return 0; | 68 | return 0; |
64 | } | 69 | } |
65 | 70 | ||
66 | /* Read the bus for PHY at addr mii_id, register regnum, and | 71 | /* |
67 | * return the value. Clears miimcom first. All PHY | 72 | * Read the bus for PHY at addr mii_id, register regnum, and |
68 | * configuration has to be done through the TSEC1 MIIM regs */ | 73 | * return the value. Clears miimcom first. All PHY operation |
69 | int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum) | 74 | * done on the bus attached to the local interface, |
75 | * which may be different from the generic mdio bus | ||
76 | * This is helpful in programming interfaces like | ||
77 | * the TBI which, inturn, control interfaces like onchip SERDES | ||
78 | * and are always tied to the local mdio pins, which may not be the | ||
79 | * same as system mdio bus, used for controlling the external PHYs, for eg. | ||
80 | */ | ||
81 | int gfar_local_mdio_read(struct gfar_mii *regs, int mii_id, int regnum) | ||
82 | |||
70 | { | 83 | { |
71 | struct gfar_mii __iomem *regs = (void __iomem *)bus->priv; | ||
72 | u16 value; | 84 | u16 value; |
73 | 85 | ||
74 | /* Set the PHY address and the register address we want to read */ | 86 | /* Set the PHY address and the register address we want to read */ |
@@ -88,6 +100,27 @@ int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum) | |||
88 | return value; | 100 | return value; |
89 | } | 101 | } |
90 | 102 | ||
103 | /* Write value to the PHY at mii_id at register regnum, | ||
104 | * on the bus, waiting until the write is done before returning. | ||
105 | * All PHY configuration is done through the TSEC1 MIIM regs */ | ||
106 | int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value) | ||
107 | { | ||
108 | struct gfar_mii __iomem *regs = (void __iomem *)bus->priv; | ||
109 | |||
110 | /* Write to the local MII regs */ | ||
111 | return(gfar_local_mdio_write(regs, mii_id, regnum, value)); | ||
112 | } | ||
113 | |||
114 | /* Read the bus for PHY at addr mii_id, register regnum, and | ||
115 | * return the value. Clears miimcom first. All PHY | ||
116 | * configuration has to be done through the TSEC1 MIIM regs */ | ||
117 | int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum) | ||
118 | { | ||
119 | struct gfar_mii __iomem *regs = (void __iomem *)bus->priv; | ||
120 | |||
121 | /* Read the local MII regs */ | ||
122 | return(gfar_local_mdio_read(regs, mii_id, regnum)); | ||
123 | } | ||
91 | 124 | ||
92 | /* Reset the MIIM registers, and wait for the bus to free */ | 125 | /* Reset the MIIM registers, and wait for the bus to free */ |
93 | int gfar_mdio_reset(struct mii_bus *bus) | 126 | int gfar_mdio_reset(struct mii_bus *bus) |