Pull up following revision(s) (requested by jmcneill in ticket #775): sys/arch/mips/atheros/ar5312_board.c: revision 1.2 sys/arch/mips/atheros/ar5315.c: revision 1.6 sys/arch/mips/atheros/ar5315_board.c: revision 1.2 sys/arch/mips/atheros/dev/if_ath_arbus.c: revision 1.16 sys/arch/mips/atheros/include/ar5312reg.h: revision 1.3 Update reference to the Atheros HAL exported headers. `external/isc/atheros_hal/dist', former `contrib/dev/ath/' is now in cpp(1)'s include path. Fix build of MERAKI kernel.diff -r1.1 -r1.1.72.1 src/sys/arch/mips/atheros/ar5312_board.c
(snj)
--- src/sys/arch/mips/atheros/ar5312_board.c 2006/09/26 06:37:32 1.1
+++ src/sys/arch/mips/atheros/ar5312_board.c 2009/08/07 06:50:47 1.1.72.1
@@ -1,156 +1,156 @@ | @@ -1,156 +1,156 @@ | |||
1 | /* $Id: ar5312_board.c,v 1.1 2006/09/26 06:37:32 gdamore Exp $ */ | 1 | /* $Id: ar5312_board.c,v 1.1.72.1 2009/08/07 06:50:47 snj Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. | 3 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. | |
4 | * Copyright (c) 2006 Garrett D'Amore. | 4 | * Copyright (c) 2006 Garrett D'Amore. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code was written by Garrett D'Amore for the Champaign-Urbana | 7 | * This code was written by Garrett D'Amore for the Champaign-Urbana | |
8 | * Community Wireless Network Project. | 8 | * Community Wireless Network Project. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or | 10 | * Redistribution and use in source and binary forms, with or | |
11 | * without modification, are permitted provided that the following | 11 | * without modification, are permitted provided that the following | |
12 | * conditions are met: | 12 | * conditions are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above | 15 | * 2. Redistributions in binary form must reproduce the above | |
16 | * copyright notice, this list of conditions and the following | 16 | * copyright notice, this list of conditions and the following | |
17 | * disclaimer in the documentation and/or other materials provided | 17 | * disclaimer in the documentation and/or other materials provided | |
18 | * with the distribution. | 18 | * with the distribution. | |
19 | * 3. All advertising materials mentioning features or use of this | 19 | * 3. All advertising materials mentioning features or use of this | |
20 | * software must display the following acknowledgements: | 20 | * software must display the following acknowledgements: | |
21 | * This product includes software developed by the Urbana-Champaign | 21 | * This product includes software developed by the Urbana-Champaign | |
22 | * Independent Media Center. | 22 | * Independent Media Center. | |
23 | * This product includes software developed by Garrett D'Amore. | 23 | * This product includes software developed by Garrett D'Amore. | |
24 | * 4. Urbana-Champaign Independent Media Center's name and Garrett | 24 | * 4. Urbana-Champaign Independent Media Center's name and Garrett | |
25 | * D'Amore's name may not be used to endorse or promote products | 25 | * D'Amore's name may not be used to endorse or promote products | |
26 | * derived from this software without specific prior written permission. | 26 | * derived from this software without specific prior written permission. | |
27 | * | 27 | * | |
28 | * THIS SOFTWARE IS PROVIDED BY THE URBANA-CHAMPAIGN INDEPENDENT | 28 | * THIS SOFTWARE IS PROVIDED BY THE URBANA-CHAMPAIGN INDEPENDENT | |
29 | * MEDIA CENTER AND GARRETT D'AMORE ``AS IS'' AND ANY EXPRESS OR | 29 | * MEDIA CENTER AND GARRETT D'AMORE ``AS IS'' AND ANY EXPRESS OR | |
30 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 30 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
31 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 31 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT | 32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT | |
33 | * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, | 33 | * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, | |
34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
35 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 35 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
38 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 38 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
39 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 39 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
40 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 40 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
41 | */ | 41 | */ | |
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: ar5312_board.c,v 1.1 2006/09/26 06:37:32 gdamore Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: ar5312_board.c,v 1.1.72.1 2009/08/07 06:50:47 snj Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | #include <sys/device.h> | 47 | #include <sys/device.h> | |
48 | 48 | |||
49 | #include <machine/bus.h> | 49 | #include <machine/bus.h> | |
50 | #include <mips/atheros/include/ar5312reg.h> | 50 | #include <mips/atheros/include/ar5312reg.h> | |
51 | #include <mips/atheros/include/ar531xvar.h> | 51 | #include <mips/atheros/include/ar531xvar.h> | |
52 | 52 | |||
53 | #include <contrib/dev/ath/ah_soc.h> | 53 | #include <ah_soc.h> | |
54 | 54 | |||
55 | extern const char *ether_sprintf(const uint8_t *); | 55 | extern const char *ether_sprintf(const uint8_t *); | |
56 | 56 | |||
57 | /* | 57 | /* | |
58 | * Locate the Board Configuration data using heuristics. | 58 | * Locate the Board Configuration data using heuristics. | |
59 | * Search backward from the (aliased) end of flash looking | 59 | * Search backward from the (aliased) end of flash looking | |
60 | * for the signature string that marks the start of the data. | 60 | * for the signature string that marks the start of the data. | |
61 | * We search at most 500KB. | 61 | * We search at most 500KB. | |
62 | */ | 62 | */ | |
63 | const struct ar531x_boarddata * | 63 | const struct ar531x_boarddata * | |
64 | ar531x_board_info(void) | 64 | ar531x_board_info(void) | |
65 | { | 65 | { | |
66 | static const struct ar531x_boarddata *board = NULL; | 66 | static const struct ar531x_boarddata *board = NULL; | |
67 | const uint8_t *ptr, *end; | 67 | const uint8_t *ptr, *end; | |
68 | uint32_t fctl; | 68 | uint32_t fctl; | |
69 | 69 | |||
70 | if (board == NULL) { | 70 | if (board == NULL) { | |
71 | /* configure flash bank 0 */ | 71 | /* configure flash bank 0 */ | |
72 | fctl = REGVAL(AR5312_FLASHCTL_BASE + AR5312_FLASHCTL_0) & | 72 | fctl = REGVAL(AR5312_FLASHCTL_BASE + AR5312_FLASHCTL_0) & | |
73 | AR5312_FLASHCTL_MW_MASK; | 73 | AR5312_FLASHCTL_MW_MASK; | |
74 | 74 | |||
75 | fctl |= | 75 | fctl |= | |
76 | AR5312_FLASHCTL_E | | 76 | AR5312_FLASHCTL_E | | |
77 | AR5312_FLASHCTL_RBLE | | 77 | AR5312_FLASHCTL_RBLE | | |
78 | AR5312_FLASHCTL_AC_8M | | 78 | AR5312_FLASHCTL_AC_8M | | |
79 | (1 << AR5312_FLASHCTL_IDCY_SHIFT) | | 79 | (1 << AR5312_FLASHCTL_IDCY_SHIFT) | | |
80 | (7 << AR5312_FLASHCTL_WST1_SHIFT) | | 80 | (7 << AR5312_FLASHCTL_WST1_SHIFT) | | |
81 | (7 << AR5312_FLASHCTL_WST2_SHIFT); | 81 | (7 << AR5312_FLASHCTL_WST2_SHIFT); | |
82 | 82 | |||
83 | REGVAL(AR5312_FLASHCTL_BASE + AR5312_FLASHCTL_0) = fctl; | 83 | REGVAL(AR5312_FLASHCTL_BASE + AR5312_FLASHCTL_0) = fctl; | |
84 | 84 | |||
85 | REGVAL(AR5312_FLASHCTL_BASE + AR5312_FLASHCTL_1) &= | 85 | REGVAL(AR5312_FLASHCTL_BASE + AR5312_FLASHCTL_1) &= | |
86 | ~(AR5312_FLASHCTL_E | AR5312_FLASHCTL_AC_MASK); | 86 | ~(AR5312_FLASHCTL_E | AR5312_FLASHCTL_AC_MASK); | |
87 | 87 | |||
88 | REGVAL(AR5312_FLASHCTL_BASE + AR5312_FLASHCTL_2) &= | 88 | REGVAL(AR5312_FLASHCTL_BASE + AR5312_FLASHCTL_2) &= | |
89 | ~(AR5312_FLASHCTL_E | AR5312_FLASHCTL_AC_MASK); | 89 | ~(AR5312_FLASHCTL_E | AR5312_FLASHCTL_AC_MASK); | |
90 | 90 | |||
91 | /* search backward in the flash looking for the signature */ | 91 | /* search backward in the flash looking for the signature */ | |
92 | ptr = (const uint8_t *) MIPS_PHYS_TO_KSEG1(AR5312_FLASH_END - 0x1000); | 92 | ptr = (const uint8_t *) MIPS_PHYS_TO_KSEG1(AR5312_FLASH_END - 0x1000); | |
93 | end = ptr - (500 * 1024); /* NB: max 500KB window */ | 93 | end = ptr - (500 * 1024); /* NB: max 500KB window */ | |
94 | /* XXX validate end */ | 94 | /* XXX validate end */ | |
95 | for (; ptr > end; ptr -= 0x1000) | 95 | for (; ptr > end; ptr -= 0x1000) | |
96 | if (*(const uint32_t *)ptr == AR531X_BD_MAGIC) { | 96 | if (*(const uint32_t *)ptr == AR531X_BD_MAGIC) { | |
97 | board = (const struct ar531x_boarddata *) ptr; | 97 | board = (const struct ar531x_boarddata *) ptr; | |
98 | break; | 98 | break; | |
99 | } | 99 | } | |
100 | } | 100 | } | |
101 | return board; | 101 | return board; | |
102 | } | 102 | } | |
103 | 103 | |||
104 | /* | 104 | /* | |
105 | * Locate the radio configuration data; it is located relative | 105 | * Locate the radio configuration data; it is located relative | |
106 | * to the board configuration data. | 106 | * to the board configuration data. | |
107 | */ | 107 | */ | |
108 | const void * | 108 | const void * | |
109 | ar531x_radio_info(void) | 109 | ar531x_radio_info(void) | |
110 | { | 110 | { | |
111 | static const void *radio = NULL; | 111 | static const void *radio = NULL; | |
112 | const struct ar531x_boarddata *board; | 112 | const struct ar531x_boarddata *board; | |
113 | const uint8_t *baddr, *ptr, *end; | 113 | const uint8_t *baddr, *ptr, *end; | |
114 | 114 | |||
115 | if (radio == NULL) { | 115 | if (radio == NULL) { | |
116 | board = ar531x_board_info(); | 116 | board = ar531x_board_info(); | |
117 | if (board == NULL) | 117 | if (board == NULL) | |
118 | return NULL; | 118 | return NULL; | |
119 | baddr = (const uint8_t *) board; | 119 | baddr = (const uint8_t *) board; | |
120 | ptr = baddr + 0x1000; | 120 | ptr = baddr + 0x1000; | |
121 | end = (const uint8_t *) | 121 | end = (const uint8_t *) | |
122 | MIPS_PHYS_TO_KSEG1(AR5312_FLASH_END-0x1000); | 122 | MIPS_PHYS_TO_KSEG1(AR5312_FLASH_END-0x1000); | |
123 | again: | 123 | again: | |
124 | for (; ptr < end; ptr += 0x1000) | 124 | for (; ptr < end; ptr += 0x1000) | |
125 | if (*(const uint32_t *)ptr != 0xffffffff) { | 125 | if (*(const uint32_t *)ptr != 0xffffffff) { | |
126 | radio = ptr; | 126 | radio = ptr; | |
127 | goto done; | 127 | goto done; | |
128 | } | 128 | } | |
129 | /* sort of an Algol-style for loop ... */ | 129 | /* sort of an Algol-style for loop ... */ | |
130 | if (end == (uint8_t *) MIPS_PHYS_TO_KSEG1(AR5312_FLASH_END)) { | 130 | if (end == (uint8_t *) MIPS_PHYS_TO_KSEG1(AR5312_FLASH_END)) { | |
131 | /* NB: AR2316 has radio data in a different location */ | 131 | /* NB: AR2316 has radio data in a different location */ | |
132 | ptr = baddr + 0xf8; | 132 | ptr = baddr + 0xf8; | |
133 | end = (const uint8_t *) | 133 | end = (const uint8_t *) | |
134 | MIPS_PHYS_TO_KSEG1(AR5312_FLASH_END-0x1000 + 0xf8); | 134 | MIPS_PHYS_TO_KSEG1(AR5312_FLASH_END-0x1000 + 0xf8); | |
135 | goto again; | 135 | goto again; | |
136 | } | 136 | } | |
137 | } | 137 | } | |
138 | done: | 138 | done: | |
139 | return radio; | 139 | return radio; | |
140 | } | 140 | } | |
141 | 141 | |||
142 | /* | 142 | /* | |
143 | * Locate board and radio configuration data in flash. | 143 | * Locate board and radio configuration data in flash. | |
144 | */ | 144 | */ | |
145 | int | 145 | int | |
146 | ar531x_board_config(struct ar531x_config *config) | 146 | ar531x_board_config(struct ar531x_config *config) | |
147 | { | 147 | { | |
148 | 148 | |||
149 | config->board = ar531x_board_info(); | 149 | config->board = ar531x_board_info(); | |
150 | if (config->board == NULL) | 150 | if (config->board == NULL) | |
151 | return ENOENT; | 151 | return ENOENT; | |
152 | config->radio = ar531x_radio_info(); | 152 | config->radio = ar531x_radio_info(); | |
153 | if (config->radio == NULL) | 153 | if (config->radio == NULL) | |
154 | return ENOENT; /* XXX distinct code */ | 154 | return ENOENT; /* XXX distinct code */ | |
155 | return 0; | 155 | return 0; | |
156 | } | 156 | } |
--- src/sys/arch/mips/atheros/ar5315_board.c 2006/09/26 06:37:32 1.1
+++ src/sys/arch/mips/atheros/ar5315_board.c 2009/08/07 06:50:48 1.1.72.1
@@ -1,159 +1,159 @@ | @@ -1,159 +1,159 @@ | |||
1 | /* $NetBSD: ar5315_board.c,v 1.1 2006/09/26 06:37:32 gdamore Exp $ */ | 1 | /* $NetBSD: ar5315_board.c,v 1.1.72.1 2009/08/07 06:50:48 snj Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. | 4 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. | |
5 | * Copyright (c) 2006 Garrett D'Amore. | 5 | * Copyright (c) 2006 Garrett D'Amore. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Portions of this code were written by Garrett D'Amore for the | 8 | * Portions of this code were written by Garrett D'Amore for the | |
9 | * Champaign-Urbana Community Wireless Network Project. | 9 | * Champaign-Urbana Community Wireless Network Project. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or | 11 | * Redistribution and use in source and binary forms, with or | |
12 | * without modification, are permitted provided that the following | 12 | * without modification, are permitted provided that the following | |
13 | * conditions are met: | 13 | * conditions are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
15 | * notice, this list of conditions and the following disclaimer. | 15 | * notice, this list of conditions and the following disclaimer. | |
16 | * 2. Redistributions in binary form must reproduce the above | 16 | * 2. Redistributions in binary form must reproduce the above | |
17 | * copyright notice, this list of conditions and the following | 17 | * copyright notice, this list of conditions and the following | |
18 | * disclaimer in the documentation and/or other materials provided | 18 | * disclaimer in the documentation and/or other materials provided | |
19 | * with the distribution. | 19 | * with the distribution. | |
20 | * 3. All advertising materials mentioning features or use of this | 20 | * 3. All advertising materials mentioning features or use of this | |
21 | * software must display the following acknowledgements: | 21 | * software must display the following acknowledgements: | |
22 | * This product includes software developed by the Urbana-Champaign | 22 | * This product includes software developed by the Urbana-Champaign | |
23 | * Independent Media Center. | 23 | * Independent Media Center. | |
24 | * This product includes software developed by Garrett D'Amore. | 24 | * This product includes software developed by Garrett D'Amore. | |
25 | * 4. Urbana-Champaign Independent Media Center's name and Garrett | 25 | * 4. Urbana-Champaign Independent Media Center's name and Garrett | |
26 | * D'Amore's name may not be used to endorse or promote products | 26 | * D'Amore's name may not be used to endorse or promote products | |
27 | * derived from this software without specific prior written permission. | 27 | * derived from this software without specific prior written permission. | |
28 | * | 28 | * | |
29 | * THIS SOFTWARE IS PROVIDED BY THE URBANA-CHAMPAIGN INDEPENDENT | 29 | * THIS SOFTWARE IS PROVIDED BY THE URBANA-CHAMPAIGN INDEPENDENT | |
30 | * MEDIA CENTER AND GARRETT D'AMORE ``AS IS'' AND ANY EXPRESS OR | 30 | * MEDIA CENTER AND GARRETT D'AMORE ``AS IS'' AND ANY EXPRESS OR | |
31 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 31 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT | 33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT | |
34 | * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, | 34 | * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, | |
35 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 35 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
36 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 36 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
38 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 38 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
41 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 41 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
42 | */ | 42 | */ | |
43 | 43 | |||
44 | /* | 44 | /* | |
45 | * This file provides code to locate board-specific configuration and radio | 45 | * This file provides code to locate board-specific configuration and radio | |
46 | * information data in flash for the AR5315. | 46 | * information data in flash for the AR5315. | |
47 | */ | 47 | */ | |
48 | #include <sys/cdefs.h> | 48 | #include <sys/cdefs.h> | |
49 | __KERNEL_RCSID(0, "$NetBSD: ar5315_board.c,v 1.1 2006/09/26 06:37:32 gdamore Exp $"); | 49 | __KERNEL_RCSID(0, "$NetBSD: ar5315_board.c,v 1.1.72.1 2009/08/07 06:50:48 snj Exp $"); | |
50 | 50 | |||
51 | #include "opt_ddb.h" | 51 | #include "opt_ddb.h" | |
52 | #include "opt_kgdb.h" | 52 | #include "opt_kgdb.h" | |
53 | 53 | |||
54 | #include "opt_memsize.h" | 54 | #include "opt_memsize.h" | |
55 | #include <sys/param.h> | 55 | #include <sys/param.h> | |
56 | #include <sys/systm.h> | 56 | #include <sys/systm.h> | |
57 | #include <sys/kernel.h> | 57 | #include <sys/kernel.h> | |
58 | #include <sys/buf.h> | 58 | #include <sys/buf.h> | |
59 | 59 | |||
60 | #include <dev/cons.h> | 60 | #include <dev/cons.h> | |
61 | 61 | |||
62 | #include <mips/cache.h> | 62 | #include <mips/cache.h> | |
63 | #include <mips/locore.h> | 63 | #include <mips/locore.h> | |
64 | #include <mips/cpuregs.h> | 64 | #include <mips/cpuregs.h> | |
65 | 65 | |||
66 | #include <net/if.h> | 66 | #include <net/if.h> | |
67 | #include <net/if_ether.h> | 67 | #include <net/if_ether.h> | |
68 | 68 | |||
69 | #include <contrib/dev/ath/ah_soc.h> /* XXX really doesn't belong in hal */ | 69 | #include <ah_soc.h> /* XXX really doesn't belong in hal */ | |
70 | 70 | |||
71 | #include <mips/atheros/include/ar5315reg.h> | 71 | #include <mips/atheros/include/ar5315reg.h> | |
72 | #include <mips/atheros/include/ar531xvar.h> | 72 | #include <mips/atheros/include/ar531xvar.h> | |
73 | #include <mips/atheros/include/arbusvar.h> | 73 | #include <mips/atheros/include/arbusvar.h> | |
74 | 74 | |||
75 | #include <machine/locore.h> | 75 | #include <machine/locore.h> | |
76 | #include "com.h" | 76 | #include "com.h" | |
77 | 77 | |||
78 | /* | 78 | /* | |
79 | * Locate the Board Configuration data using heuristics. | 79 | * Locate the Board Configuration data using heuristics. | |
80 | * Search backward from the (aliased) end of flash looking | 80 | * Search backward from the (aliased) end of flash looking | |
81 | * for the signature string that marks the start of the data. | 81 | * for the signature string that marks the start of the data. | |
82 | * We search at most 500KB. | 82 | * We search at most 500KB. | |
83 | */ | 83 | */ | |
84 | const struct ar531x_boarddata * | 84 | const struct ar531x_boarddata * | |
85 | ar531x_board_info(void) | 85 | ar531x_board_info(void) | |
86 | { | 86 | { | |
87 | static const struct ar531x_boarddata *board = NULL; | 87 | static const struct ar531x_boarddata *board = NULL; | |
88 | const uint8_t *ptr, *end; | 88 | const uint8_t *ptr, *end; | |
89 | 89 | |||
90 | if (board == NULL) { | 90 | if (board == NULL) { | |
91 | 91 | |||
92 | /* search backward in the flash looking for the signature */ | 92 | /* search backward in the flash looking for the signature */ | |
93 | ptr = (const uint8_t *) MIPS_PHYS_TO_KSEG1(AR5315_CONFIG_END | 93 | ptr = (const uint8_t *) MIPS_PHYS_TO_KSEG1(AR5315_CONFIG_END | |
94 | - 0x1000); | 94 | - 0x1000); | |
95 | end = (const uint8_t *)AR5315_CONFIG_BASE; | 95 | end = (const uint8_t *)AR5315_CONFIG_BASE; | |
96 | /* XXX validate end */ | 96 | /* XXX validate end */ | |
97 | for (; ptr > end; ptr -= 0x1000) | 97 | for (; ptr > end; ptr -= 0x1000) | |
98 | if (*(const uint32_t *)ptr == AR531X_BD_MAGIC) { | 98 | if (*(const uint32_t *)ptr == AR531X_BD_MAGIC) { | |
99 | board = (const struct ar531x_boarddata *) ptr; | 99 | board = (const struct ar531x_boarddata *) ptr; | |
100 | break; | 100 | break; | |
101 | } | 101 | } | |
102 | } | 102 | } | |
103 | return board; | 103 | return board; | |
104 | } | 104 | } | |
105 | 105 | |||
106 | /* | 106 | /* | |
107 | * Locate the radio configuration data; it is located relative to the | 107 | * Locate the radio configuration data; it is located relative to the | |
108 | * board configuration data. | 108 | * board configuration data. | |
109 | */ | 109 | */ | |
110 | const void * | 110 | const void * | |
111 | ar531x_radio_info(void) | 111 | ar531x_radio_info(void) | |
112 | { | 112 | { | |
113 | static const void *radio = NULL; | 113 | static const void *radio = NULL; | |
114 | const struct ar531x_boarddata *board; | 114 | const struct ar531x_boarddata *board; | |
115 | const uint8_t *baddr, *ptr, *end; | 115 | const uint8_t *baddr, *ptr, *end; | |
116 | 116 | |||
117 | if (radio) | 117 | if (radio) | |
118 | goto done; | 118 | goto done; | |
119 | 119 | |||
120 | board = ar531x_board_info(); | 120 | board = ar531x_board_info(); | |
121 | if (board == NULL) | 121 | if (board == NULL) | |
122 | return NULL; | 122 | return NULL; | |
123 | baddr = (const uint8_t *) board; | 123 | baddr = (const uint8_t *) board; | |
124 | end = (const uint8_t *)MIPS_PHYS_TO_KSEG1(AR5315_RADIO_END); | 124 | end = (const uint8_t *)MIPS_PHYS_TO_KSEG1(AR5315_RADIO_END); | |
125 | 125 | |||
126 | for (ptr = baddr + 0x1000; ptr < end; ptr += 0x1000) | 126 | for (ptr = baddr + 0x1000; ptr < end; ptr += 0x1000) | |
127 | if (*(const uint32_t *)ptr != 0xffffffffU) { | 127 | if (*(const uint32_t *)ptr != 0xffffffffU) { | |
128 | radio = ptr; | 128 | radio = ptr; | |
129 | goto done; | 129 | goto done; | |
130 | } | 130 | } | |
131 | 131 | |||
132 | /* AR2316 moves radio data */ | 132 | /* AR2316 moves radio data */ | |
133 | for (ptr = baddr + 0xf8; ptr < end; ptr += 0x1000) | 133 | for (ptr = baddr + 0xf8; ptr < end; ptr += 0x1000) | |
134 | if (*(const uint32_t *)ptr != 0xffffffffU) { | 134 | if (*(const uint32_t *)ptr != 0xffffffffU) { | |
135 | radio = ptr; | 135 | radio = ptr; | |
136 | goto done; | 136 | goto done; | |
137 | } | 137 | } | |
138 | 138 | |||
139 | done: | 139 | done: | |
140 | return radio; | 140 | return radio; | |
141 | } | 141 | } | |
142 | 142 | |||
143 | /* | 143 | /* | |
144 | * Locate board and radio configuration data in flash. | 144 | * Locate board and radio configuration data in flash. | |
145 | */ | 145 | */ | |
146 | int | 146 | int | |
147 | ar531x_board_config(struct ar531x_config *config) | 147 | ar531x_board_config(struct ar531x_config *config) | |
148 | { | 148 | { | |
149 | 149 | |||
150 | config->board = ar531x_board_info(); | 150 | config->board = ar531x_board_info(); | |
151 | if (config->board == NULL) | 151 | if (config->board == NULL) | |
152 | return ENOENT; | 152 | return ENOENT; | |
153 | 153 | |||
154 | config->radio = ar531x_radio_info(); | 154 | config->radio = ar531x_radio_info(); | |
155 | if (config->radio == NULL) | 155 | if (config->radio == NULL) | |
156 | return ENOENT; /* XXX distinct code */ | 156 | return ENOENT; /* XXX distinct code */ | |
157 | 157 | |||
158 | return 0; | 158 | return 0; | |
159 | } | 159 | } |
--- src/sys/arch/mips/atheros/ar5315.c 2008/01/23 05:23:59 1.5
+++ src/sys/arch/mips/atheros/ar5315.c 2009/08/07 06:50:48 1.5.20.1
@@ -1,386 +1,386 @@ | @@ -1,386 +1,386 @@ | |||
1 | /* $NetBSD: ar5315.c,v 1.5 2008/01/23 05:23:59 dyoung Exp $ */ | 1 | /* $NetBSD: ar5315.c,v 1.5.20.1 2009/08/07 06:50:48 snj Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. | 4 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. | |
5 | * Copyright (c) 2006 Garrett D'Amore. | 5 | * Copyright (c) 2006 Garrett D'Amore. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Portions of this code were written by Garrett D'Amore for the | 8 | * Portions of this code were written by Garrett D'Amore for the | |
9 | * Champaign-Urbana Community Wireless Network Project. | 9 | * Champaign-Urbana Community Wireless Network Project. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or | 11 | * Redistribution and use in source and binary forms, with or | |
12 | * without modification, are permitted provided that the following | 12 | * without modification, are permitted provided that the following | |
13 | * conditions are met: | 13 | * conditions are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
15 | * notice, this list of conditions and the following disclaimer. | 15 | * notice, this list of conditions and the following disclaimer. | |
16 | * 2. Redistributions in binary form must reproduce the above | 16 | * 2. Redistributions in binary form must reproduce the above | |
17 | * copyright notice, this list of conditions and the following | 17 | * copyright notice, this list of conditions and the following | |
18 | * disclaimer in the documentation and/or other materials provided | 18 | * disclaimer in the documentation and/or other materials provided | |
19 | * with the distribution. | 19 | * with the distribution. | |
20 | * 3. All advertising materials mentioning features or use of this | 20 | * 3. All advertising materials mentioning features or use of this | |
21 | * software must display the following acknowledgements: | 21 | * software must display the following acknowledgements: | |
22 | * This product includes software developed by the Urbana-Champaign | 22 | * This product includes software developed by the Urbana-Champaign | |
23 | * Independent Media Center. | 23 | * Independent Media Center. | |
24 | * This product includes software developed by Garrett D'Amore. | 24 | * This product includes software developed by Garrett D'Amore. | |
25 | * 4. Urbana-Champaign Independent Media Center's name and Garrett | 25 | * 4. Urbana-Champaign Independent Media Center's name and Garrett | |
26 | * D'Amore's name may not be used to endorse or promote products | 26 | * D'Amore's name may not be used to endorse or promote products | |
27 | * derived from this software without specific prior written permission. | 27 | * derived from this software without specific prior written permission. | |
28 | * | 28 | * | |
29 | * THIS SOFTWARE IS PROVIDED BY THE URBANA-CHAMPAIGN INDEPENDENT | 29 | * THIS SOFTWARE IS PROVIDED BY THE URBANA-CHAMPAIGN INDEPENDENT | |
30 | * MEDIA CENTER AND GARRETT D'AMORE ``AS IS'' AND ANY EXPRESS OR | 30 | * MEDIA CENTER AND GARRETT D'AMORE ``AS IS'' AND ANY EXPRESS OR | |
31 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 31 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 32 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT | 33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT | |
34 | * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, | 34 | * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, | |
35 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 35 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
36 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 36 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
38 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 38 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 40 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
41 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 41 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
42 | */ | 42 | */ | |
43 | 43 | |||
44 | 44 | |||
45 | /* | 45 | /* | |
46 | * This file includes a bunch of implementation specific bits for | 46 | * This file includes a bunch of implementation specific bits for | |
47 | * AR5315, which differs these from other members of the AR531X | 47 | * AR5315, which differs these from other members of the AR531X | |
48 | * family. | 48 | * family. | |
49 | */ | 49 | */ | |
50 | #include <sys/cdefs.h> | 50 | #include <sys/cdefs.h> | |
51 | __KERNEL_RCSID(0, "$NetBSD: ar5315.c,v 1.5 2008/01/23 05:23:59 dyoung Exp $"); | 51 | __KERNEL_RCSID(0, "$NetBSD: ar5315.c,v 1.5.20.1 2009/08/07 06:50:48 snj Exp $"); | |
52 | 52 | |||
53 | #include "opt_ddb.h" | 53 | #include "opt_ddb.h" | |
54 | #include "opt_kgdb.h" | 54 | #include "opt_kgdb.h" | |
55 | 55 | |||
56 | #include "opt_memsize.h" | 56 | #include "opt_memsize.h" | |
57 | #include <sys/param.h> | 57 | #include <sys/param.h> | |
58 | #include <sys/systm.h> | 58 | #include <sys/systm.h> | |
59 | #include <sys/kernel.h> | 59 | #include <sys/kernel.h> | |
60 | #include <sys/buf.h> | 60 | #include <sys/buf.h> | |
61 | #include <sys/device.h> | 61 | #include <sys/device.h> | |
62 | 62 | |||
63 | #include <mips/cache.h> | 63 | #include <mips/cache.h> | |
64 | #include <mips/locore.h> | 64 | #include <mips/locore.h> | |
65 | #include <mips/cpuregs.h> | 65 | #include <mips/cpuregs.h> | |
66 | 66 | |||
67 | #include <net/if.h> | 67 | #include <net/if.h> | |
68 | #include <net/if_ether.h> | 68 | #include <net/if_ether.h> | |
69 | 69 | |||
70 | #include <prop/proplib.h> | 70 | #include <prop/proplib.h> | |
71 | 71 | |||
72 | #include <contrib/dev/ath/ah_soc.h> /* XXX really doesn't belong in hal */ | 72 | #include <ah_soc.h> /* XXX really doesn't belong in hal */ | |
73 | 73 | |||
74 | #include <mips/atheros/include/ar5315reg.h> | 74 | #include <mips/atheros/include/ar5315reg.h> | |
75 | #include <mips/atheros/include/ar531xvar.h> | 75 | #include <mips/atheros/include/ar531xvar.h> | |
76 | #include <mips/atheros/include/arbusvar.h> | 76 | #include <mips/atheros/include/arbusvar.h> | |
77 | 77 | |||
78 | #include <machine/locore.h> | 78 | #include <machine/locore.h> | |
79 | 79 | |||
80 | /* helper macro for accessing system registers without bus space */ | 80 | /* helper macro for accessing system registers without bus space */ | |
81 | #define REGVAL(x) *((volatile uint32_t *)(MIPS_PHYS_TO_KSEG1((x)))) | 81 | #define REGVAL(x) *((volatile uint32_t *)(MIPS_PHYS_TO_KSEG1((x)))) | |
82 | #define GETSYSREG(x) REGVAL((x) + AR5315_SYSREG_BASE) | 82 | #define GETSYSREG(x) REGVAL((x) + AR5315_SYSREG_BASE) | |
83 | #define PUTSYSREG(x,v) (REGVAL((x) + AR5315_SYSREG_BASE)) = (v) | 83 | #define PUTSYSREG(x,v) (REGVAL((x) + AR5315_SYSREG_BASE)) = (v) | |
84 | #define GETPCIREG(x) REGVAL((x) + AR5315_PCI_BASE) | 84 | #define GETPCIREG(x) REGVAL((x) + AR5315_PCI_BASE) | |
85 | #define PUTPCIREG(x,v) (REGVAL((x) + AR5315_PCI_BASE)) = (v) | 85 | #define PUTPCIREG(x,v) (REGVAL((x) + AR5315_PCI_BASE)) = (v) | |
86 | #define GETSDRAMREG(x) REGVAL((x) + AR5315_SDRAMCTL_BASE) | 86 | #define GETSDRAMREG(x) REGVAL((x) + AR5315_SDRAMCTL_BASE) | |
87 | 87 | |||
88 | uint32_t | 88 | uint32_t | |
89 | ar531x_memsize(void) | 89 | ar531x_memsize(void) | |
90 | { | 90 | { | |
91 | #ifndef MEMSIZE | 91 | #ifndef MEMSIZE | |
92 | uint32_t memsize = 0; | 92 | uint32_t memsize = 0; | |
93 | uint32_t memcfg, cw, rw, dw; | 93 | uint32_t memcfg, cw, rw, dw; | |
94 | 94 | |||
95 | /* | 95 | /* | |
96 | * Determine the memory size. We query the board info. | 96 | * Determine the memory size. We query the board info. | |
97 | */ | 97 | */ | |
98 | memcfg = GETSDRAMREG(AR5315_SDRAMCTL_MEM_CFG); | 98 | memcfg = GETSDRAMREG(AR5315_SDRAMCTL_MEM_CFG); | |
99 | cw = (memcfg & AR5315_MEM_CFG_COL_WIDTH_MASK) >> | 99 | cw = (memcfg & AR5315_MEM_CFG_COL_WIDTH_MASK) >> | |
100 | AR5315_MEM_CFG_COL_WIDTH_SHIFT; | 100 | AR5315_MEM_CFG_COL_WIDTH_SHIFT; | |
101 | cw += 1; | 101 | cw += 1; | |
102 | rw = (memcfg & AR5315_MEM_CFG_ROW_WIDTH_MASK) >> | 102 | rw = (memcfg & AR5315_MEM_CFG_ROW_WIDTH_MASK) >> | |
103 | AR5315_MEM_CFG_ROW_WIDTH_SHIFT; | 103 | AR5315_MEM_CFG_ROW_WIDTH_SHIFT; | |
104 | rw += 1; | 104 | rw += 1; | |
105 | 105 | |||
106 | /* XXX: according to redboot, this could be wrong if DDR SDRAM */ | 106 | /* XXX: according to redboot, this could be wrong if DDR SDRAM */ | |
107 | dw = (memcfg & AR5315_MEM_CFG_DATA_WIDTH_MASK) >> | 107 | dw = (memcfg & AR5315_MEM_CFG_DATA_WIDTH_MASK) >> | |
108 | AR5315_MEM_CFG_DATA_WIDTH_SHIFT; | 108 | AR5315_MEM_CFG_DATA_WIDTH_SHIFT; | |
109 | dw += 1; | 109 | dw += 1; | |
110 | dw *= 8; /* bits */ | 110 | dw *= 8; /* bits */ | |
111 | 111 | |||
112 | /* not too sure about this math, but it _seems_ to add up */ | 112 | /* not too sure about this math, but it _seems_ to add up */ | |
113 | memsize = (1 << cw) * (1 << rw) * dw; | 113 | memsize = (1 << cw) * (1 << rw) * dw; | |
114 | #if 0 | 114 | #if 0 | |
115 | printf("SDRAM_MEM_CFG =%x, cw=%d rw=%d dw=%d xmemsize=%d\n", memcfg, | 115 | printf("SDRAM_MEM_CFG =%x, cw=%d rw=%d dw=%d xmemsize=%d\n", memcfg, | |
116 | cw, rw, dw, memsize); | 116 | cw, rw, dw, memsize); | |
117 | #endif | 117 | #endif | |
118 | 118 | |||
119 | return (memsize); | 119 | return (memsize); | |
120 | #else | 120 | #else | |
121 | /* compile time value forced */ | 121 | /* compile time value forced */ | |
122 | return MEMSIZE; | 122 | return MEMSIZE; | |
123 | #endif | 123 | #endif | |
124 | } | 124 | } | |
125 | 125 | |||
126 | const char * | 126 | const char * | |
127 | ar531x_cpuname(void) | 127 | ar531x_cpuname(void) | |
128 | { | 128 | { | |
129 | uint16_t rev = GETSYSREG(AR5315_SYSREG_SREV); | 129 | uint16_t rev = GETSYSREG(AR5315_SYSREG_SREV); | |
130 | switch (rev) { | 130 | switch (rev) { | |
131 | case 0x52: /* AP30 */ | 131 | case 0x52: /* AP30 */ | |
132 | case 0x57: /* AP31 */ | 132 | case 0x57: /* AP31 */ | |
133 | return "Atheros AR5312"; | 133 | return "Atheros AR5312"; | |
134 | case 0x58: /* AP43 */ | 134 | case 0x58: /* AP43 */ | |
135 | return "Atheros AR2313"; | 135 | return "Atheros AR2313"; | |
136 | case 0x86: /* AP51-Light */ | 136 | case 0x86: /* AP51-Light */ | |
137 | case 0x87: /* AP51-Full */ | 137 | case 0x87: /* AP51-Full */ | |
138 | return "Atheros AR2315"; | 138 | return "Atheros AR2315"; | |
139 | case 0x91: /* AP61 */ | 139 | case 0x91: /* AP61 */ | |
140 | return "Atheros AR2317"; | 140 | return "Atheros AR2317"; | |
141 | } | 141 | } | |
142 | return ("Atheros AR531X"); | 142 | return ("Atheros AR531X"); | |
143 | } | 143 | } | |
144 | 144 | |||
145 | void | 145 | void | |
146 | ar531x_wdog(uint32_t period) | 146 | ar531x_wdog(uint32_t period) | |
147 | { | 147 | { | |
148 | 148 | |||
149 | if (period == 0) { | 149 | if (period == 0) { | |
150 | PUTSYSREG(AR5315_SYSREG_WDOG_CTL, AR5315_WDOG_CTL_IGNORE); | 150 | PUTSYSREG(AR5315_SYSREG_WDOG_CTL, AR5315_WDOG_CTL_IGNORE); | |
151 | PUTSYSREG(AR5315_SYSREG_WDOG_TIMER, 0); | 151 | PUTSYSREG(AR5315_SYSREG_WDOG_TIMER, 0); | |
152 | } else { | 152 | } else { | |
153 | PUTSYSREG(AR5315_SYSREG_WDOG_TIMER, period); | 153 | PUTSYSREG(AR5315_SYSREG_WDOG_TIMER, period); | |
154 | PUTSYSREG(AR5315_SYSREG_WDOG_CTL, AR5315_WDOG_CTL_RESET); | 154 | PUTSYSREG(AR5315_SYSREG_WDOG_CTL, AR5315_WDOG_CTL_RESET); | |
155 | } | 155 | } | |
156 | } | 156 | } | |
157 | 157 | |||
158 | void | 158 | void | |
159 | ar531x_businit(void) | 159 | ar531x_businit(void) | |
160 | { | 160 | { | |
161 | /* | 161 | /* | |
162 | * XXX: clear COP0 config bits 0 and 1 -- Linux sets KSEG0 to either | 162 | * XXX: clear COP0 config bits 0 and 1 -- Linux sets KSEG0 to either | |
163 | * 0 or 4. Why does it do this? It is implementation defined... | 163 | * 0 or 4. Why does it do this? It is implementation defined... | |
164 | */ | 164 | */ | |
165 | mips3_cp0_config_write(mips3_cp0_config_read() & ~0x3); | 165 | mips3_cp0_config_write(mips3_cp0_config_read() & ~0x3); | |
166 | 166 | |||
167 | PUTSYSREG(AR5315_SYSREG_AHB_ERR0, AR5315_AHB_ERROR_DET); | 167 | PUTSYSREG(AR5315_SYSREG_AHB_ERR0, AR5315_AHB_ERROR_DET); | |
168 | GETSYSREG(AR5315_SYSREG_AHB_ERR1); | 168 | GETSYSREG(AR5315_SYSREG_AHB_ERR1); | |
169 | } | 169 | } | |
170 | 170 | |||
171 | static uint32_t | 171 | static uint32_t | |
172 | get_freq(uint32_t clkreg) | 172 | get_freq(uint32_t clkreg) | |
173 | { | 173 | { | |
174 | uint32_t freq = 0; | 174 | uint32_t freq = 0; | |
175 | uint32_t clkctl, pllc, pllout, refdiv, fbdiv, div2, cpudiv; | 175 | uint32_t clkctl, pllc, pllout, refdiv, fbdiv, div2, cpudiv; | |
176 | 176 | |||
177 | static const int pll_divide_table[] = { | 177 | static const int pll_divide_table[] = { | |
178 | 2, 3, 4, 6, 3, | 178 | 2, 3, 4, 6, 3, | |
179 | /* | 179 | /* | |
180 | * these entries are bogus, but it avoids a possible | 180 | * these entries are bogus, but it avoids a possible | |
181 | * bad table dereference | 181 | * bad table dereference | |
182 | */ | 182 | */ | |
183 | 1, 1, 1 | 183 | 1, 1, 1 | |
184 | }; | 184 | }; | |
185 | static const int pre_divide_table[] = { | 185 | static const int pre_divide_table[] = { | |
186 | 1, 2, 4, 5 | 186 | 1, 2, 4, 5 | |
187 | }; | 187 | }; | |
188 | 188 | |||
189 | if (freq) | 189 | if (freq) | |
190 | return freq; | 190 | return freq; | |
191 | 191 | |||
192 | pllc = GETSYSREG(AR5315_SYSREG_PLLC_CTL); | 192 | pllc = GETSYSREG(AR5315_SYSREG_PLLC_CTL); | |
193 | clkctl = GETSYSREG(clkreg); | 193 | clkctl = GETSYSREG(clkreg); | |
194 | 194 | |||
195 | refdiv = pre_divide_table[AR5315_PLLC_REF_DIV(pllc)]; | 195 | refdiv = pre_divide_table[AR5315_PLLC_REF_DIV(pllc)]; | |
196 | fbdiv = AR5315_PLLC_FB_DIV(pllc); | 196 | fbdiv = AR5315_PLLC_FB_DIV(pllc); | |
197 | div2 = (AR5315_PLLC_DIV_2(pllc) + 1) * 2; /* results in 2 or 4 */ | 197 | div2 = (AR5315_PLLC_DIV_2(pllc) + 1) * 2; /* results in 2 or 4 */ | |
198 | 198 | |||
199 | cpudiv = AR5315_CLOCKCTL_DIV(clkctl); | 199 | cpudiv = AR5315_CLOCKCTL_DIV(clkctl); | |
200 | cpudiv = cpudiv ? (cpudiv * 2) : 1; | 200 | cpudiv = cpudiv ? (cpudiv * 2) : 1; | |
201 | 201 | |||
202 | /* 40MHz reference clk, reference and feedback dividers */ | 202 | /* 40MHz reference clk, reference and feedback dividers */ | |
203 | pllout = (40000000 / refdiv) * div2 * fbdiv; | 203 | pllout = (40000000 / refdiv) * div2 * fbdiv; | |
204 | 204 | |||
205 | switch (AR5315_CLOCKCTL_SELECT(clkctl)) { | 205 | switch (AR5315_CLOCKCTL_SELECT(clkctl)) { | |
206 | case 0: | 206 | case 0: | |
207 | case 1: | 207 | case 1: | |
208 | /* CLKM select */ | 208 | /* CLKM select */ | |
209 | pllout /= pll_divide_table[AR5315_PLLC_CLKM(pllc)]; | 209 | pllout /= pll_divide_table[AR5315_PLLC_CLKM(pllc)]; | |
210 | break; | 210 | break; | |
211 | case 2: | 211 | case 2: | |
212 | /* CLKC select */ | 212 | /* CLKC select */ | |
213 | pllout /= pll_divide_table[AR5315_PLLC_CLKC(pllc)]; | 213 | pllout /= pll_divide_table[AR5315_PLLC_CLKC(pllc)]; | |
214 | break; | 214 | break; | |
215 | default: | 215 | default: | |
216 | /* ref_clk select */ | 216 | /* ref_clk select */ | |
217 | pllout = 40000000; /* use original reference clock */ | 217 | pllout = 40000000; /* use original reference clock */ | |
218 | break; | 218 | break; | |
219 | } | 219 | } | |
220 | 220 | |||
221 | freq = pllout/(cpudiv); | 221 | freq = pllout/(cpudiv); | |
222 | 222 | |||
223 | return (freq); | 223 | return (freq); | |
224 | } | 224 | } | |
225 | 225 | |||
226 | uint32_t | 226 | uint32_t | |
227 | ar531x_cpu_freq(void) | 227 | ar531x_cpu_freq(void) | |
228 | { | 228 | { | |
229 | static uint32_t freq = 0; | 229 | static uint32_t freq = 0; | |
230 | if (freq == 0) | 230 | if (freq == 0) | |
231 | freq = get_freq(AR5315_SYSREG_CPUCLK); | 231 | freq = get_freq(AR5315_SYSREG_CPUCLK); | |
232 | return (freq); | 232 | return (freq); | |
233 | } | 233 | } | |
234 | 234 | |||
235 | uint32_t | 235 | uint32_t | |
236 | ar531x_bus_freq(void) | 236 | ar531x_bus_freq(void) | |
237 | { | 237 | { | |
238 | static uint32_t freq = 0; | 238 | static uint32_t freq = 0; | |
239 | if (freq == 0) | 239 | if (freq == 0) | |
240 | freq = get_freq(AR5315_SYSREG_AMBACLK); | 240 | freq = get_freq(AR5315_SYSREG_AMBACLK); | |
241 | return (freq); | 241 | return (freq); | |
242 | } | 242 | } | |
243 | 243 | |||
244 | static void | 244 | static void | |
245 | addprop_data(struct device *dev, const char *name, const uint8_t *data, | 245 | addprop_data(struct device *dev, const char *name, const uint8_t *data, | |
246 | int len) | 246 | int len) | |
247 | { | 247 | { | |
248 | prop_data_t pd; | 248 | prop_data_t pd; | |
249 | pd = prop_data_create_data(data, len); | 249 | pd = prop_data_create_data(data, len); | |
250 | KASSERT(pd != NULL); | 250 | KASSERT(pd != NULL); | |
251 | if (prop_dictionary_set(device_properties(dev), name, pd) == false) { | 251 | if (prop_dictionary_set(device_properties(dev), name, pd) == false) { | |
252 | printf("WARNING: unable to set %s property for %s\n", | 252 | printf("WARNING: unable to set %s property for %s\n", | |
253 | name, device_xname(dev)); | 253 | name, device_xname(dev)); | |
254 | } | 254 | } | |
255 | prop_object_release(pd); | 255 | prop_object_release(pd); | |
256 | } | 256 | } | |
257 | 257 | |||
258 | static void | 258 | static void | |
259 | addprop_integer(struct device *dev, const char *name, uint32_t val) | 259 | addprop_integer(struct device *dev, const char *name, uint32_t val) | |
260 | { | 260 | { | |
261 | prop_number_t pn; | 261 | prop_number_t pn; | |
262 | pn = prop_number_create_integer(val); | 262 | pn = prop_number_create_integer(val); | |
263 | KASSERT(pn != NULL); | 263 | KASSERT(pn != NULL); | |
264 | if (prop_dictionary_set(device_properties(dev), name, pn) == false) { | 264 | if (prop_dictionary_set(device_properties(dev), name, pn) == false) { | |
265 | printf("WARNING: unable to set %s property for %s", | 265 | printf("WARNING: unable to set %s property for %s", | |
266 | name, device_xname(dev)); | 266 | name, device_xname(dev)); | |
267 | } | 267 | } | |
268 | prop_object_release(pn); | 268 | prop_object_release(pn); | |
269 | } | 269 | } | |
270 | 270 | |||
271 | void | 271 | void | |
272 | ar531x_device_register(struct device *dev, void *aux) | 272 | ar531x_device_register(struct device *dev, void *aux) | |
273 | { | 273 | { | |
274 | struct arbus_attach_args *aa = aux; | 274 | struct arbus_attach_args *aa = aux; | |
275 | const struct ar531x_boarddata *info; | 275 | const struct ar531x_boarddata *info; | |
276 | 276 | |||
277 | info = ar531x_board_info(); | 277 | info = ar531x_board_info(); | |
278 | if (info == NULL) { | 278 | if (info == NULL) { | |
279 | /* nothing known about this board! */ | 279 | /* nothing known about this board! */ | |
280 | return; | 280 | return; | |
281 | } | 281 | } | |
282 | 282 | |||
283 | /* | 283 | /* | |
284 | * We don't ever know the boot device. But that's because the | 284 | * We don't ever know the boot device. But that's because the | |
285 | * firmware only loads from the network. | 285 | * firmware only loads from the network. | |
286 | */ | 286 | */ | |
287 | 287 | |||
288 | /* Fetch the MAC addresses. */ | 288 | /* Fetch the MAC addresses. */ | |
289 | if (device_is_a(dev, "ae")) { | 289 | if (device_is_a(dev, "ae")) { | |
290 | const uint8_t *enet; | 290 | const uint8_t *enet; | |
291 | 291 | |||
292 | if (aa->aa_addr == AR5315_ENET_BASE) | 292 | if (aa->aa_addr == AR5315_ENET_BASE) | |
293 | enet = info->enet0Mac; | 293 | enet = info->enet0Mac; | |
294 | else | 294 | else | |
295 | return; | 295 | return; | |
296 | 296 | |||
297 | addprop_data(dev, "mac-addr", enet, ETHER_ADDR_LEN); | 297 | addprop_data(dev, "mac-addr", enet, ETHER_ADDR_LEN); | |
298 | } | 298 | } | |
299 | 299 | |||
300 | if (device_is_a(dev, "ath")) { | 300 | if (device_is_a(dev, "ath")) { | |
301 | const uint8_t *enet; | 301 | const uint8_t *enet; | |
302 | 302 | |||
303 | if (aa->aa_addr == AR5315_WLAN_BASE) | 303 | if (aa->aa_addr == AR5315_WLAN_BASE) | |
304 | enet = info->wlan0Mac; | 304 | enet = info->wlan0Mac; | |
305 | else | 305 | else | |
306 | return; | 306 | return; | |
307 | 307 | |||
308 | addprop_data(dev, "mac-addr", enet, ETHER_ADDR_LEN); | 308 | addprop_data(dev, "mac-addr", enet, ETHER_ADDR_LEN); | |
309 | 309 | |||
310 | addprop_integer(dev, "wmac-rev", | 310 | addprop_integer(dev, "wmac-rev", | |
311 | GETSYSREG(AR5315_SYSREG_SREV)); | 311 | GETSYSREG(AR5315_SYSREG_SREV)); | |
312 | } | 312 | } | |
313 | 313 | |||
314 | if (device_is_a(dev, "com")) { | 314 | if (device_is_a(dev, "com")) { | |
315 | addprop_integer(dev, "frequency", ar531x_bus_freq()); | 315 | addprop_integer(dev, "frequency", ar531x_bus_freq()); | |
316 | } | 316 | } | |
317 | 317 | |||
318 | if (device_is_a(dev, "argpio")) { | 318 | if (device_is_a(dev, "argpio")) { | |
319 | if (info->config & BD_RSTFACTORY) { | 319 | if (info->config & BD_RSTFACTORY) { | |
320 | addprop_integer(dev, "reset-pin", | 320 | addprop_integer(dev, "reset-pin", | |
321 | info->resetConfigGpio); | 321 | info->resetConfigGpio); | |
322 | } | 322 | } | |
323 | if (info->config & BD_SYSLED) { | 323 | if (info->config & BD_SYSLED) { | |
324 | addprop_integer(dev, "sysled-pin", | 324 | addprop_integer(dev, "sysled-pin", | |
325 | info->sysLedGpio); | 325 | info->sysLedGpio); | |
326 | } | 326 | } | |
327 | } | 327 | } | |
328 | } | 328 | } | |
329 | 329 | |||
330 | const struct ar531x_device * | 330 | const struct ar531x_device * | |
331 | ar531x_get_devices(void) | 331 | ar531x_get_devices(void) | |
332 | { | 332 | { | |
333 | const static struct ar531x_device devices[] = { | 333 | const static struct ar531x_device devices[] = { | |
334 | { | 334 | { | |
335 | "com", | 335 | "com", | |
336 | AR5315_UART_BASE, 0x1000, | 336 | AR5315_UART_BASE, 0x1000, | |
337 | AR5315_CPU_IRQ_MISC, AR5315_MISC_IRQ_UART, | 337 | AR5315_CPU_IRQ_MISC, AR5315_MISC_IRQ_UART, | |
338 | 0, 0, 0 | 338 | 0, 0, 0 | |
339 | }, | 339 | }, | |
340 | { | 340 | { | |
341 | "ae", | 341 | "ae", | |
342 | AR5315_ENET_BASE, 0x100000, | 342 | AR5315_ENET_BASE, 0x100000, | |
343 | AR5315_CPU_IRQ_ENET, -1, | 343 | AR5315_CPU_IRQ_ENET, -1, | |
344 | 0, 0, 0 | 344 | 0, 0, 0 | |
345 | }, | 345 | }, | |
346 | { | 346 | { | |
347 | "ath", | 347 | "ath", | |
348 | AR5315_WLAN_BASE, 0x100000, | 348 | AR5315_WLAN_BASE, 0x100000, | |
349 | AR5315_CPU_IRQ_WLAN, -1, | 349 | AR5315_CPU_IRQ_WLAN, -1, | |
350 | 0, 0, 0 | 350 | 0, 0, 0 | |
351 | }, | 351 | }, | |
352 | { | 352 | { | |
353 | "arspi", | 353 | "arspi", | |
354 | AR5315_SPI_BASE, 0x10, | 354 | AR5315_SPI_BASE, 0x10, | |
355 | AR5315_CPU_IRQ_MISC, AR5315_MISC_IRQ_SPI, | 355 | AR5315_CPU_IRQ_MISC, AR5315_MISC_IRQ_SPI, | |
356 | 0, 0, 0 | 356 | 0, 0, 0 | |
357 | }, | 357 | }, | |
358 | { NULL } | 358 | { NULL } | |
359 | }; | 359 | }; | |
360 | 360 | |||
361 | return devices; | 361 | return devices; | |
362 | } | 362 | } | |
363 | 363 | |||
364 | int | 364 | int | |
365 | ar531x_enable_device(const struct ar531x_device *dev) | 365 | ar531x_enable_device(const struct ar531x_device *dev) | |
366 | { | 366 | { | |
367 | if (dev->addr == AR5315_WLAN_BASE) { | 367 | if (dev->addr == AR5315_WLAN_BASE) { | |
368 | /* enable arbitration for wlan */ | 368 | /* enable arbitration for wlan */ | |
369 | PUTSYSREG(AR5315_SYSREG_AHB_ARB_CTL, | 369 | PUTSYSREG(AR5315_SYSREG_AHB_ARB_CTL, | |
370 | GETSYSREG(AR5315_SYSREG_AHB_ARB_CTL) | AR5315_ARB_WLAN); | 370 | GETSYSREG(AR5315_SYSREG_AHB_ARB_CTL) | AR5315_ARB_WLAN); | |
371 | 371 | |||
372 | /* set WLAN for big endian */ | 372 | /* set WLAN for big endian */ | |
373 | PUTSYSREG(AR5315_SYSREG_ENDIAN, | 373 | PUTSYSREG(AR5315_SYSREG_ENDIAN, | |
374 | GETSYSREG(AR5315_SYSREG_ENDIAN) | AR5315_ENDIAN_WLAN); | 374 | GETSYSREG(AR5315_SYSREG_ENDIAN) | AR5315_ENDIAN_WLAN); | |
375 | 375 | |||
376 | /* wake up the mac */ | 376 | /* wake up the mac */ | |
377 | PUTPCIREG(AR5315_PCI_MAC_SCR, | 377 | PUTPCIREG(AR5315_PCI_MAC_SCR, | |
378 | (GETPCIREG(AR5315_PCI_MAC_SCR) & ~PCI_MAC_SCR_SLM_MASK) | | 378 | (GETPCIREG(AR5315_PCI_MAC_SCR) & ~PCI_MAC_SCR_SLM_MASK) | | |
379 | PCI_MAC_SCR_SLM_FWAKE); | 379 | PCI_MAC_SCR_SLM_FWAKE); | |
380 | 380 | |||
381 | /* wait for it to wake up */ | 381 | /* wait for it to wake up */ | |
382 | while (GETPCIREG(AR5315_PCI_MAC_PCICFG) & | 382 | while (GETPCIREG(AR5315_PCI_MAC_PCICFG) & | |
383 | PCI_MAC_PCICFG_SPWR_DN); | 383 | PCI_MAC_PCICFG_SPWR_DN); | |
384 | } | 384 | } | |
385 | return 0; | 385 | return 0; | |
386 | } | 386 | } |
--- src/sys/arch/mips/atheros/dev/if_ath_arbus.c 2008/07/09 19:47:23 1.15
+++ src/sys/arch/mips/atheros/dev/if_ath_arbus.c 2009/08/07 06:50:48 1.15.4.1
@@ -1,193 +1,194 @@ | @@ -1,193 +1,194 @@ | |||
1 | /* $NetBSD: if_ath_arbus.c,v 1.15 2008/07/09 19:47:23 joerg Exp $ */ | 1 | /* $NetBSD: if_ath_arbus.c,v 1.15.4.1 2009/08/07 06:50:48 snj Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006 Jared D. McNeill <jmcneill@invisible.ca> | 4 | * Copyright (c) 2006 Jared D. McNeill <jmcneill@invisible.ca> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
15 | * 3. All advertising materials mentioning features or use of this software | 15 | * 3. All advertising materials mentioning features or use of this software | |
16 | * must display the following acknowledgement: | 16 | * must display the following acknowledgement: | |
17 | * This product includes software developed by the NetBSD | 17 | * This product includes software developed by the NetBSD | |
18 | * Foundation, Inc. and its contributors. | 18 | * Foundation, Inc. and its contributors. | |
19 | * 4. Neither the name of The NetBSD Foundation nor the names of its | 19 | * 4. Neither the name of The NetBSD Foundation nor the names of its | |
20 | * contributors may be used to endorse or promote products derived | 20 | * contributors may be used to endorse or promote products derived | |
21 | * from this software without specific prior written permission. | 21 | * from this software without specific prior written permission. | |
22 | * | 22 | * | |
23 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 23 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
24 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 24 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
25 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 25 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
26 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 26 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
27 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 27 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 31 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
33 | * POSSIBILITY OF SUCH DAMAGE. | 33 | * POSSIBILITY OF SUCH DAMAGE. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: if_ath_arbus.c,v 1.15 2008/07/09 19:47:23 joerg Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: if_ath_arbus.c,v 1.15.4.1 2009/08/07 06:50:48 snj Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/device.h> | 41 | #include <sys/device.h> | |
42 | #include <sys/mbuf.h> | 42 | #include <sys/mbuf.h> | |
43 | #include <sys/malloc.h> | 43 | #include <sys/malloc.h> | |
44 | #include <sys/kernel.h> | 44 | #include <sys/kernel.h> | |
45 | #include <sys/errno.h> | 45 | #include <sys/errno.h> | |
46 | 46 | |||
47 | #include <machine/bus.h> | 47 | #include <machine/bus.h> | |
48 | #include <machine/intr.h> | 48 | #include <machine/intr.h> | |
49 | 49 | |||
50 | #include <net/if.h> | 50 | #include <net/if.h> | |
51 | #include <net/if_media.h> | 51 | #include <net/if_media.h> | |
52 | #include <net/if_ether.h> | 52 | #include <net/if_ether.h> | |
53 | #include <net/if_llc.h> | 53 | #include <net/if_llc.h> | |
54 | #include <net/if_arp.h> | 54 | #include <net/if_arp.h> | |
55 | 55 | |||
56 | #include <netinet/in.h> | 56 | #include <netinet/in.h> | |
57 | 57 | |||
58 | #include <net80211/ieee80211_netbsd.h> | 58 | #include <net80211/ieee80211_netbsd.h> | |
59 | #include <net80211/ieee80211_var.h> | 59 | #include <net80211/ieee80211_var.h> | |
60 | 60 | |||
61 | #include <mips/atheros/include/ar531xvar.h> | 61 | #include <mips/atheros/include/ar531xvar.h> | |
62 | #include <mips/atheros/include/arbusvar.h> | 62 | #include <mips/atheros/include/arbusvar.h> | |
63 | 63 | |||
64 | #include <dev/pci/pcidevs.h> | 64 | #include <dev/pci/pcidevs.h> | |
65 | #include <dev/ic/ath_netbsd.h> | 65 | #include <dev/ic/ath_netbsd.h> | |
66 | #include <dev/ic/athvar.h> | 66 | #include <dev/ic/athvar.h> | |
67 | #include <contrib/dev/ath/ah.h> | 67 | ||
68 | #include <contrib/dev/ath/ah_soc.h> /* XXX really doesn't belong in hal */ | 68 | #include <ah.h> | |
69 | #include <ah_soc.h> /* XXX really doesn't belong in hal */ | |||
69 | 70 | |||
70 | struct ath_arbus_softc { | 71 | struct ath_arbus_softc { | |
71 | struct ath_softc sc_ath; | 72 | struct ath_softc sc_ath; | |
72 | bus_space_tag_t sc_iot; | 73 | bus_space_tag_t sc_iot; | |
73 | bus_space_handle_t sc_ioh; | 74 | bus_space_handle_t sc_ioh; | |
74 | void *sc_ih; | 75 | void *sc_ih; | |
75 | struct ar531x_config sc_config; | 76 | struct ar531x_config sc_config; | |
76 | }; | 77 | }; | |
77 | 78 | |||
78 | static int ath_arbus_match(device_t, cfdata_t, void *); | 79 | static int ath_arbus_match(device_t, cfdata_t, void *); | |
79 | static void ath_arbus_attach(device_t, device_t, void *); | 80 | static void ath_arbus_attach(device_t, device_t, void *); | |
80 | static int ath_arbus_detach(device_t, int); | 81 | static int ath_arbus_detach(device_t, int); | |
81 | 82 | |||
82 | CFATTACH_DECL_NEW(ath_arbus, sizeof(struct ath_arbus_softc), | 83 | CFATTACH_DECL_NEW(ath_arbus, sizeof(struct ath_arbus_softc), | |
83 | ath_arbus_match, ath_arbus_attach, ath_arbus_detach, NULL); | 84 | ath_arbus_match, ath_arbus_attach, ath_arbus_detach, NULL); | |
84 | 85 | |||
85 | static int | 86 | static int | |
86 | ath_arbus_match(device_t parent, cfdata_t cf, void *opaque) | 87 | ath_arbus_match(device_t parent, cfdata_t cf, void *opaque) | |
87 | { | 88 | { | |
88 | struct arbus_attach_args *aa; | 89 | struct arbus_attach_args *aa; | |
89 | 90 | |||
90 | aa = (struct arbus_attach_args *)opaque; | 91 | aa = (struct arbus_attach_args *)opaque; | |
91 | if (strcmp(aa->aa_name, "ath") == 0) | 92 | if (strcmp(aa->aa_name, "ath") == 0) | |
92 | return 1; | 93 | return 1; | |
93 | 94 | |||
94 | return 0; | 95 | return 0; | |
95 | } | 96 | } | |
96 | 97 | |||
97 | static bool | 98 | static bool | |
98 | ath_arbus_resume(device_t dv PMF_FN_ARGS) | 99 | ath_arbus_resume(device_t dv PMF_FN_ARGS) | |
99 | { | 100 | { | |
100 | struct ath_arbus_softc *asc = device_private(dv); | 101 | struct ath_arbus_softc *asc = device_private(dv); | |
101 | ath_resume(&asc->sc_ath); | 102 | ath_resume(&asc->sc_ath); | |
102 | 103 | |||
103 | return true; | 104 | return true; | |
104 | } | 105 | } | |
105 | 106 | |||
106 | 107 | |||
107 | static void | 108 | static void | |
108 | ath_arbus_attach(device_t parent, device_t self, void *opaque) | 109 | ath_arbus_attach(device_t parent, device_t self, void *opaque) | |
109 | { | 110 | { | |
110 | struct ath_arbus_softc *asc; | 111 | struct ath_arbus_softc *asc; | |
111 | struct ath_softc *sc; | 112 | struct ath_softc *sc; | |
112 | struct arbus_attach_args *aa; | 113 | struct arbus_attach_args *aa; | |
113 | const char *name; | 114 | const char *name; | |
114 | prop_number_t prop; | 115 | prop_number_t prop; | |
115 | int rv; | 116 | int rv; | |
116 | uint16_t devid; | 117 | uint16_t devid; | |
117 | 118 | |||
118 | asc = device_private(self); | 119 | asc = device_private(self); | |
119 | sc = &asc->sc_ath; | 120 | sc = &asc->sc_ath; | |
120 | sc->sc_dev = self; | 121 | sc->sc_dev = self; | |
121 | aa = (struct arbus_attach_args *)opaque; | 122 | aa = (struct arbus_attach_args *)opaque; | |
122 | 123 | |||
123 | prop = prop_dictionary_get(device_properties(sc->sc_dev), | 124 | prop = prop_dictionary_get(device_properties(sc->sc_dev), | |
124 | "wmac-rev"); | 125 | "wmac-rev"); | |
125 | if (prop == NULL) { | 126 | if (prop == NULL) { | |
126 | printf(": unable to get wmac-rev property\n"); | 127 | printf(": unable to get wmac-rev property\n"); | |
127 | return; | 128 | return; | |
128 | } | 129 | } | |
129 | KDASSERT(prop_object_type(prop) == PROP_TYPE_NUMBER); | 130 | KDASSERT(prop_object_type(prop) == PROP_TYPE_NUMBER); | |
130 | 131 | |||
131 | devid = (uint16_t)prop_number_integer_value(prop); | 132 | devid = (uint16_t)prop_number_integer_value(prop); | |
132 | name = ath_hal_probe(PCI_VENDOR_ATHEROS, devid); | 133 | name = ath_hal_probe(PCI_VENDOR_ATHEROS, devid); | |
133 | 134 | |||
134 | printf(": %s\n", name ? name : "Unknown AR531X WLAN"); | 135 | printf(": %s\n", name ? name : "Unknown AR531X WLAN"); | |
135 | 136 | |||
136 | asc->sc_iot = aa->aa_bst; | 137 | asc->sc_iot = aa->aa_bst; | |
137 | rv = bus_space_map(asc->sc_iot, aa->aa_addr, aa->aa_size, 0, | 138 | rv = bus_space_map(asc->sc_iot, aa->aa_addr, aa->aa_size, 0, | |
138 | &asc->sc_ioh); | 139 | &asc->sc_ioh); | |
139 | if (rv) { | 140 | if (rv) { | |
140 | aprint_error_dev(self, "unable to map registers\n"); | 141 | aprint_error_dev(self, "unable to map registers\n"); | |
141 | return; | 142 | return; | |
142 | } | 143 | } | |
143 | /* | 144 | /* | |
144 | * Setup HAL configuration state for use by the driver. | 145 | * Setup HAL configuration state for use by the driver. | |
145 | */ | 146 | */ | |
146 | rv = ar531x_board_config(&asc->sc_config); | 147 | rv = ar531x_board_config(&asc->sc_config); | |
147 | if (rv) { | 148 | if (rv) { | |
148 | aprint_error_dev(self, "unable to locate board configuration\n"); | 149 | aprint_error_dev(self, "unable to locate board configuration\n"); | |
149 | return; | 150 | return; | |
150 | } | 151 | } | |
151 | asc->sc_config.unit = device_unit(sc->sc_dev); | 152 | asc->sc_config.unit = device_unit(sc->sc_dev); | |
152 | asc->sc_config.tag = asc->sc_iot; | 153 | asc->sc_config.tag = asc->sc_iot; | |
153 | 154 | |||
154 | /* NB: the HAL expects the config state passed as the tag */ | 155 | /* NB: the HAL expects the config state passed as the tag */ | |
155 | sc->sc_st = (HAL_BUS_TAG) &asc->sc_config; | 156 | sc->sc_st = (HAL_BUS_TAG) &asc->sc_config; | |
156 | sc->sc_sh = (HAL_BUS_HANDLE) asc->sc_ioh; | 157 | sc->sc_sh = (HAL_BUS_HANDLE) asc->sc_ioh; | |
157 | sc->sc_dmat = aa->aa_dmat; | 158 | sc->sc_dmat = aa->aa_dmat; | |
158 | 159 | |||
159 | asc->sc_ih = arbus_intr_establish(aa->aa_cirq, aa->aa_mirq, ath_intr, | 160 | asc->sc_ih = arbus_intr_establish(aa->aa_cirq, aa->aa_mirq, ath_intr, | |
160 | sc); | 161 | sc); | |
161 | if (asc->sc_ih == NULL) { | 162 | if (asc->sc_ih == NULL) { | |
162 | aprint_error_dev(self, "couldn't establish interrupt\n"); | 163 | aprint_error_dev(self, "couldn't establish interrupt\n"); | |
163 | return; | 164 | return; | |
164 | } | 165 | } | |
165 | 166 | |||
166 | ATH_LOCK_INIT(sc); | 167 | ATH_LOCK_INIT(sc); | |
167 | 168 | |||
168 | if (!pmf_device_register(self, NULL, ath_arbus_resume)) | 169 | if (!pmf_device_register(self, NULL, ath_arbus_resume)) | |
169 | aprint_error_dev(self, "couldn't establish power handler\n"); | 170 | aprint_error_dev(self, "couldn't establish power handler\n"); | |
170 | else | 171 | else | |
171 | pmf_class_network_register(self, &sc->sc_if); | 172 | pmf_class_network_register(self, &sc->sc_if); | |
172 | 173 | |||
173 | if (ath_attach(devid, sc) != 0) { | 174 | if (ath_attach(devid, sc) != 0) { | |
174 | aprint_error_dev(self, "ath_attach failed\n"); | 175 | aprint_error_dev(self, "ath_attach failed\n"); | |
175 | goto err; | 176 | goto err; | |
176 | } | 177 | } | |
177 | 178 | |||
178 | return; | 179 | return; | |
179 | 180 | |||
180 | err: | 181 | err: | |
181 | arbus_intr_disestablish(asc->sc_ih); | 182 | arbus_intr_disestablish(asc->sc_ih); | |
182 | } | 183 | } | |
183 | 184 | |||
184 | static int | 185 | static int | |
185 | ath_arbus_detach(device_t self, int flags) | 186 | ath_arbus_detach(device_t self, int flags) | |
186 | { | 187 | { | |
187 | struct ath_arbus_softc *asc = device_private(self); | 188 | struct ath_arbus_softc *asc = device_private(self); | |
188 | 189 | |||
189 | ath_detach(&asc->sc_ath); | 190 | ath_detach(&asc->sc_ath); | |
190 | arbus_intr_disestablish(asc->sc_ih); | 191 | arbus_intr_disestablish(asc->sc_ih); | |
191 | 192 | |||
192 | return (0); | 193 | return (0); | |
193 | } | 194 | } |
--- src/sys/arch/mips/atheros/include/ar5312reg.h 2006/09/04 05:17:26 1.2
+++ src/sys/arch/mips/atheros/include/ar5312reg.h 2009/08/07 06:50:48 1.2.74.1
@@ -1,229 +1,230 @@ | @@ -1,229 +1,230 @@ | |||
1 | /* $Id: ar5312reg.h,v 1.2 2006/09/04 05:17:26 gdamore Exp $ */ | 1 | /* $Id: ar5312reg.h,v 1.2.74.1 2009/08/07 06:50:48 snj Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. | 3 | * Copyright (c) 2006 Urbana-Champaign Independent Media Center. | |
4 | * Copyright (c) 2006 Garrett D'Amore. | 4 | * Copyright (c) 2006 Garrett D'Amore. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code was written by Garrett D'Amore for the Champaign-Urbana | 7 | * This code was written by Garrett D'Amore for the Champaign-Urbana | |
8 | * Community Wireless Network Project. | 8 | * Community Wireless Network Project. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or | 10 | * Redistribution and use in source and binary forms, with or | |
11 | * without modification, are permitted provided that the following | 11 | * without modification, are permitted provided that the following | |
12 | * conditions are met: | 12 | * conditions are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above | 15 | * 2. Redistributions in binary form must reproduce the above | |
16 | * copyright notice, this list of conditions and the following | 16 | * copyright notice, this list of conditions and the following | |
17 | * disclaimer in the documentation and/or other materials provided | 17 | * disclaimer in the documentation and/or other materials provided | |
18 | * with the distribution. | 18 | * with the distribution. | |
19 | * 3. All advertising materials mentioning features or use of this | 19 | * 3. All advertising materials mentioning features or use of this | |
20 | * software must display the following acknowledgements: | 20 | * software must display the following acknowledgements: | |
21 | * This product includes software developed by the Urbana-Champaign | 21 | * This product includes software developed by the Urbana-Champaign | |
22 | * Independent Media Center. | 22 | * Independent Media Center. | |
23 | * This product includes software developed by Garrett D'Amore. | 23 | * This product includes software developed by Garrett D'Amore. | |
24 | * 4. Urbana-Champaign Independent Media Center's name and Garrett | 24 | * 4. Urbana-Champaign Independent Media Center's name and Garrett | |
25 | * D'Amore's name may not be used to endorse or promote products | 25 | * D'Amore's name may not be used to endorse or promote products | |
26 | * derived from this software without specific prior written permission. | 26 | * derived from this software without specific prior written permission. | |
27 | * | 27 | * | |
28 | * THIS SOFTWARE IS PROVIDED BY THE URBANA-CHAMPAIGN INDEPENDENT | 28 | * THIS SOFTWARE IS PROVIDED BY THE URBANA-CHAMPAIGN INDEPENDENT | |
29 | * MEDIA CENTER AND GARRETT D'AMORE ``AS IS'' AND ANY EXPRESS OR | 29 | * MEDIA CENTER AND GARRETT D'AMORE ``AS IS'' AND ANY EXPRESS OR | |
30 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 30 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
31 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 31 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT | 32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT | |
33 | * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, | 33 | * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, | |
34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
35 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 35 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
38 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 38 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
39 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 39 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
40 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 40 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
41 | */ | 41 | */ | |
42 | 42 | |||
43 | #ifndef _MIPS_ATHEROS_AR5312REG_H_ | 43 | #ifndef _MIPS_ATHEROS_AR5312REG_H_ | |
44 | #define _MIPS_ATHEROS_AR5312REG_H_ | 44 | #define _MIPS_ATHEROS_AR5312REG_H_ | |
45 | 45 | |||
46 | #define AR5312_MEM0_BASE 0x00000000 /* sdram */ | 46 | #define AR5312_MEM0_BASE 0x00000000 /* sdram */ | |
47 | #define AR5312_MEM1_BASE 0x08000000 /* sdram/flash */ | 47 | #define AR5312_MEM1_BASE 0x08000000 /* sdram/flash */ | |
48 | #define AR5312_MEM3_BASE 0x10000000 /* flash */ | 48 | #define AR5312_MEM3_BASE 0x10000000 /* flash */ | |
49 | #define AR5312_WLAN0_BASE 0x18000000 | 49 | #define AR5312_WLAN0_BASE 0x18000000 | |
50 | #define AR5312_ENET0_BASE 0x18100000 | 50 | #define AR5312_ENET0_BASE 0x18100000 | |
51 | #define AR5312_ENET1_BASE 0x18200000 | 51 | #define AR5312_ENET1_BASE 0x18200000 | |
52 | #define AR5312_SDRAMCTL_BASE 0x18300000 | 52 | #define AR5312_SDRAMCTL_BASE 0x18300000 | |
53 | #define AR5312_FLASHCTL_BASE 0x18400000 | 53 | #define AR5312_FLASHCTL_BASE 0x18400000 | |
54 | #define AR5312_WLAN1_BASE 0x18500000 | 54 | #define AR5312_WLAN1_BASE 0x18500000 | |
55 | #define AR5312_UART0_BASE 0x1C000000 /* high speed */ | 55 | #define AR5312_UART0_BASE 0x1C000000 /* high speed */ | |
56 | #define AR5312_UART1_BASE 0x1C001000 | 56 | #define AR5312_UART1_BASE 0x1C001000 | |
57 | #define AR5312_GPIO_BASE 0x1C002000 | 57 | #define AR5312_GPIO_BASE 0x1C002000 | |
58 | #define AR5312_SYSREG_BASE 0x1C003000 | 58 | #define AR5312_SYSREG_BASE 0x1C003000 | |
59 | #define AR5312_UARTDMA_BASE 0x1C004000 | 59 | #define AR5312_UARTDMA_BASE 0x1C004000 | |
60 | #define AR5312_FLASH_BASE 0x1E000000 | 60 | #define AR5312_FLASH_BASE 0x1E000000 | |
61 | #define AR5312_FLASH_END 0x20000000 /* possibly aliased */ | 61 | #define AR5312_FLASH_END 0x20000000 /* possibly aliased */ | |
62 | 62 | |||
63 | /* | 63 | /* | |
64 | * FLASHCTL registers -- offset relative to AR531X_FLASHCTL_BASE | 64 | * FLASHCTL registers -- offset relative to AR531X_FLASHCTL_BASE | |
65 | */ | 65 | */ | |
66 | #define AR5312_FLASHCTL_0 0x00 | 66 | #define AR5312_FLASHCTL_0 0x00 | |
67 | #define AR5312_FLASHCTL_1 0x04 | 67 | #define AR5312_FLASHCTL_1 0x04 | |
68 | #define AR5312_FLASHCTL_2 0x08 | 68 | #define AR5312_FLASHCTL_2 0x08 | |
69 | 69 | |||
70 | #define AR5312_FLASHCTL_IDCY_MASK 0xf /* idle cycle turn */ | 70 | #define AR5312_FLASHCTL_IDCY_MASK 0xf /* idle cycle turn */ | |
71 | #define AR5312_FLASHCTL_IDCY_SHIFT 0 | 71 | #define AR5312_FLASHCTL_IDCY_SHIFT 0 | |
72 | #define AR5312_FLASHCTL_WST1_MASK 0x3e0 /* wait state 1 */ | 72 | #define AR5312_FLASHCTL_WST1_MASK 0x3e0 /* wait state 1 */ | |
73 | #define AR5312_FLASHCTL_WST1_SHIFT 5 | 73 | #define AR5312_FLASHCTL_WST1_SHIFT 5 | |
74 | #define AR5312_FLASHCTL_WST2_MASK 0xf800 /* wait state 1 */ | 74 | #define AR5312_FLASHCTL_WST2_MASK 0xf800 /* wait state 1 */ | |
75 | #define AR5312_FLASHCTL_WST2_SHIFT 11 | 75 | #define AR5312_FLASHCTL_WST2_SHIFT 11 | |
76 | #define AR5312_FLASHCTL_RBLE 0x00000400 /* rd byte enable */ | 76 | #define AR5312_FLASHCTL_RBLE 0x00000400 /* rd byte enable */ | |
77 | #define AR5312_FLASHCTL_AC_MASK 0x00070000 /* addr chk */ | 77 | #define AR5312_FLASHCTL_AC_MASK 0x00070000 /* addr chk */ | |
78 | #define AR5312_FLASHCTL_AC_SHIFT 16 | 78 | #define AR5312_FLASHCTL_AC_SHIFT 16 | |
79 | #define AR5312_FLASHCTL_AC_128K 0x00000000 | 79 | #define AR5312_FLASHCTL_AC_128K 0x00000000 | |
80 | #define AR5312_FLASHCTL_AC_256K 0x00010000 | 80 | #define AR5312_FLASHCTL_AC_256K 0x00010000 | |
81 | #define AR5312_FLASHCTL_AC_512K 0x00020000 | 81 | #define AR5312_FLASHCTL_AC_512K 0x00020000 | |
82 | #define AR5312_FLASHCTL_AC_1M 0x00030000 | 82 | #define AR5312_FLASHCTL_AC_1M 0x00030000 | |
83 | #define AR5312_FLASHCTL_AC_2M 0x00040000 | 83 | #define AR5312_FLASHCTL_AC_2M 0x00040000 | |
84 | #define AR5312_FLASHCTL_AC_4M 0x00050000 | 84 | #define AR5312_FLASHCTL_AC_4M 0x00050000 | |
85 | #define AR5312_FLASHCTL_AC_8M 0x00060000 | 85 | #define AR5312_FLASHCTL_AC_8M 0x00060000 | |
86 | #define AR5312_FLASHCTL_AC_16M 0x00070000 | 86 | #define AR5312_FLASHCTL_AC_16M 0x00070000 | |
87 | #define AR5312_FLASHCTL_E 0x00080000 /* enable */ | 87 | #define AR5312_FLASHCTL_E 0x00080000 /* enable */ | |
88 | #define AR5312_FLASHCTL_MW_MASK 0x30000000 /* mem width */ | 88 | #define AR5312_FLASHCTL_MW_MASK 0x30000000 /* mem width */ | |
89 | 89 | |||
90 | /* | 90 | /* | |
91 | * SYSREG registers -- offset relative to AR531X_SYSREG_BASE | 91 | * SYSREG registers -- offset relative to AR531X_SYSREG_BASE | |
92 | */ | 92 | */ | |
93 | #define AR5312_SYSREG_TIMER 0x0000 | 93 | #define AR5312_SYSREG_TIMER 0x0000 | |
94 | #define AR5312_SYSREG_TIMER_RELOAD 0x0004 | 94 | #define AR5312_SYSREG_TIMER_RELOAD 0x0004 | |
95 | #define AR5312_SYSREG_WDOG_CTL 0x0008 | 95 | #define AR5312_SYSREG_WDOG_CTL 0x0008 | |
96 | #define AR5312_SYSREG_WDOG_TIMER 0x000c | 96 | #define AR5312_SYSREG_WDOG_TIMER 0x000c | |
97 | #define AR5312_SYSREG_MISC_INTSTAT 0x0010 | 97 | #define AR5312_SYSREG_MISC_INTSTAT 0x0010 | |
98 | #define AR5312_SYSREG_MISC_INTMASK 0x0014 | 98 | #define AR5312_SYSREG_MISC_INTMASK 0x0014 | |
99 | #define AR5312_SYSREG_INTSTAT 0x0018 | 99 | #define AR5312_SYSREG_INTSTAT 0x0018 | |
100 | #define AR5312_SYSREG_RESETCTL 0x0020 | 100 | #define AR5312_SYSREG_RESETCTL 0x0020 | |
101 | #define AR5312_SYSREG_CLOCKCTL 0x0064 | 101 | #define AR5312_SYSREG_CLOCKCTL 0x0064 | |
102 | #define AR5312_SYSREG_SCRATCH 0x006c | 102 | #define AR5312_SYSREG_SCRATCH 0x006c | |
103 | #define AR5312_SYSREG_AHBPERR 0x0070 | 103 | #define AR5312_SYSREG_AHBPERR 0x0070 | |
104 | #define AR5312_SYSREG_AHBDMAE 0x0078 | 104 | #define AR5312_SYSREG_AHBDMAE 0x0078 | |
105 | #define AR5312_SYSREG_ENABLE 0x0080 | 105 | #define AR5312_SYSREG_ENABLE 0x0080 | |
106 | #define AR5312_SYSREG_REVISION 0x0090 | 106 | #define AR5312_SYSREG_REVISION 0x0090 | |
107 | 107 | |||
108 | /* WDOG_CTL watchdog control bits */ | 108 | /* WDOG_CTL watchdog control bits */ | |
109 | #define AR5312_WDOG_CTL_IGNORE 0x0000 | 109 | #define AR5312_WDOG_CTL_IGNORE 0x0000 | |
110 | #define AR5312_WDOG_CTL_NMI 0x0001 | 110 | #define AR5312_WDOG_CTL_NMI 0x0001 | |
111 | #define AR5312_WDOG_CTL_RESET 0x0002 | 111 | #define AR5312_WDOG_CTL_RESET 0x0002 | |
112 | 112 | |||
113 | /* Resets */ | 113 | /* Resets */ | |
114 | #define AR5312_RESET_SYSTEM 0x00000001 | 114 | #define AR5312_RESET_SYSTEM 0x00000001 | |
115 | #define AR5312_RESET_CPU 0x00000002 | 115 | #define AR5312_RESET_CPU 0x00000002 | |
116 | #define AR5312_RESET_WLAN0 0x00000004 /* mac & bb */ | 116 | #define AR5312_RESET_WLAN0 0x00000004 /* mac & bb */ | |
117 | #define AR5312_RESET_PHY0 0x00000008 /* enet phy */ | 117 | #define AR5312_RESET_PHY0 0x00000008 /* enet phy */ | |
118 | #define AR5312_RESET_PHY1 0x00000010 /* enet phy */ | 118 | #define AR5312_RESET_PHY1 0x00000010 /* enet phy */ | |
119 | #define AR5312_RESET_ENET0 0x00000020 /* mac */ | 119 | #define AR5312_RESET_ENET0 0x00000020 /* mac */ | |
120 | #define AR5312_RESET_ENET1 0x00000040 /* mac */ | 120 | #define AR5312_RESET_ENET1 0x00000040 /* mac */ | |
121 | #define AR5312_RESET_UART0 0x00000100 /* mac */ | 121 | #define AR5312_RESET_UART0 0x00000100 /* mac */ | |
122 | #define AR5312_RESET_WLAN1 0x00000200 /* mac & bb */ | 122 | #define AR5312_RESET_WLAN1 0x00000200 /* mac & bb */ | |
123 | #define AR5312_RESET_APB 0x00000400 /* bridge */ | 123 | #define AR5312_RESET_APB 0x00000400 /* bridge */ | |
124 | #define AR5312_RESET_WARM_CPU 0x00001000 | 124 | #define AR5312_RESET_WARM_CPU 0x00001000 | |
125 | #define AR5312_RESET_WARM_WLAN0_MAC 0x00002000 | 125 | #define AR5312_RESET_WARM_WLAN0_MAC 0x00002000 | |
126 | #define AR5312_RESET_WARM_WLAN0_BB 0x00004000 | 126 | #define AR5312_RESET_WARM_WLAN0_BB 0x00004000 | |
127 | #define AR5312_RESET_NMI 0x00010000 | 127 | #define AR5312_RESET_NMI 0x00010000 | |
128 | #define AR5312_RESET_WARM_WLAN1_MAC 0x00020000 | 128 | #define AR5312_RESET_WARM_WLAN1_MAC 0x00020000 | |
129 | #define AR5312_RESET_WARM_WLAN1_BB 0x00040000 | 129 | #define AR5312_RESET_WARM_WLAN1_BB 0x00040000 | |
130 | #define AR5312_RESET_LOCAL_BUS 0x00080000 | 130 | #define AR5312_RESET_LOCAL_BUS 0x00080000 | |
131 | #define AR5312_RESET_WDOG 0x00100000 | 131 | #define AR5312_RESET_WDOG 0x00100000 | |
132 | 132 | |||
133 | /* AR5312/2312 clockctl bits */ | 133 | /* AR5312/2312 clockctl bits */ | |
134 | #define AR5312_CLOCKCTL_PREDIVIDE_MASK 0x00000030 | 134 | #define AR5312_CLOCKCTL_PREDIVIDE_MASK 0x00000030 | |
135 | #define AR5312_CLOCKCTL_PREDIVIDE_SHIFT 4 | 135 | #define AR5312_CLOCKCTL_PREDIVIDE_SHIFT 4 | |
136 | #define AR5312_CLOCKCTL_MULTIPLIER_MASK 0x00001f00 | 136 | #define AR5312_CLOCKCTL_MULTIPLIER_MASK 0x00001f00 | |
137 | #define AR5312_CLOCKCTL_MULTIPLIER_SHIFT 8 | 137 | #define AR5312_CLOCKCTL_MULTIPLIER_SHIFT 8 | |
138 | #define AR5312_CLOCKCTL_DOUBLER_MASK 0x00010000 | 138 | #define AR5312_CLOCKCTL_DOUBLER_MASK 0x00010000 | |
139 | 139 | |||
140 | /* AR2313 clockctl */ | 140 | /* AR2313 clockctl */ | |
141 | #define AR2313_CLOCKCTL_PREDIVIDE_MASK 0x00003000 | 141 | #define AR2313_CLOCKCTL_PREDIVIDE_MASK 0x00003000 | |
142 | #define AR2313_CLOCKCTL_PREDIVIDE_SHIFT 12 | 142 | #define AR2313_CLOCKCTL_PREDIVIDE_SHIFT 12 | |
143 | #define AR2313_CLOCKCTL_MULTIPLIER_MASK 0x001f0000 | 143 | #define AR2313_CLOCKCTL_MULTIPLIER_MASK 0x001f0000 | |
144 | #define AR2313_CLOCKCTL_MULTIPLIER_SHIFT 16 | 144 | #define AR2313_CLOCKCTL_MULTIPLIER_SHIFT 16 | |
145 | #define AR2313_CLOCKCTL_DOUBLER_MASK 0x00000000 | 145 | #define AR2313_CLOCKCTL_DOUBLER_MASK 0x00000000 | |
146 | 146 | |||
147 | /* Enables */ | 147 | /* Enables */ | |
148 | #define AR5312_ENABLE_WLAN0 0x0001 | 148 | #define AR5312_ENABLE_WLAN0 0x0001 | |
149 | #define AR5312_ENABLE_ENET0 0x0002 | 149 | #define AR5312_ENABLE_ENET0 0x0002 | |
150 | #define AR5312_ENABLE_ENET1 0x0004 | 150 | #define AR5312_ENABLE_ENET1 0x0004 | |
151 | #define AR5312_ENABLE_WLAN1 0x0018 /* both DMA and PIO */ | 151 | #define AR5312_ENABLE_WLAN1 0x0018 /* both DMA and PIO */ | |
152 | 152 | |||
153 | /* Revision ids */ | 153 | /* Revision ids */ | |
154 | #define AR5312_REVISION_WMAC_MAJOR(x) (((x) >> 12) & 0xf) | 154 | #define AR5312_REVISION_WMAC_MAJOR(x) (((x) >> 12) & 0xf) | |
155 | #define AR5312_REVISION_WMAC_MINOR(x) (((x) >> 8) & 0xf) | 155 | #define AR5312_REVISION_WMAC_MINOR(x) (((x) >> 8) & 0xf) | |
156 | #define AR5312_REVISION_WMAC(x) (((x) >> 8) & 0xff) | 156 | #define AR5312_REVISION_WMAC(x) (((x) >> 8) & 0xff) | |
157 | #define AR5312_REVISION_MAJOR(x) (((x) >> 4) & 0xf) | 157 | #define AR5312_REVISION_MAJOR(x) (((x) >> 4) & 0xf) | |
158 | #define AR5312_REVISION_MINOR(x) (((x) >> 0) & 0xf) | 158 | #define AR5312_REVISION_MINOR(x) (((x) >> 0) & 0xf) | |
159 | 159 | |||
160 | #define AR5312_REVISION_MAJ_AR5311 0x1 | 160 | #define AR5312_REVISION_MAJ_AR5311 0x1 | |
161 | #define AR5312_REVISION_MAJ_AR5312 0x4 | 161 | #define AR5312_REVISION_MAJ_AR5312 0x4 | |
162 | #define AR5312_REVISION_MAJ_AR2313 0x5 | 162 | #define AR5312_REVISION_MAJ_AR2313 0x5 | |
163 | #define AR5312_REVISION_MAJ_AR5315 0xB | 163 | #define AR5312_REVISION_MAJ_AR5315 0xB | |
164 | 164 | |||
165 | /* | 165 | /* | |
166 | * SDRAMCTL registers -- offset relative to SDRAMCTL | 166 | * SDRAMCTL registers -- offset relative to SDRAMCTL | |
167 | */ | 167 | */ | |
168 | #define AR5312_SDRAMCTL_MEM_CFG0 0x0000 | 168 | #define AR5312_SDRAMCTL_MEM_CFG0 0x0000 | |
169 | #define AR5312_SDRAMCTL_MEM_CFG1 0x0004 | 169 | #define AR5312_SDRAMCTL_MEM_CFG1 0x0004 | |
170 | 170 | |||
171 | /* memory config 1 bits */ | 171 | /* memory config 1 bits */ | |
172 | #define AR5312_MEM_CFG1_BANK0_MASK 0x00000700 | 172 | #define AR5312_MEM_CFG1_BANK0_MASK 0x00000700 | |
173 | #define AR5312_MEM_CFG1_BANK0_SHIFT 8 | 173 | #define AR5312_MEM_CFG1_BANK0_SHIFT 8 | |
174 | #define AR5312_MEM_CFG1_BANK1_MASK 0x00007000 | 174 | #define AR5312_MEM_CFG1_BANK1_MASK 0x00007000 | |
175 | #define AR5312_MEM_CFG1_BANK1_SHIFT 12 | 175 | #define AR5312_MEM_CFG1_BANK1_SHIFT 12 | |
176 | 176 | |||
177 | /* helper macro for accessing system registers without bus space */ | 177 | /* helper macro for accessing system registers without bus space */ | |
178 | #define REGVAL(x) *((volatile uint32_t *)(MIPS_PHYS_TO_KSEG1((x)))) | 178 | #define REGVAL(x) *((volatile uint32_t *)(MIPS_PHYS_TO_KSEG1((x)))) | |
179 | #define GETSYSREG(x) REGVAL((x) + AR5312_SYSREG_BASE) | 179 | #define GETSYSREG(x) REGVAL((x) + AR5312_SYSREG_BASE) | |
180 | #define PUTSYSREG(x,v) (REGVAL((x) + AR5312_SYSREG_BASE)) = (v) | 180 | #define PUTSYSREG(x,v) (REGVAL((x) + AR5312_SYSREG_BASE)) = (v) | |
181 | #define GETSDRAMREG(x) REGVAL((x) + AR5312_SDRAMCTL_BASE) | 181 | #define GETSDRAMREG(x) REGVAL((x) + AR5312_SDRAMCTL_BASE) | |
182 | #define PUTSDRAMREG(x,v) (REGVAL((x) + AR5312_SDRAMCTL_BASE)) = (v) | 182 | #define PUTSDRAMREG(x,v) (REGVAL((x) + AR5312_SDRAMCTL_BASE)) = (v) | |
183 | 183 | |||
184 | /* | 184 | /* | |
185 | * Interrupts. | 185 | * Interrupts. | |
186 | */ | 186 | */ | |
187 | #define AR5312_IRQ_WLAN0 0 | 187 | #define AR5312_IRQ_WLAN0 0 | |
188 | #define AR5312_IRQ_ENET0 1 | 188 | #define AR5312_IRQ_ENET0 1 | |
189 | #define AR5312_IRQ_ENET1 2 | 189 | #define AR5312_IRQ_ENET1 2 | |
190 | #define AR5312_IRQ_WLAN1 3 | 190 | #define AR5312_IRQ_WLAN1 3 | |
191 | #define AR5312_IRQ_MISC 4 | 191 | #define AR5312_IRQ_MISC 4 | |
192 | 192 | |||
193 | #define AR5312_MISC_IRQ_TIMER 0 | 193 | #define AR5312_MISC_IRQ_TIMER 0 | |
194 | #define AR5312_MISC_IRQ_AHBPERR 1 | 194 | #define AR5312_MISC_IRQ_AHBPERR 1 | |
195 | #define AR5312_MISC_IRQ_AHBDMAE 2 | 195 | #define AR5312_MISC_IRQ_AHBDMAE 2 | |
196 | #define AR5312_MISC_IRQ_GPIO 3 | 196 | #define AR5312_MISC_IRQ_GPIO 3 | |
197 | #define AR5312_MISC_IRQ_UART0 4 | 197 | #define AR5312_MISC_IRQ_UART0 4 | |
198 | #define AR5312_MISC_IRQ_UART0_DMA 5 | 198 | #define AR5312_MISC_IRQ_UART0_DMA 5 | |
199 | #define AR5312_MISC_IRQ_WDOG 6 | 199 | #define AR5312_MISC_IRQ_WDOG 6 | |
200 | ||||
200 | /* | 201 | /* | |
201 | * Board data. This is located in flash somewhere, ar531x_board_info | 202 | * Board data. This is located in flash somewhere, ar531x_board_info | |
202 | * locates it. | 203 | * locates it. | |
203 | */ | 204 | */ | |
204 | #include <contrib/dev/ath/ah_soc.h> /* XXX really doesn't belong in hal */ | 205 | #include <ah_soc.h> /* XXX really doesn't belong in hal */ | |
205 | 206 | |||
206 | /* XXX write-around for now */ | 207 | /* XXX write-around for now */ | |
207 | #define AR5312_BOARD_MAGIC AR531X_BD_MAGIC | 208 | #define AR5312_BOARD_MAGIC AR531X_BD_MAGIC | |
208 | 209 | |||
209 | /* config bits */ | 210 | /* config bits */ | |
210 | #define AR5312_BOARD_CONFIG_ENET0 BD_ENET0 | 211 | #define AR5312_BOARD_CONFIG_ENET0 BD_ENET0 | |
211 | #define AR5312_BOARD_CONFIG_ENET1 BD_ENET1 | 212 | #define AR5312_BOARD_CONFIG_ENET1 BD_ENET1 | |
212 | #define AR5312_BOARD_CONFIG_UART1 BD_UART1 | 213 | #define AR5312_BOARD_CONFIG_UART1 BD_UART1 | |
213 | #define AR5312_BOARD_CONFIG_UART0 BD_UART0 | 214 | #define AR5312_BOARD_CONFIG_UART0 BD_UART0 | |
214 | #define AR5312_BOARD_CONFIG_RSTFACTORY BD_RSTFACTORY | 215 | #define AR5312_BOARD_CONFIG_RSTFACTORY BD_RSTFACTORY | |
215 | #define AR5312_BOARD_CONFIG_SYSLED BD_SYSLED | 216 | #define AR5312_BOARD_CONFIG_SYSLED BD_SYSLED | |
216 | #define AR5312_BOARD_CONFIG_EXTUARTCLK BD_EXTUARTCLK | 217 | #define AR5312_BOARD_CONFIG_EXTUARTCLK BD_EXTUARTCLK | |
217 | #define AR5312_BOARD_CONFIG_CPUFREQ BD_CPUFREQ | 218 | #define AR5312_BOARD_CONFIG_CPUFREQ BD_CPUFREQ | |
218 | #define AR5312_BOARD_CONFIG_SYSFREQ BD_SYSFREQ | 219 | #define AR5312_BOARD_CONFIG_SYSFREQ BD_SYSFREQ | |
219 | #define AR5312_BOARD_CONFIG_WLAN0 BD_WLAN0 | 220 | #define AR5312_BOARD_CONFIG_WLAN0 BD_WLAN0 | |
220 | #define AR5312_BOARD_CONFIG_MEMCAP BD_MEMCAP | 221 | #define AR5312_BOARD_CONFIG_MEMCAP BD_MEMCAP | |
221 | #define AR5312_BOARD_CONFIG_DISWDOG BD_DISWATCHDOG | 222 | #define AR5312_BOARD_CONFIG_DISWDOG BD_DISWATCHDOG | |
222 | #define AR5312_BOARD_CONFIG_WLAN1 BD_WLAN1 | 223 | #define AR5312_BOARD_CONFIG_WLAN1 BD_WLAN1 | |
223 | #define AR5312_BOARD_CONFIG_AR2312 BD_ISCASPER | 224 | #define AR5312_BOARD_CONFIG_AR2312 BD_ISCASPER | |
224 | #define AR5312_BOARD_CONFIG_WLAN0_2G BD_WLAN0_2G_EN | 225 | #define AR5312_BOARD_CONFIG_WLAN0_2G BD_WLAN0_2G_EN | |
225 | #define AR5312_BOARD_CONFIG_WLAN0_5G BD_WLAN0_5G_EN | 226 | #define AR5312_BOARD_CONFIG_WLAN0_5G BD_WLAN0_5G_EN | |
226 | #define AR5312_BOARD_CONFIG_WLAN1_2G BD_WLAN1_2G_EN | 227 | #define AR5312_BOARD_CONFIG_WLAN1_2G BD_WLAN1_2G_EN | |
227 | #define AR5312_BOARD_CONFIG_WLAN1_5G BD_WLAN1_5G_EN | 228 | #define AR5312_BOARD_CONFIG_WLAN1_5G BD_WLAN1_5G_EN | |
228 | 229 | |||
229 | #endif /* _MIPS_ATHEROS_AR531XREG_H_ */ | 230 | #endif /* _MIPS_ATHEROS_AR531XREG_H_ */ |