Skip to content

Commit d97ab9e

Browse files
committed
Merge branch 'pci/controller/speed'
- Use PCIE_SPEED2MBS_ENC() macro in qcom host and endpoint to encode link speed instead of hard-coding the link speed in MBps (Manivannan Sadhasivam) - Use Mbps_to_icc() (not MBps_to_icc()) in tegra194 instead of explicitly doing the bytes-to-bits conversion (Manivannan Sadhasivam) * pci/controller/speed: PCI: tegra194: Use Mbps_to_icc() macro for setting icc speed PCI: qcom-ep: Use PCIE_SPEED2MBS_ENC() macro for encoding link speed PCI: qcom: Use PCIE_SPEED2MBS_ENC() macro for encoding link speed
2 parents db20113 + 85e9eb3 commit d97ab9e

File tree

3 files changed

+14
-45
lines changed

3 files changed

+14
-45
lines changed

drivers/pci/controller/dwc/pcie-qcom-ep.c

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/reset.h>
2424
#include <linux/module.h>
2525

26+
#include "../../pci.h"
2627
#include "pcie-designware.h"
2728

2829
/* PARF registers */
@@ -136,10 +137,8 @@
136137
#define CORE_RESET_TIME_US_MAX 1005
137138
#define WAKE_DELAY_US 2000 /* 2 ms */
138139

139-
#define PCIE_GEN1_BW_MBPS 250
140-
#define PCIE_GEN2_BW_MBPS 500
141-
#define PCIE_GEN3_BW_MBPS 985
142-
#define PCIE_GEN4_BW_MBPS 1969
140+
#define QCOM_PCIE_LINK_SPEED_TO_BW(speed) \
141+
Mbps_to_icc(PCIE_SPEED2MBS_ENC(pcie_link_speed[speed]))
143142

144143
#define to_pcie_ep(x) dev_get_drvdata((x)->dev)
145144

@@ -282,7 +281,7 @@ static void qcom_pcie_dw_write_dbi2(struct dw_pcie *pci, void __iomem *base,
282281
static void qcom_pcie_ep_icc_update(struct qcom_pcie_ep *pcie_ep)
283282
{
284283
struct dw_pcie *pci = &pcie_ep->pci;
285-
u32 offset, status, bw;
284+
u32 offset, status;
286285
int speed, width;
287286
int ret;
288287

@@ -295,25 +294,7 @@ static void qcom_pcie_ep_icc_update(struct qcom_pcie_ep *pcie_ep)
295294
speed = FIELD_GET(PCI_EXP_LNKSTA_CLS, status);
296295
width = FIELD_GET(PCI_EXP_LNKSTA_NLW, status);
297296

298-
switch (speed) {
299-
case 1:
300-
bw = MBps_to_icc(PCIE_GEN1_BW_MBPS);
301-
break;
302-
case 2:
303-
bw = MBps_to_icc(PCIE_GEN2_BW_MBPS);
304-
break;
305-
case 3:
306-
bw = MBps_to_icc(PCIE_GEN3_BW_MBPS);
307-
break;
308-
default:
309-
dev_warn(pci->dev, "using default GEN4 bandwidth\n");
310-
fallthrough;
311-
case 4:
312-
bw = MBps_to_icc(PCIE_GEN4_BW_MBPS);
313-
break;
314-
}
315-
316-
ret = icc_set_bw(pcie_ep->icc_mem, 0, width * bw);
297+
ret = icc_set_bw(pcie_ep->icc_mem, 0, width * QCOM_PCIE_LINK_SPEED_TO_BW(speed));
317298
if (ret)
318299
dev_err(pci->dev, "failed to set interconnect bandwidth: %d\n",
319300
ret);
@@ -351,7 +332,7 @@ static int qcom_pcie_enable_resources(struct qcom_pcie_ep *pcie_ep)
351332
* Set an initial peak bandwidth corresponding to single-lane Gen 1
352333
* for the pcie-mem path.
353334
*/
354-
ret = icc_set_bw(pcie_ep->icc_mem, 0, MBps_to_icc(PCIE_GEN1_BW_MBPS));
335+
ret = icc_set_bw(pcie_ep->icc_mem, 0, QCOM_PCIE_LINK_SPEED_TO_BW(1));
355336
if (ret) {
356337
dev_err(pci->dev, "failed to set interconnect bandwidth: %d\n",
357338
ret);

drivers/pci/controller/dwc/pcie-qcom.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@
148148

149149
#define QCOM_PCIE_CRC8_POLYNOMIAL (BIT(2) | BIT(1) | BIT(0))
150150

151+
#define QCOM_PCIE_LINK_SPEED_TO_BW(speed) \
152+
Mbps_to_icc(PCIE_SPEED2MBS_ENC(pcie_link_speed[speed]))
153+
151154
#define QCOM_PCIE_1_0_0_MAX_CLOCKS 4
152155
struct qcom_pcie_resources_1_0_0 {
153156
struct clk_bulk_data clks[QCOM_PCIE_1_0_0_MAX_CLOCKS];
@@ -1375,7 +1378,7 @@ static int qcom_pcie_icc_init(struct qcom_pcie *pcie)
13751378
* Set an initial peak bandwidth corresponding to single-lane Gen 1
13761379
* for the pcie-mem path.
13771380
*/
1378-
ret = icc_set_bw(pcie->icc_mem, 0, MBps_to_icc(250));
1381+
ret = icc_set_bw(pcie->icc_mem, 0, QCOM_PCIE_LINK_SPEED_TO_BW(1));
13791382
if (ret) {
13801383
dev_err(pci->dev, "failed to set interconnect bandwidth: %d\n",
13811384
ret);
@@ -1388,7 +1391,7 @@ static int qcom_pcie_icc_init(struct qcom_pcie *pcie)
13881391
static void qcom_pcie_icc_update(struct qcom_pcie *pcie)
13891392
{
13901393
struct dw_pcie *pci = pcie->pci;
1391-
u32 offset, status, bw;
1394+
u32 offset, status;
13921395
int speed, width;
13931396
int ret;
13941397

@@ -1405,22 +1408,7 @@ static void qcom_pcie_icc_update(struct qcom_pcie *pcie)
14051408
speed = FIELD_GET(PCI_EXP_LNKSTA_CLS, status);
14061409
width = FIELD_GET(PCI_EXP_LNKSTA_NLW, status);
14071410

1408-
switch (speed) {
1409-
case 1:
1410-
bw = MBps_to_icc(250);
1411-
break;
1412-
case 2:
1413-
bw = MBps_to_icc(500);
1414-
break;
1415-
default:
1416-
WARN_ON_ONCE(1);
1417-
fallthrough;
1418-
case 3:
1419-
bw = MBps_to_icc(985);
1420-
break;
1421-
}
1422-
1423-
ret = icc_set_bw(pcie->icc_mem, 0, width * bw);
1411+
ret = icc_set_bw(pcie->icc_mem, 0, width * QCOM_PCIE_LINK_SPEED_TO_BW(speed));
14241412
if (ret) {
14251413
dev_err(pci->dev, "failed to set interconnect bandwidth: %d\n",
14261414
ret);

drivers/pci/controller/dwc/pcie-tegra194.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ static void tegra_pcie_icc_set(struct tegra_pcie_dw *pcie)
321321
speed = FIELD_GET(PCI_EXP_LNKSTA_CLS, val);
322322
width = FIELD_GET(PCI_EXP_LNKSTA_NLW, val);
323323

324-
val = width * (PCIE_SPEED2MBS_ENC(pcie_link_speed[speed]) / BITS_PER_BYTE);
324+
val = width * PCIE_SPEED2MBS_ENC(pcie_link_speed[speed]);
325325

326-
if (icc_set_bw(pcie->icc_path, MBps_to_icc(val), 0))
326+
if (icc_set_bw(pcie->icc_path, Mbps_to_icc(val), 0))
327327
dev_err(pcie->dev, "can't set bw[%u]\n", val);
328328

329329
if (speed >= ARRAY_SIZE(pcie_gen_freq))

0 commit comments

Comments
 (0)