@@ -161,7 +161,7 @@ struct qcom_pcie_resources_2_3_3 {
161161
162162/* 6 clocks typically, 7 for sm8250 */
163163struct qcom_pcie_resources_2_7_0 {
164- struct clk_bulk_data clks [7 ];
164+ struct clk_bulk_data clks [9 ];
165165 int num_clks ;
166166 struct regulator_bulk_data supplies [2 ];
167167 struct reset_control * pci_reset ;
@@ -195,6 +195,10 @@ struct qcom_pcie_ops {
195195struct qcom_pcie_cfg {
196196 const struct qcom_pcie_ops * ops ;
197197 unsigned int pipe_clk_need_muxing :1 ;
198+ unsigned int has_tbu_clk :1 ;
199+ unsigned int has_ddrss_sf_tbu_clk :1 ;
200+ unsigned int has_aggre0_clk :1 ;
201+ unsigned int has_aggre1_clk :1 ;
198202};
199203
200204struct qcom_pcie {
@@ -204,8 +208,7 @@ struct qcom_pcie {
204208 union qcom_pcie_resources res ;
205209 struct phy * phy ;
206210 struct gpio_desc * reset ;
207- const struct qcom_pcie_ops * ops ;
208- unsigned int pipe_clk_need_muxing :1 ;
211+ const struct qcom_pcie_cfg * cfg ;
209212};
210213
211214#define to_qcom_pcie (x ) dev_get_drvdata((x)->dev)
@@ -229,8 +232,8 @@ static int qcom_pcie_start_link(struct dw_pcie *pci)
229232 struct qcom_pcie * pcie = to_qcom_pcie (pci );
230233
231234 /* Enable Link Training state machine */
232- if (pcie -> ops -> ltssm_enable )
233- pcie -> ops -> ltssm_enable (pcie );
235+ if (pcie -> cfg -> ops -> ltssm_enable )
236+ pcie -> cfg -> ops -> ltssm_enable (pcie );
234237
235238 return 0 ;
236239}
@@ -1146,6 +1149,7 @@ static int qcom_pcie_get_resources_2_7_0(struct qcom_pcie *pcie)
11461149 struct qcom_pcie_resources_2_7_0 * res = & pcie -> res .v2_7_0 ;
11471150 struct dw_pcie * pci = pcie -> pci ;
11481151 struct device * dev = pci -> dev ;
1152+ unsigned int idx ;
11491153 int ret ;
11501154
11511155 res -> pci_reset = devm_reset_control_get_exclusive (dev , "pci" );
@@ -1159,24 +1163,28 @@ static int qcom_pcie_get_resources_2_7_0(struct qcom_pcie *pcie)
11591163 if (ret )
11601164 return ret ;
11611165
1162- res -> clks [0 ].id = "aux" ;
1163- res -> clks [1 ].id = "cfg" ;
1164- res -> clks [2 ].id = "bus_master" ;
1165- res -> clks [3 ].id = "bus_slave" ;
1166- res -> clks [4 ].id = "slave_q2a" ;
1167- res -> clks [5 ].id = "tbu" ;
1168- if (of_device_is_compatible (dev -> of_node , "qcom,pcie-sm8250" )) {
1169- res -> clks [6 ].id = "ddrss_sf_tbu" ;
1170- res -> num_clks = 7 ;
1171- } else {
1172- res -> num_clks = 6 ;
1173- }
1166+ idx = 0 ;
1167+ res -> clks [idx ++ ].id = "aux" ;
1168+ res -> clks [idx ++ ].id = "cfg" ;
1169+ res -> clks [idx ++ ].id = "bus_master" ;
1170+ res -> clks [idx ++ ].id = "bus_slave" ;
1171+ res -> clks [idx ++ ].id = "slave_q2a" ;
1172+ if (pcie -> cfg -> has_tbu_clk )
1173+ res -> clks [idx ++ ].id = "tbu" ;
1174+ if (pcie -> cfg -> has_ddrss_sf_tbu_clk )
1175+ res -> clks [idx ++ ].id = "ddrss_sf_tbu" ;
1176+ if (pcie -> cfg -> has_aggre0_clk )
1177+ res -> clks [idx ++ ].id = "aggre0" ;
1178+ if (pcie -> cfg -> has_aggre1_clk )
1179+ res -> clks [idx ++ ].id = "aggre1" ;
1180+
1181+ res -> num_clks = idx ;
11741182
11751183 ret = devm_clk_bulk_get (dev , res -> num_clks , res -> clks );
11761184 if (ret < 0 )
11771185 return ret ;
11781186
1179- if (pcie -> pipe_clk_need_muxing ) {
1187+ if (pcie -> cfg -> pipe_clk_need_muxing ) {
11801188 res -> pipe_clk_src = devm_clk_get (dev , "pipe_mux" );
11811189 if (IS_ERR (res -> pipe_clk_src ))
11821190 return PTR_ERR (res -> pipe_clk_src );
@@ -1209,7 +1217,7 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie)
12091217 }
12101218
12111219 /* Set TCXO as clock source for pcie_pipe_clk_src */
1212- if (pcie -> pipe_clk_need_muxing )
1220+ if (pcie -> cfg -> pipe_clk_need_muxing )
12131221 clk_set_parent (res -> pipe_clk_src , res -> ref_clk_src );
12141222
12151223 ret = clk_bulk_prepare_enable (res -> num_clks , res -> clks );
@@ -1236,6 +1244,9 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie)
12361244 goto err_disable_clocks ;
12371245 }
12381246
1247+ /* Wait for reset to complete, required on SM8450 */
1248+ usleep_range (1000 , 1500 );
1249+
12391250 /* configure PCIe to RC mode */
12401251 writel (DEVICE_TYPE_RC , pcie -> parf + PCIE20_PARF_DEVICE_TYPE );
12411252
@@ -1284,7 +1295,7 @@ static int qcom_pcie_post_init_2_7_0(struct qcom_pcie *pcie)
12841295 struct qcom_pcie_resources_2_7_0 * res = & pcie -> res .v2_7_0 ;
12851296
12861297 /* Set pipe clock as clock source for pcie_pipe_clk_src */
1287- if (pcie -> pipe_clk_need_muxing )
1298+ if (pcie -> cfg -> pipe_clk_need_muxing )
12881299 clk_set_parent (res -> pipe_clk_src , res -> phy_pipe_clk );
12891300
12901301 return clk_prepare_enable (res -> pipe_clk );
@@ -1384,24 +1395,24 @@ static int qcom_pcie_host_init(struct pcie_port *pp)
13841395
13851396 qcom_ep_reset_assert (pcie );
13861397
1387- ret = pcie -> ops -> init (pcie );
1398+ ret = pcie -> cfg -> ops -> init (pcie );
13881399 if (ret )
13891400 return ret ;
13901401
13911402 ret = phy_power_on (pcie -> phy );
13921403 if (ret )
13931404 goto err_deinit ;
13941405
1395- if (pcie -> ops -> post_init ) {
1396- ret = pcie -> ops -> post_init (pcie );
1406+ if (pcie -> cfg -> ops -> post_init ) {
1407+ ret = pcie -> cfg -> ops -> post_init (pcie );
13971408 if (ret )
13981409 goto err_disable_phy ;
13991410 }
14001411
14011412 qcom_ep_reset_deassert (pcie );
14021413
1403- if (pcie -> ops -> config_sid ) {
1404- ret = pcie -> ops -> config_sid (pcie );
1414+ if (pcie -> cfg -> ops -> config_sid ) {
1415+ ret = pcie -> cfg -> ops -> config_sid (pcie );
14051416 if (ret )
14061417 goto err ;
14071418 }
@@ -1410,12 +1421,12 @@ static int qcom_pcie_host_init(struct pcie_port *pp)
14101421
14111422err :
14121423 qcom_ep_reset_assert (pcie );
1413- if (pcie -> ops -> post_deinit )
1414- pcie -> ops -> post_deinit (pcie );
1424+ if (pcie -> cfg -> ops -> post_deinit )
1425+ pcie -> cfg -> ops -> post_deinit (pcie );
14151426err_disable_phy :
14161427 phy_power_off (pcie -> phy );
14171428err_deinit :
1418- pcie -> ops -> deinit (pcie );
1429+ pcie -> cfg -> ops -> deinit (pcie );
14191430
14201431 return ret ;
14211432}
@@ -1509,14 +1520,33 @@ static const struct qcom_pcie_cfg ipq4019_cfg = {
15091520
15101521static const struct qcom_pcie_cfg sdm845_cfg = {
15111522 .ops = & ops_2_7_0 ,
1523+ .has_tbu_clk = true,
15121524};
15131525
15141526static const struct qcom_pcie_cfg sm8250_cfg = {
15151527 .ops = & ops_1_9_0 ,
1528+ .has_tbu_clk = true,
1529+ .has_ddrss_sf_tbu_clk = true,
1530+ };
1531+
1532+ static const struct qcom_pcie_cfg sm8450_pcie0_cfg = {
1533+ .ops = & ops_1_9_0 ,
1534+ .has_ddrss_sf_tbu_clk = true,
1535+ .pipe_clk_need_muxing = true,
1536+ .has_aggre0_clk = true,
1537+ .has_aggre1_clk = true,
1538+ };
1539+
1540+ static const struct qcom_pcie_cfg sm8450_pcie1_cfg = {
1541+ .ops = & ops_1_9_0 ,
1542+ .has_ddrss_sf_tbu_clk = true,
1543+ .pipe_clk_need_muxing = true,
1544+ .has_aggre1_clk = true,
15161545};
15171546
15181547static const struct qcom_pcie_cfg sc7280_cfg = {
15191548 .ops = & ops_1_9_0 ,
1549+ .has_tbu_clk = true,
15201550 .pipe_clk_need_muxing = true,
15211551};
15221552
@@ -1559,8 +1589,7 @@ static int qcom_pcie_probe(struct platform_device *pdev)
15591589
15601590 pcie -> pci = pci ;
15611591
1562- pcie -> ops = pcie_cfg -> ops ;
1563- pcie -> pipe_clk_need_muxing = pcie_cfg -> pipe_clk_need_muxing ;
1592+ pcie -> cfg = pcie_cfg ;
15641593
15651594 pcie -> reset = devm_gpiod_get_optional (dev , "perst" , GPIOD_OUT_HIGH );
15661595 if (IS_ERR (pcie -> reset )) {
@@ -1586,7 +1615,7 @@ static int qcom_pcie_probe(struct platform_device *pdev)
15861615 goto err_pm_runtime_put ;
15871616 }
15881617
1589- ret = pcie -> ops -> get_resources (pcie );
1618+ ret = pcie -> cfg -> ops -> get_resources (pcie );
15901619 if (ret )
15911620 goto err_pm_runtime_put ;
15921621
@@ -1628,6 +1657,8 @@ static const struct of_device_id qcom_pcie_match[] = {
16281657 { .compatible = "qcom,pcie-sdm845" , .data = & sdm845_cfg },
16291658 { .compatible = "qcom,pcie-sm8250" , .data = & sm8250_cfg },
16301659 { .compatible = "qcom,pcie-sc8180x" , .data = & sm8250_cfg },
1660+ { .compatible = "qcom,pcie-sm8450-pcie0" , .data = & sm8450_pcie0_cfg },
1661+ { .compatible = "qcom,pcie-sm8450-pcie1" , .data = & sm8450_pcie1_cfg },
16311662 { .compatible = "qcom,pcie-sc7280" , .data = & sc7280_cfg },
16321663 { }
16331664};
0 commit comments