mikroSDK Reference Manual
ar8035_driver.h
Go to the documentation of this file.
1
31#ifndef _AR8035_DRIVER_H
32#define _AR8035_DRIVER_H
33
34//Dependencies
35#include "core/nic.h"
36
37//PHY address
38#ifndef AR8035_PHY_ADDR
39 #define AR8035_PHY_ADDR 0
40#elif (AR8035_PHY_ADDR < 0 || AR8035_PHY_ADDR > 31)
41 #error AR8035_PHY_ADDR parameter is not valid
42#endif
43
44//AR8035 PHY registers
45#define AR8035_BMCR 0x00
46#define AR8035_BMSR 0x01
47#define AR8035_PHYID1 0x02
48#define AR8035_PHYID2 0x03
49#define AR8035_ANAR 0x04
50#define AR8035_ANLPAR 0x05
51#define AR8035_ANER 0x06
52#define AR8035_ANNPR 0x07
53#define AR8035_ANLPNPR 0x08
54#define AR8035_GBCR 0x09
55#define AR8035_GBSR 0x0A
56#define AR8035_MMDACR 0x0D
57#define AR8035_MMDAADR 0x0E
58#define AR8035_GBESR 0x0F
59#define AR8035_FUNC_CTRL 0x10
60#define AR8035_PHY_STATUS 0x11
61#define AR8035_INT_EN 0x12
62#define AR8035_INT_STATUS 0x13
63#define AR8035_SMART_SPEED 0x14
64#define AR8035_CDT_CTRL 0x16
65#define AR8035_LED_CTRL 0x18
66#define AR8035_CDT_STATUS 0x1C
67#define AR8035_DBG_PORT_ADDR_OFFSET 0x1D
68#define AR8035_DBG_PORT_DATA 0x1E
69
70//AR8035 MMD registers
71#define AR8035_PCS_CTRL 0x03, 0x0000
72#define AR8035_PCS_STAT 0x03, 0x0001
73#define AR8035_EEE_CAPABILITY 0x03, 0x0014
74#define AR8035_EEE_WAKE_ERROR_COUNTER 0x03, 0x0016
75#define AR8035_AN_CTRL 0x07, 0x0000
76#define AR8035_AN_STAT 0x07, 0x0001
77#define AR8035_AN_XNP_TRANSMIT 0x07, 0x0016
78#define AR8035_AN_XNP_TRANSMIT1 0x07, 0x0017
79#define AR8035_AN_XNP_TRANSMIT2 0x07, 0x0018
80#define AR8035_AN_XNP_ABILITY 0x07, 0x0019
81#define AR8035_AN_XNP_ABILITY1 0x07, 0x001A
82#define AR8035_AN_XNP_ABILITY2 0x07, 0x001B
83#define AR8035_EEE_ADV 0x07, 0x003C
84#define AR8035_EEE_LP_ADV 0x07, 0x003D
85#define AR8035_EEE_ABILITY_AN_RES 0x07, 0x8000
86
87//Control register
88#define AR8035_BMCR_RESET 0x8000
89#define AR8035_BMCR_LOOPBACK 0x4000
90#define AR8035_BMCR_SPEED_SEL_LSB 0x2000
91#define AR8035_BMCR_AN_EN 0x1000
92#define AR8035_BMCR_POWER_DOWN 0x0800
93#define AR8035_BMCR_ISOLATE 0x0400
94#define AR8035_BMCR_RESTART_AN 0x0200
95#define AR8035_BMCR_DUPLEX_MODE 0x0100
96#define AR8035_BMCR_COL_TEST 0x0080
97#define AR8035_BMCR_SPEED_SEL_MSB 0x0040
98
99//Status register
100#define AR8035_BMSR_100BT4 0x8000
101#define AR8035_BMSR_100BTX_FD 0x4000
102#define AR8035_BMSR_100BTX_HD 0x2000
103#define AR8035_BMSR_10BT_FD 0x1000
104#define AR8035_BMSR_10BT_HD 0x0800
105#define AR8035_BMSR_100BT2_FD 0x0400
106#define AR8035_BMSR_100BT2_HD 0x0200
107#define AR8035_BMSR_EXTENDED_STATUS 0x0100
108#define AR8035_BMSR_MF_PREAMBLE_SUPPR 0x0040
109#define AR8035_BMSR_AN_COMPLETE 0x0020
110#define AR8035_BMSR_REMOTE_FAULT 0x0010
111#define AR8035_BMSR_AN_CAPABLE 0x0008
112#define AR8035_BMSR_LINK_STATUS 0x0004
113#define AR8035_BMSR_JABBER_DETECT 0x0002
114#define AR8035_BMSR_EXTENDED_CAPABLE 0x0001
115
116//PHY Identifier 1 register
117#define AR8035_PHYID1_OUI_MSB 0xFFFF
118#define AR8035_PHYID1_OUI_MSB_DEFAULT 0x004D
119
120//PHY Identifier 2 register
121#define AR8035_PHYID2_OUI_LSB 0xFC00
122#define AR8035_PHYID2_OUI_LSB_DEFAULT 0xD000
123#define AR8035_PHYID2_MODEL_NUM 0x03F0
124#define AR8035_PHYID2_MODEL_NUM_DEFAULT 0x0070
125#define AR8035_PHYID2_REVISION_NUM 0x000F
126
127//Auto-Negotiation Advertisement register
128#define AR8035_ANAR_NEXT_PAGE 0x8000
129#define AR8035_ANAR_ACK 0x4000
130#define AR8035_ANAR_REMOTE_FAULT 0x2000
131#define AR8035_ANAR_XNP_ABLE 0x1000
132#define AR8035_ANAR_ASYM_PAUSE 0x0800
133#define AR8035_ANAR_PAUSE 0x0400
134#define AR8035_ANAR_100BT4 0x0200
135#define AR8035_ANAR_100BTX_FD 0x0100
136#define AR8035_ANAR_100BTX_HD 0x0080
137#define AR8035_ANAR_10BT_FD 0x0040
138#define AR8035_ANAR_10BT_HD 0x0020
139#define AR8035_ANAR_SELECTOR 0x001F
140#define AR8035_ANAR_SELECTOR_DEFAULT 0x0001
141
142//Link Partner Ability register
143#define AR8035_ANLPAR_NEXT_PAGE 0x8000
144#define AR8035_ANLPAR_ACK 0x4000
145#define AR8035_ANLPAR_REMOTE_FAULT 0x2000
146#define AR8035_ANLPAR_ASYM_PAUSE 0x0800
147#define AR8035_ANLPAR_PAUSE 0x0400
148#define AR8035_ANLPAR_100BT4 0x0200
149#define AR8035_ANLPAR_100BTX_FD 0x0100
150#define AR8035_ANLPAR_100BTX_HD 0x0080
151#define AR8035_ANLPAR_10BT_FD 0x0040
152#define AR8035_ANLPAR_10BT_HD 0x0020
153#define AR8035_ANLPAR_SELECTOR 0x001F
154#define AR8035_ANLPAR_SELECTOR_DEFAULT 0x0001
155
156//Auto-Negotiation Expansion register
157#define AR8035_ANER_PAR_DETECT_FAULT 0x0010
158#define AR8035_ANER_LP_NEXT_PAGE_ABLE 0x0008
159#define AR8035_ANER_NEXT_PAGE_ABLE 0x0004
160#define AR8035_ANER_PAGE_RECEIVED 0x0002
161#define AR8035_ANER_LP_AN_ABLE 0x0001
162
163//Auto-Negotiation Next Page Transmit register
164#define AR8035_ANNPR_NEXT_PAGE 0x8000
165#define AR8035_ANNPR_MSG_PAGE 0x2000
166#define AR8035_ANNPR_ACK2 0x1000
167#define AR8035_ANNPR_TOGGLE 0x0800
168#define AR8035_ANNPR_MESSAGE 0x07FF
169
170//Link Partner Next Page register
171#define AR8035_ANLPNPR_NEXT_PAGE 0x8000
172#define AR8035_ANLPNPR_ACK 0x4000
173#define AR8035_ANLPNPR_MSG_PAGE 0x2000
174#define AR8035_ANLPNPR_ACK2 0x1000
175#define AR8035_ANLPNPR_TOGGLE 0x0800
176#define AR8035_ANLPNPR_MESSAGE 0x07FF
177
178//1000BASE-T Control register
179#define AR8035_GBCR_TEST_MODE 0xE000
180#define AR8035_GBCR_MS_MAN_CONF_EN 0x1000
181#define AR8035_GBCR_MS_MAN_CONF_VAL 0x0800
182#define AR8035_GBCR_PORT_TYPE 0x0400
183#define AR8035_GBCR_1000BT_FD 0x0200
184#define AR8035_GBCR_1000BT_HD 0x0100
185
186//1000BASE-T Status register
187#define AR8035_GBSR_MS_CONF_FAULT 0x8000
188#define AR8035_GBSR_MS_CONF_RES 0x4000
189#define AR8035_GBSR_LOCAL_RECEIVER_STATUS 0x2000
190#define AR8035_GBSR_REMOTE_RECEIVER_STATUS 0x1000
191#define AR8035_GBSR_LP_1000BT_FD 0x0800
192#define AR8035_GBSR_LP_1000BT_HD 0x0400
193#define AR8035_GBSR_IDLE_ERR_COUNT 0x00FF
194
195//MMD Access Control register
196#define AR8035_MMDACR_FUNC 0xC000
197#define AR8035_MMDACR_FUNC_ADDR 0x0000
198#define AR8035_MMDACR_FUNC_DATA_NO_POST_INC 0x4000
199#define AR8035_MMDACR_FUNC_DATA_POST_INC_RW 0x8000
200#define AR8035_MMDACR_FUNC_DATA_POST_INC_W 0xC000
201#define AR8035_MMDACR_DEVAD 0x001F
202
203//Extended Status register
204#define AR8035_GBESR_1000BX_FD 0x8000
205#define AR8035_GBESR_1000BX_HD 0x4000
206#define AR8035_GBESR_1000BT_FD 0x2000
207#define AR8035_GBESR_1000BT_HD 0x1000
208
209//Function Control register
210#define AR8035_FUNC_CTRL_ASSERT_CRS_ON_TX 0x0800
211#define AR8035_FUNC_CTRL_MDIX_MODE 0x0060
212#define AR8035_FUNC_CTRL_MDIX_MODE_MANUAL_MDI 0x0000
213#define AR8035_FUNC_CTRL_MDIX_MODE_MANUAL_MDIX 0x0020
214#define AR8035_FUNC_CTRL_MDIX_MODE_AUTO 0x0060
215#define AR8035_FUNC_CTRL_SQE_TEST 0x0004
216#define AR8035_FUNC_CTRL_POLARITY_REVERSAL 0x0002
217#define AR8035_FUNC_CTRL_JABBER_DIS 0x0001
218
219//PHY-Specific Status register
220#define AR8035_PHY_STATUS_SPEED 0xC000
221#define AR8035_PHY_STATUS_SPEED_10MBPS 0x0000
222#define AR8035_PHY_STATUS_SPEED_100MBPS 0x4000
223#define AR8035_PHY_STATUS_SPEED_1000MBPS 0x8000
224#define AR8035_PHY_STATUS_DUPLEX 0x2000
225#define AR8035_PHY_STATUS_PAGE_RECEIVED 0x1000
226#define AR8035_PHY_STATUS_SPEED_DUPLEX_RESOLVED 0x0800
227#define AR8035_PHY_STATUS_LINK 0x0400
228#define AR8035_PHY_STATUS_MDI_CROSSOVER_STATUS 0x0040
229#define AR8035_PHY_STATUS_WIRESPEED_DOWNGRADE 0x0020
230#define AR8035_PHY_STATUS_TX_PAUSE_EN 0x0008
231#define AR8035_PHY_STATUS_RX_PAUSE_EN 0x0004
232#define AR8035_PHY_STATUS_POLARITY 0x0002
233#define AR8035_PHY_STATUS_JABBER 0x0001
234
235//Interrupt Enable Register register
236#define AR8035_INT_EN_AN_ERROR 0x8000
237#define AR8035_INT_EN_SPEED_CHANGED 0x4000
238#define AR8035_INT_EN_DUPLEX_CHANGED 0x2000
239#define AR8035_INT_EN_PAGE_RECEIVED 0x1000
240#define AR8035_INT_EN_LINK_FAIL 0x0800
241#define AR8035_INT_EN_LINK_SUCCESS 0x0400
242#define AR8035_INT_EN_WIRESPEED_DOWNGRADE 0x0020
243#define AR8035_INT_EN_POLARITY_CHANGED 0x0002
244#define AR8035_INT_EN_WOL_PTP 0x0001
245
246//Interrupt Status register
247#define AR8035_INT_STATUS_AN_ERROR 0x8000
248#define AR8035_INT_STATUS_SPEED_CHANGED 0x4000
249#define AR8035_INT_STATUS_DUPLEX_CHANGED 0x2000
250#define AR8035_INT_STATUS_PAGE_RECEIVED 0x1000
251#define AR8035_INT_STATUS_LINK_FAIL 0x0800
252#define AR8035_INT_STATUS_LINK_SUCCESS 0x0400
253#define AR8035_INT_STATUS_WIRESPEED_DOWNGRADE 0x0020
254#define AR8035_INT_STATUS_POLARITY_CHANGED 0x0002
255#define AR8035_INT_STATUS_WOL_PTP 0x0001
256
257//Smart Speed register
258#define AR8035_SMART_SPEED_EN 0x0020
259#define AR8035_SMART_SPEED_RETRY_LIMIT 0x001C
260#define AR8035_SMART_SPEED_BYPASS_TIMER 0x0002
261
262//Cable Diagnostic Tester (CDT) Control register
263#define AR8035_CDT_CTRL_MDI_PAIR_SELECT 0x0300
264#define AR8035_CDT_CTRL_TEST_EN 0x0001
265
266//LED Control register
267#define AR8035_LED_CTRL_LED_ON_TIME 0x7000
268#define AR8035_LED_CTRL_LED_OFF_TIME 0x0700
269
270//Cable Diagnostic Tester Status register
271#define AR8035_CDT_STATUS_STATUS 0x0300
272#define AR8035_CDT_STATUS_DELTA_TIME 0x00FF
273
274//C++ guard
275#ifdef __cplusplus
276extern "C" {
277#endif
278
279//AR8035 Ethernet PHY driver
280extern const PhyDriver ar8035PhyDriver;
281
282//AR8035 related functions
283error_t ar8035Init(NetInterface *interface);
284void ar8035InitHook(NetInterface *interface);
285
286void ar8035Tick(NetInterface *interface);
287
288void ar8035EnableIrq(NetInterface *interface);
289void ar8035DisableIrq(NetInterface *interface);
290
291void ar8035EventHandler(NetInterface *interface);
292
293void ar8035WritePhyReg(NetInterface *interface, uint8_t address,
294 uint16_t data);
295
296uint16_t ar8035ReadPhyReg(NetInterface *interface, uint8_t address);
297
298void ar8035DumpPhyReg(NetInterface *interface);
299
300void ar8035WriteMmdReg(NetInterface *interface, uint8_t devAddr,
301 uint16_t regAddr, uint16_t data);
302
303uint16_t ar8035ReadMmdReg(NetInterface *interface, uint8_t devAddr,
304 uint16_t regAddr);
305
306//C++ guard
307#ifdef __cplusplus
308}
309#endif
310
311#endif
error_t
Error codes.
Definition error.h:43
Network interface controller abstraction layer.
Ethernet PHY driver.
Definition nic.h:308