3c507235323de1e7330a17a80210c70c1bd6b018
[cascardo/linux.git] / 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 #ifndef CSR_WIFI_XBV_TEST
25 /* Driver includes */
26 #include "csr_wifi_hip_unifi.h"
27 #endif
28
29
30 struct VMEQ
31 {
32     u32 addr;
33     u16 mask;
34     u16 value;
35 };
36
37 struct VAND
38 {
39     u32 first;
40     u32 count;
41 };
42
43 struct VERS
44 {
45     u32 num_vand;
46 };
47
48 struct FWDL
49 {
50     u32 dl_addr;
51     u32 dl_size;
52     u32 dl_offset;
53 };
54
55 struct FWOV
56 {
57     u32 dl_size;
58     u32 dl_offset;
59 };
60
61 struct PTDL
62 {
63     u32 dl_size;
64     u32 dl_offset;
65 };
66
67 #define MAX_VMEQ 64
68 #define MAX_VAND 64
69 #define MAX_FWDL 256
70 #define MAX_PTDL 256
71
72 /* An XBV1 file can either contain firmware or patches (at the
73  * moment).  The 'mode' member of the xbv1_t structure tells us which
74  * one is the case. */
75 typedef enum
76 {
77     xbv_unknown,
78     xbv_firmware,
79     xbv_patch
80 } xbv_mode;
81
82 typedef struct
83 {
84     xbv_mode mode;
85
86     /* Parts of a Firmware XBV1 */
87
88     struct VMEQ vmeq[MAX_VMEQ];
89     u32   num_vmeq;
90     struct VAND vand[MAX_VAND];
91     struct VERS vers;
92
93     u32 slut_addr;
94
95     /* F/W download image, possibly more than one part */
96     struct FWDL fwdl[MAX_FWDL];
97     s16    num_fwdl;
98
99     /* F/W overlay image, add r not used */
100     struct FWOV fwov;
101
102     /* Parts of a Patch XBV1 */
103
104     u32 build_id;
105
106     struct PTDL ptdl[MAX_PTDL];
107     s16    num_ptdl;
108 }  xbv1_t;
109
110
111 typedef s32 (*fwreadfn_t)(void *ospriv, void *dlpriv, u32 offset, void *buf, u32 len);
112
113 CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo);
114 s32 xbv1_read_slut(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo,
115                         symbol_t *slut, u32 slut_len);
116 void* xbv_to_patch(card_t *card, fwreadfn_t readfn, const void *fw_buf, const xbv1_t *fwinfo,
117                    u32 *size);
118
119 #endif /* __XBV_H__ */