pci-keystone-dw.c 15 KB

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