1 | #include "rtemscompat_defs.h" |
---|
2 | #include "../porting/if_xxx_rtems.c" |
---|
3 | #include <bsp/early_enet_link_status.h> |
---|
4 | #include <bsp/if_em_pub.h> |
---|
5 | |
---|
6 | /* Provide a routine to check link status early, |
---|
7 | * i.e., before the network is really running. |
---|
8 | * In case someone wants to decide whether to use/configure |
---|
9 | * this interface at all :-) |
---|
10 | * |
---|
11 | * NOTE: this routine tries to enable autonegotiation! |
---|
12 | * |
---|
13 | * unit: unit number starting with 1 (usual BSDNET convention) |
---|
14 | * |
---|
15 | * RETURNS: Phy status register contents (1<<2 means link up). |
---|
16 | * or -1 on error. |
---|
17 | */ |
---|
18 | |
---|
19 | /* |
---|
20 | * Authorship |
---|
21 | * ---------- |
---|
22 | * This software ('beatnik' RTEMS BSP for MVME6100 and MVME5500) was |
---|
23 | * created by Till Straumann <strauman@slac.stanford.edu>, 2005-2007, |
---|
24 | * Stanford Linear Accelerator Center, Stanford University. |
---|
25 | * |
---|
26 | * Acknowledgement of sponsorship |
---|
27 | * ------------------------------ |
---|
28 | * The 'beatnik' BSP was produced by |
---|
29 | * the Stanford Linear Accelerator Center, Stanford University, |
---|
30 | * under Contract DE-AC03-76SFO0515 with the Department of Energy. |
---|
31 | * |
---|
32 | * Government disclaimer of liability |
---|
33 | * ---------------------------------- |
---|
34 | * Neither the United States nor the United States Department of Energy, |
---|
35 | * nor any of their employees, makes any warranty, express or implied, or |
---|
36 | * assumes any legal liability or responsibility for the accuracy, |
---|
37 | * completeness, or usefulness of any data, apparatus, product, or process |
---|
38 | * disclosed, or represents that its use would not infringe privately owned |
---|
39 | * rights. |
---|
40 | * |
---|
41 | * Stanford disclaimer of liability |
---|
42 | * -------------------------------- |
---|
43 | * Stanford University makes no representations or warranties, express or |
---|
44 | * implied, nor assumes any liability for the use of this software. |
---|
45 | * |
---|
46 | * Stanford disclaimer of copyright |
---|
47 | * -------------------------------- |
---|
48 | * Stanford University, owner of the copyright, hereby disclaims its |
---|
49 | * copyright and all other rights in this software. Hence, anyone may |
---|
50 | * freely use it for any purpose without restriction. |
---|
51 | * |
---|
52 | * Maintenance of notices |
---|
53 | * ---------------------- |
---|
54 | * In the interest of clarity regarding the origin and status of this |
---|
55 | * SLAC software, this and all the preceding Stanford University notices |
---|
56 | * are to remain affixed to any copy or derivative of this software made |
---|
57 | * or distributed by the recipient and are to be affixed to any copy of |
---|
58 | * software made or distributed by the recipient that contains a copy or |
---|
59 | * derivative of this software. |
---|
60 | * |
---|
61 | * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 |
---|
62 | */ |
---|
63 | |
---|
64 | static int |
---|
65 | em_early_init(int idx) |
---|
66 | { |
---|
67 | if ( idx < 0 || idx >= NETDRIVER_SLOTS ) |
---|
68 | return -1; |
---|
69 | return em_hw_early_init(&the_em_devs[idx]); |
---|
70 | } |
---|
71 | |
---|
72 | static int |
---|
73 | em_early_read_phy(int idx, unsigned reg) |
---|
74 | { |
---|
75 | unsigned short data; |
---|
76 | if ( idx < 0 || idx >= NETDRIVER_SLOTS ) |
---|
77 | return -1; |
---|
78 | /* Bizarre - I always have to read PHY_STATUS twice until a good link |
---|
79 | * status is read |
---|
80 | */ |
---|
81 | if ( em_read_phy_reg(&the_em_devs[idx].d_softc.hw, reg, &data) ) |
---|
82 | return -1; |
---|
83 | if ( PHY_STATUS == reg ) { |
---|
84 | /* read again */ |
---|
85 | if ( em_read_phy_reg(&the_em_devs[idx].d_softc.hw, PHY_STATUS, &data) ) |
---|
86 | return -1; |
---|
87 | } |
---|
88 | return data; |
---|
89 | } |
---|
90 | |
---|
91 | static int |
---|
92 | em_early_write_phy(int idx, unsigned reg, unsigned val) |
---|
93 | { |
---|
94 | if ( idx < 0 || idx >= NETDRIVER_SLOTS ) |
---|
95 | return -1; |
---|
96 | return em_write_phy_reg(&the_em_devs[idx].d_softc.hw, reg, val); |
---|
97 | } |
---|
98 | |
---|
99 | rtems_bsdnet_early_link_check_ops |
---|
100 | rtems_em_early_link_check_ops = { |
---|
101 | init: em_early_init, |
---|
102 | read_phy: em_early_read_phy, |
---|
103 | write_phy: em_early_write_phy, |
---|
104 | name: NETDRIVER, |
---|
105 | num_slots: NETDRIVER_SLOTS |
---|
106 | }; |
---|