3 * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 static int io_bb_mii_init(struct bb_miiphy_bus *bus)
34 static int io_bb_mdio_active(struct bb_miiphy_bus *bus)
36 out_be32((void *)GPIO0_TCR,
37 in_be32((void *)GPIO0_TCR) | CONFIG_SYS_MDIO_PIN);
42 static int io_bb_mdio_tristate(struct bb_miiphy_bus *bus)
44 out_be32((void *)GPIO0_TCR,
45 in_be32((void *)GPIO0_TCR) & ~CONFIG_SYS_MDIO_PIN);
50 static int io_bb_set_mdio(struct bb_miiphy_bus *bus, int v)
53 out_be32((void *)GPIO0_OR,
54 in_be32((void *)GPIO0_OR) | CONFIG_SYS_MDIO_PIN);
56 out_be32((void *)GPIO0_OR,
57 in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_MDIO_PIN);
62 static int io_bb_get_mdio(struct bb_miiphy_bus *bus, int *v)
64 *v = ((in_be32((void *)GPIO0_IR) & CONFIG_SYS_MDIO_PIN) != 0);
69 static int io_bb_set_mdc(struct bb_miiphy_bus *bus, int v)
72 out_be32((void *)GPIO0_OR,
73 in_be32((void *)GPIO0_OR) | CONFIG_SYS_MDC_PIN);
75 out_be32((void *)GPIO0_OR,
76 in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_MDC_PIN);
81 static int io_bb_delay(struct bb_miiphy_bus *bus)
88 struct bb_miiphy_bus bb_miiphy_buses[] = {
90 .name = CONFIG_SYS_GBIT_MII_BUSNAME,
91 .init = io_bb_mii_init,
92 .mdio_active = io_bb_mdio_active,
93 .mdio_tristate = io_bb_mdio_tristate,
94 .set_mdio = io_bb_set_mdio,
95 .get_mdio = io_bb_get_mdio,
96 .set_mdc = io_bb_set_mdc,
101 int bb_miiphy_buses_num = sizeof(bb_miiphy_buses) /
102 sizeof(bb_miiphy_buses[0]);