2 * Software PHY emulation
4 * Code taken from fixed_phy.c by Russell King <rmk+kernel@arm.linux.org.uk>
6 * Author: Vitaly Bordug <vbordug@ru.mvista.com>
7 * Anton Vorontsov <avorontsov@ru.mvista.com>
9 * Copyright (c) 2006-2007 MontaVista Software, Inc.
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
16 #include <linux/export.h>
17 #include <linux/mii.h>
18 #include <linux/phy.h>
19 #include <linux/phy_fixed.h>
24 * swphy_update_regs - update MII register array with fixed phy state
25 * @regs: array of 32 registers to update
26 * @state: fixed phy status
28 * Update the array of MII registers with the fixed phy link, speed,
29 * duplex and pause mode settings.
31 int swphy_update_regs(u16 *regs, const struct fixed_phy_status *state)
33 u16 bmsr = BMSR_ANEGCAPABLE;
39 switch (state->speed) {
53 switch (state->speed) {
69 bmsr |= BMSR_LSTATUS | BMSR_ANEGCOMPLETE;
72 bmcr |= BMCR_FULLDPLX;
74 switch (state->speed) {
76 bmcr |= BMCR_SPEED1000;
77 lpagb |= LPA_1000FULL;
80 bmcr |= BMCR_SPEED100;
87 pr_warn("swphy: unknown speed\n");
91 switch (state->speed) {
93 bmcr |= BMCR_SPEED1000;
94 lpagb |= LPA_1000HALF;
97 bmcr |= BMCR_SPEED100;
104 pr_warn("swphy: unknown speed\n");
110 lpa |= LPA_PAUSE_CAP;
112 if (state->asym_pause)
113 lpa |= LPA_PAUSE_ASYM;
116 regs[MII_PHYSID1] = 0;
117 regs[MII_PHYSID2] = 0;
119 regs[MII_BMSR] = bmsr;
120 regs[MII_BMCR] = bmcr;
122 regs[MII_STAT1000] = lpagb;
126 EXPORT_SYMBOL_GPL(swphy_update_regs);