Skip to content

Commit 0b45127

Browse files
Mani-Sadhasivambjorn-helgaas
authored andcommitted
PCI: dwc: Refactor dw_pcie_edma_find_chip() API
In order to add support for Hyper DMA (HDMA), refactor the existing dw_pcie_edma_find_chip() API by moving the common code to separate functions. No functional change. Suggested-by: Serge Semin <[email protected]> Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Frank Li <[email protected]> Reviewed-by: Serge Semin <[email protected]> Reviewed-by: Siddharth Vadapalli <[email protected]> Reviewed-by: Yoshihiro Shimoda <[email protected]>
1 parent 58d0d3e commit 0b45127

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

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

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,17 @@ static struct dw_edma_plat_ops dw_pcie_edma_ops = {
880880
.irq_vector = dw_pcie_edma_irq_vector,
881881
};
882882

883-
static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
883+
static void dw_pcie_edma_init_data(struct dw_pcie *pci)
884+
{
885+
pci->edma.dev = pci->dev;
886+
887+
if (!pci->edma.ops)
888+
pci->edma.ops = &dw_pcie_edma_ops;
889+
890+
pci->edma.flags |= DW_EDMA_CHIP_LOCAL;
891+
}
892+
893+
static int dw_pcie_edma_find_mf(struct dw_pcie *pci)
884894
{
885895
u32 val;
886896

@@ -902,8 +912,6 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
902912

903913
if (val == 0xFFFFFFFF && pci->edma.reg_base) {
904914
pci->edma.mf = EDMA_MF_EDMA_UNROLL;
905-
906-
val = dw_pcie_readl_dma(pci, PCIE_DMA_CTRL);
907915
} else if (val != 0xFFFFFFFF) {
908916
pci->edma.mf = EDMA_MF_EDMA_LEGACY;
909917

@@ -912,12 +920,14 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
912920
return -ENODEV;
913921
}
914922

915-
pci->edma.dev = pci->dev;
923+
return 0;
924+
}
916925

917-
if (!pci->edma.ops)
918-
pci->edma.ops = &dw_pcie_edma_ops;
926+
static int dw_pcie_edma_find_channels(struct dw_pcie *pci)
927+
{
928+
u32 val;
919929

920-
pci->edma.flags |= DW_EDMA_CHIP_LOCAL;
930+
val = dw_pcie_readl_dma(pci, PCIE_DMA_CTRL);
921931

922932
pci->edma.ll_wr_cnt = FIELD_GET(PCIE_DMA_NUM_WR_CHAN, val);
923933
pci->edma.ll_rd_cnt = FIELD_GET(PCIE_DMA_NUM_RD_CHAN, val);
@@ -930,6 +940,19 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
930940
return 0;
931941
}
932942

943+
static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
944+
{
945+
int ret;
946+
947+
dw_pcie_edma_init_data(pci);
948+
949+
ret = dw_pcie_edma_find_mf(pci);
950+
if (ret)
951+
return ret;
952+
953+
return dw_pcie_edma_find_channels(pci);
954+
}
955+
933956
static int dw_pcie_edma_irq_verify(struct dw_pcie *pci)
934957
{
935958
struct platform_device *pdev = to_platform_device(pci->dev);

0 commit comments

Comments
 (0)