@@ -43,14 +43,14 @@ dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no)
43
43
return NULL ;
44
44
}
45
45
46
- static unsigned int dw_pcie_ep_func_select (struct dw_pcie_ep * ep , u8 func_no )
46
+ static unsigned int dw_pcie_ep_get_dbi_offset (struct dw_pcie_ep * ep , u8 func_no )
47
47
{
48
- unsigned int func_offset = 0 ;
48
+ unsigned int dbi_offset = 0 ;
49
49
50
- if (ep -> ops -> func_conf_select )
51
- func_offset = ep -> ops -> func_conf_select (ep , func_no );
50
+ if (ep -> ops -> get_dbi_offset )
51
+ dbi_offset = ep -> ops -> get_dbi_offset (ep , func_no );
52
52
53
- return func_offset ;
53
+ return dbi_offset ;
54
54
}
55
55
56
56
static unsigned int dw_pcie_ep_get_dbi2_offset (struct dw_pcie_ep * ep , u8 func_no )
@@ -59,23 +59,23 @@ static unsigned int dw_pcie_ep_get_dbi2_offset(struct dw_pcie_ep *ep, u8 func_no
59
59
60
60
if (ep -> ops -> get_dbi2_offset )
61
61
dbi2_offset = ep -> ops -> get_dbi2_offset (ep , func_no );
62
- else if (ep -> ops -> func_conf_select ) /* for backward compatibility */
63
- dbi2_offset = ep -> ops -> func_conf_select (ep , func_no );
62
+ else if (ep -> ops -> get_dbi_offset ) /* for backward compatibility */
63
+ dbi2_offset = ep -> ops -> get_dbi_offset (ep , func_no );
64
64
65
65
return dbi2_offset ;
66
66
}
67
67
68
68
static void __dw_pcie_ep_reset_bar (struct dw_pcie * pci , u8 func_no ,
69
69
enum pci_barno bar , int flags )
70
70
{
71
- unsigned int func_offset , dbi2_offset ;
71
+ unsigned int dbi_offset , dbi2_offset ;
72
72
struct dw_pcie_ep * ep = & pci -> ep ;
73
73
u32 reg , reg_dbi2 ;
74
74
75
- func_offset = dw_pcie_ep_func_select (ep , func_no );
75
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
76
76
dbi2_offset = dw_pcie_ep_get_dbi2_offset (ep , func_no );
77
77
78
- reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar );
78
+ reg = dbi_offset + PCI_BASE_ADDRESS_0 + (4 * bar );
79
79
reg_dbi2 = dbi2_offset + PCI_BASE_ADDRESS_0 + (4 * bar );
80
80
dw_pcie_dbi_ro_wr_en (pci );
81
81
dw_pcie_writel_dbi2 (pci , reg_dbi2 , 0x0 );
@@ -102,16 +102,16 @@ static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep *ep, u8 func_no,
102
102
u8 cap_ptr , u8 cap )
103
103
{
104
104
struct dw_pcie * pci = to_dw_pcie_from_ep (ep );
105
- unsigned int func_offset = 0 ;
105
+ unsigned int dbi_offset = 0 ;
106
106
u8 cap_id , next_cap_ptr ;
107
107
u16 reg ;
108
108
109
109
if (!cap_ptr )
110
110
return 0 ;
111
111
112
- func_offset = dw_pcie_ep_func_select (ep , func_no );
112
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
113
113
114
- reg = dw_pcie_readw_dbi (pci , func_offset + cap_ptr );
114
+ reg = dw_pcie_readw_dbi (pci , dbi_offset + cap_ptr );
115
115
cap_id = (reg & 0x00ff );
116
116
117
117
if (cap_id > PCI_CAP_ID_MAX )
@@ -127,13 +127,13 @@ static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep *ep, u8 func_no,
127
127
static u8 dw_pcie_ep_find_capability (struct dw_pcie_ep * ep , u8 func_no , u8 cap )
128
128
{
129
129
struct dw_pcie * pci = to_dw_pcie_from_ep (ep );
130
- unsigned int func_offset = 0 ;
130
+ unsigned int dbi_offset = 0 ;
131
131
u8 next_cap_ptr ;
132
132
u16 reg ;
133
133
134
- func_offset = dw_pcie_ep_func_select (ep , func_no );
134
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
135
135
136
- reg = dw_pcie_readw_dbi (pci , func_offset + PCI_CAPABILITY_LIST );
136
+ reg = dw_pcie_readw_dbi (pci , dbi_offset + PCI_CAPABILITY_LIST );
137
137
next_cap_ptr = (reg & 0x00ff );
138
138
139
139
return __dw_pcie_ep_find_next_cap (ep , func_no , next_cap_ptr , cap );
@@ -144,23 +144,23 @@ static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
144
144
{
145
145
struct dw_pcie_ep * ep = epc_get_drvdata (epc );
146
146
struct dw_pcie * pci = to_dw_pcie_from_ep (ep );
147
- unsigned int func_offset = 0 ;
147
+ unsigned int dbi_offset = 0 ;
148
148
149
- func_offset = dw_pcie_ep_func_select (ep , func_no );
149
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
150
150
151
151
dw_pcie_dbi_ro_wr_en (pci );
152
- dw_pcie_writew_dbi (pci , func_offset + PCI_VENDOR_ID , hdr -> vendorid );
153
- dw_pcie_writew_dbi (pci , func_offset + PCI_DEVICE_ID , hdr -> deviceid );
154
- dw_pcie_writeb_dbi (pci , func_offset + PCI_REVISION_ID , hdr -> revid );
155
- dw_pcie_writeb_dbi (pci , func_offset + PCI_CLASS_PROG , hdr -> progif_code );
156
- dw_pcie_writew_dbi (pci , func_offset + PCI_CLASS_DEVICE ,
152
+ dw_pcie_writew_dbi (pci , dbi_offset + PCI_VENDOR_ID , hdr -> vendorid );
153
+ dw_pcie_writew_dbi (pci , dbi_offset + PCI_DEVICE_ID , hdr -> deviceid );
154
+ dw_pcie_writeb_dbi (pci , dbi_offset + PCI_REVISION_ID , hdr -> revid );
155
+ dw_pcie_writeb_dbi (pci , dbi_offset + PCI_CLASS_PROG , hdr -> progif_code );
156
+ dw_pcie_writew_dbi (pci , dbi_offset + PCI_CLASS_DEVICE ,
157
157
hdr -> subclass_code | hdr -> baseclass_code << 8 );
158
- dw_pcie_writeb_dbi (pci , func_offset + PCI_CACHE_LINE_SIZE ,
158
+ dw_pcie_writeb_dbi (pci , dbi_offset + PCI_CACHE_LINE_SIZE ,
159
159
hdr -> cache_line_size );
160
- dw_pcie_writew_dbi (pci , func_offset + PCI_SUBSYSTEM_VENDOR_ID ,
160
+ dw_pcie_writew_dbi (pci , dbi_offset + PCI_SUBSYSTEM_VENDOR_ID ,
161
161
hdr -> subsys_vendor_id );
162
- dw_pcie_writew_dbi (pci , func_offset + PCI_SUBSYSTEM_ID , hdr -> subsys_id );
163
- dw_pcie_writeb_dbi (pci , func_offset + PCI_INTERRUPT_PIN ,
162
+ dw_pcie_writew_dbi (pci , dbi_offset + PCI_SUBSYSTEM_ID , hdr -> subsys_id );
163
+ dw_pcie_writeb_dbi (pci , dbi_offset + PCI_INTERRUPT_PIN ,
164
164
hdr -> interrupt_pin );
165
165
dw_pcie_dbi_ro_wr_dis (pci );
166
166
@@ -243,17 +243,17 @@ static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
243
243
{
244
244
struct dw_pcie_ep * ep = epc_get_drvdata (epc );
245
245
struct dw_pcie * pci = to_dw_pcie_from_ep (ep );
246
- unsigned int func_offset , dbi2_offset ;
246
+ unsigned int dbi_offset , dbi2_offset ;
247
247
enum pci_barno bar = epf_bar -> barno ;
248
248
size_t size = epf_bar -> size ;
249
249
int flags = epf_bar -> flags ;
250
250
u32 reg , reg_dbi2 ;
251
251
int ret , type ;
252
252
253
- func_offset = dw_pcie_ep_func_select (ep , func_no );
253
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
254
254
dbi2_offset = dw_pcie_ep_get_dbi2_offset (ep , func_no );
255
255
256
- reg = PCI_BASE_ADDRESS_0 + (4 * bar ) + func_offset ;
256
+ reg = PCI_BASE_ADDRESS_0 + (4 * bar ) + dbi_offset ;
257
257
reg_dbi2 = PCI_BASE_ADDRESS_0 + (4 * bar ) + dbi2_offset ;
258
258
259
259
if (!(flags & PCI_BASE_ADDRESS_SPACE ))
@@ -337,16 +337,16 @@ static int dw_pcie_ep_get_msi(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
337
337
struct dw_pcie_ep * ep = epc_get_drvdata (epc );
338
338
struct dw_pcie * pci = to_dw_pcie_from_ep (ep );
339
339
u32 val , reg ;
340
- unsigned int func_offset = 0 ;
340
+ unsigned int dbi_offset = 0 ;
341
341
struct dw_pcie_ep_func * ep_func ;
342
342
343
343
ep_func = dw_pcie_ep_get_func_from_ep (ep , func_no );
344
344
if (!ep_func || !ep_func -> msi_cap )
345
345
return - EINVAL ;
346
346
347
- func_offset = dw_pcie_ep_func_select (ep , func_no );
347
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
348
348
349
- reg = ep_func -> msi_cap + func_offset + PCI_MSI_FLAGS ;
349
+ reg = ep_func -> msi_cap + dbi_offset + PCI_MSI_FLAGS ;
350
350
val = dw_pcie_readw_dbi (pci , reg );
351
351
if (!(val & PCI_MSI_FLAGS_ENABLE ))
352
352
return - EINVAL ;
@@ -362,16 +362,16 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
362
362
struct dw_pcie_ep * ep = epc_get_drvdata (epc );
363
363
struct dw_pcie * pci = to_dw_pcie_from_ep (ep );
364
364
u32 val , reg ;
365
- unsigned int func_offset = 0 ;
365
+ unsigned int dbi_offset = 0 ;
366
366
struct dw_pcie_ep_func * ep_func ;
367
367
368
368
ep_func = dw_pcie_ep_get_func_from_ep (ep , func_no );
369
369
if (!ep_func || !ep_func -> msi_cap )
370
370
return - EINVAL ;
371
371
372
- func_offset = dw_pcie_ep_func_select (ep , func_no );
372
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
373
373
374
- reg = ep_func -> msi_cap + func_offset + PCI_MSI_FLAGS ;
374
+ reg = ep_func -> msi_cap + dbi_offset + PCI_MSI_FLAGS ;
375
375
val = dw_pcie_readw_dbi (pci , reg );
376
376
val &= ~PCI_MSI_FLAGS_QMASK ;
377
377
val |= FIELD_PREP (PCI_MSI_FLAGS_QMASK , interrupts );
@@ -387,16 +387,16 @@ static int dw_pcie_ep_get_msix(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
387
387
struct dw_pcie_ep * ep = epc_get_drvdata (epc );
388
388
struct dw_pcie * pci = to_dw_pcie_from_ep (ep );
389
389
u32 val , reg ;
390
- unsigned int func_offset = 0 ;
390
+ unsigned int dbi_offset = 0 ;
391
391
struct dw_pcie_ep_func * ep_func ;
392
392
393
393
ep_func = dw_pcie_ep_get_func_from_ep (ep , func_no );
394
394
if (!ep_func || !ep_func -> msix_cap )
395
395
return - EINVAL ;
396
396
397
- func_offset = dw_pcie_ep_func_select (ep , func_no );
397
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
398
398
399
- reg = ep_func -> msix_cap + func_offset + PCI_MSIX_FLAGS ;
399
+ reg = ep_func -> msix_cap + dbi_offset + PCI_MSIX_FLAGS ;
400
400
val = dw_pcie_readw_dbi (pci , reg );
401
401
if (!(val & PCI_MSIX_FLAGS_ENABLE ))
402
402
return - EINVAL ;
@@ -412,7 +412,7 @@ static int dw_pcie_ep_set_msix(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
412
412
struct dw_pcie_ep * ep = epc_get_drvdata (epc );
413
413
struct dw_pcie * pci = to_dw_pcie_from_ep (ep );
414
414
u32 val , reg ;
415
- unsigned int func_offset = 0 ;
415
+ unsigned int dbi_offset = 0 ;
416
416
struct dw_pcie_ep_func * ep_func ;
417
417
418
418
ep_func = dw_pcie_ep_get_func_from_ep (ep , func_no );
@@ -421,19 +421,19 @@ static int dw_pcie_ep_set_msix(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
421
421
422
422
dw_pcie_dbi_ro_wr_en (pci );
423
423
424
- func_offset = dw_pcie_ep_func_select (ep , func_no );
424
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
425
425
426
- reg = ep_func -> msix_cap + func_offset + PCI_MSIX_FLAGS ;
426
+ reg = ep_func -> msix_cap + dbi_offset + PCI_MSIX_FLAGS ;
427
427
val = dw_pcie_readw_dbi (pci , reg );
428
428
val &= ~PCI_MSIX_FLAGS_QSIZE ;
429
429
val |= interrupts ;
430
430
dw_pcie_writew_dbi (pci , reg , val );
431
431
432
- reg = ep_func -> msix_cap + func_offset + PCI_MSIX_TABLE ;
432
+ reg = ep_func -> msix_cap + dbi_offset + PCI_MSIX_TABLE ;
433
433
val = offset | bir ;
434
434
dw_pcie_writel_dbi (pci , reg , val );
435
435
436
- reg = ep_func -> msix_cap + func_offset + PCI_MSIX_PBA ;
436
+ reg = ep_func -> msix_cap + dbi_offset + PCI_MSIX_PBA ;
437
437
val = (offset + (interrupts * PCI_MSIX_ENTRY_SIZE )) | bir ;
438
438
dw_pcie_writel_dbi (pci , reg , val );
439
439
@@ -514,7 +514,7 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,
514
514
struct dw_pcie_ep_func * ep_func ;
515
515
struct pci_epc * epc = ep -> epc ;
516
516
unsigned int aligned_offset ;
517
- unsigned int func_offset = 0 ;
517
+ unsigned int dbi_offset = 0 ;
518
518
u16 msg_ctrl , msg_data ;
519
519
u32 msg_addr_lower , msg_addr_upper , reg ;
520
520
u64 msg_addr ;
@@ -525,22 +525,22 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,
525
525
if (!ep_func || !ep_func -> msi_cap )
526
526
return - EINVAL ;
527
527
528
- func_offset = dw_pcie_ep_func_select (ep , func_no );
528
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
529
529
530
530
/* Raise MSI per the PCI Local Bus Specification Revision 3.0, 6.8.1. */
531
- reg = ep_func -> msi_cap + func_offset + PCI_MSI_FLAGS ;
531
+ reg = ep_func -> msi_cap + dbi_offset + PCI_MSI_FLAGS ;
532
532
msg_ctrl = dw_pcie_readw_dbi (pci , reg );
533
533
has_upper = !!(msg_ctrl & PCI_MSI_FLAGS_64BIT );
534
- reg = ep_func -> msi_cap + func_offset + PCI_MSI_ADDRESS_LO ;
534
+ reg = ep_func -> msi_cap + dbi_offset + PCI_MSI_ADDRESS_LO ;
535
535
msg_addr_lower = dw_pcie_readl_dbi (pci , reg );
536
536
if (has_upper ) {
537
- reg = ep_func -> msi_cap + func_offset + PCI_MSI_ADDRESS_HI ;
537
+ reg = ep_func -> msi_cap + dbi_offset + PCI_MSI_ADDRESS_HI ;
538
538
msg_addr_upper = dw_pcie_readl_dbi (pci , reg );
539
- reg = ep_func -> msi_cap + func_offset + PCI_MSI_DATA_64 ;
539
+ reg = ep_func -> msi_cap + dbi_offset + PCI_MSI_DATA_64 ;
540
540
msg_data = dw_pcie_readw_dbi (pci , reg );
541
541
} else {
542
542
msg_addr_upper = 0 ;
543
- reg = ep_func -> msi_cap + func_offset + PCI_MSI_DATA_32 ;
543
+ reg = ep_func -> msi_cap + dbi_offset + PCI_MSI_DATA_32 ;
544
544
msg_data = dw_pcie_readw_dbi (pci , reg );
545
545
}
546
546
aligned_offset = msg_addr_lower & (epc -> mem -> window .page_size - 1 );
@@ -585,7 +585,7 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
585
585
struct dw_pcie_ep_func * ep_func ;
586
586
struct pci_epf_msix_tbl * msix_tbl ;
587
587
struct pci_epc * epc = ep -> epc ;
588
- unsigned int func_offset = 0 ;
588
+ unsigned int dbi_offset = 0 ;
589
589
u32 reg , msg_data , vec_ctrl ;
590
590
unsigned int aligned_offset ;
591
591
u32 tbl_offset ;
@@ -597,9 +597,9 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
597
597
if (!ep_func || !ep_func -> msix_cap )
598
598
return - EINVAL ;
599
599
600
- func_offset = dw_pcie_ep_func_select (ep , func_no );
600
+ dbi_offset = dw_pcie_ep_get_dbi_offset (ep , func_no );
601
601
602
- reg = ep_func -> msix_cap + func_offset + PCI_MSIX_TABLE ;
602
+ reg = ep_func -> msix_cap + dbi_offset + PCI_MSIX_TABLE ;
603
603
tbl_offset = dw_pcie_readl_dbi (pci , reg );
604
604
bir = FIELD_GET (PCI_MSIX_TABLE_BIR , tbl_offset );
605
605
tbl_offset &= PCI_MSIX_TABLE_OFFSET ;
0 commit comments