xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852be/phl/hal_g6/mac/mac_ax/_pcie.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /** @file */
2 /******************************************************************************
3  *
4  * Copyright(c) 2019 Realtek Corporation. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  ******************************************************************************/
16 
17 #ifndef _MAC_AX_PCIE_H_
18 #define _MAC_AX_PCIE_H_
19 
20 #include "../type.h"
21 #include "../pcie_reg.h"
22 #include "../mac_ax.h"
23 
24 /*--------------------Define -------------------------------------------*/
25 #define INTF_INTGRA_MINREF_V1	90
26 #define INTF_INTGRA_HOSTREF_V1	100
27 #define GET_PCIE_FUNC_STUS(val, mask) (((val) & (mask)) ? \
28 			   MAC_AX_PCIE_ENABLE : MAC_AX_PCIE_DISABLE)
29 
30 #define PCIE_POLL_IO_IDLE_CNT 100
31 #define PCIE_POLL_IO_IDLE_DLY_US 10
32 #define PCIE_POLL_DMACH_IDLE_CNT 100
33 #define PCIE_POLL_DMACH_IDLE_DLY_US 10
34 
35 #define PCIE_POLL_BDRAM_RST_CNT 10000
36 #define PCIE_POLL_BDRAM_RST_DLY_US 50
37 
38 #define PCIE_POLL_AUTOK_CNT 1000
39 #define PCIE_POLL_AUTOK_DLY_US 50
40 
41 #define DBI_ADDR_MASK 0xFFC
42 #define DBI_ADDR_2LSB_MASK 0x3
43 #define DBI_WEN_DW 0xF
44 #define DBI_WEN_B 1
45 #define DBI_DLY_CNT 20
46 #define DBI_DLY_US 10
47 
48 #define MDIO_ADDR_PG1 0x20
49 #define MDIO_DLY_CNT 20
50 #define MDIO_DLY_US 10
51 
52 #define BDRAM_SIDX_MSK 0x1f
53 #define BDRAM_MAX_MSK 0x1f00
54 #define BDRAM_MIN_MSK 0x1f0000
55 
56 #define MDIO_PG0_G1 0
57 #define MDIO_PG1_G1 1
58 #define MDIO_PG0_G2 2
59 #define MDIO_PG1_G2 3
60 
61 #define BD_NORM_SIZE 12
62 #define BD_TRUNC_SIZE 8
63 #define RXBD_SEP_NORM_SIZE 20
64 #define RXBD_SEP_TRUNC_OLD_SIZE 12
65 #define RXBD_SEP_TRUNC_NEW_SIZE 16
66 
67 #define BD_MAX_NUM 0x3FF
68 #define BD_IDX_INVALID 0xFFFF
69 #define TXBD_BYTE_ALIGN 8
70 #define RXBD_BYTE_ALIGN 4
71 
72 #define CMAC_CLK_ALLEN 0xFFFFFFFF
73 
74 #define PC_POWER_UP 1
75 #define PC_POWER_DOWN 0
76 #define BIT_WAKE_CTRL BIT5
77 #define PCIE_DEFAULT_AGG_NUM 0x40
78 
79 #define PCIE_AUTOK_DIV_2048 0x0
80 #define PCIE_AUTOK_MGN 0x8
81 #define PCIE_AUTOK_MGN_2048 64
82 #define PCIE_AUTOK_UD_CNT 30
83 #define PCIE_DPHY_DLY_25US 0x1
84 #define PCIE_AUTOK_4 0x3
85 
86 /*--------------------Define MACRO--------------------------------------*/
87 /*--------------------Define Enum---------------------------------------*/
88 enum pcie_clkdly_hw {
89 	PCIE_CLKDLY_HW_0 = 0,
90 	PCIE_CLKDLY_HW_30US = 0x1,
91 	PCIE_CLKDLY_HW_50US = 0x2,
92 	PCIE_CLKDLY_HW_80US = 0x3,
93 	PCIE_CLKDLY_HW_100US = 0x4,
94 	PCIE_CLKDLY_HW_120US = 0x5,
95 	PCIE_CLKDLY_HW_150US = 0x6,
96 	PCIE_CLKDLY_HW_180US = 0x7,
97 	PCIE_CLKDLY_HW_200US = 0x8,
98 	PCIE_CLKDLY_HW_300US = 0x9,
99 	PCIE_CLKDLY_HW_400US = 0xA,
100 	PCIE_CLKDLY_HW_500US = 0xB,
101 	PCIE_CLKDLY_HW_1MS = 0xC,
102 	PCIE_CLKDLY_HW_3MS = 0xD,
103 	PCIE_CLKDLY_HW_5MS = 0xE,
104 	PCIE_CLKDLY_HW_10MS = 0xF
105 };
106 
107 enum pcie_l1dly_hw {
108 	PCIE_L1DLY_HW_16US = 4,
109 	PCIE_L1DLY_HW_32US = 5,
110 	PCIE_L1DLY_HW_64US = 6,
111 	PCIE_L1DLY_HW_INFI = 7
112 };
113 
114 enum pcie_l0sdly_hw {
115 	PCIE_L0SDLY_HW_1US = 0,
116 	PCIE_L0SDLY_HW_2US = 1,
117 	PCIE_L0SDLY_HW_3US = 2,
118 	PCIE_L0SDLY_HW_4US = 3,
119 	PCIE_L0SDLY_HW_5US = 4,
120 	PCIE_L0SDLY_HW_6US = 5,
121 	PCIE_L0SDLY_HW_7US = 6
122 };
123 
124 /*--------------------Define Struct-------------------------------------*/
125 struct txbd_ram {
126 	u8 sidx;
127 	u8 max;
128 	u8 min;
129 };
130 
131 /**
132  * @brief reg_read8_pcie
133  *
134  * @param *adapter
135  * @param addr
136  * @return Please Place Description here.
137  * @retval u8
138  */
139 u8 reg_read8_pcie(struct mac_ax_adapter *adapter, u32 addr);
140 /**
141  * @}
142  * @}
143  */
144 
145 /**
146  * @addtogroup HCI
147  * @{
148  * @addtogroup BasicIO
149  * @{
150  */
151 
152 /**
153  * @brief reg_write8_pcie
154  *
155  * @param *adapter
156  * @param addr
157  * @param val
158  * @return Please Place Description here.
159  * @retval void
160  */
161 void reg_write8_pcie(struct mac_ax_adapter *adapter, u32 addr, u8 val);
162 /**
163  * @}
164  * @}
165  */
166 
167 /**
168  * @addtogroup HCI
169  * @{
170  * @addtogroup BasicIO
171  * @{
172  */
173 
174 /**
175  * @brief reg_read16_pcie
176  *
177  * @param *adapter
178  * @param addr
179  * @return Please Place Description here.
180  * @retval u16
181  */
182 u16 reg_read16_pcie(struct mac_ax_adapter *adapter, u32 addr);
183 /**
184  * @}
185  * @}
186  */
187 
188 /**
189  * @addtogroup HCI
190  * @{
191  * @addtogroup BasicIO
192  * @{
193  */
194 /**
195  * @brief reg_write16_pcie
196  *
197  * @param *adapter
198  * @param addr
199  * @param val
200  * @return Please Place Description here.
201  * @retval void
202  */
203 void reg_write16_pcie(struct mac_ax_adapter *adapter, u32 addr, u16 val);
204 /**
205  * @}
206  * @}
207  */
208 
209 /**
210  * @addtogroup HCI
211  * @{
212  * @addtogroup BasicIO
213  * @{
214  */
215 
216 /**
217  * @brief reg_read32_pcie
218  *
219  * @param *adapter
220  * @param addr
221  * @return Please Place Description here.
222  * @retval u32
223  */
224 u32 reg_read32_pcie(struct mac_ax_adapter *adapter, u32 addr);
225 /**
226  * @}
227  * @}
228  */
229 
230 /**
231  * @addtogroup HCI
232  * @{
233  * @addtogroup BasicIO
234  * @{
235  */
236 
237 /**
238  * @brief reg_write32_pcie
239  *
240  * @param *adapter
241  * @param addr
242  * @param val
243  * @return Please Place Description here.
244  * @retval void
245  */
246 void reg_write32_pcie(struct mac_ax_adapter *adapter, u32 addr, u32 val);
247 /**
248  * @}
249  * @}
250  */
251 
252 /**
253  * @addtogroup HCI
254  * @{
255  * @addtogroup PCIE
256  * @{
257  */
258 
259 /**
260  * @brief dbi_r8_pcie
261  *
262  * @param *adapter
263  * @param addr
264  * @param *val
265  * @return Please Place Description here.
266  * @retval u32
267  */
268 u32 dbi_r8_pcie(struct mac_ax_adapter *adapter, u16 addr, u8 *val);
269 /**
270  * @}
271  * @}
272  */
273 
274 /**
275  * @addtogroup HCI
276  * @{
277  * @addtogroup PCIE
278  * @{
279  */
280 
281 /**
282  * @brief dbi_w8_pcie
283  *
284  * @param *adapter
285  * @param addr
286  * @param data
287  * @return Please Place Description here.
288  * @retval u32
289  */
290 u32 dbi_w8_pcie(struct mac_ax_adapter *adapter, u16 addr, u8 data);
291 /**
292  * @}
293  * @}
294  */
295 
296 /**
297  * @addtogroup HCI
298  * @{
299  * @addtogroup PCIE
300  * @{
301  */
302 
303 /**
304  * @brief dbi_r32_pcie
305  *
306  * @param *adapter
307  * @param addr
308  * @param *val
309  * @return Please Place Description here.
310  * @retval u32
311  */
312 u32 dbi_r32_pcie(struct mac_ax_adapter *adapter, u16 addr, u32 *val);
313 /**
314  * @}
315  * @}
316  */
317 
318 /**
319  * @addtogroup HCI
320  * @{
321  * @addtogroup PCIE
322  * @{
323  */
324 
325 /**
326  * @brief dbi_w32_pcie
327  *
328  * @param *adapter
329  * @param addr
330  * @param data
331  * @return Please Place Description here.
332  * @retval u32
333  */
334 u32 dbi_w32_pcie(struct mac_ax_adapter *adapter, u16 addr, u32 data);
335 /**
336  * @}
337  * @}
338  */
339 
340 /**
341  * @addtogroup HCI
342  * @{
343  * @addtogroup PCIE
344  * @{
345  */
346 
347 /**
348  * @brief mdio_r16_pcie
349  *
350  * @param *adapter
351  * @param addr
352  * @param speed
353  * @param *val
354  * @return Please Place Description here.
355  * @retval u32
356  */
357 u32 mdio_r16_pcie(struct mac_ax_adapter *adapter, u8 addr, u8 speed, u16 *val);
358 /**
359  * @}
360  * @}
361  */
362 
363 /**
364  * @addtogroup HCI
365  * @{
366  * @addtogroup PCIE
367  * @{
368  */
369 
370 /**
371  * @brief mdio_w16_pcie
372  *
373  * @param *adapter
374  * @param addr
375  * @param data
376  * @param speed
377  * @return Please Place Description here.
378  * @retval u32
379  */
380 u32 mdio_w16_pcie(struct mac_ax_adapter *adapter, u8 addr, u16 data, u8 speed);
381 /**
382  * @}
383  * @}
384  */
385 
386 /**
387  * @addtogroup HCI
388  * @{
389  * @addtogroup PCIE
390  * @{
391  */
392 
393 /**
394  * @brief cfgspc_set_pcie
395  *
396  * @param *adapter
397  * @param *param
398  * @return Please Place Description here.
399  * @retval u32
400  */
401 u32 cfgspc_set_pcie(struct mac_ax_adapter *adapter,
402 		    struct mac_ax_pcie_cfgspc_param *param);
403 /**
404  * @}
405  * @}
406  */
407 
408 /**
409  * @addtogroup HCI
410  * @{
411  * @addtogroup PCIE
412  * @{
413  */
414 
415 /**
416  * @brief ltr_set_pcie
417  *
418  * @param *adapter
419  * @param *param
420  * @return Please Place Description here.
421  * @retval u32
422  */
423 u32 ltr_set_pcie(struct mac_ax_adapter *adapter,
424 		 struct mac_ax_pcie_ltr_param *param);
425 /**
426  * @}
427  * @}
428  */
429 
430 /**
431  * @addtogroup HCI
432  * @{
433  * @addtogroup PCIE
434  * @{
435  */
436 
437 /**
438  * @brief ltr_sw_trigger
439  *
440  * @param *adapter
441  * @param ctrl
442  * @return Please Place Description here.
443  * @retval u32
444  */
445 u32 ltr_sw_trigger(struct mac_ax_adapter *adapter,
446 		   enum mac_ax_pcie_ltr_sw_ctrl ctrl);
447 /**
448  * @}
449  * @}
450  */
451 
452 /**
453  * @addtogroup HCI
454  * @{
455  * @addtogroup PCIE
456  * @{
457  */
458 
459 /**
460  * @brief ctrl_dma_all_pcie
461  *
462  * @param *adapter
463  * @param en
464  * @return Please Place Description here.
465  * @retval void
466  */
467 void ctrl_dma_all_pcie(struct mac_ax_adapter *adapter, enum mac_ax_func_sw en);
468 /**
469  * @}
470  * @}
471  */
472 
473 /**
474  * @addtogroup HCI
475  * @{
476  * @addtogroup PCIE
477  * @{
478  */
479 
480 /**
481  * @brief clr_idx_all_pcie
482  *
483  * @param *adapter
484  * @return Please Place Description here.
485  * @retval u32
486  */
487 u32 clr_idx_all_pcie(struct mac_ax_adapter *adapter);
488 /**
489  * @}
490  * @}
491  */
492 
493 /**
494  * @addtogroup HCI
495  * @{
496  * @addtogroup PCIE
497  * @{
498  */
499 
500 /**
501  * @brief ctrl_txdma_ch_pcie
502  *
503  * @param *adapter
504  * @param *ch_map
505  * @return Please Place Description here.
506  * @retval u32
507  */
508 u32 ctrl_txdma_ch_pcie(struct mac_ax_adapter *adapter,
509 		       struct mac_ax_txdma_ch_map *ch_map);
510 /**
511  * @}
512  * @}
513  */
514 
515 /**
516  * @addtogroup HCI
517  * @{
518  * @addtogroup PCIE
519  * @{
520  */
521 
522 /**
523  * @brief poll_txdma_ch_idle_pcie
524  *
525  * @param *adapter
526  * @param *ch_map
527  * @return Please Place Description here.
528  * @retval u32
529  */
530 u32 poll_txdma_ch_idle_pcie(struct mac_ax_adapter *adapter,
531 			    struct mac_ax_txdma_ch_map *ch_map);
532 /**
533  * @}
534  * @}
535  */
536 
537 /**
538  * @addtogroup HCI
539  * @{
540  * @addtogroup PCIE
541  * @{
542  */
543 
544 /**
545  * @brief poll_rxdma_ch_idle_pcie
546  *
547  * @param *adapter
548  * @param *ch_map
549  * @return Please Place Description here.
550  * @retval u32
551  */
552 u32 poll_rxdma_ch_idle_pcie(struct mac_ax_adapter *adapter,
553 			    struct mac_ax_rxdma_ch_map *ch_map);
554 /**
555  * @}
556  * @}
557  */
558 
559 /**
560  * @addtogroup HCI
561  * @{
562  * @addtogroup PCIE
563  * @{
564  */
565 
566 /**
567  * @brief poll_dma_all_idle_pcie
568  *
569  * @param *adapter
570  * @return Please Place Description here.
571  * @retval u32
572  */
573 u32 poll_dma_all_idle_pcie(struct mac_ax_adapter *adapter);
574 /**
575  * @}
576  * @}
577  */
578 
579 /**
580  * @addtogroup HCI
581  * @{
582  * @addtogroup PCIE
583  * @{
584  */
585 
586 /**
587  * @brief ctrl_txhci_pcie
588  *
589  * @param *adapter
590  * @param en
591  * @return Please Place Description here.
592  * @retval u32
593  */
594 u32 ctrl_txhci_pcie(struct mac_ax_adapter *adapter, enum mac_ax_func_sw en);
595 /**
596  * @}
597  * @}
598  */
599 
600 /**
601  * @addtogroup HCI
602  * @{
603  * @addtogroup PCIE
604  * @{
605  */
606 
607 /**
608  * @brief ctrl_rxhci_pcie
609  *
610  * @param *adapter
611  * @param en
612  * @return Please Place Description here.
613  * @retval u32
614  */
615 u32 ctrl_rxhci_pcie(struct mac_ax_adapter *adapter, enum mac_ax_func_sw en);
616 /**
617  * @}
618  * @}
619  */
620 
621 /**
622  * @addtogroup HCI
623  * @{
624  * @addtogroup PCIE
625  * @{
626  */
627 
628 /**
629  * @brief ctrl_dma_io_pcie
630  *
631  * @param *adapter
632  * @param en
633  * @return Please Place Description here.
634  * @retval u32
635  */
636 u32 ctrl_dma_io_pcie(struct mac_ax_adapter *adapter, enum mac_ax_func_sw en);
637 /**
638  * @}
639  * @}
640  */
641 
642 /**
643  * @addtogroup HCI
644  * @{
645  * @addtogroup PCIE
646  * @{
647  */
648 
649 /**
650  * @brief pcie_pre_init
651  *
652  * @param *adapter
653  * @param *param
654  * @return Please Place Description here.
655  * @retval u32
656  */
657 u32 pcie_pre_init(struct mac_ax_adapter *adapter, void *param);
658 /**
659  * @}
660  * @}
661  */
662 
663 /**
664  * @addtogroup HCI
665  * @{
666  * @addtogroup PCIE
667  * @{
668  */
669 
670 /**
671  * @brief pcie_init
672  *
673  * @param *adapter
674  * @param *param
675  * @return Please Place Description here.
676  * @retval u32
677  */
678 u32 pcie_init(struct mac_ax_adapter *adapter, void *param);
679 /**
680  * @}
681  * @}
682  */
683 
684 /**
685  * @addtogroup HCI
686  * @{
687  * @addtogroup PCIE
688  * @{
689  */
690 
691 /**
692  * @brief pcie_deinit
693  *
694  * @param *adapter
695  * @param *param
696  * @return Please Place Description here.
697  * @retval u32
698  */
699 u32 pcie_deinit(struct mac_ax_adapter *adapter, void *param);
700 /**
701  * @}
702  * @}
703  */
704 
705 /**
706  * @addtogroup HCI
707  * @{
708  * @addtogroup PCIE
709  * @{
710  */
711 
712 /**
713  * @brief rst_bdram_pcie
714  *
715  * @param *adapter
716  * @param val
717  * @return Please Place Description here.
718  * @retval u32
719  */
720 u32 rst_bdram_pcie(struct mac_ax_adapter *adapter, u8 val);
721 /**
722  * @}
723  * @}
724  */
725 
726 /**
727  * @addtogroup HCI
728  * @{
729  * @addtogroup PCIE
730  * @{
731  */
732 
733 /**
734  * @brief lv1rst_stop_dma_pcie
735  *
736  * @param *adapter
737  * @param val
738  * @return Please Place Description here.
739  * @retval u32
740  */
741 u32 lv1rst_stop_dma_pcie(struct mac_ax_adapter *adapter, u8 val);
742 /**
743  * @}
744  * @}
745  */
746 
747 /**
748  * @addtogroup HCI
749  * @{
750  * @addtogroup PCIE
751  * @{
752  */
753 
754 /**
755  * @brief lv1rst_start_dma_pcie
756  *
757  * @param *adapter
758  * @param val
759  * @return Please Place Description here.
760  * @retval u32
761  */
762 u32 lv1rst_start_dma_pcie(struct mac_ax_adapter *adapter, u8 val);
763 /**
764  * @}
765  * @}
766  */
767 
768 /**
769  * @addtogroup HCI
770  * @{
771  * @addtogroup PCIE
772  * @{
773  */
774 
775 /**
776  * @brief pcie_pwr_switch
777  *
778  * @param *vadapter
779  * @param pre_switch
780  * @param on
781  * @return Please Place Description here.
782  * @retval u32
783  */
784 u32 pcie_pwr_switch(void *vadapter,
785 		    u8 pre_switch, u8 on);
786 /**
787  * @}
788  * @}
789  */
790 
791 /**
792  * @addtogroup HCI
793  * @{
794  * @addtogroup PCIE
795  * @{
796  */
797 
798 /**
799  * @brief set_pcie_wowlan
800  *
801  * @param *adapter
802  * @param w_c
803  * @return Please Place Description here.
804  * @retval u32
805  */
806 u32 set_pcie_wowlan(struct mac_ax_adapter *adapter, enum mac_ax_wow_ctrl w_c);
807 /**
808  * @}
809  * @}
810  */
811 
812 /**
813  * @addtogroup HCI
814  * @{
815  * @addtogroup PCIE
816  * @{
817  */
818 
819 /**
820  * @brief pcie_trx_mit
821  *
822  * @param *adapter
823  * @param *mit_info
824  * @return Please Place Description here.
825  * @retval u32
826  */
827 u32 pcie_trx_mit(struct mac_ax_adapter *adapter,
828 		 struct mac_ax_pcie_trx_mitigation *mit_info);
829 /**
830  * @}
831  * @}
832  */
833 
834 /**
835  * @addtogroup HCI
836  * @{
837  * @addtogroup PCIE
838  * @{
839  */
840 
841 /**
842  * @brief set_pcie_l2_leave
843  *
844  * @param *adapter
845  * @param set
846  * @return Please Place Description here.
847  * @retval u32
848  */
849 u32 set_pcie_l2_leave(struct mac_ax_adapter *adapter, u8 set);
850 /**
851  * @}
852  * @}
853  */
854 
855 /**
856  * @addtogroup HCI
857  * @{
858  * @addtogroup PCIE
859  * @{
860  */
861 
862 /**
863  * @brief get_io_stat_pcie
864  *
865  * @param *adapter
866  * @param *out_st
867  * @return Please Place Description here.
868  * @retval u32
869  */
870 u32 get_io_stat_pcie(struct mac_ax_adapter *adapter,
871 		     struct mac_ax_io_stat *out_st);
872 /**
873  * @}
874  * @}
875  */
876 
877 /**
878  * @brief pcie_get_txagg_num
879  *
880  * @param *adapter
881  * @param band
882  * @return Please Place Description here.
883  * @retval u32
884  */
885 u32 pcie_get_txagg_num(struct mac_ax_adapter *adapter, u8 band);
886 /**
887  * @}
888  * @}
889  */
890 
891 /**
892  * @brief pcie_autok_counter_avg
893  *
894  * @param *adapter
895  * @return Please Place Description here.
896  * @retval u32
897  */
898 u32 pcie_autok_counter_avg(struct mac_ax_adapter *adapter);
899 /**
900  * @}
901  * @}
902  */
903 
904 /**
905  * @addtogroup HCI
906  * @{
907  * @addtogroup PCIE
908  * @{
909  */
910 
911 /**
912  * @brief dbcc_hci_ctrl_pcie
913  *
914  * @param *adapter
915  * @param *info
916  * @return Please Place Description here.
917  * @retval u32
918  */
919 u32 dbcc_hci_ctrl_pcie(struct mac_ax_adapter *adapter,
920 		       struct mac_ax_dbcc_hci_ctrl *info);
921 /**
922  * @}
923  * @}
924  */
925 #endif
926