diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-03-14 05:29:25 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2012-05-15 11:49:01 -0400 |
commit | 692183ef12c4ba9dcdc9a54065ca92072cd79493 (patch) | |
tree | 89f61e4ca185bfe4f347570ab1c2e00e40b0fe0b /arch/mips/pci/pci-ar724x.c | |
parent | 6335aef59c55f50e6d8017a28c0ee985b533ea29 (diff) |
MIPS: ath79: rename pci-ath724x.c to make it reflect the real SoC name
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Acked-by: René Bolldorf <xsecute@googlemail.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/3489/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/pci/pci-ar724x.c')
-rw-r--r-- | arch/mips/pci/pci-ar724x.c | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/arch/mips/pci/pci-ar724x.c b/arch/mips/pci/pci-ar724x.c new file mode 100644 index 000000000000..ebefc165fae6 --- /dev/null +++ b/arch/mips/pci/pci-ar724x.c | |||
@@ -0,0 +1,139 @@ | |||
1 | /* | ||
2 | * Atheros 724x PCI support | ||
3 | * | ||
4 | * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License version 2 as published | ||
8 | * by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/pci.h> | ||
12 | #include <asm/mach-ath79/pci.h> | ||
13 | |||
14 | #define reg_read(_phys) (*(unsigned int *) KSEG1ADDR(_phys)) | ||
15 | #define reg_write(_phys, _val) ((*(unsigned int *) KSEG1ADDR(_phys)) = (_val)) | ||
16 | |||
17 | #define ATH724X_PCI_DEV_BASE 0x14000000 | ||
18 | #define ATH724X_PCI_MEM_BASE 0x10000000 | ||
19 | #define ATH724X_PCI_MEM_SIZE 0x08000000 | ||
20 | |||
21 | static DEFINE_SPINLOCK(ath724x_pci_lock); | ||
22 | |||
23 | static int ath724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where, | ||
24 | int size, uint32_t *value) | ||
25 | { | ||
26 | unsigned long flags, addr, tval, mask; | ||
27 | |||
28 | if (devfn) | ||
29 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
30 | |||
31 | if (where & (size - 1)) | ||
32 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
33 | |||
34 | spin_lock_irqsave(&ath724x_pci_lock, flags); | ||
35 | |||
36 | switch (size) { | ||
37 | case 1: | ||
38 | addr = where & ~3; | ||
39 | mask = 0xff000000 >> ((where % 4) * 8); | ||
40 | tval = reg_read(ATH724X_PCI_DEV_BASE + addr); | ||
41 | tval = tval & ~mask; | ||
42 | *value = (tval >> ((4 - (where % 4))*8)); | ||
43 | break; | ||
44 | case 2: | ||
45 | addr = where & ~3; | ||
46 | mask = 0xffff0000 >> ((where % 4)*8); | ||
47 | tval = reg_read(ATH724X_PCI_DEV_BASE + addr); | ||
48 | tval = tval & ~mask; | ||
49 | *value = (tval >> ((4 - (where % 4))*8)); | ||
50 | break; | ||
51 | case 4: | ||
52 | *value = reg_read(ATH724X_PCI_DEV_BASE + where); | ||
53 | break; | ||
54 | default: | ||
55 | spin_unlock_irqrestore(&ath724x_pci_lock, flags); | ||
56 | |||
57 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
58 | } | ||
59 | |||
60 | spin_unlock_irqrestore(&ath724x_pci_lock, flags); | ||
61 | |||
62 | return PCIBIOS_SUCCESSFUL; | ||
63 | } | ||
64 | |||
65 | static int ath724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where, | ||
66 | int size, uint32_t value) | ||
67 | { | ||
68 | unsigned long flags, tval, addr, mask; | ||
69 | |||
70 | if (devfn) | ||
71 | return PCIBIOS_DEVICE_NOT_FOUND; | ||
72 | |||
73 | if (where & (size - 1)) | ||
74 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
75 | |||
76 | spin_lock_irqsave(&ath724x_pci_lock, flags); | ||
77 | |||
78 | switch (size) { | ||
79 | case 1: | ||
80 | addr = (ATH724X_PCI_DEV_BASE + where) & ~3; | ||
81 | mask = 0xff000000 >> ((where % 4)*8); | ||
82 | tval = reg_read(addr); | ||
83 | tval = tval & ~mask; | ||
84 | tval |= (value << ((4 - (where % 4))*8)) & mask; | ||
85 | reg_write(addr, tval); | ||
86 | break; | ||
87 | case 2: | ||
88 | addr = (ATH724X_PCI_DEV_BASE + where) & ~3; | ||
89 | mask = 0xffff0000 >> ((where % 4)*8); | ||
90 | tval = reg_read(addr); | ||
91 | tval = tval & ~mask; | ||
92 | tval |= (value << ((4 - (where % 4))*8)) & mask; | ||
93 | reg_write(addr, tval); | ||
94 | break; | ||
95 | case 4: | ||
96 | reg_write((ATH724X_PCI_DEV_BASE + where), value); | ||
97 | break; | ||
98 | default: | ||
99 | spin_unlock_irqrestore(&ath724x_pci_lock, flags); | ||
100 | |||
101 | return PCIBIOS_BAD_REGISTER_NUMBER; | ||
102 | } | ||
103 | |||
104 | spin_unlock_irqrestore(&ath724x_pci_lock, flags); | ||
105 | |||
106 | return PCIBIOS_SUCCESSFUL; | ||
107 | } | ||
108 | |||
109 | static struct pci_ops ath724x_pci_ops = { | ||
110 | .read = ath724x_pci_read, | ||
111 | .write = ath724x_pci_write, | ||
112 | }; | ||
113 | |||
114 | static struct resource ath724x_io_resource = { | ||
115 | .name = "PCI IO space", | ||
116 | .start = 0, | ||
117 | .end = 0, | ||
118 | .flags = IORESOURCE_IO, | ||
119 | }; | ||
120 | |||
121 | static struct resource ath724x_mem_resource = { | ||
122 | .name = "PCI memory space", | ||
123 | .start = ATH724X_PCI_MEM_BASE, | ||
124 | .end = ATH724X_PCI_MEM_BASE + ATH724X_PCI_MEM_SIZE - 1, | ||
125 | .flags = IORESOURCE_MEM, | ||
126 | }; | ||
127 | |||
128 | static struct pci_controller ath724x_pci_controller = { | ||
129 | .pci_ops = &ath724x_pci_ops, | ||
130 | .io_resource = &ath724x_io_resource, | ||
131 | .mem_resource = &ath724x_mem_resource, | ||
132 | }; | ||
133 | |||
134 | int __init ath724x_pcibios_init(void) | ||
135 | { | ||
136 | register_pci_controller(&ath724x_pci_controller); | ||
137 | |||
138 | return PCIBIOS_SUCCESSFUL; | ||
139 | } | ||