Skip to content

Commit 73ecd8c

Browse files
committed
Add stub QCA9888 support
Add very basic QCA9888 chips calibration (board) data support. At the moment utility support only blob (file) loading, basic checking and very basic base header dumping.
1 parent 0597e0f commit 73ecd8c

File tree

6 files changed

+172
-1
lines changed

6 files changed

+172
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ OBJ=\
1111
eep_9287.o \
1212
eep_9300.o \
1313
eep_9880.o \
14+
eep_9888.o \
1415
eep_common.o \
1516
hw.o \
1617
utils.o \

atheepmgr.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2012 Qualcomm Atheros, Inc.
3-
* Copyright (c) 2013,2016-2020 Sergey Ryazanov <[email protected]>
3+
* Copyright (c) 2013,2016-2021 Sergey Ryazanov <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any
66
* purpose with or without fee is hereby granted, provided that the above
@@ -29,6 +29,7 @@ static const struct eepmap * const eepmaps[] = {
2929
&eepmap_9287,
3030
&eepmap_9300,
3131
&eepmap_9880,
32+
&eepmap_9888,
3233
};
3334

3435
#define AEM_CHIP(__name, __eepmap) \
@@ -45,6 +46,8 @@ static const struct eepmap * const eepmaps[] = {
4546
AEM_CHIP(__name, &eepmap_9300)
4647
#define AEM_CHIP_EEP9880(__name) \
4748
AEM_CHIP(__name, &eepmap_9880)
49+
#define AEM_CHIP_EEP9888(__name) \
50+
AEM_CHIP(__name, &eepmap_9888)
4851

4952
static const struct chip chips[] = {
5053
/* AR5211 EEPROM map PCI/PCIe chip(s) */
@@ -128,6 +131,17 @@ static const struct chip chips[] = {
128131
{ AEM_CHIP_EEP9880("QCA9882"), .pciids = {{ .dev_id = 0x003c }} },
129132
{ AEM_CHIP_EEP9880("QCA9890"), .pciids = {{ .dev_id = 0x003c }} },
130133
{ AEM_CHIP_EEP9880("QCA9892"), .pciids = {{ .dev_id = 0x003c }} },
134+
135+
/* QCA9888 EEPROM map PCIe chip(s) */
136+
{ AEM_CHIP_EEP9888("QCA9886"), .pciids = {{ .dev_id = 0x0056 }} },
137+
{ AEM_CHIP_EEP9888("QCA9888"), .pciids = {{ .dev_id = 0x0056 }} },
138+
{ AEM_CHIP_EEP9888("QCA9896"), .pciids = {{ .dev_id = 0x0056 }} }, /* Check PCI Id */
139+
{ AEM_CHIP_EEP9888("QCA9898"), .pciids = {{ .dev_id = 0x0056 }} }, /* Check PCI Id */
140+
/* QCA9888 EEPROM map WiSoC (AHB interface) chip(s) */
141+
{ AEM_CHIP_EEP9888("IPQ4018") },
142+
{ AEM_CHIP_EEP9888("IPQ4019") },
143+
{ AEM_CHIP_EEP9888("IPQ4028") },
144+
{ AEM_CHIP_EEP9888("IPQ4029") },
131145
};
132146

133147
int chips_find_by_pci_id(uint16_t dev_id, const struct chip *res[], int nmemb)

atheepmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ extern const struct eepmap eepmap_9285;
286286
extern const struct eepmap eepmap_9287;
287287
extern const struct eepmap eepmap_9300;
288288
extern const struct eepmap eepmap_9880;
289+
extern const struct eepmap eepmap_9888;
289290

290291
int chips_find_by_pci_id(uint16_t dev_id, const struct chip *res[], int nmemb);
291292

eep_9888.c

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Copyright (c) 2021 Sergey Ryazanov <[email protected]>
3+
*
4+
* Permission to use, copy, modify, and/or distribute this software for any
5+
* purpose with or without fee is hereby granted, provided that the above
6+
* copyright notice and this permission notice appear in all copies.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15+
*/
16+
17+
#include "atheepmgr.h"
18+
#include "utils.h"
19+
#include "eep_common.h"
20+
#include "eep_9888.h"
21+
22+
struct eep_9888_priv {
23+
int curr_ref_tpl; /* Current reference EEPROM template */
24+
struct qca9888_eeprom eep;
25+
};
26+
27+
static bool eep_9888_load_blob(struct atheepmgr *aem)
28+
{
29+
const int data_size = sizeof(struct qca9888_eeprom);
30+
struct eep_9888_priv *emp = aem->eepmap_priv;
31+
int res;
32+
33+
if (aem->con->blob->getsize(aem) < data_size)
34+
return false;
35+
res = aem->con->blob->read(aem, aem->eep_buf, data_size);
36+
if (res != data_size) {
37+
fprintf(stderr, "Unable to read calibration data blob\n");
38+
return false;
39+
}
40+
41+
memcpy(&emp->eep, aem->eep_buf, sizeof(emp->eep));
42+
43+
aem->eep_len = (data_size + 1) / 2;
44+
45+
return true;
46+
}
47+
48+
static int eep_9888_check(struct atheepmgr *aem)
49+
{
50+
struct eep_9888_priv *emp = aem->eepmap_priv;
51+
struct qca9888_eeprom *eep = &emp->eep;
52+
struct qca9888_base_eep_hdr *pBase = &eep->baseEepHeader;
53+
uint16_t sum;
54+
55+
if (pBase->length != sizeof(*eep) &&
56+
bswap_16(pBase->length) != sizeof(*eep)) {
57+
fprintf(stderr, "Bad EEPROM length 0x%04x/0x%04x (expect 0x%04x)\n",
58+
pBase->length, bswap_16(pBase->length),
59+
(unsigned int)sizeof(*eep));
60+
return false;
61+
}
62+
63+
/**
64+
* NB: take pointer another one time from container to avoid warning
65+
* about a *possible* unaligned access
66+
*/
67+
sum = eep_calc_csum((uint16_t *)&emp->eep,
68+
sizeof(emp->eep) / sizeof(uint16_t));
69+
if (sum != 0xffff) {
70+
fprintf(stderr, "Bad EEPROM checksum 0x%04x\n", sum);
71+
return false;
72+
}
73+
74+
return true;
75+
}
76+
77+
static void eep_9888_dump_base_header(struct atheepmgr *aem)
78+
{
79+
const struct eep_9888_priv *emp = aem->eepmap_priv;
80+
const struct qca9888_eeprom *eep = &emp->eep;
81+
const struct qca9888_base_eep_hdr *pBase = &eep->baseEepHeader;
82+
83+
EEP_PRINT_SECT_NAME("EEPROM Base Header");
84+
85+
printf("%-30s : 0x%04X\n", "Length", pBase->length);
86+
printf("%-30s : 0x%04X\n", "Checksum", pBase->checksum);
87+
printf("%-30s : %d\n", "EEP Version", pBase->eepromVersion);
88+
printf("%-30s : %d\n", "Template Version", pBase->templateVersion);
89+
printf("%-30s : %02X:%02X:%02X:%02X:%02X:%02X\n",
90+
"MacAddress",
91+
pBase->macAddr[0], pBase->macAddr[1], pBase->macAddr[2],
92+
pBase->macAddr[3], pBase->macAddr[4], pBase->macAddr[5]);
93+
94+
printf("\nCustomer Data in hex:\n");
95+
hexdump_print(pBase->custData, sizeof(pBase->custData));
96+
97+
printf("\n");
98+
}
99+
100+
const struct eepmap eepmap_9888 = {
101+
.name = "9888",
102+
.desc = "EEPROM map for .11ac chips (QCA9884/QCA9886/QCA9888/IPQ4018/IPQ4019/etc.)",
103+
.chip_regs = {
104+
.srev = 0x800ec,
105+
},
106+
.priv_data_sz = sizeof(struct eep_9888_priv),
107+
.eep_buf_sz = sizeof(struct qca9888_eeprom) / sizeof(uint16_t),
108+
.load_blob = eep_9888_load_blob,
109+
.check_eeprom = eep_9888_check,
110+
.dump = {
111+
[EEP_SECT_BASE] = eep_9888_dump_base_header,
112+
},
113+
};

eep_9888.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2021 Sergey Ryazanov <[email protected]>
3+
*
4+
* Permission to use, copy, modify, and/or distribute this software for any
5+
* purpose with or without fee is hereby granted, provided that the above
6+
* copyright notice and this permission notice appear in all copies.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15+
*/
16+
17+
#ifndef EEP_9888_H
18+
#define EEP_9888_H
19+
20+
#define QCA9888_CUSTOMER_DATA_SIZE 20
21+
22+
struct qca9888_base_eep_hdr {
23+
uint16_t length;
24+
uint16_t checksum;
25+
uint8_t eepromVersion;
26+
uint8_t templateVersion;
27+
uint8_t macAddr[6];
28+
uint8_t __unkn_0c[32];
29+
uint8_t custData[QCA9888_CUSTOMER_DATA_SIZE];
30+
} __attribute__ ((packed));
31+
32+
struct qca9888_eeprom {
33+
struct qca9888_base_eep_hdr baseEepHeader;
34+
35+
uint8_t __unkn_0040[12000]; /* to match structure size to the EEPROM data size */
36+
} __attribute__ ((packed));
37+
38+
/* Structure size watchdog */
39+
_Static_assert(sizeof(struct qca9888_eeprom) == 12064, "Invalid QCA9888 EEPROM structure size");
40+
41+
#endif

hw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#define AR5211_SREV 0x4020
2222
#define QCA988X_SREV 0x40ec
23+
#define QCA9888_SREV 0x800ec
2324
#define AR_SREV_ID 0x000000FF
2425
#define AR_SREV_VERSION 0x000000F0
2526
#define AR_SREV_VERSION_S 4

0 commit comments

Comments
 (0)