45
45
46
46
#define NTB_EPF_MIN_DB_COUNT 3
47
47
#define NTB_EPF_MAX_DB_COUNT 31
48
- #define NTB_EPF_MW_OFFSET 2
49
48
50
49
#define NTB_EPF_COMMAND_TIMEOUT 1000 /* 1 Sec */
51
50
@@ -67,6 +66,7 @@ struct ntb_epf_dev {
67
66
enum pci_barno ctrl_reg_bar ;
68
67
enum pci_barno peer_spad_reg_bar ;
69
68
enum pci_barno db_reg_bar ;
69
+ enum pci_barno mw_bar ;
70
70
71
71
unsigned int mw_count ;
72
72
unsigned int spad_count ;
@@ -92,6 +92,8 @@ struct ntb_epf_data {
92
92
enum pci_barno peer_spad_reg_bar ;
93
93
/* BAR that contains Doorbell region and Memory window '1' */
94
94
enum pci_barno db_reg_bar ;
95
+ /* BAR that contains memory windows*/
96
+ enum pci_barno mw_bar ;
95
97
};
96
98
97
99
static int ntb_epf_send_command (struct ntb_epf_dev * ndev , u32 command ,
@@ -411,7 +413,7 @@ static int ntb_epf_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
411
413
return - EINVAL ;
412
414
}
413
415
414
- bar = idx + NTB_EPF_MW_OFFSET ;
416
+ bar = idx + ndev -> mw_bar ;
415
417
416
418
mw_size = pci_resource_len (ntb -> pdev , bar );
417
419
@@ -453,7 +455,7 @@ static int ntb_epf_peer_mw_get_addr(struct ntb_dev *ntb, int idx,
453
455
if (idx == 0 )
454
456
offset = readl (ndev -> ctrl_reg + NTB_EPF_MW1_OFFSET );
455
457
456
- bar = idx + NTB_EPF_MW_OFFSET ;
458
+ bar = idx + ndev -> mw_bar ;
457
459
458
460
if (base )
459
461
* base = pci_resource_start (ndev -> ntb .pdev , bar ) + offset ;
@@ -565,6 +567,7 @@ static int ntb_epf_init_pci(struct ntb_epf_dev *ndev,
565
567
struct pci_dev * pdev )
566
568
{
567
569
struct device * dev = ndev -> dev ;
570
+ size_t spad_sz , spad_off ;
568
571
int ret ;
569
572
570
573
pci_set_drvdata (pdev , ndev );
@@ -599,10 +602,16 @@ static int ntb_epf_init_pci(struct ntb_epf_dev *ndev,
599
602
goto err_dma_mask ;
600
603
}
601
604
602
- ndev -> peer_spad_reg = pci_iomap (pdev , ndev -> peer_spad_reg_bar , 0 );
603
- if (!ndev -> peer_spad_reg ) {
604
- ret = - EIO ;
605
- goto err_dma_mask ;
605
+ if (ndev -> peer_spad_reg_bar ) {
606
+ ndev -> peer_spad_reg = pci_iomap (pdev , ndev -> peer_spad_reg_bar , 0 );
607
+ if (!ndev -> peer_spad_reg ) {
608
+ ret = - EIO ;
609
+ goto err_dma_mask ;
610
+ }
611
+ } else {
612
+ spad_sz = 4 * readl (ndev -> ctrl_reg + NTB_EPF_SPAD_COUNT );
613
+ spad_off = readl (ndev -> ctrl_reg + NTB_EPF_SPAD_OFFSET );
614
+ ndev -> peer_spad_reg = ndev -> ctrl_reg + spad_off + spad_sz ;
606
615
}
607
616
608
617
ndev -> db_reg = pci_iomap (pdev , ndev -> db_reg_bar , 0 );
@@ -657,6 +666,7 @@ static int ntb_epf_pci_probe(struct pci_dev *pdev,
657
666
enum pci_barno peer_spad_reg_bar = BAR_1 ;
658
667
enum pci_barno ctrl_reg_bar = BAR_0 ;
659
668
enum pci_barno db_reg_bar = BAR_2 ;
669
+ enum pci_barno mw_bar = BAR_2 ;
660
670
struct device * dev = & pdev -> dev ;
661
671
struct ntb_epf_data * data ;
662
672
struct ntb_epf_dev * ndev ;
@@ -671,17 +681,16 @@ static int ntb_epf_pci_probe(struct pci_dev *pdev,
671
681
672
682
data = (struct ntb_epf_data * )id -> driver_data ;
673
683
if (data ) {
674
- if (data -> peer_spad_reg_bar )
675
- peer_spad_reg_bar = data -> peer_spad_reg_bar ;
676
- if (data -> ctrl_reg_bar )
677
- ctrl_reg_bar = data -> ctrl_reg_bar ;
678
- if (data -> db_reg_bar )
679
- db_reg_bar = data -> db_reg_bar ;
684
+ peer_spad_reg_bar = data -> peer_spad_reg_bar ;
685
+ ctrl_reg_bar = data -> ctrl_reg_bar ;
686
+ db_reg_bar = data -> db_reg_bar ;
687
+ mw_bar = data -> mw_bar ;
680
688
}
681
689
682
690
ndev -> peer_spad_reg_bar = peer_spad_reg_bar ;
683
691
ndev -> ctrl_reg_bar = ctrl_reg_bar ;
684
692
ndev -> db_reg_bar = db_reg_bar ;
693
+ ndev -> mw_bar = mw_bar ;
685
694
ndev -> dev = dev ;
686
695
687
696
ntb_epf_init_struct (ndev , pdev );
@@ -729,6 +738,14 @@ static const struct ntb_epf_data j721e_data = {
729
738
.ctrl_reg_bar = BAR_0 ,
730
739
.peer_spad_reg_bar = BAR_1 ,
731
740
.db_reg_bar = BAR_2 ,
741
+ .mw_bar = BAR_2 ,
742
+ };
743
+
744
+ static const struct ntb_epf_data mx8_data = {
745
+ .ctrl_reg_bar = BAR_0 ,
746
+ .peer_spad_reg_bar = BAR_0 ,
747
+ .db_reg_bar = BAR_2 ,
748
+ .mw_bar = BAR_4 ,
732
749
};
733
750
734
751
static const struct pci_device_id ntb_epf_pci_tbl [] = {
@@ -737,6 +754,11 @@ static const struct pci_device_id ntb_epf_pci_tbl[] = {
737
754
.class = PCI_CLASS_MEMORY_RAM << 8 , .class_mask = 0xffff00 ,
738
755
.driver_data = (kernel_ulong_t )& j721e_data ,
739
756
},
757
+ {
758
+ PCI_DEVICE (PCI_VENDOR_ID_FREESCALE , 0x0809 ),
759
+ .class = PCI_CLASS_MEMORY_RAM << 8 , .class_mask = 0xffff00 ,
760
+ .driver_data = (kernel_ulong_t )& mx8_data ,
761
+ },
740
762
{ },
741
763
};
742
764
0 commit comments