diff options
Diffstat (limited to 'arch/powerpc/kernel/prom_parse.c')
-rw-r--r-- | arch/powerpc/kernel/prom_parse.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c index 90eb3a3e383e..bc1fb27368af 100644 --- a/arch/powerpc/kernel/prom_parse.c +++ b/arch/powerpc/kernel/prom_parse.c | |||
@@ -128,12 +128,35 @@ static void of_bus_pci_count_cells(struct device_node *np, | |||
128 | *sizec = 2; | 128 | *sizec = 2; |
129 | } | 129 | } |
130 | 130 | ||
131 | static unsigned int of_bus_pci_get_flags(const u32 *addr) | ||
132 | { | ||
133 | unsigned int flags = 0; | ||
134 | u32 w = addr[0]; | ||
135 | |||
136 | switch((w >> 24) & 0x03) { | ||
137 | case 0x01: | ||
138 | flags |= IORESOURCE_IO; | ||
139 | break; | ||
140 | case 0x02: /* 32 bits */ | ||
141 | case 0x03: /* 64 bits */ | ||
142 | flags |= IORESOURCE_MEM; | ||
143 | break; | ||
144 | } | ||
145 | if (w & 0x40000000) | ||
146 | flags |= IORESOURCE_PREFETCH; | ||
147 | return flags; | ||
148 | } | ||
149 | |||
131 | static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna) | 150 | static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna) |
132 | { | 151 | { |
133 | u64 cp, s, da; | 152 | u64 cp, s, da; |
153 | unsigned int af, rf; | ||
154 | |||
155 | af = of_bus_pci_get_flags(addr); | ||
156 | rf = of_bus_pci_get_flags(range); | ||
134 | 157 | ||
135 | /* Check address type match */ | 158 | /* Check address type match */ |
136 | if ((addr[0] ^ range[0]) & 0x03000000) | 159 | if ((af ^ rf) & (IORESOURCE_MEM | IORESOURCE_IO)) |
137 | return OF_BAD_ADDR; | 160 | return OF_BAD_ADDR; |
138 | 161 | ||
139 | /* Read address values, skipping high cell */ | 162 | /* Read address values, skipping high cell */ |
@@ -153,25 +176,6 @@ static int of_bus_pci_translate(u32 *addr, u64 offset, int na) | |||
153 | return of_bus_default_translate(addr + 1, offset, na - 1); | 176 | return of_bus_default_translate(addr + 1, offset, na - 1); |
154 | } | 177 | } |
155 | 178 | ||
156 | static unsigned int of_bus_pci_get_flags(const u32 *addr) | ||
157 | { | ||
158 | unsigned int flags = 0; | ||
159 | u32 w = addr[0]; | ||
160 | |||
161 | switch((w >> 24) & 0x03) { | ||
162 | case 0x01: | ||
163 | flags |= IORESOURCE_IO; | ||
164 | break; | ||
165 | case 0x02: /* 32 bits */ | ||
166 | case 0x03: /* 64 bits */ | ||
167 | flags |= IORESOURCE_MEM; | ||
168 | break; | ||
169 | } | ||
170 | if (w & 0x40000000) | ||
171 | flags |= IORESOURCE_PREFETCH; | ||
172 | return flags; | ||
173 | } | ||
174 | |||
175 | const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, | 179 | const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, |
176 | unsigned int *flags) | 180 | unsigned int *flags) |
177 | { | 181 | { |