Skip to content

Commit fefb75d

Browse files
committed
Merge branch 'remotes/lorenzo/pci/dwc'
- Use dmam_alloc_coherent() instead of dma_map_page() to allocate the MSI target page, which means dwc drivers will work even when ZONE_DMA32 is disabled (Will McVicker) - If we can't allocate an MSI target page with a 32-bit address, try allocating one with a 64-bit address (Will McVicker) - Switch from of_gpio_named_count() to generic gpiod_count() (Andy Shevchenko) - Add support for i.MX8MP PCIe (Richard Zhu) - Fix the Freescale i.MX8 PHY driver, which had interchanged the phy_init() and phy_power_on() interfaces (Richard Zhu) * remotes/lorenzo/pci/dwc: phy: freescale: imx8m-pcie: Fix the wrong order of phy_init() and phy_power_on() PCI: imx6: Add i.MX8MP PCIe support PCI: dwc: Replace of_gpio_named_count() by gpiod_count() PCI: dwc: Drop dependency on ZONE_DMA32
2 parents 3de810a + cbcf872 commit fefb75d

File tree

5 files changed

+41
-33
lines changed

5 files changed

+41
-33
lines changed

drivers/pci/controller/dwc/pci-imx6.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ enum imx6_pcie_variants {
5151
IMX7D,
5252
IMX8MQ,
5353
IMX8MM,
54+
IMX8MP,
5455
};
5556

5657
#define IMX6_PCIE_FLAG_IMX6_PHY BIT(0)
@@ -61,6 +62,7 @@ struct imx6_pcie_drvdata {
6162
enum imx6_pcie_variants variant;
6263
u32 flags;
6364
int dbi_length;
65+
const char *gpr;
6466
};
6567

6668
struct imx6_pcie {
@@ -150,7 +152,8 @@ struct imx6_pcie {
150152
static unsigned int imx6_pcie_grp_offset(const struct imx6_pcie *imx6_pcie)
151153
{
152154
WARN_ON(imx6_pcie->drvdata->variant != IMX8MQ &&
153-
imx6_pcie->drvdata->variant != IMX8MM);
155+
imx6_pcie->drvdata->variant != IMX8MM &&
156+
imx6_pcie->drvdata->variant != IMX8MP);
154157
return imx6_pcie->controller_id == 1 ? IOMUXC_GPR16 : IOMUXC_GPR14;
155158
}
156159

@@ -301,6 +304,7 @@ static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie)
301304
{
302305
switch (imx6_pcie->drvdata->variant) {
303306
case IMX8MM:
307+
case IMX8MP:
304308
/*
305309
* The PHY initialization had been done in the PHY
306310
* driver, break here directly.
@@ -558,6 +562,7 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie)
558562
break;
559563
case IMX8MM:
560564
case IMX8MQ:
565+
case IMX8MP:
561566
ret = clk_prepare_enable(imx6_pcie->pcie_aux);
562567
if (ret) {
563568
dev_err(dev, "unable to enable pcie_aux clock\n");
@@ -602,6 +607,7 @@ static void imx6_pcie_disable_ref_clk(struct imx6_pcie *imx6_pcie)
602607
break;
603608
case IMX8MM:
604609
case IMX8MQ:
610+
case IMX8MP:
605611
clk_disable_unprepare(imx6_pcie->pcie_aux);
606612
break;
607613
default:
@@ -669,6 +675,7 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)
669675
reset_control_assert(imx6_pcie->pciephy_reset);
670676
fallthrough;
671677
case IMX8MM:
678+
case IMX8MP:
672679
reset_control_assert(imx6_pcie->apps_reset);
673680
break;
674681
case IMX6SX:
@@ -744,6 +751,7 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
744751
break;
745752
case IMX6Q: /* Nothing to do */
746753
case IMX8MM:
754+
case IMX8MP:
747755
break;
748756
}
749757

@@ -793,6 +801,7 @@ static void imx6_pcie_ltssm_enable(struct device *dev)
793801
case IMX7D:
794802
case IMX8MQ:
795803
case IMX8MM:
804+
case IMX8MP:
796805
reset_control_deassert(imx6_pcie->apps_reset);
797806
break;
798807
}
@@ -812,6 +821,7 @@ static void imx6_pcie_ltssm_disable(struct device *dev)
812821
case IMX7D:
813822
case IMX8MQ:
814823
case IMX8MM:
824+
case IMX8MP:
815825
reset_control_assert(imx6_pcie->apps_reset);
816826
break;
817827
}
@@ -935,7 +945,7 @@ static int imx6_pcie_host_init(struct dw_pcie_rp *pp)
935945
}
936946

937947
if (imx6_pcie->phy) {
938-
ret = phy_power_on(imx6_pcie->phy);
948+
ret = phy_init(imx6_pcie->phy);
939949
if (ret) {
940950
dev_err(dev, "pcie PHY power up failed\n");
941951
goto err_clk_disable;
@@ -949,7 +959,7 @@ static int imx6_pcie_host_init(struct dw_pcie_rp *pp)
949959
}
950960

951961
if (imx6_pcie->phy) {
952-
ret = phy_init(imx6_pcie->phy);
962+
ret = phy_power_on(imx6_pcie->phy);
953963
if (ret) {
954964
dev_err(dev, "waiting for PHY ready timeout!\n");
955965
goto err_phy_off;
@@ -961,7 +971,7 @@ static int imx6_pcie_host_init(struct dw_pcie_rp *pp)
961971

962972
err_phy_off:
963973
if (imx6_pcie->phy)
964-
phy_power_off(imx6_pcie->phy);
974+
phy_exit(imx6_pcie->phy);
965975
err_clk_disable:
966976
imx6_pcie_clk_disable(imx6_pcie);
967977
err_reg_disable:
@@ -1179,6 +1189,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
11791189
}
11801190
break;
11811191
case IMX8MM:
1192+
case IMX8MP:
11821193
imx6_pcie->pcie_aux = devm_clk_get(dev, "pcie_aux");
11831194
if (IS_ERR(imx6_pcie->pcie_aux))
11841195
return dev_err_probe(dev, PTR_ERR(imx6_pcie->pcie_aux),
@@ -1216,7 +1227,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
12161227

12171228
/* Grab GPR config register range */
12181229
imx6_pcie->iomuxc_gpr =
1219-
syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
1230+
syscon_regmap_lookup_by_compatible(imx6_pcie->drvdata->gpr);
12201231
if (IS_ERR(imx6_pcie->iomuxc_gpr)) {
12211232
dev_err(dev, "unable to find iomuxc registers\n");
12221233
return PTR_ERR(imx6_pcie->iomuxc_gpr);
@@ -1295,30 +1306,41 @@ static const struct imx6_pcie_drvdata drvdata[] = {
12951306
.flags = IMX6_PCIE_FLAG_IMX6_PHY |
12961307
IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE,
12971308
.dbi_length = 0x200,
1309+
.gpr = "fsl,imx6q-iomuxc-gpr",
12981310
},
12991311
[IMX6SX] = {
13001312
.variant = IMX6SX,
13011313
.flags = IMX6_PCIE_FLAG_IMX6_PHY |
13021314
IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE |
13031315
IMX6_PCIE_FLAG_SUPPORTS_SUSPEND,
1316+
.gpr = "fsl,imx6q-iomuxc-gpr",
13041317
},
13051318
[IMX6QP] = {
13061319
.variant = IMX6QP,
13071320
.flags = IMX6_PCIE_FLAG_IMX6_PHY |
13081321
IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE |
13091322
IMX6_PCIE_FLAG_SUPPORTS_SUSPEND,
13101323
.dbi_length = 0x200,
1324+
.gpr = "fsl,imx6q-iomuxc-gpr",
13111325
},
13121326
[IMX7D] = {
13131327
.variant = IMX7D,
13141328
.flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND,
1329+
.gpr = "fsl,imx7d-iomuxc-gpr",
13151330
},
13161331
[IMX8MQ] = {
13171332
.variant = IMX8MQ,
1333+
.gpr = "fsl,imx8mq-iomuxc-gpr",
13181334
},
13191335
[IMX8MM] = {
13201336
.variant = IMX8MM,
13211337
.flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND,
1338+
.gpr = "fsl,imx8mm-iomuxc-gpr",
1339+
},
1340+
[IMX8MP] = {
1341+
.variant = IMX8MP,
1342+
.flags = IMX6_PCIE_FLAG_SUPPORTS_SUSPEND,
1343+
.gpr = "fsl,imx8mp-iomuxc-gpr",
13221344
},
13231345
};
13241346

@@ -1329,6 +1351,7 @@ static const struct of_device_id imx6_pcie_of_match[] = {
13291351
{ .compatible = "fsl,imx7d-pcie", .data = &drvdata[IMX7D], },
13301352
{ .compatible = "fsl,imx8mq-pcie", .data = &drvdata[IMX8MQ], },
13311353
{ .compatible = "fsl,imx8mm-pcie", .data = &drvdata[IMX8MM], },
1354+
{ .compatible = "fsl,imx8mp-pcie", .data = &drvdata[IMX8MP], },
13321355
{},
13331356
};
13341357

drivers/pci/controller/dwc/pcie-designware-host.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,6 @@ static void dw_pcie_free_msi(struct dw_pcie_rp *pp)
267267

268268
irq_domain_remove(pp->msi_domain);
269269
irq_domain_remove(pp->irq_domain);
270-
271-
if (pp->msi_data) {
272-
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
273-
struct device *dev = pci->dev;
274-
275-
dma_unmap_page(dev, pp->msi_data, PAGE_SIZE, DMA_FROM_DEVICE);
276-
if (pp->msi_page)
277-
__free_page(pp->msi_page);
278-
}
279270
}
280271

281272
static void dw_pcie_msi_init(struct dw_pcie_rp *pp)
@@ -336,6 +327,7 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp)
336327
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
337328
struct device *dev = pci->dev;
338329
struct platform_device *pdev = to_platform_device(dev);
330+
u64 *msi_vaddr;
339331
int ret;
340332
u32 ctrl, num_ctrls;
341333

@@ -375,22 +367,16 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp)
375367
dw_chained_msi_isr, pp);
376368
}
377369

378-
ret = dma_set_mask(dev, DMA_BIT_MASK(32));
370+
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
379371
if (ret)
380372
dev_warn(dev, "Failed to set DMA mask to 32-bit. Devices with only 32-bit MSI support may not work properly\n");
381373

382-
pp->msi_page = alloc_page(GFP_DMA32);
383-
pp->msi_data = dma_map_page(dev, pp->msi_page, 0,
384-
PAGE_SIZE, DMA_FROM_DEVICE);
385-
ret = dma_mapping_error(dev, pp->msi_data);
386-
if (ret) {
387-
dev_err(pci->dev, "Failed to map MSI data\n");
388-
__free_page(pp->msi_page);
389-
pp->msi_page = NULL;
390-
pp->msi_data = 0;
374+
msi_vaddr = dmam_alloc_coherent(dev, sizeof(u64), &pp->msi_data,
375+
GFP_KERNEL);
376+
if (!msi_vaddr) {
377+
dev_err(dev, "Failed to alloc and map MSI data\n");
391378
dw_pcie_free_msi(pp);
392-
393-
return ret;
379+
return -ENOMEM;
394380
}
395381

396382
return 0;

drivers/pci/controller/dwc/pcie-designware.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ struct dw_pcie_rp {
243243
struct irq_domain *irq_domain;
244244
struct irq_domain *msi_domain;
245245
dma_addr_t msi_data;
246-
struct page *msi_page;
247246
struct irq_chip *msi_irq_chip;
248247
u32 num_vectors;
249248
u32 irq_mask[MAX_MSI_CTRLS];

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/delay.h>
1414
#include <linux/err.h>
1515
#include <linux/gpio.h>
16+
#include <linux/gpio/consumer.h>
1617
#include <linux/interrupt.h>
1718
#include <linux/mfd/syscon.h>
1819
#include <linux/of_address.h>
@@ -366,12 +367,11 @@ static int kirin_pcie_get_gpio_enable(struct kirin_pcie *pcie,
366367
struct platform_device *pdev)
367368
{
368369
struct device *dev = &pdev->dev;
369-
struct device_node *np = dev->of_node;
370370
char name[32];
371371
int ret, i;
372372

373373
/* This is an optional property */
374-
ret = of_gpio_named_count(np, "hisilicon,clken-gpios");
374+
ret = gpiod_count(dev, "hisilicon,clken");
375375
if (ret < 0)
376376
return 0;
377377

drivers/phy/freescale/phy-fsl-imx8m-pcie.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct imx8_pcie_phy {
5959
bool clkreq_unused;
6060
};
6161

62-
static int imx8_pcie_phy_init(struct phy *phy)
62+
static int imx8_pcie_phy_power_on(struct phy *phy)
6363
{
6464
int ret;
6565
u32 val, pad_mode;
@@ -137,14 +137,14 @@ static int imx8_pcie_phy_init(struct phy *phy)
137137
return ret;
138138
}
139139

140-
static int imx8_pcie_phy_power_on(struct phy *phy)
140+
static int imx8_pcie_phy_init(struct phy *phy)
141141
{
142142
struct imx8_pcie_phy *imx8_phy = phy_get_drvdata(phy);
143143

144144
return clk_prepare_enable(imx8_phy->clk);
145145
}
146146

147-
static int imx8_pcie_phy_power_off(struct phy *phy)
147+
static int imx8_pcie_phy_exit(struct phy *phy)
148148
{
149149
struct imx8_pcie_phy *imx8_phy = phy_get_drvdata(phy);
150150

@@ -155,8 +155,8 @@ static int imx8_pcie_phy_power_off(struct phy *phy)
155155

156156
static const struct phy_ops imx8_pcie_phy_ops = {
157157
.init = imx8_pcie_phy_init,
158+
.exit = imx8_pcie_phy_exit,
158159
.power_on = imx8_pcie_phy_power_on,
159-
.power_off = imx8_pcie_phy_power_off,
160160
.owner = THIS_MODULE,
161161
};
162162

0 commit comments

Comments
 (0)