1/*
2 * OTP support.
3 *
4 * Copyright (C) 2015, Broadcom Corporation. All Rights Reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 * $Id: bcmotp.h 461508 2014-03-12 09:37:07Z $
19 */
20
21#ifndef	_bcmotp_h_
22#define	_bcmotp_h_
23
24/* OTP regions */
25#define OTP_HW_RGN	1
26#define OTP_SW_RGN	2
27#define OTP_CI_RGN	4
28#define OTP_FUSE_RGN	8
29#define OTP_ALL_RGN	0xf	/* From h/w region to end of OTP including checksum */
30
31/* OTP Size */
32#define OTP_SZ_MAX		(6144/8)	/* maximum bytes in one CIS */
33
34/* Fixed size subregions sizes in words */
35#define OTPGU_CI_SZ		2
36
37/* OTP usage */
38#define OTP4325_FM_DISABLED_OFFSET	188
39
40#ifdef BCMNVRAMW
41/* Global RDE index for chips not having an OTP PMU resource. */
42#define OTP_GLOBAL_RDE_IDX 0xFF
43#endif
44
45/* Exported functions */
46extern int	otp_status(void *oh);
47extern int	otp_size(void *oh);
48extern uint16	otp_read_bit(void *oh, uint offset);
49extern void*	otp_init(si_t *sih);
50extern int	otp_newcis(void *oh);
51extern int	otp_read_region(si_t *sih, int region, uint16 *data, uint *wlen);
52extern int	otp_read_word(si_t *sih, uint wn, uint16 *data);
53extern int	otp_nvread(void *oh, char *data, uint *len);
54#ifdef BCMNVRAMW
55extern int	otp_write_region(si_t *sih, int region, uint16 *data, uint wlen, uint flags);
56extern int	otp_write_word(si_t *sih, uint wn, uint16 data);
57extern int	otp_cis_append_region(si_t *sih, int region, char *vars, int count);
58extern int	otp_lock(si_t *sih);
59extern int	otp_nvwrite(void *oh, uint16 *data, uint wlen);
60#endif /* BCMNVRAMW */
61
62#if defined(WLTEST)
63extern int	otp_dump(void *oh, int arg, char *buf, uint size);
64extern int	otp_dumpstats(void *oh, int arg, char *buf, uint size);
65#endif
66
67#if defined(BCMNVRAMW)
68#define otp_write_rde(oh, rde, bit, val)	ipxotp_write_rde(oh, rde, bit, val)
69extern int	ipxotp_write_rde(void *oh, int rde, uint bit, uint val);
70extern int otp_write_bits(void *oh, uint offset, int bits, uint8* data);
71
72#ifdef OTP_DEBUG
73extern int otp_verify1x(void *oh, uint off, uint fuse);
74extern int otp_read1x(void *oh, uint off, uint fuse);
75extern int otp_repair_bit(void *oh, uint off, uint val);
76extern int otp_write_ones(void *oh, uint off, uint bits);
77extern int otp_write_ones_old(void *oh, uint off, uint bits);
78#endif
79
80#endif
81
82#endif /* _bcmotp_h_ */
83