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