diff options
author | Vitaly Bordug <vbordug@ru.mvista.com> | 2006-08-15 02:00:29 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-08-19 17:44:31 -0400 |
commit | 11b0bacd717c285c94dbb56505a28434b34f0639 (patch) | |
tree | d98e1576210a258d3b412809dfe0177f028575be /drivers/net/phy/phy_device.c | |
parent | ec42cdb624059bb9d9d1accca5ed4345bf8f5fda (diff) |
[PATCH] PAL: Support of the fixed PHY
This makes it possible for HW PHY-less boards to utilize PAL goodies. Generic
routines to connect to fixed PHY are provided, as well as ability to specify
software callback that fills up link, speed, etc. information into PHY
descriptor (the latter feature not tested so far).
Signed-off-by: Vitaly Bordug <vbordug@ru.mvista.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/phy/phy_device.c')
-rw-r--r-- | drivers/net/phy/phy_device.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 1bc1e032c5d6..2d1ecfdc80db 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
@@ -45,6 +45,35 @@ static struct phy_driver genphy_driver; | |||
45 | extern int mdio_bus_init(void); | 45 | extern int mdio_bus_init(void); |
46 | extern void mdio_bus_exit(void); | 46 | extern void mdio_bus_exit(void); |
47 | 47 | ||
48 | struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) | ||
49 | { | ||
50 | struct phy_device *dev; | ||
51 | /* We allocate the device, and initialize the | ||
52 | * default values */ | ||
53 | dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); | ||
54 | |||
55 | if (NULL == dev) | ||
56 | return (struct phy_device*) PTR_ERR((void*)-ENOMEM); | ||
57 | |||
58 | dev->speed = 0; | ||
59 | dev->duplex = -1; | ||
60 | dev->pause = dev->asym_pause = 0; | ||
61 | dev->link = 1; | ||
62 | |||
63 | dev->autoneg = AUTONEG_ENABLE; | ||
64 | |||
65 | dev->addr = addr; | ||
66 | dev->phy_id = phy_id; | ||
67 | dev->bus = bus; | ||
68 | |||
69 | dev->state = PHY_DOWN; | ||
70 | |||
71 | spin_lock_init(&dev->lock); | ||
72 | |||
73 | return dev; | ||
74 | } | ||
75 | EXPORT_SYMBOL(phy_device_create); | ||
76 | |||
48 | /* get_phy_device | 77 | /* get_phy_device |
49 | * | 78 | * |
50 | * description: Reads the ID registers of the PHY at addr on the | 79 | * description: Reads the ID registers of the PHY at addr on the |
@@ -78,27 +107,7 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr) | |||
78 | if (0xffffffff == phy_id) | 107 | if (0xffffffff == phy_id) |
79 | return NULL; | 108 | return NULL; |
80 | 109 | ||
81 | /* Otherwise, we allocate the device, and initialize the | 110 | dev = phy_device_create(bus, addr, phy_id); |
82 | * default values */ | ||
83 | dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); | ||
84 | |||
85 | if (NULL == dev) | ||
86 | return ERR_PTR(-ENOMEM); | ||
87 | |||
88 | dev->speed = 0; | ||
89 | dev->duplex = -1; | ||
90 | dev->pause = dev->asym_pause = 0; | ||
91 | dev->link = 1; | ||
92 | |||
93 | dev->autoneg = AUTONEG_ENABLE; | ||
94 | |||
95 | dev->addr = addr; | ||
96 | dev->phy_id = phy_id; | ||
97 | dev->bus = bus; | ||
98 | |||
99 | dev->state = PHY_DOWN; | ||
100 | |||
101 | spin_lock_init(&dev->lock); | ||
102 | 111 | ||
103 | return dev; | 112 | return dev; |
104 | } | 113 | } |