iPXE
rfgain.h
Go to the documentation of this file.
00001 /*
00002  * RF Gain optimization
00003  *
00004  * Copyright (c) 2004-2009 Reyk Floeter <reyk@openbsd.org>
00005  * Copyright (c) 2006-2009 Nick Kossifidis <mickflemm@gmail.com>
00006  *
00007  * Permission to use, copy, modify, and distribute this software for any
00008  * purpose with or without fee is hereby granted, provided that the above
00009  * copyright notice and this permission notice appear in all copies.
00010  *
00011  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00012  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00013  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
00014  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00015  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00016  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00017  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00018  *
00019  */
00020 
00021 /*
00022  * Mode-specific RF Gain table (64bytes) for RF5111/5112
00023  * (RF5110 only comes with AR5210 and only supports a/turbo a mode so initial
00024  * RF Gain values are included in AR5K_AR5210_INI)
00025  */
00026 struct ath5k_ini_rfgain {
00027         u16     rfg_register;   /* RF Gain register address */
00028         u32     rfg_value[2];   /* [freq (see below)] */
00029 };
00030 
00031 /* Initial RF Gain settings for RF5111 */
00032 static const struct ath5k_ini_rfgain rfgain_5111[] = {
00033         /*                            5Ghz      2Ghz    */
00034         { AR5K_RF_GAIN(0),      { 0x000001a9, 0x00000000 } },
00035         { AR5K_RF_GAIN(1),      { 0x000001e9, 0x00000040 } },
00036         { AR5K_RF_GAIN(2),      { 0x00000029, 0x00000080 } },
00037         { AR5K_RF_GAIN(3),      { 0x00000069, 0x00000150 } },
00038         { AR5K_RF_GAIN(4),      { 0x00000199, 0x00000190 } },
00039         { AR5K_RF_GAIN(5),      { 0x000001d9, 0x000001d0 } },
00040         { AR5K_RF_GAIN(6),      { 0x00000019, 0x00000010 } },
00041         { AR5K_RF_GAIN(7),      { 0x00000059, 0x00000044 } },
00042         { AR5K_RF_GAIN(8),      { 0x00000099, 0x00000084 } },
00043         { AR5K_RF_GAIN(9),      { 0x000001a5, 0x00000148 } },
00044         { AR5K_RF_GAIN(10),     { 0x000001e5, 0x00000188 } },
00045         { AR5K_RF_GAIN(11),     { 0x00000025, 0x000001c8 } },
00046         { AR5K_RF_GAIN(12),     { 0x000001c8, 0x00000014 } },
00047         { AR5K_RF_GAIN(13),     { 0x00000008, 0x00000042 } },
00048         { AR5K_RF_GAIN(14),     { 0x00000048, 0x00000082 } },
00049         { AR5K_RF_GAIN(15),     { 0x00000088, 0x00000178 } },
00050         { AR5K_RF_GAIN(16),     { 0x00000198, 0x000001b8 } },
00051         { AR5K_RF_GAIN(17),     { 0x000001d8, 0x000001f8 } },
00052         { AR5K_RF_GAIN(18),     { 0x00000018, 0x00000012 } },
00053         { AR5K_RF_GAIN(19),     { 0x00000058, 0x00000052 } },
00054         { AR5K_RF_GAIN(20),     { 0x00000098, 0x00000092 } },
00055         { AR5K_RF_GAIN(21),     { 0x000001a4, 0x0000017c } },
00056         { AR5K_RF_GAIN(22),     { 0x000001e4, 0x000001bc } },
00057         { AR5K_RF_GAIN(23),     { 0x00000024, 0x000001fc } },
00058         { AR5K_RF_GAIN(24),     { 0x00000064, 0x0000000a } },
00059         { AR5K_RF_GAIN(25),     { 0x000000a4, 0x0000004a } },
00060         { AR5K_RF_GAIN(26),     { 0x000000e4, 0x0000008a } },
00061         { AR5K_RF_GAIN(27),     { 0x0000010a, 0x0000015a } },
00062         { AR5K_RF_GAIN(28),     { 0x0000014a, 0x0000019a } },
00063         { AR5K_RF_GAIN(29),     { 0x0000018a, 0x000001da } },
00064         { AR5K_RF_GAIN(30),     { 0x000001ca, 0x0000000e } },
00065         { AR5K_RF_GAIN(31),     { 0x0000000a, 0x0000004e } },
00066         { AR5K_RF_GAIN(32),     { 0x0000004a, 0x0000008e } },
00067         { AR5K_RF_GAIN(33),     { 0x0000008a, 0x0000015e } },
00068         { AR5K_RF_GAIN(34),     { 0x000001ba, 0x0000019e } },
00069         { AR5K_RF_GAIN(35),     { 0x000001fa, 0x000001de } },
00070         { AR5K_RF_GAIN(36),     { 0x0000003a, 0x00000009 } },
00071         { AR5K_RF_GAIN(37),     { 0x0000007a, 0x00000049 } },
00072         { AR5K_RF_GAIN(38),     { 0x00000186, 0x00000089 } },
00073         { AR5K_RF_GAIN(39),     { 0x000001c6, 0x00000179 } },
00074         { AR5K_RF_GAIN(40),     { 0x00000006, 0x000001b9 } },
00075         { AR5K_RF_GAIN(41),     { 0x00000046, 0x000001f9 } },
00076         { AR5K_RF_GAIN(42),     { 0x00000086, 0x00000039 } },
00077         { AR5K_RF_GAIN(43),     { 0x000000c6, 0x00000079 } },
00078         { AR5K_RF_GAIN(44),     { 0x000000c6, 0x000000b9 } },
00079         { AR5K_RF_GAIN(45),     { 0x000000c6, 0x000001bd } },
00080         { AR5K_RF_GAIN(46),     { 0x000000c6, 0x000001fd } },
00081         { AR5K_RF_GAIN(47),     { 0x000000c6, 0x0000003d } },
00082         { AR5K_RF_GAIN(48),     { 0x000000c6, 0x0000007d } },
00083         { AR5K_RF_GAIN(49),     { 0x000000c6, 0x000000bd } },
00084         { AR5K_RF_GAIN(50),     { 0x000000c6, 0x000000fd } },
00085         { AR5K_RF_GAIN(51),     { 0x000000c6, 0x000000fd } },
00086         { AR5K_RF_GAIN(52),     { 0x000000c6, 0x000000fd } },
00087         { AR5K_RF_GAIN(53),     { 0x000000c6, 0x000000fd } },
00088         { AR5K_RF_GAIN(54),     { 0x000000c6, 0x000000fd } },
00089         { AR5K_RF_GAIN(55),     { 0x000000c6, 0x000000fd } },
00090         { AR5K_RF_GAIN(56),     { 0x000000c6, 0x000000fd } },
00091         { AR5K_RF_GAIN(57),     { 0x000000c6, 0x000000fd } },
00092         { AR5K_RF_GAIN(58),     { 0x000000c6, 0x000000fd } },
00093         { AR5K_RF_GAIN(59),     { 0x000000c6, 0x000000fd } },
00094         { AR5K_RF_GAIN(60),     { 0x000000c6, 0x000000fd } },
00095         { AR5K_RF_GAIN(61),     { 0x000000c6, 0x000000fd } },
00096         { AR5K_RF_GAIN(62),     { 0x000000c6, 0x000000fd } },
00097         { AR5K_RF_GAIN(63),     { 0x000000c6, 0x000000fd } },
00098 };
00099 
00100 /* Initial RF Gain settings for RF5112 */
00101 static const struct ath5k_ini_rfgain rfgain_5112[] = {
00102         /*                            5Ghz      2Ghz    */
00103         { AR5K_RF_GAIN(0),      { 0x00000007, 0x00000007 } },
00104         { AR5K_RF_GAIN(1),      { 0x00000047, 0x00000047 } },
00105         { AR5K_RF_GAIN(2),      { 0x00000087, 0x00000087 } },
00106         { AR5K_RF_GAIN(3),      { 0x000001a0, 0x000001a0 } },
00107         { AR5K_RF_GAIN(4),      { 0x000001e0, 0x000001e0 } },
00108         { AR5K_RF_GAIN(5),      { 0x00000020, 0x00000020 } },
00109         { AR5K_RF_GAIN(6),      { 0x00000060, 0x00000060 } },
00110         { AR5K_RF_GAIN(7),      { 0x000001a1, 0x000001a1 } },
00111         { AR5K_RF_GAIN(8),      { 0x000001e1, 0x000001e1 } },
00112         { AR5K_RF_GAIN(9),      { 0x00000021, 0x00000021 } },
00113         { AR5K_RF_GAIN(10),     { 0x00000061, 0x00000061 } },
00114         { AR5K_RF_GAIN(11),     { 0x00000162, 0x00000162 } },
00115         { AR5K_RF_GAIN(12),     { 0x000001a2, 0x000001a2 } },
00116         { AR5K_RF_GAIN(13),     { 0x000001e2, 0x000001e2 } },
00117         { AR5K_RF_GAIN(14),     { 0x00000022, 0x00000022 } },
00118         { AR5K_RF_GAIN(15),     { 0x00000062, 0x00000062 } },
00119         { AR5K_RF_GAIN(16),     { 0x00000163, 0x00000163 } },
00120         { AR5K_RF_GAIN(17),     { 0x000001a3, 0x000001a3 } },
00121         { AR5K_RF_GAIN(18),     { 0x000001e3, 0x000001e3 } },
00122         { AR5K_RF_GAIN(19),     { 0x00000023, 0x00000023 } },
00123         { AR5K_RF_GAIN(20),     { 0x00000063, 0x00000063 } },
00124         { AR5K_RF_GAIN(21),     { 0x00000184, 0x00000184 } },
00125         { AR5K_RF_GAIN(22),     { 0x000001c4, 0x000001c4 } },
00126         { AR5K_RF_GAIN(23),     { 0x00000004, 0x00000004 } },
00127         { AR5K_RF_GAIN(24),     { 0x000001ea, 0x0000000b } },
00128         { AR5K_RF_GAIN(25),     { 0x0000002a, 0x0000004b } },
00129         { AR5K_RF_GAIN(26),     { 0x0000006a, 0x0000008b } },
00130         { AR5K_RF_GAIN(27),     { 0x000000aa, 0x000001ac } },
00131         { AR5K_RF_GAIN(28),     { 0x000001ab, 0x000001ec } },
00132         { AR5K_RF_GAIN(29),     { 0x000001eb, 0x0000002c } },
00133         { AR5K_RF_GAIN(30),     { 0x0000002b, 0x00000012 } },
00134         { AR5K_RF_GAIN(31),     { 0x0000006b, 0x00000052 } },
00135         { AR5K_RF_GAIN(32),     { 0x000000ab, 0x00000092 } },
00136         { AR5K_RF_GAIN(33),     { 0x000001ac, 0x00000193 } },
00137         { AR5K_RF_GAIN(34),     { 0x000001ec, 0x000001d3 } },
00138         { AR5K_RF_GAIN(35),     { 0x0000002c, 0x00000013 } },
00139         { AR5K_RF_GAIN(36),     { 0x0000003a, 0x00000053 } },
00140         { AR5K_RF_GAIN(37),     { 0x0000007a, 0x00000093 } },
00141         { AR5K_RF_GAIN(38),     { 0x000000ba, 0x00000194 } },
00142         { AR5K_RF_GAIN(39),     { 0x000001bb, 0x000001d4 } },
00143         { AR5K_RF_GAIN(40),     { 0x000001fb, 0x00000014 } },
00144         { AR5K_RF_GAIN(41),     { 0x0000003b, 0x0000003a } },
00145         { AR5K_RF_GAIN(42),     { 0x0000007b, 0x0000007a } },
00146         { AR5K_RF_GAIN(43),     { 0x000000bb, 0x000000ba } },
00147         { AR5K_RF_GAIN(44),     { 0x000001bc, 0x000001bb } },
00148         { AR5K_RF_GAIN(45),     { 0x000001fc, 0x000001fb } },
00149         { AR5K_RF_GAIN(46),     { 0x0000003c, 0x0000003b } },
00150         { AR5K_RF_GAIN(47),     { 0x0000007c, 0x0000007b } },
00151         { AR5K_RF_GAIN(48),     { 0x000000bc, 0x000000bb } },
00152         { AR5K_RF_GAIN(49),     { 0x000000fc, 0x000001bc } },
00153         { AR5K_RF_GAIN(50),     { 0x000000fc, 0x000001fc } },
00154         { AR5K_RF_GAIN(51),     { 0x000000fc, 0x0000003c } },
00155         { AR5K_RF_GAIN(52),     { 0x000000fc, 0x0000007c } },
00156         { AR5K_RF_GAIN(53),     { 0x000000fc, 0x000000bc } },
00157         { AR5K_RF_GAIN(54),     { 0x000000fc, 0x000000fc } },
00158         { AR5K_RF_GAIN(55),     { 0x000000fc, 0x000000fc } },
00159         { AR5K_RF_GAIN(56),     { 0x000000fc, 0x000000fc } },
00160         { AR5K_RF_GAIN(57),     { 0x000000fc, 0x000000fc } },
00161         { AR5K_RF_GAIN(58),     { 0x000000fc, 0x000000fc } },
00162         { AR5K_RF_GAIN(59),     { 0x000000fc, 0x000000fc } },
00163         { AR5K_RF_GAIN(60),     { 0x000000fc, 0x000000fc } },
00164         { AR5K_RF_GAIN(61),     { 0x000000fc, 0x000000fc } },
00165         { AR5K_RF_GAIN(62),     { 0x000000fc, 0x000000fc } },
00166         { AR5K_RF_GAIN(63),     { 0x000000fc, 0x000000fc } },
00167 };
00168 
00169 /* Initial RF Gain settings for RF2413 */
00170 static const struct ath5k_ini_rfgain rfgain_2413[] = {
00171         { AR5K_RF_GAIN(0),      { 0x00000000, 0x00000000 } },
00172         { AR5K_RF_GAIN(1),      { 0x00000000, 0x00000040 } },
00173         { AR5K_RF_GAIN(2),      { 0x00000000, 0x00000080 } },
00174         { AR5K_RF_GAIN(3),      { 0x00000000, 0x00000181 } },
00175         { AR5K_RF_GAIN(4),      { 0x00000000, 0x000001c1 } },
00176         { AR5K_RF_GAIN(5),      { 0x00000000, 0x00000001 } },
00177         { AR5K_RF_GAIN(6),      { 0x00000000, 0x00000041 } },
00178         { AR5K_RF_GAIN(7),      { 0x00000000, 0x00000081 } },
00179         { AR5K_RF_GAIN(8),      { 0x00000000, 0x00000168 } },
00180         { AR5K_RF_GAIN(9),      { 0x00000000, 0x000001a8 } },
00181         { AR5K_RF_GAIN(10),     { 0x00000000, 0x000001e8 } },
00182         { AR5K_RF_GAIN(11),     { 0x00000000, 0x00000028 } },
00183         { AR5K_RF_GAIN(12),     { 0x00000000, 0x00000068 } },
00184         { AR5K_RF_GAIN(13),     { 0x00000000, 0x00000189 } },
00185         { AR5K_RF_GAIN(14),     { 0x00000000, 0x000001c9 } },
00186         { AR5K_RF_GAIN(15),     { 0x00000000, 0x00000009 } },
00187         { AR5K_RF_GAIN(16),     { 0x00000000, 0x00000049 } },
00188         { AR5K_RF_GAIN(17),     { 0x00000000, 0x00000089 } },
00189         { AR5K_RF_GAIN(18),     { 0x00000000, 0x00000190 } },
00190         { AR5K_RF_GAIN(19),     { 0x00000000, 0x000001d0 } },
00191         { AR5K_RF_GAIN(20),     { 0x00000000, 0x00000010 } },
00192         { AR5K_RF_GAIN(21),     { 0x00000000, 0x00000050 } },
00193         { AR5K_RF_GAIN(22),     { 0x00000000, 0x00000090 } },
00194         { AR5K_RF_GAIN(23),     { 0x00000000, 0x00000191 } },
00195         { AR5K_RF_GAIN(24),     { 0x00000000, 0x000001d1 } },
00196         { AR5K_RF_GAIN(25),     { 0x00000000, 0x00000011 } },
00197         { AR5K_RF_GAIN(26),     { 0x00000000, 0x00000051 } },
00198         { AR5K_RF_GAIN(27),     { 0x00000000, 0x00000091 } },
00199         { AR5K_RF_GAIN(28),     { 0x00000000, 0x00000178 } },
00200         { AR5K_RF_GAIN(29),     { 0x00000000, 0x000001b8 } },
00201         { AR5K_RF_GAIN(30),     { 0x00000000, 0x000001f8 } },
00202         { AR5K_RF_GAIN(31),     { 0x00000000, 0x00000038 } },
00203         { AR5K_RF_GAIN(32),     { 0x00000000, 0x00000078 } },
00204         { AR5K_RF_GAIN(33),     { 0x00000000, 0x00000199 } },
00205         { AR5K_RF_GAIN(34),     { 0x00000000, 0x000001d9 } },
00206         { AR5K_RF_GAIN(35),     { 0x00000000, 0x00000019 } },
00207         { AR5K_RF_GAIN(36),     { 0x00000000, 0x00000059 } },
00208         { AR5K_RF_GAIN(37),     { 0x00000000, 0x00000099 } },
00209         { AR5K_RF_GAIN(38),     { 0x00000000, 0x000000d9 } },
00210         { AR5K_RF_GAIN(39),     { 0x00000000, 0x000000f9 } },
00211         { AR5K_RF_GAIN(40),     { 0x00000000, 0x000000f9 } },
00212         { AR5K_RF_GAIN(41),     { 0x00000000, 0x000000f9 } },
00213         { AR5K_RF_GAIN(42),     { 0x00000000, 0x000000f9 } },
00214         { AR5K_RF_GAIN(43),     { 0x00000000, 0x000000f9 } },
00215         { AR5K_RF_GAIN(44),     { 0x00000000, 0x000000f9 } },
00216         { AR5K_RF_GAIN(45),     { 0x00000000, 0x000000f9 } },
00217         { AR5K_RF_GAIN(46),     { 0x00000000, 0x000000f9 } },
00218         { AR5K_RF_GAIN(47),     { 0x00000000, 0x000000f9 } },
00219         { AR5K_RF_GAIN(48),     { 0x00000000, 0x000000f9 } },
00220         { AR5K_RF_GAIN(49),     { 0x00000000, 0x000000f9 } },
00221         { AR5K_RF_GAIN(50),     { 0x00000000, 0x000000f9 } },
00222         { AR5K_RF_GAIN(51),     { 0x00000000, 0x000000f9 } },
00223         { AR5K_RF_GAIN(52),     { 0x00000000, 0x000000f9 } },
00224         { AR5K_RF_GAIN(53),     { 0x00000000, 0x000000f9 } },
00225         { AR5K_RF_GAIN(54),     { 0x00000000, 0x000000f9 } },
00226         { AR5K_RF_GAIN(55),     { 0x00000000, 0x000000f9 } },
00227         { AR5K_RF_GAIN(56),     { 0x00000000, 0x000000f9 } },
00228         { AR5K_RF_GAIN(57),     { 0x00000000, 0x000000f9 } },
00229         { AR5K_RF_GAIN(58),     { 0x00000000, 0x000000f9 } },
00230         { AR5K_RF_GAIN(59),     { 0x00000000, 0x000000f9 } },
00231         { AR5K_RF_GAIN(60),     { 0x00000000, 0x000000f9 } },
00232         { AR5K_RF_GAIN(61),     { 0x00000000, 0x000000f9 } },
00233         { AR5K_RF_GAIN(62),     { 0x00000000, 0x000000f9 } },
00234         { AR5K_RF_GAIN(63),     { 0x00000000, 0x000000f9 } },
00235 };
00236 
00237 /* Initial RF Gain settings for AR2316 */
00238 static const struct ath5k_ini_rfgain rfgain_2316[] = {
00239         { AR5K_RF_GAIN(0),      { 0x00000000, 0x00000000 } },
00240         { AR5K_RF_GAIN(1),      { 0x00000000, 0x00000040 } },
00241         { AR5K_RF_GAIN(2),      { 0x00000000, 0x00000080 } },
00242         { AR5K_RF_GAIN(3),      { 0x00000000, 0x000000c0 } },
00243         { AR5K_RF_GAIN(4),      { 0x00000000, 0x000000e0 } },
00244         { AR5K_RF_GAIN(5),      { 0x00000000, 0x000000e0 } },
00245         { AR5K_RF_GAIN(6),      { 0x00000000, 0x00000128 } },
00246         { AR5K_RF_GAIN(7),      { 0x00000000, 0x00000128 } },
00247         { AR5K_RF_GAIN(8),      { 0x00000000, 0x00000128 } },
00248         { AR5K_RF_GAIN(9),      { 0x00000000, 0x00000168 } },
00249         { AR5K_RF_GAIN(10),     { 0x00000000, 0x000001a8 } },
00250         { AR5K_RF_GAIN(11),     { 0x00000000, 0x000001e8 } },
00251         { AR5K_RF_GAIN(12),     { 0x00000000, 0x00000028 } },
00252         { AR5K_RF_GAIN(13),     { 0x00000000, 0x00000068 } },
00253         { AR5K_RF_GAIN(14),     { 0x00000000, 0x000000a8 } },
00254         { AR5K_RF_GAIN(15),     { 0x00000000, 0x000000e8 } },
00255         { AR5K_RF_GAIN(16),     { 0x00000000, 0x000000e8 } },
00256         { AR5K_RF_GAIN(17),     { 0x00000000, 0x00000130 } },
00257         { AR5K_RF_GAIN(18),     { 0x00000000, 0x00000130 } },
00258         { AR5K_RF_GAIN(19),     { 0x00000000, 0x00000170 } },
00259         { AR5K_RF_GAIN(20),     { 0x00000000, 0x000001b0 } },
00260         { AR5K_RF_GAIN(21),     { 0x00000000, 0x000001f0 } },
00261         { AR5K_RF_GAIN(22),     { 0x00000000, 0x00000030 } },
00262         { AR5K_RF_GAIN(23),     { 0x00000000, 0x00000070 } },
00263         { AR5K_RF_GAIN(24),     { 0x00000000, 0x000000b0 } },
00264         { AR5K_RF_GAIN(25),     { 0x00000000, 0x000000f0 } },
00265         { AR5K_RF_GAIN(26),     { 0x00000000, 0x000000f0 } },
00266         { AR5K_RF_GAIN(27),     { 0x00000000, 0x000000f0 } },
00267         { AR5K_RF_GAIN(28),     { 0x00000000, 0x000000f0 } },
00268         { AR5K_RF_GAIN(29),     { 0x00000000, 0x000000f0 } },
00269         { AR5K_RF_GAIN(30),     { 0x00000000, 0x000000f0 } },
00270         { AR5K_RF_GAIN(31),     { 0x00000000, 0x000000f0 } },
00271         { AR5K_RF_GAIN(32),     { 0x00000000, 0x000000f0 } },
00272         { AR5K_RF_GAIN(33),     { 0x00000000, 0x000000f0 } },
00273         { AR5K_RF_GAIN(34),     { 0x00000000, 0x000000f0 } },
00274         { AR5K_RF_GAIN(35),     { 0x00000000, 0x000000f0 } },
00275         { AR5K_RF_GAIN(36),     { 0x00000000, 0x000000f0 } },
00276         { AR5K_RF_GAIN(37),     { 0x00000000, 0x000000f0 } },
00277         { AR5K_RF_GAIN(38),     { 0x00000000, 0x000000f0 } },
00278         { AR5K_RF_GAIN(39),     { 0x00000000, 0x000000f0 } },
00279         { AR5K_RF_GAIN(40),     { 0x00000000, 0x000000f0 } },
00280         { AR5K_RF_GAIN(41),     { 0x00000000, 0x000000f0 } },
00281         { AR5K_RF_GAIN(42),     { 0x00000000, 0x000000f0 } },
00282         { AR5K_RF_GAIN(43),     { 0x00000000, 0x000000f0 } },
00283         { AR5K_RF_GAIN(44),     { 0x00000000, 0x000000f0 } },
00284         { AR5K_RF_GAIN(45),     { 0x00000000, 0x000000f0 } },
00285         { AR5K_RF_GAIN(46),     { 0x00000000, 0x000000f0 } },
00286         { AR5K_RF_GAIN(47),     { 0x00000000, 0x000000f0 } },
00287         { AR5K_RF_GAIN(48),     { 0x00000000, 0x000000f0 } },
00288         { AR5K_RF_GAIN(49),     { 0x00000000, 0x000000f0 } },
00289         { AR5K_RF_GAIN(50),     { 0x00000000, 0x000000f0 } },
00290         { AR5K_RF_GAIN(51),     { 0x00000000, 0x000000f0 } },
00291         { AR5K_RF_GAIN(52),     { 0x00000000, 0x000000f0 } },
00292         { AR5K_RF_GAIN(53),     { 0x00000000, 0x000000f0 } },
00293         { AR5K_RF_GAIN(54),     { 0x00000000, 0x000000f0 } },
00294         { AR5K_RF_GAIN(55),     { 0x00000000, 0x000000f0 } },
00295         { AR5K_RF_GAIN(56),     { 0x00000000, 0x000000f0 } },
00296         { AR5K_RF_GAIN(57),     { 0x00000000, 0x000000f0 } },
00297         { AR5K_RF_GAIN(58),     { 0x00000000, 0x000000f0 } },
00298         { AR5K_RF_GAIN(59),     { 0x00000000, 0x000000f0 } },
00299         { AR5K_RF_GAIN(60),     { 0x00000000, 0x000000f0 } },
00300         { AR5K_RF_GAIN(61),     { 0x00000000, 0x000000f0 } },
00301         { AR5K_RF_GAIN(62),     { 0x00000000, 0x000000f0 } },
00302         { AR5K_RF_GAIN(63),     { 0x00000000, 0x000000f0 } },
00303 };
00304 
00305 
00306 /* Initial RF Gain settings for RF5413 */
00307 static const struct ath5k_ini_rfgain rfgain_5413[] = {
00308         /*                            5Ghz      2Ghz    */
00309         { AR5K_RF_GAIN(0),      { 0x00000000, 0x00000000 } },
00310         { AR5K_RF_GAIN(1),      { 0x00000040, 0x00000040 } },
00311         { AR5K_RF_GAIN(2),      { 0x00000080, 0x00000080 } },
00312         { AR5K_RF_GAIN(3),      { 0x000001a1, 0x00000161 } },
00313         { AR5K_RF_GAIN(4),      { 0x000001e1, 0x000001a1 } },
00314         { AR5K_RF_GAIN(5),      { 0x00000021, 0x000001e1 } },
00315         { AR5K_RF_GAIN(6),      { 0x00000061, 0x00000021 } },
00316         { AR5K_RF_GAIN(7),      { 0x00000188, 0x00000061 } },
00317         { AR5K_RF_GAIN(8),      { 0x000001c8, 0x00000188 } },
00318         { AR5K_RF_GAIN(9),      { 0x00000008, 0x000001c8 } },
00319         { AR5K_RF_GAIN(10),     { 0x00000048, 0x00000008 } },
00320         { AR5K_RF_GAIN(11),     { 0x00000088, 0x00000048 } },
00321         { AR5K_RF_GAIN(12),     { 0x000001a9, 0x00000088 } },
00322         { AR5K_RF_GAIN(13),     { 0x000001e9, 0x00000169 } },
00323         { AR5K_RF_GAIN(14),     { 0x00000029, 0x000001a9 } },
00324         { AR5K_RF_GAIN(15),     { 0x00000069, 0x000001e9 } },
00325         { AR5K_RF_GAIN(16),     { 0x000001d0, 0x00000029 } },
00326         { AR5K_RF_GAIN(17),     { 0x00000010, 0x00000069 } },
00327         { AR5K_RF_GAIN(18),     { 0x00000050, 0x00000190 } },
00328         { AR5K_RF_GAIN(19),     { 0x00000090, 0x000001d0 } },
00329         { AR5K_RF_GAIN(20),     { 0x000001b1, 0x00000010 } },
00330         { AR5K_RF_GAIN(21),     { 0x000001f1, 0x00000050 } },
00331         { AR5K_RF_GAIN(22),     { 0x00000031, 0x00000090 } },
00332         { AR5K_RF_GAIN(23),     { 0x00000071, 0x00000171 } },
00333         { AR5K_RF_GAIN(24),     { 0x000001b8, 0x000001b1 } },
00334         { AR5K_RF_GAIN(25),     { 0x000001f8, 0x000001f1 } },
00335         { AR5K_RF_GAIN(26),     { 0x00000038, 0x00000031 } },
00336         { AR5K_RF_GAIN(27),     { 0x00000078, 0x00000071 } },
00337         { AR5K_RF_GAIN(28),     { 0x00000199, 0x00000198 } },
00338         { AR5K_RF_GAIN(29),     { 0x000001d9, 0x000001d8 } },
00339         { AR5K_RF_GAIN(30),     { 0x00000019, 0x00000018 } },
00340         { AR5K_RF_GAIN(31),     { 0x00000059, 0x00000058 } },
00341         { AR5K_RF_GAIN(32),     { 0x00000099, 0x00000098 } },
00342         { AR5K_RF_GAIN(33),     { 0x000000d9, 0x00000179 } },
00343         { AR5K_RF_GAIN(34),     { 0x000000f9, 0x000001b9 } },
00344         { AR5K_RF_GAIN(35),     { 0x000000f9, 0x000001f9 } },
00345         { AR5K_RF_GAIN(36),     { 0x000000f9, 0x00000039 } },
00346         { AR5K_RF_GAIN(37),     { 0x000000f9, 0x00000079 } },
00347         { AR5K_RF_GAIN(38),     { 0x000000f9, 0x000000b9 } },
00348         { AR5K_RF_GAIN(39),     { 0x000000f9, 0x000000f9 } },
00349         { AR5K_RF_GAIN(40),     { 0x000000f9, 0x000000f9 } },
00350         { AR5K_RF_GAIN(41),     { 0x000000f9, 0x000000f9 } },
00351         { AR5K_RF_GAIN(42),     { 0x000000f9, 0x000000f9 } },
00352         { AR5K_RF_GAIN(43),     { 0x000000f9, 0x000000f9 } },
00353         { AR5K_RF_GAIN(44),     { 0x000000f9, 0x000000f9 } },
00354         { AR5K_RF_GAIN(45),     { 0x000000f9, 0x000000f9 } },
00355         { AR5K_RF_GAIN(46),     { 0x000000f9, 0x000000f9 } },
00356         { AR5K_RF_GAIN(47),     { 0x000000f9, 0x000000f9 } },
00357         { AR5K_RF_GAIN(48),     { 0x000000f9, 0x000000f9 } },
00358         { AR5K_RF_GAIN(49),     { 0x000000f9, 0x000000f9 } },
00359         { AR5K_RF_GAIN(50),     { 0x000000f9, 0x000000f9 } },
00360         { AR5K_RF_GAIN(51),     { 0x000000f9, 0x000000f9 } },
00361         { AR5K_RF_GAIN(52),     { 0x000000f9, 0x000000f9 } },
00362         { AR5K_RF_GAIN(53),     { 0x000000f9, 0x000000f9 } },
00363         { AR5K_RF_GAIN(54),     { 0x000000f9, 0x000000f9 } },
00364         { AR5K_RF_GAIN(55),     { 0x000000f9, 0x000000f9 } },
00365         { AR5K_RF_GAIN(56),     { 0x000000f9, 0x000000f9 } },
00366         { AR5K_RF_GAIN(57),     { 0x000000f9, 0x000000f9 } },
00367         { AR5K_RF_GAIN(58),     { 0x000000f9, 0x000000f9 } },
00368         { AR5K_RF_GAIN(59),     { 0x000000f9, 0x000000f9 } },
00369         { AR5K_RF_GAIN(60),     { 0x000000f9, 0x000000f9 } },
00370         { AR5K_RF_GAIN(61),     { 0x000000f9, 0x000000f9 } },
00371         { AR5K_RF_GAIN(62),     { 0x000000f9, 0x000000f9 } },
00372         { AR5K_RF_GAIN(63),     { 0x000000f9, 0x000000f9 } },
00373 };
00374 
00375 
00376 /* Initial RF Gain settings for RF2425 */
00377 static const struct ath5k_ini_rfgain rfgain_2425[] = {
00378         { AR5K_RF_GAIN(0),      { 0x00000000, 0x00000000 } },
00379         { AR5K_RF_GAIN(1),      { 0x00000000, 0x00000040 } },
00380         { AR5K_RF_GAIN(2),      { 0x00000000, 0x00000080 } },
00381         { AR5K_RF_GAIN(3),      { 0x00000000, 0x00000181 } },
00382         { AR5K_RF_GAIN(4),      { 0x00000000, 0x000001c1 } },
00383         { AR5K_RF_GAIN(5),      { 0x00000000, 0x00000001 } },
00384         { AR5K_RF_GAIN(6),      { 0x00000000, 0x00000041 } },
00385         { AR5K_RF_GAIN(7),      { 0x00000000, 0x00000081 } },
00386         { AR5K_RF_GAIN(8),      { 0x00000000, 0x00000188 } },
00387         { AR5K_RF_GAIN(9),      { 0x00000000, 0x000001c8 } },
00388         { AR5K_RF_GAIN(10),     { 0x00000000, 0x00000008 } },
00389         { AR5K_RF_GAIN(11),     { 0x00000000, 0x00000048 } },
00390         { AR5K_RF_GAIN(12),     { 0x00000000, 0x00000088 } },
00391         { AR5K_RF_GAIN(13),     { 0x00000000, 0x00000189 } },
00392         { AR5K_RF_GAIN(14),     { 0x00000000, 0x000001c9 } },
00393         { AR5K_RF_GAIN(15),     { 0x00000000, 0x00000009 } },
00394         { AR5K_RF_GAIN(16),     { 0x00000000, 0x00000049 } },
00395         { AR5K_RF_GAIN(17),     { 0x00000000, 0x00000089 } },
00396         { AR5K_RF_GAIN(18),     { 0x00000000, 0x000001b0 } },
00397         { AR5K_RF_GAIN(19),     { 0x00000000, 0x000001f0 } },
00398         { AR5K_RF_GAIN(20),     { 0x00000000, 0x00000030 } },
00399         { AR5K_RF_GAIN(21),     { 0x00000000, 0x00000070 } },
00400         { AR5K_RF_GAIN(22),     { 0x00000000, 0x00000171 } },
00401         { AR5K_RF_GAIN(23),     { 0x00000000, 0x000001b1 } },
00402         { AR5K_RF_GAIN(24),     { 0x00000000, 0x000001f1 } },
00403         { AR5K_RF_GAIN(25),     { 0x00000000, 0x00000031 } },
00404         { AR5K_RF_GAIN(26),     { 0x00000000, 0x00000071 } },
00405         { AR5K_RF_GAIN(27),     { 0x00000000, 0x000001b8 } },
00406         { AR5K_RF_GAIN(28),     { 0x00000000, 0x000001f8 } },
00407         { AR5K_RF_GAIN(29),     { 0x00000000, 0x00000038 } },
00408         { AR5K_RF_GAIN(30),     { 0x00000000, 0x00000078 } },
00409         { AR5K_RF_GAIN(31),     { 0x00000000, 0x000000b8 } },
00410         { AR5K_RF_GAIN(32),     { 0x00000000, 0x000001b9 } },
00411         { AR5K_RF_GAIN(33),     { 0x00000000, 0x000001f9 } },
00412         { AR5K_RF_GAIN(34),     { 0x00000000, 0x00000039 } },
00413         { AR5K_RF_GAIN(35),     { 0x00000000, 0x00000079 } },
00414         { AR5K_RF_GAIN(36),     { 0x00000000, 0x000000b9 } },
00415         { AR5K_RF_GAIN(37),     { 0x00000000, 0x000000f9 } },
00416         { AR5K_RF_GAIN(38),     { 0x00000000, 0x000000f9 } },
00417         { AR5K_RF_GAIN(39),     { 0x00000000, 0x000000f9 } },
00418         { AR5K_RF_GAIN(40),     { 0x00000000, 0x000000f9 } },
00419         { AR5K_RF_GAIN(41),     { 0x00000000, 0x000000f9 } },
00420         { AR5K_RF_GAIN(42),     { 0x00000000, 0x000000f9 } },
00421         { AR5K_RF_GAIN(43),     { 0x00000000, 0x000000f9 } },
00422         { AR5K_RF_GAIN(44),     { 0x00000000, 0x000000f9 } },
00423         { AR5K_RF_GAIN(45),     { 0x00000000, 0x000000f9 } },
00424         { AR5K_RF_GAIN(46),     { 0x00000000, 0x000000f9 } },
00425         { AR5K_RF_GAIN(47),     { 0x00000000, 0x000000f9 } },
00426         { AR5K_RF_GAIN(48),     { 0x00000000, 0x000000f9 } },
00427         { AR5K_RF_GAIN(49),     { 0x00000000, 0x000000f9 } },
00428         { AR5K_RF_GAIN(50),     { 0x00000000, 0x000000f9 } },
00429         { AR5K_RF_GAIN(51),     { 0x00000000, 0x000000f9 } },
00430         { AR5K_RF_GAIN(52),     { 0x00000000, 0x000000f9 } },
00431         { AR5K_RF_GAIN(53),     { 0x00000000, 0x000000f9 } },
00432         { AR5K_RF_GAIN(54),     { 0x00000000, 0x000000f9 } },
00433         { AR5K_RF_GAIN(55),     { 0x00000000, 0x000000f9 } },
00434         { AR5K_RF_GAIN(56),     { 0x00000000, 0x000000f9 } },
00435         { AR5K_RF_GAIN(57),     { 0x00000000, 0x000000f9 } },
00436         { AR5K_RF_GAIN(58),     { 0x00000000, 0x000000f9 } },
00437         { AR5K_RF_GAIN(59),     { 0x00000000, 0x000000f9 } },
00438         { AR5K_RF_GAIN(60),     { 0x00000000, 0x000000f9 } },
00439         { AR5K_RF_GAIN(61),     { 0x00000000, 0x000000f9 } },
00440         { AR5K_RF_GAIN(62),     { 0x00000000, 0x000000f9 } },
00441         { AR5K_RF_GAIN(63),     { 0x00000000, 0x000000f9 } },
00442 };
00443 
00444 #define AR5K_GAIN_CRN_FIX_BITS_5111             4
00445 #define AR5K_GAIN_CRN_FIX_BITS_5112             7
00446 #define AR5K_GAIN_CRN_MAX_FIX_BITS              AR5K_GAIN_CRN_FIX_BITS_5112
00447 #define AR5K_GAIN_DYN_ADJUST_HI_MARGIN          15
00448 #define AR5K_GAIN_DYN_ADJUST_LO_MARGIN          20
00449 #define AR5K_GAIN_CCK_PROBE_CORR                5
00450 #define AR5K_GAIN_CCK_OFDM_GAIN_DELTA           15
00451 #define AR5K_GAIN_STEP_COUNT                    10
00452 
00453 /* Check if our current measurement is inside our
00454  * current variable attenuation window */
00455 #define AR5K_GAIN_CHECK_ADJUST(_g)              \
00456         ((_g)->g_current <= (_g)->g_low || (_g)->g_current >= (_g)->g_high)
00457 
00458 struct ath5k_gain_opt_step {
00459         s8                              gos_param[AR5K_GAIN_CRN_MAX_FIX_BITS];
00460         s8                              gos_gain;
00461 };
00462 
00463 struct ath5k_gain_opt {
00464         u8                              go_default;
00465         u8                              go_steps_count;
00466         const struct ath5k_gain_opt_step        go_step[AR5K_GAIN_STEP_COUNT];
00467 };
00468 
00469 /*
00470  * Parameters on gos_param:
00471  * 1) Tx clip PHY register
00472  * 2) PWD 90 RF register
00473  * 3) PWD 84 RF register
00474  * 4) RFGainSel RF register
00475  */
00476 static const struct ath5k_gain_opt rfgain_opt_5111 = {
00477         4,
00478         9,
00479         {
00480                 { { 4, 1, 1, 1 }, 6 },
00481                 { { 4, 0, 1, 1 }, 4 },
00482                 { { 3, 1, 1, 1 }, 3 },
00483                 { { 4, 0, 0, 1 }, 1 },
00484                 { { 4, 1, 1, 0 }, 0 },
00485                 { { 4, 0, 1, 0 }, -2 },
00486                 { { 3, 1, 1, 0 }, -3 },
00487                 { { 4, 0, 0, 0 }, -4 },
00488                 { { 2, 1, 1, 0 }, -6 }
00489         }
00490 };
00491 
00492 /*
00493  * Parameters on gos_param:
00494  * 1) Mixgain ovr RF register
00495  * 2) PWD 138 RF register
00496  * 3) PWD 137 RF register
00497  * 4) PWD 136 RF register
00498  * 5) PWD 132 RF register
00499  * 6) PWD 131 RF register
00500  * 7) PWD 130 RF register
00501  */
00502 static const struct ath5k_gain_opt rfgain_opt_5112 = {
00503         1,
00504         8,
00505         {
00506                 { { 3, 0, 0, 0, 0, 0, 0 }, 6 },
00507                 { { 2, 0, 0, 0, 0, 0, 0 }, 0 },
00508                 { { 1, 0, 0, 0, 0, 0, 0 }, -3 },
00509                 { { 0, 0, 0, 0, 0, 0, 0 }, -6 },
00510                 { { 0, 1, 1, 0, 0, 0, 0 }, -8 },
00511                 { { 0, 1, 1, 0, 1, 1, 0 }, -10 },
00512                 { { 0, 1, 0, 1, 1, 1, 0 }, -13 },
00513                 { { 0, 1, 0, 1, 1, 0, 1 }, -16 },
00514         }
00515 };
00516