Skip to content

Commit 3136184

Browse files
Hans ZhangMani-Sadhasivam
authored andcommitted
PCI: dwc: Replace ATU type macros with common TLP type macros
The dwc driver defines its own ATU type macros (PCIE_ATU_TYPE_MEM, PCIE_ATU_TYPE_IO, PCIE_ATU_TYPE_CFG0, PCIE_ATU_TYPE_CFG1, PCIE_ATU_TYPE_MSG) with the same numerical values as the newly introduced common TLP type macros. Remove the local definitions and switch all DWC users to the common PCIE_TLP_TYPE_* macros. This eliminates redundancy and improves consistency across PCI controller drivers. No functional change intended. Signed-off-by: Hans Zhang <18255117159@163.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://patch.msgid.link/20260516153657.65214-3-18255117159@163.com
1 parent 286db45 commit 3136184

5 files changed

Lines changed: 16 additions & 21 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,9 @@ static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
584584

585585
config_atu:
586586
if (!(flags & PCI_BASE_ADDRESS_SPACE))
587-
type = PCIE_ATU_TYPE_MEM;
587+
type = PCIE_TLP_TYPE_MEM_RDWR;
588588
else
589-
type = PCIE_ATU_TYPE_IO;
589+
type = PCIE_TLP_TYPE_IO_RDWR;
590590

591591
if (epf_bar->num_submap)
592592
ret = dw_pcie_ep_ib_atu_addr(ep, func_no, type, epf_bar);
@@ -659,7 +659,7 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
659659
struct dw_pcie_ob_atu_cfg atu = { 0 };
660660

661661
atu.func_no = func_no;
662-
atu.type = PCIE_ATU_TYPE_MEM;
662+
atu.type = PCIE_TLP_TYPE_MEM_RDWR;
663663
atu.parent_bus_addr = addr - pci->parent_bus_offset;
664664
atu.pci_addr = pci_addr;
665665
atu.size = size;

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ static int dw_pcie_config_ecam_iatu(struct dw_pcie_rp *pp)
434434
* remaining buses need type 1 iATU configuration.
435435
*/
436436
atu.index = 0;
437-
atu.type = PCIE_ATU_TYPE_CFG0;
437+
atu.type = PCIE_TLP_TYPE_CFG0_RDWR;
438438
atu.parent_bus_addr = pp->cfg0_base + SZ_1M;
439439
/* 1MiB is to cover 1 (bus) * 32 (devices) * 8 (functions) */
440440
atu.size = SZ_1M;
@@ -450,7 +450,7 @@ static int dw_pcie_config_ecam_iatu(struct dw_pcie_rp *pp)
450450

451451
/* Configure remaining buses in type 1 iATU configuration */
452452
atu.index = 1;
453-
atu.type = PCIE_ATU_TYPE_CFG1;
453+
atu.type = PCIE_TLP_TYPE_CFG1_RDWR;
454454
atu.parent_bus_addr = pp->cfg0_base + SZ_2M;
455455
atu.size = (SZ_1M * bus_range_max) - SZ_2M;
456456
atu.ctrl2 = PCIE_ATU_CFG_SHIFT_MODE_ENABLE;
@@ -745,9 +745,9 @@ static void __iomem *dw_pcie_other_conf_map_bus(struct pci_bus *bus,
745745
PCIE_ATU_FUNC(PCI_FUNC(devfn));
746746

747747
if (pci_is_root_bus(bus->parent))
748-
type = PCIE_ATU_TYPE_CFG0;
748+
type = PCIE_TLP_TYPE_CFG0_RDWR;
749749
else
750-
type = PCIE_ATU_TYPE_CFG1;
750+
type = PCIE_TLP_TYPE_CFG1_RDWR;
751751

752752
atu.type = type;
753753
atu.parent_bus_addr = pp->cfg0_base - pci->parent_bus_offset;
@@ -774,7 +774,7 @@ static int dw_pcie_rd_other_conf(struct pci_bus *bus, unsigned int devfn,
774774
return ret;
775775

776776
if (pp->cfg0_io_shared) {
777-
atu.type = PCIE_ATU_TYPE_IO;
777+
atu.type = PCIE_TLP_TYPE_IO_RDWR;
778778
atu.parent_bus_addr = pp->io_base - pci->parent_bus_offset;
779779
atu.pci_addr = pp->io_bus_addr;
780780
atu.size = pp->io_size;
@@ -800,7 +800,7 @@ static int dw_pcie_wr_other_conf(struct pci_bus *bus, unsigned int devfn,
800800
return ret;
801801

802802
if (pp->cfg0_io_shared) {
803-
atu.type = PCIE_ATU_TYPE_IO;
803+
atu.type = PCIE_TLP_TYPE_IO_RDWR;
804804
atu.parent_bus_addr = pp->io_base - pci->parent_bus_offset;
805805
atu.pci_addr = pp->io_bus_addr;
806806
atu.size = pp->io_size;
@@ -908,7 +908,7 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)
908908
if (resource_type(entry->res) != IORESOURCE_MEM)
909909
continue;
910910

911-
atu.type = PCIE_ATU_TYPE_MEM;
911+
atu.type = PCIE_TLP_TYPE_MEM_RDWR;
912912
atu.parent_bus_addr = entry->res->start - pci->parent_bus_offset;
913913
atu.pci_addr = entry->res->start - entry->offset;
914914

@@ -951,7 +951,7 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)
951951
if (pp->io_size) {
952952
if (ob_iatu_index < pci->num_ob_windows) {
953953
atu.index = ob_iatu_index;
954-
atu.type = PCIE_ATU_TYPE_IO;
954+
atu.type = PCIE_TLP_TYPE_IO_RDWR;
955955
atu.parent_bus_addr = pp->io_base - pci->parent_bus_offset;
956956
atu.pci_addr = pp->io_bus_addr;
957957
atu.size = pp->io_size;
@@ -1013,7 +1013,7 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)
10131013

10141014
window_size = MIN(pci->region_limit + 1, res_size);
10151015
ret = dw_pcie_prog_inbound_atu(pci, ib_iatu_index,
1016-
PCIE_ATU_TYPE_MEM, res_start,
1016+
PCIE_TLP_TYPE_MEM_RDWR, res_start,
10171017
res_start - entry->offset, window_size);
10181018
if (ret) {
10191019
dev_err(pci->dev, "Failed to set DMA range %pr\n",
@@ -1194,7 +1194,7 @@ static int dw_pcie_pme_turn_off(struct dw_pcie *pci)
11941194

11951195
atu.code = PCIE_MSG_CODE_PME_TURN_OFF;
11961196
atu.routing = PCIE_MSG_TYPE_R_BC;
1197-
atu.type = PCIE_ATU_TYPE_MSG;
1197+
atu.type = PCIE_TLP_TYPE_MSG;
11981198
atu.size = resource_size(pci->pp.msg_res);
11991199
atu.index = pci->pp.msg_atu_index;
12001200

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ int dw_pcie_prog_outbound_atu(struct dw_pcie *pci,
568568
dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL1, val);
569569

570570
val = PCIE_ATU_ENABLE | atu->ctrl2;
571-
if (atu->type == PCIE_ATU_TYPE_MSG) {
571+
if (atu->type == PCIE_TLP_TYPE_MSG) {
572572
/* The data-less messages only for now */
573573
val |= PCIE_ATU_INHIBIT_PAYLOAD | atu->code;
574574
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,6 @@
170170
#define PCIE_ATU_VIEWPORT_SIZE 0x2C
171171
#define PCIE_ATU_REGION_CTRL1 0x000
172172
#define PCIE_ATU_INCREASE_REGION_SIZE BIT(13)
173-
#define PCIE_ATU_TYPE_MEM 0x0
174-
#define PCIE_ATU_TYPE_IO 0x2
175-
#define PCIE_ATU_TYPE_CFG0 0x4
176-
#define PCIE_ATU_TYPE_CFG1 0x5
177-
#define PCIE_ATU_TYPE_MSG 0x10
178173
#define PCIE_ATU_TD BIT(8)
179174
#define PCIE_ATU_FUNC_NUM(pf) ((pf) << 20)
180175
#define PCIE_ATU_REGION_CTRL2 0x004

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ static void __iomem *tegra194_map_bus(struct pci_bus *bus,
8686

8787
if (bus->parent->number == cfg->busr.start) {
8888
if (PCI_SLOT(devfn) == 0)
89-
type = PCIE_ATU_TYPE_CFG0;
89+
type = PCIE_TLP_TYPE_CFG0_RDWR;
9090
else
9191
return NULL;
9292
} else {
93-
type = PCIE_ATU_TYPE_CFG1;
93+
type = PCIE_TLP_TYPE_CFG1_RDWR;
9494
}
9595

9696
program_outbound_atu(pcie_ecam, 0, type, cfg->res.start, busdev,

0 commit comments

Comments
 (0)