xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bcmdhd/include/bcmsrom.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Misc useful routines to access NIC local SROM/OTP .
3  *
4  * Copyright (C) 2020, Broadcom.
5  *
6  *      Unless you and Broadcom execute a separate written software license
7  * agreement governing use of this software, this software is licensed to you
8  * under the terms of the GNU General Public License version 2 (the "GPL"),
9  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10  * following added to such license:
11  *
12  *      As a special exception, the copyright holders of this software give you
13  * permission to link this software with independent modules, and to copy and
14  * distribute the resulting executable under terms of your choice, provided that
15  * you also meet, for each linked independent module, the terms and conditions of
16  * the license of that module.  An independent module is a module which is not
17  * derived from this software.  The special exception does not apply to any
18  * modifications of the software.
19  *
20  *
21  * <<Broadcom-WL-IPTag/Dual:>>
22  */
23 
24 #ifndef	_bcmsrom_h_
25 #define	_bcmsrom_h_
26 
27 #include <typedefs.h>
28 #include <osl_decl.h>
29 #include <siutils.h>
30 
31 #include <bcmsrom_fmt.h>
32 
33 typedef struct srom_info {
34 	char *_srom_vars;
35 	bool is_caldata_prsnt;
36 } srom_info_t;
37 
38 /* Prototypes */
39 extern int srom_var_init(si_t *sih, uint bus, volatile void *curmap, osl_t *osh,
40                          char **vars, uint *count);
41 extern void srom_var_deinit(si_t *sih);
42 
43 extern int srom_read(si_t *sih, uint bus, volatile void *curmap, osl_t *osh,
44                      uint byteoff, uint nbytes, uint16 *buf,
45                      bool check_crc);
46 
47 extern int srom_write(si_t *sih, uint bus, volatile void *curmap, osl_t *osh,
48                       uint byteoff, uint nbytes, uint16 *buf);
49 
50 extern int srom_write_short(si_t *sih, uint bustype, volatile void *curmap, osl_t *osh,
51                             uint byteoff, uint16 value);
52 extern int srom_otp_cisrwvar(si_t *sih, osl_t *osh, char *vars, int *count);
53 extern int srom_otp_write_region_crc(si_t *sih, uint nbytes, uint16* buf16, bool write);
54 
55 /* parse standard PCMCIA cis, normally used by SB/PCMCIA/SDIO/SPI/OTP
56  *   and extract from it into name=value pairs
57  */
58 extern int srom_parsecis(si_t *sih, osl_t *osh, uint8 **pcis, uint ciscnt,
59                          char **vars, uint *count);
60 extern int _initvars_srom_pci_caldata(si_t *sih, uint16 *srom, uint32 sromrev);
61 extern void srom_set_sromvars(char *vars);
62 extern char * srom_get_sromvars(void);
63 extern srom_info_t * srom_info_init(osl_t *osh);
64 extern int get_srom_pci_caldata_size(uint32 sromrev);
65 extern uint32 get_srom_size(uint32 sromrev);
66 
67 /* Return sprom size in 16-bit words */
68 extern uint srom_size(si_t *sih, osl_t *osh);
69 
70 extern bool srom_caldata_prsnt(si_t *sih);
71 extern int srom_get_caldata(si_t *sih, uint16 *srom);
72 #endif	/* _bcmsrom_h_ */
73