pci-keystone-dw.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * DesignWare application register space functions for Keystone PCI controller
  4. *
  5. * Copyright (C) 2013-2014 Texas Instruments., Ltd.
  6. * http://www.ti.com
  7. *
  8. * Author: Murali Karicheri <m-karicheri2@ti.com>
  9. */
  10. #include <linux/irq.h>
  11. #include <linux/irqdomain.h>
  12. #include <linux/irqreturn.h>
  13. #include <linux/module.h>
  14. #include <linux/of.h>
  15. #include <linux/of_pci.h>
  16. #include <linux/pci.h>
  17. #include <linux/platform_device.h>
  18. #include "pcie-designware.h"
  19. #include "pci-keystone.h"
  20. /* Application register defines */
  21. #define LTSSM_EN_VAL 1
  22. #define LTSSM_STATE_MASK 0x1f
  23. #define LTSSM_STATE_L0 0x11
  24. #define DBI_CS2_EN_VAL 0x20
  25. #define OB_XLAT_EN_VAL 2
  26. /* Application registers */
  27. #define CMD_STATUS 0x004
  28. #define CFG_SETUP 0x008
  29. #define OB_SIZE 0x030
  30. #define CFG_PCIM_WIN_SZ_IDX 3
  31. #define CFG_PCIM_WIN_CNT 32
  32. #define SPACE0_REMOTE_CFG_OFFSET 0x1000
  33. #define OB_OFFSET_INDEX(n) (0x200 + (8 * n))
  34. #define OB_OFFSET_HI(n) (0x204 + (8 * n))
  35. /* IRQ register defines */
  36. #define IRQ_EOI 0x050
  37. #define IRQ_STATUS 0x184
  38. #define IRQ_ENABLE_SET 0x188
  39. #define IRQ_ENABLE_CLR 0x18c
  40. #define MSI_IRQ 0x054
  41. #define MSI0_IRQ_STATUS 0x104
  42. #define MSI0_IRQ_ENABLE_SET 0x108
  43. #define MSI0_IRQ_ENABLE_CLR 0x10c
  44. #define IRQ_STATUS 0x184
  45. #define MSI_IRQ_OFFSET 4
  46. /* Error IRQ bits */
  47. #define ERR_AER BIT(5) /* ECRC error */
  48. #define ERR_AXI BIT(4) /* AXI tag lookup fatal error */
  49. #define ERR_CORR BIT(3) /* Correctable error */
  50. #define ERR_NONFATAL BIT(2) /* Non-fatal error */
  51. #define ERR_FATAL BIT(1) /* Fatal error */
  52. #define ERR_SYS BIT(0) /* System (fatal, non-fatal, or correctable) */
  53. #define ERR_IRQ_ALL (ERR_AER | ERR_AXI | ERR_CORR | \
  54. ERR_NONFATAL | ERR_FATAL | ERR_SYS)
  55. #define ERR_FATAL_IRQ (ERR_FATAL | ERR_AXI)
  56. #define ERR_IRQ_STATUS_RAW 0x1c0
  57. #define ERR_IRQ_STATUS 0x1c4
  58. #define ERR_IRQ_ENABLE_SET 0x1c8
  59. #define ERR_IRQ_ENABLE_CLR 0x1cc
  60. /* Config space registers */
  61. #define DEBUG0 0x728
  62. #define to_keystone_pcie(x) dev_get_drvdata((x)->dev)
  63. static inline void update_reg_offset_bit_pos(u32 offset, u32 *reg_offset,
  64. u32 *bit_pos)
  65. {
  66. *reg_offset = offset % 8;
  67. *bit_pos = offset >> 3;
  68. }
  69. phys_addr_t ks_dw_pcie_get_msi_addr(struct pcie_port *pp)
  70. {
  71. struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
  72. struct keystone_pcie *ks_pcie = to_keystone_pcie(pci);
  73. return ks_pcie->app.start + MSI_IRQ;
  74. }
  75. static u32 ks_dw_app_readl(struct keystone_pcie *ks_pcie, u32 offset)
  76. {
  77. return readl(ks_pcie->va_app_base + offset);
  78. }
  79. static void ks_dw_app_writel(struct keystone_pcie *ks_pcie, u32 offset, u32 val)
  80. {
  81. writel(val, ks_pcie->va_app_base + offset);
  82. }
  83. void ks_dw_pcie_handle_msi_irq(struct keystone_pcie *ks_pcie, int offset)
  84. {
  85. struct dw_pcie *pci = ks_pcie->pci;
  86. struct pcie_port *pp = &pci->pp;
  87. struct device *dev = pci->dev;
  88. u32 pending, vector;
  89. int src, virq;
  90. pending = ks_dw_app_readl(ks_pcie, MSI0_IRQ_STATUS + (offset << 4));
  91. /*
  92. * MSI0 status bit 0-3 shows vectors 0, 8, 16, 24, MSI1 status bit
  93. * shows 1, 9, 17, 25 and so forth
  94. */
  95. for (src = 0; src < 4; src++) {
  96. if (BIT(src) & pending) {
  97. vector = offset + (src << 3);
  98. virq = irq_linear_revmap(pp->irq_domain, vector);
  99. dev_dbg(dev, "irq: bit %d, vector %d, virq %d\n",
  100. src, vector, virq);
  101. generic_handle_irq(virq);
  102. }
  103. }
  104. }
  105. static void ks_dw_pcie_msi_irq_ack(struct irq_data *d)
  106. {
  107. u32 offset, reg_offset, bit_pos;
  108. struct keystone_pcie *ks_pcie;
  109. struct msi_desc *msi;
  110. struct pcie_port *pp;
  111. struct dw_pcie *pci;
  112. msi = irq_data_get_msi_desc(d);
  113. pp = (struct pcie_port *) msi_desc_to_pci_sysdata(msi);
  114. pci = to_dw_pcie_from_pp(pp);
  115. ks_pcie = to_keystone_pcie(pci);
  116. offset = d->irq - irq_linear_revmap(pp->irq_domain, 0);
  117. update_reg_offset_bit_pos(offset, &reg_offset, &bit_pos);
  118. ks_dw_app_writel(ks_pcie, MSI0_IRQ_STATUS + (reg_offset << 4),
  119. BIT(bit_pos));
  120. ks_dw_app_writel(ks_pcie, IRQ_EOI, reg_offset + MSI_IRQ_OFFSET);
  121. }
  122. void ks_dw_pcie_msi_set_irq(struct pcie_port *pp, int irq)
  123. {
  124. u32 reg_offset, bit_pos;
  125. struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
  126. struct keystone_pcie *ks_pcie = to_keystone_pcie(pci);
  127. update_reg_offset_bit_pos(irq, &reg_offset, &bit_pos);
  128. ks_dw_app_writel(ks_pcie, MSI0_IRQ_ENABLE_SET + (reg_offset << 4),
  129. BIT(bit_pos));
  130. }
  131. void ks_dw_pcie_msi_clear_irq(struct pcie_port *pp, int irq)
  132. {
  133. u32 reg_offset, bit_pos;
  134. struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
  135. struct keystone_pcie *ks_pcie = to_keystone_pcie(pci);
  136. update_reg_offset_bit_pos(irq, &reg_offset, &bit_pos);
  137. ks_dw_app_writel(ks_pcie, MSI0_IRQ_ENABLE_CLR + (reg_offset << 4),
  138. BIT(bit_pos));
  139. }
  140. static void ks_dw_pcie_msi_irq_mask(struct irq_data *d)
  141. {
  142. struct msi_desc *msi;
  143. struct pcie_port *pp;
  144. u32 offset;
  145. msi = irq_data_get_msi_desc(d);
  146. pp = (struct pcie_port *) msi_desc_to_pci_sysdata(msi);
  147. offset = d->irq - irq_linear_revmap(pp->irq_domain, 0);
  148. /* Mask the end point if PVM implemented */
  149. if (IS_ENABLED(CONFIG_PCI_MSI)) {
  150. if (msi->msi_attrib.maskbit)
  151. pci_msi_mask_irq(d);
  152. }
  153. ks_dw_pcie_msi_clear_irq(pp, offset);
  154. }
  155. static void ks_dw_pcie_msi_irq_unmask(struct irq_data *d)
  156. {
  157. struct msi_desc *msi;
  158. struct pcie_port *pp;
  159. u32 offset;
  160. msi = irq_data_get_msi_desc(d);
  161. pp = (struct pcie_port *) msi_desc_to_pci_sysdata(msi);
  162. offset = d->irq - irq_linear_revmap(pp->irq_domain, 0);
  163. /* Mask the end point if PVM implemented */
  164. if (IS_ENABLED(CONFIG_PCI_MSI)) {
  165. if (msi->msi_attrib.maskbit)
  166. pci_msi_unmask_irq(d);
  167. }
  168. ks_dw_pcie_msi_set_irq(pp, offset);
  169. }
  170. static struct irq_chip ks_dw_pcie_msi_irq_chip = {
  171. .name = "Keystone-PCIe-MSI-IRQ",
  172. .irq_ack = ks_dw_pcie_msi_irq_ack,
  173. .irq_mask = ks_dw_pcie_msi_irq_mask,
  174. .irq_unmask = ks_dw_pcie_msi_irq_unmask,
  175. };
  176. static int ks_dw_pcie_msi_map(struct irq_domain *domain, unsigned int irq,
  177. irq_hw_number_t hwirq)
  178. {
  179. irq_set_chip_and_handler(irq, &ks_dw_pcie_msi_irq_chip,
  180. handle_level_irq);
  181. irq_set_chip_data(irq, domain->host_data);
  182. return 0;
  183. }
  184. static const struct irq_domain_ops ks_dw_pcie_msi_domain_ops = {
  185. .map = ks_dw_pcie_msi_map,
  186. };
  187. int ks_dw_pcie_msi_host_init(struct pcie_port *pp, struct msi_controller *chip)
  188. {
  189. struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
  190. struct keystone_pcie *ks_pcie = to_keystone_pcie(pci);
  191. struct device *dev = pci->dev;
  192. int i;
  193. pp->irq_domain = irq_domain_add_linear(ks_pcie->msi_intc_np,
  194. MAX_MSI_IRQS,
  195. &ks_dw_pcie_msi_domain_ops,
  196. chip);
  197. if (!pp->irq_domain) {
  198. dev_err(dev, "irq domain init failed\n");
  199. return -ENXIO;
  200. }
  201. for (i = 0; i < MAX_MSI_IRQS; i++)
  202. irq_create_mapping(pp->irq_domain, i);
  203. return 0;
  204. }
  205. void ks_dw_pcie_enable_legacy_irqs(struct keystone_pcie *ks_pcie)
  206. {
  207. int i;
  208. for (i = 0; i < PCI_NUM_INTX; i++)
  209. ks_dw_app_writel(ks_pcie, IRQ_ENABLE_SET + (i << 4), 0x1);
  210. }
  211. void ks_dw_pcie_handle_legacy_irq(struct keystone_pcie *ks_pcie, int offset)
  212. {
  213. struct dw_pcie *pci = ks_pcie->pci;
  214. struct device *dev = pci->dev;
  215. u32 pending;
  216. int virq;
  217. pending = ks_dw_app_readl(ks_pcie, IRQ_STATUS + (offset << 4));
  218. if (BIT(0) & pending) {
  219. virq = irq_linear_revmap(ks_pcie->legacy_irq_domain, offset);
  220. dev_dbg(dev, ": irq: irq_offset %d, virq %d\n", offset, virq);
  221. generic_handle_irq(virq);
  222. }
  223. /* EOI the INTx interrupt */
  224. ks_dw_app_writel(ks_pcie, IRQ_EOI, offset);
  225. }
  226. void ks_dw_pcie_enable_error_irq(struct keystone_pcie *ks_pcie)
  227. {
  228. ks_dw_app_writel(ks_pcie, ERR_IRQ_ENABLE_SET, ERR_IRQ_ALL);
  229. }
  230. irqreturn_t ks_dw_pcie_handle_error_irq(struct keystone_pcie *ks_pcie)
  231. {
  232. u32 status;
  233. status = ks_dw_app_readl(ks_pcie, ERR_IRQ_STATUS_RAW) & ERR_IRQ_ALL;
  234. if (!status)
  235. return IRQ_NONE;
  236. if (status & ERR_FATAL_IRQ)
  237. dev_err(ks_pcie->pci->dev, "fatal error (status %#010x)\n",
  238. status);
  239. /* Ack the IRQ; status bits are RW1C */
  240. ks_dw_app_writel(ks_pcie, ERR_IRQ_STATUS, status);
  241. return IRQ_HANDLED;
  242. }
  243. static void ks_dw_pcie_ack_legacy_irq(struct irq_data *d)
  244. {
  245. }
  246. static void ks_dw_pcie_mask_legacy_irq(struct irq_data *d)
  247. {
  248. }
  249. static void ks_dw_pcie_unmask_legacy_irq(struct irq_data *d)
  250. {
  251. }
  252. static struct irq_chip ks_dw_pcie_legacy_irq_chip = {
  253. .name = "Keystone-PCI-Legacy-IRQ",
  254. .irq_ack = ks_dw_pcie_ack_legacy_irq,
  255. .irq_mask = ks_dw_pcie_mask_legacy_irq,
  256. .irq_unmask = ks_dw_pcie_unmask_legacy_irq,
  257. };
  258. static int ks_dw_pcie_init_legacy_irq_map(struct irq_domain *d,
  259. unsigned int irq, irq_hw_number_t hw_irq)
  260. {
  261. irq_set_chip_and_handler(irq, &ks_dw_pcie_legacy_irq_chip,
  262. handle_level_irq);
  263. irq_set_chip_data(irq, d->host_data);
  264. return 0;
  265. }
  266. static const struct irq_domain_ops ks_dw_pcie_legacy_irq_domain_ops = {
  267. .map = ks_dw_pcie_init_legacy_irq_map,
  268. .xlate = irq_domain_xlate_onetwocell,
  269. };
  270. /**
  271. * ks_dw_pcie_set_dbi_mode() - Set DBI mode to access overlaid BAR mask
  272. * registers
  273. *
  274. * Since modification of dbi_cs2 involves different clock domain, read the
  275. * status back to ensure the transition is complete.
  276. */
  277. static void ks_dw_pcie_set_dbi_mode(struct keystone_pcie *ks_pcie)
  278. {
  279. u32 val;
  280. val = ks_dw_app_readl(ks_pcie, CMD_STATUS);
  281. ks_dw_app_writel(ks_pcie, CMD_STATUS, DBI_CS2_EN_VAL | val);
  282. do {
  283. val = ks_dw_app_readl(ks_pcie, CMD_STATUS);
  284. } while (!(val & DBI_CS2_EN_VAL));
  285. }
  286. /**
  287. * ks_dw_pcie_clear_dbi_mode() - Disable DBI mode
  288. *
  289. * Since modification of dbi_cs2 involves different clock domain, read the
  290. * status back to ensure the transition is complete.
  291. */
  292. static void ks_dw_pcie_clear_dbi_mode(struct keystone_pcie *ks_pcie)
  293. {
  294. u32 val;
  295. val = ks_dw_app_readl(ks_pcie, CMD_STATUS);
  296. ks_dw_app_writel(ks_pcie, CMD_STATUS, ~DBI_CS2_EN_VAL & val);
  297. do {
  298. val = ks_dw_app_readl(ks_pcie, CMD_STATUS);
  299. } while (val & DBI_CS2_EN_VAL);
  300. }
  301. void ks_dw_pcie_setup_rc_app_regs(struct keystone_pcie *ks_pcie)
  302. {
  303. struct dw_pcie *pci = ks_pcie->pci;
  304. struct pcie_port *pp = &pci->pp;
  305. u32 start = pp->mem->start, end = pp->mem->end;
  306. int i, tr_size;
  307. u32 val;
  308. /* Disable BARs for inbound access */
  309. ks_dw_pcie_set_dbi_mode(ks_pcie);
  310. dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, 0);
  311. dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_1, 0);
  312. ks_dw_pcie_clear_dbi_mode(ks_pcie);
  313. /* Set outbound translation size per window division */
  314. ks_dw_app_writel(ks_pcie, OB_SIZE, CFG_PCIM_WIN_SZ_IDX & 0x7);
  315. tr_size = (1 << (CFG_PCIM_WIN_SZ_IDX & 0x7)) * SZ_1M;
  316. /* Using Direct 1:1 mapping of RC <-> PCI memory space */
  317. for (i = 0; (i < CFG_PCIM_WIN_CNT) && (start < end); i++) {
  318. ks_dw_app_writel(ks_pcie, OB_OFFSET_INDEX(i), start | 1);
  319. ks_dw_app_writel(ks_pcie, OB_OFFSET_HI(i), 0);
  320. start += tr_size;
  321. }
  322. /* Enable OB translation */
  323. val = ks_dw_app_readl(ks_pcie, CMD_STATUS);
  324. ks_dw_app_writel(ks_pcie, CMD_STATUS, OB_XLAT_EN_VAL | val);
  325. }
  326. /**
  327. * ks_pcie_cfg_setup() - Set up configuration space address for a device
  328. *
  329. * @ks_pcie: ptr to keystone_pcie structure
  330. * @bus: Bus number the device is residing on
  331. * @devfn: device, function number info
  332. *
  333. * Forms and returns the address of configuration space mapped in PCIESS
  334. * address space 0. Also configures CFG_SETUP for remote configuration space
  335. * access.
  336. *
  337. * The address space has two regions to access configuration - local and remote.
  338. * We access local region for bus 0 (as RC is attached on bus 0) and remote
  339. * region for others with TYPE 1 access when bus > 1. As for device on bus = 1,
  340. * we will do TYPE 0 access as it will be on our secondary bus (logical).
  341. * CFG_SETUP is needed only for remote configuration access.
  342. */
  343. static void __iomem *ks_pcie_cfg_setup(struct keystone_pcie *ks_pcie, u8 bus,
  344. unsigned int devfn)
  345. {
  346. u8 device = PCI_SLOT(devfn), function = PCI_FUNC(devfn);
  347. struct dw_pcie *pci = ks_pcie->pci;
  348. struct pcie_port *pp = &pci->pp;
  349. u32 regval;
  350. if (bus == 0)
  351. return pci->dbi_base;
  352. regval = (bus << 16) | (device << 8) | function;
  353. /*
  354. * Since Bus#1 will be a virtual bus, we need to have TYPE0
  355. * access only.
  356. * TYPE 1
  357. */
  358. if (bus != 1)
  359. regval |= BIT(24);
  360. ks_dw_app_writel(ks_pcie, CFG_SETUP, regval);
  361. return pp->va_cfg0_base;
  362. }
  363. int ks_dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
  364. unsigned int devfn, int where, int size, u32 *val)
  365. {
  366. struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
  367. struct keystone_pcie *ks_pcie = to_keystone_pcie(pci);
  368. u8 bus_num = bus->number;
  369. void __iomem *addr;
  370. addr = ks_pcie_cfg_setup(ks_pcie, bus_num, devfn);
  371. return dw_pcie_read(addr + where, size, val);
  372. }
  373. int ks_dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
  374. unsigned int devfn, int where, int size, u32 val)
  375. {
  376. struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
  377. struct keystone_pcie *ks_pcie = to_keystone_pcie(pci);
  378. u8 bus_num = bus->number;
  379. void __iomem *addr;
  380. addr = ks_pcie_cfg_setup(ks_pcie, bus_num, devfn);
  381. return dw_pcie_write(addr + where, size, val);
  382. }
  383. /**
  384. * ks_dw_pcie_v3_65_scan_bus() - keystone scan_bus post initialization
  385. *
  386. * This sets BAR0 to enable inbound access for MSI_IRQ register
  387. */
  388. void ks_dw_pcie_v3_65_scan_bus(struct pcie_port *pp)
  389. {
  390. struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
  391. struct keystone_pcie *ks_pcie = to_keystone_pcie(pci);
  392. /* Configure and set up BAR0 */
  393. ks_dw_pcie_set_dbi_mode(ks_pcie);
  394. /* Enable BAR0 */
  395. dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, 1);
  396. dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, SZ_4K - 1);
  397. ks_dw_pcie_clear_dbi_mode(ks_pcie);
  398. /*
  399. * For BAR0, just setting bus address for inbound writes (MSI) should
  400. * be sufficient. Use physical address to avoid any conflicts.
  401. */
  402. dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_0, ks_pcie->app.start);
  403. }
  404. /**
  405. * ks_dw_pcie_link_up() - Check if link up
  406. */
  407. int ks_dw_pcie_link_up(struct dw_pcie *pci)
  408. {
  409. u32 val;
  410. val = dw_pcie_readl_dbi(pci, DEBUG0);
  411. return (val & LTSSM_STATE_MASK) == LTSSM_STATE_L0;
  412. }
  413. void ks_dw_pcie_initiate_link_train(struct keystone_pcie *ks_pcie)
  414. {
  415. u32 val;
  416. /* Disable Link training */
  417. val = ks_dw_app_readl(ks_pcie, CMD_STATUS);
  418. val &= ~LTSSM_EN_VAL;
  419. ks_dw_app_writel(ks_pcie, CMD_STATUS, LTSSM_EN_VAL | val);
  420. /* Initiate Link Training */
  421. val = ks_dw_app_readl(ks_pcie, CMD_STATUS);
  422. ks_dw_app_writel(ks_pcie, CMD_STATUS, LTSSM_EN_VAL | val);
  423. }
  424. /**
  425. * ks_dw_pcie_host_init() - initialize host for v3_65 dw hardware
  426. *
  427. * Ioremap the register resources, initialize legacy irq domain
  428. * and call dw_pcie_v3_65_host_init() API to initialize the Keystone
  429. * PCI host controller.
  430. */
  431. int __init ks_dw_pcie_host_init(struct keystone_pcie *ks_pcie,
  432. struct device_node *msi_intc_np)
  433. {
  434. struct dw_pcie *pci = ks_pcie->pci;
  435. struct pcie_port *pp = &pci->pp;
  436. struct device *dev = pci->dev;
  437. struct platform_device *pdev = to_platform_device(dev);
  438. struct resource *res;
  439. /* Index 0 is the config reg. space address */
  440. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  441. pci->dbi_base = devm_pci_remap_cfg_resource(dev, res);
  442. if (IS_ERR(pci->dbi_base))
  443. return PTR_ERR(pci->dbi_base);
  444. /*
  445. * We set these same and is used in pcie rd/wr_other_conf
  446. * functions
  447. */
  448. pp->va_cfg0_base = pci->dbi_base + SPACE0_REMOTE_CFG_OFFSET;
  449. pp->va_cfg1_base = pp->va_cfg0_base;
  450. /* Index 1 is the application reg. space address */
  451. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  452. ks_pcie->va_app_base = devm_ioremap_resource(dev, res);
  453. if (IS_ERR(ks_pcie->va_app_base))
  454. return PTR_ERR(ks_pcie->va_app_base);
  455. ks_pcie->app = *res;
  456. /* Create legacy IRQ domain */
  457. ks_pcie->legacy_irq_domain =
  458. irq_domain_add_linear(ks_pcie->legacy_intc_np,
  459. PCI_NUM_INTX,
  460. &ks_dw_pcie_legacy_irq_domain_ops,
  461. NULL);
  462. if (!ks_pcie->legacy_irq_domain) {
  463. dev_err(dev, "Failed to add irq domain for legacy irqs\n");
  464. return -EINVAL;
  465. }
  466. return dw_pcie_host_init(pp);
  467. }