e1b109cbf2d59f73b9a69cbf443a6dabdde834ed
[b43-tools.git] / ssb_sprom / ssb_sprom.h
1 /*
2
3   Broadcom Sonics Silicon Backplane bus SPROM data modification tool
4
5   Copyright (c) 2006-2007 Michael Buesch <mb@bu3sch.de>
6
7   This program is free software; you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation; either version 2 of the License, or
10   (at your option) any later version.
11
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with this program; see the file COPYING.  If not, write to
19   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20   Boston, MA 02110-1301, USA.
21
22 */
23
24 #ifndef SSB_SPROMTOOL_H_
25 #define SSB_SPROMTOOL_H_
26
27 #include "utils.h"
28
29 #define VERSION                 ssb_stringify(VERSION_)
30
31 #define SPROM_SIZE              128 /* bytes */
32 #define SPROM4_SIZE             440
33
34 /* byte offsets */
35 #define SPROM_SUBP              (0x02 * 2)
36 #define SPROM4_SUBP             (0x02 * 2)
37 #define SPROM_SUBV              (0x03 * 2)
38 #define SPROM_PPID              (0x04 * 2)
39 #define SPROM4_PPID             (0x04 * 2)
40 #define SPROM_BFLHI             (0x1C * 2)
41 #define SPROM_IL0MACADDR        (0x24 * 2)
42 #define SPROM_ET0MACADDR        (0x27 * 2)
43 #define SPROM_ET1MACADDR        (0x2a * 2)
44 #define SPROM3_IL0MACADDR       (0x25 * 2)
45 #define SPROM3_ET0MACADDR       (0x28 * 2)
46 #define SPROM3_ET1MACADDR       (0x28 * 2)
47 #define SPROM4_IL0MACADDR       (0x26 * 2)
48 #define SPROM4_ET0MACADDR       (0x18 * 2)
49 #define SPROM4_ET1MACADDR       (0x26 * 2)
50 #define SPROM_ETHPHY            (0x2d * 2)
51 #define SPROM_BOARDREV          (0x2e * 2)
52 #define SPROM4_BOARDREV         (0x21 * 2)
53 #define SPROM4_ANTAVAIL         (0x2e * 2)
54 #define SPROM4_COUNTRY          (0x29 * 2)
55 #define SPROM_PA0B0             (0x2f * 2)
56 #define SPROM_PA0B1             (0x30 * 2)
57 #define SPROM_PA0B2             (0x31 * 2)
58 #define SPROM_WL0GPIO0          (0x32 * 2)
59 #define SPROM_WL0GPIO2          (0x33 * 2)
60 #define SPROM4_WL0GPIO0         (0x2b * 2)
61 #define SPROM4_WL0GPIO2         (0x2c * 2)
62 #define SPROM_MAXPWR            (0x34 * 2)
63 #define SPROM4_MAXPWR           (0x45 * 2)
64 #define SPROM_PA1B0             (0x35 * 2)
65 #define SPROM_PA1B1             (0x36 * 2)
66 #define SPROM_PA1B2             (0x37 * 2)
67 #define SPROM_IDL_TSSI_TGT      (0x38 * 2)
68 #define SPROM4_IDL_TSSI_TGT     (0x40 * 2)
69 #define SPROM_BOARDFLAGS        (0x39 * 2)
70 #define SPROM4_BOARDFLAGS       (0x22 * 2)
71 #define SPROM_ANTENNA_GAIN      (0x3a * 2)
72 #define SPROM4_ANTENNA_GAIN     (0x2f * 2)
73 #define SPROM_VERSION           (0x3f * 2)
74 #define SPROM4_VERSION          (0xdb * 2)
75
76 enum valuetype {
77         VALUE_RAW,
78
79         VALUE_SUBP,
80  VALUE_FIRST = VALUE_SUBP,
81         VALUE_SUBV,
82         VALUE_PPID,
83         VALUE_BFLHI,
84         VALUE_BFL,
85         VALUE_BGMAC,
86         VALUE_ETMAC,
87         VALUE_AMAC,
88         VALUE_ET0PHY,
89         VALUE_ET1PHY,
90         VALUE_ET0MDC,
91         VALUE_ET1MDC,
92         VALUE_BREV,
93         VALUE_LOC,
94         VALUE_ANTBG0,
95         VALUE_ANTBG1,
96         VALUE_ANTA0,
97         VALUE_ANTA1,
98         VALUE_ANTGBG,
99         VALUE_ANTGA,
100         VALUE_PA0B0,
101         VALUE_PA0B1,
102         VALUE_PA0B2,
103         VALUE_PA1B0,
104         VALUE_PA1B1,
105         VALUE_PA1B2,
106         VALUE_WL0GPIO0,
107         VALUE_WL0GPIO1,
108         VALUE_WL0GPIO2,
109         VALUE_WL0GPIO3,
110         VALUE_MAXPBG,
111         VALUE_MAXPA,
112         VALUE_ITSSIBG,
113         VALUE_ITSSIA,
114         VALUE_SVER,
115  VALUE_LAST = VALUE_SVER,
116 };
117
118 struct cmdline_vparm {
119         enum valuetype type;
120         int set;
121         int bits;
122         union {
123                 uint16_t value;
124                 uint8_t mac[6];
125                 struct {
126                         uint16_t value;
127                         uint16_t offset;
128                 } raw;
129         } u;
130 };
131
132 struct cmdline_args {
133         const char *infile;
134         const char *outfile;
135         int verbose;
136         int force;
137         int bin_mode;
138
139 #define MAX_VPARM       512
140         struct cmdline_vparm vparm[MAX_VPARM];
141         int nr_vparm;
142 };
143 extern struct cmdline_args cmdargs;
144
145 #endif /* SSB_SPROMTOOL_H_ */