Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'pci/driver-cleanup'

- Use of_device_get_match_data(), not of_match_device(), when we only need
the device data in altera, artpec6, cadence, designware-plat, dra7xx,
keystone, kirin (Fan Fei)

- Drop pointless of_device_get_match_data() cast in j721e (Bjorn Helgaas)

- Drop redundant struct device * from j721e since struct cdns_pcie already
has one (Bjorn Helgaas)

- Rename driver structs to *_pcie in intel-gw, iproc, ls-gen4,
mediatek-gen3, microchip, mt7621, rcar-gen2, tegra194, uniphier, xgene,
xilinx, xilinx-cpm for consistency across drivers (Fan Fei)

- Fix invalid address space conversions in hisi, spear13xx (Bjorn Helgaas)

* pci/driver-cleanup:
PCI: spear13xx: Avoid invalid address space conversions
PCI: hisi: Avoid invalid address space conversions
PCI: xilinx-cpm: Rename xilinx_cpm_pcie_port to xilinx_cpm_pcie
PCI: xilinx: Rename xilinx_pcie_port to xilinx_pcie
PCI: xgene: Rename xgene_pcie_port to xgene_pcie
PCI: uniphier: Rename uniphier_pcie_priv to uniphier_pcie
PCI: tegra194: Rename tegra_pcie_dw to tegra194_pcie
PCI: rcar-gen2: Rename rcar_pci_priv to rcar_pci
PCI: mt7621: Rename mt7621_pci_ to mt7621_pcie_
PCI: microchip: Rename mc_port to mc_pcie
PCI: mediatek-gen3: Rename mtk_pcie_port to mtk_gen3_pcie
PCI: ls-gen4: Rename ls_pcie_g4 to ls_g4_pcie
PCI: iproc: Rename iproc_pcie_pltfm_ to iproc_pltfm_pcie_
PCI: iproc: Rename iproc_pcie_bcma_ to iproc_bcma_pcie_
PCI: intel-gw: Rename intel_pcie_port to intel_pcie
PCI: j721e: Drop redundant struct device *
PCI: j721e: Drop pointless of_device_get_match_data() cast
PCI: kirin: Prefer of_device_get_match_data()
PCI: keystone: Prefer of_device_get_match_data()
PCI: dra7xx: Prefer of_device_get_match_data()
PCI: designware-plat: Prefer of_device_get_match_data()
PCI: cadence: Prefer of_device_get_match_data()
PCI: artpec6: Prefer of_device_get_match_data()
PCI: altera: Prefer of_device_get_match_data()

# Conflicts:
# drivers/pci/controller/pcie-mt7621.c

+755 -756
+8 -10
drivers/pci/controller/cadence/pci-j721e.c
··· 51 51 #define MAX_LANES 2 52 52 53 53 struct j721e_pcie { 54 - struct device *dev; 54 + struct cdns_pcie *cdns_pcie; 55 55 struct clk *refclk; 56 56 u32 mode; 57 57 u32 num_lanes; 58 - struct cdns_pcie *cdns_pcie; 59 58 void __iomem *user_cfg_base; 60 59 void __iomem *intd_cfg_base; 61 60 u32 linkdown_irq_regfield; ··· 98 99 static irqreturn_t j721e_pcie_link_irq_handler(int irq, void *priv) 99 100 { 100 101 struct j721e_pcie *pcie = priv; 101 - struct device *dev = pcie->dev; 102 + struct device *dev = pcie->cdns_pcie->dev; 102 103 u32 reg; 103 104 104 105 reg = j721e_pcie_intd_readl(pcie, STATUS_REG_SYS_2); ··· 164 165 static int j721e_pcie_set_mode(struct j721e_pcie *pcie, struct regmap *syscon, 165 166 unsigned int offset) 166 167 { 167 - struct device *dev = pcie->dev; 168 + struct device *dev = pcie->cdns_pcie->dev; 168 169 u32 mask = J721E_MODE_RC; 169 170 u32 mode = pcie->mode; 170 171 u32 val = 0; ··· 183 184 static int j721e_pcie_set_link_speed(struct j721e_pcie *pcie, 184 185 struct regmap *syscon, unsigned int offset) 185 186 { 186 - struct device *dev = pcie->dev; 187 + struct device *dev = pcie->cdns_pcie->dev; 187 188 struct device_node *np = dev->of_node; 188 189 int link_speed; 189 190 u32 val = 0; ··· 204 205 static int j721e_pcie_set_lane_count(struct j721e_pcie *pcie, 205 206 struct regmap *syscon, unsigned int offset) 206 207 { 207 - struct device *dev = pcie->dev; 208 + struct device *dev = pcie->cdns_pcie->dev; 208 209 u32 lanes = pcie->num_lanes; 209 210 u32 val = 0; 210 211 int ret; ··· 219 220 220 221 static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie) 221 222 { 222 - struct device *dev = pcie->dev; 223 + struct device *dev = pcie->cdns_pcie->dev; 223 224 struct device_node *node = dev->of_node; 224 225 struct of_phandle_args args; 225 226 unsigned int offset = 0; ··· 353 354 struct device *dev = &pdev->dev; 354 355 struct device_node *node = dev->of_node; 355 356 struct pci_host_bridge *bridge; 356 - struct j721e_pcie_data *data; 357 + const struct j721e_pcie_data *data; 357 358 struct cdns_pcie *cdns_pcie; 358 359 struct j721e_pcie *pcie; 359 360 struct cdns_pcie_rc *rc; ··· 366 367 int ret; 367 368 int irq; 368 369 369 - data = (struct j721e_pcie_data *)of_device_get_match_data(dev); 370 + data = of_device_get_match_data(dev); 370 371 if (!data) 371 372 return -EINVAL; 372 373 ··· 376 377 if (!pcie) 377 378 return -ENOMEM; 378 379 379 - pcie->dev = dev; 380 380 pcie->mode = mode; 381 381 pcie->linkdown_irq_regfield = data->linkdown_irq_regfield; 382 382
+2 -4
drivers/pci/controller/cadence/pcie-cadence-plat.c
··· 45 45 { 46 46 const struct cdns_plat_pcie_of_data *data; 47 47 struct cdns_plat_pcie *cdns_plat_pcie; 48 - const struct of_device_id *match; 49 48 struct device *dev = &pdev->dev; 50 49 struct pci_host_bridge *bridge; 51 50 struct cdns_pcie_ep *ep; ··· 53 54 bool is_rc; 54 55 int ret; 55 56 56 - match = of_match_device(cdns_plat_pcie_of_match, dev); 57 - if (!match) 57 + data = of_device_get_match_data(dev); 58 + if (!data) 58 59 return -EINVAL; 59 60 60 - data = (struct cdns_plat_pcie_of_data *)match->data; 61 61 is_rc = data->is_rc; 62 62 63 63 pr_debug(" Started %s with is_rc: %d\n", __func__, is_rc);
+2 -4
drivers/pci/controller/dwc/pci-dra7xx.c
··· 697 697 struct device_node *np = dev->of_node; 698 698 char name[10]; 699 699 struct gpio_desc *reset; 700 - const struct of_device_id *match; 701 700 const struct dra7xx_pcie_of_data *data; 702 701 enum dw_pcie_device_mode mode; 703 702 u32 b1co_mode_sel_mask; 704 703 705 - match = of_match_device(of_match_ptr(of_dra7xx_pcie_match), dev); 706 - if (!match) 704 + data = of_device_get_match_data(dev); 705 + if (!data) 707 706 return -EINVAL; 708 707 709 - data = (struct dra7xx_pcie_of_data *)match->data; 710 708 mode = (enum dw_pcie_device_mode)data->mode; 711 709 b1co_mode_sel_mask = data->b1co_mode_sel_mask; 712 710
+1 -3
drivers/pci/controller/dwc/pci-keystone.c
··· 1108 1108 struct device *dev = &pdev->dev; 1109 1109 struct device_node *np = dev->of_node; 1110 1110 const struct ks_pcie_of_data *data; 1111 - const struct of_device_id *match; 1112 1111 enum dw_pcie_device_mode mode; 1113 1112 struct dw_pcie *pci; 1114 1113 struct keystone_pcie *ks_pcie; ··· 1124 1125 int irq; 1125 1126 int i; 1126 1127 1127 - match = of_match_device(of_match_ptr(ks_pcie_of_match), dev); 1128 - data = (struct ks_pcie_of_data *)match->data; 1128 + data = of_device_get_match_data(dev); 1129 1129 if (!data) 1130 1130 return -EINVAL; 1131 1131
+2 -4
drivers/pci/controller/dwc/pcie-artpec6.c
··· 380 380 struct dw_pcie *pci; 381 381 struct artpec6_pcie *artpec6_pcie; 382 382 int ret; 383 - const struct of_device_id *match; 384 383 const struct artpec_pcie_of_data *data; 385 384 enum artpec_pcie_variants variant; 386 385 enum dw_pcie_device_mode mode; 387 386 u32 val; 388 387 389 - match = of_match_device(artpec6_pcie_of_match, dev); 390 - if (!match) 388 + data = of_device_get_match_data(dev); 389 + if (!data) 391 390 return -EINVAL; 392 391 393 - data = (struct artpec_pcie_of_data *)match->data; 394 392 variant = (enum artpec_pcie_variants)data->variant; 395 393 mode = (enum dw_pcie_device_mode)data->mode; 396 394
+2 -4
drivers/pci/controller/dwc/pcie-designware-plat.c
··· 122 122 struct dw_plat_pcie *dw_plat_pcie; 123 123 struct dw_pcie *pci; 124 124 int ret; 125 - const struct of_device_id *match; 126 125 const struct dw_plat_pcie_of_data *data; 127 126 enum dw_pcie_device_mode mode; 128 127 129 - match = of_match_device(dw_plat_pcie_of_match, dev); 130 - if (!match) 128 + data = of_device_get_match_data(dev); 129 + if (!data) 131 130 return -EINVAL; 132 131 133 - data = (struct dw_plat_pcie_of_data *)match->data; 134 132 mode = (enum dw_pcie_device_mode)data->mode; 135 133 136 134 dw_plat_pcie = devm_kzalloc(dev, sizeof(*dw_plat_pcie), GFP_KERNEL);
+22 -10
drivers/pci/controller/dwc/pcie-hisi.c
··· 18 18 19 19 #if defined(CONFIG_PCI_HISI) || (defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS)) 20 20 21 + struct hisi_pcie { 22 + void __iomem *reg_base; 23 + }; 24 + 21 25 static int hisi_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, 22 26 int size, u32 *val) 23 27 { ··· 62 58 int where) 63 59 { 64 60 struct pci_config_window *cfg = bus->sysdata; 65 - void __iomem *reg_base = cfg->priv; 61 + struct hisi_pcie *pcie = cfg->priv; 66 62 67 63 if (bus->number == cfg->busr.start) 68 - return reg_base + where; 64 + return pcie->reg_base + where; 69 65 else 70 66 return pci_ecam_map_bus(bus, devfn, where); 71 67 } ··· 75 71 static int hisi_pcie_init(struct pci_config_window *cfg) 76 72 { 77 73 struct device *dev = cfg->parent; 74 + struct hisi_pcie *pcie; 78 75 struct acpi_device *adev = to_acpi_device(dev); 79 76 struct acpi_pci_root *root = acpi_driver_data(adev); 80 77 struct resource *res; 81 - void __iomem *reg_base; 82 78 int ret; 79 + 80 + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); 81 + if (!pcie) 82 + return -ENOMEM; 83 83 84 84 /* 85 85 * Retrieve RC base and size from a HISI0081 device with _UID ··· 99 91 return -ENOMEM; 100 92 } 101 93 102 - reg_base = devm_pci_remap_cfgspace(dev, res->start, resource_size(res)); 103 - if (!reg_base) 94 + pcie->reg_base = devm_pci_remap_cfgspace(dev, res->start, resource_size(res)); 95 + if (!pcie->reg_base) 104 96 return -ENOMEM; 105 97 106 - cfg->priv = reg_base; 98 + cfg->priv = pcie; 107 99 return 0; 108 100 } 109 101 ··· 123 115 static int hisi_pcie_platform_init(struct pci_config_window *cfg) 124 116 { 125 117 struct device *dev = cfg->parent; 118 + struct hisi_pcie *pcie; 126 119 struct platform_device *pdev = to_platform_device(dev); 127 120 struct resource *res; 128 - void __iomem *reg_base; 121 + 122 + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); 123 + if (!pcie) 124 + return -ENOMEM; 129 125 130 126 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 131 127 if (!res) { ··· 137 125 return -EINVAL; 138 126 } 139 127 140 - reg_base = devm_pci_remap_cfgspace(dev, res->start, resource_size(res)); 141 - if (!reg_base) 128 + pcie->reg_base = devm_pci_remap_cfgspace(dev, res->start, resource_size(res)); 129 + if (!pcie->reg_base) 142 130 return -ENOMEM; 143 131 144 - cfg->priv = reg_base; 132 + cfg->priv = pcie; 145 133 return 0; 146 134 } 147 135
+102 -102
drivers/pci/controller/dwc/pcie-intel-gw.c
··· 62 62 unsigned int pcie_ver; 63 63 }; 64 64 65 - struct intel_pcie_port { 65 + struct intel_pcie { 66 66 struct dw_pcie pci; 67 67 void __iomem *app_base; 68 68 struct gpio_desc *reset_gpio; ··· 83 83 writel(val, base + ofs); 84 84 } 85 85 86 - static inline void pcie_app_wr(struct intel_pcie_port *lpp, u32 ofs, u32 val) 86 + static inline void pcie_app_wr(struct intel_pcie *pcie, u32 ofs, u32 val) 87 87 { 88 - writel(val, lpp->app_base + ofs); 88 + writel(val, pcie->app_base + ofs); 89 89 } 90 90 91 - static void pcie_app_wr_mask(struct intel_pcie_port *lpp, u32 ofs, 91 + static void pcie_app_wr_mask(struct intel_pcie *pcie, u32 ofs, 92 92 u32 mask, u32 val) 93 93 { 94 - pcie_update_bits(lpp->app_base, ofs, mask, val); 94 + pcie_update_bits(pcie->app_base, ofs, mask, val); 95 95 } 96 96 97 - static inline u32 pcie_rc_cfg_rd(struct intel_pcie_port *lpp, u32 ofs) 97 + static inline u32 pcie_rc_cfg_rd(struct intel_pcie *pcie, u32 ofs) 98 98 { 99 - return dw_pcie_readl_dbi(&lpp->pci, ofs); 99 + return dw_pcie_readl_dbi(&pcie->pci, ofs); 100 100 } 101 101 102 - static inline void pcie_rc_cfg_wr(struct intel_pcie_port *lpp, u32 ofs, u32 val) 102 + static inline void pcie_rc_cfg_wr(struct intel_pcie *pcie, u32 ofs, u32 val) 103 103 { 104 - dw_pcie_writel_dbi(&lpp->pci, ofs, val); 104 + dw_pcie_writel_dbi(&pcie->pci, ofs, val); 105 105 } 106 106 107 - static void pcie_rc_cfg_wr_mask(struct intel_pcie_port *lpp, u32 ofs, 107 + static void pcie_rc_cfg_wr_mask(struct intel_pcie *pcie, u32 ofs, 108 108 u32 mask, u32 val) 109 109 { 110 - pcie_update_bits(lpp->pci.dbi_base, ofs, mask, val); 110 + pcie_update_bits(pcie->pci.dbi_base, ofs, mask, val); 111 111 } 112 112 113 - static void intel_pcie_ltssm_enable(struct intel_pcie_port *lpp) 113 + static void intel_pcie_ltssm_enable(struct intel_pcie *pcie) 114 114 { 115 - pcie_app_wr_mask(lpp, PCIE_APP_CCR, PCIE_APP_CCR_LTSSM_ENABLE, 115 + pcie_app_wr_mask(pcie, PCIE_APP_CCR, PCIE_APP_CCR_LTSSM_ENABLE, 116 116 PCIE_APP_CCR_LTSSM_ENABLE); 117 117 } 118 118 119 - static void intel_pcie_ltssm_disable(struct intel_pcie_port *lpp) 119 + static void intel_pcie_ltssm_disable(struct intel_pcie *pcie) 120 120 { 121 - pcie_app_wr_mask(lpp, PCIE_APP_CCR, PCIE_APP_CCR_LTSSM_ENABLE, 0); 121 + pcie_app_wr_mask(pcie, PCIE_APP_CCR, PCIE_APP_CCR_LTSSM_ENABLE, 0); 122 122 } 123 123 124 - static void intel_pcie_link_setup(struct intel_pcie_port *lpp) 124 + static void intel_pcie_link_setup(struct intel_pcie *pcie) 125 125 { 126 126 u32 val; 127 - u8 offset = dw_pcie_find_capability(&lpp->pci, PCI_CAP_ID_EXP); 127 + u8 offset = dw_pcie_find_capability(&pcie->pci, PCI_CAP_ID_EXP); 128 128 129 - val = pcie_rc_cfg_rd(lpp, offset + PCI_EXP_LNKCTL); 129 + val = pcie_rc_cfg_rd(pcie, offset + PCI_EXP_LNKCTL); 130 130 131 131 val &= ~(PCI_EXP_LNKCTL_LD | PCI_EXP_LNKCTL_ASPMC); 132 - pcie_rc_cfg_wr(lpp, offset + PCI_EXP_LNKCTL, val); 132 + pcie_rc_cfg_wr(pcie, offset + PCI_EXP_LNKCTL, val); 133 133 } 134 134 135 135 static void intel_pcie_init_n_fts(struct dw_pcie *pci) ··· 148 148 pci->n_fts[0] = PORT_AFR_N_FTS_GEN12_DFT; 149 149 } 150 150 151 - static int intel_pcie_ep_rst_init(struct intel_pcie_port *lpp) 151 + static int intel_pcie_ep_rst_init(struct intel_pcie *pcie) 152 152 { 153 - struct device *dev = lpp->pci.dev; 153 + struct device *dev = pcie->pci.dev; 154 154 int ret; 155 155 156 - lpp->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); 157 - if (IS_ERR(lpp->reset_gpio)) { 158 - ret = PTR_ERR(lpp->reset_gpio); 156 + pcie->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); 157 + if (IS_ERR(pcie->reset_gpio)) { 158 + ret = PTR_ERR(pcie->reset_gpio); 159 159 if (ret != -EPROBE_DEFER) 160 160 dev_err(dev, "Failed to request PCIe GPIO: %d\n", ret); 161 161 return ret; ··· 167 167 return 0; 168 168 } 169 169 170 - static void intel_pcie_core_rst_assert(struct intel_pcie_port *lpp) 170 + static void intel_pcie_core_rst_assert(struct intel_pcie *pcie) 171 171 { 172 - reset_control_assert(lpp->core_rst); 172 + reset_control_assert(pcie->core_rst); 173 173 } 174 174 175 - static void intel_pcie_core_rst_deassert(struct intel_pcie_port *lpp) 175 + static void intel_pcie_core_rst_deassert(struct intel_pcie *pcie) 176 176 { 177 177 /* 178 178 * One micro-second delay to make sure the reset pulse 179 179 * wide enough so that core reset is clean. 180 180 */ 181 181 udelay(1); 182 - reset_control_deassert(lpp->core_rst); 182 + reset_control_deassert(pcie->core_rst); 183 183 184 184 /* 185 185 * Some SoC core reset also reset PHY, more delay needed ··· 188 188 usleep_range(1000, 2000); 189 189 } 190 190 191 - static void intel_pcie_device_rst_assert(struct intel_pcie_port *lpp) 191 + static void intel_pcie_device_rst_assert(struct intel_pcie *pcie) 192 192 { 193 - gpiod_set_value_cansleep(lpp->reset_gpio, 1); 193 + gpiod_set_value_cansleep(pcie->reset_gpio, 1); 194 194 } 195 195 196 - static void intel_pcie_device_rst_deassert(struct intel_pcie_port *lpp) 196 + static void intel_pcie_device_rst_deassert(struct intel_pcie *pcie) 197 197 { 198 - msleep(lpp->rst_intrvl); 199 - gpiod_set_value_cansleep(lpp->reset_gpio, 0); 198 + msleep(pcie->rst_intrvl); 199 + gpiod_set_value_cansleep(pcie->reset_gpio, 0); 200 200 } 201 201 202 - static void intel_pcie_core_irq_disable(struct intel_pcie_port *lpp) 202 + static void intel_pcie_core_irq_disable(struct intel_pcie *pcie) 203 203 { 204 - pcie_app_wr(lpp, PCIE_APP_IRNEN, 0); 205 - pcie_app_wr(lpp, PCIE_APP_IRNCR, PCIE_APP_IRN_INT); 204 + pcie_app_wr(pcie, PCIE_APP_IRNEN, 0); 205 + pcie_app_wr(pcie, PCIE_APP_IRNCR, PCIE_APP_IRN_INT); 206 206 } 207 207 208 208 static int intel_pcie_get_resources(struct platform_device *pdev) 209 209 { 210 - struct intel_pcie_port *lpp = platform_get_drvdata(pdev); 211 - struct dw_pcie *pci = &lpp->pci; 210 + struct intel_pcie *pcie = platform_get_drvdata(pdev); 211 + struct dw_pcie *pci = &pcie->pci; 212 212 struct device *dev = pci->dev; 213 213 int ret; 214 214 215 - lpp->core_clk = devm_clk_get(dev, NULL); 216 - if (IS_ERR(lpp->core_clk)) { 217 - ret = PTR_ERR(lpp->core_clk); 215 + pcie->core_clk = devm_clk_get(dev, NULL); 216 + if (IS_ERR(pcie->core_clk)) { 217 + ret = PTR_ERR(pcie->core_clk); 218 218 if (ret != -EPROBE_DEFER) 219 219 dev_err(dev, "Failed to get clks: %d\n", ret); 220 220 return ret; 221 221 } 222 222 223 - lpp->core_rst = devm_reset_control_get(dev, NULL); 224 - if (IS_ERR(lpp->core_rst)) { 225 - ret = PTR_ERR(lpp->core_rst); 223 + pcie->core_rst = devm_reset_control_get(dev, NULL); 224 + if (IS_ERR(pcie->core_rst)) { 225 + ret = PTR_ERR(pcie->core_rst); 226 226 if (ret != -EPROBE_DEFER) 227 227 dev_err(dev, "Failed to get resets: %d\n", ret); 228 228 return ret; 229 229 } 230 230 231 231 ret = device_property_read_u32(dev, "reset-assert-ms", 232 - &lpp->rst_intrvl); 232 + &pcie->rst_intrvl); 233 233 if (ret) 234 - lpp->rst_intrvl = RESET_INTERVAL_MS; 234 + pcie->rst_intrvl = RESET_INTERVAL_MS; 235 235 236 - lpp->app_base = devm_platform_ioremap_resource_byname(pdev, "app"); 237 - if (IS_ERR(lpp->app_base)) 238 - return PTR_ERR(lpp->app_base); 236 + pcie->app_base = devm_platform_ioremap_resource_byname(pdev, "app"); 237 + if (IS_ERR(pcie->app_base)) 238 + return PTR_ERR(pcie->app_base); 239 239 240 - lpp->phy = devm_phy_get(dev, "pcie"); 241 - if (IS_ERR(lpp->phy)) { 242 - ret = PTR_ERR(lpp->phy); 240 + pcie->phy = devm_phy_get(dev, "pcie"); 241 + if (IS_ERR(pcie->phy)) { 242 + ret = PTR_ERR(pcie->phy); 243 243 if (ret != -EPROBE_DEFER) 244 244 dev_err(dev, "Couldn't get pcie-phy: %d\n", ret); 245 245 return ret; ··· 248 248 return 0; 249 249 } 250 250 251 - static int intel_pcie_wait_l2(struct intel_pcie_port *lpp) 251 + static int intel_pcie_wait_l2(struct intel_pcie *pcie) 252 252 { 253 253 u32 value; 254 254 int ret; 255 - struct dw_pcie *pci = &lpp->pci; 255 + struct dw_pcie *pci = &pcie->pci; 256 256 257 257 if (pci->link_gen < 3) 258 258 return 0; 259 259 260 260 /* Send PME_TURN_OFF message */ 261 - pcie_app_wr_mask(lpp, PCIE_APP_MSG_CR, PCIE_APP_MSG_XMT_PM_TURNOFF, 261 + pcie_app_wr_mask(pcie, PCIE_APP_MSG_CR, PCIE_APP_MSG_XMT_PM_TURNOFF, 262 262 PCIE_APP_MSG_XMT_PM_TURNOFF); 263 263 264 264 /* Read PMC status and wait for falling into L2 link state */ 265 - ret = readl_poll_timeout(lpp->app_base + PCIE_APP_PMC, value, 265 + ret = readl_poll_timeout(pcie->app_base + PCIE_APP_PMC, value, 266 266 value & PCIE_APP_PMC_IN_L2, 20, 267 267 jiffies_to_usecs(5 * HZ)); 268 268 if (ret) 269 - dev_err(lpp->pci.dev, "PCIe link enter L2 timeout!\n"); 269 + dev_err(pcie->pci.dev, "PCIe link enter L2 timeout!\n"); 270 270 271 271 return ret; 272 272 } 273 273 274 - static void intel_pcie_turn_off(struct intel_pcie_port *lpp) 274 + static void intel_pcie_turn_off(struct intel_pcie *pcie) 275 275 { 276 - if (dw_pcie_link_up(&lpp->pci)) 277 - intel_pcie_wait_l2(lpp); 276 + if (dw_pcie_link_up(&pcie->pci)) 277 + intel_pcie_wait_l2(pcie); 278 278 279 279 /* Put endpoint device in reset state */ 280 - intel_pcie_device_rst_assert(lpp); 281 - pcie_rc_cfg_wr_mask(lpp, PCI_COMMAND, PCI_COMMAND_MEMORY, 0); 280 + intel_pcie_device_rst_assert(pcie); 281 + pcie_rc_cfg_wr_mask(pcie, PCI_COMMAND, PCI_COMMAND_MEMORY, 0); 282 282 } 283 283 284 - static int intel_pcie_host_setup(struct intel_pcie_port *lpp) 284 + static int intel_pcie_host_setup(struct intel_pcie *pcie) 285 285 { 286 286 int ret; 287 - struct dw_pcie *pci = &lpp->pci; 287 + struct dw_pcie *pci = &pcie->pci; 288 288 289 - intel_pcie_core_rst_assert(lpp); 290 - intel_pcie_device_rst_assert(lpp); 289 + intel_pcie_core_rst_assert(pcie); 290 + intel_pcie_device_rst_assert(pcie); 291 291 292 - ret = phy_init(lpp->phy); 292 + ret = phy_init(pcie->phy); 293 293 if (ret) 294 294 return ret; 295 295 296 - intel_pcie_core_rst_deassert(lpp); 296 + intel_pcie_core_rst_deassert(pcie); 297 297 298 - ret = clk_prepare_enable(lpp->core_clk); 298 + ret = clk_prepare_enable(pcie->core_clk); 299 299 if (ret) { 300 - dev_err(lpp->pci.dev, "Core clock enable failed: %d\n", ret); 300 + dev_err(pcie->pci.dev, "Core clock enable failed: %d\n", ret); 301 301 goto clk_err; 302 302 } 303 303 304 304 pci->atu_base = pci->dbi_base + 0xC0000; 305 305 306 - intel_pcie_ltssm_disable(lpp); 307 - intel_pcie_link_setup(lpp); 306 + intel_pcie_ltssm_disable(pcie); 307 + intel_pcie_link_setup(pcie); 308 308 intel_pcie_init_n_fts(pci); 309 309 dw_pcie_setup_rc(&pci->pp); 310 310 dw_pcie_upconfig_setup(pci); 311 311 312 - intel_pcie_device_rst_deassert(lpp); 313 - intel_pcie_ltssm_enable(lpp); 312 + intel_pcie_device_rst_deassert(pcie); 313 + intel_pcie_ltssm_enable(pcie); 314 314 315 315 ret = dw_pcie_wait_for_link(pci); 316 316 if (ret) 317 317 goto app_init_err; 318 318 319 319 /* Enable integrated interrupts */ 320 - pcie_app_wr_mask(lpp, PCIE_APP_IRNEN, PCIE_APP_IRN_INT, 320 + pcie_app_wr_mask(pcie, PCIE_APP_IRNEN, PCIE_APP_IRN_INT, 321 321 PCIE_APP_IRN_INT); 322 322 323 323 return 0; 324 324 325 325 app_init_err: 326 - clk_disable_unprepare(lpp->core_clk); 326 + clk_disable_unprepare(pcie->core_clk); 327 327 clk_err: 328 - intel_pcie_core_rst_assert(lpp); 329 - phy_exit(lpp->phy); 328 + intel_pcie_core_rst_assert(pcie); 329 + phy_exit(pcie->phy); 330 330 331 331 return ret; 332 332 } 333 333 334 - static void __intel_pcie_remove(struct intel_pcie_port *lpp) 334 + static void __intel_pcie_remove(struct intel_pcie *pcie) 335 335 { 336 - intel_pcie_core_irq_disable(lpp); 337 - intel_pcie_turn_off(lpp); 338 - clk_disable_unprepare(lpp->core_clk); 339 - intel_pcie_core_rst_assert(lpp); 340 - phy_exit(lpp->phy); 336 + intel_pcie_core_irq_disable(pcie); 337 + intel_pcie_turn_off(pcie); 338 + clk_disable_unprepare(pcie->core_clk); 339 + intel_pcie_core_rst_assert(pcie); 340 + phy_exit(pcie->phy); 341 341 } 342 342 343 343 static int intel_pcie_remove(struct platform_device *pdev) 344 344 { 345 - struct intel_pcie_port *lpp = platform_get_drvdata(pdev); 346 - struct pcie_port *pp = &lpp->pci.pp; 345 + struct intel_pcie *pcie = platform_get_drvdata(pdev); 346 + struct pcie_port *pp = &pcie->pci.pp; 347 347 348 348 dw_pcie_host_deinit(pp); 349 - __intel_pcie_remove(lpp); 349 + __intel_pcie_remove(pcie); 350 350 351 351 return 0; 352 352 } 353 353 354 354 static int __maybe_unused intel_pcie_suspend_noirq(struct device *dev) 355 355 { 356 - struct intel_pcie_port *lpp = dev_get_drvdata(dev); 356 + struct intel_pcie *pcie = dev_get_drvdata(dev); 357 357 int ret; 358 358 359 - intel_pcie_core_irq_disable(lpp); 360 - ret = intel_pcie_wait_l2(lpp); 359 + intel_pcie_core_irq_disable(pcie); 360 + ret = intel_pcie_wait_l2(pcie); 361 361 if (ret) 362 362 return ret; 363 363 364 - phy_exit(lpp->phy); 365 - clk_disable_unprepare(lpp->core_clk); 364 + phy_exit(pcie->phy); 365 + clk_disable_unprepare(pcie->core_clk); 366 366 return ret; 367 367 } 368 368 369 369 static int __maybe_unused intel_pcie_resume_noirq(struct device *dev) 370 370 { 371 - struct intel_pcie_port *lpp = dev_get_drvdata(dev); 371 + struct intel_pcie *pcie = dev_get_drvdata(dev); 372 372 373 - return intel_pcie_host_setup(lpp); 373 + return intel_pcie_host_setup(pcie); 374 374 } 375 375 376 376 static int intel_pcie_rc_init(struct pcie_port *pp) 377 377 { 378 378 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 379 - struct intel_pcie_port *lpp = dev_get_drvdata(pci->dev); 379 + struct intel_pcie *pcie = dev_get_drvdata(pci->dev); 380 380 381 - return intel_pcie_host_setup(lpp); 381 + return intel_pcie_host_setup(pcie); 382 382 } 383 383 384 384 static u64 intel_pcie_cpu_addr(struct dw_pcie *pcie, u64 cpu_addr) ··· 402 402 { 403 403 const struct intel_pcie_soc *data; 404 404 struct device *dev = &pdev->dev; 405 - struct intel_pcie_port *lpp; 405 + struct intel_pcie *pcie; 406 406 struct pcie_port *pp; 407 407 struct dw_pcie *pci; 408 408 int ret; 409 409 410 - lpp = devm_kzalloc(dev, sizeof(*lpp), GFP_KERNEL); 411 - if (!lpp) 410 + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); 411 + if (!pcie) 412 412 return -ENOMEM; 413 413 414 - platform_set_drvdata(pdev, lpp); 415 - pci = &lpp->pci; 414 + platform_set_drvdata(pdev, pcie); 415 + pci = &pcie->pci; 416 416 pci->dev = dev; 417 417 pp = &pci->pp; 418 418 ··· 420 420 if (ret) 421 421 return ret; 422 422 423 - ret = intel_pcie_ep_rst_init(lpp); 423 + ret = intel_pcie_ep_rst_init(pcie); 424 424 if (ret) 425 425 return ret; 426 426
+2 -4
drivers/pci/controller/dwc/pcie-kirin.c
··· 771 771 static int kirin_pcie_probe(struct platform_device *pdev) 772 772 { 773 773 enum pcie_kirin_phy_type phy_type; 774 - const struct of_device_id *of_id; 775 774 struct device *dev = &pdev->dev; 776 775 struct kirin_pcie *kirin_pcie; 777 776 struct dw_pcie *pci; ··· 781 782 return -EINVAL; 782 783 } 783 784 784 - of_id = of_match_device(kirin_pcie_match, dev); 785 - if (!of_id) { 785 + phy_type = (long)of_device_get_match_data(dev); 786 + if (!phy_type) { 786 787 dev_err(dev, "OF data missing\n"); 787 788 return -EINVAL; 788 789 } 789 790 790 - phy_type = (long)of_id->data; 791 791 792 792 kirin_pcie = devm_kzalloc(dev, sizeof(struct kirin_pcie), GFP_KERNEL); 793 793 if (!kirin_pcie)
+4 -4
drivers/pci/controller/dwc/pcie-spear13xx.c
··· 69 69 static int spear13xx_pcie_start_link(struct dw_pcie *pci) 70 70 { 71 71 struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pci); 72 - struct pcie_app_reg *app_reg = spear13xx_pcie->app_base; 72 + struct pcie_app_reg __iomem *app_reg = spear13xx_pcie->app_base; 73 73 74 74 /* enable ltssm */ 75 75 writel(DEVICE_TYPE_RC | (1 << MISCTRL_EN_ID) ··· 83 83 static irqreturn_t spear13xx_pcie_irq_handler(int irq, void *arg) 84 84 { 85 85 struct spear13xx_pcie *spear13xx_pcie = arg; 86 - struct pcie_app_reg *app_reg = spear13xx_pcie->app_base; 86 + struct pcie_app_reg __iomem *app_reg = spear13xx_pcie->app_base; 87 87 struct dw_pcie *pci = spear13xx_pcie->pci; 88 88 struct pcie_port *pp = &pci->pp; 89 89 unsigned int status; ··· 102 102 103 103 static void spear13xx_pcie_enable_interrupts(struct spear13xx_pcie *spear13xx_pcie) 104 104 { 105 - struct pcie_app_reg *app_reg = spear13xx_pcie->app_base; 105 + struct pcie_app_reg __iomem *app_reg = spear13xx_pcie->app_base; 106 106 107 107 /* Enable MSI interrupt */ 108 108 if (IS_ENABLED(CONFIG_PCI_MSI)) ··· 113 113 static int spear13xx_pcie_link_up(struct dw_pcie *pci) 114 114 { 115 115 struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pci); 116 - struct pcie_app_reg *app_reg = spear13xx_pcie->app_base; 116 + struct pcie_app_reg __iomem *app_reg = spear13xx_pcie->app_base; 117 117 118 118 if (readl(&app_reg->app_status_1) & XMLH_LINK_UP) 119 119 return 1;
+111 -111
drivers/pci/controller/dwc/pcie-tegra194.c
··· 245 245 GEN4_CORE_CLK_FREQ 246 246 }; 247 247 248 - struct tegra_pcie_dw { 248 + struct tegra194_pcie { 249 249 struct device *dev; 250 250 struct resource *appl_res; 251 251 struct resource *dbi_res; ··· 289 289 int ep_state; 290 290 }; 291 291 292 - struct tegra_pcie_dw_of_data { 292 + struct tegra194_pcie_of_data { 293 293 enum dw_pcie_device_mode mode; 294 294 }; 295 295 296 - static inline struct tegra_pcie_dw *to_tegra_pcie(struct dw_pcie *pci) 296 + static inline struct tegra194_pcie *to_tegra_pcie(struct dw_pcie *pci) 297 297 { 298 - return container_of(pci, struct tegra_pcie_dw, pci); 298 + return container_of(pci, struct tegra194_pcie, pci); 299 299 } 300 300 301 - static inline void appl_writel(struct tegra_pcie_dw *pcie, const u32 value, 301 + static inline void appl_writel(struct tegra194_pcie *pcie, const u32 value, 302 302 const u32 reg) 303 303 { 304 304 writel_relaxed(value, pcie->appl_base + reg); 305 305 } 306 306 307 - static inline u32 appl_readl(struct tegra_pcie_dw *pcie, const u32 reg) 307 + static inline u32 appl_readl(struct tegra194_pcie *pcie, const u32 reg) 308 308 { 309 309 return readl_relaxed(pcie->appl_base + reg); 310 310 } ··· 316 316 static void apply_bad_link_workaround(struct pcie_port *pp) 317 317 { 318 318 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 319 - struct tegra_pcie_dw *pcie = to_tegra_pcie(pci); 319 + struct tegra194_pcie *pcie = to_tegra_pcie(pci); 320 320 u32 current_link_width; 321 321 u16 val; 322 322 ··· 349 349 350 350 static irqreturn_t tegra_pcie_rp_irq_handler(int irq, void *arg) 351 351 { 352 - struct tegra_pcie_dw *pcie = arg; 352 + struct tegra194_pcie *pcie = arg; 353 353 struct dw_pcie *pci = &pcie->pci; 354 354 struct pcie_port *pp = &pci->pp; 355 355 u32 val, tmp; ··· 420 420 return IRQ_HANDLED; 421 421 } 422 422 423 - static void pex_ep_event_hot_rst_done(struct tegra_pcie_dw *pcie) 423 + static void pex_ep_event_hot_rst_done(struct tegra194_pcie *pcie) 424 424 { 425 425 u32 val; 426 426 ··· 448 448 449 449 static irqreturn_t tegra_pcie_ep_irq_thread(int irq, void *arg) 450 450 { 451 - struct tegra_pcie_dw *pcie = arg; 451 + struct tegra194_pcie *pcie = arg; 452 452 struct dw_pcie *pci = &pcie->pci; 453 453 u32 val, speed; 454 454 ··· 494 494 495 495 static irqreturn_t tegra_pcie_ep_hard_irq(int irq, void *arg) 496 496 { 497 - struct tegra_pcie_dw *pcie = arg; 497 + struct tegra194_pcie *pcie = arg; 498 498 struct dw_pcie_ep *ep = &pcie->pci.ep; 499 499 int spurious = 1; 500 500 u32 status_l0, status_l1, link_status; ··· 537 537 return IRQ_HANDLED; 538 538 } 539 539 540 - static int tegra_pcie_dw_rd_own_conf(struct pci_bus *bus, u32 devfn, int where, 540 + static int tegra194_pcie_rd_own_conf(struct pci_bus *bus, u32 devfn, int where, 541 541 int size, u32 *val) 542 542 { 543 543 /* ··· 554 554 return pci_generic_config_read(bus, devfn, where, size, val); 555 555 } 556 556 557 - static int tegra_pcie_dw_wr_own_conf(struct pci_bus *bus, u32 devfn, int where, 557 + static int tegra194_pcie_wr_own_conf(struct pci_bus *bus, u32 devfn, int where, 558 558 int size, u32 val) 559 559 { 560 560 /* ··· 571 571 572 572 static struct pci_ops tegra_pci_ops = { 573 573 .map_bus = dw_pcie_own_conf_map_bus, 574 - .read = tegra_pcie_dw_rd_own_conf, 575 - .write = tegra_pcie_dw_wr_own_conf, 574 + .read = tegra194_pcie_rd_own_conf, 575 + .write = tegra194_pcie_wr_own_conf, 576 576 }; 577 577 578 578 #if defined(CONFIG_PCIEASPM) ··· 594 594 0x1dc 595 595 }; 596 596 597 - static void disable_aspm_l11(struct tegra_pcie_dw *pcie) 597 + static void disable_aspm_l11(struct tegra194_pcie *pcie) 598 598 { 599 599 u32 val; 600 600 ··· 603 603 dw_pcie_writel_dbi(&pcie->pci, pcie->cfg_link_cap_l1sub, val); 604 604 } 605 605 606 - static void disable_aspm_l12(struct tegra_pcie_dw *pcie) 606 + static void disable_aspm_l12(struct tegra194_pcie *pcie) 607 607 { 608 608 u32 val; 609 609 ··· 612 612 dw_pcie_writel_dbi(&pcie->pci, pcie->cfg_link_cap_l1sub, val); 613 613 } 614 614 615 - static inline u32 event_counter_prog(struct tegra_pcie_dw *pcie, u32 event) 615 + static inline u32 event_counter_prog(struct tegra194_pcie *pcie, u32 event) 616 616 { 617 617 u32 val; 618 618 ··· 629 629 630 630 static int aspm_state_cnt(struct seq_file *s, void *data) 631 631 { 632 - struct tegra_pcie_dw *pcie = (struct tegra_pcie_dw *) 632 + struct tegra194_pcie *pcie = (struct tegra194_pcie *) 633 633 dev_get_drvdata(s->private); 634 634 u32 val; 635 635 ··· 660 660 return 0; 661 661 } 662 662 663 - static void init_host_aspm(struct tegra_pcie_dw *pcie) 663 + static void init_host_aspm(struct tegra194_pcie *pcie) 664 664 { 665 665 struct dw_pcie *pci = &pcie->pci; 666 666 u32 val; ··· 688 688 dw_pcie_writel_dbi(pci, PCIE_PORT_AFR, val); 689 689 } 690 690 691 - static void init_debugfs(struct tegra_pcie_dw *pcie) 691 + static void init_debugfs(struct tegra194_pcie *pcie) 692 692 { 693 693 debugfs_create_devm_seqfile(pcie->dev, "aspm_state_cnt", pcie->debugfs, 694 694 aspm_state_cnt); 695 695 } 696 696 #else 697 - static inline void disable_aspm_l12(struct tegra_pcie_dw *pcie) { return; } 698 - static inline void disable_aspm_l11(struct tegra_pcie_dw *pcie) { return; } 699 - static inline void init_host_aspm(struct tegra_pcie_dw *pcie) { return; } 700 - static inline void init_debugfs(struct tegra_pcie_dw *pcie) { return; } 697 + static inline void disable_aspm_l12(struct tegra194_pcie *pcie) { return; } 698 + static inline void disable_aspm_l11(struct tegra194_pcie *pcie) { return; } 699 + static inline void init_host_aspm(struct tegra194_pcie *pcie) { return; } 700 + static inline void init_debugfs(struct tegra194_pcie *pcie) { return; } 701 701 #endif 702 702 703 703 static void tegra_pcie_enable_system_interrupts(struct pcie_port *pp) 704 704 { 705 705 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 706 - struct tegra_pcie_dw *pcie = to_tegra_pcie(pci); 706 + struct tegra194_pcie *pcie = to_tegra_pcie(pci); 707 707 u32 val; 708 708 u16 val_w; 709 709 ··· 741 741 static void tegra_pcie_enable_legacy_interrupts(struct pcie_port *pp) 742 742 { 743 743 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 744 - struct tegra_pcie_dw *pcie = to_tegra_pcie(pci); 744 + struct tegra194_pcie *pcie = to_tegra_pcie(pci); 745 745 u32 val; 746 746 747 747 /* Enable legacy interrupt generation */ ··· 762 762 static void tegra_pcie_enable_msi_interrupts(struct pcie_port *pp) 763 763 { 764 764 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 765 - struct tegra_pcie_dw *pcie = to_tegra_pcie(pci); 765 + struct tegra194_pcie *pcie = to_tegra_pcie(pci); 766 766 u32 val; 767 767 768 768 /* Enable MSI interrupt generation */ ··· 775 775 static void tegra_pcie_enable_interrupts(struct pcie_port *pp) 776 776 { 777 777 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 778 - struct tegra_pcie_dw *pcie = to_tegra_pcie(pci); 778 + struct tegra194_pcie *pcie = to_tegra_pcie(pci); 779 779 780 780 /* Clear interrupt statuses before enabling interrupts */ 781 781 appl_writel(pcie, 0xFFFFFFFF, APPL_INTR_STATUS_L0); ··· 800 800 tegra_pcie_enable_msi_interrupts(pp); 801 801 } 802 802 803 - static void config_gen3_gen4_eq_presets(struct tegra_pcie_dw *pcie) 803 + static void config_gen3_gen4_eq_presets(struct tegra194_pcie *pcie) 804 804 { 805 805 struct dw_pcie *pci = &pcie->pci; 806 806 u32 val, offset, i; ··· 853 853 dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val); 854 854 } 855 855 856 - static int tegra_pcie_dw_host_init(struct pcie_port *pp) 856 + static int tegra194_pcie_host_init(struct pcie_port *pp) 857 857 { 858 858 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 859 - struct tegra_pcie_dw *pcie = to_tegra_pcie(pci); 859 + struct tegra194_pcie *pcie = to_tegra_pcie(pci); 860 860 u32 val; 861 861 862 862 pp->bridge->ops = &tegra_pci_ops; ··· 914 914 return 0; 915 915 } 916 916 917 - static int tegra_pcie_dw_start_link(struct dw_pcie *pci) 917 + static int tegra194_pcie_start_link(struct dw_pcie *pci) 918 918 { 919 919 u32 val, offset, speed, tmp; 920 - struct tegra_pcie_dw *pcie = to_tegra_pcie(pci); 920 + struct tegra194_pcie *pcie = to_tegra_pcie(pci); 921 921 struct pcie_port *pp = &pci->pp; 922 922 bool retry = true; 923 923 ··· 982 982 val &= ~PCI_DLF_EXCHANGE_ENABLE; 983 983 dw_pcie_writel_dbi(pci, offset, val); 984 984 985 - tegra_pcie_dw_host_init(pp); 985 + tegra194_pcie_host_init(pp); 986 986 dw_pcie_setup_rc(pp); 987 987 988 988 retry = false; ··· 998 998 return 0; 999 999 } 1000 1000 1001 - static int tegra_pcie_dw_link_up(struct dw_pcie *pci) 1001 + static int tegra194_pcie_link_up(struct dw_pcie *pci) 1002 1002 { 1003 - struct tegra_pcie_dw *pcie = to_tegra_pcie(pci); 1003 + struct tegra194_pcie *pcie = to_tegra_pcie(pci); 1004 1004 u32 val = dw_pcie_readw_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKSTA); 1005 1005 1006 1006 return !!(val & PCI_EXP_LNKSTA_DLLLA); 1007 1007 } 1008 1008 1009 - static void tegra_pcie_dw_stop_link(struct dw_pcie *pci) 1009 + static void tegra194_pcie_stop_link(struct dw_pcie *pci) 1010 1010 { 1011 - struct tegra_pcie_dw *pcie = to_tegra_pcie(pci); 1011 + struct tegra194_pcie *pcie = to_tegra_pcie(pci); 1012 1012 1013 1013 disable_irq(pcie->pex_rst_irq); 1014 1014 } 1015 1015 1016 1016 static const struct dw_pcie_ops tegra_dw_pcie_ops = { 1017 - .link_up = tegra_pcie_dw_link_up, 1018 - .start_link = tegra_pcie_dw_start_link, 1019 - .stop_link = tegra_pcie_dw_stop_link, 1017 + .link_up = tegra194_pcie_link_up, 1018 + .start_link = tegra194_pcie_start_link, 1019 + .stop_link = tegra194_pcie_stop_link, 1020 1020 }; 1021 1021 1022 - static const struct dw_pcie_host_ops tegra_pcie_dw_host_ops = { 1023 - .host_init = tegra_pcie_dw_host_init, 1022 + static const struct dw_pcie_host_ops tegra194_pcie_host_ops = { 1023 + .host_init = tegra194_pcie_host_init, 1024 1024 }; 1025 1025 1026 - static void tegra_pcie_disable_phy(struct tegra_pcie_dw *pcie) 1026 + static void tegra_pcie_disable_phy(struct tegra194_pcie *pcie) 1027 1027 { 1028 1028 unsigned int phy_count = pcie->phy_count; 1029 1029 ··· 1033 1033 } 1034 1034 } 1035 1035 1036 - static int tegra_pcie_enable_phy(struct tegra_pcie_dw *pcie) 1036 + static int tegra_pcie_enable_phy(struct tegra194_pcie *pcie) 1037 1037 { 1038 1038 unsigned int i; 1039 1039 int ret; ··· 1060 1060 return ret; 1061 1061 } 1062 1062 1063 - static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie) 1063 + static int tegra194_pcie_parse_dt(struct tegra194_pcie *pcie) 1064 1064 { 1065 1065 struct platform_device *pdev = to_platform_device(pcie->dev); 1066 1066 struct device_node *np = pcie->dev->of_node; ··· 1156 1156 return 0; 1157 1157 } 1158 1158 1159 - static int tegra_pcie_bpmp_set_ctrl_state(struct tegra_pcie_dw *pcie, 1159 + static int tegra_pcie_bpmp_set_ctrl_state(struct tegra194_pcie *pcie, 1160 1160 bool enable) 1161 1161 { 1162 1162 struct mrq_uphy_response resp; ··· 1184 1184 return tegra_bpmp_transfer(pcie->bpmp, &msg); 1185 1185 } 1186 1186 1187 - static int tegra_pcie_bpmp_set_pll_state(struct tegra_pcie_dw *pcie, 1187 + static int tegra_pcie_bpmp_set_pll_state(struct tegra194_pcie *pcie, 1188 1188 bool enable) 1189 1189 { 1190 1190 struct mrq_uphy_response resp; ··· 1212 1212 return tegra_bpmp_transfer(pcie->bpmp, &msg); 1213 1213 } 1214 1214 1215 - static void tegra_pcie_downstream_dev_to_D0(struct tegra_pcie_dw *pcie) 1215 + static void tegra_pcie_downstream_dev_to_D0(struct tegra194_pcie *pcie) 1216 1216 { 1217 1217 struct pcie_port *pp = &pcie->pci.pp; 1218 1218 struct pci_bus *child, *root_bus = NULL; ··· 1250 1250 } 1251 1251 } 1252 1252 1253 - static int tegra_pcie_get_slot_regulators(struct tegra_pcie_dw *pcie) 1253 + static int tegra_pcie_get_slot_regulators(struct tegra194_pcie *pcie) 1254 1254 { 1255 1255 pcie->slot_ctl_3v3 = devm_regulator_get_optional(pcie->dev, "vpcie3v3"); 1256 1256 if (IS_ERR(pcie->slot_ctl_3v3)) { ··· 1271 1271 return 0; 1272 1272 } 1273 1273 1274 - static int tegra_pcie_enable_slot_regulators(struct tegra_pcie_dw *pcie) 1274 + static int tegra_pcie_enable_slot_regulators(struct tegra194_pcie *pcie) 1275 1275 { 1276 1276 int ret; 1277 1277 ··· 1309 1309 return ret; 1310 1310 } 1311 1311 1312 - static void tegra_pcie_disable_slot_regulators(struct tegra_pcie_dw *pcie) 1312 + static void tegra_pcie_disable_slot_regulators(struct tegra194_pcie *pcie) 1313 1313 { 1314 1314 if (pcie->slot_ctl_12v) 1315 1315 regulator_disable(pcie->slot_ctl_12v); ··· 1317 1317 regulator_disable(pcie->slot_ctl_3v3); 1318 1318 } 1319 1319 1320 - static int tegra_pcie_config_controller(struct tegra_pcie_dw *pcie, 1320 + static int tegra_pcie_config_controller(struct tegra194_pcie *pcie, 1321 1321 bool en_hw_hot_rst) 1322 1322 { 1323 1323 int ret; ··· 1414 1414 return ret; 1415 1415 } 1416 1416 1417 - static void tegra_pcie_unconfig_controller(struct tegra_pcie_dw *pcie) 1417 + static void tegra_pcie_unconfig_controller(struct tegra194_pcie *pcie) 1418 1418 { 1419 1419 int ret; 1420 1420 ··· 1442 1442 pcie->cid, ret); 1443 1443 } 1444 1444 1445 - static int tegra_pcie_init_controller(struct tegra_pcie_dw *pcie) 1445 + static int tegra_pcie_init_controller(struct tegra194_pcie *pcie) 1446 1446 { 1447 1447 struct dw_pcie *pci = &pcie->pci; 1448 1448 struct pcie_port *pp = &pci->pp; ··· 1452 1452 if (ret < 0) 1453 1453 return ret; 1454 1454 1455 - pp->ops = &tegra_pcie_dw_host_ops; 1455 + pp->ops = &tegra194_pcie_host_ops; 1456 1456 1457 1457 ret = dw_pcie_host_init(pp); 1458 1458 if (ret < 0) { ··· 1467 1467 return ret; 1468 1468 } 1469 1469 1470 - static int tegra_pcie_try_link_l2(struct tegra_pcie_dw *pcie) 1470 + static int tegra_pcie_try_link_l2(struct tegra194_pcie *pcie) 1471 1471 { 1472 1472 u32 val; 1473 1473 1474 - if (!tegra_pcie_dw_link_up(&pcie->pci)) 1474 + if (!tegra194_pcie_link_up(&pcie->pci)) 1475 1475 return 0; 1476 1476 1477 1477 val = appl_readl(pcie, APPL_RADM_STATUS); ··· 1483 1483 1, PME_ACK_TIMEOUT); 1484 1484 } 1485 1485 1486 - static void tegra_pcie_dw_pme_turnoff(struct tegra_pcie_dw *pcie) 1486 + static void tegra194_pcie_pme_turnoff(struct tegra194_pcie *pcie) 1487 1487 { 1488 1488 u32 data; 1489 1489 int err; 1490 1490 1491 - if (!tegra_pcie_dw_link_up(&pcie->pci)) { 1491 + if (!tegra194_pcie_link_up(&pcie->pci)) { 1492 1492 dev_dbg(pcie->dev, "PCIe link is not up...!\n"); 1493 1493 return; 1494 1494 } ··· 1545 1545 appl_writel(pcie, data, APPL_PINMUX); 1546 1546 } 1547 1547 1548 - static void tegra_pcie_deinit_controller(struct tegra_pcie_dw *pcie) 1548 + static void tegra_pcie_deinit_controller(struct tegra194_pcie *pcie) 1549 1549 { 1550 1550 tegra_pcie_downstream_dev_to_D0(pcie); 1551 1551 dw_pcie_host_deinit(&pcie->pci.pp); 1552 - tegra_pcie_dw_pme_turnoff(pcie); 1552 + tegra194_pcie_pme_turnoff(pcie); 1553 1553 tegra_pcie_unconfig_controller(pcie); 1554 1554 } 1555 1555 1556 - static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie) 1556 + static int tegra_pcie_config_rp(struct tegra194_pcie *pcie) 1557 1557 { 1558 1558 struct device *dev = pcie->dev; 1559 1559 char *name; ··· 1580 1580 goto fail_pm_get_sync; 1581 1581 } 1582 1582 1583 - pcie->link_state = tegra_pcie_dw_link_up(&pcie->pci); 1583 + pcie->link_state = tegra194_pcie_link_up(&pcie->pci); 1584 1584 if (!pcie->link_state) { 1585 1585 ret = -ENOMEDIUM; 1586 1586 goto fail_host_init; ··· 1605 1605 return ret; 1606 1606 } 1607 1607 1608 - static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie) 1608 + static void pex_ep_event_pex_rst_assert(struct tegra194_pcie *pcie) 1609 1609 { 1610 1610 u32 val; 1611 1611 int ret; ··· 1644 1644 dev_dbg(pcie->dev, "Uninitialization of endpoint is completed\n"); 1645 1645 } 1646 1646 1647 - static void pex_ep_event_pex_rst_deassert(struct tegra_pcie_dw *pcie) 1647 + static void pex_ep_event_pex_rst_deassert(struct tegra194_pcie *pcie) 1648 1648 { 1649 1649 struct dw_pcie *pci = &pcie->pci; 1650 1650 struct dw_pcie_ep *ep = &pci->ep; ··· 1809 1809 1810 1810 static irqreturn_t tegra_pcie_ep_pex_rst_irq(int irq, void *arg) 1811 1811 { 1812 - struct tegra_pcie_dw *pcie = arg; 1812 + struct tegra194_pcie *pcie = arg; 1813 1813 1814 1814 if (gpiod_get_value(pcie->pex_rst_gpiod)) 1815 1815 pex_ep_event_pex_rst_assert(pcie); ··· 1819 1819 return IRQ_HANDLED; 1820 1820 } 1821 1821 1822 - static int tegra_pcie_ep_raise_legacy_irq(struct tegra_pcie_dw *pcie, u16 irq) 1822 + static int tegra_pcie_ep_raise_legacy_irq(struct tegra194_pcie *pcie, u16 irq) 1823 1823 { 1824 1824 /* Tegra194 supports only INTA */ 1825 1825 if (irq > 1) ··· 1831 1831 return 0; 1832 1832 } 1833 1833 1834 - static int tegra_pcie_ep_raise_msi_irq(struct tegra_pcie_dw *pcie, u16 irq) 1834 + static int tegra_pcie_ep_raise_msi_irq(struct tegra194_pcie *pcie, u16 irq) 1835 1835 { 1836 1836 if (unlikely(irq > 31)) 1837 1837 return -EINVAL; ··· 1841 1841 return 0; 1842 1842 } 1843 1843 1844 - static int tegra_pcie_ep_raise_msix_irq(struct tegra_pcie_dw *pcie, u16 irq) 1844 + static int tegra_pcie_ep_raise_msix_irq(struct tegra194_pcie *pcie, u16 irq) 1845 1845 { 1846 1846 struct dw_pcie_ep *ep = &pcie->pci.ep; 1847 1847 ··· 1855 1855 u16 interrupt_num) 1856 1856 { 1857 1857 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 1858 - struct tegra_pcie_dw *pcie = to_tegra_pcie(pci); 1858 + struct tegra194_pcie *pcie = to_tegra_pcie(pci); 1859 1859 1860 1860 switch (type) { 1861 1861 case PCI_EPC_IRQ_LEGACY: ··· 1896 1896 .get_features = tegra_pcie_ep_get_features, 1897 1897 }; 1898 1898 1899 - static int tegra_pcie_config_ep(struct tegra_pcie_dw *pcie, 1899 + static int tegra_pcie_config_ep(struct tegra194_pcie *pcie, 1900 1900 struct platform_device *pdev) 1901 1901 { 1902 1902 struct dw_pcie *pci = &pcie->pci; ··· 1957 1957 return 0; 1958 1958 } 1959 1959 1960 - static int tegra_pcie_dw_probe(struct platform_device *pdev) 1960 + static int tegra194_pcie_probe(struct platform_device *pdev) 1961 1961 { 1962 - const struct tegra_pcie_dw_of_data *data; 1962 + const struct tegra194_pcie_of_data *data; 1963 1963 struct device *dev = &pdev->dev; 1964 1964 struct resource *atu_dma_res; 1965 - struct tegra_pcie_dw *pcie; 1965 + struct tegra194_pcie *pcie; 1966 1966 struct pcie_port *pp; 1967 1967 struct dw_pcie *pci; 1968 1968 struct phy **phys; ··· 1988 1988 pcie->dev = &pdev->dev; 1989 1989 pcie->mode = (enum dw_pcie_device_mode)data->mode; 1990 1990 1991 - ret = tegra_pcie_dw_parse_dt(pcie); 1991 + ret = tegra194_pcie_parse_dt(pcie); 1992 1992 if (ret < 0) { 1993 1993 const char *level = KERN_ERR; 1994 1994 ··· 2146 2146 return ret; 2147 2147 } 2148 2148 2149 - static int tegra_pcie_dw_remove(struct platform_device *pdev) 2149 + static int tegra194_pcie_remove(struct platform_device *pdev) 2150 2150 { 2151 - struct tegra_pcie_dw *pcie = platform_get_drvdata(pdev); 2151 + struct tegra194_pcie *pcie = platform_get_drvdata(pdev); 2152 2152 2153 2153 if (!pcie->link_state) 2154 2154 return 0; ··· 2164 2164 return 0; 2165 2165 } 2166 2166 2167 - static int tegra_pcie_dw_suspend_late(struct device *dev) 2167 + static int tegra194_pcie_suspend_late(struct device *dev) 2168 2168 { 2169 - struct tegra_pcie_dw *pcie = dev_get_drvdata(dev); 2169 + struct tegra194_pcie *pcie = dev_get_drvdata(dev); 2170 2170 u32 val; 2171 2171 2172 2172 if (!pcie->link_state) ··· 2182 2182 return 0; 2183 2183 } 2184 2184 2185 - static int tegra_pcie_dw_suspend_noirq(struct device *dev) 2185 + static int tegra194_pcie_suspend_noirq(struct device *dev) 2186 2186 { 2187 - struct tegra_pcie_dw *pcie = dev_get_drvdata(dev); 2187 + struct tegra194_pcie *pcie = dev_get_drvdata(dev); 2188 2188 2189 2189 if (!pcie->link_state) 2190 2190 return 0; ··· 2193 2193 pcie->msi_ctrl_int = dw_pcie_readl_dbi(&pcie->pci, 2194 2194 PORT_LOGIC_MSI_CTRL_INT_0_EN); 2195 2195 tegra_pcie_downstream_dev_to_D0(pcie); 2196 - tegra_pcie_dw_pme_turnoff(pcie); 2196 + tegra194_pcie_pme_turnoff(pcie); 2197 2197 tegra_pcie_unconfig_controller(pcie); 2198 2198 2199 2199 return 0; 2200 2200 } 2201 2201 2202 - static int tegra_pcie_dw_resume_noirq(struct device *dev) 2202 + static int tegra194_pcie_resume_noirq(struct device *dev) 2203 2203 { 2204 - struct tegra_pcie_dw *pcie = dev_get_drvdata(dev); 2204 + struct tegra194_pcie *pcie = dev_get_drvdata(dev); 2205 2205 int ret; 2206 2206 2207 2207 if (!pcie->link_state) ··· 2211 2211 if (ret < 0) 2212 2212 return ret; 2213 2213 2214 - ret = tegra_pcie_dw_host_init(&pcie->pci.pp); 2214 + ret = tegra194_pcie_host_init(&pcie->pci.pp); 2215 2215 if (ret < 0) { 2216 2216 dev_err(dev, "Failed to init host: %d\n", ret); 2217 2217 goto fail_host_init; ··· 2219 2219 2220 2220 dw_pcie_setup_rc(&pcie->pci.pp); 2221 2221 2222 - ret = tegra_pcie_dw_start_link(&pcie->pci); 2222 + ret = tegra194_pcie_start_link(&pcie->pci); 2223 2223 if (ret < 0) 2224 2224 goto fail_host_init; 2225 2225 ··· 2234 2234 return ret; 2235 2235 } 2236 2236 2237 - static int tegra_pcie_dw_resume_early(struct device *dev) 2237 + static int tegra194_pcie_resume_early(struct device *dev) 2238 2238 { 2239 - struct tegra_pcie_dw *pcie = dev_get_drvdata(dev); 2239 + struct tegra194_pcie *pcie = dev_get_drvdata(dev); 2240 2240 u32 val; 2241 2241 2242 2242 if (pcie->mode == DW_PCIE_EP_TYPE) { ··· 2259 2259 return 0; 2260 2260 } 2261 2261 2262 - static void tegra_pcie_dw_shutdown(struct platform_device *pdev) 2262 + static void tegra194_pcie_shutdown(struct platform_device *pdev) 2263 2263 { 2264 - struct tegra_pcie_dw *pcie = platform_get_drvdata(pdev); 2264 + struct tegra194_pcie *pcie = platform_get_drvdata(pdev); 2265 2265 2266 2266 if (!pcie->link_state) 2267 2267 return; ··· 2273 2273 if (IS_ENABLED(CONFIG_PCI_MSI)) 2274 2274 disable_irq(pcie->pci.pp.msi_irq); 2275 2275 2276 - tegra_pcie_dw_pme_turnoff(pcie); 2276 + tegra194_pcie_pme_turnoff(pcie); 2277 2277 tegra_pcie_unconfig_controller(pcie); 2278 2278 } 2279 2279 2280 - static const struct tegra_pcie_dw_of_data tegra_pcie_dw_rc_of_data = { 2280 + static const struct tegra194_pcie_of_data tegra194_pcie_rc_of_data = { 2281 2281 .mode = DW_PCIE_RC_TYPE, 2282 2282 }; 2283 2283 2284 - static const struct tegra_pcie_dw_of_data tegra_pcie_dw_ep_of_data = { 2284 + static const struct tegra194_pcie_of_data tegra194_pcie_ep_of_data = { 2285 2285 .mode = DW_PCIE_EP_TYPE, 2286 2286 }; 2287 2287 2288 - static const struct of_device_id tegra_pcie_dw_of_match[] = { 2288 + static const struct of_device_id tegra194_pcie_of_match[] = { 2289 2289 { 2290 2290 .compatible = "nvidia,tegra194-pcie", 2291 - .data = &tegra_pcie_dw_rc_of_data, 2291 + .data = &tegra194_pcie_rc_of_data, 2292 2292 }, 2293 2293 { 2294 2294 .compatible = "nvidia,tegra194-pcie-ep", 2295 - .data = &tegra_pcie_dw_ep_of_data, 2295 + .data = &tegra194_pcie_ep_of_data, 2296 2296 }, 2297 2297 {}, 2298 2298 }; 2299 2299 2300 - static const struct dev_pm_ops tegra_pcie_dw_pm_ops = { 2301 - .suspend_late = tegra_pcie_dw_suspend_late, 2302 - .suspend_noirq = tegra_pcie_dw_suspend_noirq, 2303 - .resume_noirq = tegra_pcie_dw_resume_noirq, 2304 - .resume_early = tegra_pcie_dw_resume_early, 2300 + static const struct dev_pm_ops tegra194_pcie_pm_ops = { 2301 + .suspend_late = tegra194_pcie_suspend_late, 2302 + .suspend_noirq = tegra194_pcie_suspend_noirq, 2303 + .resume_noirq = tegra194_pcie_resume_noirq, 2304 + .resume_early = tegra194_pcie_resume_early, 2305 2305 }; 2306 2306 2307 - static struct platform_driver tegra_pcie_dw_driver = { 2308 - .probe = tegra_pcie_dw_probe, 2309 - .remove = tegra_pcie_dw_remove, 2310 - .shutdown = tegra_pcie_dw_shutdown, 2307 + static struct platform_driver tegra194_pcie_driver = { 2308 + .probe = tegra194_pcie_probe, 2309 + .remove = tegra194_pcie_remove, 2310 + .shutdown = tegra194_pcie_shutdown, 2311 2311 .driver = { 2312 2312 .name = "tegra194-pcie", 2313 - .pm = &tegra_pcie_dw_pm_ops, 2314 - .of_match_table = tegra_pcie_dw_of_match, 2313 + .pm = &tegra194_pcie_pm_ops, 2314 + .of_match_table = tegra194_pcie_of_match, 2315 2315 }, 2316 2316 }; 2317 - module_platform_driver(tegra_pcie_dw_driver); 2317 + module_platform_driver(tegra194_pcie_driver); 2318 2318 2319 - MODULE_DEVICE_TABLE(of, tegra_pcie_dw_of_match); 2319 + MODULE_DEVICE_TABLE(of, tegra194_pcie_of_match); 2320 2320 2321 2321 MODULE_AUTHOR("Vidya Sagar <vidyas@nvidia.com>"); 2322 2322 MODULE_DESCRIPTION("NVIDIA PCIe host controller driver");
+74 -73
drivers/pci/controller/dwc/pcie-uniphier.c
··· 61 61 #define PCL_RDLH_LINK_UP BIT(1) 62 62 #define PCL_XMLH_LINK_UP BIT(0) 63 63 64 - struct uniphier_pcie_priv { 65 - void __iomem *base; 64 + struct uniphier_pcie { 66 65 struct dw_pcie pci; 66 + void __iomem *base; 67 67 struct clk *clk; 68 68 struct reset_control *rst; 69 69 struct phy *phy; ··· 72 72 73 73 #define to_uniphier_pcie(x) dev_get_drvdata((x)->dev) 74 74 75 - static void uniphier_pcie_ltssm_enable(struct uniphier_pcie_priv *priv, 75 + static void uniphier_pcie_ltssm_enable(struct uniphier_pcie *pcie, 76 76 bool enable) 77 77 { 78 78 u32 val; 79 79 80 - val = readl(priv->base + PCL_APP_READY_CTRL); 80 + val = readl(pcie->base + PCL_APP_READY_CTRL); 81 81 if (enable) 82 82 val |= PCL_APP_LTSSM_ENABLE; 83 83 else 84 84 val &= ~PCL_APP_LTSSM_ENABLE; 85 - writel(val, priv->base + PCL_APP_READY_CTRL); 85 + writel(val, pcie->base + PCL_APP_READY_CTRL); 86 86 } 87 87 88 - static void uniphier_pcie_init_rc(struct uniphier_pcie_priv *priv) 88 + static void uniphier_pcie_init_rc(struct uniphier_pcie *pcie) 89 89 { 90 90 u32 val; 91 91 92 92 /* set RC MODE */ 93 - val = readl(priv->base + PCL_MODE); 93 + val = readl(pcie->base + PCL_MODE); 94 94 val |= PCL_MODE_REGEN; 95 95 val &= ~PCL_MODE_REGVAL; 96 - writel(val, priv->base + PCL_MODE); 96 + writel(val, pcie->base + PCL_MODE); 97 97 98 98 /* use auxiliary power detection */ 99 - val = readl(priv->base + PCL_APP_PM0); 99 + val = readl(pcie->base + PCL_APP_PM0); 100 100 val |= PCL_SYS_AUX_PWR_DET; 101 - writel(val, priv->base + PCL_APP_PM0); 101 + writel(val, pcie->base + PCL_APP_PM0); 102 102 103 103 /* assert PERST# */ 104 - val = readl(priv->base + PCL_PINCTRL0); 104 + val = readl(pcie->base + PCL_PINCTRL0); 105 105 val &= ~(PCL_PERST_NOE_REGVAL | PCL_PERST_OUT_REGVAL 106 106 | PCL_PERST_PLDN_REGVAL); 107 107 val |= PCL_PERST_NOE_REGEN | PCL_PERST_OUT_REGEN 108 108 | PCL_PERST_PLDN_REGEN; 109 - writel(val, priv->base + PCL_PINCTRL0); 109 + writel(val, pcie->base + PCL_PINCTRL0); 110 110 111 - uniphier_pcie_ltssm_enable(priv, false); 111 + uniphier_pcie_ltssm_enable(pcie, false); 112 112 113 113 usleep_range(100000, 200000); 114 114 115 115 /* deassert PERST# */ 116 - val = readl(priv->base + PCL_PINCTRL0); 116 + val = readl(pcie->base + PCL_PINCTRL0); 117 117 val |= PCL_PERST_OUT_REGVAL | PCL_PERST_OUT_REGEN; 118 - writel(val, priv->base + PCL_PINCTRL0); 118 + writel(val, pcie->base + PCL_PINCTRL0); 119 119 } 120 120 121 - static int uniphier_pcie_wait_rc(struct uniphier_pcie_priv *priv) 121 + static int uniphier_pcie_wait_rc(struct uniphier_pcie *pcie) 122 122 { 123 123 u32 status; 124 124 int ret; 125 125 126 126 /* wait PIPE clock */ 127 - ret = readl_poll_timeout(priv->base + PCL_PIPEMON, status, 127 + ret = readl_poll_timeout(pcie->base + PCL_PIPEMON, status, 128 128 status & PCL_PCLK_ALIVE, 100000, 1000000); 129 129 if (ret) { 130 - dev_err(priv->pci.dev, 130 + dev_err(pcie->pci.dev, 131 131 "Failed to initialize controller in RC mode\n"); 132 132 return ret; 133 133 } ··· 137 137 138 138 static int uniphier_pcie_link_up(struct dw_pcie *pci) 139 139 { 140 - struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); 140 + struct uniphier_pcie *pcie = to_uniphier_pcie(pci); 141 141 u32 val, mask; 142 142 143 - val = readl(priv->base + PCL_STATUS_LINK); 143 + val = readl(pcie->base + PCL_STATUS_LINK); 144 144 mask = PCL_RDLH_LINK_UP | PCL_XMLH_LINK_UP; 145 145 146 146 return (val & mask) == mask; ··· 148 148 149 149 static int uniphier_pcie_start_link(struct dw_pcie *pci) 150 150 { 151 - struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); 151 + struct uniphier_pcie *pcie = to_uniphier_pcie(pci); 152 152 153 - uniphier_pcie_ltssm_enable(priv, true); 153 + uniphier_pcie_ltssm_enable(pcie, true); 154 154 155 155 return 0; 156 156 } 157 157 158 158 static void uniphier_pcie_stop_link(struct dw_pcie *pci) 159 159 { 160 - struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); 160 + struct uniphier_pcie *pcie = to_uniphier_pcie(pci); 161 161 162 - uniphier_pcie_ltssm_enable(priv, false); 162 + uniphier_pcie_ltssm_enable(pcie, false); 163 163 } 164 164 165 - static void uniphier_pcie_irq_enable(struct uniphier_pcie_priv *priv) 165 + static void uniphier_pcie_irq_enable(struct uniphier_pcie *pcie) 166 166 { 167 - writel(PCL_RCV_INT_ALL_ENABLE, priv->base + PCL_RCV_INT); 168 - writel(PCL_RCV_INTX_ALL_ENABLE, priv->base + PCL_RCV_INTX); 167 + writel(PCL_RCV_INT_ALL_ENABLE, pcie->base + PCL_RCV_INT); 168 + writel(PCL_RCV_INTX_ALL_ENABLE, pcie->base + PCL_RCV_INTX); 169 169 } 170 + 170 171 171 172 static void uniphier_pcie_irq_mask(struct irq_data *d) 172 173 { 173 174 struct pcie_port *pp = irq_data_get_irq_chip_data(d); 174 175 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 175 - struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); 176 + struct uniphier_pcie *pcie = to_uniphier_pcie(pci); 176 177 unsigned long flags; 177 178 u32 val; 178 179 179 180 raw_spin_lock_irqsave(&pp->lock, flags); 180 181 181 - val = readl(priv->base + PCL_RCV_INTX); 182 + val = readl(pcie->base + PCL_RCV_INTX); 182 183 val |= BIT(irqd_to_hwirq(d) + PCL_RCV_INTX_MASK_SHIFT); 183 - writel(val, priv->base + PCL_RCV_INTX); 184 + writel(val, pcie->base + PCL_RCV_INTX); 184 185 185 186 raw_spin_unlock_irqrestore(&pp->lock, flags); 186 187 } ··· 190 189 { 191 190 struct pcie_port *pp = irq_data_get_irq_chip_data(d); 192 191 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 193 - struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); 192 + struct uniphier_pcie *pcie = to_uniphier_pcie(pci); 194 193 unsigned long flags; 195 194 u32 val; 196 195 197 196 raw_spin_lock_irqsave(&pp->lock, flags); 198 197 199 - val = readl(priv->base + PCL_RCV_INTX); 198 + val = readl(pcie->base + PCL_RCV_INTX); 200 199 val &= ~BIT(irqd_to_hwirq(d) + PCL_RCV_INTX_MASK_SHIFT); 201 - writel(val, priv->base + PCL_RCV_INTX); 200 + writel(val, pcie->base + PCL_RCV_INTX); 202 201 203 202 raw_spin_unlock_irqrestore(&pp->lock, flags); 204 203 } ··· 227 226 { 228 227 struct pcie_port *pp = irq_desc_get_handler_data(desc); 229 228 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 230 - struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); 229 + struct uniphier_pcie *pcie = to_uniphier_pcie(pci); 231 230 struct irq_chip *chip = irq_desc_get_chip(desc); 232 231 unsigned long reg; 233 232 u32 val, bit; 234 233 235 234 /* INT for debug */ 236 - val = readl(priv->base + PCL_RCV_INT); 235 + val = readl(pcie->base + PCL_RCV_INT); 237 236 238 237 if (val & PCL_CFG_BW_MGT_STATUS) 239 238 dev_dbg(pci->dev, "Link Bandwidth Management Event\n"); ··· 244 243 if (val & PCL_CFG_PME_MSI_STATUS) 245 244 dev_dbg(pci->dev, "PME Interrupt\n"); 246 245 247 - writel(val, priv->base + PCL_RCV_INT); 246 + writel(val, pcie->base + PCL_RCV_INT); 248 247 249 248 /* INTx */ 250 249 chained_irq_enter(chip, desc); 251 250 252 - val = readl(priv->base + PCL_RCV_INTX); 251 + val = readl(pcie->base + PCL_RCV_INTX); 253 252 reg = FIELD_GET(PCL_RCV_INTX_ALL_STATUS, val); 254 253 255 254 for_each_set_bit(bit, &reg, PCI_NUM_INTX) 256 - generic_handle_domain_irq(priv->legacy_irq_domain, bit); 255 + generic_handle_domain_irq(pcie->legacy_irq_domain, bit); 257 256 258 257 chained_irq_exit(chip, desc); 259 258 } ··· 261 260 static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp) 262 261 { 263 262 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 264 - struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); 263 + struct uniphier_pcie *pcie = to_uniphier_pcie(pci); 265 264 struct device_node *np = pci->dev->of_node; 266 265 struct device_node *np_intc; 267 266 int ret = 0; ··· 279 278 goto out_put_node; 280 279 } 281 280 282 - priv->legacy_irq_domain = irq_domain_add_linear(np_intc, PCI_NUM_INTX, 281 + pcie->legacy_irq_domain = irq_domain_add_linear(np_intc, PCI_NUM_INTX, 283 282 &uniphier_intx_domain_ops, pp); 284 - if (!priv->legacy_irq_domain) { 283 + if (!pcie->legacy_irq_domain) { 285 284 dev_err(pci->dev, "Failed to get INTx domain\n"); 286 285 ret = -ENODEV; 287 286 goto out_put_node; ··· 298 297 static int uniphier_pcie_host_init(struct pcie_port *pp) 299 298 { 300 299 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); 301 - struct uniphier_pcie_priv *priv = to_uniphier_pcie(pci); 300 + struct uniphier_pcie *pcie = to_uniphier_pcie(pci); 302 301 int ret; 303 302 304 303 ret = uniphier_pcie_config_legacy_irq(pp); 305 304 if (ret) 306 305 return ret; 307 306 308 - uniphier_pcie_irq_enable(priv); 307 + uniphier_pcie_irq_enable(pcie); 309 308 310 309 return 0; 311 310 } ··· 314 313 .host_init = uniphier_pcie_host_init, 315 314 }; 316 315 317 - static int uniphier_pcie_host_enable(struct uniphier_pcie_priv *priv) 316 + static int uniphier_pcie_host_enable(struct uniphier_pcie *pcie) 318 317 { 319 318 int ret; 320 319 321 - ret = clk_prepare_enable(priv->clk); 320 + ret = clk_prepare_enable(pcie->clk); 322 321 if (ret) 323 322 return ret; 324 323 325 - ret = reset_control_deassert(priv->rst); 324 + ret = reset_control_deassert(pcie->rst); 326 325 if (ret) 327 326 goto out_clk_disable; 328 327 329 - uniphier_pcie_init_rc(priv); 328 + uniphier_pcie_init_rc(pcie); 330 329 331 - ret = phy_init(priv->phy); 330 + ret = phy_init(pcie->phy); 332 331 if (ret) 333 332 goto out_rst_assert; 334 333 335 - ret = uniphier_pcie_wait_rc(priv); 334 + ret = uniphier_pcie_wait_rc(pcie); 336 335 if (ret) 337 336 goto out_phy_exit; 338 337 339 338 return 0; 340 339 341 340 out_phy_exit: 342 - phy_exit(priv->phy); 341 + phy_exit(pcie->phy); 343 342 out_rst_assert: 344 - reset_control_assert(priv->rst); 343 + reset_control_assert(pcie->rst); 345 344 out_clk_disable: 346 - clk_disable_unprepare(priv->clk); 345 + clk_disable_unprepare(pcie->clk); 347 346 348 347 return ret; 349 348 } ··· 357 356 static int uniphier_pcie_probe(struct platform_device *pdev) 358 357 { 359 358 struct device *dev = &pdev->dev; 360 - struct uniphier_pcie_priv *priv; 359 + struct uniphier_pcie *pcie; 361 360 int ret; 362 361 363 - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 364 - if (!priv) 362 + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); 363 + if (!pcie) 365 364 return -ENOMEM; 366 365 367 - priv->pci.dev = dev; 368 - priv->pci.ops = &dw_pcie_ops; 366 + pcie->pci.dev = dev; 367 + pcie->pci.ops = &dw_pcie_ops; 369 368 370 - priv->base = devm_platform_ioremap_resource_byname(pdev, "link"); 371 - if (IS_ERR(priv->base)) 372 - return PTR_ERR(priv->base); 369 + pcie->base = devm_platform_ioremap_resource_byname(pdev, "link"); 370 + if (IS_ERR(pcie->base)) 371 + return PTR_ERR(pcie->base); 373 372 374 - priv->clk = devm_clk_get(dev, NULL); 375 - if (IS_ERR(priv->clk)) 376 - return PTR_ERR(priv->clk); 373 + pcie->clk = devm_clk_get(dev, NULL); 374 + if (IS_ERR(pcie->clk)) 375 + return PTR_ERR(pcie->clk); 377 376 378 - priv->rst = devm_reset_control_get_shared(dev, NULL); 379 - if (IS_ERR(priv->rst)) 380 - return PTR_ERR(priv->rst); 377 + pcie->rst = devm_reset_control_get_shared(dev, NULL); 378 + if (IS_ERR(pcie->rst)) 379 + return PTR_ERR(pcie->rst); 381 380 382 - priv->phy = devm_phy_optional_get(dev, "pcie-phy"); 383 - if (IS_ERR(priv->phy)) 384 - return PTR_ERR(priv->phy); 381 + pcie->phy = devm_phy_optional_get(dev, "pcie-phy"); 382 + if (IS_ERR(pcie->phy)) 383 + return PTR_ERR(pcie->phy); 385 384 386 - platform_set_drvdata(pdev, priv); 385 + platform_set_drvdata(pdev, pcie); 387 386 388 - ret = uniphier_pcie_host_enable(priv); 387 + ret = uniphier_pcie_host_enable(pcie); 389 388 if (ret) 390 389 return ret; 391 390 392 - priv->pci.pp.ops = &uniphier_pcie_host_ops; 391 + pcie->pci.pp.ops = &uniphier_pcie_host_ops; 393 392 394 - return dw_pcie_host_init(&priv->pci.pp); 393 + return dw_pcie_host_init(&pcie->pci.pp); 395 394 } 396 395 397 396 static const struct of_device_id uniphier_pcie_match[] = {
+42 -42
drivers/pci/controller/mobiveil/pcie-layerscape-gen4.c
··· 34 34 #define PF_DBG_WE BIT(31) 35 35 #define PF_DBG_PABR BIT(27) 36 36 37 - #define to_ls_pcie_g4(x) platform_get_drvdata((x)->pdev) 37 + #define to_ls_g4_pcie(x) platform_get_drvdata((x)->pdev) 38 38 39 - struct ls_pcie_g4 { 39 + struct ls_g4_pcie { 40 40 struct mobiveil_pcie pci; 41 41 struct delayed_work dwork; 42 42 int irq; 43 43 }; 44 44 45 - static inline u32 ls_pcie_g4_pf_readl(struct ls_pcie_g4 *pcie, u32 off) 45 + static inline u32 ls_g4_pcie_pf_readl(struct ls_g4_pcie *pcie, u32 off) 46 46 { 47 47 return ioread32(pcie->pci.csr_axi_slave_base + PCIE_PF_OFF + off); 48 48 } 49 49 50 - static inline void ls_pcie_g4_pf_writel(struct ls_pcie_g4 *pcie, 50 + static inline void ls_g4_pcie_pf_writel(struct ls_g4_pcie *pcie, 51 51 u32 off, u32 val) 52 52 { 53 53 iowrite32(val, pcie->pci.csr_axi_slave_base + PCIE_PF_OFF + off); 54 54 } 55 55 56 - static int ls_pcie_g4_link_up(struct mobiveil_pcie *pci) 56 + static int ls_g4_pcie_link_up(struct mobiveil_pcie *pci) 57 57 { 58 - struct ls_pcie_g4 *pcie = to_ls_pcie_g4(pci); 58 + struct ls_g4_pcie *pcie = to_ls_g4_pcie(pci); 59 59 u32 state; 60 60 61 - state = ls_pcie_g4_pf_readl(pcie, PCIE_PF_DBG); 61 + state = ls_g4_pcie_pf_readl(pcie, PCIE_PF_DBG); 62 62 state = state & PF_DBG_LTSSM_MASK; 63 63 64 64 if (state == PF_DBG_LTSSM_L0) ··· 67 67 return 0; 68 68 } 69 69 70 - static void ls_pcie_g4_disable_interrupt(struct ls_pcie_g4 *pcie) 70 + static void ls_g4_pcie_disable_interrupt(struct ls_g4_pcie *pcie) 71 71 { 72 72 struct mobiveil_pcie *mv_pci = &pcie->pci; 73 73 74 74 mobiveil_csr_writel(mv_pci, 0, PAB_INTP_AMBA_MISC_ENB); 75 75 } 76 76 77 - static void ls_pcie_g4_enable_interrupt(struct ls_pcie_g4 *pcie) 77 + static void ls_g4_pcie_enable_interrupt(struct ls_g4_pcie *pcie) 78 78 { 79 79 struct mobiveil_pcie *mv_pci = &pcie->pci; 80 80 u32 val; ··· 87 87 mobiveil_csr_writel(mv_pci, val, PAB_INTP_AMBA_MISC_ENB); 88 88 } 89 89 90 - static int ls_pcie_g4_reinit_hw(struct ls_pcie_g4 *pcie) 90 + static int ls_g4_pcie_reinit_hw(struct ls_g4_pcie *pcie) 91 91 { 92 92 struct mobiveil_pcie *mv_pci = &pcie->pci; 93 93 struct device *dev = &mv_pci->pdev->dev; ··· 97 97 /* Poll for pab_csb_reset to set and PAB activity to clear */ 98 98 do { 99 99 usleep_range(10, 15); 100 - val = ls_pcie_g4_pf_readl(pcie, PCIE_PF_INT_STAT); 100 + val = ls_g4_pcie_pf_readl(pcie, PCIE_PF_INT_STAT); 101 101 act_stat = mobiveil_csr_readl(mv_pci, PAB_ACTIVITY_STAT); 102 102 } while (((val & PF_INT_STAT_PABRST) == 0 || act_stat) && to--); 103 103 if (to < 0) { ··· 106 106 } 107 107 108 108 /* clear PEX_RESET bit in PEX_PF0_DBG register */ 109 - val = ls_pcie_g4_pf_readl(pcie, PCIE_PF_DBG); 109 + val = ls_g4_pcie_pf_readl(pcie, PCIE_PF_DBG); 110 110 val |= PF_DBG_WE; 111 - ls_pcie_g4_pf_writel(pcie, PCIE_PF_DBG, val); 111 + ls_g4_pcie_pf_writel(pcie, PCIE_PF_DBG, val); 112 112 113 - val = ls_pcie_g4_pf_readl(pcie, PCIE_PF_DBG); 113 + val = ls_g4_pcie_pf_readl(pcie, PCIE_PF_DBG); 114 114 val |= PF_DBG_PABR; 115 - ls_pcie_g4_pf_writel(pcie, PCIE_PF_DBG, val); 115 + ls_g4_pcie_pf_writel(pcie, PCIE_PF_DBG, val); 116 116 117 - val = ls_pcie_g4_pf_readl(pcie, PCIE_PF_DBG); 117 + val = ls_g4_pcie_pf_readl(pcie, PCIE_PF_DBG); 118 118 val &= ~PF_DBG_WE; 119 - ls_pcie_g4_pf_writel(pcie, PCIE_PF_DBG, val); 119 + ls_g4_pcie_pf_writel(pcie, PCIE_PF_DBG, val); 120 120 121 121 mobiveil_host_init(mv_pci, true); 122 122 123 123 to = 100; 124 - while (!ls_pcie_g4_link_up(mv_pci) && to--) 124 + while (!ls_g4_pcie_link_up(mv_pci) && to--) 125 125 usleep_range(200, 250); 126 126 if (to < 0) { 127 127 dev_err(dev, "PCIe link training timeout\n"); ··· 131 131 return 0; 132 132 } 133 133 134 - static irqreturn_t ls_pcie_g4_isr(int irq, void *dev_id) 134 + static irqreturn_t ls_g4_pcie_isr(int irq, void *dev_id) 135 135 { 136 - struct ls_pcie_g4 *pcie = (struct ls_pcie_g4 *)dev_id; 136 + struct ls_g4_pcie *pcie = (struct ls_g4_pcie *)dev_id; 137 137 struct mobiveil_pcie *mv_pci = &pcie->pci; 138 138 u32 val; 139 139 ··· 142 142 return IRQ_NONE; 143 143 144 144 if (val & PAB_INTP_RESET) { 145 - ls_pcie_g4_disable_interrupt(pcie); 145 + ls_g4_pcie_disable_interrupt(pcie); 146 146 schedule_delayed_work(&pcie->dwork, msecs_to_jiffies(1)); 147 147 } 148 148 ··· 151 151 return IRQ_HANDLED; 152 152 } 153 153 154 - static int ls_pcie_g4_interrupt_init(struct mobiveil_pcie *mv_pci) 154 + static int ls_g4_pcie_interrupt_init(struct mobiveil_pcie *mv_pci) 155 155 { 156 - struct ls_pcie_g4 *pcie = to_ls_pcie_g4(mv_pci); 156 + struct ls_g4_pcie *pcie = to_ls_g4_pcie(mv_pci); 157 157 struct platform_device *pdev = mv_pci->pdev; 158 158 struct device *dev = &pdev->dev; 159 159 int ret; ··· 162 162 if (pcie->irq < 0) 163 163 return pcie->irq; 164 164 165 - ret = devm_request_irq(dev, pcie->irq, ls_pcie_g4_isr, 165 + ret = devm_request_irq(dev, pcie->irq, ls_g4_pcie_isr, 166 166 IRQF_SHARED, pdev->name, pcie); 167 167 if (ret) { 168 168 dev_err(dev, "Can't register PCIe IRQ, errno = %d\n", ret); ··· 172 172 return 0; 173 173 } 174 174 175 - static void ls_pcie_g4_reset(struct work_struct *work) 175 + static void ls_g4_pcie_reset(struct work_struct *work) 176 176 { 177 177 struct delayed_work *dwork = container_of(work, struct delayed_work, 178 178 work); 179 - struct ls_pcie_g4 *pcie = container_of(dwork, struct ls_pcie_g4, dwork); 179 + struct ls_g4_pcie *pcie = container_of(dwork, struct ls_g4_pcie, dwork); 180 180 struct mobiveil_pcie *mv_pci = &pcie->pci; 181 181 u16 ctrl; 182 182 ··· 184 184 ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET; 185 185 mobiveil_csr_writew(mv_pci, ctrl, PCI_BRIDGE_CONTROL); 186 186 187 - if (!ls_pcie_g4_reinit_hw(pcie)) 187 + if (!ls_g4_pcie_reinit_hw(pcie)) 188 188 return; 189 189 190 - ls_pcie_g4_enable_interrupt(pcie); 190 + ls_g4_pcie_enable_interrupt(pcie); 191 191 } 192 192 193 - static struct mobiveil_rp_ops ls_pcie_g4_rp_ops = { 194 - .interrupt_init = ls_pcie_g4_interrupt_init, 193 + static struct mobiveil_rp_ops ls_g4_pcie_rp_ops = { 194 + .interrupt_init = ls_g4_pcie_interrupt_init, 195 195 }; 196 196 197 - static const struct mobiveil_pab_ops ls_pcie_g4_pab_ops = { 198 - .link_up = ls_pcie_g4_link_up, 197 + static const struct mobiveil_pab_ops ls_g4_pcie_pab_ops = { 198 + .link_up = ls_g4_pcie_link_up, 199 199 }; 200 200 201 - static int __init ls_pcie_g4_probe(struct platform_device *pdev) 201 + static int __init ls_g4_pcie_probe(struct platform_device *pdev) 202 202 { 203 203 struct device *dev = &pdev->dev; 204 204 struct pci_host_bridge *bridge; 205 205 struct mobiveil_pcie *mv_pci; 206 - struct ls_pcie_g4 *pcie; 206 + struct ls_g4_pcie *pcie; 207 207 struct device_node *np = dev->of_node; 208 208 int ret; 209 209 ··· 220 220 mv_pci = &pcie->pci; 221 221 222 222 mv_pci->pdev = pdev; 223 - mv_pci->ops = &ls_pcie_g4_pab_ops; 224 - mv_pci->rp.ops = &ls_pcie_g4_rp_ops; 223 + mv_pci->ops = &ls_g4_pcie_pab_ops; 224 + mv_pci->rp.ops = &ls_g4_pcie_rp_ops; 225 225 mv_pci->rp.bridge = bridge; 226 226 227 227 platform_set_drvdata(pdev, pcie); 228 228 229 - INIT_DELAYED_WORK(&pcie->dwork, ls_pcie_g4_reset); 229 + INIT_DELAYED_WORK(&pcie->dwork, ls_g4_pcie_reset); 230 230 231 231 ret = mobiveil_pcie_host_probe(mv_pci); 232 232 if (ret) { ··· 234 234 return ret; 235 235 } 236 236 237 - ls_pcie_g4_enable_interrupt(pcie); 237 + ls_g4_pcie_enable_interrupt(pcie); 238 238 239 239 return 0; 240 240 } 241 241 242 - static const struct of_device_id ls_pcie_g4_of_match[] = { 242 + static const struct of_device_id ls_g4_pcie_of_match[] = { 243 243 { .compatible = "fsl,lx2160a-pcie", }, 244 244 { }, 245 245 }; 246 246 247 - static struct platform_driver ls_pcie_g4_driver = { 247 + static struct platform_driver ls_g4_pcie_driver = { 248 248 .driver = { 249 249 .name = "layerscape-pcie-gen4", 250 - .of_match_table = ls_pcie_g4_of_match, 250 + .of_match_table = ls_g4_pcie_of_match, 251 251 .suppress_bind_attrs = true, 252 252 }, 253 253 }; 254 254 255 - builtin_platform_driver_probe(ls_pcie_g4_driver, ls_pcie_g4_probe); 255 + builtin_platform_driver_probe(ls_g4_pcie_driver, ls_g4_pcie_probe);
+7 -7
drivers/pci/controller/pci-rcar-gen2.c
··· 93 93 94 94 #define RCAR_PCI_UNIT_REV_REG (RCAR_AHBPCI_PCICOM_OFFSET + 0x48) 95 95 96 - struct rcar_pci_priv { 96 + struct rcar_pci { 97 97 struct device *dev; 98 98 void __iomem *reg; 99 99 struct resource mem_res; ··· 105 105 static void __iomem *rcar_pci_cfg_base(struct pci_bus *bus, unsigned int devfn, 106 106 int where) 107 107 { 108 - struct rcar_pci_priv *priv = bus->sysdata; 108 + struct rcar_pci *priv = bus->sysdata; 109 109 int slot, val; 110 110 111 111 if (!pci_is_root_bus(bus) || PCI_FUNC(devfn)) ··· 132 132 133 133 static irqreturn_t rcar_pci_err_irq(int irq, void *pw) 134 134 { 135 - struct rcar_pci_priv *priv = pw; 135 + struct rcar_pci *priv = pw; 136 136 struct device *dev = priv->dev; 137 137 u32 status = ioread32(priv->reg + RCAR_PCI_INT_STATUS_REG); 138 138 ··· 148 148 return IRQ_NONE; 149 149 } 150 150 151 - static void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) 151 + static void rcar_pci_setup_errirq(struct rcar_pci *priv) 152 152 { 153 153 struct device *dev = priv->dev; 154 154 int ret; ··· 166 166 iowrite32(val, priv->reg + RCAR_PCI_INT_ENABLE_REG); 167 167 } 168 168 #else 169 - static inline void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) { } 169 + static inline void rcar_pci_setup_errirq(struct rcar_pci *priv) { } 170 170 #endif 171 171 172 172 /* PCI host controller setup */ 173 - static void rcar_pci_setup(struct rcar_pci_priv *priv) 173 + static void rcar_pci_setup(struct rcar_pci *priv) 174 174 { 175 175 struct pci_host_bridge *bridge = pci_host_bridge_from_priv(priv); 176 176 struct device *dev = priv->dev; ··· 279 279 { 280 280 struct device *dev = &pdev->dev; 281 281 struct resource *cfg_res, *mem_res; 282 - struct rcar_pci_priv *priv; 282 + struct rcar_pci *priv; 283 283 struct pci_host_bridge *bridge; 284 284 void __iomem *reg; 285 285
+23 -23
drivers/pci/controller/pci-xgene.c
··· 60 60 #define XGENE_PCIE_IP_VER_2 2 61 61 62 62 #if defined(CONFIG_PCI_XGENE) || (defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS)) 63 - struct xgene_pcie_port { 63 + struct xgene_pcie { 64 64 struct device_node *node; 65 65 struct device *dev; 66 66 struct clk *clk; ··· 71 71 u32 version; 72 72 }; 73 73 74 - static u32 xgene_pcie_readl(struct xgene_pcie_port *port, u32 reg) 74 + static u32 xgene_pcie_readl(struct xgene_pcie *port, u32 reg) 75 75 { 76 76 return readl(port->csr_base + reg); 77 77 } 78 78 79 - static void xgene_pcie_writel(struct xgene_pcie_port *port, u32 reg, u32 val) 79 + static void xgene_pcie_writel(struct xgene_pcie *port, u32 reg, u32 val) 80 80 { 81 81 writel(val, port->csr_base + reg); 82 82 } ··· 86 86 return (addr & PCI_BASE_ADDRESS_MEM_MASK) | flags; 87 87 } 88 88 89 - static inline struct xgene_pcie_port *pcie_bus_to_port(struct pci_bus *bus) 89 + static inline struct xgene_pcie *pcie_bus_to_port(struct pci_bus *bus) 90 90 { 91 91 struct pci_config_window *cfg; 92 92 93 93 if (acpi_disabled) 94 - return (struct xgene_pcie_port *)(bus->sysdata); 94 + return (struct xgene_pcie *)(bus->sysdata); 95 95 96 96 cfg = bus->sysdata; 97 - return (struct xgene_pcie_port *)(cfg->priv); 97 + return (struct xgene_pcie *)(cfg->priv); 98 98 } 99 99 100 100 /* ··· 103 103 */ 104 104 static void __iomem *xgene_pcie_get_cfg_base(struct pci_bus *bus) 105 105 { 106 - struct xgene_pcie_port *port = pcie_bus_to_port(bus); 106 + struct xgene_pcie *port = pcie_bus_to_port(bus); 107 107 108 108 if (bus->number >= (bus->primary + 1)) 109 109 return port->cfg_base + AXI_EP_CFG_ACCESS; ··· 117 117 */ 118 118 static void xgene_pcie_set_rtdid_reg(struct pci_bus *bus, uint devfn) 119 119 { 120 - struct xgene_pcie_port *port = pcie_bus_to_port(bus); 120 + struct xgene_pcie *port = pcie_bus_to_port(bus); 121 121 unsigned int b, d, f; 122 122 u32 rtdid_val = 0; 123 123 ··· 164 164 static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn, 165 165 int where, int size, u32 *val) 166 166 { 167 - struct xgene_pcie_port *port = pcie_bus_to_port(bus); 167 + struct xgene_pcie *port = pcie_bus_to_port(bus); 168 168 169 169 if (pci_generic_config_read32(bus, devfn, where & ~0x3, 4, val) != 170 170 PCIBIOS_SUCCESSFUL) ··· 227 227 { 228 228 struct device *dev = cfg->parent; 229 229 struct acpi_device *adev = to_acpi_device(dev); 230 - struct xgene_pcie_port *port; 230 + struct xgene_pcie *port; 231 231 struct resource csr; 232 232 int ret; 233 233 ··· 281 281 #endif 282 282 283 283 #if defined(CONFIG_PCI_XGENE) 284 - static u64 xgene_pcie_set_ib_mask(struct xgene_pcie_port *port, u32 addr, 284 + static u64 xgene_pcie_set_ib_mask(struct xgene_pcie *port, u32 addr, 285 285 u32 flags, u64 size) 286 286 { 287 287 u64 mask = (~(size - 1) & PCI_BASE_ADDRESS_MEM_MASK) | flags; ··· 307 307 return mask; 308 308 } 309 309 310 - static void xgene_pcie_linkup(struct xgene_pcie_port *port, 310 + static void xgene_pcie_linkup(struct xgene_pcie *port, 311 311 u32 *lanes, u32 *speed) 312 312 { 313 313 u32 val32; ··· 322 322 } 323 323 } 324 324 325 - static int xgene_pcie_init_port(struct xgene_pcie_port *port) 325 + static int xgene_pcie_init_port(struct xgene_pcie *port) 326 326 { 327 327 struct device *dev = port->dev; 328 328 int rc; ··· 342 342 return 0; 343 343 } 344 344 345 - static int xgene_pcie_map_reg(struct xgene_pcie_port *port, 345 + static int xgene_pcie_map_reg(struct xgene_pcie *port, 346 346 struct platform_device *pdev) 347 347 { 348 348 struct device *dev = port->dev; ··· 362 362 return 0; 363 363 } 364 364 365 - static void xgene_pcie_setup_ob_reg(struct xgene_pcie_port *port, 365 + static void xgene_pcie_setup_ob_reg(struct xgene_pcie *port, 366 366 struct resource *res, u32 offset, 367 367 u64 cpu_addr, u64 pci_addr) 368 368 { ··· 394 394 xgene_pcie_writel(port, offset + 0x14, upper_32_bits(pci_addr)); 395 395 } 396 396 397 - static void xgene_pcie_setup_cfg_reg(struct xgene_pcie_port *port) 397 + static void xgene_pcie_setup_cfg_reg(struct xgene_pcie *port) 398 398 { 399 399 u64 addr = port->cfg_addr; 400 400 ··· 403 403 xgene_pcie_writel(port, CFGCTL, EN_REG); 404 404 } 405 405 406 - static int xgene_pcie_map_ranges(struct xgene_pcie_port *port) 406 + static int xgene_pcie_map_ranges(struct xgene_pcie *port) 407 407 { 408 408 struct pci_host_bridge *bridge = pci_host_bridge_from_priv(port); 409 409 struct resource_entry *window; ··· 444 444 return 0; 445 445 } 446 446 447 - static void xgene_pcie_setup_pims(struct xgene_pcie_port *port, u32 pim_reg, 447 + static void xgene_pcie_setup_pims(struct xgene_pcie *port, u32 pim_reg, 448 448 u64 pim, u64 size) 449 449 { 450 450 xgene_pcie_writel(port, pim_reg, lower_32_bits(pim)); ··· 478 478 return -EINVAL; 479 479 } 480 480 481 - static void xgene_pcie_setup_ib_reg(struct xgene_pcie_port *port, 481 + static void xgene_pcie_setup_ib_reg(struct xgene_pcie *port, 482 482 struct resource_entry *entry, 483 483 u8 *ib_reg_mask) 484 484 { ··· 529 529 xgene_pcie_setup_pims(port, pim_reg, pci_addr, ~(size - 1)); 530 530 } 531 531 532 - static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port) 532 + static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie *port) 533 533 { 534 534 struct pci_host_bridge *bridge = pci_host_bridge_from_priv(port); 535 535 struct resource_entry *entry; ··· 542 542 } 543 543 544 544 /* clear BAR configuration which was done by firmware */ 545 - static void xgene_pcie_clear_config(struct xgene_pcie_port *port) 545 + static void xgene_pcie_clear_config(struct xgene_pcie *port) 546 546 { 547 547 int i; 548 548 ··· 550 550 xgene_pcie_writel(port, i, 0); 551 551 } 552 552 553 - static int xgene_pcie_setup(struct xgene_pcie_port *port) 553 + static int xgene_pcie_setup(struct xgene_pcie *port) 554 554 { 555 555 struct device *dev = port->dev; 556 556 u32 val, lanes = 0, speed = 0; ··· 588 588 { 589 589 struct device *dev = &pdev->dev; 590 590 struct device_node *dn = dev->of_node; 591 - struct xgene_pcie_port *port; 591 + struct xgene_pcie *port; 592 592 struct pci_host_bridge *bridge; 593 593 int ret; 594 594
+4 -4
drivers/pci/controller/pcie-altera.c
··· 765 765 struct altera_pcie *pcie; 766 766 struct pci_host_bridge *bridge; 767 767 int ret; 768 - const struct of_device_id *match; 768 + const struct altera_pcie_data *data; 769 769 770 770 bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); 771 771 if (!bridge) ··· 775 775 pcie->pdev = pdev; 776 776 platform_set_drvdata(pdev, pcie); 777 777 778 - match = of_match_device(altera_pcie_of_match, &pdev->dev); 779 - if (!match) 778 + data = of_device_get_match_data(&pdev->dev); 779 + if (!data) 780 780 return -ENODEV; 781 781 782 - pcie->pcie_data = match->data; 782 + pcie->pcie_data = data; 783 783 784 784 ret = altera_pcie_parse_dt(pcie); 785 785 if (ret) {
+11 -11
drivers/pci/controller/pcie-iproc-bcma.c
··· 23 23 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x8011, bcma_pcie2_fixup_class); 24 24 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x8012, bcma_pcie2_fixup_class); 25 25 26 - static int iproc_pcie_bcma_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 26 + static int iproc_bcma_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 27 27 { 28 28 struct iproc_pcie *pcie = dev->sysdata; 29 29 struct bcma_device *bdev = container_of(pcie->dev, struct bcma_device, dev); ··· 31 31 return bcma_core_irq(bdev, 5); 32 32 } 33 33 34 - static int iproc_pcie_bcma_probe(struct bcma_device *bdev) 34 + static int iproc_bcma_pcie_probe(struct bcma_device *bdev) 35 35 { 36 36 struct device *dev = &bdev->dev; 37 37 struct iproc_pcie *pcie; ··· 64 64 if (ret) 65 65 return ret; 66 66 67 - pcie->map_irq = iproc_pcie_bcma_map_irq; 67 + pcie->map_irq = iproc_bcma_pcie_map_irq; 68 68 69 69 bcma_set_drvdata(bdev, pcie); 70 70 71 71 return iproc_pcie_setup(pcie, &bridge->windows); 72 72 } 73 73 74 - static void iproc_pcie_bcma_remove(struct bcma_device *bdev) 74 + static void iproc_bcma_pcie_remove(struct bcma_device *bdev) 75 75 { 76 76 struct iproc_pcie *pcie = bcma_get_drvdata(bdev); 77 77 78 78 iproc_pcie_remove(pcie); 79 79 } 80 80 81 - static const struct bcma_device_id iproc_pcie_bcma_table[] = { 81 + static const struct bcma_device_id iproc_bcma_pcie_table[] = { 82 82 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_PCIEG2, BCMA_ANY_REV, BCMA_ANY_CLASS), 83 83 {}, 84 84 }; 85 - MODULE_DEVICE_TABLE(bcma, iproc_pcie_bcma_table); 85 + MODULE_DEVICE_TABLE(bcma, iproc_bcma_pcie_table); 86 86 87 - static struct bcma_driver iproc_pcie_bcma_driver = { 87 + static struct bcma_driver iproc_bcma_pcie_driver = { 88 88 .name = KBUILD_MODNAME, 89 - .id_table = iproc_pcie_bcma_table, 90 - .probe = iproc_pcie_bcma_probe, 91 - .remove = iproc_pcie_bcma_remove, 89 + .id_table = iproc_bcma_pcie_table, 90 + .probe = iproc_bcma_pcie_probe, 91 + .remove = iproc_bcma_pcie_remove, 92 92 }; 93 - module_bcma_driver(iproc_pcie_bcma_driver); 93 + module_bcma_driver(iproc_bcma_pcie_driver); 94 94 95 95 MODULE_AUTHOR("Hauke Mehrtens"); 96 96 MODULE_DESCRIPTION("Broadcom iProc PCIe BCMA driver");
+8 -8
drivers/pci/controller/pcie-iproc-platform.c
··· 37 37 }; 38 38 MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table); 39 39 40 - static int iproc_pcie_pltfm_probe(struct platform_device *pdev) 40 + static int iproc_pltfm_pcie_probe(struct platform_device *pdev) 41 41 { 42 42 struct device *dev = &pdev->dev; 43 43 struct iproc_pcie *pcie; ··· 115 115 return 0; 116 116 } 117 117 118 - static int iproc_pcie_pltfm_remove(struct platform_device *pdev) 118 + static int iproc_pltfm_pcie_remove(struct platform_device *pdev) 119 119 { 120 120 struct iproc_pcie *pcie = platform_get_drvdata(pdev); 121 121 122 122 return iproc_pcie_remove(pcie); 123 123 } 124 124 125 - static void iproc_pcie_pltfm_shutdown(struct platform_device *pdev) 125 + static void iproc_pltfm_pcie_shutdown(struct platform_device *pdev) 126 126 { 127 127 struct iproc_pcie *pcie = platform_get_drvdata(pdev); 128 128 129 129 iproc_pcie_shutdown(pcie); 130 130 } 131 131 132 - static struct platform_driver iproc_pcie_pltfm_driver = { 132 + static struct platform_driver iproc_pltfm_pcie_driver = { 133 133 .driver = { 134 134 .name = "iproc-pcie", 135 135 .of_match_table = of_match_ptr(iproc_pcie_of_match_table), 136 136 }, 137 - .probe = iproc_pcie_pltfm_probe, 138 - .remove = iproc_pcie_pltfm_remove, 139 - .shutdown = iproc_pcie_pltfm_shutdown, 137 + .probe = iproc_pltfm_pcie_probe, 138 + .remove = iproc_pltfm_pcie_remove, 139 + .shutdown = iproc_pltfm_pcie_shutdown, 140 140 }; 141 - module_platform_driver(iproc_pcie_pltfm_driver); 141 + module_platform_driver(iproc_pltfm_pcie_driver); 142 142 143 143 MODULE_AUTHOR("Ray Jui <rjui@broadcom.com>"); 144 144 MODULE_DESCRIPTION("Broadcom iPROC PCIe platform driver");
+188 -188
drivers/pci/controller/pcie-mediatek-gen3.c
··· 113 113 }; 114 114 115 115 /** 116 - * struct mtk_pcie_port - PCIe port information 116 + * struct mtk_gen3_pcie - PCIe port information 117 117 * @dev: pointer to PCIe device 118 118 * @base: IO mapped register base 119 119 * @reg_base: physical register base ··· 132 132 * @lock: lock protecting IRQ bit map 133 133 * @msi_irq_in_use: bit map for assigned MSI IRQ 134 134 */ 135 - struct mtk_pcie_port { 135 + struct mtk_gen3_pcie { 136 136 struct device *dev; 137 137 void __iomem *base; 138 138 phys_addr_t reg_base; ··· 165 165 static void mtk_pcie_config_tlp_header(struct pci_bus *bus, unsigned int devfn, 166 166 int where, int size) 167 167 { 168 - struct mtk_pcie_port *port = bus->sysdata; 168 + struct mtk_gen3_pcie *pcie = bus->sysdata; 169 169 int bytes; 170 170 u32 val; 171 171 ··· 174 174 val = PCIE_CFG_FORCE_BYTE_EN | PCIE_CFG_BYTE_EN(bytes) | 175 175 PCIE_CFG_HEADER(bus->number, devfn); 176 176 177 - writel_relaxed(val, port->base + PCIE_CFGNUM_REG); 177 + writel_relaxed(val, pcie->base + PCIE_CFGNUM_REG); 178 178 } 179 179 180 180 static void __iomem *mtk_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, 181 181 int where) 182 182 { 183 - struct mtk_pcie_port *port = bus->sysdata; 183 + struct mtk_gen3_pcie *pcie = bus->sysdata; 184 184 185 - return port->base + PCIE_CFG_OFFSET_ADDR + where; 185 + return pcie->base + PCIE_CFG_OFFSET_ADDR + where; 186 186 } 187 187 188 188 static int mtk_pcie_config_read(struct pci_bus *bus, unsigned int devfn, ··· 210 210 .write = mtk_pcie_config_write, 211 211 }; 212 212 213 - static int mtk_pcie_set_trans_table(struct mtk_pcie_port *port, 213 + static int mtk_pcie_set_trans_table(struct mtk_gen3_pcie *pcie, 214 214 resource_size_t cpu_addr, 215 215 resource_size_t pci_addr, 216 216 resource_size_t size, ··· 220 220 u32 val; 221 221 222 222 if (num >= PCIE_MAX_TRANS_TABLES) { 223 - dev_err(port->dev, "not enough translate table for addr: %#llx, limited to [%d]\n", 223 + dev_err(pcie->dev, "not enough translate table for addr: %#llx, limited to [%d]\n", 224 224 (unsigned long long)cpu_addr, PCIE_MAX_TRANS_TABLES); 225 225 return -ENODEV; 226 226 } 227 227 228 - table = port->base + PCIE_TRANS_TABLE_BASE_REG + 228 + table = pcie->base + PCIE_TRANS_TABLE_BASE_REG + 229 229 num * PCIE_ATR_TLB_SET_OFFSET; 230 230 231 231 writel_relaxed(lower_32_bits(cpu_addr) | PCIE_ATR_SIZE(fls(size) - 1), ··· 247 247 return 0; 248 248 } 249 249 250 - static void mtk_pcie_enable_msi(struct mtk_pcie_port *port) 250 + static void mtk_pcie_enable_msi(struct mtk_gen3_pcie *pcie) 251 251 { 252 252 int i; 253 253 u32 val; 254 254 255 255 for (i = 0; i < PCIE_MSI_SET_NUM; i++) { 256 - struct mtk_msi_set *msi_set = &port->msi_sets[i]; 256 + struct mtk_msi_set *msi_set = &pcie->msi_sets[i]; 257 257 258 - msi_set->base = port->base + PCIE_MSI_SET_BASE_REG + 258 + msi_set->base = pcie->base + PCIE_MSI_SET_BASE_REG + 259 259 i * PCIE_MSI_SET_OFFSET; 260 - msi_set->msg_addr = port->reg_base + PCIE_MSI_SET_BASE_REG + 260 + msi_set->msg_addr = pcie->reg_base + PCIE_MSI_SET_BASE_REG + 261 261 i * PCIE_MSI_SET_OFFSET; 262 262 263 263 /* Configure the MSI capture address */ 264 264 writel_relaxed(lower_32_bits(msi_set->msg_addr), msi_set->base); 265 265 writel_relaxed(upper_32_bits(msi_set->msg_addr), 266 - port->base + PCIE_MSI_SET_ADDR_HI_BASE + 266 + pcie->base + PCIE_MSI_SET_ADDR_HI_BASE + 267 267 i * PCIE_MSI_SET_ADDR_HI_OFFSET); 268 268 } 269 269 270 - val = readl_relaxed(port->base + PCIE_MSI_SET_ENABLE_REG); 270 + val = readl_relaxed(pcie->base + PCIE_MSI_SET_ENABLE_REG); 271 271 val |= PCIE_MSI_SET_ENABLE; 272 - writel_relaxed(val, port->base + PCIE_MSI_SET_ENABLE_REG); 272 + writel_relaxed(val, pcie->base + PCIE_MSI_SET_ENABLE_REG); 273 273 274 - val = readl_relaxed(port->base + PCIE_INT_ENABLE_REG); 274 + val = readl_relaxed(pcie->base + PCIE_INT_ENABLE_REG); 275 275 val |= PCIE_MSI_ENABLE; 276 - writel_relaxed(val, port->base + PCIE_INT_ENABLE_REG); 276 + writel_relaxed(val, pcie->base + PCIE_INT_ENABLE_REG); 277 277 } 278 278 279 - static int mtk_pcie_startup_port(struct mtk_pcie_port *port) 279 + static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) 280 280 { 281 281 struct resource_entry *entry; 282 - struct pci_host_bridge *host = pci_host_bridge_from_priv(port); 282 + struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); 283 283 unsigned int table_index = 0; 284 284 int err; 285 285 u32 val; 286 286 287 287 /* Set as RC mode */ 288 - val = readl_relaxed(port->base + PCIE_SETTING_REG); 288 + val = readl_relaxed(pcie->base + PCIE_SETTING_REG); 289 289 val |= PCIE_RC_MODE; 290 - writel_relaxed(val, port->base + PCIE_SETTING_REG); 290 + writel_relaxed(val, pcie->base + PCIE_SETTING_REG); 291 291 292 292 /* Set class code */ 293 - val = readl_relaxed(port->base + PCIE_PCI_IDS_1); 293 + val = readl_relaxed(pcie->base + PCIE_PCI_IDS_1); 294 294 val &= ~GENMASK(31, 8); 295 295 val |= PCI_CLASS(PCI_CLASS_BRIDGE_PCI << 8); 296 - writel_relaxed(val, port->base + PCIE_PCI_IDS_1); 296 + writel_relaxed(val, pcie->base + PCIE_PCI_IDS_1); 297 297 298 298 /* Mask all INTx interrupts */ 299 - val = readl_relaxed(port->base + PCIE_INT_ENABLE_REG); 299 + val = readl_relaxed(pcie->base + PCIE_INT_ENABLE_REG); 300 300 val &= ~PCIE_INTX_ENABLE; 301 - writel_relaxed(val, port->base + PCIE_INT_ENABLE_REG); 301 + writel_relaxed(val, pcie->base + PCIE_INT_ENABLE_REG); 302 302 303 303 /* Disable DVFSRC voltage request */ 304 - val = readl_relaxed(port->base + PCIE_MISC_CTRL_REG); 304 + val = readl_relaxed(pcie->base + PCIE_MISC_CTRL_REG); 305 305 val |= PCIE_DISABLE_DVFSRC_VLT_REQ; 306 - writel_relaxed(val, port->base + PCIE_MISC_CTRL_REG); 306 + writel_relaxed(val, pcie->base + PCIE_MISC_CTRL_REG); 307 307 308 308 /* Assert all reset signals */ 309 - val = readl_relaxed(port->base + PCIE_RST_CTRL_REG); 309 + val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG); 310 310 val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB; 311 - writel_relaxed(val, port->base + PCIE_RST_CTRL_REG); 311 + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); 312 312 313 313 /* 314 314 * Described in PCIe CEM specification sections 2.2 (PERST# Signal) ··· 320 320 321 321 /* De-assert reset signals */ 322 322 val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB); 323 - writel_relaxed(val, port->base + PCIE_RST_CTRL_REG); 323 + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); 324 324 325 325 /* Check if the link is up or not */ 326 - err = readl_poll_timeout(port->base + PCIE_LINK_STATUS_REG, val, 326 + err = readl_poll_timeout(pcie->base + PCIE_LINK_STATUS_REG, val, 327 327 !!(val & PCIE_PORT_LINKUP), 20, 328 328 PCI_PM_D3COLD_WAIT * USEC_PER_MSEC); 329 329 if (err) { 330 - val = readl_relaxed(port->base + PCIE_LTSSM_STATUS_REG); 331 - dev_err(port->dev, "PCIe link down, ltssm reg val: %#x\n", val); 330 + val = readl_relaxed(pcie->base + PCIE_LTSSM_STATUS_REG); 331 + dev_err(pcie->dev, "PCIe link down, ltssm reg val: %#x\n", val); 332 332 return err; 333 333 } 334 334 335 - mtk_pcie_enable_msi(port); 335 + mtk_pcie_enable_msi(pcie); 336 336 337 337 /* Set PCIe translation windows */ 338 338 resource_list_for_each_entry(entry, &host->windows) { ··· 355 355 356 356 pci_addr = res->start - entry->offset; 357 357 size = resource_size(res); 358 - err = mtk_pcie_set_trans_table(port, cpu_addr, pci_addr, size, 358 + err = mtk_pcie_set_trans_table(pcie, cpu_addr, pci_addr, size, 359 359 type, table_index); 360 360 if (err) 361 361 return err; 362 362 363 - dev_dbg(port->dev, "set %s trans window[%d]: cpu_addr = %#llx, pci_addr = %#llx, size = %#llx\n", 363 + dev_dbg(pcie->dev, "set %s trans window[%d]: cpu_addr = %#llx, pci_addr = %#llx, size = %#llx\n", 364 364 range_type, table_index, (unsigned long long)cpu_addr, 365 365 (unsigned long long)pci_addr, (unsigned long long)size); 366 366 ··· 404 404 static void mtk_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) 405 405 { 406 406 struct mtk_msi_set *msi_set = irq_data_get_irq_chip_data(data); 407 - struct mtk_pcie_port *port = data->domain->host_data; 407 + struct mtk_gen3_pcie *pcie = data->domain->host_data; 408 408 unsigned long hwirq; 409 409 410 410 hwirq = data->hwirq % PCIE_MSI_IRQS_PER_SET; ··· 412 412 msg->address_hi = upper_32_bits(msi_set->msg_addr); 413 413 msg->address_lo = lower_32_bits(msi_set->msg_addr); 414 414 msg->data = hwirq; 415 - dev_dbg(port->dev, "msi#%#lx address_hi %#x address_lo %#x data %d\n", 415 + dev_dbg(pcie->dev, "msi#%#lx address_hi %#x address_lo %#x data %d\n", 416 416 hwirq, msg->address_hi, msg->address_lo, msg->data); 417 417 } 418 418 ··· 429 429 static void mtk_msi_bottom_irq_mask(struct irq_data *data) 430 430 { 431 431 struct mtk_msi_set *msi_set = irq_data_get_irq_chip_data(data); 432 - struct mtk_pcie_port *port = data->domain->host_data; 432 + struct mtk_gen3_pcie *pcie = data->domain->host_data; 433 433 unsigned long hwirq, flags; 434 434 u32 val; 435 435 436 436 hwirq = data->hwirq % PCIE_MSI_IRQS_PER_SET; 437 437 438 - raw_spin_lock_irqsave(&port->irq_lock, flags); 438 + raw_spin_lock_irqsave(&pcie->irq_lock, flags); 439 439 val = readl_relaxed(msi_set->base + PCIE_MSI_SET_ENABLE_OFFSET); 440 440 val &= ~BIT(hwirq); 441 441 writel_relaxed(val, msi_set->base + PCIE_MSI_SET_ENABLE_OFFSET); 442 - raw_spin_unlock_irqrestore(&port->irq_lock, flags); 442 + raw_spin_unlock_irqrestore(&pcie->irq_lock, flags); 443 443 } 444 444 445 445 static void mtk_msi_bottom_irq_unmask(struct irq_data *data) 446 446 { 447 447 struct mtk_msi_set *msi_set = irq_data_get_irq_chip_data(data); 448 - struct mtk_pcie_port *port = data->domain->host_data; 448 + struct mtk_gen3_pcie *pcie = data->domain->host_data; 449 449 unsigned long hwirq, flags; 450 450 u32 val; 451 451 452 452 hwirq = data->hwirq % PCIE_MSI_IRQS_PER_SET; 453 453 454 - raw_spin_lock_irqsave(&port->irq_lock, flags); 454 + raw_spin_lock_irqsave(&pcie->irq_lock, flags); 455 455 val = readl_relaxed(msi_set->base + PCIE_MSI_SET_ENABLE_OFFSET); 456 456 val |= BIT(hwirq); 457 457 writel_relaxed(val, msi_set->base + PCIE_MSI_SET_ENABLE_OFFSET); 458 - raw_spin_unlock_irqrestore(&port->irq_lock, flags); 458 + raw_spin_unlock_irqrestore(&pcie->irq_lock, flags); 459 459 } 460 460 461 461 static struct irq_chip mtk_msi_bottom_irq_chip = { ··· 471 471 unsigned int virq, unsigned int nr_irqs, 472 472 void *arg) 473 473 { 474 - struct mtk_pcie_port *port = domain->host_data; 474 + struct mtk_gen3_pcie *pcie = domain->host_data; 475 475 struct mtk_msi_set *msi_set; 476 476 int i, hwirq, set_idx; 477 477 478 - mutex_lock(&port->lock); 478 + mutex_lock(&pcie->lock); 479 479 480 - hwirq = bitmap_find_free_region(port->msi_irq_in_use, PCIE_MSI_IRQS_NUM, 480 + hwirq = bitmap_find_free_region(pcie->msi_irq_in_use, PCIE_MSI_IRQS_NUM, 481 481 order_base_2(nr_irqs)); 482 482 483 - mutex_unlock(&port->lock); 483 + mutex_unlock(&pcie->lock); 484 484 485 485 if (hwirq < 0) 486 486 return -ENOSPC; 487 487 488 488 set_idx = hwirq / PCIE_MSI_IRQS_PER_SET; 489 - msi_set = &port->msi_sets[set_idx]; 489 + msi_set = &pcie->msi_sets[set_idx]; 490 490 491 491 for (i = 0; i < nr_irqs; i++) 492 492 irq_domain_set_info(domain, virq + i, hwirq + i, ··· 499 499 static void mtk_msi_bottom_domain_free(struct irq_domain *domain, 500 500 unsigned int virq, unsigned int nr_irqs) 501 501 { 502 - struct mtk_pcie_port *port = domain->host_data; 502 + struct mtk_gen3_pcie *pcie = domain->host_data; 503 503 struct irq_data *data = irq_domain_get_irq_data(domain, virq); 504 504 505 - mutex_lock(&port->lock); 505 + mutex_lock(&pcie->lock); 506 506 507 - bitmap_release_region(port->msi_irq_in_use, data->hwirq, 507 + bitmap_release_region(pcie->msi_irq_in_use, data->hwirq, 508 508 order_base_2(nr_irqs)); 509 509 510 - mutex_unlock(&port->lock); 510 + mutex_unlock(&pcie->lock); 511 511 512 512 irq_domain_free_irqs_common(domain, virq, nr_irqs); 513 513 } ··· 519 519 520 520 static void mtk_intx_mask(struct irq_data *data) 521 521 { 522 - struct mtk_pcie_port *port = irq_data_get_irq_chip_data(data); 522 + struct mtk_gen3_pcie *pcie = irq_data_get_irq_chip_data(data); 523 523 unsigned long flags; 524 524 u32 val; 525 525 526 - raw_spin_lock_irqsave(&port->irq_lock, flags); 527 - val = readl_relaxed(port->base + PCIE_INT_ENABLE_REG); 526 + raw_spin_lock_irqsave(&pcie->irq_lock, flags); 527 + val = readl_relaxed(pcie->base + PCIE_INT_ENABLE_REG); 528 528 val &= ~BIT(data->hwirq + PCIE_INTX_SHIFT); 529 - writel_relaxed(val, port->base + PCIE_INT_ENABLE_REG); 530 - raw_spin_unlock_irqrestore(&port->irq_lock, flags); 529 + writel_relaxed(val, pcie->base + PCIE_INT_ENABLE_REG); 530 + raw_spin_unlock_irqrestore(&pcie->irq_lock, flags); 531 531 } 532 532 533 533 static void mtk_intx_unmask(struct irq_data *data) 534 534 { 535 - struct mtk_pcie_port *port = irq_data_get_irq_chip_data(data); 535 + struct mtk_gen3_pcie *pcie = irq_data_get_irq_chip_data(data); 536 536 unsigned long flags; 537 537 u32 val; 538 538 539 - raw_spin_lock_irqsave(&port->irq_lock, flags); 540 - val = readl_relaxed(port->base + PCIE_INT_ENABLE_REG); 539 + raw_spin_lock_irqsave(&pcie->irq_lock, flags); 540 + val = readl_relaxed(pcie->base + PCIE_INT_ENABLE_REG); 541 541 val |= BIT(data->hwirq + PCIE_INTX_SHIFT); 542 - writel_relaxed(val, port->base + PCIE_INT_ENABLE_REG); 543 - raw_spin_unlock_irqrestore(&port->irq_lock, flags); 542 + writel_relaxed(val, pcie->base + PCIE_INT_ENABLE_REG); 543 + raw_spin_unlock_irqrestore(&pcie->irq_lock, flags); 544 544 } 545 545 546 546 /** ··· 553 553 */ 554 554 static void mtk_intx_eoi(struct irq_data *data) 555 555 { 556 - struct mtk_pcie_port *port = irq_data_get_irq_chip_data(data); 556 + struct mtk_gen3_pcie *pcie = irq_data_get_irq_chip_data(data); 557 557 unsigned long hwirq; 558 558 559 559 hwirq = data->hwirq + PCIE_INTX_SHIFT; 560 - writel_relaxed(BIT(hwirq), port->base + PCIE_INT_STATUS_REG); 560 + writel_relaxed(BIT(hwirq), pcie->base + PCIE_INT_STATUS_REG); 561 561 } 562 562 563 563 static struct irq_chip mtk_intx_irq_chip = { ··· 581 581 .map = mtk_pcie_intx_map, 582 582 }; 583 583 584 - static int mtk_pcie_init_irq_domains(struct mtk_pcie_port *port) 584 + static int mtk_pcie_init_irq_domains(struct mtk_gen3_pcie *pcie) 585 585 { 586 - struct device *dev = port->dev; 586 + struct device *dev = pcie->dev; 587 587 struct device_node *intc_node, *node = dev->of_node; 588 588 int ret; 589 589 590 - raw_spin_lock_init(&port->irq_lock); 590 + raw_spin_lock_init(&pcie->irq_lock); 591 591 592 592 /* Setup INTx */ 593 593 intc_node = of_get_child_by_name(node, "interrupt-controller"); ··· 596 596 return -ENODEV; 597 597 } 598 598 599 - port->intx_domain = irq_domain_add_linear(intc_node, PCI_NUM_INTX, 600 - &intx_domain_ops, port); 601 - if (!port->intx_domain) { 599 + pcie->intx_domain = irq_domain_add_linear(intc_node, PCI_NUM_INTX, 600 + &intx_domain_ops, pcie); 601 + if (!pcie->intx_domain) { 602 602 dev_err(dev, "failed to create INTx IRQ domain\n"); 603 603 return -ENODEV; 604 604 } 605 605 606 606 /* Setup MSI */ 607 - mutex_init(&port->lock); 607 + mutex_init(&pcie->lock); 608 608 609 - port->msi_bottom_domain = irq_domain_add_linear(node, PCIE_MSI_IRQS_NUM, 610 - &mtk_msi_bottom_domain_ops, port); 611 - if (!port->msi_bottom_domain) { 609 + pcie->msi_bottom_domain = irq_domain_add_linear(node, PCIE_MSI_IRQS_NUM, 610 + &mtk_msi_bottom_domain_ops, pcie); 611 + if (!pcie->msi_bottom_domain) { 612 612 dev_err(dev, "failed to create MSI bottom domain\n"); 613 613 ret = -ENODEV; 614 614 goto err_msi_bottom_domain; 615 615 } 616 616 617 - port->msi_domain = pci_msi_create_irq_domain(dev->fwnode, 617 + pcie->msi_domain = pci_msi_create_irq_domain(dev->fwnode, 618 618 &mtk_msi_domain_info, 619 - port->msi_bottom_domain); 620 - if (!port->msi_domain) { 619 + pcie->msi_bottom_domain); 620 + if (!pcie->msi_domain) { 621 621 dev_err(dev, "failed to create MSI domain\n"); 622 622 ret = -ENODEV; 623 623 goto err_msi_domain; ··· 626 626 return 0; 627 627 628 628 err_msi_domain: 629 - irq_domain_remove(port->msi_bottom_domain); 629 + irq_domain_remove(pcie->msi_bottom_domain); 630 630 err_msi_bottom_domain: 631 - irq_domain_remove(port->intx_domain); 631 + irq_domain_remove(pcie->intx_domain); 632 632 633 633 return ret; 634 634 } 635 635 636 - static void mtk_pcie_irq_teardown(struct mtk_pcie_port *port) 636 + static void mtk_pcie_irq_teardown(struct mtk_gen3_pcie *pcie) 637 637 { 638 - irq_set_chained_handler_and_data(port->irq, NULL, NULL); 638 + irq_set_chained_handler_and_data(pcie->irq, NULL, NULL); 639 639 640 - if (port->intx_domain) 641 - irq_domain_remove(port->intx_domain); 640 + if (pcie->intx_domain) 641 + irq_domain_remove(pcie->intx_domain); 642 642 643 - if (port->msi_domain) 644 - irq_domain_remove(port->msi_domain); 643 + if (pcie->msi_domain) 644 + irq_domain_remove(pcie->msi_domain); 645 645 646 - if (port->msi_bottom_domain) 647 - irq_domain_remove(port->msi_bottom_domain); 646 + if (pcie->msi_bottom_domain) 647 + irq_domain_remove(pcie->msi_bottom_domain); 648 648 649 - irq_dispose_mapping(port->irq); 649 + irq_dispose_mapping(pcie->irq); 650 650 } 651 651 652 - static void mtk_pcie_msi_handler(struct mtk_pcie_port *port, int set_idx) 652 + static void mtk_pcie_msi_handler(struct mtk_gen3_pcie *pcie, int set_idx) 653 653 { 654 - struct mtk_msi_set *msi_set = &port->msi_sets[set_idx]; 654 + struct mtk_msi_set *msi_set = &pcie->msi_sets[set_idx]; 655 655 unsigned long msi_enable, msi_status; 656 656 irq_hw_number_t bit, hwirq; 657 657 ··· 666 666 667 667 for_each_set_bit(bit, &msi_status, PCIE_MSI_IRQS_PER_SET) { 668 668 hwirq = bit + set_idx * PCIE_MSI_IRQS_PER_SET; 669 - generic_handle_domain_irq(port->msi_bottom_domain, hwirq); 669 + generic_handle_domain_irq(pcie->msi_bottom_domain, hwirq); 670 670 } 671 671 } while (true); 672 672 } 673 673 674 674 static void mtk_pcie_irq_handler(struct irq_desc *desc) 675 675 { 676 - struct mtk_pcie_port *port = irq_desc_get_handler_data(desc); 676 + struct mtk_gen3_pcie *pcie = irq_desc_get_handler_data(desc); 677 677 struct irq_chip *irqchip = irq_desc_get_chip(desc); 678 678 unsigned long status; 679 679 irq_hw_number_t irq_bit = PCIE_INTX_SHIFT; 680 680 681 681 chained_irq_enter(irqchip, desc); 682 682 683 - status = readl_relaxed(port->base + PCIE_INT_STATUS_REG); 683 + status = readl_relaxed(pcie->base + PCIE_INT_STATUS_REG); 684 684 for_each_set_bit_from(irq_bit, &status, PCI_NUM_INTX + 685 685 PCIE_INTX_SHIFT) 686 - generic_handle_domain_irq(port->intx_domain, 686 + generic_handle_domain_irq(pcie->intx_domain, 687 687 irq_bit - PCIE_INTX_SHIFT); 688 688 689 689 irq_bit = PCIE_MSI_SHIFT; 690 690 for_each_set_bit_from(irq_bit, &status, PCIE_MSI_SET_NUM + 691 691 PCIE_MSI_SHIFT) { 692 - mtk_pcie_msi_handler(port, irq_bit - PCIE_MSI_SHIFT); 692 + mtk_pcie_msi_handler(pcie, irq_bit - PCIE_MSI_SHIFT); 693 693 694 - writel_relaxed(BIT(irq_bit), port->base + PCIE_INT_STATUS_REG); 694 + writel_relaxed(BIT(irq_bit), pcie->base + PCIE_INT_STATUS_REG); 695 695 } 696 696 697 697 chained_irq_exit(irqchip, desc); 698 698 } 699 699 700 - static int mtk_pcie_setup_irq(struct mtk_pcie_port *port) 700 + static int mtk_pcie_setup_irq(struct mtk_gen3_pcie *pcie) 701 701 { 702 - struct device *dev = port->dev; 702 + struct device *dev = pcie->dev; 703 703 struct platform_device *pdev = to_platform_device(dev); 704 704 int err; 705 705 706 - err = mtk_pcie_init_irq_domains(port); 706 + err = mtk_pcie_init_irq_domains(pcie); 707 707 if (err) 708 708 return err; 709 709 710 - port->irq = platform_get_irq(pdev, 0); 711 - if (port->irq < 0) 712 - return port->irq; 710 + pcie->irq = platform_get_irq(pdev, 0); 711 + if (pcie->irq < 0) 712 + return pcie->irq; 713 713 714 - irq_set_chained_handler_and_data(port->irq, mtk_pcie_irq_handler, port); 714 + irq_set_chained_handler_and_data(pcie->irq, mtk_pcie_irq_handler, pcie); 715 715 716 716 return 0; 717 717 } 718 718 719 - static int mtk_pcie_parse_port(struct mtk_pcie_port *port) 719 + static int mtk_pcie_parse_port(struct mtk_gen3_pcie *pcie) 720 720 { 721 - struct device *dev = port->dev; 721 + struct device *dev = pcie->dev; 722 722 struct platform_device *pdev = to_platform_device(dev); 723 723 struct resource *regs; 724 724 int ret; ··· 726 726 regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcie-mac"); 727 727 if (!regs) 728 728 return -EINVAL; 729 - port->base = devm_ioremap_resource(dev, regs); 730 - if (IS_ERR(port->base)) { 729 + pcie->base = devm_ioremap_resource(dev, regs); 730 + if (IS_ERR(pcie->base)) { 731 731 dev_err(dev, "failed to map register base\n"); 732 - return PTR_ERR(port->base); 732 + return PTR_ERR(pcie->base); 733 733 } 734 734 735 - port->reg_base = regs->start; 735 + pcie->reg_base = regs->start; 736 736 737 - port->phy_reset = devm_reset_control_get_optional_exclusive(dev, "phy"); 738 - if (IS_ERR(port->phy_reset)) { 739 - ret = PTR_ERR(port->phy_reset); 737 + pcie->phy_reset = devm_reset_control_get_optional_exclusive(dev, "phy"); 738 + if (IS_ERR(pcie->phy_reset)) { 739 + ret = PTR_ERR(pcie->phy_reset); 740 740 if (ret != -EPROBE_DEFER) 741 741 dev_err(dev, "failed to get PHY reset\n"); 742 742 743 743 return ret; 744 744 } 745 745 746 - port->mac_reset = devm_reset_control_get_optional_exclusive(dev, "mac"); 747 - if (IS_ERR(port->mac_reset)) { 748 - ret = PTR_ERR(port->mac_reset); 746 + pcie->mac_reset = devm_reset_control_get_optional_exclusive(dev, "mac"); 747 + if (IS_ERR(pcie->mac_reset)) { 748 + ret = PTR_ERR(pcie->mac_reset); 749 749 if (ret != -EPROBE_DEFER) 750 750 dev_err(dev, "failed to get MAC reset\n"); 751 751 752 752 return ret; 753 753 } 754 754 755 - port->phy = devm_phy_optional_get(dev, "pcie-phy"); 756 - if (IS_ERR(port->phy)) { 757 - ret = PTR_ERR(port->phy); 755 + pcie->phy = devm_phy_optional_get(dev, "pcie-phy"); 756 + if (IS_ERR(pcie->phy)) { 757 + ret = PTR_ERR(pcie->phy); 758 758 if (ret != -EPROBE_DEFER) 759 759 dev_err(dev, "failed to get PHY\n"); 760 760 761 761 return ret; 762 762 } 763 763 764 - port->num_clks = devm_clk_bulk_get_all(dev, &port->clks); 765 - if (port->num_clks < 0) { 764 + pcie->num_clks = devm_clk_bulk_get_all(dev, &pcie->clks); 765 + if (pcie->num_clks < 0) { 766 766 dev_err(dev, "failed to get clocks\n"); 767 - return port->num_clks; 767 + return pcie->num_clks; 768 768 } 769 769 770 770 return 0; 771 771 } 772 772 773 - static int mtk_pcie_power_up(struct mtk_pcie_port *port) 773 + static int mtk_pcie_power_up(struct mtk_gen3_pcie *pcie) 774 774 { 775 - struct device *dev = port->dev; 775 + struct device *dev = pcie->dev; 776 776 int err; 777 777 778 778 /* PHY power on and enable pipe clock */ 779 - reset_control_deassert(port->phy_reset); 779 + reset_control_deassert(pcie->phy_reset); 780 780 781 - err = phy_init(port->phy); 781 + err = phy_init(pcie->phy); 782 782 if (err) { 783 783 dev_err(dev, "failed to initialize PHY\n"); 784 784 goto err_phy_init; 785 785 } 786 786 787 - err = phy_power_on(port->phy); 787 + err = phy_power_on(pcie->phy); 788 788 if (err) { 789 789 dev_err(dev, "failed to power on PHY\n"); 790 790 goto err_phy_on; 791 791 } 792 792 793 793 /* MAC power on and enable transaction layer clocks */ 794 - reset_control_deassert(port->mac_reset); 794 + reset_control_deassert(pcie->mac_reset); 795 795 796 796 pm_runtime_enable(dev); 797 797 pm_runtime_get_sync(dev); 798 798 799 - err = clk_bulk_prepare_enable(port->num_clks, port->clks); 799 + err = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); 800 800 if (err) { 801 801 dev_err(dev, "failed to enable clocks\n"); 802 802 goto err_clk_init; ··· 807 807 err_clk_init: 808 808 pm_runtime_put_sync(dev); 809 809 pm_runtime_disable(dev); 810 - reset_control_assert(port->mac_reset); 811 - phy_power_off(port->phy); 810 + reset_control_assert(pcie->mac_reset); 811 + phy_power_off(pcie->phy); 812 812 err_phy_on: 813 - phy_exit(port->phy); 813 + phy_exit(pcie->phy); 814 814 err_phy_init: 815 - reset_control_assert(port->phy_reset); 815 + reset_control_assert(pcie->phy_reset); 816 816 817 817 return err; 818 818 } 819 819 820 - static void mtk_pcie_power_down(struct mtk_pcie_port *port) 820 + static void mtk_pcie_power_down(struct mtk_gen3_pcie *pcie) 821 821 { 822 - clk_bulk_disable_unprepare(port->num_clks, port->clks); 822 + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); 823 823 824 - pm_runtime_put_sync(port->dev); 825 - pm_runtime_disable(port->dev); 826 - reset_control_assert(port->mac_reset); 824 + pm_runtime_put_sync(pcie->dev); 825 + pm_runtime_disable(pcie->dev); 826 + reset_control_assert(pcie->mac_reset); 827 827 828 - phy_power_off(port->phy); 829 - phy_exit(port->phy); 830 - reset_control_assert(port->phy_reset); 828 + phy_power_off(pcie->phy); 829 + phy_exit(pcie->phy); 830 + reset_control_assert(pcie->phy_reset); 831 831 } 832 832 833 - static int mtk_pcie_setup(struct mtk_pcie_port *port) 833 + static int mtk_pcie_setup(struct mtk_gen3_pcie *pcie) 834 834 { 835 835 int err; 836 836 837 - err = mtk_pcie_parse_port(port); 837 + err = mtk_pcie_parse_port(pcie); 838 838 if (err) 839 839 return err; 840 840 841 841 /* Don't touch the hardware registers before power up */ 842 - err = mtk_pcie_power_up(port); 842 + err = mtk_pcie_power_up(pcie); 843 843 if (err) 844 844 return err; 845 845 846 846 /* Try link up */ 847 - err = mtk_pcie_startup_port(port); 847 + err = mtk_pcie_startup_port(pcie); 848 848 if (err) 849 849 goto err_setup; 850 850 851 - err = mtk_pcie_setup_irq(port); 851 + err = mtk_pcie_setup_irq(pcie); 852 852 if (err) 853 853 goto err_setup; 854 854 855 855 return 0; 856 856 857 857 err_setup: 858 - mtk_pcie_power_down(port); 858 + mtk_pcie_power_down(pcie); 859 859 860 860 return err; 861 861 } ··· 863 863 static int mtk_pcie_probe(struct platform_device *pdev) 864 864 { 865 865 struct device *dev = &pdev->dev; 866 - struct mtk_pcie_port *port; 866 + struct mtk_gen3_pcie *pcie; 867 867 struct pci_host_bridge *host; 868 868 int err; 869 869 870 - host = devm_pci_alloc_host_bridge(dev, sizeof(*port)); 870 + host = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); 871 871 if (!host) 872 872 return -ENOMEM; 873 873 874 - port = pci_host_bridge_priv(host); 874 + pcie = pci_host_bridge_priv(host); 875 875 876 - port->dev = dev; 877 - platform_set_drvdata(pdev, port); 876 + pcie->dev = dev; 877 + platform_set_drvdata(pdev, pcie); 878 878 879 - err = mtk_pcie_setup(port); 879 + err = mtk_pcie_setup(pcie); 880 880 if (err) 881 881 return err; 882 882 883 883 host->ops = &mtk_pcie_ops; 884 - host->sysdata = port; 884 + host->sysdata = pcie; 885 885 886 886 err = pci_host_probe(host); 887 887 if (err) { 888 - mtk_pcie_irq_teardown(port); 889 - mtk_pcie_power_down(port); 888 + mtk_pcie_irq_teardown(pcie); 889 + mtk_pcie_power_down(pcie); 890 890 return err; 891 891 } 892 892 ··· 895 895 896 896 static int mtk_pcie_remove(struct platform_device *pdev) 897 897 { 898 - struct mtk_pcie_port *port = platform_get_drvdata(pdev); 899 - struct pci_host_bridge *host = pci_host_bridge_from_priv(port); 898 + struct mtk_gen3_pcie *pcie = platform_get_drvdata(pdev); 899 + struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); 900 900 901 901 pci_lock_rescan_remove(); 902 902 pci_stop_root_bus(host->bus); 903 903 pci_remove_root_bus(host->bus); 904 904 pci_unlock_rescan_remove(); 905 905 906 - mtk_pcie_irq_teardown(port); 907 - mtk_pcie_power_down(port); 906 + mtk_pcie_irq_teardown(pcie); 907 + mtk_pcie_power_down(pcie); 908 908 909 909 return 0; 910 910 } 911 911 912 - static void __maybe_unused mtk_pcie_irq_save(struct mtk_pcie_port *port) 912 + static void __maybe_unused mtk_pcie_irq_save(struct mtk_gen3_pcie *pcie) 913 913 { 914 914 int i; 915 915 916 - raw_spin_lock(&port->irq_lock); 916 + raw_spin_lock(&pcie->irq_lock); 917 917 918 - port->saved_irq_state = readl_relaxed(port->base + PCIE_INT_ENABLE_REG); 918 + pcie->saved_irq_state = readl_relaxed(pcie->base + PCIE_INT_ENABLE_REG); 919 919 920 920 for (i = 0; i < PCIE_MSI_SET_NUM; i++) { 921 - struct mtk_msi_set *msi_set = &port->msi_sets[i]; 921 + struct mtk_msi_set *msi_set = &pcie->msi_sets[i]; 922 922 923 923 msi_set->saved_irq_state = readl_relaxed(msi_set->base + 924 924 PCIE_MSI_SET_ENABLE_OFFSET); 925 925 } 926 926 927 - raw_spin_unlock(&port->irq_lock); 927 + raw_spin_unlock(&pcie->irq_lock); 928 928 } 929 929 930 - static void __maybe_unused mtk_pcie_irq_restore(struct mtk_pcie_port *port) 930 + static void __maybe_unused mtk_pcie_irq_restore(struct mtk_gen3_pcie *pcie) 931 931 { 932 932 int i; 933 933 934 - raw_spin_lock(&port->irq_lock); 934 + raw_spin_lock(&pcie->irq_lock); 935 935 936 - writel_relaxed(port->saved_irq_state, port->base + PCIE_INT_ENABLE_REG); 936 + writel_relaxed(pcie->saved_irq_state, pcie->base + PCIE_INT_ENABLE_REG); 937 937 938 938 for (i = 0; i < PCIE_MSI_SET_NUM; i++) { 939 - struct mtk_msi_set *msi_set = &port->msi_sets[i]; 939 + struct mtk_msi_set *msi_set = &pcie->msi_sets[i]; 940 940 941 941 writel_relaxed(msi_set->saved_irq_state, 942 942 msi_set->base + PCIE_MSI_SET_ENABLE_OFFSET); 943 943 } 944 944 945 - raw_spin_unlock(&port->irq_lock); 945 + raw_spin_unlock(&pcie->irq_lock); 946 946 } 947 947 948 - static int __maybe_unused mtk_pcie_turn_off_link(struct mtk_pcie_port *port) 948 + static int __maybe_unused mtk_pcie_turn_off_link(struct mtk_gen3_pcie *pcie) 949 949 { 950 950 u32 val; 951 951 952 - val = readl_relaxed(port->base + PCIE_ICMD_PM_REG); 952 + val = readl_relaxed(pcie->base + PCIE_ICMD_PM_REG); 953 953 val |= PCIE_TURN_OFF_LINK; 954 - writel_relaxed(val, port->base + PCIE_ICMD_PM_REG); 954 + writel_relaxed(val, pcie->base + PCIE_ICMD_PM_REG); 955 955 956 956 /* Check the link is L2 */ 957 - return readl_poll_timeout(port->base + PCIE_LTSSM_STATUS_REG, val, 957 + return readl_poll_timeout(pcie->base + PCIE_LTSSM_STATUS_REG, val, 958 958 (PCIE_LTSSM_STATE(val) == 959 959 PCIE_LTSSM_STATE_L2_IDLE), 20, 960 960 50 * USEC_PER_MSEC); ··· 962 962 963 963 static int __maybe_unused mtk_pcie_suspend_noirq(struct device *dev) 964 964 { 965 - struct mtk_pcie_port *port = dev_get_drvdata(dev); 965 + struct mtk_gen3_pcie *pcie = dev_get_drvdata(dev); 966 966 int err; 967 967 u32 val; 968 968 969 969 /* Trigger link to L2 state */ 970 - err = mtk_pcie_turn_off_link(port); 970 + err = mtk_pcie_turn_off_link(pcie); 971 971 if (err) { 972 - dev_err(port->dev, "cannot enter L2 state\n"); 972 + dev_err(pcie->dev, "cannot enter L2 state\n"); 973 973 return err; 974 974 } 975 975 976 976 /* Pull down the PERST# pin */ 977 - val = readl_relaxed(port->base + PCIE_RST_CTRL_REG); 977 + val = readl_relaxed(pcie->base + PCIE_RST_CTRL_REG); 978 978 val |= PCIE_PE_RSTB; 979 - writel_relaxed(val, port->base + PCIE_RST_CTRL_REG); 979 + writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG); 980 980 981 - dev_dbg(port->dev, "entered L2 states successfully"); 981 + dev_dbg(pcie->dev, "entered L2 states successfully"); 982 982 983 - mtk_pcie_irq_save(port); 984 - mtk_pcie_power_down(port); 983 + mtk_pcie_irq_save(pcie); 984 + mtk_pcie_power_down(pcie); 985 985 986 986 return 0; 987 987 } 988 988 989 989 static int __maybe_unused mtk_pcie_resume_noirq(struct device *dev) 990 990 { 991 - struct mtk_pcie_port *port = dev_get_drvdata(dev); 991 + struct mtk_gen3_pcie *pcie = dev_get_drvdata(dev); 992 992 int err; 993 993 994 - err = mtk_pcie_power_up(port); 994 + err = mtk_pcie_power_up(pcie); 995 995 if (err) 996 996 return err; 997 997 998 - err = mtk_pcie_startup_port(port); 998 + err = mtk_pcie_startup_port(pcie); 999 999 if (err) { 1000 - mtk_pcie_power_down(port); 1000 + mtk_pcie_power_down(pcie); 1001 1001 return err; 1002 1002 } 1003 1003 1004 - mtk_pcie_irq_restore(port); 1004 + mtk_pcie_irq_restore(pcie); 1005 1005 1006 1006 return 0; 1007 1007 }
+21 -21
drivers/pci/controller/pcie-microchip-host.c
··· 262 262 DECLARE_BITMAP(used, MC_NUM_MSI_IRQS); 263 263 }; 264 264 265 - struct mc_port { 265 + struct mc_pcie { 266 266 void __iomem *axi_base_addr; 267 267 struct device *dev; 268 268 struct irq_domain *intx_domain; ··· 382 382 383 383 static char poss_clks[][5] = { "fic0", "fic1", "fic2", "fic3" }; 384 384 385 - static void mc_pcie_enable_msi(struct mc_port *port, void __iomem *base) 385 + static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *base) 386 386 { 387 387 struct mc_msi *msi = &port->msi; 388 388 u32 cap_offset = MC_MSI_CAP_CTRL_OFFSET; ··· 405 405 406 406 static void mc_handle_msi(struct irq_desc *desc) 407 407 { 408 - struct mc_port *port = irq_desc_get_handler_data(desc); 408 + struct mc_pcie *port = irq_desc_get_handler_data(desc); 409 409 struct device *dev = port->dev; 410 410 struct mc_msi *msi = &port->msi; 411 411 void __iomem *bridge_base_addr = ··· 428 428 429 429 static void mc_msi_bottom_irq_ack(struct irq_data *data) 430 430 { 431 - struct mc_port *port = irq_data_get_irq_chip_data(data); 431 + struct mc_pcie *port = irq_data_get_irq_chip_data(data); 432 432 void __iomem *bridge_base_addr = 433 433 port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; 434 434 u32 bitpos = data->hwirq; ··· 443 443 444 444 static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) 445 445 { 446 - struct mc_port *port = irq_data_get_irq_chip_data(data); 446 + struct mc_pcie *port = irq_data_get_irq_chip_data(data); 447 447 phys_addr_t addr = port->msi.vector_phy; 448 448 449 449 msg->address_lo = lower_32_bits(addr); ··· 470 470 static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, 471 471 unsigned int nr_irqs, void *args) 472 472 { 473 - struct mc_port *port = domain->host_data; 473 + struct mc_pcie *port = domain->host_data; 474 474 struct mc_msi *msi = &port->msi; 475 475 void __iomem *bridge_base_addr = 476 476 port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; ··· 503 503 unsigned int nr_irqs) 504 504 { 505 505 struct irq_data *d = irq_domain_get_irq_data(domain, virq); 506 - struct mc_port *port = irq_data_get_irq_chip_data(d); 506 + struct mc_pcie *port = irq_data_get_irq_chip_data(d); 507 507 struct mc_msi *msi = &port->msi; 508 508 509 509 mutex_lock(&msi->lock); ··· 534 534 .chip = &mc_msi_irq_chip, 535 535 }; 536 536 537 - static int mc_allocate_msi_domains(struct mc_port *port) 537 + static int mc_allocate_msi_domains(struct mc_pcie *port) 538 538 { 539 539 struct device *dev = port->dev; 540 540 struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); ··· 562 562 563 563 static void mc_handle_intx(struct irq_desc *desc) 564 564 { 565 - struct mc_port *port = irq_desc_get_handler_data(desc); 565 + struct mc_pcie *port = irq_desc_get_handler_data(desc); 566 566 struct device *dev = port->dev; 567 567 void __iomem *bridge_base_addr = 568 568 port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; ··· 585 585 586 586 static void mc_ack_intx_irq(struct irq_data *data) 587 587 { 588 - struct mc_port *port = irq_data_get_irq_chip_data(data); 588 + struct mc_pcie *port = irq_data_get_irq_chip_data(data); 589 589 void __iomem *bridge_base_addr = 590 590 port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; 591 591 u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); ··· 595 595 596 596 static void mc_mask_intx_irq(struct irq_data *data) 597 597 { 598 - struct mc_port *port = irq_data_get_irq_chip_data(data); 598 + struct mc_pcie *port = irq_data_get_irq_chip_data(data); 599 599 void __iomem *bridge_base_addr = 600 600 port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; 601 601 unsigned long flags; ··· 611 611 612 612 static void mc_unmask_intx_irq(struct irq_data *data) 613 613 { 614 - struct mc_port *port = irq_data_get_irq_chip_data(data); 614 + struct mc_pcie *port = irq_data_get_irq_chip_data(data); 615 615 void __iomem *bridge_base_addr = 616 616 port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; 617 617 unsigned long flags; ··· 698 698 return val; 699 699 } 700 700 701 - static u32 get_events(struct mc_port *port) 701 + static u32 get_events(struct mc_pcie *port) 702 702 { 703 703 void __iomem *bridge_base_addr = 704 704 port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; ··· 715 715 716 716 static irqreturn_t mc_event_handler(int irq, void *dev_id) 717 717 { 718 - struct mc_port *port = dev_id; 718 + struct mc_pcie *port = dev_id; 719 719 struct device *dev = port->dev; 720 720 struct irq_data *data; 721 721 ··· 731 731 732 732 static void mc_handle_event(struct irq_desc *desc) 733 733 { 734 - struct mc_port *port = irq_desc_get_handler_data(desc); 734 + struct mc_pcie *port = irq_desc_get_handler_data(desc); 735 735 unsigned long events; 736 736 u32 bit; 737 737 struct irq_chip *chip = irq_desc_get_chip(desc); ··· 748 748 749 749 static void mc_ack_event_irq(struct irq_data *data) 750 750 { 751 - struct mc_port *port = irq_data_get_irq_chip_data(data); 751 + struct mc_pcie *port = irq_data_get_irq_chip_data(data); 752 752 u32 event = data->hwirq; 753 753 void __iomem *addr; 754 754 u32 mask; ··· 763 763 764 764 static void mc_mask_event_irq(struct irq_data *data) 765 765 { 766 - struct mc_port *port = irq_data_get_irq_chip_data(data); 766 + struct mc_pcie *port = irq_data_get_irq_chip_data(data); 767 767 u32 event = data->hwirq; 768 768 void __iomem *addr; 769 769 u32 mask; ··· 793 793 794 794 static void mc_unmask_event_irq(struct irq_data *data) 795 795 { 796 - struct mc_port *port = irq_data_get_irq_chip_data(data); 796 + struct mc_pcie *port = irq_data_get_irq_chip_data(data); 797 797 u32 event = data->hwirq; 798 798 void __iomem *addr; 799 799 u32 mask; ··· 881 881 return 0; 882 882 } 883 883 884 - static int mc_pcie_init_irq_domains(struct mc_port *port) 884 + static int mc_pcie_init_irq_domains(struct mc_pcie *port) 885 885 { 886 886 struct device *dev = port->dev; 887 887 struct device_node *node = dev->of_node; ··· 957 957 } 958 958 959 959 static int mc_pcie_setup_windows(struct platform_device *pdev, 960 - struct mc_port *port) 960 + struct mc_pcie *port) 961 961 { 962 962 void __iomem *bridge_base_addr = 963 963 port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; ··· 983 983 { 984 984 struct device *dev = cfg->parent; 985 985 struct platform_device *pdev = to_platform_device(dev); 986 - struct mc_port *port; 986 + struct mc_pcie *port; 987 987 void __iomem *bridge_base_addr; 988 988 void __iomem *ctrl_base_addr; 989 989 int ret;
+18 -18
drivers/pci/controller/pcie-mt7621.c
··· 93 93 * reset lines are inverted. 94 94 */ 95 95 struct mt7621_pcie { 96 - void __iomem *base; 97 96 struct device *dev; 97 + void __iomem *base; 98 98 struct list_head ports; 99 99 bool resets_inverted; 100 100 }; ··· 129 129 writel_relaxed(val, port->base + reg); 130 130 } 131 131 132 - static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot, 132 + static inline u32 mt7621_pcie_get_cfgaddr(unsigned int bus, unsigned int slot, 133 133 unsigned int func, unsigned int where) 134 134 { 135 135 return (((where & 0xf00) >> 8) << 24) | (bus << 16) | (slot << 11) | ··· 140 140 unsigned int devfn, int where) 141 141 { 142 142 struct mt7621_pcie *pcie = bus->sysdata; 143 - u32 address = mt7621_pci_get_cfgaddr(bus->number, PCI_SLOT(devfn), 143 + u32 address = mt7621_pcie_get_cfgaddr(bus->number, PCI_SLOT(devfn), 144 144 PCI_FUNC(devfn), where); 145 145 146 146 writel_relaxed(address, pcie->base + RALINK_PCI_CONFIG_ADDR); ··· 148 148 return pcie->base + RALINK_PCI_CONFIG_DATA + (where & 3); 149 149 } 150 150 151 - static struct pci_ops mt7621_pci_ops = { 151 + static struct pci_ops mt7621_pcie_ops = { 152 152 .map_bus = mt7621_pcie_map_bus, 153 153 .read = pci_generic_config_read, 154 154 .write = pci_generic_config_write, ··· 156 156 157 157 static u32 read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg) 158 158 { 159 - u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg); 159 + u32 address = mt7621_pcie_get_cfgaddr(0, dev, 0, reg); 160 160 161 161 pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR); 162 162 return pcie_read(pcie, RALINK_PCI_CONFIG_DATA); ··· 165 165 static void write_config(struct mt7621_pcie *pcie, unsigned int dev, 166 166 u32 reg, u32 val) 167 167 { 168 - u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg); 168 + u32 address = mt7621_pcie_get_cfgaddr(0, dev, 0, reg); 169 169 170 170 pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR); 171 171 pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA); ··· 474 474 { 475 475 struct mt7621_pcie *pcie = pci_host_bridge_priv(host); 476 476 477 - host->ops = &mt7621_pci_ops; 477 + host->ops = &mt7621_pcie_ops; 478 478 host->sysdata = pcie; 479 479 return pci_host_probe(host); 480 480 } 481 481 482 - static const struct soc_device_attribute mt7621_pci_quirks_match[] = { 482 + static const struct soc_device_attribute mt7621_pcie_quirks_match[] = { 483 483 { .soc_id = "mt7621", .revision = "E2" } 484 484 }; 485 485 486 - static int mt7621_pci_probe(struct platform_device *pdev) 486 + static int mt7621_pcie_probe(struct platform_device *pdev) 487 487 { 488 488 struct device *dev = &pdev->dev; 489 489 const struct soc_device_attribute *attr; ··· 504 504 platform_set_drvdata(pdev, pcie); 505 505 INIT_LIST_HEAD(&pcie->ports); 506 506 507 - attr = soc_device_match(mt7621_pci_quirks_match); 507 + attr = soc_device_match(mt7621_pcie_quirks_match); 508 508 if (attr) 509 509 pcie->resets_inverted = true; 510 510 ··· 535 535 return err; 536 536 } 537 537 538 - static int mt7621_pci_remove(struct platform_device *pdev) 538 + static int mt7621_pcie_remove(struct platform_device *pdev) 539 539 { 540 540 struct mt7621_pcie *pcie = platform_get_drvdata(pdev); 541 541 struct mt7621_pcie_port *port; ··· 546 546 return 0; 547 547 } 548 548 549 - static const struct of_device_id mt7621_pci_ids[] = { 549 + static const struct of_device_id mt7621_pcie_ids[] = { 550 550 { .compatible = "mediatek,mt7621-pci" }, 551 551 {}, 552 552 }; 553 - MODULE_DEVICE_TABLE(of, mt7621_pci_ids); 553 + MODULE_DEVICE_TABLE(of, mt7621_pcie_ids); 554 554 555 - static struct platform_driver mt7621_pci_driver = { 556 - .probe = mt7621_pci_probe, 557 - .remove = mt7621_pci_remove, 555 + static struct platform_driver mt7621_pcie_driver = { 556 + .probe = mt7621_pcie_probe, 557 + .remove = mt7621_pcie_remove, 558 558 .driver = { 559 559 .name = "mt7621-pci", 560 - .of_match_table = of_match_ptr(mt7621_pci_ids), 560 + .of_match_table = of_match_ptr(mt7621_pcie_ids), 561 561 }, 562 562 }; 563 - builtin_platform_driver(mt7621_pci_driver); 563 + builtin_platform_driver(mt7621_pcie_driver); 564 564 565 565 MODULE_LICENSE("GPL v2");
+22 -22
drivers/pci/controller/pcie-xilinx-cpm.c
··· 99 99 #define XILINX_CPM_PCIE_REG_PSCR_LNKUP BIT(11) 100 100 101 101 /** 102 - * struct xilinx_cpm_pcie_port - PCIe port information 102 + * struct xilinx_cpm_pcie - PCIe port information 103 + * @dev: Device pointer 103 104 * @reg_base: Bridge Register Base 104 105 * @cpm_base: CPM System Level Control and Status Register(SLCR) Base 105 - * @dev: Device pointer 106 106 * @intx_domain: Legacy IRQ domain pointer 107 107 * @cpm_domain: CPM IRQ domain pointer 108 108 * @cfg: Holds mappings of config space window ··· 110 110 * @irq: Error interrupt number 111 111 * @lock: lock protecting shared register access 112 112 */ 113 - struct xilinx_cpm_pcie_port { 113 + struct xilinx_cpm_pcie { 114 + struct device *dev; 114 115 void __iomem *reg_base; 115 116 void __iomem *cpm_base; 116 - struct device *dev; 117 117 struct irq_domain *intx_domain; 118 118 struct irq_domain *cpm_domain; 119 119 struct pci_config_window *cfg; ··· 122 122 raw_spinlock_t lock; 123 123 }; 124 124 125 - static u32 pcie_read(struct xilinx_cpm_pcie_port *port, u32 reg) 125 + static u32 pcie_read(struct xilinx_cpm_pcie *port, u32 reg) 126 126 { 127 127 return readl_relaxed(port->reg_base + reg); 128 128 } 129 129 130 - static void pcie_write(struct xilinx_cpm_pcie_port *port, 130 + static void pcie_write(struct xilinx_cpm_pcie *port, 131 131 u32 val, u32 reg) 132 132 { 133 133 writel_relaxed(val, port->reg_base + reg); 134 134 } 135 135 136 - static bool cpm_pcie_link_up(struct xilinx_cpm_pcie_port *port) 136 + static bool cpm_pcie_link_up(struct xilinx_cpm_pcie *port) 137 137 { 138 138 return (pcie_read(port, XILINX_CPM_PCIE_REG_PSCR) & 139 139 XILINX_CPM_PCIE_REG_PSCR_LNKUP); 140 140 } 141 141 142 - static void cpm_pcie_clear_err_interrupts(struct xilinx_cpm_pcie_port *port) 142 + static void cpm_pcie_clear_err_interrupts(struct xilinx_cpm_pcie *port) 143 143 { 144 144 unsigned long val = pcie_read(port, XILINX_CPM_PCIE_REG_RPEFR); 145 145 ··· 153 153 154 154 static void xilinx_cpm_mask_leg_irq(struct irq_data *data) 155 155 { 156 - struct xilinx_cpm_pcie_port *port = irq_data_get_irq_chip_data(data); 156 + struct xilinx_cpm_pcie *port = irq_data_get_irq_chip_data(data); 157 157 unsigned long flags; 158 158 u32 mask; 159 159 u32 val; ··· 167 167 168 168 static void xilinx_cpm_unmask_leg_irq(struct irq_data *data) 169 169 { 170 - struct xilinx_cpm_pcie_port *port = irq_data_get_irq_chip_data(data); 170 + struct xilinx_cpm_pcie *port = irq_data_get_irq_chip_data(data); 171 171 unsigned long flags; 172 172 u32 mask; 173 173 u32 val; ··· 211 211 212 212 static void xilinx_cpm_pcie_intx_flow(struct irq_desc *desc) 213 213 { 214 - struct xilinx_cpm_pcie_port *port = irq_desc_get_handler_data(desc); 214 + struct xilinx_cpm_pcie *port = irq_desc_get_handler_data(desc); 215 215 struct irq_chip *chip = irq_desc_get_chip(desc); 216 216 unsigned long val; 217 217 int i; ··· 229 229 230 230 static void xilinx_cpm_mask_event_irq(struct irq_data *d) 231 231 { 232 - struct xilinx_cpm_pcie_port *port = irq_data_get_irq_chip_data(d); 232 + struct xilinx_cpm_pcie *port = irq_data_get_irq_chip_data(d); 233 233 u32 val; 234 234 235 235 raw_spin_lock(&port->lock); ··· 241 241 242 242 static void xilinx_cpm_unmask_event_irq(struct irq_data *d) 243 243 { 244 - struct xilinx_cpm_pcie_port *port = irq_data_get_irq_chip_data(d); 244 + struct xilinx_cpm_pcie *port = irq_data_get_irq_chip_data(d); 245 245 u32 val; 246 246 247 247 raw_spin_lock(&port->lock); ··· 273 273 274 274 static void xilinx_cpm_pcie_event_flow(struct irq_desc *desc) 275 275 { 276 - struct xilinx_cpm_pcie_port *port = irq_desc_get_handler_data(desc); 276 + struct xilinx_cpm_pcie *port = irq_desc_get_handler_data(desc); 277 277 struct irq_chip *chip = irq_desc_get_chip(desc); 278 278 unsigned long val; 279 279 int i; ··· 327 327 328 328 static irqreturn_t xilinx_cpm_pcie_intr_handler(int irq, void *dev_id) 329 329 { 330 - struct xilinx_cpm_pcie_port *port = dev_id; 330 + struct xilinx_cpm_pcie *port = dev_id; 331 331 struct device *dev = port->dev; 332 332 struct irq_data *d; 333 333 ··· 350 350 return IRQ_HANDLED; 351 351 } 352 352 353 - static void xilinx_cpm_free_irq_domains(struct xilinx_cpm_pcie_port *port) 353 + static void xilinx_cpm_free_irq_domains(struct xilinx_cpm_pcie *port) 354 354 { 355 355 if (port->intx_domain) { 356 356 irq_domain_remove(port->intx_domain); ··· 369 369 * 370 370 * Return: '0' on success and error value on failure 371 371 */ 372 - static int xilinx_cpm_pcie_init_irq_domain(struct xilinx_cpm_pcie_port *port) 372 + static int xilinx_cpm_pcie_init_irq_domain(struct xilinx_cpm_pcie *port) 373 373 { 374 374 struct device *dev = port->dev; 375 375 struct device_node *node = dev->of_node; ··· 410 410 return -ENOMEM; 411 411 } 412 412 413 - static int xilinx_cpm_setup_irq(struct xilinx_cpm_pcie_port *port) 413 + static int xilinx_cpm_setup_irq(struct xilinx_cpm_pcie *port) 414 414 { 415 415 struct device *dev = port->dev; 416 416 struct platform_device *pdev = to_platform_device(dev); ··· 462 462 * xilinx_cpm_pcie_init_port - Initialize hardware 463 463 * @port: PCIe port information 464 464 */ 465 - static void xilinx_cpm_pcie_init_port(struct xilinx_cpm_pcie_port *port) 465 + static void xilinx_cpm_pcie_init_port(struct xilinx_cpm_pcie *port) 466 466 { 467 467 if (cpm_pcie_link_up(port)) 468 468 dev_info(port->dev, "PCIe Link is UP\n"); ··· 497 497 * 498 498 * Return: '0' on success and error value on failure 499 499 */ 500 - static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie_port *port, 500 + static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port, 501 501 struct resource *bus_range) 502 502 { 503 503 struct device *dev = port->dev; ··· 523 523 return 0; 524 524 } 525 525 526 - static void xilinx_cpm_free_interrupts(struct xilinx_cpm_pcie_port *port) 526 + static void xilinx_cpm_free_interrupts(struct xilinx_cpm_pcie *port) 527 527 { 528 528 irq_set_chained_handler_and_data(port->intx_irq, NULL, NULL); 529 529 irq_set_chained_handler_and_data(port->irq, NULL, NULL); ··· 537 537 */ 538 538 static int xilinx_cpm_pcie_probe(struct platform_device *pdev) 539 539 { 540 - struct xilinx_cpm_pcie_port *port; 540 + struct xilinx_cpm_pcie *port; 541 541 struct device *dev = &pdev->dev; 542 542 struct pci_host_bridge *bridge; 543 543 struct resource_entry *bus;
+79 -79
drivers/pci/controller/pcie-xilinx.c
··· 91 91 #define XILINX_NUM_MSI_IRQS 128 92 92 93 93 /** 94 - * struct xilinx_pcie_port - PCIe port information 95 - * @reg_base: IO Mapped Register Base 94 + * struct xilinx_pcie - PCIe port information 96 95 * @dev: Device pointer 96 + * @reg_base: IO Mapped Register Base 97 97 * @msi_map: Bitmap of allocated MSIs 98 98 * @map_lock: Mutex protecting the MSI allocation 99 99 * @msi_domain: MSI IRQ domain pointer 100 100 * @leg_domain: Legacy IRQ domain pointer 101 101 * @resources: Bus Resources 102 102 */ 103 - struct xilinx_pcie_port { 104 - void __iomem *reg_base; 103 + struct xilinx_pcie { 105 104 struct device *dev; 105 + void __iomem *reg_base; 106 106 unsigned long msi_map[BITS_TO_LONGS(XILINX_NUM_MSI_IRQS)]; 107 107 struct mutex map_lock; 108 108 struct irq_domain *msi_domain; ··· 110 110 struct list_head resources; 111 111 }; 112 112 113 - static inline u32 pcie_read(struct xilinx_pcie_port *port, u32 reg) 113 + static inline u32 pcie_read(struct xilinx_pcie *pcie, u32 reg) 114 114 { 115 - return readl(port->reg_base + reg); 115 + return readl(pcie->reg_base + reg); 116 116 } 117 117 118 - static inline void pcie_write(struct xilinx_pcie_port *port, u32 val, u32 reg) 118 + static inline void pcie_write(struct xilinx_pcie *pcie, u32 val, u32 reg) 119 119 { 120 - writel(val, port->reg_base + reg); 120 + writel(val, pcie->reg_base + reg); 121 121 } 122 122 123 - static inline bool xilinx_pcie_link_up(struct xilinx_pcie_port *port) 123 + static inline bool xilinx_pcie_link_up(struct xilinx_pcie *pcie) 124 124 { 125 - return (pcie_read(port, XILINX_PCIE_REG_PSCR) & 125 + return (pcie_read(pcie, XILINX_PCIE_REG_PSCR) & 126 126 XILINX_PCIE_REG_PSCR_LNKUP) ? 1 : 0; 127 127 } 128 128 129 129 /** 130 130 * xilinx_pcie_clear_err_interrupts - Clear Error Interrupts 131 - * @port: PCIe port information 131 + * @pcie: PCIe port information 132 132 */ 133 - static void xilinx_pcie_clear_err_interrupts(struct xilinx_pcie_port *port) 133 + static void xilinx_pcie_clear_err_interrupts(struct xilinx_pcie *pcie) 134 134 { 135 - struct device *dev = port->dev; 136 - unsigned long val = pcie_read(port, XILINX_PCIE_REG_RPEFR); 135 + struct device *dev = pcie->dev; 136 + unsigned long val = pcie_read(pcie, XILINX_PCIE_REG_RPEFR); 137 137 138 138 if (val & XILINX_PCIE_RPEFR_ERR_VALID) { 139 139 dev_dbg(dev, "Requester ID %lu\n", 140 140 val & XILINX_PCIE_RPEFR_REQ_ID); 141 - pcie_write(port, XILINX_PCIE_RPEFR_ALL_MASK, 141 + pcie_write(pcie, XILINX_PCIE_RPEFR_ALL_MASK, 142 142 XILINX_PCIE_REG_RPEFR); 143 143 } 144 144 } ··· 152 152 */ 153 153 static bool xilinx_pcie_valid_device(struct pci_bus *bus, unsigned int devfn) 154 154 { 155 - struct xilinx_pcie_port *port = bus->sysdata; 155 + struct xilinx_pcie *pcie = bus->sysdata; 156 156 157 - /* Check if link is up when trying to access downstream ports */ 157 + /* Check if link is up when trying to access downstream pcie ports */ 158 158 if (!pci_is_root_bus(bus)) { 159 - if (!xilinx_pcie_link_up(port)) 159 + if (!xilinx_pcie_link_up(pcie)) 160 160 return false; 161 161 } else if (devfn > 0) { 162 162 /* Only one device down on each root port */ ··· 177 177 static void __iomem *xilinx_pcie_map_bus(struct pci_bus *bus, 178 178 unsigned int devfn, int where) 179 179 { 180 - struct xilinx_pcie_port *port = bus->sysdata; 180 + struct xilinx_pcie *pcie = bus->sysdata; 181 181 182 182 if (!xilinx_pcie_valid_device(bus, devfn)) 183 183 return NULL; 184 184 185 - return port->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where); 185 + return pcie->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where); 186 186 } 187 187 188 188 /* PCIe operations */ ··· 215 215 216 216 static void xilinx_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) 217 217 { 218 - struct xilinx_pcie_port *pcie = irq_data_get_irq_chip_data(data); 218 + struct xilinx_pcie *pcie = irq_data_get_irq_chip_data(data); 219 219 phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K); 220 220 221 221 msg->address_lo = lower_32_bits(pa); ··· 232 232 static int xilinx_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, 233 233 unsigned int nr_irqs, void *args) 234 234 { 235 - struct xilinx_pcie_port *port = domain->host_data; 235 + struct xilinx_pcie *pcie = domain->host_data; 236 236 int hwirq, i; 237 237 238 - mutex_lock(&port->map_lock); 238 + mutex_lock(&pcie->map_lock); 239 239 240 - hwirq = bitmap_find_free_region(port->msi_map, XILINX_NUM_MSI_IRQS, order_base_2(nr_irqs)); 240 + hwirq = bitmap_find_free_region(pcie->msi_map, XILINX_NUM_MSI_IRQS, order_base_2(nr_irqs)); 241 241 242 - mutex_unlock(&port->map_lock); 242 + mutex_unlock(&pcie->map_lock); 243 243 244 244 if (hwirq < 0) 245 245 return -ENOSPC; ··· 256 256 unsigned int nr_irqs) 257 257 { 258 258 struct irq_data *d = irq_domain_get_irq_data(domain, virq); 259 - struct xilinx_pcie_port *port = domain->host_data; 259 + struct xilinx_pcie *pcie = domain->host_data; 260 260 261 - mutex_lock(&port->map_lock); 261 + mutex_lock(&pcie->map_lock); 262 262 263 - bitmap_release_region(port->msi_map, d->hwirq, order_base_2(nr_irqs)); 263 + bitmap_release_region(pcie->msi_map, d->hwirq, order_base_2(nr_irqs)); 264 264 265 - mutex_unlock(&port->map_lock); 265 + mutex_unlock(&pcie->map_lock); 266 266 } 267 267 268 268 static const struct irq_domain_ops xilinx_msi_domain_ops = { ··· 275 275 .chip = &xilinx_msi_top_chip, 276 276 }; 277 277 278 - static int xilinx_allocate_msi_domains(struct xilinx_pcie_port *pcie) 278 + static int xilinx_allocate_msi_domains(struct xilinx_pcie *pcie) 279 279 { 280 280 struct fwnode_handle *fwnode = dev_fwnode(pcie->dev); 281 281 struct irq_domain *parent; ··· 298 298 return 0; 299 299 } 300 300 301 - static void xilinx_free_msi_domains(struct xilinx_pcie_port *pcie) 301 + static void xilinx_free_msi_domains(struct xilinx_pcie *pcie) 302 302 { 303 303 struct irq_domain *parent = pcie->msi_domain->parent; 304 304 ··· 342 342 */ 343 343 static irqreturn_t xilinx_pcie_intr_handler(int irq, void *data) 344 344 { 345 - struct xilinx_pcie_port *port = (struct xilinx_pcie_port *)data; 346 - struct device *dev = port->dev; 345 + struct xilinx_pcie *pcie = (struct xilinx_pcie *)data; 346 + struct device *dev = pcie->dev; 347 347 u32 val, mask, status; 348 348 349 349 /* Read interrupt decode and mask registers */ 350 - val = pcie_read(port, XILINX_PCIE_REG_IDR); 351 - mask = pcie_read(port, XILINX_PCIE_REG_IMR); 350 + val = pcie_read(pcie, XILINX_PCIE_REG_IDR); 351 + mask = pcie_read(pcie, XILINX_PCIE_REG_IMR); 352 352 353 353 status = val & mask; 354 354 if (!status) ··· 371 371 372 372 if (status & XILINX_PCIE_INTR_CORRECTABLE) { 373 373 dev_warn(dev, "Correctable error message\n"); 374 - xilinx_pcie_clear_err_interrupts(port); 374 + xilinx_pcie_clear_err_interrupts(pcie); 375 375 } 376 376 377 377 if (status & XILINX_PCIE_INTR_NONFATAL) { 378 378 dev_warn(dev, "Non fatal error message\n"); 379 - xilinx_pcie_clear_err_interrupts(port); 379 + xilinx_pcie_clear_err_interrupts(pcie); 380 380 } 381 381 382 382 if (status & XILINX_PCIE_INTR_FATAL) { 383 383 dev_warn(dev, "Fatal error message\n"); 384 - xilinx_pcie_clear_err_interrupts(port); 384 + xilinx_pcie_clear_err_interrupts(pcie); 385 385 } 386 386 387 387 if (status & (XILINX_PCIE_INTR_INTX | XILINX_PCIE_INTR_MSI)) { 388 388 struct irq_domain *domain; 389 389 390 - val = pcie_read(port, XILINX_PCIE_REG_RPIFR1); 390 + val = pcie_read(pcie, XILINX_PCIE_REG_RPIFR1); 391 391 392 392 /* Check whether interrupt valid */ 393 393 if (!(val & XILINX_PCIE_RPIFR1_INTR_VALID)) { ··· 397 397 398 398 /* Decode the IRQ number */ 399 399 if (val & XILINX_PCIE_RPIFR1_MSI_INTR) { 400 - val = pcie_read(port, XILINX_PCIE_REG_RPIFR2) & 400 + val = pcie_read(pcie, XILINX_PCIE_REG_RPIFR2) & 401 401 XILINX_PCIE_RPIFR2_MSG_DATA; 402 - domain = port->msi_domain->parent; 402 + domain = pcie->msi_domain->parent; 403 403 } else { 404 404 val = (val & XILINX_PCIE_RPIFR1_INTR_MASK) >> 405 405 XILINX_PCIE_RPIFR1_INTR_SHIFT; 406 - domain = port->leg_domain; 406 + domain = pcie->leg_domain; 407 407 } 408 408 409 409 /* Clear interrupt FIFO register 1 */ 410 - pcie_write(port, XILINX_PCIE_RPIFR1_ALL_MASK, 410 + pcie_write(pcie, XILINX_PCIE_RPIFR1_ALL_MASK, 411 411 XILINX_PCIE_REG_RPIFR1); 412 412 413 413 generic_handle_domain_irq(domain, val); ··· 442 442 443 443 error: 444 444 /* Clear the Interrupt Decode register */ 445 - pcie_write(port, status, XILINX_PCIE_REG_IDR); 445 + pcie_write(pcie, status, XILINX_PCIE_REG_IDR); 446 446 447 447 return IRQ_HANDLED; 448 448 } 449 449 450 450 /** 451 451 * xilinx_pcie_init_irq_domain - Initialize IRQ domain 452 - * @port: PCIe port information 452 + * @pcie: PCIe port information 453 453 * 454 454 * Return: '0' on success and error value on failure 455 455 */ 456 - static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port) 456 + static int xilinx_pcie_init_irq_domain(struct xilinx_pcie *pcie) 457 457 { 458 - struct device *dev = port->dev; 458 + struct device *dev = pcie->dev; 459 459 struct device_node *pcie_intc_node; 460 460 int ret; 461 461 ··· 466 466 return -ENODEV; 467 467 } 468 468 469 - port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, 469 + pcie->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, 470 470 &intx_domain_ops, 471 - port); 471 + pcie); 472 472 of_node_put(pcie_intc_node); 473 - if (!port->leg_domain) { 473 + if (!pcie->leg_domain) { 474 474 dev_err(dev, "Failed to get a INTx IRQ domain\n"); 475 475 return -ENODEV; 476 476 } 477 477 478 478 /* Setup MSI */ 479 479 if (IS_ENABLED(CONFIG_PCI_MSI)) { 480 - phys_addr_t pa = ALIGN_DOWN(virt_to_phys(port), SZ_4K); 480 + phys_addr_t pa = ALIGN_DOWN(virt_to_phys(pcie), SZ_4K); 481 481 482 - ret = xilinx_allocate_msi_domains(port); 482 + ret = xilinx_allocate_msi_domains(pcie); 483 483 if (ret) 484 484 return ret; 485 485 486 - pcie_write(port, upper_32_bits(pa), XILINX_PCIE_REG_MSIBASE1); 487 - pcie_write(port, lower_32_bits(pa), XILINX_PCIE_REG_MSIBASE2); 486 + pcie_write(pcie, upper_32_bits(pa), XILINX_PCIE_REG_MSIBASE1); 487 + pcie_write(pcie, lower_32_bits(pa), XILINX_PCIE_REG_MSIBASE2); 488 488 } 489 489 490 490 return 0; ··· 492 492 493 493 /** 494 494 * xilinx_pcie_init_port - Initialize hardware 495 - * @port: PCIe port information 495 + * @pcie: PCIe port information 496 496 */ 497 - static void xilinx_pcie_init_port(struct xilinx_pcie_port *port) 497 + static void xilinx_pcie_init_port(struct xilinx_pcie *pcie) 498 498 { 499 - struct device *dev = port->dev; 499 + struct device *dev = pcie->dev; 500 500 501 - if (xilinx_pcie_link_up(port)) 501 + if (xilinx_pcie_link_up(pcie)) 502 502 dev_info(dev, "PCIe Link is UP\n"); 503 503 else 504 504 dev_info(dev, "PCIe Link is DOWN\n"); 505 505 506 506 /* Disable all interrupts */ 507 - pcie_write(port, ~XILINX_PCIE_IDR_ALL_MASK, 507 + pcie_write(pcie, ~XILINX_PCIE_IDR_ALL_MASK, 508 508 XILINX_PCIE_REG_IMR); 509 509 510 510 /* Clear pending interrupts */ 511 - pcie_write(port, pcie_read(port, XILINX_PCIE_REG_IDR) & 511 + pcie_write(pcie, pcie_read(pcie, XILINX_PCIE_REG_IDR) & 512 512 XILINX_PCIE_IMR_ALL_MASK, 513 513 XILINX_PCIE_REG_IDR); 514 514 515 515 /* Enable all interrupts we handle */ 516 - pcie_write(port, XILINX_PCIE_IMR_ENABLE_MASK, XILINX_PCIE_REG_IMR); 516 + pcie_write(pcie, XILINX_PCIE_IMR_ENABLE_MASK, XILINX_PCIE_REG_IMR); 517 517 518 518 /* Enable the Bridge enable bit */ 519 - pcie_write(port, pcie_read(port, XILINX_PCIE_REG_RPSC) | 519 + pcie_write(pcie, pcie_read(pcie, XILINX_PCIE_REG_RPSC) | 520 520 XILINX_PCIE_REG_RPSC_BEN, 521 521 XILINX_PCIE_REG_RPSC); 522 522 } 523 523 524 524 /** 525 525 * xilinx_pcie_parse_dt - Parse Device tree 526 - * @port: PCIe port information 526 + * @pcie: PCIe port information 527 527 * 528 528 * Return: '0' on success and error value on failure 529 529 */ 530 - static int xilinx_pcie_parse_dt(struct xilinx_pcie_port *port) 530 + static int xilinx_pcie_parse_dt(struct xilinx_pcie *pcie) 531 531 { 532 - struct device *dev = port->dev; 532 + struct device *dev = pcie->dev; 533 533 struct device_node *node = dev->of_node; 534 534 struct resource regs; 535 535 unsigned int irq; ··· 541 541 return err; 542 542 } 543 543 544 - port->reg_base = devm_pci_remap_cfg_resource(dev, &regs); 545 - if (IS_ERR(port->reg_base)) 546 - return PTR_ERR(port->reg_base); 544 + pcie->reg_base = devm_pci_remap_cfg_resource(dev, &regs); 545 + if (IS_ERR(pcie->reg_base)) 546 + return PTR_ERR(pcie->reg_base); 547 547 548 548 irq = irq_of_parse_and_map(node, 0); 549 549 err = devm_request_irq(dev, irq, xilinx_pcie_intr_handler, 550 550 IRQF_SHARED | IRQF_NO_THREAD, 551 - "xilinx-pcie", port); 551 + "xilinx-pcie", pcie); 552 552 if (err) { 553 553 dev_err(dev, "unable to request irq %d\n", irq); 554 554 return err; ··· 566 566 static int xilinx_pcie_probe(struct platform_device *pdev) 567 567 { 568 568 struct device *dev = &pdev->dev; 569 - struct xilinx_pcie_port *port; 569 + struct xilinx_pcie *pcie; 570 570 struct pci_host_bridge *bridge; 571 571 int err; 572 572 573 573 if (!dev->of_node) 574 574 return -ENODEV; 575 575 576 - bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port)); 576 + bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); 577 577 if (!bridge) 578 578 return -ENODEV; 579 579 580 - port = pci_host_bridge_priv(bridge); 581 - mutex_init(&port->map_lock); 582 - port->dev = dev; 580 + pcie = pci_host_bridge_priv(bridge); 581 + mutex_init(&pcie->map_lock); 582 + pcie->dev = dev; 583 583 584 - err = xilinx_pcie_parse_dt(port); 584 + err = xilinx_pcie_parse_dt(pcie); 585 585 if (err) { 586 586 dev_err(dev, "Parsing DT failed\n"); 587 587 return err; 588 588 } 589 589 590 - xilinx_pcie_init_port(port); 590 + xilinx_pcie_init_port(pcie); 591 591 592 - err = xilinx_pcie_init_irq_domain(port); 592 + err = xilinx_pcie_init_irq_domain(pcie); 593 593 if (err) { 594 594 dev_err(dev, "Failed creating IRQ Domain\n"); 595 595 return err; 596 596 } 597 597 598 - bridge->sysdata = port; 598 + bridge->sysdata = pcie; 599 599 bridge->ops = &xilinx_pcie_ops; 600 600 601 601 err = pci_host_probe(bridge); 602 602 if (err) 603 - xilinx_free_msi_domains(port); 603 + xilinx_free_msi_domains(pcie); 604 604 605 605 return err; 606 606 }