libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
phy_ksz80x1.h
Go to the documentation of this file.
1/** @defgroup ethernet_phy_ksz80x1_defines PHY KSZ80X1 Defines
2 *
3 * @brief <b>Defined Constants and Types for the Ethernet PHY KSZ80X1 chips
4 * chips</b>
5 *
6 * @ingroup ETH
7 *
8 * @version 1.0.0
9 *
10 * @author @htmlonly &copy; @endhtmlonly 2013 Frantisek Burian <BuFran@seznam.cz>
11 *
12 * @date 1 September 2013
13 *
14 * LGPL License Terms @ref lgpl_license
15 */
16/*
17 * This file is part of the libopencm3 project.
18 *
19 * Copyright (C) 2013 Frantisek Burian <BuFran@seznam.cz>
20 *
21 * This library is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU Lesser General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
25 *
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU Lesser General Public License for more details.
30 *
31 * You should have received a copy of the GNU Lesser General Public License
32 * along with this library. If not, see <http://www.gnu.org/licenses/>.
33 */
34
35#ifndef LIBOPENCM3_PHY_KSZ80X1_H
36#define LIBOPENCM3_PHY_KSZ80X1_H
37
39
40/**@{*/
41
42/*
43 * Architecture availability:
44 *
45 * A stands for KSZ8001 / KSZ8001L
46 * B stands for KSZ8021RNL / KSZ8031RNL
47 * C stands for KSZ8041NL / KSZ8041NLJ
48 * D stands for KSZ8041RNL
49 * E stands for KSZ8041TL / KSZ8041FTL / KSZ8041MLL
50 * F stands for KSZ8051MLL
51 * G stands for KSZ8051MNL / KSZ8051RNL
52 * H stands for KSZ8051MNLU / KSZ8051RNLU
53 * I stands for KSZ8081MLX /KSZ8081MNX / KSZ8081RNB
54 * J stands for KSZ8081RNA / KSZ8081RND
55 * K stands for KSZ8091MLX / KSZ8091MNX / KSZ8091RNB
56 * L stands for KSZ8091RNA / KSZ8091RND
57 *
58 * No sign marks available for all
59 */
60
61/*****************************************************************************/
62/* Register definitions */
63/*****************************************************************************/
64
65#define KSZ80X1_BCR 0x00 /* ABCDEFGHIJKL */
66#define KSZ80X1_BSR 0x01 /* ABCDEFGHIJKL */
67#define KSZ80X1_ID1 0x02 /* ABCDEFGHIJKL */
68#define KSZ80X1_ID2 0x03 /* ABCDEFGHIJKL */
69#define KSZ80X1_ANTX 0x04 /* ABCDEFGHIJKL */
70#define KSZ80X1_ANRX 0x05 /* ABCDEFGHIJKL */
71#define KSZ80X1_ANEXP 0x06 /* ABCDEFGHIJKL */
72#define KSZ80X1_ANNPTX 0x07 /* ABCDEFGHIJKL */
73#define KSZ80X1_ANNPRX 0x08 /* ABCDEFGHIJKL */
74
75#define KSZ80X1_MMDCR 0x0D /* ----------KL */
76#define KSZ80X1_MMDAR 0x0E /* ----------KL */
77
78#define KSZ80X1_DRCTRL 0x10 /* -B-----HIJKL */
79#define KSZ80X1_AFECTRL 0x11 /* -B---FGHIJKL */
80#define KSZ80X1_AFECTRL4 0x13 /* ----------KL */
81#define KSZ80X1_MIICTRL 0x14 /* ---DE------- */
82#define KSZ80X1_RXERCTR 0x15 /* ABCDEFGHIJKL */
83#define KSZ80X1_STRAPOVRD 0x16 /* -B---FGHIJKL */
84#define KSZ80X1_STRAPSTAT 0x17 /* -B---FGHIJKL */
85#define KSZ80X1_ECR 0x18 /* -B---FGHIJKL */
86
87#define KSZ80X1_ICSR 0x1B /* ABCDEFGHIJKL */
88
89#define KSZ80X1_LINKMD 0x1D /* AB--EFGHIJKL */
90#define KSZ80X1_CR1 0x1E /* ABCDEFGHIJKL */
91#define KSZ80X1_CR2 0x1F /* ABCDEFGHIJKL */
92
93/*****************************************************************************/
94/* Register values */
95/*****************************************************************************/
96
97/* KSZ80X1_BCR --------------------------------------------------------------*/
98/* KSZ80X1_BSR --------------------------------------------------------------*/
99/* KSZ80X1_ID1 --------------------------------------------------------------*/
100/* KSZ80X1_ID2 --------------------------------------------------------------*/
101/* KSZ80X1_ANTX -------------------------------------------------------------*/
102/* KSZ80X1_ANRX -------------------------------------------------------------*/
103/* KSZ80X1_ANEXP ------------------------------------------------------------*/
104/* KSZ80X1_ANNPTX -----------------------------------------------------------*/
105/* KSZ80X1_ANNPRX -----------------------------------------------------------*/
106
107/* KSZ80X1_MMDCR ------------------------------------------------------------*/
108
109#define KSZ80X1_MMDCR_OPMODE (3 << 14) /* ----------KL */
110#define KSZ80X1_MMDCR_OPMODE_REGISTER (0 << 14) /* ----------KL */
111#define KSZ80X1_MMDCR_OPMODE_DATA (1 << 14) /* ----------KL */
112#define KSZ80X1_MMDCR_OPMODE_DATA_POSTINC (2 << 14) /* ----------KL */
113#define KSZ80X1_MMDCR_OPMODE_DATA_WPOSTINC (3 << 14) /* ----------KL */
114
115#define KSZ80X1_MMDCR_DEVADDR (31 << 14) /* ----------KL */
116
117/* KSZ80X1_MMDAR ------------------------------------------------------------*/
118
119/* KSZ80X1_DRCTRL -----------------------------------------------------------*/
120
121#define KSZ80X1_DRCTRL_PLLOFF (1 << 4) /* -B-----HIJKL */
122
123/* KSZ80X1_AFECTRL ----------------------------------------------------------*/
124
125#define KSZ80X1_AFECTRL_SLOWOSC (1 << 5) /* -B---FGHIJKL */
126
127/* KSZ80X1_AFECTRL4 ---------------------------------------------------------*/
128
129#define KSZ80X1_AFECTRL4_10TE (1 << 4) /* ----------KL */
130
131/* KSZ80X1_MIICTRL ----------------------------------------------------------*/
132#define KSZ8051_MIICTRL_PREAM_RESTORE_100M (1 << 7) /* ---DE------ */
133#define KSZ8051_MIICTRL_PREAM_RESTORE_10M (1 << 6) /* ---DE------ */
134
135/* KSZ80X1_RXERCTR ----------------------------------------------------------*/
136
137/* KSZ8051_STRAPOVRD --------------------------------------------------------*/
138
139/* strapping options availability depends on MII/RMII availability on chip */
140
141#define KSZ80X1_STRAPOVRD_FACTORY (1 << 15) /* --------IJ-- */
142#define KSZ80X1_STRAPOVRD_PMEWOL (1 << 15) /* ----------KL */
143#define KSZ80X1_STRAPOVRD_BCASTOFF (1 << 9) /* -----FGHIJKL */
144#define KSZ80X1_STRAPOVRD_MIIBTOB (1 << 7) /* -----FGHI-K- */
145#define KSZ80X1_STRAPOVRD_RMIIBTOB (1 << 6) /* -B----GHIJKL */
146#define KSZ80X1_STRAPOVRD_NANDTREE (1 << 5) /* -B---FGHIJK- */
147#define KSZ80X1_STRAPOVRD_RMIIOVRD (1 << 1) /* -B----GHIJKL */
148#define KSZ80X1_STRAPOVRD_MIIOVRD (1 << 0) /* -----FGHI-K- */
149
150/* KSZ80X1_STRAPSTAT --------------------------------------------------------*/
151
152/* strapping options availability depends on MII/RMII availability on chip */
153/* KSZ8021/KSZ8031/KSZ8091RNA/KSZ8091RND supports phy address 0 and 3 only! */
154
155#define KSZ80X1_STRAPSTAT_PHYAD_SHIFT 13 /* -B---FGHIJKL */
156#define KSZ80X1_STRAPSTAT_PHYAD (7 << KSZ8051_STRAPSTAT_PHYAD_SHIFT)
157
158#define KSZ80X1_STRAPSTAT_BCASTOFF (1 << 9) /* -----FGHI-K- */
159#define KSZ80X1_STRAPSTAT_MIIBTOB (1 << 7) /* -----FGHI-K- */
160#define KSZ80X1_STRAPSTAT_RMIIBTOB (1 << 6) /* ------GHI-K- */
161#define KSZ80X1_STRAPSTAT_NANDTREE (1 << 5) /* -----FGHI-K- */
162#define KSZ80X1_STRAPSTAT_RMII (1 << 1) /* -B----GHIJKL */
163#define KSZ80X1_STRAPSTAT_MII (1 << 0) /* -----FGHI-K- */
164
165/* KSZ80X1_ECR --------------------------------------------------------------*/
166
167#define KSZ8051_ECR_EDPDDIS (1 << 11) /* -B---FGHIJKL */
168#define KSZ8051_ECR_100TXPREAMBLE (1 << 10) /* -----FGHI-K- */
169#define KSZ8051_ECR_10TXPREAMBLE (1 << 6) /* -----FGHI-K- */
170
171/* KSZ80X1_ICSR -------------------------------------------------------------*/
172
173#define KSZ80X1_ICSR_JABIE (1 << 15) /* ABCDEFGHIJKL */
174#define KSZ80X1_ICSR_RERRIE (1 << 14) /* ABCDEFGHIJKL */
175#define KSZ80X1_ICSR_PRIE (1 << 13) /* ABCDEFGHIJKL */
176#define KSZ80X1_ICSR_PDFLTIE (1 << 12) /* ABCDEFGHIJKL */
177#define KSZ80X1_ICSR_LPACKIE (1 << 11) /* ABCDEFGHIJKL */
178#define KSZ80X1_ICSR_LDIE (1 << 10) /* ABCDEFGHIJKL */
179#define KSZ80X1_ICSR_RFAULTIE (1 << 9) /* ABCDEFGHIJKL */
180#define KSZ80X1_ICSR_LINKUPIE (1 << 8) /* ABCDEFGHIJKL */
181
182#define KSZ80X1_ICSR_JABIF (1 << 7) /* ABCDEFGHIJKL */
183#define KSZ80X1_ICSR_RERRIF (1 << 6) /* ABCDEFGHIJKL */
184#define KSZ80X1_ICSR_PRIF (1 << 5) /* ABCDEFGHIJKL */
185#define KSZ80X1_ICSR_PDFLTIF (1 << 4) /* ABCDEFGHIJKL */
186#define KSZ80X1_ICSR_LPACKIF (1 << 3) /* ABCDEFGHIJKL */
187#define KSZ80X1_ICSR_LDIF (1 << 2) /* ABCDEFGHIJKL */
188#define KSZ80X1_ICSR_RFAULTIF (1 << 1) /* ABCDEFGHIJKL */
189#define KSZ80X1_ICSR_LINKUPIF (1 << 0) /* ABCDEFGHIJKL */
190
191/* KSZ80X1_LINKMD -----------------------------------------------------------*/
192
193#define KSZ80X1_LINKMD_TESTEN (1 << 15) /* AB--EFGHIJKL */
194
195#define KSZ80X1_LINKMD_TESTRES (3 << 13) /* AB--EFGHIJKL */
196#define KSZ80X1_LINKMD_TESTRES_NORMAL (0 << 13) /* AB--EFGHIJKL */
197#define KSZ80X1_LINKMD_TESTRES_OPEN (1 << 13) /* AB--EFGHIJKL */
198#define KSZ80X1_LINKMD_TESTRES_SHORT (2 << 13) /* AB--EFGHIJKL */
199#define KSZ80X1_LINKMD_TESTRES_FAILED (3 << 13) /* AB--EFGHIJKL */
200
201#define KSZ80X1_LINKMD_SHORTCABLE (1 << 12) /* -----FGHIJKL */
202#define KSZ80X1_LINKMD_DISTANCE (0x1FF << 0) /* AB--EFGHIJKL */
203
204/* KSZ80X1_CR1 --------------------------------------------------------------*/
205
206/* family set 1, "8041" when conflicts arise */
207
208#define KSZ80X1_CR1_LEDMODE (3 << 14) /* A-CDE------- */
209#define KSZ80X1_CR1_LEDMODE_COL_FD_SPD_LNK (0 << 14) /* A---------- */
210#define KSZ80X1_CR1_LEDMODE_ACT_FD_SPD_LNK (1 << 14) /* A---------- */
211#define KSZ80X1_CR1_LEDMODE_ACT_FD_100_10 (2 << 14) /* A---------- */
212#define KSZ80X1_CR1_LEDMODE_SPD_LNK (0 << 14) /* --CDE------ */
213#define KSZ80X1_CR1_LEDMODE_ACT_LNK (1 << 14) /* --CDE------ */
214#define KSZ8041_CR1_POLARITY (1 << 13) /* A-CDE------ */
215#define KSZ80X1_CR1_FEFAULT (1 << 12) /* A---E------ */
216#define KSZ8041_CR1_MDIX (1 << 11) /* A-CDE------ */
217#define KSZ80X1_CR1_LOOPBACK (1 << 7) /* A-CDE------ */
218
219/* family set 2 */
220
221#define KSZ80X1_CR1_FLOWCTRL (1 << 9) /* -B---FGHIJKL */
222#define KSZ80X1_CR1_LINK (1 << 8) /* -B---FGHIJKL */
223#define KSZ80X1_CR1_POLARITY (1 << 7) /* -B---FGHIJKL */
224#define KSZ80X1_CR1_MDIX (1 << 5) /* -B---FGHIJKL */
225#define KSZ80X1_CR1_ENERGY (1 << 4) /* -B---FGHIJKL */
226#define KSZ80X1_CR1_ISOLATE (1 << 3) /* -B---FGHIJKL */
227
228#define KSZ80X1_CR1_MODE (7 << 0) /* -B---FGHIJKL */
229#define KSZ80X1_CR1_MODE_AUTONEG (0 << 0) /* -B---FGHIJKL */
230#define KSZ80X1_CR1_MODE_10HD (1 << 0) /* -B---FGHIJKL */
231#define KSZ80X1_CR1_MODE_100HD (2 << 0) /* -B---FGHIJKL */
232#define KSZ80X1_CR1_MODE_10FD (5 << 0) /* -B---FGHIJKL */
233#define KSZ80X1_CR1_MODE_100FD (6 << 0) /* -B---FGHIJKL */
234
235/* KSZ80X1_CR2 --------------------------------------------------------------*/
236
237/* refclk options availability depends on RMII availability on chip */
238
239#define KSZ80X1_CR2_HPMDIX (1 << 15) /* ABCDEFGHIJKL */
240#define KSZ80X1_CR2_MDIXSEL (1 << 14) /* ABCDEFGHIJKL*/
241#define KSZ80X1_CR2_MDIXEN (1 << 13) /* ABCDEFGHIJKL */
242#define KSZ80X1_CR2_ENERGY (1 << 12) /* A-CDE------- */
243#define KSZ80X1_CR2_FORCE (1 << 11) /* ABCDEFGHIJKL */
244#define KSZ80X1_CR2_POWERSAVE (1 << 10) /* ABCDEFGHIJKL */
245#define KSZ80X1_CR2_IRQLVL (1 << 9) /* ABCDEFGHIJKL */
246#define KSZ80X1_CR2_JABEN (1 << 8) /* ABCDEFGHIJKL */
247
248/* family set 1 */
249
250#define KSZ80X1_CR2_ANDONE (1 << 7) /* A-CDE------- */
251#define KSZ80X1_CR2_PAUSEEN (1 << 6) /* A-CDE------- */
252#define KSZ80X1_CR2_ISOLATE (1 << 5) /* A-CDE------- */
253#define KSZ80X1_CR2_MODE (7 << 2) /* A-CDE */
254#define KSZ80X1_CR2_MODE_AN (0 << 2) /* A-CDE */
255#define KSZ80X1_CR2_MODE_10HD (1 << 2) /* A-CDE */
256#define KSZ80X1_CR2_MODE_100HD (2 << 2) /* A-CDE */
257#define KSZ80X1_CR2_MODE_DEFAULT (3 << 2) /* A--- */
258#define KSZ80X1_CR2_MODE_10FD (5 << 2) /* A-CDE */
259#define KSZ80X1_CR2_MODE_100FD (6 << 2) /* A-CDE */
260#define KSZ80X1_CR2_MODE_ISOLATE (7 << 2) /* A--- */
261
262/* family set 2 */
263
264#define KSZ80X1_CR2_REFCLK (1 << 7) /* -B----GHIJKL */
265#define KSZ80X1_CR2_REFCLK_25MHZ (0 << 7) /* -B----GHIJKL */
266#define KSZ80X1_CR2_REFCLK_50MHZ (1 << 7) /* -B----GHIJKL */
267#define KSZ80X1_CR2_LED (3 << 4) /* -B---FGHIJKL */
268#define KSZ80X1_CR2_LED_SPD_LNKACT (0 << 4) /* -B---FGHIJKL */
269#define KSZ80X1_CR2_LED_ACT_LNK (1 << 4) /* -B---FGHIJKL */
270#define KSZ80X1_CR2_TXDIS (1 << 3) /* -B---FGHIJKL */
271#define KSZ80X1_CR2_REMLPB (1 << 2) /* -B---FGHIJKL */
272
273
274#define KSZ80X1_CR2_SQEEN (1 << 1) /* ABCDEFGHI-KL */
275#define KSZ80X1_CR2_SCRAMBEN (1 << 0) /* ABCDEFGHIJKL */
276
277/*****************************************************************************/
278/* API definitions */
279/*****************************************************************************/
280
281/*****************************************************************************/
282/* API Functions */
283/*****************************************************************************/
284
285/**@}*/
286
287
288#endif /* LIBOPENCM3_PHY_KSZ8051_H__ */