diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2011-06-27 08:58:50 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-06-29 14:53:22 -0400 |
commit | 1a93139237180404dc01970dfd33f4a5d5b2054c (patch) | |
tree | 4e9c593b552c2ea8174b4f0e46445a72e94b906f /drivers/net/wireless | |
parent | 3be3fdb58ad22f67c5fd12548c88cefe3f726588 (diff) |
b43: HT-PHY: prepare place for HT-PHY tables
They are big arrays uploaded to the hardware on init, calibration, etc.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/b43/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/wireless/b43/tables_phy_ht.c | 162 | ||||
-rw-r--r-- | drivers/net/wireless/b43/tables_phy_ht.h | 20 |
3 files changed, 183 insertions, 0 deletions
diff --git a/drivers/net/wireless/b43/Makefile b/drivers/net/wireless/b43/Makefile index 900dc9c8c688..1b25604be547 100644 --- a/drivers/net/wireless/b43/Makefile +++ b/drivers/net/wireless/b43/Makefile | |||
@@ -11,6 +11,7 @@ b43-$(CONFIG_B43_PHY_N) += phy_n.o | |||
11 | b43-$(CONFIG_B43_PHY_LP) += phy_lp.o | 11 | b43-$(CONFIG_B43_PHY_LP) += phy_lp.o |
12 | b43-$(CONFIG_B43_PHY_LP) += tables_lpphy.o | 12 | b43-$(CONFIG_B43_PHY_LP) += tables_lpphy.o |
13 | b43-$(CONFIG_B43_PHY_HT) += phy_ht.o | 13 | b43-$(CONFIG_B43_PHY_HT) += phy_ht.o |
14 | b43-$(CONFIG_B43_PHY_HT) += tables_phy_ht.o | ||
14 | b43-$(CONFIG_B43_PHY_HT) += radio_2059.o | 15 | b43-$(CONFIG_B43_PHY_HT) += radio_2059.o |
15 | b43-y += sysfs.o | 16 | b43-y += sysfs.o |
16 | b43-y += xmit.o | 17 | b43-y += xmit.o |
diff --git a/drivers/net/wireless/b43/tables_phy_ht.c b/drivers/net/wireless/b43/tables_phy_ht.c new file mode 100644 index 000000000000..df08be28f502 --- /dev/null +++ b/drivers/net/wireless/b43/tables_phy_ht.c | |||
@@ -0,0 +1,162 @@ | |||
1 | /* | ||
2 | |||
3 | Broadcom B43 wireless driver | ||
4 | IEEE 802.11n HT-PHY data tables | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 2 of the License, or | ||
9 | (at your option) any later version. | ||
10 | |||
11 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; see the file COPYING. If not, write to | ||
18 | the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, | ||
19 | Boston, MA 02110-1301, USA. | ||
20 | |||
21 | */ | ||
22 | |||
23 | #include "b43.h" | ||
24 | #include "tables_phy_ht.h" | ||
25 | #include "phy_common.h" | ||
26 | #include "phy_ht.h" | ||
27 | |||
28 | u32 b43_httab_read(struct b43_wldev *dev, u32 offset) | ||
29 | { | ||
30 | u32 type, value; | ||
31 | |||
32 | type = offset & B43_HTTAB_TYPEMASK; | ||
33 | offset &= ~B43_HTTAB_TYPEMASK; | ||
34 | B43_WARN_ON(offset > 0xFFFF); | ||
35 | |||
36 | switch (type) { | ||
37 | case B43_HTTAB_8BIT: | ||
38 | b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); | ||
39 | value = b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO) & 0xFF; | ||
40 | break; | ||
41 | case B43_HTTAB_16BIT: | ||
42 | b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); | ||
43 | value = b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO); | ||
44 | break; | ||
45 | case B43_HTTAB_32BIT: | ||
46 | b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); | ||
47 | value = b43_phy_read(dev, B43_PHY_HT_TABLE_DATAHI); | ||
48 | value <<= 16; | ||
49 | value |= b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO); | ||
50 | break; | ||
51 | default: | ||
52 | B43_WARN_ON(1); | ||
53 | value = 0; | ||
54 | } | ||
55 | |||
56 | return value; | ||
57 | } | ||
58 | |||
59 | void b43_httab_read_bulk(struct b43_wldev *dev, u32 offset, | ||
60 | unsigned int nr_elements, void *_data) | ||
61 | { | ||
62 | u32 type; | ||
63 | u8 *data = _data; | ||
64 | unsigned int i; | ||
65 | |||
66 | type = offset & B43_HTTAB_TYPEMASK; | ||
67 | offset &= ~B43_HTTAB_TYPEMASK; | ||
68 | B43_WARN_ON(offset > 0xFFFF); | ||
69 | |||
70 | b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); | ||
71 | |||
72 | for (i = 0; i < nr_elements; i++) { | ||
73 | switch (type) { | ||
74 | case B43_HTTAB_8BIT: | ||
75 | *data = b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO) & 0xFF; | ||
76 | data++; | ||
77 | break; | ||
78 | case B43_HTTAB_16BIT: | ||
79 | *((u16 *)data) = b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO); | ||
80 | data += 2; | ||
81 | break; | ||
82 | case B43_HTTAB_32BIT: | ||
83 | *((u32 *)data) = b43_phy_read(dev, B43_PHY_HT_TABLE_DATAHI); | ||
84 | *((u32 *)data) <<= 16; | ||
85 | *((u32 *)data) |= b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO); | ||
86 | data += 4; | ||
87 | break; | ||
88 | default: | ||
89 | B43_WARN_ON(1); | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | |||
94 | void b43_httab_write(struct b43_wldev *dev, u32 offset, u32 value) | ||
95 | { | ||
96 | u32 type; | ||
97 | |||
98 | type = offset & B43_HTTAB_TYPEMASK; | ||
99 | offset &= 0xFFFF; | ||
100 | |||
101 | switch (type) { | ||
102 | case B43_HTTAB_8BIT: | ||
103 | B43_WARN_ON(value & ~0xFF); | ||
104 | b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); | ||
105 | b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, value); | ||
106 | break; | ||
107 | case B43_HTTAB_16BIT: | ||
108 | B43_WARN_ON(value & ~0xFFFF); | ||
109 | b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); | ||
110 | b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, value); | ||
111 | break; | ||
112 | case B43_HTTAB_32BIT: | ||
113 | b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); | ||
114 | b43_phy_write(dev, B43_PHY_HT_TABLE_DATAHI, value >> 16); | ||
115 | b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, value & 0xFFFF); | ||
116 | break; | ||
117 | default: | ||
118 | B43_WARN_ON(1); | ||
119 | } | ||
120 | |||
121 | return; | ||
122 | } | ||
123 | |||
124 | void b43_httab_write_bulk(struct b43_wldev *dev, u32 offset, | ||
125 | unsigned int nr_elements, const void *_data) | ||
126 | { | ||
127 | u32 type, value; | ||
128 | const u8 *data = _data; | ||
129 | unsigned int i; | ||
130 | |||
131 | type = offset & B43_HTTAB_TYPEMASK; | ||
132 | offset &= ~B43_HTTAB_TYPEMASK; | ||
133 | B43_WARN_ON(offset > 0xFFFF); | ||
134 | |||
135 | b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); | ||
136 | |||
137 | for (i = 0; i < nr_elements; i++) { | ||
138 | switch (type) { | ||
139 | case B43_HTTAB_8BIT: | ||
140 | value = *data; | ||
141 | data++; | ||
142 | B43_WARN_ON(value & ~0xFF); | ||
143 | b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, value); | ||
144 | break; | ||
145 | case B43_HTTAB_16BIT: | ||
146 | value = *((u16 *)data); | ||
147 | data += 2; | ||
148 | B43_WARN_ON(value & ~0xFFFF); | ||
149 | b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, value); | ||
150 | break; | ||
151 | case B43_HTTAB_32BIT: | ||
152 | value = *((u32 *)data); | ||
153 | data += 4; | ||
154 | b43_phy_write(dev, B43_PHY_HT_TABLE_DATAHI, value >> 16); | ||
155 | b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, | ||
156 | value & 0xFFFF); | ||
157 | break; | ||
158 | default: | ||
159 | B43_WARN_ON(1); | ||
160 | } | ||
161 | } | ||
162 | } | ||
diff --git a/drivers/net/wireless/b43/tables_phy_ht.h b/drivers/net/wireless/b43/tables_phy_ht.h new file mode 100644 index 000000000000..6a136148edd7 --- /dev/null +++ b/drivers/net/wireless/b43/tables_phy_ht.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef B43_TABLES_PHY_HT_H_ | ||
2 | #define B43_TABLES_PHY_HT_H_ | ||
3 | |||
4 | /* The HT-PHY tables. */ | ||
5 | #define B43_HTTAB_TYPEMASK 0xF0000000 | ||
6 | #define B43_HTTAB_8BIT 0x10000000 | ||
7 | #define B43_HTTAB_16BIT 0x20000000 | ||
8 | #define B43_HTTAB_32BIT 0x30000000 | ||
9 | #define B43_HTTAB8(table, offset) (((table) << 10) | (offset) | B43_HTTAB_8BIT) | ||
10 | #define B43_HTTAB16(table, offset) (((table) << 10) | (offset) | B43_HTTAB_16BIT) | ||
11 | #define B43_HTTAB32(table, offset) (((table) << 10) | (offset) | B43_HTTAB_32BIT) | ||
12 | |||
13 | u32 b43_httab_read(struct b43_wldev *dev, u32 offset); | ||
14 | void b43_httab_read_bulk(struct b43_wldev *dev, u32 offset, | ||
15 | unsigned int nr_elements, void *_data); | ||
16 | void b43_httab_write(struct b43_wldev *dev, u32 offset, u32 value); | ||
17 | void b43_httab_write_bulk(struct b43_wldev *dev, u32 offset, | ||
18 | unsigned int nr_elements, const void *_data); | ||
19 | |||
20 | #endif /* B43_TABLES_PHY_HT_H_ */ | ||