]> Pileus Git - ~andy/linux/blob - drivers/staging/csr/csr_wifi_hip_xbv.h
Merge git://git.infradead.org/users/willy/linux-nvme
[~andy/linux] / drivers / staging / csr / csr_wifi_hip_xbv.h
1 /*****************************************************************************
2
3             (c) Cambridge Silicon Radio Limited 2011
4             All rights reserved and confidential information of CSR
5
6             Refer to LICENSE.txt included with this source for details
7             on the license terms.
8
9 *****************************************************************************/
10
11 /*
12  * ---------------------------------------------------------------------------
13  * FILE: csr_wifi_hip_xbv.h
14  *
15  * PURPOSE:
16  *      Definitions and declarations for code to read XBV files - the UniFi
17  *      firmware download file format.
18  *
19  * ---------------------------------------------------------------------------
20  */
21 #ifndef __XBV_H__
22 #define __XBV_H__
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #ifndef CSR_WIFI_XBV_TEST
29 /* Driver includes */
30 #include "csr_wifi_hip_unifi.h"
31 #endif
32
33
34 struct VMEQ
35 {
36     u32 addr;
37     u16 mask;
38     u16 value;
39 };
40
41 struct VAND
42 {
43     u32 first;
44     u32 count;
45 };
46
47 struct VERS
48 {
49     u32 num_vand;
50 };
51
52 struct FWDL
53 {
54     u32 dl_addr;
55     u32 dl_size;
56     u32 dl_offset;
57 };
58
59 struct FWOV
60 {
61     u32 dl_size;
62     u32 dl_offset;
63 };
64
65 struct PTDL
66 {
67     u32 dl_size;
68     u32 dl_offset;
69 };
70
71 #define MAX_VMEQ 64
72 #define MAX_VAND 64
73 #define MAX_FWDL 256
74 #define MAX_PTDL 256
75
76 /* An XBV1 file can either contain firmware or patches (at the
77  * moment).  The 'mode' member of the xbv1_t structure tells us which
78  * one is the case. */
79 typedef enum
80 {
81     xbv_unknown,
82     xbv_firmware,
83     xbv_patch
84 } xbv_mode;
85
86 typedef struct
87 {
88     xbv_mode mode;
89
90     /* Parts of a Firmware XBV1 */
91
92     struct VMEQ vmeq[MAX_VMEQ];
93     u32   num_vmeq;
94     struct VAND vand[MAX_VAND];
95     struct VERS vers;
96
97     u32 slut_addr;
98
99     /* F/W download image, possibly more than one part */
100     struct FWDL fwdl[MAX_FWDL];
101     s16    num_fwdl;
102
103     /* F/W overlay image, add r not used */
104     struct FWOV fwov;
105
106     /* Parts of a Patch XBV1 */
107
108     u32 build_id;
109
110     struct PTDL ptdl[MAX_PTDL];
111     s16    num_ptdl;
112 }  xbv1_t;
113
114
115 typedef s32 (*fwreadfn_t)(void *ospriv, void *dlpriv, u32 offset, void *buf, u32 len);
116
117 CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo);
118 s32 xbv1_read_slut(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo,
119                         symbol_t *slut, u32 slut_len);
120 void* xbv_to_patch(card_t *card, fwreadfn_t readfn, const void *fw_buf, const xbv1_t *fwinfo,
121                    u32 *size);
122
123 #ifdef __cplusplus
124 }
125 #endif
126
127 #endif /* __XBV_H__ */