9705c0a0aab1a581843a15aca8e4e85e9d2b9b67
[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
30 #define SPROM_SIZE              128 /* bytes */
31 #define SPROM4_SIZE             440
32
33 /* byte offsets */
34 #define SPROM_SUBP              (0x02 * 2)
35 #define SPROM4_SUBP             (0x02 * 2)
36 #define SPROM_SUBV              (0x03 * 2)
37 #define SPROM_PPID              (0x04 * 2)
38 #define SPROM4_PPID             (0x04 * 2)
39 #define SPROM_BFLHI             (0x1C * 2)
40 #define SPROM_IL0MACADDR        (0x24 * 2)
41 #define SPROM_ET0MACADDR        (0x27 * 2)
42 #define SPROM_ET1MACADDR        (0x2a * 2)
43 #define SPROM3_IL0MACADDR       (0x25 * 2)
44 #define SPROM3_ET0MACADDR       (0x28 * 2)
45 #define SPROM3_ET1MACADDR       (0x28 * 2)
46 #define SPROM4_IL0MACADDR       (0x26 * 2)
47 #define SPROM4_ET0MACADDR       (0x18 * 2)
48 #define SPROM4_ET1MACADDR       (0x26 * 2)
49 #define SPROM_ETHPHY            (0x2d * 2)
50 #define SPROM_BOARDREV          (0x2e * 2)
51 #define SPROM4_BOARDREV         (0x21 * 2)
52 #define SPROM4_ANTAVAIL         (0x2e * 2)
53 #define SPROM4_COUNTRY          (0x29 * 2)
54 #define SPROM_PA0B0             (0x2f * 2)
55 #define SPROM_PA0B1             (0x30 * 2)
56 #define SPROM_PA0B2             (0x31 * 2)
57 #define SPROM_WL0GPIO0          (0x32 * 2)
58 #define SPROM_WL0GPIO2          (0x33 * 2)
59 #define SPROM4_WL0GPIO0         (0x2b * 2)
60 #define SPROM4_WL0GPIO2         (0x2c * 2)
61 #define SPROM_MAXPWR            (0x34 * 2)
62 #define SPROM4_MAXPWR           (0x45 * 2)
63 #define SPROM_PA1B0             (0x35 * 2)
64 #define SPROM_PA1B1             (0x36 * 2)
65 #define SPROM_PA1B2             (0x37 * 2)
66 #define SPROM_IDL_TSSI_TGT      (0x38 * 2)
67 #define SPROM4_IDL_TSSI_TGT     (0x40 * 2)
68 #define SPROM_BOARDFLAGS        (0x39 * 2)
69 #define SPROM4_BOARDFLAGS       (0x22 * 2)
70 #define SPROM_ANTENNA_GAIN      (0x3a * 2)
71 #define SPROM4_ANTENNA_GAIN     (0x2f * 2)
72 #define SPROM_VERSION           (0x3f * 2)
73 #define SPROM4_VERSION          (0xdb * 2)
74
75 enum valuetype {
76         VALUE_RAW,
77
78         VALUE_SUBP,
79  VALUE_FIRST = VALUE_SUBP,
80         VALUE_SUBV,
81         VALUE_PPID,
82         VALUE_BFLHI,
83         VALUE_BFL,
84         VALUE_BGMAC,
85         VALUE_ETMAC,
86         VALUE_AMAC,
87         VALUE_ET0PHY,
88         VALUE_ET1PHY,
89         VALUE_ET0MDC,
90         VALUE_ET1MDC,
91         VALUE_BREV,
92         VALUE_LOC,
93         VALUE_ANTBG0,
94         VALUE_ANTBG1,
95         VALUE_ANTA0,
96         VALUE_ANTA1,
97         VALUE_ANTGBG,
98         VALUE_ANTGA,
99         VALUE_PA0B0,
100         VALUE_PA0B1,
101         VALUE_PA0B2,
102         VALUE_PA1B0,
103         VALUE_PA1B1,
104         VALUE_PA1B2,
105         VALUE_WL0GPIO0,
106         VALUE_WL0GPIO1,
107         VALUE_WL0GPIO2,
108         VALUE_WL0GPIO3,
109         VALUE_MAXPBG,
110         VALUE_MAXPA,
111         VALUE_ITSSIBG,
112         VALUE_ITSSIA,
113         VALUE_SVER,
114  VALUE_LAST = VALUE_SVER,
115 };
116
117 struct cmdline_vparm {
118         enum valuetype type;
119         int set;
120         int bits;
121         union {
122                 uint16_t value;
123                 uint8_t mac[6];
124                 struct {
125                         uint16_t value;
126                         uint16_t offset;
127                 } raw;
128         } u;
129 };
130
131 struct cmdline_args {
132         const char *infile;
133         const char *outfile;
134         int verbose;
135         int force;
136         int bin_mode;
137
138 #define MAX_VPARM       512
139         struct cmdline_vparm vparm[MAX_VPARM];
140         int nr_vparm;
141 };
142 extern struct cmdline_args cmdargs;
143
144 #endif /* SSB_SPROMTOOL_H_ */