annotate packages/devs/eth/arm/netarm/current/src/MII.c @ 3292:7f8e529b4d82 default tip

Fix FREESCALE_EDMA_NBYTES_MLOFFYES_MLOFF() so it works with negative offsets.
author vae
date Wed, 29 Apr 2015 23:31:48 +0000
parents 74dbf4c3f2e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
1 //==========================================================================
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
2 //
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
3 // MII.c
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
4 //
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
5 // NetSilion NET+ARM PHY chip configuration
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
6 //
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
7 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
8 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
9 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
11 // Copyright (C) 2005 Free Software Foundation, Inc.
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
12 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
14 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
16 // version.
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
17 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
21 // for more details.
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
22 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
23 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
26 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
27 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
28 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
29 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
30 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
31 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
32 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
33 // General Public License v2.
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
34 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
35 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
36 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
37 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2105
diff changeset
38 // ####ECOSGPLCOPYRIGHTEND####
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
39 //==========================================================================
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
40 //#####DESCRIPTIONBEGIN####
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
41 //
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
42 // Author(s): Harald Brandl (harald.brandl@fh-joanneum.at)
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
43 // Contributors: Harald Brandl
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
44 // Date: 01.08.2004
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
45 // Purpose: PHY chip configuration
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
46 // Description:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
47 //
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
48 //####DESCRIPTIONEND####
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
49 //
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
50 //==========================================================================
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
51
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
52 #include "eth_regs.h"
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
53
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
54
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
55 #define PHYS(_i_) (0x800 | _i_)
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
56
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
57 #define SysReg (unsigned *)0xffb00004 // System Status Register
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
58
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
59 /* Function: void cyg_netarm_mii_poll_busy (void)
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
60 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
61 * Description:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
62 * This routine is responsible for waiting for the current PHY
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
63 * operation to complete.
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
64 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
65 * Parameters:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
66 * none
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
67 */
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
68
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
69 static void
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
70 mii_poll_busy(void)
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
71 {
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
72 unsigned reg;
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
73 /* check to see if PHY is busy with read or write */
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
74 do
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
75 {
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
76 HAL_READ_UINT32(MIIIR, reg);
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
77 }while (reg & 1);
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
78 }
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
79
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
80 /* Function: void cyg_netarm_mii_reset (void)
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
81 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
82 * Description:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
83 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
84 * This routine resets the PHY.
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
85 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
86 * Return Values:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
87 * none
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
88 */
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
89
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
90 void
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
91 cyg_netarm_mii_reset(void)
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
92 {
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
93 HAL_WRITE_UINT32(MIIAR, PHYS(0)); // select command register
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
94 HAL_WRITE_UINT32(MIIWDR, 0x8000); // reset
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
95 mii_poll_busy();
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
96 }
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
97
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
98 /* Function: cyg_bool cyg_netarm_mii_negotiate (void)
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
99 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
100 * Description:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
101 * This routine is responsible for causing the external Ethernet PHY
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
102 * to begin the negotatiation process.
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
103 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
104 * Parameters:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
105 * none
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
106 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
107 * Return Value:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
108 * 0: SUCCESS
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
109 * 1: ERROR
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
110 */
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
111
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
112 cyg_bool
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
113 cyg_netarm_mii_negotiate(void)
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
114 {
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
115 unsigned timeout = 100000, reg;
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
116
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
117 HAL_WRITE_UINT32(MIIAR, PHYS(4));
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
118
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
119 mii_poll_busy();
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
120
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
121 HAL_WRITE_UINT32(MIIAR, PHYS(0));
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
122 HAL_OR_UINT32(MIIWDR, 0x1200);
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
123
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
124 mii_poll_busy();
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
125
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
126 while(timeout)
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
127 {
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
128 HAL_WRITE_UINT32(MIIAR, PHYS(1));
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
129 HAL_WRITE_UINT32(MIICR, 1);
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
130
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
131 mii_poll_busy();
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
132
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
133 HAL_READ_UINT32(MIIRDR, reg);
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
134
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
135 if(0x24 == (reg & 0x24))
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
136 return 0;
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
137 else
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
138 timeout--;
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
139 }
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
140
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
141 return 1;
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
142 }
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
143
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
144
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
145 /* Function: void cyg_netarm_mii_set_speed (cyg_bool speed, cyg_bool duplex)
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
146 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
147 * Description:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
148 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
149 * This routine will set the speed and duplex of the external PHY.
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
150 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
151 * Parameters:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
152 * Speed
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
153 * 0: 10Mbit
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
154 * 1: 100Mbit
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
155 * Duplex
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
156 * 0: Half
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
157 * 1: Full
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
158 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
159 * Return Values:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
160 * none
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
161 */
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
162
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
163 void
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
164 cyg_netarm_mii_set_speed(cyg_uint32 speed, cyg_bool duplex)
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
165 {
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
166 unsigned timeout = 1000000, reg;
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
167
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
168 HAL_WRITE_UINT32(MIIAR, PHYS(0)); // select command register
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
169 HAL_WRITE_UINT32(MIIWDR, (speed << 13) | (duplex << 8)); // set speed and duplex
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
170 mii_poll_busy();
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
171
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
172 while(timeout)
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
173 {
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
174 HAL_WRITE_UINT32(MIIAR, PHYS(1)); // select status register
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
175 HAL_WRITE_UINT32(MIICR, 1);
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
176 mii_poll_busy();
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
177 HAL_READ_UINT32(MIIRDR, reg);
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
178 if(reg & 0x4)
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
179 break;
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
180 timeout--;
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
181 }
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
182 }
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
183
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
184 /* Function: cyg_bool cyg_netarm_mii_check_speed
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
185 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
186 * Description:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
187 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
188 * This routine will check the operating speed of the ethernet
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
189 * interface.
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
190 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
191 * Parameters:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
192 * none
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
193 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
194 * Return Values:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
195 * 0: 10Mbit Speed
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
196 * 1: 100Mbit Speed
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
197 */
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
198
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
199 cyg_uint32
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
200 cyg_netarm_mii_check_speed(void)
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
201 {
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
202 unsigned reg;
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
203
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
204 HAL_WRITE_UINT32(MIIAR, PHYS(17));
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
205 HAL_WRITE_UINT32(MIICR, 1);
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
206 mii_poll_busy();
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
207 HAL_READ_UINT32(MIIRDR, reg);
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
208 return (reg >> 14) & 1;
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
209 }
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
210
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
211 /* Function: void cyg_netarm_mii_check_duplex
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
212 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
213 * Description:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
214 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
215 * This routine will check the operating duplex of the ethernet
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
216 * interface.
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
217 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
218 * Parameters:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
219 * none
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
220 *
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
221 * Return Values:
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
222 * 0: Half Duplex
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
223 * 1: Full Duplex
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
224 */
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
225
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
226 cyg_bool
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
227 cyg_netarm_mii_check_duplex(void)
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
228 {
2105
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
229 unsigned reg;
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
230
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
231 HAL_WRITE_UINT32(MIIAR, PHYS(17));
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
232 HAL_WRITE_UINT32(MIICR, 1);
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
233 mii_poll_busy();
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
234 HAL_READ_UINT32(MIIRDR, reg);
e7d311287dec * Fixed data alignment problems. Cleaned up the naming of
asl
parents: 1986
diff changeset
235 return (reg >> 9) & 1;
1986
e256aea3e373 * First import of an ethernet device driver for the NETARM
asl
parents:
diff changeset
236 }