9 #include <linux/types.h>
10 #include <linux/pci.h>
11 #include <linux/kernel.h>
16 #include <linux/module.h>
25 #include <asm/addrspace.h>
27 #include <lantiq_soc.h>
32 #define PCI_CR_FCI_ADDR_MAP0 0x00C0
33 #define PCI_CR_FCI_ADDR_MAP1 0x00C4
34 #define PCI_CR_FCI_ADDR_MAP2 0x00C8
35 #define PCI_CR_FCI_ADDR_MAP3 0x00CC
36 #define PCI_CR_FCI_ADDR_MAP4 0x00D0
37 #define PCI_CR_FCI_ADDR_MAP5 0x00D4
38 #define PCI_CR_FCI_ADDR_MAP6 0x00D8
39 #define PCI_CR_FCI_ADDR_MAP7 0x00DC
40 #define PCI_CR_CLK_CTRL 0x0000
41 #define PCI_CR_PCI_MOD 0x0030
42 #define PCI_CR_PC_ARB 0x0080
43 #define PCI_CR_FCI_ADDR_MAP11hg 0x00E4
44 #define PCI_CR_BAR11MASK 0x0044
45 #define PCI_CR_BAR12MASK 0x0048
46 #define PCI_CR_BAR13MASK 0x004C
47 #define PCI_CS_BASE_ADDR1 0x0010
48 #define PCI_CR_PCI_ADDR_MAP11 0x0064
49 #define PCI_CR_FCI_BURST_LENGTH 0x00E8
50 #define PCI_CR_PCI_EOI 0x002C
51 #define PCI_CS_STS_CMD 0x0004
53 #define PCI_MASTER0_REQ_MASK_2BITS 8
54 #define PCI_MASTER1_REQ_MASK_2BITS 10
55 #define PCI_MASTER2_REQ_MASK_2BITS 12
56 #define INTERNAL_ARB_ENABLE_BIT 0
58 #define LTQ_CGU_IFCCR 0x0018
59 #define LTQ_CGU_PCICR 0x0034
61 #define ltq_pci_w32(x, y) ltq_w32((x), ltq_pci_membase + (y))
62 #define ltq_pci_r32(x) ltq_r32(ltq_pci_membase + (x))
64 #define ltq_pci_cfg_w32(x, y) ltq_w32((x), ltq_pci_mapped_cfg + (y))
65 #define ltq_pci_cfg_r32(x) ltq_r32(ltq_pci_mapped_cfg + (x))
68 static __iomem void *ltq_pci_membase;
70 static int reset_gpio;
71 static struct clk *clk_pci, *clk_external;
72 static struct resource pci_io_resource;
73 static struct resource pci_mem_resource;
81 .mem_resource = &pci_mem_resource,
82 .mem_offset = 0x00000000
UL,
83 .io_resource = &pci_io_resource,
84 .io_offset = 0x00000000
UL,
87 static inline u32 ltq_calc_bar11mask(
void)
93 bar11mask = (0x0ffffff0 & ~((1 << (fls(mem) - 1)) - 1)) | 8;
101 const __be32 *req_mask, *bus_clk;
106 if (IS_ERR(clk_pci)) {
107 dev_err(&pdev->
dev,
"failed to get pci clock\n");
108 return PTR_ERR(clk_pci);
111 clk_external =
clk_get(&pdev->
dev,
"external");
112 if (IS_ERR(clk_external)) {
114 dev_err(&pdev->
dev,
"failed to get external pci clock\n");
115 return PTR_ERR(clk_external);
131 reset_gpio = of_get_named_gpio(node,
"gpio-reset", 0);
132 if (gpio_is_valid(reset_gpio))
149 temp_buffer &= ~((*req_mask & 0xf) << 16);
151 temp_buffer &= ~0xf0000;
195 if (gpio_is_valid(reset_gpio)) {
206 struct resource *res_cfg, *res_bridge;
208 pci_clear_flags(PCI_PROBE_ONLY);
212 if (!res_cfg || !res_bridge) {
213 dev_err(&pdev->
dev,
"missing memory reources\n");
221 dev_err(&pdev->
dev,
"failed to remap resources\n");
225 ltq_pci_startup(pdev);
233 { .compatible =
"lantiq,pci-xway" },
239 .probe = ltq_pci_probe,
243 .of_match_table = ltq_pci_match,
251 pr_info(
"pci-xway: Error registering platform driver!");