hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
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
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
/******************************************************************************
 *
 * Copyright(c) 2016 - 2019 Realtek Corporation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 ******************************************************************************/
 
#include "halmac_cfg_wmac_88xx.h"
#include "halmac_88xx_cfg.h"
#include "halmac_efuse_88xx.h"
 
#if HALMAC_88XX_SUPPORT
 
#define MAC_CLK_SPEED    80 /* 80M */
#define MAC_CLK_SPEED_BW_5M_10M    20 /* 20M */
 
#define EFUSE_PCB_INFO_OFFSET    0xCA
 
enum mac_clock_hw_def {
   MAC_CLK_HW_DEF_80M = 0,
   MAC_CLK_HW_DEF_40M = 1,
   MAC_CLK_HW_DEF_20M = 2,
};
 
static enum halmac_ret_status
board_rf_fine_tune_88xx(struct halmac_adapter *adapter);
 
/**
 * cfg_mac_addr_88xx() - config mac address
 * @adapter : the adapter of halmac
 * @port : 0 for port0, 1 for port1, 2 for port2, 3 for port3, 4 for port4
 * @addr : mac address
 * Author : KaiYuan Chang/Ivan Lin
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
cfg_mac_addr_88xx(struct halmac_adapter *adapter, u8 port,
         union halmac_wlan_addr *addr)
{
   u32 offset;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   if (port >= HALMAC_PORTID_NUM) {
       PLTFM_MSG_ERR("[ERR]port index >= 5\n");
       return HALMAC_RET_PORT_NOT_SUPPORT;
   }
 
   switch (port) {
   case HALMAC_PORTID0:
       offset = REG_MACID;
       break;
   case HALMAC_PORTID1:
       offset = REG_MACID1;
       break;
   case HALMAC_PORTID2:
       offset = REG_MACID2;
       break;
   case HALMAC_PORTID3:
       offset = REG_MACID3;
       break;
   case HALMAC_PORTID4:
       offset = REG_MACID4;
       break;
   default:
       return HALMAC_RET_PORT_NOT_SUPPORT;
   }
 
   HALMAC_REG_W32(offset, rtk_le32_to_cpu(addr->addr_l_h.low));
   HALMAC_REG_W16(offset + 4, rtk_le16_to_cpu(addr->addr_l_h.high));
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * cfg_bssid_88xx() - config BSSID
 * @adapter : the adapter of halmac
 * @port : 0 for port0, 1 for port1, 2 for port2, 3 for port3, 4 for port4
 * @addr : bssid
 * Author : KaiYuan Chang/Ivan Lin
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
cfg_bssid_88xx(struct halmac_adapter *adapter, u8 port,
          union halmac_wlan_addr *addr)
{
   u32 offset;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   if (port >= HALMAC_PORTID_NUM) {
       PLTFM_MSG_ERR("[ERR]port index > 5\n");
       return HALMAC_RET_PORT_NOT_SUPPORT;
   }
 
   switch (port) {
   case HALMAC_PORTID0:
       offset = REG_BSSID;
       break;
   case HALMAC_PORTID1:
       offset = REG_BSSID1;
       break;
   case HALMAC_PORTID2:
       offset = REG_BSSID2;
       break;
   case HALMAC_PORTID3:
       offset = REG_BSSID3;
       break;
   case HALMAC_PORTID4:
       offset = REG_BSSID4;
       break;
   default:
       return HALMAC_RET_PORT_NOT_SUPPORT;
   }
 
   HALMAC_REG_W32(offset, rtk_le32_to_cpu(addr->addr_l_h.low));
   HALMAC_REG_W16(offset + 4, rtk_le16_to_cpu(addr->addr_l_h.high));
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * cfg_transmitter_addr_88xx() - config transmitter address
 * @adapter : the adapter of halmac
 * @port :  0 for port0, 1 for port1, 2 for port2, 3 for port3, 4 for port4
 * @addr :
 * Author : Alan
 * Return : enum halmac_ret_status
 */
enum halmac_ret_status
cfg_transmitter_addr_88xx(struct halmac_adapter *adapter, u8 port,
             union halmac_wlan_addr *addr)
{
   u32 offset;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   if (port >= HALMAC_PORTID_NUM) {
       PLTFM_MSG_ERR("[ERR]port index > 5\n");
       return HALMAC_RET_PORT_NOT_SUPPORT;
   }
 
   switch (port) {
   case HALMAC_PORTID0:
       offset = REG_TRANSMIT_ADDRSS_0;
       break;
   case HALMAC_PORTID1:
       offset = REG_TRANSMIT_ADDRSS_1;
       break;
   case HALMAC_PORTID2:
       offset = REG_TRANSMIT_ADDRSS_2;
       break;
   case HALMAC_PORTID3:
       offset = REG_TRANSMIT_ADDRSS_3;
       break;
   case HALMAC_PORTID4:
       offset = REG_TRANSMIT_ADDRSS_4;
       break;
   default:
       return HALMAC_RET_PORT_NOT_SUPPORT;
   }
 
   HALMAC_REG_W32(offset, rtk_le32_to_cpu(addr->addr_l_h.low));
   HALMAC_REG_W16(offset + 4, rtk_le16_to_cpu(addr->addr_l_h.high));
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * cfg_net_type_88xx() - config network type
 * @adapter : the adapter of halmac
 * @port :  0 for port0, 1 for port1, 2 for port2, 3 for port3, 4 for port4
 * @addr : mac address
 * Author : Alan
 * Return : enum halmac_ret_status
 */
enum halmac_ret_status
cfg_net_type_88xx(struct halmac_adapter *adapter, u8 port,
         enum halmac_network_type_select net_type)
{
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
   u8 value8 = 0;
   u8 net_type_tmp = 0;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   if (net_type == HALMAC_NETWORK_AP) {
       if (port >= HALMAC_PORTID1) {
           PLTFM_MSG_ERR("[ERR]AP port > 1\n");
           return HALMAC_RET_PORT_NOT_SUPPORT;
       }
   }
 
   switch (port) {
   case HALMAC_PORTID0:
       net_type_tmp = net_type;
       value8 = ((HALMAC_REG_R8(REG_CR + 2) & 0xFC) | net_type_tmp);
       HALMAC_REG_W8(REG_CR + 2, value8);
       break;
   case HALMAC_PORTID1:
       net_type_tmp = (net_type << 2);
       value8 = ((HALMAC_REG_R8(REG_CR + 2) & 0xF3) | net_type_tmp);
       HALMAC_REG_W8(REG_CR + 2, value8);
       break;
   case HALMAC_PORTID2:
       net_type_tmp = net_type;
       value8 = ((HALMAC_REG_R8(REG_CR_EXT) & 0xFC) | net_type_tmp);
       HALMAC_REG_W8(REG_CR_EXT, value8);
       break;
   case HALMAC_PORTID3:
       net_type_tmp = (net_type << 2);
       value8 = ((HALMAC_REG_R8(REG_CR_EXT) & 0xF3) | net_type_tmp);
       HALMAC_REG_W8(REG_CR_EXT, value8);
       break;
   case HALMAC_PORTID4:
       net_type_tmp = (net_type << 4);
       value8 = ((HALMAC_REG_R8(REG_CR_EXT) & 0xCF) | net_type_tmp);
       HALMAC_REG_W8(REG_CR_EXT, value8);
       break;
   default:
       break;
   }
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * cfg_tsf_rst_88xx() - tsf reset
 * @adapter : the adapter of halmac
 * @port :  0 for port0, 1 for port1, 2 for port2, 3 for port3, 4 for port4
 * Author : Alan
 * Return : enum halmac_ret_status
 */
enum halmac_ret_status
cfg_tsf_rst_88xx(struct halmac_adapter *adapter, u8 port)
{
   u8 tsf_rst = 0;
   u8 value8;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   switch (port) {
   case HALMAC_PORTID0:
       tsf_rst = BIT_TSFTR_RST;
       break;
   case HALMAC_PORTID1:
       tsf_rst = BIT_TSFTR_CLI0_RST;
       break;
   case HALMAC_PORTID2:
       tsf_rst = BIT_TSFTR_CLI1_RST;
       break;
   case HALMAC_PORTID3:
       tsf_rst = BIT_TSFTR_CLI2_RST;
       break;
   case HALMAC_PORTID4:
       tsf_rst = BIT_TSFTR_CLI3_RST;
       break;
   default:
       break;
   }
 
   value8 = HALMAC_REG_R8(REG_DUAL_TSF_RST);
   HALMAC_REG_W8(REG_DUAL_TSF_RST, value8 | tsf_rst);
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * cfg_bcn_space_88xx() - config beacon space
 * @adapter : the adapter of halmac
 * @port :  0 for port0, 1 for port1, 2 for port2, 3 for port3, 4 for port4
 * @bcn_space : beacon space
 * Author : Alan
 * Return : enum halmac_ret_status
 */
enum halmac_ret_status
cfg_bcn_space_88xx(struct halmac_adapter *adapter, u8 port, u32 bcn_space)
{
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
   u16 bcn_space_real = 0;
   u16 value16 = 0;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   bcn_space_real = ((u16)bcn_space);
 
   switch (port) {
   case HALMAC_PORTID0:
       HALMAC_REG_W16(REG_MBSSID_BCN_SPACE, bcn_space_real);
       break;
   case HALMAC_PORTID1:
       value16 = HALMAC_REG_R16(REG_MBSSID_BCN_SPACE + 2) & 0xF000;
       value16 |= bcn_space_real;
       HALMAC_REG_W16(REG_MBSSID_BCN_SPACE + 2, value16);
       break;
   case HALMAC_PORTID2:
       value16 = HALMAC_REG_R16(REG_MBSSID_BCN_SPACE2) & 0xF000;
       value16 |= bcn_space_real;
       HALMAC_REG_W16(REG_MBSSID_BCN_SPACE2, value16);
       break;
   case HALMAC_PORTID3:
       value16 = HALMAC_REG_R16(REG_MBSSID_BCN_SPACE2 + 2) & 0xF000;
       value16 |= bcn_space_real;
       HALMAC_REG_W16(REG_MBSSID_BCN_SPACE2 + 2, value16);
       break;
   case HALMAC_PORTID4:
       value16 = HALMAC_REG_R16(REG_MBSSID_BCN_SPACE3) & 0xF000;
       value16 |= bcn_space_real;
       HALMAC_REG_W16(REG_MBSSID_BCN_SPACE3, value16);
       break;
   default:
       break;
   }
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * rw_bcn_ctrl_88xx() - r/w beacon control
 * @adapter : the adapter of halmac
 * @port :  0 for port0, 1 for port1, 2 for port2, 3 for port3, 4 for port4
 * @write_en : 1->write beacon function 0->read beacon function
 * @pBcn_ctrl : beacon control info
 * Author : KaiYuan Chang/Ivan Lin
 * Return : enum halmac_ret_status
 */
enum halmac_ret_status
rw_bcn_ctrl_88xx(struct halmac_adapter *adapter, u8 port, u8 write_en,
        struct halmac_bcn_ctrl *ctrl)
{
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
   u8 ctrl_value = 0;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   if (write_en) {
       if (ctrl->dis_rx_bssid_fit == 1)
           ctrl_value |= BIT_DIS_RX_BSSID_FIT;
 
       if (ctrl->en_txbcn_rpt == 1)
           ctrl_value |= BIT_P0_EN_TXBCN_RPT;
 
       if (ctrl->dis_tsf_udt == 1)
           ctrl_value |= BIT_DIS_TSF_UDT;
 
       if (ctrl->en_bcn == 1)
           ctrl_value |= BIT_EN_BCN_FUNCTION;
 
       if (ctrl->en_rxbcn_rpt == 1)
           ctrl_value |= BIT_P0_EN_RXBCN_RPT;
 
       if (ctrl->en_p2p_ctwin == 1)
           ctrl_value |= BIT_EN_P2P_CTWINDOW;
 
       if (ctrl->en_p2p_bcn_area == 1)
           ctrl_value |= BIT_EN_P2P_BCNQ_AREA;
 
       switch (port) {
       case HALMAC_PORTID0:
           HALMAC_REG_W8(REG_BCN_CTRL, ctrl_value);
           break;
       case HALMAC_PORTID1:
           HALMAC_REG_W8(REG_BCN_CTRL_CLINT0, ctrl_value);
           break;
       case HALMAC_PORTID2:
           HALMAC_REG_W8(REG_BCN_CTRL_CLINT1, ctrl_value);
           break;
       case HALMAC_PORTID3:
           HALMAC_REG_W8(REG_BCN_CTRL_CLINT2, ctrl_value);
           break;
       case HALMAC_PORTID4:
           HALMAC_REG_W8(REG_BCN_CTRL_CLINT3, ctrl_value);
           break;
       default:
           break;
       }
 
   } else {
       switch (port) {
       case HALMAC_PORTID0:
           ctrl_value = HALMAC_REG_R8(REG_BCN_CTRL);
           break;
       case HALMAC_PORTID1:
           ctrl_value = HALMAC_REG_R8(REG_BCN_CTRL_CLINT0);
           break;
       case HALMAC_PORTID2:
           ctrl_value = HALMAC_REG_R8(REG_BCN_CTRL_CLINT1);
           break;
       case HALMAC_PORTID3:
           ctrl_value = HALMAC_REG_R8(REG_BCN_CTRL_CLINT2);
           break;
       case HALMAC_PORTID4:
           ctrl_value = HALMAC_REG_R8(REG_BCN_CTRL_CLINT3);
           break;
       default:
           break;
       }
 
       if (ctrl_value & BIT_EN_P2P_BCNQ_AREA)
           ctrl->en_p2p_bcn_area = 1;
       else
           ctrl->en_p2p_bcn_area = 0;
 
       if (ctrl_value & BIT_EN_P2P_CTWINDOW)
           ctrl->en_p2p_ctwin = 1;
       else
           ctrl->en_p2p_ctwin = 0;
 
       if (ctrl_value & BIT_P0_EN_RXBCN_RPT)
           ctrl->en_rxbcn_rpt = 1;
       else
           ctrl->en_rxbcn_rpt = 0;
 
       if (ctrl_value & BIT_EN_BCN_FUNCTION)
           ctrl->en_bcn = 1;
       else
           ctrl->en_bcn = 0;
 
       if (ctrl_value & BIT_DIS_TSF_UDT)
           ctrl->dis_tsf_udt = 1;
       else
           ctrl->dis_tsf_udt = 0;
 
       if (ctrl_value & BIT_P0_EN_TXBCN_RPT)
           ctrl->en_txbcn_rpt = 1;
       else
           ctrl->en_txbcn_rpt = 0;
 
       if (ctrl_value & BIT_DIS_RX_BSSID_FIT)
           ctrl->dis_rx_bssid_fit = 1;
       else
           ctrl->dis_rx_bssid_fit = 0;
   }
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * cfg_multicast_addr_88xx() - config multicast address
 * @adapter : the adapter of halmac
 * @addr : multicast address
 * Author : KaiYuan Chang/Ivan Lin
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
cfg_multicast_addr_88xx(struct halmac_adapter *adapter,
           union halmac_wlan_addr *addr)
{
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   HALMAC_REG_W32(REG_MAR, rtk_le32_to_cpu(addr->addr_l_h.low));
   HALMAC_REG_W16(REG_MAR + 4, rtk_le16_to_cpu(addr->addr_l_h.high));
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * cfg_operation_mode_88xx() - config operation mode
 * @adapter : the adapter of halmac
 * @mode : 802.11 standard(b/g/n/ac)
 * Author : KaiYuan Chang/Ivan Lin
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
cfg_operation_mode_88xx(struct halmac_adapter *adapter,
           enum halmac_wireless_mode mode)
{
   return HALMAC_RET_SUCCESS;
}
 
/**
 * cfg_ch_bw_88xx() - config channel & bandwidth
 * @adapter : the adapter of halmac
 * @ch : WLAN channel, support 2.4G & 5G
 * @idx : primary channel index, idx1, idx2, idx3, idx4
 * @bw : band width, 20, 40, 80, 160, 5 ,10
 * Author : KaiYuan Chang
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
cfg_ch_bw_88xx(struct halmac_adapter *adapter, u8 ch,
          enum halmac_pri_ch_idx idx, enum halmac_bw bw)
{
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   cfg_pri_ch_idx_88xx(adapter, idx);
   cfg_bw_88xx(adapter, bw);
   cfg_ch_88xx(adapter, ch);
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
enum halmac_ret_status
cfg_ch_88xx(struct halmac_adapter *adapter, u8 ch)
{
   u8 value8;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   value8 = HALMAC_REG_R8(REG_CCK_CHECK);
   value8 = value8 & (~(BIT(7)));
 
   if (ch > 35)
       value8 = value8 | BIT(7);
 
   HALMAC_REG_W8(REG_CCK_CHECK, value8);
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
enum halmac_ret_status
cfg_pri_ch_idx_88xx(struct halmac_adapter *adapter, enum halmac_pri_ch_idx idx)
{
   u8 txsc40 = 0, txsc20 = 0;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   txsc20 = idx;
   if (txsc20 == HALMAC_CH_IDX_1 || txsc20 == HALMAC_CH_IDX_3)
       txsc40 = 9;
   else
       txsc40 = 10;
 
   HALMAC_REG_W8(REG_DATA_SC, BIT_TXSC_20M(txsc20) | BIT_TXSC_40M(txsc40));
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * cfg_bw_88xx() - config bandwidth
 * @adapter : the adapter of halmac
 * @bw : band width, 20, 40, 80, 160, 5 ,10
 * Author : KaiYuan Chang
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
cfg_bw_88xx(struct halmac_adapter *adapter, enum halmac_bw bw)
{
   u32 value32;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   value32 = HALMAC_REG_R32(REG_WMAC_TRXPTCL_CTL);
   value32 = value32 & (~(BIT(7) | BIT(8)));
 
   switch (bw) {
   case HALMAC_BW_80:
       adapter->curr_bw = HALMAC_BW_80;
       value32 = value32 | BIT(8);
       break;
   case HALMAC_BW_40:
       adapter->curr_bw = HALMAC_BW_40;
       value32 = value32 | BIT(7);
       break;
   case HALMAC_BW_20:
       adapter->curr_bw = HALMAC_BW_20;
       break;
   case HALMAC_BW_10:
       adapter->curr_bw = HALMAC_BW_10;
       break;
   case HALMAC_BW_5:
       adapter->curr_bw = HALMAC_BW_5;
       break;
   default:
       break;
   }
 
   HALMAC_REG_W32(REG_WMAC_TRXPTCL_CTL, value32);
 
   cfg_mac_clk_88xx(adapter);
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
void
cfg_txfifo_lt_88xx(struct halmac_adapter *adapter,
          struct halmac_txfifo_lifetime_cfg *cfg)
{
   u8 value8;
   u32 value32;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   if (cfg->enable == 1) {
       value8 = HALMAC_REG_R8(REG_LIFETIME_EN);
       value8 = value8 | BIT(0) | BIT(1) | BIT(2) | BIT(3);
       HALMAC_REG_W8(REG_LIFETIME_EN, value8);
 
       value32 = (cfg->lifetime) >> 8;
       value32 = value32 + (value32 << 16);
       HALMAC_REG_W32(REG_PKT_LIFE_TIME, value32);
   } else {
       value8 = HALMAC_REG_R8(REG_LIFETIME_EN);
       value8 = value8 & (~(BIT(0) | BIT(1) | BIT(2) | BIT(3)));
       HALMAC_REG_W8(REG_LIFETIME_EN, value8);
   }
}
 
enum halmac_ret_status
enable_bb_rf_88xx(struct halmac_adapter *adapter, u8 enable)
{
   u8 value8;
   u32 value32;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
   enum halmac_ret_status status = HALMAC_RET_SUCCESS;
 
   if (enable == 1) {
       status = board_rf_fine_tune_88xx(adapter);
       value8 = HALMAC_REG_R8(REG_SYS_FUNC_EN);
       value8 = value8 | BIT(0) | BIT(1);
       HALMAC_REG_W8(REG_SYS_FUNC_EN, value8);
 
       value8 = HALMAC_REG_R8(REG_RF_CTRL);
       value8 = value8 | BIT(0) | BIT(1) | BIT(2);
       HALMAC_REG_W8(REG_RF_CTRL, value8);
 
       value32 = HALMAC_REG_R32(REG_WLRF1);
       value32 = value32 | BIT(24) | BIT(25) | BIT(26);
       HALMAC_REG_W32(REG_WLRF1, value32);
   } else {
       value8 = HALMAC_REG_R8(REG_SYS_FUNC_EN);
       value8 = value8 & (~(BIT(0) | BIT(1)));
       HALMAC_REG_W8(REG_SYS_FUNC_EN, value8);
 
       value8 = HALMAC_REG_R8(REG_RF_CTRL);
       value8 = value8 & (~(BIT(0) | BIT(1) | BIT(2)));
       HALMAC_REG_W8(REG_RF_CTRL, value8);
 
       value32 = HALMAC_REG_R32(REG_WLRF1);
       value32 = value32 & (~(BIT(24) | BIT(25) | BIT(26)));
       HALMAC_REG_W32(REG_WLRF1, value32);
   }
 
   return status;
}
 
static enum halmac_ret_status
board_rf_fine_tune_88xx(struct halmac_adapter *adapter)
{
   u8 *map = NULL;
   u32 size = adapter->hw_cfg_info.eeprom_size;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   if (adapter->chip_id == HALMAC_CHIP_ID_8822B) {
       if (!adapter->efuse_map_valid || !adapter->efuse_map) {
           PLTFM_MSG_ERR("[ERR]efuse map invalid!!\n");
           return HALMAC_RET_EFUSE_R_FAIL;
       }
 
       map = (u8 *)PLTFM_MALLOC(size);
       if (!map) {
           PLTFM_MSG_ERR("[ERR]malloc map\n");
           return HALMAC_RET_MALLOC_FAIL;
       }
 
       PLTFM_MEMSET(map, 0xFF, size);
 
       if (eeprom_parser_88xx(adapter, adapter->efuse_map, map) !=
           HALMAC_RET_SUCCESS) {
           PLTFM_FREE(map, size);
           return HALMAC_RET_EEPROM_PARSING_FAIL;
       }
 
       /* Fine-tune XTAL voltage for 2L PCB board */
       if (*(map + EFUSE_PCB_INFO_OFFSET) == 0x0C)
           HALMAC_REG_W8_SET(REG_AFE_CTRL1 + 1, BIT(1));
 
       PLTFM_FREE(map, size);
   }
 
   return HALMAC_RET_SUCCESS;
}
 
void
cfg_mac_clk_88xx(struct halmac_adapter *adapter)
{
   u32 value32;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   value32 = HALMAC_REG_R32(REG_AFE_CTRL1) & ~(BIT(20) | BIT(21));
   if (adapter->curr_bw == HALMAC_BW_5 ||
       adapter->curr_bw == HALMAC_BW_10) {
       value32 |= (MAC_CLK_HW_DEF_20M << BIT_SHIFT_MAC_CLK_SEL);
       HALMAC_REG_W32(REG_AFE_CTRL1, value32);
       HALMAC_REG_W8(REG_USTIME_TSF, MAC_CLK_SPEED_BW_5M_10M);
       HALMAC_REG_W8(REG_USTIME_EDCA, MAC_CLK_SPEED_BW_5M_10M);
   } else {
       value32 |= (MAC_CLK_HW_DEF_80M << BIT_SHIFT_MAC_CLK_SEL);
       HALMAC_REG_W32(REG_AFE_CTRL1, value32);
       HALMAC_REG_W8(REG_USTIME_TSF, MAC_CLK_SPEED);
       HALMAC_REG_W8(REG_USTIME_EDCA, MAC_CLK_SPEED);
   }
}
 
/**
 * cfg_la_mode_88xx() - config la mode
 * @adapter : the adapter of halmac
 * @mode :
 *    disable : no TXFF space reserved for LA debug
 *    partial : partial TXFF space is reserved for LA debug
 *    full : all TXFF space is reserved for LA debug
 * Author : KaiYuan Chang
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
cfg_la_mode_88xx(struct halmac_adapter *adapter, enum halmac_la_mode mode)
{
   if (adapter->api_registry.la_mode_en == 0)
       return HALMAC_RET_NOT_SUPPORT;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   adapter->txff_alloc.la_mode = mode;
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * cfg_rxfifo_expand_mode_88xx() - rx fifo expanding
 * @adapter : the adapter of halmac
 * @mode :
 *    disable : normal mode
 *    1 block : Rx FIFO + 1 FIFO block; Tx fifo - 1 FIFO block
 *    2 block : Rx FIFO + 2 FIFO block; Tx fifo - 2 FIFO block
 *    3 block : Rx FIFO + 3 FIFO block; Tx fifo - 3 FIFO block
 * Author : Soar
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
cfg_rxfifo_expand_mode_88xx(struct halmac_adapter *adapter,
               enum halmac_rx_fifo_expanding_mode mode)
{
   if (adapter->api_registry.rx_exp_en == 0)
       return HALMAC_RET_NOT_SUPPORT;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   adapter->txff_alloc.rx_fifo_exp_mode = mode;
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
enum halmac_ret_status
config_security_88xx(struct halmac_adapter *adapter,
            struct halmac_security_setting *setting)
{
   u8 sec_cfg;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   HALMAC_REG_W16_SET(REG_CR, BIT_MAC_SEC_EN);
 
   if (setting->compare_keyid == 1) {
       HALMAC_REG_W8_SET(REG_SECCFG + 1, BIT(0));
       adapter->hw_cfg_info.chk_security_keyid = 1;
   } else {
       adapter->hw_cfg_info.chk_security_keyid = 0;
   }
 
   sec_cfg = HALMAC_REG_R8(REG_SECCFG);
 
   /* BC/MC uses default key */
   /* cam entry 0~3, kei id = 0 -> entry0, kei id = 1 -> entry1... */
   sec_cfg |= (BIT_TXBCUSEDK | BIT_RXBCUSEDK);
 
   if (setting->tx_encryption == 1)
       sec_cfg |= BIT_TXENC;
   else
       sec_cfg &= ~BIT_TXENC;
 
   if (setting->rx_decryption == 1)
       sec_cfg |= BIT_RXDEC;
   else
       sec_cfg &= ~BIT_RXDEC;
 
   HALMAC_REG_W8(REG_SECCFG, sec_cfg);
 
   if (setting->bip_enable == 1) {
       if (adapter->chip_id == HALMAC_CHIP_ID_8822B)
           return HALMAC_RET_BIP_NO_SUPPORT;
#if (HALMAC_8821C_SUPPORT || HALMAC_8822C_SUPPORT || HALMAC_8812F_SUPPORT)
       sec_cfg = HALMAC_REG_R8(REG_WSEC_OPTION + 2);
 
       if (setting->tx_encryption == 1)
           sec_cfg |= (BIT(3) | BIT(5));
       else
           sec_cfg &= ~(BIT(3) | BIT(5));
 
       if (setting->rx_decryption == 1)
           sec_cfg |= (BIT(4) | BIT(6));
       else
           sec_cfg &= ~(BIT(4) | BIT(6));
 
       HALMAC_REG_W8(REG_WSEC_OPTION + 2, sec_cfg);
#endif
   }
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
u8
get_used_cam_entry_num_88xx(struct halmac_adapter *adapter,
               enum hal_security_type sec_type)
{
   u8 entry_num;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   switch (sec_type) {
   case HAL_SECURITY_TYPE_WEP40:
   case HAL_SECURITY_TYPE_WEP104:
   case HAL_SECURITY_TYPE_TKIP:
   case HAL_SECURITY_TYPE_AES128:
   case HAL_SECURITY_TYPE_GCMP128:
   case HAL_SECURITY_TYPE_GCMSMS4:
   case HAL_SECURITY_TYPE_BIP:
       entry_num = 1;
       break;
   case HAL_SECURITY_TYPE_WAPI:
   case HAL_SECURITY_TYPE_AES256:
   case HAL_SECURITY_TYPE_GCMP256:
       entry_num = 2;
       break;
   default:
       entry_num = 0;
       break;
   }
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return entry_num;
}
 
enum halmac_ret_status
write_cam_88xx(struct halmac_adapter *adapter, u32 idx,
          struct halmac_cam_entry_info *info)
{
   u32 i;
   u32 cmd = 0x80010000;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
   struct halmac_cam_entry_format *fmt = NULL;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   if (idx >= adapter->hw_cfg_info.cam_entry_num)
       return HALMAC_RET_ENTRY_INDEX_ERROR;
 
   if (info->key_id > 3)
       return HALMAC_RET_FAIL;
 
   fmt = (struct halmac_cam_entry_format *)PLTFM_MALLOC(sizeof(*fmt));
   if (!fmt)
       return HALMAC_RET_NULL_POINTER;
   PLTFM_MEMSET(fmt, 0x00, sizeof(*fmt));
 
   if (adapter->hw_cfg_info.chk_security_keyid == 1)
       fmt->key_id = info->key_id;
   fmt->valid = info->valid;
   PLTFM_MEMCPY(fmt->mac_address, info->mac_address, 6);
   PLTFM_MEMCPY(fmt->key, info->key, 16);
 
   switch (info->security_type) {
   case HAL_SECURITY_TYPE_NONE:
       fmt->type = 0;
       break;
   case HAL_SECURITY_TYPE_WEP40:
       fmt->type = 1;
       break;
   case HAL_SECURITY_TYPE_WEP104:
       fmt->type = 5;
       break;
   case HAL_SECURITY_TYPE_TKIP:
       fmt->type = 2;
       break;
   case HAL_SECURITY_TYPE_AES128:
       fmt->type = 4;
       break;
   case HAL_SECURITY_TYPE_WAPI:
       fmt->type = 6;
       break;
   case HAL_SECURITY_TYPE_AES256:
       fmt->type = 4;
       fmt->ext_sectype = 1;
       break;
   case HAL_SECURITY_TYPE_GCMP128:
       fmt->type = 7;
       break;
   case HAL_SECURITY_TYPE_GCMP256:
   case HAL_SECURITY_TYPE_GCMSMS4:
       fmt->type = 7;
       fmt->ext_sectype = 1;
       break;
   case HAL_SECURITY_TYPE_BIP:
       fmt->type = (info->unicast == 1) ? 4 : 0;
       fmt->mgnt = 1;
       fmt->grp = (info->unicast == 1) ? 0 : 1;
       break;
   default:
       PLTFM_FREE(fmt, sizeof(*fmt));
       return HALMAC_RET_FAIL;
   }
 
   for (i = 0; i < 8; i++) {
       HALMAC_REG_W32(REG_CAMWRITE, *((u32 *)fmt + i));
       HALMAC_REG_W32(REG_CAMCMD, cmd | ((idx << 3) + i));
   }
 
   if (info->security_type == HAL_SECURITY_TYPE_WAPI ||
       info->security_type == HAL_SECURITY_TYPE_AES256 ||
       info->security_type == HAL_SECURITY_TYPE_GCMP256 ||
       info->security_type == HAL_SECURITY_TYPE_GCMSMS4) {
       fmt->mic = 1;
       PLTFM_MEMCPY(fmt->key, info->key_ext, 16);
       idx++;
       for (i = 0; i < 8; i++) {
           HALMAC_REG_W32(REG_CAMWRITE, *((u32 *)fmt + i));
           HALMAC_REG_W32(REG_CAMCMD, cmd | ((idx << 3) + i));
       }
   }
 
   PLTFM_FREE(fmt, sizeof(*fmt));
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
enum halmac_ret_status
read_cam_entry_88xx(struct halmac_adapter *adapter, u32 idx,
           struct halmac_cam_entry_format *content)
{
   u32 i;
   u32 cmd = 0x80000000;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   if (idx >= adapter->hw_cfg_info.cam_entry_num)
       return HALMAC_RET_ENTRY_INDEX_ERROR;
 
   for (i = 0; i < 8; i++) {
       HALMAC_REG_W32(REG_CAMCMD, cmd | ((idx << 3) + i));
       *((u32 *)content + i) = HALMAC_REG_R32(REG_CAMREAD);
   }
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
enum halmac_ret_status
clear_cam_entry_88xx(struct halmac_adapter *adapter, u32 idx)
{
   u32 i;
   u32 cmd = 0x80010000;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
   struct halmac_cam_entry_format *fmt = NULL;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   if (idx >= adapter->hw_cfg_info.cam_entry_num)
       return HALMAC_RET_ENTRY_INDEX_ERROR;
 
   fmt = (struct halmac_cam_entry_format *)PLTFM_MALLOC(sizeof(*fmt));
   if (!fmt)
       return HALMAC_RET_NULL_POINTER;
   PLTFM_MEMSET(fmt, 0x00, sizeof(*fmt));
 
   for (i = 0; i < 8; i++) {
       HALMAC_REG_W32(REG_CAMWRITE, *((u32 *)fmt + i));
       HALMAC_REG_W32(REG_CAMCMD, cmd | ((idx << 3) + i));
   }
 
   PLTFM_FREE(fmt, sizeof(*fmt));
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
void
rx_shift_88xx(struct halmac_adapter *adapter, u8 enable)
{
   u8 value8;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   value8 = HALMAC_REG_R8(REG_TXDMA_PQ_MAP);
 
   if (enable == 1)
       HALMAC_REG_W8(REG_TXDMA_PQ_MAP, value8 | BIT(1));
   else
       HALMAC_REG_W8(REG_TXDMA_PQ_MAP, value8 & ~(BIT(1)));
}
 
/**
 * cfg_edca_para_88xx() - config edca parameter
 * @adapter : the adapter of halmac
 * @acq_id : VO/VI/BE/BK
 * @param : aifs, cw, txop limit
 * Author : Ivan Lin
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
cfg_edca_para_88xx(struct halmac_adapter *adapter, enum halmac_acq_id acq_id,
          struct halmac_edca_para *param)
{
   u32 offset;
   u32 value32;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   switch (acq_id) {
   case HALMAC_ACQ_ID_VO:
       offset = REG_EDCA_VO_PARAM;
       break;
   case HALMAC_ACQ_ID_VI:
       offset = REG_EDCA_VI_PARAM;
       break;
   case HALMAC_ACQ_ID_BE:
       offset = REG_EDCA_BE_PARAM;
       break;
   case HALMAC_ACQ_ID_BK:
       offset = REG_EDCA_BK_PARAM;
       break;
   default:
       return HALMAC_RET_SWITCH_CASE_ERROR;
   }
 
   param->txop_limit &= 0x7FF;
   value32 = (param->aifs) | (param->cw << 8) | (param->txop_limit << 16);
 
   HALMAC_REG_W32(offset, value32);
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
void
rx_clk_gate_88xx(struct halmac_adapter *adapter, u8 enable)
{
   u8 value8;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   value8 = HALMAC_REG_R8(REG_RCR + 2);
 
   if (enable == 1)
       HALMAC_REG_W8(REG_RCR + 2, value8 & ~(BIT(3)));
   else
       HALMAC_REG_W8(REG_RCR + 2, value8 | BIT(3));
}
 
enum halmac_ret_status
rx_cut_amsdu_cfg_88xx(struct halmac_adapter *adapter,
             struct halmac_cut_amsdu_cfg *cfg)
{
   return HALMAC_RET_NOT_SUPPORT;
}
 
enum halmac_ret_status
fast_edca_cfg_88xx(struct halmac_adapter *adapter,
          struct halmac_fast_edca_cfg *cfg)
{
   u16 value16;
   u32 offset;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   switch (cfg->acq_id) {
   case HALMAC_ACQ_ID_VO:
       offset = REG_FAST_EDCA_VOVI_SETTING;
       break;
   case HALMAC_ACQ_ID_VI:
       offset = REG_FAST_EDCA_VOVI_SETTING + 2;
       break;
   case HALMAC_ACQ_ID_BE:
       offset = REG_FAST_EDCA_BEBK_SETTING;
       break;
   case HALMAC_ACQ_ID_BK:
       offset = REG_FAST_EDCA_BEBK_SETTING + 2;
       break;
   default:
       return HALMAC_RET_SWITCH_CASE_ERROR;
   }
 
   value16 = HALMAC_REG_R16(offset);
   value16 &= 0xFF;
   value16 = value16 | (cfg->queue_to << 8);
 
   HALMAC_REG_W16(offset, value16);
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * get_mac_addr_88xx() - get mac address
 * @adapter : the adapter of halmac
 * @port : 0 for port0, 1 for port1, 2 for port2, 3 for port3, 4 for port4
 * @addr : mac address
 * Author : Ivan Lin
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
get_mac_addr_88xx(struct halmac_adapter *adapter, u8 port,
         union halmac_wlan_addr *addr)
{
   u16 mac_addr_h;
   u32 mac_addr_l;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
 
   if (port >= HALMAC_PORTID_NUM) {
       PLTFM_MSG_ERR("[ERR]port index >= 5\n");
       return HALMAC_RET_PORT_NOT_SUPPORT;
   }
 
   switch (port) {
   case HALMAC_PORTID0:
       mac_addr_l = HALMAC_REG_R32(REG_MACID);
       mac_addr_h = HALMAC_REG_R16(REG_MACID + 4);
       break;
   case HALMAC_PORTID1:
       mac_addr_l = HALMAC_REG_R32(REG_MACID1);
       mac_addr_h = HALMAC_REG_R16(REG_MACID1 + 4);
       break;
   case HALMAC_PORTID2:
       mac_addr_l = HALMAC_REG_R32(REG_MACID2);
       mac_addr_h = HALMAC_REG_R16(REG_MACID2 + 4);
       break;
   case HALMAC_PORTID3:
       mac_addr_l = HALMAC_REG_R32(REG_MACID3);
       mac_addr_h = HALMAC_REG_R16(REG_MACID3 + 4);
       break;
   case HALMAC_PORTID4:
       mac_addr_l = HALMAC_REG_R32(REG_MACID4);
       mac_addr_h = HALMAC_REG_R16(REG_MACID4 + 4);
       break;
   default:
       return HALMAC_RET_PORT_NOT_SUPPORT;
   }
 
   addr->addr_l_h.low = rtk_cpu_to_le32(mac_addr_l);
   addr->addr_l_h.high = rtk_cpu_to_le16(mac_addr_h);
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
void
rts_full_bw_88xx(struct halmac_adapter *adapter, u8 enable)
{
   u8 value8;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   value8 = HALMAC_REG_R8(REG_INIRTS_RATE_SEL);
 
   if (enable == 1)
       HALMAC_REG_W8(REG_INIRTS_RATE_SEL, value8 | BIT(5));
   else
       HALMAC_REG_W8(REG_INIRTS_RATE_SEL, value8 & ~(BIT(5)));
}
 
#endif /* HALMAC_88XX_SUPPORT */