@@ -108,7 +108,6 @@ enum imx_pcie_variants {
108
108
109
109
#define imx_check_flag (pci , val ) (pci->drvdata->flags & val)
110
110
111
- #define IMX_PCIE_MAX_CLKS 6
112
111
#define IMX_PCIE_MAX_INSTANCES 2
113
112
114
113
struct imx_pcie ;
@@ -119,9 +118,6 @@ struct imx_pcie_drvdata {
119
118
u32 flags ;
120
119
int dbi_length ;
121
120
const char * gpr ;
122
- const char * const * clk_names ;
123
- const u32 clks_cnt ;
124
- const u32 clks_optional_cnt ;
125
121
const u32 ltssm_off ;
126
122
const u32 ltssm_mask ;
127
123
const u32 mode_off [IMX_PCIE_MAX_INSTANCES ];
@@ -136,7 +132,8 @@ struct imx_pcie_drvdata {
136
132
struct imx_pcie {
137
133
struct dw_pcie * pci ;
138
134
struct gpio_desc * reset_gpiod ;
139
- struct clk_bulk_data clks [IMX_PCIE_MAX_CLKS ];
135
+ struct clk_bulk_data * clks ;
136
+ int num_clks ;
140
137
struct regmap * iomuxc_gpr ;
141
138
u16 msi_ctrl ;
142
139
u32 controller_id ;
@@ -469,13 +466,14 @@ static int imx_setup_phy_mpll(struct imx_pcie *imx_pcie)
469
466
int mult , div ;
470
467
u16 val ;
471
468
int i ;
469
+ struct clk_bulk_data * clks = imx_pcie -> clks ;
472
470
473
471
if (!(imx_pcie -> drvdata -> flags & IMX_PCIE_FLAG_IMX_PHY ))
474
472
return 0 ;
475
473
476
- for (i = 0 ; i < imx_pcie -> drvdata -> clks_cnt ; i ++ )
477
- if (strncmp (imx_pcie -> clks [i ].id , "pcie_phy" , 8 ) == 0 )
478
- phy_rate = clk_get_rate (imx_pcie -> clks [i ].clk );
474
+ for (i = 0 ; i < imx_pcie -> num_clks ; i ++ )
475
+ if (strncmp (clks [i ].id , "pcie_phy" , 8 ) == 0 )
476
+ phy_rate = clk_get_rate (clks [i ].clk );
479
477
480
478
switch (phy_rate ) {
481
479
case 125000000 :
@@ -667,7 +665,7 @@ static int imx_pcie_clk_enable(struct imx_pcie *imx_pcie)
667
665
struct device * dev = pci -> dev ;
668
666
int ret ;
669
667
670
- ret = clk_bulk_prepare_enable (imx_pcie -> drvdata -> clks_cnt , imx_pcie -> clks );
668
+ ret = clk_bulk_prepare_enable (imx_pcie -> num_clks , imx_pcie -> clks );
671
669
if (ret )
672
670
return ret ;
673
671
@@ -684,7 +682,7 @@ static int imx_pcie_clk_enable(struct imx_pcie *imx_pcie)
684
682
return 0 ;
685
683
686
684
err_ref_clk :
687
- clk_bulk_disable_unprepare (imx_pcie -> drvdata -> clks_cnt , imx_pcie -> clks );
685
+ clk_bulk_disable_unprepare (imx_pcie -> num_clks , imx_pcie -> clks );
688
686
689
687
return ret ;
690
688
}
@@ -693,7 +691,7 @@ static void imx_pcie_clk_disable(struct imx_pcie *imx_pcie)
693
691
{
694
692
if (imx_pcie -> drvdata -> enable_ref_clk )
695
693
imx_pcie -> drvdata -> enable_ref_clk (imx_pcie , false);
696
- clk_bulk_disable_unprepare (imx_pcie -> drvdata -> clks_cnt , imx_pcie -> clks );
694
+ clk_bulk_disable_unprepare (imx_pcie -> num_clks , imx_pcie -> clks );
697
695
}
698
696
699
697
static int imx6sx_pcie_core_reset (struct imx_pcie * imx_pcie , bool assert )
@@ -1474,7 +1472,7 @@ static int imx_pcie_probe(struct platform_device *pdev)
1474
1472
struct imx_pcie * imx_pcie ;
1475
1473
struct device_node * np ;
1476
1474
struct device_node * node = dev -> of_node ;
1477
- int i , ret , req_cnt , domain ;
1475
+ int ret , domain ;
1478
1476
u16 val ;
1479
1477
1480
1478
imx_pcie = devm_kzalloc (dev , sizeof (* imx_pcie ), GFP_KERNEL );
@@ -1520,20 +1518,11 @@ static int imx_pcie_probe(struct platform_device *pdev)
1520
1518
"unable to get reset gpio\n" );
1521
1519
gpiod_set_consumer_name (imx_pcie -> reset_gpiod , "PCIe reset" );
1522
1520
1523
- if (imx_pcie -> drvdata -> clks_cnt >= IMX_PCIE_MAX_CLKS )
1524
- return dev_err_probe (dev , - ENOMEM , "clks_cnt is too big\n" );
1525
-
1526
- for (i = 0 ; i < imx_pcie -> drvdata -> clks_cnt ; i ++ )
1527
- imx_pcie -> clks [i ].id = imx_pcie -> drvdata -> clk_names [i ];
1528
-
1529
1521
/* Fetch clocks */
1530
- req_cnt = imx_pcie -> drvdata -> clks_cnt - imx_pcie -> drvdata -> clks_optional_cnt ;
1531
- ret = devm_clk_bulk_get (dev , req_cnt , imx_pcie -> clks );
1532
- if (ret )
1533
- return ret ;
1534
- imx_pcie -> clks [req_cnt ].clk = devm_clk_get_optional (dev , "ref" );
1535
- if (IS_ERR (imx_pcie -> clks [req_cnt ].clk ))
1536
- return PTR_ERR (imx_pcie -> clks [req_cnt ].clk );
1522
+ imx_pcie -> num_clks = devm_clk_bulk_get_all (dev , & imx_pcie -> clks );
1523
+ if (imx_pcie -> num_clks < 0 )
1524
+ return dev_err_probe (dev , imx_pcie -> num_clks ,
1525
+ "failed to get clocks\n" );
1537
1526
1538
1527
if (imx_check_flag (imx_pcie , IMX_PCIE_FLAG_HAS_PHYDRV )) {
1539
1528
imx_pcie -> phy = devm_phy_get (dev , "pcie-phy" );
@@ -1672,13 +1661,6 @@ static void imx_pcie_shutdown(struct platform_device *pdev)
1672
1661
imx_pcie_assert_core_reset (imx_pcie );
1673
1662
}
1674
1663
1675
- static const char * const imx6q_clks [] = {"pcie_bus" , "pcie" , "pcie_phy" };
1676
- static const char * const imx8mm_clks [] = {"pcie_bus" , "pcie" , "pcie_aux" };
1677
- static const char * const imx8mq_clks [] = {"pcie_bus" , "pcie" , "pcie_phy" , "pcie_aux" };
1678
- static const char * const imx6sx_clks [] = {"pcie_bus" , "pcie" , "pcie_phy" , "pcie_inbound_axi" };
1679
- static const char * const imx8q_clks [] = {"mstr" , "slv" , "dbi" };
1680
- static const char * const imx95_clks [] = {"pcie_bus" , "pcie" , "pcie_phy" , "pcie_aux" , "ref" };
1681
-
1682
1664
static const struct imx_pcie_drvdata drvdata [] = {
1683
1665
[IMX6Q ] = {
1684
1666
.variant = IMX6Q ,
@@ -1688,8 +1670,6 @@ static const struct imx_pcie_drvdata drvdata[] = {
1688
1670
IMX_PCIE_FLAG_SUPPORTS_SUSPEND ,
1689
1671
.dbi_length = 0x200 ,
1690
1672
.gpr = "fsl,imx6q-iomuxc-gpr" ,
1691
- .clk_names = imx6q_clks ,
1692
- .clks_cnt = ARRAY_SIZE (imx6q_clks ),
1693
1673
.ltssm_off = IOMUXC_GPR12 ,
1694
1674
.ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2 ,
1695
1675
.mode_off [0 ] = IOMUXC_GPR12 ,
@@ -1704,8 +1684,6 @@ static const struct imx_pcie_drvdata drvdata[] = {
1704
1684
IMX_PCIE_FLAG_IMX_SPEED_CHANGE |
1705
1685
IMX_PCIE_FLAG_SUPPORTS_SUSPEND ,
1706
1686
.gpr = "fsl,imx6q-iomuxc-gpr" ,
1707
- .clk_names = imx6sx_clks ,
1708
- .clks_cnt = ARRAY_SIZE (imx6sx_clks ),
1709
1687
.ltssm_off = IOMUXC_GPR12 ,
1710
1688
.ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2 ,
1711
1689
.mode_off [0 ] = IOMUXC_GPR12 ,
@@ -1722,8 +1700,6 @@ static const struct imx_pcie_drvdata drvdata[] = {
1722
1700
IMX_PCIE_FLAG_SUPPORTS_SUSPEND ,
1723
1701
.dbi_length = 0x200 ,
1724
1702
.gpr = "fsl,imx6q-iomuxc-gpr" ,
1725
- .clk_names = imx6q_clks ,
1726
- .clks_cnt = ARRAY_SIZE (imx6q_clks ),
1727
1703
.ltssm_off = IOMUXC_GPR12 ,
1728
1704
.ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2 ,
1729
1705
.mode_off [0 ] = IOMUXC_GPR12 ,
@@ -1739,8 +1715,6 @@ static const struct imx_pcie_drvdata drvdata[] = {
1739
1715
IMX_PCIE_FLAG_HAS_APP_RESET |
1740
1716
IMX_PCIE_FLAG_HAS_PHY_RESET ,
1741
1717
.gpr = "fsl,imx7d-iomuxc-gpr" ,
1742
- .clk_names = imx6q_clks ,
1743
- .clks_cnt = ARRAY_SIZE (imx6q_clks ),
1744
1718
.mode_off [0 ] = IOMUXC_GPR12 ,
1745
1719
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1746
1720
.enable_ref_clk = imx7d_pcie_enable_ref_clk ,
@@ -1752,8 +1726,6 @@ static const struct imx_pcie_drvdata drvdata[] = {
1752
1726
IMX_PCIE_FLAG_HAS_PHY_RESET |
1753
1727
IMX_PCIE_FLAG_SUPPORTS_SUSPEND ,
1754
1728
.gpr = "fsl,imx8mq-iomuxc-gpr" ,
1755
- .clk_names = imx8mq_clks ,
1756
- .clks_cnt = ARRAY_SIZE (imx8mq_clks ),
1757
1729
.mode_off [0 ] = IOMUXC_GPR12 ,
1758
1730
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1759
1731
.mode_off [1 ] = IOMUXC_GPR12 ,
@@ -1767,8 +1739,6 @@ static const struct imx_pcie_drvdata drvdata[] = {
1767
1739
IMX_PCIE_FLAG_HAS_PHYDRV |
1768
1740
IMX_PCIE_FLAG_HAS_APP_RESET ,
1769
1741
.gpr = "fsl,imx8mm-iomuxc-gpr" ,
1770
- .clk_names = imx8mm_clks ,
1771
- .clks_cnt = ARRAY_SIZE (imx8mm_clks ),
1772
1742
.mode_off [0 ] = IOMUXC_GPR12 ,
1773
1743
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1774
1744
.enable_ref_clk = imx8mm_pcie_enable_ref_clk ,
@@ -1779,8 +1749,6 @@ static const struct imx_pcie_drvdata drvdata[] = {
1779
1749
IMX_PCIE_FLAG_HAS_PHYDRV |
1780
1750
IMX_PCIE_FLAG_HAS_APP_RESET ,
1781
1751
.gpr = "fsl,imx8mp-iomuxc-gpr" ,
1782
- .clk_names = imx8mm_clks ,
1783
- .clks_cnt = ARRAY_SIZE (imx8mm_clks ),
1784
1752
.mode_off [0 ] = IOMUXC_GPR12 ,
1785
1753
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1786
1754
.enable_ref_clk = imx8mm_pcie_enable_ref_clk ,
@@ -1790,17 +1758,12 @@ static const struct imx_pcie_drvdata drvdata[] = {
1790
1758
.flags = IMX_PCIE_FLAG_HAS_PHYDRV |
1791
1759
IMX_PCIE_FLAG_CPU_ADDR_FIXUP |
1792
1760
IMX_PCIE_FLAG_SUPPORTS_SUSPEND ,
1793
- .clk_names = imx8q_clks ,
1794
- .clks_cnt = ARRAY_SIZE (imx8q_clks ),
1795
1761
},
1796
1762
[IMX95 ] = {
1797
1763
.variant = IMX95 ,
1798
1764
.flags = IMX_PCIE_FLAG_HAS_SERDES |
1799
1765
IMX_PCIE_FLAG_HAS_LUT |
1800
1766
IMX_PCIE_FLAG_SUPPORTS_SUSPEND ,
1801
- .clk_names = imx95_clks ,
1802
- .clks_cnt = ARRAY_SIZE (imx95_clks ),
1803
- .clks_optional_cnt = 1 ,
1804
1767
.ltssm_off = IMX95_PE0_GEN_CTRL_3 ,
1805
1768
.ltssm_mask = IMX95_PCIE_LTSSM_EN ,
1806
1769
.mode_off [0 ] = IMX95_PE0_GEN_CTRL_1 ,
@@ -1813,8 +1776,6 @@ static const struct imx_pcie_drvdata drvdata[] = {
1813
1776
IMX_PCIE_FLAG_HAS_PHY_RESET ,
1814
1777
.mode = DW_PCIE_EP_TYPE ,
1815
1778
.gpr = "fsl,imx8mq-iomuxc-gpr" ,
1816
- .clk_names = imx8mq_clks ,
1817
- .clks_cnt = ARRAY_SIZE (imx8mq_clks ),
1818
1779
.mode_off [0 ] = IOMUXC_GPR12 ,
1819
1780
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1820
1781
.mode_off [1 ] = IOMUXC_GPR12 ,
@@ -1829,8 +1790,6 @@ static const struct imx_pcie_drvdata drvdata[] = {
1829
1790
IMX_PCIE_FLAG_HAS_PHYDRV ,
1830
1791
.mode = DW_PCIE_EP_TYPE ,
1831
1792
.gpr = "fsl,imx8mm-iomuxc-gpr" ,
1832
- .clk_names = imx8mm_clks ,
1833
- .clks_cnt = ARRAY_SIZE (imx8mm_clks ),
1834
1793
.mode_off [0 ] = IOMUXC_GPR12 ,
1835
1794
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1836
1795
.epc_features = & imx8m_pcie_epc_features ,
@@ -1842,8 +1801,6 @@ static const struct imx_pcie_drvdata drvdata[] = {
1842
1801
IMX_PCIE_FLAG_HAS_PHYDRV ,
1843
1802
.mode = DW_PCIE_EP_TYPE ,
1844
1803
.gpr = "fsl,imx8mp-iomuxc-gpr" ,
1845
- .clk_names = imx8mm_clks ,
1846
- .clks_cnt = ARRAY_SIZE (imx8mm_clks ),
1847
1804
.mode_off [0 ] = IOMUXC_GPR12 ,
1848
1805
.mode_mask [0 ] = IMX6Q_GPR12_DEVICE_TYPE ,
1849
1806
.epc_features = & imx8m_pcie_epc_features ,
@@ -1854,15 +1811,11 @@ static const struct imx_pcie_drvdata drvdata[] = {
1854
1811
.flags = IMX_PCIE_FLAG_HAS_PHYDRV ,
1855
1812
.mode = DW_PCIE_EP_TYPE ,
1856
1813
.epc_features = & imx8q_pcie_epc_features ,
1857
- .clk_names = imx8q_clks ,
1858
- .clks_cnt = ARRAY_SIZE (imx8q_clks ),
1859
1814
},
1860
1815
[IMX95_EP ] = {
1861
1816
.variant = IMX95_EP ,
1862
1817
.flags = IMX_PCIE_FLAG_HAS_SERDES |
1863
1818
IMX_PCIE_FLAG_SUPPORT_64BIT ,
1864
- .clk_names = imx8mq_clks ,
1865
- .clks_cnt = ARRAY_SIZE (imx8mq_clks ),
1866
1819
.ltssm_off = IMX95_PE0_GEN_CTRL_3 ,
1867
1820
.ltssm_mask = IMX95_PCIE_LTSSM_EN ,
1868
1821
.mode_off [0 ] = IMX95_PE0_GEN_CTRL_1 ,
0 commit comments