Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 2 | /* |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 3 | * (C) Copyright 2009 Industrie Dial Face S.p.A. |
| 4 | * Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com> |
| 5 | * |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 6 | * (C) Copyright 2001 |
| 7 | * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com. |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | /* |
| 11 | * This provides a bit-banged interface to the ethernet MII management |
| 12 | * channel. |
| 13 | */ |
| 14 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 15 | #include <ioports.h> |
| 16 | #include <ppc_asm.tmpl> |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 17 | #include <miiphy.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 18 | #include <asm/global_data.h> |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 19 | |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 20 | #ifndef CONFIG_BITBANGMII_MULTI |
| 21 | |
| 22 | /* |
| 23 | * If CONFIG_BITBANGMII_MULTI is not defined we use a |
| 24 | * compatibility layer with the previous miiphybb implementation |
| 25 | * based on macros usage. |
| 26 | * |
| 27 | */ |
| 28 | static int bb_mii_init_wrap(struct bb_miiphy_bus *bus) |
| 29 | { |
| 30 | #ifdef MII_INIT |
| 31 | MII_INIT; |
| 32 | #endif |
| 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | static int bb_mdio_active_wrap(struct bb_miiphy_bus *bus) |
| 37 | { |
| 38 | #ifdef MDIO_DECLARE |
| 39 | MDIO_DECLARE; |
| 40 | #endif |
| 41 | MDIO_ACTIVE; |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | static int bb_mdio_tristate_wrap(struct bb_miiphy_bus *bus) |
| 46 | { |
| 47 | #ifdef MDIO_DECLARE |
| 48 | MDIO_DECLARE; |
| 49 | #endif |
| 50 | MDIO_TRISTATE; |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | static int bb_set_mdio_wrap(struct bb_miiphy_bus *bus, int v) |
| 55 | { |
| 56 | #ifdef MDIO_DECLARE |
| 57 | MDIO_DECLARE; |
| 58 | #endif |
| 59 | MDIO(v); |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | static int bb_get_mdio_wrap(struct bb_miiphy_bus *bus, int *v) |
| 64 | { |
| 65 | #ifdef MDIO_DECLARE |
| 66 | MDIO_DECLARE; |
| 67 | #endif |
| 68 | *v = MDIO_READ; |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | static int bb_set_mdc_wrap(struct bb_miiphy_bus *bus, int v) |
| 73 | { |
| 74 | #ifdef MDC_DECLARE |
| 75 | MDC_DECLARE; |
| 76 | #endif |
| 77 | MDC(v); |
| 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | static int bb_delay_wrap(struct bb_miiphy_bus *bus) |
| 82 | { |
| 83 | MIIDELAY; |
| 84 | return 0; |
| 85 | } |
| 86 | |
| 87 | struct bb_miiphy_bus bb_miiphy_buses[] = { |
| 88 | { |
| 89 | .name = BB_MII_DEVNAME, |
| 90 | .init = bb_mii_init_wrap, |
| 91 | .mdio_active = bb_mdio_active_wrap, |
| 92 | .mdio_tristate = bb_mdio_tristate_wrap, |
| 93 | .set_mdio = bb_set_mdio_wrap, |
| 94 | .get_mdio = bb_get_mdio_wrap, |
| 95 | .set_mdc = bb_set_mdc_wrap, |
| 96 | .delay = bb_delay_wrap, |
| 97 | } |
| 98 | }; |
| 99 | |
| 100 | int bb_miiphy_buses_num = sizeof(bb_miiphy_buses) / |
Wolfgang Denk | d61fbcc | 2009-10-28 00:49:47 +0100 | [diff] [blame] | 101 | sizeof(bb_miiphy_buses[0]); |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 102 | #endif |
| 103 | |
Ovidiu Panait | 69d1ddb | 2020-11-28 10:43:17 +0200 | [diff] [blame] | 104 | int bb_miiphy_init(void) |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 105 | { |
| 106 | int i; |
| 107 | |
Marek Vasut | ab7c4be | 2023-09-06 23:30:08 +0200 | [diff] [blame] | 108 | for (i = 0; i < bb_miiphy_buses_num; i++) |
| 109 | if (bb_miiphy_buses[i].init != NULL) |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 110 | bb_miiphy_buses[i].init(&bb_miiphy_buses[i]); |
Ovidiu Panait | 69d1ddb | 2020-11-28 10:43:17 +0200 | [diff] [blame] | 111 | |
| 112 | return 0; |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 113 | } |
| 114 | |
Ben Warren | 97824d6 | 2010-07-29 12:56:11 -0700 | [diff] [blame] | 115 | static inline struct bb_miiphy_bus *bb_miiphy_getbus(const char *devname) |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 116 | { |
| 117 | #ifdef CONFIG_BITBANGMII_MULTI |
| 118 | int i; |
| 119 | |
| 120 | /* Search the correct bus */ |
| 121 | for (i = 0; i < bb_miiphy_buses_num; i++) { |
| 122 | if (!strcmp(bb_miiphy_buses[i].name, devname)) { |
| 123 | return &bb_miiphy_buses[i]; |
| 124 | } |
| 125 | } |
| 126 | return NULL; |
| 127 | #else |
| 128 | /* We have just one bitbanging bus */ |
| 129 | return &bb_miiphy_buses[0]; |
| 130 | #endif |
| 131 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 132 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 133 | /***************************************************************************** |
| 134 | * |
| 135 | * Utility to send the preamble, address, and register (common to read |
| 136 | * and write). |
| 137 | */ |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 138 | static void miiphy_pre(struct bb_miiphy_bus *bus, char read, |
Wolfgang Denk | d61fbcc | 2009-10-28 00:49:47 +0100 | [diff] [blame] | 139 | unsigned char addr, unsigned char reg) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 140 | { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 141 | int j; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 142 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 143 | /* |
| 144 | * Send a 32 bit preamble ('1's) with an extra '1' bit for good measure. |
| 145 | * The IEEE spec says this is a PHY optional requirement. The AMD |
| 146 | * 79C874 requires one after power up and one after a MII communications |
| 147 | * error. This means that we are doing more preambles than we need, |
| 148 | * but it is safer and will be much more robust. |
| 149 | */ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 150 | |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 151 | bus->mdio_active(bus); |
| 152 | bus->set_mdio(bus, 1); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 153 | for (j = 0; j < 32; j++) { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 154 | bus->set_mdc(bus, 0); |
| 155 | bus->delay(bus); |
| 156 | bus->set_mdc(bus, 1); |
| 157 | bus->delay(bus); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 158 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 159 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 160 | /* send the start bit (01) and the read opcode (10) or write (10) */ |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 161 | bus->set_mdc(bus, 0); |
| 162 | bus->set_mdio(bus, 0); |
| 163 | bus->delay(bus); |
| 164 | bus->set_mdc(bus, 1); |
| 165 | bus->delay(bus); |
| 166 | bus->set_mdc(bus, 0); |
| 167 | bus->set_mdio(bus, 1); |
| 168 | bus->delay(bus); |
| 169 | bus->set_mdc(bus, 1); |
| 170 | bus->delay(bus); |
| 171 | bus->set_mdc(bus, 0); |
| 172 | bus->set_mdio(bus, read); |
| 173 | bus->delay(bus); |
| 174 | bus->set_mdc(bus, 1); |
| 175 | bus->delay(bus); |
| 176 | bus->set_mdc(bus, 0); |
| 177 | bus->set_mdio(bus, !read); |
| 178 | bus->delay(bus); |
| 179 | bus->set_mdc(bus, 1); |
| 180 | bus->delay(bus); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 181 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 182 | /* send the PHY address */ |
| 183 | for (j = 0; j < 5; j++) { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 184 | bus->set_mdc(bus, 0); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 185 | if ((addr & 0x10) == 0) { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 186 | bus->set_mdio(bus, 0); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 187 | } else { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 188 | bus->set_mdio(bus, 1); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 189 | } |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 190 | bus->delay(bus); |
| 191 | bus->set_mdc(bus, 1); |
| 192 | bus->delay(bus); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 193 | addr <<= 1; |
| 194 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 195 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 196 | /* send the register address */ |
| 197 | for (j = 0; j < 5; j++) { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 198 | bus->set_mdc(bus, 0); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 199 | if ((reg & 0x10) == 0) { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 200 | bus->set_mdio(bus, 0); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 201 | } else { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 202 | bus->set_mdio(bus, 1); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 203 | } |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 204 | bus->delay(bus); |
| 205 | bus->set_mdc(bus, 1); |
| 206 | bus->delay(bus); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 207 | reg <<= 1; |
| 208 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 209 | } |
| 210 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 211 | /***************************************************************************** |
| 212 | * |
| 213 | * Read a MII PHY register. |
| 214 | * |
| 215 | * Returns: |
| 216 | * 0 on success |
| 217 | */ |
Joe Hershberger | 0c33319 | 2016-08-08 11:28:39 -0500 | [diff] [blame] | 218 | int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 219 | { |
Chris Brandt | 7e4d4d1 | 2017-11-03 08:30:13 -0500 | [diff] [blame] | 220 | unsigned short rdreg; /* register working value */ |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 221 | int v; |
| 222 | int j; /* counter */ |
| 223 | struct bb_miiphy_bus *bus; |
| 224 | |
Joe Hershberger | 0c33319 | 2016-08-08 11:28:39 -0500 | [diff] [blame] | 225 | bus = bb_miiphy_getbus(miidev->name); |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 226 | if (bus == NULL) { |
| 227 | return -1; |
| 228 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 229 | |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 230 | miiphy_pre (bus, 1, addr, reg); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 231 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 232 | /* tri-state our MDIO I/O pin so we can read */ |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 233 | bus->set_mdc(bus, 0); |
| 234 | bus->mdio_tristate(bus); |
| 235 | bus->delay(bus); |
| 236 | bus->set_mdc(bus, 1); |
| 237 | bus->delay(bus); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 238 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 239 | /* check the turnaround bit: the PHY should be driving it to zero */ |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 240 | bus->get_mdio(bus, &v); |
| 241 | if (v != 0) { |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 242 | /* puts ("PHY didn't drive TA low\n"); */ |
| 243 | for (j = 0; j < 32; j++) { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 244 | bus->set_mdc(bus, 0); |
| 245 | bus->delay(bus); |
| 246 | bus->set_mdc(bus, 1); |
| 247 | bus->delay(bus); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 248 | } |
Joe Hershberger | 0c33319 | 2016-08-08 11:28:39 -0500 | [diff] [blame] | 249 | /* There is no PHY, return */ |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 250 | return -1; |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 251 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 252 | |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 253 | bus->set_mdc(bus, 0); |
| 254 | bus->delay(bus); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 255 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 256 | /* read 16 bits of register data, MSB first */ |
| 257 | rdreg = 0; |
| 258 | for (j = 0; j < 16; j++) { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 259 | bus->set_mdc(bus, 1); |
| 260 | bus->delay(bus); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 261 | rdreg <<= 1; |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 262 | bus->get_mdio(bus, &v); |
| 263 | rdreg |= (v & 0x1); |
| 264 | bus->set_mdc(bus, 0); |
| 265 | bus->delay(bus); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 266 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 267 | |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 268 | bus->set_mdc(bus, 1); |
| 269 | bus->delay(bus); |
| 270 | bus->set_mdc(bus, 0); |
| 271 | bus->delay(bus); |
| 272 | bus->set_mdc(bus, 1); |
| 273 | bus->delay(bus); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 274 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 275 | #ifdef DEBUG |
Joe Hershberger | 0c33319 | 2016-08-08 11:28:39 -0500 | [diff] [blame] | 276 | printf("miiphy_read(0x%x) @ 0x%x = 0x%04x\n", reg, addr, rdreg); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 277 | #endif |
| 278 | |
Joe Hershberger | 0c33319 | 2016-08-08 11:28:39 -0500 | [diff] [blame] | 279 | return rdreg; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | |
| 283 | /***************************************************************************** |
| 284 | * |
| 285 | * Write a MII PHY register. |
| 286 | * |
| 287 | * Returns: |
| 288 | * 0 on success |
| 289 | */ |
Joe Hershberger | 0c33319 | 2016-08-08 11:28:39 -0500 | [diff] [blame] | 290 | int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, |
| 291 | u16 value) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 292 | { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 293 | struct bb_miiphy_bus *bus; |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 294 | int j; /* counter */ |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 295 | |
Joe Hershberger | 0c33319 | 2016-08-08 11:28:39 -0500 | [diff] [blame] | 296 | bus = bb_miiphy_getbus(miidev->name); |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 297 | if (bus == NULL) { |
| 298 | /* Bus not found! */ |
| 299 | return -1; |
| 300 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 301 | |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 302 | miiphy_pre (bus, 0, addr, reg); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 303 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 304 | /* send the turnaround (10) */ |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 305 | bus->set_mdc(bus, 0); |
| 306 | bus->set_mdio(bus, 1); |
| 307 | bus->delay(bus); |
| 308 | bus->set_mdc(bus, 1); |
| 309 | bus->delay(bus); |
| 310 | bus->set_mdc(bus, 0); |
| 311 | bus->set_mdio(bus, 0); |
| 312 | bus->delay(bus); |
| 313 | bus->set_mdc(bus, 1); |
| 314 | bus->delay(bus); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 315 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 316 | /* write 16 bits of register data, MSB first */ |
| 317 | for (j = 0; j < 16; j++) { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 318 | bus->set_mdc(bus, 0); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 319 | if ((value & 0x00008000) == 0) { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 320 | bus->set_mdio(bus, 0); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 321 | } else { |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 322 | bus->set_mdio(bus, 1); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 323 | } |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 324 | bus->delay(bus); |
| 325 | bus->set_mdc(bus, 1); |
| 326 | bus->delay(bus); |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 327 | value <<= 1; |
| 328 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 329 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 330 | /* |
| 331 | * Tri-state the MDIO line. |
| 332 | */ |
Luigi 'Comio' Mantellini | 466827e | 2009-10-10 12:42:20 +0200 | [diff] [blame] | 333 | bus->mdio_tristate(bus); |
| 334 | bus->set_mdc(bus, 0); |
| 335 | bus->delay(bus); |
| 336 | bus->set_mdc(bus, 1); |
| 337 | bus->delay(bus); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 338 | |
Wolfgang Denk | 7b4e347 | 2005-08-13 02:04:37 +0200 | [diff] [blame] | 339 | return 0; |
Wolfgang Denk | 9235e0c | 2009-10-25 23:00:09 +0100 | [diff] [blame] | 340 | } |