summaryrefslogtreecommitdiff
path: root/drivers/power/wmt_battery/gauge/ug31xx/uG31xx_API_Otp.c
blob: 0b1b2d1a7112fb2201c0169aefbf91bfd33be28d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
/**
 * @filename  uG31xx_API_Otp.cpp
 *
 *  Convert OTP registers into readable value
 *
 * @author  AllenTeng <allen_teng@upi-semi.com>
 */

#include "stdafx.h"     //windows need this??
#include "uG31xx_API.h"

/// =============================================
/// [AT-PM] : OTP register definition
/// =============================================

#define OTP1_OFFSET_E0                (0)
  #define INDEX_ADC1_200_25_0         (1<<0)
  #define INDEX_ADC1_200_25_1         (1<<1)
  #define INDEX_ADC1_200_25_2         (1<<2)
  #define INDEX_ADC1_200_25_3         (1<<3)
  #define DELTA_VREF_0                (1<<4)
  #define DELTA_VREF_1                (1<<5)
  #define DELTA_VREF_2                (1<<6)
  #define DELTA_VREF_3                (1<<7)
  
#define OTP1_OFFSET_E1                (OTP1_OFFSET_E0 + 1)
  #define INDEX_ADC1_100_25_0         (1<<0)
  #define INDEX_ADC1_100_25_1         (1<<1)
  #define INDEX_ADC1_100_25_2         (1<<2)
  #define INDEX_ADC1_100_25_3         (1<<3)
  #define FT_IT_3                     (1<<4)
  #define FT_IT_4                     (1<<5)
  #define FT_IT_5                     (1<<6)
  #define FT_IT_6                     (1<<7)

#define OTP1_OFFSET_E2                (OTP1_OFFSET_E1 + 1)
  #define INDEX_ADC2_200_25_0         (1<<0)
  #define INDEX_ADC2_200_25_1         (1<<1)
  #define INDEX_ADC2_200_25_2         (1<<2)
  #define INDEX_ADC2_200_25_3         (1<<3)
  #define FT_IT_7                     (1<<4)
  #define FT_IT_8                     (1<<5)
  #define FT_IT_9                     (1<<6)
  #define FT_IT_10                    (1<<7)

#define OTP1_OFFSET_E3                (OTP1_OFFSET_E2 + 1)
  #define INDEX_ADC2_100_25_0         (1<<0)
  #define INDEX_ADC2_100_25_1         (1<<1)
  #define INDEX_ADC2_100_25_2         (1<<2)
  #define INDEX_ADC2_100_25_3         (1<<3)
  #define FT_IT_11                    (1<<4)
  #define FT_IT_12                    (1<<5)
  #define FT_IT_13                    (1<<6)
  #define FT_IT_14                    (1<<7)

#define OTP2_OFFSET_F0                (0)
  #define OTP2_OFFSET_F0_RSVD_0       (1<<0)
  #define OTP2_OFFSET_F0_RSVD_1       (1<<1)
  #define OTP2_OFFSET_F0_RSVD_2       (1<<2)
  #define PRODUCT_TYPE_0              (1<<3)
  #define PRODUCT_TYPE_1              (1<<4)
  #define DELTA_ET_0                  (1<<5)
  #define INDEX_ADC2_100_25_4         (1<<6)
  #define DELTA_ET_1                  (1<<7)

#define OTP2_OFFSET_F1                (OTP2_OFFSET_F0 + 1)
  #define OTP2_OFFSET_F1_RSVD_0       (1<<0)
  #define OTP2_OFFSET_F1_RSVD_1       (1<<1)
  #define OTP2_OFFSET_F1_RSVD_2       (1<<2)
  #define OTP2_OFFSET_F1_RSVD_3       (1<<3)
  #define OTP2_OFFSET_F1_RSVD_4       (1<<4)
  #define OTP2_OFFSET_F1_RSVD_5       (1<<5)
  #define OTP2_OFFSET_F1_RSVD_6       (1<<6)
  #define OTP2_OFFSET_F1_RSVD_7       (1<<7)

#define OTP2_OFFSET_F2                (OTP2_OFFSET_F1 + 1)
  #define OTP2_OFFSET_F2_RSVD_0       (1<<0)
  #define OTP2_OFFSET_F2_RSVD_1       (1<<1)
  #define OTP2_OFFSET_F2_RSVD_2       (1<<2)
  #define OTP_CELL_EN_0               (1<<3)
  #define OTP_CELL_EN_1               (1<<4)
  #define OTP_CELL_EN_2               (1<<5)
  #define OTP_CELL_EN_3               (1<<6)
  #define OTP_CELL_EN_4               (1<<7)

#define OTP2_OFFSET_F3                (OTP2_OFFSET_F2 + 1)
  #define OTP2_OFFSET_F3_RSVD_0       (1<<0)
  #define OTP2_OFFSET_F3_RSVD_1       (1<<1)
  #define OTP2_OFFSET_F3_RSVD_2       (1<<2)
  #define OTP2_OFFSET_F3_RSVD_3       (1<<3)
  #define OTP2_OFFSET_F3_RSVD_4       (1<<4)
  #define OTP2_OFFSET_F3_RSVD_5       (1<<5)
  #define OTP2_OFFSET_F3_RSVD_6       (1<<6)
  #define OTP2_OFFSET_F3_RSVD_7       (1<<7)

#define OTP2_OFFSET_F4                (OTP2_OFFSET_F3 + 1)
  #define ADC1_DELTA_CODE_25_200MV_8  (1<<0)
  #define ADC1_DELTA_CODE_25_200MV_9  (1<<1)
  #define DEV_ADDR_0                  (1<<2)
  #define DEV_ADDR_1                  (1<<3)
  #define DEV_ADDR_2                  (1<<4)
  #define DEV_ADDR_7                  (1<<5)
  #define DEV_ADDR_8                  (1<<6)
  #define DEV_ADDR_9                  (1<<7)
  
#define OTP2_OFFSET_F5                (OTP2_OFFSET_F4 + 1)
  #define OTP2_OFFSET_F5_RSVD_0       (1<<0)
  #define OTP2_OFFSET_F5_RSVD_1       (1<<1)
  #define BGR_TUNE_0                  (1<<2)
  #define BGR_TUNE_1                  (1<<3)
  #define BGR_TUNE_2                  (1<<4)
  #define BGR_TUNE_3                  (1<<5)
  #define BGR_TUNE_4                  (1<<6)
  #define BGR_TUNE_5                  (1<<7)

#define OTP2_OFFSET_F6                (OTP2_OFFSET_F5 + 1)
  #define OSC_DELTA_CODE_25_0         (1<<0)
  #define OSC_DELTA_CODE_25_1         (1<<1)
  #define OSC_DELTA_CODE_25_2         (1<<2)
  #define OSC_DELTA_CODE_25_3         (1<<3)
  #define OSC_DELTA_CODE_25_4         (1<<4)
  #define OSC_DELTA_CODE_25_5         (1<<5)
  #define OSC_DELTA_CODE_25_6         (1<<6)
  #define OSC_DELTA_CODE_25_7         (1<<7)

#define OTP2_OFFSET_F7                (OTP2_OFFSET_F6 + 1)
  #define OSC_DELTA_CODE_80_0         (1<<0)
  #define OSC_DELTA_CODE_80_1         (1<<1)
  #define OSC_DELTA_CODE_80_2         (1<<2)
  #define OSC_DELTA_CODE_80_3         (1<<3)
  #define OSC_DELTA_CODE_80_4         (1<<4)
  #define OSC_DELTA_CODE_80_5         (1<<5)
  #define OSC_DELTA_CODE_80_6         (1<<6)
  #define OSC_DELTA_CODE_80_7         (1<<7)

#define OTP2_OFFSET_F8                (OTP2_OFFSET_F7 + 1)
  #define ADC1_DELTA_CODE_25_200MV_0  (1<<0)
  #define ADC1_DELTA_CODE_25_200MV_1  (1<<1)
  #define ADC1_DELTA_CODE_25_200MV_2  (1<<2)
  #define ADC1_DELTA_CODE_25_200MV_3  (1<<3)
  #define ADC1_DELTA_CODE_25_200MV_4  (1<<4)
  #define ADC1_DELTA_CODE_25_200MV_5  (1<<5)
  #define ADC1_DELTA_CODE_25_200MV_6  (1<<6)
  #define ADC1_DELTA_CODE_25_200MV_7  (1<<7)

#define OTP2_OFFSET_F9                (OTP2_OFFSET_F8 + 1)
  #define OTP2_OFFSET_F9_RSVD_0       (1<<0)
  #define OTP2_OFFSET_F9_RSVD_1       (1<<1)
  #define OTP2_OFFSET_F9_RSVD_2       (1<<2)
  #define OTP2_OFFSET_F9_RSVD_3       (1<<3)
  #define OTP2_OFFSET_F9_RSVD_4       (1<<4)
  #define OTP2_OFFSET_F9_RSVD_5       (1<<5)
  #define OTP2_OFFSET_F9_RSVD_6       (1<<6)
  #define OTP2_OFFSET_F9_RSVD_7       (1<<7)

#define OTP2_OFFSET_FA                (OTP2_OFFSET_F9 + 1)
  #define ADC1_DELTA_CODE_25_100MV_0  (1<<0)
  #define ADC1_DELTA_CODE_25_100MV_1  (1<<1)
  #define ADC1_DELTA_CODE_25_100MV_2  (1<<2)
  #define ADC1_DELTA_CODE_25_100MV_3  (1<<3)
  #define ADC1_DELTA_CODE_25_100MV_4  (1<<4)
  #define ADC1_DELTA_CODE_25_100MV_5  (1<<5)
  #define ADC1_DELTA_CODE_25_100MV_6  (1<<6)
  #define ADC1_DELTA_CODE_25_100MV_7  (1<<7)

#define OTP2_OFFSET_FB                (OTP2_OFFSET_FA + 1)
  #define OTP2_OFFSET_FB_RSVD_0       (1<<0)
  #define OTP2_OFFSET_FB_RSVD_1       (1<<1)
  #define OTP2_OFFSET_FB_RSVD_2       (1<<2)
  #define OTP2_OFFSET_FB_RSVD_3       (1<<3)
  #define OTP2_OFFSET_FB_RSVD_4       (1<<4)
  #define OTP2_OFFSET_FB_RSVD_5       (1<<5)
  #define OTP2_OFFSET_FB_RSVD_6       (1<<6)
  #define OTP2_OFFSET_FB_RSVD_7       (1<<7)

#define OTP2_OFFSET_FC                (OTP2_OFFSET_FB + 1)
  #define ADC1_DELTA_CODE_25_100MV_8  (1<<0)
  #define ADC2_DELTA_CODE_25_100MV_0  (1<<1)
  #define ADC2_DELTA_CODE_25_100MV_1  (1<<2)
  #define ADC2_DELTA_CODE_25_100MV_2  (1<<3)
  #define ADC2_DELTA_CODE_25_100MV_3  (1<<4)
  #define ADC2_DELTA_CODE_25_100MV_4  (1<<5)
  #define ADC2_DELTA_CODE_25_100MV_5  (1<<6)
  #define ADC2_DELTA_CODE_25_100MV_6  (1<<7)

#define OTP2_OFFSET_FD                (OTP2_OFFSET_FC + 1)
  #define OTP2_OFFSET_FD_RSVD_0       (1<<0)
  #define OTP2_OFFSET_FD_RSVD_1       (1<<1)
  #define OTP2_OFFSET_FD_RSVD_2       (1<<2)
  #define OTP2_OFFSET_FD_RSVD_3       (1<<3)
  #define OTP2_OFFSET_FD_RSVD_4       (1<<4)
  #define OTP2_OFFSET_FD_RSVD_5       (1<<5)
  #define OTP2_OFFSET_FD_RSVD_6       (1<<6)
  #define OTP2_OFFSET_FD_RSVD_7       (1<<7)

#define OTP2_OFFSET_FE                (OTP2_OFFSET_FD + 1)
  #define ADC2_DELTA_CODE_25_200MV_0  (1<<0)
  #define ADC2_DELTA_CODE_25_200MV_1  (1<<1)
  #define ADC2_DELTA_CODE_25_200MV_2  (1<<2)
  #define ADC2_DELTA_CODE_25_200MV_3  (1<<3)
  #define ADC2_DELTA_CODE_25_200MV_4  (1<<4)
  #define ADC2_DELTA_CODE_25_200MV_5  (1<<5)
  #define ADC2_DELTA_CODE_25_200MV_6  (1<<6)
  #define ADC2_DELTA_CODE_25_200MV_7  (1<<7)

#define OTP2_OFFSET_FF                (OTP2_OFFSET_FE + 1)
  #define OTP2_OFFSET_FF_RSVD_0       (1<<0)
  #define OTP2_OFFSET_FF_RSVD_1       (1<<1)
  #define OTP2_OFFSET_FF_RSVD_2       (1<<2)
  #define OTP2_OFFSET_FF_RSVD_3       (1<<3)
  #define OTP2_OFFSET_FF_RSVD_4       (1<<4)
  #define OTP2_OFFSET_FF_RSVD_5       (1<<5)
  #define OTP2_OFFSET_FF_RSVD_6       (1<<6)
  #define OTP2_OFFSET_FF_RSVD_7       (1<<7)


#define OTP3_OFFSET_70                (0)
  #define DELTA_VREF_4                (1<<0)
  #define DELTA_ET_2                  (1<<1)
  #define DELTA_ET_3                  (1<<2)
  #define AVE_IT_25_3                 (1<<3)
  #define AVE_IT_25_4                 (1<<4)
  #define AVE_IT_25_5                 (1<<5)
  #define AVE_IT_25_6                 (1<<6)
  #define AVE_IT_25_7                 (1<<7)

#define OTP3_OFFSET_71                (OTP3_OFFSET_70 + 1)
  #define AVE_IT_25_8                 (1<<0)
  #define AVE_IT_25_9                 (1<<1)
  #define AVE_IT_25_10                (1<<2)
  #define AVE_IT_25_11                (1<<3)
  #define AVE_IT_25_12                (1<<4)
  #define AVE_IT_25_13                (1<<5)
  #define AVE_IT_25_14                (1<<6)
  #define AVE_IT_25_15                (1<<7)

#define OTP3_OFFSET_72                (OTP3_OFFSET_71 + 1)
  #define INDEX_ADC2_200_25_4         (1<<0)
  #define INDEX_ADC1_100_25_4         (1<<1)
  #define INDEX_ADC1_200_25_4         (1<<2)
  #define AVE_IT_80_3                 (1<<3)
  #define AVE_IT_80_4                 (1<<4)
  #define AVE_IT_80_5                 (1<<5)
  #define AVE_IT_80_6                 (1<<6)
  #define AVE_IT_80_7                 (1<<7)

#define OTP3_OFFSET_73                (OTP3_OFFSET_72 + 1)
  #define AVE_IT_80_8                 (1<<0)
  #define AVE_IT_80_9                 (1<<1)
  #define AVE_IT_80_10                (1<<2)
  #define AVE_IT_80_11                (1<<3)
  #define AVE_IT_80_12                (1<<4)
  #define AVE_IT_80_13                (1<<5)
  #define AVE_IT_80_14                (1<<6)
  #define AVE_IT_80_15                (1<<7)

/// =============================================
/// [AT-PM] : OTP register conversion routine
/// =============================================

/**
 * @brief ConvOtp1E0
 *
 *  Convert OTP1 0xE0
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp1E0(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp1[OTP1_OFFSET_E0];
  
  obj->indexAdc1V200T25 = obj->indexAdc1V200T25 + (value & (INDEX_ADC1_200_25_0 | 
                                                            INDEX_ADC1_200_25_1 | 
                                                            INDEX_ADC1_200_25_2 | 
                                                            INDEX_ADC1_200_25_3));

  obj->deltaVref = obj->deltaVref + ((value & (DELTA_VREF_0| DELTA_VREF_1 | DELTA_VREF_2 | DELTA_VREF_3)) >> 4);
}

/**
 * @brief ConvOtp1E1
 *
 *  Convert OTP1 0xE1
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp1E1(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp1[OTP1_OFFSET_E1];

  obj->indexAdc1V100T25 = obj->indexAdc1V100T25 + (value & (INDEX_ADC1_100_25_0 | 
                                                            INDEX_ADC1_100_25_1 | 
                                                            INDEX_ADC1_100_25_2 | 
                                                            INDEX_ADC1_100_25_3));

  obj->ftIT = obj->ftIT + ((value & (FT_IT_3 | FT_IT_4 | FT_IT_5 | FT_IT_6)) >> 1);
}

/**
 * @brief ConvOtp1E2
 *
 *  Convert OTP1 0xE2
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp1E2(OtpDataType *obj)
{
  _otp_u8_ value;
  _otp_u16_ tmp;

  value = obj->otp1[OTP1_OFFSET_E2];

  obj->indexAdc2V200T25 = obj->indexAdc2V200T25 + (value & (INDEX_ADC2_200_25_0 | 
                                                            INDEX_ADC2_200_25_1 | 
                                                            INDEX_ADC2_200_25_2 | 
                                                            INDEX_ADC2_200_25_3));

  tmp = (value & (FT_IT_7 | FT_IT_8 | FT_IT_9 | FT_IT_10));
  obj->ftIT = obj->ftIT + (tmp << 3);
}

/**
 * @brief ConvOtp1E3
 *
 *  Convert OTP1 0xE3
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp1E3(OtpDataType *obj)
{
  _otp_u8_ value;
  _otp_u16_ tmp;

  value = obj->otp1[OTP1_OFFSET_E3];

  obj->indexAdc2V100T25 = obj->indexAdc2V100T25 + (value & (INDEX_ADC2_100_25_0 | 
                                                            INDEX_ADC2_100_25_1 | 
                                                            INDEX_ADC2_100_25_2 | 
                                                            INDEX_ADC2_100_25_3));

  tmp = (value & (FT_IT_11 | FT_IT_12 | FT_IT_13 | FT_IT_14));
  obj->ftIT = obj->ftIT + (tmp << 7);
}

/**
 * @brief ConvOtp2F0
 *
 *  Convert OTP2 0xF0
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2F0(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp2[OTP2_OFFSET_F0];

  obj->productType = (value & (PRODUCT_TYPE_0 | PRODUCT_TYPE_1)) >> 3;

  obj->deltaET = obj->deltaET + ((value & DELTA_ET_0) >> 5) + ((value & DELTA_ET_1) >> 6);

  obj->indexAdc2V100T25 = obj->indexAdc2V100T25 + ((value & INDEX_ADC2_100_25_4) >> 2);
}

/**
 * @brief ConvOtp2F1
 *
 *  Convert OTP2 0xF1
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2F1(OtpDataType *obj)
{
}

/**
 * @brief ConvOtp2F2
 *
 *  Convert OTP2 0xF2
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2F2(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp2[OTP2_OFFSET_F2];

  obj->otpCellEN = obj->otpCellEN + ((value & (OTP_CELL_EN_0 | 
                                               OTP_CELL_EN_1 | 
                                               OTP_CELL_EN_2 | 
                                               OTP_CELL_EN_3 | 
                                               OTP_CELL_EN_4)) >> 3);
}

/**
 * @brief ConvOtp2F3
 *
 *  Convert OTP2 0xF3
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2F3(OtpDataType *obj)
{
}

/**
 * @brief ConvOtp2F4
 *
 *  Convert OTP2 0xF4
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2F4(OtpDataType *obj)
{
  _otp_u8_ value;
  _otp_u16_ tmp;

  value = obj->otp2[OTP2_OFFSET_F4];

  tmp = value & (ADC1_DELTA_CODE_25_200MV_8| ADC1_DELTA_CODE_25_200MV_9);
  obj->adc1DeltaCodeT25V200 = obj->adc1DeltaCodeT25V200 + (tmp << 8);

  tmp = value & (DEV_ADDR_7 | DEV_ADDR_8 | DEV_ADDR_9);
  obj->devAddr = (tmp << 2) + ((value & (DEV_ADDR_0 | DEV_ADDR_1 | DEV_ADDR_2)) >> 2);
}

/**
 * @brief ConvOtp2F5
 *
 *  Convert OTP2 0xF5
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2F5(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp2[OTP2_OFFSET_F5];

  obj->bgrTune = obj->bgrTune + ((value & (BGR_TUNE_0 | 
                                           BGR_TUNE_1 | 
                                           BGR_TUNE_2 | 
                                           BGR_TUNE_3 | 
                                           BGR_TUNE_4 | 
                                           BGR_TUNE_5)) >> 2);
}

/**
 * @brief ConvOtp2F6
 *
 *  Convert OTP2 0xF6
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2F6(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp2[OTP2_OFFSET_F6];

  obj->oscDeltaCode25 = obj->oscDeltaCode25 + (value & (OSC_DELTA_CODE_25_0 | 
                                                        OSC_DELTA_CODE_25_1 |
                                                        OSC_DELTA_CODE_25_2 |
                                                        OSC_DELTA_CODE_25_3 |
                                                        OSC_DELTA_CODE_25_4 |
                                                        OSC_DELTA_CODE_25_5 |
                                                        OSC_DELTA_CODE_25_6 |
                                                        OSC_DELTA_CODE_25_7));
}

/**
 * @brief ConvOtp2F7
 *
 *  Convert OTP2 0xF7
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2F7(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp2[OTP2_OFFSET_F7];

  obj->oscDeltaCode80 = obj->oscDeltaCode80 + (value & (OSC_DELTA_CODE_80_0 | 
                                                        OSC_DELTA_CODE_80_1 |
                                                        OSC_DELTA_CODE_80_2 |
                                                        OSC_DELTA_CODE_80_3 |
                                                        OSC_DELTA_CODE_80_4 |
                                                        OSC_DELTA_CODE_80_5 |
                                                        OSC_DELTA_CODE_80_6 |
                                                        OSC_DELTA_CODE_80_7));
}

/**
 * @brief ConvOtp2F8
 *
 *  Convert OTP2 0xF8
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2F8(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp2[OTP2_OFFSET_F8];

  obj->adc1DeltaCodeT25V200 = obj->adc1DeltaCodeT25V200 + (value & (ADC1_DELTA_CODE_25_200MV_0 |
                                                                    ADC1_DELTA_CODE_25_200MV_1 |
                                                                    ADC1_DELTA_CODE_25_200MV_2 |
                                                                    ADC1_DELTA_CODE_25_200MV_3 |
                                                                    ADC1_DELTA_CODE_25_200MV_4 |
                                                                    ADC1_DELTA_CODE_25_200MV_5 |
                                                                    ADC1_DELTA_CODE_25_200MV_6 |
                                                                    ADC1_DELTA_CODE_25_200MV_7));
}

/**
 * @brief ConvOtp2F9
 *
 *  Convert OTP2 0xF9
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2F9(OtpDataType *obj)
{
}

/**
 * @brief ConvOtp2FA
 *
 *  Convert OTP2 0xFA
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2FA(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp2[OTP2_OFFSET_FA];

  obj->adc1DeltaCodeT25V100 = obj->adc1DeltaCodeT25V100 + (value & (ADC1_DELTA_CODE_25_100MV_0 |
                                                                    ADC1_DELTA_CODE_25_100MV_1 |
                                                                    ADC1_DELTA_CODE_25_100MV_2 |
                                                                    ADC1_DELTA_CODE_25_100MV_3 |
                                                                    ADC1_DELTA_CODE_25_100MV_4 |
                                                                    ADC1_DELTA_CODE_25_100MV_5 |
                                                                    ADC1_DELTA_CODE_25_100MV_6 |
                                                                    ADC1_DELTA_CODE_25_100MV_7));
}

/**
 * @brief ConvOtp2FB
 *
 *  Convert OTP2 0xFB
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2FB(OtpDataType *obj)
{
}

/**
 * @brief ConvOtp2FC
 *
 *  Convert OTP2 0xFC
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2FC(OtpDataType *obj)
{
  _otp_u8_ value;
  _otp_u16_ tmp;

  value = obj->otp2[OTP2_OFFSET_FC];

  tmp = value & ADC1_DELTA_CODE_25_100MV_8;
  obj->adc1DeltaCodeT25V100 = obj->adc1DeltaCodeT25V100 + (tmp << 8);
  
  obj->adc2DeltaCodeT25V100 = obj->adc2DeltaCodeT25V100 + ((value & (ADC2_DELTA_CODE_25_100MV_0 |
                                                                     ADC2_DELTA_CODE_25_100MV_1 |
                                                                     ADC2_DELTA_CODE_25_100MV_2 |
                                                                     ADC2_DELTA_CODE_25_100MV_3 |
                                                                     ADC2_DELTA_CODE_25_100MV_4 |
                                                                     ADC2_DELTA_CODE_25_100MV_5 |
                                                                     ADC2_DELTA_CODE_25_100MV_6)) >> 1);
}

/**
 * @brief ConvOtp2FD
 *
 *  Convert OTP2 0xFD
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2FD(OtpDataType *obj)
{
}

/**
 * @brief ConvOtp2FE
 *
 *  Convert OTP2 0xFE
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2FE(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp2[OTP2_OFFSET_FE];

  obj->adc2DeltaCodeT25V200 = obj->adc2DeltaCodeT25V200 + (value & (ADC2_DELTA_CODE_25_200MV_0 |
                                                                    ADC2_DELTA_CODE_25_200MV_1 |
                                                                    ADC2_DELTA_CODE_25_200MV_2 |
                                                                    ADC2_DELTA_CODE_25_200MV_3 |
                                                                    ADC2_DELTA_CODE_25_200MV_4 |
                                                                    ADC2_DELTA_CODE_25_200MV_5 |
                                                                    ADC2_DELTA_CODE_25_200MV_6 |
                                                                    ADC2_DELTA_CODE_25_200MV_7));
}

/**
 * @brief ConvOtp2FF
 *
 *  Convert OTP2 0xFF
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp2FF(OtpDataType *obj)
{
}

/**
 * @brief ConvOtp370
 *
 *  Convert OTP3 0x70
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp370(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp3[OTP3_OFFSET_70];

  obj->deltaVref = obj->deltaVref + ((value & DELTA_VREF_4) << 4);

  obj->deltaET = obj->deltaET + ((value & (DELTA_ET_2 | DELTA_ET_3)) << 1);

  obj->aveIT25 = obj->aveIT25 + (value & (AVE_IT_25_3 | AVE_IT_25_4 | AVE_IT_25_5 | AVE_IT_25_6 | AVE_IT_25_7));
}

/**
 * @brief ConvOtp371
 *
 *  Convert OTP3 0x71
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp371(OtpDataType *obj)
{
  _otp_u8_ value;
  _otp_u16_ tmp;

  value = obj->otp3[OTP3_OFFSET_71];

  tmp = value & (AVE_IT_25_8 | 
                 AVE_IT_25_9 | 
                 AVE_IT_25_10 | 
                 AVE_IT_25_11 | 
                 AVE_IT_25_12 | 
                 AVE_IT_25_13 | 
                 AVE_IT_25_14 | 
                 AVE_IT_25_15);
  obj->aveIT25 = obj->aveIT25 + (tmp << 8);
}

/**
 * @brief ConvOtp372
 *
 *  Convert OTP3 0x72
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp372(OtpDataType *obj)
{
  _otp_u8_ value;

  value = obj->otp3[OTP3_OFFSET_72];

  obj->indexAdc2V200T25 = obj->indexAdc2V200T25 + ((value & INDEX_ADC2_200_25_4) << 4);

  obj->indexAdc1V100T25 = obj->indexAdc1V100T25 + ((value & INDEX_ADC1_100_25_4) << 3);

  obj->indexAdc1V200T25 = obj->indexAdc1V200T25 + ((value & INDEX_ADC1_200_25_4) << 2);

  obj->aveIT80 = obj->aveIT80 + (value & (AVE_IT_80_3 | AVE_IT_80_4 | AVE_IT_80_5 | AVE_IT_80_6 | AVE_IT_80_7));
}

/**
 * @brief ConvOtp373
 *
 *  Convert OTP3 0x73
 *
 * @para  obj address of OtpDataType
 * @return  _UPI_NULL_
 */
void ConvOtp373(OtpDataType *obj)
{
  _otp_u8_ value;
  _otp_u16_ tmp;

  value = obj->otp3[OTP3_OFFSET_73];

  tmp = value & (AVE_IT_80_8 | 
                 AVE_IT_80_9 | 
                 AVE_IT_80_10 | 
                 AVE_IT_80_11 | 
                 AVE_IT_80_12 | 
                 AVE_IT_80_13 | 
                 AVE_IT_80_14 | 
                 AVE_IT_80_15);
  obj->aveIT80 = obj->aveIT80 + (tmp << 8);
}

#define CONV_FUNC_PTR_NULL  (0)

typedef void (*ConvFuncPtr)(OtpDataType *obj);

static ConvFuncPtr ConvFuncTable[] = {
  ConvOtp1E0,
  ConvOtp1E1,
  ConvOtp1E2,
  ConvOtp1E3,

  ConvOtp2F0,
  ConvOtp2F1,
  ConvOtp2F2,
  ConvOtp2F3,
  ConvOtp2F4,
  ConvOtp2F5,
  ConvOtp2F6,
  ConvOtp2F7,
  ConvOtp2F8,
  ConvOtp2F9,
  ConvOtp2FA,
  ConvOtp2FB,
  ConvOtp2FC,
  ConvOtp2FD,
  ConvOtp2FE,
  ConvOtp2FF,

  ConvOtp370,
  ConvOtp371,
  ConvOtp372,
  ConvOtp373,
  
  CONV_FUNC_PTR_NULL,
};

/**
 * @brief CheckOtpISEmpty
 *
 *  Check OTP is empty or not
 *
 * @para  data  address of OtpDataType
 * @return  _UPI_NULL_
 */
void CheckOtpISEmpty(OtpDataType *data)
{
  _otp_u8_ idx;

  /// [AT-PM] : Check OTP1 ; 01/25/2013
  idx = 0;
  while(idx < OTP1_SIZE)
  {
    if(data->otp1[idx] != 0)
    {
      data->empty = OTP_IS_NOT_EMPTY;
      return;
    }
  }

  /// [AT-PM] : Check OTP2 ; 01/25/2013
  idx = 0;
  while(idx < OTP2_SIZE)
  {
    if(data->otp2[idx] != 0)
    {
      data->empty = OTP_IS_NOT_EMPTY;
      return;
    }
  }

  /// [AT-PM] : Check OTP3 ; 01/25/2013
  idx = 0;
  while(idx < OTP3_SIZE)
  {
    if(data->otp3[idx] != 0)
    {
      data->empty = OTP_IS_NOT_EMPTY;
      return;
    }
  }

  /// [AT-PM] : Set OTP is empty ; 01/25/2013
  data->empty = OTP_IS_EMPTY;
}

/// =============================================
/// [AT-PM] : Extern function region
/// =============================================

/**
 * @brief UpiConvertOtp
 *
 *  Convert OTP register value to readable value
 *
 * @para  data  address of OtpDataType
 * @return  _UPI_NULL_
 */
void UpiConvertOtp(OtpDataType *data)
{
  _otp_u8_ idx;

  UG31_LOGI("[%s]: OTP version : %d.%02x\n", __func__, UG31XX_OTP_VERSION_MAIN, UG31XX_OTP_VERSION_SUB);

  /// [AT-PM] : Set version ; 01/25/2013
  data->versionMain = UG31XX_OTP_VERSION_MAIN;
  data->versionSub = UG31XX_OTP_VERSION_SUB;
  
  /// [AT-PM] : Conversion ; 01/23/2013
  idx = 0;
  while(1)
  {
    (*ConvFuncTable[idx])(data);
    
    idx = idx + 1;
    if(ConvFuncTable[idx] == CONV_FUNC_PTR_NULL)
    {
      break;
    }
  }

  /// [AT-PM] : Check OTP is empty ; 01/25/2013
  CheckOtpISEmpty(data);
}