1 From 6f933347d0b4ed02d9534f5fa07f7b99f13eeaa1 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Thu, 7 Aug 2014 18:12:28 +0200
4 Subject: [PATCH 01/36] MIPS: lantiq: add pcie driver
6 Signed-off-by: John Crispin <blogic@openwrt.org>
8 arch/mips/lantiq/Kconfig | 10 +
9 arch/mips/lantiq/xway/sysctrl.c | 2 +
10 arch/mips/pci/Makefile | 2 +
11 arch/mips/pci/fixup-lantiq-pcie.c | 82 +++
12 arch/mips/pci/fixup-lantiq.c | 5 +-
13 arch/mips/pci/ifxmips_pci_common.h | 57 ++
14 arch/mips/pci/ifxmips_pcie.c | 1099 ++++++++++++++++++++++++++++++
15 arch/mips/pci/ifxmips_pcie.h | 135 ++++
16 arch/mips/pci/ifxmips_pcie_ar10.h | 290 ++++++++
17 arch/mips/pci/ifxmips_pcie_msi.c | 392 +++++++++++
18 arch/mips/pci/ifxmips_pcie_phy.c | 478 +++++++++++++
19 arch/mips/pci/ifxmips_pcie_pm.c | 176 +++++
20 arch/mips/pci/ifxmips_pcie_pm.h | 36 +
21 arch/mips/pci/ifxmips_pcie_reg.h | 1001 +++++++++++++++++++++++++++
22 arch/mips/pci/ifxmips_pcie_vr9.h | 271 ++++++++
23 arch/mips/pci/pci.c | 25 +
24 arch/mips/pci/pcie-lantiq.h | 1305 ++++++++++++++++++++++++++++++++++++
25 drivers/pci/pcie/aer/Kconfig | 2 +-
26 include/linux/pci.h | 2 +
27 include/linux/pci_ids.h | 6 +
28 20 files changed, 5374 insertions(+), 2 deletions(-)
29 create mode 100644 arch/mips/pci/fixup-lantiq-pcie.c
30 create mode 100644 arch/mips/pci/ifxmips_pci_common.h
31 create mode 100644 arch/mips/pci/ifxmips_pcie.c
32 create mode 100644 arch/mips/pci/ifxmips_pcie.h
33 create mode 100644 arch/mips/pci/ifxmips_pcie_ar10.h
34 create mode 100644 arch/mips/pci/ifxmips_pcie_msi.c
35 create mode 100644 arch/mips/pci/ifxmips_pcie_phy.c
36 create mode 100644 arch/mips/pci/ifxmips_pcie_pm.c
37 create mode 100644 arch/mips/pci/ifxmips_pcie_pm.h
38 create mode 100644 arch/mips/pci/ifxmips_pcie_reg.h
39 create mode 100644 arch/mips/pci/ifxmips_pcie_vr9.h
40 create mode 100644 arch/mips/pci/pcie-lantiq.h
42 --- a/arch/mips/lantiq/Kconfig
43 +++ b/arch/mips/lantiq/Kconfig
44 @@ -17,6 +17,7 @@ config SOC_XWAY
48 + select ARCH_SUPPORTS_MSI
52 @@ -37,6 +38,15 @@ config PCI_LANTIQ
54 depends on SOC_XWAY && PCI
58 + depends on SOC_XWAY && PCI
60 +config PCIE_LANTIQ_MSI
62 + depends on PCIE_LANTIQ && PCI_MSI
66 bool "XRX200 PHY firmware loader"
68 --- a/arch/mips/lantiq/xway/sysctrl.c
69 +++ b/arch/mips/lantiq/xway/sysctrl.c
70 @@ -377,6 +377,8 @@ void __init ltq_soc_init(void)
71 PMU_PPE_EMA | PMU_PPE_TC | PMU_PPE_SLL01 |
72 PMU_PPE_QSB | PMU_PPE_TOP);
73 clkdev_add_pmu("1f203000.rcu", "gphy", 0, PMU_GPHY);
74 + pmu_w32(~0, PMU_PWDSR1);
75 + pmu_w32(pmu_r32(PMU_PWDSR) & ~PMU_PCIE_CLK, PMU_PWDSR);
76 } else if (of_machine_is_compatible("lantiq,ar9")) {
77 clkdev_add_static(ltq_ar9_cpu_hz(), ltq_ar9_fpi_hz(),
78 ltq_ar9_fpi_hz(), CLOCK_250M);
79 --- a/arch/mips/pci/Makefile
80 +++ b/arch/mips/pci/Makefile
81 @@ -45,6 +45,8 @@ obj-$(CONFIG_LANTIQ) += fixup-lantiq.o
82 obj-$(CONFIG_PCI_LANTIQ) += pci-lantiq.o ops-lantiq.o
83 obj-$(CONFIG_SOC_RT288X) += pci-rt2880.o
84 obj-$(CONFIG_SOC_RT3883) += pci-rt3883.o
85 +obj-$(CONFIG_PCIE_LANTIQ) += ifxmips_pcie_phy.o ifxmips_pcie.o fixup-lantiq-pcie.o
86 +obj-$(CONFIG_PCIE_LANTIQ_MSI) += pcie-lantiq-msi.o
87 obj-$(CONFIG_TANBAC_TB0219) += fixup-tb0219.o
88 obj-$(CONFIG_TANBAC_TB0226) += fixup-tb0226.o
89 obj-$(CONFIG_TANBAC_TB0287) += fixup-tb0287.o
91 +++ b/arch/mips/pci/fixup-lantiq-pcie.c
93 +/******************************************************************************
95 +** FILE NAME : ifxmips_fixup_pcie.c
96 +** PROJECT : IFX UEIP for VRX200
99 +** DATE : 02 Mar 2009
100 +** AUTHOR : Lei Chuanhua
101 +** DESCRIPTION : PCIe Root Complex Driver
102 +** COPYRIGHT : Copyright (c) 2009
103 +** Infineon Technologies AG
104 +** Am Campeon 1-12, 85579 Neubiberg, Germany
106 +** This program is free software; you can redistribute it and/or modify
107 +** it under the terms of the GNU General Public License as published by
108 +** the Free Software Foundation; either version 2 of the License, or
109 +** (at your option) any later version.
111 +** $Version $Date $Author $Comment
112 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
113 +*******************************************************************************/
115 + \file ifxmips_fixup_pcie.c
117 + \brief PCIe Fixup functions source file
119 +#include <linux/pci.h>
120 +#include <linux/pci_regs.h>
121 +#include <linux/pci_ids.h>
123 +#include <lantiq_soc.h>
125 +#include "pcie-lantiq.h"
127 +#define PCI_VENDOR_ID_INFINEON 0x15D1
128 +#define PCI_DEVICE_ID_INFINEON_DANUBE 0x000F
129 +#define PCI_DEVICE_ID_INFINEON_PCIE 0x0011
130 +#define PCI_VENDOR_ID_LANTIQ 0x1BEF
131 +#define PCI_DEVICE_ID_LANTIQ_PCIE 0x0011
136 +ifx_pcie_fixup_resource(struct pci_dev *dev)
140 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: enter\n", __func__, pci_name(dev));
142 + printk("%s: fixup host controller %s (%04x:%04x)\n",
143 + __func__, pci_name(dev), dev->vendor, dev->device);
145 + /* Setup COMMAND register */
146 + reg = PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER /* |
147 + PCI_COMMAND_INTX_DISABLE */| PCI_COMMAND_SERR;
148 + pci_write_config_word(dev, PCI_COMMAND, reg);
149 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: exit\n", __func__, pci_name(dev));
151 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INFINEON, PCI_DEVICE_ID_INFINEON_PCIE, ifx_pcie_fixup_resource);
152 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LANTIQ, PCI_VENDOR_ID_LANTIQ, ifx_pcie_fixup_resource);
155 +ifx_pcie_rc_class_early_fixup(struct pci_dev *dev)
157 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: enter\n", __func__, pci_name(dev));
159 + if (dev->devfn == PCI_DEVFN(0, 0) &&
160 + (dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) {
162 + dev->class = (PCI_CLASS_BRIDGE_PCI << 8) | (dev->class & 0xff);
164 + printk(KERN_INFO "%s: fixed pcie host bridge to pci-pci bridge\n", __func__);
166 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: exit\n", __func__, pci_name(dev));
170 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INFINEON, PCI_DEVICE_ID_INFINEON_PCIE,
171 + ifx_pcie_rc_class_early_fixup);
173 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LANTIQ, PCI_DEVICE_ID_LANTIQ_PCIE,
174 + ifx_pcie_rc_class_early_fixup);
175 --- a/arch/mips/pci/fixup-lantiq.c
176 +++ b/arch/mips/pci/fixup-lantiq.c
179 #include <linux/of_irq.h>
180 #include <linux/of_pci.h>
181 +#include "ifxmips_pci_common.h"
183 int (*ltq_pci_plat_arch_init)(struct pci_dev *dev) = NULL;
184 int (*ltq_pci_plat_dev_init)(struct pci_dev *dev) = NULL;
186 int pcibios_plat_dev_init(struct pci_dev *dev)
188 +#ifdef CONFIG_PCIE_LANTIQ
189 + if (pci_find_capability(dev, PCI_CAP_ID_EXP))
190 + ifx_pcie_bios_plat_dev_init(dev);
193 if (ltq_pci_plat_arch_init)
194 return ltq_pci_plat_arch_init(dev);
196 @@ -25,5 +31,10 @@ int pcibios_plat_dev_init(struct pci_dev
198 int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
200 +#ifdef CONFIG_PCIE_LANTIQ
201 + if (pci_find_capability(dev, PCI_CAP_ID_EXP))
202 + return ifx_pcie_bios_map_irq(dev, slot, pin);
205 return of_irq_parse_and_map_pci(dev, slot, pin);
208 +++ b/arch/mips/pci/ifxmips_pci_common.h
210 +/******************************************************************************
212 +** FILE NAME : ifxmips_pci_common.h
213 +** PROJECT : IFX UEIP
214 +** MODULES : PCI subsystem
216 +** DATE : 30 June 2009
217 +** AUTHOR : Lei Chuanhua
218 +** DESCRIPTION : PCIe Root Complex Driver
219 +** COPYRIGHT : Copyright (c) 2009
220 +** Infineon Technologies AG
221 +** Am Campeon 1-12, 85579 Neubiberg, Germany
223 +** This program is free software; you can redistribute it and/or modify
224 +** it under the terms of the GNU General Public License as published by
225 +** the Free Software Foundation; either version 2 of the License, or
226 +** (at your option) any later version.
228 +** $Version $Date $Author $Comment
229 +** 0.0.1 30 June,2009 Lei Chuanhua Initial version
230 +*******************************************************************************/
232 +#ifndef IFXMIPS_PCI_COMMON_H
233 +#define IFXMIPS_PCI_COMMON_H
234 +#include <linux/version.h>
236 + \defgroup IFX_PCI_COM IFX PCI/PCIe common parts for OS integration
237 + \brief PCI/PCIe common parts
241 + \defgroup IFX_PCI_COM_OS OS APIs
242 + \ingroup IFX_PCI_COM
243 + \brief PCI/PCIe bus driver OS interface functions
246 + \file ifxmips_pci_common.h
247 + \ingroup IFX_PCI_COM
248 + \brief PCI/PCIe bus driver common OS header file
250 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
251 +#define IFX_PCI_CONST
253 +#define IFX_PCI_CONST const
255 +#ifdef CONFIG_IFX_PCI
256 +extern int ifx_pci_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin);
257 +extern int ifx_pci_bios_plat_dev_init(struct pci_dev *dev);
258 +#endif /* COFNIG_IFX_PCI */
260 +#ifdef CONFIG_PCIE_LANTIQ
261 +extern int ifx_pcie_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin);
262 +extern int ifx_pcie_bios_plat_dev_init(struct pci_dev *dev);
265 +#endif /* IFXMIPS_PCI_COMMON_H */
268 +++ b/arch/mips/pci/ifxmips_pcie.c
271 + * This program is free software; you can redistribute it and/or modify it
272 + * under the terms of the GNU General Public License version 2 as published
273 + * by the Free Software Foundation.
275 + * Copyright (C) 2009 Lei Chuanhua <chuanhua.lei@infineon.com>
276 + * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
279 +#include <linux/types.h>
280 +#include <linux/pci.h>
281 +#include <linux/kernel.h>
282 +#include <linux/init.h>
283 +#include <linux/delay.h>
284 +#include <linux/mm.h>
285 +#include <asm/paccess.h>
286 +#include <linux/pci.h>
287 +#include <linux/pci_regs.h>
288 +#include <linux/module.h>
290 +#include "ifxmips_pcie.h"
291 +#include "ifxmips_pcie_reg.h"
293 +/* Enable 32bit io due to its mem mapped io nature */
294 +#define IFX_PCIE_ERROR_INT
295 +#define IFX_PCIE_IO_32BIT
297 +#define IFX_PCIE_IR (INT_NUM_IM4_IRL0 + 25)
298 +#define IFX_PCIE_INTA (INT_NUM_IM4_IRL0 + 8)
299 +#define IFX_PCIE_INTB (INT_NUM_IM4_IRL0 + 9)
300 +#define IFX_PCIE_INTC (INT_NUM_IM4_IRL0 + 10)
301 +#define IFX_PCIE_INTD (INT_NUM_IM4_IRL0 + 11)
302 +#define MS(_v, _f) (((_v) & (_f)) >> _f##_S)
303 +#define SM(_v, _f) (((_v) << _f##_S) & (_f))
304 +#define IFX_REG_SET_BIT(_f, _r) \
305 + IFX_REG_W32((IFX_REG_R32((_r)) &~ (_f)) | (_f), (_r))
307 +#define IFX_PCIE_LTSSM_ENABLE_TIMEOUT 10
309 +static DEFINE_SPINLOCK(ifx_pcie_lock);
311 +u32 g_pcie_debug_flag = PCIE_MSG_ANY & (~PCIE_MSG_CFG);
313 +static ifx_pcie_irq_t pcie_irqs[IFX_PCIE_CORE_NR] = {
316 + .irq = IFX_PCIE_IR,
317 + .name = "ifx_pcie_rc0",
322 + .irq_bit = PCIE_IRN_INTA,
323 + .irq = IFX_PCIE_INTA,
326 + .irq_bit = PCIE_IRN_INTB,
327 + .irq = IFX_PCIE_INTB,
330 + .irq_bit = PCIE_IRN_INTC,
331 + .irq = IFX_PCIE_INTC,
334 + .irq_bit = PCIE_IRN_INTD,
335 + .irq = IFX_PCIE_INTD,
342 +void ifx_pcie_debug(const char *fmt, ...)
344 + static char buf[256] = {0}; /* XXX */
348 + vsnprintf(buf, sizeof(buf), fmt, ap);
355 +static inline int pcie_ltssm_enable(int pcie_port)
360 + IFX_REG_W32(PCIE_RC_CCR_LTSSM_ENABLE, PCIE_RC_CCR(pcie_port));
362 + /* Wait for the link to come up */
363 + for (i = 0; i < IFX_PCIE_LTSSM_ENABLE_TIMEOUT; i++) {
364 + if (!(IFX_REG_R32(PCIE_LCTLSTS(pcie_port)) & PCIE_LCTLSTS_RETRAIN_PENDING))
369 + printk("%s link timeout!!!!!\n", __func__);
373 +static inline void pcie_status_register_clear(int pcie_port)
375 + IFX_REG_W32(0, PCIE_RC_DR(pcie_port));
376 + IFX_REG_W32(0, PCIE_PCICMDSTS(pcie_port));
377 + IFX_REG_W32(0, PCIE_DCTLSTS(pcie_port));
378 + IFX_REG_W32(0, PCIE_LCTLSTS(pcie_port));
379 + IFX_REG_W32(0, PCIE_SLCTLSTS(pcie_port));
380 + IFX_REG_W32(0, PCIE_RSTS(pcie_port));
381 + IFX_REG_W32(0, PCIE_UES_R(pcie_port));
382 + IFX_REG_W32(0, PCIE_UEMR(pcie_port));
383 + IFX_REG_W32(0, PCIE_UESR(pcie_port));
384 + IFX_REG_W32(0, PCIE_CESR(pcie_port));
385 + IFX_REG_W32(0, PCIE_CEMR(pcie_port));
386 + IFX_REG_W32(0, PCIE_RESR(pcie_port));
387 + IFX_REG_W32(0, PCIE_PVCCRSR(pcie_port));
388 + IFX_REG_W32(0, PCIE_VC0_RSR0(pcie_port));
389 + IFX_REG_W32(0, PCIE_TPFCS(pcie_port));
390 + IFX_REG_W32(0, PCIE_TNPFCS(pcie_port));
391 + IFX_REG_W32(0, PCIE_TCFCS(pcie_port));
392 + IFX_REG_W32(0, PCIE_QSR(pcie_port));
393 + IFX_REG_W32(0, PCIE_IOBLSECS(pcie_port));
396 +static inline int ifx_pcie_link_up(int pcie_port)
398 + return (IFX_REG_R32(PCIE_PHY_SR(pcie_port)) & PCIE_PHY_SR_PHY_LINK_UP) ? 1 : 0;
402 +static inline void pcie_mem_io_setup(int pcie_port)
406 + * BAR[0:1] readonly register
407 + * RC contains only minimal BARs for packets mapped to this device
408 + * Mem/IO filters defines a range of memory occupied by memory mapped IO devices that
409 + * reside on the downstream side fo the bridge.
411 + reg = SM((PCIE_MEM_PHY_PORT_TO_END(pcie_port) >> 20), PCIE_MBML_MEM_LIMIT_ADDR)
412 + | SM((PCIE_MEM_PHY_PORT_TO_BASE(pcie_port) >> 20), PCIE_MBML_MEM_BASE_ADDR);
414 + IFX_REG_W32(reg, PCIE_MBML(pcie_port));
417 +#ifdef IFX_PCIE_PREFETCH_MEM_64BIT
418 + reg = SM((PCIE_MEM_PHY_PORT_TO_END(pcie_port) >> 20), PCIE_PMBL_END_ADDR)
419 + | SM((PCIE_MEM_PHY_PORT_TO_BASE(pcie_port) >> 20), PCIE_PMBL_UPPER_12BIT)
420 + | PCIE_PMBL_64BIT_ADDR;
421 + IFX_REG_W32(reg, PCIE_PMBL(pcie_port));
423 + /* Must configure upper 32bit */
424 + IFX_REG_W32(0, PCIE_PMBU32(pcie_port));
425 + IFX_REG_W32(0, PCIE_PMLU32(pcie_port));
427 + /* PCIe_PBML, same as MBML */
428 + IFX_REG_W32(IFX_REG_R32(PCIE_MBML(pcie_port)), PCIE_PMBL(pcie_port));
431 + /* IO Address Range */
432 + reg = SM((PCIE_IO_PHY_PORT_TO_END(pcie_port) >> 12), PCIE_IOBLSECS_IO_LIMIT_ADDR)
433 + | SM((PCIE_IO_PHY_PORT_TO_BASE(pcie_port) >> 12), PCIE_IOBLSECS_IO_BASE_ADDR);
434 +#ifdef IFX_PCIE_IO_32BIT
435 + reg |= PCIE_IOBLSECS_32BIT_IO_ADDR;
436 +#endif /* IFX_PCIE_IO_32BIT */
437 + IFX_REG_W32(reg, PCIE_IOBLSECS(pcie_port));
439 +#ifdef IFX_PCIE_IO_32BIT
440 + reg = SM((PCIE_IO_PHY_PORT_TO_END(pcie_port) >> 16), PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT)
441 + | SM((PCIE_IO_PHY_PORT_TO_BASE(pcie_port) >> 16), PCIE_IO_BANDL_UPPER_16BIT_IO_BASE);
442 + IFX_REG_W32(reg, PCIE_IO_BANDL(pcie_port));
444 +#endif /* IFX_PCIE_IO_32BIT */
448 +pcie_device_setup(int pcie_port)
452 + /* Device capability register, set up Maximum payload size */
453 + reg = IFX_REG_R32(PCIE_DCAP(pcie_port));
454 + reg |= PCIE_DCAP_ROLE_BASE_ERR_REPORT;
455 + reg |= SM(PCIE_MAX_PAYLOAD_128, PCIE_DCAP_MAX_PAYLOAD_SIZE);
457 + /* Only available for EP */
458 + reg &= ~(PCIE_DCAP_EP_L0S_LATENCY | PCIE_DCAP_EP_L1_LATENCY);
459 + IFX_REG_W32(reg, PCIE_DCAP(pcie_port));
461 + /* Device control and status register */
462 + /* Set Maximum Read Request size for the device as a Requestor */
463 + reg = IFX_REG_R32(PCIE_DCTLSTS(pcie_port));
466 + * Request size can be larger than the MPS used, but the completions returned
467 + * for the read will be bounded by the MPS size.
468 + * In our system, Max request size depends on AHB burst size. It is 64 bytes.
469 + * but we set it as 128 as minimum one.
471 + reg |= SM(PCIE_MAX_PAYLOAD_128, PCIE_DCTLSTS_MAX_READ_SIZE)
472 + | SM(PCIE_MAX_PAYLOAD_128, PCIE_DCTLSTS_MAX_PAYLOAD_SIZE);
474 + /* Enable relaxed ordering, no snoop, and all kinds of errors */
475 + reg |= PCIE_DCTLSTS_RELAXED_ORDERING_EN | PCIE_DCTLSTS_ERR_EN | PCIE_DCTLSTS_NO_SNOOP_EN;
477 + IFX_REG_W32(reg, PCIE_DCTLSTS(pcie_port));
481 +pcie_link_setup(int pcie_port)
486 + * XXX, Link capability register, bit 18 for EP CLKREQ# dynamic clock management for L1, L2/3 CPM
487 + * L0s is reported during link training via TS1 order set by N_FTS
489 + reg = IFX_REG_R32(PCIE_LCAP(pcie_port));
490 + reg &= ~PCIE_LCAP_L0S_EIXT_LATENCY;
491 + reg |= SM(3, PCIE_LCAP_L0S_EIXT_LATENCY);
492 + IFX_REG_W32(reg, PCIE_LCAP(pcie_port));
494 + /* Link control and status register */
495 + reg = IFX_REG_R32(PCIE_LCTLSTS(pcie_port));
497 + /* Link Enable, ASPM enabled */
498 + reg &= ~PCIE_LCTLSTS_LINK_DISABLE;
500 +#ifdef CONFIG_PCIEASPM
502 + * We use the same physical reference clock that the platform provides on the connector
503 + * It paved the way for ASPM to calculate the new exit Latency
505 + reg |= PCIE_LCTLSTS_SLOT_CLK_CFG;
506 + reg |= PCIE_LCTLSTS_COM_CLK_CFG;
508 + * We should disable ASPM by default except that we have dedicated power management support
509 + * Enable ASPM will cause the system hangup/instability, performance degration
511 + reg |= PCIE_LCTLSTS_ASPM_ENABLE;
513 + reg &= ~PCIE_LCTLSTS_ASPM_ENABLE;
514 +#endif /* CONFIG_PCIEASPM */
517 + * The maximum size of any completion with data packet is bounded by the MPS setting
518 + * in device control register
521 + /* RCB may cause multiple split transactions, two options available, we use 64 byte RCB */
522 + reg &= ~ PCIE_LCTLSTS_RCB128;
524 + IFX_REG_W32(reg, PCIE_LCTLSTS(pcie_port));
527 +static inline void pcie_error_setup(int pcie_port)
532 + * Forward ERR_COR, ERR_NONFATAL, ERR_FATAL to the backbone
533 + * Poisoned write TLPs and completions indicating poisoned TLPs will set the PCIe_PCICMDSTS.MDPE
535 + reg = IFX_REG_R32(PCIE_INTRBCTRL(pcie_port));
536 + reg |= PCIE_INTRBCTRL_SERR_ENABLE | PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE;
538 + IFX_REG_W32(reg, PCIE_INTRBCTRL(pcie_port));
540 + /* Uncorrectable Error Mask Register, Unmask <enable> all bits in PCIE_UESR */
541 + reg = IFX_REG_R32(PCIE_UEMR(pcie_port));
542 + reg &= ~PCIE_ALL_UNCORRECTABLE_ERR;
543 + IFX_REG_W32(reg, PCIE_UEMR(pcie_port));
545 + /* Uncorrectable Error Severity Register, ALL errors are FATAL */
546 + IFX_REG_W32(PCIE_ALL_UNCORRECTABLE_ERR, PCIE_UESR(pcie_port));
548 + /* Correctable Error Mask Register, unmask <enable> all bits */
549 + reg = IFX_REG_R32(PCIE_CEMR(pcie_port));
550 + reg &= ~PCIE_CORRECTABLE_ERR;
551 + IFX_REG_W32(reg, PCIE_CEMR(pcie_port));
553 + /* Advanced Error Capabilities and Control Registr */
554 + reg = IFX_REG_R32(PCIE_AECCR(pcie_port));
555 + reg |= PCIE_AECCR_ECRC_CHECK_EN | PCIE_AECCR_ECRC_GEN_EN;
556 + IFX_REG_W32(reg, PCIE_AECCR(pcie_port));
558 + /* Root Error Command Register, Report all types of errors */
559 + reg = IFX_REG_R32(PCIE_RECR(pcie_port));
560 + reg |= PCIE_RECR_ERR_REPORT_EN;
561 + IFX_REG_W32(reg, PCIE_RECR(pcie_port));
563 + /* Clear the Root status register */
564 + reg = IFX_REG_R32(PCIE_RESR(pcie_port));
565 + IFX_REG_W32(reg, PCIE_RESR(pcie_port));
568 +static inline void pcie_port_logic_setup(int pcie_port)
572 + /* FTS number, default 12, increase to 63, may increase time from/to L0s to L0 */
573 + reg = IFX_REG_R32(PCIE_AFR(pcie_port));
574 + reg &= ~(PCIE_AFR_FTS_NUM | PCIE_AFR_COM_FTS_NUM);
575 + reg |= SM(PCIE_AFR_FTS_NUM_DEFAULT, PCIE_AFR_FTS_NUM)
576 + | SM(PCIE_AFR_FTS_NUM_DEFAULT, PCIE_AFR_COM_FTS_NUM);
577 + /* L0s and L1 entry latency */
578 + reg &= ~(PCIE_AFR_L0S_ENTRY_LATENCY | PCIE_AFR_L1_ENTRY_LATENCY);
579 + reg |= SM(PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT, PCIE_AFR_L0S_ENTRY_LATENCY)
580 + | SM(PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT, PCIE_AFR_L1_ENTRY_LATENCY);
581 + IFX_REG_W32(reg, PCIE_AFR(pcie_port));
584 + /* Port Link Control Register */
585 + reg = IFX_REG_R32(PCIE_PLCR(pcie_port));
586 + reg |= PCIE_PLCR_DLL_LINK_EN; /* Enable the DLL link */
587 + IFX_REG_W32(reg, PCIE_PLCR(pcie_port));
589 + /* Lane Skew Register */
590 + reg = IFX_REG_R32(PCIE_LSR(pcie_port));
591 + /* Enable ACK/NACK and FC */
592 + reg &= ~(PCIE_LSR_ACKNAK_DISABLE | PCIE_LSR_FC_DISABLE);
593 + IFX_REG_W32(reg, PCIE_LSR(pcie_port));
595 + /* Symbol Timer Register and Filter Mask Register 1 */
596 + reg = IFX_REG_R32(PCIE_STRFMR(pcie_port));
598 + /* Default SKP interval is very accurate already, 5us */
599 + /* Enable IO/CFG transaction */
600 + reg |= PCIE_STRFMR_RX_CFG_TRANS_ENABLE | PCIE_STRFMR_RX_IO_TRANS_ENABLE;
601 + /* Disable FC WDT */
602 + reg &= ~PCIE_STRFMR_FC_WDT_DISABLE;
603 + IFX_REG_W32(reg, PCIE_STRFMR(pcie_port));
605 + /* Filter Masker Register 2 */
606 + reg = IFX_REG_R32(PCIE_FMR2(pcie_port));
607 + reg |= PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 | PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1;
608 + IFX_REG_W32(reg, PCIE_FMR2(pcie_port));
610 + /* VC0 Completion Receive Queue Control Register */
611 + reg = IFX_REG_R32(PCIE_VC0_CRQCR(pcie_port));
612 + reg &= ~PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE;
613 + reg |= SM(PCIE_VC0_TLP_QUEUE_MODE_BYPASS, PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE);
614 + IFX_REG_W32(reg, PCIE_VC0_CRQCR(pcie_port));
617 +static inline void pcie_rc_cfg_reg_setup(int pcie_port)
621 + /* Disable LTSSM */
622 + IFX_REG_W32(0, PCIE_RC_CCR(pcie_port)); /* Disable LTSSM */
624 + pcie_mem_io_setup(pcie_port);
626 + /* XXX, MSI stuff should only apply to EP */
627 + /* MSI Capability: Only enable 32-bit addresses */
628 + reg = IFX_REG_R32(PCIE_MCAPR(pcie_port));
629 + reg &= ~PCIE_MCAPR_ADDR64_CAP;
631 + reg |= PCIE_MCAPR_MSI_ENABLE;
633 + /* Disable multiple message */
634 + reg &= ~(PCIE_MCAPR_MULTI_MSG_CAP | PCIE_MCAPR_MULTI_MSG_ENABLE);
635 + IFX_REG_W32(reg, PCIE_MCAPR(pcie_port));
638 + /* Enable PME, Soft reset enabled */
639 + reg = IFX_REG_R32(PCIE_PM_CSR(pcie_port));
640 + reg |= PCIE_PM_CSR_PME_ENABLE | PCIE_PM_CSR_SW_RST;
641 + IFX_REG_W32(reg, PCIE_PM_CSR(pcie_port));
643 + /* setup the bus */
644 + reg = SM(0, PCIE_BNR_PRIMARY_BUS_NUM) | SM(1, PCIE_PNR_SECONDARY_BUS_NUM) | SM(0xFF, PCIE_PNR_SUB_BUS_NUM);
645 + IFX_REG_W32(reg, PCIE_BNR(pcie_port));
648 + pcie_device_setup(pcie_port);
649 + pcie_link_setup(pcie_port);
650 + pcie_error_setup(pcie_port);
652 + /* Root control and capabilities register */
653 + reg = IFX_REG_R32(PCIE_RCTLCAP(pcie_port));
654 + reg |= PCIE_RCTLCAP_SERR_ENABLE | PCIE_RCTLCAP_PME_INT_EN;
655 + IFX_REG_W32(reg, PCIE_RCTLCAP(pcie_port));
657 + /* Port VC Capability Register 2 */
658 + reg = IFX_REG_R32(PCIE_PVC2(pcie_port));
659 + reg &= ~PCIE_PVC2_VC_ARB_WRR;
660 + reg |= PCIE_PVC2_VC_ARB_16P_FIXED_WRR;
661 + IFX_REG_W32(reg, PCIE_PVC2(pcie_port));
663 + /* VC0 Resource Capability Register */
664 + reg = IFX_REG_R32(PCIE_VC0_RC(pcie_port));
665 + reg &= ~PCIE_VC0_RC_REJECT_SNOOP;
666 + IFX_REG_W32(reg, PCIE_VC0_RC(pcie_port));
668 + pcie_port_logic_setup(pcie_port);
671 +static int ifx_pcie_wait_phy_link_up(int pcie_port)
673 +#define IFX_PCIE_PHY_LINK_UP_TIMEOUT 1000 /* XXX, tunable */
676 + /* Wait for PHY link is up */
677 + for (i = 0; i < IFX_PCIE_PHY_LINK_UP_TIMEOUT; i++) {
678 + if (ifx_pcie_link_up(pcie_port)) {
683 + if (i >= IFX_PCIE_PHY_LINK_UP_TIMEOUT) {
684 + printk(KERN_ERR "%s timeout\n", __func__);
688 + /* Check data link up or not */
689 + if (!(IFX_REG_R32(PCIE_RC_DR(pcie_port)) & PCIE_RC_DR_DLL_UP)) {
690 + printk(KERN_ERR "%s DLL link is still down\n", __func__);
694 + /* Check Data link active or not */
695 + if (!(IFX_REG_R32(PCIE_LCTLSTS(pcie_port)) & PCIE_LCTLSTS_DLL_ACTIVE)) {
696 + printk(KERN_ERR "%s DLL is not active\n", __func__);
702 +static inline int pcie_app_loigc_setup(int pcie_port)
704 + /* supress ahb bus errrors */
705 + IFX_REG_W32(PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS, PCIE_AHB_CTRL(pcie_port));
707 + /* Pull PCIe EP out of reset */
708 + pcie_device_rst_deassert(pcie_port);
710 + /* Start LTSSM training between RC and EP */
711 + pcie_ltssm_enable(pcie_port);
713 + /* Check PHY status after enabling LTSSM */
714 + if (ifx_pcie_wait_phy_link_up(pcie_port) != 0)
721 + * The numbers below are directly from the PCIe spec table 3-4/5.
723 +static inline void pcie_replay_time_update(int pcie_port)
729 + reg = IFX_REG_R32(PCIE_LCTLSTS(pcie_port));
731 + nlw = MS(reg, PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH);
733 + case PCIE_MAX_LENGTH_WIDTH_X1:
736 + case PCIE_MAX_LENGTH_WIDTH_X2:
739 + case PCIE_MAX_LENGTH_WIDTH_X4:
742 + case PCIE_MAX_LENGTH_WIDTH_X8:
749 + reg = IFX_REG_R32(PCIE_ALTRT(pcie_port));
750 + reg &= ~PCIE_ALTRT_REPLAY_TIME_LIMIT;
751 + reg |= SM(rtl, PCIE_ALTRT_REPLAY_TIME_LIMIT);
752 + IFX_REG_W32(reg, PCIE_ALTRT(pcie_port));
756 + * Table 359 Enhanced Configuration Address Mapping1)
757 + * 1) This table is defined in Table 7-1, page 341, PCI Express Base Specification v1.1
758 + * Memory Address PCI Express Configuration Space
759 + * A[(20+n-1):20] Bus Number 1 < n < 8
760 + * A[19:15] Device Number
761 + * A[14:12] Function Number
762 + * A[11:8] Extended Register Number
763 + * A[7:2] Register Number
764 + * A[1:0] Along with size of the access, used to generate Byte Enables
765 + * For VR9, only the address bits [22:0] are mapped to the configuration space:
766 + * . Address bits [22:20] select the target bus (1-of-8)1)
767 + * . Address bits [19:15] select the target device (1-of-32) on the bus
768 + * . Address bits [14:12] select the target function (1-of-8) within the device.
769 + * . Address bits [11:2] selects the target dword (1-of-1024) within the selected function.s configuration space
770 + * . Address bits [1:0] define the start byte location within the selected dword.
772 +static inline u32 pcie_bus_addr(u8 bus_num, u16 devfn, int where)
779 + addr = ((PCI_SLOT(devfn) & 0x1F) << 15) | ((PCI_FUNC(devfn) & 0x7) << 12) | ((where & 0xFFF)& ~3);
782 + /* type 1, only support 8 buses */
783 + addr = ((bus & 0x7) << 20) | ((PCI_SLOT(devfn) & 0x1F) << 15) |
784 + ((PCI_FUNC(devfn) & 0x7) << 12) | ((where & 0xFFF) & ~3);
789 +static int pcie_valid_config(int pcie_port, int bus, int dev)
792 + if ((bus == 0) && (dev == 0)) {
796 + /* No physical link */
797 + if (!ifx_pcie_link_up(pcie_port)) {
801 + /* Bus zero only has RC itself
802 + * XXX, check if EP will be integrated
804 + if ((bus == 0) && (dev != 0)) {
808 + /* Maximum 8 buses supported for VRX */
814 + * PCIe is PtP link, one bus only supports only one device
815 + * except bus zero and PCIe switch which is virtual bus device
816 + * The following two conditions really depends on the system design
817 + * and attached the device.
818 + * XXX, how about more new switch
820 + if ((bus == 1) && (dev != 0)) {
824 + if ((bus >= 3) && (dev != 0)) {
830 +static inline u32 ifx_pcie_cfg_rd(int pcie_port, u32 reg)
832 + return IFX_REG_R32((volatile u32 *)(PCIE_CFG_PORT_TO_BASE(pcie_port) + reg));
835 +static inline void ifx_pcie_cfg_wr(int pcie_port, unsigned int reg, u32 val)
837 + IFX_REG_W32( val, (volatile u32 *)(PCIE_CFG_PORT_TO_BASE(pcie_port) + reg));
840 +static inline u32 ifx_pcie_rc_cfg_rd(int pcie_port, u32 reg)
842 + return IFX_REG_R32((volatile u32 *)(PCIE_RC_PORT_TO_BASE(pcie_port) + reg));
845 +static inline void ifx_pcie_rc_cfg_wr(int pcie_port, unsigned int reg, u32 val)
847 + IFX_REG_W32(val, (volatile u32 *)(PCIE_RC_PORT_TO_BASE(pcie_port) + reg));
850 +u32 ifx_pcie_bus_enum_read_hack(int where, u32 value)
852 + u32 tvalue = value;
854 + if (where == PCI_PRIMARY_BUS) {
855 + u8 primary, secondary, subordinate;
857 + primary = tvalue & 0xFF;
858 + secondary = (tvalue >> 8) & 0xFF;
859 + subordinate = (tvalue >> 16) & 0xFF;
860 + primary += pcibios_1st_host_bus_nr();
861 + secondary += pcibios_1st_host_bus_nr();
862 + subordinate += pcibios_1st_host_bus_nr();
863 + tvalue = (tvalue & 0xFF000000) | (u32)primary | (u32)(secondary << 8) | (u32)(subordinate << 16);
868 +u32 ifx_pcie_bus_enum_write_hack(int where, u32 value)
870 + u32 tvalue = value;
872 + if (where == PCI_PRIMARY_BUS) {
873 + u8 primary, secondary, subordinate;
875 + primary = tvalue & 0xFF;
876 + secondary = (tvalue >> 8) & 0xFF;
877 + subordinate = (tvalue >> 16) & 0xFF;
878 + if (primary > 0 && primary != 0xFF) {
879 + primary -= pcibios_1st_host_bus_nr();
882 + if (secondary > 0 && secondary != 0xFF) {
883 + secondary -= pcibios_1st_host_bus_nr();
885 + if (subordinate > 0 && subordinate != 0xFF) {
886 + subordinate -= pcibios_1st_host_bus_nr();
888 + tvalue = (tvalue & 0xFF000000) | (u32)primary | (u32)(secondary << 8) | (u32)(subordinate << 16);
890 + else if (where == PCI_SUBORDINATE_BUS) {
891 + u8 subordinate = tvalue & 0xFF;
893 + subordinate = subordinate > 0 ? subordinate - pcibios_1st_host_bus_nr() : 0;
894 + tvalue = subordinate;
899 +static int ifx_pcie_read_config(struct pci_bus *bus, u32 devfn,
900 + int where, int size, u32 *value)
903 + int bus_number = bus->number;
904 + static const u32 mask[8] = {0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0};
905 + int ret = PCIBIOS_SUCCESSFUL;
906 + struct ifx_pci_controller *ctrl = bus->sysdata;
907 + int pcie_port = ctrl->port;
909 + if (unlikely(size != 1 && size != 2 && size != 4)){
910 + ret = PCIBIOS_BAD_REGISTER_NUMBER;
914 + /* Make sure the address is aligned to natural boundary */
915 + if (unlikely(((size - 1) & where))) {
916 + ret = PCIBIOS_BAD_REGISTER_NUMBER;
921 + * If we are second controller, we have to cheat OS so that it assume
922 + * its bus number starts from 0 in host controller
924 + bus_number = ifx_pcie_bus_nr_deduct(bus_number, pcie_port);
927 + * We need to force the bus number to be zero on the root
928 + * bus. Linux numbers the 2nd root bus to start after all
929 + * busses on root 0.
931 + if (bus->parent == NULL) {
936 + * PCIe only has a single device connected to it. It is
937 + * always device ID 0. Don't bother doing reads for other
938 + * device IDs on the first segment.
940 + if ((bus_number == 0) && (PCI_SLOT(devfn) != 0)) {
941 + ret = PCIBIOS_FUNC_NOT_SUPPORTED;
945 + if (pcie_valid_config(pcie_port, bus_number, PCI_SLOT(devfn)) == 0) {
946 + *value = 0xffffffff;
947 + ret = PCIBIOS_DEVICE_NOT_FOUND;
951 + PCIE_IRQ_LOCK(ifx_pcie_lock);
952 + if (bus_number == 0) { /* RC itself */
956 + data = ifx_pcie_rc_cfg_rd(pcie_port, t);
958 + u32 addr = pcie_bus_addr(bus_number, devfn, where);
960 + data = ifx_pcie_cfg_rd(pcie_port, addr);
961 + #ifdef CONFIG_IFX_PCIE_HW_SWAP
962 + data = le32_to_cpu(data);
963 + #endif /* CONFIG_IFX_PCIE_HW_SWAP */
965 + /* To get a correct PCI topology, we have to restore the bus number to OS */
966 + data = ifx_pcie_bus_enum_hack(bus, devfn, where, data, pcie_port, 1);
968 + PCIE_IRQ_UNLOCK(ifx_pcie_lock);
970 + *value = (data >> (8 * (where & 3))) & mask[size & 7];
975 +static u32 ifx_pcie_size_to_value(int where, int size, u32 data, u32 value)
982 + shift = (where & 0x3) << 3;
983 + tdata &= ~(0xffU << shift);
984 + tdata |= ((value & 0xffU) << shift);
987 + shift = (where & 3) << 3;
988 + tdata &= ~(0xffffU << shift);
989 + tdata |= ((value & 0xffffU) << shift);
998 +static int ifx_pcie_write_config(struct pci_bus *bus, u32 devfn,
999 + int where, int size, u32 value)
1001 + int bus_number = bus->number;
1002 + int ret = PCIBIOS_SUCCESSFUL;
1003 + struct ifx_pci_controller *ctrl = bus->sysdata;
1004 + int pcie_port = ctrl->port;
1005 + u32 tvalue = value;
1008 + /* Make sure the address is aligned to natural boundary */
1009 + if (unlikely(((size - 1) & where))) {
1010 + ret = PCIBIOS_BAD_REGISTER_NUMBER;
1014 + * If we are second controller, we have to cheat OS so that it assume
1015 + * its bus number starts from 0 in host controller
1017 + bus_number = ifx_pcie_bus_nr_deduct(bus_number, pcie_port);
1020 + * We need to force the bus number to be zero on the root
1021 + * bus. Linux numbers the 2nd root bus to start after all
1022 + * busses on root 0.
1024 + if (bus->parent == NULL) {
1028 + if (pcie_valid_config(pcie_port, bus_number, PCI_SLOT(devfn)) == 0) {
1029 + ret = PCIBIOS_DEVICE_NOT_FOUND;
1033 + /* XXX, some PCIe device may need some delay */
1034 + PCIE_IRQ_LOCK(ifx_pcie_lock);
1037 + * To configure the correct bus topology using native way, we have to cheat Os so that
1038 + * it can configure the PCIe hardware correctly.
1040 + tvalue = ifx_pcie_bus_enum_hack(bus, devfn, where, value, pcie_port, 0);
1042 + if (bus_number == 0) { /* RC itself */
1046 + data = ifx_pcie_rc_cfg_rd(pcie_port, t);
1048 + data = ifx_pcie_size_to_value(where, size, data, tvalue);
1050 + ifx_pcie_rc_cfg_wr(pcie_port, t, data);
1052 + u32 addr = pcie_bus_addr(bus_number, devfn, where);
1054 + data = ifx_pcie_cfg_rd(pcie_port, addr);
1055 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
1056 + data = le32_to_cpu(data);
1059 + data = ifx_pcie_size_to_value(where, size, data, tvalue);
1060 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
1061 + data = cpu_to_le32(data);
1063 + ifx_pcie_cfg_wr(pcie_port, addr, data);
1065 + PCIE_IRQ_UNLOCK(ifx_pcie_lock);
1070 +static struct resource ifx_pcie_io_resource = {
1071 + .name = "PCIe0 I/O space",
1072 + .start = PCIE_IO_PHY_BASE,
1073 + .end = PCIE_IO_PHY_END,
1074 + .flags = IORESOURCE_IO,
1077 +static struct resource ifx_pcie_mem_resource = {
1078 + .name = "PCIe0 Memory space",
1079 + .start = PCIE_MEM_PHY_BASE,
1080 + .end = PCIE_MEM_PHY_END,
1081 + .flags = IORESOURCE_MEM,
1084 +static struct pci_ops ifx_pcie_ops = {
1085 + .read = ifx_pcie_read_config,
1086 + .write = ifx_pcie_write_config,
1089 +static struct ifx_pci_controller ifx_pcie_controller[IFX_PCIE_CORE_NR] = {
1092 + .pci_ops = &ifx_pcie_ops,
1093 + .mem_resource = &ifx_pcie_mem_resource,
1094 + .io_resource = &ifx_pcie_io_resource,
1096 + .port = IFX_PCIE_PORT0,
1100 +#ifdef IFX_PCIE_ERROR_INT
1102 +static irqreturn_t pcie_rc_core_isr(int irq, void *dev_id)
1104 + struct ifx_pci_controller *ctrl = (struct ifx_pci_controller *)dev_id;
1105 + int pcie_port = ctrl->port;
1108 + pr_debug("PCIe RC error intr %d\n", irq);
1109 + reg = IFX_REG_R32(PCIE_IRNCR(pcie_port));
1110 + reg &= PCIE_RC_CORE_COMBINED_INT;
1111 + IFX_REG_W32(reg, PCIE_IRNCR(pcie_port));
1113 + return IRQ_HANDLED;
1117 +pcie_rc_core_int_init(int pcie_port)
1121 + /* Enable core interrupt */
1122 + IFX_REG_SET_BIT(PCIE_RC_CORE_COMBINED_INT, PCIE_IRNEN(pcie_port));
1124 + /* Clear it first */
1125 + IFX_REG_SET_BIT(PCIE_RC_CORE_COMBINED_INT, PCIE_IRNCR(pcie_port));
1126 + ret = request_irq(pcie_irqs[pcie_port].ir_irq.irq, pcie_rc_core_isr, 0,
1127 + pcie_irqs[pcie_port].ir_irq.name, &ifx_pcie_controller[pcie_port]);
1129 + printk(KERN_ERR "%s request irq %d failed\n", __func__, IFX_PCIE_IR);
1135 +int ifx_pcie_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin)
1139 + struct ifx_pci_controller *ctrl = dev->bus->sysdata;
1140 + int pcie_port = ctrl->port;
1142 + printk("%s port %d dev %s slot %d pin %d \n", __func__, pcie_port, pci_name(dev), slot, pin);
1144 + if ((pin == PCIE_LEGACY_DISABLE) || (pin > PCIE_LEGACY_INT_MAX)) {
1145 + printk(KERN_WARNING "WARNING: dev %s: invalid interrupt pin %d\n", pci_name(dev), pin);
1149 + /* Pin index so minus one */
1150 + irq_bit = pcie_irqs[pcie_port].legacy_irq[pin - 1].irq_bit;
1151 + irq = pcie_irqs[pcie_port].legacy_irq[pin - 1].irq;
1152 + IFX_REG_SET_BIT(irq_bit, PCIE_IRNEN(pcie_port));
1153 + IFX_REG_SET_BIT(irq_bit, PCIE_IRNCR(pcie_port));
1154 + printk("%s dev %s irq %d assigned\n", __func__, pci_name(dev), irq);
1158 +int ifx_pcie_bios_plat_dev_init(struct pci_dev *dev)
1161 +#ifdef IFX_PCIE_ERROR_INT
1166 + /* Enable reporting System errors and parity errors on all devices */
1167 + /* Enable parity checking and error reporting */
1168 + pci_read_config_word(dev, PCI_COMMAND, &config);
1169 + config |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR /*| PCI_COMMAND_INVALIDATE |
1170 + PCI_COMMAND_FAST_BACK*/;
1171 + pci_write_config_word(dev, PCI_COMMAND, config);
1173 + if (dev->subordinate) {
1174 + /* Set latency timers on sub bridges */
1175 + pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 0x40); /* XXX, */
1176 + /* More bridge error detection */
1177 + pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &config);
1178 + config |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR;
1179 + pci_write_config_word(dev, PCI_BRIDGE_CONTROL, config);
1181 +#ifdef IFX_PCIE_ERROR_INT
1182 + /* Enable the PCIe normal error reporting */
1183 + pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
1186 + /* Disable system error generation in response to error messages */
1187 + pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &config);
1188 + config &= ~(PCI_EXP_RTCTL_SECEE | PCI_EXP_RTCTL_SENFEE | PCI_EXP_RTCTL_SEFEE);
1189 + pci_write_config_word(dev, pos + PCI_EXP_RTCTL, config);
1191 + /* Clear PCIE Capability's Device Status */
1192 + pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &config);
1193 + pci_write_config_word(dev, pos + PCI_EXP_DEVSTA, config);
1195 + /* Update Device Control */
1196 + pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &config);
1197 + /* Correctable Error Reporting */
1198 + config |= PCI_EXP_DEVCTL_CERE;
1199 + /* Non-Fatal Error Reporting */
1200 + config |= PCI_EXP_DEVCTL_NFERE;
1201 + /* Fatal Error Reporting */
1202 + config |= PCI_EXP_DEVCTL_FERE;
1203 + /* Unsupported Request */
1204 + config |= PCI_EXP_DEVCTL_URRE;
1205 + pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, config);
1208 + /* Find the Advanced Error Reporting capability */
1209 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
1211 + /* Clear Uncorrectable Error Status */
1212 + pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &dconfig);
1213 + pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, dconfig);
1214 + /* Enable reporting of all uncorrectable errors */
1215 + /* Uncorrectable Error Mask - turned on bits disable errors */
1216 + pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 0);
1218 + * Leave severity at HW default. This only controls if
1219 + * errors are reported as uncorrectable or
1220 + * correctable, not if the error is reported.
1222 + /* PCI_ERR_UNCOR_SEVER - Uncorrectable Error Severity */
1223 + /* Clear Correctable Error Status */
1224 + pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &dconfig);
1225 + pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, dconfig);
1226 + /* Enable reporting of all correctable errors */
1227 + /* Correctable Error Mask - turned on bits disable errors */
1228 + pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, 0);
1229 + /* Advanced Error Capabilities */
1230 + pci_read_config_dword(dev, pos + PCI_ERR_CAP, &dconfig);
1231 + /* ECRC Generation Enable */
1232 + if (dconfig & PCI_ERR_CAP_ECRC_GENC) {
1233 + dconfig |= PCI_ERR_CAP_ECRC_GENE;
1235 + /* ECRC Check Enable */
1236 + if (dconfig & PCI_ERR_CAP_ECRC_CHKC) {
1237 + dconfig |= PCI_ERR_CAP_ECRC_CHKE;
1239 + pci_write_config_dword(dev, pos + PCI_ERR_CAP, dconfig);
1241 + /* PCI_ERR_HEADER_LOG - Header Log Register (16 bytes) */
1242 + /* Enable Root Port's interrupt in response to error messages */
1243 + pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND,
1244 + PCI_ERR_ROOT_CMD_COR_EN |
1245 + PCI_ERR_ROOT_CMD_NONFATAL_EN |
1246 + PCI_ERR_ROOT_CMD_FATAL_EN);
1247 + /* Clear the Root status register */
1248 + pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &dconfig);
1249 + pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, dconfig);
1251 +#endif /* IFX_PCIE_ERROR_INT */
1252 + /* WAR, only 128 MRRS is supported, force all EPs to support this value */
1253 + pcie_set_readrq(dev, 128);
1258 +pcie_rc_initialize(int pcie_port)
1261 +#define IFX_PCIE_PHY_LOOP_CNT 5
1263 + pcie_rcu_endian_setup(pcie_port);
1265 + pcie_ep_gpio_rst_init(pcie_port);
1268 + * XXX, PCIe elastic buffer bug will cause not to be detected. One more
1269 + * reset PCIe PHY will solve this issue
1271 + for (i = 0; i < IFX_PCIE_PHY_LOOP_CNT; i++) {
1272 + /* Disable PCIe PHY Analog part for sanity check */
1273 + pcie_phy_pmu_disable(pcie_port);
1275 + pcie_phy_rst_assert(pcie_port);
1276 + pcie_phy_rst_deassert(pcie_port);
1278 + /* Make sure PHY PLL is stable */
1281 + /* PCIe Core reset enabled, low active, sw programmed */
1282 + pcie_core_rst_assert(pcie_port);
1284 + /* Put PCIe EP in reset status */
1285 + pcie_device_rst_assert(pcie_port);
1287 + /* PCI PHY & Core reset disabled, high active, sw programmed */
1288 + pcie_core_rst_deassert(pcie_port);
1290 + /* Already in a quiet state, program PLL, enable PHY, check ready bit */
1291 + pcie_phy_clock_mode_setup(pcie_port);
1293 + /* Enable PCIe PHY and Clock */
1294 + pcie_core_pmu_setup(pcie_port);
1296 + /* Clear status registers */
1297 + pcie_status_register_clear(pcie_port);
1299 +#ifdef CONFIG_PCI_MSI
1300 + pcie_msi_init(pcie_port);
1301 +#endif /* CONFIG_PCI_MSI */
1302 + pcie_rc_cfg_reg_setup(pcie_port);
1304 + /* Once link is up, break out */
1305 + if (pcie_app_loigc_setup(pcie_port) == 0)
1308 + if (i >= IFX_PCIE_PHY_LOOP_CNT) {
1309 + printk(KERN_ERR "%s link up failed!!!!!\n", __func__);
1312 + /* NB, don't increase ACK/NACK timer timeout value, which will cause a lot of COR errors */
1313 + pcie_replay_time_update(pcie_port);
1317 +static int __init ifx_pcie_bios_init(void)
1319 + void __iomem *io_map_base;
1323 + /* Enable AHB Master/ Slave */
1324 + pcie_ahb_pmu_setup();
1326 + startup_port = IFX_PCIE_PORT0;
1328 + for (pcie_port = startup_port; pcie_port < IFX_PCIE_CORE_NR; pcie_port++){
1329 + if (pcie_rc_initialize(pcie_port) == 0) {
1330 + IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: ifx_pcie_cfg_base 0x%p\n",
1331 + __func__, PCIE_CFG_PORT_TO_BASE(pcie_port));
1332 + /* Otherwise, warning will pop up */
1333 + io_map_base = ioremap(PCIE_IO_PHY_PORT_TO_BASE(pcie_port), PCIE_IO_SIZE);
1334 + if (io_map_base == NULL) {
1335 + IFX_PCIE_PRINT(PCIE_MSG_ERR, "%s io space ioremap failed\n", __func__);
1338 + ifx_pcie_controller[pcie_port].pcic.io_map_base = (unsigned long)io_map_base;
1340 + register_pci_controller(&ifx_pcie_controller[pcie_port].pcic);
1341 + /* XXX, clear error status */
1343 + IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: mem_resource 0x%p, io_resource 0x%p\n",
1344 + __func__, &ifx_pcie_controller[pcie_port].pcic.mem_resource,
1345 + &ifx_pcie_controller[pcie_port].pcic.io_resource);
1347 + #ifdef IFX_PCIE_ERROR_INT
1348 + pcie_rc_core_int_init(pcie_port);
1349 + #endif /* IFX_PCIE_ERROR_INT */
1355 +arch_initcall(ifx_pcie_bios_init);
1357 +MODULE_LICENSE("GPL");
1358 +MODULE_AUTHOR("Chuanhua.Lei@infineon.com");
1359 +MODULE_SUPPORTED_DEVICE("Infineon builtin PCIe RC module");
1360 +MODULE_DESCRIPTION("Infineon builtin PCIe RC driver");
1363 +++ b/arch/mips/pci/ifxmips_pcie.h
1365 +/******************************************************************************
1367 +** FILE NAME : ifxmips_pcie.h
1368 +** PROJECT : IFX UEIP for VRX200
1369 +** MODULES : PCIe module
1371 +** DATE : 02 Mar 2009
1372 +** AUTHOR : Lei Chuanhua
1373 +** DESCRIPTION : PCIe Root Complex Driver
1374 +** COPYRIGHT : Copyright (c) 2009
1375 +** Infineon Technologies AG
1376 +** Am Campeon 1-12, 85579 Neubiberg, Germany
1378 +** This program is free software; you can redistribute it and/or modify
1379 +** it under the terms of the GNU General Public License as published by
1380 +** the Free Software Foundation; either version 2 of the License, or
1381 +** (at your option) any later version.
1383 +** $Version $Date $Author $Comment
1384 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
1385 +*******************************************************************************/
1386 +#ifndef IFXMIPS_PCIE_H
1387 +#define IFXMIPS_PCIE_H
1388 +#include <linux/version.h>
1389 +#include <linux/types.h>
1390 +#include <linux/pci.h>
1391 +#include <linux/interrupt.h>
1392 +#include "ifxmips_pci_common.h"
1393 +#include "ifxmips_pcie_reg.h"
1396 + \defgroup IFX_PCIE PCI Express bus driver module
1397 + \brief PCI Express IP module support VRX200
1401 + \defgroup IFX_PCIE_OS OS APIs
1403 + \brief PCIe bus driver OS interface functions
1407 + \file ifxmips_pcie.h
1409 + \brief header file for PCIe module common header file
1411 +#define PCIE_IRQ_LOCK(lock) do { \
1412 + unsigned long flags; \
1413 + spin_lock_irqsave(&(lock), flags);
1414 +#define PCIE_IRQ_UNLOCK(lock) \
1415 + spin_unlock_irqrestore(&(lock), flags); \
1418 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
1419 +#define IRQF_SHARED SA_SHIRQ
1422 +#define PCIE_MSG_MSI 0x00000001
1423 +#define PCIE_MSG_ISR 0x00000002
1424 +#define PCIE_MSG_FIXUP 0x00000004
1425 +#define PCIE_MSG_READ_CFG 0x00000008
1426 +#define PCIE_MSG_WRITE_CFG 0x00000010
1427 +#define PCIE_MSG_CFG (PCIE_MSG_READ_CFG | PCIE_MSG_WRITE_CFG)
1428 +#define PCIE_MSG_REG 0x00000020
1429 +#define PCIE_MSG_INIT 0x00000040
1430 +#define PCIE_MSG_ERR 0x00000080
1431 +#define PCIE_MSG_PHY 0x00000100
1432 +#define PCIE_MSG_ANY 0x000001ff
1434 +#define IFX_PCIE_PORT0 0
1435 +#define IFX_PCIE_PORT1 1
1437 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
1438 +#define IFX_PCIE_CORE_NR 2
1440 +#define IFX_PCIE_CORE_NR 1
1443 +#define IFX_PCIE_ERROR_INT
1445 +//#define IFX_PCIE_DBG
1447 +#if defined(IFX_PCIE_DBG)
1448 +#define IFX_PCIE_PRINT(_m, _fmt, args...) do { \
1449 + ifx_pcie_debug((_fmt), ##args); \
1454 +#define IFX_PCIE_PRINT(_m, _fmt, args...) \
1456 +#define INLINE inline
1459 +struct ifx_pci_controller {
1460 + struct pci_controller pcic;
1462 + /* RC specific, per host bus information */
1463 + u32 port; /* Port index, 0 -- 1st core, 1 -- 2nd core */
1466 +typedef struct ifx_pcie_ir_irq {
1467 + const unsigned int irq;
1468 + const char name[16];
1469 +}ifx_pcie_ir_irq_t;
1471 +typedef struct ifx_pcie_legacy_irq{
1472 + const u32 irq_bit;
1474 +}ifx_pcie_legacy_irq_t;
1476 +typedef struct ifx_pcie_irq {
1477 + ifx_pcie_ir_irq_t ir_irq;
1478 + ifx_pcie_legacy_irq_t legacy_irq[PCIE_LEGACY_INT_MAX];
1481 +extern u32 g_pcie_debug_flag;
1482 +extern void ifx_pcie_debug(const char *fmt, ...);
1483 +extern void pcie_phy_clock_mode_setup(int pcie_port);
1484 +extern void pcie_msi_pic_init(int pcie_port);
1485 +extern u32 ifx_pcie_bus_enum_read_hack(int where, u32 value);
1486 +extern u32 ifx_pcie_bus_enum_write_hack(int where, u32 value);
1491 +#include "ifxmips_pcie_vr9.h"
1492 +#elif defined (CONFIG_AR10)
1493 +#include "ifxmips_pcie_ar10.h"
1495 +#error "PCIE: platform not defined"
1496 +#endif /* CONFIG_VR9 */
1498 +#endif /* IFXMIPS_PCIE_H */
1501 +++ b/arch/mips/pci/ifxmips_pcie_ar10.h
1503 +/****************************************************************************
1504 + Copyright (c) 2010
1505 + Lantiq Deutschland GmbH
1506 + Am Campeon 3; 85579 Neubiberg, Germany
1508 + For licensing information, see the file 'LICENSE' in the root folder of
1509 + this software module.
1511 + *****************************************************************************/
1513 + \file ifxmips_pcie_ar10.h
1515 + \brief PCIe RC driver ar10 specific file
1518 +#ifndef IFXMIPS_PCIE_AR10_H
1519 +#define IFXMIPS_PCIE_AR10_H
1520 +#ifndef AUTOCONF_INCLUDED
1521 +#include <linux/config.h>
1522 +#endif /* AUTOCONF_INCLUDED */
1523 +#include <linux/types.h>
1524 +#include <linux/delay.h>
1526 +/* Project header file */
1527 +#include <asm/ifx/ifx_types.h>
1528 +#include <asm/ifx/ifx_pmu.h>
1529 +#include <asm/ifx/ifx_gpio.h>
1530 +#include <asm/ifx/ifx_ebu_led.h>
1532 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
1534 + ifx_ebu_led_enable();
1535 + if (pcie_port == 0) {
1536 + ifx_ebu_led_set_data(11, 1);
1539 + ifx_ebu_led_set_data(12, 1);
1543 +static inline void pcie_ahb_pmu_setup(void)
1545 + /* XXX, moved to CGU to control AHBM */
1548 +static inline void pcie_rcu_endian_setup(int pcie_port)
1552 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
1553 + /* Inbound, big endian */
1554 + reg |= IFX_RCU_BE_AHB4S;
1555 + if (pcie_port == 0) {
1556 + reg |= IFX_RCU_BE_PCIE0M;
1558 + #ifdef CONFIG_IFX_PCIE_HW_SWAP
1559 + /* Outbound, software swap needed */
1560 + reg |= IFX_RCU_BE_AHB3M;
1561 + reg &= ~IFX_RCU_BE_PCIE0S;
1563 + /* Outbound little endian */
1564 + reg &= ~IFX_RCU_BE_AHB3M;
1565 + reg &= ~IFX_RCU_BE_PCIE0S;
1569 + reg |= IFX_RCU_BE_PCIE1M;
1570 + #ifdef CONFIG_IFX_PCIE1_HW_SWAP
1571 + /* Outbound, software swap needed */
1572 + reg |= IFX_RCU_BE_AHB3M;
1573 + reg &= ~IFX_RCU_BE_PCIE1S;
1575 + /* Outbound little endian */
1576 + reg &= ~IFX_RCU_BE_AHB3M;
1577 + reg &= ~IFX_RCU_BE_PCIE1S;
1581 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
1582 + IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
1585 +static inline void pcie_phy_pmu_enable(int pcie_port)
1587 + if (pcie_port == 0) { /* XXX, should use macro*/
1588 + PCIE0_PHY_PMU_SETUP(IFX_PMU_ENABLE);
1591 + PCIE1_PHY_PMU_SETUP(IFX_PMU_ENABLE);
1595 +static inline void pcie_phy_pmu_disable(int pcie_port)
1597 + if (pcie_port == 0) { /* XXX, should use macro*/
1598 + PCIE0_PHY_PMU_SETUP(IFX_PMU_DISABLE);
1601 + PCIE1_PHY_PMU_SETUP(IFX_PMU_DISABLE);
1605 +static inline void pcie_pdi_big_endian(int pcie_port)
1609 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
1610 + if (pcie_port == 0) {
1611 + /* Config AHB->PCIe and PDI endianness */
1612 + reg |= IFX_RCU_BE_PCIE0_PDI;
1615 + /* Config AHB->PCIe and PDI endianness */
1616 + reg |= IFX_RCU_BE_PCIE1_PDI;
1618 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
1621 +static inline void pcie_pdi_pmu_enable(int pcie_port)
1623 + if (pcie_port == 0) {
1624 + /* Enable PDI to access PCIe PHY register */
1625 + PDI0_PMU_SETUP(IFX_PMU_ENABLE);
1628 + PDI1_PMU_SETUP(IFX_PMU_ENABLE);
1632 +static inline void pcie_core_rst_assert(int pcie_port)
1636 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1638 + /* Reset Core, bit 22 */
1639 + if (pcie_port == 0) {
1640 + reg |= 0x00400000;
1643 + reg |= 0x08000000; /* Bit 27 */
1645 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1648 +static inline void pcie_core_rst_deassert(int pcie_port)
1652 + /* Make sure one micro-second delay */
1655 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1656 + if (pcie_port == 0) {
1657 + reg &= ~0x00400000; /* bit 22 */
1660 + reg &= ~0x08000000; /* Bit 27 */
1662 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1665 +static inline void pcie_phy_rst_assert(int pcie_port)
1669 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1670 + if (pcie_port == 0) {
1671 + reg |= 0x00001000; /* Bit 12 */
1674 + reg |= 0x00002000; /* Bit 13 */
1676 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1679 +static inline void pcie_phy_rst_deassert(int pcie_port)
1683 + /* Make sure one micro-second delay */
1686 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1687 + if (pcie_port == 0) {
1688 + reg &= ~0x00001000; /* Bit 12 */
1691 + reg &= ~0x00002000; /* Bit 13 */
1693 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1696 +static inline void pcie_device_rst_assert(int pcie_port)
1698 + if (pcie_port == 0) {
1699 + ifx_ebu_led_set_data(11, 0);
1702 + ifx_ebu_led_set_data(12, 0);
1706 +static inline void pcie_device_rst_deassert(int pcie_port)
1709 + if (pcie_port == 0) {
1710 + ifx_ebu_led_set_data(11, 1);
1713 + ifx_ebu_led_set_data(12, 1);
1715 + ifx_ebu_led_disable();
1718 +static inline void pcie_core_pmu_setup(int pcie_port)
1720 + if (pcie_port == 0) {
1721 + PCIE0_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
1724 + PCIE1_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
1728 +static inline void pcie_msi_init(int pcie_port)
1730 + pcie_msi_pic_init(pcie_port);
1731 + if (pcie_port == 0) {
1732 + MSI0_PMU_SETUP(IFX_PMU_ENABLE);
1735 + MSI1_PMU_SETUP(IFX_PMU_ENABLE);
1740 +ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
1742 + u32 tbus_number = bus_number;
1744 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
1745 + if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
1746 + if (pcibios_host_nr() > 1) {
1747 + tbus_number -= pcibios_1st_host_bus_nr();
1750 +#endif /* CONFIG_IFX_PCI */
1751 + return tbus_number;
1755 +ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
1757 + struct pci_dev *pdev;
1758 + u32 tvalue = value;
1760 + /* Sanity check */
1761 + pdev = pci_get_slot(bus, devfn);
1762 + if (pdev == NULL) {
1766 + /* Only care about PCI bridge */
1767 + if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
1771 + if (read) { /* Read hack */
1772 + #ifdef CONFIG_IFX_PCIE_2ND_CORE
1773 + if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
1774 + if (pcibios_host_nr() > 1) {
1775 + tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
1778 + #endif /* CONFIG_IFX_PCIE_2ND_CORE */
1780 + else { /* Write hack */
1781 + #ifdef CONFIG_IFX_PCIE_2ND_CORE
1782 + if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
1783 + if (pcibios_host_nr() > 1) {
1784 + tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
1792 +#endif /* IFXMIPS_PCIE_AR10_H */
1794 +++ b/arch/mips/pci/ifxmips_pcie_msi.c
1796 +/******************************************************************************
1798 +** FILE NAME : ifxmips_pcie_msi.c
1799 +** PROJECT : IFX UEIP for VRX200
1800 +** MODULES : PCI MSI sub module
1802 +** DATE : 02 Mar 2009
1803 +** AUTHOR : Lei Chuanhua
1804 +** DESCRIPTION : PCIe MSI Driver
1805 +** COPYRIGHT : Copyright (c) 2009
1806 +** Infineon Technologies AG
1807 +** Am Campeon 1-12, 85579 Neubiberg, Germany
1809 +** This program is free software; you can redistribute it and/or modify
1810 +** it under the terms of the GNU General Public License as published by
1811 +** the Free Software Foundation; either version 2 of the License, or
1812 +** (at your option) any later version.
1814 +** $Date $Author $Comment
1815 +** 02 Mar,2009 Lei Chuanhua Initial version
1816 +*******************************************************************************/
1818 + \defgroup IFX_PCIE_MSI MSI OS APIs
1820 + \brief PCIe bus driver OS interface functions
1824 + \file ifxmips_pcie_msi.c
1826 + \brief PCIe MSI OS interface file
1829 +#ifndef AUTOCONF_INCLUDED
1830 +#include <linux/config.h>
1831 +#endif /* AUTOCONF_INCLUDED */
1832 +#include <linux/init.h>
1833 +#include <linux/sched.h>
1834 +#include <linux/slab.h>
1835 +#include <linux/interrupt.h>
1836 +#include <linux/kernel_stat.h>
1837 +#include <linux/pci.h>
1838 +#include <linux/msi.h>
1839 +#include <linux/module.h>
1840 +#include <asm/bootinfo.h>
1841 +#include <asm/irq.h>
1842 +#include <asm/traps.h>
1844 +#include <asm/ifx/ifx_types.h>
1845 +#include <asm/ifx/ifx_regs.h>
1846 +#include <asm/ifx/common_routines.h>
1847 +#include <asm/ifx/irq.h>
1849 +#include "ifxmips_pcie_reg.h"
1850 +#include "ifxmips_pcie.h"
1852 +#define IFX_MSI_IRQ_NUM 16
1855 + IFX_PCIE_MSI_IDX0 = 0,
1856 + IFX_PCIE_MSI_IDX1,
1857 + IFX_PCIE_MSI_IDX2,
1858 + IFX_PCIE_MSI_IDX3,
1861 +typedef struct ifx_msi_irq_idx {
1864 +}ifx_msi_irq_idx_t;
1866 +struct ifx_msi_pic {
1867 + volatile u32 pic_table[IFX_MSI_IRQ_NUM];
1868 + volatile u32 pic_endian; /* 0x40 */
1870 +typedef struct ifx_msi_pic *ifx_msi_pic_t;
1872 +typedef struct ifx_msi_irq {
1873 + const volatile ifx_msi_pic_t msi_pic_p;
1874 + const u32 msi_phy_base;
1875 + const ifx_msi_irq_idx_t msi_irq_idx[IFX_MSI_IRQ_NUM];
1877 + * Each bit in msi_free_irq_bitmask represents a MSI interrupt that is
1880 + u16 msi_free_irq_bitmask;
1883 + * Each bit in msi_multiple_irq_bitmask tells that the device using
1884 + * this bit in msi_free_irq_bitmask is also using the next bit. This
1885 + * is used so we can disable all of the MSI interrupts when a device
1888 + u16 msi_multiple_irq_bitmask;
1891 +static ifx_msi_irq_t msi_irqs[IFX_PCIE_CORE_NR] = {
1893 + .msi_pic_p = (const volatile ifx_msi_pic_t)IFX_MSI_PIC_REG_BASE,
1894 + .msi_phy_base = PCIE_MSI_PHY_BASE,
1896 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1897 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1898 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1899 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1900 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1901 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1902 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1903 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1905 + .msi_free_irq_bitmask = 0,
1906 + .msi_multiple_irq_bitmask= 0,
1908 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
1910 + .msi_pic_p = (const volatile ifx_msi_pic_t)IFX_MSI1_PIC_REG_BASE,
1911 + .msi_phy_base = PCIE1_MSI_PHY_BASE,
1913 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1914 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1915 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1916 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1917 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1918 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1919 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1920 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1922 + .msi_free_irq_bitmask = 0,
1923 + .msi_multiple_irq_bitmask= 0,
1926 +#endif /* CONFIG_IFX_PCIE_2ND_CORE */
1930 + * This lock controls updates to msi_free_irq_bitmask,
1931 + * msi_multiple_irq_bitmask and pic register settting
1933 +static DEFINE_SPINLOCK(ifx_pcie_msi_lock);
1935 +void pcie_msi_pic_init(int pcie_port)
1937 + spin_lock(&ifx_pcie_msi_lock);
1938 + msi_irqs[pcie_port].msi_pic_p->pic_endian = IFX_MSI_PIC_BIG_ENDIAN;
1939 + spin_unlock(&ifx_pcie_msi_lock);
1943 + * \fn int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
1944 + * \brief Called when a driver request MSI interrupts instead of the
1945 + * legacy INT A-D. This routine will allocate multiple interrupts
1946 + * for MSI devices that support them. A device can override this by
1947 + * programming the MSI control bits [6:4] before calling
1948 + * pci_enable_msi().
1950 + * \param[in] pdev Device requesting MSI interrupts
1951 + * \param[in] desc MSI descriptor
1953 + * \return -EINVAL Invalid pcie root port or invalid msi bit
1955 + * \ingroup IFX_PCIE_MSI
1958 +arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
1964 + int configured_private_bits;
1965 + int request_private_bits;
1966 + struct msi_msg msg;
1968 + struct ifx_pci_controller *ctrl = pdev->bus->sysdata;
1969 + int pcie_port = ctrl->port;
1971 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s %s enter\n", __func__, pci_name(pdev));
1973 + /* XXX, skip RC MSI itself */
1974 + if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) {
1975 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s RC itself doesn't use MSI interrupt\n", __func__);
1980 + * Read the MSI config to figure out how many IRQs this device
1981 + * wants. Most devices only want 1, which will give
1982 + * configured_private_bits and request_private_bits equal 0.
1984 + pci_read_config_word(pdev, desc->msi_attrib.pos + PCI_MSI_FLAGS, &control);
1987 + * If the number of private bits has been configured then use
1988 + * that value instead of the requested number. This gives the
1989 + * driver the chance to override the number of interrupts
1990 + * before calling pci_enable_msi().
1992 + configured_private_bits = (control & PCI_MSI_FLAGS_QSIZE) >> 4;
1993 + if (configured_private_bits == 0) {
1994 + /* Nothing is configured, so use the hardware requested size */
1995 + request_private_bits = (control & PCI_MSI_FLAGS_QMASK) >> 1;
1999 + * Use the number of configured bits, assuming the
2000 + * driver wanted to override the hardware request
2003 + request_private_bits = configured_private_bits;
2007 + * The PCI 2.3 spec mandates that there are at most 32
2008 + * interrupts. If this device asks for more, only give it one.
2010 + if (request_private_bits > 5) {
2011 + request_private_bits = 0;
2015 + * The IRQs have to be aligned on a power of two based on the
2016 + * number being requested.
2018 + irq_step = (1 << request_private_bits);
2020 + /* Mask with one bit for each IRQ */
2021 + search_mask = (1 << irq_step) - 1;
2024 + * We're going to search msi_free_irq_bitmask_lock for zero
2025 + * bits. This represents an MSI interrupt number that isn't in
2028 + spin_lock(&ifx_pcie_msi_lock);
2029 + for (pos = 0; pos < IFX_MSI_IRQ_NUM; pos += irq_step) {
2030 + if ((msi_irqs[pcie_port].msi_free_irq_bitmask & (search_mask << pos)) == 0) {
2031 + msi_irqs[pcie_port].msi_free_irq_bitmask |= search_mask << pos;
2032 + msi_irqs[pcie_port].msi_multiple_irq_bitmask |= (search_mask >> 1) << pos;
2036 + spin_unlock(&ifx_pcie_msi_lock);
2038 + /* Make sure the search for available interrupts didn't fail */
2039 + if (pos >= IFX_MSI_IRQ_NUM) {
2040 + if (request_private_bits) {
2041 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s: Unable to find %d free "
2042 + "interrupts, trying just one", __func__, 1 << request_private_bits);
2043 + request_private_bits = 0;
2047 + printk(KERN_ERR "%s: Unable to find a free MSI interrupt\n", __func__);
2051 + irq = msi_irqs[pcie_port].msi_irq_idx[pos].irq;
2052 + irq_idx = msi_irqs[pcie_port].msi_irq_idx[pos].idx;
2054 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "pos %d, irq %d irq_idx %d\n", pos, irq, irq_idx);
2057 + * Initialize MSI. This has to match the memory-write endianess from the device
2058 + * Address bits [23:12]
2060 + spin_lock(&ifx_pcie_msi_lock);
2061 + msi_irqs[pcie_port].msi_pic_p->pic_table[pos] = SM(irq_idx, IFX_MSI_PIC_INT_LINE) |
2062 + SM((msi_irqs[pcie_port].msi_phy_base >> 12), IFX_MSI_PIC_MSG_ADDR) |
2063 + SM((1 << pos), IFX_MSI_PIC_MSG_DATA);
2065 + /* Enable this entry */
2066 + msi_irqs[pcie_port].msi_pic_p->pic_table[pos] &= ~IFX_MSI_PCI_INT_DISABLE;
2067 + spin_unlock(&ifx_pcie_msi_lock);
2069 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "pic_table[%d]: 0x%08x\n",
2070 + pos, msi_irqs[pcie_port].msi_pic_p->pic_table[pos]);
2072 + /* Update the number of IRQs the device has available to it */
2073 + control &= ~PCI_MSI_FLAGS_QSIZE;
2074 + control |= (request_private_bits << 4);
2075 + pci_write_config_word(pdev, desc->msi_attrib.pos + PCI_MSI_FLAGS, control);
2077 + set_irq_msi(irq, desc);
2078 + msg.address_hi = 0x0;
2079 + msg.address_lo = msi_irqs[pcie_port].msi_phy_base;
2080 + msg.data = SM((1 << pos), IFX_MSI_PIC_MSG_DATA);
2081 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "msi_data: pos %d 0x%08x\n", pos, msg.data);
2083 + write_msi_msg(irq, &msg);
2084 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s exit\n", __func__);
2089 +pcie_msi_irq_to_port(unsigned int irq, int *port)
2093 + if (irq == IFX_PCIE_MSI_IR0 || irq == IFX_PCIE_MSI_IR1 ||
2094 + irq == IFX_PCIE_MSI_IR2 || irq == IFX_PCIE_MSI_IR3) {
2095 + *port = IFX_PCIE_PORT0;
2097 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
2098 + else if (irq == IFX_PCIE1_MSI_IR0 || irq == IFX_PCIE1_MSI_IR1 ||
2099 + irq == IFX_PCIE1_MSI_IR2 || irq == IFX_PCIE1_MSI_IR3) {
2100 + *port = IFX_PCIE_PORT1;
2102 +#endif /* CONFIG_IFX_PCIE_2ND_CORE */
2104 + printk(KERN_ERR "%s: Attempted to teardown illegal "
2105 + "MSI interrupt (%d)\n", __func__, irq);
2112 + * \fn void arch_teardown_msi_irq(unsigned int irq)
2113 + * \brief Called when a device no longer needs its MSI interrupts. All
2114 + * MSI interrupts for the device are freed.
2116 + * \param irq The devices first irq number. There may be multple in sequence.
2118 + * \ingroup IFX_PCIE_MSI
2121 +arch_teardown_msi_irq(unsigned int irq)
2128 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s enter\n", __func__);
2130 + BUG_ON(irq > INT_NUM_IM4_IRL31);
2132 + if (pcie_msi_irq_to_port(irq, &pcie_port) != 0) {
2136 + /* Shift the mask to the correct bit location, not always correct
2137 + * Probally, the first match will be chosen.
2139 + for (pos = 0; pos < IFX_MSI_IRQ_NUM; pos++) {
2140 + if ((msi_irqs[pcie_port].msi_irq_idx[pos].irq == irq)
2141 + && (msi_irqs[pcie_port].msi_free_irq_bitmask & ( 1 << pos))) {
2145 + if (pos >= IFX_MSI_IRQ_NUM) {
2146 + printk(KERN_ERR "%s: Unable to find a matched MSI interrupt\n", __func__);
2149 + spin_lock(&ifx_pcie_msi_lock);
2150 + /* Disable this entry */
2151 + msi_irqs[pcie_port].msi_pic_p->pic_table[pos] |= IFX_MSI_PCI_INT_DISABLE;
2152 + msi_irqs[pcie_port].msi_pic_p->pic_table[pos] &= ~(IFX_MSI_PIC_INT_LINE | IFX_MSI_PIC_MSG_ADDR | IFX_MSI_PIC_MSG_DATA);
2153 + spin_unlock(&ifx_pcie_msi_lock);
2155 + * Count the number of IRQs we need to free by looking at the
2156 + * msi_multiple_irq_bitmask. Each bit set means that the next
2157 + * IRQ is also owned by this device.
2160 + while (((pos + number_irqs) < IFX_MSI_IRQ_NUM) &&
2161 + (msi_irqs[pcie_port].msi_multiple_irq_bitmask & (1 << (pos + number_irqs)))) {
2166 + /* Mask with one bit for each IRQ */
2167 + bitmask = (1 << number_irqs) - 1;
2170 + if ((msi_irqs[pcie_port].msi_free_irq_bitmask & bitmask) != bitmask) {
2171 + printk(KERN_ERR "%s: Attempted to teardown MSI "
2172 + "interrupt (%d) not in use\n", __func__, irq);
2175 + /* Checks are done, update the in use bitmask */
2176 + spin_lock(&ifx_pcie_msi_lock);
2177 + msi_irqs[pcie_port].msi_free_irq_bitmask &= ~bitmask;
2178 + msi_irqs[pcie_port].msi_multiple_irq_bitmask &= ~(bitmask >> 1);
2179 + spin_unlock(&ifx_pcie_msi_lock);
2180 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s exit\n", __func__);
2183 +MODULE_LICENSE("GPL");
2184 +MODULE_AUTHOR("Chuanhua.Lei@infineon.com");
2185 +MODULE_SUPPORTED_DEVICE("Infineon PCIe IP builtin MSI PIC module");
2186 +MODULE_DESCRIPTION("Infineon PCIe IP builtin MSI PIC driver");
2189 +++ b/arch/mips/pci/ifxmips_pcie_phy.c
2191 +/******************************************************************************
2193 +** FILE NAME : ifxmips_pcie_phy.c
2194 +** PROJECT : IFX UEIP for VRX200
2195 +** MODULES : PCIe PHY sub module
2197 +** DATE : 14 May 2009
2198 +** AUTHOR : Lei Chuanhua
2199 +** DESCRIPTION : PCIe Root Complex Driver
2200 +** COPYRIGHT : Copyright (c) 2009
2201 +** Infineon Technologies AG
2202 +** Am Campeon 1-12, 85579 Neubiberg, Germany
2204 +** This program is free software; you can redistribute it and/or modify
2205 +** it under the terms of the GNU General Public License as published by
2206 +** the Free Software Foundation; either version 2 of the License, or
2207 +** (at your option) any later version.
2209 +** $Version $Date $Author $Comment
2210 +** 0.0.1 14 May,2009 Lei Chuanhua Initial version
2211 +*******************************************************************************/
2213 + \file ifxmips_pcie_phy.c
2215 + \brief PCIe PHY PLL register programming source file
2217 +#include <linux/types.h>
2218 +#include <linux/kernel.h>
2219 +#include <asm/paccess.h>
2220 +#include <linux/delay.h>
2222 +#include "ifxmips_pcie_reg.h"
2223 +#include "ifxmips_pcie.h"
2225 +/* PCIe PDI only supports 16 bit operation */
2227 +#define IFX_PCIE_PHY_REG_WRITE16(__addr, __data) \
2228 + ((*(volatile u16 *) (__addr)) = (__data))
2230 +#define IFX_PCIE_PHY_REG_READ16(__addr) \
2231 + (*(volatile u16 *) (__addr))
2233 +#define IFX_PCIE_PHY_REG16(__addr) \
2234 + (*(volatile u16 *) (__addr))
2236 +#define IFX_PCIE_PHY_REG(__reg, __value, __mask) do { \
2239 + read_data = IFX_PCIE_PHY_REG_READ16((__reg)); \
2240 + write_data = (read_data & ((u16)~(__mask))) | (((u16)(__value)) & ((u16)(__mask)));\
2241 + IFX_PCIE_PHY_REG_WRITE16((__reg), write_data); \
2244 +#define IFX_PCIE_PLL_TIMEOUT 1000 /* Tunnable */
2246 +//#define IFX_PCI_PHY_REG_DUMP
2248 +#ifdef IFX_PCI_PHY_REG_DUMP
2250 +pcie_phy_reg_dump(int pcie_port)
2252 + printk("PLL REGFILE\n");
2253 + printk("PCIE_PHY_PLL_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL1(pcie_port)));
2254 + printk("PCIE_PHY_PLL_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL2(pcie_port)));
2255 + printk("PCIE_PHY_PLL_CTRL3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL3(pcie_port)));
2256 + printk("PCIE_PHY_PLL_CTRL4 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL4(pcie_port)));
2257 + printk("PCIE_PHY_PLL_CTRL5 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL5(pcie_port)));
2258 + printk("PCIE_PHY_PLL_CTRL6 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL6(pcie_port)));
2259 + printk("PCIE_PHY_PLL_CTRL7 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL7(pcie_port)));
2260 + printk("PCIE_PHY_PLL_A_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL1(pcie_port)));
2261 + printk("PCIE_PHY_PLL_A_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL2(pcie_port)));
2262 + printk("PCIE_PHY_PLL_A_CTRL3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL3(pcie_port)));
2263 + printk("PCIE_PHY_PLL_STATUS 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_STATUS(pcie_port)));
2265 + printk("TX1 REGFILE\n");
2266 + printk("PCIE_PHY_TX1_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL1(pcie_port)));
2267 + printk("PCIE_PHY_TX1_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL2(pcie_port)));
2268 + printk("PCIE_PHY_TX1_CTRL3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL3(pcie_port)));
2269 + printk("PCIE_PHY_TX1_A_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_A_CTRL1(pcie_port)));
2270 + printk("PCIE_PHY_TX1_A_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_A_CTRL2(pcie_port)));
2271 + printk("PCIE_PHY_TX1_MOD1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD1(pcie_port)));
2272 + printk("PCIE_PHY_TX1_MOD2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD2(pcie_port)));
2273 + printk("PCIE_PHY_TX1_MOD3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD3(pcie_port)));
2275 + printk("TX2 REGFILE\n");
2276 + printk("PCIE_PHY_TX2_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_CTRL1(pcie_port)));
2277 + printk("PCIE_PHY_TX2_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_CTRL2(pcie_port)));
2278 + printk("PCIE_PHY_TX2_A_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_A_CTRL1(pcie_port)));
2279 + printk("PCIE_PHY_TX2_A_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_A_CTRL2(pcie_port)));
2280 + printk("PCIE_PHY_TX2_MOD1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD1(pcie_port)));
2281 + printk("PCIE_PHY_TX2_MOD2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD2(pcie_port)));
2282 + printk("PCIE_PHY_TX2_MOD3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD3(pcie_port)));
2284 + printk("RX1 REGFILE\n");
2285 + printk("PCIE_PHY_RX1_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CTRL1(pcie_port)));
2286 + printk("PCIE_PHY_RX1_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CTRL2(pcie_port)));
2287 + printk("PCIE_PHY_RX1_CDR 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CDR(pcie_port)));
2288 + printk("PCIE_PHY_RX1_EI 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_EI(pcie_port)));
2289 + printk("PCIE_PHY_RX1_A_CTRL 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_A_CTRL(pcie_port)));
2291 +#endif /* IFX_PCI_PHY_REG_DUMP */
2294 +pcie_phy_comm_setup(int pcie_port)
2297 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL1(pcie_port), 0x120e, 0xFFFF);
2299 + /* increase the bias reference voltage */
2300 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x39D7, 0xFFFF);
2301 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x0900, 0xFFFF);
2304 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_EI(pcie_port), 0x0004, 0xFFFF);
2305 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_A_CTRL(pcie_port), 0x6803, 0xFFFF);
2308 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0008, 0x0008);
2310 + /* predrv_ser_en */
2311 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL2(pcie_port), 0x0706, 0xFFFF);
2314 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL3(pcie_port), 0x1FFF, 0xFFFF);
2317 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL1(pcie_port), 0x0800, 0xFF00);
2319 + /* predrv_ser_en */
2320 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4702, 0x7F00);
2323 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL2(pcie_port), 0x2e00, 0xFFFF);
2325 + /* Improved 100MHz clock output */
2326 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL2(pcie_port), 0x3096, 0xFFFF);
2327 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4707, 0xFFFF);
2329 + /* Reduced CDR BW to avoid glitches */
2330 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CDR(pcie_port), 0x0235, 0xFFFF);
2333 +#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_MODE
2335 +pcie_phy_36mhz_mode_setup(int pcie_port)
2337 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2338 +#ifdef IFX_PCI_PHY_REG_DUMP
2339 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2340 + pcie_phy_reg_dump(pcie_port);
2343 + /* en_ext_mmd_div_ratio */
2344 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
2346 + /* ext_mmd_div_ratio*/
2347 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
2350 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
2352 + /* en_const_sdm */
2353 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
2356 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
2359 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
2362 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
2365 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
2368 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
2369 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
2370 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
2371 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1b72, 0xFFFF);
2373 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2375 +#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_MODE */
2377 +#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE
2379 +pcie_phy_36mhz_ssc_mode_setup(int pcie_port)
2381 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2382 +#ifdef IFX_PCI_PHY_REG_DUMP
2383 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2384 + pcie_phy_reg_dump(pcie_port);
2388 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL1(pcie_port), 0x120e, 0xFFFF);
2390 + /* Increase the bias reference voltage */
2391 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x39D7, 0xFFFF);
2392 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x0900, 0xFFFF);
2395 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_EI(pcie_port), 0x0004, 0xFFFF);
2396 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_A_CTRL(pcie_port), 0x6803, 0xFFFF);
2399 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0008, 0x0008);
2401 + /* Predrv_ser_en */
2402 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL2(pcie_port), 0x0706, 0xFFFF);
2405 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL3(pcie_port), 0x1FFF, 0xFFFF);
2408 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL1(pcie_port), 0x0800, 0xFF00);
2410 + /* predrv_ser_en */
2411 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4702, 0x7F00);
2414 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL2(pcie_port), 0x2e00, 0xFFFF);
2416 + /* en_ext_mmd_div_ratio */
2417 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
2419 + /* ext_mmd_div_ratio*/
2420 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
2423 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0400, 0x0400);
2425 + /* en_const_sdm */
2426 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
2429 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
2432 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
2435 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
2437 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0000, 0x0100);
2439 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
2442 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
2443 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
2444 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
2445 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1c72, 0xFFFF);
2447 + /* improved 100MHz clock output */
2448 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL2(pcie_port), 0x3096, 0xFFFF);
2449 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4707, 0xFFFF);
2451 + /* reduced CDR BW to avoid glitches */
2452 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CDR(pcie_port), 0x0235, 0xFFFF);
2454 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2456 +#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE */
2458 +#ifdef CONFIG_IFX_PCIE_PHY_25MHZ_MODE
2460 +pcie_phy_25mhz_mode_setup(int pcie_port)
2462 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2463 +#ifdef IFX_PCI_PHY_REG_DUMP
2464 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2465 + pcie_phy_reg_dump(pcie_port);
2467 + /* en_const_sdm */
2468 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
2471 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0000, 0x0200);
2473 + /* en_ext_mmd_div_ratio*/
2474 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0002, 0x0002);
2476 + /* ext_mmd_div_ratio*/
2477 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0040, 0x0070);
2480 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x6000, 0xe000);
2483 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x4000, 0x4000);
2485 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2487 +#endif /* CONFIG_IFX_PCIE_PHY_25MHZ_MODE */
2489 +#ifdef CONFIG_IFX_PCIE_PHY_100MHZ_MODE
2491 +pcie_phy_100mhz_mode_setup(int pcie_port)
2493 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2494 +#ifdef IFX_PCI_PHY_REG_DUMP
2495 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2496 + pcie_phy_reg_dump(pcie_port);
2498 + /* en_ext_mmd_div_ratio */
2499 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
2501 + /* ext_mmd_div_ratio*/
2502 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
2505 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
2507 + /* en_const_sdm */
2508 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
2511 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
2514 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
2517 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
2520 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
2523 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
2524 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
2525 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
2526 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1b72, 0xFFFF);
2528 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2530 +#endif /* CONFIG_IFX_PCIE_PHY_100MHZ_MODE */
2533 +pcie_phy_wait_startup_ready(int pcie_port)
2537 + for (i = 0; i < IFX_PCIE_PLL_TIMEOUT; i++) {
2538 + if ((IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_STATUS(pcie_port)) & 0x0040) != 0) {
2543 + if (i >= IFX_PCIE_PLL_TIMEOUT) {
2544 + printk(KERN_ERR "%s PLL Link timeout\n", __func__);
2551 +pcie_phy_load_enable(int pcie_port, int slice)
2553 + /* Set the load_en of tx/rx slice to '1' */
2556 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0010, 0x0010);
2559 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL1(pcie_port), 0x0010, 0x0010);
2562 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CTRL1(pcie_port), 0x0002, 0x0002);
2568 +pcie_phy_load_disable(int pcie_port, int slice)
2570 + /* set the load_en of tx/rx slice to '0' */
2573 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0000, 0x0010);
2576 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL1(pcie_port), 0x0000, 0x0010);
2579 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CTRL1(pcie_port), 0x0000, 0x0002);
2585 +pcie_phy_load_war(int pcie_port)
2589 + for (slice = 1; slice < 4; slice++) {
2590 + pcie_phy_load_enable(pcie_port, slice);
2592 + pcie_phy_load_disable(pcie_port, slice);
2597 +pcie_phy_tx2_modulation(int pcie_port)
2599 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD1(pcie_port), 0x1FFE, 0xFFFF);
2600 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD2(pcie_port), 0xFFFE, 0xFFFF);
2601 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD3(pcie_port), 0x0601, 0xFFFF);
2603 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD3(pcie_port), 0x0001, 0xFFFF);
2607 +pcie_phy_tx1_modulation(int pcie_port)
2609 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD1(pcie_port), 0x1FFE, 0xFFFF);
2610 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD2(pcie_port), 0xFFFE, 0xFFFF);
2611 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD3(pcie_port), 0x0601, 0xFFFF);
2613 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD3(pcie_port), 0x0001, 0xFFFF);
2617 +pcie_phy_tx_modulation_war(int pcie_port)
2621 +#define PCIE_PHY_MODULATION_NUM 5
2622 + for (i = 0; i < PCIE_PHY_MODULATION_NUM; i++) {
2623 + pcie_phy_tx2_modulation(pcie_port);
2624 + pcie_phy_tx1_modulation(pcie_port);
2626 +#undef PCIE_PHY_MODULATION_NUM
2630 +pcie_phy_clock_mode_setup(int pcie_port)
2632 + pcie_pdi_big_endian(pcie_port);
2634 + /* Enable PDI to access PCIe PHY register */
2635 + pcie_pdi_pmu_enable(pcie_port);
2637 + /* Configure PLL and PHY clock */
2638 + pcie_phy_comm_setup(pcie_port);
2640 +#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_MODE
2641 + pcie_phy_36mhz_mode_setup(pcie_port);
2642 +#elif defined(CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE)
2643 + pcie_phy_36mhz_ssc_mode_setup(pcie_port);
2644 +#elif defined(CONFIG_IFX_PCIE_PHY_25MHZ_MODE)
2645 + pcie_phy_25mhz_mode_setup(pcie_port);
2646 +#elif defined (CONFIG_IFX_PCIE_PHY_100MHZ_MODE)
2647 + pcie_phy_100mhz_mode_setup(pcie_port);
2649 + #error "PCIE PHY Clock Mode must be chosen first!!!!"
2650 +#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_MODE */
2652 + /* Enable PCIe PHY and make PLL setting take effect */
2653 + pcie_phy_pmu_enable(pcie_port);
2655 + /* Check if we are in startup_ready status */
2656 + pcie_phy_wait_startup_ready(pcie_port);
2658 + pcie_phy_load_war(pcie_port);
2660 + /* Apply TX modulation workarounds */
2661 + pcie_phy_tx_modulation_war(pcie_port);
2663 +#ifdef IFX_PCI_PHY_REG_DUMP
2664 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Modified PHY register dump\n");
2665 + pcie_phy_reg_dump(pcie_port);
2670 +++ b/arch/mips/pci/ifxmips_pcie_pm.c
2672 +/******************************************************************************
2674 +** FILE NAME : ifxmips_pcie_pm.c
2675 +** PROJECT : IFX UEIP
2676 +** MODULES : PCIE Root Complex Driver
2678 +** DATE : 21 Dec 2009
2679 +** AUTHOR : Lei Chuanhua
2680 +** DESCRIPTION : PCIE Root Complex Driver Power Managment
2681 +** COPYRIGHT : Copyright (c) 2009
2682 +** Lantiq Deutschland GmbH
2683 +** Am Campeon 3, 85579 Neubiberg, Germany
2685 +** This program is free software; you can redistribute it and/or modify
2686 +** it under the terms of the GNU General Public License as published by
2687 +** the Free Software Foundation; either version 2 of the License, or
2688 +** (at your option) any later version.
2691 +** $Date $Author $Comment
2692 +** 21 Dec,2009 Lei Chuanhua First UEIP release
2693 +*******************************************************************************/
2695 + \defgroup IFX_PCIE_PM Power Management functions
2697 + \brief IFX PCIE Root Complex Driver power management functions
2701 + \file ifxmips_pcie_pm.c
2703 + \brief source file for PCIE Root Complex Driver Power Management
2706 +#ifndef EXPORT_SYMTAB
2707 +#define EXPORT_SYMTAB
2709 +#ifndef AUTOCONF_INCLUDED
2710 +#include <linux/config.h>
2711 +#endif /* AUTOCONF_INCLUDED */
2712 +#include <linux/version.h>
2713 +#include <linux/module.h>
2714 +#include <linux/types.h>
2715 +#include <linux/kernel.h>
2716 +#include <asm/system.h>
2718 +/* Project header */
2719 +#include <asm/ifx/ifx_types.h>
2720 +#include <asm/ifx/ifx_regs.h>
2721 +#include <asm/ifx/common_routines.h>
2722 +#include <asm/ifx/ifx_pmcu.h>
2723 +#include "ifxmips_pcie_pm.h"
2726 + * \fn static IFX_PMCU_RETURN_t ifx_pcie_pmcu_state_change(IFX_PMCU_STATE_t pmcuState)
2727 + * \brief the callback function to request pmcu state in the power management hardware-dependent module
2729 + * \param pmcuState This parameter is a PMCU state.
2731 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2732 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2733 + * \return IFX_PMCU_RETURN_DENIED Not allowed to operate power state
2734 + * \ingroup IFX_PCIE_PM
2736 +static IFX_PMCU_RETURN_t
2737 +ifx_pcie_pmcu_state_change(IFX_PMCU_STATE_t pmcuState)
2741 + case IFX_PMCU_STATE_D0:
2742 + return IFX_PMCU_RETURN_SUCCESS;
2743 + case IFX_PMCU_STATE_D1: // Not Applicable
2744 + return IFX_PMCU_RETURN_DENIED;
2745 + case IFX_PMCU_STATE_D2: // Not Applicable
2746 + return IFX_PMCU_RETURN_DENIED;
2747 + case IFX_PMCU_STATE_D3: // Module clock gating and Power gating
2748 + return IFX_PMCU_RETURN_SUCCESS;
2750 + return IFX_PMCU_RETURN_DENIED;
2755 + * \fn static IFX_PMCU_RETURN_t ifx_pcie_pmcu_state_get(IFX_PMCU_STATE_t *pmcuState)
2756 + * \brief the callback function to get pmcu state in the power management hardware-dependent module
2758 + * \param pmcuState Pointer to return power state.
2760 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2761 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2762 + * \return IFX_PMCU_RETURN_DENIED Not allowed to operate power state
2763 + * \ingroup IFX_PCIE_PM
2765 +static IFX_PMCU_RETURN_t
2766 +ifx_pcie_pmcu_state_get(IFX_PMCU_STATE_t *pmcuState)
2768 + return IFX_PMCU_RETURN_SUCCESS;
2772 + * \fn IFX_PMCU_RETURN_t ifx_pcie_pmcu_prechange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2773 + * \brief Apply all callbacks registered to be executed before a state change for pmcuModule
2775 + * \param pmcuModule Module
2776 + * \param newState New state
2777 + * \param oldState Old state
2778 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2779 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2780 + * \ingroup IFX_PCIE_PM
2782 +static IFX_PMCU_RETURN_t
2783 +ifx_pcie_pmcu_prechange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2785 + return IFX_PMCU_RETURN_SUCCESS;
2789 + * \fn IFX_PMCU_RETURN_t ifx_pcie_pmcu_postchange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2790 + * \brief Apply all callbacks registered to be executed before a state change for pmcuModule
2792 + * \param pmcuModule Module
2793 + * \param newState New state
2794 + * \param oldState Old state
2795 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2796 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2797 + * \ingroup IFX_PCIE_PM
2799 +static IFX_PMCU_RETURN_t
2800 +ifx_pcie_pmcu_postchange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2802 + return IFX_PMCU_RETURN_SUCCESS;
2806 + * \fn static void ifx_pcie_pmcu_init(void)
2807 + * \brief Register with central PMCU module
2809 + * \ingroup IFX_PCIE_PM
2812 +ifx_pcie_pmcu_init(void)
2814 + IFX_PMCU_REGISTER_t pmcuRegister;
2816 + /* XXX, hook driver context */
2818 + /* State function register */
2819 + memset(&pmcuRegister, 0, sizeof(IFX_PMCU_REGISTER_t));
2820 + pmcuRegister.pmcuModule = IFX_PMCU_MODULE_PCIE;
2821 + pmcuRegister.pmcuModuleNr = 0;
2822 + pmcuRegister.ifx_pmcu_state_change = ifx_pcie_pmcu_state_change;
2823 + pmcuRegister.ifx_pmcu_state_get = ifx_pcie_pmcu_state_get;
2824 + pmcuRegister.pre = ifx_pcie_pmcu_prechange;
2825 + pmcuRegister.post= ifx_pcie_pmcu_postchange;
2826 + ifx_pmcu_register(&pmcuRegister);
2830 + * \fn static void ifx_pcie_pmcu_exit(void)
2831 + * \brief Unregister with central PMCU module
2834 + * \ingroup IFX_PCIE_PM
2837 +ifx_pcie_pmcu_exit(void)
2839 + IFX_PMCU_REGISTER_t pmcuUnRegister;
2841 + /* XXX, hook driver context */
2843 + pmcuUnRegister.pmcuModule = IFX_PMCU_MODULE_PCIE;
2844 + pmcuUnRegister.pmcuModuleNr = 0;
2845 + ifx_pmcu_unregister(&pmcuUnRegister);
2849 +++ b/arch/mips/pci/ifxmips_pcie_pm.h
2851 +/******************************************************************************
2853 +** FILE NAME : ifxmips_pcie_pm.h
2854 +** PROJECT : IFX UEIP
2855 +** MODULES : PCIe Root Complex Driver
2857 +** DATE : 21 Dec 2009
2858 +** AUTHOR : Lei Chuanhua
2859 +** DESCRIPTION : PCIe Root Complex Driver Power Managment
2860 +** COPYRIGHT : Copyright (c) 2009
2861 +** Lantiq Deutschland GmbH
2862 +** Am Campeon 3, 85579 Neubiberg, Germany
2864 +** This program is free software; you can redistribute it and/or modify
2865 +** it under the terms of the GNU General Public License as published by
2866 +** the Free Software Foundation; either version 2 of the License, or
2867 +** (at your option) any later version.
2870 +** $Date $Author $Comment
2871 +** 21 Dec,2009 Lei Chuanhua First UEIP release
2872 +*******************************************************************************/
2874 + \file ifxmips_pcie_pm.h
2876 + \brief header file for PCIe Root Complex Driver Power Management
2879 +#ifndef IFXMIPS_PCIE_PM_H
2880 +#define IFXMIPS_PCIE_PM_H
2882 +void ifx_pcie_pmcu_init(void);
2883 +void ifx_pcie_pmcu_exit(void);
2885 +#endif /* IFXMIPS_PCIE_PM_H */
2888 +++ b/arch/mips/pci/ifxmips_pcie_reg.h
2890 +/******************************************************************************
2892 +** FILE NAME : ifxmips_pcie_reg.h
2893 +** PROJECT : IFX UEIP for VRX200
2894 +** MODULES : PCIe module
2896 +** DATE : 02 Mar 2009
2897 +** AUTHOR : Lei Chuanhua
2898 +** DESCRIPTION : PCIe Root Complex Driver
2899 +** COPYRIGHT : Copyright (c) 2009
2900 +** Infineon Technologies AG
2901 +** Am Campeon 1-12, 85579 Neubiberg, Germany
2903 +** This program is free software; you can redistribute it and/or modify
2904 +** it under the terms of the GNU General Public License as published by
2905 +** the Free Software Foundation; either version 2 of the License, or
2906 +** (at your option) any later version.
2908 +** $Version $Date $Author $Comment
2909 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
2910 +*******************************************************************************/
2911 +#ifndef IFXMIPS_PCIE_REG_H
2912 +#define IFXMIPS_PCIE_REG_H
2914 + \file ifxmips_pcie_reg.h
2916 + \brief header file for PCIe module register definition
2918 +/* PCIe Address Mapping Base */
2919 +#define PCIE_CFG_PHY_BASE 0x1D000000UL
2920 +#define PCIE_CFG_BASE (KSEG1 + PCIE_CFG_PHY_BASE)
2921 +#define PCIE_CFG_SIZE (8 * 1024 * 1024)
2923 +#define PCIE_MEM_PHY_BASE 0x1C000000UL
2924 +#define PCIE_MEM_BASE (KSEG1 + PCIE_MEM_PHY_BASE)
2925 +#define PCIE_MEM_SIZE (16 * 1024 * 1024)
2926 +#define PCIE_MEM_PHY_END (PCIE_MEM_PHY_BASE + PCIE_MEM_SIZE - 1)
2928 +#define PCIE_IO_PHY_BASE 0x1D800000UL
2929 +#define PCIE_IO_BASE (KSEG1 + PCIE_IO_PHY_BASE)
2930 +#define PCIE_IO_SIZE (1 * 1024 * 1024)
2931 +#define PCIE_IO_PHY_END (PCIE_IO_PHY_BASE + PCIE_IO_SIZE - 1)
2933 +#define PCIE_RC_CFG_BASE (KSEG1 + 0x1D900000)
2934 +#define PCIE_APP_LOGIC_REG (KSEG1 + 0x1E100900)
2935 +#define PCIE_MSI_PHY_BASE 0x1F600000UL
2937 +#define PCIE_PDI_PHY_BASE 0x1F106800UL
2938 +#define PCIE_PDI_BASE (KSEG1 + PCIE_PDI_PHY_BASE)
2939 +#define PCIE_PDI_SIZE 0x400
2941 +#define PCIE1_CFG_PHY_BASE 0x19000000UL
2942 +#define PCIE1_CFG_BASE (KSEG1 + PCIE1_CFG_PHY_BASE)
2943 +#define PCIE1_CFG_SIZE (8 * 1024 * 1024)
2945 +#define PCIE1_MEM_PHY_BASE 0x18000000UL
2946 +#define PCIE1_MEM_BASE (KSEG1 + PCIE1_MEM_PHY_BASE)
2947 +#define PCIE1_MEM_SIZE (16 * 1024 * 1024)
2948 +#define PCIE1_MEM_PHY_END (PCIE1_MEM_PHY_BASE + PCIE1_MEM_SIZE - 1)
2950 +#define PCIE1_IO_PHY_BASE 0x19800000UL
2951 +#define PCIE1_IO_BASE (KSEG1 + PCIE1_IO_PHY_BASE)
2952 +#define PCIE1_IO_SIZE (1 * 1024 * 1024)
2953 +#define PCIE1_IO_PHY_END (PCIE1_IO_PHY_BASE + PCIE1_IO_SIZE - 1)
2955 +#define PCIE1_RC_CFG_BASE (KSEG1 + 0x19900000)
2956 +#define PCIE1_APP_LOGIC_REG (KSEG1 + 0x1E100700)
2957 +#define PCIE1_MSI_PHY_BASE 0x1F400000UL
2959 +#define PCIE1_PDI_PHY_BASE 0x1F700400UL
2960 +#define PCIE1_PDI_BASE (KSEG1 + PCIE1_PDI_PHY_BASE)
2961 +#define PCIE1_PDI_SIZE 0x400
2963 +#define PCIE_CFG_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_CFG_BASE) : (PCIE_CFG_BASE))
2964 +#define PCIE_MEM_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_BASE) : (PCIE_MEM_BASE))
2965 +#define PCIE_IO_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_BASE) : (PCIE_IO_BASE))
2966 +#define PCIE_MEM_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_PHY_BASE) : (PCIE_MEM_PHY_BASE))
2967 +#define PCIE_MEM_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_MEM_PHY_END) : (PCIE_MEM_PHY_END))
2968 +#define PCIE_IO_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_PHY_BASE) : (PCIE_IO_PHY_BASE))
2969 +#define PCIE_IO_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_IO_PHY_END) : (PCIE_IO_PHY_END))
2970 +#define PCIE_APP_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_APP_LOGIC_REG) : (PCIE_APP_LOGIC_REG))
2971 +#define PCIE_RC_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_RC_CFG_BASE) : (PCIE_RC_CFG_BASE))
2972 +#define PCIE_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_PDI_BASE) : (PCIE_PDI_BASE))
2974 +/* PCIe Application Logic Register */
2975 +/* RC Core Control Register */
2976 +#define PCIE_RC_CCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x10)
2977 +/* This should be enabled after initializing configuratin registers
2978 + * Also should check link status retraining bit
2980 +#define PCIE_RC_CCR_LTSSM_ENABLE 0x00000001 /* Enable LTSSM to continue link establishment */
2982 +/* RC Core Debug Register */
2983 +#define PCIE_RC_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x14)
2984 +#define PCIE_RC_DR_DLL_UP 0x00000001 /* Data Link Layer Up */
2985 +#define PCIE_RC_DR_CURRENT_POWER_STATE 0x0000000E /* Current Power State */
2986 +#define PCIE_RC_DR_CURRENT_POWER_STATE_S 1
2987 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE 0x000001F0 /* Current LTSSM State */
2988 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE_S 4
2990 +#define PCIE_RC_DR_PM_DEV_STATE 0x00000E00 /* Power Management D-State */
2991 +#define PCIE_RC_DR_PM_DEV_STATE_S 9
2993 +#define PCIE_RC_DR_PM_ENABLED 0x00001000 /* Power Management State from PMU */
2994 +#define PCIE_RC_DR_PME_EVENT_ENABLED 0x00002000 /* Power Management Event Enable State */
2995 +#define PCIE_RC_DR_AUX_POWER_ENABLED 0x00004000 /* Auxiliary Power Enable */
2997 +/* Current Power State Definition */
2999 + PCIE_RC_DR_D0 = 0,
3000 + PCIE_RC_DR_D1, /* Not supported */
3001 + PCIE_RC_DR_D2, /* Not supported */
3006 +/* PHY Link Status Register */
3007 +#define PCIE_PHY_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x18)
3008 +#define PCIE_PHY_SR_PHY_LINK_UP 0x00000001 /* PHY Link Up/Down Indicator */
3010 +/* Electromechanical Control Register */
3011 +#define PCIE_EM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x1C)
3012 +#define PCIE_EM_CR_CARD_IS_PRESENT 0x00000001 /* Card Presence Detect State */
3013 +#define PCIE_EM_CR_MRL_OPEN 0x00000002 /* MRL Sensor State */
3014 +#define PCIE_EM_CR_POWER_FAULT_SET 0x00000004 /* Power Fault Detected */
3015 +#define PCIE_EM_CR_MRL_SENSOR_SET 0x00000008 /* MRL Sensor Changed */
3016 +#define PCIE_EM_CR_PRESENT_DETECT_SET 0x00000010 /* Card Presense Detect Changed */
3017 +#define PCIE_EM_CR_CMD_CPL_INT_SET 0x00000020 /* Command Complete Interrupt */
3018 +#define PCIE_EM_CR_SYS_INTERLOCK_SET 0x00000040 /* System Electromechanical IterLock Engaged */
3019 +#define PCIE_EM_CR_ATTENTION_BUTTON_SET 0x00000080 /* Attention Button Pressed */
3021 +/* Interrupt Status Register */
3022 +#define PCIE_IR_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x20)
3023 +#define PCIE_IR_SR_PME_CAUSE_MSI 0x00000002 /* MSI caused by PME */
3024 +#define PCIE_IR_SR_HP_PME_WAKE_GEN 0x00000004 /* Hotplug PME Wake Generation */
3025 +#define PCIE_IR_SR_HP_MSI 0x00000008 /* Hotplug MSI */
3026 +#define PCIE_IR_SR_AHB_LU_ERR 0x00000030 /* AHB Bridge Lookup Error Signals */
3027 +#define PCIE_IR_SR_AHB_LU_ERR_S 4
3028 +#define PCIE_IR_SR_INT_MSG_NUM 0x00003E00 /* Interrupt Message Number */
3029 +#define PCIE_IR_SR_INT_MSG_NUM_S 9
3030 +#define PCIE_IR_SR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
3031 +#define PCIE_IR_SR_AER_INT_MSG_NUM_S 27
3033 +/* Message Control Register */
3034 +#define PCIE_MSG_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x30)
3035 +#define PCIE_MSG_CR_GEN_PME_TURN_OFF_MSG 0x00000001 /* Generate PME Turn Off Message */
3036 +#define PCIE_MSG_CR_GEN_UNLOCK_MSG 0x00000002 /* Generate Unlock Message */
3038 +#define PCIE_VDM_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x34)
3040 +/* Vendor-Defined Message Requester ID Register */
3041 +#define PCIE_VDM_RID(X) (PCIE_APP_PORT_TO_BASE (X) + 0x38)
3042 +#define PCIE_VDM_RID_VENROR_MSG_REQ_ID 0x0000FFFF
3043 +#define PCIE_VDM_RID_VDMRID_S 0
3045 +/* ASPM Control Register */
3046 +#define PCIE_ASPM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x40)
3047 +#define PCIE_ASPM_CR_HOT_RST 0x00000001 /* Hot Reset Request to the downstream device */
3048 +#define PCIE_ASPM_CR_REQ_EXIT_L1 0x00000002 /* Request to Exit L1 */
3049 +#define PCIE_ASPM_CR_REQ_ENTER_L1 0x00000004 /* Request to Enter L1 */
3051 +/* Vendor Message DW0 Register */
3052 +#define PCIE_VM_MSG_DW0(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x50)
3053 +#define PCIE_VM_MSG_DW0_TYPE 0x0000001F /* Message type */
3054 +#define PCIE_VM_MSG_DW0_TYPE_S 0
3055 +#define PCIE_VM_MSG_DW0_FORMAT 0x00000060 /* Format */
3056 +#define PCIE_VM_MSG_DW0_FORMAT_S 5
3057 +#define PCIE_VM_MSG_DW0_TC 0x00007000 /* Traffic Class */
3058 +#define PCIE_VM_MSG_DW0_TC_S 12
3059 +#define PCIE_VM_MSG_DW0_ATTR 0x000C0000 /* Atrributes */
3060 +#define PCIE_VM_MSG_DW0_ATTR_S 18
3061 +#define PCIE_VM_MSG_DW0_EP_TLP 0x00100000 /* Poisoned TLP */
3062 +#define PCIE_VM_MSG_DW0_TD 0x00200000 /* TLP Digest */
3063 +#define PCIE_VM_MSG_DW0_LEN 0xFFC00000 /* Length */
3064 +#define PCIE_VM_MSG_DW0_LEN_S 22
3066 +/* Format Definition */
3068 + PCIE_VM_MSG_FORMAT_00 = 0, /* 3DW Hdr, no data*/
3069 + PCIE_VM_MSG_FORMAT_01, /* 4DW Hdr, no data */
3070 + PCIE_VM_MSG_FORMAT_10, /* 3DW Hdr, with data */
3071 + PCIE_VM_MSG_FORMAT_11, /* 4DW Hdr, with data */
3074 +/* Traffic Class Definition */
3076 + PCIE_VM_MSG_TC0 = 0,
3086 +/* Attributes Definition */
3088 + PCIE_VM_MSG_ATTR_00 = 0, /* RO and No Snoop cleared */
3089 + PCIE_VM_MSG_ATTR_01, /* RO cleared , No Snoop set */
3090 + PCIE_VM_MSG_ATTR_10, /* RO set, No Snoop cleared*/
3091 + PCIE_VM_MSG_ATTR_11, /* RO and No Snoop set */
3094 +/* Payload Size Definition */
3095 +#define PCIE_VM_MSG_LEN_MIN 0
3096 +#define PCIE_VM_MSG_LEN_MAX 1024
3098 +/* Vendor Message DW1 Register */
3099 +#define PCIE_VM_MSG_DW1(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x54)
3100 +#define PCIE_VM_MSG_DW1_FUNC_NUM 0x00000070 /* Function Number */
3101 +#define PCIE_VM_MSG_DW1_FUNC_NUM_S 8
3102 +#define PCIE_VM_MSG_DW1_CODE 0x00FF0000 /* Message Code */
3103 +#define PCIE_VM_MSG_DW1_CODE_S 16
3104 +#define PCIE_VM_MSG_DW1_TAG 0xFF000000 /* Tag */
3105 +#define PCIE_VM_MSG_DW1_TAG_S 24
3107 +#define PCIE_VM_MSG_DW2(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x58)
3108 +#define PCIE_VM_MSG_DW3(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x5C)
3110 +/* Vendor Message Request Register */
3111 +#define PCIE_VM_MSG_REQR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x60)
3112 +#define PCIE_VM_MSG_REQR_REQ 0x00000001 /* Vendor Message Request */
3115 +/* AHB Slave Side Band Control Register */
3116 +#define PCIE_AHB_SSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x70)
3117 +#define PCIE_AHB_SSB_REQ_BCM 0x00000001 /* Slave Reques BCM filed */
3118 +#define PCIE_AHB_SSB_REQ_EP 0x00000002 /* Slave Reques EP filed */
3119 +#define PCIE_AHB_SSB_REQ_TD 0x00000004 /* Slave Reques TD filed */
3120 +#define PCIE_AHB_SSB_REQ_ATTR 0x00000018 /* Slave Reques Attribute number */
3121 +#define PCIE_AHB_SSB_REQ_ATTR_S 3
3122 +#define PCIE_AHB_SSB_REQ_TC 0x000000E0 /* Slave Request TC Field */
3123 +#define PCIE_AHB_SSB_REQ_TC_S 5
3125 +/* AHB Master SideBand Ctrl Register */
3126 +#define PCIE_AHB_MSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x74)
3127 +#define PCIE_AHB_MSB_RESP_ATTR 0x00000003 /* Master Response Attribute number */
3128 +#define PCIE_AHB_MSB_RESP_ATTR_S 0
3129 +#define PCIE_AHB_MSB_RESP_BAD_EOT 0x00000004 /* Master Response Badeot filed */
3130 +#define PCIE_AHB_MSB_RESP_BCM 0x00000008 /* Master Response BCM filed */
3131 +#define PCIE_AHB_MSB_RESP_EP 0x00000010 /* Master Response EP filed */
3132 +#define PCIE_AHB_MSB_RESP_TD 0x00000020 /* Master Response TD filed */
3133 +#define PCIE_AHB_MSB_RESP_FUN_NUM 0x000003C0 /* Master Response Function number */
3134 +#define PCIE_AHB_MSB_RESP_FUN_NUM_S 6
3136 +/* AHB Control Register, fixed bus enumeration exception */
3137 +#define PCIE_AHB_CTRL(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x78)
3138 +#define PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS 0x00000001
3140 +/* Interrupt Enalbe Register */
3141 +#define PCIE_IRNEN(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF4)
3142 +#define PCIE_IRNCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF8)
3143 +#define PCIE_IRNICR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xFC)
3145 +/* PCIe interrupt enable/control/capture register definition */
3146 +#define PCIE_IRN_AER_REPORT 0x00000001 /* AER Interrupt */
3147 +#define PCIE_IRN_AER_MSIX 0x00000002 /* Advanced Error MSI-X Interrupt */
3148 +#define PCIE_IRN_PME 0x00000004 /* PME Interrupt */
3149 +#define PCIE_IRN_HOTPLUG 0x00000008 /* Hotplug Interrupt */
3150 +#define PCIE_IRN_RX_VDM_MSG 0x00000010 /* Vendor-Defined Message Interrupt */
3151 +#define PCIE_IRN_RX_CORRECTABLE_ERR_MSG 0x00000020 /* Correctable Error Message Interrupt */
3152 +#define PCIE_IRN_RX_NON_FATAL_ERR_MSG 0x00000040 /* Non-fatal Error Message */
3153 +#define PCIE_IRN_RX_FATAL_ERR_MSG 0x00000080 /* Fatal Error Message */
3154 +#define PCIE_IRN_RX_PME_MSG 0x00000100 /* PME Message Interrupt */
3155 +#define PCIE_IRN_RX_PME_TURNOFF_ACK 0x00000200 /* PME Turnoff Ack Message Interrupt */
3156 +#define PCIE_IRN_AHB_BR_FATAL_ERR 0x00000400 /* AHB Fatal Error Interrupt */
3157 +#define PCIE_IRN_LINK_AUTO_BW_STATUS 0x00000800 /* Link Auto Bandwidth Status Interrupt */
3158 +#define PCIE_IRN_BW_MGT 0x00001000 /* Bandwidth Managment Interrupt */
3159 +#define PCIE_IRN_INTA 0x00002000 /* INTA */
3160 +#define PCIE_IRN_INTB 0x00004000 /* INTB */
3161 +#define PCIE_IRN_INTC 0x00008000 /* INTC */
3162 +#define PCIE_IRN_INTD 0x00010000 /* INTD */
3163 +#define PCIE_IRN_WAKEUP 0x00020000 /* Wake up Interrupt */
3165 +#define PCIE_RC_CORE_COMBINED_INT (PCIE_IRN_AER_REPORT | PCIE_IRN_AER_MSIX | PCIE_IRN_PME | \
3166 + PCIE_IRN_HOTPLUG | PCIE_IRN_RX_VDM_MSG | PCIE_IRN_RX_CORRECTABLE_ERR_MSG |\
3167 + PCIE_IRN_RX_NON_FATAL_ERR_MSG | PCIE_IRN_RX_FATAL_ERR_MSG | \
3168 + PCIE_IRN_RX_PME_MSG | PCIE_IRN_RX_PME_TURNOFF_ACK | PCIE_IRN_AHB_BR_FATAL_ERR | \
3169 + PCIE_IRN_LINK_AUTO_BW_STATUS | PCIE_IRN_BW_MGT)
3170 +/* PCIe RC Configuration Register */
3171 +#define PCIE_VDID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x00)
3173 +/* Bit definition from pci_reg.h */
3174 +#define PCIE_PCICMDSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x04)
3175 +#define PCIE_CCRID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x08)
3176 +#define PCIE_CLSLTHTBR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x0C) /* EP only */
3177 +/* BAR0, BAR1,Only necessary if the bridges implements a device-specific register set or memory buffer */
3178 +#define PCIE_BAR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10) /* Not used*/
3179 +#define PCIE_BAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14) /* Not used */
3181 +#define PCIE_BNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x18) /* Mandatory */
3182 +/* Bus Number Register bits */
3183 +#define PCIE_BNR_PRIMARY_BUS_NUM 0x000000FF
3184 +#define PCIE_BNR_PRIMARY_BUS_NUM_S 0
3185 +#define PCIE_PNR_SECONDARY_BUS_NUM 0x0000FF00
3186 +#define PCIE_PNR_SECONDARY_BUS_NUM_S 8
3187 +#define PCIE_PNR_SUB_BUS_NUM 0x00FF0000
3188 +#define PCIE_PNR_SUB_BUS_NUM_S 16
3190 +/* IO Base/Limit Register bits */
3191 +#define PCIE_IOBLSECS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x1C) /* RC only */
3192 +#define PCIE_IOBLSECS_32BIT_IO_ADDR 0x00000001
3193 +#define PCIE_IOBLSECS_IO_BASE_ADDR 0x000000F0
3194 +#define PCIE_IOBLSECS_IO_BASE_ADDR_S 4
3195 +#define PCIE_IOBLSECS_32BIT_IOLIMT 0x00000100
3196 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR 0x0000F000
3197 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR_S 12
3199 +/* Non-prefetchable Memory Base/Limit Register bit */
3200 +#define PCIE_MBML(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x20) /* RC only */
3201 +#define PCIE_MBML_MEM_BASE_ADDR 0x0000FFF0
3202 +#define PCIE_MBML_MEM_BASE_ADDR_S 4
3203 +#define PCIE_MBML_MEM_LIMIT_ADDR 0xFFF00000
3204 +#define PCIE_MBML_MEM_LIMIT_ADDR_S 20
3206 +/* Prefetchable Memory Base/Limit Register bit */
3207 +#define PCIE_PMBL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x24) /* RC only */
3208 +#define PCIE_PMBL_64BIT_ADDR 0x00000001
3209 +#define PCIE_PMBL_UPPER_12BIT 0x0000FFF0
3210 +#define PCIE_PMBL_UPPER_12BIT_S 4
3211 +#define PCIE_PMBL_E64MA 0x00010000
3212 +#define PCIE_PMBL_END_ADDR 0xFFF00000
3213 +#define PCIE_PMBL_END_ADDR_S 20
3214 +#define PCIE_PMBU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x28) /* RC only */
3215 +#define PCIE_PMLU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x2C) /* RC only */
3217 +/* I/O Base/Limit Upper 16 bits register */
3218 +#define PCIE_IO_BANDL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x30) /* RC only */
3219 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE 0x0000FFFF
3220 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE_S 0
3221 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT 0xFFFF0000
3222 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT_S 16
3224 +#define PCIE_CPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x34)
3225 +#define PCIE_EBBAR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x38)
3227 +/* Interrupt and Secondary Bridge Control Register */
3228 +#define PCIE_INTRBCTRL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x3C)
3230 +#define PCIE_INTRBCTRL_INT_LINE 0x000000FF
3231 +#define PCIE_INTRBCTRL_INT_LINE_S 0
3232 +#define PCIE_INTRBCTRL_INT_PIN 0x0000FF00
3233 +#define PCIE_INTRBCTRL_INT_PIN_S 8
3234 +#define PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE 0x00010000 /* #PERR */
3235 +#define PCIE_INTRBCTRL_SERR_ENABLE 0x00020000 /* #SERR */
3236 +#define PCIE_INTRBCTRL_ISA_ENABLE 0x00040000 /* ISA enable, IO 64KB only */
3237 +#define PCIE_INTRBCTRL_VGA_ENABLE 0x00080000 /* VGA enable */
3238 +#define PCIE_INTRBCTRL_VGA_16BIT_DECODE 0x00100000 /* VGA 16bit decode */
3239 +#define PCIE_INTRBCTRL_RST_SECONDARY_BUS 0x00400000 /* Secondary bus rest, hot rest, 1ms */
3240 +/* Others are read only */
3242 + PCIE_INTRBCTRL_INT_NON = 0,
3243 + PCIE_INTRBCTRL_INTA,
3244 + PCIE_INTRBCTRL_INTB,
3245 + PCIE_INTRBCTRL_INTC,
3246 + PCIE_INTRBCTRL_INTD,
3249 +#define PCIE_PM_CAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x40)
3251 +/* Power Management Control and Status Register */
3252 +#define PCIE_PM_CSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x44)
3254 +#define PCIE_PM_CSR_POWER_STATE 0x00000003 /* Power State */
3255 +#define PCIE_PM_CSR_POWER_STATE_S 0
3256 +#define PCIE_PM_CSR_SW_RST 0x00000008 /* Soft Reset Enabled */
3257 +#define PCIE_PM_CSR_PME_ENABLE 0x00000100 /* PME Enable */
3258 +#define PCIE_PM_CSR_PME_STATUS 0x00008000 /* PME status */
3260 +/* MSI Capability Register for EP */
3261 +#define PCIE_MCAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x50)
3263 +#define PCIE_MCAPR_MSI_CAP_ID 0x000000FF /* MSI Capability ID */
3264 +#define PCIE_MCAPR_MSI_CAP_ID_S 0
3265 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR 0x0000FF00 /* Next Capability Pointer */
3266 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR_S 8
3267 +#define PCIE_MCAPR_MSI_ENABLE 0x00010000 /* MSI Enable */
3268 +#define PCIE_MCAPR_MULTI_MSG_CAP 0x000E0000 /* Multiple Message Capable */
3269 +#define PCIE_MCAPR_MULTI_MSG_CAP_S 17
3270 +#define PCIE_MCAPR_MULTI_MSG_ENABLE 0x00700000 /* Multiple Message Enable */
3271 +#define PCIE_MCAPR_MULTI_MSG_ENABLE_S 20
3272 +#define PCIE_MCAPR_ADDR64_CAP 0X00800000 /* 64-bit Address Capable */
3274 +/* MSI Message Address Register */
3275 +#define PCIE_MA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x54)
3277 +#define PCIE_MA_ADDR_MASK 0xFFFFFFFC /* Message Address */
3279 +/* MSI Message Upper Address Register */
3280 +#define PCIE_MUA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x58)
3282 +/* MSI Message Data Register */
3283 +#define PCIE_MD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x5C)
3285 +#define PCIE_MD_DATA 0x0000FFFF /* Message Data */
3286 +#define PCIE_MD_DATA_S 0
3288 +/* PCI Express Capability Register */
3289 +#define PCIE_XCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70)
3291 +#define PCIE_XCAP_ID 0x000000FF /* PCI Express Capability ID */
3292 +#define PCIE_XCAP_ID_S 0
3293 +#define PCIE_XCAP_NEXT_CAP 0x0000FF00 /* Next Capability Pointer */
3294 +#define PCIE_XCAP_NEXT_CAP_S 8
3295 +#define PCIE_XCAP_VER 0x000F0000 /* PCI Express Capability Version */
3296 +#define PCIE_XCAP_VER_S 16
3297 +#define PCIE_XCAP_DEV_PORT_TYPE 0x00F00000 /* Device Port Type */
3298 +#define PCIE_XCAP_DEV_PORT_TYPE_S 20
3299 +#define PCIE_XCAP_SLOT_IMPLEMENTED 0x01000000 /* Slot Implemented */
3300 +#define PCIE_XCAP_MSG_INT_NUM 0x3E000000 /* Interrupt Message Number */
3301 +#define PCIE_XCAP_MSG_INT_NUM_S 25
3303 +/* Device Capability Register */
3304 +#define PCIE_DCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74)
3306 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE 0x00000007 /* Max Payload size */
3307 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE_S 0
3308 +#define PCIE_DCAP_PHANTOM_FUNC 0x00000018 /* Phanton Function, not supported */
3309 +#define PCIE_DCAP_PHANTOM_FUNC_S 3
3310 +#define PCIE_DCAP_EXT_TAG 0x00000020 /* Extended Tag Field */
3311 +#define PCIE_DCAP_EP_L0S_LATENCY 0x000001C0 /* EP L0s latency only */
3312 +#define PCIE_DCAP_EP_L0S_LATENCY_S 6
3313 +#define PCIE_DCAP_EP_L1_LATENCY 0x00000E00 /* EP L1 latency only */
3314 +#define PCIE_DCAP_EP_L1_LATENCY_S 9
3315 +#define PCIE_DCAP_ROLE_BASE_ERR_REPORT 0x00008000 /* Role Based ERR */
3317 +/* Maximum payload size supported */
3319 + PCIE_MAX_PAYLOAD_128 = 0,
3320 + PCIE_MAX_PAYLOAD_256,
3321 + PCIE_MAX_PAYLOAD_512,
3322 + PCIE_MAX_PAYLOAD_1024,
3323 + PCIE_MAX_PAYLOAD_2048,
3324 + PCIE_MAX_PAYLOAD_4096,
3327 +/* Device Control and Status Register */
3328 +#define PCIE_DCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x78)
3330 +#define PCIE_DCTLSTS_CORRECTABLE_ERR_EN 0x00000001 /* COR-ERR */
3331 +#define PCIE_DCTLSTS_NONFATAL_ERR_EN 0x00000002 /* Non-fatal ERR */
3332 +#define PCIE_DCTLSTS_FATAL_ERR_EN 0x00000004 /* Fatal ERR */
3333 +#define PCIE_DCTLSYS_UR_REQ_EN 0x00000008 /* UR ERR */
3334 +#define PCIE_DCTLSTS_RELAXED_ORDERING_EN 0x00000010 /* Enable relaxing ordering */
3335 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE 0x000000E0 /* Max payload mask */
3336 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE_S 5
3337 +#define PCIE_DCTLSTS_EXT_TAG_EN 0x00000100 /* Extended tag field */
3338 +#define PCIE_DCTLSTS_PHANTOM_FUNC_EN 0x00000200 /* Phantom Function Enable */
3339 +#define PCIE_DCTLSTS_AUX_PM_EN 0x00000400 /* AUX Power PM Enable */
3340 +#define PCIE_DCTLSTS_NO_SNOOP_EN 0x00000800 /* Enable no snoop, except root port*/
3341 +#define PCIE_DCTLSTS_MAX_READ_SIZE 0x00007000 /* Max Read Request size*/
3342 +#define PCIE_DCTLSTS_MAX_READ_SIZE_S 12
3343 +#define PCIE_DCTLSTS_CORRECTABLE_ERR 0x00010000 /* COR-ERR Detected */
3344 +#define PCIE_DCTLSTS_NONFATAL_ERR 0x00020000 /* Non-Fatal ERR Detected */
3345 +#define PCIE_DCTLSTS_FATAL_ER 0x00040000 /* Fatal ERR Detected */
3346 +#define PCIE_DCTLSTS_UNSUPPORTED_REQ 0x00080000 /* UR Detected */
3347 +#define PCIE_DCTLSTS_AUX_POWER 0x00100000 /* Aux Power Detected */
3348 +#define PCIE_DCTLSTS_TRANSACT_PENDING 0x00200000 /* Transaction pending */
3350 +#define PCIE_DCTLSTS_ERR_EN (PCIE_DCTLSTS_CORRECTABLE_ERR_EN | \
3351 + PCIE_DCTLSTS_NONFATAL_ERR_EN | PCIE_DCTLSTS_FATAL_ERR_EN | \
3352 + PCIE_DCTLSYS_UR_REQ_EN)
3354 +/* Link Capability Register */
3355 +#define PCIE_LCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7C)
3356 +#define PCIE_LCAP_MAX_LINK_SPEED 0x0000000F /* Max link speed, 0x1 by default */
3357 +#define PCIE_LCAP_MAX_LINK_SPEED_S 0
3358 +#define PCIE_LCAP_MAX_LENGTH_WIDTH 0x000003F0 /* Maxium Length Width */
3359 +#define PCIE_LCAP_MAX_LENGTH_WIDTH_S 4
3360 +#define PCIE_LCAP_ASPM_LEVEL 0x00000C00 /* Active State Link PM Support */
3361 +#define PCIE_LCAP_ASPM_LEVEL_S 10
3362 +#define PCIE_LCAP_L0S_EIXT_LATENCY 0x00007000 /* L0s Exit Latency */
3363 +#define PCIE_LCAP_L0S_EIXT_LATENCY_S 12
3364 +#define PCIE_LCAP_L1_EXIT_LATENCY 0x00038000 /* L1 Exit Latency */
3365 +#define PCIE_LCAP_L1_EXIT_LATENCY_S 15
3366 +#define PCIE_LCAP_CLK_PM 0x00040000 /* Clock Power Management */
3367 +#define PCIE_LCAP_SDER 0x00080000 /* Surprise Down Error Reporting */
3368 +#define PCIE_LCAP_DLL_ACTIVE_REPROT 0x00100000 /* Data Link Layer Active Reporting Capable */
3369 +#define PCIE_LCAP_PORT_NUM 0xFF0000000 /* Port number */
3370 +#define PCIE_LCAP_PORT_NUM_S 24
3372 +/* Maximum Length width definition */
3373 +#define PCIE_MAX_LENGTH_WIDTH_RES 0x00
3374 +#define PCIE_MAX_LENGTH_WIDTH_X1 0x01 /* Default */
3375 +#define PCIE_MAX_LENGTH_WIDTH_X2 0x02
3376 +#define PCIE_MAX_LENGTH_WIDTH_X4 0x04
3377 +#define PCIE_MAX_LENGTH_WIDTH_X8 0x08
3378 +#define PCIE_MAX_LENGTH_WIDTH_X12 0x0C
3379 +#define PCIE_MAX_LENGTH_WIDTH_X16 0x10
3380 +#define PCIE_MAX_LENGTH_WIDTH_X32 0x20
3382 +/* Active State Link PM definition */
3384 + PCIE_ASPM_RES0 = 0,
3385 + PCIE_ASPM_L0S_ENTRY_SUPPORT, /* L0s */
3387 + PCIE_ASPM_L0S_L1_ENTRY_SUPPORT, /* L0s and L1, default */
3390 +/* L0s Exit Latency definition */
3392 + PCIE_L0S_EIXT_LATENCY_L64NS = 0, /* < 64 ns */
3393 + PCIE_L0S_EIXT_LATENCY_B64A128, /* > 64 ns < 128 ns */
3394 + PCIE_L0S_EIXT_LATENCY_B128A256, /* > 128 ns < 256 ns */
3395 + PCIE_L0S_EIXT_LATENCY_B256A512, /* > 256 ns < 512 ns */
3396 + PCIE_L0S_EIXT_LATENCY_B512TO1U, /* > 512 ns < 1 us */
3397 + PCIE_L0S_EIXT_LATENCY_B1A2U, /* > 1 us < 2 us */
3398 + PCIE_L0S_EIXT_LATENCY_B2A4U, /* > 2 us < 4 us */
3399 + PCIE_L0S_EIXT_LATENCY_M4US, /* > 4 us */
3402 +/* L1 Exit Latency definition */
3404 + PCIE_L1_EXIT_LATENCY_L1US = 0, /* < 1 us */
3405 + PCIE_L1_EXIT_LATENCY_B1A2, /* > 1 us < 2 us */
3406 + PCIE_L1_EXIT_LATENCY_B2A4, /* > 2 us < 4 us */
3407 + PCIE_L1_EXIT_LATENCY_B4A8, /* > 4 us < 8 us */
3408 + PCIE_L1_EXIT_LATENCY_B8A16, /* > 8 us < 16 us */
3409 + PCIE_L1_EXIT_LATENCY_B16A32, /* > 16 us < 32 us */
3410 + PCIE_L1_EXIT_LATENCY_B32A64, /* > 32 us < 64 us */
3411 + PCIE_L1_EXIT_LATENCY_M64US, /* > 64 us */
3414 +/* Link Control and Status Register */
3415 +#define PCIE_LCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x80)
3416 +#define PCIE_LCTLSTS_ASPM_ENABLE 0x00000003 /* Active State Link PM Control */
3417 +#define PCIE_LCTLSTS_ASPM_ENABLE_S 0
3418 +#define PCIE_LCTLSTS_RCB128 0x00000008 /* Read Completion Boundary 128*/
3419 +#define PCIE_LCTLSTS_LINK_DISABLE 0x00000010 /* Link Disable */
3420 +#define PCIE_LCTLSTS_RETRIAN_LINK 0x00000020 /* Retrain Link */
3421 +#define PCIE_LCTLSTS_COM_CLK_CFG 0x00000040 /* Common Clock Configuration */
3422 +#define PCIE_LCTLSTS_EXT_SYNC 0x00000080 /* Extended Synch */
3423 +#define PCIE_LCTLSTS_CLK_PM_EN 0x00000100 /* Enable Clock Powerm Management */
3424 +#define PCIE_LCTLSTS_LINK_SPEED 0x000F0000 /* Link Speed */
3425 +#define PCIE_LCTLSTS_LINK_SPEED_S 16
3426 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH 0x03F00000 /* Negotiated Link Width */
3427 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH_S 20
3428 +#define PCIE_LCTLSTS_RETRAIN_PENDING 0x08000000 /* Link training is ongoing */
3429 +#define PCIE_LCTLSTS_SLOT_CLK_CFG 0x10000000 /* Slot Clock Configuration */
3430 +#define PCIE_LCTLSTS_DLL_ACTIVE 0x20000000 /* Data Link Layer Active */
3432 +/* Slot Capabilities Register */
3433 +#define PCIE_SLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x84)
3435 +/* Slot Capabilities */
3436 +#define PCIE_SLCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x88)
3438 +/* Root Control and Capability Register */
3439 +#define PCIE_RCTLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x8C)
3440 +#define PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR 0x00000001 /* #SERR on COR-ERR */
3441 +#define PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR 0x00000002 /* #SERR on Non-Fatal ERR */
3442 +#define PCIE_RCTLCAP_SERR_ON_FATAL_ERR 0x00000004 /* #SERR on Fatal ERR */
3443 +#define PCIE_RCTLCAP_PME_INT_EN 0x00000008 /* PME Interrupt Enable */
3444 +#define PCIE_RCTLCAP_SERR_ENABLE (PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR | \
3445 + PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR | PCIE_RCTLCAP_SERR_ON_FATAL_ERR)
3446 +/* Root Status Register */
3447 +#define PCIE_RSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x90)
3448 +#define PCIE_RSTS_PME_REQ_ID 0x0000FFFF /* PME Request ID */
3449 +#define PCIE_RSTS_PME_REQ_ID_S 0
3450 +#define PCIE_RSTS_PME_STATUS 0x00010000 /* PME Status */
3451 +#define PCIE_RSTS_PME_PENDING 0x00020000 /* PME Pending */
3453 +/* PCI Express Enhanced Capability Header */
3454 +#define PCIE_ENHANCED_CAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x100)
3455 +#define PCIE_ENHANCED_CAP_ID 0x0000FFFF /* PCI Express Extended Capability ID */
3456 +#define PCIE_ENHANCED_CAP_ID_S 0
3457 +#define PCIE_ENHANCED_CAP_VER 0x000F0000 /* Capability Version */
3458 +#define PCIE_ENHANCED_CAP_VER_S 16
3459 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET 0xFFF00000 /* Next Capability Offset */
3460 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET_S 20
3462 +/* Uncorrectable Error Status Register */
3463 +#define PCIE_UES_R(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x104)
3464 +#define PCIE_DATA_LINK_PROTOCOL_ERR 0x00000010 /* Data Link Protocol Error Status */
3465 +#define PCIE_SURPRISE_DOWN_ERROR 0x00000020 /* Surprise Down Error Status */
3466 +#define PCIE_POISONED_TLP 0x00001000 /* Poisoned TLP Status */
3467 +#define PCIE_FC_PROTOCOL_ERR 0x00002000 /* Flow Control Protocol Error Status */
3468 +#define PCIE_COMPLETION_TIMEOUT 0x00004000 /* Completion Timeout Status */
3469 +#define PCIE_COMPLETOR_ABORT 0x00008000 /* Completer Abort Error */
3470 +#define PCIE_UNEXPECTED_COMPLETION 0x00010000 /* Unexpected Completion Status */
3471 +#define PCIE_RECEIVER_OVERFLOW 0x00020000 /* Receive Overflow Status */
3472 +#define PCIE_MALFORNED_TLP 0x00040000 /* Malformed TLP Stauts */
3473 +#define PCIE_ECRC_ERR 0x00080000 /* ECRC Error Stauts */
3474 +#define PCIE_UR_REQ 0x00100000 /* Unsupported Request Error Status */
3475 +#define PCIE_ALL_UNCORRECTABLE_ERR (PCIE_DATA_LINK_PROTOCOL_ERR | PCIE_SURPRISE_DOWN_ERROR | \
3476 + PCIE_POISONED_TLP | PCIE_FC_PROTOCOL_ERR | PCIE_COMPLETION_TIMEOUT | \
3477 + PCIE_COMPLETOR_ABORT | PCIE_UNEXPECTED_COMPLETION | PCIE_RECEIVER_OVERFLOW |\
3478 + PCIE_MALFORNED_TLP | PCIE_ECRC_ERR | PCIE_UR_REQ)
3480 +/* Uncorrectable Error Mask Register, Mask means no report */
3481 +#define PCIE_UEMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x108)
3483 +/* Uncorrectable Error Severity Register */
3484 +#define PCIE_UESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10C)
3486 +/* Correctable Error Status Register */
3487 +#define PCIE_CESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x110)
3488 +#define PCIE_RX_ERR 0x00000001 /* Receive Error Status */
3489 +#define PCIE_BAD_TLP 0x00000040 /* Bad TLP Status */
3490 +#define PCIE_BAD_DLLP 0x00000080 /* Bad DLLP Status */
3491 +#define PCIE_REPLAY_NUM_ROLLOVER 0x00000100 /* Replay Number Rollover Status */
3492 +#define PCIE_REPLAY_TIMER_TIMEOUT_ERR 0x00001000 /* Reply Timer Timeout Status */
3493 +#define PCIE_ADVISORY_NONFTAL_ERR 0x00002000 /* Advisory Non-Fatal Error Status */
3494 +#define PCIE_CORRECTABLE_ERR (PCIE_RX_ERR | PCIE_BAD_TLP | PCIE_BAD_DLLP | PCIE_REPLAY_NUM_ROLLOVER |\
3495 + PCIE_REPLAY_TIMER_TIMEOUT_ERR | PCIE_ADVISORY_NONFTAL_ERR)
3497 +/* Correctable Error Mask Register */
3498 +#define PCIE_CEMR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x114)
3500 +/* Advanced Error Capabilities and Control Register */
3501 +#define PCIE_AECCR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x118)
3502 +#define PCIE_AECCR_FIRST_ERR_PTR 0x0000001F /* First Error Pointer */
3503 +#define PCIE_AECCR_FIRST_ERR_PTR_S 0
3504 +#define PCIE_AECCR_ECRC_GEN_CAP 0x00000020 /* ECRC Generation Capable */
3505 +#define PCIE_AECCR_ECRC_GEN_EN 0x00000040 /* ECRC Generation Enable */
3506 +#define PCIE_AECCR_ECRC_CHECK_CAP 0x00000080 /* ECRC Check Capable */
3507 +#define PCIE_AECCR_ECRC_CHECK_EN 0x00000100 /* ECRC Check Enable */
3509 +/* Header Log Register 1 */
3510 +#define PCIE_HLR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x11C)
3512 +/* Header Log Register 2 */
3513 +#define PCIE_HLR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x120)
3515 +/* Header Log Register 3 */
3516 +#define PCIE_HLR3(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x124)
3518 +/* Header Log Register 4 */
3519 +#define PCIE_HLR4(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x128)
3521 +/* Root Error Command Register */
3522 +#define PCIE_RECR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x12C)
3523 +#define PCIE_RECR_CORRECTABLE_ERR_REPORT_EN 0x00000001 /* COR-ERR */
3524 +#define PCIE_RECR_NONFATAL_ERR_REPORT_EN 0x00000002 /* Non-Fatal ERR */
3525 +#define PCIE_RECR_FATAL_ERR_REPORT_EN 0x00000004 /* Fatal ERR */
3526 +#define PCIE_RECR_ERR_REPORT_EN (PCIE_RECR_CORRECTABLE_ERR_REPORT_EN | \
3527 + PCIE_RECR_NONFATAL_ERR_REPORT_EN | PCIE_RECR_FATAL_ERR_REPORT_EN)
3529 +/* Root Error Status Register */
3530 +#define PCIE_RESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x130)
3531 +#define PCIE_RESR_CORRECTABLE_ERR 0x00000001 /* COR-ERR Receveid */
3532 +#define PCIE_RESR_MULTI_CORRECTABLE_ERR 0x00000002 /* Multiple COR-ERR Received */
3533 +#define PCIE_RESR_FATAL_NOFATAL_ERR 0x00000004 /* ERR Fatal/Non-Fatal Received */
3534 +#define PCIE_RESR_MULTI_FATAL_NOFATAL_ERR 0x00000008 /* Multiple ERR Fatal/Non-Fatal Received */
3535 +#define PCIE_RESR_FIRST_UNCORRECTABLE_FATAL_ERR 0x00000010 /* First UN-COR Fatal */
3536 +#define PCIR_RESR_NON_FATAL_ERR 0x00000020 /* Non-Fatal Error Message Received */
3537 +#define PCIE_RESR_FATAL_ERR 0x00000040 /* Fatal Message Received */
3538 +#define PCIE_RESR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
3539 +#define PCIE_RESR_AER_INT_MSG_NUM_S 27
3541 +/* Error Source Indentification Register */
3542 +#define PCIE_ESIR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x134)
3543 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID 0x0000FFFF
3544 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID_S 0
3545 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID 0xFFFF0000
3546 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID_S 16
3548 +/* VC Enhanced Capability Header */
3549 +#define PCIE_VC_ECH(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x140)
3551 +/* Port VC Capability Register */
3552 +#define PCIE_PVC1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x144)
3553 +#define PCIE_PVC1_EXT_VC_CNT 0x00000007 /* Extended VC Count */
3554 +#define PCIE_PVC1_EXT_VC_CNT_S 0
3555 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT 0x00000070 /* Low Priority Extended VC Count */
3556 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT_S 4
3557 +#define PCIE_PVC1_REF_CLK 0x00000300 /* Reference Clock */
3558 +#define PCIE_PVC1_REF_CLK_S 8
3559 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE 0x00000C00 /* Port Arbitration Table Entry Size */
3560 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE_S 10
3562 +/* Extended Virtual Channel Count Defintion */
3563 +#define PCIE_EXT_VC_CNT_MIN 0
3564 +#define PCIE_EXT_VC_CNT_MAX 7
3566 +/* Port Arbitration Table Entry Size Definition */
3568 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S1BIT = 0,
3569 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S2BIT,
3570 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S4BIT,
3571 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S8BIT,
3574 +/* Port VC Capability Register 2 */
3575 +#define PCIE_PVC2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x148)
3576 +#define PCIE_PVC2_VC_ARB_16P_FIXED_WRR 0x00000001 /* HW Fixed arbitration, 16 phase WRR */
3577 +#define PCIE_PVC2_VC_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
3578 +#define PCIE_PVC2_VC_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
3579 +#define PCIE_PVC2_VC_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
3580 +#define PCIE_PVC2_VC_ARB_WRR 0x0000000F
3581 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET 0xFF000000 /* VC arbitration table offset, not support */
3582 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET_S 24
3584 +/* Port VC Control and Status Register */
3585 +#define PCIE_PVCCRSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14C)
3586 +#define PCIE_PVCCRSR_LOAD_VC_ARB_TAB 0x00000001 /* Load VC Arbitration Table */
3587 +#define PCIE_PVCCRSR_VC_ARB_SEL 0x0000000E /* VC Arbitration Select */
3588 +#define PCIE_PVCCRSR_VC_ARB_SEL_S 1
3589 +#define PCIE_PVCCRSR_VC_ARB_TAB_STATUS 0x00010000 /* Arbitration Status */
3591 +/* VC0 Resource Capability Register */
3592 +#define PCIE_VC0_RC(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x150)
3593 +#define PCIE_VC0_RC_PORT_ARB_HW_FIXED 0x00000001 /* HW Fixed arbitration */
3594 +#define PCIE_VC0_RC_PORT_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
3595 +#define PCIE_VC0_RC_PORT_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
3596 +#define PCIE_VC0_RC_PORT_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
3597 +#define PCIE_VC0_RC_PORT_ARB_TM_128P_WRR 0x00000010 /* Time-based 128 phase WRR */
3598 +#define PCIE_VC0_RC_PORT_ARB_TM_256P_WRR 0x00000020 /* Time-based 256 phase WRR */
3599 +#define PCIE_VC0_RC_PORT_ARB (PCIE_VC0_RC_PORT_ARB_HW_FIXED | PCIE_VC0_RC_PORT_ARB_32P_WRR |\
3600 + PCIE_VC0_RC_PORT_ARB_64P_WRR | PCIE_VC0_RC_PORT_ARB_128P_WRR | \
3601 + PCIE_VC0_RC_PORT_ARB_TM_128P_WRR | PCIE_VC0_RC_PORT_ARB_TM_256P_WRR)
3603 +#define PCIE_VC0_RC_REJECT_SNOOP 0x00008000 /* Reject Snoop Transactioin */
3604 +#define PCIE_VC0_RC_MAX_TIMESLOTS 0x007F0000 /* Maximum time Slots */
3605 +#define PCIE_VC0_RC_MAX_TIMESLOTS_S 16
3606 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET 0xFF000000 /* Port Arbitration Table Offset */
3607 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET_S 24
3609 +/* VC0 Resource Control Register */
3610 +#define PCIE_VC0_RC0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x154)
3611 +#define PCIE_VC0_RC0_TVM0 0x00000001 /* TC0 and VC0 */
3612 +#define PCIE_VC0_RC0_TVM1 0x00000002 /* TC1 and VC1 */
3613 +#define PCIE_VC0_RC0_TVM2 0x00000004 /* TC2 and VC2 */
3614 +#define PCIE_VC0_RC0_TVM3 0x00000008 /* TC3 and VC3 */
3615 +#define PCIE_VC0_RC0_TVM4 0x00000010 /* TC4 and VC4 */
3616 +#define PCIE_VC0_RC0_TVM5 0x00000020 /* TC5 and VC5 */
3617 +#define PCIE_VC0_RC0_TVM6 0x00000040 /* TC6 and VC6 */
3618 +#define PCIE_VC0_RC0_TVM7 0x00000080 /* TC7 and VC7 */
3619 +#define PCIE_VC0_RC0_TC_VC 0x000000FF /* TC/VC mask */
3621 +#define PCIE_VC0_RC0_LOAD_PORT_ARB_TAB 0x00010000 /* Load Port Arbitration Table */
3622 +#define PCIE_VC0_RC0_PORT_ARB_SEL 0x000E0000 /* Port Arbitration Select */
3623 +#define PCIE_VC0_RC0_PORT_ARB_SEL_S 17
3624 +#define PCIE_VC0_RC0_VC_ID 0x07000000 /* VC ID */
3625 +#define PCIE_VC0_RC0_VC_ID_S 24
3626 +#define PCIE_VC0_RC0_VC_EN 0x80000000 /* VC Enable */
3628 +/* VC0 Resource Status Register */
3629 +#define PCIE_VC0_RSR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x158)
3630 +#define PCIE_VC0_RSR0_PORT_ARB_TAB_STATUS 0x00010000 /* Port Arbitration Table Status,not used */
3631 +#define PCIE_VC0_RSR0_VC_NEG_PENDING 0x00020000 /* VC Negotiation Pending */
3633 +/* Ack Latency Timer and Replay Timer Register */
3634 +#define PCIE_ALTRT(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x700)
3635 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT 0x0000FFFF /* Round Trip Latency Time Limit */
3636 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT_S 0
3637 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT 0xFFFF0000 /* Replay Time Limit */
3638 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT_S 16
3640 +/* Other Message Register */
3641 +#define PCIE_OMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x704)
3643 +/* Port Force Link Register */
3644 +#define PCIE_PFLR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x708)
3645 +#define PCIE_PFLR_LINK_NUM 0x000000FF /* Link Number */
3646 +#define PCIE_PFLR_LINK_NUM_S 0
3647 +#define PCIE_PFLR_FORCE_LINK 0x00008000 /* Force link */
3648 +#define PCIE_PFLR_LINK_STATE 0x003F0000 /* Link State */
3649 +#define PCIE_PFLR_LINK_STATE_S 16
3650 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT 0xFF000000 /* Low Power Entrance Count, only for EP */
3651 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT_S 24
3653 +/* Ack Frequency Register */
3654 +#define PCIE_AFR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70C)
3655 +#define PCIE_AFR_AF 0x000000FF /* Ack Frequency */
3656 +#define PCIE_AFR_AF_S 0
3657 +#define PCIE_AFR_FTS_NUM 0x0000FF00 /* The number of Fast Training Sequence from L0S to L0 */
3658 +#define PCIE_AFR_FTS_NUM_S 8
3659 +#define PCIE_AFR_COM_FTS_NUM 0x00FF0000 /* N_FTS; when common clock is used*/
3660 +#define PCIE_AFR_COM_FTS_NUM_S 16
3661 +#define PCIE_AFR_L0S_ENTRY_LATENCY 0x07000000 /* L0s Entrance Latency */
3662 +#define PCIE_AFR_L0S_ENTRY_LATENCY_S 24
3663 +#define PCIE_AFR_L1_ENTRY_LATENCY 0x38000000 /* L1 Entrance Latency */
3664 +#define PCIE_AFR_L1_ENTRY_LATENCY_S 27
3665 +#define PCIE_AFR_FTS_NUM_DEFAULT 32
3666 +#define PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT 7
3667 +#define PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT 5
3669 +/* Port Link Control Register */
3670 +#define PCIE_PLCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x710)
3671 +#define PCIE_PLCR_OTHER_MSG_REQ 0x00000001 /* Other Message Request */
3672 +#define PCIE_PLCR_SCRAMBLE_DISABLE 0x00000002 /* Scramble Disable */
3673 +#define PCIE_PLCR_LOOPBACK_EN 0x00000004 /* Loopback Enable */
3674 +#define PCIE_PLCR_LTSSM_HOT_RST 0x00000008 /* Force LTSSM to the hot reset */
3675 +#define PCIE_PLCR_DLL_LINK_EN 0x00000020 /* Enable Link initialization */
3676 +#define PCIE_PLCR_FAST_LINK_SIM_EN 0x00000080 /* Sets all internal timers to fast mode for simulation purposes */
3677 +#define PCIE_PLCR_LINK_MODE 0x003F0000 /* Link Mode Enable Mask */
3678 +#define PCIE_PLCR_LINK_MODE_S 16
3679 +#define PCIE_PLCR_CORRUPTED_CRC_EN 0x02000000 /* Enabled Corrupt CRC */
3681 +/* Lane Skew Register */
3682 +#define PCIE_LSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x714)
3683 +#define PCIE_LSR_LANE_SKEW_NUM 0x00FFFFFF /* Insert Lane Skew for Transmit, not applicable */
3684 +#define PCIE_LSR_LANE_SKEW_NUM_S 0
3685 +#define PCIE_LSR_FC_DISABLE 0x01000000 /* Disable of Flow Control */
3686 +#define PCIE_LSR_ACKNAK_DISABLE 0x02000000 /* Disable of Ack/Nak */
3687 +#define PCIE_LSR_LANE_DESKEW_DISABLE 0x80000000 /* Disable of Lane-to-Lane Skew */
3689 +/* Symbol Number Register */
3690 +#define PCIE_SNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x718)
3691 +#define PCIE_SNR_TS 0x0000000F /* Number of TS Symbol */
3692 +#define PCIE_SNR_TS_S 0
3693 +#define PCIE_SNR_SKP 0x00000700 /* Number of SKP Symbol */
3694 +#define PCIE_SNR_SKP_S 8
3695 +#define PCIE_SNR_REPLAY_TIMER 0x0007C000 /* Timer Modifier for Replay Timer */
3696 +#define PCIE_SNR_REPLAY_TIMER_S 14
3697 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER 0x00F80000 /* Timer Modifier for Ack/Nak Latency Timer */
3698 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER_S 19
3699 +#define PCIE_SNR_FC_TIMER 0x1F000000 /* Timer Modifier for Flow Control Watchdog Timer */
3700 +#define PCIE_SNR_FC_TIMER_S 28
3702 +/* Symbol Timer Register and Filter Mask Register 1 */
3703 +#define PCIE_STRFMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x71C)
3704 +#define PCIE_STRFMR_SKP_INTERVAL 0x000007FF /* SKP lnterval Value */
3705 +#define PCIE_STRFMR_SKP_INTERVAL_S 0
3706 +#define PCIE_STRFMR_FC_WDT_DISABLE 0x00008000 /* Disable of FC Watchdog Timer */
3707 +#define PCIE_STRFMR_TLP_FUNC_MISMATCH_OK 0x00010000 /* Mask Function Mismatch Filtering for Incoming Requests */
3708 +#define PCIE_STRFMR_POISONED_TLP_OK 0x00020000 /* Mask Poisoned TLP Filtering */
3709 +#define PCIE_STRFMR_BAR_MATCH_OK 0x00040000 /* Mask BAR Match Filtering */
3710 +#define PCIE_STRFMR_TYPE1_CFG_REQ_OK 0x00080000 /* Mask Type 1 Configuration Request Filtering */
3711 +#define PCIE_STRFMR_LOCKED_REQ_OK 0x00100000 /* Mask Locked Request Filtering */
3712 +#define PCIE_STRFMR_CPL_TAG_ERR_RULES_OK 0x00200000 /* Mask Tag Error Rules for Received Completions */
3713 +#define PCIE_STRFMR_CPL_REQUESTOR_ID_MISMATCH_OK 0x00400000 /* Mask Requester ID Mismatch Error for Received Completions */
3714 +#define PCIE_STRFMR_CPL_FUNC_MISMATCH_OK 0x00800000 /* Mask Function Mismatch Error for Received Completions */
3715 +#define PCIE_STRFMR_CPL_TC_MISMATCH_OK 0x01000000 /* Mask Traffic Class Mismatch Error for Received Completions */
3716 +#define PCIE_STRFMR_CPL_ATTR_MISMATCH_OK 0x02000000 /* Mask Attribute Mismatch Error for Received Completions */
3717 +#define PCIE_STRFMR_CPL_LENGTH_MISMATCH_OK 0x04000000 /* Mask Length Mismatch Error for Received Completions */
3718 +#define PCIE_STRFMR_TLP_ECRC_ERR_OK 0x08000000 /* Mask ECRC Error Filtering */
3719 +#define PCIE_STRFMR_CPL_TLP_ECRC_OK 0x10000000 /* Mask ECRC Error Filtering for Completions */
3720 +#define PCIE_STRFMR_RX_TLP_MSG_NO_DROP 0x20000000 /* Send Message TLPs */
3721 +#define PCIE_STRFMR_RX_IO_TRANS_ENABLE 0x40000000 /* Mask Filtering of received I/O Requests */
3722 +#define PCIE_STRFMR_RX_CFG_TRANS_ENABLE 0x80000000 /* Mask Filtering of Received Configuration Requests */
3724 +#define PCIE_DEF_SKP_INTERVAL 700 /* 1180 ~1538 , 125MHz * 2, 250MHz * 1 */
3726 +/* Filter Masker Register 2 */
3727 +#define PCIE_FMR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x720)
3728 +#define PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1 0x00000001 /* Mask RADM Filtering and Error Handling Rules */
3729 +#define PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 0x00000002 /* Mask RADM Filtering and Error Handling Rules */
3731 +/* Debug Register 0 */
3732 +#define PCIE_DBR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x728)
3734 +/* Debug Register 1 */
3735 +#define PCIE_DBR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x72C)
3737 +/* Transmit Posted FC Credit Status Register */
3738 +#define PCIE_TPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x730)
3739 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS 0x00000FFF /* Transmit Posted Data FC Credits */
3740 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS_S 0
3741 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS 0x000FF000 /* Transmit Posted Header FC Credits */
3742 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS_S 12
3744 +/* Transmit Non-Posted FC Credit Status */
3745 +#define PCIE_TNPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x734)
3746 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS 0x00000FFF /* Transmit Non-Posted Data FC Credits */
3747 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS_S 0
3748 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS 0x000FF000 /* Transmit Non-Posted Header FC Credits */
3749 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS_S 12
3751 +/* Transmit Complete FC Credit Status Register */
3752 +#define PCIE_TCFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x738)
3753 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS 0x00000FFF /* Transmit Completion Data FC Credits */
3754 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS_S 0
3755 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS 0x000FF000 /* Transmit Completion Header FC Credits */
3756 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS_S 12
3758 +/* Queue Status Register */
3759 +#define PCIE_QSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x73C)
3760 +#define PCIE_QSR_WAIT_UPDATE_FC_DLL 0x00000001 /* Received TLP FC Credits Not Returned */
3761 +#define PCIE_QSR_TX_RETRY_BUF_NOT_EMPTY 0x00000002 /* Transmit Retry Buffer Not Empty */
3762 +#define PCIE_QSR_RX_QUEUE_NOT_EMPTY 0x00000004 /* Received Queue Not Empty */
3764 +/* VC Transmit Arbitration Register 1 */
3765 +#define PCIE_VCTAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x740)
3766 +#define PCIE_VCTAR1_WRR_WEIGHT_VC0 0x000000FF /* WRR Weight for VC0 */
3767 +#define PCIE_VCTAR1_WRR_WEIGHT_VC1 0x0000FF00 /* WRR Weight for VC1 */
3768 +#define PCIE_VCTAR1_WRR_WEIGHT_VC2 0x00FF0000 /* WRR Weight for VC2 */
3769 +#define PCIE_VCTAR1_WRR_WEIGHT_VC3 0xFF000000 /* WRR Weight for VC3 */
3771 +/* VC Transmit Arbitration Register 2 */
3772 +#define PCIE_VCTAR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x744)
3773 +#define PCIE_VCTAR2_WRR_WEIGHT_VC4 0x000000FF /* WRR Weight for VC4 */
3774 +#define PCIE_VCTAR2_WRR_WEIGHT_VC5 0x0000FF00 /* WRR Weight for VC5 */
3775 +#define PCIE_VCTAR2_WRR_WEIGHT_VC6 0x00FF0000 /* WRR Weight for VC6 */
3776 +#define PCIE_VCTAR2_WRR_WEIGHT_VC7 0xFF000000 /* WRR Weight for VC7 */
3778 +/* VC0 Posted Receive Queue Control Register */
3779 +#define PCIE_VC0_PRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x748)
3780 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS 0x00000FFF /* VC0 Posted Data Credits */
3781 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS_S 0
3782 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS 0x000FF000 /* VC0 Posted Header Credits */
3783 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS_S 12
3784 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE 0x00E00000 /* VC0 Posted TLP Queue Mode */
3785 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE_S 20
3786 +#define PCIE_VC0_PRQCR_TLP_RELAX_ORDER 0x40000000 /* TLP Type Ordering for VC0 */
3787 +#define PCIE_VC0_PRQCR_VC_STRICT_ORDER 0x80000000 /* VC0 Ordering for Receive Queues */
3789 +/* VC0 Non-Posted Receive Queue Control */
3790 +#define PCIE_VC0_NPRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74C)
3791 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS 0x00000FFF /* VC0 Non-Posted Data Credits */
3792 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS_S 0
3793 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS 0x000FF000 /* VC0 Non-Posted Header Credits */
3794 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS_S 12
3795 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE 0x00E00000 /* VC0 Non-Posted TLP Queue Mode */
3796 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE_S 20
3798 +/* VC0 Completion Receive Queue Control */
3799 +#define PCIE_VC0_CRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x750)
3800 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS 0x00000FFF /* VC0 Completion TLP Queue Mode */
3801 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS_S 0
3802 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS 0x000FF000 /* VC0 Completion Header Credits */
3803 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS_S 12
3804 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE 0x00E00000 /* VC0 Completion Data Credits */
3805 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE_S 21
3807 +/* Applicable to the above three registers */
3809 + PCIE_VC0_TLP_QUEUE_MODE_STORE_FORWARD = 1,
3810 + PCIE_VC0_TLP_QUEUE_MODE_CUT_THROUGH = 2,
3811 + PCIE_VC0_TLP_QUEUE_MODE_BYPASS = 4,
3814 +/* VC0 Posted Buffer Depth Register */
3815 +#define PCIE_VC0_PBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7A8)
3816 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Posted Data Queue Depth */
3817 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES_S 0
3818 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Posted Header Queue Depth */
3819 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES_S 16
3821 +/* VC0 Non-Posted Buffer Depth Register */
3822 +#define PCIE_VC0_NPBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7AC)
3823 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Non-Posted Data Queue Depth */
3824 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES_S 0
3825 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Non-Posted Header Queue Depth */
3826 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES_S 16
3828 +/* VC0 Completion Buffer Depth Register */
3829 +#define PCIE_VC0_CBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7B0)
3830 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES 0x00003FFF /* C0 Completion Data Queue Depth */
3831 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES_S 0
3832 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Completion Header Queue Depth */
3833 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES_S 16
3835 +/* PHY Status Register, all zeros in VR9 */
3836 +#define PCIE_PHYSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x810)
3838 +/* PHY Control Register, all zeros in VR9 */
3839 +#define PCIE_PHYCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x814)
3842 + * PCIe PDI PHY register definition, suppose all the following
3843 + * stuff is confidential.
3844 + * XXX, detailed bit definition
3846 +#define PCIE_PHY_PLL_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x22 << 1))
3847 +#define PCIE_PHY_PLL_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x23 << 1))
3848 +#define PCIE_PHY_PLL_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x24 << 1))
3849 +#define PCIE_PHY_PLL_CTRL4(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x25 << 1))
3850 +#define PCIE_PHY_PLL_CTRL5(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x26 << 1))
3851 +#define PCIE_PHY_PLL_CTRL6(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x27 << 1))
3852 +#define PCIE_PHY_PLL_CTRL7(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x28 << 1))
3853 +#define PCIE_PHY_PLL_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x29 << 1))
3854 +#define PCIE_PHY_PLL_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2A << 1))
3855 +#define PCIE_PHY_PLL_A_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2B << 1))
3856 +#define PCIE_PHY_PLL_STATUS(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2C << 1))
3858 +#define PCIE_PHY_TX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x30 << 1))
3859 +#define PCIE_PHY_TX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x31 << 1))
3860 +#define PCIE_PHY_TX1_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x32 << 1))
3861 +#define PCIE_PHY_TX1_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x33 << 1))
3862 +#define PCIE_PHY_TX1_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x34 << 1))
3863 +#define PCIE_PHY_TX1_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x35 << 1))
3864 +#define PCIE_PHY_TX1_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x36 << 1))
3865 +#define PCIE_PHY_TX1_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x37 << 1))
3867 +#define PCIE_PHY_TX2_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x38 << 1))
3868 +#define PCIE_PHY_TX2_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x39 << 1))
3869 +#define PCIE_PHY_TX2_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3B << 1))
3870 +#define PCIE_PHY_TX2_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3C << 1))
3871 +#define PCIE_PHY_TX2_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3D << 1))
3872 +#define PCIE_PHY_TX2_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3E << 1))
3873 +#define PCIE_PHY_TX2_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3F << 1))
3875 +#define PCIE_PHY_RX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x50 << 1))
3876 +#define PCIE_PHY_RX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x51 << 1))
3877 +#define PCIE_PHY_RX1_CDR(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x52 << 1))
3878 +#define PCIE_PHY_RX1_EI(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x53 << 1))
3879 +#define PCIE_PHY_RX1_A_CTRL(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x55 << 1))
3881 +/* Interrupt related stuff */
3882 +#define PCIE_LEGACY_DISABLE 0
3883 +#define PCIE_LEGACY_INTA 1
3884 +#define PCIE_LEGACY_INTB 2
3885 +#define PCIE_LEGACY_INTC 3
3886 +#define PCIE_LEGACY_INTD 4
3887 +#define PCIE_LEGACY_INT_MAX PCIE_LEGACY_INTD
3889 +#endif /* IFXMIPS_PCIE_REG_H */
3892 +++ b/arch/mips/pci/ifxmips_pcie_vr9.h
3894 +/****************************************************************************
3895 + Copyright (c) 2010
3896 + Lantiq Deutschland GmbH
3897 + Am Campeon 3; 85579 Neubiberg, Germany
3899 + For licensing information, see the file 'LICENSE' in the root folder of
3900 + this software module.
3902 + *****************************************************************************/
3904 + \file ifxmips_pcie_vr9.h
3906 + \brief PCIe RC driver vr9 specific file
3909 +#ifndef IFXMIPS_PCIE_VR9_H
3910 +#define IFXMIPS_PCIE_VR9_H
3912 +#include <linux/types.h>
3913 +#include <linux/delay.h>
3915 +#include <linux/gpio.h>
3916 +#include <lantiq_soc.h>
3918 +#define IFX_PCIE_GPIO_RESET 494
3920 +#define IFX_REG_R32 ltq_r32
3921 +#define IFX_REG_W32 ltq_w32
3922 +#define CONFIG_IFX_PCIE_HW_SWAP
3923 +#define IFX_RCU_AHB_ENDIAN ((volatile u32*)(IFX_RCU + 0x004C))
3924 +#define IFX_RCU_RST_REQ ((volatile u32*)(IFX_RCU + 0x0010))
3925 +#define IFX_RCU_AHB_BE_PCIE_PDI 0x00000080 /* Configure PCIE PDI module in big endian*/
3927 +#define IFX_RCU (KSEG1 | 0x1F203000)
3928 +#define IFX_RCU_AHB_BE_PCIE_M 0x00000001 /* Configure AHB master port that connects to PCIe RC in big endian */
3929 +#define IFX_RCU_AHB_BE_PCIE_S 0x00000010 /* Configure AHB slave port that connects to PCIe RC in little endian */
3930 +#define IFX_RCU_AHB_BE_XBAR_M 0x00000002 /* Configure AHB master port that connects to XBAR in big endian */
3931 +#define CONFIG_IFX_PCIE_PHY_36MHZ_MODE
3933 +#define IFX_PMU1_MODULE_PCIE_PHY (0)
3934 +#define IFX_PMU1_MODULE_PCIE_CTRL (1)
3935 +#define IFX_PMU1_MODULE_PDI (4)
3936 +#define IFX_PMU1_MODULE_MSI (5)
3938 +#define IFX_PMU_MODULE_PCIE_L0_CLK (31)
3941 +#define IFX_GPIO (KSEG1 | 0x1E100B00)
3942 +#define ALT0 ((volatile u32*)(IFX_GPIO + 0x007c))
3943 +#define ALT1 ((volatile u32*)(IFX_GPIO + 0x0080))
3944 +#define OD ((volatile u32*)(IFX_GPIO + 0x0084))
3945 +#define DIR ((volatile u32*)(IFX_GPIO + 0x0078))
3946 +#define OUT ((volatile u32*)(IFX_GPIO + 0x0070))
3949 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
3952 + gpio_request(IFX_PCIE_GPIO_RESET, "pcie-reset");
3953 + gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
3954 + gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
3956 +/* ifx_gpio_pin_reserve(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3957 + ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3958 + ifx_gpio_dir_out_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3959 + ifx_gpio_altsel0_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3960 + ifx_gpio_altsel1_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3961 + ifx_gpio_open_drain_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);*/
3964 +static inline void pcie_ahb_pmu_setup(void)
3966 + /* Enable AHB bus master/slave */
3968 + clk = clk_get_sys("1d900000.pcie", "ahb");
3971 + //AHBM_PMU_SETUP(IFX_PMU_ENABLE);
3972 + //AHBS_PMU_SETUP(IFX_PMU_ENABLE);
3975 +static inline void pcie_rcu_endian_setup(int pcie_port)
3979 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
3980 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
3981 + reg |= IFX_RCU_AHB_BE_PCIE_M;
3982 + reg |= IFX_RCU_AHB_BE_PCIE_S;
3983 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
3985 + reg |= IFX_RCU_AHB_BE_PCIE_M;
3986 + reg &= ~IFX_RCU_AHB_BE_PCIE_S;
3987 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
3988 +#endif /* CONFIG_IFX_PCIE_HW_SWAP */
3989 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
3990 + IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
3993 +static inline void pcie_phy_pmu_enable(int pcie_port)
3996 + clk = clk_get_sys("1d900000.pcie", "phy");
3999 + //PCIE_PHY_PMU_SETUP(IFX_PMU_ENABLE);
4002 +static inline void pcie_phy_pmu_disable(int pcie_port)
4005 + clk = clk_get_sys("1d900000.pcie", "phy");
4008 +// PCIE_PHY_PMU_SETUP(IFX_PMU_DISABLE);
4011 +static inline void pcie_pdi_big_endian(int pcie_port)
4015 + /* SRAM2PDI endianness control. */
4016 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
4017 + /* Config AHB->PCIe and PDI endianness */
4018 + reg |= IFX_RCU_AHB_BE_PCIE_PDI;
4019 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
4022 +static inline void pcie_pdi_pmu_enable(int pcie_port)
4024 + /* Enable PDI to access PCIe PHY register */
4026 + clk = clk_get_sys("1d900000.pcie", "pdi");
4028 + //PDI_PMU_SETUP(IFX_PMU_ENABLE);
4031 +static inline void pcie_core_rst_assert(int pcie_port)
4035 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4037 + /* Reset PCIe PHY & Core, bit 22, bit 26 may be affected if write it directly */
4038 + reg |= 0x00400000;
4039 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4042 +static inline void pcie_core_rst_deassert(int pcie_port)
4046 + /* Make sure one micro-second delay */
4049 + /* Reset PCIe PHY & Core, bit 22 */
4050 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4051 + reg &= ~0x00400000;
4052 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4055 +static inline void pcie_phy_rst_assert(int pcie_port)
4059 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4060 + reg |= 0x00001000; /* Bit 12 */
4061 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4064 +static inline void pcie_phy_rst_deassert(int pcie_port)
4068 + /* Make sure one micro-second delay */
4071 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4072 + reg &= ~0x00001000; /* Bit 12 */
4073 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4076 +static inline void pcie_device_rst_assert(int pcie_port)
4078 + gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
4079 +// ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
4082 +static inline void pcie_device_rst_deassert(int pcie_port)
4085 + gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
4086 +// gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
4087 + //ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
4090 +static inline void pcie_core_pmu_setup(int pcie_port)
4093 + clk = clk_get_sys("1d900000.pcie", "ctl");
4095 + clk = clk_get_sys("1d900000.pcie", "bus");
4098 + /* PCIe Core controller enabled */
4099 +// PCIE_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
4101 + /* Enable PCIe L0 Clock */
4102 +// PCIE_L0_CLK_PMU_SETUP(IFX_PMU_ENABLE);
4105 +static inline void pcie_msi_init(int pcie_port)
4108 + pcie_msi_pic_init(pcie_port);
4109 + clk = clk_get_sys("ltq_pcie", "msi");
4111 +// MSI_PMU_SETUP(IFX_PMU_ENABLE);
4115 +ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
4117 + u32 tbus_number = bus_number;
4119 +#ifdef CONFIG_PCI_LANTIQ
4120 + if (pcibios_host_nr() > 1) {
4121 + tbus_number -= pcibios_1st_host_bus_nr();
4123 +#endif /* CONFIG_PCI_LANTIQ */
4124 + return tbus_number;
4128 +ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
4130 + struct pci_dev *pdev;
4131 + u32 tvalue = value;
4133 + /* Sanity check */
4134 + pdev = pci_get_slot(bus, devfn);
4135 + if (pdev == NULL) {
4139 + /* Only care about PCI bridge */
4140 + if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
4144 + if (read) { /* Read hack */
4145 + #ifdef CONFIG_PCI_LANTIQ
4146 + if (pcibios_host_nr() > 1) {
4147 + tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
4149 + #endif /* CONFIG_PCI_LANTIQ */
4151 + else { /* Write hack */
4152 + #ifdef CONFIG_PCI_LANTIQ
4153 + if (pcibios_host_nr() > 1) {
4154 + tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
4161 +#endif /* IFXMIPS_PCIE_VR9_H */
4163 --- a/arch/mips/pci/pci.c
4164 +++ b/arch/mips/pci/pci.c
4165 @@ -256,6 +256,31 @@ static int __init pcibios_init(void)
4167 subsys_initcall(pcibios_init);
4169 +int pcibios_host_nr(void)
4172 + struct pci_controller *hose;
4173 + for (count = 0, hose = hose_head; hose; hose = hose->next, count++) {
4178 +EXPORT_SYMBOL(pcibios_host_nr);
4180 +int pcibios_1st_host_bus_nr(void)
4183 + struct pci_controller *hose = hose_head;
4185 + if (hose != NULL) {
4186 + if (hose->bus != NULL) {
4187 + bus_nr = hose->bus->number + 1;
4192 +EXPORT_SYMBOL(pcibios_1st_host_bus_nr);
4194 static int pcibios_enable_resources(struct pci_dev *dev, int mask)
4198 +++ b/arch/mips/pci/pcie-lantiq.h
4200 +/******************************************************************************
4202 +** FILE NAME : ifxmips_pcie_reg.h
4203 +** PROJECT : IFX UEIP for VRX200
4204 +** MODULES : PCIe module
4206 +** DATE : 02 Mar 2009
4207 +** AUTHOR : Lei Chuanhua
4208 +** DESCRIPTION : PCIe Root Complex Driver
4209 +** COPYRIGHT : Copyright (c) 2009
4210 +** Infineon Technologies AG
4211 +** Am Campeon 1-12, 85579 Neubiberg, Germany
4213 +** This program is free software; you can redistribute it and/or modify
4214 +** it under the terms of the GNU General Public License as published by
4215 +** the Free Software Foundation; either version 2 of the License, or
4216 +** (at your option) any later version.
4218 +** $Version $Date $Author $Comment
4219 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
4220 +*******************************************************************************/
4221 +#ifndef IFXMIPS_PCIE_REG_H
4222 +#define IFXMIPS_PCIE_REG_H
4223 +#include <linux/version.h>
4224 +#include <linux/types.h>
4225 +#include <linux/pci.h>
4226 +#include <linux/interrupt.h>
4228 + \file ifxmips_pcie_reg.h
4230 + \brief header file for PCIe module register definition
4232 +/* PCIe Address Mapping Base */
4233 +#define PCIE_CFG_PHY_BASE 0x1D000000UL
4234 +#define PCIE_CFG_BASE (KSEG1 + PCIE_CFG_PHY_BASE)
4235 +#define PCIE_CFG_SIZE (8 * 1024 * 1024)
4237 +#define PCIE_MEM_PHY_BASE 0x1C000000UL
4238 +#define PCIE_MEM_BASE (KSEG1 + PCIE_MEM_PHY_BASE)
4239 +#define PCIE_MEM_SIZE (16 * 1024 * 1024)
4240 +#define PCIE_MEM_PHY_END (PCIE_MEM_PHY_BASE + PCIE_MEM_SIZE - 1)
4242 +#define PCIE_IO_PHY_BASE 0x1D800000UL
4243 +#define PCIE_IO_BASE (KSEG1 + PCIE_IO_PHY_BASE)
4244 +#define PCIE_IO_SIZE (1 * 1024 * 1024)
4245 +#define PCIE_IO_PHY_END (PCIE_IO_PHY_BASE + PCIE_IO_SIZE - 1)
4247 +#define PCIE_RC_CFG_BASE (KSEG1 + 0x1D900000)
4248 +#define PCIE_APP_LOGIC_REG (KSEG1 + 0x1E100900)
4249 +#define PCIE_MSI_PHY_BASE 0x1F600000UL
4251 +#define PCIE_PDI_PHY_BASE 0x1F106800UL
4252 +#define PCIE_PDI_BASE (KSEG1 + PCIE_PDI_PHY_BASE)
4253 +#define PCIE_PDI_SIZE 0x400
4255 +#define PCIE1_CFG_PHY_BASE 0x19000000UL
4256 +#define PCIE1_CFG_BASE (KSEG1 + PCIE1_CFG_PHY_BASE)
4257 +#define PCIE1_CFG_SIZE (8 * 1024 * 1024)
4259 +#define PCIE1_MEM_PHY_BASE 0x18000000UL
4260 +#define PCIE1_MEM_BASE (KSEG1 + PCIE1_MEM_PHY_BASE)
4261 +#define PCIE1_MEM_SIZE (16 * 1024 * 1024)
4262 +#define PCIE1_MEM_PHY_END (PCIE1_MEM_PHY_BASE + PCIE1_MEM_SIZE - 1)
4264 +#define PCIE1_IO_PHY_BASE 0x19800000UL
4265 +#define PCIE1_IO_BASE (KSEG1 + PCIE1_IO_PHY_BASE)
4266 +#define PCIE1_IO_SIZE (1 * 1024 * 1024)
4267 +#define PCIE1_IO_PHY_END (PCIE1_IO_PHY_BASE + PCIE1_IO_SIZE - 1)
4269 +#define PCIE1_RC_CFG_BASE (KSEG1 + 0x19900000)
4270 +#define PCIE1_APP_LOGIC_REG (KSEG1 + 0x1E100700)
4271 +#define PCIE1_MSI_PHY_BASE 0x1F400000UL
4273 +#define PCIE1_PDI_PHY_BASE 0x1F700400UL
4274 +#define PCIE1_PDI_BASE (KSEG1 + PCIE1_PDI_PHY_BASE)
4275 +#define PCIE1_PDI_SIZE 0x400
4277 +#define PCIE_CFG_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_CFG_BASE) : (PCIE_CFG_BASE))
4278 +#define PCIE_MEM_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_BASE) : (PCIE_MEM_BASE))
4279 +#define PCIE_IO_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_BASE) : (PCIE_IO_BASE))
4280 +#define PCIE_MEM_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_PHY_BASE) : (PCIE_MEM_PHY_BASE))
4281 +#define PCIE_MEM_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_MEM_PHY_END) : (PCIE_MEM_PHY_END))
4282 +#define PCIE_IO_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_PHY_BASE) : (PCIE_IO_PHY_BASE))
4283 +#define PCIE_IO_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_IO_PHY_END) : (PCIE_IO_PHY_END))
4284 +#define PCIE_APP_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_APP_LOGIC_REG) : (PCIE_APP_LOGIC_REG))
4285 +#define PCIE_RC_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_RC_CFG_BASE) : (PCIE_RC_CFG_BASE))
4286 +#define PCIE_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_PDI_BASE) : (PCIE_PDI_BASE))
4288 +/* PCIe Application Logic Register */
4289 +/* RC Core Control Register */
4290 +#define PCIE_RC_CCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x10)
4291 +/* This should be enabled after initializing configuratin registers
4292 + * Also should check link status retraining bit
4294 +#define PCIE_RC_CCR_LTSSM_ENABLE 0x00000001 /* Enable LTSSM to continue link establishment */
4296 +/* RC Core Debug Register */
4297 +#define PCIE_RC_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x14)
4298 +#define PCIE_RC_DR_DLL_UP 0x00000001 /* Data Link Layer Up */
4299 +#define PCIE_RC_DR_CURRENT_POWER_STATE 0x0000000E /* Current Power State */
4300 +#define PCIE_RC_DR_CURRENT_POWER_STATE_S 1
4301 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE 0x000001F0 /* Current LTSSM State */
4302 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE_S 4
4304 +#define PCIE_RC_DR_PM_DEV_STATE 0x00000E00 /* Power Management D-State */
4305 +#define PCIE_RC_DR_PM_DEV_STATE_S 9
4307 +#define PCIE_RC_DR_PM_ENABLED 0x00001000 /* Power Management State from PMU */
4308 +#define PCIE_RC_DR_PME_EVENT_ENABLED 0x00002000 /* Power Management Event Enable State */
4309 +#define PCIE_RC_DR_AUX_POWER_ENABLED 0x00004000 /* Auxiliary Power Enable */
4311 +/* Current Power State Definition */
4313 + PCIE_RC_DR_D0 = 0,
4314 + PCIE_RC_DR_D1, /* Not supported */
4315 + PCIE_RC_DR_D2, /* Not supported */
4320 +/* PHY Link Status Register */
4321 +#define PCIE_PHY_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x18)
4322 +#define PCIE_PHY_SR_PHY_LINK_UP 0x00000001 /* PHY Link Up/Down Indicator */
4324 +/* Electromechanical Control Register */
4325 +#define PCIE_EM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x1C)
4326 +#define PCIE_EM_CR_CARD_IS_PRESENT 0x00000001 /* Card Presence Detect State */
4327 +#define PCIE_EM_CR_MRL_OPEN 0x00000002 /* MRL Sensor State */
4328 +#define PCIE_EM_CR_POWER_FAULT_SET 0x00000004 /* Power Fault Detected */
4329 +#define PCIE_EM_CR_MRL_SENSOR_SET 0x00000008 /* MRL Sensor Changed */
4330 +#define PCIE_EM_CR_PRESENT_DETECT_SET 0x00000010 /* Card Presense Detect Changed */
4331 +#define PCIE_EM_CR_CMD_CPL_INT_SET 0x00000020 /* Command Complete Interrupt */
4332 +#define PCIE_EM_CR_SYS_INTERLOCK_SET 0x00000040 /* System Electromechanical IterLock Engaged */
4333 +#define PCIE_EM_CR_ATTENTION_BUTTON_SET 0x00000080 /* Attention Button Pressed */
4335 +/* Interrupt Status Register */
4336 +#define PCIE_IR_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x20)
4337 +#define PCIE_IR_SR_PME_CAUSE_MSI 0x00000002 /* MSI caused by PME */
4338 +#define PCIE_IR_SR_HP_PME_WAKE_GEN 0x00000004 /* Hotplug PME Wake Generation */
4339 +#define PCIE_IR_SR_HP_MSI 0x00000008 /* Hotplug MSI */
4340 +#define PCIE_IR_SR_AHB_LU_ERR 0x00000030 /* AHB Bridge Lookup Error Signals */
4341 +#define PCIE_IR_SR_AHB_LU_ERR_S 4
4342 +#define PCIE_IR_SR_INT_MSG_NUM 0x00003E00 /* Interrupt Message Number */
4343 +#define PCIE_IR_SR_INT_MSG_NUM_S 9
4344 +#define PCIE_IR_SR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
4345 +#define PCIE_IR_SR_AER_INT_MSG_NUM_S 27
4347 +/* Message Control Register */
4348 +#define PCIE_MSG_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x30)
4349 +#define PCIE_MSG_CR_GEN_PME_TURN_OFF_MSG 0x00000001 /* Generate PME Turn Off Message */
4350 +#define PCIE_MSG_CR_GEN_UNLOCK_MSG 0x00000002 /* Generate Unlock Message */
4352 +#define PCIE_VDM_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x34)
4354 +/* Vendor-Defined Message Requester ID Register */
4355 +#define PCIE_VDM_RID(X) (PCIE_APP_PORT_TO_BASE (X) + 0x38)
4356 +#define PCIE_VDM_RID_VENROR_MSG_REQ_ID 0x0000FFFF
4357 +#define PCIE_VDM_RID_VDMRID_S 0
4359 +/* ASPM Control Register */
4360 +#define PCIE_ASPM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x40)
4361 +#define PCIE_ASPM_CR_HOT_RST 0x00000001 /* Hot Reset Request to the downstream device */
4362 +#define PCIE_ASPM_CR_REQ_EXIT_L1 0x00000002 /* Request to Exit L1 */
4363 +#define PCIE_ASPM_CR_REQ_ENTER_L1 0x00000004 /* Request to Enter L1 */
4365 +/* Vendor Message DW0 Register */
4366 +#define PCIE_VM_MSG_DW0(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x50)
4367 +#define PCIE_VM_MSG_DW0_TYPE 0x0000001F /* Message type */
4368 +#define PCIE_VM_MSG_DW0_TYPE_S 0
4369 +#define PCIE_VM_MSG_DW0_FORMAT 0x00000060 /* Format */
4370 +#define PCIE_VM_MSG_DW0_FORMAT_S 5
4371 +#define PCIE_VM_MSG_DW0_TC 0x00007000 /* Traffic Class */
4372 +#define PCIE_VM_MSG_DW0_TC_S 12
4373 +#define PCIE_VM_MSG_DW0_ATTR 0x000C0000 /* Atrributes */
4374 +#define PCIE_VM_MSG_DW0_ATTR_S 18
4375 +#define PCIE_VM_MSG_DW0_EP_TLP 0x00100000 /* Poisoned TLP */
4376 +#define PCIE_VM_MSG_DW0_TD 0x00200000 /* TLP Digest */
4377 +#define PCIE_VM_MSG_DW0_LEN 0xFFC00000 /* Length */
4378 +#define PCIE_VM_MSG_DW0_LEN_S 22
4380 +/* Format Definition */
4382 + PCIE_VM_MSG_FORMAT_00 = 0, /* 3DW Hdr, no data*/
4383 + PCIE_VM_MSG_FORMAT_01, /* 4DW Hdr, no data */
4384 + PCIE_VM_MSG_FORMAT_10, /* 3DW Hdr, with data */
4385 + PCIE_VM_MSG_FORMAT_11, /* 4DW Hdr, with data */
4388 +/* Traffic Class Definition */
4390 + PCIE_VM_MSG_TC0 = 0,
4400 +/* Attributes Definition */
4402 + PCIE_VM_MSG_ATTR_00 = 0, /* RO and No Snoop cleared */
4403 + PCIE_VM_MSG_ATTR_01, /* RO cleared , No Snoop set */
4404 + PCIE_VM_MSG_ATTR_10, /* RO set, No Snoop cleared*/
4405 + PCIE_VM_MSG_ATTR_11, /* RO and No Snoop set */
4408 +/* Payload Size Definition */
4409 +#define PCIE_VM_MSG_LEN_MIN 0
4410 +#define PCIE_VM_MSG_LEN_MAX 1024
4412 +/* Vendor Message DW1 Register */
4413 +#define PCIE_VM_MSG_DW1(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x54)
4414 +#define PCIE_VM_MSG_DW1_FUNC_NUM 0x00000070 /* Function Number */
4415 +#define PCIE_VM_MSG_DW1_FUNC_NUM_S 8
4416 +#define PCIE_VM_MSG_DW1_CODE 0x00FF0000 /* Message Code */
4417 +#define PCIE_VM_MSG_DW1_CODE_S 16
4418 +#define PCIE_VM_MSG_DW1_TAG 0xFF000000 /* Tag */
4419 +#define PCIE_VM_MSG_DW1_TAG_S 24
4421 +#define PCIE_VM_MSG_DW2(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x58)
4422 +#define PCIE_VM_MSG_DW3(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x5C)
4424 +/* Vendor Message Request Register */
4425 +#define PCIE_VM_MSG_REQR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x60)
4426 +#define PCIE_VM_MSG_REQR_REQ 0x00000001 /* Vendor Message Request */
4429 +/* AHB Slave Side Band Control Register */
4430 +#define PCIE_AHB_SSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x70)
4431 +#define PCIE_AHB_SSB_REQ_BCM 0x00000001 /* Slave Reques BCM filed */
4432 +#define PCIE_AHB_SSB_REQ_EP 0x00000002 /* Slave Reques EP filed */
4433 +#define PCIE_AHB_SSB_REQ_TD 0x00000004 /* Slave Reques TD filed */
4434 +#define PCIE_AHB_SSB_REQ_ATTR 0x00000018 /* Slave Reques Attribute number */
4435 +#define PCIE_AHB_SSB_REQ_ATTR_S 3
4436 +#define PCIE_AHB_SSB_REQ_TC 0x000000E0 /* Slave Request TC Field */
4437 +#define PCIE_AHB_SSB_REQ_TC_S 5
4439 +/* AHB Master SideBand Ctrl Register */
4440 +#define PCIE_AHB_MSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x74)
4441 +#define PCIE_AHB_MSB_RESP_ATTR 0x00000003 /* Master Response Attribute number */
4442 +#define PCIE_AHB_MSB_RESP_ATTR_S 0
4443 +#define PCIE_AHB_MSB_RESP_BAD_EOT 0x00000004 /* Master Response Badeot filed */
4444 +#define PCIE_AHB_MSB_RESP_BCM 0x00000008 /* Master Response BCM filed */
4445 +#define PCIE_AHB_MSB_RESP_EP 0x00000010 /* Master Response EP filed */
4446 +#define PCIE_AHB_MSB_RESP_TD 0x00000020 /* Master Response TD filed */
4447 +#define PCIE_AHB_MSB_RESP_FUN_NUM 0x000003C0 /* Master Response Function number */
4448 +#define PCIE_AHB_MSB_RESP_FUN_NUM_S 6
4450 +/* AHB Control Register, fixed bus enumeration exception */
4451 +#define PCIE_AHB_CTRL(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x78)
4452 +#define PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS 0x00000001
4454 +/* Interrupt Enalbe Register */
4455 +#define PCIE_IRNEN(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF4)
4456 +#define PCIE_IRNCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF8)
4457 +#define PCIE_IRNICR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xFC)
4459 +/* PCIe interrupt enable/control/capture register definition */
4460 +#define PCIE_IRN_AER_REPORT 0x00000001 /* AER Interrupt */
4461 +#define PCIE_IRN_AER_MSIX 0x00000002 /* Advanced Error MSI-X Interrupt */
4462 +#define PCIE_IRN_PME 0x00000004 /* PME Interrupt */
4463 +#define PCIE_IRN_HOTPLUG 0x00000008 /* Hotplug Interrupt */
4464 +#define PCIE_IRN_RX_VDM_MSG 0x00000010 /* Vendor-Defined Message Interrupt */
4465 +#define PCIE_IRN_RX_CORRECTABLE_ERR_MSG 0x00000020 /* Correctable Error Message Interrupt */
4466 +#define PCIE_IRN_RX_NON_FATAL_ERR_MSG 0x00000040 /* Non-fatal Error Message */
4467 +#define PCIE_IRN_RX_FATAL_ERR_MSG 0x00000080 /* Fatal Error Message */
4468 +#define PCIE_IRN_RX_PME_MSG 0x00000100 /* PME Message Interrupt */
4469 +#define PCIE_IRN_RX_PME_TURNOFF_ACK 0x00000200 /* PME Turnoff Ack Message Interrupt */
4470 +#define PCIE_IRN_AHB_BR_FATAL_ERR 0x00000400 /* AHB Fatal Error Interrupt */
4471 +#define PCIE_IRN_LINK_AUTO_BW_STATUS 0x00000800 /* Link Auto Bandwidth Status Interrupt */
4472 +#define PCIE_IRN_BW_MGT 0x00001000 /* Bandwidth Managment Interrupt */
4473 +#define PCIE_IRN_INTA 0x00002000 /* INTA */
4474 +#define PCIE_IRN_INTB 0x00004000 /* INTB */
4475 +#define PCIE_IRN_INTC 0x00008000 /* INTC */
4476 +#define PCIE_IRN_INTD 0x00010000 /* INTD */
4477 +#define PCIE_IRN_WAKEUP 0x00020000 /* Wake up Interrupt */
4479 +#define PCIE_RC_CORE_COMBINED_INT (PCIE_IRN_AER_REPORT | PCIE_IRN_AER_MSIX | PCIE_IRN_PME | \
4480 + PCIE_IRN_HOTPLUG | PCIE_IRN_RX_VDM_MSG | PCIE_IRN_RX_CORRECTABLE_ERR_MSG |\
4481 + PCIE_IRN_RX_NON_FATAL_ERR_MSG | PCIE_IRN_RX_FATAL_ERR_MSG | \
4482 + PCIE_IRN_RX_PME_MSG | PCIE_IRN_RX_PME_TURNOFF_ACK | PCIE_IRN_AHB_BR_FATAL_ERR | \
4483 + PCIE_IRN_LINK_AUTO_BW_STATUS | PCIE_IRN_BW_MGT)
4484 +/* PCIe RC Configuration Register */
4485 +#define PCIE_VDID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x00)
4487 +/* Bit definition from pci_reg.h */
4488 +#define PCIE_PCICMDSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x04)
4489 +#define PCIE_CCRID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x08)
4490 +#define PCIE_CLSLTHTBR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x0C) /* EP only */
4491 +/* BAR0, BAR1,Only necessary if the bridges implements a device-specific register set or memory buffer */
4492 +#define PCIE_BAR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10) /* Not used*/
4493 +#define PCIE_BAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14) /* Not used */
4495 +#define PCIE_BNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x18) /* Mandatory */
4496 +/* Bus Number Register bits */
4497 +#define PCIE_BNR_PRIMARY_BUS_NUM 0x000000FF
4498 +#define PCIE_BNR_PRIMARY_BUS_NUM_S 0
4499 +#define PCIE_PNR_SECONDARY_BUS_NUM 0x0000FF00
4500 +#define PCIE_PNR_SECONDARY_BUS_NUM_S 8
4501 +#define PCIE_PNR_SUB_BUS_NUM 0x00FF0000
4502 +#define PCIE_PNR_SUB_BUS_NUM_S 16
4504 +/* IO Base/Limit Register bits */
4505 +#define PCIE_IOBLSECS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x1C) /* RC only */
4506 +#define PCIE_IOBLSECS_32BIT_IO_ADDR 0x00000001
4507 +#define PCIE_IOBLSECS_IO_BASE_ADDR 0x000000F0
4508 +#define PCIE_IOBLSECS_IO_BASE_ADDR_S 4
4509 +#define PCIE_IOBLSECS_32BIT_IOLIMT 0x00000100
4510 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR 0x0000F000
4511 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR_S 12
4513 +/* Non-prefetchable Memory Base/Limit Register bit */
4514 +#define PCIE_MBML(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x20) /* RC only */
4515 +#define PCIE_MBML_MEM_BASE_ADDR 0x0000FFF0
4516 +#define PCIE_MBML_MEM_BASE_ADDR_S 4
4517 +#define PCIE_MBML_MEM_LIMIT_ADDR 0xFFF00000
4518 +#define PCIE_MBML_MEM_LIMIT_ADDR_S 20
4520 +/* Prefetchable Memory Base/Limit Register bit */
4521 +#define PCIE_PMBL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x24) /* RC only */
4522 +#define PCIE_PMBL_64BIT_ADDR 0x00000001
4523 +#define PCIE_PMBL_UPPER_12BIT 0x0000FFF0
4524 +#define PCIE_PMBL_UPPER_12BIT_S 4
4525 +#define PCIE_PMBL_E64MA 0x00010000
4526 +#define PCIE_PMBL_END_ADDR 0xFFF00000
4527 +#define PCIE_PMBL_END_ADDR_S 20
4528 +#define PCIE_PMBU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x28) /* RC only */
4529 +#define PCIE_PMLU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x2C) /* RC only */
4531 +/* I/O Base/Limit Upper 16 bits register */
4532 +#define PCIE_IO_BANDL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x30) /* RC only */
4533 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE 0x0000FFFF
4534 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE_S 0
4535 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT 0xFFFF0000
4536 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT_S 16
4538 +#define PCIE_CPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x34)
4539 +#define PCIE_EBBAR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x38)
4541 +/* Interrupt and Secondary Bridge Control Register */
4542 +#define PCIE_INTRBCTRL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x3C)
4544 +#define PCIE_INTRBCTRL_INT_LINE 0x000000FF
4545 +#define PCIE_INTRBCTRL_INT_LINE_S 0
4546 +#define PCIE_INTRBCTRL_INT_PIN 0x0000FF00
4547 +#define PCIE_INTRBCTRL_INT_PIN_S 8
4548 +#define PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE 0x00010000 /* #PERR */
4549 +#define PCIE_INTRBCTRL_SERR_ENABLE 0x00020000 /* #SERR */
4550 +#define PCIE_INTRBCTRL_ISA_ENABLE 0x00040000 /* ISA enable, IO 64KB only */
4551 +#define PCIE_INTRBCTRL_VGA_ENABLE 0x00080000 /* VGA enable */
4552 +#define PCIE_INTRBCTRL_VGA_16BIT_DECODE 0x00100000 /* VGA 16bit decode */
4553 +#define PCIE_INTRBCTRL_RST_SECONDARY_BUS 0x00400000 /* Secondary bus rest, hot rest, 1ms */
4554 +/* Others are read only */
4556 + PCIE_INTRBCTRL_INT_NON = 0,
4557 + PCIE_INTRBCTRL_INTA,
4558 + PCIE_INTRBCTRL_INTB,
4559 + PCIE_INTRBCTRL_INTC,
4560 + PCIE_INTRBCTRL_INTD,
4563 +#define PCIE_PM_CAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x40)
4565 +/* Power Management Control and Status Register */
4566 +#define PCIE_PM_CSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x44)
4568 +#define PCIE_PM_CSR_POWER_STATE 0x00000003 /* Power State */
4569 +#define PCIE_PM_CSR_POWER_STATE_S 0
4570 +#define PCIE_PM_CSR_SW_RST 0x00000008 /* Soft Reset Enabled */
4571 +#define PCIE_PM_CSR_PME_ENABLE 0x00000100 /* PME Enable */
4572 +#define PCIE_PM_CSR_PME_STATUS 0x00008000 /* PME status */
4574 +/* MSI Capability Register for EP */
4575 +#define PCIE_MCAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x50)
4577 +#define PCIE_MCAPR_MSI_CAP_ID 0x000000FF /* MSI Capability ID */
4578 +#define PCIE_MCAPR_MSI_CAP_ID_S 0
4579 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR 0x0000FF00 /* Next Capability Pointer */
4580 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR_S 8
4581 +#define PCIE_MCAPR_MSI_ENABLE 0x00010000 /* MSI Enable */
4582 +#define PCIE_MCAPR_MULTI_MSG_CAP 0x000E0000 /* Multiple Message Capable */
4583 +#define PCIE_MCAPR_MULTI_MSG_CAP_S 17
4584 +#define PCIE_MCAPR_MULTI_MSG_ENABLE 0x00700000 /* Multiple Message Enable */
4585 +#define PCIE_MCAPR_MULTI_MSG_ENABLE_S 20
4586 +#define PCIE_MCAPR_ADDR64_CAP 0X00800000 /* 64-bit Address Capable */
4588 +/* MSI Message Address Register */
4589 +#define PCIE_MA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x54)
4591 +#define PCIE_MA_ADDR_MASK 0xFFFFFFFC /* Message Address */
4593 +/* MSI Message Upper Address Register */
4594 +#define PCIE_MUA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x58)
4596 +/* MSI Message Data Register */
4597 +#define PCIE_MD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x5C)
4599 +#define PCIE_MD_DATA 0x0000FFFF /* Message Data */
4600 +#define PCIE_MD_DATA_S 0
4602 +/* PCI Express Capability Register */
4603 +#define PCIE_XCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70)
4605 +#define PCIE_XCAP_ID 0x000000FF /* PCI Express Capability ID */
4606 +#define PCIE_XCAP_ID_S 0
4607 +#define PCIE_XCAP_NEXT_CAP 0x0000FF00 /* Next Capability Pointer */
4608 +#define PCIE_XCAP_NEXT_CAP_S 8
4609 +#define PCIE_XCAP_VER 0x000F0000 /* PCI Express Capability Version */
4610 +#define PCIE_XCAP_VER_S 16
4611 +#define PCIE_XCAP_DEV_PORT_TYPE 0x00F00000 /* Device Port Type */
4612 +#define PCIE_XCAP_DEV_PORT_TYPE_S 20
4613 +#define PCIE_XCAP_SLOT_IMPLEMENTED 0x01000000 /* Slot Implemented */
4614 +#define PCIE_XCAP_MSG_INT_NUM 0x3E000000 /* Interrupt Message Number */
4615 +#define PCIE_XCAP_MSG_INT_NUM_S 25
4617 +/* Device Capability Register */
4618 +#define PCIE_DCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74)
4620 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE 0x00000007 /* Max Payload size */
4621 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE_S 0
4622 +#define PCIE_DCAP_PHANTOM_FUNC 0x00000018 /* Phanton Function, not supported */
4623 +#define PCIE_DCAP_PHANTOM_FUNC_S 3
4624 +#define PCIE_DCAP_EXT_TAG 0x00000020 /* Extended Tag Field */
4625 +#define PCIE_DCAP_EP_L0S_LATENCY 0x000001C0 /* EP L0s latency only */
4626 +#define PCIE_DCAP_EP_L0S_LATENCY_S 6
4627 +#define PCIE_DCAP_EP_L1_LATENCY 0x00000E00 /* EP L1 latency only */
4628 +#define PCIE_DCAP_EP_L1_LATENCY_S 9
4629 +#define PCIE_DCAP_ROLE_BASE_ERR_REPORT 0x00008000 /* Role Based ERR */
4631 +/* Maximum payload size supported */
4633 + PCIE_MAX_PAYLOAD_128 = 0,
4634 + PCIE_MAX_PAYLOAD_256,
4635 + PCIE_MAX_PAYLOAD_512,
4636 + PCIE_MAX_PAYLOAD_1024,
4637 + PCIE_MAX_PAYLOAD_2048,
4638 + PCIE_MAX_PAYLOAD_4096,
4641 +/* Device Control and Status Register */
4642 +#define PCIE_DCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x78)
4644 +#define PCIE_DCTLSTS_CORRECTABLE_ERR_EN 0x00000001 /* COR-ERR */
4645 +#define PCIE_DCTLSTS_NONFATAL_ERR_EN 0x00000002 /* Non-fatal ERR */
4646 +#define PCIE_DCTLSTS_FATAL_ERR_EN 0x00000004 /* Fatal ERR */
4647 +#define PCIE_DCTLSYS_UR_REQ_EN 0x00000008 /* UR ERR */
4648 +#define PCIE_DCTLSTS_RELAXED_ORDERING_EN 0x00000010 /* Enable relaxing ordering */
4649 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE 0x000000E0 /* Max payload mask */
4650 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE_S 5
4651 +#define PCIE_DCTLSTS_EXT_TAG_EN 0x00000100 /* Extended tag field */
4652 +#define PCIE_DCTLSTS_PHANTOM_FUNC_EN 0x00000200 /* Phantom Function Enable */
4653 +#define PCIE_DCTLSTS_AUX_PM_EN 0x00000400 /* AUX Power PM Enable */
4654 +#define PCIE_DCTLSTS_NO_SNOOP_EN 0x00000800 /* Enable no snoop, except root port*/
4655 +#define PCIE_DCTLSTS_MAX_READ_SIZE 0x00007000 /* Max Read Request size*/
4656 +#define PCIE_DCTLSTS_MAX_READ_SIZE_S 12
4657 +#define PCIE_DCTLSTS_CORRECTABLE_ERR 0x00010000 /* COR-ERR Detected */
4658 +#define PCIE_DCTLSTS_NONFATAL_ERR 0x00020000 /* Non-Fatal ERR Detected */
4659 +#define PCIE_DCTLSTS_FATAL_ER 0x00040000 /* Fatal ERR Detected */
4660 +#define PCIE_DCTLSTS_UNSUPPORTED_REQ 0x00080000 /* UR Detected */
4661 +#define PCIE_DCTLSTS_AUX_POWER 0x00100000 /* Aux Power Detected */
4662 +#define PCIE_DCTLSTS_TRANSACT_PENDING 0x00200000 /* Transaction pending */
4664 +#define PCIE_DCTLSTS_ERR_EN (PCIE_DCTLSTS_CORRECTABLE_ERR_EN | \
4665 + PCIE_DCTLSTS_NONFATAL_ERR_EN | PCIE_DCTLSTS_FATAL_ERR_EN | \
4666 + PCIE_DCTLSYS_UR_REQ_EN)
4668 +/* Link Capability Register */
4669 +#define PCIE_LCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7C)
4670 +#define PCIE_LCAP_MAX_LINK_SPEED 0x0000000F /* Max link speed, 0x1 by default */
4671 +#define PCIE_LCAP_MAX_LINK_SPEED_S 0
4672 +#define PCIE_LCAP_MAX_LENGTH_WIDTH 0x000003F0 /* Maxium Length Width */
4673 +#define PCIE_LCAP_MAX_LENGTH_WIDTH_S 4
4674 +#define PCIE_LCAP_ASPM_LEVEL 0x00000C00 /* Active State Link PM Support */
4675 +#define PCIE_LCAP_ASPM_LEVEL_S 10
4676 +#define PCIE_LCAP_L0S_EIXT_LATENCY 0x00007000 /* L0s Exit Latency */
4677 +#define PCIE_LCAP_L0S_EIXT_LATENCY_S 12
4678 +#define PCIE_LCAP_L1_EXIT_LATENCY 0x00038000 /* L1 Exit Latency */
4679 +#define PCIE_LCAP_L1_EXIT_LATENCY_S 15
4680 +#define PCIE_LCAP_CLK_PM 0x00040000 /* Clock Power Management */
4681 +#define PCIE_LCAP_SDER 0x00080000 /* Surprise Down Error Reporting */
4682 +#define PCIE_LCAP_DLL_ACTIVE_REPROT 0x00100000 /* Data Link Layer Active Reporting Capable */
4683 +#define PCIE_LCAP_PORT_NUM 0xFF0000000 /* Port number */
4684 +#define PCIE_LCAP_PORT_NUM_S 24
4686 +/* Maximum Length width definition */
4687 +#define PCIE_MAX_LENGTH_WIDTH_RES 0x00
4688 +#define PCIE_MAX_LENGTH_WIDTH_X1 0x01 /* Default */
4689 +#define PCIE_MAX_LENGTH_WIDTH_X2 0x02
4690 +#define PCIE_MAX_LENGTH_WIDTH_X4 0x04
4691 +#define PCIE_MAX_LENGTH_WIDTH_X8 0x08
4692 +#define PCIE_MAX_LENGTH_WIDTH_X12 0x0C
4693 +#define PCIE_MAX_LENGTH_WIDTH_X16 0x10
4694 +#define PCIE_MAX_LENGTH_WIDTH_X32 0x20
4696 +/* Active State Link PM definition */
4698 + PCIE_ASPM_RES0 = 0,
4699 + PCIE_ASPM_L0S_ENTRY_SUPPORT, /* L0s */
4701 + PCIE_ASPM_L0S_L1_ENTRY_SUPPORT, /* L0s and L1, default */
4704 +/* L0s Exit Latency definition */
4706 + PCIE_L0S_EIXT_LATENCY_L64NS = 0, /* < 64 ns */
4707 + PCIE_L0S_EIXT_LATENCY_B64A128, /* > 64 ns < 128 ns */
4708 + PCIE_L0S_EIXT_LATENCY_B128A256, /* > 128 ns < 256 ns */
4709 + PCIE_L0S_EIXT_LATENCY_B256A512, /* > 256 ns < 512 ns */
4710 + PCIE_L0S_EIXT_LATENCY_B512TO1U, /* > 512 ns < 1 us */
4711 + PCIE_L0S_EIXT_LATENCY_B1A2U, /* > 1 us < 2 us */
4712 + PCIE_L0S_EIXT_LATENCY_B2A4U, /* > 2 us < 4 us */
4713 + PCIE_L0S_EIXT_LATENCY_M4US, /* > 4 us */
4716 +/* L1 Exit Latency definition */
4718 + PCIE_L1_EXIT_LATENCY_L1US = 0, /* < 1 us */
4719 + PCIE_L1_EXIT_LATENCY_B1A2, /* > 1 us < 2 us */
4720 + PCIE_L1_EXIT_LATENCY_B2A4, /* > 2 us < 4 us */
4721 + PCIE_L1_EXIT_LATENCY_B4A8, /* > 4 us < 8 us */
4722 + PCIE_L1_EXIT_LATENCY_B8A16, /* > 8 us < 16 us */
4723 + PCIE_L1_EXIT_LATENCY_B16A32, /* > 16 us < 32 us */
4724 + PCIE_L1_EXIT_LATENCY_B32A64, /* > 32 us < 64 us */
4725 + PCIE_L1_EXIT_LATENCY_M64US, /* > 64 us */
4728 +/* Link Control and Status Register */
4729 +#define PCIE_LCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x80)
4730 +#define PCIE_LCTLSTS_ASPM_ENABLE 0x00000003 /* Active State Link PM Control */
4731 +#define PCIE_LCTLSTS_ASPM_ENABLE_S 0
4732 +#define PCIE_LCTLSTS_RCB128 0x00000008 /* Read Completion Boundary 128*/
4733 +#define PCIE_LCTLSTS_LINK_DISABLE 0x00000010 /* Link Disable */
4734 +#define PCIE_LCTLSTS_RETRIAN_LINK 0x00000020 /* Retrain Link */
4735 +#define PCIE_LCTLSTS_COM_CLK_CFG 0x00000040 /* Common Clock Configuration */
4736 +#define PCIE_LCTLSTS_EXT_SYNC 0x00000080 /* Extended Synch */
4737 +#define PCIE_LCTLSTS_CLK_PM_EN 0x00000100 /* Enable Clock Powerm Management */
4738 +#define PCIE_LCTLSTS_LINK_SPEED 0x000F0000 /* Link Speed */
4739 +#define PCIE_LCTLSTS_LINK_SPEED_S 16
4740 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH 0x03F00000 /* Negotiated Link Width */
4741 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH_S 20
4742 +#define PCIE_LCTLSTS_RETRAIN_PENDING 0x08000000 /* Link training is ongoing */
4743 +#define PCIE_LCTLSTS_SLOT_CLK_CFG 0x10000000 /* Slot Clock Configuration */
4744 +#define PCIE_LCTLSTS_DLL_ACTIVE 0x20000000 /* Data Link Layer Active */
4746 +/* Slot Capabilities Register */
4747 +#define PCIE_SLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x84)
4749 +/* Slot Capabilities */
4750 +#define PCIE_SLCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x88)
4752 +/* Root Control and Capability Register */
4753 +#define PCIE_RCTLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x8C)
4754 +#define PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR 0x00000001 /* #SERR on COR-ERR */
4755 +#define PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR 0x00000002 /* #SERR on Non-Fatal ERR */
4756 +#define PCIE_RCTLCAP_SERR_ON_FATAL_ERR 0x00000004 /* #SERR on Fatal ERR */
4757 +#define PCIE_RCTLCAP_PME_INT_EN 0x00000008 /* PME Interrupt Enable */
4758 +#define PCIE_RCTLCAP_SERR_ENABLE (PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR | \
4759 + PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR | PCIE_RCTLCAP_SERR_ON_FATAL_ERR)
4760 +/* Root Status Register */
4761 +#define PCIE_RSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x90)
4762 +#define PCIE_RSTS_PME_REQ_ID 0x0000FFFF /* PME Request ID */
4763 +#define PCIE_RSTS_PME_REQ_ID_S 0
4764 +#define PCIE_RSTS_PME_STATUS 0x00010000 /* PME Status */
4765 +#define PCIE_RSTS_PME_PENDING 0x00020000 /* PME Pending */
4767 +/* PCI Express Enhanced Capability Header */
4768 +#define PCIE_ENHANCED_CAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x100)
4769 +#define PCIE_ENHANCED_CAP_ID 0x0000FFFF /* PCI Express Extended Capability ID */
4770 +#define PCIE_ENHANCED_CAP_ID_S 0
4771 +#define PCIE_ENHANCED_CAP_VER 0x000F0000 /* Capability Version */
4772 +#define PCIE_ENHANCED_CAP_VER_S 16
4773 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET 0xFFF00000 /* Next Capability Offset */
4774 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET_S 20
4776 +/* Uncorrectable Error Status Register */
4777 +#define PCIE_UES_R(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x104)
4778 +#define PCIE_DATA_LINK_PROTOCOL_ERR 0x00000010 /* Data Link Protocol Error Status */
4779 +#define PCIE_SURPRISE_DOWN_ERROR 0x00000020 /* Surprise Down Error Status */
4780 +#define PCIE_POISONED_TLP 0x00001000 /* Poisoned TLP Status */
4781 +#define PCIE_FC_PROTOCOL_ERR 0x00002000 /* Flow Control Protocol Error Status */
4782 +#define PCIE_COMPLETION_TIMEOUT 0x00004000 /* Completion Timeout Status */
4783 +#define PCIE_COMPLETOR_ABORT 0x00008000 /* Completer Abort Error */
4784 +#define PCIE_UNEXPECTED_COMPLETION 0x00010000 /* Unexpected Completion Status */
4785 +#define PCIE_RECEIVER_OVERFLOW 0x00020000 /* Receive Overflow Status */
4786 +#define PCIE_MALFORNED_TLP 0x00040000 /* Malformed TLP Stauts */
4787 +#define PCIE_ECRC_ERR 0x00080000 /* ECRC Error Stauts */
4788 +#define PCIE_UR_REQ 0x00100000 /* Unsupported Request Error Status */
4789 +#define PCIE_ALL_UNCORRECTABLE_ERR (PCIE_DATA_LINK_PROTOCOL_ERR | PCIE_SURPRISE_DOWN_ERROR | \
4790 + PCIE_POISONED_TLP | PCIE_FC_PROTOCOL_ERR | PCIE_COMPLETION_TIMEOUT | \
4791 + PCIE_COMPLETOR_ABORT | PCIE_UNEXPECTED_COMPLETION | PCIE_RECEIVER_OVERFLOW |\
4792 + PCIE_MALFORNED_TLP | PCIE_ECRC_ERR | PCIE_UR_REQ)
4794 +/* Uncorrectable Error Mask Register, Mask means no report */
4795 +#define PCIE_UEMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x108)
4797 +/* Uncorrectable Error Severity Register */
4798 +#define PCIE_UESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10C)
4800 +/* Correctable Error Status Register */
4801 +#define PCIE_CESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x110)
4802 +#define PCIE_RX_ERR 0x00000001 /* Receive Error Status */
4803 +#define PCIE_BAD_TLP 0x00000040 /* Bad TLP Status */
4804 +#define PCIE_BAD_DLLP 0x00000080 /* Bad DLLP Status */
4805 +#define PCIE_REPLAY_NUM_ROLLOVER 0x00000100 /* Replay Number Rollover Status */
4806 +#define PCIE_REPLAY_TIMER_TIMEOUT_ERR 0x00001000 /* Reply Timer Timeout Status */
4807 +#define PCIE_ADVISORY_NONFTAL_ERR 0x00002000 /* Advisory Non-Fatal Error Status */
4808 +#define PCIE_CORRECTABLE_ERR (PCIE_RX_ERR | PCIE_BAD_TLP | PCIE_BAD_DLLP | PCIE_REPLAY_NUM_ROLLOVER |\
4809 + PCIE_REPLAY_TIMER_TIMEOUT_ERR | PCIE_ADVISORY_NONFTAL_ERR)
4811 +/* Correctable Error Mask Register */
4812 +#define PCIE_CEMR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x114)
4814 +/* Advanced Error Capabilities and Control Register */
4815 +#define PCIE_AECCR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x118)
4816 +#define PCIE_AECCR_FIRST_ERR_PTR 0x0000001F /* First Error Pointer */
4817 +#define PCIE_AECCR_FIRST_ERR_PTR_S 0
4818 +#define PCIE_AECCR_ECRC_GEN_CAP 0x00000020 /* ECRC Generation Capable */
4819 +#define PCIE_AECCR_ECRC_GEN_EN 0x00000040 /* ECRC Generation Enable */
4820 +#define PCIE_AECCR_ECRC_CHECK_CAP 0x00000080 /* ECRC Check Capable */
4821 +#define PCIE_AECCR_ECRC_CHECK_EN 0x00000100 /* ECRC Check Enable */
4823 +/* Header Log Register 1 */
4824 +#define PCIE_HLR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x11C)
4826 +/* Header Log Register 2 */
4827 +#define PCIE_HLR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x120)
4829 +/* Header Log Register 3 */
4830 +#define PCIE_HLR3(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x124)
4832 +/* Header Log Register 4 */
4833 +#define PCIE_HLR4(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x128)
4835 +/* Root Error Command Register */
4836 +#define PCIE_RECR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x12C)
4837 +#define PCIE_RECR_CORRECTABLE_ERR_REPORT_EN 0x00000001 /* COR-ERR */
4838 +#define PCIE_RECR_NONFATAL_ERR_REPORT_EN 0x00000002 /* Non-Fatal ERR */
4839 +#define PCIE_RECR_FATAL_ERR_REPORT_EN 0x00000004 /* Fatal ERR */
4840 +#define PCIE_RECR_ERR_REPORT_EN (PCIE_RECR_CORRECTABLE_ERR_REPORT_EN | \
4841 + PCIE_RECR_NONFATAL_ERR_REPORT_EN | PCIE_RECR_FATAL_ERR_REPORT_EN)
4843 +/* Root Error Status Register */
4844 +#define PCIE_RESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x130)
4845 +#define PCIE_RESR_CORRECTABLE_ERR 0x00000001 /* COR-ERR Receveid */
4846 +#define PCIE_RESR_MULTI_CORRECTABLE_ERR 0x00000002 /* Multiple COR-ERR Received */
4847 +#define PCIE_RESR_FATAL_NOFATAL_ERR 0x00000004 /* ERR Fatal/Non-Fatal Received */
4848 +#define PCIE_RESR_MULTI_FATAL_NOFATAL_ERR 0x00000008 /* Multiple ERR Fatal/Non-Fatal Received */
4849 +#define PCIE_RESR_FIRST_UNCORRECTABLE_FATAL_ERR 0x00000010 /* First UN-COR Fatal */
4850 +#define PCIR_RESR_NON_FATAL_ERR 0x00000020 /* Non-Fatal Error Message Received */
4851 +#define PCIE_RESR_FATAL_ERR 0x00000040 /* Fatal Message Received */
4852 +#define PCIE_RESR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
4853 +#define PCIE_RESR_AER_INT_MSG_NUM_S 27
4855 +/* Error Source Indentification Register */
4856 +#define PCIE_ESIR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x134)
4857 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID 0x0000FFFF
4858 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID_S 0
4859 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID 0xFFFF0000
4860 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID_S 16
4862 +/* VC Enhanced Capability Header */
4863 +#define PCIE_VC_ECH(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x140)
4865 +/* Port VC Capability Register */
4866 +#define PCIE_PVC1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x144)
4867 +#define PCIE_PVC1_EXT_VC_CNT 0x00000007 /* Extended VC Count */
4868 +#define PCIE_PVC1_EXT_VC_CNT_S 0
4869 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT 0x00000070 /* Low Priority Extended VC Count */
4870 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT_S 4
4871 +#define PCIE_PVC1_REF_CLK 0x00000300 /* Reference Clock */
4872 +#define PCIE_PVC1_REF_CLK_S 8
4873 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE 0x00000C00 /* Port Arbitration Table Entry Size */
4874 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE_S 10
4876 +/* Extended Virtual Channel Count Defintion */
4877 +#define PCIE_EXT_VC_CNT_MIN 0
4878 +#define PCIE_EXT_VC_CNT_MAX 7
4880 +/* Port Arbitration Table Entry Size Definition */
4882 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S1BIT = 0,
4883 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S2BIT,
4884 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S4BIT,
4885 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S8BIT,
4888 +/* Port VC Capability Register 2 */
4889 +#define PCIE_PVC2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x148)
4890 +#define PCIE_PVC2_VC_ARB_16P_FIXED_WRR 0x00000001 /* HW Fixed arbitration, 16 phase WRR */
4891 +#define PCIE_PVC2_VC_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
4892 +#define PCIE_PVC2_VC_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
4893 +#define PCIE_PVC2_VC_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
4894 +#define PCIE_PVC2_VC_ARB_WRR 0x0000000F
4895 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET 0xFF000000 /* VC arbitration table offset, not support */
4896 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET_S 24
4898 +/* Port VC Control and Status Register */
4899 +#define PCIE_PVCCRSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14C)
4900 +#define PCIE_PVCCRSR_LOAD_VC_ARB_TAB 0x00000001 /* Load VC Arbitration Table */
4901 +#define PCIE_PVCCRSR_VC_ARB_SEL 0x0000000E /* VC Arbitration Select */
4902 +#define PCIE_PVCCRSR_VC_ARB_SEL_S 1
4903 +#define PCIE_PVCCRSR_VC_ARB_TAB_STATUS 0x00010000 /* Arbitration Status */
4905 +/* VC0 Resource Capability Register */
4906 +#define PCIE_VC0_RC(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x150)
4907 +#define PCIE_VC0_RC_PORT_ARB_HW_FIXED 0x00000001 /* HW Fixed arbitration */
4908 +#define PCIE_VC0_RC_PORT_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
4909 +#define PCIE_VC0_RC_PORT_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
4910 +#define PCIE_VC0_RC_PORT_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
4911 +#define PCIE_VC0_RC_PORT_ARB_TM_128P_WRR 0x00000010 /* Time-based 128 phase WRR */
4912 +#define PCIE_VC0_RC_PORT_ARB_TM_256P_WRR 0x00000020 /* Time-based 256 phase WRR */
4913 +#define PCIE_VC0_RC_PORT_ARB (PCIE_VC0_RC_PORT_ARB_HW_FIXED | PCIE_VC0_RC_PORT_ARB_32P_WRR |\
4914 + PCIE_VC0_RC_PORT_ARB_64P_WRR | PCIE_VC0_RC_PORT_ARB_128P_WRR | \
4915 + PCIE_VC0_RC_PORT_ARB_TM_128P_WRR | PCIE_VC0_RC_PORT_ARB_TM_256P_WRR)
4917 +#define PCIE_VC0_RC_REJECT_SNOOP 0x00008000 /* Reject Snoop Transactioin */
4918 +#define PCIE_VC0_RC_MAX_TIMESLOTS 0x007F0000 /* Maximum time Slots */
4919 +#define PCIE_VC0_RC_MAX_TIMESLOTS_S 16
4920 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET 0xFF000000 /* Port Arbitration Table Offset */
4921 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET_S 24
4923 +/* VC0 Resource Control Register */
4924 +#define PCIE_VC0_RC0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x154)
4925 +#define PCIE_VC0_RC0_TVM0 0x00000001 /* TC0 and VC0 */
4926 +#define PCIE_VC0_RC0_TVM1 0x00000002 /* TC1 and VC1 */
4927 +#define PCIE_VC0_RC0_TVM2 0x00000004 /* TC2 and VC2 */
4928 +#define PCIE_VC0_RC0_TVM3 0x00000008 /* TC3 and VC3 */
4929 +#define PCIE_VC0_RC0_TVM4 0x00000010 /* TC4 and VC4 */
4930 +#define PCIE_VC0_RC0_TVM5 0x00000020 /* TC5 and VC5 */
4931 +#define PCIE_VC0_RC0_TVM6 0x00000040 /* TC6 and VC6 */
4932 +#define PCIE_VC0_RC0_TVM7 0x00000080 /* TC7 and VC7 */
4933 +#define PCIE_VC0_RC0_TC_VC 0x000000FF /* TC/VC mask */
4935 +#define PCIE_VC0_RC0_LOAD_PORT_ARB_TAB 0x00010000 /* Load Port Arbitration Table */
4936 +#define PCIE_VC0_RC0_PORT_ARB_SEL 0x000E0000 /* Port Arbitration Select */
4937 +#define PCIE_VC0_RC0_PORT_ARB_SEL_S 17
4938 +#define PCIE_VC0_RC0_VC_ID 0x07000000 /* VC ID */
4939 +#define PCIE_VC0_RC0_VC_ID_S 24
4940 +#define PCIE_VC0_RC0_VC_EN 0x80000000 /* VC Enable */
4942 +/* VC0 Resource Status Register */
4943 +#define PCIE_VC0_RSR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x158)
4944 +#define PCIE_VC0_RSR0_PORT_ARB_TAB_STATUS 0x00010000 /* Port Arbitration Table Status,not used */
4945 +#define PCIE_VC0_RSR0_VC_NEG_PENDING 0x00020000 /* VC Negotiation Pending */
4947 +/* Ack Latency Timer and Replay Timer Register */
4948 +#define PCIE_ALTRT(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x700)
4949 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT 0x0000FFFF /* Round Trip Latency Time Limit */
4950 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT_S 0
4951 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT 0xFFFF0000 /* Replay Time Limit */
4952 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT_S 16
4954 +/* Other Message Register */
4955 +#define PCIE_OMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x704)
4957 +/* Port Force Link Register */
4958 +#define PCIE_PFLR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x708)
4959 +#define PCIE_PFLR_LINK_NUM 0x000000FF /* Link Number */
4960 +#define PCIE_PFLR_LINK_NUM_S 0
4961 +#define PCIE_PFLR_FORCE_LINK 0x00008000 /* Force link */
4962 +#define PCIE_PFLR_LINK_STATE 0x003F0000 /* Link State */
4963 +#define PCIE_PFLR_LINK_STATE_S 16
4964 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT 0xFF000000 /* Low Power Entrance Count, only for EP */
4965 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT_S 24
4967 +/* Ack Frequency Register */
4968 +#define PCIE_AFR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70C)
4969 +#define PCIE_AFR_AF 0x000000FF /* Ack Frequency */
4970 +#define PCIE_AFR_AF_S 0
4971 +#define PCIE_AFR_FTS_NUM 0x0000FF00 /* The number of Fast Training Sequence from L0S to L0 */
4972 +#define PCIE_AFR_FTS_NUM_S 8
4973 +#define PCIE_AFR_COM_FTS_NUM 0x00FF0000 /* N_FTS; when common clock is used*/
4974 +#define PCIE_AFR_COM_FTS_NUM_S 16
4975 +#define PCIE_AFR_L0S_ENTRY_LATENCY 0x07000000 /* L0s Entrance Latency */
4976 +#define PCIE_AFR_L0S_ENTRY_LATENCY_S 24
4977 +#define PCIE_AFR_L1_ENTRY_LATENCY 0x38000000 /* L1 Entrance Latency */
4978 +#define PCIE_AFR_L1_ENTRY_LATENCY_S 27
4979 +#define PCIE_AFR_FTS_NUM_DEFAULT 32
4980 +#define PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT 7
4981 +#define PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT 5
4983 +/* Port Link Control Register */
4984 +#define PCIE_PLCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x710)
4985 +#define PCIE_PLCR_OTHER_MSG_REQ 0x00000001 /* Other Message Request */
4986 +#define PCIE_PLCR_SCRAMBLE_DISABLE 0x00000002 /* Scramble Disable */
4987 +#define PCIE_PLCR_LOOPBACK_EN 0x00000004 /* Loopback Enable */
4988 +#define PCIE_PLCR_LTSSM_HOT_RST 0x00000008 /* Force LTSSM to the hot reset */
4989 +#define PCIE_PLCR_DLL_LINK_EN 0x00000020 /* Enable Link initialization */
4990 +#define PCIE_PLCR_FAST_LINK_SIM_EN 0x00000080 /* Sets all internal timers to fast mode for simulation purposes */
4991 +#define PCIE_PLCR_LINK_MODE 0x003F0000 /* Link Mode Enable Mask */
4992 +#define PCIE_PLCR_LINK_MODE_S 16
4993 +#define PCIE_PLCR_CORRUPTED_CRC_EN 0x02000000 /* Enabled Corrupt CRC */
4995 +/* Lane Skew Register */
4996 +#define PCIE_LSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x714)
4997 +#define PCIE_LSR_LANE_SKEW_NUM 0x00FFFFFF /* Insert Lane Skew for Transmit, not applicable */
4998 +#define PCIE_LSR_LANE_SKEW_NUM_S 0
4999 +#define PCIE_LSR_FC_DISABLE 0x01000000 /* Disable of Flow Control */
5000 +#define PCIE_LSR_ACKNAK_DISABLE 0x02000000 /* Disable of Ack/Nak */
5001 +#define PCIE_LSR_LANE_DESKEW_DISABLE 0x80000000 /* Disable of Lane-to-Lane Skew */
5003 +/* Symbol Number Register */
5004 +#define PCIE_SNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x718)
5005 +#define PCIE_SNR_TS 0x0000000F /* Number of TS Symbol */
5006 +#define PCIE_SNR_TS_S 0
5007 +#define PCIE_SNR_SKP 0x00000700 /* Number of SKP Symbol */
5008 +#define PCIE_SNR_SKP_S 8
5009 +#define PCIE_SNR_REPLAY_TIMER 0x0007C000 /* Timer Modifier for Replay Timer */
5010 +#define PCIE_SNR_REPLAY_TIMER_S 14
5011 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER 0x00F80000 /* Timer Modifier for Ack/Nak Latency Timer */
5012 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER_S 19
5013 +#define PCIE_SNR_FC_TIMER 0x1F000000 /* Timer Modifier for Flow Control Watchdog Timer */
5014 +#define PCIE_SNR_FC_TIMER_S 28
5016 +/* Symbol Timer Register and Filter Mask Register 1 */
5017 +#define PCIE_STRFMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x71C)
5018 +#define PCIE_STRFMR_SKP_INTERVAL 0x000007FF /* SKP lnterval Value */
5019 +#define PCIE_STRFMR_SKP_INTERVAL_S 0
5020 +#define PCIE_STRFMR_FC_WDT_DISABLE 0x00008000 /* Disable of FC Watchdog Timer */
5021 +#define PCIE_STRFMR_TLP_FUNC_MISMATCH_OK 0x00010000 /* Mask Function Mismatch Filtering for Incoming Requests */
5022 +#define PCIE_STRFMR_POISONED_TLP_OK 0x00020000 /* Mask Poisoned TLP Filtering */
5023 +#define PCIE_STRFMR_BAR_MATCH_OK 0x00040000 /* Mask BAR Match Filtering */
5024 +#define PCIE_STRFMR_TYPE1_CFG_REQ_OK 0x00080000 /* Mask Type 1 Configuration Request Filtering */
5025 +#define PCIE_STRFMR_LOCKED_REQ_OK 0x00100000 /* Mask Locked Request Filtering */
5026 +#define PCIE_STRFMR_CPL_TAG_ERR_RULES_OK 0x00200000 /* Mask Tag Error Rules for Received Completions */
5027 +#define PCIE_STRFMR_CPL_REQUESTOR_ID_MISMATCH_OK 0x00400000 /* Mask Requester ID Mismatch Error for Received Completions */
5028 +#define PCIE_STRFMR_CPL_FUNC_MISMATCH_OK 0x00800000 /* Mask Function Mismatch Error for Received Completions */
5029 +#define PCIE_STRFMR_CPL_TC_MISMATCH_OK 0x01000000 /* Mask Traffic Class Mismatch Error for Received Completions */
5030 +#define PCIE_STRFMR_CPL_ATTR_MISMATCH_OK 0x02000000 /* Mask Attribute Mismatch Error for Received Completions */
5031 +#define PCIE_STRFMR_CPL_LENGTH_MISMATCH_OK 0x04000000 /* Mask Length Mismatch Error for Received Completions */
5032 +#define PCIE_STRFMR_TLP_ECRC_ERR_OK 0x08000000 /* Mask ECRC Error Filtering */
5033 +#define PCIE_STRFMR_CPL_TLP_ECRC_OK 0x10000000 /* Mask ECRC Error Filtering for Completions */
5034 +#define PCIE_STRFMR_RX_TLP_MSG_NO_DROP 0x20000000 /* Send Message TLPs */
5035 +#define PCIE_STRFMR_RX_IO_TRANS_ENABLE 0x40000000 /* Mask Filtering of received I/O Requests */
5036 +#define PCIE_STRFMR_RX_CFG_TRANS_ENABLE 0x80000000 /* Mask Filtering of Received Configuration Requests */
5038 +#define PCIE_DEF_SKP_INTERVAL 700 /* 1180 ~1538 , 125MHz * 2, 250MHz * 1 */
5040 +/* Filter Masker Register 2 */
5041 +#define PCIE_FMR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x720)
5042 +#define PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1 0x00000001 /* Mask RADM Filtering and Error Handling Rules */
5043 +#define PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 0x00000002 /* Mask RADM Filtering and Error Handling Rules */
5045 +/* Debug Register 0 */
5046 +#define PCIE_DBR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x728)
5048 +/* Debug Register 1 */
5049 +#define PCIE_DBR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x72C)
5051 +/* Transmit Posted FC Credit Status Register */
5052 +#define PCIE_TPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x730)
5053 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS 0x00000FFF /* Transmit Posted Data FC Credits */
5054 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS_S 0
5055 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS 0x000FF000 /* Transmit Posted Header FC Credits */
5056 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS_S 12
5058 +/* Transmit Non-Posted FC Credit Status */
5059 +#define PCIE_TNPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x734)
5060 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS 0x00000FFF /* Transmit Non-Posted Data FC Credits */
5061 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS_S 0
5062 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS 0x000FF000 /* Transmit Non-Posted Header FC Credits */
5063 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS_S 12
5065 +/* Transmit Complete FC Credit Status Register */
5066 +#define PCIE_TCFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x738)
5067 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS 0x00000FFF /* Transmit Completion Data FC Credits */
5068 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS_S 0
5069 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS 0x000FF000 /* Transmit Completion Header FC Credits */
5070 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS_S 12
5072 +/* Queue Status Register */
5073 +#define PCIE_QSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x73C)
5074 +#define PCIE_QSR_WAIT_UPDATE_FC_DLL 0x00000001 /* Received TLP FC Credits Not Returned */
5075 +#define PCIE_QSR_TX_RETRY_BUF_NOT_EMPTY 0x00000002 /* Transmit Retry Buffer Not Empty */
5076 +#define PCIE_QSR_RX_QUEUE_NOT_EMPTY 0x00000004 /* Received Queue Not Empty */
5078 +/* VC Transmit Arbitration Register 1 */
5079 +#define PCIE_VCTAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x740)
5080 +#define PCIE_VCTAR1_WRR_WEIGHT_VC0 0x000000FF /* WRR Weight for VC0 */
5081 +#define PCIE_VCTAR1_WRR_WEIGHT_VC1 0x0000FF00 /* WRR Weight for VC1 */
5082 +#define PCIE_VCTAR1_WRR_WEIGHT_VC2 0x00FF0000 /* WRR Weight for VC2 */
5083 +#define PCIE_VCTAR1_WRR_WEIGHT_VC3 0xFF000000 /* WRR Weight for VC3 */
5085 +/* VC Transmit Arbitration Register 2 */
5086 +#define PCIE_VCTAR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x744)
5087 +#define PCIE_VCTAR2_WRR_WEIGHT_VC4 0x000000FF /* WRR Weight for VC4 */
5088 +#define PCIE_VCTAR2_WRR_WEIGHT_VC5 0x0000FF00 /* WRR Weight for VC5 */
5089 +#define PCIE_VCTAR2_WRR_WEIGHT_VC6 0x00FF0000 /* WRR Weight for VC6 */
5090 +#define PCIE_VCTAR2_WRR_WEIGHT_VC7 0xFF000000 /* WRR Weight for VC7 */
5092 +/* VC0 Posted Receive Queue Control Register */
5093 +#define PCIE_VC0_PRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x748)
5094 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS 0x00000FFF /* VC0 Posted Data Credits */
5095 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS_S 0
5096 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS 0x000FF000 /* VC0 Posted Header Credits */
5097 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS_S 12
5098 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE 0x00E00000 /* VC0 Posted TLP Queue Mode */
5099 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE_S 20
5100 +#define PCIE_VC0_PRQCR_TLP_RELAX_ORDER 0x40000000 /* TLP Type Ordering for VC0 */
5101 +#define PCIE_VC0_PRQCR_VC_STRICT_ORDER 0x80000000 /* VC0 Ordering for Receive Queues */
5103 +/* VC0 Non-Posted Receive Queue Control */
5104 +#define PCIE_VC0_NPRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74C)
5105 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS 0x00000FFF /* VC0 Non-Posted Data Credits */
5106 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS_S 0
5107 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS 0x000FF000 /* VC0 Non-Posted Header Credits */
5108 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS_S 12
5109 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE 0x00E00000 /* VC0 Non-Posted TLP Queue Mode */
5110 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE_S 20
5112 +/* VC0 Completion Receive Queue Control */
5113 +#define PCIE_VC0_CRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x750)
5114 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS 0x00000FFF /* VC0 Completion TLP Queue Mode */
5115 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS_S 0
5116 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS 0x000FF000 /* VC0 Completion Header Credits */
5117 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS_S 12
5118 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE 0x00E00000 /* VC0 Completion Data Credits */
5119 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE_S 21
5121 +/* Applicable to the above three registers */
5123 + PCIE_VC0_TLP_QUEUE_MODE_STORE_FORWARD = 1,
5124 + PCIE_VC0_TLP_QUEUE_MODE_CUT_THROUGH = 2,
5125 + PCIE_VC0_TLP_QUEUE_MODE_BYPASS = 4,
5128 +/* VC0 Posted Buffer Depth Register */
5129 +#define PCIE_VC0_PBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7A8)
5130 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Posted Data Queue Depth */
5131 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES_S 0
5132 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Posted Header Queue Depth */
5133 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES_S 16
5135 +/* VC0 Non-Posted Buffer Depth Register */
5136 +#define PCIE_VC0_NPBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7AC)
5137 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Non-Posted Data Queue Depth */
5138 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES_S 0
5139 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Non-Posted Header Queue Depth */
5140 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES_S 16
5142 +/* VC0 Completion Buffer Depth Register */
5143 +#define PCIE_VC0_CBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7B0)
5144 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES 0x00003FFF /* C0 Completion Data Queue Depth */
5145 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES_S 0
5146 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Completion Header Queue Depth */
5147 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES_S 16
5149 +/* PHY Status Register, all zeros in VR9 */
5150 +#define PCIE_PHYSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x810)
5152 +/* PHY Control Register, all zeros in VR9 */
5153 +#define PCIE_PHYCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x814)
5156 + * PCIe PDI PHY register definition, suppose all the following
5157 + * stuff is confidential.
5158 + * XXX, detailed bit definition
5160 +#define PCIE_PHY_PLL_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x22 << 1))
5161 +#define PCIE_PHY_PLL_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x23 << 1))
5162 +#define PCIE_PHY_PLL_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x24 << 1))
5163 +#define PCIE_PHY_PLL_CTRL4(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x25 << 1))
5164 +#define PCIE_PHY_PLL_CTRL5(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x26 << 1))
5165 +#define PCIE_PHY_PLL_CTRL6(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x27 << 1))
5166 +#define PCIE_PHY_PLL_CTRL7(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x28 << 1))
5167 +#define PCIE_PHY_PLL_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x29 << 1))
5168 +#define PCIE_PHY_PLL_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2A << 1))
5169 +#define PCIE_PHY_PLL_A_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2B << 1))
5170 +#define PCIE_PHY_PLL_STATUS(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2C << 1))
5172 +#define PCIE_PHY_TX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x30 << 1))
5173 +#define PCIE_PHY_TX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x31 << 1))
5174 +#define PCIE_PHY_TX1_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x32 << 1))
5175 +#define PCIE_PHY_TX1_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x33 << 1))
5176 +#define PCIE_PHY_TX1_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x34 << 1))
5177 +#define PCIE_PHY_TX1_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x35 << 1))
5178 +#define PCIE_PHY_TX1_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x36 << 1))
5179 +#define PCIE_PHY_TX1_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x37 << 1))
5181 +#define PCIE_PHY_TX2_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x38 << 1))
5182 +#define PCIE_PHY_TX2_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x39 << 1))
5183 +#define PCIE_PHY_TX2_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3B << 1))
5184 +#define PCIE_PHY_TX2_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3C << 1))
5185 +#define PCIE_PHY_TX2_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3D << 1))
5186 +#define PCIE_PHY_TX2_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3E << 1))
5187 +#define PCIE_PHY_TX2_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3F << 1))
5189 +#define PCIE_PHY_RX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x50 << 1))
5190 +#define PCIE_PHY_RX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x51 << 1))
5191 +#define PCIE_PHY_RX1_CDR(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x52 << 1))
5192 +#define PCIE_PHY_RX1_EI(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x53 << 1))
5193 +#define PCIE_PHY_RX1_A_CTRL(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x55 << 1))
5195 +/* Interrupt related stuff */
5196 +#define PCIE_LEGACY_DISABLE 0
5197 +#define PCIE_LEGACY_INTA 1
5198 +#define PCIE_LEGACY_INTB 2
5199 +#define PCIE_LEGACY_INTC 3
5200 +#define PCIE_LEGACY_INTD 4
5201 +#define PCIE_LEGACY_INT_MAX PCIE_LEGACY_INTD
5203 +#define PCIE_IRQ_LOCK(lock) do { \
5204 + unsigned long flags; \
5205 + spin_lock_irqsave(&(lock), flags);
5206 +#define PCIE_IRQ_UNLOCK(lock) \
5207 + spin_unlock_irqrestore(&(lock), flags); \
5210 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
5211 +#define IRQF_SHARED SA_SHIRQ
5214 +#define PCIE_MSG_MSI 0x00000001
5215 +#define PCIE_MSG_ISR 0x00000002
5216 +#define PCIE_MSG_FIXUP 0x00000004
5217 +#define PCIE_MSG_READ_CFG 0x00000008
5218 +#define PCIE_MSG_WRITE_CFG 0x00000010
5219 +#define PCIE_MSG_CFG (PCIE_MSG_READ_CFG | PCIE_MSG_WRITE_CFG)
5220 +#define PCIE_MSG_REG 0x00000020
5221 +#define PCIE_MSG_INIT 0x00000040
5222 +#define PCIE_MSG_ERR 0x00000080
5223 +#define PCIE_MSG_PHY 0x00000100
5224 +#define PCIE_MSG_ANY 0x000001ff
5226 +#define IFX_PCIE_PORT0 0
5227 +#define IFX_PCIE_PORT1 1
5229 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
5230 +#define IFX_PCIE_CORE_NR 2
5232 +#define IFX_PCIE_CORE_NR 1
5235 +//#define IFX_PCIE_ERROR_INT
5237 +//#define IFX_PCIE_DBG
5239 +#if defined(IFX_PCIE_DBG)
5240 +#define IFX_PCIE_PRINT(_m, _fmt, args...) do { \
5241 + if (g_pcie_debug_flag & (_m)) { \
5242 + ifx_pcie_debug((_fmt), ##args); \
5248 +#define IFX_PCIE_PRINT(_m, _fmt, args...) \
5250 +#define INLINE inline
5253 +struct ifx_pci_controller {
5254 + struct pci_controller pcic;
5256 + /* RC specific, per host bus information */
5257 + u32 port; /* Port index, 0 -- 1st core, 1 -- 2nd core */
5260 +typedef struct ifx_pcie_ir_irq {
5261 + const unsigned int irq;
5262 + const char name[16];
5263 +}ifx_pcie_ir_irq_t;
5265 +typedef struct ifx_pcie_legacy_irq{
5266 + const u32 irq_bit;
5268 +}ifx_pcie_legacy_irq_t;
5270 +typedef struct ifx_pcie_irq {
5271 + ifx_pcie_ir_irq_t ir_irq;
5272 + ifx_pcie_legacy_irq_t legacy_irq[PCIE_LEGACY_INT_MAX];
5275 +extern u32 g_pcie_debug_flag;
5276 +extern void ifx_pcie_debug(const char *fmt, ...);
5277 +extern void pcie_phy_clock_mode_setup(int pcie_port);
5278 +extern void pcie_msi_pic_init(int pcie_port);
5279 +extern u32 ifx_pcie_bus_enum_read_hack(int where, u32 value);
5280 +extern u32 ifx_pcie_bus_enum_write_hack(int where, u32 value);
5283 +#include <linux/types.h>
5284 +#include <linux/delay.h>
5285 +#include <linux/gpio.h>
5286 +#include <linux/clk.h>
5288 +#include <lantiq_soc.h>
5290 +#define IFX_PCIE_GPIO_RESET 38
5291 +#define IFX_REG_R32 ltq_r32
5292 +#define IFX_REG_W32 ltq_w32
5293 +#define CONFIG_IFX_PCIE_HW_SWAP
5294 +#define IFX_RCU_AHB_ENDIAN ((volatile u32*)(IFX_RCU + 0x004C))
5295 +#define IFX_RCU_RST_REQ ((volatile u32*)(IFX_RCU + 0x0010))
5296 +#define IFX_RCU_AHB_BE_PCIE_PDI 0x00000080 /* Configure PCIE PDI module in big endian*/
5298 +#define IFX_RCU (KSEG1 | 0x1F203000)
5299 +#define IFX_RCU_AHB_BE_PCIE_M 0x00000001 /* Configure AHB master port that connects to PCIe RC in big endian */
5300 +#define IFX_RCU_AHB_BE_PCIE_S 0x00000010 /* Configure AHB slave port that connects to PCIe RC in little endian */
5301 +#define IFX_RCU_AHB_BE_XBAR_M 0x00000002 /* Configure AHB master port that connects to XBAR in big endian */
5302 +#define CONFIG_IFX_PCIE_PHY_36MHZ_MODE
5304 +#define IFX_PMU1_MODULE_PCIE_PHY (0)
5305 +#define IFX_PMU1_MODULE_PCIE_CTRL (1)
5306 +#define IFX_PMU1_MODULE_PDI (4)
5307 +#define IFX_PMU1_MODULE_MSI (5)
5309 +#define IFX_PMU_MODULE_PCIE_L0_CLK (31)
5312 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
5316 +static inline void pcie_ahb_pmu_setup(void)
5319 + clk = clk_get_sys("ltq_pcie", "ahb");
5321 + //ltq_pmu_enable(PMU_AHBM | PMU_AHBS);
5324 +static inline void pcie_rcu_endian_setup(int pcie_port)
5328 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
5329 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
5330 + reg |= IFX_RCU_AHB_BE_PCIE_M;
5331 + reg |= IFX_RCU_AHB_BE_PCIE_S;
5332 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
5334 + reg |= IFX_RCU_AHB_BE_PCIE_M;
5335 + reg &= ~IFX_RCU_AHB_BE_PCIE_S;
5336 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
5337 +#endif /* CONFIG_IFX_PCIE_HW_SWAP */
5338 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
5339 + IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
5342 +static inline void pcie_phy_pmu_enable(int pcie_port)
5345 + clk = clk_get_sys("ltq_pcie", "phy");
5347 + //ltq_pmu1_enable(1<<IFX_PMU1_MODULE_PCIE_PHY);
5350 +static inline void pcie_phy_pmu_disable(int pcie_port)
5353 + clk = clk_get_sys("ltq_pcie", "phy");
5355 + //ltq_pmu1_disable(1<<IFX_PMU1_MODULE_PCIE_PHY);
5358 +static inline void pcie_pdi_big_endian(int pcie_port)
5362 + /* SRAM2PDI endianness control. */
5363 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
5364 + /* Config AHB->PCIe and PDI endianness */
5365 + reg |= IFX_RCU_AHB_BE_PCIE_PDI;
5366 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
5369 +static inline void pcie_pdi_pmu_enable(int pcie_port)
5372 + clk = clk_get_sys("ltq_pcie", "pdi");
5374 + //ltq_pmu1_enable(1<<IFX_PMU1_MODULE_PDI);
5377 +static inline void pcie_core_rst_assert(int pcie_port)
5381 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5383 + /* Reset PCIe PHY & Core, bit 22, bit 26 may be affected if write it directly */
5384 + reg |= 0x00400000;
5385 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5388 +static inline void pcie_core_rst_deassert(int pcie_port)
5392 + /* Make sure one micro-second delay */
5395 + /* Reset PCIe PHY & Core, bit 22 */
5396 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5397 + reg &= ~0x00400000;
5398 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5401 +static inline void pcie_phy_rst_assert(int pcie_port)
5405 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5406 + reg |= 0x00001000; /* Bit 12 */
5407 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5410 +static inline void pcie_phy_rst_deassert(int pcie_port)
5414 + /* Make sure one micro-second delay */
5417 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5418 + reg &= ~0x00001000; /* Bit 12 */
5419 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5422 +static inline void pcie_device_rst_assert(int pcie_port)
5424 + gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
5425 + // ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
5428 +static inline void pcie_device_rst_deassert(int pcie_port)
5431 + gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
5432 +// ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
5435 +static inline void pcie_core_pmu_setup(int pcie_port)
5438 + clk = clk_get_sys("ltq_pcie", "ctl");
5440 + clk = clk_get_sys("ltq_pcie", "bus");
5443 + //ltq_pmu1_enable(1 << IFX_PMU1_MODULE_PCIE_CTRL);
5444 + //ltq_pmu_enable(1 << IFX_PMU_MODULE_PCIE_L0_CLK);
5447 +static inline void pcie_msi_init(int pcie_port)
5450 + pcie_msi_pic_init(pcie_port);
5451 + clk = clk_get_sys("ltq_pcie", "msi");
5453 + //ltq_pmu1_enable(1 << IFX_PMU1_MODULE_MSI);
5457 +ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
5459 + u32 tbus_number = bus_number;
5461 +#ifdef CONFIG_PCI_LANTIQ
5462 + if (pcibios_host_nr() > 1) {
5463 + tbus_number -= pcibios_1st_host_bus_nr();
5465 +#endif /* CONFIG_PCI_LANTIQ */
5466 + return tbus_number;
5470 +ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
5472 + struct pci_dev *pdev;
5473 + u32 tvalue = value;
5475 + /* Sanity check */
5476 + pdev = pci_get_slot(bus, devfn);
5477 + if (pdev == NULL) {
5481 + /* Only care about PCI bridge */
5482 + if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
5486 + if (read) { /* Read hack */
5487 + #ifdef CONFIG_PCI_LANTIQ
5488 + if (pcibios_host_nr() > 1) {
5489 + tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
5491 + #endif /* CONFIG_PCI_LANTIQ */
5493 + else { /* Write hack */
5494 + #ifdef CONFIG_PCI_LANTIQ
5495 + if (pcibios_host_nr() > 1) {
5496 + tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
5503 +#endif /* IFXMIPS_PCIE_VR9_H */
5505 --- a/drivers/pci/pcie/aer/Kconfig
5506 +++ b/drivers/pci/pcie/aer/Kconfig
5507 @@ -19,6 +19,7 @@ config PCIEAER
5509 bool "PCI Express ECRC settings control"
5513 Used to override firmware/bios settings for PCI Express ECRC
5514 (transaction layer end-to-end CRC checking).
5515 --- a/include/linux/pci.h
5516 +++ b/include/linux/pci.h
5517 @@ -1179,6 +1179,8 @@ void pci_walk_bus(struct pci_bus *top, i
5519 int pci_cfg_space_size(struct pci_dev *dev);
5520 unsigned char pci_bus_max_busnr(struct pci_bus *bus);
5521 +int pcibios_host_nr(void);
5522 +int pcibios_1st_host_bus_nr(void);
5523 void pci_setup_bridge(struct pci_bus *bus);
5524 resource_size_t pcibios_window_alignment(struct pci_bus *bus,
5525 unsigned long type);
5526 --- a/include/linux/pci_ids.h
5527 +++ b/include/linux/pci_ids.h
5528 @@ -1053,6 +1053,12 @@
5529 #define PCI_DEVICE_ID_SGI_LITHIUM 0x1002
5530 #define PCI_DEVICE_ID_SGI_IOC4 0x100a
5532 +#define PCI_VENDOR_ID_INFINEON 0x15D1
5533 +#define PCI_DEVICE_ID_INFINEON_DANUBE 0x000F
5534 +#define PCI_DEVICE_ID_INFINEON_PCIE 0x0011
5535 +#define PCI_VENDOR_ID_LANTIQ 0x1BEF
5536 +#define PCI_DEVICE_ID_LANTIQ_PCIE 0x00
5538 #define PCI_VENDOR_ID_WINBOND 0x10ad
5539 #define PCI_DEVICE_ID_WINBOND_82C105 0x0105
5540 #define PCI_DEVICE_ID_WINBOND_83C553 0x0565