1 From 86b0b37729298b067157263b7bf5dbf735527e7c Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Wed, 13 Mar 2013 09:39:02 +0100
4 Subject: [PATCH 30/40] MIPS: lantiq: add pcie driver
7 arch/mips/lantiq/Kconfig | 10 +
8 arch/mips/lantiq/xway/sysctrl.c | 2 +
9 arch/mips/pci/Makefile | 2 +
10 arch/mips/pci/fixup-lantiq-pcie.c | 82 ++
11 arch/mips/pci/fixup-lantiq.c | 3 +
12 arch/mips/pci/ifxmips_pci_common.h | 57 ++
13 arch/mips/pci/ifxmips_pcie.c | 1607 ++++++++++++++++++++++++++++++++++++
14 arch/mips/pci/ifxmips_pcie.h | 135 +++
15 arch/mips/pci/ifxmips_pcie_ar10.h | 290 +++++++
16 arch/mips/pci/ifxmips_pcie_msi.c | 392 +++++++++
17 arch/mips/pci/ifxmips_pcie_phy.c | 478 +++++++++++
18 arch/mips/pci/ifxmips_pcie_pm.c | 176 ++++
19 arch/mips/pci/ifxmips_pcie_pm.h | 36 +
20 arch/mips/pci/ifxmips_pcie_reg.h | 1001 ++++++++++++++++++++++
21 arch/mips/pci/ifxmips_pcie_vr9.h | 271 ++++++
22 arch/mips/pci/pci.c | 25 +
23 drivers/pci/pcie/aer/Kconfig | 2 +-
24 include/linux/pci.h | 2 +
25 include/linux/pci_ids.h | 6 +
26 19 files changed, 4576 insertions(+), 1 deletion(-)
27 create mode 100644 arch/mips/pci/fixup-lantiq-pcie.c
28 create mode 100644 arch/mips/pci/ifxmips_pci_common.h
29 create mode 100644 arch/mips/pci/ifxmips_pcie.c
30 create mode 100644 arch/mips/pci/ifxmips_pcie.h
31 create mode 100644 arch/mips/pci/ifxmips_pcie_ar10.h
32 create mode 100644 arch/mips/pci/ifxmips_pcie_msi.c
33 create mode 100644 arch/mips/pci/ifxmips_pcie_phy.c
34 create mode 100644 arch/mips/pci/ifxmips_pcie_pm.c
35 create mode 100644 arch/mips/pci/ifxmips_pcie_pm.h
36 create mode 100644 arch/mips/pci/ifxmips_pcie_reg.h
37 create mode 100644 arch/mips/pci/ifxmips_pcie_vr9.h
39 Index: linux-3.8.13/arch/mips/lantiq/Kconfig
40 ===================================================================
41 --- linux-3.8.13.orig/arch/mips/lantiq/Kconfig 2013-07-25 20:01:18.211262427 +0200
42 +++ linux-3.8.13/arch/mips/lantiq/Kconfig 2013-07-25 20:01:18.399262431 +0200
47 + select ARCH_SUPPORTS_MSI
53 depends on SOC_XWAY && PCI
57 + depends on SOC_XWAY && PCI
59 +config PCIE_LANTIQ_MSI
61 + depends on PCIE_LANTIQ && PCI_MSI
65 bool "XRX200 PHY firmware loader"
67 Index: linux-3.8.13/arch/mips/lantiq/xway/sysctrl.c
68 ===================================================================
69 --- linux-3.8.13.orig/arch/mips/lantiq/xway/sysctrl.c 2013-07-25 20:01:18.375262431 +0200
70 +++ linux-3.8.13/arch/mips/lantiq/xway/sysctrl.c 2013-07-25 20:01:18.399262431 +0200
72 PMU_PPE_EMA | PMU_PPE_TC | PMU_PPE_SLL01 |
73 PMU_PPE_QSB | PMU_PPE_TOP);
74 clkdev_add_pmu("1f203000.rcu", "gphy", 0, PMU_GPHY);
75 + pmu_w32(~0, PMU_PWDSR1);
76 + pmu_w32(pmu_r32(PMU_PWDSR) & ~PMU_PCIE_CLK, PMU_PWDSR);
77 } else if (of_machine_is_compatible("lantiq,ar9")) {
78 clkdev_add_static(ltq_ar9_cpu_hz(), ltq_ar9_fpi_hz(),
79 ltq_ar9_fpi_hz(), CLOCK_250M);
80 Index: linux-3.8.13/arch/mips/pci/Makefile
81 ===================================================================
82 --- linux-3.8.13.orig/arch/mips/pci/Makefile 2013-05-11 22:57:46.000000000 +0200
83 +++ linux-3.8.13/arch/mips/pci/Makefile 2013-07-25 20:01:18.399262431 +0200
85 obj-$(CONFIG_SNI_RM) += fixup-sni.o ops-sni.o
86 obj-$(CONFIG_LANTIQ) += fixup-lantiq.o
87 obj-$(CONFIG_PCI_LANTIQ) += pci-lantiq.o ops-lantiq.o
88 +obj-$(CONFIG_PCIE_LANTIQ) += ifxmips_pcie_phy.o ifxmips_pcie.o fixup-lantiq-pcie.o
89 +obj-$(CONFIG_PCIE_LANTIQ_MSI) += pcie-lantiq-msi.o
90 obj-$(CONFIG_TANBAC_TB0219) += fixup-tb0219.o
91 obj-$(CONFIG_TANBAC_TB0226) += fixup-tb0226.o
92 obj-$(CONFIG_TANBAC_TB0287) += fixup-tb0287.o
93 Index: linux-3.8.13/arch/mips/pci/fixup-lantiq-pcie.c
94 ===================================================================
95 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
96 +++ linux-3.8.13/arch/mips/pci/fixup-lantiq-pcie.c 2013-07-25 20:01:18.403262431 +0200
98 +/******************************************************************************
100 +** FILE NAME : ifxmips_fixup_pcie.c
101 +** PROJECT : IFX UEIP for VRX200
104 +** DATE : 02 Mar 2009
105 +** AUTHOR : Lei Chuanhua
106 +** DESCRIPTION : PCIe Root Complex Driver
107 +** COPYRIGHT : Copyright (c) 2009
108 +** Infineon Technologies AG
109 +** Am Campeon 1-12, 85579 Neubiberg, Germany
111 +** This program is free software; you can redistribute it and/or modify
112 +** it under the terms of the GNU General Public License as published by
113 +** the Free Software Foundation; either version 2 of the License, or
114 +** (at your option) any later version.
116 +** $Version $Date $Author $Comment
117 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
118 +*******************************************************************************/
120 + \file ifxmips_fixup_pcie.c
122 + \brief PCIe Fixup functions source file
124 +#include <linux/pci.h>
125 +#include <linux/pci_regs.h>
126 +#include <linux/pci_ids.h>
128 +#include <lantiq_soc.h>
130 +#include "pcie-lantiq.h"
132 +#define PCI_VENDOR_ID_INFINEON 0x15D1
133 +#define PCI_DEVICE_ID_INFINEON_DANUBE 0x000F
134 +#define PCI_DEVICE_ID_INFINEON_PCIE 0x0011
135 +#define PCI_VENDOR_ID_LANTIQ 0x1BEF
136 +#define PCI_DEVICE_ID_LANTIQ_PCIE 0x0011
141 +ifx_pcie_fixup_resource(struct pci_dev *dev)
145 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: enter\n", __func__, pci_name(dev));
147 + printk("%s: fixup host controller %s (%04x:%04x)\n",
148 + __func__, pci_name(dev), dev->vendor, dev->device);
150 + /* Setup COMMAND register */
151 + reg = PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER /* |
152 + PCI_COMMAND_INTX_DISABLE */| PCI_COMMAND_SERR;
153 + pci_write_config_word(dev, PCI_COMMAND, reg);
154 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: exit\n", __func__, pci_name(dev));
156 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INFINEON, PCI_DEVICE_ID_INFINEON_PCIE, ifx_pcie_fixup_resource);
157 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LANTIQ, PCI_VENDOR_ID_LANTIQ, ifx_pcie_fixup_resource);
160 +ifx_pcie_rc_class_early_fixup(struct pci_dev *dev)
162 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: enter\n", __func__, pci_name(dev));
164 + if (dev->devfn == PCI_DEVFN(0, 0) &&
165 + (dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) {
167 + dev->class = (PCI_CLASS_BRIDGE_PCI << 8) | (dev->class & 0xff);
169 + printk(KERN_INFO "%s: fixed pcie host bridge to pci-pci bridge\n", __func__);
171 + IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: exit\n", __func__, pci_name(dev));
175 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INFINEON, PCI_DEVICE_ID_INFINEON_PCIE,
176 + ifx_pcie_rc_class_early_fixup);
178 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LANTIQ, PCI_DEVICE_ID_LANTIQ_PCIE,
179 + ifx_pcie_rc_class_early_fixup);
180 Index: linux-3.8.13/arch/mips/pci/fixup-lantiq.c
181 ===================================================================
182 --- linux-3.8.13.orig/arch/mips/pci/fixup-lantiq.c 2013-05-11 22:57:46.000000000 +0200
183 +++ linux-3.8.13/arch/mips/pci/fixup-lantiq.c 2013-07-25 20:46:47.227327456 +0200
186 int (*ltq_pci_plat_arch_init)(struct pci_dev *dev) = NULL;
187 int (*ltq_pci_plat_dev_init)(struct pci_dev *dev) = NULL;
188 +int (*ltq_pci_map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
190 int pcibios_plat_dev_init(struct pci_dev *dev)
192 if (ltq_pci_plat_arch_init)
193 - return ltq_pci_plat_arch_init(dev);
194 + ltq_pci_plat_arch_init(dev);
196 if (ltq_pci_plat_dev_init)
197 return ltq_pci_plat_dev_init(dev);
199 struct of_irq dev_irq;
202 + if (ltq_pci_map_irq)
203 + return ltq_pci_map_irq(dev, slot, pin);
204 if (of_irq_map_pci(dev, &dev_irq)) {
205 dev_err(&dev->dev, "trying to map irq for unknown slot:%d pin:%d\n",
207 Index: linux-3.8.13/arch/mips/pci/ifxmips_pci_common.h
208 ===================================================================
209 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
210 +++ linux-3.8.13/arch/mips/pci/ifxmips_pci_common.h 2013-07-25 20:01:18.403262431 +0200
212 +/******************************************************************************
214 +** FILE NAME : ifxmips_pci_common.h
215 +** PROJECT : IFX UEIP
216 +** MODULES : PCI subsystem
218 +** DATE : 30 June 2009
219 +** AUTHOR : Lei Chuanhua
220 +** DESCRIPTION : PCIe Root Complex Driver
221 +** COPYRIGHT : Copyright (c) 2009
222 +** Infineon Technologies AG
223 +** Am Campeon 1-12, 85579 Neubiberg, Germany
225 +** This program is free software; you can redistribute it and/or modify
226 +** it under the terms of the GNU General Public License as published by
227 +** the Free Software Foundation; either version 2 of the License, or
228 +** (at your option) any later version.
230 +** $Version $Date $Author $Comment
231 +** 0.0.1 30 June,2009 Lei Chuanhua Initial version
232 +*******************************************************************************/
234 +#ifndef IFXMIPS_PCI_COMMON_H
235 +#define IFXMIPS_PCI_COMMON_H
236 +#include <linux/version.h>
238 + \defgroup IFX_PCI_COM IFX PCI/PCIe common parts for OS integration
239 + \brief PCI/PCIe common parts
243 + \defgroup IFX_PCI_COM_OS OS APIs
244 + \ingroup IFX_PCI_COM
245 + \brief PCI/PCIe bus driver OS interface functions
248 + \file ifxmips_pci_common.h
249 + \ingroup IFX_PCI_COM
250 + \brief PCI/PCIe bus driver common OS header file
252 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
253 +#define IFX_PCI_CONST
255 +#define IFX_PCI_CONST const
257 +#ifdef CONFIG_IFX_PCI
258 +extern int ifx_pci_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin);
259 +extern int ifx_pci_bios_plat_dev_init(struct pci_dev *dev);
260 +#endif /* COFNIG_IFX_PCI */
262 +#ifdef CONFIG_IFX_PCIE
263 +extern int ifx_pcie_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin);
264 +extern int ifx_pcie_bios_plat_dev_init(struct pci_dev *dev);
267 +#endif /* IFXMIPS_PCI_COMMON_H */
269 Index: linux-3.8.13/arch/mips/pci/ifxmips_pcie.c
270 ===================================================================
271 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
272 +++ linux-3.8.13/arch/mips/pci/ifxmips_pcie.c 2013-07-25 20:01:18.403262431 +0200
275 + * This program is free software; you can redistribute it and/or modify it
276 + * under the terms of the GNU General Public License version 2 as published
277 + * by the Free Software Foundation.
279 + * Copyright (C) 2009 Lei Chuanhua <chuanhua.lei@infineon.com>
280 + * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
283 +#include <linux/types.h>
284 +#include <linux/pci.h>
285 +#include <linux/kernel.h>
286 +#include <linux/init.h>
287 +#include <linux/delay.h>
288 +#include <linux/mm.h>
289 +#include <asm/paccess.h>
290 +#include <linux/pci.h>
291 +#include <linux/pci_regs.h>
292 +#include <linux/module.h>
294 +#include "ifxmips_pcie.h"
295 +#include "ifxmips_pcie_reg.h"
297 +/* Enable 32bit io due to its mem mapped io nature */
298 +#define IFX_PCIE_ERROR_INT
299 +#define IFX_PCIE_IO_32BIT
301 +#define IFX_PCIE_IR (INT_NUM_IM4_IRL0 + 25)
302 +#define IFX_PCIE_INTA (INT_NUM_IM4_IRL0 + 8)
303 +#define IFX_PCIE_INTB (INT_NUM_IM4_IRL0 + 9)
304 +#define IFX_PCIE_INTC (INT_NUM_IM4_IRL0 + 10)
305 +#define IFX_PCIE_INTD (INT_NUM_IM4_IRL0 + 11)
306 +#define MS(_v, _f) (((_v) & (_f)) >> _f##_S)
307 +#define SM(_v, _f) (((_v) << _f##_S) & (_f))
308 +#define IFX_REG_SET_BIT(_f, _r) \
309 + IFX_REG_W32((IFX_REG_R32((_r)) &~ (_f)) | (_f), (_r))
311 +#define IFX_PCIE_LTSSM_ENABLE_TIMEOUT 10
313 +static DEFINE_SPINLOCK(ifx_pcie_lock);
315 +u32 g_pcie_debug_flag = PCIE_MSG_ANY & (~PCIE_MSG_CFG);
317 +static ifx_pcie_irq_t pcie_irqs[IFX_PCIE_CORE_NR] = {
320 + .irq = IFX_PCIE_IR,
321 + .name = "ifx_pcie_rc0",
326 + .irq_bit = PCIE_IRN_INTA,
327 + .irq = IFX_PCIE_INTA,
330 + .irq_bit = PCIE_IRN_INTB,
331 + .irq = IFX_PCIE_INTB,
334 + .irq_bit = PCIE_IRN_INTC,
335 + .irq = IFX_PCIE_INTC,
338 + .irq_bit = PCIE_IRN_INTD,
339 + .irq = IFX_PCIE_INTD,
346 +void ifx_pcie_debug(const char *fmt, ...)
348 + static char buf[256] = {0}; /* XXX */
352 + vsnprintf(buf, sizeof(buf), fmt, ap);
359 +static inline int pcie_ltssm_enable(int pcie_port)
364 + IFX_REG_W32(PCIE_RC_CCR_LTSSM_ENABLE, PCIE_RC_CCR(pcie_port));
366 + /* Wait for the link to come up */
367 + for (i = 0; i < IFX_PCIE_LTSSM_ENABLE_TIMEOUT; i++) {
368 + if (!(IFX_REG_R32(PCIE_LCTLSTS(pcie_port)) & PCIE_LCTLSTS_RETRAIN_PENDING))
373 + printk("%s link timeout!!!!!\n", __func__);
377 +static inline void pcie_status_register_clear(int pcie_port)
379 + IFX_REG_W32(0, PCIE_RC_DR(pcie_port));
380 + IFX_REG_W32(0, PCIE_PCICMDSTS(pcie_port));
381 + IFX_REG_W32(0, PCIE_DCTLSTS(pcie_port));
382 + IFX_REG_W32(0, PCIE_LCTLSTS(pcie_port));
383 + IFX_REG_W32(0, PCIE_SLCTLSTS(pcie_port));
384 + IFX_REG_W32(0, PCIE_RSTS(pcie_port));
385 + IFX_REG_W32(0, PCIE_UES_R(pcie_port));
386 + IFX_REG_W32(0, PCIE_UEMR(pcie_port));
387 + IFX_REG_W32(0, PCIE_UESR(pcie_port));
388 + IFX_REG_W32(0, PCIE_CESR(pcie_port));
389 + IFX_REG_W32(0, PCIE_CEMR(pcie_port));
390 + IFX_REG_W32(0, PCIE_RESR(pcie_port));
391 + IFX_REG_W32(0, PCIE_PVCCRSR(pcie_port));
392 + IFX_REG_W32(0, PCIE_VC0_RSR0(pcie_port));
393 + IFX_REG_W32(0, PCIE_TPFCS(pcie_port));
394 + IFX_REG_W32(0, PCIE_TNPFCS(pcie_port));
395 + IFX_REG_W32(0, PCIE_TCFCS(pcie_port));
396 + IFX_REG_W32(0, PCIE_QSR(pcie_port));
397 + IFX_REG_W32(0, PCIE_IOBLSECS(pcie_port));
400 +static inline int ifx_pcie_link_up(int pcie_port)
402 + return (IFX_REG_R32(PCIE_PHY_SR(pcie_port)) & PCIE_PHY_SR_PHY_LINK_UP) ? 1 : 0;
406 +static inline void pcie_mem_io_setup(int pcie_port)
410 + * BAR[0:1] readonly register
411 + * RC contains only minimal BARs for packets mapped to this device
412 + * Mem/IO filters defines a range of memory occupied by memory mapped IO devices that
413 + * reside on the downstream side fo the bridge.
415 + reg = SM((PCIE_MEM_PHY_PORT_TO_END(pcie_port) >> 20), PCIE_MBML_MEM_LIMIT_ADDR)
416 + | SM((PCIE_MEM_PHY_PORT_TO_BASE(pcie_port) >> 20), PCIE_MBML_MEM_BASE_ADDR);
418 + IFX_REG_W32(reg, PCIE_MBML(pcie_port));
421 +#ifdef IFX_PCIE_PREFETCH_MEM_64BIT
422 + reg = SM((PCIE_MEM_PHY_PORT_TO_END(pcie_port) >> 20), PCIE_PMBL_END_ADDR)
423 + | SM((PCIE_MEM_PHY_PORT_TO_BASE(pcie_port) >> 20), PCIE_PMBL_UPPER_12BIT)
424 + | PCIE_PMBL_64BIT_ADDR;
425 + IFX_REG_W32(reg, PCIE_PMBL(pcie_port));
427 + /* Must configure upper 32bit */
428 + IFX_REG_W32(0, PCIE_PMBU32(pcie_port));
429 + IFX_REG_W32(0, PCIE_PMLU32(pcie_port));
431 + /* PCIe_PBML, same as MBML */
432 + IFX_REG_W32(IFX_REG_R32(PCIE_MBML(pcie_port)), PCIE_PMBL(pcie_port));
435 + /* IO Address Range */
436 + reg = SM((PCIE_IO_PHY_PORT_TO_END(pcie_port) >> 12), PCIE_IOBLSECS_IO_LIMIT_ADDR)
437 + | SM((PCIE_IO_PHY_PORT_TO_BASE(pcie_port) >> 12), PCIE_IOBLSECS_IO_BASE_ADDR);
438 +#ifdef IFX_PCIE_IO_32BIT
439 + reg |= PCIE_IOBLSECS_32BIT_IO_ADDR;
440 +#endif /* IFX_PCIE_IO_32BIT */
441 + IFX_REG_W32(reg, PCIE_IOBLSECS(pcie_port));
443 +#ifdef IFX_PCIE_IO_32BIT
444 + reg = SM((PCIE_IO_PHY_PORT_TO_END(pcie_port) >> 16), PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT)
445 + | SM((PCIE_IO_PHY_PORT_TO_BASE(pcie_port) >> 16), PCIE_IO_BANDL_UPPER_16BIT_IO_BASE);
446 + IFX_REG_W32(reg, PCIE_IO_BANDL(pcie_port));
448 +#endif /* IFX_PCIE_IO_32BIT */
452 +pcie_device_setup(int pcie_port)
456 + /* Device capability register, set up Maximum payload size */
457 + reg = IFX_REG_R32(PCIE_DCAP(pcie_port));
458 + reg |= PCIE_DCAP_ROLE_BASE_ERR_REPORT;
459 + reg |= SM(PCIE_MAX_PAYLOAD_128, PCIE_DCAP_MAX_PAYLOAD_SIZE);
461 + /* Only available for EP */
462 + reg &= ~(PCIE_DCAP_EP_L0S_LATENCY | PCIE_DCAP_EP_L1_LATENCY);
463 + IFX_REG_W32(reg, PCIE_DCAP(pcie_port));
465 + /* Device control and status register */
466 + /* Set Maximum Read Request size for the device as a Requestor */
467 + reg = IFX_REG_R32(PCIE_DCTLSTS(pcie_port));
470 + * Request size can be larger than the MPS used, but the completions returned
471 + * for the read will be bounded by the MPS size.
472 + * In our system, Max request size depends on AHB burst size. It is 64 bytes.
473 + * but we set it as 128 as minimum one.
475 + reg |= SM(PCIE_MAX_PAYLOAD_128, PCIE_DCTLSTS_MAX_READ_SIZE)
476 + | SM(PCIE_MAX_PAYLOAD_128, PCIE_DCTLSTS_MAX_PAYLOAD_SIZE);
478 + /* Enable relaxed ordering, no snoop, and all kinds of errors */
479 + reg |= PCIE_DCTLSTS_RELAXED_ORDERING_EN | PCIE_DCTLSTS_ERR_EN | PCIE_DCTLSTS_NO_SNOOP_EN;
481 + IFX_REG_W32(reg, PCIE_DCTLSTS(pcie_port));
485 +pcie_link_setup(int pcie_port)
490 + * XXX, Link capability register, bit 18 for EP CLKREQ# dynamic clock management for L1, L2/3 CPM
491 + * L0s is reported during link training via TS1 order set by N_FTS
493 + reg = IFX_REG_R32(PCIE_LCAP(pcie_port));
494 + reg &= ~PCIE_LCAP_L0S_EIXT_LATENCY;
495 + reg |= SM(3, PCIE_LCAP_L0S_EIXT_LATENCY);
496 + IFX_REG_W32(reg, PCIE_LCAP(pcie_port));
498 + /* Link control and status register */
499 + reg = IFX_REG_R32(PCIE_LCTLSTS(pcie_port));
501 + /* Link Enable, ASPM enabled */
502 + reg &= ~PCIE_LCTLSTS_LINK_DISABLE;
504 +#ifdef CONFIG_PCIEASPM
506 + * We use the same physical reference clock that the platform provides on the connector
507 + * It paved the way for ASPM to calculate the new exit Latency
509 + reg |= PCIE_LCTLSTS_SLOT_CLK_CFG;
510 + reg |= PCIE_LCTLSTS_COM_CLK_CFG;
512 + * We should disable ASPM by default except that we have dedicated power management support
513 + * Enable ASPM will cause the system hangup/instability, performance degration
515 + reg |= PCIE_LCTLSTS_ASPM_ENABLE;
517 + reg &= ~PCIE_LCTLSTS_ASPM_ENABLE;
518 +#endif /* CONFIG_PCIEASPM */
521 + * The maximum size of any completion with data packet is bounded by the MPS setting
522 + * in device control register
525 + /* RCB may cause multiple split transactions, two options available, we use 64 byte RCB */
526 + reg &= ~ PCIE_LCTLSTS_RCB128;
528 + IFX_REG_W32(reg, PCIE_LCTLSTS(pcie_port));
531 +static inline void pcie_error_setup(int pcie_port)
536 + * Forward ERR_COR, ERR_NONFATAL, ERR_FATAL to the backbone
537 + * Poisoned write TLPs and completions indicating poisoned TLPs will set the PCIe_PCICMDSTS.MDPE
539 + reg = IFX_REG_R32(PCIE_INTRBCTRL(pcie_port));
540 + reg |= PCIE_INTRBCTRL_SERR_ENABLE | PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE;
542 + IFX_REG_W32(reg, PCIE_INTRBCTRL(pcie_port));
544 + /* Uncorrectable Error Mask Register, Unmask <enable> all bits in PCIE_UESR */
545 + reg = IFX_REG_R32(PCIE_UEMR(pcie_port));
546 + reg &= ~PCIE_ALL_UNCORRECTABLE_ERR;
547 + IFX_REG_W32(reg, PCIE_UEMR(pcie_port));
549 + /* Uncorrectable Error Severity Register, ALL errors are FATAL */
550 + IFX_REG_W32(PCIE_ALL_UNCORRECTABLE_ERR, PCIE_UESR(pcie_port));
552 + /* Correctable Error Mask Register, unmask <enable> all bits */
553 + reg = IFX_REG_R32(PCIE_CEMR(pcie_port));
554 + reg &= ~PCIE_CORRECTABLE_ERR;
555 + IFX_REG_W32(reg, PCIE_CEMR(pcie_port));
557 + /* Advanced Error Capabilities and Control Registr */
558 + reg = IFX_REG_R32(PCIE_AECCR(pcie_port));
559 + reg |= PCIE_AECCR_ECRC_CHECK_EN | PCIE_AECCR_ECRC_GEN_EN;
560 + IFX_REG_W32(reg, PCIE_AECCR(pcie_port));
562 + /* Root Error Command Register, Report all types of errors */
563 + reg = IFX_REG_R32(PCIE_RECR(pcie_port));
564 + reg |= PCIE_RECR_ERR_REPORT_EN;
565 + IFX_REG_W32(reg, PCIE_RECR(pcie_port));
567 + /* Clear the Root status register */
568 + reg = IFX_REG_R32(PCIE_RESR(pcie_port));
569 + IFX_REG_W32(reg, PCIE_RESR(pcie_port));
572 +static inline void pcie_port_logic_setup(int pcie_port)
576 + /* FTS number, default 12, increase to 63, may increase time from/to L0s to L0 */
577 + reg = IFX_REG_R32(PCIE_AFR(pcie_port));
578 + reg &= ~(PCIE_AFR_FTS_NUM | PCIE_AFR_COM_FTS_NUM);
579 + reg |= SM(PCIE_AFR_FTS_NUM_DEFAULT, PCIE_AFR_FTS_NUM)
580 + | SM(PCIE_AFR_FTS_NUM_DEFAULT, PCIE_AFR_COM_FTS_NUM);
581 + /* L0s and L1 entry latency */
582 + reg &= ~(PCIE_AFR_L0S_ENTRY_LATENCY | PCIE_AFR_L1_ENTRY_LATENCY);
583 + reg |= SM(PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT, PCIE_AFR_L0S_ENTRY_LATENCY)
584 + | SM(PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT, PCIE_AFR_L1_ENTRY_LATENCY);
585 + IFX_REG_W32(reg, PCIE_AFR(pcie_port));
588 + /* Port Link Control Register */
589 + reg = IFX_REG_R32(PCIE_PLCR(pcie_port));
590 + reg |= PCIE_PLCR_DLL_LINK_EN; /* Enable the DLL link */
591 + IFX_REG_W32(reg, PCIE_PLCR(pcie_port));
593 + /* Lane Skew Register */
594 + reg = IFX_REG_R32(PCIE_LSR(pcie_port));
595 + /* Enable ACK/NACK and FC */
596 + reg &= ~(PCIE_LSR_ACKNAK_DISABLE | PCIE_LSR_FC_DISABLE);
597 + IFX_REG_W32(reg, PCIE_LSR(pcie_port));
599 + /* Symbol Timer Register and Filter Mask Register 1 */
600 + reg = IFX_REG_R32(PCIE_STRFMR(pcie_port));
602 + /* Default SKP interval is very accurate already, 5us */
603 + /* Enable IO/CFG transaction */
604 + reg |= PCIE_STRFMR_RX_CFG_TRANS_ENABLE | PCIE_STRFMR_RX_IO_TRANS_ENABLE;
605 + /* Disable FC WDT */
606 + reg &= ~PCIE_STRFMR_FC_WDT_DISABLE;
607 + IFX_REG_W32(reg, PCIE_STRFMR(pcie_port));
609 + /* Filter Masker Register 2 */
610 + reg = IFX_REG_R32(PCIE_FMR2(pcie_port));
611 + reg |= PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 | PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1;
612 + IFX_REG_W32(reg, PCIE_FMR2(pcie_port));
614 + /* VC0 Completion Receive Queue Control Register */
615 + reg = IFX_REG_R32(PCIE_VC0_CRQCR(pcie_port));
616 + reg &= ~PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE;
617 + reg |= SM(PCIE_VC0_TLP_QUEUE_MODE_BYPASS, PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE);
618 + IFX_REG_W32(reg, PCIE_VC0_CRQCR(pcie_port));
621 +static inline void pcie_rc_cfg_reg_setup(int pcie_port)
625 + /* Disable LTSSM */
626 + IFX_REG_W32(0, PCIE_RC_CCR(pcie_port)); /* Disable LTSSM */
628 + pcie_mem_io_setup(pcie_port);
630 + /* XXX, MSI stuff should only apply to EP */
631 + /* MSI Capability: Only enable 32-bit addresses */
632 + reg = IFX_REG_R32(PCIE_MCAPR(pcie_port));
633 + reg &= ~PCIE_MCAPR_ADDR64_CAP;
635 + reg |= PCIE_MCAPR_MSI_ENABLE;
637 + /* Disable multiple message */
638 + reg &= ~(PCIE_MCAPR_MULTI_MSG_CAP | PCIE_MCAPR_MULTI_MSG_ENABLE);
639 + IFX_REG_W32(reg, PCIE_MCAPR(pcie_port));
642 + /* Enable PME, Soft reset enabled */
643 + reg = IFX_REG_R32(PCIE_PM_CSR(pcie_port));
644 + reg |= PCIE_PM_CSR_PME_ENABLE | PCIE_PM_CSR_SW_RST;
645 + IFX_REG_W32(reg, PCIE_PM_CSR(pcie_port));
647 + /* setup the bus */
648 + reg = SM(0, PCIE_BNR_PRIMARY_BUS_NUM) | SM(1, PCIE_PNR_SECONDARY_BUS_NUM) | SM(0xFF, PCIE_PNR_SUB_BUS_NUM);
649 + IFX_REG_W32(reg, PCIE_BNR(pcie_port));
652 + pcie_device_setup(pcie_port);
653 + pcie_link_setup(pcie_port);
654 + pcie_error_setup(pcie_port);
656 + /* Root control and capabilities register */
657 + reg = IFX_REG_R32(PCIE_RCTLCAP(pcie_port));
658 + reg |= PCIE_RCTLCAP_SERR_ENABLE | PCIE_RCTLCAP_PME_INT_EN;
659 + IFX_REG_W32(reg, PCIE_RCTLCAP(pcie_port));
661 + /* Port VC Capability Register 2 */
662 + reg = IFX_REG_R32(PCIE_PVC2(pcie_port));
663 + reg &= ~PCIE_PVC2_VC_ARB_WRR;
664 + reg |= PCIE_PVC2_VC_ARB_16P_FIXED_WRR;
665 + IFX_REG_W32(reg, PCIE_PVC2(pcie_port));
667 + /* VC0 Resource Capability Register */
668 + reg = IFX_REG_R32(PCIE_VC0_RC(pcie_port));
669 + reg &= ~PCIE_VC0_RC_REJECT_SNOOP;
670 + IFX_REG_W32(reg, PCIE_VC0_RC(pcie_port));
672 + pcie_port_logic_setup(pcie_port);
675 +static int ifx_pcie_wait_phy_link_up(int pcie_port)
677 +#define IFX_PCIE_PHY_LINK_UP_TIMEOUT 1000 /* XXX, tunable */
680 + /* Wait for PHY link is up */
681 + for (i = 0; i < IFX_PCIE_PHY_LINK_UP_TIMEOUT; i++) {
682 + if (ifx_pcie_link_up(pcie_port)) {
687 + if (i >= IFX_PCIE_PHY_LINK_UP_TIMEOUT) {
688 + printk(KERN_ERR "%s timeout\n", __func__);
692 + /* Check data link up or not */
693 + if (!(IFX_REG_R32(PCIE_RC_DR(pcie_port)) & PCIE_RC_DR_DLL_UP)) {
694 + printk(KERN_ERR "%s DLL link is still down\n", __func__);
698 + /* Check Data link active or not */
699 + if (!(IFX_REG_R32(PCIE_LCTLSTS(pcie_port)) & PCIE_LCTLSTS_DLL_ACTIVE)) {
700 + printk(KERN_ERR "%s DLL is not active\n", __func__);
706 +static inline int pcie_app_loigc_setup(int pcie_port)
708 + /* supress ahb bus errrors */
709 + IFX_REG_W32(PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS, PCIE_AHB_CTRL(pcie_port));
711 + /* Pull PCIe EP out of reset */
712 + pcie_device_rst_deassert(pcie_port);
714 + /* Start LTSSM training between RC and EP */
715 + pcie_ltssm_enable(pcie_port);
717 + /* Check PHY status after enabling LTSSM */
718 + if (ifx_pcie_wait_phy_link_up(pcie_port) != 0)
725 + * The numbers below are directly from the PCIe spec table 3-4/5.
727 +static inline void pcie_replay_time_update(int pcie_port)
733 + reg = IFX_REG_R32(PCIE_LCTLSTS(pcie_port));
735 + nlw = MS(reg, PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH);
737 + case PCIE_MAX_LENGTH_WIDTH_X1:
740 + case PCIE_MAX_LENGTH_WIDTH_X2:
743 + case PCIE_MAX_LENGTH_WIDTH_X4:
746 + case PCIE_MAX_LENGTH_WIDTH_X8:
753 + reg = IFX_REG_R32(PCIE_ALTRT(pcie_port));
754 + reg &= ~PCIE_ALTRT_REPLAY_TIME_LIMIT;
755 + reg |= SM(rtl, PCIE_ALTRT_REPLAY_TIME_LIMIT);
756 + IFX_REG_W32(reg, PCIE_ALTRT(pcie_port));
760 + * Table 359 Enhanced Configuration Address Mapping1)
761 + * 1) This table is defined in Table 7-1, page 341, PCI Express Base Specification v1.1
762 + * Memory Address PCI Express Configuration Space
763 + * A[(20+n-1):20] Bus Number 1 < n < 8
764 + * A[19:15] Device Number
765 + * A[14:12] Function Number
766 + * A[11:8] Extended Register Number
767 + * A[7:2] Register Number
768 + * A[1:0] Along with size of the access, used to generate Byte Enables
769 + * For VR9, only the address bits [22:0] are mapped to the configuration space:
770 + * . Address bits [22:20] select the target bus (1-of-8)1)
771 + * . Address bits [19:15] select the target device (1-of-32) on the bus
772 + * . Address bits [14:12] select the target function (1-of-8) within the device.
773 + * . Address bits [11:2] selects the target dword (1-of-1024) within the selected function.s configuration space
774 + * . Address bits [1:0] define the start byte location within the selected dword.
776 +static inline u32 pcie_bus_addr(u8 bus_num, u16 devfn, int where)
783 + addr = ((PCI_SLOT(devfn) & 0x1F) << 15) | ((PCI_FUNC(devfn) & 0x7) << 12) | ((where & 0xFFF)& ~3);
786 + /* type 1, only support 8 buses */
787 + addr = ((bus & 0x7) << 20) | ((PCI_SLOT(devfn) & 0x1F) << 15) |
788 + ((PCI_FUNC(devfn) & 0x7) << 12) | ((where & 0xFFF) & ~3);
793 +static int pcie_valid_config(int pcie_port, int bus, int dev)
796 + if ((bus == 0) && (dev == 0)) {
800 + /* No physical link */
801 + if (!ifx_pcie_link_up(pcie_port)) {
805 + /* Bus zero only has RC itself
806 + * XXX, check if EP will be integrated
808 + if ((bus == 0) && (dev != 0)) {
812 + /* Maximum 8 buses supported for VRX */
818 + * PCIe is PtP link, one bus only supports only one device
819 + * except bus zero and PCIe switch which is virtual bus device
820 + * The following two conditions really depends on the system design
821 + * and attached the device.
822 + * XXX, how about more new switch
824 + if ((bus == 1) && (dev != 0)) {
828 + if ((bus >= 3) && (dev != 0)) {
834 +static inline u32 ifx_pcie_cfg_rd(int pcie_port, u32 reg)
836 + return IFX_REG_R32((volatile u32 *)(PCIE_CFG_PORT_TO_BASE(pcie_port) + reg));
839 +static inline void ifx_pcie_cfg_wr(int pcie_port, unsigned int reg, u32 val)
841 + IFX_REG_W32( val, (volatile u32 *)(PCIE_CFG_PORT_TO_BASE(pcie_port) + reg));
844 +static inline u32 ifx_pcie_rc_cfg_rd(int pcie_port, u32 reg)
846 + return IFX_REG_R32((volatile u32 *)(PCIE_RC_PORT_TO_BASE(pcie_port) + reg));
849 +static inline void ifx_pcie_rc_cfg_wr(int pcie_port, unsigned int reg, u32 val)
851 + IFX_REG_W32(val, (volatile u32 *)(PCIE_RC_PORT_TO_BASE(pcie_port) + reg));
854 +u32 ifx_pcie_bus_enum_read_hack(int where, u32 value)
856 + u32 tvalue = value;
858 + if (where == PCI_PRIMARY_BUS) {
859 + u8 primary, secondary, subordinate;
861 + primary = tvalue & 0xFF;
862 + secondary = (tvalue >> 8) & 0xFF;
863 + subordinate = (tvalue >> 16) & 0xFF;
864 + primary += pcibios_1st_host_bus_nr();
865 + secondary += pcibios_1st_host_bus_nr();
866 + subordinate += pcibios_1st_host_bus_nr();
867 + tvalue = (tvalue & 0xFF000000) | (u32)primary | (u32)(secondary << 8) | (u32)(subordinate << 16);
872 +u32 ifx_pcie_bus_enum_write_hack(int where, u32 value)
874 + u32 tvalue = value;
876 + if (where == PCI_PRIMARY_BUS) {
877 + u8 primary, secondary, subordinate;
879 + primary = tvalue & 0xFF;
880 + secondary = (tvalue >> 8) & 0xFF;
881 + subordinate = (tvalue >> 16) & 0xFF;
882 + if (primary > 0 && primary != 0xFF) {
883 + primary -= pcibios_1st_host_bus_nr();
886 + if (secondary > 0 && secondary != 0xFF) {
887 + secondary -= pcibios_1st_host_bus_nr();
889 + if (subordinate > 0 && subordinate != 0xFF) {
890 + subordinate -= pcibios_1st_host_bus_nr();
892 + tvalue = (tvalue & 0xFF000000) | (u32)primary | (u32)(secondary << 8) | (u32)(subordinate << 16);
894 + else if (where == PCI_SUBORDINATE_BUS) {
895 + u8 subordinate = tvalue & 0xFF;
897 + subordinate = subordinate > 0 ? subordinate - pcibios_1st_host_bus_nr() : 0;
898 + tvalue = subordinate;
903 +static int ifx_pcie_read_config(struct pci_bus *bus, u32 devfn,
904 + int where, int size, u32 *value)
907 + int bus_number = bus->number;
908 + static const u32 mask[8] = {0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0};
909 + int ret = PCIBIOS_SUCCESSFUL;
910 + struct ifx_pci_controller *ctrl = bus->sysdata;
911 + int pcie_port = ctrl->port;
913 + if (unlikely(size != 1 && size != 2 && size != 4)){
914 + ret = PCIBIOS_BAD_REGISTER_NUMBER;
918 + /* Make sure the address is aligned to natural boundary */
919 + if (unlikely(((size - 1) & where))) {
920 + ret = PCIBIOS_BAD_REGISTER_NUMBER;
925 + * If we are second controller, we have to cheat OS so that it assume
926 + * its bus number starts from 0 in host controller
928 + bus_number = ifx_pcie_bus_nr_deduct(bus_number, pcie_port);
931 + * We need to force the bus number to be zero on the root
932 + * bus. Linux numbers the 2nd root bus to start after all
933 + * busses on root 0.
935 + if (bus->parent == NULL) {
940 + * PCIe only has a single device connected to it. It is
941 + * always device ID 0. Don't bother doing reads for other
942 + * device IDs on the first segment.
944 + if ((bus_number == 0) && (PCI_SLOT(devfn) != 0)) {
945 + ret = PCIBIOS_FUNC_NOT_SUPPORTED;
949 + if (pcie_valid_config(pcie_port, bus_number, PCI_SLOT(devfn)) == 0) {
950 + *value = 0xffffffff;
951 + ret = PCIBIOS_DEVICE_NOT_FOUND;
955 + PCIE_IRQ_LOCK(ifx_pcie_lock);
956 + if (bus_number == 0) { /* RC itself */
960 + data = ifx_pcie_rc_cfg_rd(pcie_port, t);
962 + u32 addr = pcie_bus_addr(bus_number, devfn, where);
964 + data = ifx_pcie_cfg_rd(pcie_port, addr);
965 + #ifdef CONFIG_IFX_PCIE_HW_SWAP
966 + data = le32_to_cpu(data);
967 + #endif /* CONFIG_IFX_PCIE_HW_SWAP */
969 + /* To get a correct PCI topology, we have to restore the bus number to OS */
970 + data = ifx_pcie_bus_enum_hack(bus, devfn, where, data, pcie_port, 1);
972 + PCIE_IRQ_UNLOCK(ifx_pcie_lock);
974 + *value = (data >> (8 * (where & 3))) & mask[size & 7];
979 +static u32 ifx_pcie_size_to_value(int where, int size, u32 data, u32 value)
986 + shift = (where & 0x3) << 3;
987 + tdata &= ~(0xffU << shift);
988 + tdata |= ((value & 0xffU) << shift);
991 + shift = (where & 3) << 3;
992 + tdata &= ~(0xffffU << shift);
993 + tdata |= ((value & 0xffffU) << shift);
1002 +static int ifx_pcie_write_config(struct pci_bus *bus, u32 devfn,
1003 + int where, int size, u32 value)
1005 + int bus_number = bus->number;
1006 + int ret = PCIBIOS_SUCCESSFUL;
1007 + struct ifx_pci_controller *ctrl = bus->sysdata;
1008 + int pcie_port = ctrl->port;
1009 + u32 tvalue = value;
1012 + /* Make sure the address is aligned to natural boundary */
1013 + if (unlikely(((size - 1) & where))) {
1014 + ret = PCIBIOS_BAD_REGISTER_NUMBER;
1018 + * If we are second controller, we have to cheat OS so that it assume
1019 + * its bus number starts from 0 in host controller
1021 + bus_number = ifx_pcie_bus_nr_deduct(bus_number, pcie_port);
1024 + * We need to force the bus number to be zero on the root
1025 + * bus. Linux numbers the 2nd root bus to start after all
1026 + * busses on root 0.
1028 + if (bus->parent == NULL) {
1032 + if (pcie_valid_config(pcie_port, bus_number, PCI_SLOT(devfn)) == 0) {
1033 + ret = PCIBIOS_DEVICE_NOT_FOUND;
1037 + /* XXX, some PCIe device may need some delay */
1038 + PCIE_IRQ_LOCK(ifx_pcie_lock);
1041 + * To configure the correct bus topology using native way, we have to cheat Os so that
1042 + * it can configure the PCIe hardware correctly.
1044 + tvalue = ifx_pcie_bus_enum_hack(bus, devfn, where, value, pcie_port, 0);
1046 + if (bus_number == 0) { /* RC itself */
1050 + data = ifx_pcie_rc_cfg_rd(pcie_port, t);
1052 + data = ifx_pcie_size_to_value(where, size, data, tvalue);
1054 + ifx_pcie_rc_cfg_wr(pcie_port, t, data);
1056 + u32 addr = pcie_bus_addr(bus_number, devfn, where);
1058 + data = ifx_pcie_cfg_rd(pcie_port, addr);
1059 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
1060 + data = le32_to_cpu(data);
1063 + data = ifx_pcie_size_to_value(where, size, data, tvalue);
1064 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
1065 + data = cpu_to_le32(data);
1067 + ifx_pcie_cfg_wr(pcie_port, addr, data);
1069 + PCIE_IRQ_UNLOCK(ifx_pcie_lock);
1074 +static struct resource ifx_pcie_io_resource = {
1075 + .name = "PCIe0 I/O space",
1076 + .start = PCIE_IO_PHY_BASE,
1077 + .end = PCIE_IO_PHY_END,
1078 + .flags = IORESOURCE_IO,
1081 +static struct resource ifx_pcie_mem_resource = {
1082 + .name = "PCIe0 Memory space",
1083 + .start = PCIE_MEM_PHY_BASE,
1084 + .end = PCIE_MEM_PHY_END,
1085 + .flags = IORESOURCE_MEM,
1088 +static struct pci_ops ifx_pcie_ops = {
1089 + .read = ifx_pcie_read_config,
1090 + .write = ifx_pcie_write_config,
1093 +static struct ifx_pci_controller ifx_pcie_controller[IFX_PCIE_CORE_NR] = {
1096 + .pci_ops = &ifx_pcie_ops,
1097 + .mem_resource = &ifx_pcie_mem_resource,
1098 + .io_resource = &ifx_pcie_io_resource,
1100 + .port = IFX_PCIE_PORT0,
1104 +#ifdef IFX_PCIE_ERROR_INT
1106 +static irqreturn_t pcie_rc_core_isr(int irq, void *dev_id)
1108 + struct ifx_pci_controller *ctrl = (struct ifx_pci_controller *)dev_id;
1109 + int pcie_port = ctrl->port;
1112 + printk("PCIe RC error intr %d\n", irq);
1113 + reg = IFX_REG_R32(PCIE_IRNCR(pcie_port));
1114 + reg &= PCIE_RC_CORE_COMBINED_INT;
1115 + IFX_REG_W32(reg, PCIE_IRNCR(pcie_port));
1117 + return IRQ_HANDLED;
1121 +pcie_rc_core_int_init(int pcie_port)
1125 + /* Enable core interrupt */
1126 + IFX_REG_SET_BIT(PCIE_RC_CORE_COMBINED_INT, PCIE_IRNEN(pcie_port));
1128 + /* Clear it first */
1129 + IFX_REG_SET_BIT(PCIE_RC_CORE_COMBINED_INT, PCIE_IRNCR(pcie_port));
1130 + ret = request_irq(pcie_irqs[pcie_port].ir_irq.irq, pcie_rc_core_isr, 0,
1131 + pcie_irqs[pcie_port].ir_irq.name, &ifx_pcie_controller[pcie_port]);
1133 + printk(KERN_ERR "%s request irq %d failed\n", __func__, IFX_PCIE_IR);
1139 +int ifx_pcie_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin)
1143 + struct ifx_pci_controller *ctrl = dev->bus->sysdata;
1144 + int pcie_port = ctrl->port;
1146 + printk("%s port %d dev %s slot %d pin %d \n", __func__, pcie_port, pci_name(dev), slot, pin);
1148 + if ((pin == PCIE_LEGACY_DISABLE) || (pin > PCIE_LEGACY_INT_MAX)) {
1149 + printk(KERN_WARNING "WARNING: dev %s: invalid interrupt pin %d\n", pci_name(dev), pin);
1153 + /* Pin index so minus one */
1154 + irq_bit = pcie_irqs[pcie_port].legacy_irq[pin - 1].irq_bit;
1155 + irq = pcie_irqs[pcie_port].legacy_irq[pin - 1].irq;
1156 + IFX_REG_SET_BIT(irq_bit, PCIE_IRNEN(pcie_port));
1157 + IFX_REG_SET_BIT(irq_bit, PCIE_IRNCR(pcie_port));
1158 + printk("%s dev %s irq %d assigned\n", __func__, pci_name(dev), irq);
1162 +int ifx_pcie_bios_plat_dev_init(struct pci_dev *dev)
1165 +#ifdef IFX_PCIE_ERROR_INT
1170 + /* Enable reporting System errors and parity errors on all devices */
1171 + /* Enable parity checking and error reporting */
1172 + pci_read_config_word(dev, PCI_COMMAND, &config);
1173 + config |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR /*| PCI_COMMAND_INVALIDATE |
1174 + PCI_COMMAND_FAST_BACK*/;
1175 + pci_write_config_word(dev, PCI_COMMAND, config);
1177 + if (dev->subordinate) {
1178 + /* Set latency timers on sub bridges */
1179 + pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 0x40); /* XXX, */
1180 + /* More bridge error detection */
1181 + pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &config);
1182 + config |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR;
1183 + pci_write_config_word(dev, PCI_BRIDGE_CONTROL, config);
1185 +#ifdef IFX_PCIE_ERROR_INT
1186 + /* Enable the PCIe normal error reporting */
1187 + pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
1190 + /* Disable system error generation in response to error messages */
1191 + pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &config);
1192 + config &= ~(PCI_EXP_RTCTL_SECEE | PCI_EXP_RTCTL_SENFEE | PCI_EXP_RTCTL_SEFEE);
1193 + pci_write_config_word(dev, pos + PCI_EXP_RTCTL, config);
1195 + /* Clear PCIE Capability's Device Status */
1196 + pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &config);
1197 + pci_write_config_word(dev, pos + PCI_EXP_DEVSTA, config);
1199 + /* Update Device Control */
1200 + pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &config);
1201 + /* Correctable Error Reporting */
1202 + config |= PCI_EXP_DEVCTL_CERE;
1203 + /* Non-Fatal Error Reporting */
1204 + config |= PCI_EXP_DEVCTL_NFERE;
1205 + /* Fatal Error Reporting */
1206 + config |= PCI_EXP_DEVCTL_FERE;
1207 + /* Unsupported Request */
1208 + config |= PCI_EXP_DEVCTL_URRE;
1209 + pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, config);
1212 + /* Find the Advanced Error Reporting capability */
1213 + pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
1215 + /* Clear Uncorrectable Error Status */
1216 + pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &dconfig);
1217 + pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, dconfig);
1218 + /* Enable reporting of all uncorrectable errors */
1219 + /* Uncorrectable Error Mask - turned on bits disable errors */
1220 + pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 0);
1222 + * Leave severity at HW default. This only controls if
1223 + * errors are reported as uncorrectable or
1224 + * correctable, not if the error is reported.
1226 + /* PCI_ERR_UNCOR_SEVER - Uncorrectable Error Severity */
1227 + /* Clear Correctable Error Status */
1228 + pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &dconfig);
1229 + pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, dconfig);
1230 + /* Enable reporting of all correctable errors */
1231 + /* Correctable Error Mask - turned on bits disable errors */
1232 + pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, 0);
1233 + /* Advanced Error Capabilities */
1234 + pci_read_config_dword(dev, pos + PCI_ERR_CAP, &dconfig);
1235 + /* ECRC Generation Enable */
1236 + if (dconfig & PCI_ERR_CAP_ECRC_GENC) {
1237 + dconfig |= PCI_ERR_CAP_ECRC_GENE;
1239 + /* ECRC Check Enable */
1240 + if (dconfig & PCI_ERR_CAP_ECRC_CHKC) {
1241 + dconfig |= PCI_ERR_CAP_ECRC_CHKE;
1243 + pci_write_config_dword(dev, pos + PCI_ERR_CAP, dconfig);
1245 + /* PCI_ERR_HEADER_LOG - Header Log Register (16 bytes) */
1246 + /* Enable Root Port's interrupt in response to error messages */
1247 + pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND,
1248 + PCI_ERR_ROOT_CMD_COR_EN |
1249 + PCI_ERR_ROOT_CMD_NONFATAL_EN |
1250 + PCI_ERR_ROOT_CMD_FATAL_EN);
1251 + /* Clear the Root status register */
1252 + pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &dconfig);
1253 + pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, dconfig);
1255 +#endif /* IFX_PCIE_ERROR_INT */
1256 + /* WAR, only 128 MRRS is supported, force all EPs to support this value */
1257 + pcie_set_readrq(dev, 128);
1262 +pcie_rc_initialize(int pcie_port)
1265 +#define IFX_PCIE_PHY_LOOP_CNT 5
1267 + pcie_rcu_endian_setup(pcie_port);
1269 + pcie_ep_gpio_rst_init(pcie_port);
1272 + * XXX, PCIe elastic buffer bug will cause not to be detected. One more
1273 + * reset PCIe PHY will solve this issue
1275 + for (i = 0; i < IFX_PCIE_PHY_LOOP_CNT; i++) {
1276 + /* Disable PCIe PHY Analog part for sanity check */
1277 + pcie_phy_pmu_disable(pcie_port);
1279 + pcie_phy_rst_assert(pcie_port);
1280 + pcie_phy_rst_deassert(pcie_port);
1282 + /* Make sure PHY PLL is stable */
1285 + /* PCIe Core reset enabled, low active, sw programmed */
1286 + pcie_core_rst_assert(pcie_port);
1288 + /* Put PCIe EP in reset status */
1289 + pcie_device_rst_assert(pcie_port);
1291 + /* PCI PHY & Core reset disabled, high active, sw programmed */
1292 + pcie_core_rst_deassert(pcie_port);
1294 + /* Already in a quiet state, program PLL, enable PHY, check ready bit */
1295 + pcie_phy_clock_mode_setup(pcie_port);
1297 + /* Enable PCIe PHY and Clock */
1298 + pcie_core_pmu_setup(pcie_port);
1300 + /* Clear status registers */
1301 + pcie_status_register_clear(pcie_port);
1303 +#ifdef CONFIG_PCI_MSI
1304 + pcie_msi_init(pcie_port);
1305 +#endif /* CONFIG_PCI_MSI */
1306 + pcie_rc_cfg_reg_setup(pcie_port);
1308 + /* Once link is up, break out */
1309 + if (pcie_app_loigc_setup(pcie_port) == 0)
1312 + if (i >= IFX_PCIE_PHY_LOOP_CNT) {
1313 + printk(KERN_ERR "%s link up failed!!!!!\n", __func__);
1316 + /* NB, don't increase ACK/NACK timer timeout value, which will cause a lot of COR errors */
1317 + pcie_replay_time_update(pcie_port);
1321 +extern int (*ltq_pci_plat_arch_init)(struct pci_dev *dev);
1322 +extern int (*ltq_pci_map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
1324 +static int __init ifx_pcie_bios_init(void)
1326 + void __iomem *io_map_base;
1331 + ltq_pci_map_irq = ifx_pcie_bios_map_irq;
1332 + ltq_pci_plat_arch_init = ifx_pcie_bios_plat_dev_init;
1334 + /* Enable AHB Master/ Slave */
1335 + pcie_ahb_pmu_setup();
1337 + startup_port = IFX_PCIE_PORT0;
1339 + for (pcie_port = startup_port; pcie_port < IFX_PCIE_CORE_NR; pcie_port++){
1340 + if (pcie_rc_initialize(pcie_port) == 0) {
1341 + IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: ifx_pcie_cfg_base 0x%p\n",
1342 + __func__, PCIE_CFG_PORT_TO_BASE(pcie_port));
1343 + /* Otherwise, warning will pop up */
1344 + io_map_base = ioremap(PCIE_IO_PHY_PORT_TO_BASE(pcie_port), PCIE_IO_SIZE);
1345 + if (io_map_base == NULL) {
1346 + IFX_PCIE_PRINT(PCIE_MSG_ERR, "%s io space ioremap failed\n", __func__);
1349 + ifx_pcie_controller[pcie_port].pcic.io_map_base = (unsigned long)io_map_base;
1351 + register_pci_controller(&ifx_pcie_controller[pcie_port].pcic);
1352 + /* XXX, clear error status */
1354 + IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: mem_resource 0x%p, io_resource 0x%p\n",
1355 + __func__, &ifx_pcie_controller[pcie_port].pcic.mem_resource,
1356 + &ifx_pcie_controller[pcie_port].pcic.io_resource);
1358 + #ifdef IFX_PCIE_ERROR_INT
1359 + pcie_rc_core_int_init(pcie_port);
1360 + #endif /* IFX_PCIE_ERROR_INT */
1366 +arch_initcall(ifx_pcie_bios_init);
1368 +MODULE_LICENSE("GPL");
1369 +MODULE_AUTHOR("Chuanhua.Lei@infineon.com");
1370 +MODULE_SUPPORTED_DEVICE("Infineon builtin PCIe RC module");
1371 +MODULE_DESCRIPTION("Infineon builtin PCIe RC driver");
1373 Index: linux-3.8.13/arch/mips/pci/ifxmips_pcie.h
1374 ===================================================================
1375 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1376 +++ linux-3.8.13/arch/mips/pci/ifxmips_pcie.h 2013-07-25 20:01:18.403262431 +0200
1378 +/******************************************************************************
1380 +** FILE NAME : ifxmips_pcie.h
1381 +** PROJECT : IFX UEIP for VRX200
1382 +** MODULES : PCIe module
1384 +** DATE : 02 Mar 2009
1385 +** AUTHOR : Lei Chuanhua
1386 +** DESCRIPTION : PCIe Root Complex Driver
1387 +** COPYRIGHT : Copyright (c) 2009
1388 +** Infineon Technologies AG
1389 +** Am Campeon 1-12, 85579 Neubiberg, Germany
1391 +** This program is free software; you can redistribute it and/or modify
1392 +** it under the terms of the GNU General Public License as published by
1393 +** the Free Software Foundation; either version 2 of the License, or
1394 +** (at your option) any later version.
1396 +** $Version $Date $Author $Comment
1397 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
1398 +*******************************************************************************/
1399 +#ifndef IFXMIPS_PCIE_H
1400 +#define IFXMIPS_PCIE_H
1401 +#include <linux/version.h>
1402 +#include <linux/types.h>
1403 +#include <linux/pci.h>
1404 +#include <linux/interrupt.h>
1405 +#include "ifxmips_pci_common.h"
1406 +#include "ifxmips_pcie_reg.h"
1409 + \defgroup IFX_PCIE PCI Express bus driver module
1410 + \brief PCI Express IP module support VRX200
1414 + \defgroup IFX_PCIE_OS OS APIs
1416 + \brief PCIe bus driver OS interface functions
1420 + \file ifxmips_pcie.h
1422 + \brief header file for PCIe module common header file
1424 +#define PCIE_IRQ_LOCK(lock) do { \
1425 + unsigned long flags; \
1426 + spin_lock_irqsave(&(lock), flags);
1427 +#define PCIE_IRQ_UNLOCK(lock) \
1428 + spin_unlock_irqrestore(&(lock), flags); \
1431 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
1432 +#define IRQF_SHARED SA_SHIRQ
1435 +#define PCIE_MSG_MSI 0x00000001
1436 +#define PCIE_MSG_ISR 0x00000002
1437 +#define PCIE_MSG_FIXUP 0x00000004
1438 +#define PCIE_MSG_READ_CFG 0x00000008
1439 +#define PCIE_MSG_WRITE_CFG 0x00000010
1440 +#define PCIE_MSG_CFG (PCIE_MSG_READ_CFG | PCIE_MSG_WRITE_CFG)
1441 +#define PCIE_MSG_REG 0x00000020
1442 +#define PCIE_MSG_INIT 0x00000040
1443 +#define PCIE_MSG_ERR 0x00000080
1444 +#define PCIE_MSG_PHY 0x00000100
1445 +#define PCIE_MSG_ANY 0x000001ff
1447 +#define IFX_PCIE_PORT0 0
1448 +#define IFX_PCIE_PORT1 1
1450 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
1451 +#define IFX_PCIE_CORE_NR 2
1453 +#define IFX_PCIE_CORE_NR 1
1456 +#define IFX_PCIE_ERROR_INT
1458 +//#define IFX_PCIE_DBG
1460 +#if defined(IFX_PCIE_DBG)
1461 +#define IFX_PCIE_PRINT(_m, _fmt, args...) do { \
1462 + ifx_pcie_debug((_fmt), ##args); \
1467 +#define IFX_PCIE_PRINT(_m, _fmt, args...) \
1469 +#define INLINE inline
1472 +struct ifx_pci_controller {
1473 + struct pci_controller pcic;
1475 + /* RC specific, per host bus information */
1476 + u32 port; /* Port index, 0 -- 1st core, 1 -- 2nd core */
1479 +typedef struct ifx_pcie_ir_irq {
1480 + const unsigned int irq;
1481 + const char name[16];
1482 +}ifx_pcie_ir_irq_t;
1484 +typedef struct ifx_pcie_legacy_irq{
1485 + const u32 irq_bit;
1487 +}ifx_pcie_legacy_irq_t;
1489 +typedef struct ifx_pcie_irq {
1490 + ifx_pcie_ir_irq_t ir_irq;
1491 + ifx_pcie_legacy_irq_t legacy_irq[PCIE_LEGACY_INT_MAX];
1494 +extern u32 g_pcie_debug_flag;
1495 +extern void ifx_pcie_debug(const char *fmt, ...);
1496 +extern void pcie_phy_clock_mode_setup(int pcie_port);
1497 +extern void pcie_msi_pic_init(int pcie_port);
1498 +extern u32 ifx_pcie_bus_enum_read_hack(int where, u32 value);
1499 +extern u32 ifx_pcie_bus_enum_write_hack(int where, u32 value);
1504 +#include "ifxmips_pcie_vr9.h"
1505 +#elif defined (CONFIG_AR10)
1506 +#include "ifxmips_pcie_ar10.h"
1508 +#error "PCIE: platform not defined"
1509 +#endif /* CONFIG_VR9 */
1511 +#endif /* IFXMIPS_PCIE_H */
1513 Index: linux-3.8.13/arch/mips/pci/ifxmips_pcie_ar10.h
1514 ===================================================================
1515 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1516 +++ linux-3.8.13/arch/mips/pci/ifxmips_pcie_ar10.h 2013-07-25 20:01:18.407262431 +0200
1518 +/****************************************************************************
1519 + Copyright (c) 2010
1520 + Lantiq Deutschland GmbH
1521 + Am Campeon 3; 85579 Neubiberg, Germany
1523 + For licensing information, see the file 'LICENSE' in the root folder of
1524 + this software module.
1526 + *****************************************************************************/
1528 + \file ifxmips_pcie_ar10.h
1530 + \brief PCIe RC driver ar10 specific file
1533 +#ifndef IFXMIPS_PCIE_AR10_H
1534 +#define IFXMIPS_PCIE_AR10_H
1535 +#ifndef AUTOCONF_INCLUDED
1536 +#include <linux/config.h>
1537 +#endif /* AUTOCONF_INCLUDED */
1538 +#include <linux/types.h>
1539 +#include <linux/delay.h>
1541 +/* Project header file */
1542 +#include <asm/ifx/ifx_types.h>
1543 +#include <asm/ifx/ifx_pmu.h>
1544 +#include <asm/ifx/ifx_gpio.h>
1545 +#include <asm/ifx/ifx_ebu_led.h>
1547 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
1549 + ifx_ebu_led_enable();
1550 + if (pcie_port == 0) {
1551 + ifx_ebu_led_set_data(11, 1);
1554 + ifx_ebu_led_set_data(12, 1);
1558 +static inline void pcie_ahb_pmu_setup(void)
1560 + /* XXX, moved to CGU to control AHBM */
1563 +static inline void pcie_rcu_endian_setup(int pcie_port)
1567 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
1568 + /* Inbound, big endian */
1569 + reg |= IFX_RCU_BE_AHB4S;
1570 + if (pcie_port == 0) {
1571 + reg |= IFX_RCU_BE_PCIE0M;
1573 + #ifdef CONFIG_IFX_PCIE_HW_SWAP
1574 + /* Outbound, software swap needed */
1575 + reg |= IFX_RCU_BE_AHB3M;
1576 + reg &= ~IFX_RCU_BE_PCIE0S;
1578 + /* Outbound little endian */
1579 + reg &= ~IFX_RCU_BE_AHB3M;
1580 + reg &= ~IFX_RCU_BE_PCIE0S;
1584 + reg |= IFX_RCU_BE_PCIE1M;
1585 + #ifdef CONFIG_IFX_PCIE1_HW_SWAP
1586 + /* Outbound, software swap needed */
1587 + reg |= IFX_RCU_BE_AHB3M;
1588 + reg &= ~IFX_RCU_BE_PCIE1S;
1590 + /* Outbound little endian */
1591 + reg &= ~IFX_RCU_BE_AHB3M;
1592 + reg &= ~IFX_RCU_BE_PCIE1S;
1596 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
1597 + IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
1600 +static inline void pcie_phy_pmu_enable(int pcie_port)
1602 + if (pcie_port == 0) { /* XXX, should use macro*/
1603 + PCIE0_PHY_PMU_SETUP(IFX_PMU_ENABLE);
1606 + PCIE1_PHY_PMU_SETUP(IFX_PMU_ENABLE);
1610 +static inline void pcie_phy_pmu_disable(int pcie_port)
1612 + if (pcie_port == 0) { /* XXX, should use macro*/
1613 + PCIE0_PHY_PMU_SETUP(IFX_PMU_DISABLE);
1616 + PCIE1_PHY_PMU_SETUP(IFX_PMU_DISABLE);
1620 +static inline void pcie_pdi_big_endian(int pcie_port)
1624 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
1625 + if (pcie_port == 0) {
1626 + /* Config AHB->PCIe and PDI endianness */
1627 + reg |= IFX_RCU_BE_PCIE0_PDI;
1630 + /* Config AHB->PCIe and PDI endianness */
1631 + reg |= IFX_RCU_BE_PCIE1_PDI;
1633 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
1636 +static inline void pcie_pdi_pmu_enable(int pcie_port)
1638 + if (pcie_port == 0) {
1639 + /* Enable PDI to access PCIe PHY register */
1640 + PDI0_PMU_SETUP(IFX_PMU_ENABLE);
1643 + PDI1_PMU_SETUP(IFX_PMU_ENABLE);
1647 +static inline void pcie_core_rst_assert(int pcie_port)
1651 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1653 + /* Reset Core, bit 22 */
1654 + if (pcie_port == 0) {
1655 + reg |= 0x00400000;
1658 + reg |= 0x08000000; /* Bit 27 */
1660 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1663 +static inline void pcie_core_rst_deassert(int pcie_port)
1667 + /* Make sure one micro-second delay */
1670 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1671 + if (pcie_port == 0) {
1672 + reg &= ~0x00400000; /* bit 22 */
1675 + reg &= ~0x08000000; /* Bit 27 */
1677 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1680 +static inline void pcie_phy_rst_assert(int pcie_port)
1684 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1685 + if (pcie_port == 0) {
1686 + reg |= 0x00001000; /* Bit 12 */
1689 + reg |= 0x00002000; /* Bit 13 */
1691 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1694 +static inline void pcie_phy_rst_deassert(int pcie_port)
1698 + /* Make sure one micro-second delay */
1701 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
1702 + if (pcie_port == 0) {
1703 + reg &= ~0x00001000; /* Bit 12 */
1706 + reg &= ~0x00002000; /* Bit 13 */
1708 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
1711 +static inline void pcie_device_rst_assert(int pcie_port)
1713 + if (pcie_port == 0) {
1714 + ifx_ebu_led_set_data(11, 0);
1717 + ifx_ebu_led_set_data(12, 0);
1721 +static inline void pcie_device_rst_deassert(int pcie_port)
1724 + if (pcie_port == 0) {
1725 + ifx_ebu_led_set_data(11, 1);
1728 + ifx_ebu_led_set_data(12, 1);
1730 + ifx_ebu_led_disable();
1733 +static inline void pcie_core_pmu_setup(int pcie_port)
1735 + if (pcie_port == 0) {
1736 + PCIE0_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
1739 + PCIE1_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
1743 +static inline void pcie_msi_init(int pcie_port)
1745 + pcie_msi_pic_init(pcie_port);
1746 + if (pcie_port == 0) {
1747 + MSI0_PMU_SETUP(IFX_PMU_ENABLE);
1750 + MSI1_PMU_SETUP(IFX_PMU_ENABLE);
1755 +ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
1757 + u32 tbus_number = bus_number;
1759 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
1760 + if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
1761 + if (pcibios_host_nr() > 1) {
1762 + tbus_number -= pcibios_1st_host_bus_nr();
1765 +#endif /* CONFIG_IFX_PCI */
1766 + return tbus_number;
1770 +ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
1772 + struct pci_dev *pdev;
1773 + u32 tvalue = value;
1775 + /* Sanity check */
1776 + pdev = pci_get_slot(bus, devfn);
1777 + if (pdev == NULL) {
1781 + /* Only care about PCI bridge */
1782 + if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
1786 + if (read) { /* Read hack */
1787 + #ifdef CONFIG_IFX_PCIE_2ND_CORE
1788 + if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
1789 + if (pcibios_host_nr() > 1) {
1790 + tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
1793 + #endif /* CONFIG_IFX_PCIE_2ND_CORE */
1795 + else { /* Write hack */
1796 + #ifdef CONFIG_IFX_PCIE_2ND_CORE
1797 + if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
1798 + if (pcibios_host_nr() > 1) {
1799 + tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
1807 +#endif /* IFXMIPS_PCIE_AR10_H */
1808 Index: linux-3.8.13/arch/mips/pci/ifxmips_pcie_msi.c
1809 ===================================================================
1810 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1811 +++ linux-3.8.13/arch/mips/pci/ifxmips_pcie_msi.c 2013-07-25 20:01:18.407262431 +0200
1813 +/******************************************************************************
1815 +** FILE NAME : ifxmips_pcie_msi.c
1816 +** PROJECT : IFX UEIP for VRX200
1817 +** MODULES : PCI MSI sub module
1819 +** DATE : 02 Mar 2009
1820 +** AUTHOR : Lei Chuanhua
1821 +** DESCRIPTION : PCIe MSI Driver
1822 +** COPYRIGHT : Copyright (c) 2009
1823 +** Infineon Technologies AG
1824 +** Am Campeon 1-12, 85579 Neubiberg, Germany
1826 +** This program is free software; you can redistribute it and/or modify
1827 +** it under the terms of the GNU General Public License as published by
1828 +** the Free Software Foundation; either version 2 of the License, or
1829 +** (at your option) any later version.
1831 +** $Date $Author $Comment
1832 +** 02 Mar,2009 Lei Chuanhua Initial version
1833 +*******************************************************************************/
1835 + \defgroup IFX_PCIE_MSI MSI OS APIs
1837 + \brief PCIe bus driver OS interface functions
1841 + \file ifxmips_pcie_msi.c
1843 + \brief PCIe MSI OS interface file
1846 +#ifndef AUTOCONF_INCLUDED
1847 +#include <linux/config.h>
1848 +#endif /* AUTOCONF_INCLUDED */
1849 +#include <linux/init.h>
1850 +#include <linux/sched.h>
1851 +#include <linux/slab.h>
1852 +#include <linux/interrupt.h>
1853 +#include <linux/kernel_stat.h>
1854 +#include <linux/pci.h>
1855 +#include <linux/msi.h>
1856 +#include <linux/module.h>
1857 +#include <asm/bootinfo.h>
1858 +#include <asm/irq.h>
1859 +#include <asm/traps.h>
1861 +#include <asm/ifx/ifx_types.h>
1862 +#include <asm/ifx/ifx_regs.h>
1863 +#include <asm/ifx/common_routines.h>
1864 +#include <asm/ifx/irq.h>
1866 +#include "ifxmips_pcie_reg.h"
1867 +#include "ifxmips_pcie.h"
1869 +#define IFX_MSI_IRQ_NUM 16
1872 + IFX_PCIE_MSI_IDX0 = 0,
1873 + IFX_PCIE_MSI_IDX1,
1874 + IFX_PCIE_MSI_IDX2,
1875 + IFX_PCIE_MSI_IDX3,
1878 +typedef struct ifx_msi_irq_idx {
1881 +}ifx_msi_irq_idx_t;
1883 +struct ifx_msi_pic {
1884 + volatile u32 pic_table[IFX_MSI_IRQ_NUM];
1885 + volatile u32 pic_endian; /* 0x40 */
1887 +typedef struct ifx_msi_pic *ifx_msi_pic_t;
1889 +typedef struct ifx_msi_irq {
1890 + const volatile ifx_msi_pic_t msi_pic_p;
1891 + const u32 msi_phy_base;
1892 + const ifx_msi_irq_idx_t msi_irq_idx[IFX_MSI_IRQ_NUM];
1894 + * Each bit in msi_free_irq_bitmask represents a MSI interrupt that is
1897 + u16 msi_free_irq_bitmask;
1900 + * Each bit in msi_multiple_irq_bitmask tells that the device using
1901 + * this bit in msi_free_irq_bitmask is also using the next bit. This
1902 + * is used so we can disable all of the MSI interrupts when a device
1905 + u16 msi_multiple_irq_bitmask;
1908 +static ifx_msi_irq_t msi_irqs[IFX_PCIE_CORE_NR] = {
1910 + .msi_pic_p = (const volatile ifx_msi_pic_t)IFX_MSI_PIC_REG_BASE,
1911 + .msi_phy_base = PCIE_MSI_PHY_BASE,
1913 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1914 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1915 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1916 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1917 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1918 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1919 + {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
1920 + {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
1922 + .msi_free_irq_bitmask = 0,
1923 + .msi_multiple_irq_bitmask= 0,
1925 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
1927 + .msi_pic_p = (const volatile ifx_msi_pic_t)IFX_MSI1_PIC_REG_BASE,
1928 + .msi_phy_base = PCIE1_MSI_PHY_BASE,
1930 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1931 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1932 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1933 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1934 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1935 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1936 + {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
1937 + {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
1939 + .msi_free_irq_bitmask = 0,
1940 + .msi_multiple_irq_bitmask= 0,
1943 +#endif /* CONFIG_IFX_PCIE_2ND_CORE */
1947 + * This lock controls updates to msi_free_irq_bitmask,
1948 + * msi_multiple_irq_bitmask and pic register settting
1950 +static DEFINE_SPINLOCK(ifx_pcie_msi_lock);
1952 +void pcie_msi_pic_init(int pcie_port)
1954 + spin_lock(&ifx_pcie_msi_lock);
1955 + msi_irqs[pcie_port].msi_pic_p->pic_endian = IFX_MSI_PIC_BIG_ENDIAN;
1956 + spin_unlock(&ifx_pcie_msi_lock);
1960 + * \fn int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
1961 + * \brief Called when a driver request MSI interrupts instead of the
1962 + * legacy INT A-D. This routine will allocate multiple interrupts
1963 + * for MSI devices that support them. A device can override this by
1964 + * programming the MSI control bits [6:4] before calling
1965 + * pci_enable_msi().
1967 + * \param[in] pdev Device requesting MSI interrupts
1968 + * \param[in] desc MSI descriptor
1970 + * \return -EINVAL Invalid pcie root port or invalid msi bit
1972 + * \ingroup IFX_PCIE_MSI
1975 +arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
1981 + int configured_private_bits;
1982 + int request_private_bits;
1983 + struct msi_msg msg;
1985 + struct ifx_pci_controller *ctrl = pdev->bus->sysdata;
1986 + int pcie_port = ctrl->port;
1988 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s %s enter\n", __func__, pci_name(pdev));
1990 + /* XXX, skip RC MSI itself */
1991 + if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) {
1992 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s RC itself doesn't use MSI interrupt\n", __func__);
1997 + * Read the MSI config to figure out how many IRQs this device
1998 + * wants. Most devices only want 1, which will give
1999 + * configured_private_bits and request_private_bits equal 0.
2001 + pci_read_config_word(pdev, desc->msi_attrib.pos + PCI_MSI_FLAGS, &control);
2004 + * If the number of private bits has been configured then use
2005 + * that value instead of the requested number. This gives the
2006 + * driver the chance to override the number of interrupts
2007 + * before calling pci_enable_msi().
2009 + configured_private_bits = (control & PCI_MSI_FLAGS_QSIZE) >> 4;
2010 + if (configured_private_bits == 0) {
2011 + /* Nothing is configured, so use the hardware requested size */
2012 + request_private_bits = (control & PCI_MSI_FLAGS_QMASK) >> 1;
2016 + * Use the number of configured bits, assuming the
2017 + * driver wanted to override the hardware request
2020 + request_private_bits = configured_private_bits;
2024 + * The PCI 2.3 spec mandates that there are at most 32
2025 + * interrupts. If this device asks for more, only give it one.
2027 + if (request_private_bits > 5) {
2028 + request_private_bits = 0;
2032 + * The IRQs have to be aligned on a power of two based on the
2033 + * number being requested.
2035 + irq_step = (1 << request_private_bits);
2037 + /* Mask with one bit for each IRQ */
2038 + search_mask = (1 << irq_step) - 1;
2041 + * We're going to search msi_free_irq_bitmask_lock for zero
2042 + * bits. This represents an MSI interrupt number that isn't in
2045 + spin_lock(&ifx_pcie_msi_lock);
2046 + for (pos = 0; pos < IFX_MSI_IRQ_NUM; pos += irq_step) {
2047 + if ((msi_irqs[pcie_port].msi_free_irq_bitmask & (search_mask << pos)) == 0) {
2048 + msi_irqs[pcie_port].msi_free_irq_bitmask |= search_mask << pos;
2049 + msi_irqs[pcie_port].msi_multiple_irq_bitmask |= (search_mask >> 1) << pos;
2053 + spin_unlock(&ifx_pcie_msi_lock);
2055 + /* Make sure the search for available interrupts didn't fail */
2056 + if (pos >= IFX_MSI_IRQ_NUM) {
2057 + if (request_private_bits) {
2058 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s: Unable to find %d free "
2059 + "interrupts, trying just one", __func__, 1 << request_private_bits);
2060 + request_private_bits = 0;
2064 + printk(KERN_ERR "%s: Unable to find a free MSI interrupt\n", __func__);
2068 + irq = msi_irqs[pcie_port].msi_irq_idx[pos].irq;
2069 + irq_idx = msi_irqs[pcie_port].msi_irq_idx[pos].idx;
2071 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "pos %d, irq %d irq_idx %d\n", pos, irq, irq_idx);
2074 + * Initialize MSI. This has to match the memory-write endianess from the device
2075 + * Address bits [23:12]
2077 + spin_lock(&ifx_pcie_msi_lock);
2078 + msi_irqs[pcie_port].msi_pic_p->pic_table[pos] = SM(irq_idx, IFX_MSI_PIC_INT_LINE) |
2079 + SM((msi_irqs[pcie_port].msi_phy_base >> 12), IFX_MSI_PIC_MSG_ADDR) |
2080 + SM((1 << pos), IFX_MSI_PIC_MSG_DATA);
2082 + /* Enable this entry */
2083 + msi_irqs[pcie_port].msi_pic_p->pic_table[pos] &= ~IFX_MSI_PCI_INT_DISABLE;
2084 + spin_unlock(&ifx_pcie_msi_lock);
2086 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "pic_table[%d]: 0x%08x\n",
2087 + pos, msi_irqs[pcie_port].msi_pic_p->pic_table[pos]);
2089 + /* Update the number of IRQs the device has available to it */
2090 + control &= ~PCI_MSI_FLAGS_QSIZE;
2091 + control |= (request_private_bits << 4);
2092 + pci_write_config_word(pdev, desc->msi_attrib.pos + PCI_MSI_FLAGS, control);
2094 + set_irq_msi(irq, desc);
2095 + msg.address_hi = 0x0;
2096 + msg.address_lo = msi_irqs[pcie_port].msi_phy_base;
2097 + msg.data = SM((1 << pos), IFX_MSI_PIC_MSG_DATA);
2098 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "msi_data: pos %d 0x%08x\n", pos, msg.data);
2100 + write_msi_msg(irq, &msg);
2101 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s exit\n", __func__);
2106 +pcie_msi_irq_to_port(unsigned int irq, int *port)
2110 + if (irq == IFX_PCIE_MSI_IR0 || irq == IFX_PCIE_MSI_IR1 ||
2111 + irq == IFX_PCIE_MSI_IR2 || irq == IFX_PCIE_MSI_IR3) {
2112 + *port = IFX_PCIE_PORT0;
2114 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
2115 + else if (irq == IFX_PCIE1_MSI_IR0 || irq == IFX_PCIE1_MSI_IR1 ||
2116 + irq == IFX_PCIE1_MSI_IR2 || irq == IFX_PCIE1_MSI_IR3) {
2117 + *port = IFX_PCIE_PORT1;
2119 +#endif /* CONFIG_IFX_PCIE_2ND_CORE */
2121 + printk(KERN_ERR "%s: Attempted to teardown illegal "
2122 + "MSI interrupt (%d)\n", __func__, irq);
2129 + * \fn void arch_teardown_msi_irq(unsigned int irq)
2130 + * \brief Called when a device no longer needs its MSI interrupts. All
2131 + * MSI interrupts for the device are freed.
2133 + * \param irq The devices first irq number. There may be multple in sequence.
2135 + * \ingroup IFX_PCIE_MSI
2138 +arch_teardown_msi_irq(unsigned int irq)
2145 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s enter\n", __func__);
2147 + BUG_ON(irq > INT_NUM_IM4_IRL31);
2149 + if (pcie_msi_irq_to_port(irq, &pcie_port) != 0) {
2153 + /* Shift the mask to the correct bit location, not always correct
2154 + * Probally, the first match will be chosen.
2156 + for (pos = 0; pos < IFX_MSI_IRQ_NUM; pos++) {
2157 + if ((msi_irqs[pcie_port].msi_irq_idx[pos].irq == irq)
2158 + && (msi_irqs[pcie_port].msi_free_irq_bitmask & ( 1 << pos))) {
2162 + if (pos >= IFX_MSI_IRQ_NUM) {
2163 + printk(KERN_ERR "%s: Unable to find a matched MSI interrupt\n", __func__);
2166 + spin_lock(&ifx_pcie_msi_lock);
2167 + /* Disable this entry */
2168 + msi_irqs[pcie_port].msi_pic_p->pic_table[pos] |= IFX_MSI_PCI_INT_DISABLE;
2169 + 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);
2170 + spin_unlock(&ifx_pcie_msi_lock);
2172 + * Count the number of IRQs we need to free by looking at the
2173 + * msi_multiple_irq_bitmask. Each bit set means that the next
2174 + * IRQ is also owned by this device.
2177 + while (((pos + number_irqs) < IFX_MSI_IRQ_NUM) &&
2178 + (msi_irqs[pcie_port].msi_multiple_irq_bitmask & (1 << (pos + number_irqs)))) {
2183 + /* Mask with one bit for each IRQ */
2184 + bitmask = (1 << number_irqs) - 1;
2187 + if ((msi_irqs[pcie_port].msi_free_irq_bitmask & bitmask) != bitmask) {
2188 + printk(KERN_ERR "%s: Attempted to teardown MSI "
2189 + "interrupt (%d) not in use\n", __func__, irq);
2192 + /* Checks are done, update the in use bitmask */
2193 + spin_lock(&ifx_pcie_msi_lock);
2194 + msi_irqs[pcie_port].msi_free_irq_bitmask &= ~bitmask;
2195 + msi_irqs[pcie_port].msi_multiple_irq_bitmask &= ~(bitmask >> 1);
2196 + spin_unlock(&ifx_pcie_msi_lock);
2197 + IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s exit\n", __func__);
2200 +MODULE_LICENSE("GPL");
2201 +MODULE_AUTHOR("Chuanhua.Lei@infineon.com");
2202 +MODULE_SUPPORTED_DEVICE("Infineon PCIe IP builtin MSI PIC module");
2203 +MODULE_DESCRIPTION("Infineon PCIe IP builtin MSI PIC driver");
2205 Index: linux-3.8.13/arch/mips/pci/ifxmips_pcie_phy.c
2206 ===================================================================
2207 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2208 +++ linux-3.8.13/arch/mips/pci/ifxmips_pcie_phy.c 2013-07-25 20:01:18.407262431 +0200
2210 +/******************************************************************************
2212 +** FILE NAME : ifxmips_pcie_phy.c
2213 +** PROJECT : IFX UEIP for VRX200
2214 +** MODULES : PCIe PHY sub module
2216 +** DATE : 14 May 2009
2217 +** AUTHOR : Lei Chuanhua
2218 +** DESCRIPTION : PCIe Root Complex Driver
2219 +** COPYRIGHT : Copyright (c) 2009
2220 +** Infineon Technologies AG
2221 +** Am Campeon 1-12, 85579 Neubiberg, Germany
2223 +** This program is free software; you can redistribute it and/or modify
2224 +** it under the terms of the GNU General Public License as published by
2225 +** the Free Software Foundation; either version 2 of the License, or
2226 +** (at your option) any later version.
2228 +** $Version $Date $Author $Comment
2229 +** 0.0.1 14 May,2009 Lei Chuanhua Initial version
2230 +*******************************************************************************/
2232 + \file ifxmips_pcie_phy.c
2234 + \brief PCIe PHY PLL register programming source file
2236 +#include <linux/types.h>
2237 +#include <linux/kernel.h>
2238 +#include <asm/paccess.h>
2239 +#include <linux/delay.h>
2241 +#include "ifxmips_pcie_reg.h"
2242 +#include "ifxmips_pcie.h"
2244 +/* PCIe PDI only supports 16 bit operation */
2246 +#define IFX_PCIE_PHY_REG_WRITE16(__addr, __data) \
2247 + ((*(volatile u16 *) (__addr)) = (__data))
2249 +#define IFX_PCIE_PHY_REG_READ16(__addr) \
2250 + (*(volatile u16 *) (__addr))
2252 +#define IFX_PCIE_PHY_REG16(__addr) \
2253 + (*(volatile u16 *) (__addr))
2255 +#define IFX_PCIE_PHY_REG(__reg, __value, __mask) do { \
2258 + read_data = IFX_PCIE_PHY_REG_READ16((__reg)); \
2259 + write_data = (read_data & ((u16)~(__mask))) | (((u16)(__value)) & ((u16)(__mask)));\
2260 + IFX_PCIE_PHY_REG_WRITE16((__reg), write_data); \
2263 +#define IFX_PCIE_PLL_TIMEOUT 1000 /* Tunnable */
2265 +//#define IFX_PCI_PHY_REG_DUMP
2267 +#ifdef IFX_PCI_PHY_REG_DUMP
2269 +pcie_phy_reg_dump(int pcie_port)
2271 + printk("PLL REGFILE\n");
2272 + printk("PCIE_PHY_PLL_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL1(pcie_port)));
2273 + printk("PCIE_PHY_PLL_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL2(pcie_port)));
2274 + printk("PCIE_PHY_PLL_CTRL3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL3(pcie_port)));
2275 + printk("PCIE_PHY_PLL_CTRL4 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL4(pcie_port)));
2276 + printk("PCIE_PHY_PLL_CTRL5 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL5(pcie_port)));
2277 + printk("PCIE_PHY_PLL_CTRL6 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL6(pcie_port)));
2278 + printk("PCIE_PHY_PLL_CTRL7 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL7(pcie_port)));
2279 + printk("PCIE_PHY_PLL_A_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL1(pcie_port)));
2280 + printk("PCIE_PHY_PLL_A_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL2(pcie_port)));
2281 + printk("PCIE_PHY_PLL_A_CTRL3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL3(pcie_port)));
2282 + printk("PCIE_PHY_PLL_STATUS 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_STATUS(pcie_port)));
2284 + printk("TX1 REGFILE\n");
2285 + printk("PCIE_PHY_TX1_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL1(pcie_port)));
2286 + printk("PCIE_PHY_TX1_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL2(pcie_port)));
2287 + printk("PCIE_PHY_TX1_CTRL3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL3(pcie_port)));
2288 + printk("PCIE_PHY_TX1_A_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_A_CTRL1(pcie_port)));
2289 + printk("PCIE_PHY_TX1_A_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_A_CTRL2(pcie_port)));
2290 + printk("PCIE_PHY_TX1_MOD1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD1(pcie_port)));
2291 + printk("PCIE_PHY_TX1_MOD2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD2(pcie_port)));
2292 + printk("PCIE_PHY_TX1_MOD3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD3(pcie_port)));
2294 + printk("TX2 REGFILE\n");
2295 + printk("PCIE_PHY_TX2_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_CTRL1(pcie_port)));
2296 + printk("PCIE_PHY_TX2_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_CTRL2(pcie_port)));
2297 + printk("PCIE_PHY_TX2_A_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_A_CTRL1(pcie_port)));
2298 + printk("PCIE_PHY_TX2_A_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_A_CTRL2(pcie_port)));
2299 + printk("PCIE_PHY_TX2_MOD1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD1(pcie_port)));
2300 + printk("PCIE_PHY_TX2_MOD2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD2(pcie_port)));
2301 + printk("PCIE_PHY_TX2_MOD3 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD3(pcie_port)));
2303 + printk("RX1 REGFILE\n");
2304 + printk("PCIE_PHY_RX1_CTRL1 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CTRL1(pcie_port)));
2305 + printk("PCIE_PHY_RX1_CTRL2 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CTRL2(pcie_port)));
2306 + printk("PCIE_PHY_RX1_CDR 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CDR(pcie_port)));
2307 + printk("PCIE_PHY_RX1_EI 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_EI(pcie_port)));
2308 + printk("PCIE_PHY_RX1_A_CTRL 0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_A_CTRL(pcie_port)));
2310 +#endif /* IFX_PCI_PHY_REG_DUMP */
2313 +pcie_phy_comm_setup(int pcie_port)
2316 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL1(pcie_port), 0x120e, 0xFFFF);
2318 + /* increase the bias reference voltage */
2319 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x39D7, 0xFFFF);
2320 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x0900, 0xFFFF);
2323 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_EI(pcie_port), 0x0004, 0xFFFF);
2324 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_A_CTRL(pcie_port), 0x6803, 0xFFFF);
2327 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0008, 0x0008);
2329 + /* predrv_ser_en */
2330 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL2(pcie_port), 0x0706, 0xFFFF);
2333 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL3(pcie_port), 0x1FFF, 0xFFFF);
2336 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL1(pcie_port), 0x0800, 0xFF00);
2338 + /* predrv_ser_en */
2339 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4702, 0x7F00);
2342 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL2(pcie_port), 0x2e00, 0xFFFF);
2344 + /* Improved 100MHz clock output */
2345 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL2(pcie_port), 0x3096, 0xFFFF);
2346 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4707, 0xFFFF);
2348 + /* Reduced CDR BW to avoid glitches */
2349 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CDR(pcie_port), 0x0235, 0xFFFF);
2352 +#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_MODE
2354 +pcie_phy_36mhz_mode_setup(int pcie_port)
2356 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2357 +#ifdef IFX_PCI_PHY_REG_DUMP
2358 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2359 + pcie_phy_reg_dump(pcie_port);
2362 + /* en_ext_mmd_div_ratio */
2363 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
2365 + /* ext_mmd_div_ratio*/
2366 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
2369 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
2371 + /* en_const_sdm */
2372 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
2375 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
2378 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
2381 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
2384 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
2387 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
2388 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
2389 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
2390 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1b72, 0xFFFF);
2392 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2394 +#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_MODE */
2396 +#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE
2398 +pcie_phy_36mhz_ssc_mode_setup(int pcie_port)
2400 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2401 +#ifdef IFX_PCI_PHY_REG_DUMP
2402 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2403 + pcie_phy_reg_dump(pcie_port);
2407 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL1(pcie_port), 0x120e, 0xFFFF);
2409 + /* Increase the bias reference voltage */
2410 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x39D7, 0xFFFF);
2411 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x0900, 0xFFFF);
2414 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_EI(pcie_port), 0x0004, 0xFFFF);
2415 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_A_CTRL(pcie_port), 0x6803, 0xFFFF);
2418 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0008, 0x0008);
2420 + /* Predrv_ser_en */
2421 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL2(pcie_port), 0x0706, 0xFFFF);
2424 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL3(pcie_port), 0x1FFF, 0xFFFF);
2427 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL1(pcie_port), 0x0800, 0xFF00);
2429 + /* predrv_ser_en */
2430 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4702, 0x7F00);
2433 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL2(pcie_port), 0x2e00, 0xFFFF);
2435 + /* en_ext_mmd_div_ratio */
2436 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
2438 + /* ext_mmd_div_ratio*/
2439 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
2442 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0400, 0x0400);
2444 + /* en_const_sdm */
2445 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
2448 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
2451 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
2454 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
2456 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0000, 0x0100);
2458 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
2461 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
2462 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
2463 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
2464 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1c72, 0xFFFF);
2466 + /* improved 100MHz clock output */
2467 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL2(pcie_port), 0x3096, 0xFFFF);
2468 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4707, 0xFFFF);
2470 + /* reduced CDR BW to avoid glitches */
2471 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CDR(pcie_port), 0x0235, 0xFFFF);
2473 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2475 +#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE */
2477 +#ifdef CONFIG_IFX_PCIE_PHY_25MHZ_MODE
2479 +pcie_phy_25mhz_mode_setup(int pcie_port)
2481 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2482 +#ifdef IFX_PCI_PHY_REG_DUMP
2483 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2484 + pcie_phy_reg_dump(pcie_port);
2486 + /* en_const_sdm */
2487 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
2490 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0000, 0x0200);
2492 + /* en_ext_mmd_div_ratio*/
2493 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0002, 0x0002);
2495 + /* ext_mmd_div_ratio*/
2496 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0040, 0x0070);
2499 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x6000, 0xe000);
2502 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x4000, 0x4000);
2504 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2506 +#endif /* CONFIG_IFX_PCIE_PHY_25MHZ_MODE */
2508 +#ifdef CONFIG_IFX_PCIE_PHY_100MHZ_MODE
2510 +pcie_phy_100mhz_mode_setup(int pcie_port)
2512 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
2513 +#ifdef IFX_PCI_PHY_REG_DUMP
2514 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
2515 + pcie_phy_reg_dump(pcie_port);
2517 + /* en_ext_mmd_div_ratio */
2518 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
2520 + /* ext_mmd_div_ratio*/
2521 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
2524 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
2526 + /* en_const_sdm */
2527 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
2530 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
2533 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
2536 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
2539 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
2542 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
2543 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
2544 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
2545 + IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1b72, 0xFFFF);
2547 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
2549 +#endif /* CONFIG_IFX_PCIE_PHY_100MHZ_MODE */
2552 +pcie_phy_wait_startup_ready(int pcie_port)
2556 + for (i = 0; i < IFX_PCIE_PLL_TIMEOUT; i++) {
2557 + if ((IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_STATUS(pcie_port)) & 0x0040) != 0) {
2562 + if (i >= IFX_PCIE_PLL_TIMEOUT) {
2563 + printk(KERN_ERR "%s PLL Link timeout\n", __func__);
2570 +pcie_phy_load_enable(int pcie_port, int slice)
2572 + /* Set the load_en of tx/rx slice to '1' */
2575 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0010, 0x0010);
2578 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL1(pcie_port), 0x0010, 0x0010);
2581 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CTRL1(pcie_port), 0x0002, 0x0002);
2587 +pcie_phy_load_disable(int pcie_port, int slice)
2589 + /* set the load_en of tx/rx slice to '0' */
2592 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0000, 0x0010);
2595 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL1(pcie_port), 0x0000, 0x0010);
2598 + IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CTRL1(pcie_port), 0x0000, 0x0002);
2604 +pcie_phy_load_war(int pcie_port)
2608 + for (slice = 1; slice < 4; slice++) {
2609 + pcie_phy_load_enable(pcie_port, slice);
2611 + pcie_phy_load_disable(pcie_port, slice);
2616 +pcie_phy_tx2_modulation(int pcie_port)
2618 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD1(pcie_port), 0x1FFE, 0xFFFF);
2619 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD2(pcie_port), 0xFFFE, 0xFFFF);
2620 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD3(pcie_port), 0x0601, 0xFFFF);
2622 + IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD3(pcie_port), 0x0001, 0xFFFF);
2626 +pcie_phy_tx1_modulation(int pcie_port)
2628 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD1(pcie_port), 0x1FFE, 0xFFFF);
2629 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD2(pcie_port), 0xFFFE, 0xFFFF);
2630 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD3(pcie_port), 0x0601, 0xFFFF);
2632 + IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD3(pcie_port), 0x0001, 0xFFFF);
2636 +pcie_phy_tx_modulation_war(int pcie_port)
2640 +#define PCIE_PHY_MODULATION_NUM 5
2641 + for (i = 0; i < PCIE_PHY_MODULATION_NUM; i++) {
2642 + pcie_phy_tx2_modulation(pcie_port);
2643 + pcie_phy_tx1_modulation(pcie_port);
2645 +#undef PCIE_PHY_MODULATION_NUM
2649 +pcie_phy_clock_mode_setup(int pcie_port)
2651 + pcie_pdi_big_endian(pcie_port);
2653 + /* Enable PDI to access PCIe PHY register */
2654 + pcie_pdi_pmu_enable(pcie_port);
2656 + /* Configure PLL and PHY clock */
2657 + pcie_phy_comm_setup(pcie_port);
2659 +#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_MODE
2660 + pcie_phy_36mhz_mode_setup(pcie_port);
2661 +#elif defined(CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE)
2662 + pcie_phy_36mhz_ssc_mode_setup(pcie_port);
2663 +#elif defined(CONFIG_IFX_PCIE_PHY_25MHZ_MODE)
2664 + pcie_phy_25mhz_mode_setup(pcie_port);
2665 +#elif defined (CONFIG_IFX_PCIE_PHY_100MHZ_MODE)
2666 + pcie_phy_100mhz_mode_setup(pcie_port);
2668 + #error "PCIE PHY Clock Mode must be chosen first!!!!"
2669 +#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_MODE */
2671 + /* Enable PCIe PHY and make PLL setting take effect */
2672 + pcie_phy_pmu_enable(pcie_port);
2674 + /* Check if we are in startup_ready status */
2675 + pcie_phy_wait_startup_ready(pcie_port);
2677 + pcie_phy_load_war(pcie_port);
2679 + /* Apply TX modulation workarounds */
2680 + pcie_phy_tx_modulation_war(pcie_port);
2682 +#ifdef IFX_PCI_PHY_REG_DUMP
2683 + IFX_PCIE_PRINT(PCIE_MSG_PHY, "Modified PHY register dump\n");
2684 + pcie_phy_reg_dump(pcie_port);
2688 Index: linux-3.8.13/arch/mips/pci/ifxmips_pcie_pm.c
2689 ===================================================================
2690 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2691 +++ linux-3.8.13/arch/mips/pci/ifxmips_pcie_pm.c 2013-07-25 20:01:18.407262431 +0200
2693 +/******************************************************************************
2695 +** FILE NAME : ifxmips_pcie_pm.c
2696 +** PROJECT : IFX UEIP
2697 +** MODULES : PCIE Root Complex Driver
2699 +** DATE : 21 Dec 2009
2700 +** AUTHOR : Lei Chuanhua
2701 +** DESCRIPTION : PCIE Root Complex Driver Power Managment
2702 +** COPYRIGHT : Copyright (c) 2009
2703 +** Lantiq Deutschland GmbH
2704 +** Am Campeon 3, 85579 Neubiberg, Germany
2706 +** This program is free software; you can redistribute it and/or modify
2707 +** it under the terms of the GNU General Public License as published by
2708 +** the Free Software Foundation; either version 2 of the License, or
2709 +** (at your option) any later version.
2712 +** $Date $Author $Comment
2713 +** 21 Dec,2009 Lei Chuanhua First UEIP release
2714 +*******************************************************************************/
2716 + \defgroup IFX_PCIE_PM Power Management functions
2718 + \brief IFX PCIE Root Complex Driver power management functions
2722 + \file ifxmips_pcie_pm.c
2724 + \brief source file for PCIE Root Complex Driver Power Management
2727 +#ifndef EXPORT_SYMTAB
2728 +#define EXPORT_SYMTAB
2730 +#ifndef AUTOCONF_INCLUDED
2731 +#include <linux/config.h>
2732 +#endif /* AUTOCONF_INCLUDED */
2733 +#include <linux/version.h>
2734 +#include <linux/module.h>
2735 +#include <linux/types.h>
2736 +#include <linux/kernel.h>
2737 +#include <asm/system.h>
2739 +/* Project header */
2740 +#include <asm/ifx/ifx_types.h>
2741 +#include <asm/ifx/ifx_regs.h>
2742 +#include <asm/ifx/common_routines.h>
2743 +#include <asm/ifx/ifx_pmcu.h>
2744 +#include "ifxmips_pcie_pm.h"
2747 + * \fn static IFX_PMCU_RETURN_t ifx_pcie_pmcu_state_change(IFX_PMCU_STATE_t pmcuState)
2748 + * \brief the callback function to request pmcu state in the power management hardware-dependent module
2750 + * \param pmcuState This parameter is a PMCU state.
2752 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2753 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2754 + * \return IFX_PMCU_RETURN_DENIED Not allowed to operate power state
2755 + * \ingroup IFX_PCIE_PM
2757 +static IFX_PMCU_RETURN_t
2758 +ifx_pcie_pmcu_state_change(IFX_PMCU_STATE_t pmcuState)
2762 + case IFX_PMCU_STATE_D0:
2763 + return IFX_PMCU_RETURN_SUCCESS;
2764 + case IFX_PMCU_STATE_D1: // Not Applicable
2765 + return IFX_PMCU_RETURN_DENIED;
2766 + case IFX_PMCU_STATE_D2: // Not Applicable
2767 + return IFX_PMCU_RETURN_DENIED;
2768 + case IFX_PMCU_STATE_D3: // Module clock gating and Power gating
2769 + return IFX_PMCU_RETURN_SUCCESS;
2771 + return IFX_PMCU_RETURN_DENIED;
2776 + * \fn static IFX_PMCU_RETURN_t ifx_pcie_pmcu_state_get(IFX_PMCU_STATE_t *pmcuState)
2777 + * \brief the callback function to get pmcu state in the power management hardware-dependent module
2779 + * \param pmcuState Pointer to return power state.
2781 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2782 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2783 + * \return IFX_PMCU_RETURN_DENIED Not allowed to operate power state
2784 + * \ingroup IFX_PCIE_PM
2786 +static IFX_PMCU_RETURN_t
2787 +ifx_pcie_pmcu_state_get(IFX_PMCU_STATE_t *pmcuState)
2789 + return IFX_PMCU_RETURN_SUCCESS;
2793 + * \fn IFX_PMCU_RETURN_t ifx_pcie_pmcu_prechange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2794 + * \brief Apply all callbacks registered to be executed before a state change for pmcuModule
2796 + * \param pmcuModule Module
2797 + * \param newState New state
2798 + * \param oldState Old state
2799 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2800 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2801 + * \ingroup IFX_PCIE_PM
2803 +static IFX_PMCU_RETURN_t
2804 +ifx_pcie_pmcu_prechange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2806 + return IFX_PMCU_RETURN_SUCCESS;
2810 + * \fn IFX_PMCU_RETURN_t ifx_pcie_pmcu_postchange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2811 + * \brief Apply all callbacks registered to be executed before a state change for pmcuModule
2813 + * \param pmcuModule Module
2814 + * \param newState New state
2815 + * \param oldState Old state
2816 + * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
2817 + * \return IFX_PMCU_RETURN_ERROR Failed to set power state.
2818 + * \ingroup IFX_PCIE_PM
2820 +static IFX_PMCU_RETURN_t
2821 +ifx_pcie_pmcu_postchange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2823 + return IFX_PMCU_RETURN_SUCCESS;
2827 + * \fn static void ifx_pcie_pmcu_init(void)
2828 + * \brief Register with central PMCU module
2830 + * \ingroup IFX_PCIE_PM
2833 +ifx_pcie_pmcu_init(void)
2835 + IFX_PMCU_REGISTER_t pmcuRegister;
2837 + /* XXX, hook driver context */
2839 + /* State function register */
2840 + memset(&pmcuRegister, 0, sizeof(IFX_PMCU_REGISTER_t));
2841 + pmcuRegister.pmcuModule = IFX_PMCU_MODULE_PCIE;
2842 + pmcuRegister.pmcuModuleNr = 0;
2843 + pmcuRegister.ifx_pmcu_state_change = ifx_pcie_pmcu_state_change;
2844 + pmcuRegister.ifx_pmcu_state_get = ifx_pcie_pmcu_state_get;
2845 + pmcuRegister.pre = ifx_pcie_pmcu_prechange;
2846 + pmcuRegister.post= ifx_pcie_pmcu_postchange;
2847 + ifx_pmcu_register(&pmcuRegister);
2851 + * \fn static void ifx_pcie_pmcu_exit(void)
2852 + * \brief Unregister with central PMCU module
2855 + * \ingroup IFX_PCIE_PM
2858 +ifx_pcie_pmcu_exit(void)
2860 + IFX_PMCU_REGISTER_t pmcuUnRegister;
2862 + /* XXX, hook driver context */
2864 + pmcuUnRegister.pmcuModule = IFX_PMCU_MODULE_PCIE;
2865 + pmcuUnRegister.pmcuModuleNr = 0;
2866 + ifx_pmcu_unregister(&pmcuUnRegister);
2869 Index: linux-3.8.13/arch/mips/pci/ifxmips_pcie_pm.h
2870 ===================================================================
2871 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2872 +++ linux-3.8.13/arch/mips/pci/ifxmips_pcie_pm.h 2013-07-25 20:01:18.407262431 +0200
2874 +/******************************************************************************
2876 +** FILE NAME : ifxmips_pcie_pm.h
2877 +** PROJECT : IFX UEIP
2878 +** MODULES : PCIe Root Complex Driver
2880 +** DATE : 21 Dec 2009
2881 +** AUTHOR : Lei Chuanhua
2882 +** DESCRIPTION : PCIe Root Complex Driver Power Managment
2883 +** COPYRIGHT : Copyright (c) 2009
2884 +** Lantiq Deutschland GmbH
2885 +** Am Campeon 3, 85579 Neubiberg, Germany
2887 +** This program is free software; you can redistribute it and/or modify
2888 +** it under the terms of the GNU General Public License as published by
2889 +** the Free Software Foundation; either version 2 of the License, or
2890 +** (at your option) any later version.
2893 +** $Date $Author $Comment
2894 +** 21 Dec,2009 Lei Chuanhua First UEIP release
2895 +*******************************************************************************/
2897 + \file ifxmips_pcie_pm.h
2899 + \brief header file for PCIe Root Complex Driver Power Management
2902 +#ifndef IFXMIPS_PCIE_PM_H
2903 +#define IFXMIPS_PCIE_PM_H
2905 +void ifx_pcie_pmcu_init(void);
2906 +void ifx_pcie_pmcu_exit(void);
2908 +#endif /* IFXMIPS_PCIE_PM_H */
2910 Index: linux-3.8.13/arch/mips/pci/ifxmips_pcie_reg.h
2911 ===================================================================
2912 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2913 +++ linux-3.8.13/arch/mips/pci/ifxmips_pcie_reg.h 2013-07-25 20:01:18.411262431 +0200
2915 +/******************************************************************************
2917 +** FILE NAME : ifxmips_pcie_reg.h
2918 +** PROJECT : IFX UEIP for VRX200
2919 +** MODULES : PCIe module
2921 +** DATE : 02 Mar 2009
2922 +** AUTHOR : Lei Chuanhua
2923 +** DESCRIPTION : PCIe Root Complex Driver
2924 +** COPYRIGHT : Copyright (c) 2009
2925 +** Infineon Technologies AG
2926 +** Am Campeon 1-12, 85579 Neubiberg, Germany
2928 +** This program is free software; you can redistribute it and/or modify
2929 +** it under the terms of the GNU General Public License as published by
2930 +** the Free Software Foundation; either version 2 of the License, or
2931 +** (at your option) any later version.
2933 +** $Version $Date $Author $Comment
2934 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
2935 +*******************************************************************************/
2936 +#ifndef IFXMIPS_PCIE_REG_H
2937 +#define IFXMIPS_PCIE_REG_H
2939 + \file ifxmips_pcie_reg.h
2941 + \brief header file for PCIe module register definition
2943 +/* PCIe Address Mapping Base */
2944 +#define PCIE_CFG_PHY_BASE 0x1D000000UL
2945 +#define PCIE_CFG_BASE (KSEG1 + PCIE_CFG_PHY_BASE)
2946 +#define PCIE_CFG_SIZE (8 * 1024 * 1024)
2948 +#define PCIE_MEM_PHY_BASE 0x1C000000UL
2949 +#define PCIE_MEM_BASE (KSEG1 + PCIE_MEM_PHY_BASE)
2950 +#define PCIE_MEM_SIZE (16 * 1024 * 1024)
2951 +#define PCIE_MEM_PHY_END (PCIE_MEM_PHY_BASE + PCIE_MEM_SIZE - 1)
2953 +#define PCIE_IO_PHY_BASE 0x1D800000UL
2954 +#define PCIE_IO_BASE (KSEG1 + PCIE_IO_PHY_BASE)
2955 +#define PCIE_IO_SIZE (1 * 1024 * 1024)
2956 +#define PCIE_IO_PHY_END (PCIE_IO_PHY_BASE + PCIE_IO_SIZE - 1)
2958 +#define PCIE_RC_CFG_BASE (KSEG1 + 0x1D900000)
2959 +#define PCIE_APP_LOGIC_REG (KSEG1 + 0x1E100900)
2960 +#define PCIE_MSI_PHY_BASE 0x1F600000UL
2962 +#define PCIE_PDI_PHY_BASE 0x1F106800UL
2963 +#define PCIE_PDI_BASE (KSEG1 + PCIE_PDI_PHY_BASE)
2964 +#define PCIE_PDI_SIZE 0x400
2966 +#define PCIE1_CFG_PHY_BASE 0x19000000UL
2967 +#define PCIE1_CFG_BASE (KSEG1 + PCIE1_CFG_PHY_BASE)
2968 +#define PCIE1_CFG_SIZE (8 * 1024 * 1024)
2970 +#define PCIE1_MEM_PHY_BASE 0x18000000UL
2971 +#define PCIE1_MEM_BASE (KSEG1 + PCIE1_MEM_PHY_BASE)
2972 +#define PCIE1_MEM_SIZE (16 * 1024 * 1024)
2973 +#define PCIE1_MEM_PHY_END (PCIE1_MEM_PHY_BASE + PCIE1_MEM_SIZE - 1)
2975 +#define PCIE1_IO_PHY_BASE 0x19800000UL
2976 +#define PCIE1_IO_BASE (KSEG1 + PCIE1_IO_PHY_BASE)
2977 +#define PCIE1_IO_SIZE (1 * 1024 * 1024)
2978 +#define PCIE1_IO_PHY_END (PCIE1_IO_PHY_BASE + PCIE1_IO_SIZE - 1)
2980 +#define PCIE1_RC_CFG_BASE (KSEG1 + 0x19900000)
2981 +#define PCIE1_APP_LOGIC_REG (KSEG1 + 0x1E100700)
2982 +#define PCIE1_MSI_PHY_BASE 0x1F400000UL
2984 +#define PCIE1_PDI_PHY_BASE 0x1F700400UL
2985 +#define PCIE1_PDI_BASE (KSEG1 + PCIE1_PDI_PHY_BASE)
2986 +#define PCIE1_PDI_SIZE 0x400
2988 +#define PCIE_CFG_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_CFG_BASE) : (PCIE_CFG_BASE))
2989 +#define PCIE_MEM_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_BASE) : (PCIE_MEM_BASE))
2990 +#define PCIE_IO_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_BASE) : (PCIE_IO_BASE))
2991 +#define PCIE_MEM_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_PHY_BASE) : (PCIE_MEM_PHY_BASE))
2992 +#define PCIE_MEM_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_MEM_PHY_END) : (PCIE_MEM_PHY_END))
2993 +#define PCIE_IO_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_PHY_BASE) : (PCIE_IO_PHY_BASE))
2994 +#define PCIE_IO_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_IO_PHY_END) : (PCIE_IO_PHY_END))
2995 +#define PCIE_APP_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_APP_LOGIC_REG) : (PCIE_APP_LOGIC_REG))
2996 +#define PCIE_RC_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_RC_CFG_BASE) : (PCIE_RC_CFG_BASE))
2997 +#define PCIE_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_PDI_BASE) : (PCIE_PDI_BASE))
2999 +/* PCIe Application Logic Register */
3000 +/* RC Core Control Register */
3001 +#define PCIE_RC_CCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x10)
3002 +/* This should be enabled after initializing configuratin registers
3003 + * Also should check link status retraining bit
3005 +#define PCIE_RC_CCR_LTSSM_ENABLE 0x00000001 /* Enable LTSSM to continue link establishment */
3007 +/* RC Core Debug Register */
3008 +#define PCIE_RC_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x14)
3009 +#define PCIE_RC_DR_DLL_UP 0x00000001 /* Data Link Layer Up */
3010 +#define PCIE_RC_DR_CURRENT_POWER_STATE 0x0000000E /* Current Power State */
3011 +#define PCIE_RC_DR_CURRENT_POWER_STATE_S 1
3012 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE 0x000001F0 /* Current LTSSM State */
3013 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE_S 4
3015 +#define PCIE_RC_DR_PM_DEV_STATE 0x00000E00 /* Power Management D-State */
3016 +#define PCIE_RC_DR_PM_DEV_STATE_S 9
3018 +#define PCIE_RC_DR_PM_ENABLED 0x00001000 /* Power Management State from PMU */
3019 +#define PCIE_RC_DR_PME_EVENT_ENABLED 0x00002000 /* Power Management Event Enable State */
3020 +#define PCIE_RC_DR_AUX_POWER_ENABLED 0x00004000 /* Auxiliary Power Enable */
3022 +/* Current Power State Definition */
3024 + PCIE_RC_DR_D0 = 0,
3025 + PCIE_RC_DR_D1, /* Not supported */
3026 + PCIE_RC_DR_D2, /* Not supported */
3031 +/* PHY Link Status Register */
3032 +#define PCIE_PHY_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x18)
3033 +#define PCIE_PHY_SR_PHY_LINK_UP 0x00000001 /* PHY Link Up/Down Indicator */
3035 +/* Electromechanical Control Register */
3036 +#define PCIE_EM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x1C)
3037 +#define PCIE_EM_CR_CARD_IS_PRESENT 0x00000001 /* Card Presence Detect State */
3038 +#define PCIE_EM_CR_MRL_OPEN 0x00000002 /* MRL Sensor State */
3039 +#define PCIE_EM_CR_POWER_FAULT_SET 0x00000004 /* Power Fault Detected */
3040 +#define PCIE_EM_CR_MRL_SENSOR_SET 0x00000008 /* MRL Sensor Changed */
3041 +#define PCIE_EM_CR_PRESENT_DETECT_SET 0x00000010 /* Card Presense Detect Changed */
3042 +#define PCIE_EM_CR_CMD_CPL_INT_SET 0x00000020 /* Command Complete Interrupt */
3043 +#define PCIE_EM_CR_SYS_INTERLOCK_SET 0x00000040 /* System Electromechanical IterLock Engaged */
3044 +#define PCIE_EM_CR_ATTENTION_BUTTON_SET 0x00000080 /* Attention Button Pressed */
3046 +/* Interrupt Status Register */
3047 +#define PCIE_IR_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x20)
3048 +#define PCIE_IR_SR_PME_CAUSE_MSI 0x00000002 /* MSI caused by PME */
3049 +#define PCIE_IR_SR_HP_PME_WAKE_GEN 0x00000004 /* Hotplug PME Wake Generation */
3050 +#define PCIE_IR_SR_HP_MSI 0x00000008 /* Hotplug MSI */
3051 +#define PCIE_IR_SR_AHB_LU_ERR 0x00000030 /* AHB Bridge Lookup Error Signals */
3052 +#define PCIE_IR_SR_AHB_LU_ERR_S 4
3053 +#define PCIE_IR_SR_INT_MSG_NUM 0x00003E00 /* Interrupt Message Number */
3054 +#define PCIE_IR_SR_INT_MSG_NUM_S 9
3055 +#define PCIE_IR_SR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
3056 +#define PCIE_IR_SR_AER_INT_MSG_NUM_S 27
3058 +/* Message Control Register */
3059 +#define PCIE_MSG_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x30)
3060 +#define PCIE_MSG_CR_GEN_PME_TURN_OFF_MSG 0x00000001 /* Generate PME Turn Off Message */
3061 +#define PCIE_MSG_CR_GEN_UNLOCK_MSG 0x00000002 /* Generate Unlock Message */
3063 +#define PCIE_VDM_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x34)
3065 +/* Vendor-Defined Message Requester ID Register */
3066 +#define PCIE_VDM_RID(X) (PCIE_APP_PORT_TO_BASE (X) + 0x38)
3067 +#define PCIE_VDM_RID_VENROR_MSG_REQ_ID 0x0000FFFF
3068 +#define PCIE_VDM_RID_VDMRID_S 0
3070 +/* ASPM Control Register */
3071 +#define PCIE_ASPM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x40)
3072 +#define PCIE_ASPM_CR_HOT_RST 0x00000001 /* Hot Reset Request to the downstream device */
3073 +#define PCIE_ASPM_CR_REQ_EXIT_L1 0x00000002 /* Request to Exit L1 */
3074 +#define PCIE_ASPM_CR_REQ_ENTER_L1 0x00000004 /* Request to Enter L1 */
3076 +/* Vendor Message DW0 Register */
3077 +#define PCIE_VM_MSG_DW0(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x50)
3078 +#define PCIE_VM_MSG_DW0_TYPE 0x0000001F /* Message type */
3079 +#define PCIE_VM_MSG_DW0_TYPE_S 0
3080 +#define PCIE_VM_MSG_DW0_FORMAT 0x00000060 /* Format */
3081 +#define PCIE_VM_MSG_DW0_FORMAT_S 5
3082 +#define PCIE_VM_MSG_DW0_TC 0x00007000 /* Traffic Class */
3083 +#define PCIE_VM_MSG_DW0_TC_S 12
3084 +#define PCIE_VM_MSG_DW0_ATTR 0x000C0000 /* Atrributes */
3085 +#define PCIE_VM_MSG_DW0_ATTR_S 18
3086 +#define PCIE_VM_MSG_DW0_EP_TLP 0x00100000 /* Poisoned TLP */
3087 +#define PCIE_VM_MSG_DW0_TD 0x00200000 /* TLP Digest */
3088 +#define PCIE_VM_MSG_DW0_LEN 0xFFC00000 /* Length */
3089 +#define PCIE_VM_MSG_DW0_LEN_S 22
3091 +/* Format Definition */
3093 + PCIE_VM_MSG_FORMAT_00 = 0, /* 3DW Hdr, no data*/
3094 + PCIE_VM_MSG_FORMAT_01, /* 4DW Hdr, no data */
3095 + PCIE_VM_MSG_FORMAT_10, /* 3DW Hdr, with data */
3096 + PCIE_VM_MSG_FORMAT_11, /* 4DW Hdr, with data */
3099 +/* Traffic Class Definition */
3101 + PCIE_VM_MSG_TC0 = 0,
3111 +/* Attributes Definition */
3113 + PCIE_VM_MSG_ATTR_00 = 0, /* RO and No Snoop cleared */
3114 + PCIE_VM_MSG_ATTR_01, /* RO cleared , No Snoop set */
3115 + PCIE_VM_MSG_ATTR_10, /* RO set, No Snoop cleared*/
3116 + PCIE_VM_MSG_ATTR_11, /* RO and No Snoop set */
3119 +/* Payload Size Definition */
3120 +#define PCIE_VM_MSG_LEN_MIN 0
3121 +#define PCIE_VM_MSG_LEN_MAX 1024
3123 +/* Vendor Message DW1 Register */
3124 +#define PCIE_VM_MSG_DW1(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x54)
3125 +#define PCIE_VM_MSG_DW1_FUNC_NUM 0x00000070 /* Function Number */
3126 +#define PCIE_VM_MSG_DW1_FUNC_NUM_S 8
3127 +#define PCIE_VM_MSG_DW1_CODE 0x00FF0000 /* Message Code */
3128 +#define PCIE_VM_MSG_DW1_CODE_S 16
3129 +#define PCIE_VM_MSG_DW1_TAG 0xFF000000 /* Tag */
3130 +#define PCIE_VM_MSG_DW1_TAG_S 24
3132 +#define PCIE_VM_MSG_DW2(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x58)
3133 +#define PCIE_VM_MSG_DW3(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x5C)
3135 +/* Vendor Message Request Register */
3136 +#define PCIE_VM_MSG_REQR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x60)
3137 +#define PCIE_VM_MSG_REQR_REQ 0x00000001 /* Vendor Message Request */
3140 +/* AHB Slave Side Band Control Register */
3141 +#define PCIE_AHB_SSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x70)
3142 +#define PCIE_AHB_SSB_REQ_BCM 0x00000001 /* Slave Reques BCM filed */
3143 +#define PCIE_AHB_SSB_REQ_EP 0x00000002 /* Slave Reques EP filed */
3144 +#define PCIE_AHB_SSB_REQ_TD 0x00000004 /* Slave Reques TD filed */
3145 +#define PCIE_AHB_SSB_REQ_ATTR 0x00000018 /* Slave Reques Attribute number */
3146 +#define PCIE_AHB_SSB_REQ_ATTR_S 3
3147 +#define PCIE_AHB_SSB_REQ_TC 0x000000E0 /* Slave Request TC Field */
3148 +#define PCIE_AHB_SSB_REQ_TC_S 5
3150 +/* AHB Master SideBand Ctrl Register */
3151 +#define PCIE_AHB_MSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x74)
3152 +#define PCIE_AHB_MSB_RESP_ATTR 0x00000003 /* Master Response Attribute number */
3153 +#define PCIE_AHB_MSB_RESP_ATTR_S 0
3154 +#define PCIE_AHB_MSB_RESP_BAD_EOT 0x00000004 /* Master Response Badeot filed */
3155 +#define PCIE_AHB_MSB_RESP_BCM 0x00000008 /* Master Response BCM filed */
3156 +#define PCIE_AHB_MSB_RESP_EP 0x00000010 /* Master Response EP filed */
3157 +#define PCIE_AHB_MSB_RESP_TD 0x00000020 /* Master Response TD filed */
3158 +#define PCIE_AHB_MSB_RESP_FUN_NUM 0x000003C0 /* Master Response Function number */
3159 +#define PCIE_AHB_MSB_RESP_FUN_NUM_S 6
3161 +/* AHB Control Register, fixed bus enumeration exception */
3162 +#define PCIE_AHB_CTRL(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x78)
3163 +#define PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS 0x00000001
3165 +/* Interrupt Enalbe Register */
3166 +#define PCIE_IRNEN(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF4)
3167 +#define PCIE_IRNCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF8)
3168 +#define PCIE_IRNICR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xFC)
3170 +/* PCIe interrupt enable/control/capture register definition */
3171 +#define PCIE_IRN_AER_REPORT 0x00000001 /* AER Interrupt */
3172 +#define PCIE_IRN_AER_MSIX 0x00000002 /* Advanced Error MSI-X Interrupt */
3173 +#define PCIE_IRN_PME 0x00000004 /* PME Interrupt */
3174 +#define PCIE_IRN_HOTPLUG 0x00000008 /* Hotplug Interrupt */
3175 +#define PCIE_IRN_RX_VDM_MSG 0x00000010 /* Vendor-Defined Message Interrupt */
3176 +#define PCIE_IRN_RX_CORRECTABLE_ERR_MSG 0x00000020 /* Correctable Error Message Interrupt */
3177 +#define PCIE_IRN_RX_NON_FATAL_ERR_MSG 0x00000040 /* Non-fatal Error Message */
3178 +#define PCIE_IRN_RX_FATAL_ERR_MSG 0x00000080 /* Fatal Error Message */
3179 +#define PCIE_IRN_RX_PME_MSG 0x00000100 /* PME Message Interrupt */
3180 +#define PCIE_IRN_RX_PME_TURNOFF_ACK 0x00000200 /* PME Turnoff Ack Message Interrupt */
3181 +#define PCIE_IRN_AHB_BR_FATAL_ERR 0x00000400 /* AHB Fatal Error Interrupt */
3182 +#define PCIE_IRN_LINK_AUTO_BW_STATUS 0x00000800 /* Link Auto Bandwidth Status Interrupt */
3183 +#define PCIE_IRN_BW_MGT 0x00001000 /* Bandwidth Managment Interrupt */
3184 +#define PCIE_IRN_INTA 0x00002000 /* INTA */
3185 +#define PCIE_IRN_INTB 0x00004000 /* INTB */
3186 +#define PCIE_IRN_INTC 0x00008000 /* INTC */
3187 +#define PCIE_IRN_INTD 0x00010000 /* INTD */
3188 +#define PCIE_IRN_WAKEUP 0x00020000 /* Wake up Interrupt */
3190 +#define PCIE_RC_CORE_COMBINED_INT (PCIE_IRN_AER_REPORT | PCIE_IRN_AER_MSIX | PCIE_IRN_PME | \
3191 + PCIE_IRN_HOTPLUG | PCIE_IRN_RX_VDM_MSG | PCIE_IRN_RX_CORRECTABLE_ERR_MSG |\
3192 + PCIE_IRN_RX_NON_FATAL_ERR_MSG | PCIE_IRN_RX_FATAL_ERR_MSG | \
3193 + PCIE_IRN_RX_PME_MSG | PCIE_IRN_RX_PME_TURNOFF_ACK | PCIE_IRN_AHB_BR_FATAL_ERR | \
3194 + PCIE_IRN_LINK_AUTO_BW_STATUS | PCIE_IRN_BW_MGT)
3195 +/* PCIe RC Configuration Register */
3196 +#define PCIE_VDID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x00)
3198 +/* Bit definition from pci_reg.h */
3199 +#define PCIE_PCICMDSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x04)
3200 +#define PCIE_CCRID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x08)
3201 +#define PCIE_CLSLTHTBR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x0C) /* EP only */
3202 +/* BAR0, BAR1,Only necessary if the bridges implements a device-specific register set or memory buffer */
3203 +#define PCIE_BAR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10) /* Not used*/
3204 +#define PCIE_BAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14) /* Not used */
3206 +#define PCIE_BNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x18) /* Mandatory */
3207 +/* Bus Number Register bits */
3208 +#define PCIE_BNR_PRIMARY_BUS_NUM 0x000000FF
3209 +#define PCIE_BNR_PRIMARY_BUS_NUM_S 0
3210 +#define PCIE_PNR_SECONDARY_BUS_NUM 0x0000FF00
3211 +#define PCIE_PNR_SECONDARY_BUS_NUM_S 8
3212 +#define PCIE_PNR_SUB_BUS_NUM 0x00FF0000
3213 +#define PCIE_PNR_SUB_BUS_NUM_S 16
3215 +/* IO Base/Limit Register bits */
3216 +#define PCIE_IOBLSECS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x1C) /* RC only */
3217 +#define PCIE_IOBLSECS_32BIT_IO_ADDR 0x00000001
3218 +#define PCIE_IOBLSECS_IO_BASE_ADDR 0x000000F0
3219 +#define PCIE_IOBLSECS_IO_BASE_ADDR_S 4
3220 +#define PCIE_IOBLSECS_32BIT_IOLIMT 0x00000100
3221 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR 0x0000F000
3222 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR_S 12
3224 +/* Non-prefetchable Memory Base/Limit Register bit */
3225 +#define PCIE_MBML(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x20) /* RC only */
3226 +#define PCIE_MBML_MEM_BASE_ADDR 0x0000FFF0
3227 +#define PCIE_MBML_MEM_BASE_ADDR_S 4
3228 +#define PCIE_MBML_MEM_LIMIT_ADDR 0xFFF00000
3229 +#define PCIE_MBML_MEM_LIMIT_ADDR_S 20
3231 +/* Prefetchable Memory Base/Limit Register bit */
3232 +#define PCIE_PMBL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x24) /* RC only */
3233 +#define PCIE_PMBL_64BIT_ADDR 0x00000001
3234 +#define PCIE_PMBL_UPPER_12BIT 0x0000FFF0
3235 +#define PCIE_PMBL_UPPER_12BIT_S 4
3236 +#define PCIE_PMBL_E64MA 0x00010000
3237 +#define PCIE_PMBL_END_ADDR 0xFFF00000
3238 +#define PCIE_PMBL_END_ADDR_S 20
3239 +#define PCIE_PMBU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x28) /* RC only */
3240 +#define PCIE_PMLU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x2C) /* RC only */
3242 +/* I/O Base/Limit Upper 16 bits register */
3243 +#define PCIE_IO_BANDL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x30) /* RC only */
3244 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE 0x0000FFFF
3245 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE_S 0
3246 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT 0xFFFF0000
3247 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT_S 16
3249 +#define PCIE_CPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x34)
3250 +#define PCIE_EBBAR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x38)
3252 +/* Interrupt and Secondary Bridge Control Register */
3253 +#define PCIE_INTRBCTRL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x3C)
3255 +#define PCIE_INTRBCTRL_INT_LINE 0x000000FF
3256 +#define PCIE_INTRBCTRL_INT_LINE_S 0
3257 +#define PCIE_INTRBCTRL_INT_PIN 0x0000FF00
3258 +#define PCIE_INTRBCTRL_INT_PIN_S 8
3259 +#define PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE 0x00010000 /* #PERR */
3260 +#define PCIE_INTRBCTRL_SERR_ENABLE 0x00020000 /* #SERR */
3261 +#define PCIE_INTRBCTRL_ISA_ENABLE 0x00040000 /* ISA enable, IO 64KB only */
3262 +#define PCIE_INTRBCTRL_VGA_ENABLE 0x00080000 /* VGA enable */
3263 +#define PCIE_INTRBCTRL_VGA_16BIT_DECODE 0x00100000 /* VGA 16bit decode */
3264 +#define PCIE_INTRBCTRL_RST_SECONDARY_BUS 0x00400000 /* Secondary bus rest, hot rest, 1ms */
3265 +/* Others are read only */
3267 + PCIE_INTRBCTRL_INT_NON = 0,
3268 + PCIE_INTRBCTRL_INTA,
3269 + PCIE_INTRBCTRL_INTB,
3270 + PCIE_INTRBCTRL_INTC,
3271 + PCIE_INTRBCTRL_INTD,
3274 +#define PCIE_PM_CAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x40)
3276 +/* Power Management Control and Status Register */
3277 +#define PCIE_PM_CSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x44)
3279 +#define PCIE_PM_CSR_POWER_STATE 0x00000003 /* Power State */
3280 +#define PCIE_PM_CSR_POWER_STATE_S 0
3281 +#define PCIE_PM_CSR_SW_RST 0x00000008 /* Soft Reset Enabled */
3282 +#define PCIE_PM_CSR_PME_ENABLE 0x00000100 /* PME Enable */
3283 +#define PCIE_PM_CSR_PME_STATUS 0x00008000 /* PME status */
3285 +/* MSI Capability Register for EP */
3286 +#define PCIE_MCAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x50)
3288 +#define PCIE_MCAPR_MSI_CAP_ID 0x000000FF /* MSI Capability ID */
3289 +#define PCIE_MCAPR_MSI_CAP_ID_S 0
3290 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR 0x0000FF00 /* Next Capability Pointer */
3291 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR_S 8
3292 +#define PCIE_MCAPR_MSI_ENABLE 0x00010000 /* MSI Enable */
3293 +#define PCIE_MCAPR_MULTI_MSG_CAP 0x000E0000 /* Multiple Message Capable */
3294 +#define PCIE_MCAPR_MULTI_MSG_CAP_S 17
3295 +#define PCIE_MCAPR_MULTI_MSG_ENABLE 0x00700000 /* Multiple Message Enable */
3296 +#define PCIE_MCAPR_MULTI_MSG_ENABLE_S 20
3297 +#define PCIE_MCAPR_ADDR64_CAP 0X00800000 /* 64-bit Address Capable */
3299 +/* MSI Message Address Register */
3300 +#define PCIE_MA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x54)
3302 +#define PCIE_MA_ADDR_MASK 0xFFFFFFFC /* Message Address */
3304 +/* MSI Message Upper Address Register */
3305 +#define PCIE_MUA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x58)
3307 +/* MSI Message Data Register */
3308 +#define PCIE_MD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x5C)
3310 +#define PCIE_MD_DATA 0x0000FFFF /* Message Data */
3311 +#define PCIE_MD_DATA_S 0
3313 +/* PCI Express Capability Register */
3314 +#define PCIE_XCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70)
3316 +#define PCIE_XCAP_ID 0x000000FF /* PCI Express Capability ID */
3317 +#define PCIE_XCAP_ID_S 0
3318 +#define PCIE_XCAP_NEXT_CAP 0x0000FF00 /* Next Capability Pointer */
3319 +#define PCIE_XCAP_NEXT_CAP_S 8
3320 +#define PCIE_XCAP_VER 0x000F0000 /* PCI Express Capability Version */
3321 +#define PCIE_XCAP_VER_S 16
3322 +#define PCIE_XCAP_DEV_PORT_TYPE 0x00F00000 /* Device Port Type */
3323 +#define PCIE_XCAP_DEV_PORT_TYPE_S 20
3324 +#define PCIE_XCAP_SLOT_IMPLEMENTED 0x01000000 /* Slot Implemented */
3325 +#define PCIE_XCAP_MSG_INT_NUM 0x3E000000 /* Interrupt Message Number */
3326 +#define PCIE_XCAP_MSG_INT_NUM_S 25
3328 +/* Device Capability Register */
3329 +#define PCIE_DCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74)
3331 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE 0x00000007 /* Max Payload size */
3332 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE_S 0
3333 +#define PCIE_DCAP_PHANTOM_FUNC 0x00000018 /* Phanton Function, not supported */
3334 +#define PCIE_DCAP_PHANTOM_FUNC_S 3
3335 +#define PCIE_DCAP_EXT_TAG 0x00000020 /* Extended Tag Field */
3336 +#define PCIE_DCAP_EP_L0S_LATENCY 0x000001C0 /* EP L0s latency only */
3337 +#define PCIE_DCAP_EP_L0S_LATENCY_S 6
3338 +#define PCIE_DCAP_EP_L1_LATENCY 0x00000E00 /* EP L1 latency only */
3339 +#define PCIE_DCAP_EP_L1_LATENCY_S 9
3340 +#define PCIE_DCAP_ROLE_BASE_ERR_REPORT 0x00008000 /* Role Based ERR */
3342 +/* Maximum payload size supported */
3344 + PCIE_MAX_PAYLOAD_128 = 0,
3345 + PCIE_MAX_PAYLOAD_256,
3346 + PCIE_MAX_PAYLOAD_512,
3347 + PCIE_MAX_PAYLOAD_1024,
3348 + PCIE_MAX_PAYLOAD_2048,
3349 + PCIE_MAX_PAYLOAD_4096,
3352 +/* Device Control and Status Register */
3353 +#define PCIE_DCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x78)
3355 +#define PCIE_DCTLSTS_CORRECTABLE_ERR_EN 0x00000001 /* COR-ERR */
3356 +#define PCIE_DCTLSTS_NONFATAL_ERR_EN 0x00000002 /* Non-fatal ERR */
3357 +#define PCIE_DCTLSTS_FATAL_ERR_EN 0x00000004 /* Fatal ERR */
3358 +#define PCIE_DCTLSYS_UR_REQ_EN 0x00000008 /* UR ERR */
3359 +#define PCIE_DCTLSTS_RELAXED_ORDERING_EN 0x00000010 /* Enable relaxing ordering */
3360 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE 0x000000E0 /* Max payload mask */
3361 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE_S 5
3362 +#define PCIE_DCTLSTS_EXT_TAG_EN 0x00000100 /* Extended tag field */
3363 +#define PCIE_DCTLSTS_PHANTOM_FUNC_EN 0x00000200 /* Phantom Function Enable */
3364 +#define PCIE_DCTLSTS_AUX_PM_EN 0x00000400 /* AUX Power PM Enable */
3365 +#define PCIE_DCTLSTS_NO_SNOOP_EN 0x00000800 /* Enable no snoop, except root port*/
3366 +#define PCIE_DCTLSTS_MAX_READ_SIZE 0x00007000 /* Max Read Request size*/
3367 +#define PCIE_DCTLSTS_MAX_READ_SIZE_S 12
3368 +#define PCIE_DCTLSTS_CORRECTABLE_ERR 0x00010000 /* COR-ERR Detected */
3369 +#define PCIE_DCTLSTS_NONFATAL_ERR 0x00020000 /* Non-Fatal ERR Detected */
3370 +#define PCIE_DCTLSTS_FATAL_ER 0x00040000 /* Fatal ERR Detected */
3371 +#define PCIE_DCTLSTS_UNSUPPORTED_REQ 0x00080000 /* UR Detected */
3372 +#define PCIE_DCTLSTS_AUX_POWER 0x00100000 /* Aux Power Detected */
3373 +#define PCIE_DCTLSTS_TRANSACT_PENDING 0x00200000 /* Transaction pending */
3375 +#define PCIE_DCTLSTS_ERR_EN (PCIE_DCTLSTS_CORRECTABLE_ERR_EN | \
3376 + PCIE_DCTLSTS_NONFATAL_ERR_EN | PCIE_DCTLSTS_FATAL_ERR_EN | \
3377 + PCIE_DCTLSYS_UR_REQ_EN)
3379 +/* Link Capability Register */
3380 +#define PCIE_LCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7C)
3381 +#define PCIE_LCAP_MAX_LINK_SPEED 0x0000000F /* Max link speed, 0x1 by default */
3382 +#define PCIE_LCAP_MAX_LINK_SPEED_S 0
3383 +#define PCIE_LCAP_MAX_LENGTH_WIDTH 0x000003F0 /* Maxium Length Width */
3384 +#define PCIE_LCAP_MAX_LENGTH_WIDTH_S 4
3385 +#define PCIE_LCAP_ASPM_LEVEL 0x00000C00 /* Active State Link PM Support */
3386 +#define PCIE_LCAP_ASPM_LEVEL_S 10
3387 +#define PCIE_LCAP_L0S_EIXT_LATENCY 0x00007000 /* L0s Exit Latency */
3388 +#define PCIE_LCAP_L0S_EIXT_LATENCY_S 12
3389 +#define PCIE_LCAP_L1_EXIT_LATENCY 0x00038000 /* L1 Exit Latency */
3390 +#define PCIE_LCAP_L1_EXIT_LATENCY_S 15
3391 +#define PCIE_LCAP_CLK_PM 0x00040000 /* Clock Power Management */
3392 +#define PCIE_LCAP_SDER 0x00080000 /* Surprise Down Error Reporting */
3393 +#define PCIE_LCAP_DLL_ACTIVE_REPROT 0x00100000 /* Data Link Layer Active Reporting Capable */
3394 +#define PCIE_LCAP_PORT_NUM 0xFF0000000 /* Port number */
3395 +#define PCIE_LCAP_PORT_NUM_S 24
3397 +/* Maximum Length width definition */
3398 +#define PCIE_MAX_LENGTH_WIDTH_RES 0x00
3399 +#define PCIE_MAX_LENGTH_WIDTH_X1 0x01 /* Default */
3400 +#define PCIE_MAX_LENGTH_WIDTH_X2 0x02
3401 +#define PCIE_MAX_LENGTH_WIDTH_X4 0x04
3402 +#define PCIE_MAX_LENGTH_WIDTH_X8 0x08
3403 +#define PCIE_MAX_LENGTH_WIDTH_X12 0x0C
3404 +#define PCIE_MAX_LENGTH_WIDTH_X16 0x10
3405 +#define PCIE_MAX_LENGTH_WIDTH_X32 0x20
3407 +/* Active State Link PM definition */
3409 + PCIE_ASPM_RES0 = 0,
3410 + PCIE_ASPM_L0S_ENTRY_SUPPORT, /* L0s */
3412 + PCIE_ASPM_L0S_L1_ENTRY_SUPPORT, /* L0s and L1, default */
3415 +/* L0s Exit Latency definition */
3417 + PCIE_L0S_EIXT_LATENCY_L64NS = 0, /* < 64 ns */
3418 + PCIE_L0S_EIXT_LATENCY_B64A128, /* > 64 ns < 128 ns */
3419 + PCIE_L0S_EIXT_LATENCY_B128A256, /* > 128 ns < 256 ns */
3420 + PCIE_L0S_EIXT_LATENCY_B256A512, /* > 256 ns < 512 ns */
3421 + PCIE_L0S_EIXT_LATENCY_B512TO1U, /* > 512 ns < 1 us */
3422 + PCIE_L0S_EIXT_LATENCY_B1A2U, /* > 1 us < 2 us */
3423 + PCIE_L0S_EIXT_LATENCY_B2A4U, /* > 2 us < 4 us */
3424 + PCIE_L0S_EIXT_LATENCY_M4US, /* > 4 us */
3427 +/* L1 Exit Latency definition */
3429 + PCIE_L1_EXIT_LATENCY_L1US = 0, /* < 1 us */
3430 + PCIE_L1_EXIT_LATENCY_B1A2, /* > 1 us < 2 us */
3431 + PCIE_L1_EXIT_LATENCY_B2A4, /* > 2 us < 4 us */
3432 + PCIE_L1_EXIT_LATENCY_B4A8, /* > 4 us < 8 us */
3433 + PCIE_L1_EXIT_LATENCY_B8A16, /* > 8 us < 16 us */
3434 + PCIE_L1_EXIT_LATENCY_B16A32, /* > 16 us < 32 us */
3435 + PCIE_L1_EXIT_LATENCY_B32A64, /* > 32 us < 64 us */
3436 + PCIE_L1_EXIT_LATENCY_M64US, /* > 64 us */
3439 +/* Link Control and Status Register */
3440 +#define PCIE_LCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x80)
3441 +#define PCIE_LCTLSTS_ASPM_ENABLE 0x00000003 /* Active State Link PM Control */
3442 +#define PCIE_LCTLSTS_ASPM_ENABLE_S 0
3443 +#define PCIE_LCTLSTS_RCB128 0x00000008 /* Read Completion Boundary 128*/
3444 +#define PCIE_LCTLSTS_LINK_DISABLE 0x00000010 /* Link Disable */
3445 +#define PCIE_LCTLSTS_RETRIAN_LINK 0x00000020 /* Retrain Link */
3446 +#define PCIE_LCTLSTS_COM_CLK_CFG 0x00000040 /* Common Clock Configuration */
3447 +#define PCIE_LCTLSTS_EXT_SYNC 0x00000080 /* Extended Synch */
3448 +#define PCIE_LCTLSTS_CLK_PM_EN 0x00000100 /* Enable Clock Powerm Management */
3449 +#define PCIE_LCTLSTS_LINK_SPEED 0x000F0000 /* Link Speed */
3450 +#define PCIE_LCTLSTS_LINK_SPEED_S 16
3451 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH 0x03F00000 /* Negotiated Link Width */
3452 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH_S 20
3453 +#define PCIE_LCTLSTS_RETRAIN_PENDING 0x08000000 /* Link training is ongoing */
3454 +#define PCIE_LCTLSTS_SLOT_CLK_CFG 0x10000000 /* Slot Clock Configuration */
3455 +#define PCIE_LCTLSTS_DLL_ACTIVE 0x20000000 /* Data Link Layer Active */
3457 +/* Slot Capabilities Register */
3458 +#define PCIE_SLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x84)
3460 +/* Slot Capabilities */
3461 +#define PCIE_SLCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x88)
3463 +/* Root Control and Capability Register */
3464 +#define PCIE_RCTLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x8C)
3465 +#define PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR 0x00000001 /* #SERR on COR-ERR */
3466 +#define PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR 0x00000002 /* #SERR on Non-Fatal ERR */
3467 +#define PCIE_RCTLCAP_SERR_ON_FATAL_ERR 0x00000004 /* #SERR on Fatal ERR */
3468 +#define PCIE_RCTLCAP_PME_INT_EN 0x00000008 /* PME Interrupt Enable */
3469 +#define PCIE_RCTLCAP_SERR_ENABLE (PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR | \
3470 + PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR | PCIE_RCTLCAP_SERR_ON_FATAL_ERR)
3471 +/* Root Status Register */
3472 +#define PCIE_RSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x90)
3473 +#define PCIE_RSTS_PME_REQ_ID 0x0000FFFF /* PME Request ID */
3474 +#define PCIE_RSTS_PME_REQ_ID_S 0
3475 +#define PCIE_RSTS_PME_STATUS 0x00010000 /* PME Status */
3476 +#define PCIE_RSTS_PME_PENDING 0x00020000 /* PME Pending */
3478 +/* PCI Express Enhanced Capability Header */
3479 +#define PCIE_ENHANCED_CAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x100)
3480 +#define PCIE_ENHANCED_CAP_ID 0x0000FFFF /* PCI Express Extended Capability ID */
3481 +#define PCIE_ENHANCED_CAP_ID_S 0
3482 +#define PCIE_ENHANCED_CAP_VER 0x000F0000 /* Capability Version */
3483 +#define PCIE_ENHANCED_CAP_VER_S 16
3484 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET 0xFFF00000 /* Next Capability Offset */
3485 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET_S 20
3487 +/* Uncorrectable Error Status Register */
3488 +#define PCIE_UES_R(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x104)
3489 +#define PCIE_DATA_LINK_PROTOCOL_ERR 0x00000010 /* Data Link Protocol Error Status */
3490 +#define PCIE_SURPRISE_DOWN_ERROR 0x00000020 /* Surprise Down Error Status */
3491 +#define PCIE_POISONED_TLP 0x00001000 /* Poisoned TLP Status */
3492 +#define PCIE_FC_PROTOCOL_ERR 0x00002000 /* Flow Control Protocol Error Status */
3493 +#define PCIE_COMPLETION_TIMEOUT 0x00004000 /* Completion Timeout Status */
3494 +#define PCIE_COMPLETOR_ABORT 0x00008000 /* Completer Abort Error */
3495 +#define PCIE_UNEXPECTED_COMPLETION 0x00010000 /* Unexpected Completion Status */
3496 +#define PCIE_RECEIVER_OVERFLOW 0x00020000 /* Receive Overflow Status */
3497 +#define PCIE_MALFORNED_TLP 0x00040000 /* Malformed TLP Stauts */
3498 +#define PCIE_ECRC_ERR 0x00080000 /* ECRC Error Stauts */
3499 +#define PCIE_UR_REQ 0x00100000 /* Unsupported Request Error Status */
3500 +#define PCIE_ALL_UNCORRECTABLE_ERR (PCIE_DATA_LINK_PROTOCOL_ERR | PCIE_SURPRISE_DOWN_ERROR | \
3501 + PCIE_POISONED_TLP | PCIE_FC_PROTOCOL_ERR | PCIE_COMPLETION_TIMEOUT | \
3502 + PCIE_COMPLETOR_ABORT | PCIE_UNEXPECTED_COMPLETION | PCIE_RECEIVER_OVERFLOW |\
3503 + PCIE_MALFORNED_TLP | PCIE_ECRC_ERR | PCIE_UR_REQ)
3505 +/* Uncorrectable Error Mask Register, Mask means no report */
3506 +#define PCIE_UEMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x108)
3508 +/* Uncorrectable Error Severity Register */
3509 +#define PCIE_UESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10C)
3511 +/* Correctable Error Status Register */
3512 +#define PCIE_CESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x110)
3513 +#define PCIE_RX_ERR 0x00000001 /* Receive Error Status */
3514 +#define PCIE_BAD_TLP 0x00000040 /* Bad TLP Status */
3515 +#define PCIE_BAD_DLLP 0x00000080 /* Bad DLLP Status */
3516 +#define PCIE_REPLAY_NUM_ROLLOVER 0x00000100 /* Replay Number Rollover Status */
3517 +#define PCIE_REPLAY_TIMER_TIMEOUT_ERR 0x00001000 /* Reply Timer Timeout Status */
3518 +#define PCIE_ADVISORY_NONFTAL_ERR 0x00002000 /* Advisory Non-Fatal Error Status */
3519 +#define PCIE_CORRECTABLE_ERR (PCIE_RX_ERR | PCIE_BAD_TLP | PCIE_BAD_DLLP | PCIE_REPLAY_NUM_ROLLOVER |\
3520 + PCIE_REPLAY_TIMER_TIMEOUT_ERR | PCIE_ADVISORY_NONFTAL_ERR)
3522 +/* Correctable Error Mask Register */
3523 +#define PCIE_CEMR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x114)
3525 +/* Advanced Error Capabilities and Control Register */
3526 +#define PCIE_AECCR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x118)
3527 +#define PCIE_AECCR_FIRST_ERR_PTR 0x0000001F /* First Error Pointer */
3528 +#define PCIE_AECCR_FIRST_ERR_PTR_S 0
3529 +#define PCIE_AECCR_ECRC_GEN_CAP 0x00000020 /* ECRC Generation Capable */
3530 +#define PCIE_AECCR_ECRC_GEN_EN 0x00000040 /* ECRC Generation Enable */
3531 +#define PCIE_AECCR_ECRC_CHECK_CAP 0x00000080 /* ECRC Check Capable */
3532 +#define PCIE_AECCR_ECRC_CHECK_EN 0x00000100 /* ECRC Check Enable */
3534 +/* Header Log Register 1 */
3535 +#define PCIE_HLR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x11C)
3537 +/* Header Log Register 2 */
3538 +#define PCIE_HLR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x120)
3540 +/* Header Log Register 3 */
3541 +#define PCIE_HLR3(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x124)
3543 +/* Header Log Register 4 */
3544 +#define PCIE_HLR4(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x128)
3546 +/* Root Error Command Register */
3547 +#define PCIE_RECR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x12C)
3548 +#define PCIE_RECR_CORRECTABLE_ERR_REPORT_EN 0x00000001 /* COR-ERR */
3549 +#define PCIE_RECR_NONFATAL_ERR_REPORT_EN 0x00000002 /* Non-Fatal ERR */
3550 +#define PCIE_RECR_FATAL_ERR_REPORT_EN 0x00000004 /* Fatal ERR */
3551 +#define PCIE_RECR_ERR_REPORT_EN (PCIE_RECR_CORRECTABLE_ERR_REPORT_EN | \
3552 + PCIE_RECR_NONFATAL_ERR_REPORT_EN | PCIE_RECR_FATAL_ERR_REPORT_EN)
3554 +/* Root Error Status Register */
3555 +#define PCIE_RESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x130)
3556 +#define PCIE_RESR_CORRECTABLE_ERR 0x00000001 /* COR-ERR Receveid */
3557 +#define PCIE_RESR_MULTI_CORRECTABLE_ERR 0x00000002 /* Multiple COR-ERR Received */
3558 +#define PCIE_RESR_FATAL_NOFATAL_ERR 0x00000004 /* ERR Fatal/Non-Fatal Received */
3559 +#define PCIE_RESR_MULTI_FATAL_NOFATAL_ERR 0x00000008 /* Multiple ERR Fatal/Non-Fatal Received */
3560 +#define PCIE_RESR_FIRST_UNCORRECTABLE_FATAL_ERR 0x00000010 /* First UN-COR Fatal */
3561 +#define PCIR_RESR_NON_FATAL_ERR 0x00000020 /* Non-Fatal Error Message Received */
3562 +#define PCIE_RESR_FATAL_ERR 0x00000040 /* Fatal Message Received */
3563 +#define PCIE_RESR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
3564 +#define PCIE_RESR_AER_INT_MSG_NUM_S 27
3566 +/* Error Source Indentification Register */
3567 +#define PCIE_ESIR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x134)
3568 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID 0x0000FFFF
3569 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID_S 0
3570 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID 0xFFFF0000
3571 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID_S 16
3573 +/* VC Enhanced Capability Header */
3574 +#define PCIE_VC_ECH(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x140)
3576 +/* Port VC Capability Register */
3577 +#define PCIE_PVC1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x144)
3578 +#define PCIE_PVC1_EXT_VC_CNT 0x00000007 /* Extended VC Count */
3579 +#define PCIE_PVC1_EXT_VC_CNT_S 0
3580 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT 0x00000070 /* Low Priority Extended VC Count */
3581 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT_S 4
3582 +#define PCIE_PVC1_REF_CLK 0x00000300 /* Reference Clock */
3583 +#define PCIE_PVC1_REF_CLK_S 8
3584 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE 0x00000C00 /* Port Arbitration Table Entry Size */
3585 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE_S 10
3587 +/* Extended Virtual Channel Count Defintion */
3588 +#define PCIE_EXT_VC_CNT_MIN 0
3589 +#define PCIE_EXT_VC_CNT_MAX 7
3591 +/* Port Arbitration Table Entry Size Definition */
3593 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S1BIT = 0,
3594 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S2BIT,
3595 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S4BIT,
3596 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S8BIT,
3599 +/* Port VC Capability Register 2 */
3600 +#define PCIE_PVC2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x148)
3601 +#define PCIE_PVC2_VC_ARB_16P_FIXED_WRR 0x00000001 /* HW Fixed arbitration, 16 phase WRR */
3602 +#define PCIE_PVC2_VC_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
3603 +#define PCIE_PVC2_VC_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
3604 +#define PCIE_PVC2_VC_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
3605 +#define PCIE_PVC2_VC_ARB_WRR 0x0000000F
3606 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET 0xFF000000 /* VC arbitration table offset, not support */
3607 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET_S 24
3609 +/* Port VC Control and Status Register */
3610 +#define PCIE_PVCCRSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14C)
3611 +#define PCIE_PVCCRSR_LOAD_VC_ARB_TAB 0x00000001 /* Load VC Arbitration Table */
3612 +#define PCIE_PVCCRSR_VC_ARB_SEL 0x0000000E /* VC Arbitration Select */
3613 +#define PCIE_PVCCRSR_VC_ARB_SEL_S 1
3614 +#define PCIE_PVCCRSR_VC_ARB_TAB_STATUS 0x00010000 /* Arbitration Status */
3616 +/* VC0 Resource Capability Register */
3617 +#define PCIE_VC0_RC(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x150)
3618 +#define PCIE_VC0_RC_PORT_ARB_HW_FIXED 0x00000001 /* HW Fixed arbitration */
3619 +#define PCIE_VC0_RC_PORT_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
3620 +#define PCIE_VC0_RC_PORT_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
3621 +#define PCIE_VC0_RC_PORT_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
3622 +#define PCIE_VC0_RC_PORT_ARB_TM_128P_WRR 0x00000010 /* Time-based 128 phase WRR */
3623 +#define PCIE_VC0_RC_PORT_ARB_TM_256P_WRR 0x00000020 /* Time-based 256 phase WRR */
3624 +#define PCIE_VC0_RC_PORT_ARB (PCIE_VC0_RC_PORT_ARB_HW_FIXED | PCIE_VC0_RC_PORT_ARB_32P_WRR |\
3625 + PCIE_VC0_RC_PORT_ARB_64P_WRR | PCIE_VC0_RC_PORT_ARB_128P_WRR | \
3626 + PCIE_VC0_RC_PORT_ARB_TM_128P_WRR | PCIE_VC0_RC_PORT_ARB_TM_256P_WRR)
3628 +#define PCIE_VC0_RC_REJECT_SNOOP 0x00008000 /* Reject Snoop Transactioin */
3629 +#define PCIE_VC0_RC_MAX_TIMESLOTS 0x007F0000 /* Maximum time Slots */
3630 +#define PCIE_VC0_RC_MAX_TIMESLOTS_S 16
3631 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET 0xFF000000 /* Port Arbitration Table Offset */
3632 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET_S 24
3634 +/* VC0 Resource Control Register */
3635 +#define PCIE_VC0_RC0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x154)
3636 +#define PCIE_VC0_RC0_TVM0 0x00000001 /* TC0 and VC0 */
3637 +#define PCIE_VC0_RC0_TVM1 0x00000002 /* TC1 and VC1 */
3638 +#define PCIE_VC0_RC0_TVM2 0x00000004 /* TC2 and VC2 */
3639 +#define PCIE_VC0_RC0_TVM3 0x00000008 /* TC3 and VC3 */
3640 +#define PCIE_VC0_RC0_TVM4 0x00000010 /* TC4 and VC4 */
3641 +#define PCIE_VC0_RC0_TVM5 0x00000020 /* TC5 and VC5 */
3642 +#define PCIE_VC0_RC0_TVM6 0x00000040 /* TC6 and VC6 */
3643 +#define PCIE_VC0_RC0_TVM7 0x00000080 /* TC7 and VC7 */
3644 +#define PCIE_VC0_RC0_TC_VC 0x000000FF /* TC/VC mask */
3646 +#define PCIE_VC0_RC0_LOAD_PORT_ARB_TAB 0x00010000 /* Load Port Arbitration Table */
3647 +#define PCIE_VC0_RC0_PORT_ARB_SEL 0x000E0000 /* Port Arbitration Select */
3648 +#define PCIE_VC0_RC0_PORT_ARB_SEL_S 17
3649 +#define PCIE_VC0_RC0_VC_ID 0x07000000 /* VC ID */
3650 +#define PCIE_VC0_RC0_VC_ID_S 24
3651 +#define PCIE_VC0_RC0_VC_EN 0x80000000 /* VC Enable */
3653 +/* VC0 Resource Status Register */
3654 +#define PCIE_VC0_RSR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x158)
3655 +#define PCIE_VC0_RSR0_PORT_ARB_TAB_STATUS 0x00010000 /* Port Arbitration Table Status,not used */
3656 +#define PCIE_VC0_RSR0_VC_NEG_PENDING 0x00020000 /* VC Negotiation Pending */
3658 +/* Ack Latency Timer and Replay Timer Register */
3659 +#define PCIE_ALTRT(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x700)
3660 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT 0x0000FFFF /* Round Trip Latency Time Limit */
3661 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT_S 0
3662 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT 0xFFFF0000 /* Replay Time Limit */
3663 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT_S 16
3665 +/* Other Message Register */
3666 +#define PCIE_OMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x704)
3668 +/* Port Force Link Register */
3669 +#define PCIE_PFLR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x708)
3670 +#define PCIE_PFLR_LINK_NUM 0x000000FF /* Link Number */
3671 +#define PCIE_PFLR_LINK_NUM_S 0
3672 +#define PCIE_PFLR_FORCE_LINK 0x00008000 /* Force link */
3673 +#define PCIE_PFLR_LINK_STATE 0x003F0000 /* Link State */
3674 +#define PCIE_PFLR_LINK_STATE_S 16
3675 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT 0xFF000000 /* Low Power Entrance Count, only for EP */
3676 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT_S 24
3678 +/* Ack Frequency Register */
3679 +#define PCIE_AFR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70C)
3680 +#define PCIE_AFR_AF 0x000000FF /* Ack Frequency */
3681 +#define PCIE_AFR_AF_S 0
3682 +#define PCIE_AFR_FTS_NUM 0x0000FF00 /* The number of Fast Training Sequence from L0S to L0 */
3683 +#define PCIE_AFR_FTS_NUM_S 8
3684 +#define PCIE_AFR_COM_FTS_NUM 0x00FF0000 /* N_FTS; when common clock is used*/
3685 +#define PCIE_AFR_COM_FTS_NUM_S 16
3686 +#define PCIE_AFR_L0S_ENTRY_LATENCY 0x07000000 /* L0s Entrance Latency */
3687 +#define PCIE_AFR_L0S_ENTRY_LATENCY_S 24
3688 +#define PCIE_AFR_L1_ENTRY_LATENCY 0x38000000 /* L1 Entrance Latency */
3689 +#define PCIE_AFR_L1_ENTRY_LATENCY_S 27
3690 +#define PCIE_AFR_FTS_NUM_DEFAULT 32
3691 +#define PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT 7
3692 +#define PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT 5
3694 +/* Port Link Control Register */
3695 +#define PCIE_PLCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x710)
3696 +#define PCIE_PLCR_OTHER_MSG_REQ 0x00000001 /* Other Message Request */
3697 +#define PCIE_PLCR_SCRAMBLE_DISABLE 0x00000002 /* Scramble Disable */
3698 +#define PCIE_PLCR_LOOPBACK_EN 0x00000004 /* Loopback Enable */
3699 +#define PCIE_PLCR_LTSSM_HOT_RST 0x00000008 /* Force LTSSM to the hot reset */
3700 +#define PCIE_PLCR_DLL_LINK_EN 0x00000020 /* Enable Link initialization */
3701 +#define PCIE_PLCR_FAST_LINK_SIM_EN 0x00000080 /* Sets all internal timers to fast mode for simulation purposes */
3702 +#define PCIE_PLCR_LINK_MODE 0x003F0000 /* Link Mode Enable Mask */
3703 +#define PCIE_PLCR_LINK_MODE_S 16
3704 +#define PCIE_PLCR_CORRUPTED_CRC_EN 0x02000000 /* Enabled Corrupt CRC */
3706 +/* Lane Skew Register */
3707 +#define PCIE_LSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x714)
3708 +#define PCIE_LSR_LANE_SKEW_NUM 0x00FFFFFF /* Insert Lane Skew for Transmit, not applicable */
3709 +#define PCIE_LSR_LANE_SKEW_NUM_S 0
3710 +#define PCIE_LSR_FC_DISABLE 0x01000000 /* Disable of Flow Control */
3711 +#define PCIE_LSR_ACKNAK_DISABLE 0x02000000 /* Disable of Ack/Nak */
3712 +#define PCIE_LSR_LANE_DESKEW_DISABLE 0x80000000 /* Disable of Lane-to-Lane Skew */
3714 +/* Symbol Number Register */
3715 +#define PCIE_SNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x718)
3716 +#define PCIE_SNR_TS 0x0000000F /* Number of TS Symbol */
3717 +#define PCIE_SNR_TS_S 0
3718 +#define PCIE_SNR_SKP 0x00000700 /* Number of SKP Symbol */
3719 +#define PCIE_SNR_SKP_S 8
3720 +#define PCIE_SNR_REPLAY_TIMER 0x0007C000 /* Timer Modifier for Replay Timer */
3721 +#define PCIE_SNR_REPLAY_TIMER_S 14
3722 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER 0x00F80000 /* Timer Modifier for Ack/Nak Latency Timer */
3723 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER_S 19
3724 +#define PCIE_SNR_FC_TIMER 0x1F000000 /* Timer Modifier for Flow Control Watchdog Timer */
3725 +#define PCIE_SNR_FC_TIMER_S 28
3727 +/* Symbol Timer Register and Filter Mask Register 1 */
3728 +#define PCIE_STRFMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x71C)
3729 +#define PCIE_STRFMR_SKP_INTERVAL 0x000007FF /* SKP lnterval Value */
3730 +#define PCIE_STRFMR_SKP_INTERVAL_S 0
3731 +#define PCIE_STRFMR_FC_WDT_DISABLE 0x00008000 /* Disable of FC Watchdog Timer */
3732 +#define PCIE_STRFMR_TLP_FUNC_MISMATCH_OK 0x00010000 /* Mask Function Mismatch Filtering for Incoming Requests */
3733 +#define PCIE_STRFMR_POISONED_TLP_OK 0x00020000 /* Mask Poisoned TLP Filtering */
3734 +#define PCIE_STRFMR_BAR_MATCH_OK 0x00040000 /* Mask BAR Match Filtering */
3735 +#define PCIE_STRFMR_TYPE1_CFG_REQ_OK 0x00080000 /* Mask Type 1 Configuration Request Filtering */
3736 +#define PCIE_STRFMR_LOCKED_REQ_OK 0x00100000 /* Mask Locked Request Filtering */
3737 +#define PCIE_STRFMR_CPL_TAG_ERR_RULES_OK 0x00200000 /* Mask Tag Error Rules for Received Completions */
3738 +#define PCIE_STRFMR_CPL_REQUESTOR_ID_MISMATCH_OK 0x00400000 /* Mask Requester ID Mismatch Error for Received Completions */
3739 +#define PCIE_STRFMR_CPL_FUNC_MISMATCH_OK 0x00800000 /* Mask Function Mismatch Error for Received Completions */
3740 +#define PCIE_STRFMR_CPL_TC_MISMATCH_OK 0x01000000 /* Mask Traffic Class Mismatch Error for Received Completions */
3741 +#define PCIE_STRFMR_CPL_ATTR_MISMATCH_OK 0x02000000 /* Mask Attribute Mismatch Error for Received Completions */
3742 +#define PCIE_STRFMR_CPL_LENGTH_MISMATCH_OK 0x04000000 /* Mask Length Mismatch Error for Received Completions */
3743 +#define PCIE_STRFMR_TLP_ECRC_ERR_OK 0x08000000 /* Mask ECRC Error Filtering */
3744 +#define PCIE_STRFMR_CPL_TLP_ECRC_OK 0x10000000 /* Mask ECRC Error Filtering for Completions */
3745 +#define PCIE_STRFMR_RX_TLP_MSG_NO_DROP 0x20000000 /* Send Message TLPs */
3746 +#define PCIE_STRFMR_RX_IO_TRANS_ENABLE 0x40000000 /* Mask Filtering of received I/O Requests */
3747 +#define PCIE_STRFMR_RX_CFG_TRANS_ENABLE 0x80000000 /* Mask Filtering of Received Configuration Requests */
3749 +#define PCIE_DEF_SKP_INTERVAL 700 /* 1180 ~1538 , 125MHz * 2, 250MHz * 1 */
3751 +/* Filter Masker Register 2 */
3752 +#define PCIE_FMR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x720)
3753 +#define PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1 0x00000001 /* Mask RADM Filtering and Error Handling Rules */
3754 +#define PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 0x00000002 /* Mask RADM Filtering and Error Handling Rules */
3756 +/* Debug Register 0 */
3757 +#define PCIE_DBR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x728)
3759 +/* Debug Register 1 */
3760 +#define PCIE_DBR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x72C)
3762 +/* Transmit Posted FC Credit Status Register */
3763 +#define PCIE_TPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x730)
3764 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS 0x00000FFF /* Transmit Posted Data FC Credits */
3765 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS_S 0
3766 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS 0x000FF000 /* Transmit Posted Header FC Credits */
3767 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS_S 12
3769 +/* Transmit Non-Posted FC Credit Status */
3770 +#define PCIE_TNPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x734)
3771 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS 0x00000FFF /* Transmit Non-Posted Data FC Credits */
3772 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS_S 0
3773 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS 0x000FF000 /* Transmit Non-Posted Header FC Credits */
3774 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS_S 12
3776 +/* Transmit Complete FC Credit Status Register */
3777 +#define PCIE_TCFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x738)
3778 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS 0x00000FFF /* Transmit Completion Data FC Credits */
3779 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS_S 0
3780 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS 0x000FF000 /* Transmit Completion Header FC Credits */
3781 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS_S 12
3783 +/* Queue Status Register */
3784 +#define PCIE_QSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x73C)
3785 +#define PCIE_QSR_WAIT_UPDATE_FC_DLL 0x00000001 /* Received TLP FC Credits Not Returned */
3786 +#define PCIE_QSR_TX_RETRY_BUF_NOT_EMPTY 0x00000002 /* Transmit Retry Buffer Not Empty */
3787 +#define PCIE_QSR_RX_QUEUE_NOT_EMPTY 0x00000004 /* Received Queue Not Empty */
3789 +/* VC Transmit Arbitration Register 1 */
3790 +#define PCIE_VCTAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x740)
3791 +#define PCIE_VCTAR1_WRR_WEIGHT_VC0 0x000000FF /* WRR Weight for VC0 */
3792 +#define PCIE_VCTAR1_WRR_WEIGHT_VC1 0x0000FF00 /* WRR Weight for VC1 */
3793 +#define PCIE_VCTAR1_WRR_WEIGHT_VC2 0x00FF0000 /* WRR Weight for VC2 */
3794 +#define PCIE_VCTAR1_WRR_WEIGHT_VC3 0xFF000000 /* WRR Weight for VC3 */
3796 +/* VC Transmit Arbitration Register 2 */
3797 +#define PCIE_VCTAR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x744)
3798 +#define PCIE_VCTAR2_WRR_WEIGHT_VC4 0x000000FF /* WRR Weight for VC4 */
3799 +#define PCIE_VCTAR2_WRR_WEIGHT_VC5 0x0000FF00 /* WRR Weight for VC5 */
3800 +#define PCIE_VCTAR2_WRR_WEIGHT_VC6 0x00FF0000 /* WRR Weight for VC6 */
3801 +#define PCIE_VCTAR2_WRR_WEIGHT_VC7 0xFF000000 /* WRR Weight for VC7 */
3803 +/* VC0 Posted Receive Queue Control Register */
3804 +#define PCIE_VC0_PRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x748)
3805 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS 0x00000FFF /* VC0 Posted Data Credits */
3806 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS_S 0
3807 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS 0x000FF000 /* VC0 Posted Header Credits */
3808 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS_S 12
3809 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE 0x00E00000 /* VC0 Posted TLP Queue Mode */
3810 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE_S 20
3811 +#define PCIE_VC0_PRQCR_TLP_RELAX_ORDER 0x40000000 /* TLP Type Ordering for VC0 */
3812 +#define PCIE_VC0_PRQCR_VC_STRICT_ORDER 0x80000000 /* VC0 Ordering for Receive Queues */
3814 +/* VC0 Non-Posted Receive Queue Control */
3815 +#define PCIE_VC0_NPRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74C)
3816 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS 0x00000FFF /* VC0 Non-Posted Data Credits */
3817 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS_S 0
3818 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS 0x000FF000 /* VC0 Non-Posted Header Credits */
3819 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS_S 12
3820 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE 0x00E00000 /* VC0 Non-Posted TLP Queue Mode */
3821 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE_S 20
3823 +/* VC0 Completion Receive Queue Control */
3824 +#define PCIE_VC0_CRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x750)
3825 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS 0x00000FFF /* VC0 Completion TLP Queue Mode */
3826 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS_S 0
3827 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS 0x000FF000 /* VC0 Completion Header Credits */
3828 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS_S 12
3829 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE 0x00E00000 /* VC0 Completion Data Credits */
3830 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE_S 21
3832 +/* Applicable to the above three registers */
3834 + PCIE_VC0_TLP_QUEUE_MODE_STORE_FORWARD = 1,
3835 + PCIE_VC0_TLP_QUEUE_MODE_CUT_THROUGH = 2,
3836 + PCIE_VC0_TLP_QUEUE_MODE_BYPASS = 4,
3839 +/* VC0 Posted Buffer Depth Register */
3840 +#define PCIE_VC0_PBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7A8)
3841 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Posted Data Queue Depth */
3842 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES_S 0
3843 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Posted Header Queue Depth */
3844 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES_S 16
3846 +/* VC0 Non-Posted Buffer Depth Register */
3847 +#define PCIE_VC0_NPBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7AC)
3848 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Non-Posted Data Queue Depth */
3849 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES_S 0
3850 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Non-Posted Header Queue Depth */
3851 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES_S 16
3853 +/* VC0 Completion Buffer Depth Register */
3854 +#define PCIE_VC0_CBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7B0)
3855 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES 0x00003FFF /* C0 Completion Data Queue Depth */
3856 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES_S 0
3857 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Completion Header Queue Depth */
3858 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES_S 16
3860 +/* PHY Status Register, all zeros in VR9 */
3861 +#define PCIE_PHYSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x810)
3863 +/* PHY Control Register, all zeros in VR9 */
3864 +#define PCIE_PHYCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x814)
3867 + * PCIe PDI PHY register definition, suppose all the following
3868 + * stuff is confidential.
3869 + * XXX, detailed bit definition
3871 +#define PCIE_PHY_PLL_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x22 << 1))
3872 +#define PCIE_PHY_PLL_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x23 << 1))
3873 +#define PCIE_PHY_PLL_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x24 << 1))
3874 +#define PCIE_PHY_PLL_CTRL4(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x25 << 1))
3875 +#define PCIE_PHY_PLL_CTRL5(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x26 << 1))
3876 +#define PCIE_PHY_PLL_CTRL6(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x27 << 1))
3877 +#define PCIE_PHY_PLL_CTRL7(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x28 << 1))
3878 +#define PCIE_PHY_PLL_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x29 << 1))
3879 +#define PCIE_PHY_PLL_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2A << 1))
3880 +#define PCIE_PHY_PLL_A_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2B << 1))
3881 +#define PCIE_PHY_PLL_STATUS(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2C << 1))
3883 +#define PCIE_PHY_TX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x30 << 1))
3884 +#define PCIE_PHY_TX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x31 << 1))
3885 +#define PCIE_PHY_TX1_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x32 << 1))
3886 +#define PCIE_PHY_TX1_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x33 << 1))
3887 +#define PCIE_PHY_TX1_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x34 << 1))
3888 +#define PCIE_PHY_TX1_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x35 << 1))
3889 +#define PCIE_PHY_TX1_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x36 << 1))
3890 +#define PCIE_PHY_TX1_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x37 << 1))
3892 +#define PCIE_PHY_TX2_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x38 << 1))
3893 +#define PCIE_PHY_TX2_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x39 << 1))
3894 +#define PCIE_PHY_TX2_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3B << 1))
3895 +#define PCIE_PHY_TX2_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3C << 1))
3896 +#define PCIE_PHY_TX2_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3D << 1))
3897 +#define PCIE_PHY_TX2_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3E << 1))
3898 +#define PCIE_PHY_TX2_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3F << 1))
3900 +#define PCIE_PHY_RX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x50 << 1))
3901 +#define PCIE_PHY_RX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x51 << 1))
3902 +#define PCIE_PHY_RX1_CDR(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x52 << 1))
3903 +#define PCIE_PHY_RX1_EI(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x53 << 1))
3904 +#define PCIE_PHY_RX1_A_CTRL(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x55 << 1))
3906 +/* Interrupt related stuff */
3907 +#define PCIE_LEGACY_DISABLE 0
3908 +#define PCIE_LEGACY_INTA 1
3909 +#define PCIE_LEGACY_INTB 2
3910 +#define PCIE_LEGACY_INTC 3
3911 +#define PCIE_LEGACY_INTD 4
3912 +#define PCIE_LEGACY_INT_MAX PCIE_LEGACY_INTD
3914 +#endif /* IFXMIPS_PCIE_REG_H */
3916 Index: linux-3.8.13/arch/mips/pci/ifxmips_pcie_vr9.h
3917 ===================================================================
3918 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3919 +++ linux-3.8.13/arch/mips/pci/ifxmips_pcie_vr9.h 2013-07-25 20:01:18.411262431 +0200
3921 +/****************************************************************************
3922 + Copyright (c) 2010
3923 + Lantiq Deutschland GmbH
3924 + Am Campeon 3; 85579 Neubiberg, Germany
3926 + For licensing information, see the file 'LICENSE' in the root folder of
3927 + this software module.
3929 + *****************************************************************************/
3931 + \file ifxmips_pcie_vr9.h
3933 + \brief PCIe RC driver vr9 specific file
3936 +#ifndef IFXMIPS_PCIE_VR9_H
3937 +#define IFXMIPS_PCIE_VR9_H
3939 +#include <linux/types.h>
3940 +#include <linux/delay.h>
3942 +#include <linux/gpio.h>
3943 +#include <lantiq_soc.h>
3945 +#define IFX_PCIE_GPIO_RESET 238
3947 +#define IFX_REG_R32 ltq_r32
3948 +#define IFX_REG_W32 ltq_w32
3949 +#define CONFIG_IFX_PCIE_HW_SWAP
3950 +#define IFX_RCU_AHB_ENDIAN ((volatile u32*)(IFX_RCU + 0x004C))
3951 +#define IFX_RCU_RST_REQ ((volatile u32*)(IFX_RCU + 0x0010))
3952 +#define IFX_RCU_AHB_BE_PCIE_PDI 0x00000080 /* Configure PCIE PDI module in big endian*/
3954 +#define IFX_RCU (KSEG1 | 0x1F203000)
3955 +#define IFX_RCU_AHB_BE_PCIE_M 0x00000001 /* Configure AHB master port that connects to PCIe RC in big endian */
3956 +#define IFX_RCU_AHB_BE_PCIE_S 0x00000010 /* Configure AHB slave port that connects to PCIe RC in little endian */
3957 +#define IFX_RCU_AHB_BE_XBAR_M 0x00000002 /* Configure AHB master port that connects to XBAR in big endian */
3958 +#define CONFIG_IFX_PCIE_PHY_36MHZ_MODE
3960 +#define IFX_PMU1_MODULE_PCIE_PHY (0)
3961 +#define IFX_PMU1_MODULE_PCIE_CTRL (1)
3962 +#define IFX_PMU1_MODULE_PDI (4)
3963 +#define IFX_PMU1_MODULE_MSI (5)
3965 +#define IFX_PMU_MODULE_PCIE_L0_CLK (31)
3968 +#define IFX_GPIO (KSEG1 | 0x1E100B00)
3969 +#define ALT0 ((volatile u32*)(IFX_GPIO + 0x007c))
3970 +#define ALT1 ((volatile u32*)(IFX_GPIO + 0x0080))
3971 +#define OD ((volatile u32*)(IFX_GPIO + 0x0084))
3972 +#define DIR ((volatile u32*)(IFX_GPIO + 0x0078))
3973 +#define OUT ((volatile u32*)(IFX_GPIO + 0x0070))
3976 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
3979 + gpio_request(IFX_PCIE_GPIO_RESET, "pcie-reset");
3980 + gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
3981 + gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
3983 +/* ifx_gpio_pin_reserve(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3984 + ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3985 + ifx_gpio_dir_out_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3986 + ifx_gpio_altsel0_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3987 + ifx_gpio_altsel1_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
3988 + ifx_gpio_open_drain_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);*/
3991 +static inline void pcie_ahb_pmu_setup(void)
3993 + /* Enable AHB bus master/slave */
3995 + clk = clk_get_sys("1d900000.pcie", "ahb");
3998 + //AHBM_PMU_SETUP(IFX_PMU_ENABLE);
3999 + //AHBS_PMU_SETUP(IFX_PMU_ENABLE);
4002 +static inline void pcie_rcu_endian_setup(int pcie_port)
4006 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
4007 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
4008 + reg |= IFX_RCU_AHB_BE_PCIE_M;
4009 + reg |= IFX_RCU_AHB_BE_PCIE_S;
4010 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
4012 + reg |= IFX_RCU_AHB_BE_PCIE_M;
4013 + reg &= ~IFX_RCU_AHB_BE_PCIE_S;
4014 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
4015 +#endif /* CONFIG_IFX_PCIE_HW_SWAP */
4016 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
4017 + IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
4020 +static inline void pcie_phy_pmu_enable(int pcie_port)
4023 + clk = clk_get_sys("1d900000.pcie", "phy");
4026 + //PCIE_PHY_PMU_SETUP(IFX_PMU_ENABLE);
4029 +static inline void pcie_phy_pmu_disable(int pcie_port)
4032 + clk = clk_get_sys("1d900000.pcie", "phy");
4035 +// PCIE_PHY_PMU_SETUP(IFX_PMU_DISABLE);
4038 +static inline void pcie_pdi_big_endian(int pcie_port)
4042 + /* SRAM2PDI endianness control. */
4043 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
4044 + /* Config AHB->PCIe and PDI endianness */
4045 + reg |= IFX_RCU_AHB_BE_PCIE_PDI;
4046 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
4049 +static inline void pcie_pdi_pmu_enable(int pcie_port)
4051 + /* Enable PDI to access PCIe PHY register */
4053 + clk = clk_get_sys("1d900000.pcie", "pdi");
4055 + //PDI_PMU_SETUP(IFX_PMU_ENABLE);
4058 +static inline void pcie_core_rst_assert(int pcie_port)
4062 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4064 + /* Reset PCIe PHY & Core, bit 22, bit 26 may be affected if write it directly */
4065 + reg |= 0x00400000;
4066 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4069 +static inline void pcie_core_rst_deassert(int pcie_port)
4073 + /* Make sure one micro-second delay */
4076 + /* Reset PCIe PHY & Core, bit 22 */
4077 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4078 + reg &= ~0x00400000;
4079 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4082 +static inline void pcie_phy_rst_assert(int pcie_port)
4086 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4087 + reg |= 0x00001000; /* Bit 12 */
4088 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4091 +static inline void pcie_phy_rst_deassert(int pcie_port)
4095 + /* Make sure one micro-second delay */
4098 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
4099 + reg &= ~0x00001000; /* Bit 12 */
4100 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
4103 +static inline void pcie_device_rst_assert(int pcie_port)
4105 + printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
4106 + gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
4107 +// ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
4110 +static inline void pcie_device_rst_deassert(int pcie_port)
4113 + printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
4114 + gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
4115 +// gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
4116 + //ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
4119 +static inline void pcie_core_pmu_setup(int pcie_port)
4122 + clk = clk_get_sys("1d900000.pcie", "ctl");
4124 + clk = clk_get_sys("1d900000.pcie", "bus");
4127 + /* PCIe Core controller enabled */
4128 +// PCIE_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
4130 + /* Enable PCIe L0 Clock */
4131 +// PCIE_L0_CLK_PMU_SETUP(IFX_PMU_ENABLE);
4134 +static inline void pcie_msi_init(int pcie_port)
4137 + pcie_msi_pic_init(pcie_port);
4138 + clk = clk_get_sys("ltq_pcie", "msi");
4140 +// MSI_PMU_SETUP(IFX_PMU_ENABLE);
4144 +ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
4146 + u32 tbus_number = bus_number;
4148 +#ifdef CONFIG_IFX_PCI
4149 + if (pcibios_host_nr() > 1) {
4150 + tbus_number -= pcibios_1st_host_bus_nr();
4152 +#endif /* CONFIG_IFX_PCI */
4153 + return tbus_number;
4157 +ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
4159 + struct pci_dev *pdev;
4160 + u32 tvalue = value;
4162 + /* Sanity check */
4163 + pdev = pci_get_slot(bus, devfn);
4164 + if (pdev == NULL) {
4168 + /* Only care about PCI bridge */
4169 + if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
4173 + if (read) { /* Read hack */
4174 + #ifdef CONFIG_IFX_PCI
4175 + if (pcibios_host_nr() > 1) {
4176 + tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
4178 + #endif /* CONFIG_IFX_PCI */
4180 + else { /* Write hack */
4181 + #ifdef CONFIG_IFX_PCI
4182 + if (pcibios_host_nr() > 1) {
4183 + tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
4190 +#endif /* IFXMIPS_PCIE_VR9_H */
4192 Index: linux-3.8.13/arch/mips/pci/pci.c
4193 ===================================================================
4194 --- linux-3.8.13.orig/arch/mips/pci/pci.c 2013-07-25 20:01:13.135262305 +0200
4195 +++ linux-3.8.13/arch/mips/pci/pci.c 2013-07-25 20:01:18.411262431 +0200
4196 @@ -255,6 +255,31 @@
4198 subsys_initcall(pcibios_init);
4200 +int pcibios_host_nr(void)
4203 + struct pci_controller *hose;
4204 + for (count = 0, hose = hose_head; hose; hose = hose->next, count++) {
4209 +EXPORT_SYMBOL(pcibios_host_nr);
4211 +int pcibios_1st_host_bus_nr(void)
4214 + struct pci_controller *hose = hose_head;
4216 + if (hose != NULL) {
4217 + if (hose->bus != NULL) {
4218 + bus_nr = hose->bus->number + 1;
4223 +EXPORT_SYMBOL(pcibios_1st_host_bus_nr);
4225 static int pcibios_enable_resources(struct pci_dev *dev, int mask)
4228 Index: linux-3.8.13/drivers/pci/pcie/aer/Kconfig
4229 ===================================================================
4230 --- linux-3.8.13.orig/drivers/pci/pcie/aer/Kconfig 2013-05-11 22:57:46.000000000 +0200
4231 +++ linux-3.8.13/drivers/pci/pcie/aer/Kconfig 2013-07-25 20:01:18.411262431 +0200
4234 boolean "Root Port Advanced Error Reporting support"
4235 depends on PCIEPORTBUS
4239 This enables PCI Express Root Port Advanced Error Reporting
4240 (AER) driver support. Error reporting messages sent to Root
4241 Index: linux-3.8.13/include/linux/pci.h
4242 ===================================================================
4243 --- linux-3.8.13.orig/include/linux/pci.h 2013-07-25 20:01:13.111262305 +0200
4244 +++ linux-3.8.13/include/linux/pci.h 2013-07-25 20:01:18.415262432 +0200
4245 @@ -1059,6 +1059,8 @@
4246 int pci_cfg_space_size_ext(struct pci_dev *dev);
4247 int pci_cfg_space_size(struct pci_dev *dev);
4248 unsigned char pci_bus_max_busnr(struct pci_bus *bus);
4249 +int pcibios_host_nr(void);
4250 +int pcibios_1st_host_bus_nr(void);
4251 void pci_setup_bridge(struct pci_bus *bus);
4252 resource_size_t pcibios_window_alignment(struct pci_bus *bus,
4253 unsigned long type);
4254 Index: linux-3.8.13/include/linux/pci_ids.h
4255 ===================================================================
4256 --- linux-3.8.13.orig/include/linux/pci_ids.h 2013-05-11 22:57:46.000000000 +0200
4257 +++ linux-3.8.13/include/linux/pci_ids.h 2013-07-25 20:01:18.415262432 +0200
4258 @@ -1040,6 +1040,12 @@
4259 #define PCI_DEVICE_ID_SGI_LITHIUM 0x1002
4260 #define PCI_DEVICE_ID_SGI_IOC4 0x100a
4262 +#define PCI_VENDOR_ID_INFINEON 0x15D1
4263 +#define PCI_DEVICE_ID_INFINEON_DANUBE 0x000F
4264 +#define PCI_DEVICE_ID_INFINEON_PCIE 0x0011
4265 +#define PCI_VENDOR_ID_LANTIQ 0x1BEF
4266 +#define PCI_DEVICE_ID_LANTIQ_PCIE 0x00
4268 #define PCI_VENDOR_ID_WINBOND 0x10ad
4269 #define PCI_DEVICE_ID_WINBOND_82C105 0x0105
4270 #define PCI_DEVICE_ID_WINBOND_83C553 0x0565
4271 Index: linux-3.8.13/arch/mips/pci/pcie-lantiq.h
4272 ===================================================================
4273 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4274 +++ linux-3.8.13/arch/mips/pci/pcie-lantiq.h 2013-07-25 20:01:18.419262432 +0200
4276 +/******************************************************************************
4278 +** FILE NAME : ifxmips_pcie_reg.h
4279 +** PROJECT : IFX UEIP for VRX200
4280 +** MODULES : PCIe module
4282 +** DATE : 02 Mar 2009
4283 +** AUTHOR : Lei Chuanhua
4284 +** DESCRIPTION : PCIe Root Complex Driver
4285 +** COPYRIGHT : Copyright (c) 2009
4286 +** Infineon Technologies AG
4287 +** Am Campeon 1-12, 85579 Neubiberg, Germany
4289 +** This program is free software; you can redistribute it and/or modify
4290 +** it under the terms of the GNU General Public License as published by
4291 +** the Free Software Foundation; either version 2 of the License, or
4292 +** (at your option) any later version.
4294 +** $Version $Date $Author $Comment
4295 +** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version
4296 +*******************************************************************************/
4297 +#ifndef IFXMIPS_PCIE_REG_H
4298 +#define IFXMIPS_PCIE_REG_H
4299 +#include <linux/version.h>
4300 +#include <linux/types.h>
4301 +#include <linux/pci.h>
4302 +#include <linux/interrupt.h>
4304 + \file ifxmips_pcie_reg.h
4306 + \brief header file for PCIe module register definition
4308 +/* PCIe Address Mapping Base */
4309 +#define PCIE_CFG_PHY_BASE 0x1D000000UL
4310 +#define PCIE_CFG_BASE (KSEG1 + PCIE_CFG_PHY_BASE)
4311 +#define PCIE_CFG_SIZE (8 * 1024 * 1024)
4313 +#define PCIE_MEM_PHY_BASE 0x1C000000UL
4314 +#define PCIE_MEM_BASE (KSEG1 + PCIE_MEM_PHY_BASE)
4315 +#define PCIE_MEM_SIZE (16 * 1024 * 1024)
4316 +#define PCIE_MEM_PHY_END (PCIE_MEM_PHY_BASE + PCIE_MEM_SIZE - 1)
4318 +#define PCIE_IO_PHY_BASE 0x1D800000UL
4319 +#define PCIE_IO_BASE (KSEG1 + PCIE_IO_PHY_BASE)
4320 +#define PCIE_IO_SIZE (1 * 1024 * 1024)
4321 +#define PCIE_IO_PHY_END (PCIE_IO_PHY_BASE + PCIE_IO_SIZE - 1)
4323 +#define PCIE_RC_CFG_BASE (KSEG1 + 0x1D900000)
4324 +#define PCIE_APP_LOGIC_REG (KSEG1 + 0x1E100900)
4325 +#define PCIE_MSI_PHY_BASE 0x1F600000UL
4327 +#define PCIE_PDI_PHY_BASE 0x1F106800UL
4328 +#define PCIE_PDI_BASE (KSEG1 + PCIE_PDI_PHY_BASE)
4329 +#define PCIE_PDI_SIZE 0x400
4331 +#define PCIE1_CFG_PHY_BASE 0x19000000UL
4332 +#define PCIE1_CFG_BASE (KSEG1 + PCIE1_CFG_PHY_BASE)
4333 +#define PCIE1_CFG_SIZE (8 * 1024 * 1024)
4335 +#define PCIE1_MEM_PHY_BASE 0x18000000UL
4336 +#define PCIE1_MEM_BASE (KSEG1 + PCIE1_MEM_PHY_BASE)
4337 +#define PCIE1_MEM_SIZE (16 * 1024 * 1024)
4338 +#define PCIE1_MEM_PHY_END (PCIE1_MEM_PHY_BASE + PCIE1_MEM_SIZE - 1)
4340 +#define PCIE1_IO_PHY_BASE 0x19800000UL
4341 +#define PCIE1_IO_BASE (KSEG1 + PCIE1_IO_PHY_BASE)
4342 +#define PCIE1_IO_SIZE (1 * 1024 * 1024)
4343 +#define PCIE1_IO_PHY_END (PCIE1_IO_PHY_BASE + PCIE1_IO_SIZE - 1)
4345 +#define PCIE1_RC_CFG_BASE (KSEG1 + 0x19900000)
4346 +#define PCIE1_APP_LOGIC_REG (KSEG1 + 0x1E100700)
4347 +#define PCIE1_MSI_PHY_BASE 0x1F400000UL
4349 +#define PCIE1_PDI_PHY_BASE 0x1F700400UL
4350 +#define PCIE1_PDI_BASE (KSEG1 + PCIE1_PDI_PHY_BASE)
4351 +#define PCIE1_PDI_SIZE 0x400
4353 +#define PCIE_CFG_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_CFG_BASE) : (PCIE_CFG_BASE))
4354 +#define PCIE_MEM_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_BASE) : (PCIE_MEM_BASE))
4355 +#define PCIE_IO_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_BASE) : (PCIE_IO_BASE))
4356 +#define PCIE_MEM_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_PHY_BASE) : (PCIE_MEM_PHY_BASE))
4357 +#define PCIE_MEM_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_MEM_PHY_END) : (PCIE_MEM_PHY_END))
4358 +#define PCIE_IO_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_PHY_BASE) : (PCIE_IO_PHY_BASE))
4359 +#define PCIE_IO_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_IO_PHY_END) : (PCIE_IO_PHY_END))
4360 +#define PCIE_APP_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_APP_LOGIC_REG) : (PCIE_APP_LOGIC_REG))
4361 +#define PCIE_RC_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_RC_CFG_BASE) : (PCIE_RC_CFG_BASE))
4362 +#define PCIE_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_PDI_BASE) : (PCIE_PDI_BASE))
4364 +/* PCIe Application Logic Register */
4365 +/* RC Core Control Register */
4366 +#define PCIE_RC_CCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x10)
4367 +/* This should be enabled after initializing configuratin registers
4368 + * Also should check link status retraining bit
4370 +#define PCIE_RC_CCR_LTSSM_ENABLE 0x00000001 /* Enable LTSSM to continue link establishment */
4372 +/* RC Core Debug Register */
4373 +#define PCIE_RC_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x14)
4374 +#define PCIE_RC_DR_DLL_UP 0x00000001 /* Data Link Layer Up */
4375 +#define PCIE_RC_DR_CURRENT_POWER_STATE 0x0000000E /* Current Power State */
4376 +#define PCIE_RC_DR_CURRENT_POWER_STATE_S 1
4377 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE 0x000001F0 /* Current LTSSM State */
4378 +#define PCIE_RC_DR_CURRENT_LTSSM_STATE_S 4
4380 +#define PCIE_RC_DR_PM_DEV_STATE 0x00000E00 /* Power Management D-State */
4381 +#define PCIE_RC_DR_PM_DEV_STATE_S 9
4383 +#define PCIE_RC_DR_PM_ENABLED 0x00001000 /* Power Management State from PMU */
4384 +#define PCIE_RC_DR_PME_EVENT_ENABLED 0x00002000 /* Power Management Event Enable State */
4385 +#define PCIE_RC_DR_AUX_POWER_ENABLED 0x00004000 /* Auxiliary Power Enable */
4387 +/* Current Power State Definition */
4389 + PCIE_RC_DR_D0 = 0,
4390 + PCIE_RC_DR_D1, /* Not supported */
4391 + PCIE_RC_DR_D2, /* Not supported */
4396 +/* PHY Link Status Register */
4397 +#define PCIE_PHY_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x18)
4398 +#define PCIE_PHY_SR_PHY_LINK_UP 0x00000001 /* PHY Link Up/Down Indicator */
4400 +/* Electromechanical Control Register */
4401 +#define PCIE_EM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x1C)
4402 +#define PCIE_EM_CR_CARD_IS_PRESENT 0x00000001 /* Card Presence Detect State */
4403 +#define PCIE_EM_CR_MRL_OPEN 0x00000002 /* MRL Sensor State */
4404 +#define PCIE_EM_CR_POWER_FAULT_SET 0x00000004 /* Power Fault Detected */
4405 +#define PCIE_EM_CR_MRL_SENSOR_SET 0x00000008 /* MRL Sensor Changed */
4406 +#define PCIE_EM_CR_PRESENT_DETECT_SET 0x00000010 /* Card Presense Detect Changed */
4407 +#define PCIE_EM_CR_CMD_CPL_INT_SET 0x00000020 /* Command Complete Interrupt */
4408 +#define PCIE_EM_CR_SYS_INTERLOCK_SET 0x00000040 /* System Electromechanical IterLock Engaged */
4409 +#define PCIE_EM_CR_ATTENTION_BUTTON_SET 0x00000080 /* Attention Button Pressed */
4411 +/* Interrupt Status Register */
4412 +#define PCIE_IR_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x20)
4413 +#define PCIE_IR_SR_PME_CAUSE_MSI 0x00000002 /* MSI caused by PME */
4414 +#define PCIE_IR_SR_HP_PME_WAKE_GEN 0x00000004 /* Hotplug PME Wake Generation */
4415 +#define PCIE_IR_SR_HP_MSI 0x00000008 /* Hotplug MSI */
4416 +#define PCIE_IR_SR_AHB_LU_ERR 0x00000030 /* AHB Bridge Lookup Error Signals */
4417 +#define PCIE_IR_SR_AHB_LU_ERR_S 4
4418 +#define PCIE_IR_SR_INT_MSG_NUM 0x00003E00 /* Interrupt Message Number */
4419 +#define PCIE_IR_SR_INT_MSG_NUM_S 9
4420 +#define PCIE_IR_SR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
4421 +#define PCIE_IR_SR_AER_INT_MSG_NUM_S 27
4423 +/* Message Control Register */
4424 +#define PCIE_MSG_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x30)
4425 +#define PCIE_MSG_CR_GEN_PME_TURN_OFF_MSG 0x00000001 /* Generate PME Turn Off Message */
4426 +#define PCIE_MSG_CR_GEN_UNLOCK_MSG 0x00000002 /* Generate Unlock Message */
4428 +#define PCIE_VDM_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x34)
4430 +/* Vendor-Defined Message Requester ID Register */
4431 +#define PCIE_VDM_RID(X) (PCIE_APP_PORT_TO_BASE (X) + 0x38)
4432 +#define PCIE_VDM_RID_VENROR_MSG_REQ_ID 0x0000FFFF
4433 +#define PCIE_VDM_RID_VDMRID_S 0
4435 +/* ASPM Control Register */
4436 +#define PCIE_ASPM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x40)
4437 +#define PCIE_ASPM_CR_HOT_RST 0x00000001 /* Hot Reset Request to the downstream device */
4438 +#define PCIE_ASPM_CR_REQ_EXIT_L1 0x00000002 /* Request to Exit L1 */
4439 +#define PCIE_ASPM_CR_REQ_ENTER_L1 0x00000004 /* Request to Enter L1 */
4441 +/* Vendor Message DW0 Register */
4442 +#define PCIE_VM_MSG_DW0(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x50)
4443 +#define PCIE_VM_MSG_DW0_TYPE 0x0000001F /* Message type */
4444 +#define PCIE_VM_MSG_DW0_TYPE_S 0
4445 +#define PCIE_VM_MSG_DW0_FORMAT 0x00000060 /* Format */
4446 +#define PCIE_VM_MSG_DW0_FORMAT_S 5
4447 +#define PCIE_VM_MSG_DW0_TC 0x00007000 /* Traffic Class */
4448 +#define PCIE_VM_MSG_DW0_TC_S 12
4449 +#define PCIE_VM_MSG_DW0_ATTR 0x000C0000 /* Atrributes */
4450 +#define PCIE_VM_MSG_DW0_ATTR_S 18
4451 +#define PCIE_VM_MSG_DW0_EP_TLP 0x00100000 /* Poisoned TLP */
4452 +#define PCIE_VM_MSG_DW0_TD 0x00200000 /* TLP Digest */
4453 +#define PCIE_VM_MSG_DW0_LEN 0xFFC00000 /* Length */
4454 +#define PCIE_VM_MSG_DW0_LEN_S 22
4456 +/* Format Definition */
4458 + PCIE_VM_MSG_FORMAT_00 = 0, /* 3DW Hdr, no data*/
4459 + PCIE_VM_MSG_FORMAT_01, /* 4DW Hdr, no data */
4460 + PCIE_VM_MSG_FORMAT_10, /* 3DW Hdr, with data */
4461 + PCIE_VM_MSG_FORMAT_11, /* 4DW Hdr, with data */
4464 +/* Traffic Class Definition */
4466 + PCIE_VM_MSG_TC0 = 0,
4476 +/* Attributes Definition */
4478 + PCIE_VM_MSG_ATTR_00 = 0, /* RO and No Snoop cleared */
4479 + PCIE_VM_MSG_ATTR_01, /* RO cleared , No Snoop set */
4480 + PCIE_VM_MSG_ATTR_10, /* RO set, No Snoop cleared*/
4481 + PCIE_VM_MSG_ATTR_11, /* RO and No Snoop set */
4484 +/* Payload Size Definition */
4485 +#define PCIE_VM_MSG_LEN_MIN 0
4486 +#define PCIE_VM_MSG_LEN_MAX 1024
4488 +/* Vendor Message DW1 Register */
4489 +#define PCIE_VM_MSG_DW1(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x54)
4490 +#define PCIE_VM_MSG_DW1_FUNC_NUM 0x00000070 /* Function Number */
4491 +#define PCIE_VM_MSG_DW1_FUNC_NUM_S 8
4492 +#define PCIE_VM_MSG_DW1_CODE 0x00FF0000 /* Message Code */
4493 +#define PCIE_VM_MSG_DW1_CODE_S 16
4494 +#define PCIE_VM_MSG_DW1_TAG 0xFF000000 /* Tag */
4495 +#define PCIE_VM_MSG_DW1_TAG_S 24
4497 +#define PCIE_VM_MSG_DW2(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x58)
4498 +#define PCIE_VM_MSG_DW3(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x5C)
4500 +/* Vendor Message Request Register */
4501 +#define PCIE_VM_MSG_REQR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x60)
4502 +#define PCIE_VM_MSG_REQR_REQ 0x00000001 /* Vendor Message Request */
4505 +/* AHB Slave Side Band Control Register */
4506 +#define PCIE_AHB_SSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x70)
4507 +#define PCIE_AHB_SSB_REQ_BCM 0x00000001 /* Slave Reques BCM filed */
4508 +#define PCIE_AHB_SSB_REQ_EP 0x00000002 /* Slave Reques EP filed */
4509 +#define PCIE_AHB_SSB_REQ_TD 0x00000004 /* Slave Reques TD filed */
4510 +#define PCIE_AHB_SSB_REQ_ATTR 0x00000018 /* Slave Reques Attribute number */
4511 +#define PCIE_AHB_SSB_REQ_ATTR_S 3
4512 +#define PCIE_AHB_SSB_REQ_TC 0x000000E0 /* Slave Request TC Field */
4513 +#define PCIE_AHB_SSB_REQ_TC_S 5
4515 +/* AHB Master SideBand Ctrl Register */
4516 +#define PCIE_AHB_MSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x74)
4517 +#define PCIE_AHB_MSB_RESP_ATTR 0x00000003 /* Master Response Attribute number */
4518 +#define PCIE_AHB_MSB_RESP_ATTR_S 0
4519 +#define PCIE_AHB_MSB_RESP_BAD_EOT 0x00000004 /* Master Response Badeot filed */
4520 +#define PCIE_AHB_MSB_RESP_BCM 0x00000008 /* Master Response BCM filed */
4521 +#define PCIE_AHB_MSB_RESP_EP 0x00000010 /* Master Response EP filed */
4522 +#define PCIE_AHB_MSB_RESP_TD 0x00000020 /* Master Response TD filed */
4523 +#define PCIE_AHB_MSB_RESP_FUN_NUM 0x000003C0 /* Master Response Function number */
4524 +#define PCIE_AHB_MSB_RESP_FUN_NUM_S 6
4526 +/* AHB Control Register, fixed bus enumeration exception */
4527 +#define PCIE_AHB_CTRL(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x78)
4528 +#define PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS 0x00000001
4530 +/* Interrupt Enalbe Register */
4531 +#define PCIE_IRNEN(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF4)
4532 +#define PCIE_IRNCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF8)
4533 +#define PCIE_IRNICR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xFC)
4535 +/* PCIe interrupt enable/control/capture register definition */
4536 +#define PCIE_IRN_AER_REPORT 0x00000001 /* AER Interrupt */
4537 +#define PCIE_IRN_AER_MSIX 0x00000002 /* Advanced Error MSI-X Interrupt */
4538 +#define PCIE_IRN_PME 0x00000004 /* PME Interrupt */
4539 +#define PCIE_IRN_HOTPLUG 0x00000008 /* Hotplug Interrupt */
4540 +#define PCIE_IRN_RX_VDM_MSG 0x00000010 /* Vendor-Defined Message Interrupt */
4541 +#define PCIE_IRN_RX_CORRECTABLE_ERR_MSG 0x00000020 /* Correctable Error Message Interrupt */
4542 +#define PCIE_IRN_RX_NON_FATAL_ERR_MSG 0x00000040 /* Non-fatal Error Message */
4543 +#define PCIE_IRN_RX_FATAL_ERR_MSG 0x00000080 /* Fatal Error Message */
4544 +#define PCIE_IRN_RX_PME_MSG 0x00000100 /* PME Message Interrupt */
4545 +#define PCIE_IRN_RX_PME_TURNOFF_ACK 0x00000200 /* PME Turnoff Ack Message Interrupt */
4546 +#define PCIE_IRN_AHB_BR_FATAL_ERR 0x00000400 /* AHB Fatal Error Interrupt */
4547 +#define PCIE_IRN_LINK_AUTO_BW_STATUS 0x00000800 /* Link Auto Bandwidth Status Interrupt */
4548 +#define PCIE_IRN_BW_MGT 0x00001000 /* Bandwidth Managment Interrupt */
4549 +#define PCIE_IRN_INTA 0x00002000 /* INTA */
4550 +#define PCIE_IRN_INTB 0x00004000 /* INTB */
4551 +#define PCIE_IRN_INTC 0x00008000 /* INTC */
4552 +#define PCIE_IRN_INTD 0x00010000 /* INTD */
4553 +#define PCIE_IRN_WAKEUP 0x00020000 /* Wake up Interrupt */
4555 +#define PCIE_RC_CORE_COMBINED_INT (PCIE_IRN_AER_REPORT | PCIE_IRN_AER_MSIX | PCIE_IRN_PME | \
4556 + PCIE_IRN_HOTPLUG | PCIE_IRN_RX_VDM_MSG | PCIE_IRN_RX_CORRECTABLE_ERR_MSG |\
4557 + PCIE_IRN_RX_NON_FATAL_ERR_MSG | PCIE_IRN_RX_FATAL_ERR_MSG | \
4558 + PCIE_IRN_RX_PME_MSG | PCIE_IRN_RX_PME_TURNOFF_ACK | PCIE_IRN_AHB_BR_FATAL_ERR | \
4559 + PCIE_IRN_LINK_AUTO_BW_STATUS | PCIE_IRN_BW_MGT)
4560 +/* PCIe RC Configuration Register */
4561 +#define PCIE_VDID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x00)
4563 +/* Bit definition from pci_reg.h */
4564 +#define PCIE_PCICMDSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x04)
4565 +#define PCIE_CCRID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x08)
4566 +#define PCIE_CLSLTHTBR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x0C) /* EP only */
4567 +/* BAR0, BAR1,Only necessary if the bridges implements a device-specific register set or memory buffer */
4568 +#define PCIE_BAR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10) /* Not used*/
4569 +#define PCIE_BAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14) /* Not used */
4571 +#define PCIE_BNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x18) /* Mandatory */
4572 +/* Bus Number Register bits */
4573 +#define PCIE_BNR_PRIMARY_BUS_NUM 0x000000FF
4574 +#define PCIE_BNR_PRIMARY_BUS_NUM_S 0
4575 +#define PCIE_PNR_SECONDARY_BUS_NUM 0x0000FF00
4576 +#define PCIE_PNR_SECONDARY_BUS_NUM_S 8
4577 +#define PCIE_PNR_SUB_BUS_NUM 0x00FF0000
4578 +#define PCIE_PNR_SUB_BUS_NUM_S 16
4580 +/* IO Base/Limit Register bits */
4581 +#define PCIE_IOBLSECS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x1C) /* RC only */
4582 +#define PCIE_IOBLSECS_32BIT_IO_ADDR 0x00000001
4583 +#define PCIE_IOBLSECS_IO_BASE_ADDR 0x000000F0
4584 +#define PCIE_IOBLSECS_IO_BASE_ADDR_S 4
4585 +#define PCIE_IOBLSECS_32BIT_IOLIMT 0x00000100
4586 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR 0x0000F000
4587 +#define PCIE_IOBLSECS_IO_LIMIT_ADDR_S 12
4589 +/* Non-prefetchable Memory Base/Limit Register bit */
4590 +#define PCIE_MBML(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x20) /* RC only */
4591 +#define PCIE_MBML_MEM_BASE_ADDR 0x0000FFF0
4592 +#define PCIE_MBML_MEM_BASE_ADDR_S 4
4593 +#define PCIE_MBML_MEM_LIMIT_ADDR 0xFFF00000
4594 +#define PCIE_MBML_MEM_LIMIT_ADDR_S 20
4596 +/* Prefetchable Memory Base/Limit Register bit */
4597 +#define PCIE_PMBL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x24) /* RC only */
4598 +#define PCIE_PMBL_64BIT_ADDR 0x00000001
4599 +#define PCIE_PMBL_UPPER_12BIT 0x0000FFF0
4600 +#define PCIE_PMBL_UPPER_12BIT_S 4
4601 +#define PCIE_PMBL_E64MA 0x00010000
4602 +#define PCIE_PMBL_END_ADDR 0xFFF00000
4603 +#define PCIE_PMBL_END_ADDR_S 20
4604 +#define PCIE_PMBU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x28) /* RC only */
4605 +#define PCIE_PMLU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x2C) /* RC only */
4607 +/* I/O Base/Limit Upper 16 bits register */
4608 +#define PCIE_IO_BANDL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x30) /* RC only */
4609 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE 0x0000FFFF
4610 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE_S 0
4611 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT 0xFFFF0000
4612 +#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT_S 16
4614 +#define PCIE_CPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x34)
4615 +#define PCIE_EBBAR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x38)
4617 +/* Interrupt and Secondary Bridge Control Register */
4618 +#define PCIE_INTRBCTRL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x3C)
4620 +#define PCIE_INTRBCTRL_INT_LINE 0x000000FF
4621 +#define PCIE_INTRBCTRL_INT_LINE_S 0
4622 +#define PCIE_INTRBCTRL_INT_PIN 0x0000FF00
4623 +#define PCIE_INTRBCTRL_INT_PIN_S 8
4624 +#define PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE 0x00010000 /* #PERR */
4625 +#define PCIE_INTRBCTRL_SERR_ENABLE 0x00020000 /* #SERR */
4626 +#define PCIE_INTRBCTRL_ISA_ENABLE 0x00040000 /* ISA enable, IO 64KB only */
4627 +#define PCIE_INTRBCTRL_VGA_ENABLE 0x00080000 /* VGA enable */
4628 +#define PCIE_INTRBCTRL_VGA_16BIT_DECODE 0x00100000 /* VGA 16bit decode */
4629 +#define PCIE_INTRBCTRL_RST_SECONDARY_BUS 0x00400000 /* Secondary bus rest, hot rest, 1ms */
4630 +/* Others are read only */
4632 + PCIE_INTRBCTRL_INT_NON = 0,
4633 + PCIE_INTRBCTRL_INTA,
4634 + PCIE_INTRBCTRL_INTB,
4635 + PCIE_INTRBCTRL_INTC,
4636 + PCIE_INTRBCTRL_INTD,
4639 +#define PCIE_PM_CAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x40)
4641 +/* Power Management Control and Status Register */
4642 +#define PCIE_PM_CSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x44)
4644 +#define PCIE_PM_CSR_POWER_STATE 0x00000003 /* Power State */
4645 +#define PCIE_PM_CSR_POWER_STATE_S 0
4646 +#define PCIE_PM_CSR_SW_RST 0x00000008 /* Soft Reset Enabled */
4647 +#define PCIE_PM_CSR_PME_ENABLE 0x00000100 /* PME Enable */
4648 +#define PCIE_PM_CSR_PME_STATUS 0x00008000 /* PME status */
4650 +/* MSI Capability Register for EP */
4651 +#define PCIE_MCAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x50)
4653 +#define PCIE_MCAPR_MSI_CAP_ID 0x000000FF /* MSI Capability ID */
4654 +#define PCIE_MCAPR_MSI_CAP_ID_S 0
4655 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR 0x0000FF00 /* Next Capability Pointer */
4656 +#define PCIE_MCAPR_MSI_NEXT_CAP_PTR_S 8
4657 +#define PCIE_MCAPR_MSI_ENABLE 0x00010000 /* MSI Enable */
4658 +#define PCIE_MCAPR_MULTI_MSG_CAP 0x000E0000 /* Multiple Message Capable */
4659 +#define PCIE_MCAPR_MULTI_MSG_CAP_S 17
4660 +#define PCIE_MCAPR_MULTI_MSG_ENABLE 0x00700000 /* Multiple Message Enable */
4661 +#define PCIE_MCAPR_MULTI_MSG_ENABLE_S 20
4662 +#define PCIE_MCAPR_ADDR64_CAP 0X00800000 /* 64-bit Address Capable */
4664 +/* MSI Message Address Register */
4665 +#define PCIE_MA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x54)
4667 +#define PCIE_MA_ADDR_MASK 0xFFFFFFFC /* Message Address */
4669 +/* MSI Message Upper Address Register */
4670 +#define PCIE_MUA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x58)
4672 +/* MSI Message Data Register */
4673 +#define PCIE_MD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x5C)
4675 +#define PCIE_MD_DATA 0x0000FFFF /* Message Data */
4676 +#define PCIE_MD_DATA_S 0
4678 +/* PCI Express Capability Register */
4679 +#define PCIE_XCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70)
4681 +#define PCIE_XCAP_ID 0x000000FF /* PCI Express Capability ID */
4682 +#define PCIE_XCAP_ID_S 0
4683 +#define PCIE_XCAP_NEXT_CAP 0x0000FF00 /* Next Capability Pointer */
4684 +#define PCIE_XCAP_NEXT_CAP_S 8
4685 +#define PCIE_XCAP_VER 0x000F0000 /* PCI Express Capability Version */
4686 +#define PCIE_XCAP_VER_S 16
4687 +#define PCIE_XCAP_DEV_PORT_TYPE 0x00F00000 /* Device Port Type */
4688 +#define PCIE_XCAP_DEV_PORT_TYPE_S 20
4689 +#define PCIE_XCAP_SLOT_IMPLEMENTED 0x01000000 /* Slot Implemented */
4690 +#define PCIE_XCAP_MSG_INT_NUM 0x3E000000 /* Interrupt Message Number */
4691 +#define PCIE_XCAP_MSG_INT_NUM_S 25
4693 +/* Device Capability Register */
4694 +#define PCIE_DCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74)
4696 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE 0x00000007 /* Max Payload size */
4697 +#define PCIE_DCAP_MAX_PAYLOAD_SIZE_S 0
4698 +#define PCIE_DCAP_PHANTOM_FUNC 0x00000018 /* Phanton Function, not supported */
4699 +#define PCIE_DCAP_PHANTOM_FUNC_S 3
4700 +#define PCIE_DCAP_EXT_TAG 0x00000020 /* Extended Tag Field */
4701 +#define PCIE_DCAP_EP_L0S_LATENCY 0x000001C0 /* EP L0s latency only */
4702 +#define PCIE_DCAP_EP_L0S_LATENCY_S 6
4703 +#define PCIE_DCAP_EP_L1_LATENCY 0x00000E00 /* EP L1 latency only */
4704 +#define PCIE_DCAP_EP_L1_LATENCY_S 9
4705 +#define PCIE_DCAP_ROLE_BASE_ERR_REPORT 0x00008000 /* Role Based ERR */
4707 +/* Maximum payload size supported */
4709 + PCIE_MAX_PAYLOAD_128 = 0,
4710 + PCIE_MAX_PAYLOAD_256,
4711 + PCIE_MAX_PAYLOAD_512,
4712 + PCIE_MAX_PAYLOAD_1024,
4713 + PCIE_MAX_PAYLOAD_2048,
4714 + PCIE_MAX_PAYLOAD_4096,
4717 +/* Device Control and Status Register */
4718 +#define PCIE_DCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x78)
4720 +#define PCIE_DCTLSTS_CORRECTABLE_ERR_EN 0x00000001 /* COR-ERR */
4721 +#define PCIE_DCTLSTS_NONFATAL_ERR_EN 0x00000002 /* Non-fatal ERR */
4722 +#define PCIE_DCTLSTS_FATAL_ERR_EN 0x00000004 /* Fatal ERR */
4723 +#define PCIE_DCTLSYS_UR_REQ_EN 0x00000008 /* UR ERR */
4724 +#define PCIE_DCTLSTS_RELAXED_ORDERING_EN 0x00000010 /* Enable relaxing ordering */
4725 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE 0x000000E0 /* Max payload mask */
4726 +#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE_S 5
4727 +#define PCIE_DCTLSTS_EXT_TAG_EN 0x00000100 /* Extended tag field */
4728 +#define PCIE_DCTLSTS_PHANTOM_FUNC_EN 0x00000200 /* Phantom Function Enable */
4729 +#define PCIE_DCTLSTS_AUX_PM_EN 0x00000400 /* AUX Power PM Enable */
4730 +#define PCIE_DCTLSTS_NO_SNOOP_EN 0x00000800 /* Enable no snoop, except root port*/
4731 +#define PCIE_DCTLSTS_MAX_READ_SIZE 0x00007000 /* Max Read Request size*/
4732 +#define PCIE_DCTLSTS_MAX_READ_SIZE_S 12
4733 +#define PCIE_DCTLSTS_CORRECTABLE_ERR 0x00010000 /* COR-ERR Detected */
4734 +#define PCIE_DCTLSTS_NONFATAL_ERR 0x00020000 /* Non-Fatal ERR Detected */
4735 +#define PCIE_DCTLSTS_FATAL_ER 0x00040000 /* Fatal ERR Detected */
4736 +#define PCIE_DCTLSTS_UNSUPPORTED_REQ 0x00080000 /* UR Detected */
4737 +#define PCIE_DCTLSTS_AUX_POWER 0x00100000 /* Aux Power Detected */
4738 +#define PCIE_DCTLSTS_TRANSACT_PENDING 0x00200000 /* Transaction pending */
4740 +#define PCIE_DCTLSTS_ERR_EN (PCIE_DCTLSTS_CORRECTABLE_ERR_EN | \
4741 + PCIE_DCTLSTS_NONFATAL_ERR_EN | PCIE_DCTLSTS_FATAL_ERR_EN | \
4742 + PCIE_DCTLSYS_UR_REQ_EN)
4744 +/* Link Capability Register */
4745 +#define PCIE_LCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7C)
4746 +#define PCIE_LCAP_MAX_LINK_SPEED 0x0000000F /* Max link speed, 0x1 by default */
4747 +#define PCIE_LCAP_MAX_LINK_SPEED_S 0
4748 +#define PCIE_LCAP_MAX_LENGTH_WIDTH 0x000003F0 /* Maxium Length Width */
4749 +#define PCIE_LCAP_MAX_LENGTH_WIDTH_S 4
4750 +#define PCIE_LCAP_ASPM_LEVEL 0x00000C00 /* Active State Link PM Support */
4751 +#define PCIE_LCAP_ASPM_LEVEL_S 10
4752 +#define PCIE_LCAP_L0S_EIXT_LATENCY 0x00007000 /* L0s Exit Latency */
4753 +#define PCIE_LCAP_L0S_EIXT_LATENCY_S 12
4754 +#define PCIE_LCAP_L1_EXIT_LATENCY 0x00038000 /* L1 Exit Latency */
4755 +#define PCIE_LCAP_L1_EXIT_LATENCY_S 15
4756 +#define PCIE_LCAP_CLK_PM 0x00040000 /* Clock Power Management */
4757 +#define PCIE_LCAP_SDER 0x00080000 /* Surprise Down Error Reporting */
4758 +#define PCIE_LCAP_DLL_ACTIVE_REPROT 0x00100000 /* Data Link Layer Active Reporting Capable */
4759 +#define PCIE_LCAP_PORT_NUM 0xFF0000000 /* Port number */
4760 +#define PCIE_LCAP_PORT_NUM_S 24
4762 +/* Maximum Length width definition */
4763 +#define PCIE_MAX_LENGTH_WIDTH_RES 0x00
4764 +#define PCIE_MAX_LENGTH_WIDTH_X1 0x01 /* Default */
4765 +#define PCIE_MAX_LENGTH_WIDTH_X2 0x02
4766 +#define PCIE_MAX_LENGTH_WIDTH_X4 0x04
4767 +#define PCIE_MAX_LENGTH_WIDTH_X8 0x08
4768 +#define PCIE_MAX_LENGTH_WIDTH_X12 0x0C
4769 +#define PCIE_MAX_LENGTH_WIDTH_X16 0x10
4770 +#define PCIE_MAX_LENGTH_WIDTH_X32 0x20
4772 +/* Active State Link PM definition */
4774 + PCIE_ASPM_RES0 = 0,
4775 + PCIE_ASPM_L0S_ENTRY_SUPPORT, /* L0s */
4777 + PCIE_ASPM_L0S_L1_ENTRY_SUPPORT, /* L0s and L1, default */
4780 +/* L0s Exit Latency definition */
4782 + PCIE_L0S_EIXT_LATENCY_L64NS = 0, /* < 64 ns */
4783 + PCIE_L0S_EIXT_LATENCY_B64A128, /* > 64 ns < 128 ns */
4784 + PCIE_L0S_EIXT_LATENCY_B128A256, /* > 128 ns < 256 ns */
4785 + PCIE_L0S_EIXT_LATENCY_B256A512, /* > 256 ns < 512 ns */
4786 + PCIE_L0S_EIXT_LATENCY_B512TO1U, /* > 512 ns < 1 us */
4787 + PCIE_L0S_EIXT_LATENCY_B1A2U, /* > 1 us < 2 us */
4788 + PCIE_L0S_EIXT_LATENCY_B2A4U, /* > 2 us < 4 us */
4789 + PCIE_L0S_EIXT_LATENCY_M4US, /* > 4 us */
4792 +/* L1 Exit Latency definition */
4794 + PCIE_L1_EXIT_LATENCY_L1US = 0, /* < 1 us */
4795 + PCIE_L1_EXIT_LATENCY_B1A2, /* > 1 us < 2 us */
4796 + PCIE_L1_EXIT_LATENCY_B2A4, /* > 2 us < 4 us */
4797 + PCIE_L1_EXIT_LATENCY_B4A8, /* > 4 us < 8 us */
4798 + PCIE_L1_EXIT_LATENCY_B8A16, /* > 8 us < 16 us */
4799 + PCIE_L1_EXIT_LATENCY_B16A32, /* > 16 us < 32 us */
4800 + PCIE_L1_EXIT_LATENCY_B32A64, /* > 32 us < 64 us */
4801 + PCIE_L1_EXIT_LATENCY_M64US, /* > 64 us */
4804 +/* Link Control and Status Register */
4805 +#define PCIE_LCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x80)
4806 +#define PCIE_LCTLSTS_ASPM_ENABLE 0x00000003 /* Active State Link PM Control */
4807 +#define PCIE_LCTLSTS_ASPM_ENABLE_S 0
4808 +#define PCIE_LCTLSTS_RCB128 0x00000008 /* Read Completion Boundary 128*/
4809 +#define PCIE_LCTLSTS_LINK_DISABLE 0x00000010 /* Link Disable */
4810 +#define PCIE_LCTLSTS_RETRIAN_LINK 0x00000020 /* Retrain Link */
4811 +#define PCIE_LCTLSTS_COM_CLK_CFG 0x00000040 /* Common Clock Configuration */
4812 +#define PCIE_LCTLSTS_EXT_SYNC 0x00000080 /* Extended Synch */
4813 +#define PCIE_LCTLSTS_CLK_PM_EN 0x00000100 /* Enable Clock Powerm Management */
4814 +#define PCIE_LCTLSTS_LINK_SPEED 0x000F0000 /* Link Speed */
4815 +#define PCIE_LCTLSTS_LINK_SPEED_S 16
4816 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH 0x03F00000 /* Negotiated Link Width */
4817 +#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH_S 20
4818 +#define PCIE_LCTLSTS_RETRAIN_PENDING 0x08000000 /* Link training is ongoing */
4819 +#define PCIE_LCTLSTS_SLOT_CLK_CFG 0x10000000 /* Slot Clock Configuration */
4820 +#define PCIE_LCTLSTS_DLL_ACTIVE 0x20000000 /* Data Link Layer Active */
4822 +/* Slot Capabilities Register */
4823 +#define PCIE_SLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x84)
4825 +/* Slot Capabilities */
4826 +#define PCIE_SLCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x88)
4828 +/* Root Control and Capability Register */
4829 +#define PCIE_RCTLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x8C)
4830 +#define PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR 0x00000001 /* #SERR on COR-ERR */
4831 +#define PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR 0x00000002 /* #SERR on Non-Fatal ERR */
4832 +#define PCIE_RCTLCAP_SERR_ON_FATAL_ERR 0x00000004 /* #SERR on Fatal ERR */
4833 +#define PCIE_RCTLCAP_PME_INT_EN 0x00000008 /* PME Interrupt Enable */
4834 +#define PCIE_RCTLCAP_SERR_ENABLE (PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR | \
4835 + PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR | PCIE_RCTLCAP_SERR_ON_FATAL_ERR)
4836 +/* Root Status Register */
4837 +#define PCIE_RSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x90)
4838 +#define PCIE_RSTS_PME_REQ_ID 0x0000FFFF /* PME Request ID */
4839 +#define PCIE_RSTS_PME_REQ_ID_S 0
4840 +#define PCIE_RSTS_PME_STATUS 0x00010000 /* PME Status */
4841 +#define PCIE_RSTS_PME_PENDING 0x00020000 /* PME Pending */
4843 +/* PCI Express Enhanced Capability Header */
4844 +#define PCIE_ENHANCED_CAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x100)
4845 +#define PCIE_ENHANCED_CAP_ID 0x0000FFFF /* PCI Express Extended Capability ID */
4846 +#define PCIE_ENHANCED_CAP_ID_S 0
4847 +#define PCIE_ENHANCED_CAP_VER 0x000F0000 /* Capability Version */
4848 +#define PCIE_ENHANCED_CAP_VER_S 16
4849 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET 0xFFF00000 /* Next Capability Offset */
4850 +#define PCIE_ENHANCED_CAP_NEXT_OFFSET_S 20
4852 +/* Uncorrectable Error Status Register */
4853 +#define PCIE_UES_R(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x104)
4854 +#define PCIE_DATA_LINK_PROTOCOL_ERR 0x00000010 /* Data Link Protocol Error Status */
4855 +#define PCIE_SURPRISE_DOWN_ERROR 0x00000020 /* Surprise Down Error Status */
4856 +#define PCIE_POISONED_TLP 0x00001000 /* Poisoned TLP Status */
4857 +#define PCIE_FC_PROTOCOL_ERR 0x00002000 /* Flow Control Protocol Error Status */
4858 +#define PCIE_COMPLETION_TIMEOUT 0x00004000 /* Completion Timeout Status */
4859 +#define PCIE_COMPLETOR_ABORT 0x00008000 /* Completer Abort Error */
4860 +#define PCIE_UNEXPECTED_COMPLETION 0x00010000 /* Unexpected Completion Status */
4861 +#define PCIE_RECEIVER_OVERFLOW 0x00020000 /* Receive Overflow Status */
4862 +#define PCIE_MALFORNED_TLP 0x00040000 /* Malformed TLP Stauts */
4863 +#define PCIE_ECRC_ERR 0x00080000 /* ECRC Error Stauts */
4864 +#define PCIE_UR_REQ 0x00100000 /* Unsupported Request Error Status */
4865 +#define PCIE_ALL_UNCORRECTABLE_ERR (PCIE_DATA_LINK_PROTOCOL_ERR | PCIE_SURPRISE_DOWN_ERROR | \
4866 + PCIE_POISONED_TLP | PCIE_FC_PROTOCOL_ERR | PCIE_COMPLETION_TIMEOUT | \
4867 + PCIE_COMPLETOR_ABORT | PCIE_UNEXPECTED_COMPLETION | PCIE_RECEIVER_OVERFLOW |\
4868 + PCIE_MALFORNED_TLP | PCIE_ECRC_ERR | PCIE_UR_REQ)
4870 +/* Uncorrectable Error Mask Register, Mask means no report */
4871 +#define PCIE_UEMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x108)
4873 +/* Uncorrectable Error Severity Register */
4874 +#define PCIE_UESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10C)
4876 +/* Correctable Error Status Register */
4877 +#define PCIE_CESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x110)
4878 +#define PCIE_RX_ERR 0x00000001 /* Receive Error Status */
4879 +#define PCIE_BAD_TLP 0x00000040 /* Bad TLP Status */
4880 +#define PCIE_BAD_DLLP 0x00000080 /* Bad DLLP Status */
4881 +#define PCIE_REPLAY_NUM_ROLLOVER 0x00000100 /* Replay Number Rollover Status */
4882 +#define PCIE_REPLAY_TIMER_TIMEOUT_ERR 0x00001000 /* Reply Timer Timeout Status */
4883 +#define PCIE_ADVISORY_NONFTAL_ERR 0x00002000 /* Advisory Non-Fatal Error Status */
4884 +#define PCIE_CORRECTABLE_ERR (PCIE_RX_ERR | PCIE_BAD_TLP | PCIE_BAD_DLLP | PCIE_REPLAY_NUM_ROLLOVER |\
4885 + PCIE_REPLAY_TIMER_TIMEOUT_ERR | PCIE_ADVISORY_NONFTAL_ERR)
4887 +/* Correctable Error Mask Register */
4888 +#define PCIE_CEMR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x114)
4890 +/* Advanced Error Capabilities and Control Register */
4891 +#define PCIE_AECCR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x118)
4892 +#define PCIE_AECCR_FIRST_ERR_PTR 0x0000001F /* First Error Pointer */
4893 +#define PCIE_AECCR_FIRST_ERR_PTR_S 0
4894 +#define PCIE_AECCR_ECRC_GEN_CAP 0x00000020 /* ECRC Generation Capable */
4895 +#define PCIE_AECCR_ECRC_GEN_EN 0x00000040 /* ECRC Generation Enable */
4896 +#define PCIE_AECCR_ECRC_CHECK_CAP 0x00000080 /* ECRC Check Capable */
4897 +#define PCIE_AECCR_ECRC_CHECK_EN 0x00000100 /* ECRC Check Enable */
4899 +/* Header Log Register 1 */
4900 +#define PCIE_HLR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x11C)
4902 +/* Header Log Register 2 */
4903 +#define PCIE_HLR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x120)
4905 +/* Header Log Register 3 */
4906 +#define PCIE_HLR3(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x124)
4908 +/* Header Log Register 4 */
4909 +#define PCIE_HLR4(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x128)
4911 +/* Root Error Command Register */
4912 +#define PCIE_RECR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x12C)
4913 +#define PCIE_RECR_CORRECTABLE_ERR_REPORT_EN 0x00000001 /* COR-ERR */
4914 +#define PCIE_RECR_NONFATAL_ERR_REPORT_EN 0x00000002 /* Non-Fatal ERR */
4915 +#define PCIE_RECR_FATAL_ERR_REPORT_EN 0x00000004 /* Fatal ERR */
4916 +#define PCIE_RECR_ERR_REPORT_EN (PCIE_RECR_CORRECTABLE_ERR_REPORT_EN | \
4917 + PCIE_RECR_NONFATAL_ERR_REPORT_EN | PCIE_RECR_FATAL_ERR_REPORT_EN)
4919 +/* Root Error Status Register */
4920 +#define PCIE_RESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x130)
4921 +#define PCIE_RESR_CORRECTABLE_ERR 0x00000001 /* COR-ERR Receveid */
4922 +#define PCIE_RESR_MULTI_CORRECTABLE_ERR 0x00000002 /* Multiple COR-ERR Received */
4923 +#define PCIE_RESR_FATAL_NOFATAL_ERR 0x00000004 /* ERR Fatal/Non-Fatal Received */
4924 +#define PCIE_RESR_MULTI_FATAL_NOFATAL_ERR 0x00000008 /* Multiple ERR Fatal/Non-Fatal Received */
4925 +#define PCIE_RESR_FIRST_UNCORRECTABLE_FATAL_ERR 0x00000010 /* First UN-COR Fatal */
4926 +#define PCIR_RESR_NON_FATAL_ERR 0x00000020 /* Non-Fatal Error Message Received */
4927 +#define PCIE_RESR_FATAL_ERR 0x00000040 /* Fatal Message Received */
4928 +#define PCIE_RESR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */
4929 +#define PCIE_RESR_AER_INT_MSG_NUM_S 27
4931 +/* Error Source Indentification Register */
4932 +#define PCIE_ESIR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x134)
4933 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID 0x0000FFFF
4934 +#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID_S 0
4935 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID 0xFFFF0000
4936 +#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID_S 16
4938 +/* VC Enhanced Capability Header */
4939 +#define PCIE_VC_ECH(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x140)
4941 +/* Port VC Capability Register */
4942 +#define PCIE_PVC1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x144)
4943 +#define PCIE_PVC1_EXT_VC_CNT 0x00000007 /* Extended VC Count */
4944 +#define PCIE_PVC1_EXT_VC_CNT_S 0
4945 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT 0x00000070 /* Low Priority Extended VC Count */
4946 +#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT_S 4
4947 +#define PCIE_PVC1_REF_CLK 0x00000300 /* Reference Clock */
4948 +#define PCIE_PVC1_REF_CLK_S 8
4949 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE 0x00000C00 /* Port Arbitration Table Entry Size */
4950 +#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE_S 10
4952 +/* Extended Virtual Channel Count Defintion */
4953 +#define PCIE_EXT_VC_CNT_MIN 0
4954 +#define PCIE_EXT_VC_CNT_MAX 7
4956 +/* Port Arbitration Table Entry Size Definition */
4958 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S1BIT = 0,
4959 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S2BIT,
4960 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S4BIT,
4961 + PCIE_PORT_ARB_TAB_ENTRY_SIZE_S8BIT,
4964 +/* Port VC Capability Register 2 */
4965 +#define PCIE_PVC2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x148)
4966 +#define PCIE_PVC2_VC_ARB_16P_FIXED_WRR 0x00000001 /* HW Fixed arbitration, 16 phase WRR */
4967 +#define PCIE_PVC2_VC_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
4968 +#define PCIE_PVC2_VC_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
4969 +#define PCIE_PVC2_VC_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
4970 +#define PCIE_PVC2_VC_ARB_WRR 0x0000000F
4971 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET 0xFF000000 /* VC arbitration table offset, not support */
4972 +#define PCIE_PVC2_VC_ARB_TAB_OFFSET_S 24
4974 +/* Port VC Control and Status Register */
4975 +#define PCIE_PVCCRSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14C)
4976 +#define PCIE_PVCCRSR_LOAD_VC_ARB_TAB 0x00000001 /* Load VC Arbitration Table */
4977 +#define PCIE_PVCCRSR_VC_ARB_SEL 0x0000000E /* VC Arbitration Select */
4978 +#define PCIE_PVCCRSR_VC_ARB_SEL_S 1
4979 +#define PCIE_PVCCRSR_VC_ARB_TAB_STATUS 0x00010000 /* Arbitration Status */
4981 +/* VC0 Resource Capability Register */
4982 +#define PCIE_VC0_RC(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x150)
4983 +#define PCIE_VC0_RC_PORT_ARB_HW_FIXED 0x00000001 /* HW Fixed arbitration */
4984 +#define PCIE_VC0_RC_PORT_ARB_32P_WRR 0x00000002 /* 32 phase WRR */
4985 +#define PCIE_VC0_RC_PORT_ARB_64P_WRR 0x00000004 /* 64 phase WRR */
4986 +#define PCIE_VC0_RC_PORT_ARB_128P_WRR 0x00000008 /* 128 phase WRR */
4987 +#define PCIE_VC0_RC_PORT_ARB_TM_128P_WRR 0x00000010 /* Time-based 128 phase WRR */
4988 +#define PCIE_VC0_RC_PORT_ARB_TM_256P_WRR 0x00000020 /* Time-based 256 phase WRR */
4989 +#define PCIE_VC0_RC_PORT_ARB (PCIE_VC0_RC_PORT_ARB_HW_FIXED | PCIE_VC0_RC_PORT_ARB_32P_WRR |\
4990 + PCIE_VC0_RC_PORT_ARB_64P_WRR | PCIE_VC0_RC_PORT_ARB_128P_WRR | \
4991 + PCIE_VC0_RC_PORT_ARB_TM_128P_WRR | PCIE_VC0_RC_PORT_ARB_TM_256P_WRR)
4993 +#define PCIE_VC0_RC_REJECT_SNOOP 0x00008000 /* Reject Snoop Transactioin */
4994 +#define PCIE_VC0_RC_MAX_TIMESLOTS 0x007F0000 /* Maximum time Slots */
4995 +#define PCIE_VC0_RC_MAX_TIMESLOTS_S 16
4996 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET 0xFF000000 /* Port Arbitration Table Offset */
4997 +#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET_S 24
4999 +/* VC0 Resource Control Register */
5000 +#define PCIE_VC0_RC0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x154)
5001 +#define PCIE_VC0_RC0_TVM0 0x00000001 /* TC0 and VC0 */
5002 +#define PCIE_VC0_RC0_TVM1 0x00000002 /* TC1 and VC1 */
5003 +#define PCIE_VC0_RC0_TVM2 0x00000004 /* TC2 and VC2 */
5004 +#define PCIE_VC0_RC0_TVM3 0x00000008 /* TC3 and VC3 */
5005 +#define PCIE_VC0_RC0_TVM4 0x00000010 /* TC4 and VC4 */
5006 +#define PCIE_VC0_RC0_TVM5 0x00000020 /* TC5 and VC5 */
5007 +#define PCIE_VC0_RC0_TVM6 0x00000040 /* TC6 and VC6 */
5008 +#define PCIE_VC0_RC0_TVM7 0x00000080 /* TC7 and VC7 */
5009 +#define PCIE_VC0_RC0_TC_VC 0x000000FF /* TC/VC mask */
5011 +#define PCIE_VC0_RC0_LOAD_PORT_ARB_TAB 0x00010000 /* Load Port Arbitration Table */
5012 +#define PCIE_VC0_RC0_PORT_ARB_SEL 0x000E0000 /* Port Arbitration Select */
5013 +#define PCIE_VC0_RC0_PORT_ARB_SEL_S 17
5014 +#define PCIE_VC0_RC0_VC_ID 0x07000000 /* VC ID */
5015 +#define PCIE_VC0_RC0_VC_ID_S 24
5016 +#define PCIE_VC0_RC0_VC_EN 0x80000000 /* VC Enable */
5018 +/* VC0 Resource Status Register */
5019 +#define PCIE_VC0_RSR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x158)
5020 +#define PCIE_VC0_RSR0_PORT_ARB_TAB_STATUS 0x00010000 /* Port Arbitration Table Status,not used */
5021 +#define PCIE_VC0_RSR0_VC_NEG_PENDING 0x00020000 /* VC Negotiation Pending */
5023 +/* Ack Latency Timer and Replay Timer Register */
5024 +#define PCIE_ALTRT(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x700)
5025 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT 0x0000FFFF /* Round Trip Latency Time Limit */
5026 +#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT_S 0
5027 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT 0xFFFF0000 /* Replay Time Limit */
5028 +#define PCIE_ALTRT_REPLAY_TIME_LIMIT_S 16
5030 +/* Other Message Register */
5031 +#define PCIE_OMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x704)
5033 +/* Port Force Link Register */
5034 +#define PCIE_PFLR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x708)
5035 +#define PCIE_PFLR_LINK_NUM 0x000000FF /* Link Number */
5036 +#define PCIE_PFLR_LINK_NUM_S 0
5037 +#define PCIE_PFLR_FORCE_LINK 0x00008000 /* Force link */
5038 +#define PCIE_PFLR_LINK_STATE 0x003F0000 /* Link State */
5039 +#define PCIE_PFLR_LINK_STATE_S 16
5040 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT 0xFF000000 /* Low Power Entrance Count, only for EP */
5041 +#define PCIE_PFLR_LOW_POWER_ENTRY_CNT_S 24
5043 +/* Ack Frequency Register */
5044 +#define PCIE_AFR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70C)
5045 +#define PCIE_AFR_AF 0x000000FF /* Ack Frequency */
5046 +#define PCIE_AFR_AF_S 0
5047 +#define PCIE_AFR_FTS_NUM 0x0000FF00 /* The number of Fast Training Sequence from L0S to L0 */
5048 +#define PCIE_AFR_FTS_NUM_S 8
5049 +#define PCIE_AFR_COM_FTS_NUM 0x00FF0000 /* N_FTS; when common clock is used*/
5050 +#define PCIE_AFR_COM_FTS_NUM_S 16
5051 +#define PCIE_AFR_L0S_ENTRY_LATENCY 0x07000000 /* L0s Entrance Latency */
5052 +#define PCIE_AFR_L0S_ENTRY_LATENCY_S 24
5053 +#define PCIE_AFR_L1_ENTRY_LATENCY 0x38000000 /* L1 Entrance Latency */
5054 +#define PCIE_AFR_L1_ENTRY_LATENCY_S 27
5055 +#define PCIE_AFR_FTS_NUM_DEFAULT 32
5056 +#define PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT 7
5057 +#define PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT 5
5059 +/* Port Link Control Register */
5060 +#define PCIE_PLCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x710)
5061 +#define PCIE_PLCR_OTHER_MSG_REQ 0x00000001 /* Other Message Request */
5062 +#define PCIE_PLCR_SCRAMBLE_DISABLE 0x00000002 /* Scramble Disable */
5063 +#define PCIE_PLCR_LOOPBACK_EN 0x00000004 /* Loopback Enable */
5064 +#define PCIE_PLCR_LTSSM_HOT_RST 0x00000008 /* Force LTSSM to the hot reset */
5065 +#define PCIE_PLCR_DLL_LINK_EN 0x00000020 /* Enable Link initialization */
5066 +#define PCIE_PLCR_FAST_LINK_SIM_EN 0x00000080 /* Sets all internal timers to fast mode for simulation purposes */
5067 +#define PCIE_PLCR_LINK_MODE 0x003F0000 /* Link Mode Enable Mask */
5068 +#define PCIE_PLCR_LINK_MODE_S 16
5069 +#define PCIE_PLCR_CORRUPTED_CRC_EN 0x02000000 /* Enabled Corrupt CRC */
5071 +/* Lane Skew Register */
5072 +#define PCIE_LSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x714)
5073 +#define PCIE_LSR_LANE_SKEW_NUM 0x00FFFFFF /* Insert Lane Skew for Transmit, not applicable */
5074 +#define PCIE_LSR_LANE_SKEW_NUM_S 0
5075 +#define PCIE_LSR_FC_DISABLE 0x01000000 /* Disable of Flow Control */
5076 +#define PCIE_LSR_ACKNAK_DISABLE 0x02000000 /* Disable of Ack/Nak */
5077 +#define PCIE_LSR_LANE_DESKEW_DISABLE 0x80000000 /* Disable of Lane-to-Lane Skew */
5079 +/* Symbol Number Register */
5080 +#define PCIE_SNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x718)
5081 +#define PCIE_SNR_TS 0x0000000F /* Number of TS Symbol */
5082 +#define PCIE_SNR_TS_S 0
5083 +#define PCIE_SNR_SKP 0x00000700 /* Number of SKP Symbol */
5084 +#define PCIE_SNR_SKP_S 8
5085 +#define PCIE_SNR_REPLAY_TIMER 0x0007C000 /* Timer Modifier for Replay Timer */
5086 +#define PCIE_SNR_REPLAY_TIMER_S 14
5087 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER 0x00F80000 /* Timer Modifier for Ack/Nak Latency Timer */
5088 +#define PCIE_SNR_ACKNAK_LATENCY_TIMER_S 19
5089 +#define PCIE_SNR_FC_TIMER 0x1F000000 /* Timer Modifier for Flow Control Watchdog Timer */
5090 +#define PCIE_SNR_FC_TIMER_S 28
5092 +/* Symbol Timer Register and Filter Mask Register 1 */
5093 +#define PCIE_STRFMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x71C)
5094 +#define PCIE_STRFMR_SKP_INTERVAL 0x000007FF /* SKP lnterval Value */
5095 +#define PCIE_STRFMR_SKP_INTERVAL_S 0
5096 +#define PCIE_STRFMR_FC_WDT_DISABLE 0x00008000 /* Disable of FC Watchdog Timer */
5097 +#define PCIE_STRFMR_TLP_FUNC_MISMATCH_OK 0x00010000 /* Mask Function Mismatch Filtering for Incoming Requests */
5098 +#define PCIE_STRFMR_POISONED_TLP_OK 0x00020000 /* Mask Poisoned TLP Filtering */
5099 +#define PCIE_STRFMR_BAR_MATCH_OK 0x00040000 /* Mask BAR Match Filtering */
5100 +#define PCIE_STRFMR_TYPE1_CFG_REQ_OK 0x00080000 /* Mask Type 1 Configuration Request Filtering */
5101 +#define PCIE_STRFMR_LOCKED_REQ_OK 0x00100000 /* Mask Locked Request Filtering */
5102 +#define PCIE_STRFMR_CPL_TAG_ERR_RULES_OK 0x00200000 /* Mask Tag Error Rules for Received Completions */
5103 +#define PCIE_STRFMR_CPL_REQUESTOR_ID_MISMATCH_OK 0x00400000 /* Mask Requester ID Mismatch Error for Received Completions */
5104 +#define PCIE_STRFMR_CPL_FUNC_MISMATCH_OK 0x00800000 /* Mask Function Mismatch Error for Received Completions */
5105 +#define PCIE_STRFMR_CPL_TC_MISMATCH_OK 0x01000000 /* Mask Traffic Class Mismatch Error for Received Completions */
5106 +#define PCIE_STRFMR_CPL_ATTR_MISMATCH_OK 0x02000000 /* Mask Attribute Mismatch Error for Received Completions */
5107 +#define PCIE_STRFMR_CPL_LENGTH_MISMATCH_OK 0x04000000 /* Mask Length Mismatch Error for Received Completions */
5108 +#define PCIE_STRFMR_TLP_ECRC_ERR_OK 0x08000000 /* Mask ECRC Error Filtering */
5109 +#define PCIE_STRFMR_CPL_TLP_ECRC_OK 0x10000000 /* Mask ECRC Error Filtering for Completions */
5110 +#define PCIE_STRFMR_RX_TLP_MSG_NO_DROP 0x20000000 /* Send Message TLPs */
5111 +#define PCIE_STRFMR_RX_IO_TRANS_ENABLE 0x40000000 /* Mask Filtering of received I/O Requests */
5112 +#define PCIE_STRFMR_RX_CFG_TRANS_ENABLE 0x80000000 /* Mask Filtering of Received Configuration Requests */
5114 +#define PCIE_DEF_SKP_INTERVAL 700 /* 1180 ~1538 , 125MHz * 2, 250MHz * 1 */
5116 +/* Filter Masker Register 2 */
5117 +#define PCIE_FMR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x720)
5118 +#define PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1 0x00000001 /* Mask RADM Filtering and Error Handling Rules */
5119 +#define PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 0x00000002 /* Mask RADM Filtering and Error Handling Rules */
5121 +/* Debug Register 0 */
5122 +#define PCIE_DBR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x728)
5124 +/* Debug Register 1 */
5125 +#define PCIE_DBR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x72C)
5127 +/* Transmit Posted FC Credit Status Register */
5128 +#define PCIE_TPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x730)
5129 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS 0x00000FFF /* Transmit Posted Data FC Credits */
5130 +#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS_S 0
5131 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS 0x000FF000 /* Transmit Posted Header FC Credits */
5132 +#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS_S 12
5134 +/* Transmit Non-Posted FC Credit Status */
5135 +#define PCIE_TNPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x734)
5136 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS 0x00000FFF /* Transmit Non-Posted Data FC Credits */
5137 +#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS_S 0
5138 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS 0x000FF000 /* Transmit Non-Posted Header FC Credits */
5139 +#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS_S 12
5141 +/* Transmit Complete FC Credit Status Register */
5142 +#define PCIE_TCFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x738)
5143 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS 0x00000FFF /* Transmit Completion Data FC Credits */
5144 +#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS_S 0
5145 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS 0x000FF000 /* Transmit Completion Header FC Credits */
5146 +#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS_S 12
5148 +/* Queue Status Register */
5149 +#define PCIE_QSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x73C)
5150 +#define PCIE_QSR_WAIT_UPDATE_FC_DLL 0x00000001 /* Received TLP FC Credits Not Returned */
5151 +#define PCIE_QSR_TX_RETRY_BUF_NOT_EMPTY 0x00000002 /* Transmit Retry Buffer Not Empty */
5152 +#define PCIE_QSR_RX_QUEUE_NOT_EMPTY 0x00000004 /* Received Queue Not Empty */
5154 +/* VC Transmit Arbitration Register 1 */
5155 +#define PCIE_VCTAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x740)
5156 +#define PCIE_VCTAR1_WRR_WEIGHT_VC0 0x000000FF /* WRR Weight for VC0 */
5157 +#define PCIE_VCTAR1_WRR_WEIGHT_VC1 0x0000FF00 /* WRR Weight for VC1 */
5158 +#define PCIE_VCTAR1_WRR_WEIGHT_VC2 0x00FF0000 /* WRR Weight for VC2 */
5159 +#define PCIE_VCTAR1_WRR_WEIGHT_VC3 0xFF000000 /* WRR Weight for VC3 */
5161 +/* VC Transmit Arbitration Register 2 */
5162 +#define PCIE_VCTAR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x744)
5163 +#define PCIE_VCTAR2_WRR_WEIGHT_VC4 0x000000FF /* WRR Weight for VC4 */
5164 +#define PCIE_VCTAR2_WRR_WEIGHT_VC5 0x0000FF00 /* WRR Weight for VC5 */
5165 +#define PCIE_VCTAR2_WRR_WEIGHT_VC6 0x00FF0000 /* WRR Weight for VC6 */
5166 +#define PCIE_VCTAR2_WRR_WEIGHT_VC7 0xFF000000 /* WRR Weight for VC7 */
5168 +/* VC0 Posted Receive Queue Control Register */
5169 +#define PCIE_VC0_PRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x748)
5170 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS 0x00000FFF /* VC0 Posted Data Credits */
5171 +#define PCIE_VC0_PRQCR_P_DATA_CREDITS_S 0
5172 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS 0x000FF000 /* VC0 Posted Header Credits */
5173 +#define PCIE_VC0_PRQCR_P_HDR_CREDITS_S 12
5174 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE 0x00E00000 /* VC0 Posted TLP Queue Mode */
5175 +#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE_S 20
5176 +#define PCIE_VC0_PRQCR_TLP_RELAX_ORDER 0x40000000 /* TLP Type Ordering for VC0 */
5177 +#define PCIE_VC0_PRQCR_VC_STRICT_ORDER 0x80000000 /* VC0 Ordering for Receive Queues */
5179 +/* VC0 Non-Posted Receive Queue Control */
5180 +#define PCIE_VC0_NPRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74C)
5181 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS 0x00000FFF /* VC0 Non-Posted Data Credits */
5182 +#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS_S 0
5183 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS 0x000FF000 /* VC0 Non-Posted Header Credits */
5184 +#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS_S 12
5185 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE 0x00E00000 /* VC0 Non-Posted TLP Queue Mode */
5186 +#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE_S 20
5188 +/* VC0 Completion Receive Queue Control */
5189 +#define PCIE_VC0_CRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x750)
5190 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS 0x00000FFF /* VC0 Completion TLP Queue Mode */
5191 +#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS_S 0
5192 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS 0x000FF000 /* VC0 Completion Header Credits */
5193 +#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS_S 12
5194 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE 0x00E00000 /* VC0 Completion Data Credits */
5195 +#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE_S 21
5197 +/* Applicable to the above three registers */
5199 + PCIE_VC0_TLP_QUEUE_MODE_STORE_FORWARD = 1,
5200 + PCIE_VC0_TLP_QUEUE_MODE_CUT_THROUGH = 2,
5201 + PCIE_VC0_TLP_QUEUE_MODE_BYPASS = 4,
5204 +/* VC0 Posted Buffer Depth Register */
5205 +#define PCIE_VC0_PBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7A8)
5206 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Posted Data Queue Depth */
5207 +#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES_S 0
5208 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Posted Header Queue Depth */
5209 +#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES_S 16
5211 +/* VC0 Non-Posted Buffer Depth Register */
5212 +#define PCIE_VC0_NPBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7AC)
5213 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Non-Posted Data Queue Depth */
5214 +#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES_S 0
5215 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Non-Posted Header Queue Depth */
5216 +#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES_S 16
5218 +/* VC0 Completion Buffer Depth Register */
5219 +#define PCIE_VC0_CBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7B0)
5220 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES 0x00003FFF /* C0 Completion Data Queue Depth */
5221 +#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES_S 0
5222 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Completion Header Queue Depth */
5223 +#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES_S 16
5225 +/* PHY Status Register, all zeros in VR9 */
5226 +#define PCIE_PHYSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x810)
5228 +/* PHY Control Register, all zeros in VR9 */
5229 +#define PCIE_PHYCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x814)
5232 + * PCIe PDI PHY register definition, suppose all the following
5233 + * stuff is confidential.
5234 + * XXX, detailed bit definition
5236 +#define PCIE_PHY_PLL_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x22 << 1))
5237 +#define PCIE_PHY_PLL_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x23 << 1))
5238 +#define PCIE_PHY_PLL_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x24 << 1))
5239 +#define PCIE_PHY_PLL_CTRL4(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x25 << 1))
5240 +#define PCIE_PHY_PLL_CTRL5(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x26 << 1))
5241 +#define PCIE_PHY_PLL_CTRL6(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x27 << 1))
5242 +#define PCIE_PHY_PLL_CTRL7(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x28 << 1))
5243 +#define PCIE_PHY_PLL_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x29 << 1))
5244 +#define PCIE_PHY_PLL_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2A << 1))
5245 +#define PCIE_PHY_PLL_A_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2B << 1))
5246 +#define PCIE_PHY_PLL_STATUS(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2C << 1))
5248 +#define PCIE_PHY_TX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x30 << 1))
5249 +#define PCIE_PHY_TX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x31 << 1))
5250 +#define PCIE_PHY_TX1_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x32 << 1))
5251 +#define PCIE_PHY_TX1_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x33 << 1))
5252 +#define PCIE_PHY_TX1_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x34 << 1))
5253 +#define PCIE_PHY_TX1_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x35 << 1))
5254 +#define PCIE_PHY_TX1_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x36 << 1))
5255 +#define PCIE_PHY_TX1_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x37 << 1))
5257 +#define PCIE_PHY_TX2_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x38 << 1))
5258 +#define PCIE_PHY_TX2_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x39 << 1))
5259 +#define PCIE_PHY_TX2_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3B << 1))
5260 +#define PCIE_PHY_TX2_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3C << 1))
5261 +#define PCIE_PHY_TX2_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3D << 1))
5262 +#define PCIE_PHY_TX2_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3E << 1))
5263 +#define PCIE_PHY_TX2_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3F << 1))
5265 +#define PCIE_PHY_RX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x50 << 1))
5266 +#define PCIE_PHY_RX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x51 << 1))
5267 +#define PCIE_PHY_RX1_CDR(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x52 << 1))
5268 +#define PCIE_PHY_RX1_EI(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x53 << 1))
5269 +#define PCIE_PHY_RX1_A_CTRL(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x55 << 1))
5271 +/* Interrupt related stuff */
5272 +#define PCIE_LEGACY_DISABLE 0
5273 +#define PCIE_LEGACY_INTA 1
5274 +#define PCIE_LEGACY_INTB 2
5275 +#define PCIE_LEGACY_INTC 3
5276 +#define PCIE_LEGACY_INTD 4
5277 +#define PCIE_LEGACY_INT_MAX PCIE_LEGACY_INTD
5279 +#define PCIE_IRQ_LOCK(lock) do { \
5280 + unsigned long flags; \
5281 + spin_lock_irqsave(&(lock), flags);
5282 +#define PCIE_IRQ_UNLOCK(lock) \
5283 + spin_unlock_irqrestore(&(lock), flags); \
5286 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
5287 +#define IRQF_SHARED SA_SHIRQ
5290 +#define PCIE_MSG_MSI 0x00000001
5291 +#define PCIE_MSG_ISR 0x00000002
5292 +#define PCIE_MSG_FIXUP 0x00000004
5293 +#define PCIE_MSG_READ_CFG 0x00000008
5294 +#define PCIE_MSG_WRITE_CFG 0x00000010
5295 +#define PCIE_MSG_CFG (PCIE_MSG_READ_CFG | PCIE_MSG_WRITE_CFG)
5296 +#define PCIE_MSG_REG 0x00000020
5297 +#define PCIE_MSG_INIT 0x00000040
5298 +#define PCIE_MSG_ERR 0x00000080
5299 +#define PCIE_MSG_PHY 0x00000100
5300 +#define PCIE_MSG_ANY 0x000001ff
5302 +#define IFX_PCIE_PORT0 0
5303 +#define IFX_PCIE_PORT1 1
5305 +#ifdef CONFIG_IFX_PCIE_2ND_CORE
5306 +#define IFX_PCIE_CORE_NR 2
5308 +#define IFX_PCIE_CORE_NR 1
5311 +//#define IFX_PCIE_ERROR_INT
5313 +//#define IFX_PCIE_DBG
5315 +#if defined(IFX_PCIE_DBG)
5316 +#define IFX_PCIE_PRINT(_m, _fmt, args...) do { \
5317 + if (g_pcie_debug_flag & (_m)) { \
5318 + ifx_pcie_debug((_fmt), ##args); \
5324 +#define IFX_PCIE_PRINT(_m, _fmt, args...) \
5326 +#define INLINE inline
5329 +struct ifx_pci_controller {
5330 + struct pci_controller pcic;
5332 + /* RC specific, per host bus information */
5333 + u32 port; /* Port index, 0 -- 1st core, 1 -- 2nd core */
5336 +typedef struct ifx_pcie_ir_irq {
5337 + const unsigned int irq;
5338 + const char name[16];
5339 +}ifx_pcie_ir_irq_t;
5341 +typedef struct ifx_pcie_legacy_irq{
5342 + const u32 irq_bit;
5344 +}ifx_pcie_legacy_irq_t;
5346 +typedef struct ifx_pcie_irq {
5347 + ifx_pcie_ir_irq_t ir_irq;
5348 + ifx_pcie_legacy_irq_t legacy_irq[PCIE_LEGACY_INT_MAX];
5351 +extern u32 g_pcie_debug_flag;
5352 +extern void ifx_pcie_debug(const char *fmt, ...);
5353 +extern void pcie_phy_clock_mode_setup(int pcie_port);
5354 +extern void pcie_msi_pic_init(int pcie_port);
5355 +extern u32 ifx_pcie_bus_enum_read_hack(int where, u32 value);
5356 +extern u32 ifx_pcie_bus_enum_write_hack(int where, u32 value);
5359 +#include <linux/types.h>
5360 +#include <linux/delay.h>
5361 +#include <linux/gpio.h>
5362 +#include <linux/clk.h>
5364 +#include <lantiq_soc.h>
5366 +#define IFX_PCIE_GPIO_RESET 38
5367 +#define IFX_REG_R32 ltq_r32
5368 +#define IFX_REG_W32 ltq_w32
5369 +#define CONFIG_IFX_PCIE_HW_SWAP
5370 +#define IFX_RCU_AHB_ENDIAN ((volatile u32*)(IFX_RCU + 0x004C))
5371 +#define IFX_RCU_RST_REQ ((volatile u32*)(IFX_RCU + 0x0010))
5372 +#define IFX_RCU_AHB_BE_PCIE_PDI 0x00000080 /* Configure PCIE PDI module in big endian*/
5374 +#define IFX_RCU (KSEG1 | 0x1F203000)
5375 +#define IFX_RCU_AHB_BE_PCIE_M 0x00000001 /* Configure AHB master port that connects to PCIe RC in big endian */
5376 +#define IFX_RCU_AHB_BE_PCIE_S 0x00000010 /* Configure AHB slave port that connects to PCIe RC in little endian */
5377 +#define IFX_RCU_AHB_BE_XBAR_M 0x00000002 /* Configure AHB master port that connects to XBAR in big endian */
5378 +#define CONFIG_IFX_PCIE_PHY_36MHZ_MODE
5380 +#define IFX_PMU1_MODULE_PCIE_PHY (0)
5381 +#define IFX_PMU1_MODULE_PCIE_CTRL (1)
5382 +#define IFX_PMU1_MODULE_PDI (4)
5383 +#define IFX_PMU1_MODULE_MSI (5)
5385 +#define IFX_PMU_MODULE_PCIE_L0_CLK (31)
5388 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
5392 +static inline void pcie_ahb_pmu_setup(void)
5395 + clk = clk_get_sys("ltq_pcie", "ahb");
5397 + //ltq_pmu_enable(PMU_AHBM | PMU_AHBS);
5400 +static inline void pcie_rcu_endian_setup(int pcie_port)
5404 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
5405 +#ifdef CONFIG_IFX_PCIE_HW_SWAP
5406 + reg |= IFX_RCU_AHB_BE_PCIE_M;
5407 + reg |= IFX_RCU_AHB_BE_PCIE_S;
5408 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
5410 + reg |= IFX_RCU_AHB_BE_PCIE_M;
5411 + reg &= ~IFX_RCU_AHB_BE_PCIE_S;
5412 + reg &= ~IFX_RCU_AHB_BE_XBAR_M;
5413 +#endif /* CONFIG_IFX_PCIE_HW_SWAP */
5414 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
5415 + IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
5418 +static inline void pcie_phy_pmu_enable(int pcie_port)
5421 + clk = clk_get_sys("ltq_pcie", "phy");
5423 + //ltq_pmu1_enable(1<<IFX_PMU1_MODULE_PCIE_PHY);
5426 +static inline void pcie_phy_pmu_disable(int pcie_port)
5429 + clk = clk_get_sys("ltq_pcie", "phy");
5431 + //ltq_pmu1_disable(1<<IFX_PMU1_MODULE_PCIE_PHY);
5434 +static inline void pcie_pdi_big_endian(int pcie_port)
5438 + /* SRAM2PDI endianness control. */
5439 + reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
5440 + /* Config AHB->PCIe and PDI endianness */
5441 + reg |= IFX_RCU_AHB_BE_PCIE_PDI;
5442 + IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
5445 +static inline void pcie_pdi_pmu_enable(int pcie_port)
5448 + clk = clk_get_sys("ltq_pcie", "pdi");
5450 + //ltq_pmu1_enable(1<<IFX_PMU1_MODULE_PDI);
5453 +static inline void pcie_core_rst_assert(int pcie_port)
5457 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5459 + /* Reset PCIe PHY & Core, bit 22, bit 26 may be affected if write it directly */
5460 + reg |= 0x00400000;
5461 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5464 +static inline void pcie_core_rst_deassert(int pcie_port)
5468 + /* Make sure one micro-second delay */
5471 + /* Reset PCIe PHY & Core, bit 22 */
5472 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5473 + reg &= ~0x00400000;
5474 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5477 +static inline void pcie_phy_rst_assert(int pcie_port)
5481 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5482 + reg |= 0x00001000; /* Bit 12 */
5483 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5486 +static inline void pcie_phy_rst_deassert(int pcie_port)
5490 + /* Make sure one micro-second delay */
5493 + reg = IFX_REG_R32(IFX_RCU_RST_REQ);
5494 + reg &= ~0x00001000; /* Bit 12 */
5495 + IFX_REG_W32(reg, IFX_RCU_RST_REQ);
5498 +static inline void pcie_device_rst_assert(int pcie_port)
5500 + gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
5501 + // ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
5504 +static inline void pcie_device_rst_deassert(int pcie_port)
5507 + gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
5508 +// ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
5511 +static inline void pcie_core_pmu_setup(int pcie_port)
5514 + clk = clk_get_sys("ltq_pcie", "ctl");
5516 + clk = clk_get_sys("ltq_pcie", "bus");
5519 + //ltq_pmu1_enable(1 << IFX_PMU1_MODULE_PCIE_CTRL);
5520 + //ltq_pmu_enable(1 << IFX_PMU_MODULE_PCIE_L0_CLK);
5523 +static inline void pcie_msi_init(int pcie_port)
5526 + pcie_msi_pic_init(pcie_port);
5527 + clk = clk_get_sys("ltq_pcie", "msi");
5529 + //ltq_pmu1_enable(1 << IFX_PMU1_MODULE_MSI);
5533 +ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
5535 + u32 tbus_number = bus_number;
5537 +#ifdef CONFIG_IFX_PCI
5538 + if (pcibios_host_nr() > 1) {
5539 + tbus_number -= pcibios_1st_host_bus_nr();
5541 +#endif /* CONFIG_IFX_PCI */
5542 + return tbus_number;
5546 +ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
5548 + struct pci_dev *pdev;
5549 + u32 tvalue = value;
5551 + /* Sanity check */
5552 + pdev = pci_get_slot(bus, devfn);
5553 + if (pdev == NULL) {
5557 + /* Only care about PCI bridge */
5558 + if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
5562 + if (read) { /* Read hack */
5563 + #ifdef CONFIG_IFX_PCI
5564 + if (pcibios_host_nr() > 1) {
5565 + tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
5567 + #endif /* CONFIG_IFX_PCI */
5569 + else { /* Write hack */
5570 + #ifdef CONFIG_IFX_PCI
5571 + if (pcibios_host_nr() > 1) {
5572 + tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
5579 +#endif /* IFXMIPS_PCIE_VR9_H */