2 * Copyright (c) 2010-2011 Adrian Chadd, Xenion Pty Ltd.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/types.h>
36 AH_FALSE = 0, /* NB: lots of code assumes false is zero */
41 HAL_OK = 0, /* No error */
46 #include "ah_eeprom_v14.h"
47 #include "ah_eeprom_9287.h"
50 eeprom_9287_base_print(uint16_t *buf)
52 HAL_EEPROM_9287 *eep = (HAL_EEPROM_9287 *) buf;
53 BASE_EEP_9287_HEADER *eh = &eep->ee_base.baseEepHeader;
56 printf("| Version: 0x%.4x | Length: 0x%.4x | Checksum: 0x%.4x ",
57 eh->version, eh->length, eh->checksum);
58 printf("| CapFlags: 0x%.2x | eepMisc: 0x%.2x | RegDomain: 0x%.4x 0x%.4x | \n",
59 eh->opCapFlags, eh->eepMisc, eh->regDmn[0], eh->regDmn[1]);
60 printf("| MAC: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x ",
61 eh->macAddr[0], eh->macAddr[1], eh->macAddr[2],
62 eh->macAddr[3], eh->macAddr[4], eh->macAddr[5]);
63 printf("| RxMask: 0x%.2x | TxMask: 0x%.2x | RfSilent: 0x%.4x | btOptions: 0x%.4x |\n",
64 eh->rxMask, eh->txMask, eh->rfSilent, eh->blueToothOptions);
65 printf("| DeviceCap: 0x%.4x | binBuildNumber: %.8x | deviceType: 0x%.2x | openLoopPwrCntl 0x%.2x |\n",
66 eh->deviceCap, eh->binBuildNumber, eh->deviceType, eh->openLoopPwrCntl);
67 printf("| pwrTableOffset: %d | tempSensSlope: %d | tempSensSlopePalOn: %d |\n",
68 eh->pwrTableOffset, eh->tempSensSlope, eh->tempSensSlopePalOn);
71 for (i = 0; i < sizeof(eh->futureBase) / sizeof(uint16_t); i++) {
72 printf("0x%.2x ", eh->futureBase[i]);
78 eeprom_9287_custdata_print(uint16_t *buf)
80 HAL_EEPROM_9287 *eep = (HAL_EEPROM_9287 *) buf;
81 uint8_t *custdata = (uint8_t *) &eep->ee_base.custData;
84 printf("\n| Custdata: |\n");
85 for (i = 0; i < 20; i++) {
87 i % 16 == 0 ? "| " : "",
89 i % 16 == 15 ? "|\n" : "");
95 eeprom_9287_modal_print(uint16_t *buf)
97 HAL_EEPROM_9287 *eep = (HAL_EEPROM_9287 *) buf;
98 MODAL_EEP_9287_HEADER *mh = &eep->ee_base.modalHeader;
101 printf("| antCtrlCommon: 0x%.8x |\n", mh->antCtrlCommon);
102 printf("| switchSettling: 0x%.2x |\n", mh->switchSettling);
103 printf("| adcDesiredSize: %d |\n", mh->adcDesiredSize);
105 for (i = 0; i < AR9287_MAX_CHAINS; i++) {
106 printf("| Chain %d:\n", i);
107 printf("| antCtrlChain: 0:0x%.4x |\n", mh->antCtrlChain[i]);
108 printf("| antennaGainCh: 0:0x%.2x |\n", mh->antennaGainCh[i]);
109 printf("| txRxAttenCh: 0:0x%.2x |\n", mh->txRxAttenCh[i]);
110 printf("| rxTxMarginCh: 0:0x%.2x |\n", mh->rxTxMarginCh[i]);
111 printf("| noiseFloorThresCh: 0:0x%.2x |\n", mh->noiseFloorThreshCh[i]);
112 printf("| iqCalICh: 0:0x%.2x |\n", mh->iqCalICh[i]);
113 printf("| iqCalQCh: 0:0x%.2x |\n", mh->iqCalQCh[i]);
114 printf("| bswAtten: 0:0x%.2x |\n", mh->bswAtten[i]);
115 printf("| bswMargin: 0:0x%.2x |\n", mh->bswMargin[i]);
119 printf("| txEndToXpaOff: 0x%.2x | txEndToRxOn: 0x%.2x | txFrameToXpaOn: 0x%.2x |\n",
120 mh->txEndToXpaOff, mh->txEndToRxOn, mh->txFrameToXpaOn);
121 printf("| thres62: 0x%.2x\n", mh->thresh62);
122 printf("| xpdGain: 0x%.2x | xpd: 0x%.2x |\n", mh->xpdGain, mh->xpd);
124 printf("| pdGainOverlap: 0x%.2x xpaBiasLvl: 0x%.2x |\n", mh->pdGainOverlap, mh->xpaBiasLvl);
125 printf("| txFrameToDataStart: 0x%.2x | txFrameToPaOn: 0x%.2x |\n", mh->txFrameToDataStart, mh->txFrameToPaOn);
126 printf("| ht40PowerIncForPdadc: 0x%.2x |\n", mh->ht40PowerIncForPdadc);
127 printf("| swSettleHt40: 0x%.2x |\n", mh->swSettleHt40);
129 printf("| Modal Version: %.2x |\n", mh->version);
130 printf("| db1 = %d | db2 = %d |\n", mh->db1, mh->db2);
131 printf("| ob_cck = %d | ob_psk = %d | ob_qam = %d | ob_pal_off = %d |\n",
132 mh->ob_cck, mh->ob_psk, mh->ob_qam, mh->ob_pal_off);
134 printf("| futureModal: ");
135 for (i = 0; i < sizeof(mh->futureModal) / sizeof(uint16_t); i++) {
136 printf("0x%.2x ", mh->futureModal[i]);
140 /* and now, spur channels */
141 for (i = 0; i < AR5416_EEPROM_MODAL_SPURS; i++) {
142 printf("| Spur %d: spurChan: 0x%.4x spurRangeLow: 0x%.2x spurRangeHigh: 0x%.2x |\n",
143 i, mh->spurChans[i].spurChan,
144 (int) mh->spurChans[i].spurRangeLow,
145 (int) mh->spurChans[i].spurRangeHigh);
150 eeprom_9287_print_caldata_oploop(struct cal_data_op_loop_ar9287 *f)
154 /* XXX flesh out the rest */
155 for (i = 0; i < 2; i++) {
157 for (j = 0; j < 5; j++) {
158 printf("[%d][%d]=%d, ", i, j, f->pwrPdg[i][j]);
163 for (j = 0; j < 5; j++) {
164 printf("[%d][%d]=%d, ", i, j, f->vpdPdg[i][j]);
169 for (j = 0; j < 5; j++) {
170 printf("[%d][%d]=%d, ", i, j, f->pcdac[i][j]);
175 for (j = 0; j < 5; j++) {
176 printf("[%d][%d]=%d, ", i, j, f->empty[i][j]);
183 eeprom_9287_calfreqpiers_print(uint16_t *buf)
185 HAL_EEPROM_9287 *eep = (HAL_EEPROM_9287 *) buf;
189 printf("calFreqPier2G: ");
190 for (i = 0; i < AR9287_NUM_2G_CAL_PIERS; i++) {
191 printf(" 0x%.2x ", eep->ee_base.calFreqPier2G[i]);
195 for (i = 0; i < AR9287_NUM_2G_CAL_PIERS; i++) {
196 if (eep->ee_base.calFreqPier2G[i] == 0xff)
198 printf("2Ghz Cal Pier %d\n", i);
199 for (n = 0; n < AR9287_MAX_CHAINS; n++) {
200 printf(" Chain %d:\n", n);
201 eeprom_9287_print_caldata_oploop((void *)&eep->ee_base.calPierData2G[n][i]);
208 /* XXX these should just reference the v14 print routines */
210 eeprom_v14_target_legacy_print(CAL_TARGET_POWER_LEG *l)
213 if (l->bChannel == 0xff)
215 printf(" bChannel: %d;", l->bChannel);
216 for (i = 0; i < 4; i++) {
217 printf(" %.2f", (float) l->tPow2x[i] / 2.0);
223 eeprom_v14_target_ht_print(CAL_TARGET_POWER_HT *l)
226 if (l->bChannel == 0xff)
228 printf(" bChannel: %d;", l->bChannel);
229 for (i = 0; i < 8; i++) {
230 printf(" %.2f", (float) l->tPow2x[i] / 2.0);
236 eeprom_9287_print_targets(uint16_t *buf)
238 HAL_EEPROM_9287 *eep = (HAL_EEPROM_9287 *) buf;
242 printf("2Ghz CCK:\n");
243 for (i = 0; i < AR9287_NUM_2G_CCK_TARGET_POWERS; i++) {
244 eeprom_v14_target_legacy_print(&eep->ee_base.calTargetPowerCck[i]);
246 printf("2Ghz 11g:\n");
247 for (i = 0; i < AR9287_NUM_2G_20_TARGET_POWERS; i++) {
248 eeprom_v14_target_legacy_print(&eep->ee_base.calTargetPower2G[i]);
250 printf("2Ghz HT20:\n");
251 for (i = 0; i < AR9287_NUM_2G_20_TARGET_POWERS; i++) {
252 eeprom_v14_target_ht_print(&eep->ee_base.calTargetPower2GHT20[i]);
254 printf("2Ghz HT40:\n");
255 for (i = 0; i < AR9287_NUM_2G_40_TARGET_POWERS; i++) {
256 eeprom_v14_target_ht_print(&eep->ee_base.calTargetPower2GHT40[i]);
262 eeprom_9287_ctl_edge_print(struct cal_ctl_data_ar9287 *ctl)
267 for (i = 0; i < AR9287_MAX_CHAINS; i++) {
268 printf(" chain %d: ", i);
269 for (j = 0; j < AR9287_NUM_BAND_EDGES; j++) {
270 pow = ctl->ctlEdges[i][j].tPowerFlag & 0x3f;
271 flag = (ctl->ctlEdges[i][j].tPowerFlag & 0xc0) >> 6;
272 printf(" %d:pow=%d,flag=%.2x", j, pow, flag);
279 eeprom_9287_ctl_print(uint16_t *buf)
281 HAL_EEPROM_9287 *eep = (HAL_EEPROM_9287 *) buf;
284 for (i = 0; i < AR9287_NUM_CTLS; i++) {
285 if (eep->ee_base.ctlIndex[i] == 0)
287 printf("| ctlIndex: offset %d, value %d\n", i, eep->ee_base.ctlIndex[i]);
288 eeprom_9287_ctl_edge_print(&eep->ee_base.ctlData[i]);
293 eeprom_9287_print_edges(uint16_t *buf)
295 HAL_EEPROM_9287 *eep = (HAL_EEPROM_9287 *) buf;
298 printf("| eeNumCtls: %d\n", eep->ee_numCtls);
299 for (i = 0; i < NUM_EDGES*eep->ee_numCtls; i++) {
300 /* XXX is flag 8 or 32 bits? */
301 printf("| edge %2d/%2d: rdEdge: %5d EdgePower: %.2f dBm Flag: 0x%.8x\n",
302 i / NUM_EDGES, i % NUM_EDGES,
303 eep->ee_rdEdgesPower[i].rdEdge,
304 (float) eep->ee_rdEdgesPower[i].twice_rdEdgePower / 2.0,
305 eep->ee_rdEdgesPower[i].flag);
307 if (i % NUM_EDGES == (NUM_EDGES -1))
313 eeprom_9287_print_other(uint16_t *buf)
315 HAL_EEPROM_9287 *eep = (HAL_EEPROM_9287 *) buf;