@@ -46,6 +46,16 @@ static const struct intel_ntb_alt_reg gen4_b2b_reg = {
4646 .spad = GEN4_EM_SPAD_OFFSET ,
4747};
4848
49+ static u64 get_ppd0 (struct pci_dev * pdev )
50+ {
51+ if (pdev_is_gen4 (pdev ) || pdev_is_gen5 (pdev ))
52+ return GEN4_PPD0_OFFSET ;
53+ else if (pdev_is_gen6 (pdev ))
54+ return GEN6_PPD0_OFFSET ;
55+
56+ return ULLONG_MAX ;
57+ }
58+
4959static int gen4_poll_link (struct intel_ntb_dev * ndev )
5060{
5161 u16 reg_val ;
@@ -183,7 +193,7 @@ static enum ntb_topo spr_ppd_topo(struct intel_ntb_dev *ndev, u32 ppd)
183193int gen4_init_dev (struct intel_ntb_dev * ndev )
184194{
185195 struct pci_dev * pdev = ndev -> ntb .pdev ;
186- u32 ppd1 /*, ppd0*/ ;
196+ u32 ppd1 ;
187197 u16 lnkctl ;
188198 int rc ;
189199
@@ -197,7 +207,7 @@ int gen4_init_dev(struct intel_ntb_dev *ndev)
197207 ppd1 = ioread32 (ndev -> self_mmio + GEN4_PPD1_OFFSET );
198208 if (pdev_is_ICX (pdev ))
199209 ndev -> ntb .topo = gen4_ppd_topo (ndev , ppd1 );
200- else if (pdev_is_SPR (pdev ) || pdev_is_gen5 (pdev ))
210+ else if (pdev_is_SPR (pdev ) || pdev_is_gen5 (pdev ) || pdev_is_gen6 ( pdev ) )
201211 ndev -> ntb .topo = spr_ppd_topo (ndev , ppd1 );
202212 dev_dbg (& pdev -> dev , "ppd %#x topo %s\n" , ppd1 ,
203213 ntb_topo_string (ndev -> ntb .topo ));
@@ -432,10 +442,12 @@ static int intel_ntb4_link_enable(struct ntb_dev *ntb,
432442 enum ntb_speed max_speed , enum ntb_width max_width )
433443{
434444 struct intel_ntb_dev * ndev ;
445+ struct pci_dev * pdev ;
435446 u32 ntb_ctl , ppd0 ;
436447 u16 lnkctl ;
437448
438449 ndev = container_of (ntb , struct intel_ntb_dev , ntb );
450+ pdev = ntb -> pdev ;
439451
440452 dev_dbg (& ntb -> pdev -> dev ,
441453 "Enabling link with max_speed %d max_width %d\n" ,
@@ -476,12 +488,12 @@ static int intel_ntb4_link_enable(struct ntb_dev *ntb,
476488 iowrite16 (lnkctl , ndev -> self_mmio + GEN4_LINK_CTRL_OFFSET );
477489
478490 /* start link training in PPD0 */
479- ppd0 = ioread32 (ndev -> self_mmio + GEN4_PPD0_OFFSET );
491+ ppd0 = ioread32 (ndev -> self_mmio + get_ppd0 ( pdev ) );
480492 ppd0 |= GEN4_PPD_LINKTRN ;
481- iowrite32 (ppd0 , ndev -> self_mmio + GEN4_PPD0_OFFSET );
493+ iowrite32 (ppd0 , ndev -> self_mmio + get_ppd0 ( pdev ) );
482494
483495 /* make sure link training has started */
484- ppd0 = ioread32 (ndev -> self_mmio + GEN4_PPD0_OFFSET );
496+ ppd0 = ioread32 (ndev -> self_mmio + get_ppd0 ( pdev ) );
485497 if (!(ppd0 & GEN4_PPD_LINKTRN )) {
486498 dev_warn (& ntb -> pdev -> dev , "Link is not training\n" );
487499 return - ENXIO ;
0 commit comments