@@ -101,6 +101,7 @@ struct imx_pcie_drvdata {
101
101
const u32 mode_mask [IMX_PCIE_MAX_INSTANCES ];
102
102
const struct pci_epc_features * epc_features ;
103
103
int (* init_phy )(struct imx_pcie * pcie );
104
+ int (* enable_ref_clk )(struct imx_pcie * pcie , bool enable );
104
105
};
105
106
106
107
struct imx_pcie {
@@ -582,77 +583,54 @@ static int imx_pcie_attach_pd(struct device *dev)
582
583
return 0 ;
583
584
}
584
585
585
- static int imx_pcie_enable_ref_clk (struct imx_pcie * imx_pcie )
586
+ static int imx6sx_pcie_enable_ref_clk (struct imx_pcie * imx_pcie , bool enable )
586
587
{
587
- unsigned int offset ;
588
- int ret = 0 ;
588
+ if (enable )
589
+ regmap_clear_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR12 ,
590
+ IMX6SX_GPR12_PCIE_TEST_POWERDOWN );
589
591
590
- switch (imx_pcie -> drvdata -> variant ) {
591
- case IMX6SX :
592
- regmap_update_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR12 ,
593
- IMX6SX_GPR12_PCIE_TEST_POWERDOWN , 0 );
594
- break ;
595
- case IMX6QP :
596
- case IMX6Q :
592
+ return 0 ;
593
+ }
594
+
595
+ static int imx6q_pcie_enable_ref_clk (struct imx_pcie * imx_pcie , bool enable )
596
+ {
597
+ if (enable ) {
597
598
/* power up core phy and enable ref clock */
598
- regmap_update_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR1 ,
599
- IMX6Q_GPR1_PCIE_TEST_PD , 0 << 18 );
599
+ regmap_clear_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR1 , IMX6Q_GPR1_PCIE_TEST_PD );
600
600
/*
601
601
* the async reset input need ref clock to sync internally,
602
602
* when the ref clock comes after reset, internal synced
603
603
* reset time is too short, cannot meet the requirement.
604
604
* add one ~10us delay here.
605
605
*/
606
606
usleep_range (10 , 100 );
607
- regmap_update_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR1 ,
608
- IMX6Q_GPR1_PCIE_REF_CLK_EN , 1 << 16 );
609
- break ;
610
- case IMX7D :
611
- case IMX95 :
612
- case IMX95_EP :
613
- break ;
614
- case IMX8MM :
615
- case IMX8MM_EP :
616
- case IMX8MQ :
617
- case IMX8MQ_EP :
618
- case IMX8MP :
619
- case IMX8MP_EP :
620
- offset = imx_pcie_grp_offset (imx_pcie );
621
- /*
622
- * Set the over ride low and enabled
623
- * make sure that REF_CLK is turned on.
624
- */
625
- regmap_update_bits (imx_pcie -> iomuxc_gpr , offset ,
626
- IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE ,
627
- 0 );
628
- regmap_update_bits (imx_pcie -> iomuxc_gpr , offset ,
629
- IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN ,
630
- IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN );
631
- break ;
607
+ regmap_set_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR1 , IMX6Q_GPR1_PCIE_REF_CLK_EN );
608
+ } else {
609
+ regmap_clear_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR1 , IMX6Q_GPR1_PCIE_REF_CLK_EN );
610
+ regmap_set_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR1 , IMX6Q_GPR1_PCIE_TEST_PD );
632
611
}
633
612
634
- return ret ;
613
+ return 0 ;
635
614
}
636
615
637
- static void imx_pcie_disable_ref_clk (struct imx_pcie * imx_pcie )
616
+ static int imx8mm_pcie_enable_ref_clk (struct imx_pcie * imx_pcie , bool enable )
638
617
{
639
- switch (imx_pcie -> drvdata -> variant ) {
640
- case IMX6QP :
641
- case IMX6Q :
642
- regmap_update_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR1 ,
643
- IMX6Q_GPR1_PCIE_REF_CLK_EN , 0 );
644
- regmap_update_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR1 ,
645
- IMX6Q_GPR1_PCIE_TEST_PD ,
646
- IMX6Q_GPR1_PCIE_TEST_PD );
647
- break ;
648
- case IMX7D :
649
- regmap_update_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR12 ,
650
- IMX7D_GPR12_PCIE_PHY_REFCLK_SEL ,
651
- IMX7D_GPR12_PCIE_PHY_REFCLK_SEL );
652
- break ;
653
- default :
654
- break ;
618
+ int offset = imx_pcie_grp_offset (imx_pcie );
619
+
620
+ if (enable ) {
621
+ regmap_clear_bits (imx_pcie -> iomuxc_gpr , offset , IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE );
622
+ regmap_set_bits (imx_pcie -> iomuxc_gpr , offset , IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN );
655
623
}
624
+
625
+ return 0 ;
626
+ }
627
+
628
+ static int imx7d_pcie_enable_ref_clk (struct imx_pcie * imx_pcie , bool enable )
629
+ {
630
+ if (!enable )
631
+ regmap_set_bits (imx_pcie -> iomuxc_gpr , IOMUXC_GPR12 ,
632
+ IMX7D_GPR12_PCIE_PHY_REFCLK_SEL );
633
+ return 0 ;
656
634
}
657
635
658
636
static int imx_pcie_clk_enable (struct imx_pcie * imx_pcie )
@@ -665,10 +643,12 @@ static int imx_pcie_clk_enable(struct imx_pcie *imx_pcie)
665
643
if (ret )
666
644
return ret ;
667
645
668
- ret = imx_pcie_enable_ref_clk (imx_pcie );
669
- if (ret ) {
670
- dev_err (dev , "unable to enable pcie ref clock\n" );
671
- goto err_ref_clk ;
646
+ if (imx_pcie -> drvdata -> enable_ref_clk ) {
647
+ ret = imx_pcie -> drvdata -> enable_ref_clk (imx_pcie , true);
648
+ if (ret ) {
649
+ dev_err (dev , "Failed to enable PCIe REFCLK\n" );
650
+ goto err_ref_clk ;
651
+ }
672
652
}
673
653
674
654
/* allow the clocks to stabilize */
@@ -683,7 +663,8 @@ static int imx_pcie_clk_enable(struct imx_pcie *imx_pcie)
683
663
684
664
static void imx_pcie_clk_disable (struct imx_pcie * imx_pcie )
685
665
{
686
- imx_pcie_disable_ref_clk (imx_pcie );
666
+ if (imx_pcie -> drvdata -> enable_ref_clk )
667
+ imx_pcie -> drvdata -> enable_ref_clk (imx_pcie , false);
687
668
clk_bulk_disable_unprepare (imx_pcie -> drvdata -> clks_cnt , imx_pcie -> clks );
688
669
}
689
670
@@ -1459,6 +1440,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
1459
1440
.mode_off [0 ] = IOMUXC_GPR12 ,
1460
1441
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1461
1442
.init_phy = imx_pcie_init_phy ,
1443
+ .enable_ref_clk = imx6q_pcie_enable_ref_clk ,
1462
1444
},
1463
1445
[IMX6SX ] = {
1464
1446
.variant = IMX6SX ,
@@ -1473,6 +1455,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
1473
1455
.mode_off [0 ] = IOMUXC_GPR12 ,
1474
1456
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1475
1457
.init_phy = imx6sx_pcie_init_phy ,
1458
+ .enable_ref_clk = imx6sx_pcie_enable_ref_clk ,
1476
1459
},
1477
1460
[IMX6QP ] = {
1478
1461
.variant = IMX6QP ,
@@ -1488,6 +1471,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
1488
1471
.mode_off [0 ] = IOMUXC_GPR12 ,
1489
1472
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1490
1473
.init_phy = imx_pcie_init_phy ,
1474
+ .enable_ref_clk = imx6q_pcie_enable_ref_clk ,
1491
1475
},
1492
1476
[IMX7D ] = {
1493
1477
.variant = IMX7D ,
@@ -1500,6 +1484,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
1500
1484
.mode_off [0 ] = IOMUXC_GPR12 ,
1501
1485
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1502
1486
.init_phy = imx7d_pcie_init_phy ,
1487
+ .enable_ref_clk = imx7d_pcie_enable_ref_clk ,
1503
1488
},
1504
1489
[IMX8MQ ] = {
1505
1490
.variant = IMX8MQ ,
@@ -1513,6 +1498,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
1513
1498
.mode_off [1 ] = IOMUXC_GPR12 ,
1514
1499
.mode_mask [1 ] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE ,
1515
1500
.init_phy = imx8mq_pcie_init_phy ,
1501
+ .enable_ref_clk = imx8mm_pcie_enable_ref_clk ,
1516
1502
},
1517
1503
[IMX8MM ] = {
1518
1504
.variant = IMX8MM ,
@@ -1524,6 +1510,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
1524
1510
.clks_cnt = ARRAY_SIZE (imx8mm_clks ),
1525
1511
.mode_off [0 ] = IOMUXC_GPR12 ,
1526
1512
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1513
+ .enable_ref_clk = imx8mm_pcie_enable_ref_clk ,
1527
1514
},
1528
1515
[IMX8MP ] = {
1529
1516
.variant = IMX8MP ,
@@ -1535,6 +1522,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
1535
1522
.clks_cnt = ARRAY_SIZE (imx8mm_clks ),
1536
1523
.mode_off [0 ] = IOMUXC_GPR12 ,
1537
1524
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1525
+ .enable_ref_clk = imx8mm_pcie_enable_ref_clk ,
1538
1526
},
1539
1527
[IMX95 ] = {
1540
1528
.variant = IMX95 ,
@@ -1561,6 +1549,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
1561
1549
.mode_mask [1 ] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE ,
1562
1550
.epc_features = & imx8m_pcie_epc_features ,
1563
1551
.init_phy = imx8mq_pcie_init_phy ,
1552
+ .enable_ref_clk = imx8mm_pcie_enable_ref_clk ,
1564
1553
},
1565
1554
[IMX8MM_EP ] = {
1566
1555
.variant = IMX8MM_EP ,
@@ -1573,6 +1562,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
1573
1562
.mode_off [0 ] = IOMUXC_GPR12 ,
1574
1563
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1575
1564
.epc_features = & imx8m_pcie_epc_features ,
1565
+ .enable_ref_clk = imx8mm_pcie_enable_ref_clk ,
1576
1566
},
1577
1567
[IMX8MP_EP ] = {
1578
1568
.variant = IMX8MP_EP ,
@@ -1585,6 +1575,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
1585
1575
.mode_off [0 ] = IOMUXC_GPR12 ,
1586
1576
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1587
1577
.epc_features = & imx8m_pcie_epc_features ,
1578
+ .enable_ref_clk = imx8mm_pcie_enable_ref_clk ,
1588
1579
},
1589
1580
[IMX95_EP ] = {
1590
1581
.variant = IMX95_EP ,
0 commit comments