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 diff --git a/arch/mips/lantiq/Kconfig b/arch/mips/lantiq/Kconfig
43 index c002191..1621b1d 100644
44 --- a/arch/mips/lantiq/Kconfig
45 +++ b/arch/mips/lantiq/Kconfig
46 @@ -17,6 +17,7 @@ config SOC_XWAY
50 + select ARCH_SUPPORTS_MSI
54 @@ -36,6 +37,15 @@ config PCI_LANTIQ
56 depends on SOC_XWAY && PCI
60 + depends on SOC_XWAY && PCI
62 +config PCIE_LANTIQ_MSI
64 + depends on PCIE_LANTIQ && PCI_MSI
68 bool "XRX200 PHY firmware loader"
70 diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c
71 index 51804b1..510a387 100644
72 --- a/arch/mips/lantiq/xway/sysctrl.c
73 +++ b/arch/mips/lantiq/xway/sysctrl.c
74 @@ -377,6 +377,8 @@ void __init ltq_soc_init(void)
75 PMU_PPE_EMA | PMU_PPE_TC | PMU_PPE_SLL01 |
76 PMU_PPE_QSB | PMU_PPE_TOP);
77 clkdev_add_pmu("1f203000.rcu", "gphy", 0, PMU_GPHY);
78 + pmu_w32(~0, PMU_PWDSR1);
79 + pmu_w32(pmu_r32(PMU_PWDSR) & ~PMU_PCIE_CLK, PMU_PWDSR);
80 } else if (of_machine_is_compatible("lantiq,ar9")) {
81 clkdev_add_static(ltq_ar9_cpu_hz(), ltq_ar9_fpi_hz(),
82 ltq_ar9_fpi_hz(), CLOCK_250M);
83 diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
84 index 137f2a6..1e1726f 100644
85 --- a/arch/mips/pci/Makefile
86 +++ b/arch/mips/pci/Makefile
87 @@ -42,6 +42,8 @@ obj-$(CONFIG_SNI_RM) += fixup-sni.o ops-sni.o
88 obj-$(CONFIG_LANTIQ) += fixup-lantiq.o
89 obj-$(CONFIG_PCI_LANTIQ) += pci-lantiq.o ops-lantiq.o
90 obj-$(CONFIG_SOC_RT3883) += pci-rt3883.o
91 +obj-$(CONFIG_PCIE_LANTIQ) += ifxmips_pcie_phy.o ifxmips_pcie.o fixup-lantiq-pcie.o
92 +obj-$(CONFIG_PCIE_LANTIQ_MSI) += pcie-lantiq-msi.o
93 obj-$(CONFIG_TANBAC_TB0219) += fixup-tb0219.o
94 obj-$(CONFIG_TANBAC_TB0226) += fixup-tb0226.o
95 obj-$(CONFIG_TANBAC_TB0287) += fixup-tb0287.o
96 diff --git a/arch/mips/pci/fixup-lantiq-pcie.c b/arch/mips/pci/fixup-lantiq-pcie.c
98 index 0000000..3325e24
100 +++ b/arch/mips/pci/fixup-lantiq-pcie.c
102 +/******************************************************************************
104 +** FILE NAME : ifxmips_fixup_pcie.c
105 +** PROJECT : IFX UEIP for VRX200
108 +** DATE : 02 Mar 2009
109 +** AUTHOR : Lei Chuanhua
110 +** DESCRIPTION : PCIe Root Complex Driver
111 +** COPYRIGHT : Copyright (c) 2009
112 +** Infineon Technologies AG
113 +** Am Campeon 1-12, 85579 Neubiberg, Germany
115 +** This program is free software; you can redistribute it and/or modify
116 +** it under the terms of the GNU General Public License as published by
117 +** the Free Software Foundation; either version 2 of the License, or
118 +** (at your option) any later version.
120 +** $Version $Date $Author $Comment
121 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
122 +*******************************************************************************/
124 + \file ifxmips_fixup_pcie.c
126 + \brief PCIe Fixup functions source file
128 +#include <linux/pci.h>
129 +#include <linux/pci_regs.h>
130 +#include <linux/pci_ids.h>
132 +#include <lantiq_soc.h>
134 +#include "pcie-lantiq.h"
136 +#define PCI_VENDOR_ID_INFINEON 0x15D1
137 +#define PCI_DEVICE_ID_INFINEON_DANUBE 0x000F
138 +#define PCI_DEVICE_ID_INFINEON_PCIE 0x0011
139 +#define PCI_VENDOR_ID_LANTIQ 0x1BEF
140 +#define PCI_DEVICE_ID_LANTIQ_PCIE 0x0011
145 +ifx_pcie_fixup_resource(struct pci_dev *dev)
149 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: enter\n", __func__, pci_name(dev));
151 + printk("%s: fixup host controller %s (%04x:%04x)\n",
152 + __func__, pci_name(dev), dev->vendor, dev->device);
154 + /* Setup COMMAND register */
155 + reg = PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER /* |
156 + PCI_COMMAND_INTX_DISABLE */| PCI_COMMAND_SERR;
157 + pci_write_config_word(dev, PCI_COMMAND, reg);
158 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: exit\n", __func__, pci_name(dev));
160 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INFINEON, PCI_DEVICE_ID_INFINEON_PCIE, ifx_pcie_fixup_resource);
161 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LANTIQ, PCI_VENDOR_ID_LANTIQ, ifx_pcie_fixup_resource);
164 +ifx_pcie_rc_class_early_fixup(struct pci_dev *dev)
166 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: enter\n", __func__, pci_name(dev));
168 + if (dev->devfn == PCI_DEVFN(0, 0) &&
169 + (dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) {
171 + dev->class = (PCI_CLASS_BRIDGE_PCI << 8) | (dev->class & 0xff);
173 + printk(KERN_INFO "%s: fixed pcie host bridge to pci-pci bridge\n", __func__);
175 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: exit\n", __func__, pci_name(dev));
179 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INFINEON, PCI_DEVICE_ID_INFINEON_PCIE,
180 + ifx_pcie_rc_class_early_fixup);
182 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LANTIQ, PCI_DEVICE_ID_LANTIQ_PCIE,
183 + ifx_pcie_rc_class_early_fixup);
184 diff --git a/arch/mips/pci/fixup-lantiq.c b/arch/mips/pci/fixup-lantiq.c
185 index c2ce41e..c110c10 100644
186 --- a/arch/mips/pci/fixup-lantiq.c
187 +++ b/arch/mips/pci/fixup-lantiq.c
190 int (*ltq_pci_plat_arch_init)(struct pci_dev *dev) = NULL;
191 int (*ltq_pci_plat_dev_init)(struct pci_dev *dev) = NULL;
192 +int (*ltq_pci_map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
194 int pcibios_plat_dev_init(struct pci_dev *dev)
196 if (ltq_pci_plat_arch_init)
197 - return ltq_pci_plat_arch_init(dev);
198 + ltq_pci_plat_arch_init(dev);
200 if (ltq_pci_plat_dev_init)
201 return ltq_pci_plat_dev_init(dev);
202 @@ -25,5 +26,7 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
204 int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
206 + if (ltq_pci_map_irq)
207 + return ltq_pci_map_irq(dev, slot, pin);
208 return of_irq_parse_and_map_pci(dev, slot, pin);
210 diff --git a/arch/mips/pci/ifxmips_pci_common.h b/arch/mips/pci/ifxmips_pci_common.h
212 index 0000000..46f4cb2
214 +++ b/arch/mips/pci/ifxmips_pci_common.h
216 +/******************************************************************************
218 +** FILE NAME : ifxmips_pci_common.h
219 +** PROJECT : IFX UEIP
220 +** MODULES : PCI subsystem
222 +** DATE : 30 June 2009
223 +** AUTHOR : Lei Chuanhua
224 +** DESCRIPTION : PCIe Root Complex Driver
225 +** COPYRIGHT : Copyright (c) 2009
226 +** Infineon Technologies AG
227 +** Am Campeon 1-12, 85579 Neubiberg, Germany
229 +** This program is free software; you can redistribute it and/or modify
230 +** it under the terms of the GNU General Public License as published by
231 +** the Free Software Foundation; either version 2 of the License, or
232 +** (at your option) any later version.
234 +** $Version $Date $Author $Comment
235 +** 0.0.1 30 June,2009 Lei Chuanhua Initial version
236 +*******************************************************************************/
238 +#ifndef IFXMIPS_PCI_COMMON_H
239 +#define IFXMIPS_PCI_COMMON_H
240 +#include <linux/version.h>
242 + \defgroup IFX_PCI_COM IFX PCI/PCIe common parts for OS integration
243 + \brief PCI/PCIe common parts
247 + \defgroup IFX_PCI_COM_OS OS APIs
248 + \ingroup IFX_PCI_COM
249 + \brief PCI/PCIe bus driver OS interface functions
252 + \file ifxmips_pci_common.h
253 + \ingroup IFX_PCI_COM
254 + \brief PCI/PCIe bus driver common OS header file
256 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
257 +#define IFX_PCI_CONST
259 +#define IFX_PCI_CONST const
261 +#ifdef CONFIG_IFX_PCI
262 +extern int ifx_pci_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin);
263 +extern int ifx_pci_bios_plat_dev_init(struct pci_dev *dev);
264 +#endif /* COFNIG_IFX_PCI */
266 +#ifdef CONFIG_IFX_PCIE
267 +extern int ifx_pcie_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin);
268 +extern int ifx_pcie_bios_plat_dev_init(struct pci_dev *dev);
271 +#endif /* IFXMIPS_PCI_COMMON_H */
273 diff --git a/arch/mips/pci/ifxmips_pcie.c b/arch/mips/pci/ifxmips_pcie.c
275 index 0000000..4128898
277 +++ b/arch/mips/pci/ifxmips_pcie.c
280 + * This program is free software; you can redistribute it and/or modify it
281 + * under the terms of the GNU General Public License version 2 as published
282 + * by the Free Software Foundation.
284 + * Copyright (C) 2009 Lei Chuanhua <chuanhua.lei@infineon.com>
285 + * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
288 +#include <linux/types.h>
289 +#include <linux/pci.h>
290 +#include <linux/kernel.h>
291 +#include <linux/init.h>
292 +#include <linux/delay.h>
293 +#include <linux/mm.h>
294 +#include <asm/paccess.h>
295 +#include <linux/pci.h>
296 +#include <linux/pci_regs.h>
297 +#include <linux/module.h>
299 +#include "ifxmips_pcie.h"
300 +#include "ifxmips_pcie_reg.h"
302 +/* Enable 32bit io due to its mem mapped io nature */
303 +#define IFX_PCIE_ERROR_INT
304 +#define IFX_PCIE_IO_32BIT
306 +#define IFX_PCIE_IR (INT_NUM_IM4_IRL0 + 25)
307 +#define IFX_PCIE_INTA (INT_NUM_IM4_IRL0 + 8)
308 +#define IFX_PCIE_INTB (INT_NUM_IM4_IRL0 + 9)
309 +#define IFX_PCIE_INTC (INT_NUM_IM4_IRL0 + 10)
310 +#define IFX_PCIE_INTD (INT_NUM_IM4_IRL0 + 11)
311 +#define MS(_v, _f) (((_v) & (_f)) >> _f##_S)
312 +#define SM(_v, _f) (((_v) << _f##_S) & (_f))
313 +#define IFX_REG_SET_BIT(_f, _r) \
314 + IFX_REG_W32((IFX_REG_R32((_r)) &~ (_f)) | (_f), (_r))
316 +#define IFX_PCIE_LTSSM_ENABLE_TIMEOUT 10
318 +static DEFINE_SPINLOCK(ifx_pcie_lock);
320 +u32 g_pcie_debug_flag = PCIE_MSG_ANY & (~PCIE_MSG_CFG);
322 +static ifx_pcie_irq_t pcie_irqs[IFX_PCIE_CORE_NR] = {
325 + .irq = IFX_PCIE_IR,
326 + .name = "ifx_pcie_rc0",
331 + .irq_bit = PCIE_IRN_INTA,
332 + .irq = IFX_PCIE_INTA,
335 + .irq_bit = PCIE_IRN_INTB,
336 + .irq = IFX_PCIE_INTB,
339 + .irq_bit = PCIE_IRN_INTC,
340 + .irq = IFX_PCIE_INTC,
343 + .irq_bit = PCIE_IRN_INTD,
344 + .irq = IFX_PCIE_INTD,
351 +void ifx_pcie_debug(const char *fmt, ...)
353 + static char buf[256] = {0}; /* XXX */
357 + vsnprintf(buf, sizeof(buf), fmt, ap);
364 +static inline int pcie_ltssm_enable(int pcie_port)
369 + IFX_REG_W32(PCIE_RC_CCR_LTSSM_ENABLE, PCIE_RC_CCR(pcie_port));
371 + /* Wait for the link to come up */
372 + for (i = 0; i < IFX_PCIE_LTSSM_ENABLE_TIMEOUT; i++) {
373 + if (!(IFX_REG_R32(PCIE_LCTLSTS(pcie_port)) & PCIE_LCTLSTS_RETRAIN_PENDING))
378 + printk("%s link timeout!!!!!\n", __func__);
382 +static inline void pcie_status_register_clear(int pcie_port)
384 + IFX_REG_W32(0, PCIE_RC_DR(pcie_port));
385 + IFX_REG_W32(0, PCIE_PCICMDSTS(pcie_port));
386 + IFX_REG_W32(0, PCIE_DCTLSTS(pcie_port));
387 + IFX_REG_W32(0, PCIE_LCTLSTS(pcie_port));
388 + IFX_REG_W32(0, PCIE_SLCTLSTS(pcie_port));
389 + IFX_REG_W32(0, PCIE_RSTS(pcie_port));
390 + IFX_REG_W32(0, PCIE_UES_R(pcie_port));
391 + IFX_REG_W32(0, PCIE_UEMR(pcie_port));
392 + IFX_REG_W32(0, PCIE_UESR(pcie_port));
393 + IFX_REG_W32(0, PCIE_CESR(pcie_port));
394 + IFX_REG_W32(0, PCIE_CEMR(pcie_port));
395 + IFX_REG_W32(0, PCIE_RESR(pcie_port));
396 + IFX_REG_W32(0, PCIE_PVCCRSR(pcie_port));
397 + IFX_REG_W32(0, PCIE_VC0_RSR0(pcie_port));
398 + IFX_REG_W32(0, PCIE_TPFCS(pcie_port));
399 + IFX_REG_W32(0, PCIE_TNPFCS(pcie_port));
400 + IFX_REG_W32(0, PCIE_TCFCS(pcie_port));
401 + IFX_REG_W32(0, PCIE_QSR(pcie_port));
402 + IFX_REG_W32(0, PCIE_IOBLSECS(pcie_port));
405 +static inline int ifx_pcie_link_up(int pcie_port)
407 + return (IFX_REG_R32(PCIE_PHY_SR(pcie_port)) & PCIE_PHY_SR_PHY_LINK_UP) ? 1 : 0;
411 +static inline void pcie_mem_io_setup(int pcie_port)
415 + * BAR[0:1] readonly register
416 + * RC contains only minimal BARs for packets mapped to this device
417 + * Mem/IO filters defines a range of memory occupied by memory mapped IO devices that
418 + * reside on the downstream side fo the bridge.
420 + reg = SM((PCIE_MEM_PHY_PORT_TO_END(pcie_port) >> 20), PCIE_MBML_MEM_LIMIT_ADDR)
421 + | SM((PCIE_MEM_PHY_PORT_TO_BASE(pcie_port) >> 20), PCIE_MBML_MEM_BASE_ADDR);
423 + IFX_REG_W32(reg, PCIE_MBML(pcie_port));
426 +#ifdef IFX_PCIE_PREFETCH_MEM_64BIT
427 + reg = SM((PCIE_MEM_PHY_PORT_TO_END(pcie_port) >> 20), PCIE_PMBL_END_ADDR)
428 + | SM((PCIE_MEM_PHY_PORT_TO_BASE(pcie_port) >> 20), PCIE_PMBL_UPPER_12BIT)
429 + | PCIE_PMBL_64BIT_ADDR;
430 + IFX_REG_W32(reg, PCIE_PMBL(pcie_port));
432 + /* Must configure upper 32bit */
433 + IFX_REG_W32(0, PCIE_PMBU32(pcie_port));
434 + IFX_REG_W32(0, PCIE_PMLU32(pcie_port));
436 + /* PCIe_PBML, same as MBML */
437 + IFX_REG_W32(IFX_REG_R32(PCIE_MBML(pcie_port)), PCIE_PMBL(pcie_port));
440 + /* IO Address Range */
441 + reg = SM((PCIE_IO_PHY_PORT_TO_END(pcie_port) >> 12), PCIE_IOBLSECS_IO_LIMIT_ADDR)
442 + | SM((PCIE_IO_PHY_PORT_TO_BASE(pcie_port) >> 12), PCIE_IOBLSECS_IO_BASE_ADDR);
443 +#ifdef IFX_PCIE_IO_32BIT
444 + reg |= PCIE_IOBLSECS_32BIT_IO_ADDR;
445 +#endif /* IFX_PCIE_IO_32BIT */
446 + IFX_REG_W32(reg, PCIE_IOBLSECS(pcie_port));
448 +#ifdef IFX_PCIE_IO_32BIT
449 + reg = SM((PCIE_IO_PHY_PORT_TO_END(pcie_port) >> 16), PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT)
450 + | SM((PCIE_IO_PHY_PORT_TO_BASE(pcie_port) >> 16), PCIE_IO_BANDL_UPPER_16BIT_IO_BASE);
451 + IFX_REG_W32(reg, PCIE_IO_BANDL(pcie_port));
453 +#endif /* IFX_PCIE_IO_32BIT */
457 +pcie_device_setup(int pcie_port)
461 + /* Device capability register, set up Maximum payload size */
462 + reg = IFX_REG_R32(PCIE_DCAP(pcie_port));
463 + reg |= PCIE_DCAP_ROLE_BASE_ERR_REPORT;
464 + reg |= SM(PCIE_MAX_PAYLOAD_128, PCIE_DCAP_MAX_PAYLOAD_SIZE);
466 + /* Only available for EP */
467 + reg &= ~(PCIE_DCAP_EP_L0S_LATENCY | PCIE_DCAP_EP_L1_LATENCY);
468 + IFX_REG_W32(reg, PCIE_DCAP(pcie_port));
470 + /* Device control and status register */
471 + /* Set Maximum Read Request size for the device as a Requestor */
472 + reg = IFX_REG_R32(PCIE_DCTLSTS(pcie_port));
475 + * Request size can be larger than the MPS used, but the completions returned
476 + * for the read will be bounded by the MPS size.
477 + * In our system, Max request size depends on AHB burst size. It is 64 bytes.
478 + * but we set it as 128 as minimum one.
480 + reg |= SM(PCIE_MAX_PAYLOAD_128, PCIE_DCTLSTS_MAX_READ_SIZE)
481 + | SM(PCIE_MAX_PAYLOAD_128, PCIE_DCTLSTS_MAX_PAYLOAD_SIZE);
483 + /* Enable relaxed ordering, no snoop, and all kinds of errors */
484 + reg |= PCIE_DCTLSTS_RELAXED_ORDERING_EN | PCIE_DCTLSTS_ERR_EN | PCIE_DCTLSTS_NO_SNOOP_EN;
486 + IFX_REG_W32(reg, PCIE_DCTLSTS(pcie_port));
490 +pcie_link_setup(int pcie_port)
495 + * XXX, Link capability register, bit 18 for EP CLKREQ# dynamic clock management for L1, L2/3 CPM
496 + * L0s is reported during link training via TS1 order set by N_FTS
498 + reg = IFX_REG_R32(PCIE_LCAP(pcie_port));
499 + reg &= ~PCIE_LCAP_L0S_EIXT_LATENCY;
500 + reg |= SM(3, PCIE_LCAP_L0S_EIXT_LATENCY);
501 + IFX_REG_W32(reg, PCIE_LCAP(pcie_port));
503 + /* Link control and status register */
504 + reg = IFX_REG_R32(PCIE_LCTLSTS(pcie_port));
506 + /* Link Enable, ASPM enabled */
507 + reg &= ~PCIE_LCTLSTS_LINK_DISABLE;
509 +#ifdef CONFIG_PCIEASPM
511 + * We use the same physical reference clock that the platform provides on the connector
512 + * It paved the way for ASPM to calculate the new exit Latency
514 + reg |= PCIE_LCTLSTS_SLOT_CLK_CFG;
515 + reg |= PCIE_LCTLSTS_COM_CLK_CFG;
517 + * We should disable ASPM by default except that we have dedicated power management support
518 + * Enable ASPM will cause the system hangup/instability, performance degration
520 + reg |= PCIE_LCTLSTS_ASPM_ENABLE;
522 + reg &= ~PCIE_LCTLSTS_ASPM_ENABLE;
523 +#endif /* CONFIG_PCIEASPM */
526 + * The maximum size of any completion with data packet is bounded by the MPS setting
527 + * in device control register
530 + /* RCB may cause multiple split transactions, two options available, we use 64 byte RCB */
531 + reg &= ~ PCIE_LCTLSTS_RCB128;
533 + IFX_REG_W32(reg, PCIE_LCTLSTS(pcie_port));
536 +static inline void pcie_error_setup(int pcie_port)
541 + * Forward ERR_COR, ERR_NONFATAL, ERR_FATAL to the backbone
542 + * Poisoned write TLPs and completions indicating poisoned TLPs will set the PCIe_PCICMDSTS.MDPE
544 + reg = IFX_REG_R32(PCIE_INTRBCTRL(pcie_port));
545 + reg |= PCIE_INTRBCTRL_SERR_ENABLE | PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE;
547 + IFX_REG_W32(reg, PCIE_INTRBCTRL(pcie_port));
549 + /* Uncorrectable Error Mask Register, Unmask <enable> all bits in PCIE_UESR */
550 + reg = IFX_REG_R32(PCIE_UEMR(pcie_port));
551 + reg &= ~PCIE_ALL_UNCORRECTABLE_ERR;
552 + IFX_REG_W32(reg, PCIE_UEMR(pcie_port));
554 + /* Uncorrectable Error Severity Register, ALL errors are FATAL */
555 + IFX_REG_W32(PCIE_ALL_UNCORRECTABLE_ERR, PCIE_UESR(pcie_port));
557 + /* Correctable Error Mask Register, unmask <enable> all bits */
558 + reg = IFX_REG_R32(PCIE_CEMR(pcie_port));
559 + reg &= ~PCIE_CORRECTABLE_ERR;
560 + IFX_REG_W32(reg, PCIE_CEMR(pcie_port));
562 + /* Advanced Error Capabilities and Control Registr */
563 + reg = IFX_REG_R32(PCIE_AECCR(pcie_port));
564 + reg |= PCIE_AECCR_ECRC_CHECK_EN | PCIE_AECCR_ECRC_GEN_EN;
565 + IFX_REG_W32(reg, PCIE_AECCR(pcie_port));
567 + /* Root Error Command Register, Report all types of errors */
568 + reg = IFX_REG_R32(PCIE_RECR(pcie_port));
569 + reg |= PCIE_RECR_ERR_REPORT_EN;
570 + IFX_REG_W32(reg, PCIE_RECR(pcie_port));
572 + /* Clear the Root status register */
573 + reg = IFX_REG_R32(PCIE_RESR(pcie_port));
574 + IFX_REG_W32(reg, PCIE_RESR(pcie_port));
577 +static inline void pcie_port_logic_setup(int pcie_port)
581 + /* FTS number, default 12, increase to 63, may increase time from/to L0s to L0 */
582 + reg = IFX_REG_R32(PCIE_AFR(pcie_port));
583 + reg &= ~(PCIE_AFR_FTS_NUM | PCIE_AFR_COM_FTS_NUM);
584 + reg |= SM(PCIE_AFR_FTS_NUM_DEFAULT, PCIE_AFR_FTS_NUM)
585 + | SM(PCIE_AFR_FTS_NUM_DEFAULT, PCIE_AFR_COM_FTS_NUM);
586 + /* L0s and L1 entry latency */
587 + reg &= ~(PCIE_AFR_L0S_ENTRY_LATENCY | PCIE_AFR_L1_ENTRY_LATENCY);
588 + reg |= SM(PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT, PCIE_AFR_L0S_ENTRY_LATENCY)
589 + | SM(PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT, PCIE_AFR_L1_ENTRY_LATENCY);
590 + IFX_REG_W32(reg, PCIE_AFR(pcie_port));
593 + /* Port Link Control Register */
594 + reg = IFX_REG_R32(PCIE_PLCR(pcie_port));
595 + reg |= PCIE_PLCR_DLL_LINK_EN; /* Enable the DLL link */
596 + IFX_REG_W32(reg, PCIE_PLCR(pcie_port));
598 + /* Lane Skew Register */
599 + reg = IFX_REG_R32(PCIE_LSR(pcie_port));
600 + /* Enable ACK/NACK and FC */
601 + reg &= ~(PCIE_LSR_ACKNAK_DISABLE | PCIE_LSR_FC_DISABLE);
602 + IFX_REG_W32(reg, PCIE_LSR(pcie_port));
604 + /* Symbol Timer Register and Filter Mask Register 1 */
605 + reg = IFX_REG_R32(PCIE_STRFMR(pcie_port));
607 + /* Default SKP interval is very accurate already, 5us */
608 + /* Enable IO/CFG transaction */
609 + reg |= PCIE_STRFMR_RX_CFG_TRANS_ENABLE | PCIE_STRFMR_RX_IO_TRANS_ENABLE;
610 + /* Disable FC WDT */
611 + reg &= ~PCIE_STRFMR_FC_WDT_DISABLE;
612 + IFX_REG_W32(reg, PCIE_STRFMR(pcie_port));
614 + /* Filter Masker Register 2 */
615 + reg = IFX_REG_R32(PCIE_FMR2(pcie_port));
616 + reg |= PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 | PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1;
617 + IFX_REG_W32(reg, PCIE_FMR2(pcie_port));
619 + /* VC0 Completion Receive Queue Control Register */
620 + reg = IFX_REG_R32(PCIE_VC0_CRQCR(pcie_port));
621 + reg &= ~PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE;
622 + reg |= SM(PCIE_VC0_TLP_QUEUE_MODE_BYPASS, PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE);
623 + IFX_REG_W32(reg, PCIE_VC0_CRQCR(pcie_port));
626 +static inline void pcie_rc_cfg_reg_setup(int pcie_port)
630 + /* Disable LTSSM */
631 + IFX_REG_W32(0, PCIE_RC_CCR(pcie_port)); /* Disable LTSSM */
633 + pcie_mem_io_setup(pcie_port);
635 + /* XXX, MSI stuff should only apply to EP */
636 + /* MSI Capability: Only enable 32-bit addresses */
637 + reg = IFX_REG_R32(PCIE_MCAPR(pcie_port));
638 + reg &= ~PCIE_MCAPR_ADDR64_CAP;
640 + reg |= PCIE_MCAPR_MSI_ENABLE;
642 + /* Disable multiple message */
643 + reg &= ~(PCIE_MCAPR_MULTI_MSG_CAP | PCIE_MCAPR_MULTI_MSG_ENABLE);
644 + IFX_REG_W32(reg, PCIE_MCAPR(pcie_port));
647 + /* Enable PME, Soft reset enabled */
648 + reg = IFX_REG_R32(PCIE_PM_CSR(pcie_port));
649 + reg |= PCIE_PM_CSR_PME_ENABLE | PCIE_PM_CSR_SW_RST;
650 + IFX_REG_W32(reg, PCIE_PM_CSR(pcie_port));
652 + /* setup the bus */
653 + reg = SM(0, PCIE_BNR_PRIMARY_BUS_NUM) | SM(1, PCIE_PNR_SECONDARY_BUS_NUM) | SM(0xFF, PCIE_PNR_SUB_BUS_NUM);
654 + IFX_REG_W32(reg, PCIE_BNR(pcie_port));
657 + pcie_device_setup(pcie_port);
658 + pcie_link_setup(pcie_port);
659 + pcie_error_setup(pcie_port);
661 + /* Root control and capabilities register */
662 + reg = IFX_REG_R32(PCIE_RCTLCAP(pcie_port));
663 + reg |= PCIE_RCTLCAP_SERR_ENABLE | PCIE_RCTLCAP_PME_INT_EN;
664 + IFX_REG_W32(reg, PCIE_RCTLCAP(pcie_port));
666 + /* Port VC Capability Register 2 */
667 + reg = IFX_REG_R32(PCIE_PVC2(pcie_port));
668 + reg &= ~PCIE_PVC2_VC_ARB_WRR;
669 + reg |= PCIE_PVC2_VC_ARB_16P_FIXED_WRR;
670 + IFX_REG_W32(reg, PCIE_PVC2(pcie_port));
672 + /* VC0 Resource Capability Register */
673 + reg = IFX_REG_R32(PCIE_VC0_RC(pcie_port));
674 + reg &= ~PCIE_VC0_RC_REJECT_SNOOP;
675 + IFX_REG_W32(reg, PCIE_VC0_RC(pcie_port));
677 + pcie_port_logic_setup(pcie_port);
680 +static int ifx_pcie_wait_phy_link_up(int pcie_port)
682 +#define IFX_PCIE_PHY_LINK_UP_TIMEOUT 1000 /* XXX, tunable */
685 + /* Wait for PHY link is up */
686 + for (i = 0; i < IFX_PCIE_PHY_LINK_UP_TIMEOUT; i++) {
687 + if (ifx_pcie_link_up(pcie_port)) {
692 + if (i >= IFX_PCIE_PHY_LINK_UP_TIMEOUT) {
693 + printk(KERN_ERR "%s timeout\n", __func__);
697 + /* Check data link up or not */
698 + if (!(IFX_REG_R32(PCIE_RC_DR(pcie_port)) & PCIE_RC_DR_DLL_UP)) {
699 + printk(KERN_ERR "%s DLL link is still down\n", __func__);
703 + /* Check Data link active or not */
704 + if (!(IFX_REG_R32(PCIE_LCTLSTS(pcie_port)) & PCIE_LCTLSTS_DLL_ACTIVE)) {
705 + printk(KERN_ERR "%s DLL is not active\n", __func__);
711 +static inline int pcie_app_loigc_setup(int pcie_port)
713 + /* supress ahb bus errrors */
714 + IFX_REG_W32(PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS, PCIE_AHB_CTRL(pcie_port));
716 + /* Pull PCIe EP out of reset */
717 + pcie_device_rst_deassert(pcie_port);
719 + /* Start LTSSM training between RC and EP */
720 + pcie_ltssm_enable(pcie_port);
722 + /* Check PHY status after enabling LTSSM */
723 + if (ifx_pcie_wait_phy_link_up(pcie_port) != 0)
730 + * The numbers below are directly from the PCIe spec table 3-4/5.
732 +static inline void pcie_replay_time_update(int pcie_port)
738 + reg = IFX_REG_R32(PCIE_LCTLSTS(pcie_port));
740 + nlw = MS(reg, PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH);
742 + case PCIE_MAX_LENGTH_WIDTH_X1:
745 + case PCIE_MAX_LENGTH_WIDTH_X2:
748 + case PCIE_MAX_LENGTH_WIDTH_X4:
751 + case PCIE_MAX_LENGTH_WIDTH_X8:
758 + reg = IFX_REG_R32(PCIE_ALTRT(pcie_port));
759 + reg &= ~PCIE_ALTRT_REPLAY_TIME_LIMIT;
760 + reg |= SM(rtl, PCIE_ALTRT_REPLAY_TIME_LIMIT);
761 + IFX_REG_W32(reg, PCIE_ALTRT(pcie_port));
765 + * Table 359 Enhanced Configuration Address Mapping1)
766 + * 1) This table is defined in Table 7-1, page 341, PCI Express Base Specification v1.1
767 + * Memory Address PCI Express Configuration Space
768 + * A[(20+n-1):20] Bus Number 1 < n < 8
769 + * A[19:15] Device Number
770 + * A[14:12] Function Number
771 + * A[11:8] Extended Register Number
772 + * A[7:2] Register Number
773 + * A[1:0] Along with size of the access, used to generate Byte Enables
774 + * For VR9, only the address bits [22:0] are mapped to the configuration space:
775 + * . Address bits [22:20] select the target bus (1-of-8)1)
776 + * . Address bits [19:15] select the target device (1-of-32) on the bus
777 + * . Address bits [14:12] select the target function (1-of-8) within the device.
778 + * . Address bits [11:2] selects the target dword (1-of-1024) within the selected function.s configuration space
779 + * . Address bits [1:0] define the start byte location within the selected dword.
781 +static inline u32 pcie_bus_addr(u8 bus_num, u16 devfn, int where)
788 + addr = ((PCI_SLOT(devfn) & 0x1F) << 15) | ((PCI_FUNC(devfn) & 0x7) << 12) | ((where & 0xFFF)& ~3);
791 + /* type 1, only support 8 buses */
792 + addr = ((bus & 0x7) << 20) | ((PCI_SLOT(devfn) & 0x1F) << 15) |
793 + ((PCI_FUNC(devfn) & 0x7) << 12) | ((where & 0xFFF) & ~3);
798 +static int pcie_valid_config(int pcie_port, int bus, int dev)
801 + if ((bus == 0) && (dev == 0)) {
805 + /* No physical link */
806 + if (!ifx_pcie_link_up(pcie_port)) {
810 + /* Bus zero only has RC itself
811 + * XXX, check if EP will be integrated
813 + if ((bus == 0) && (dev != 0)) {
817 + /* Maximum 8 buses supported for VRX */
823 + * PCIe is PtP link, one bus only supports only one device
824 + * except bus zero and PCIe switch which is virtual bus device
825 + * The following two conditions really depends on the system design
826 + * and attached the device.
827 + * XXX, how about more new switch
829 + if ((bus == 1) && (dev != 0)) {
833 + if ((bus >= 3) && (dev != 0)) {
839 +static inline u32 ifx_pcie_cfg_rd(int pcie_port, u32 reg)
841 + return IFX_REG_R32((volatile u32 *)(PCIE_CFG_PORT_TO_BASE(pcie_port) + reg));
844 +static inline void ifx_pcie_cfg_wr(int pcie_port, unsigned int reg, u32 val)
846 + IFX_REG_W32( val, (volatile u32 *)(PCIE_CFG_PORT_TO_BASE(pcie_port) + reg));
849 +static inline u32 ifx_pcie_rc_cfg_rd(int pcie_port, u32 reg)
851 + return IFX_REG_R32((volatile u32 *)(PCIE_RC_PORT_TO_BASE(pcie_port) + reg));
854 +static inline void ifx_pcie_rc_cfg_wr(int pcie_port, unsigned int reg, u32 val)
856 + IFX_REG_W32(val, (volatile u32 *)(PCIE_RC_PORT_TO_BASE(pcie_port) + reg));
859 +u32 ifx_pcie_bus_enum_read_hack(int where, u32 value)
861 + u32 tvalue = value;
863 + if (where == PCI_PRIMARY_BUS) {
864 + u8 primary, secondary, subordinate;
866 + primary = tvalue & 0xFF;
867 + secondary = (tvalue >> 8) & 0xFF;
868 + subordinate = (tvalue >> 16) & 0xFF;
869 + primary += pcibios_1st_host_bus_nr();
870 + secondary += pcibios_1st_host_bus_nr();
871 + subordinate += pcibios_1st_host_bus_nr();
872 + tvalue = (tvalue & 0xFF000000) | (u32)primary | (u32)(secondary << 8) | (u32)(subordinate << 16);
877 +u32 ifx_pcie_bus_enum_write_hack(int where, u32 value)
879 + u32 tvalue = value;
881 + if (where == PCI_PRIMARY_BUS) {
882 + u8 primary, secondary, subordinate;
884 + primary = tvalue & 0xFF;
885 + secondary = (tvalue >> 8) & 0xFF;
886 + subordinate = (tvalue >> 16) & 0xFF;
887 + if (primary > 0 && primary != 0xFF) {
888 + primary -= pcibios_1st_host_bus_nr();
891 + if (secondary > 0 && secondary != 0xFF) {
892 + secondary -= pcibios_1st_host_bus_nr();
894 + if (subordinate > 0 && subordinate != 0xFF) {
895 + subordinate -= pcibios_1st_host_bus_nr();
897 + tvalue = (tvalue & 0xFF000000) | (u32)primary | (u32)(secondary << 8) | (u32)(subordinate << 16);
899 + else if (where == PCI_SUBORDINATE_BUS) {
900 + u8 subordinate = tvalue & 0xFF;
902 + subordinate = subordinate > 0 ? subordinate - pcibios_1st_host_bus_nr() : 0;
903 + tvalue = subordinate;
908 +static int ifx_pcie_read_config(struct pci_bus *bus, u32 devfn,
909 + int where, int size, u32 *value)
912 + int bus_number = bus->number;
913 + static const u32 mask[8] = {0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0};
914 + int ret = PCIBIOS_SUCCESSFUL;
915 + struct ifx_pci_controller *ctrl = bus->sysdata;
916 + int pcie_port = ctrl->port;
918 + if (unlikely(size != 1 && size != 2 && size != 4)){
919 + ret = PCIBIOS_BAD_REGISTER_NUMBER;
923 + /* Make sure the address is aligned to natural boundary */
924 + if (unlikely(((size - 1) & where))) {
925 + ret = PCIBIOS_BAD_REGISTER_NUMBER;
930 + * If we are second controller, we have to cheat OS so that it assume
931 + * its bus number starts from 0 in host controller
933 + bus_number = ifx_pcie_bus_nr_deduct(bus_number, pcie_port);
936 + * We need to force the bus number to be zero on the root
937 + * bus. Linux numbers the 2nd root bus to start after all
938 + * busses on root 0.
940 + if (bus->parent == NULL) {
945 + * PCIe only has a single device connected to it. It is
946 + * always device ID 0. Don't bother doing reads for other
947 + * device IDs on the first segment.
949 + if ((bus_number == 0) && (PCI_SLOT(devfn) != 0)) {
950 + ret = PCIBIOS_FUNC_NOT_SUPPORTED;
954 + if (pcie_valid_config(pcie_port, bus_number, PCI_SLOT(devfn)) == 0) {
955 + *value = 0xffffffff;
956 + ret = PCIBIOS_DEVICE_NOT_FOUND;
960 + PCIE_IRQ_LOCK(ifx_pcie_lock);
961 + if (bus_number == 0) { /* RC itself */
965 + data = ifx_pcie_rc_cfg_rd(pcie_port, t);
967 + u32 addr = pcie_bus_addr(bus_number, devfn, where);
969 + data = ifx_pcie_cfg_rd(pcie_port, addr);
970 + #ifdef CONFIG_IFX_PCIE_HW_SWAP
971 + data = le32_to_cpu(data);
972 + #endif /* CONFIG_IFX_PCIE_HW_SWAP */
974 + /* To get a correct PCI topology, we have to restore the bus number to OS */
975 + data = ifx_pcie_bus_enum_hack(bus, devfn, where, data, pcie_port, 1);
977 + PCIE_IRQ_UNLOCK(ifx_pcie_lock);
979 + *value = (data >> (8 * (where & 3))) & mask[size & 7];
984 +static u32 ifx_pcie_size_to_value(int where, int size, u32 data, u32 value)
991 + shift = (where & 0x3) << 3;
992 + tdata &= ~(0xffU << shift);
993 + tdata |= ((value & 0xffU) << shift);
996 + shift = (where & 3) << 3;
997 + tdata &= ~(0xffffU << shift);
998 + tdata |= ((value & 0xffffU) << shift);
1007 +static int ifx_pcie_write_config(struct pci_bus *bus, u32 devfn,
1008 + int where, int size, u32 value)
1010 + int bus_number = bus->number;
1011 + int ret = PCIBIOS_SUCCESSFUL;
1012 + struct ifx_pci_controller *ctrl = bus->sysdata;
1013 + int pcie_port = ctrl->port;
1014 + u32 tvalue = value;
1017 + /* Make sure the address is aligned to natural boundary */
1018 + if (unlikely(((size - 1) & where))) {
1019 + ret = PCIBIOS_BAD_REGISTER_NUMBER;
1023 + * If we are second controller, we have to cheat OS so that it assume
1024 + * its bus number starts from 0 in host controller
1026 + bus_number = ifx_pcie_bus_nr_deduct(bus_number, pcie_port);
1029 + * We need to force the bus number to be zero on the root
1030 + * bus. Linux numbers the 2nd root bus to start after all
1031 + * busses on root 0.
1033 + if (bus->parent == NULL) {
1037 + if (pcie_valid_config(pcie_port, bus_number, PCI_SLOT(devfn)) == 0) {
1038 + ret = PCIBIOS_DEVICE_NOT_FOUND;
1042 + /* XXX, some PCIe device may need some delay */
1043 + PCIE_IRQ_LOCK(ifx_pcie_lock);
1046 + * To configure the correct bus topology using native way, we have to cheat Os so that
1047 + * it can configure the PCIe hardware correctly.
1049 + tvalue = ifx_pcie_bus_enum_hack(bus, devfn, where, value, pcie_port, 0);
1051 + if (bus_number == 0) { /* RC itself */
1055 + data = ifx_pcie_rc_cfg_rd(pcie_port, t);
1057 + data = ifx_pcie_size_to_value(where, size, data, tvalue);
1059 + ifx_pcie_rc_cfg_wr(pcie_port, t, data);
1061 + u32 addr = pcie_bus_addr(bus_number, devfn, where);
1063 + data = ifx_pcie_cfg_rd(pcie_port, addr);
1064 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
1065 + data = le32_to_cpu(data);
1068 + data = ifx_pcie_size_to_value(where, size, data, tvalue);
1069 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
1070 + data = cpu_to_le32(data);
1072 + ifx_pcie_cfg_wr(pcie_port, addr, data);
1074 + PCIE_IRQ_UNLOCK(ifx_pcie_lock);
1079 +static struct resource ifx_pcie_io_resource = {
1080 + .name = "PCIe0 I/O space",
1081 + .start = PCIE_IO_PHY_BASE,
1082 + .end = PCIE_IO_PHY_END,
1083 + .flags = IORESOURCE_IO,
1086 +static struct resource ifx_pcie_mem_resource = {
1087 + .name = "PCIe0 Memory space",
1088 + .start = PCIE_MEM_PHY_BASE,
1089 + .end = PCIE_MEM_PHY_END,
1090 + .flags = IORESOURCE_MEM,
1093 +static struct pci_ops ifx_pcie_ops = {
1094 + .read = ifx_pcie_read_config,
1095 + .write = ifx_pcie_write_config,
1098 +static struct ifx_pci_controller ifx_pcie_controller[IFX_PCIE_CORE_NR] = {
1101 + .pci_ops = &ifx_pcie_ops,
1102 + .mem_resource = &ifx_pcie_mem_resource,
1103 + .io_resource = &ifx_pcie_io_resource,
1105 + .port = IFX_PCIE_PORT0,
1109 +#ifdef IFX_PCIE_ERROR_INT
1111 +static irqreturn_t pcie_rc_core_isr(int irq, void *dev_id)
1113 + struct ifx_pci_controller *ctrl = (struct ifx_pci_controller *)dev_id;
1114 + int pcie_port = ctrl->port;
1117 + printk("PCIe RC error intr %d\n", irq);
1118 + reg = IFX_REG_R32(PCIE_IRNCR(pcie_port));
1119 + reg &= PCIE_RC_CORE_COMBINED_INT;
1120 + IFX_REG_W32(reg, PCIE_IRNCR(pcie_port));
1122 + return IRQ_HANDLED;
1126 +pcie_rc_core_int_init(int pcie_port)
1130 + /* Enable core interrupt */
1131 + IFX_REG_SET_BIT(PCIE_RC_CORE_COMBINED_INT, PCIE_IRNEN(pcie_port));
1133 + /* Clear it first */
1134 + IFX_REG_SET_BIT(PCIE_RC_CORE_COMBINED_INT, PCIE_IRNCR(pcie_port));
1135 + ret = request_irq(pcie_irqs[pcie_port].ir_irq.irq, pcie_rc_core_isr, 0,
1136 + pcie_irqs[pcie_port].ir_irq.name, &ifx_pcie_controller[pcie_port]);
1138 + printk(KERN_ERR "%s request irq %d failed\n", __func__, IFX_PCIE_IR);
1144 +int ifx_pcie_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin)
1148 + struct ifx_pci_controller *ctrl = dev->bus->sysdata;
1149 + int pcie_port = ctrl->port;
1151 + printk("%s port %d dev %s slot %d pin %d \n", __func__, pcie_port, pci_name(dev), slot, pin);
1153 + if ((pin == PCIE_LEGACY_DISABLE) || (pin > PCIE_LEGACY_INT_MAX)) {
1154 + printk(KERN_WARNING "WARNING: dev %s: invalid interrupt pin %d\n", pci_name(dev), pin);
1158 + /* Pin index so minus one */
1159 + irq_bit = pcie_irqs[pcie_port].legacy_irq[pin - 1].irq_bit;
1160 + irq = pcie_irqs[pcie_port].legacy_irq[pin - 1].irq;
1161 + IFX_REG_SET_BIT(irq_bit, PCIE_IRNEN(pcie_port));
1162 + IFX_REG_SET_BIT(irq_bit, PCIE_IRNCR(pcie_port));
1163 + printk("%s dev %s irq %d assigned\n", __func__, pci_name(dev), irq);
1167 +int ifx_pcie_bios_plat_dev_init(struct pci_dev *dev)
1170 +#ifdef IFX_PCIE_ERROR_INT
1175 + /* Enable reporting System errors and parity errors on all devices */
1176 + /* Enable parity checking and error reporting */
1177 + pci_read_config_word(dev, PCI_COMMAND, &config);
1178 + config |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR /*| PCI_COMMAND_INVALIDATE |
1179 + PCI_COMMAND_FAST_BACK*/;
1180 + pci_write_config_word(dev, PCI_COMMAND, config);
1182 + if (dev->subordinate) {
1183 + /* Set latency timers on sub bridges */
1184 + pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 0x40); /* XXX, */
1185 + /* More bridge error detection */
1186 + pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &config);
1187 + config |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR;
1188 + pci_write_config_word(dev, PCI_BRIDGE_CONTROL, config);
1190 +#ifdef IFX_PCIE_ERROR_INT
1191 + /* Enable the PCIe normal error reporting */
1192 + pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
1195 + /* Disable system error generation in response to error messages */
1196 + pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &config);
1197 + config &= ~(PCI_EXP_RTCTL_SECEE | PCI_EXP_RTCTL_SENFEE | PCI_EXP_RTCTL_SEFEE);
1198 + pci_write_config_word(dev, pos + PCI_EXP_RTCTL, config);
1200 + /* Clear PCIE Capability's Device Status */
1201 + pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &config);
1202 + pci_write_config_word(dev, pos + PCI_EXP_DEVSTA, config);
1204 + /* Update Device Control */
1205 + pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &config);
1206 + /* Correctable Error Reporting */
1207 + config |= PCI_EXP_DEVCTL_CERE;
1208 + /* Non-Fatal Error Reporting */
1209 + config |= PCI_EXP_DEVCTL_NFERE;
1210 + /* Fatal Error Reporting */
1211 + config |= PCI_EXP_DEVCTL_FERE;
1212 + /* Unsupported Request */
1213 + config |= PCI_EXP_DEVCTL_URRE;
1214 + pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, config);
1217 + /* Find the Advanced Error Reporting capability */
1218 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
1220 + /* Clear Uncorrectable Error Status */
1221 + pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &dconfig);
1222 + pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, dconfig);
1223 + /* Enable reporting of all uncorrectable errors */
1224 + /* Uncorrectable Error Mask - turned on bits disable errors */
1225 + pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 0);
1227 + * Leave severity at HW default. This only controls if
1228 + * errors are reported as uncorrectable or
1229 + * correctable, not if the error is reported.
1231 + /* PCI_ERR_UNCOR_SEVER - Uncorrectable Error Severity */
1232 + /* Clear Correctable Error Status */
1233 + pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &dconfig);
1234 + pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, dconfig);
1235 + /* Enable reporting of all correctable errors */
1236 + /* Correctable Error Mask - turned on bits disable errors */
1237 + pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, 0);
1238 + /* Advanced Error Capabilities */
1239 + pci_read_config_dword(dev, pos + PCI_ERR_CAP, &dconfig);
1240 + /* ECRC Generation Enable */
1241 + if (dconfig & PCI_ERR_CAP_ECRC_GENC) {
1242 + dconfig |= PCI_ERR_CAP_ECRC_GENE;
1244 + /* ECRC Check Enable */
1245 + if (dconfig & PCI_ERR_CAP_ECRC_CHKC) {
1246 + dconfig |= PCI_ERR_CAP_ECRC_CHKE;
1248 + pci_write_config_dword(dev, pos + PCI_ERR_CAP, dconfig);
1250 + /* PCI_ERR_HEADER_LOG - Header Log Register (16 bytes) */
1251 + /* Enable Root Port's interrupt in response to error messages */
1252 + pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND,
1253 + PCI_ERR_ROOT_CMD_COR_EN |
1254 + PCI_ERR_ROOT_CMD_NONFATAL_EN |
1255 + PCI_ERR_ROOT_CMD_FATAL_EN);
1256 + /* Clear the Root status register */
1257 + pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &dconfig);
1258 + pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, dconfig);
1260 +#endif /* IFX_PCIE_ERROR_INT */
1261 + /* WAR, only 128 MRRS is supported, force all EPs to support this value */
1262 + pcie_set_readrq(dev, 128);
1267 +pcie_rc_initialize(int pcie_port)
1270 +#define IFX_PCIE_PHY_LOOP_CNT 5
1272 + pcie_rcu_endian_setup(pcie_port);
1274 + pcie_ep_gpio_rst_init(pcie_port);
1277 + * XXX, PCIe elastic buffer bug will cause not to be detected. One more
1278 + * reset PCIe PHY will solve this issue
1280 + for (i = 0; i < IFX_PCIE_PHY_LOOP_CNT; i++) {
1281 + /* Disable PCIe PHY Analog part for sanity check */
1282 + pcie_phy_pmu_disable(pcie_port);
1284 + pcie_phy_rst_assert(pcie_port);
1285 + pcie_phy_rst_deassert(pcie_port);
1287 + /* Make sure PHY PLL is stable */
1290 + /* PCIe Core reset enabled, low active, sw programmed */
1291 + pcie_core_rst_assert(pcie_port);
1293 + /* Put PCIe EP in reset status */
1294 + pcie_device_rst_assert(pcie_port);
1296 + /* PCI PHY & Core reset disabled, high active, sw programmed */
1297 + pcie_core_rst_deassert(pcie_port);
1299 + /* Already in a quiet state, program PLL, enable PHY, check ready bit */
1300 + pcie_phy_clock_mode_setup(pcie_port);
1302 + /* Enable PCIe PHY and Clock */
1303 + pcie_core_pmu_setup(pcie_port);
1305 + /* Clear status registers */
1306 + pcie_status_register_clear(pcie_port);
1308 +#ifdef CONFIG_PCI_MSI
1309 + pcie_msi_init(pcie_port);
1310 +#endif /* CONFIG_PCI_MSI */
1311 + pcie_rc_cfg_reg_setup(pcie_port);
1313 + /* Once link is up, break out */
1314 + if (pcie_app_loigc_setup(pcie_port) == 0)
1317 + if (i >= IFX_PCIE_PHY_LOOP_CNT) {
1318 + printk(KERN_ERR "%s link up failed!!!!!\n", __func__);
1321 + /* NB, don't increase ACK/NACK timer timeout value, which will cause a lot of COR errors */
1322 + pcie_replay_time_update(pcie_port);
1326 +extern int (*ltq_pci_plat_arch_init)(struct pci_dev *dev);
1327 +extern int (*ltq_pci_map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
1329 +static int __init ifx_pcie_bios_init(void)
1331 + void __iomem *io_map_base;
1336 + ltq_pci_map_irq = ifx_pcie_bios_map_irq;
1337 + ltq_pci_plat_arch_init = ifx_pcie_bios_plat_dev_init;
1339 + /* Enable AHB Master/ Slave */
1340 + pcie_ahb_pmu_setup();
1342 + startup_port = IFX_PCIE_PORT0;
1344 + for (pcie_port = startup_port; pcie_port < IFX_PCIE_CORE_NR; pcie_port++){
1345 + if (pcie_rc_initialize(pcie_port) == 0) {
1346 + IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: ifx_pcie_cfg_base 0x%p\n",
1347 + __func__, PCIE_CFG_PORT_TO_BASE(pcie_port));
1348 + /* Otherwise, warning will pop up */
1349 + io_map_base = ioremap(PCIE_IO_PHY_PORT_TO_BASE(pcie_port), PCIE_IO_SIZE);
1350 + if (io_map_base == NULL) {
1351 + IFX_PCIE_PRINT(PCIE_MSG_ERR, "%s io space ioremap failed\n", __func__);
1354 + ifx_pcie_controller[pcie_port].pcic.io_map_base = (unsigned long)io_map_base;
1356 + register_pci_controller(&ifx_pcie_controller[pcie_port].pcic);
1357 + /* XXX, clear error status */
1359 + IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: mem_resource 0x%p, io_resource 0x%p\n",
1360 + __func__, &ifx_pcie_controller[pcie_port].pcic.mem_resource,
1361 + &ifx_pcie_controller[pcie_port].pcic.io_resource);
1363 + #ifdef IFX_PCIE_ERROR_INT
1364 + pcie_rc_core_int_init(pcie_port);
1365 + #endif /* IFX_PCIE_ERROR_INT */
1371 +arch_initcall(ifx_pcie_bios_init);
1373 +MODULE_LICENSE("GPL");
1374 +MODULE_AUTHOR("Chuanhua.Lei@infineon.com");
1375 +MODULE_SUPPORTED_DEVICE("Infineon builtin PCIe RC module");
1376 +MODULE_DESCRIPTION("Infineon builtin PCIe RC driver");
1378 diff --git a/arch/mips/pci/ifxmips_pcie.h b/arch/mips/pci/ifxmips_pcie.h
1379 new file mode 100644
1380 index 0000000..c6f92f5
1382 +++ b/arch/mips/pci/ifxmips_pcie.h
1384 +/******************************************************************************
1386 +** FILE NAME : ifxmips_pcie.h
1387 +** PROJECT : IFX UEIP for VRX200
1388 +** MODULES : PCIe module
1390 +** DATE : 02 Mar 2009
1391 +** AUTHOR : Lei Chuanhua
1392 +** DESCRIPTION : PCIe Root Complex Driver
1393 +** COPYRIGHT : Copyright (c) 2009
1394 +** Infineon Technologies AG
1395 +** Am Campeon 1-12, 85579 Neubiberg, Germany
1397 +** This program is free software; you can redistribute it and/or modify
1398 +** it under the terms of the GNU General Public License as published by
1399 +** the Free Software Foundation; either version 2 of the License, or
1400 +** (at your option) any later version.
1402 +** $Version $Date $Author $Comment
1403 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
1404 +*******************************************************************************/
1405 +#ifndef IFXMIPS_PCIE_H
1406 +#define IFXMIPS_PCIE_H
1407 +#include <linux/version.h>
1408 +#include <linux/types.h>
1409 +#include <linux/pci.h>
1410 +#include <linux/interrupt.h>
1411 +#include "ifxmips_pci_common.h"
1412 +#include "ifxmips_pcie_reg.h"
1415 + \defgroup IFX_PCIE PCI Express bus driver module
1416 + \brief PCI Express IP module support VRX200
1420 + \defgroup IFX_PCIE_OS OS APIs
1422 + \brief PCIe bus driver OS interface functions
1426 + \file ifxmips_pcie.h
1428 + \brief header file for PCIe module common header file
1430 +#define PCIE_IRQ_LOCK(lock) do { \
1431 + unsigned long flags; \
1432 + spin_lock_irqsave(&(lock), flags);
1433 +#define PCIE_IRQ_UNLOCK(lock) \
1434 + spin_unlock_irqrestore(&(lock), flags); \
1437 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
1438 +#define IRQF_SHARED SA_SHIRQ
1441 +#define PCIE_MSG_MSI 0x00000001
1442 +#define PCIE_MSG_ISR 0x00000002
1443 +#define PCIE_MSG_FIXUP 0x00000004
1444 +#define PCIE_MSG_READ_CFG 0x00000008
1445 +#define PCIE_MSG_WRITE_CFG 0x00000010
1446 +#define PCIE_MSG_CFG (PCIE_MSG_READ_CFG | PCIE_MSG_WRITE_CFG)
1447 +#define PCIE_MSG_REG 0x00000020
1448 +#define PCIE_MSG_INIT 0x00000040
1449 +#define PCIE_MSG_ERR 0x00000080
1450 +#define PCIE_MSG_PHY 0x00000100
1451 +#define PCIE_MSG_ANY 0x000001ff
1453 +#define IFX_PCIE_PORT0 0
1454 +#define IFX_PCIE_PORT1 1
1456 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
1457 +#define IFX_PCIE_CORE_NR 2
1459 +#define IFX_PCIE_CORE_NR 1
1462 +#define IFX_PCIE_ERROR_INT
1464 +//#define IFX_PCIE_DBG
1466 +#if defined(IFX_PCIE_DBG)
1467 +#define IFX_PCIE_PRINT(_m, _fmt, args...) do { \
1468 + ifx_pcie_debug((_fmt), ##args); \
1473 +#define IFX_PCIE_PRINT(_m, _fmt, args...) \
1475 +#define INLINE inline
1478 +struct ifx_pci_controller {
1479 + struct pci_controller pcic;
1481 + /* RC specific, per host bus information */
1482 + u32 port; /* Port index, 0 -- 1st core, 1 -- 2nd core */
1485 +typedef struct ifx_pcie_ir_irq {
1486 + const unsigned int irq;
1487 + const char name[16];
1488 +}ifx_pcie_ir_irq_t;
1490 +typedef struct ifx_pcie_legacy_irq{
1491 + const u32 irq_bit;
1493 +}ifx_pcie_legacy_irq_t;
1495 +typedef struct ifx_pcie_irq {
1496 + ifx_pcie_ir_irq_t ir_irq;
1497 + ifx_pcie_legacy_irq_t legacy_irq[PCIE_LEGACY_INT_MAX];
1500 +extern u32 g_pcie_debug_flag;
1501 +extern void ifx_pcie_debug(const char *fmt, ...);
1502 +extern void pcie_phy_clock_mode_setup(int pcie_port);
1503 +extern void pcie_msi_pic_init(int pcie_port);
1504 +extern u32 ifx_pcie_bus_enum_read_hack(int where, u32 value);
1505 +extern u32 ifx_pcie_bus_enum_write_hack(int where, u32 value);
1510 +#include "ifxmips_pcie_vr9.h"
1511 +#elif defined (CONFIG_AR10)
1512 +#include "ifxmips_pcie_ar10.h"
1514 +#error "PCIE: platform not defined"
1515 +#endif /* CONFIG_VR9 */
1517 +#endif /* IFXMIPS_PCIE_H */
1519 diff --git a/arch/mips/pci/ifxmips_pcie_ar10.h b/arch/mips/pci/ifxmips_pcie_ar10.h
1520 new file mode 100644
1521 index 0000000..99ff463
1523 +++ b/arch/mips/pci/ifxmips_pcie_ar10.h
1525 +/****************************************************************************
1526 + Copyright (c) 2010
1527 + Lantiq Deutschland GmbH
1528 + Am Campeon 3; 85579 Neubiberg, Germany
1530 + For licensing information, see the file 'LICENSE' in the root folder of
1531 + this software module.
1533 + *****************************************************************************/
1535 + \file ifxmips_pcie_ar10.h
1537 + \brief PCIe RC driver ar10 specific file
1540 +#ifndef IFXMIPS_PCIE_AR10_H
1541 +#define IFXMIPS_PCIE_AR10_H
1542 +#ifndef AUTOCONF_INCLUDED
1543 +#include <linux/config.h>
1544 +#endif /* AUTOCONF_INCLUDED */
1545 +#include <linux/types.h>
1546 +#include <linux/delay.h>
1548 +/* Project header file */
1549 +#include <asm/ifx/ifx_types.h>
1550 +#include <asm/ifx/ifx_pmu.h>
1551 +#include <asm/ifx/ifx_gpio.h>
1552 +#include <asm/ifx/ifx_ebu_led.h>
1554 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
1556 + ifx_ebu_led_enable();
1557 + if (pcie_port == 0) {
1558 + ifx_ebu_led_set_data(11, 1);
1561 + ifx_ebu_led_set_data(12, 1);
1565 +static inline void pcie_ahb_pmu_setup(void)
1567 + /* XXX, moved to CGU to control AHBM */
1570 +static inline void pcie_rcu_endian_setup(int pcie_port)
1574 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
1575 + /* Inbound, big endian */
1576 + reg |= IFX_RCU_BE_AHB4S;
1577 + if (pcie_port == 0) {
1578 + reg |= IFX_RCU_BE_PCIE0M;
1580 + #ifdef CONFIG_IFX_PCIE_HW_SWAP
1581 + /* Outbound, software swap needed */
1582 + reg |= IFX_RCU_BE_AHB3M;
1583 + reg &= ~IFX_RCU_BE_PCIE0S;
1585 + /* Outbound little endian */
1586 + reg &= ~IFX_RCU_BE_AHB3M;
1587 + reg &= ~IFX_RCU_BE_PCIE0S;
1591 + reg |= IFX_RCU_BE_PCIE1M;
1592 + #ifdef CONFIG_IFX_PCIE1_HW_SWAP
1593 + /* Outbound, software swap needed */
1594 + reg |= IFX_RCU_BE_AHB3M;
1595 + reg &= ~IFX_RCU_BE_PCIE1S;
1597 + /* Outbound little endian */
1598 + reg &= ~IFX_RCU_BE_AHB3M;
1599 + reg &= ~IFX_RCU_BE_PCIE1S;
1603 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
1604 + IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
1607 +static inline void pcie_phy_pmu_enable(int pcie_port)
1609 + if (pcie_port == 0) { /* XXX, should use macro*/
1610 + PCIE0_PHY_PMU_SETUP(IFX_PMU_ENABLE);
1613 + PCIE1_PHY_PMU_SETUP(IFX_PMU_ENABLE);
1617 +static inline void pcie_phy_pmu_disable(int pcie_port)
1619 + if (pcie_port == 0) { /* XXX, should use macro*/
1620 + PCIE0_PHY_PMU_SETUP(IFX_PMU_DISABLE);
1623 + PCIE1_PHY_PMU_SETUP(IFX_PMU_DISABLE);
1627 +static inline void pcie_pdi_big_endian(int pcie_port)
1631 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
1632 + if (pcie_port == 0) {
1633 + /* Config AHB->PCIe and PDI endianness */
1634 + reg |= IFX_RCU_BE_PCIE0_PDI;
1637 + /* Config AHB->PCIe and PDI endianness */
1638 + reg |= IFX_RCU_BE_PCIE1_PDI;
1640 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
1643 +static inline void pcie_pdi_pmu_enable(int pcie_port)
1645 + if (pcie_port == 0) {
1646 + /* Enable PDI to access PCIe PHY register */
1647 + PDI0_PMU_SETUP(IFX_PMU_ENABLE);
1650 + PDI1_PMU_SETUP(IFX_PMU_ENABLE);
1654 +static inline void pcie_core_rst_assert(int pcie_port)
1658 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1660 + /* Reset Core, bit 22 */
1661 + if (pcie_port == 0) {
1662 + reg |= 0x00400000;
1665 + reg |= 0x08000000; /* Bit 27 */
1667 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1670 +static inline void pcie_core_rst_deassert(int pcie_port)
1674 + /* Make sure one micro-second delay */
1677 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1678 + if (pcie_port == 0) {
1679 + reg &= ~0x00400000; /* bit 22 */
1682 + reg &= ~0x08000000; /* Bit 27 */
1684 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1687 +static inline void pcie_phy_rst_assert(int pcie_port)
1691 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1692 + if (pcie_port == 0) {
1693 + reg |= 0x00001000; /* Bit 12 */
1696 + reg |= 0x00002000; /* Bit 13 */
1698 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1701 +static inline void pcie_phy_rst_deassert(int pcie_port)
1705 + /* Make sure one micro-second delay */
1708 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1709 + if (pcie_port == 0) {
1710 + reg &= ~0x00001000; /* Bit 12 */
1713 + reg &= ~0x00002000; /* Bit 13 */
1715 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1718 +static inline void pcie_device_rst_assert(int pcie_port)
1720 + if (pcie_port == 0) {
1721 + ifx_ebu_led_set_data(11, 0);
1724 + ifx_ebu_led_set_data(12, 0);
1728 +static inline void pcie_device_rst_deassert(int pcie_port)
1731 + if (pcie_port == 0) {
1732 + ifx_ebu_led_set_data(11, 1);
1735 + ifx_ebu_led_set_data(12, 1);
1737 + ifx_ebu_led_disable();
1740 +static inline void pcie_core_pmu_setup(int pcie_port)
1742 + if (pcie_port == 0) {
1743 + PCIE0_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
1746 + PCIE1_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
1750 +static inline void pcie_msi_init(int pcie_port)
1752 + pcie_msi_pic_init(pcie_port);
1753 + if (pcie_port == 0) {
1754 + MSI0_PMU_SETUP(IFX_PMU_ENABLE);
1757 + MSI1_PMU_SETUP(IFX_PMU_ENABLE);
1762 +ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
1764 + u32 tbus_number = bus_number;
1766 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
1767 + if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
1768 + if (pcibios_host_nr() > 1) {
1769 + tbus_number -= pcibios_1st_host_bus_nr();
1772 +#endif /* CONFIG_IFX_PCI */
1773 + return tbus_number;
1777 +ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
1779 + struct pci_dev *pdev;
1780 + u32 tvalue = value;
1782 + /* Sanity check */
1783 + pdev = pci_get_slot(bus, devfn);
1784 + if (pdev == NULL) {
1788 + /* Only care about PCI bridge */
1789 + if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
1793 + if (read) { /* Read hack */
1794 + #ifdef CONFIG_IFX_PCIE_2ND_CORE
1795 + if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
1796 + if (pcibios_host_nr() > 1) {
1797 + tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
1800 + #endif /* CONFIG_IFX_PCIE_2ND_CORE */
1802 + else { /* Write hack */
1803 + #ifdef CONFIG_IFX_PCIE_2ND_CORE
1804 + if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
1805 + if (pcibios_host_nr() > 1) {
1806 + tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
1814 +#endif /* IFXMIPS_PCIE_AR10_H */
1815 diff --git a/arch/mips/pci/ifxmips_pcie_msi.c b/arch/mips/pci/ifxmips_pcie_msi.c
1816 new file mode 100644
1817 index 0000000..bffd6fa
1819 +++ b/arch/mips/pci/ifxmips_pcie_msi.c
1821 +/******************************************************************************
1823 +** FILE NAME : ifxmips_pcie_msi.c
1824 +** PROJECT : IFX UEIP for VRX200
1825 +** MODULES : PCI MSI sub module
1827 +** DATE : 02 Mar 2009
1828 +** AUTHOR : Lei Chuanhua
1829 +** DESCRIPTION : PCIe MSI Driver
1830 +** COPYRIGHT : Copyright (c) 2009
1831 +** Infineon Technologies AG
1832 +** Am Campeon 1-12, 85579 Neubiberg, Germany
1834 +** This program is free software; you can redistribute it and/or modify
1835 +** it under the terms of the GNU General Public License as published by
1836 +** the Free Software Foundation; either version 2 of the License, or
1837 +** (at your option) any later version.
1839 +** $Date $Author $Comment
1840 +** 02 Mar,2009 Lei Chuanhua Initial version
1841 +*******************************************************************************/
1843 + \defgroup IFX_PCIE_MSI MSI OS APIs
1845 + \brief PCIe bus driver OS interface functions
1849 + \file ifxmips_pcie_msi.c
1851 + \brief PCIe MSI OS interface file
1854 +#ifndef AUTOCONF_INCLUDED
1855 +#include <linux/config.h>
1856 +#endif /* AUTOCONF_INCLUDED */
1857 +#include <linux/init.h>
1858 +#include <linux/sched.h>
1859 +#include <linux/slab.h>
1860 +#include <linux/interrupt.h>
1861 +#include <linux/kernel_stat.h>
1862 +#include <linux/pci.h>
1863 +#include <linux/msi.h>
1864 +#include <linux/module.h>
1865 +#include <asm/bootinfo.h>
1866 +#include <asm/irq.h>
1867 +#include <asm/traps.h>
1869 +#include <asm/ifx/ifx_types.h>
1870 +#include <asm/ifx/ifx_regs.h>
1871 +#include <asm/ifx/common_routines.h>
1872 +#include <asm/ifx/irq.h>
1874 +#include "ifxmips_pcie_reg.h"
1875 +#include "ifxmips_pcie.h"
1877 +#define IFX_MSI_IRQ_NUM 16
1880 + IFX_PCIE_MSI_IDX0 = 0,
1881 + IFX_PCIE_MSI_IDX1,
1882 + IFX_PCIE_MSI_IDX2,
1883 + IFX_PCIE_MSI_IDX3,
1886 +typedef struct ifx_msi_irq_idx {
1889 +}ifx_msi_irq_idx_t;
1891 +struct ifx_msi_pic {
1892 + volatile u32 pic_table[IFX_MSI_IRQ_NUM];
1893 + volatile u32 pic_endian; /* 0x40 */
1895 +typedef struct ifx_msi_pic *ifx_msi_pic_t;
1897 +typedef struct ifx_msi_irq {
1898 + const volatile ifx_msi_pic_t msi_pic_p;
1899 + const u32 msi_phy_base;
1900 + const ifx_msi_irq_idx_t msi_irq_idx[IFX_MSI_IRQ_NUM];
1902 + * Each bit in msi_free_irq_bitmask represents a MSI interrupt that is
1905 + u16 msi_free_irq_bitmask;
1908 + * Each bit in msi_multiple_irq_bitmask tells that the device using
1909 + * this bit in msi_free_irq_bitmask is also using the next bit. This
1910 + * is used so we can disable all of the MSI interrupts when a device
1913 + u16 msi_multiple_irq_bitmask;
1916 +static ifx_msi_irq_t msi_irqs[IFX_PCIE_CORE_NR] = {
1918 + .msi_pic_p = (const volatile ifx_msi_pic_t)IFX_MSI_PIC_REG_BASE,
1919 + .msi_phy_base = PCIE_MSI_PHY_BASE,
1921 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1922 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1923 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1924 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1925 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1926 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1927 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1928 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1930 + .msi_free_irq_bitmask = 0,
1931 + .msi_multiple_irq_bitmask= 0,
1933 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
1935 + .msi_pic_p = (const volatile ifx_msi_pic_t)IFX_MSI1_PIC_REG_BASE,
1936 + .msi_phy_base = PCIE1_MSI_PHY_BASE,
1938 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1939 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1940 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1941 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1942 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1943 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1944 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1945 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1947 + .msi_free_irq_bitmask = 0,
1948 + .msi_multiple_irq_bitmask= 0,
1951 +#endif /* CONFIG_IFX_PCIE_2ND_CORE */
1955 + * This lock controls updates to msi_free_irq_bitmask,
1956 + * msi_multiple_irq_bitmask and pic register settting
1958 +static DEFINE_SPINLOCK(ifx_pcie_msi_lock);
1960 +void pcie_msi_pic_init(int pcie_port)
1962 + spin_lock(&ifx_pcie_msi_lock);
1963 + msi_irqs[pcie_port].msi_pic_p->pic_endian = IFX_MSI_PIC_BIG_ENDIAN;
1964 + spin_unlock(&ifx_pcie_msi_lock);
1968 + * \fn int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
1969 + * \brief Called when a driver request MSI interrupts instead of the
1970 + * legacy INT A-D. This routine will allocate multiple interrupts
1971 + * for MSI devices that support them. A device can override this by
1972 + * programming the MSI control bits [6:4] before calling
1973 + * pci_enable_msi().
1975 + * \param[in] pdev Device requesting MSI interrupts
1976 + * \param[in] desc MSI descriptor
1978 + * \return -EINVAL Invalid pcie root port or invalid msi bit
1980 + * \ingroup IFX_PCIE_MSI
1983 +arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
1989 + int configured_private_bits;
1990 + int request_private_bits;
1991 + struct msi_msg msg;
1993 + struct ifx_pci_controller *ctrl = pdev->bus->sysdata;
1994 + int pcie_port = ctrl->port;
1996 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s %s enter\n", __func__, pci_name(pdev));
1998 + /* XXX, skip RC MSI itself */
1999 + if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) {
2000 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s RC itself doesn't use MSI interrupt\n", __func__);
2005 + * Read the MSI config to figure out how many IRQs this device
2006 + * wants. Most devices only want 1, which will give
2007 + * configured_private_bits and request_private_bits equal 0.
2009 + pci_read_config_word(pdev, desc->msi_attrib.pos + PCI_MSI_FLAGS, &control);
2012 + * If the number of private bits has been configured then use
2013 + * that value instead of the requested number. This gives the
2014 + * driver the chance to override the number of interrupts
2015 + * before calling pci_enable_msi().
2017 + configured_private_bits = (control & PCI_MSI_FLAGS_QSIZE) >> 4;
2018 + if (configured_private_bits == 0) {
2019 + /* Nothing is configured, so use the hardware requested size */
2020 + request_private_bits = (control & PCI_MSI_FLAGS_QMASK) >> 1;
2024 + * Use the number of configured bits, assuming the
2025 + * driver wanted to override the hardware request
2028 + request_private_bits = configured_private_bits;
2032 + * The PCI 2.3 spec mandates that there are at most 32
2033 + * interrupts. If this device asks for more, only give it one.
2035 + if (request_private_bits > 5) {
2036 + request_private_bits = 0;
2040 + * The IRQs have to be aligned on a power of two based on the
2041 + * number being requested.
2043 + irq_step = (1 << request_private_bits);
2045 + /* Mask with one bit for each IRQ */
2046 + search_mask = (1 << irq_step) - 1;
2049 + * We're going to search msi_free_irq_bitmask_lock for zero
2050 + * bits. This represents an MSI interrupt number that isn't in
2053 + spin_lock(&ifx_pcie_msi_lock);
2054 + for (pos = 0; pos < IFX_MSI_IRQ_NUM; pos += irq_step) {
2055 + if ((msi_irqs[pcie_port].msi_free_irq_bitmask & (search_mask << pos)) == 0) {
2056 + msi_irqs[pcie_port].msi_free_irq_bitmask |= search_mask << pos;
2057 + msi_irqs[pcie_port].msi_multiple_irq_bitmask |= (search_mask >> 1) << pos;
2061 + spin_unlock(&ifx_pcie_msi_lock);
2063 + /* Make sure the search for available interrupts didn't fail */
2064 + if (pos >= IFX_MSI_IRQ_NUM) {
2065 + if (request_private_bits) {
2066 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s: Unable to find %d free "
2067 + "interrupts, trying just one", __func__, 1 << request_private_bits);
2068 + request_private_bits = 0;
2072 + printk(KERN_ERR "%s: Unable to find a free MSI interrupt\n", __func__);
2076 + irq = msi_irqs[pcie_port].msi_irq_idx[pos].irq;
2077 + irq_idx = msi_irqs[pcie_port].msi_irq_idx[pos].idx;
2079 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "pos %d, irq %d irq_idx %d\n", pos, irq, irq_idx);
2082 + * Initialize MSI. This has to match the memory-write endianess from the device
2083 + * Address bits [23:12]
2085 + spin_lock(&ifx_pcie_msi_lock);
2086 + msi_irqs[pcie_port].msi_pic_p->pic_table[pos] = SM(irq_idx, IFX_MSI_PIC_INT_LINE) |
2087 + SM((msi_irqs[pcie_port].msi_phy_base >> 12), IFX_MSI_PIC_MSG_ADDR) |
2088 + SM((1 << pos), IFX_MSI_PIC_MSG_DATA);
2090 + /* Enable this entry */
2091 + msi_irqs[pcie_port].msi_pic_p->pic_table[pos] &= ~IFX_MSI_PCI_INT_DISABLE;
2092 + spin_unlock(&ifx_pcie_msi_lock);
2094 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "pic_table[%d]: 0x%08x\n",
2095 + pos, msi_irqs[pcie_port].msi_pic_p->pic_table[pos]);
2097 + /* Update the number of IRQs the device has available to it */
2098 + control &= ~PCI_MSI_FLAGS_QSIZE;
2099 + control |= (request_private_bits << 4);
2100 + pci_write_config_word(pdev, desc->msi_attrib.pos + PCI_MSI_FLAGS, control);
2102 + set_irq_msi(irq, desc);
2103 + msg.address_hi = 0x0;
2104 + msg.address_lo = msi_irqs[pcie_port].msi_phy_base;
2105 + msg.data = SM((1 << pos), IFX_MSI_PIC_MSG_DATA);
2106 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "msi_data: pos %d 0x%08x\n", pos, msg.data);
2108 + write_msi_msg(irq, &msg);
2109 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s exit\n", __func__);
2114 +pcie_msi_irq_to_port(unsigned int irq, int *port)
2118 + if (irq == IFX_PCIE_MSI_IR0 || irq == IFX_PCIE_MSI_IR1 ||
2119 + irq == IFX_PCIE_MSI_IR2 || irq == IFX_PCIE_MSI_IR3) {
2120 + *port = IFX_PCIE_PORT0;
2122 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
2123 + else if (irq == IFX_PCIE1_MSI_IR0 || irq == IFX_PCIE1_MSI_IR1 ||
2124 + irq == IFX_PCIE1_MSI_IR2 || irq == IFX_PCIE1_MSI_IR3) {
2125 + *port = IFX_PCIE_PORT1;
2127 +#endif /* CONFIG_IFX_PCIE_2ND_CORE */
2129 + printk(KERN_ERR "%s: Attempted to teardown illegal "
2130 + "MSI interrupt (%d)\n", __func__, irq);
2137 + * \fn void arch_teardown_msi_irq(unsigned int irq)
2138 + * \brief Called when a device no longer needs its MSI interrupts. All
2139 + * MSI interrupts for the device are freed.
2141 + * \param irq The devices first irq number. There may be multple in sequence.
2143 + * \ingroup IFX_PCIE_MSI
2146 +arch_teardown_msi_irq(unsigned int irq)
2153 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s enter\n", __func__);
2155 + BUG_ON(irq > INT_NUM_IM4_IRL31);
2157 + if (pcie_msi_irq_to_port(irq, &pcie_port) != 0) {
2161 + /* Shift the mask to the correct bit location, not always correct
2162 + * Probally, the first match will be chosen.
2164 + for (pos = 0; pos < IFX_MSI_IRQ_NUM; pos++) {
2165 + if ((msi_irqs[pcie_port].msi_irq_idx[pos].irq == irq)
2166 + && (msi_irqs[pcie_port].msi_free_irq_bitmask & ( 1 << pos))) {
2170 + if (pos >= IFX_MSI_IRQ_NUM) {
2171 + printk(KERN_ERR "%s: Unable to find a matched MSI interrupt\n", __func__);
2174 + spin_lock(&ifx_pcie_msi_lock);
2175 + /* Disable this entry */
2176 + msi_irqs[pcie_port].msi_pic_p->pic_table[pos] |= IFX_MSI_PCI_INT_DISABLE;
2177 + 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);
2178 + spin_unlock(&ifx_pcie_msi_lock);
2180 + * Count the number of IRQs we need to free by looking at the
2181 + * msi_multiple_irq_bitmask. Each bit set means that the next
2182 + * IRQ is also owned by this device.
2185 + while (((pos + number_irqs) < IFX_MSI_IRQ_NUM) &&
2186 + (msi_irqs[pcie_port].msi_multiple_irq_bitmask & (1 << (pos + number_irqs)))) {
2191 + /* Mask with one bit for each IRQ */
2192 + bitmask = (1 << number_irqs) - 1;
2195 + if ((msi_irqs[pcie_port].msi_free_irq_bitmask & bitmask) != bitmask) {
2196 + printk(KERN_ERR "%s: Attempted to teardown MSI "
2197 + "interrupt (%d) not in use\n", __func__, irq);
2200 + /* Checks are done, update the in use bitmask */
2201 + spin_lock(&ifx_pcie_msi_lock);
2202 + msi_irqs[pcie_port].msi_free_irq_bitmask &= ~bitmask;
2203 + msi_irqs[pcie_port].msi_multiple_irq_bitmask &= ~(bitmask >> 1);
2204 + spin_unlock(&ifx_pcie_msi_lock);
2205 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s exit\n", __func__);
2208 +MODULE_LICENSE("GPL");
2209 +MODULE_AUTHOR("Chuanhua.Lei@infineon.com");
2210 +MODULE_SUPPORTED_DEVICE("Infineon PCIe IP builtin MSI PIC module");
2211 +MODULE_DESCRIPTION("Infineon PCIe IP builtin MSI PIC driver");
2213 diff --git a/arch/mips/pci/ifxmips_pcie_phy.c b/arch/mips/pci/ifxmips_pcie_phy.c
2214 new file mode 100644
2215 index 0000000..f5b0f13
2217 +++ b/arch/mips/pci/ifxmips_pcie_phy.c
2219 +/******************************************************************************
2221 +** FILE NAME : ifxmips_pcie_phy.c
2222 +** PROJECT : IFX UEIP for VRX200
2223 +** MODULES : PCIe PHY sub module
2225 +** DATE : 14 May 2009
2226 +** AUTHOR : Lei Chuanhua
2227 +** DESCRIPTION : PCIe Root Complex Driver
2228 +** COPYRIGHT : Copyright (c) 2009
2229 +** Infineon Technologies AG
2230 +** Am Campeon 1-12, 85579 Neubiberg, Germany
2232 +** This program is free software; you can redistribute it and/or modify
2233 +** it under the terms of the GNU General Public License as published by
2234 +** the Free Software Foundation; either version 2 of the License, or
2235 +** (at your option) any later version.
2237 +** $Version $Date $Author $Comment
2238 +** 0.0.1 14 May,2009 Lei Chuanhua Initial version
2239 +*******************************************************************************/
2241 + \file ifxmips_pcie_phy.c
2243 + \brief PCIe PHY PLL register programming source file
2245 +#include <linux/types.h>
2246 +#include <linux/kernel.h>
2247 +#include <asm/paccess.h>
2248 +#include <linux/delay.h>
2250 +#include "ifxmips_pcie_reg.h"
2251 +#include "ifxmips_pcie.h"
2253 +/* PCIe PDI only supports 16 bit operation */
2255 +#define IFX_PCIE_PHY_REG_WRITE16(__addr, __data) \
2256 + ((*(volatile u16 *) (__addr)) = (__data))
2258 +#define IFX_PCIE_PHY_REG_READ16(__addr) \
2259 + (*(volatile u16 *) (__addr))
2261 +#define IFX_PCIE_PHY_REG16(__addr) \
2262 + (*(volatile u16 *) (__addr))
2264 +#define IFX_PCIE_PHY_REG(__reg, __value, __mask) do { \
2267 + read_data = IFX_PCIE_PHY_REG_READ16((__reg)); \
2268 + write_data = (read_data & ((u16)~(__mask))) | (((u16)(__value)) & ((u16)(__mask)));\
2269 + IFX_PCIE_PHY_REG_WRITE16((__reg), write_data); \
2272 +#define IFX_PCIE_PLL_TIMEOUT 1000 /* Tunnable */
2274 +//#define IFX_PCI_PHY_REG_DUMP
2276 +#ifdef IFX_PCI_PHY_REG_DUMP
2278 +pcie_phy_reg_dump(int pcie_port)
2280 + printk("PLL REGFILE\n");
2281 + printk("PCIE_PHY_PLL_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL1(pcie_port)));
2282 + printk("PCIE_PHY_PLL_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL2(pcie_port)));
2283 + printk("PCIE_PHY_PLL_CTRL3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL3(pcie_port)));
2284 + printk("PCIE_PHY_PLL_CTRL4 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL4(pcie_port)));
2285 + printk("PCIE_PHY_PLL_CTRL5 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL5(pcie_port)));
2286 + printk("PCIE_PHY_PLL_CTRL6 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL6(pcie_port)));
2287 + printk("PCIE_PHY_PLL_CTRL7 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL7(pcie_port)));
2288 + printk("PCIE_PHY_PLL_A_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL1(pcie_port)));
2289 + printk("PCIE_PHY_PLL_A_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL2(pcie_port)));
2290 + printk("PCIE_PHY_PLL_A_CTRL3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL3(pcie_port)));
2291 + printk("PCIE_PHY_PLL_STATUS 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_STATUS(pcie_port)));
2293 + printk("TX1 REGFILE\n");
2294 + printk("PCIE_PHY_TX1_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL1(pcie_port)));
2295 + printk("PCIE_PHY_TX1_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL2(pcie_port)));
2296 + printk("PCIE_PHY_TX1_CTRL3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL3(pcie_port)));
2297 + printk("PCIE_PHY_TX1_A_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_A_CTRL1(pcie_port)));
2298 + printk("PCIE_PHY_TX1_A_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_A_CTRL2(pcie_port)));
2299 + printk("PCIE_PHY_TX1_MOD1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD1(pcie_port)));
2300 + printk("PCIE_PHY_TX1_MOD2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD2(pcie_port)));
2301 + printk("PCIE_PHY_TX1_MOD3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD3(pcie_port)));
2303 + printk("TX2 REGFILE\n");
2304 + printk("PCIE_PHY_TX2_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_CTRL1(pcie_port)));
2305 + printk("PCIE_PHY_TX2_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_CTRL2(pcie_port)));
2306 + printk("PCIE_PHY_TX2_A_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_A_CTRL1(pcie_port)));
2307 + printk("PCIE_PHY_TX2_A_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_A_CTRL2(pcie_port)));
2308 + printk("PCIE_PHY_TX2_MOD1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD1(pcie_port)));
2309 + printk("PCIE_PHY_TX2_MOD2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD2(pcie_port)));
2310 + printk("PCIE_PHY_TX2_MOD3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD3(pcie_port)));
2312 + printk("RX1 REGFILE\n");
2313 + printk("PCIE_PHY_RX1_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CTRL1(pcie_port)));
2314 + printk("PCIE_PHY_RX1_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CTRL2(pcie_port)));
2315 + printk("PCIE_PHY_RX1_CDR 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CDR(pcie_port)));
2316 + printk("PCIE_PHY_RX1_EI 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_EI(pcie_port)));
2317 + printk("PCIE_PHY_RX1_A_CTRL 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_A_CTRL(pcie_port)));
2319 +#endif /* IFX_PCI_PHY_REG_DUMP */
2322 +pcie_phy_comm_setup(int pcie_port)
2325 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL1(pcie_port), 0x120e, 0xFFFF);
2327 + /* increase the bias reference voltage */
2328 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x39D7, 0xFFFF);
2329 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x0900, 0xFFFF);
2332 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_EI(pcie_port), 0x0004, 0xFFFF);
2333 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_A_CTRL(pcie_port), 0x6803, 0xFFFF);
2336 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0008, 0x0008);
2338 + /* predrv_ser_en */
2339 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL2(pcie_port), 0x0706, 0xFFFF);
2342 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL3(pcie_port), 0x1FFF, 0xFFFF);
2345 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL1(pcie_port), 0x0800, 0xFF00);
2347 + /* predrv_ser_en */
2348 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4702, 0x7F00);
2351 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL2(pcie_port), 0x2e00, 0xFFFF);
2353 + /* Improved 100MHz clock output */
2354 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL2(pcie_port), 0x3096, 0xFFFF);
2355 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4707, 0xFFFF);
2357 + /* Reduced CDR BW to avoid glitches */
2358 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CDR(pcie_port), 0x0235, 0xFFFF);
2361 +#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_MODE
2363 +pcie_phy_36mhz_mode_setup(int pcie_port)
2365 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2366 +#ifdef IFX_PCI_PHY_REG_DUMP
2367 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2368 + pcie_phy_reg_dump(pcie_port);
2371 + /* en_ext_mmd_div_ratio */
2372 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
2374 + /* ext_mmd_div_ratio*/
2375 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
2378 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
2380 + /* en_const_sdm */
2381 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
2384 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
2387 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
2390 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
2393 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
2396 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
2397 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
2398 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
2399 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1b72, 0xFFFF);
2401 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2403 +#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_MODE */
2405 +#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE
2407 +pcie_phy_36mhz_ssc_mode_setup(int pcie_port)
2409 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2410 +#ifdef IFX_PCI_PHY_REG_DUMP
2411 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2412 + pcie_phy_reg_dump(pcie_port);
2416 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL1(pcie_port), 0x120e, 0xFFFF);
2418 + /* Increase the bias reference voltage */
2419 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x39D7, 0xFFFF);
2420 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x0900, 0xFFFF);
2423 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_EI(pcie_port), 0x0004, 0xFFFF);
2424 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_A_CTRL(pcie_port), 0x6803, 0xFFFF);
2427 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0008, 0x0008);
2429 + /* Predrv_ser_en */
2430 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL2(pcie_port), 0x0706, 0xFFFF);
2433 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL3(pcie_port), 0x1FFF, 0xFFFF);
2436 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL1(pcie_port), 0x0800, 0xFF00);
2438 + /* predrv_ser_en */
2439 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4702, 0x7F00);
2442 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL2(pcie_port), 0x2e00, 0xFFFF);
2444 + /* en_ext_mmd_div_ratio */
2445 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
2447 + /* ext_mmd_div_ratio*/
2448 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
2451 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0400, 0x0400);
2453 + /* en_const_sdm */
2454 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
2457 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
2460 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
2463 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
2465 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0000, 0x0100);
2467 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
2470 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
2471 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
2472 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
2473 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1c72, 0xFFFF);
2475 + /* improved 100MHz clock output */
2476 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL2(pcie_port), 0x3096, 0xFFFF);
2477 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4707, 0xFFFF);
2479 + /* reduced CDR BW to avoid glitches */
2480 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CDR(pcie_port), 0x0235, 0xFFFF);
2482 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2484 +#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE */
2486 +#ifdef CONFIG_IFX_PCIE_PHY_25MHZ_MODE
2488 +pcie_phy_25mhz_mode_setup(int pcie_port)
2490 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2491 +#ifdef IFX_PCI_PHY_REG_DUMP
2492 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2493 + pcie_phy_reg_dump(pcie_port);
2495 + /* en_const_sdm */
2496 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
2499 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0000, 0x0200);
2501 + /* en_ext_mmd_div_ratio*/
2502 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0002, 0x0002);
2504 + /* ext_mmd_div_ratio*/
2505 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0040, 0x0070);
2508 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x6000, 0xe000);
2511 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x4000, 0x4000);
2513 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2515 +#endif /* CONFIG_IFX_PCIE_PHY_25MHZ_MODE */
2517 +#ifdef CONFIG_IFX_PCIE_PHY_100MHZ_MODE
2519 +pcie_phy_100mhz_mode_setup(int pcie_port)
2521 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2522 +#ifdef IFX_PCI_PHY_REG_DUMP
2523 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2524 + pcie_phy_reg_dump(pcie_port);
2526 + /* en_ext_mmd_div_ratio */
2527 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
2529 + /* ext_mmd_div_ratio*/
2530 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
2533 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
2535 + /* en_const_sdm */
2536 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
2539 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
2542 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
2545 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
2548 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
2551 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
2552 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
2553 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
2554 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1b72, 0xFFFF);
2556 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2558 +#endif /* CONFIG_IFX_PCIE_PHY_100MHZ_MODE */
2561 +pcie_phy_wait_startup_ready(int pcie_port)
2565 + for (i = 0; i < IFX_PCIE_PLL_TIMEOUT; i++) {
2566 + if ((IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_STATUS(pcie_port)) & 0x0040) != 0) {
2571 + if (i >= IFX_PCIE_PLL_TIMEOUT) {
2572 + printk(KERN_ERR "%s PLL Link timeout\n", __func__);
2579 +pcie_phy_load_enable(int pcie_port, int slice)
2581 + /* Set the load_en of tx/rx slice to '1' */
2584 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0010, 0x0010);
2587 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL1(pcie_port), 0x0010, 0x0010);
2590 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CTRL1(pcie_port), 0x0002, 0x0002);
2596 +pcie_phy_load_disable(int pcie_port, int slice)
2598 + /* set the load_en of tx/rx slice to '0' */
2601 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0000, 0x0010);
2604 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL1(pcie_port), 0x0000, 0x0010);
2607 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CTRL1(pcie_port), 0x0000, 0x0002);
2613 +pcie_phy_load_war(int pcie_port)
2617 + for (slice = 1; slice < 4; slice++) {
2618 + pcie_phy_load_enable(pcie_port, slice);
2620 + pcie_phy_load_disable(pcie_port, slice);
2625 +pcie_phy_tx2_modulation(int pcie_port)
2627 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD1(pcie_port), 0x1FFE, 0xFFFF);
2628 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD2(pcie_port), 0xFFFE, 0xFFFF);
2629 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD3(pcie_port), 0x0601, 0xFFFF);
2631 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD3(pcie_port), 0x0001, 0xFFFF);
2635 +pcie_phy_tx1_modulation(int pcie_port)
2637 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD1(pcie_port), 0x1FFE, 0xFFFF);
2638 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD2(pcie_port), 0xFFFE, 0xFFFF);
2639 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD3(pcie_port), 0x0601, 0xFFFF);
2641 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD3(pcie_port), 0x0001, 0xFFFF);
2645 +pcie_phy_tx_modulation_war(int pcie_port)
2649 +#define PCIE_PHY_MODULATION_NUM 5
2650 + for (i = 0; i < PCIE_PHY_MODULATION_NUM; i++) {
2651 + pcie_phy_tx2_modulation(pcie_port);
2652 + pcie_phy_tx1_modulation(pcie_port);
2654 +#undef PCIE_PHY_MODULATION_NUM
2658 +pcie_phy_clock_mode_setup(int pcie_port)
2660 + pcie_pdi_big_endian(pcie_port);
2662 + /* Enable PDI to access PCIe PHY register */
2663 + pcie_pdi_pmu_enable(pcie_port);
2665 + /* Configure PLL and PHY clock */
2666 + pcie_phy_comm_setup(pcie_port);
2668 +#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_MODE
2669 + pcie_phy_36mhz_mode_setup(pcie_port);
2670 +#elif defined(CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE)
2671 + pcie_phy_36mhz_ssc_mode_setup(pcie_port);
2672 +#elif defined(CONFIG_IFX_PCIE_PHY_25MHZ_MODE)
2673 + pcie_phy_25mhz_mode_setup(pcie_port);
2674 +#elif defined (CONFIG_IFX_PCIE_PHY_100MHZ_MODE)
2675 + pcie_phy_100mhz_mode_setup(pcie_port);
2677 + #error "PCIE PHY Clock Mode must be chosen first!!!!"
2678 +#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_MODE */
2680 + /* Enable PCIe PHY and make PLL setting take effect */
2681 + pcie_phy_pmu_enable(pcie_port);
2683 + /* Check if we are in startup_ready status */
2684 + pcie_phy_wait_startup_ready(pcie_port);
2686 + pcie_phy_load_war(pcie_port);
2688 + /* Apply TX modulation workarounds */
2689 + pcie_phy_tx_modulation_war(pcie_port);
2691 +#ifdef IFX_PCI_PHY_REG_DUMP
2692 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Modified PHY register dump\n");
2693 + pcie_phy_reg_dump(pcie_port);
2697 diff --git a/arch/mips/pci/ifxmips_pcie_pm.c b/arch/mips/pci/ifxmips_pcie_pm.c
2698 new file mode 100644
2699 index 0000000..a10ecad
2701 +++ b/arch/mips/pci/ifxmips_pcie_pm.c
2703 +/******************************************************************************
2705 +** FILE NAME : ifxmips_pcie_pm.c
2706 +** PROJECT : IFX UEIP
2707 +** MODULES : PCIE Root Complex Driver
2709 +** DATE : 21 Dec 2009
2710 +** AUTHOR : Lei Chuanhua
2711 +** DESCRIPTION : PCIE Root Complex Driver Power Managment
2712 +** COPYRIGHT : Copyright (c) 2009
2713 +** Lantiq Deutschland GmbH
2714 +** Am Campeon 3, 85579 Neubiberg, Germany
2716 +** This program is free software; you can redistribute it and/or modify
2717 +** it under the terms of the GNU General Public License as published by
2718 +** the Free Software Foundation; either version 2 of the License, or
2719 +** (at your option) any later version.
2722 +** $Date $Author $Comment
2723 +** 21 Dec,2009 Lei Chuanhua First UEIP release
2724 +*******************************************************************************/
2726 + \defgroup IFX_PCIE_PM Power Management functions
2728 + \brief IFX PCIE Root Complex Driver power management functions
2732 + \file ifxmips_pcie_pm.c
2734 + \brief source file for PCIE Root Complex Driver Power Management
2737 +#ifndef EXPORT_SYMTAB
2738 +#define EXPORT_SYMTAB
2740 +#ifndef AUTOCONF_INCLUDED
2741 +#include <linux/config.h>
2742 +#endif /* AUTOCONF_INCLUDED */
2743 +#include <linux/version.h>
2744 +#include <linux/module.h>
2745 +#include <linux/types.h>
2746 +#include <linux/kernel.h>
2747 +#include <asm/system.h>
2749 +/* Project header */
2750 +#include <asm/ifx/ifx_types.h>
2751 +#include <asm/ifx/ifx_regs.h>
2752 +#include <asm/ifx/common_routines.h>
2753 +#include <asm/ifx/ifx_pmcu.h>
2754 +#include "ifxmips_pcie_pm.h"
2757 + * \fn static IFX_PMCU_RETURN_t ifx_pcie_pmcu_state_change(IFX_PMCU_STATE_t pmcuState)
2758 + * \brief the callback function to request pmcu state in the power management hardware-dependent module
2760 + * \param pmcuState This parameter is a PMCU state.
2762 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2763 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2764 + * \return IFX_PMCU_RETURN_DENIED Not allowed to operate power state
2765 + * \ingroup IFX_PCIE_PM
2767 +static IFX_PMCU_RETURN_t
2768 +ifx_pcie_pmcu_state_change(IFX_PMCU_STATE_t pmcuState)
2772 + case IFX_PMCU_STATE_D0:
2773 + return IFX_PMCU_RETURN_SUCCESS;
2774 + case IFX_PMCU_STATE_D1: // Not Applicable
2775 + return IFX_PMCU_RETURN_DENIED;
2776 + case IFX_PMCU_STATE_D2: // Not Applicable
2777 + return IFX_PMCU_RETURN_DENIED;
2778 + case IFX_PMCU_STATE_D3: // Module clock gating and Power gating
2779 + return IFX_PMCU_RETURN_SUCCESS;
2781 + return IFX_PMCU_RETURN_DENIED;
2786 + * \fn static IFX_PMCU_RETURN_t ifx_pcie_pmcu_state_get(IFX_PMCU_STATE_t *pmcuState)
2787 + * \brief the callback function to get pmcu state in the power management hardware-dependent module
2789 + * \param pmcuState Pointer to return power state.
2791 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2792 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2793 + * \return IFX_PMCU_RETURN_DENIED Not allowed to operate power state
2794 + * \ingroup IFX_PCIE_PM
2796 +static IFX_PMCU_RETURN_t
2797 +ifx_pcie_pmcu_state_get(IFX_PMCU_STATE_t *pmcuState)
2799 + return IFX_PMCU_RETURN_SUCCESS;
2803 + * \fn IFX_PMCU_RETURN_t ifx_pcie_pmcu_prechange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2804 + * \brief Apply all callbacks registered to be executed before a state change for pmcuModule
2806 + * \param pmcuModule Module
2807 + * \param newState New state
2808 + * \param oldState Old state
2809 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2810 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2811 + * \ingroup IFX_PCIE_PM
2813 +static IFX_PMCU_RETURN_t
2814 +ifx_pcie_pmcu_prechange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2816 + return IFX_PMCU_RETURN_SUCCESS;
2820 + * \fn IFX_PMCU_RETURN_t ifx_pcie_pmcu_postchange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2821 + * \brief Apply all callbacks registered to be executed before a state change for pmcuModule
2823 + * \param pmcuModule Module
2824 + * \param newState New state
2825 + * \param oldState Old state
2826 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2827 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2828 + * \ingroup IFX_PCIE_PM
2830 +static IFX_PMCU_RETURN_t
2831 +ifx_pcie_pmcu_postchange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2833 + return IFX_PMCU_RETURN_SUCCESS;
2837 + * \fn static void ifx_pcie_pmcu_init(void)
2838 + * \brief Register with central PMCU module
2840 + * \ingroup IFX_PCIE_PM
2843 +ifx_pcie_pmcu_init(void)
2845 + IFX_PMCU_REGISTER_t pmcuRegister;
2847 + /* XXX, hook driver context */
2849 + /* State function register */
2850 + memset(&pmcuRegister, 0, sizeof(IFX_PMCU_REGISTER_t));
2851 + pmcuRegister.pmcuModule = IFX_PMCU_MODULE_PCIE;
2852 + pmcuRegister.pmcuModuleNr = 0;
2853 + pmcuRegister.ifx_pmcu_state_change = ifx_pcie_pmcu_state_change;
2854 + pmcuRegister.ifx_pmcu_state_get = ifx_pcie_pmcu_state_get;
2855 + pmcuRegister.pre = ifx_pcie_pmcu_prechange;
2856 + pmcuRegister.post= ifx_pcie_pmcu_postchange;
2857 + ifx_pmcu_register(&pmcuRegister);
2861 + * \fn static void ifx_pcie_pmcu_exit(void)
2862 + * \brief Unregister with central PMCU module
2865 + * \ingroup IFX_PCIE_PM
2868 +ifx_pcie_pmcu_exit(void)
2870 + IFX_PMCU_REGISTER_t pmcuUnRegister;
2872 + /* XXX, hook driver context */
2874 + pmcuUnRegister.pmcuModule = IFX_PMCU_MODULE_PCIE;
2875 + pmcuUnRegister.pmcuModuleNr = 0;
2876 + ifx_pmcu_unregister(&pmcuUnRegister);
2879 diff --git a/arch/mips/pci/ifxmips_pcie_pm.h b/arch/mips/pci/ifxmips_pcie_pm.h
2880 new file mode 100644
2881 index 0000000..6ece20d
2883 +++ b/arch/mips/pci/ifxmips_pcie_pm.h
2885 +/******************************************************************************
2887 +** FILE NAME : ifxmips_pcie_pm.h
2888 +** PROJECT : IFX UEIP
2889 +** MODULES : PCIe Root Complex Driver
2891 +** DATE : 21 Dec 2009
2892 +** AUTHOR : Lei Chuanhua
2893 +** DESCRIPTION : PCIe Root Complex Driver Power Managment
2894 +** COPYRIGHT : Copyright (c) 2009
2895 +** Lantiq Deutschland GmbH
2896 +** Am Campeon 3, 85579 Neubiberg, Germany
2898 +** This program is free software; you can redistribute it and/or modify
2899 +** it under the terms of the GNU General Public License as published by
2900 +** the Free Software Foundation; either version 2 of the License, or
2901 +** (at your option) any later version.
2904 +** $Date $Author $Comment
2905 +** 21 Dec,2009 Lei Chuanhua First UEIP release
2906 +*******************************************************************************/
2908 + \file ifxmips_pcie_pm.h
2910 + \brief header file for PCIe Root Complex Driver Power Management
2913 +#ifndef IFXMIPS_PCIE_PM_H
2914 +#define IFXMIPS_PCIE_PM_H
2916 +void ifx_pcie_pmcu_init(void);
2917 +void ifx_pcie_pmcu_exit(void);
2919 +#endif /* IFXMIPS_PCIE_PM_H */
2921 diff --git a/arch/mips/pci/ifxmips_pcie_reg.h b/arch/mips/pci/ifxmips_pcie_reg.h
2922 new file mode 100644
2923 index 0000000..e7e4b6c
2925 +++ b/arch/mips/pci/ifxmips_pcie_reg.h
2927 +/******************************************************************************
2929 +** FILE NAME : ifxmips_pcie_reg.h
2930 +** PROJECT : IFX UEIP for VRX200
2931 +** MODULES : PCIe module
2933 +** DATE : 02 Mar 2009
2934 +** AUTHOR : Lei Chuanhua
2935 +** DESCRIPTION : PCIe Root Complex Driver
2936 +** COPYRIGHT : Copyright (c) 2009
2937 +** Infineon Technologies AG
2938 +** Am Campeon 1-12, 85579 Neubiberg, Germany
2940 +** This program is free software; you can redistribute it and/or modify
2941 +** it under the terms of the GNU General Public License as published by
2942 +** the Free Software Foundation; either version 2 of the License, or
2943 +** (at your option) any later version.
2945 +** $Version $Date $Author $Comment
2946 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
2947 +*******************************************************************************/
2948 +#ifndef IFXMIPS_PCIE_REG_H
2949 +#define IFXMIPS_PCIE_REG_H
2951 + \file ifxmips_pcie_reg.h
2953 + \brief header file for PCIe module register definition
2955 +/* PCIe Address Mapping Base */
2956 +#define PCIE_CFG_PHY_BASE 0x1D000000UL
2957 +#define PCIE_CFG_BASE (KSEG1 + PCIE_CFG_PHY_BASE)
2958 +#define PCIE_CFG_SIZE (8 * 1024 * 1024)
2960 +#define PCIE_MEM_PHY_BASE 0x1C000000UL
2961 +#define PCIE_MEM_BASE (KSEG1 + PCIE_MEM_PHY_BASE)
2962 +#define PCIE_MEM_SIZE (16 * 1024 * 1024)
2963 +#define PCIE_MEM_PHY_END (PCIE_MEM_PHY_BASE + PCIE_MEM_SIZE - 1)
2965 +#define PCIE_IO_PHY_BASE 0x1D800000UL
2966 +#define PCIE_IO_BASE (KSEG1 + PCIE_IO_PHY_BASE)
2967 +#define PCIE_IO_SIZE (1 * 1024 * 1024)
2968 +#define PCIE_IO_PHY_END (PCIE_IO_PHY_BASE + PCIE_IO_SIZE - 1)
2970 +#define PCIE_RC_CFG_BASE (KSEG1 + 0x1D900000)
2971 +#define PCIE_APP_LOGIC_REG (KSEG1 + 0x1E100900)
2972 +#define PCIE_MSI_PHY_BASE 0x1F600000UL
2974 +#define PCIE_PDI_PHY_BASE 0x1F106800UL
2975 +#define PCIE_PDI_BASE (KSEG1 + PCIE_PDI_PHY_BASE)
2976 +#define PCIE_PDI_SIZE 0x400
2978 +#define PCIE1_CFG_PHY_BASE 0x19000000UL
2979 +#define PCIE1_CFG_BASE (KSEG1 + PCIE1_CFG_PHY_BASE)
2980 +#define PCIE1_CFG_SIZE (8 * 1024 * 1024)
2982 +#define PCIE1_MEM_PHY_BASE 0x18000000UL
2983 +#define PCIE1_MEM_BASE (KSEG1 + PCIE1_MEM_PHY_BASE)
2984 +#define PCIE1_MEM_SIZE (16 * 1024 * 1024)
2985 +#define PCIE1_MEM_PHY_END (PCIE1_MEM_PHY_BASE + PCIE1_MEM_SIZE - 1)
2987 +#define PCIE1_IO_PHY_BASE 0x19800000UL
2988 +#define PCIE1_IO_BASE (KSEG1 + PCIE1_IO_PHY_BASE)
2989 +#define PCIE1_IO_SIZE (1 * 1024 * 1024)
2990 +#define PCIE1_IO_PHY_END (PCIE1_IO_PHY_BASE + PCIE1_IO_SIZE - 1)
2992 +#define PCIE1_RC_CFG_BASE (KSEG1 + 0x19900000)
2993 +#define PCIE1_APP_LOGIC_REG (KSEG1 + 0x1E100700)
2994 +#define PCIE1_MSI_PHY_BASE 0x1F400000UL
2996 +#define PCIE1_PDI_PHY_BASE 0x1F700400UL
2997 +#define PCIE1_PDI_BASE (KSEG1 + PCIE1_PDI_PHY_BASE)
2998 +#define PCIE1_PDI_SIZE 0x400
3000 +#define PCIE_CFG_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_CFG_BASE) : (PCIE_CFG_BASE))
3001 +#define PCIE_MEM_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_BASE) : (PCIE_MEM_BASE))
3002 +#define PCIE_IO_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_BASE) : (PCIE_IO_BASE))
3003 +#define PCIE_MEM_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_PHY_BASE) : (PCIE_MEM_PHY_BASE))
3004 +#define PCIE_MEM_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_MEM_PHY_END) : (PCIE_MEM_PHY_END))
3005 +#define PCIE_IO_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_PHY_BASE) : (PCIE_IO_PHY_BASE))
3006 +#define PCIE_IO_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_IO_PHY_END) : (PCIE_IO_PHY_END))
3007 +#define PCIE_APP_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_APP_LOGIC_REG) : (PCIE_APP_LOGIC_REG))
3008 +#define PCIE_RC_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_RC_CFG_BASE) : (PCIE_RC_CFG_BASE))
3009 +#define PCIE_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_PDI_BASE) : (PCIE_PDI_BASE))
3011 +/* PCIe Application Logic Register */
3012 +/* RC Core Control Register */
3013 +#define PCIE_RC_CCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x10)
3014 +/* This should be enabled after initializing configuratin registers
3015 + * Also should check link status retraining bit
3017 +#define PCIE_RC_CCR_LTSSM_ENABLE 0x00000001 /* Enable LTSSM to continue link establishment */
3019 +/* RC Core Debug Register */
3020 +#define PCIE_RC_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x14)
3021 +#define PCIE_RC_DR_DLL_UP 0x00000001 /* Data Link Layer Up */
3022 +#define PCIE_RC_DR_CURRENT_POWER_STATE 0x0000000E /* Current Power State */
3023 +#define PCIE_RC_DR_CURRENT_POWER_STATE_S 1
3024 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE 0x000001F0 /* Current LTSSM State */
3025 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE_S 4
3027 +#define PCIE_RC_DR_PM_DEV_STATE 0x00000E00 /* Power Management D-State */
3028 +#define PCIE_RC_DR_PM_DEV_STATE_S 9
3030 +#define PCIE_RC_DR_PM_ENABLED 0x00001000 /* Power Management State from PMU */
3031 +#define PCIE_RC_DR_PME_EVENT_ENABLED 0x00002000 /* Power Management Event Enable State */
3032 +#define PCIE_RC_DR_AUX_POWER_ENABLED 0x00004000 /* Auxiliary Power Enable */
3034 +/* Current Power State Definition */
3036 + PCIE_RC_DR_D0 = 0,
3037 + PCIE_RC_DR_D1, /* Not supported */
3038 + PCIE_RC_DR_D2, /* Not supported */
3043 +/* PHY Link Status Register */
3044 +#define PCIE_PHY_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x18)
3045 +#define PCIE_PHY_SR_PHY_LINK_UP 0x00000001 /* PHY Link Up/Down Indicator */
3047 +/* Electromechanical Control Register */
3048 +#define PCIE_EM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x1C)
3049 +#define PCIE_EM_CR_CARD_IS_PRESENT 0x00000001 /* Card Presence Detect State */
3050 +#define PCIE_EM_CR_MRL_OPEN 0x00000002 /* MRL Sensor State */
3051 +#define PCIE_EM_CR_POWER_FAULT_SET 0x00000004 /* Power Fault Detected */
3052 +#define PCIE_EM_CR_MRL_SENSOR_SET 0x00000008 /* MRL Sensor Changed */
3053 +#define PCIE_EM_CR_PRESENT_DETECT_SET 0x00000010 /* Card Presense Detect Changed */
3054 +#define PCIE_EM_CR_CMD_CPL_INT_SET 0x00000020 /* Command Complete Interrupt */
3055 +#define PCIE_EM_CR_SYS_INTERLOCK_SET 0x00000040 /* System Electromechanical IterLock Engaged */
3056 +#define PCIE_EM_CR_ATTENTION_BUTTON_SET 0x00000080 /* Attention Button Pressed */
3058 +/* Interrupt Status Register */
3059 +#define PCIE_IR_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x20)
3060 +#define PCIE_IR_SR_PME_CAUSE_MSI 0x00000002 /* MSI caused by PME */
3061 +#define PCIE_IR_SR_HP_PME_WAKE_GEN 0x00000004 /* Hotplug PME Wake Generation */
3062 +#define PCIE_IR_SR_HP_MSI 0x00000008 /* Hotplug MSI */
3063 +#define PCIE_IR_SR_AHB_LU_ERR 0x00000030 /* AHB Bridge Lookup Error Signals */
3064 +#define PCIE_IR_SR_AHB_LU_ERR_S 4
3065 +#define PCIE_IR_SR_INT_MSG_NUM 0x00003E00 /* Interrupt Message Number */
3066 +#define PCIE_IR_SR_INT_MSG_NUM_S 9
3067 +#define PCIE_IR_SR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
3068 +#define PCIE_IR_SR_AER_INT_MSG_NUM_S 27
3070 +/* Message Control Register */
3071 +#define PCIE_MSG_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x30)
3072 +#define PCIE_MSG_CR_GEN_PME_TURN_OFF_MSG 0x00000001 /* Generate PME Turn Off Message */
3073 +#define PCIE_MSG_CR_GEN_UNLOCK_MSG 0x00000002 /* Generate Unlock Message */
3075 +#define PCIE_VDM_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x34)
3077 +/* Vendor-Defined Message Requester ID Register */
3078 +#define PCIE_VDM_RID(X) (PCIE_APP_PORT_TO_BASE (X) + 0x38)
3079 +#define PCIE_VDM_RID_VENROR_MSG_REQ_ID 0x0000FFFF
3080 +#define PCIE_VDM_RID_VDMRID_S 0
3082 +/* ASPM Control Register */
3083 +#define PCIE_ASPM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x40)
3084 +#define PCIE_ASPM_CR_HOT_RST 0x00000001 /* Hot Reset Request to the downstream device */
3085 +#define PCIE_ASPM_CR_REQ_EXIT_L1 0x00000002 /* Request to Exit L1 */
3086 +#define PCIE_ASPM_CR_REQ_ENTER_L1 0x00000004 /* Request to Enter L1 */
3088 +/* Vendor Message DW0 Register */
3089 +#define PCIE_VM_MSG_DW0(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x50)
3090 +#define PCIE_VM_MSG_DW0_TYPE 0x0000001F /* Message type */
3091 +#define PCIE_VM_MSG_DW0_TYPE_S 0
3092 +#define PCIE_VM_MSG_DW0_FORMAT 0x00000060 /* Format */
3093 +#define PCIE_VM_MSG_DW0_FORMAT_S 5
3094 +#define PCIE_VM_MSG_DW0_TC 0x00007000 /* Traffic Class */
3095 +#define PCIE_VM_MSG_DW0_TC_S 12
3096 +#define PCIE_VM_MSG_DW0_ATTR 0x000C0000 /* Atrributes */
3097 +#define PCIE_VM_MSG_DW0_ATTR_S 18
3098 +#define PCIE_VM_MSG_DW0_EP_TLP 0x00100000 /* Poisoned TLP */
3099 +#define PCIE_VM_MSG_DW0_TD 0x00200000 /* TLP Digest */
3100 +#define PCIE_VM_MSG_DW0_LEN 0xFFC00000 /* Length */
3101 +#define PCIE_VM_MSG_DW0_LEN_S 22
3103 +/* Format Definition */
3105 + PCIE_VM_MSG_FORMAT_00 = 0, /* 3DW Hdr, no data*/
3106 + PCIE_VM_MSG_FORMAT_01, /* 4DW Hdr, no data */
3107 + PCIE_VM_MSG_FORMAT_10, /* 3DW Hdr, with data */
3108 + PCIE_VM_MSG_FORMAT_11, /* 4DW Hdr, with data */
3111 +/* Traffic Class Definition */
3113 + PCIE_VM_MSG_TC0 = 0,
3123 +/* Attributes Definition */
3125 + PCIE_VM_MSG_ATTR_00 = 0, /* RO and No Snoop cleared */
3126 + PCIE_VM_MSG_ATTR_01, /* RO cleared , No Snoop set */
3127 + PCIE_VM_MSG_ATTR_10, /* RO set, No Snoop cleared*/
3128 + PCIE_VM_MSG_ATTR_11, /* RO and No Snoop set */
3131 +/* Payload Size Definition */
3132 +#define PCIE_VM_MSG_LEN_MIN 0
3133 +#define PCIE_VM_MSG_LEN_MAX 1024
3135 +/* Vendor Message DW1 Register */
3136 +#define PCIE_VM_MSG_DW1(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x54)
3137 +#define PCIE_VM_MSG_DW1_FUNC_NUM 0x00000070 /* Function Number */
3138 +#define PCIE_VM_MSG_DW1_FUNC_NUM_S 8
3139 +#define PCIE_VM_MSG_DW1_CODE 0x00FF0000 /* Message Code */
3140 +#define PCIE_VM_MSG_DW1_CODE_S 16
3141 +#define PCIE_VM_MSG_DW1_TAG 0xFF000000 /* Tag */
3142 +#define PCIE_VM_MSG_DW1_TAG_S 24
3144 +#define PCIE_VM_MSG_DW2(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x58)
3145 +#define PCIE_VM_MSG_DW3(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x5C)
3147 +/* Vendor Message Request Register */
3148 +#define PCIE_VM_MSG_REQR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x60)
3149 +#define PCIE_VM_MSG_REQR_REQ 0x00000001 /* Vendor Message Request */
3152 +/* AHB Slave Side Band Control Register */
3153 +#define PCIE_AHB_SSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x70)
3154 +#define PCIE_AHB_SSB_REQ_BCM 0x00000001 /* Slave Reques BCM filed */
3155 +#define PCIE_AHB_SSB_REQ_EP 0x00000002 /* Slave Reques EP filed */
3156 +#define PCIE_AHB_SSB_REQ_TD 0x00000004 /* Slave Reques TD filed */
3157 +#define PCIE_AHB_SSB_REQ_ATTR 0x00000018 /* Slave Reques Attribute number */
3158 +#define PCIE_AHB_SSB_REQ_ATTR_S 3
3159 +#define PCIE_AHB_SSB_REQ_TC 0x000000E0 /* Slave Request TC Field */
3160 +#define PCIE_AHB_SSB_REQ_TC_S 5
3162 +/* AHB Master SideBand Ctrl Register */
3163 +#define PCIE_AHB_MSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x74)
3164 +#define PCIE_AHB_MSB_RESP_ATTR 0x00000003 /* Master Response Attribute number */
3165 +#define PCIE_AHB_MSB_RESP_ATTR_S 0
3166 +#define PCIE_AHB_MSB_RESP_BAD_EOT 0x00000004 /* Master Response Badeot filed */
3167 +#define PCIE_AHB_MSB_RESP_BCM 0x00000008 /* Master Response BCM filed */
3168 +#define PCIE_AHB_MSB_RESP_EP 0x00000010 /* Master Response EP filed */
3169 +#define PCIE_AHB_MSB_RESP_TD 0x00000020 /* Master Response TD filed */
3170 +#define PCIE_AHB_MSB_RESP_FUN_NUM 0x000003C0 /* Master Response Function number */
3171 +#define PCIE_AHB_MSB_RESP_FUN_NUM_S 6
3173 +/* AHB Control Register, fixed bus enumeration exception */
3174 +#define PCIE_AHB_CTRL(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x78)
3175 +#define PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS 0x00000001
3177 +/* Interrupt Enalbe Register */
3178 +#define PCIE_IRNEN(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF4)
3179 +#define PCIE_IRNCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF8)
3180 +#define PCIE_IRNICR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xFC)
3182 +/* PCIe interrupt enable/control/capture register definition */
3183 +#define PCIE_IRN_AER_REPORT 0x00000001 /* AER Interrupt */
3184 +#define PCIE_IRN_AER_MSIX 0x00000002 /* Advanced Error MSI-X Interrupt */
3185 +#define PCIE_IRN_PME 0x00000004 /* PME Interrupt */
3186 +#define PCIE_IRN_HOTPLUG 0x00000008 /* Hotplug Interrupt */
3187 +#define PCIE_IRN_RX_VDM_MSG 0x00000010 /* Vendor-Defined Message Interrupt */
3188 +#define PCIE_IRN_RX_CORRECTABLE_ERR_MSG 0x00000020 /* Correctable Error Message Interrupt */
3189 +#define PCIE_IRN_RX_NON_FATAL_ERR_MSG 0x00000040 /* Non-fatal Error Message */
3190 +#define PCIE_IRN_RX_FATAL_ERR_MSG 0x00000080 /* Fatal Error Message */
3191 +#define PCIE_IRN_RX_PME_MSG 0x00000100 /* PME Message Interrupt */
3192 +#define PCIE_IRN_RX_PME_TURNOFF_ACK 0x00000200 /* PME Turnoff Ack Message Interrupt */
3193 +#define PCIE_IRN_AHB_BR_FATAL_ERR 0x00000400 /* AHB Fatal Error Interrupt */
3194 +#define PCIE_IRN_LINK_AUTO_BW_STATUS 0x00000800 /* Link Auto Bandwidth Status Interrupt */
3195 +#define PCIE_IRN_BW_MGT 0x00001000 /* Bandwidth Managment Interrupt */
3196 +#define PCIE_IRN_INTA 0x00002000 /* INTA */
3197 +#define PCIE_IRN_INTB 0x00004000 /* INTB */
3198 +#define PCIE_IRN_INTC 0x00008000 /* INTC */
3199 +#define PCIE_IRN_INTD 0x00010000 /* INTD */
3200 +#define PCIE_IRN_WAKEUP 0x00020000 /* Wake up Interrupt */
3202 +#define PCIE_RC_CORE_COMBINED_INT (PCIE_IRN_AER_REPORT | PCIE_IRN_AER_MSIX | PCIE_IRN_PME | \
3203 + PCIE_IRN_HOTPLUG | PCIE_IRN_RX_VDM_MSG | PCIE_IRN_RX_CORRECTABLE_ERR_MSG |\
3204 + PCIE_IRN_RX_NON_FATAL_ERR_MSG | PCIE_IRN_RX_FATAL_ERR_MSG | \
3205 + PCIE_IRN_RX_PME_MSG | PCIE_IRN_RX_PME_TURNOFF_ACK | PCIE_IRN_AHB_BR_FATAL_ERR | \
3206 + PCIE_IRN_LINK_AUTO_BW_STATUS | PCIE_IRN_BW_MGT)
3207 +/* PCIe RC Configuration Register */
3208 +#define PCIE_VDID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x00)
3210 +/* Bit definition from pci_reg.h */
3211 +#define PCIE_PCICMDSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x04)
3212 +#define PCIE_CCRID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x08)
3213 +#define PCIE_CLSLTHTBR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x0C) /* EP only */
3214 +/* BAR0, BAR1,Only necessary if the bridges implements a device-specific register set or memory buffer */
3215 +#define PCIE_BAR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10) /* Not used*/
3216 +#define PCIE_BAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14) /* Not used */
3218 +#define PCIE_BNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x18) /* Mandatory */
3219 +/* Bus Number Register bits */
3220 +#define PCIE_BNR_PRIMARY_BUS_NUM 0x000000FF
3221 +#define PCIE_BNR_PRIMARY_BUS_NUM_S 0
3222 +#define PCIE_PNR_SECONDARY_BUS_NUM 0x0000FF00
3223 +#define PCIE_PNR_SECONDARY_BUS_NUM_S 8
3224 +#define PCIE_PNR_SUB_BUS_NUM 0x00FF0000
3225 +#define PCIE_PNR_SUB_BUS_NUM_S 16
3227 +/* IO Base/Limit Register bits */
3228 +#define PCIE_IOBLSECS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x1C) /* RC only */
3229 +#define PCIE_IOBLSECS_32BIT_IO_ADDR 0x00000001
3230 +#define PCIE_IOBLSECS_IO_BASE_ADDR 0x000000F0
3231 +#define PCIE_IOBLSECS_IO_BASE_ADDR_S 4
3232 +#define PCIE_IOBLSECS_32BIT_IOLIMT 0x00000100
3233 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR 0x0000F000
3234 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR_S 12
3236 +/* Non-prefetchable Memory Base/Limit Register bit */
3237 +#define PCIE_MBML(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x20) /* RC only */
3238 +#define PCIE_MBML_MEM_BASE_ADDR 0x0000FFF0
3239 +#define PCIE_MBML_MEM_BASE_ADDR_S 4
3240 +#define PCIE_MBML_MEM_LIMIT_ADDR 0xFFF00000
3241 +#define PCIE_MBML_MEM_LIMIT_ADDR_S 20
3243 +/* Prefetchable Memory Base/Limit Register bit */
3244 +#define PCIE_PMBL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x24) /* RC only */
3245 +#define PCIE_PMBL_64BIT_ADDR 0x00000001
3246 +#define PCIE_PMBL_UPPER_12BIT 0x0000FFF0
3247 +#define PCIE_PMBL_UPPER_12BIT_S 4
3248 +#define PCIE_PMBL_E64MA 0x00010000
3249 +#define PCIE_PMBL_END_ADDR 0xFFF00000
3250 +#define PCIE_PMBL_END_ADDR_S 20
3251 +#define PCIE_PMBU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x28) /* RC only */
3252 +#define PCIE_PMLU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x2C) /* RC only */
3254 +/* I/O Base/Limit Upper 16 bits register */
3255 +#define PCIE_IO_BANDL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x30) /* RC only */
3256 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE 0x0000FFFF
3257 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE_S 0
3258 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT 0xFFFF0000
3259 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT_S 16
3261 +#define PCIE_CPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x34)
3262 +#define PCIE_EBBAR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x38)
3264 +/* Interrupt and Secondary Bridge Control Register */
3265 +#define PCIE_INTRBCTRL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x3C)
3267 +#define PCIE_INTRBCTRL_INT_LINE 0x000000FF
3268 +#define PCIE_INTRBCTRL_INT_LINE_S 0
3269 +#define PCIE_INTRBCTRL_INT_PIN 0x0000FF00
3270 +#define PCIE_INTRBCTRL_INT_PIN_S 8
3271 +#define PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE 0x00010000 /* #PERR */
3272 +#define PCIE_INTRBCTRL_SERR_ENABLE 0x00020000 /* #SERR */
3273 +#define PCIE_INTRBCTRL_ISA_ENABLE 0x00040000 /* ISA enable, IO 64KB only */
3274 +#define PCIE_INTRBCTRL_VGA_ENABLE 0x00080000 /* VGA enable */
3275 +#define PCIE_INTRBCTRL_VGA_16BIT_DECODE 0x00100000 /* VGA 16bit decode */
3276 +#define PCIE_INTRBCTRL_RST_SECONDARY_BUS 0x00400000 /* Secondary bus rest, hot rest, 1ms */
3277 +/* Others are read only */
3279 + PCIE_INTRBCTRL_INT_NON = 0,
3280 + PCIE_INTRBCTRL_INTA,
3281 + PCIE_INTRBCTRL_INTB,
3282 + PCIE_INTRBCTRL_INTC,
3283 + PCIE_INTRBCTRL_INTD,
3286 +#define PCIE_PM_CAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x40)
3288 +/* Power Management Control and Status Register */
3289 +#define PCIE_PM_CSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x44)
3291 +#define PCIE_PM_CSR_POWER_STATE 0x00000003 /* Power State */
3292 +#define PCIE_PM_CSR_POWER_STATE_S 0
3293 +#define PCIE_PM_CSR_SW_RST 0x00000008 /* Soft Reset Enabled */
3294 +#define PCIE_PM_CSR_PME_ENABLE 0x00000100 /* PME Enable */
3295 +#define PCIE_PM_CSR_PME_STATUS 0x00008000 /* PME status */
3297 +/* MSI Capability Register for EP */
3298 +#define PCIE_MCAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x50)
3300 +#define PCIE_MCAPR_MSI_CAP_ID 0x000000FF /* MSI Capability ID */
3301 +#define PCIE_MCAPR_MSI_CAP_ID_S 0
3302 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR 0x0000FF00 /* Next Capability Pointer */
3303 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR_S 8
3304 +#define PCIE_MCAPR_MSI_ENABLE 0x00010000 /* MSI Enable */
3305 +#define PCIE_MCAPR_MULTI_MSG_CAP 0x000E0000 /* Multiple Message Capable */
3306 +#define PCIE_MCAPR_MULTI_MSG_CAP_S 17
3307 +#define PCIE_MCAPR_MULTI_MSG_ENABLE 0x00700000 /* Multiple Message Enable */
3308 +#define PCIE_MCAPR_MULTI_MSG_ENABLE_S 20
3309 +#define PCIE_MCAPR_ADDR64_CAP 0X00800000 /* 64-bit Address Capable */
3311 +/* MSI Message Address Register */
3312 +#define PCIE_MA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x54)
3314 +#define PCIE_MA_ADDR_MASK 0xFFFFFFFC /* Message Address */
3316 +/* MSI Message Upper Address Register */
3317 +#define PCIE_MUA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x58)
3319 +/* MSI Message Data Register */
3320 +#define PCIE_MD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x5C)
3322 +#define PCIE_MD_DATA 0x0000FFFF /* Message Data */
3323 +#define PCIE_MD_DATA_S 0
3325 +/* PCI Express Capability Register */
3326 +#define PCIE_XCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70)
3328 +#define PCIE_XCAP_ID 0x000000FF /* PCI Express Capability ID */
3329 +#define PCIE_XCAP_ID_S 0
3330 +#define PCIE_XCAP_NEXT_CAP 0x0000FF00 /* Next Capability Pointer */
3331 +#define PCIE_XCAP_NEXT_CAP_S 8
3332 +#define PCIE_XCAP_VER 0x000F0000 /* PCI Express Capability Version */
3333 +#define PCIE_XCAP_VER_S 16
3334 +#define PCIE_XCAP_DEV_PORT_TYPE 0x00F00000 /* Device Port Type */
3335 +#define PCIE_XCAP_DEV_PORT_TYPE_S 20
3336 +#define PCIE_XCAP_SLOT_IMPLEMENTED 0x01000000 /* Slot Implemented */
3337 +#define PCIE_XCAP_MSG_INT_NUM 0x3E000000 /* Interrupt Message Number */
3338 +#define PCIE_XCAP_MSG_INT_NUM_S 25
3340 +/* Device Capability Register */
3341 +#define PCIE_DCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74)
3343 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE 0x00000007 /* Max Payload size */
3344 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE_S 0
3345 +#define PCIE_DCAP_PHANTOM_FUNC 0x00000018 /* Phanton Function, not supported */
3346 +#define PCIE_DCAP_PHANTOM_FUNC_S 3
3347 +#define PCIE_DCAP_EXT_TAG 0x00000020 /* Extended Tag Field */
3348 +#define PCIE_DCAP_EP_L0S_LATENCY 0x000001C0 /* EP L0s latency only */
3349 +#define PCIE_DCAP_EP_L0S_LATENCY_S 6
3350 +#define PCIE_DCAP_EP_L1_LATENCY 0x00000E00 /* EP L1 latency only */
3351 +#define PCIE_DCAP_EP_L1_LATENCY_S 9
3352 +#define PCIE_DCAP_ROLE_BASE_ERR_REPORT 0x00008000 /* Role Based ERR */
3354 +/* Maximum payload size supported */
3356 + PCIE_MAX_PAYLOAD_128 = 0,
3357 + PCIE_MAX_PAYLOAD_256,
3358 + PCIE_MAX_PAYLOAD_512,
3359 + PCIE_MAX_PAYLOAD_1024,
3360 + PCIE_MAX_PAYLOAD_2048,
3361 + PCIE_MAX_PAYLOAD_4096,
3364 +/* Device Control and Status Register */
3365 +#define PCIE_DCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x78)
3367 +#define PCIE_DCTLSTS_CORRECTABLE_ERR_EN 0x00000001 /* COR-ERR */
3368 +#define PCIE_DCTLSTS_NONFATAL_ERR_EN 0x00000002 /* Non-fatal ERR */
3369 +#define PCIE_DCTLSTS_FATAL_ERR_EN 0x00000004 /* Fatal ERR */
3370 +#define PCIE_DCTLSYS_UR_REQ_EN 0x00000008 /* UR ERR */
3371 +#define PCIE_DCTLSTS_RELAXED_ORDERING_EN 0x00000010 /* Enable relaxing ordering */
3372 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE 0x000000E0 /* Max payload mask */
3373 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE_S 5
3374 +#define PCIE_DCTLSTS_EXT_TAG_EN 0x00000100 /* Extended tag field */
3375 +#define PCIE_DCTLSTS_PHANTOM_FUNC_EN 0x00000200 /* Phantom Function Enable */
3376 +#define PCIE_DCTLSTS_AUX_PM_EN 0x00000400 /* AUX Power PM Enable */
3377 +#define PCIE_DCTLSTS_NO_SNOOP_EN 0x00000800 /* Enable no snoop, except root port*/
3378 +#define PCIE_DCTLSTS_MAX_READ_SIZE 0x00007000 /* Max Read Request size*/
3379 +#define PCIE_DCTLSTS_MAX_READ_SIZE_S 12
3380 +#define PCIE_DCTLSTS_CORRECTABLE_ERR 0x00010000 /* COR-ERR Detected */
3381 +#define PCIE_DCTLSTS_NONFATAL_ERR 0x00020000 /* Non-Fatal ERR Detected */
3382 +#define PCIE_DCTLSTS_FATAL_ER 0x00040000 /* Fatal ERR Detected */
3383 +#define PCIE_DCTLSTS_UNSUPPORTED_REQ 0x00080000 /* UR Detected */
3384 +#define PCIE_DCTLSTS_AUX_POWER 0x00100000 /* Aux Power Detected */
3385 +#define PCIE_DCTLSTS_TRANSACT_PENDING 0x00200000 /* Transaction pending */
3387 +#define PCIE_DCTLSTS_ERR_EN (PCIE_DCTLSTS_CORRECTABLE_ERR_EN | \
3388 + PCIE_DCTLSTS_NONFATAL_ERR_EN | PCIE_DCTLSTS_FATAL_ERR_EN | \
3389 + PCIE_DCTLSYS_UR_REQ_EN)
3391 +/* Link Capability Register */
3392 +#define PCIE_LCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7C)
3393 +#define PCIE_LCAP_MAX_LINK_SPEED 0x0000000F /* Max link speed, 0x1 by default */
3394 +#define PCIE_LCAP_MAX_LINK_SPEED_S 0
3395 +#define PCIE_LCAP_MAX_LENGTH_WIDTH 0x000003F0 /* Maxium Length Width */
3396 +#define PCIE_LCAP_MAX_LENGTH_WIDTH_S 4
3397 +#define PCIE_LCAP_ASPM_LEVEL 0x00000C00 /* Active State Link PM Support */
3398 +#define PCIE_LCAP_ASPM_LEVEL_S 10
3399 +#define PCIE_LCAP_L0S_EIXT_LATENCY 0x00007000 /* L0s Exit Latency */
3400 +#define PCIE_LCAP_L0S_EIXT_LATENCY_S 12
3401 +#define PCIE_LCAP_L1_EXIT_LATENCY 0x00038000 /* L1 Exit Latency */
3402 +#define PCIE_LCAP_L1_EXIT_LATENCY_S 15
3403 +#define PCIE_LCAP_CLK_PM 0x00040000 /* Clock Power Management */
3404 +#define PCIE_LCAP_SDER 0x00080000 /* Surprise Down Error Reporting */
3405 +#define PCIE_LCAP_DLL_ACTIVE_REPROT 0x00100000 /* Data Link Layer Active Reporting Capable */
3406 +#define PCIE_LCAP_PORT_NUM 0xFF0000000 /* Port number */
3407 +#define PCIE_LCAP_PORT_NUM_S 24
3409 +/* Maximum Length width definition */
3410 +#define PCIE_MAX_LENGTH_WIDTH_RES 0x00
3411 +#define PCIE_MAX_LENGTH_WIDTH_X1 0x01 /* Default */
3412 +#define PCIE_MAX_LENGTH_WIDTH_X2 0x02
3413 +#define PCIE_MAX_LENGTH_WIDTH_X4 0x04
3414 +#define PCIE_MAX_LENGTH_WIDTH_X8 0x08
3415 +#define PCIE_MAX_LENGTH_WIDTH_X12 0x0C
3416 +#define PCIE_MAX_LENGTH_WIDTH_X16 0x10
3417 +#define PCIE_MAX_LENGTH_WIDTH_X32 0x20
3419 +/* Active State Link PM definition */
3421 + PCIE_ASPM_RES0 = 0,
3422 + PCIE_ASPM_L0S_ENTRY_SUPPORT, /* L0s */
3424 + PCIE_ASPM_L0S_L1_ENTRY_SUPPORT, /* L0s and L1, default */
3427 +/* L0s Exit Latency definition */
3429 + PCIE_L0S_EIXT_LATENCY_L64NS = 0, /* < 64 ns */
3430 + PCIE_L0S_EIXT_LATENCY_B64A128, /* > 64 ns < 128 ns */
3431 + PCIE_L0S_EIXT_LATENCY_B128A256, /* > 128 ns < 256 ns */
3432 + PCIE_L0S_EIXT_LATENCY_B256A512, /* > 256 ns < 512 ns */
3433 + PCIE_L0S_EIXT_LATENCY_B512TO1U, /* > 512 ns < 1 us */
3434 + PCIE_L0S_EIXT_LATENCY_B1A2U, /* > 1 us < 2 us */
3435 + PCIE_L0S_EIXT_LATENCY_B2A4U, /* > 2 us < 4 us */
3436 + PCIE_L0S_EIXT_LATENCY_M4US, /* > 4 us */
3439 +/* L1 Exit Latency definition */
3441 + PCIE_L1_EXIT_LATENCY_L1US = 0, /* < 1 us */
3442 + PCIE_L1_EXIT_LATENCY_B1A2, /* > 1 us < 2 us */
3443 + PCIE_L1_EXIT_LATENCY_B2A4, /* > 2 us < 4 us */
3444 + PCIE_L1_EXIT_LATENCY_B4A8, /* > 4 us < 8 us */
3445 + PCIE_L1_EXIT_LATENCY_B8A16, /* > 8 us < 16 us */
3446 + PCIE_L1_EXIT_LATENCY_B16A32, /* > 16 us < 32 us */
3447 + PCIE_L1_EXIT_LATENCY_B32A64, /* > 32 us < 64 us */
3448 + PCIE_L1_EXIT_LATENCY_M64US, /* > 64 us */
3451 +/* Link Control and Status Register */
3452 +#define PCIE_LCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x80)
3453 +#define PCIE_LCTLSTS_ASPM_ENABLE 0x00000003 /* Active State Link PM Control */
3454 +#define PCIE_LCTLSTS_ASPM_ENABLE_S 0
3455 +#define PCIE_LCTLSTS_RCB128 0x00000008 /* Read Completion Boundary 128*/
3456 +#define PCIE_LCTLSTS_LINK_DISABLE 0x00000010 /* Link Disable */
3457 +#define PCIE_LCTLSTS_RETRIAN_LINK 0x00000020 /* Retrain Link */
3458 +#define PCIE_LCTLSTS_COM_CLK_CFG 0x00000040 /* Common Clock Configuration */
3459 +#define PCIE_LCTLSTS_EXT_SYNC 0x00000080 /* Extended Synch */
3460 +#define PCIE_LCTLSTS_CLK_PM_EN 0x00000100 /* Enable Clock Powerm Management */
3461 +#define PCIE_LCTLSTS_LINK_SPEED 0x000F0000 /* Link Speed */
3462 +#define PCIE_LCTLSTS_LINK_SPEED_S 16
3463 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH 0x03F00000 /* Negotiated Link Width */
3464 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH_S 20
3465 +#define PCIE_LCTLSTS_RETRAIN_PENDING 0x08000000 /* Link training is ongoing */
3466 +#define PCIE_LCTLSTS_SLOT_CLK_CFG 0x10000000 /* Slot Clock Configuration */
3467 +#define PCIE_LCTLSTS_DLL_ACTIVE 0x20000000 /* Data Link Layer Active */
3469 +/* Slot Capabilities Register */
3470 +#define PCIE_SLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x84)
3472 +/* Slot Capabilities */
3473 +#define PCIE_SLCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x88)
3475 +/* Root Control and Capability Register */
3476 +#define PCIE_RCTLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x8C)
3477 +#define PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR 0x00000001 /* #SERR on COR-ERR */
3478 +#define PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR 0x00000002 /* #SERR on Non-Fatal ERR */
3479 +#define PCIE_RCTLCAP_SERR_ON_FATAL_ERR 0x00000004 /* #SERR on Fatal ERR */
3480 +#define PCIE_RCTLCAP_PME_INT_EN 0x00000008 /* PME Interrupt Enable */
3481 +#define PCIE_RCTLCAP_SERR_ENABLE (PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR | \
3482 + PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR | PCIE_RCTLCAP_SERR_ON_FATAL_ERR)
3483 +/* Root Status Register */
3484 +#define PCIE_RSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x90)
3485 +#define PCIE_RSTS_PME_REQ_ID 0x0000FFFF /* PME Request ID */
3486 +#define PCIE_RSTS_PME_REQ_ID_S 0
3487 +#define PCIE_RSTS_PME_STATUS 0x00010000 /* PME Status */
3488 +#define PCIE_RSTS_PME_PENDING 0x00020000 /* PME Pending */
3490 +/* PCI Express Enhanced Capability Header */
3491 +#define PCIE_ENHANCED_CAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x100)
3492 +#define PCIE_ENHANCED_CAP_ID 0x0000FFFF /* PCI Express Extended Capability ID */
3493 +#define PCIE_ENHANCED_CAP_ID_S 0
3494 +#define PCIE_ENHANCED_CAP_VER 0x000F0000 /* Capability Version */
3495 +#define PCIE_ENHANCED_CAP_VER_S 16
3496 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET 0xFFF00000 /* Next Capability Offset */
3497 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET_S 20
3499 +/* Uncorrectable Error Status Register */
3500 +#define PCIE_UES_R(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x104)
3501 +#define PCIE_DATA_LINK_PROTOCOL_ERR 0x00000010 /* Data Link Protocol Error Status */
3502 +#define PCIE_SURPRISE_DOWN_ERROR 0x00000020 /* Surprise Down Error Status */
3503 +#define PCIE_POISONED_TLP 0x00001000 /* Poisoned TLP Status */
3504 +#define PCIE_FC_PROTOCOL_ERR 0x00002000 /* Flow Control Protocol Error Status */
3505 +#define PCIE_COMPLETION_TIMEOUT 0x00004000 /* Completion Timeout Status */
3506 +#define PCIE_COMPLETOR_ABORT 0x00008000 /* Completer Abort Error */
3507 +#define PCIE_UNEXPECTED_COMPLETION 0x00010000 /* Unexpected Completion Status */
3508 +#define PCIE_RECEIVER_OVERFLOW 0x00020000 /* Receive Overflow Status */
3509 +#define PCIE_MALFORNED_TLP 0x00040000 /* Malformed TLP Stauts */
3510 +#define PCIE_ECRC_ERR 0x00080000 /* ECRC Error Stauts */
3511 +#define PCIE_UR_REQ 0x00100000 /* Unsupported Request Error Status */
3512 +#define PCIE_ALL_UNCORRECTABLE_ERR (PCIE_DATA_LINK_PROTOCOL_ERR | PCIE_SURPRISE_DOWN_ERROR | \
3513 + PCIE_POISONED_TLP | PCIE_FC_PROTOCOL_ERR | PCIE_COMPLETION_TIMEOUT | \
3514 + PCIE_COMPLETOR_ABORT | PCIE_UNEXPECTED_COMPLETION | PCIE_RECEIVER_OVERFLOW |\
3515 + PCIE_MALFORNED_TLP | PCIE_ECRC_ERR | PCIE_UR_REQ)
3517 +/* Uncorrectable Error Mask Register, Mask means no report */
3518 +#define PCIE_UEMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x108)
3520 +/* Uncorrectable Error Severity Register */
3521 +#define PCIE_UESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10C)
3523 +/* Correctable Error Status Register */
3524 +#define PCIE_CESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x110)
3525 +#define PCIE_RX_ERR 0x00000001 /* Receive Error Status */
3526 +#define PCIE_BAD_TLP 0x00000040 /* Bad TLP Status */
3527 +#define PCIE_BAD_DLLP 0x00000080 /* Bad DLLP Status */
3528 +#define PCIE_REPLAY_NUM_ROLLOVER 0x00000100 /* Replay Number Rollover Status */
3529 +#define PCIE_REPLAY_TIMER_TIMEOUT_ERR 0x00001000 /* Reply Timer Timeout Status */
3530 +#define PCIE_ADVISORY_NONFTAL_ERR 0x00002000 /* Advisory Non-Fatal Error Status */
3531 +#define PCIE_CORRECTABLE_ERR (PCIE_RX_ERR | PCIE_BAD_TLP | PCIE_BAD_DLLP | PCIE_REPLAY_NUM_ROLLOVER |\
3532 + PCIE_REPLAY_TIMER_TIMEOUT_ERR | PCIE_ADVISORY_NONFTAL_ERR)
3534 +/* Correctable Error Mask Register */
3535 +#define PCIE_CEMR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x114)
3537 +/* Advanced Error Capabilities and Control Register */
3538 +#define PCIE_AECCR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x118)
3539 +#define PCIE_AECCR_FIRST_ERR_PTR 0x0000001F /* First Error Pointer */
3540 +#define PCIE_AECCR_FIRST_ERR_PTR_S 0
3541 +#define PCIE_AECCR_ECRC_GEN_CAP 0x00000020 /* ECRC Generation Capable */
3542 +#define PCIE_AECCR_ECRC_GEN_EN 0x00000040 /* ECRC Generation Enable */
3543 +#define PCIE_AECCR_ECRC_CHECK_CAP 0x00000080 /* ECRC Check Capable */
3544 +#define PCIE_AECCR_ECRC_CHECK_EN 0x00000100 /* ECRC Check Enable */
3546 +/* Header Log Register 1 */
3547 +#define PCIE_HLR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x11C)
3549 +/* Header Log Register 2 */
3550 +#define PCIE_HLR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x120)
3552 +/* Header Log Register 3 */
3553 +#define PCIE_HLR3(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x124)
3555 +/* Header Log Register 4 */
3556 +#define PCIE_HLR4(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x128)
3558 +/* Root Error Command Register */
3559 +#define PCIE_RECR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x12C)
3560 +#define PCIE_RECR_CORRECTABLE_ERR_REPORT_EN 0x00000001 /* COR-ERR */
3561 +#define PCIE_RECR_NONFATAL_ERR_REPORT_EN 0x00000002 /* Non-Fatal ERR */
3562 +#define PCIE_RECR_FATAL_ERR_REPORT_EN 0x00000004 /* Fatal ERR */
3563 +#define PCIE_RECR_ERR_REPORT_EN (PCIE_RECR_CORRECTABLE_ERR_REPORT_EN | \
3564 + PCIE_RECR_NONFATAL_ERR_REPORT_EN | PCIE_RECR_FATAL_ERR_REPORT_EN)
3566 +/* Root Error Status Register */
3567 +#define PCIE_RESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x130)
3568 +#define PCIE_RESR_CORRECTABLE_ERR 0x00000001 /* COR-ERR Receveid */
3569 +#define PCIE_RESR_MULTI_CORRECTABLE_ERR 0x00000002 /* Multiple COR-ERR Received */
3570 +#define PCIE_RESR_FATAL_NOFATAL_ERR 0x00000004 /* ERR Fatal/Non-Fatal Received */
3571 +#define PCIE_RESR_MULTI_FATAL_NOFATAL_ERR 0x00000008 /* Multiple ERR Fatal/Non-Fatal Received */
3572 +#define PCIE_RESR_FIRST_UNCORRECTABLE_FATAL_ERR 0x00000010 /* First UN-COR Fatal */
3573 +#define PCIR_RESR_NON_FATAL_ERR 0x00000020 /* Non-Fatal Error Message Received */
3574 +#define PCIE_RESR_FATAL_ERR 0x00000040 /* Fatal Message Received */
3575 +#define PCIE_RESR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
3576 +#define PCIE_RESR_AER_INT_MSG_NUM_S 27
3578 +/* Error Source Indentification Register */
3579 +#define PCIE_ESIR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x134)
3580 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID 0x0000FFFF
3581 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID_S 0
3582 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID 0xFFFF0000
3583 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID_S 16
3585 +/* VC Enhanced Capability Header */
3586 +#define PCIE_VC_ECH(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x140)
3588 +/* Port VC Capability Register */
3589 +#define PCIE_PVC1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x144)
3590 +#define PCIE_PVC1_EXT_VC_CNT 0x00000007 /* Extended VC Count */
3591 +#define PCIE_PVC1_EXT_VC_CNT_S 0
3592 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT 0x00000070 /* Low Priority Extended VC Count */
3593 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT_S 4
3594 +#define PCIE_PVC1_REF_CLK 0x00000300 /* Reference Clock */
3595 +#define PCIE_PVC1_REF_CLK_S 8
3596 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE 0x00000C00 /* Port Arbitration Table Entry Size */
3597 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE_S 10
3599 +/* Extended Virtual Channel Count Defintion */
3600 +#define PCIE_EXT_VC_CNT_MIN 0
3601 +#define PCIE_EXT_VC_CNT_MAX 7
3603 +/* Port Arbitration Table Entry Size Definition */
3605 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S1BIT = 0,
3606 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S2BIT,
3607 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S4BIT,
3608 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S8BIT,
3611 +/* Port VC Capability Register 2 */
3612 +#define PCIE_PVC2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x148)
3613 +#define PCIE_PVC2_VC_ARB_16P_FIXED_WRR 0x00000001 /* HW Fixed arbitration, 16 phase WRR */
3614 +#define PCIE_PVC2_VC_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
3615 +#define PCIE_PVC2_VC_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
3616 +#define PCIE_PVC2_VC_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
3617 +#define PCIE_PVC2_VC_ARB_WRR 0x0000000F
3618 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET 0xFF000000 /* VC arbitration table offset, not support */
3619 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET_S 24
3621 +/* Port VC Control and Status Register */
3622 +#define PCIE_PVCCRSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14C)
3623 +#define PCIE_PVCCRSR_LOAD_VC_ARB_TAB 0x00000001 /* Load VC Arbitration Table */
3624 +#define PCIE_PVCCRSR_VC_ARB_SEL 0x0000000E /* VC Arbitration Select */
3625 +#define PCIE_PVCCRSR_VC_ARB_SEL_S 1
3626 +#define PCIE_PVCCRSR_VC_ARB_TAB_STATUS 0x00010000 /* Arbitration Status */
3628 +/* VC0 Resource Capability Register */
3629 +#define PCIE_VC0_RC(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x150)
3630 +#define PCIE_VC0_RC_PORT_ARB_HW_FIXED 0x00000001 /* HW Fixed arbitration */
3631 +#define PCIE_VC0_RC_PORT_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
3632 +#define PCIE_VC0_RC_PORT_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
3633 +#define PCIE_VC0_RC_PORT_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
3634 +#define PCIE_VC0_RC_PORT_ARB_TM_128P_WRR 0x00000010 /* Time-based 128 phase WRR */
3635 +#define PCIE_VC0_RC_PORT_ARB_TM_256P_WRR 0x00000020 /* Time-based 256 phase WRR */
3636 +#define PCIE_VC0_RC_PORT_ARB (PCIE_VC0_RC_PORT_ARB_HW_FIXED | PCIE_VC0_RC_PORT_ARB_32P_WRR |\
3637 + PCIE_VC0_RC_PORT_ARB_64P_WRR | PCIE_VC0_RC_PORT_ARB_128P_WRR | \
3638 + PCIE_VC0_RC_PORT_ARB_TM_128P_WRR | PCIE_VC0_RC_PORT_ARB_TM_256P_WRR)
3640 +#define PCIE_VC0_RC_REJECT_SNOOP 0x00008000 /* Reject Snoop Transactioin */
3641 +#define PCIE_VC0_RC_MAX_TIMESLOTS 0x007F0000 /* Maximum time Slots */
3642 +#define PCIE_VC0_RC_MAX_TIMESLOTS_S 16
3643 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET 0xFF000000 /* Port Arbitration Table Offset */
3644 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET_S 24
3646 +/* VC0 Resource Control Register */
3647 +#define PCIE_VC0_RC0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x154)
3648 +#define PCIE_VC0_RC0_TVM0 0x00000001 /* TC0 and VC0 */
3649 +#define PCIE_VC0_RC0_TVM1 0x00000002 /* TC1 and VC1 */
3650 +#define PCIE_VC0_RC0_TVM2 0x00000004 /* TC2 and VC2 */
3651 +#define PCIE_VC0_RC0_TVM3 0x00000008 /* TC3 and VC3 */
3652 +#define PCIE_VC0_RC0_TVM4 0x00000010 /* TC4 and VC4 */
3653 +#define PCIE_VC0_RC0_TVM5 0x00000020 /* TC5 and VC5 */
3654 +#define PCIE_VC0_RC0_TVM6 0x00000040 /* TC6 and VC6 */
3655 +#define PCIE_VC0_RC0_TVM7 0x00000080 /* TC7 and VC7 */
3656 +#define PCIE_VC0_RC0_TC_VC 0x000000FF /* TC/VC mask */
3658 +#define PCIE_VC0_RC0_LOAD_PORT_ARB_TAB 0x00010000 /* Load Port Arbitration Table */
3659 +#define PCIE_VC0_RC0_PORT_ARB_SEL 0x000E0000 /* Port Arbitration Select */
3660 +#define PCIE_VC0_RC0_PORT_ARB_SEL_S 17
3661 +#define PCIE_VC0_RC0_VC_ID 0x07000000 /* VC ID */
3662 +#define PCIE_VC0_RC0_VC_ID_S 24
3663 +#define PCIE_VC0_RC0_VC_EN 0x80000000 /* VC Enable */
3665 +/* VC0 Resource Status Register */
3666 +#define PCIE_VC0_RSR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x158)
3667 +#define PCIE_VC0_RSR0_PORT_ARB_TAB_STATUS 0x00010000 /* Port Arbitration Table Status,not used */
3668 +#define PCIE_VC0_RSR0_VC_NEG_PENDING 0x00020000 /* VC Negotiation Pending */
3670 +/* Ack Latency Timer and Replay Timer Register */
3671 +#define PCIE_ALTRT(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x700)
3672 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT 0x0000FFFF /* Round Trip Latency Time Limit */
3673 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT_S 0
3674 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT 0xFFFF0000 /* Replay Time Limit */
3675 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT_S 16
3677 +/* Other Message Register */
3678 +#define PCIE_OMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x704)
3680 +/* Port Force Link Register */
3681 +#define PCIE_PFLR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x708)
3682 +#define PCIE_PFLR_LINK_NUM 0x000000FF /* Link Number */
3683 +#define PCIE_PFLR_LINK_NUM_S 0
3684 +#define PCIE_PFLR_FORCE_LINK 0x00008000 /* Force link */
3685 +#define PCIE_PFLR_LINK_STATE 0x003F0000 /* Link State */
3686 +#define PCIE_PFLR_LINK_STATE_S 16
3687 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT 0xFF000000 /* Low Power Entrance Count, only for EP */
3688 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT_S 24
3690 +/* Ack Frequency Register */
3691 +#define PCIE_AFR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70C)
3692 +#define PCIE_AFR_AF 0x000000FF /* Ack Frequency */
3693 +#define PCIE_AFR_AF_S 0
3694 +#define PCIE_AFR_FTS_NUM 0x0000FF00 /* The number of Fast Training Sequence from L0S to L0 */
3695 +#define PCIE_AFR_FTS_NUM_S 8
3696 +#define PCIE_AFR_COM_FTS_NUM 0x00FF0000 /* N_FTS; when common clock is used*/
3697 +#define PCIE_AFR_COM_FTS_NUM_S 16
3698 +#define PCIE_AFR_L0S_ENTRY_LATENCY 0x07000000 /* L0s Entrance Latency */
3699 +#define PCIE_AFR_L0S_ENTRY_LATENCY_S 24
3700 +#define PCIE_AFR_L1_ENTRY_LATENCY 0x38000000 /* L1 Entrance Latency */
3701 +#define PCIE_AFR_L1_ENTRY_LATENCY_S 27
3702 +#define PCIE_AFR_FTS_NUM_DEFAULT 32
3703 +#define PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT 7
3704 +#define PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT 5
3706 +/* Port Link Control Register */
3707 +#define PCIE_PLCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x710)
3708 +#define PCIE_PLCR_OTHER_MSG_REQ 0x00000001 /* Other Message Request */
3709 +#define PCIE_PLCR_SCRAMBLE_DISABLE 0x00000002 /* Scramble Disable */
3710 +#define PCIE_PLCR_LOOPBACK_EN 0x00000004 /* Loopback Enable */
3711 +#define PCIE_PLCR_LTSSM_HOT_RST 0x00000008 /* Force LTSSM to the hot reset */
3712 +#define PCIE_PLCR_DLL_LINK_EN 0x00000020 /* Enable Link initialization */
3713 +#define PCIE_PLCR_FAST_LINK_SIM_EN 0x00000080 /* Sets all internal timers to fast mode for simulation purposes */
3714 +#define PCIE_PLCR_LINK_MODE 0x003F0000 /* Link Mode Enable Mask */
3715 +#define PCIE_PLCR_LINK_MODE_S 16
3716 +#define PCIE_PLCR_CORRUPTED_CRC_EN 0x02000000 /* Enabled Corrupt CRC */
3718 +/* Lane Skew Register */
3719 +#define PCIE_LSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x714)
3720 +#define PCIE_LSR_LANE_SKEW_NUM 0x00FFFFFF /* Insert Lane Skew for Transmit, not applicable */
3721 +#define PCIE_LSR_LANE_SKEW_NUM_S 0
3722 +#define PCIE_LSR_FC_DISABLE 0x01000000 /* Disable of Flow Control */
3723 +#define PCIE_LSR_ACKNAK_DISABLE 0x02000000 /* Disable of Ack/Nak */
3724 +#define PCIE_LSR_LANE_DESKEW_DISABLE 0x80000000 /* Disable of Lane-to-Lane Skew */
3726 +/* Symbol Number Register */
3727 +#define PCIE_SNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x718)
3728 +#define PCIE_SNR_TS 0x0000000F /* Number of TS Symbol */
3729 +#define PCIE_SNR_TS_S 0
3730 +#define PCIE_SNR_SKP 0x00000700 /* Number of SKP Symbol */
3731 +#define PCIE_SNR_SKP_S 8
3732 +#define PCIE_SNR_REPLAY_TIMER 0x0007C000 /* Timer Modifier for Replay Timer */
3733 +#define PCIE_SNR_REPLAY_TIMER_S 14
3734 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER 0x00F80000 /* Timer Modifier for Ack/Nak Latency Timer */
3735 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER_S 19
3736 +#define PCIE_SNR_FC_TIMER 0x1F000000 /* Timer Modifier for Flow Control Watchdog Timer */
3737 +#define PCIE_SNR_FC_TIMER_S 28
3739 +/* Symbol Timer Register and Filter Mask Register 1 */
3740 +#define PCIE_STRFMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x71C)
3741 +#define PCIE_STRFMR_SKP_INTERVAL 0x000007FF /* SKP lnterval Value */
3742 +#define PCIE_STRFMR_SKP_INTERVAL_S 0
3743 +#define PCIE_STRFMR_FC_WDT_DISABLE 0x00008000 /* Disable of FC Watchdog Timer */
3744 +#define PCIE_STRFMR_TLP_FUNC_MISMATCH_OK 0x00010000 /* Mask Function Mismatch Filtering for Incoming Requests */
3745 +#define PCIE_STRFMR_POISONED_TLP_OK 0x00020000 /* Mask Poisoned TLP Filtering */
3746 +#define PCIE_STRFMR_BAR_MATCH_OK 0x00040000 /* Mask BAR Match Filtering */
3747 +#define PCIE_STRFMR_TYPE1_CFG_REQ_OK 0x00080000 /* Mask Type 1 Configuration Request Filtering */
3748 +#define PCIE_STRFMR_LOCKED_REQ_OK 0x00100000 /* Mask Locked Request Filtering */
3749 +#define PCIE_STRFMR_CPL_TAG_ERR_RULES_OK 0x00200000 /* Mask Tag Error Rules for Received Completions */
3750 +#define PCIE_STRFMR_CPL_REQUESTOR_ID_MISMATCH_OK 0x00400000 /* Mask Requester ID Mismatch Error for Received Completions */
3751 +#define PCIE_STRFMR_CPL_FUNC_MISMATCH_OK 0x00800000 /* Mask Function Mismatch Error for Received Completions */
3752 +#define PCIE_STRFMR_CPL_TC_MISMATCH_OK 0x01000000 /* Mask Traffic Class Mismatch Error for Received Completions */
3753 +#define PCIE_STRFMR_CPL_ATTR_MISMATCH_OK 0x02000000 /* Mask Attribute Mismatch Error for Received Completions */
3754 +#define PCIE_STRFMR_CPL_LENGTH_MISMATCH_OK 0x04000000 /* Mask Length Mismatch Error for Received Completions */
3755 +#define PCIE_STRFMR_TLP_ECRC_ERR_OK 0x08000000 /* Mask ECRC Error Filtering */
3756 +#define PCIE_STRFMR_CPL_TLP_ECRC_OK 0x10000000 /* Mask ECRC Error Filtering for Completions */
3757 +#define PCIE_STRFMR_RX_TLP_MSG_NO_DROP 0x20000000 /* Send Message TLPs */
3758 +#define PCIE_STRFMR_RX_IO_TRANS_ENABLE 0x40000000 /* Mask Filtering of received I/O Requests */
3759 +#define PCIE_STRFMR_RX_CFG_TRANS_ENABLE 0x80000000 /* Mask Filtering of Received Configuration Requests */
3761 +#define PCIE_DEF_SKP_INTERVAL 700 /* 1180 ~1538 , 125MHz * 2, 250MHz * 1 */
3763 +/* Filter Masker Register 2 */
3764 +#define PCIE_FMR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x720)
3765 +#define PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1 0x00000001 /* Mask RADM Filtering and Error Handling Rules */
3766 +#define PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 0x00000002 /* Mask RADM Filtering and Error Handling Rules */
3768 +/* Debug Register 0 */
3769 +#define PCIE_DBR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x728)
3771 +/* Debug Register 1 */
3772 +#define PCIE_DBR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x72C)
3774 +/* Transmit Posted FC Credit Status Register */
3775 +#define PCIE_TPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x730)
3776 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS 0x00000FFF /* Transmit Posted Data FC Credits */
3777 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS_S 0
3778 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS 0x000FF000 /* Transmit Posted Header FC Credits */
3779 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS_S 12
3781 +/* Transmit Non-Posted FC Credit Status */
3782 +#define PCIE_TNPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x734)
3783 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS 0x00000FFF /* Transmit Non-Posted Data FC Credits */
3784 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS_S 0
3785 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS 0x000FF000 /* Transmit Non-Posted Header FC Credits */
3786 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS_S 12
3788 +/* Transmit Complete FC Credit Status Register */
3789 +#define PCIE_TCFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x738)
3790 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS 0x00000FFF /* Transmit Completion Data FC Credits */
3791 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS_S 0
3792 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS 0x000FF000 /* Transmit Completion Header FC Credits */
3793 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS_S 12
3795 +/* Queue Status Register */
3796 +#define PCIE_QSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x73C)
3797 +#define PCIE_QSR_WAIT_UPDATE_FC_DLL 0x00000001 /* Received TLP FC Credits Not Returned */
3798 +#define PCIE_QSR_TX_RETRY_BUF_NOT_EMPTY 0x00000002 /* Transmit Retry Buffer Not Empty */
3799 +#define PCIE_QSR_RX_QUEUE_NOT_EMPTY 0x00000004 /* Received Queue Not Empty */
3801 +/* VC Transmit Arbitration Register 1 */
3802 +#define PCIE_VCTAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x740)
3803 +#define PCIE_VCTAR1_WRR_WEIGHT_VC0 0x000000FF /* WRR Weight for VC0 */
3804 +#define PCIE_VCTAR1_WRR_WEIGHT_VC1 0x0000FF00 /* WRR Weight for VC1 */
3805 +#define PCIE_VCTAR1_WRR_WEIGHT_VC2 0x00FF0000 /* WRR Weight for VC2 */
3806 +#define PCIE_VCTAR1_WRR_WEIGHT_VC3 0xFF000000 /* WRR Weight for VC3 */
3808 +/* VC Transmit Arbitration Register 2 */
3809 +#define PCIE_VCTAR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x744)
3810 +#define PCIE_VCTAR2_WRR_WEIGHT_VC4 0x000000FF /* WRR Weight for VC4 */
3811 +#define PCIE_VCTAR2_WRR_WEIGHT_VC5 0x0000FF00 /* WRR Weight for VC5 */
3812 +#define PCIE_VCTAR2_WRR_WEIGHT_VC6 0x00FF0000 /* WRR Weight for VC6 */
3813 +#define PCIE_VCTAR2_WRR_WEIGHT_VC7 0xFF000000 /* WRR Weight for VC7 */
3815 +/* VC0 Posted Receive Queue Control Register */
3816 +#define PCIE_VC0_PRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x748)
3817 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS 0x00000FFF /* VC0 Posted Data Credits */
3818 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS_S 0
3819 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS 0x000FF000 /* VC0 Posted Header Credits */
3820 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS_S 12
3821 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE 0x00E00000 /* VC0 Posted TLP Queue Mode */
3822 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE_S 20
3823 +#define PCIE_VC0_PRQCR_TLP_RELAX_ORDER 0x40000000 /* TLP Type Ordering for VC0 */
3824 +#define PCIE_VC0_PRQCR_VC_STRICT_ORDER 0x80000000 /* VC0 Ordering for Receive Queues */
3826 +/* VC0 Non-Posted Receive Queue Control */
3827 +#define PCIE_VC0_NPRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74C)
3828 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS 0x00000FFF /* VC0 Non-Posted Data Credits */
3829 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS_S 0
3830 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS 0x000FF000 /* VC0 Non-Posted Header Credits */
3831 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS_S 12
3832 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE 0x00E00000 /* VC0 Non-Posted TLP Queue Mode */
3833 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE_S 20
3835 +/* VC0 Completion Receive Queue Control */
3836 +#define PCIE_VC0_CRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x750)
3837 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS 0x00000FFF /* VC0 Completion TLP Queue Mode */
3838 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS_S 0
3839 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS 0x000FF000 /* VC0 Completion Header Credits */
3840 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS_S 12
3841 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE 0x00E00000 /* VC0 Completion Data Credits */
3842 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE_S 21
3844 +/* Applicable to the above three registers */
3846 + PCIE_VC0_TLP_QUEUE_MODE_STORE_FORWARD = 1,
3847 + PCIE_VC0_TLP_QUEUE_MODE_CUT_THROUGH = 2,
3848 + PCIE_VC0_TLP_QUEUE_MODE_BYPASS = 4,
3851 +/* VC0 Posted Buffer Depth Register */
3852 +#define PCIE_VC0_PBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7A8)
3853 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Posted Data Queue Depth */
3854 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES_S 0
3855 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Posted Header Queue Depth */
3856 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES_S 16
3858 +/* VC0 Non-Posted Buffer Depth Register */
3859 +#define PCIE_VC0_NPBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7AC)
3860 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Non-Posted Data Queue Depth */
3861 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES_S 0
3862 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Non-Posted Header Queue Depth */
3863 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES_S 16
3865 +/* VC0 Completion Buffer Depth Register */
3866 +#define PCIE_VC0_CBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7B0)
3867 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES 0x00003FFF /* C0 Completion Data Queue Depth */
3868 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES_S 0
3869 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Completion Header Queue Depth */
3870 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES_S 16
3872 +/* PHY Status Register, all zeros in VR9 */
3873 +#define PCIE_PHYSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x810)
3875 +/* PHY Control Register, all zeros in VR9 */
3876 +#define PCIE_PHYCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x814)
3879 + * PCIe PDI PHY register definition, suppose all the following
3880 + * stuff is confidential.
3881 + * XXX, detailed bit definition
3883 +#define PCIE_PHY_PLL_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x22 << 1))
3884 +#define PCIE_PHY_PLL_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x23 << 1))
3885 +#define PCIE_PHY_PLL_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x24 << 1))
3886 +#define PCIE_PHY_PLL_CTRL4(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x25 << 1))
3887 +#define PCIE_PHY_PLL_CTRL5(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x26 << 1))
3888 +#define PCIE_PHY_PLL_CTRL6(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x27 << 1))
3889 +#define PCIE_PHY_PLL_CTRL7(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x28 << 1))
3890 +#define PCIE_PHY_PLL_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x29 << 1))
3891 +#define PCIE_PHY_PLL_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2A << 1))
3892 +#define PCIE_PHY_PLL_A_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2B << 1))
3893 +#define PCIE_PHY_PLL_STATUS(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2C << 1))
3895 +#define PCIE_PHY_TX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x30 << 1))
3896 +#define PCIE_PHY_TX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x31 << 1))
3897 +#define PCIE_PHY_TX1_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x32 << 1))
3898 +#define PCIE_PHY_TX1_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x33 << 1))
3899 +#define PCIE_PHY_TX1_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x34 << 1))
3900 +#define PCIE_PHY_TX1_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x35 << 1))
3901 +#define PCIE_PHY_TX1_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x36 << 1))
3902 +#define PCIE_PHY_TX1_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x37 << 1))
3904 +#define PCIE_PHY_TX2_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x38 << 1))
3905 +#define PCIE_PHY_TX2_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x39 << 1))
3906 +#define PCIE_PHY_TX2_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3B << 1))
3907 +#define PCIE_PHY_TX2_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3C << 1))
3908 +#define PCIE_PHY_TX2_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3D << 1))
3909 +#define PCIE_PHY_TX2_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3E << 1))
3910 +#define PCIE_PHY_TX2_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3F << 1))
3912 +#define PCIE_PHY_RX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x50 << 1))
3913 +#define PCIE_PHY_RX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x51 << 1))
3914 +#define PCIE_PHY_RX1_CDR(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x52 << 1))
3915 +#define PCIE_PHY_RX1_EI(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x53 << 1))
3916 +#define PCIE_PHY_RX1_A_CTRL(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x55 << 1))
3918 +/* Interrupt related stuff */
3919 +#define PCIE_LEGACY_DISABLE 0
3920 +#define PCIE_LEGACY_INTA 1
3921 +#define PCIE_LEGACY_INTB 2
3922 +#define PCIE_LEGACY_INTC 3
3923 +#define PCIE_LEGACY_INTD 4
3924 +#define PCIE_LEGACY_INT_MAX PCIE_LEGACY_INTD
3926 +#endif /* IFXMIPS_PCIE_REG_H */
3928 diff --git a/arch/mips/pci/ifxmips_pcie_vr9.h b/arch/mips/pci/ifxmips_pcie_vr9.h
3929 new file mode 100644
3930 index 0000000..57d9368
3932 +++ b/arch/mips/pci/ifxmips_pcie_vr9.h
3934 +/****************************************************************************
3935 + Copyright (c) 2010
3936 + Lantiq Deutschland GmbH
3937 + Am Campeon 3; 85579 Neubiberg, Germany
3939 + For licensing information, see the file 'LICENSE' in the root folder of
3940 + this software module.
3942 + *****************************************************************************/
3944 + \file ifxmips_pcie_vr9.h
3946 + \brief PCIe RC driver vr9 specific file
3949 +#ifndef IFXMIPS_PCIE_VR9_H
3950 +#define IFXMIPS_PCIE_VR9_H
3952 +#include <linux/types.h>
3953 +#include <linux/delay.h>
3955 +#include <linux/gpio.h>
3956 +#include <lantiq_soc.h>
3958 +#define IFX_PCIE_GPIO_RESET 238
3960 +#define IFX_REG_R32 ltq_r32
3961 +#define IFX_REG_W32 ltq_w32
3962 +#define CONFIG_IFX_PCIE_HW_SWAP
3963 +#define IFX_RCU_AHB_ENDIAN ((volatile u32*)(IFX_RCU + 0x004C))
3964 +#define IFX_RCU_RST_REQ ((volatile u32*)(IFX_RCU + 0x0010))
3965 +#define IFX_RCU_AHB_BE_PCIE_PDI 0x00000080 /* Configure PCIE PDI module in big endian*/
3967 +#define IFX_RCU (KSEG1 | 0x1F203000)
3968 +#define IFX_RCU_AHB_BE_PCIE_M 0x00000001 /* Configure AHB master port that connects to PCIe RC in big endian */
3969 +#define IFX_RCU_AHB_BE_PCIE_S 0x00000010 /* Configure AHB slave port that connects to PCIe RC in little endian */
3970 +#define IFX_RCU_AHB_BE_XBAR_M 0x00000002 /* Configure AHB master port that connects to XBAR in big endian */
3971 +#define CONFIG_IFX_PCIE_PHY_36MHZ_MODE
3973 +#define IFX_PMU1_MODULE_PCIE_PHY (0)
3974 +#define IFX_PMU1_MODULE_PCIE_CTRL (1)
3975 +#define IFX_PMU1_MODULE_PDI (4)
3976 +#define IFX_PMU1_MODULE_MSI (5)
3978 +#define IFX_PMU_MODULE_PCIE_L0_CLK (31)
3981 +#define IFX_GPIO (KSEG1 | 0x1E100B00)
3982 +#define ALT0 ((volatile u32*)(IFX_GPIO + 0x007c))
3983 +#define ALT1 ((volatile u32*)(IFX_GPIO + 0x0080))
3984 +#define OD ((volatile u32*)(IFX_GPIO + 0x0084))
3985 +#define DIR ((volatile u32*)(IFX_GPIO + 0x0078))
3986 +#define OUT ((volatile u32*)(IFX_GPIO + 0x0070))
3989 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
3992 + gpio_request(IFX_PCIE_GPIO_RESET, "pcie-reset");
3993 + gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
3994 + gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
3996 +/* ifx_gpio_pin_reserve(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3997 + ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3998 + ifx_gpio_dir_out_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3999 + ifx_gpio_altsel0_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
4000 + ifx_gpio_altsel1_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
4001 + ifx_gpio_open_drain_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);*/
4004 +static inline void pcie_ahb_pmu_setup(void)
4006 + /* Enable AHB bus master/slave */
4008 + clk = clk_get_sys("1d900000.pcie", "ahb");
4011 + //AHBM_PMU_SETUP(IFX_PMU_ENABLE);
4012 + //AHBS_PMU_SETUP(IFX_PMU_ENABLE);
4015 +static inline void pcie_rcu_endian_setup(int pcie_port)
4019 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
4020 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
4021 + reg |= IFX_RCU_AHB_BE_PCIE_M;
4022 + reg |= IFX_RCU_AHB_BE_PCIE_S;
4023 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
4025 + reg |= IFX_RCU_AHB_BE_PCIE_M;
4026 + reg &= ~IFX_RCU_AHB_BE_PCIE_S;
4027 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
4028 +#endif /* CONFIG_IFX_PCIE_HW_SWAP */
4029 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
4030 + IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
4033 +static inline void pcie_phy_pmu_enable(int pcie_port)
4036 + clk = clk_get_sys("1d900000.pcie", "phy");
4039 + //PCIE_PHY_PMU_SETUP(IFX_PMU_ENABLE);
4042 +static inline void pcie_phy_pmu_disable(int pcie_port)
4045 + clk = clk_get_sys("1d900000.pcie", "phy");
4048 +// PCIE_PHY_PMU_SETUP(IFX_PMU_DISABLE);
4051 +static inline void pcie_pdi_big_endian(int pcie_port)
4055 + /* SRAM2PDI endianness control. */
4056 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
4057 + /* Config AHB->PCIe and PDI endianness */
4058 + reg |= IFX_RCU_AHB_BE_PCIE_PDI;
4059 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
4062 +static inline void pcie_pdi_pmu_enable(int pcie_port)
4064 + /* Enable PDI to access PCIe PHY register */
4066 + clk = clk_get_sys("1d900000.pcie", "pdi");
4068 + //PDI_PMU_SETUP(IFX_PMU_ENABLE);
4071 +static inline void pcie_core_rst_assert(int pcie_port)
4075 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4077 + /* Reset PCIe PHY & Core, bit 22, bit 26 may be affected if write it directly */
4078 + reg |= 0x00400000;
4079 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4082 +static inline void pcie_core_rst_deassert(int pcie_port)
4086 + /* Make sure one micro-second delay */
4089 + /* Reset PCIe PHY & Core, bit 22 */
4090 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4091 + reg &= ~0x00400000;
4092 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4095 +static inline void pcie_phy_rst_assert(int pcie_port)
4099 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4100 + reg |= 0x00001000; /* Bit 12 */
4101 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4104 +static inline void pcie_phy_rst_deassert(int pcie_port)
4108 + /* Make sure one micro-second delay */
4111 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4112 + reg &= ~0x00001000; /* Bit 12 */
4113 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4116 +static inline void pcie_device_rst_assert(int pcie_port)
4118 + printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
4119 + gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
4120 +// ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
4123 +static inline void pcie_device_rst_deassert(int pcie_port)
4126 + printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
4127 + gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
4128 +// gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
4129 + //ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
4132 +static inline void pcie_core_pmu_setup(int pcie_port)
4135 + clk = clk_get_sys("1d900000.pcie", "ctl");
4137 + clk = clk_get_sys("1d900000.pcie", "bus");
4140 + /* PCIe Core controller enabled */
4141 +// PCIE_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
4143 + /* Enable PCIe L0 Clock */
4144 +// PCIE_L0_CLK_PMU_SETUP(IFX_PMU_ENABLE);
4147 +static inline void pcie_msi_init(int pcie_port)
4150 + pcie_msi_pic_init(pcie_port);
4151 + clk = clk_get_sys("ltq_pcie", "msi");
4153 +// MSI_PMU_SETUP(IFX_PMU_ENABLE);
4157 +ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
4159 + u32 tbus_number = bus_number;
4161 +#ifdef CONFIG_IFX_PCI
4162 + if (pcibios_host_nr() > 1) {
4163 + tbus_number -= pcibios_1st_host_bus_nr();
4165 +#endif /* CONFIG_IFX_PCI */
4166 + return tbus_number;
4170 +ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
4172 + struct pci_dev *pdev;
4173 + u32 tvalue = value;
4175 + /* Sanity check */
4176 + pdev = pci_get_slot(bus, devfn);
4177 + if (pdev == NULL) {
4181 + /* Only care about PCI bridge */
4182 + if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
4186 + if (read) { /* Read hack */
4187 + #ifdef CONFIG_IFX_PCI
4188 + if (pcibios_host_nr() > 1) {
4189 + tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
4191 + #endif /* CONFIG_IFX_PCI */
4193 + else { /* Write hack */
4194 + #ifdef CONFIG_IFX_PCI
4195 + if (pcibios_host_nr() > 1) {
4196 + tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
4203 +#endif /* IFXMIPS_PCIE_VR9_H */
4205 diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
4206 index 1bf60b1..31ee19b 100644
4207 --- a/arch/mips/pci/pci.c
4208 +++ b/arch/mips/pci/pci.c
4209 @@ -251,6 +251,31 @@ static int __init pcibios_init(void)
4211 subsys_initcall(pcibios_init);
4213 +int pcibios_host_nr(void)
4216 + struct pci_controller *hose;
4217 + for (count = 0, hose = hose_head; hose; hose = hose->next, count++) {
4222 +EXPORT_SYMBOL(pcibios_host_nr);
4224 +int pcibios_1st_host_bus_nr(void)
4227 + struct pci_controller *hose = hose_head;
4229 + if (hose != NULL) {
4230 + if (hose->bus != NULL) {
4231 + bus_nr = hose->bus->number + 1;
4236 +EXPORT_SYMBOL(pcibios_1st_host_bus_nr);
4238 static int pcibios_enable_resources(struct pci_dev *dev, int mask)
4241 diff --git a/arch/mips/pci/pcie-lantiq.h b/arch/mips/pci/pcie-lantiq.h
4242 new file mode 100644
4243 index 0000000..d877c23
4245 +++ b/arch/mips/pci/pcie-lantiq.h
4247 +/******************************************************************************
4249 +** FILE NAME : ifxmips_pcie_reg.h
4250 +** PROJECT : IFX UEIP for VRX200
4251 +** MODULES : PCIe module
4253 +** DATE : 02 Mar 2009
4254 +** AUTHOR : Lei Chuanhua
4255 +** DESCRIPTION : PCIe Root Complex Driver
4256 +** COPYRIGHT : Copyright (c) 2009
4257 +** Infineon Technologies AG
4258 +** Am Campeon 1-12, 85579 Neubiberg, Germany
4260 +** This program is free software; you can redistribute it and/or modify
4261 +** it under the terms of the GNU General Public License as published by
4262 +** the Free Software Foundation; either version 2 of the License, or
4263 +** (at your option) any later version.
4265 +** $Version $Date $Author $Comment
4266 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
4267 +*******************************************************************************/
4268 +#ifndef IFXMIPS_PCIE_REG_H
4269 +#define IFXMIPS_PCIE_REG_H
4270 +#include <linux/version.h>
4271 +#include <linux/types.h>
4272 +#include <linux/pci.h>
4273 +#include <linux/interrupt.h>
4275 + \file ifxmips_pcie_reg.h
4277 + \brief header file for PCIe module register definition
4279 +/* PCIe Address Mapping Base */
4280 +#define PCIE_CFG_PHY_BASE 0x1D000000UL
4281 +#define PCIE_CFG_BASE (KSEG1 + PCIE_CFG_PHY_BASE)
4282 +#define PCIE_CFG_SIZE (8 * 1024 * 1024)
4284 +#define PCIE_MEM_PHY_BASE 0x1C000000UL
4285 +#define PCIE_MEM_BASE (KSEG1 + PCIE_MEM_PHY_BASE)
4286 +#define PCIE_MEM_SIZE (16 * 1024 * 1024)
4287 +#define PCIE_MEM_PHY_END (PCIE_MEM_PHY_BASE + PCIE_MEM_SIZE - 1)
4289 +#define PCIE_IO_PHY_BASE 0x1D800000UL
4290 +#define PCIE_IO_BASE (KSEG1 + PCIE_IO_PHY_BASE)
4291 +#define PCIE_IO_SIZE (1 * 1024 * 1024)
4292 +#define PCIE_IO_PHY_END (PCIE_IO_PHY_BASE + PCIE_IO_SIZE - 1)
4294 +#define PCIE_RC_CFG_BASE (KSEG1 + 0x1D900000)
4295 +#define PCIE_APP_LOGIC_REG (KSEG1 + 0x1E100900)
4296 +#define PCIE_MSI_PHY_BASE 0x1F600000UL
4298 +#define PCIE_PDI_PHY_BASE 0x1F106800UL
4299 +#define PCIE_PDI_BASE (KSEG1 + PCIE_PDI_PHY_BASE)
4300 +#define PCIE_PDI_SIZE 0x400
4302 +#define PCIE1_CFG_PHY_BASE 0x19000000UL
4303 +#define PCIE1_CFG_BASE (KSEG1 + PCIE1_CFG_PHY_BASE)
4304 +#define PCIE1_CFG_SIZE (8 * 1024 * 1024)
4306 +#define PCIE1_MEM_PHY_BASE 0x18000000UL
4307 +#define PCIE1_MEM_BASE (KSEG1 + PCIE1_MEM_PHY_BASE)
4308 +#define PCIE1_MEM_SIZE (16 * 1024 * 1024)
4309 +#define PCIE1_MEM_PHY_END (PCIE1_MEM_PHY_BASE + PCIE1_MEM_SIZE - 1)
4311 +#define PCIE1_IO_PHY_BASE 0x19800000UL
4312 +#define PCIE1_IO_BASE (KSEG1 + PCIE1_IO_PHY_BASE)
4313 +#define PCIE1_IO_SIZE (1 * 1024 * 1024)
4314 +#define PCIE1_IO_PHY_END (PCIE1_IO_PHY_BASE + PCIE1_IO_SIZE - 1)
4316 +#define PCIE1_RC_CFG_BASE (KSEG1 + 0x19900000)
4317 +#define PCIE1_APP_LOGIC_REG (KSEG1 + 0x1E100700)
4318 +#define PCIE1_MSI_PHY_BASE 0x1F400000UL
4320 +#define PCIE1_PDI_PHY_BASE 0x1F700400UL
4321 +#define PCIE1_PDI_BASE (KSEG1 + PCIE1_PDI_PHY_BASE)
4322 +#define PCIE1_PDI_SIZE 0x400
4324 +#define PCIE_CFG_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_CFG_BASE) : (PCIE_CFG_BASE))
4325 +#define PCIE_MEM_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_BASE) : (PCIE_MEM_BASE))
4326 +#define PCIE_IO_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_BASE) : (PCIE_IO_BASE))
4327 +#define PCIE_MEM_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_PHY_BASE) : (PCIE_MEM_PHY_BASE))
4328 +#define PCIE_MEM_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_MEM_PHY_END) : (PCIE_MEM_PHY_END))
4329 +#define PCIE_IO_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_PHY_BASE) : (PCIE_IO_PHY_BASE))
4330 +#define PCIE_IO_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_IO_PHY_END) : (PCIE_IO_PHY_END))
4331 +#define PCIE_APP_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_APP_LOGIC_REG) : (PCIE_APP_LOGIC_REG))
4332 +#define PCIE_RC_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_RC_CFG_BASE) : (PCIE_RC_CFG_BASE))
4333 +#define PCIE_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_PDI_BASE) : (PCIE_PDI_BASE))
4335 +/* PCIe Application Logic Register */
4336 +/* RC Core Control Register */
4337 +#define PCIE_RC_CCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x10)
4338 +/* This should be enabled after initializing configuratin registers
4339 + * Also should check link status retraining bit
4341 +#define PCIE_RC_CCR_LTSSM_ENABLE 0x00000001 /* Enable LTSSM to continue link establishment */
4343 +/* RC Core Debug Register */
4344 +#define PCIE_RC_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x14)
4345 +#define PCIE_RC_DR_DLL_UP 0x00000001 /* Data Link Layer Up */
4346 +#define PCIE_RC_DR_CURRENT_POWER_STATE 0x0000000E /* Current Power State */
4347 +#define PCIE_RC_DR_CURRENT_POWER_STATE_S 1
4348 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE 0x000001F0 /* Current LTSSM State */
4349 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE_S 4
4351 +#define PCIE_RC_DR_PM_DEV_STATE 0x00000E00 /* Power Management D-State */
4352 +#define PCIE_RC_DR_PM_DEV_STATE_S 9
4354 +#define PCIE_RC_DR_PM_ENABLED 0x00001000 /* Power Management State from PMU */
4355 +#define PCIE_RC_DR_PME_EVENT_ENABLED 0x00002000 /* Power Management Event Enable State */
4356 +#define PCIE_RC_DR_AUX_POWER_ENABLED 0x00004000 /* Auxiliary Power Enable */
4358 +/* Current Power State Definition */
4360 + PCIE_RC_DR_D0 = 0,
4361 + PCIE_RC_DR_D1, /* Not supported */
4362 + PCIE_RC_DR_D2, /* Not supported */
4367 +/* PHY Link Status Register */
4368 +#define PCIE_PHY_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x18)
4369 +#define PCIE_PHY_SR_PHY_LINK_UP 0x00000001 /* PHY Link Up/Down Indicator */
4371 +/* Electromechanical Control Register */
4372 +#define PCIE_EM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x1C)
4373 +#define PCIE_EM_CR_CARD_IS_PRESENT 0x00000001 /* Card Presence Detect State */
4374 +#define PCIE_EM_CR_MRL_OPEN 0x00000002 /* MRL Sensor State */
4375 +#define PCIE_EM_CR_POWER_FAULT_SET 0x00000004 /* Power Fault Detected */
4376 +#define PCIE_EM_CR_MRL_SENSOR_SET 0x00000008 /* MRL Sensor Changed */
4377 +#define PCIE_EM_CR_PRESENT_DETECT_SET 0x00000010 /* Card Presense Detect Changed */
4378 +#define PCIE_EM_CR_CMD_CPL_INT_SET 0x00000020 /* Command Complete Interrupt */
4379 +#define PCIE_EM_CR_SYS_INTERLOCK_SET 0x00000040 /* System Electromechanical IterLock Engaged */
4380 +#define PCIE_EM_CR_ATTENTION_BUTTON_SET 0x00000080 /* Attention Button Pressed */
4382 +/* Interrupt Status Register */
4383 +#define PCIE_IR_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x20)
4384 +#define PCIE_IR_SR_PME_CAUSE_MSI 0x00000002 /* MSI caused by PME */
4385 +#define PCIE_IR_SR_HP_PME_WAKE_GEN 0x00000004 /* Hotplug PME Wake Generation */
4386 +#define PCIE_IR_SR_HP_MSI 0x00000008 /* Hotplug MSI */
4387 +#define PCIE_IR_SR_AHB_LU_ERR 0x00000030 /* AHB Bridge Lookup Error Signals */
4388 +#define PCIE_IR_SR_AHB_LU_ERR_S 4
4389 +#define PCIE_IR_SR_INT_MSG_NUM 0x00003E00 /* Interrupt Message Number */
4390 +#define PCIE_IR_SR_INT_MSG_NUM_S 9
4391 +#define PCIE_IR_SR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
4392 +#define PCIE_IR_SR_AER_INT_MSG_NUM_S 27
4394 +/* Message Control Register */
4395 +#define PCIE_MSG_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x30)
4396 +#define PCIE_MSG_CR_GEN_PME_TURN_OFF_MSG 0x00000001 /* Generate PME Turn Off Message */
4397 +#define PCIE_MSG_CR_GEN_UNLOCK_MSG 0x00000002 /* Generate Unlock Message */
4399 +#define PCIE_VDM_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x34)
4401 +/* Vendor-Defined Message Requester ID Register */
4402 +#define PCIE_VDM_RID(X) (PCIE_APP_PORT_TO_BASE (X) + 0x38)
4403 +#define PCIE_VDM_RID_VENROR_MSG_REQ_ID 0x0000FFFF
4404 +#define PCIE_VDM_RID_VDMRID_S 0
4406 +/* ASPM Control Register */
4407 +#define PCIE_ASPM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x40)
4408 +#define PCIE_ASPM_CR_HOT_RST 0x00000001 /* Hot Reset Request to the downstream device */
4409 +#define PCIE_ASPM_CR_REQ_EXIT_L1 0x00000002 /* Request to Exit L1 */
4410 +#define PCIE_ASPM_CR_REQ_ENTER_L1 0x00000004 /* Request to Enter L1 */
4412 +/* Vendor Message DW0 Register */
4413 +#define PCIE_VM_MSG_DW0(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x50)
4414 +#define PCIE_VM_MSG_DW0_TYPE 0x0000001F /* Message type */
4415 +#define PCIE_VM_MSG_DW0_TYPE_S 0
4416 +#define PCIE_VM_MSG_DW0_FORMAT 0x00000060 /* Format */
4417 +#define PCIE_VM_MSG_DW0_FORMAT_S 5
4418 +#define PCIE_VM_MSG_DW0_TC 0x00007000 /* Traffic Class */
4419 +#define PCIE_VM_MSG_DW0_TC_S 12
4420 +#define PCIE_VM_MSG_DW0_ATTR 0x000C0000 /* Atrributes */
4421 +#define PCIE_VM_MSG_DW0_ATTR_S 18
4422 +#define PCIE_VM_MSG_DW0_EP_TLP 0x00100000 /* Poisoned TLP */
4423 +#define PCIE_VM_MSG_DW0_TD 0x00200000 /* TLP Digest */
4424 +#define PCIE_VM_MSG_DW0_LEN 0xFFC00000 /* Length */
4425 +#define PCIE_VM_MSG_DW0_LEN_S 22
4427 +/* Format Definition */
4429 + PCIE_VM_MSG_FORMAT_00 = 0, /* 3DW Hdr, no data*/
4430 + PCIE_VM_MSG_FORMAT_01, /* 4DW Hdr, no data */
4431 + PCIE_VM_MSG_FORMAT_10, /* 3DW Hdr, with data */
4432 + PCIE_VM_MSG_FORMAT_11, /* 4DW Hdr, with data */
4435 +/* Traffic Class Definition */
4437 + PCIE_VM_MSG_TC0 = 0,
4447 +/* Attributes Definition */
4449 + PCIE_VM_MSG_ATTR_00 = 0, /* RO and No Snoop cleared */
4450 + PCIE_VM_MSG_ATTR_01, /* RO cleared , No Snoop set */
4451 + PCIE_VM_MSG_ATTR_10, /* RO set, No Snoop cleared*/
4452 + PCIE_VM_MSG_ATTR_11, /* RO and No Snoop set */
4455 +/* Payload Size Definition */
4456 +#define PCIE_VM_MSG_LEN_MIN 0
4457 +#define PCIE_VM_MSG_LEN_MAX 1024
4459 +/* Vendor Message DW1 Register */
4460 +#define PCIE_VM_MSG_DW1(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x54)
4461 +#define PCIE_VM_MSG_DW1_FUNC_NUM 0x00000070 /* Function Number */
4462 +#define PCIE_VM_MSG_DW1_FUNC_NUM_S 8
4463 +#define PCIE_VM_MSG_DW1_CODE 0x00FF0000 /* Message Code */
4464 +#define PCIE_VM_MSG_DW1_CODE_S 16
4465 +#define PCIE_VM_MSG_DW1_TAG 0xFF000000 /* Tag */
4466 +#define PCIE_VM_MSG_DW1_TAG_S 24
4468 +#define PCIE_VM_MSG_DW2(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x58)
4469 +#define PCIE_VM_MSG_DW3(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x5C)
4471 +/* Vendor Message Request Register */
4472 +#define PCIE_VM_MSG_REQR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x60)
4473 +#define PCIE_VM_MSG_REQR_REQ 0x00000001 /* Vendor Message Request */
4476 +/* AHB Slave Side Band Control Register */
4477 +#define PCIE_AHB_SSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x70)
4478 +#define PCIE_AHB_SSB_REQ_BCM 0x00000001 /* Slave Reques BCM filed */
4479 +#define PCIE_AHB_SSB_REQ_EP 0x00000002 /* Slave Reques EP filed */
4480 +#define PCIE_AHB_SSB_REQ_TD 0x00000004 /* Slave Reques TD filed */
4481 +#define PCIE_AHB_SSB_REQ_ATTR 0x00000018 /* Slave Reques Attribute number */
4482 +#define PCIE_AHB_SSB_REQ_ATTR_S 3
4483 +#define PCIE_AHB_SSB_REQ_TC 0x000000E0 /* Slave Request TC Field */
4484 +#define PCIE_AHB_SSB_REQ_TC_S 5
4486 +/* AHB Master SideBand Ctrl Register */
4487 +#define PCIE_AHB_MSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x74)
4488 +#define PCIE_AHB_MSB_RESP_ATTR 0x00000003 /* Master Response Attribute number */
4489 +#define PCIE_AHB_MSB_RESP_ATTR_S 0
4490 +#define PCIE_AHB_MSB_RESP_BAD_EOT 0x00000004 /* Master Response Badeot filed */
4491 +#define PCIE_AHB_MSB_RESP_BCM 0x00000008 /* Master Response BCM filed */
4492 +#define PCIE_AHB_MSB_RESP_EP 0x00000010 /* Master Response EP filed */
4493 +#define PCIE_AHB_MSB_RESP_TD 0x00000020 /* Master Response TD filed */
4494 +#define PCIE_AHB_MSB_RESP_FUN_NUM 0x000003C0 /* Master Response Function number */
4495 +#define PCIE_AHB_MSB_RESP_FUN_NUM_S 6
4497 +/* AHB Control Register, fixed bus enumeration exception */
4498 +#define PCIE_AHB_CTRL(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x78)
4499 +#define PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS 0x00000001
4501 +/* Interrupt Enalbe Register */
4502 +#define PCIE_IRNEN(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF4)
4503 +#define PCIE_IRNCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF8)
4504 +#define PCIE_IRNICR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xFC)
4506 +/* PCIe interrupt enable/control/capture register definition */
4507 +#define PCIE_IRN_AER_REPORT 0x00000001 /* AER Interrupt */
4508 +#define PCIE_IRN_AER_MSIX 0x00000002 /* Advanced Error MSI-X Interrupt */
4509 +#define PCIE_IRN_PME 0x00000004 /* PME Interrupt */
4510 +#define PCIE_IRN_HOTPLUG 0x00000008 /* Hotplug Interrupt */
4511 +#define PCIE_IRN_RX_VDM_MSG 0x00000010 /* Vendor-Defined Message Interrupt */
4512 +#define PCIE_IRN_RX_CORRECTABLE_ERR_MSG 0x00000020 /* Correctable Error Message Interrupt */
4513 +#define PCIE_IRN_RX_NON_FATAL_ERR_MSG 0x00000040 /* Non-fatal Error Message */
4514 +#define PCIE_IRN_RX_FATAL_ERR_MSG 0x00000080 /* Fatal Error Message */
4515 +#define PCIE_IRN_RX_PME_MSG 0x00000100 /* PME Message Interrupt */
4516 +#define PCIE_IRN_RX_PME_TURNOFF_ACK 0x00000200 /* PME Turnoff Ack Message Interrupt */
4517 +#define PCIE_IRN_AHB_BR_FATAL_ERR 0x00000400 /* AHB Fatal Error Interrupt */
4518 +#define PCIE_IRN_LINK_AUTO_BW_STATUS 0x00000800 /* Link Auto Bandwidth Status Interrupt */
4519 +#define PCIE_IRN_BW_MGT 0x00001000 /* Bandwidth Managment Interrupt */
4520 +#define PCIE_IRN_INTA 0x00002000 /* INTA */
4521 +#define PCIE_IRN_INTB 0x00004000 /* INTB */
4522 +#define PCIE_IRN_INTC 0x00008000 /* INTC */
4523 +#define PCIE_IRN_INTD 0x00010000 /* INTD */
4524 +#define PCIE_IRN_WAKEUP 0x00020000 /* Wake up Interrupt */
4526 +#define PCIE_RC_CORE_COMBINED_INT (PCIE_IRN_AER_REPORT | PCIE_IRN_AER_MSIX | PCIE_IRN_PME | \
4527 + PCIE_IRN_HOTPLUG | PCIE_IRN_RX_VDM_MSG | PCIE_IRN_RX_CORRECTABLE_ERR_MSG |\
4528 + PCIE_IRN_RX_NON_FATAL_ERR_MSG | PCIE_IRN_RX_FATAL_ERR_MSG | \
4529 + PCIE_IRN_RX_PME_MSG | PCIE_IRN_RX_PME_TURNOFF_ACK | PCIE_IRN_AHB_BR_FATAL_ERR | \
4530 + PCIE_IRN_LINK_AUTO_BW_STATUS | PCIE_IRN_BW_MGT)
4531 +/* PCIe RC Configuration Register */
4532 +#define PCIE_VDID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x00)
4534 +/* Bit definition from pci_reg.h */
4535 +#define PCIE_PCICMDSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x04)
4536 +#define PCIE_CCRID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x08)
4537 +#define PCIE_CLSLTHTBR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x0C) /* EP only */
4538 +/* BAR0, BAR1,Only necessary if the bridges implements a device-specific register set or memory buffer */
4539 +#define PCIE_BAR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10) /* Not used*/
4540 +#define PCIE_BAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14) /* Not used */
4542 +#define PCIE_BNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x18) /* Mandatory */
4543 +/* Bus Number Register bits */
4544 +#define PCIE_BNR_PRIMARY_BUS_NUM 0x000000FF
4545 +#define PCIE_BNR_PRIMARY_BUS_NUM_S 0
4546 +#define PCIE_PNR_SECONDARY_BUS_NUM 0x0000FF00
4547 +#define PCIE_PNR_SECONDARY_BUS_NUM_S 8
4548 +#define PCIE_PNR_SUB_BUS_NUM 0x00FF0000
4549 +#define PCIE_PNR_SUB_BUS_NUM_S 16
4551 +/* IO Base/Limit Register bits */
4552 +#define PCIE_IOBLSECS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x1C) /* RC only */
4553 +#define PCIE_IOBLSECS_32BIT_IO_ADDR 0x00000001
4554 +#define PCIE_IOBLSECS_IO_BASE_ADDR 0x000000F0
4555 +#define PCIE_IOBLSECS_IO_BASE_ADDR_S 4
4556 +#define PCIE_IOBLSECS_32BIT_IOLIMT 0x00000100
4557 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR 0x0000F000
4558 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR_S 12
4560 +/* Non-prefetchable Memory Base/Limit Register bit */
4561 +#define PCIE_MBML(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x20) /* RC only */
4562 +#define PCIE_MBML_MEM_BASE_ADDR 0x0000FFF0
4563 +#define PCIE_MBML_MEM_BASE_ADDR_S 4
4564 +#define PCIE_MBML_MEM_LIMIT_ADDR 0xFFF00000
4565 +#define PCIE_MBML_MEM_LIMIT_ADDR_S 20
4567 +/* Prefetchable Memory Base/Limit Register bit */
4568 +#define PCIE_PMBL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x24) /* RC only */
4569 +#define PCIE_PMBL_64BIT_ADDR 0x00000001
4570 +#define PCIE_PMBL_UPPER_12BIT 0x0000FFF0
4571 +#define PCIE_PMBL_UPPER_12BIT_S 4
4572 +#define PCIE_PMBL_E64MA 0x00010000
4573 +#define PCIE_PMBL_END_ADDR 0xFFF00000
4574 +#define PCIE_PMBL_END_ADDR_S 20
4575 +#define PCIE_PMBU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x28) /* RC only */
4576 +#define PCIE_PMLU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x2C) /* RC only */
4578 +/* I/O Base/Limit Upper 16 bits register */
4579 +#define PCIE_IO_BANDL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x30) /* RC only */
4580 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE 0x0000FFFF
4581 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE_S 0
4582 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT 0xFFFF0000
4583 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT_S 16
4585 +#define PCIE_CPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x34)
4586 +#define PCIE_EBBAR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x38)
4588 +/* Interrupt and Secondary Bridge Control Register */
4589 +#define PCIE_INTRBCTRL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x3C)
4591 +#define PCIE_INTRBCTRL_INT_LINE 0x000000FF
4592 +#define PCIE_INTRBCTRL_INT_LINE_S 0
4593 +#define PCIE_INTRBCTRL_INT_PIN 0x0000FF00
4594 +#define PCIE_INTRBCTRL_INT_PIN_S 8
4595 +#define PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE 0x00010000 /* #PERR */
4596 +#define PCIE_INTRBCTRL_SERR_ENABLE 0x00020000 /* #SERR */
4597 +#define PCIE_INTRBCTRL_ISA_ENABLE 0x00040000 /* ISA enable, IO 64KB only */
4598 +#define PCIE_INTRBCTRL_VGA_ENABLE 0x00080000 /* VGA enable */
4599 +#define PCIE_INTRBCTRL_VGA_16BIT_DECODE 0x00100000 /* VGA 16bit decode */
4600 +#define PCIE_INTRBCTRL_RST_SECONDARY_BUS 0x00400000 /* Secondary bus rest, hot rest, 1ms */
4601 +/* Others are read only */
4603 + PCIE_INTRBCTRL_INT_NON = 0,
4604 + PCIE_INTRBCTRL_INTA,
4605 + PCIE_INTRBCTRL_INTB,
4606 + PCIE_INTRBCTRL_INTC,
4607 + PCIE_INTRBCTRL_INTD,
4610 +#define PCIE_PM_CAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x40)
4612 +/* Power Management Control and Status Register */
4613 +#define PCIE_PM_CSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x44)
4615 +#define PCIE_PM_CSR_POWER_STATE 0x00000003 /* Power State */
4616 +#define PCIE_PM_CSR_POWER_STATE_S 0
4617 +#define PCIE_PM_CSR_SW_RST 0x00000008 /* Soft Reset Enabled */
4618 +#define PCIE_PM_CSR_PME_ENABLE 0x00000100 /* PME Enable */
4619 +#define PCIE_PM_CSR_PME_STATUS 0x00008000 /* PME status */
4621 +/* MSI Capability Register for EP */
4622 +#define PCIE_MCAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x50)
4624 +#define PCIE_MCAPR_MSI_CAP_ID 0x000000FF /* MSI Capability ID */
4625 +#define PCIE_MCAPR_MSI_CAP_ID_S 0
4626 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR 0x0000FF00 /* Next Capability Pointer */
4627 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR_S 8
4628 +#define PCIE_MCAPR_MSI_ENABLE 0x00010000 /* MSI Enable */
4629 +#define PCIE_MCAPR_MULTI_MSG_CAP 0x000E0000 /* Multiple Message Capable */
4630 +#define PCIE_MCAPR_MULTI_MSG_CAP_S 17
4631 +#define PCIE_MCAPR_MULTI_MSG_ENABLE 0x00700000 /* Multiple Message Enable */
4632 +#define PCIE_MCAPR_MULTI_MSG_ENABLE_S 20
4633 +#define PCIE_MCAPR_ADDR64_CAP 0X00800000 /* 64-bit Address Capable */
4635 +/* MSI Message Address Register */
4636 +#define PCIE_MA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x54)
4638 +#define PCIE_MA_ADDR_MASK 0xFFFFFFFC /* Message Address */
4640 +/* MSI Message Upper Address Register */
4641 +#define PCIE_MUA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x58)
4643 +/* MSI Message Data Register */
4644 +#define PCIE_MD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x5C)
4646 +#define PCIE_MD_DATA 0x0000FFFF /* Message Data */
4647 +#define PCIE_MD_DATA_S 0
4649 +/* PCI Express Capability Register */
4650 +#define PCIE_XCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70)
4652 +#define PCIE_XCAP_ID 0x000000FF /* PCI Express Capability ID */
4653 +#define PCIE_XCAP_ID_S 0
4654 +#define PCIE_XCAP_NEXT_CAP 0x0000FF00 /* Next Capability Pointer */
4655 +#define PCIE_XCAP_NEXT_CAP_S 8
4656 +#define PCIE_XCAP_VER 0x000F0000 /* PCI Express Capability Version */
4657 +#define PCIE_XCAP_VER_S 16
4658 +#define PCIE_XCAP_DEV_PORT_TYPE 0x00F00000 /* Device Port Type */
4659 +#define PCIE_XCAP_DEV_PORT_TYPE_S 20
4660 +#define PCIE_XCAP_SLOT_IMPLEMENTED 0x01000000 /* Slot Implemented */
4661 +#define PCIE_XCAP_MSG_INT_NUM 0x3E000000 /* Interrupt Message Number */
4662 +#define PCIE_XCAP_MSG_INT_NUM_S 25
4664 +/* Device Capability Register */
4665 +#define PCIE_DCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74)
4667 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE 0x00000007 /* Max Payload size */
4668 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE_S 0
4669 +#define PCIE_DCAP_PHANTOM_FUNC 0x00000018 /* Phanton Function, not supported */
4670 +#define PCIE_DCAP_PHANTOM_FUNC_S 3
4671 +#define PCIE_DCAP_EXT_TAG 0x00000020 /* Extended Tag Field */
4672 +#define PCIE_DCAP_EP_L0S_LATENCY 0x000001C0 /* EP L0s latency only */
4673 +#define PCIE_DCAP_EP_L0S_LATENCY_S 6
4674 +#define PCIE_DCAP_EP_L1_LATENCY 0x00000E00 /* EP L1 latency only */
4675 +#define PCIE_DCAP_EP_L1_LATENCY_S 9
4676 +#define PCIE_DCAP_ROLE_BASE_ERR_REPORT 0x00008000 /* Role Based ERR */
4678 +/* Maximum payload size supported */
4680 + PCIE_MAX_PAYLOAD_128 = 0,
4681 + PCIE_MAX_PAYLOAD_256,
4682 + PCIE_MAX_PAYLOAD_512,
4683 + PCIE_MAX_PAYLOAD_1024,
4684 + PCIE_MAX_PAYLOAD_2048,
4685 + PCIE_MAX_PAYLOAD_4096,
4688 +/* Device Control and Status Register */
4689 +#define PCIE_DCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x78)
4691 +#define PCIE_DCTLSTS_CORRECTABLE_ERR_EN 0x00000001 /* COR-ERR */
4692 +#define PCIE_DCTLSTS_NONFATAL_ERR_EN 0x00000002 /* Non-fatal ERR */
4693 +#define PCIE_DCTLSTS_FATAL_ERR_EN 0x00000004 /* Fatal ERR */
4694 +#define PCIE_DCTLSYS_UR_REQ_EN 0x00000008 /* UR ERR */
4695 +#define PCIE_DCTLSTS_RELAXED_ORDERING_EN 0x00000010 /* Enable relaxing ordering */
4696 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE 0x000000E0 /* Max payload mask */
4697 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE_S 5
4698 +#define PCIE_DCTLSTS_EXT_TAG_EN 0x00000100 /* Extended tag field */
4699 +#define PCIE_DCTLSTS_PHANTOM_FUNC_EN 0x00000200 /* Phantom Function Enable */
4700 +#define PCIE_DCTLSTS_AUX_PM_EN 0x00000400 /* AUX Power PM Enable */
4701 +#define PCIE_DCTLSTS_NO_SNOOP_EN 0x00000800 /* Enable no snoop, except root port*/
4702 +#define PCIE_DCTLSTS_MAX_READ_SIZE 0x00007000 /* Max Read Request size*/
4703 +#define PCIE_DCTLSTS_MAX_READ_SIZE_S 12
4704 +#define PCIE_DCTLSTS_CORRECTABLE_ERR 0x00010000 /* COR-ERR Detected */
4705 +#define PCIE_DCTLSTS_NONFATAL_ERR 0x00020000 /* Non-Fatal ERR Detected */
4706 +#define PCIE_DCTLSTS_FATAL_ER 0x00040000 /* Fatal ERR Detected */
4707 +#define PCIE_DCTLSTS_UNSUPPORTED_REQ 0x00080000 /* UR Detected */
4708 +#define PCIE_DCTLSTS_AUX_POWER 0x00100000 /* Aux Power Detected */
4709 +#define PCIE_DCTLSTS_TRANSACT_PENDING 0x00200000 /* Transaction pending */
4711 +#define PCIE_DCTLSTS_ERR_EN (PCIE_DCTLSTS_CORRECTABLE_ERR_EN | \
4712 + PCIE_DCTLSTS_NONFATAL_ERR_EN | PCIE_DCTLSTS_FATAL_ERR_EN | \
4713 + PCIE_DCTLSYS_UR_REQ_EN)
4715 +/* Link Capability Register */
4716 +#define PCIE_LCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7C)
4717 +#define PCIE_LCAP_MAX_LINK_SPEED 0x0000000F /* Max link speed, 0x1 by default */
4718 +#define PCIE_LCAP_MAX_LINK_SPEED_S 0
4719 +#define PCIE_LCAP_MAX_LENGTH_WIDTH 0x000003F0 /* Maxium Length Width */
4720 +#define PCIE_LCAP_MAX_LENGTH_WIDTH_S 4
4721 +#define PCIE_LCAP_ASPM_LEVEL 0x00000C00 /* Active State Link PM Support */
4722 +#define PCIE_LCAP_ASPM_LEVEL_S 10
4723 +#define PCIE_LCAP_L0S_EIXT_LATENCY 0x00007000 /* L0s Exit Latency */
4724 +#define PCIE_LCAP_L0S_EIXT_LATENCY_S 12
4725 +#define PCIE_LCAP_L1_EXIT_LATENCY 0x00038000 /* L1 Exit Latency */
4726 +#define PCIE_LCAP_L1_EXIT_LATENCY_S 15
4727 +#define PCIE_LCAP_CLK_PM 0x00040000 /* Clock Power Management */
4728 +#define PCIE_LCAP_SDER 0x00080000 /* Surprise Down Error Reporting */
4729 +#define PCIE_LCAP_DLL_ACTIVE_REPROT 0x00100000 /* Data Link Layer Active Reporting Capable */
4730 +#define PCIE_LCAP_PORT_NUM 0xFF0000000 /* Port number */
4731 +#define PCIE_LCAP_PORT_NUM_S 24
4733 +/* Maximum Length width definition */
4734 +#define PCIE_MAX_LENGTH_WIDTH_RES 0x00
4735 +#define PCIE_MAX_LENGTH_WIDTH_X1 0x01 /* Default */
4736 +#define PCIE_MAX_LENGTH_WIDTH_X2 0x02
4737 +#define PCIE_MAX_LENGTH_WIDTH_X4 0x04
4738 +#define PCIE_MAX_LENGTH_WIDTH_X8 0x08
4739 +#define PCIE_MAX_LENGTH_WIDTH_X12 0x0C
4740 +#define PCIE_MAX_LENGTH_WIDTH_X16 0x10
4741 +#define PCIE_MAX_LENGTH_WIDTH_X32 0x20
4743 +/* Active State Link PM definition */
4745 + PCIE_ASPM_RES0 = 0,
4746 + PCIE_ASPM_L0S_ENTRY_SUPPORT, /* L0s */
4748 + PCIE_ASPM_L0S_L1_ENTRY_SUPPORT, /* L0s and L1, default */
4751 +/* L0s Exit Latency definition */
4753 + PCIE_L0S_EIXT_LATENCY_L64NS = 0, /* < 64 ns */
4754 + PCIE_L0S_EIXT_LATENCY_B64A128, /* > 64 ns < 128 ns */
4755 + PCIE_L0S_EIXT_LATENCY_B128A256, /* > 128 ns < 256 ns */
4756 + PCIE_L0S_EIXT_LATENCY_B256A512, /* > 256 ns < 512 ns */
4757 + PCIE_L0S_EIXT_LATENCY_B512TO1U, /* > 512 ns < 1 us */
4758 + PCIE_L0S_EIXT_LATENCY_B1A2U, /* > 1 us < 2 us */
4759 + PCIE_L0S_EIXT_LATENCY_B2A4U, /* > 2 us < 4 us */
4760 + PCIE_L0S_EIXT_LATENCY_M4US, /* > 4 us */
4763 +/* L1 Exit Latency definition */
4765 + PCIE_L1_EXIT_LATENCY_L1US = 0, /* < 1 us */
4766 + PCIE_L1_EXIT_LATENCY_B1A2, /* > 1 us < 2 us */
4767 + PCIE_L1_EXIT_LATENCY_B2A4, /* > 2 us < 4 us */
4768 + PCIE_L1_EXIT_LATENCY_B4A8, /* > 4 us < 8 us */
4769 + PCIE_L1_EXIT_LATENCY_B8A16, /* > 8 us < 16 us */
4770 + PCIE_L1_EXIT_LATENCY_B16A32, /* > 16 us < 32 us */
4771 + PCIE_L1_EXIT_LATENCY_B32A64, /* > 32 us < 64 us */
4772 + PCIE_L1_EXIT_LATENCY_M64US, /* > 64 us */
4775 +/* Link Control and Status Register */
4776 +#define PCIE_LCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x80)
4777 +#define PCIE_LCTLSTS_ASPM_ENABLE 0x00000003 /* Active State Link PM Control */
4778 +#define PCIE_LCTLSTS_ASPM_ENABLE_S 0
4779 +#define PCIE_LCTLSTS_RCB128 0x00000008 /* Read Completion Boundary 128*/
4780 +#define PCIE_LCTLSTS_LINK_DISABLE 0x00000010 /* Link Disable */
4781 +#define PCIE_LCTLSTS_RETRIAN_LINK 0x00000020 /* Retrain Link */
4782 +#define PCIE_LCTLSTS_COM_CLK_CFG 0x00000040 /* Common Clock Configuration */
4783 +#define PCIE_LCTLSTS_EXT_SYNC 0x00000080 /* Extended Synch */
4784 +#define PCIE_LCTLSTS_CLK_PM_EN 0x00000100 /* Enable Clock Powerm Management */
4785 +#define PCIE_LCTLSTS_LINK_SPEED 0x000F0000 /* Link Speed */
4786 +#define PCIE_LCTLSTS_LINK_SPEED_S 16
4787 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH 0x03F00000 /* Negotiated Link Width */
4788 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH_S 20
4789 +#define PCIE_LCTLSTS_RETRAIN_PENDING 0x08000000 /* Link training is ongoing */
4790 +#define PCIE_LCTLSTS_SLOT_CLK_CFG 0x10000000 /* Slot Clock Configuration */
4791 +#define PCIE_LCTLSTS_DLL_ACTIVE 0x20000000 /* Data Link Layer Active */
4793 +/* Slot Capabilities Register */
4794 +#define PCIE_SLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x84)
4796 +/* Slot Capabilities */
4797 +#define PCIE_SLCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x88)
4799 +/* Root Control and Capability Register */
4800 +#define PCIE_RCTLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x8C)
4801 +#define PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR 0x00000001 /* #SERR on COR-ERR */
4802 +#define PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR 0x00000002 /* #SERR on Non-Fatal ERR */
4803 +#define PCIE_RCTLCAP_SERR_ON_FATAL_ERR 0x00000004 /* #SERR on Fatal ERR */
4804 +#define PCIE_RCTLCAP_PME_INT_EN 0x00000008 /* PME Interrupt Enable */
4805 +#define PCIE_RCTLCAP_SERR_ENABLE (PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR | \
4806 + PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR | PCIE_RCTLCAP_SERR_ON_FATAL_ERR)
4807 +/* Root Status Register */
4808 +#define PCIE_RSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x90)
4809 +#define PCIE_RSTS_PME_REQ_ID 0x0000FFFF /* PME Request ID */
4810 +#define PCIE_RSTS_PME_REQ_ID_S 0
4811 +#define PCIE_RSTS_PME_STATUS 0x00010000 /* PME Status */
4812 +#define PCIE_RSTS_PME_PENDING 0x00020000 /* PME Pending */
4814 +/* PCI Express Enhanced Capability Header */
4815 +#define PCIE_ENHANCED_CAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x100)
4816 +#define PCIE_ENHANCED_CAP_ID 0x0000FFFF /* PCI Express Extended Capability ID */
4817 +#define PCIE_ENHANCED_CAP_ID_S 0
4818 +#define PCIE_ENHANCED_CAP_VER 0x000F0000 /* Capability Version */
4819 +#define PCIE_ENHANCED_CAP_VER_S 16
4820 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET 0xFFF00000 /* Next Capability Offset */
4821 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET_S 20
4823 +/* Uncorrectable Error Status Register */
4824 +#define PCIE_UES_R(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x104)
4825 +#define PCIE_DATA_LINK_PROTOCOL_ERR 0x00000010 /* Data Link Protocol Error Status */
4826 +#define PCIE_SURPRISE_DOWN_ERROR 0x00000020 /* Surprise Down Error Status */
4827 +#define PCIE_POISONED_TLP 0x00001000 /* Poisoned TLP Status */
4828 +#define PCIE_FC_PROTOCOL_ERR 0x00002000 /* Flow Control Protocol Error Status */
4829 +#define PCIE_COMPLETION_TIMEOUT 0x00004000 /* Completion Timeout Status */
4830 +#define PCIE_COMPLETOR_ABORT 0x00008000 /* Completer Abort Error */
4831 +#define PCIE_UNEXPECTED_COMPLETION 0x00010000 /* Unexpected Completion Status */
4832 +#define PCIE_RECEIVER_OVERFLOW 0x00020000 /* Receive Overflow Status */
4833 +#define PCIE_MALFORNED_TLP 0x00040000 /* Malformed TLP Stauts */
4834 +#define PCIE_ECRC_ERR 0x00080000 /* ECRC Error Stauts */
4835 +#define PCIE_UR_REQ 0x00100000 /* Unsupported Request Error Status */
4836 +#define PCIE_ALL_UNCORRECTABLE_ERR (PCIE_DATA_LINK_PROTOCOL_ERR | PCIE_SURPRISE_DOWN_ERROR | \
4837 + PCIE_POISONED_TLP | PCIE_FC_PROTOCOL_ERR | PCIE_COMPLETION_TIMEOUT | \
4838 + PCIE_COMPLETOR_ABORT | PCIE_UNEXPECTED_COMPLETION | PCIE_RECEIVER_OVERFLOW |\
4839 + PCIE_MALFORNED_TLP | PCIE_ECRC_ERR | PCIE_UR_REQ)
4841 +/* Uncorrectable Error Mask Register, Mask means no report */
4842 +#define PCIE_UEMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x108)
4844 +/* Uncorrectable Error Severity Register */
4845 +#define PCIE_UESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10C)
4847 +/* Correctable Error Status Register */
4848 +#define PCIE_CESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x110)
4849 +#define PCIE_RX_ERR 0x00000001 /* Receive Error Status */
4850 +#define PCIE_BAD_TLP 0x00000040 /* Bad TLP Status */
4851 +#define PCIE_BAD_DLLP 0x00000080 /* Bad DLLP Status */
4852 +#define PCIE_REPLAY_NUM_ROLLOVER 0x00000100 /* Replay Number Rollover Status */
4853 +#define PCIE_REPLAY_TIMER_TIMEOUT_ERR 0x00001000 /* Reply Timer Timeout Status */
4854 +#define PCIE_ADVISORY_NONFTAL_ERR 0x00002000 /* Advisory Non-Fatal Error Status */
4855 +#define PCIE_CORRECTABLE_ERR (PCIE_RX_ERR | PCIE_BAD_TLP | PCIE_BAD_DLLP | PCIE_REPLAY_NUM_ROLLOVER |\
4856 + PCIE_REPLAY_TIMER_TIMEOUT_ERR | PCIE_ADVISORY_NONFTAL_ERR)
4858 +/* Correctable Error Mask Register */
4859 +#define PCIE_CEMR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x114)
4861 +/* Advanced Error Capabilities and Control Register */
4862 +#define PCIE_AECCR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x118)
4863 +#define PCIE_AECCR_FIRST_ERR_PTR 0x0000001F /* First Error Pointer */
4864 +#define PCIE_AECCR_FIRST_ERR_PTR_S 0
4865 +#define PCIE_AECCR_ECRC_GEN_CAP 0x00000020 /* ECRC Generation Capable */
4866 +#define PCIE_AECCR_ECRC_GEN_EN 0x00000040 /* ECRC Generation Enable */
4867 +#define PCIE_AECCR_ECRC_CHECK_CAP 0x00000080 /* ECRC Check Capable */
4868 +#define PCIE_AECCR_ECRC_CHECK_EN 0x00000100 /* ECRC Check Enable */
4870 +/* Header Log Register 1 */
4871 +#define PCIE_HLR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x11C)
4873 +/* Header Log Register 2 */
4874 +#define PCIE_HLR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x120)
4876 +/* Header Log Register 3 */
4877 +#define PCIE_HLR3(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x124)
4879 +/* Header Log Register 4 */
4880 +#define PCIE_HLR4(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x128)
4882 +/* Root Error Command Register */
4883 +#define PCIE_RECR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x12C)
4884 +#define PCIE_RECR_CORRECTABLE_ERR_REPORT_EN 0x00000001 /* COR-ERR */
4885 +#define PCIE_RECR_NONFATAL_ERR_REPORT_EN 0x00000002 /* Non-Fatal ERR */
4886 +#define PCIE_RECR_FATAL_ERR_REPORT_EN 0x00000004 /* Fatal ERR */
4887 +#define PCIE_RECR_ERR_REPORT_EN (PCIE_RECR_CORRECTABLE_ERR_REPORT_EN | \
4888 + PCIE_RECR_NONFATAL_ERR_REPORT_EN | PCIE_RECR_FATAL_ERR_REPORT_EN)
4890 +/* Root Error Status Register */
4891 +#define PCIE_RESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x130)
4892 +#define PCIE_RESR_CORRECTABLE_ERR 0x00000001 /* COR-ERR Receveid */
4893 +#define PCIE_RESR_MULTI_CORRECTABLE_ERR 0x00000002 /* Multiple COR-ERR Received */
4894 +#define PCIE_RESR_FATAL_NOFATAL_ERR 0x00000004 /* ERR Fatal/Non-Fatal Received */
4895 +#define PCIE_RESR_MULTI_FATAL_NOFATAL_ERR 0x00000008 /* Multiple ERR Fatal/Non-Fatal Received */
4896 +#define PCIE_RESR_FIRST_UNCORRECTABLE_FATAL_ERR 0x00000010 /* First UN-COR Fatal */
4897 +#define PCIR_RESR_NON_FATAL_ERR 0x00000020 /* Non-Fatal Error Message Received */
4898 +#define PCIE_RESR_FATAL_ERR 0x00000040 /* Fatal Message Received */
4899 +#define PCIE_RESR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
4900 +#define PCIE_RESR_AER_INT_MSG_NUM_S 27
4902 +/* Error Source Indentification Register */
4903 +#define PCIE_ESIR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x134)
4904 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID 0x0000FFFF
4905 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID_S 0
4906 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID 0xFFFF0000
4907 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID_S 16
4909 +/* VC Enhanced Capability Header */
4910 +#define PCIE_VC_ECH(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x140)
4912 +/* Port VC Capability Register */
4913 +#define PCIE_PVC1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x144)
4914 +#define PCIE_PVC1_EXT_VC_CNT 0x00000007 /* Extended VC Count */
4915 +#define PCIE_PVC1_EXT_VC_CNT_S 0
4916 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT 0x00000070 /* Low Priority Extended VC Count */
4917 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT_S 4
4918 +#define PCIE_PVC1_REF_CLK 0x00000300 /* Reference Clock */
4919 +#define PCIE_PVC1_REF_CLK_S 8
4920 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE 0x00000C00 /* Port Arbitration Table Entry Size */
4921 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE_S 10
4923 +/* Extended Virtual Channel Count Defintion */
4924 +#define PCIE_EXT_VC_CNT_MIN 0
4925 +#define PCIE_EXT_VC_CNT_MAX 7
4927 +/* Port Arbitration Table Entry Size Definition */
4929 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S1BIT = 0,
4930 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S2BIT,
4931 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S4BIT,
4932 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S8BIT,
4935 +/* Port VC Capability Register 2 */
4936 +#define PCIE_PVC2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x148)
4937 +#define PCIE_PVC2_VC_ARB_16P_FIXED_WRR 0x00000001 /* HW Fixed arbitration, 16 phase WRR */
4938 +#define PCIE_PVC2_VC_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
4939 +#define PCIE_PVC2_VC_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
4940 +#define PCIE_PVC2_VC_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
4941 +#define PCIE_PVC2_VC_ARB_WRR 0x0000000F
4942 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET 0xFF000000 /* VC arbitration table offset, not support */
4943 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET_S 24
4945 +/* Port VC Control and Status Register */
4946 +#define PCIE_PVCCRSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14C)
4947 +#define PCIE_PVCCRSR_LOAD_VC_ARB_TAB 0x00000001 /* Load VC Arbitration Table */
4948 +#define PCIE_PVCCRSR_VC_ARB_SEL 0x0000000E /* VC Arbitration Select */
4949 +#define PCIE_PVCCRSR_VC_ARB_SEL_S 1
4950 +#define PCIE_PVCCRSR_VC_ARB_TAB_STATUS 0x00010000 /* Arbitration Status */
4952 +/* VC0 Resource Capability Register */
4953 +#define PCIE_VC0_RC(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x150)
4954 +#define PCIE_VC0_RC_PORT_ARB_HW_FIXED 0x00000001 /* HW Fixed arbitration */
4955 +#define PCIE_VC0_RC_PORT_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
4956 +#define PCIE_VC0_RC_PORT_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
4957 +#define PCIE_VC0_RC_PORT_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
4958 +#define PCIE_VC0_RC_PORT_ARB_TM_128P_WRR 0x00000010 /* Time-based 128 phase WRR */
4959 +#define PCIE_VC0_RC_PORT_ARB_TM_256P_WRR 0x00000020 /* Time-based 256 phase WRR */
4960 +#define PCIE_VC0_RC_PORT_ARB (PCIE_VC0_RC_PORT_ARB_HW_FIXED | PCIE_VC0_RC_PORT_ARB_32P_WRR |\
4961 + PCIE_VC0_RC_PORT_ARB_64P_WRR | PCIE_VC0_RC_PORT_ARB_128P_WRR | \
4962 + PCIE_VC0_RC_PORT_ARB_TM_128P_WRR | PCIE_VC0_RC_PORT_ARB_TM_256P_WRR)
4964 +#define PCIE_VC0_RC_REJECT_SNOOP 0x00008000 /* Reject Snoop Transactioin */
4965 +#define PCIE_VC0_RC_MAX_TIMESLOTS 0x007F0000 /* Maximum time Slots */
4966 +#define PCIE_VC0_RC_MAX_TIMESLOTS_S 16
4967 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET 0xFF000000 /* Port Arbitration Table Offset */
4968 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET_S 24
4970 +/* VC0 Resource Control Register */
4971 +#define PCIE_VC0_RC0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x154)
4972 +#define PCIE_VC0_RC0_TVM0 0x00000001 /* TC0 and VC0 */
4973 +#define PCIE_VC0_RC0_TVM1 0x00000002 /* TC1 and VC1 */
4974 +#define PCIE_VC0_RC0_TVM2 0x00000004 /* TC2 and VC2 */
4975 +#define PCIE_VC0_RC0_TVM3 0x00000008 /* TC3 and VC3 */
4976 +#define PCIE_VC0_RC0_TVM4 0x00000010 /* TC4 and VC4 */
4977 +#define PCIE_VC0_RC0_TVM5 0x00000020 /* TC5 and VC5 */
4978 +#define PCIE_VC0_RC0_TVM6 0x00000040 /* TC6 and VC6 */
4979 +#define PCIE_VC0_RC0_TVM7 0x00000080 /* TC7 and VC7 */
4980 +#define PCIE_VC0_RC0_TC_VC 0x000000FF /* TC/VC mask */
4982 +#define PCIE_VC0_RC0_LOAD_PORT_ARB_TAB 0x00010000 /* Load Port Arbitration Table */
4983 +#define PCIE_VC0_RC0_PORT_ARB_SEL 0x000E0000 /* Port Arbitration Select */
4984 +#define PCIE_VC0_RC0_PORT_ARB_SEL_S 17
4985 +#define PCIE_VC0_RC0_VC_ID 0x07000000 /* VC ID */
4986 +#define PCIE_VC0_RC0_VC_ID_S 24
4987 +#define PCIE_VC0_RC0_VC_EN 0x80000000 /* VC Enable */
4989 +/* VC0 Resource Status Register */
4990 +#define PCIE_VC0_RSR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x158)
4991 +#define PCIE_VC0_RSR0_PORT_ARB_TAB_STATUS 0x00010000 /* Port Arbitration Table Status,not used */
4992 +#define PCIE_VC0_RSR0_VC_NEG_PENDING 0x00020000 /* VC Negotiation Pending */
4994 +/* Ack Latency Timer and Replay Timer Register */
4995 +#define PCIE_ALTRT(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x700)
4996 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT 0x0000FFFF /* Round Trip Latency Time Limit */
4997 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT_S 0
4998 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT 0xFFFF0000 /* Replay Time Limit */
4999 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT_S 16
5001 +/* Other Message Register */
5002 +#define PCIE_OMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x704)
5004 +/* Port Force Link Register */
5005 +#define PCIE_PFLR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x708)
5006 +#define PCIE_PFLR_LINK_NUM 0x000000FF /* Link Number */
5007 +#define PCIE_PFLR_LINK_NUM_S 0
5008 +#define PCIE_PFLR_FORCE_LINK 0x00008000 /* Force link */
5009 +#define PCIE_PFLR_LINK_STATE 0x003F0000 /* Link State */
5010 +#define PCIE_PFLR_LINK_STATE_S 16
5011 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT 0xFF000000 /* Low Power Entrance Count, only for EP */
5012 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT_S 24
5014 +/* Ack Frequency Register */
5015 +#define PCIE_AFR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70C)
5016 +#define PCIE_AFR_AF 0x000000FF /* Ack Frequency */
5017 +#define PCIE_AFR_AF_S 0
5018 +#define PCIE_AFR_FTS_NUM 0x0000FF00 /* The number of Fast Training Sequence from L0S to L0 */
5019 +#define PCIE_AFR_FTS_NUM_S 8
5020 +#define PCIE_AFR_COM_FTS_NUM 0x00FF0000 /* N_FTS; when common clock is used*/
5021 +#define PCIE_AFR_COM_FTS_NUM_S 16
5022 +#define PCIE_AFR_L0S_ENTRY_LATENCY 0x07000000 /* L0s Entrance Latency */
5023 +#define PCIE_AFR_L0S_ENTRY_LATENCY_S 24
5024 +#define PCIE_AFR_L1_ENTRY_LATENCY 0x38000000 /* L1 Entrance Latency */
5025 +#define PCIE_AFR_L1_ENTRY_LATENCY_S 27
5026 +#define PCIE_AFR_FTS_NUM_DEFAULT 32
5027 +#define PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT 7
5028 +#define PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT 5
5030 +/* Port Link Control Register */
5031 +#define PCIE_PLCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x710)
5032 +#define PCIE_PLCR_OTHER_MSG_REQ 0x00000001 /* Other Message Request */
5033 +#define PCIE_PLCR_SCRAMBLE_DISABLE 0x00000002 /* Scramble Disable */
5034 +#define PCIE_PLCR_LOOPBACK_EN 0x00000004 /* Loopback Enable */
5035 +#define PCIE_PLCR_LTSSM_HOT_RST 0x00000008 /* Force LTSSM to the hot reset */
5036 +#define PCIE_PLCR_DLL_LINK_EN 0x00000020 /* Enable Link initialization */
5037 +#define PCIE_PLCR_FAST_LINK_SIM_EN 0x00000080 /* Sets all internal timers to fast mode for simulation purposes */
5038 +#define PCIE_PLCR_LINK_MODE 0x003F0000 /* Link Mode Enable Mask */
5039 +#define PCIE_PLCR_LINK_MODE_S 16
5040 +#define PCIE_PLCR_CORRUPTED_CRC_EN 0x02000000 /* Enabled Corrupt CRC */
5042 +/* Lane Skew Register */
5043 +#define PCIE_LSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x714)
5044 +#define PCIE_LSR_LANE_SKEW_NUM 0x00FFFFFF /* Insert Lane Skew for Transmit, not applicable */
5045 +#define PCIE_LSR_LANE_SKEW_NUM_S 0
5046 +#define PCIE_LSR_FC_DISABLE 0x01000000 /* Disable of Flow Control */
5047 +#define PCIE_LSR_ACKNAK_DISABLE 0x02000000 /* Disable of Ack/Nak */
5048 +#define PCIE_LSR_LANE_DESKEW_DISABLE 0x80000000 /* Disable of Lane-to-Lane Skew */
5050 +/* Symbol Number Register */
5051 +#define PCIE_SNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x718)
5052 +#define PCIE_SNR_TS 0x0000000F /* Number of TS Symbol */
5053 +#define PCIE_SNR_TS_S 0
5054 +#define PCIE_SNR_SKP 0x00000700 /* Number of SKP Symbol */
5055 +#define PCIE_SNR_SKP_S 8
5056 +#define PCIE_SNR_REPLAY_TIMER 0x0007C000 /* Timer Modifier for Replay Timer */
5057 +#define PCIE_SNR_REPLAY_TIMER_S 14
5058 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER 0x00F80000 /* Timer Modifier for Ack/Nak Latency Timer */
5059 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER_S 19
5060 +#define PCIE_SNR_FC_TIMER 0x1F000000 /* Timer Modifier for Flow Control Watchdog Timer */
5061 +#define PCIE_SNR_FC_TIMER_S 28
5063 +/* Symbol Timer Register and Filter Mask Register 1 */
5064 +#define PCIE_STRFMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x71C)
5065 +#define PCIE_STRFMR_SKP_INTERVAL 0x000007FF /* SKP lnterval Value */
5066 +#define PCIE_STRFMR_SKP_INTERVAL_S 0
5067 +#define PCIE_STRFMR_FC_WDT_DISABLE 0x00008000 /* Disable of FC Watchdog Timer */
5068 +#define PCIE_STRFMR_TLP_FUNC_MISMATCH_OK 0x00010000 /* Mask Function Mismatch Filtering for Incoming Requests */
5069 +#define PCIE_STRFMR_POISONED_TLP_OK 0x00020000 /* Mask Poisoned TLP Filtering */
5070 +#define PCIE_STRFMR_BAR_MATCH_OK 0x00040000 /* Mask BAR Match Filtering */
5071 +#define PCIE_STRFMR_TYPE1_CFG_REQ_OK 0x00080000 /* Mask Type 1 Configuration Request Filtering */
5072 +#define PCIE_STRFMR_LOCKED_REQ_OK 0x00100000 /* Mask Locked Request Filtering */
5073 +#define PCIE_STRFMR_CPL_TAG_ERR_RULES_OK 0x00200000 /* Mask Tag Error Rules for Received Completions */
5074 +#define PCIE_STRFMR_CPL_REQUESTOR_ID_MISMATCH_OK 0x00400000 /* Mask Requester ID Mismatch Error for Received Completions */
5075 +#define PCIE_STRFMR_CPL_FUNC_MISMATCH_OK 0x00800000 /* Mask Function Mismatch Error for Received Completions */
5076 +#define PCIE_STRFMR_CPL_TC_MISMATCH_OK 0x01000000 /* Mask Traffic Class Mismatch Error for Received Completions */
5077 +#define PCIE_STRFMR_CPL_ATTR_MISMATCH_OK 0x02000000 /* Mask Attribute Mismatch Error for Received Completions */
5078 +#define PCIE_STRFMR_CPL_LENGTH_MISMATCH_OK 0x04000000 /* Mask Length Mismatch Error for Received Completions */
5079 +#define PCIE_STRFMR_TLP_ECRC_ERR_OK 0x08000000 /* Mask ECRC Error Filtering */
5080 +#define PCIE_STRFMR_CPL_TLP_ECRC_OK 0x10000000 /* Mask ECRC Error Filtering for Completions */
5081 +#define PCIE_STRFMR_RX_TLP_MSG_NO_DROP 0x20000000 /* Send Message TLPs */
5082 +#define PCIE_STRFMR_RX_IO_TRANS_ENABLE 0x40000000 /* Mask Filtering of received I/O Requests */
5083 +#define PCIE_STRFMR_RX_CFG_TRANS_ENABLE 0x80000000 /* Mask Filtering of Received Configuration Requests */
5085 +#define PCIE_DEF_SKP_INTERVAL 700 /* 1180 ~1538 , 125MHz * 2, 250MHz * 1 */
5087 +/* Filter Masker Register 2 */
5088 +#define PCIE_FMR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x720)
5089 +#define PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1 0x00000001 /* Mask RADM Filtering and Error Handling Rules */
5090 +#define PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 0x00000002 /* Mask RADM Filtering and Error Handling Rules */
5092 +/* Debug Register 0 */
5093 +#define PCIE_DBR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x728)
5095 +/* Debug Register 1 */
5096 +#define PCIE_DBR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x72C)
5098 +/* Transmit Posted FC Credit Status Register */
5099 +#define PCIE_TPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x730)
5100 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS 0x00000FFF /* Transmit Posted Data FC Credits */
5101 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS_S 0
5102 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS 0x000FF000 /* Transmit Posted Header FC Credits */
5103 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS_S 12
5105 +/* Transmit Non-Posted FC Credit Status */
5106 +#define PCIE_TNPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x734)
5107 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS 0x00000FFF /* Transmit Non-Posted Data FC Credits */
5108 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS_S 0
5109 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS 0x000FF000 /* Transmit Non-Posted Header FC Credits */
5110 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS_S 12
5112 +/* Transmit Complete FC Credit Status Register */
5113 +#define PCIE_TCFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x738)
5114 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS 0x00000FFF /* Transmit Completion Data FC Credits */
5115 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS_S 0
5116 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS 0x000FF000 /* Transmit Completion Header FC Credits */
5117 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS_S 12
5119 +/* Queue Status Register */
5120 +#define PCIE_QSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x73C)
5121 +#define PCIE_QSR_WAIT_UPDATE_FC_DLL 0x00000001 /* Received TLP FC Credits Not Returned */
5122 +#define PCIE_QSR_TX_RETRY_BUF_NOT_EMPTY 0x00000002 /* Transmit Retry Buffer Not Empty */
5123 +#define PCIE_QSR_RX_QUEUE_NOT_EMPTY 0x00000004 /* Received Queue Not Empty */
5125 +/* VC Transmit Arbitration Register 1 */
5126 +#define PCIE_VCTAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x740)
5127 +#define PCIE_VCTAR1_WRR_WEIGHT_VC0 0x000000FF /* WRR Weight for VC0 */
5128 +#define PCIE_VCTAR1_WRR_WEIGHT_VC1 0x0000FF00 /* WRR Weight for VC1 */
5129 +#define PCIE_VCTAR1_WRR_WEIGHT_VC2 0x00FF0000 /* WRR Weight for VC2 */
5130 +#define PCIE_VCTAR1_WRR_WEIGHT_VC3 0xFF000000 /* WRR Weight for VC3 */
5132 +/* VC Transmit Arbitration Register 2 */
5133 +#define PCIE_VCTAR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x744)
5134 +#define PCIE_VCTAR2_WRR_WEIGHT_VC4 0x000000FF /* WRR Weight for VC4 */
5135 +#define PCIE_VCTAR2_WRR_WEIGHT_VC5 0x0000FF00 /* WRR Weight for VC5 */
5136 +#define PCIE_VCTAR2_WRR_WEIGHT_VC6 0x00FF0000 /* WRR Weight for VC6 */
5137 +#define PCIE_VCTAR2_WRR_WEIGHT_VC7 0xFF000000 /* WRR Weight for VC7 */
5139 +/* VC0 Posted Receive Queue Control Register */
5140 +#define PCIE_VC0_PRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x748)
5141 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS 0x00000FFF /* VC0 Posted Data Credits */
5142 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS_S 0
5143 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS 0x000FF000 /* VC0 Posted Header Credits */
5144 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS_S 12
5145 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE 0x00E00000 /* VC0 Posted TLP Queue Mode */
5146 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE_S 20
5147 +#define PCIE_VC0_PRQCR_TLP_RELAX_ORDER 0x40000000 /* TLP Type Ordering for VC0 */
5148 +#define PCIE_VC0_PRQCR_VC_STRICT_ORDER 0x80000000 /* VC0 Ordering for Receive Queues */
5150 +/* VC0 Non-Posted Receive Queue Control */
5151 +#define PCIE_VC0_NPRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74C)
5152 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS 0x00000FFF /* VC0 Non-Posted Data Credits */
5153 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS_S 0
5154 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS 0x000FF000 /* VC0 Non-Posted Header Credits */
5155 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS_S 12
5156 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE 0x00E00000 /* VC0 Non-Posted TLP Queue Mode */
5157 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE_S 20
5159 +/* VC0 Completion Receive Queue Control */
5160 +#define PCIE_VC0_CRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x750)
5161 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS 0x00000FFF /* VC0 Completion TLP Queue Mode */
5162 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS_S 0
5163 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS 0x000FF000 /* VC0 Completion Header Credits */
5164 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS_S 12
5165 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE 0x00E00000 /* VC0 Completion Data Credits */
5166 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE_S 21
5168 +/* Applicable to the above three registers */
5170 + PCIE_VC0_TLP_QUEUE_MODE_STORE_FORWARD = 1,
5171 + PCIE_VC0_TLP_QUEUE_MODE_CUT_THROUGH = 2,
5172 + PCIE_VC0_TLP_QUEUE_MODE_BYPASS = 4,
5175 +/* VC0 Posted Buffer Depth Register */
5176 +#define PCIE_VC0_PBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7A8)
5177 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Posted Data Queue Depth */
5178 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES_S 0
5179 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Posted Header Queue Depth */
5180 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES_S 16
5182 +/* VC0 Non-Posted Buffer Depth Register */
5183 +#define PCIE_VC0_NPBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7AC)
5184 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Non-Posted Data Queue Depth */
5185 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES_S 0
5186 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Non-Posted Header Queue Depth */
5187 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES_S 16
5189 +/* VC0 Completion Buffer Depth Register */
5190 +#define PCIE_VC0_CBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7B0)
5191 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES 0x00003FFF /* C0 Completion Data Queue Depth */
5192 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES_S 0
5193 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Completion Header Queue Depth */
5194 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES_S 16
5196 +/* PHY Status Register, all zeros in VR9 */
5197 +#define PCIE_PHYSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x810)
5199 +/* PHY Control Register, all zeros in VR9 */
5200 +#define PCIE_PHYCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x814)
5203 + * PCIe PDI PHY register definition, suppose all the following
5204 + * stuff is confidential.
5205 + * XXX, detailed bit definition
5207 +#define PCIE_PHY_PLL_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x22 << 1))
5208 +#define PCIE_PHY_PLL_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x23 << 1))
5209 +#define PCIE_PHY_PLL_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x24 << 1))
5210 +#define PCIE_PHY_PLL_CTRL4(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x25 << 1))
5211 +#define PCIE_PHY_PLL_CTRL5(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x26 << 1))
5212 +#define PCIE_PHY_PLL_CTRL6(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x27 << 1))
5213 +#define PCIE_PHY_PLL_CTRL7(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x28 << 1))
5214 +#define PCIE_PHY_PLL_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x29 << 1))
5215 +#define PCIE_PHY_PLL_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2A << 1))
5216 +#define PCIE_PHY_PLL_A_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2B << 1))
5217 +#define PCIE_PHY_PLL_STATUS(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2C << 1))
5219 +#define PCIE_PHY_TX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x30 << 1))
5220 +#define PCIE_PHY_TX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x31 << 1))
5221 +#define PCIE_PHY_TX1_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x32 << 1))
5222 +#define PCIE_PHY_TX1_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x33 << 1))
5223 +#define PCIE_PHY_TX1_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x34 << 1))
5224 +#define PCIE_PHY_TX1_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x35 << 1))
5225 +#define PCIE_PHY_TX1_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x36 << 1))
5226 +#define PCIE_PHY_TX1_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x37 << 1))
5228 +#define PCIE_PHY_TX2_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x38 << 1))
5229 +#define PCIE_PHY_TX2_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x39 << 1))
5230 +#define PCIE_PHY_TX2_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3B << 1))
5231 +#define PCIE_PHY_TX2_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3C << 1))
5232 +#define PCIE_PHY_TX2_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3D << 1))
5233 +#define PCIE_PHY_TX2_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3E << 1))
5234 +#define PCIE_PHY_TX2_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3F << 1))
5236 +#define PCIE_PHY_RX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x50 << 1))
5237 +#define PCIE_PHY_RX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x51 << 1))
5238 +#define PCIE_PHY_RX1_CDR(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x52 << 1))
5239 +#define PCIE_PHY_RX1_EI(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x53 << 1))
5240 +#define PCIE_PHY_RX1_A_CTRL(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x55 << 1))
5242 +/* Interrupt related stuff */
5243 +#define PCIE_LEGACY_DISABLE 0
5244 +#define PCIE_LEGACY_INTA 1
5245 +#define PCIE_LEGACY_INTB 2
5246 +#define PCIE_LEGACY_INTC 3
5247 +#define PCIE_LEGACY_INTD 4
5248 +#define PCIE_LEGACY_INT_MAX PCIE_LEGACY_INTD
5250 +#define PCIE_IRQ_LOCK(lock) do { \
5251 + unsigned long flags; \
5252 + spin_lock_irqsave(&(lock), flags);
5253 +#define PCIE_IRQ_UNLOCK(lock) \
5254 + spin_unlock_irqrestore(&(lock), flags); \
5257 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
5258 +#define IRQF_SHARED SA_SHIRQ
5261 +#define PCIE_MSG_MSI 0x00000001
5262 +#define PCIE_MSG_ISR 0x00000002
5263 +#define PCIE_MSG_FIXUP 0x00000004
5264 +#define PCIE_MSG_READ_CFG 0x00000008
5265 +#define PCIE_MSG_WRITE_CFG 0x00000010
5266 +#define PCIE_MSG_CFG (PCIE_MSG_READ_CFG | PCIE_MSG_WRITE_CFG)
5267 +#define PCIE_MSG_REG 0x00000020
5268 +#define PCIE_MSG_INIT 0x00000040
5269 +#define PCIE_MSG_ERR 0x00000080
5270 +#define PCIE_MSG_PHY 0x00000100
5271 +#define PCIE_MSG_ANY 0x000001ff
5273 +#define IFX_PCIE_PORT0 0
5274 +#define IFX_PCIE_PORT1 1
5276 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
5277 +#define IFX_PCIE_CORE_NR 2
5279 +#define IFX_PCIE_CORE_NR 1
5282 +//#define IFX_PCIE_ERROR_INT
5284 +//#define IFX_PCIE_DBG
5286 +#if defined(IFX_PCIE_DBG)
5287 +#define IFX_PCIE_PRINT(_m, _fmt, args...) do { \
5288 + if (g_pcie_debug_flag & (_m)) { \
5289 + ifx_pcie_debug((_fmt), ##args); \
5295 +#define IFX_PCIE_PRINT(_m, _fmt, args...) \
5297 +#define INLINE inline
5300 +struct ifx_pci_controller {
5301 + struct pci_controller pcic;
5303 + /* RC specific, per host bus information */
5304 + u32 port; /* Port index, 0 -- 1st core, 1 -- 2nd core */
5307 +typedef struct ifx_pcie_ir_irq {
5308 + const unsigned int irq;
5309 + const char name[16];
5310 +}ifx_pcie_ir_irq_t;
5312 +typedef struct ifx_pcie_legacy_irq{
5313 + const u32 irq_bit;
5315 +}ifx_pcie_legacy_irq_t;
5317 +typedef struct ifx_pcie_irq {
5318 + ifx_pcie_ir_irq_t ir_irq;
5319 + ifx_pcie_legacy_irq_t legacy_irq[PCIE_LEGACY_INT_MAX];
5322 +extern u32 g_pcie_debug_flag;
5323 +extern void ifx_pcie_debug(const char *fmt, ...);
5324 +extern void pcie_phy_clock_mode_setup(int pcie_port);
5325 +extern void pcie_msi_pic_init(int pcie_port);
5326 +extern u32 ifx_pcie_bus_enum_read_hack(int where, u32 value);
5327 +extern u32 ifx_pcie_bus_enum_write_hack(int where, u32 value);
5330 +#include <linux/types.h>
5331 +#include <linux/delay.h>
5332 +#include <linux/gpio.h>
5333 +#include <linux/clk.h>
5335 +#include <lantiq_soc.h>
5337 +#define IFX_PCIE_GPIO_RESET 38
5338 +#define IFX_REG_R32 ltq_r32
5339 +#define IFX_REG_W32 ltq_w32
5340 +#define CONFIG_IFX_PCIE_HW_SWAP
5341 +#define IFX_RCU_AHB_ENDIAN ((volatile u32*)(IFX_RCU + 0x004C))
5342 +#define IFX_RCU_RST_REQ ((volatile u32*)(IFX_RCU + 0x0010))
5343 +#define IFX_RCU_AHB_BE_PCIE_PDI 0x00000080 /* Configure PCIE PDI module in big endian*/
5345 +#define IFX_RCU (KSEG1 | 0x1F203000)
5346 +#define IFX_RCU_AHB_BE_PCIE_M 0x00000001 /* Configure AHB master port that connects to PCIe RC in big endian */
5347 +#define IFX_RCU_AHB_BE_PCIE_S 0x00000010 /* Configure AHB slave port that connects to PCIe RC in little endian */
5348 +#define IFX_RCU_AHB_BE_XBAR_M 0x00000002 /* Configure AHB master port that connects to XBAR in big endian */
5349 +#define CONFIG_IFX_PCIE_PHY_36MHZ_MODE
5351 +#define IFX_PMU1_MODULE_PCIE_PHY (0)
5352 +#define IFX_PMU1_MODULE_PCIE_CTRL (1)
5353 +#define IFX_PMU1_MODULE_PDI (4)
5354 +#define IFX_PMU1_MODULE_MSI (5)
5356 +#define IFX_PMU_MODULE_PCIE_L0_CLK (31)
5359 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
5363 +static inline void pcie_ahb_pmu_setup(void)
5366 + clk = clk_get_sys("ltq_pcie", "ahb");
5368 + //ltq_pmu_enable(PMU_AHBM | PMU_AHBS);
5371 +static inline void pcie_rcu_endian_setup(int pcie_port)
5375 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
5376 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
5377 + reg |= IFX_RCU_AHB_BE_PCIE_M;
5378 + reg |= IFX_RCU_AHB_BE_PCIE_S;
5379 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
5381 + reg |= IFX_RCU_AHB_BE_PCIE_M;
5382 + reg &= ~IFX_RCU_AHB_BE_PCIE_S;
5383 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
5384 +#endif /* CONFIG_IFX_PCIE_HW_SWAP */
5385 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
5386 + IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
5389 +static inline void pcie_phy_pmu_enable(int pcie_port)
5392 + clk = clk_get_sys("ltq_pcie", "phy");
5394 + //ltq_pmu1_enable(1<<IFX_PMU1_MODULE_PCIE_PHY);
5397 +static inline void pcie_phy_pmu_disable(int pcie_port)
5400 + clk = clk_get_sys("ltq_pcie", "phy");
5402 + //ltq_pmu1_disable(1<<IFX_PMU1_MODULE_PCIE_PHY);
5405 +static inline void pcie_pdi_big_endian(int pcie_port)
5409 + /* SRAM2PDI endianness control. */
5410 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
5411 + /* Config AHB->PCIe and PDI endianness */
5412 + reg |= IFX_RCU_AHB_BE_PCIE_PDI;
5413 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
5416 +static inline void pcie_pdi_pmu_enable(int pcie_port)
5419 + clk = clk_get_sys("ltq_pcie", "pdi");
5421 + //ltq_pmu1_enable(1<<IFX_PMU1_MODULE_PDI);
5424 +static inline void pcie_core_rst_assert(int pcie_port)
5428 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5430 + /* Reset PCIe PHY & Core, bit 22, bit 26 may be affected if write it directly */
5431 + reg |= 0x00400000;
5432 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5435 +static inline void pcie_core_rst_deassert(int pcie_port)
5439 + /* Make sure one micro-second delay */
5442 + /* Reset PCIe PHY & Core, bit 22 */
5443 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5444 + reg &= ~0x00400000;
5445 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5448 +static inline void pcie_phy_rst_assert(int pcie_port)
5452 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5453 + reg |= 0x00001000; /* Bit 12 */
5454 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5457 +static inline void pcie_phy_rst_deassert(int pcie_port)
5461 + /* Make sure one micro-second delay */
5464 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5465 + reg &= ~0x00001000; /* Bit 12 */
5466 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5469 +static inline void pcie_device_rst_assert(int pcie_port)
5471 + gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
5472 + // ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
5475 +static inline void pcie_device_rst_deassert(int pcie_port)
5478 + gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
5479 +// ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
5482 +static inline void pcie_core_pmu_setup(int pcie_port)
5485 + clk = clk_get_sys("ltq_pcie", "ctl");
5487 + clk = clk_get_sys("ltq_pcie", "bus");
5490 + //ltq_pmu1_enable(1 << IFX_PMU1_MODULE_PCIE_CTRL);
5491 + //ltq_pmu_enable(1 << IFX_PMU_MODULE_PCIE_L0_CLK);
5494 +static inline void pcie_msi_init(int pcie_port)
5497 + pcie_msi_pic_init(pcie_port);
5498 + clk = clk_get_sys("ltq_pcie", "msi");
5500 + //ltq_pmu1_enable(1 << IFX_PMU1_MODULE_MSI);
5504 +ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
5506 + u32 tbus_number = bus_number;
5508 +#ifdef CONFIG_IFX_PCI
5509 + if (pcibios_host_nr() > 1) {
5510 + tbus_number -= pcibios_1st_host_bus_nr();
5512 +#endif /* CONFIG_IFX_PCI */
5513 + return tbus_number;
5517 +ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
5519 + struct pci_dev *pdev;
5520 + u32 tvalue = value;
5522 + /* Sanity check */
5523 + pdev = pci_get_slot(bus, devfn);
5524 + if (pdev == NULL) {
5528 + /* Only care about PCI bridge */
5529 + if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
5533 + if (read) { /* Read hack */
5534 + #ifdef CONFIG_IFX_PCI
5535 + if (pcibios_host_nr() > 1) {
5536 + tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
5538 + #endif /* CONFIG_IFX_PCI */
5540 + else { /* Write hack */
5541 + #ifdef CONFIG_IFX_PCI
5542 + if (pcibios_host_nr() > 1) {
5543 + tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
5550 +#endif /* IFXMIPS_PCIE_VR9_H */
5552 diff --git a/drivers/pci/pcie/aer/Kconfig b/drivers/pci/pcie/aer/Kconfig
5553 index 50e94e0..4bf848f 100644
5554 --- a/drivers/pci/pcie/aer/Kconfig
5555 +++ b/drivers/pci/pcie/aer/Kconfig
5558 boolean "Root Port Advanced Error Reporting support"
5559 depends on PCIEPORTBUS
5563 This enables PCI Express Root Port Advanced Error Reporting
5564 (AER) driver support. Error reporting messages sent to Root
5565 diff --git a/include/linux/pci.h b/include/linux/pci.h
5566 index 33aa2ca..f5e4a13 100644
5567 --- a/include/linux/pci.h
5568 +++ b/include/linux/pci.h
5569 @@ -1120,6 +1120,8 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
5571 int pci_cfg_space_size(struct pci_dev *dev);
5572 unsigned char pci_bus_max_busnr(struct pci_bus *bus);
5573 +int pcibios_host_nr(void);
5574 +int pcibios_1st_host_bus_nr(void);
5575 void pci_setup_bridge(struct pci_bus *bus);
5576 resource_size_t pcibios_window_alignment(struct pci_bus *bus,
5577 unsigned long type);
5578 diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
5579 index 97fbecd..cb3bde3 100644
5580 --- a/include/linux/pci_ids.h
5581 +++ b/include/linux/pci_ids.h
5582 @@ -1045,6 +1045,12 @@
5583 #define PCI_DEVICE_ID_SGI_LITHIUM 0x1002
5584 #define PCI_DEVICE_ID_SGI_IOC4 0x100a
5586 +#define PCI_VENDOR_ID_INFINEON 0x15D1
5587 +#define PCI_DEVICE_ID_INFINEON_DANUBE 0x000F
5588 +#define PCI_DEVICE_ID_INFINEON_PCIE 0x0011
5589 +#define PCI_VENDOR_ID_LANTIQ 0x1BEF
5590 +#define PCI_DEVICE_ID_LANTIQ_PCIE 0x00
5592 #define PCI_VENDOR_ID_WINBOND 0x10ad
5593 #define PCI_DEVICE_ID_WINBOND_82C105 0x0105
5594 #define PCI_DEVICE_ID_WINBOND_83C553 0x0565