2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <linux/delay.h>
18 #include <linux/kernel.h>
19 #include <linux/string.h>
21 #include <linux/module.h>
22 #include <linux/pci.h>
29 #include "siutils_priv.h"
32 * There are two different OTP controllers so far:
33 * 1. new IPX OTP controller: chipc 21, >=23
34 * 2. older HND OTP controller: chipc 12, 17, 22
36 * Define BCMHNDOTP to include support for the HND OTP controller.
37 * Define BCMIPXOTP to include support for the IPX OTP controller.
39 * NOTE 1: More than one may be defined
40 * NOTE 2: If none are defined, the default is to include them all.
43 #if !defined(BCMHNDOTP) && !defined(BCMIPXOTP)
48 #define OTPTYPE_HND(ccrev) ((ccrev) < 21 || (ccrev) == 22)
49 #define OTPTYPE_IPX(ccrev) ((ccrev) == 21 || (ccrev) >= 23)
51 #define OTPP_TRIES 10000000 /* # of tries for OTPP */
54 #define MAXNUMRDES 9 /* Maximum OTP redundancy entries */
57 /* OTP common function type */
58 typedef int (*otp_status_t) (void *oh);
59 typedef int (*otp_size_t) (void *oh);
60 typedef void *(*otp_init_t) (si_t *sih);
61 typedef u16(*otp_read_bit_t) (void *oh, chipcregs_t *cc, uint off);
62 typedef int (*otp_read_region_t) (si_t *sih, int region, u16 *data,
64 typedef int (*otp_nvread_t) (void *oh, char *data, uint *len);
66 /* OTP function struct */
67 typedef struct otp_fn_s {
69 otp_read_bit_t read_bit;
71 otp_read_region_t read_region;
77 uint ccrev; /* chipc revision */
78 otp_fn_t *fn; /* OTP functions */
79 si_t *sih; /* Saved sb handle */
83 u16 wsize; /* Size of otp in words */
84 u16 rows; /* Geometry */
85 u16 cols; /* Geometry */
86 u32 status; /* Flag bits (lock/prog/rv).
87 * (Reflected only when OTP is power cycled)
89 u16 hwbase; /* hardware subregion offset */
90 u16 hwlim; /* hardware subregion boundary */
91 u16 swbase; /* software subregion offset */
92 u16 swlim; /* software subregion boundary */
93 u16 fbase; /* fuse subregion offset */
94 u16 flim; /* fuse subregion boundary */
95 int otpgu_base; /* offset to General Use Region */
96 #endif /* BCMIPXOTP */
100 uint size; /* Size of otp in bytes */
101 uint hwprot; /* Hardware protection bits */
102 uint signvalid; /* Signature valid bits */
103 int boundary; /* hw/sw boundary */
104 #endif /* BCMHNDOTP */
107 static otpinfo_t otpinfo;
112 * Exported functions:
117 * ipxotp_read_region()
124 #define HWSW_RGN(rgn) (((rgn) == OTP_HW_RGN) ? "h/w" : "s/w")
127 /* CC revs 21, 24 and 27 OTP General Use Region word offset */
128 #define REVA4_OTPGU_BASE 12
130 /* CC revs 23, 25, 26, 28 and above OTP General Use Region word offset */
131 #define REVB8_OTPGU_BASE 20
133 /* CC rev 36 OTP General Use Region word offset */
134 #define REV36_OTPGU_BASE 12
136 /* Subregion word offsets in General Use region */
137 #define OTPGU_HSB_OFF 0
138 #define OTPGU_SFB_OFF 1
139 #define OTPGU_CI_OFF 2
140 #define OTPGU_P_OFF 3
141 #define OTPGU_SROM_OFF 4
143 /* Flag bit offsets in General Use region */
144 #define OTPGU_HWP_OFF 60
145 #define OTPGU_SWP_OFF 61
146 #define OTPGU_CIP_OFF 62
147 #define OTPGU_FUSEP_OFF 63
148 #define OTPGU_CIP_MSK 0x4000
149 #define OTPGU_P_MSK 0xf000
150 #define OTPGU_P_SHIFT (OTPGU_HWP_OFF % 16)
153 #define OTP_SZ_FU_324 ((roundup(324, 8))/8) /* 324 bits */
154 #define OTP_SZ_FU_288 (288/8) /* 288 bits */
155 #define OTP_SZ_FU_216 (216/8) /* 216 bits */
156 #define OTP_SZ_FU_72 (72/8) /* 72 bits */
157 #define OTP_SZ_CHECKSUM (16/8) /* 16 bits */
158 #define OTP4315_SWREG_SZ 178 /* 178 bytes */
159 #define OTP_SZ_FU_144 (144/8) /* 144 bits */
161 static int ipxotp_status(void *oh)
163 otpinfo_t *oi = (otpinfo_t *) oh;
164 return (int)(oi->status);
167 /* Return size in bytes */
168 static int ipxotp_size(void *oh)
170 otpinfo_t *oi = (otpinfo_t *) oh;
171 return (int)oi->wsize * 2;
174 static u16 ipxotp_otpr(void *oh, chipcregs_t *cc, uint wn)
178 oi = (otpinfo_t *) oh;
180 ASSERT(wn < oi->wsize);
183 return R_REG(&cc->sromotp[wn]);
186 static u16 ipxotp_read_bit(void *oh, chipcregs_t *cc, uint off)
188 otpinfo_t *oi = (otpinfo_t *) oh;
192 row = off / oi->cols;
193 col = off % oi->cols;
195 otpp = OTPP_START_BUSY |
196 ((OTPPOC_READ << OTPP_OC_SHIFT) & OTPP_OC_MASK) |
197 ((row << OTPP_ROW_SHIFT) & OTPP_ROW_MASK) |
198 ((col << OTPP_COL_SHIFT) & OTPP_COL_MASK);
199 W_REG(&cc->otpprog, otpp);
202 ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY)
203 && (k < OTPP_TRIES); k++)
205 if (k >= OTPP_TRIES) {
208 if (st & OTPP_READERR) {
211 st = (st & OTPP_VALUE_MASK) >> OTPP_VALUE_SHIFT;
216 /* Calculate max HW/SW region byte size by substracting fuse region and checksum size,
217 * osizew is oi->wsize (OTP size - GU size) in words
219 static int ipxotp_max_rgnsz(si_t *sih, int osizew)
224 case BCM43224_CHIP_ID:
225 case BCM43225_CHIP_ID:
226 ret = osizew * 2 - OTP_SZ_FU_72 - OTP_SZ_CHECKSUM;
228 case BCM4313_CHIP_ID:
229 ret = osizew * 2 - OTP_SZ_FU_72 - OTP_SZ_CHECKSUM;
232 ASSERT(0); /* Don't konw about this chip */
238 static void _ipxotp_init(otpinfo_t *oi, chipcregs_t *cc)
243 /* record word offset of General Use Region for various chipcommon revs */
244 if (oi->sih->ccrev == 21 || oi->sih->ccrev == 24
245 || oi->sih->ccrev == 27) {
246 oi->otpgu_base = REVA4_OTPGU_BASE;
247 } else if (oi->sih->ccrev == 36) {
248 /* OTP size greater than equal to 2KB (128 words), otpgu_base is similar to rev23 */
249 if (oi->wsize >= 128)
250 oi->otpgu_base = REVB8_OTPGU_BASE;
252 oi->otpgu_base = REV36_OTPGU_BASE;
253 } else if (oi->sih->ccrev == 23 || oi->sih->ccrev >= 25) {
254 oi->otpgu_base = REVB8_OTPGU_BASE;
257 /* First issue an init command so the status is up to date */
259 OTPP_START_BUSY | ((OTPPOC_INIT << OTPP_OC_SHIFT) & OTPP_OC_MASK);
261 W_REG(&cc->otpprog, otpp);
263 ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY)
264 && (k < OTPP_TRIES); k++)
266 if (k >= OTPP_TRIES) {
270 /* Read OTP lock bits and subregion programmed indication bits */
271 oi->status = R_REG(&cc->otpstatus);
273 if ((oi->sih->chip == BCM43224_CHIP_ID)
274 || (oi->sih->chip == BCM43225_CHIP_ID)) {
277 (ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_P_OFF) &
280 oi->status |= (p_bits << OTPS_GUP_SHIFT);
284 * h/w region base and fuse region limit are fixed to the top and
285 * the bottom of the general use region. Everything else can be flexible.
287 oi->hwbase = oi->otpgu_base + OTPGU_SROM_OFF;
288 oi->hwlim = oi->wsize;
289 if (oi->status & OTPS_GUP_HW) {
291 ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_HSB_OFF) / 16;
292 oi->swbase = oi->hwlim;
294 oi->swbase = oi->hwbase;
296 /* subtract fuse and checksum from beginning */
297 oi->swlim = ipxotp_max_rgnsz(oi->sih, oi->wsize) / 2;
299 if (oi->status & OTPS_GUP_SW) {
301 ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_SFB_OFF) / 16;
302 oi->fbase = oi->swlim;
304 oi->fbase = oi->swbase;
306 oi->flim = oi->wsize;
309 static void *ipxotp_init(si_t *sih)
315 /* Make sure we're running IPX OTP */
316 ASSERT(OTPTYPE_IPX(sih->ccrev));
317 if (!OTPTYPE_IPX(sih->ccrev))
320 /* Make sure OTP is not disabled */
321 if (si_is_otp_disabled(sih)) {
325 /* Make sure OTP is powered up */
326 if (!si_is_otp_powered(sih)) {
332 /* Check for otp size */
333 switch ((sih->cccaps & CC_CAP_OTPSIZE) >> CC_CAP_OTPSIZE_SHIFT) {
352 case 7: /* 16x64 *//* 1024 bits */
358 /* Don't know the geometry */
362 /* Retrieve OTP region info */
363 idx = si_coreidx(sih);
364 cc = si_setcoreidx(sih, SI_CC_IDX);
367 _ipxotp_init(oi, cc);
369 si_setcoreidx(sih, idx);
374 static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen)
376 otpinfo_t *oi = (otpinfo_t *) oh;
381 /* Validate region selection */
384 sz = (uint) oi->hwlim - oi->hwbase;
385 if (!(oi->status & OTPS_GUP_HW)) {
387 return BCME_NOTFOUND;
391 return BCME_BUFTOOSHORT;
396 sz = ((uint) oi->swlim - oi->swbase);
397 if (!(oi->status & OTPS_GUP_SW)) {
399 return BCME_NOTFOUND;
403 return BCME_BUFTOOSHORT;
409 if (!(oi->status & OTPS_GUP_CI)) {
411 return BCME_NOTFOUND;
415 return BCME_BUFTOOSHORT;
417 base = oi->otpgu_base + OTPGU_CI_OFF;
420 sz = (uint) oi->flim - oi->fbase;
421 if (!(oi->status & OTPS_GUP_FUSE)) {
423 return BCME_NOTFOUND;
427 return BCME_BUFTOOSHORT;
432 sz = ((uint) oi->flim - oi->hwbase);
433 if (!(oi->status & (OTPS_GUP_HW | OTPS_GUP_SW))) {
435 return BCME_NOTFOUND;
439 return BCME_BUFTOOSHORT;
447 idx = si_coreidx(oi->sih);
448 cc = si_setcoreidx(oi->sih, SI_CC_IDX);
452 for (i = 0; i < sz; i++)
453 data[i] = ipxotp_otpr(oh, cc, base + i);
455 si_setcoreidx(oi->sih, idx);
460 static int ipxotp_nvread(void *oh, char *data, uint *len)
462 return BCME_UNSUPPORTED;
465 static otp_fn_t ipxotp_fn = {
466 (otp_size_t) ipxotp_size,
467 (otp_read_bit_t) ipxotp_read_bit,
469 (otp_init_t) ipxotp_init,
470 (otp_read_region_t) ipxotp_read_region,
471 (otp_nvread_t) ipxotp_nvread,
473 (otp_status_t) ipxotp_status
476 #endif /* BCMIPXOTP */
481 * Exported functions:
486 * hndotp_read_region()
493 /* Fields in otpstatus */
494 #define OTPS_PROGFAIL 0x80000000
495 #define OTPS_PROTECT 0x00000007
496 #define OTPS_HW_PROTECT 0x00000001
497 #define OTPS_SW_PROTECT 0x00000002
498 #define OTPS_CID_PROTECT 0x00000004
499 #define OTPS_RCEV_MSK 0x00003f00
500 #define OTPS_RCEV_SHIFT 8
502 /* Fields in the otpcontrol register */
503 #define OTPC_RECWAIT 0xff000000
504 #define OTPC_PROGWAIT 0x00ffff00
505 #define OTPC_PRW_SHIFT 8
506 #define OTPC_MAXFAIL 0x00000038
507 #define OTPC_VSEL 0x00000006
508 #define OTPC_SELVL 0x00000001
510 /* OTP regions (Word offsets from otp size) */
511 #define OTP_SWLIM_OFF (-4)
512 #define OTP_CIDBASE_OFF 0
513 #define OTP_CIDLIM_OFF 4
515 /* Predefined OTP words (Word offset from otp size) */
516 #define OTP_BOUNDARY_OFF (-4)
517 #define OTP_HWSIGN_OFF (-3)
518 #define OTP_SWSIGN_OFF (-2)
519 #define OTP_CIDSIGN_OFF (-1)
520 #define OTP_CID_OFF 0
521 #define OTP_PKG_OFF 1
522 #define OTP_FID_OFF 2
523 #define OTP_RSV_OFF 3
524 #define OTP_LIM_OFF 4
525 #define OTP_RD_OFF 4 /* Redundancy row starts here */
526 #define OTP_RC0_OFF 28 /* Redundancy control word 1 */
527 #define OTP_RC1_OFF 32 /* Redundancy control word 2 */
528 #define OTP_RC_LIM_OFF 36 /* Redundancy control word end */
530 #define OTP_HW_REGION OTPS_HW_PROTECT
531 #define OTP_SW_REGION OTPS_SW_PROTECT
532 #define OTP_CID_REGION OTPS_CID_PROTECT
534 #if OTP_HW_REGION != OTP_HW_RGN
535 #error "incompatible OTP_HW_RGN"
537 #if OTP_SW_REGION != OTP_SW_RGN
538 #error "incompatible OTP_SW_RGN"
540 #if OTP_CID_REGION != OTP_CI_RGN
541 #error "incompatible OTP_CI_RGN"
544 /* Redundancy entry definitions */
545 #define OTP_RCE_ROW_SZ 6
546 #define OTP_RCE_SIGN_MASK 0x7fff
547 #define OTP_RCE_ROW_MASK 0x3f
548 #define OTP_RCE_BITS 21
549 #define OTP_RCE_SIGN_SZ 15
550 #define OTP_RCE_BIT0 1
553 #define OTP_SIGNATURE 0x578a
554 #define OTP_MAGIC 0x4e56
556 static int hndotp_status(void *oh)
558 otpinfo_t *oi = (otpinfo_t *) oh;
559 return (int)(oi->hwprot | oi->signvalid);
562 static int hndotp_size(void *oh)
564 otpinfo_t *oi = (otpinfo_t *) oh;
565 return (int)(oi->size);
568 static u16 hndotp_otpr(void *oh, chipcregs_t *cc, uint wn)
571 otpinfo_t *oi = (otpinfo_t *) oh;
575 ASSERT(wn < ((oi->size / 2) + OTP_RC_LIM_OFF));
578 ptr = (volatile u16 *)((volatile char *)cc + CC_SROM_OTP);
579 return R_REG(&ptr[wn]);
582 static u16 hndotp_otproff(void *oh, chipcregs_t *cc, int woff)
584 otpinfo_t *oi = (otpinfo_t *) oh;
587 ASSERT(woff >= (-((int)oi->size / 2)));
588 ASSERT(woff < OTP_LIM_OFF);
591 ptr = (volatile u16 *)((volatile char *)cc + CC_SROM_OTP);
593 return R_REG(&ptr[(oi->size / 2) + woff]);
596 static u16 hndotp_read_bit(void *oh, chipcregs_t *cc, uint idx)
604 otpp = OTPP_START_BUSY | OTPP_READ |
605 ((row << OTPP_ROW_SHIFT) & OTPP_ROW_MASK) | (col & OTPP_COL_MASK);
607 W_REG(&cc->otpprog, otpp);
608 st = R_REG(&cc->otpprog);
610 ((st & OTPP_START_BUSY) == OTPP_START_BUSY) && (k < OTPP_TRIES);
612 st = R_REG(&cc->otpprog);
614 if (k >= OTPP_TRIES) {
617 if (st & OTPP_READERR) {
620 st = (st & OTPP_VALUE_MASK) >> OTPP_VALUE_SHIFT;
624 static void *hndotp_init(si_t *sih)
629 u32 cap = 0, clkdiv, otpdiv = 0;
634 idx = si_coreidx(sih);
637 cc = si_setcoreidx(sih, SI_CC_IDX);
639 cap = R_REG(&cc->capabilities);
640 if ((cap & CC_CAP_OTPSIZE) == 0) {
645 /* As of right now, support only 4320a2, 4311a1 and 4312 */
646 ASSERT((oi->ccrev == 12) || (oi->ccrev == 17)
647 || (oi->ccrev == 22));
649 ((oi->ccrev == 12) || (oi->ccrev == 17)
650 || (oi->ccrev == 22)))
653 /* Read the OTP byte size. chipcommon rev >= 18 has RCE so the size is
654 * 8 row (64 bytes) smaller
657 1 << (((cap & CC_CAP_OTPSIZE) >> CC_CAP_OTPSIZE_SHIFT)
658 + CC_CAP_OTPSIZE_BASE);
660 oi->size -= ((OTP_RC0_OFF - OTP_BOUNDARY_OFF) * 2);
662 oi->hwprot = (int)(R_REG(&cc->otpstatus) & OTPS_PROTECT);
665 /* Check the region signature */
666 if (hndotp_otproff(oi, cc, OTP_HWSIGN_OFF) == OTP_SIGNATURE) {
667 oi->signvalid |= OTP_HW_REGION;
668 oi->boundary = hndotp_otproff(oi, cc, OTP_BOUNDARY_OFF);
671 if (hndotp_otproff(oi, cc, OTP_SWSIGN_OFF) == OTP_SIGNATURE)
672 oi->signvalid |= OTP_SW_REGION;
674 if (hndotp_otproff(oi, cc, OTP_CIDSIGN_OFF) == OTP_SIGNATURE)
675 oi->signvalid |= OTP_CID_REGION;
677 /* Set OTP clkdiv for stability */
682 clkdiv = R_REG(&cc->clkdiv);
684 (clkdiv & ~CLKD_OTP) | (otpdiv << CLKD_OTP_SHIFT);
685 W_REG(&cc->clkdiv, clkdiv);
693 si_setcoreidx(sih, idx);
698 static int hndotp_read_region(void *oh, int region, u16 *data, uint *wlen)
700 otpinfo_t *oi = (otpinfo_t *) oh;
705 /* Only support HW region (no active chips use HND OTP SW region) */
706 ASSERT(region == OTP_HW_REGION);
709 st = oi->hwprot | oi->signvalid;
710 if ((st & region) == 0)
711 return BCME_NOTFOUND;
714 ((int)*wlen < oi->boundary / 2) ? *wlen : (uint) oi->boundary / 2;
716 idx = si_coreidx(oi->sih);
717 cc = si_setcoreidx(oi->sih, SI_CC_IDX);
720 for (i = 0; i < (int)*wlen; i++)
721 data[i] = hndotp_otpr(oh, cc, i);
723 si_setcoreidx(oi->sih, idx);
728 static int hndotp_nvread(void *oh, char *data, uint *len)
731 otpinfo_t *oi = (otpinfo_t *) oh;
732 u32 base, bound, lim = 0, st;
733 int i, chunk, gchunks, tsz = 0;
739 /* save the orig core */
740 idx = si_coreidx(oi->sih);
741 cc = si_setcoreidx(oi->sih, SI_CC_IDX);
744 st = hndotp_status(oh);
745 if (!(st & (OTP_HW_REGION | OTP_SW_REGION))) {
750 /* Read the whole otp so we can easily manipulate it */
751 lim = hndotp_size(oh);
752 rawotp = kmalloc(lim, GFP_ATOMIC);
753 if (rawotp == NULL) {
757 for (i = 0; i < (int)(lim / 2); i++)
758 rawotp[i] = hndotp_otpr(oh, cc, i);
760 if ((st & OTP_HW_REGION) == 0) {
761 /* This could be a programming failure in the first
762 * chunk followed by one or more good chunks
764 for (i = 0; i < (int)(lim / 2); i++)
765 if (rawotp[i] == OTP_MAGIC)
768 if (i < (int)(lim / 2)) {
770 bound = (i * 2) + rawotp[i + 1];
776 bound = rawotp[(lim / 2) + OTP_BOUNDARY_OFF];
778 /* There are two cases: 1) The whole otp is used as nvram
779 * and 2) There is a hardware header followed by nvram.
781 if (rawotp[0] == OTP_MAGIC) {
787 /* Find and copy the data */
793 while ((i < (int)(lim / 2)) && (rawotp[i] == OTP_MAGIC)) {
794 int dsz, rsz = rawotp[i + 1];
796 if (((i * 2) + rsz) >= (int)lim) {
797 /* Bad length, try to find another chunk anyway */
800 if (hndcrc16((u8 *) &rawotp[i], rsz,
801 CRC16_INIT_VALUE) == CRC16_GOOD_VALUE) {
802 /* Good crc, copy the vars */
806 if (offset + dsz >= *len) {
809 memcpy(&data[offset], &rawotp[i + 2], dsz);
811 /* Remove extra null characters at the end */
813 data[offset - 1] == 0 && data[offset - 2] == 0)
817 /* bad length or crc didn't check, try to find the next set */
818 if (rawotp[i + (rsz / 2)] == OTP_MAGIC) {
819 /* Assume length is good */
822 while (++i < (int)(lim / 2))
823 if (rawotp[i] == OTP_MAGIC)
834 si_setcoreidx(oi->sih, idx);
839 static otp_fn_t hndotp_fn = {
840 (otp_size_t) hndotp_size,
841 (otp_read_bit_t) hndotp_read_bit,
843 (otp_init_t) hndotp_init,
844 (otp_read_region_t) hndotp_read_region,
845 (otp_nvread_t) hndotp_nvread,
847 (otp_status_t) hndotp_status
850 #endif /* BCMHNDOTP */
853 * Common Code: Compiled for IPX / HND / AUTO
862 int otp_status(void *oh)
864 otpinfo_t *oi = (otpinfo_t *) oh;
866 return oi->fn->status(oh);
869 int otp_size(void *oh)
871 otpinfo_t *oi = (otpinfo_t *) oh;
873 return oi->fn->size(oh);
876 u16 otp_read_bit(void *oh, uint offset)
878 otpinfo_t *oi = (otpinfo_t *) oh;
879 uint idx = si_coreidx(oi->sih);
880 chipcregs_t *cc = si_setcoreidx(oi->sih, SI_CC_IDX);
881 u16 readBit = (u16) oi->fn->read_bit(oh, cc, offset);
882 si_setcoreidx(oi->sih, idx);
886 void *otp_init(si_t *sih)
892 memset(oi, 0, sizeof(otpinfo_t));
894 oi->ccrev = sih->ccrev;
897 if (OTPTYPE_IPX(oi->ccrev))
902 if (OTPTYPE_HND(oi->ccrev))
906 if (oi->fn == NULL) {
912 ret = (oi->fn->init) (sih);
918 otp_read_region(si_t *sih, int region, u16 *data,
924 wasup = si_is_otp_powered(sih);
926 si_otp_power(sih, true);
928 if (!si_is_otp_powered(sih) || si_is_otp_disabled(sih)) {
939 err = (((otpinfo_t *) oh)->fn->read_region) (oh, region, data, wlen);
943 si_otp_power(sih, false);
948 int otp_nvread(void *oh, char *data, uint *len)
950 otpinfo_t *oi = (otpinfo_t *) oh;
952 return oi->fn->nvread(oh, data, len);