Commit e7b3dc7ef1e27fd5713a0df71f82c0a27de1c2eb
Committed by
Russell King
1 parent
1709e2af78
Exists in
master
and in
7 other branches
[NET] smc91x: Make smc91x use IRQ resource trigger flags
smc91x is shared between many different platforms. Each platform needs to specify the interrupt type, and in some cases the irq type depends on more than just the build configuration - it depends on runtime checks. Rather than throwing this code into the SMC_IRQ_FLAGS definition, provide a way for these flags to be passed via the IRQ resource itself. Note that IRQF_TRIGGER_* constants are intentionally defined to correspond with the IORESOURCE_IRQ_* interrupt type flags, in much the same way that the low bits of PCI iomem resources correspond with the BAR flag bits. Also provide a way to configure smc91x to read the IRQ flags from the resource. Once all platforms have been converted over (signified by all definitions of SMC_IRQ_FLAGS being -1) SMC_IRQ_FLAGS should be removed. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Nicolas Pitre <nico@cam.org> Acked-by: Jeff Garzik <jgarzik@redhat.com>
Showing 17 changed files with 36 additions and 36 deletions Side-by-side Diff
- arch/arm/mach-omap1/board-fsample.c
- arch/arm/mach-omap1/board-h2.c
- arch/arm/mach-omap1/board-h3.c
- arch/arm/mach-omap1/board-innovator.c
- arch/arm/mach-omap1/board-osk.c
- arch/arm/mach-omap1/board-perseus2.c
- arch/arm/mach-omap1/board-voiceblue.c
- arch/arm/mach-omap2/board-2430sdp.c
- arch/arm/mach-omap2/board-apollon.c
- arch/arm/mach-pxa/idp.c
- arch/arm/mach-pxa/littleton.c
- arch/arm/mach-pxa/lubbock.c
- arch/arm/mach-pxa/mainstone.c
- arch/arm/mach-pxa/zylonite.c
- arch/arm/plat-omap/debug-devices.c
- drivers/net/smc91x.c
- drivers/net/smc91x.h
arch/arm/mach-omap1/board-fsample.c
arch/arm/mach-omap1/board-h2.c
arch/arm/mach-omap1/board-h3.c
arch/arm/mach-omap1/board-innovator.c
... | ... | @@ -202,7 +202,7 @@ |
202 | 202 | [1] = { |
203 | 203 | .start = OMAP1510_INT_ETHER, |
204 | 204 | .end = OMAP1510_INT_ETHER, |
205 | - .flags = IORESOURCE_IRQ, | |
205 | + .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, | |
206 | 206 | }, |
207 | 207 | }; |
208 | 208 | |
... | ... | @@ -269,7 +269,7 @@ |
269 | 269 | [1] = { |
270 | 270 | .start = OMAP_GPIO_IRQ(0), |
271 | 271 | .end = OMAP_GPIO_IRQ(0), |
272 | - .flags = IORESOURCE_IRQ, | |
272 | + .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, | |
273 | 273 | }, |
274 | 274 | }; |
275 | 275 |
arch/arm/mach-omap1/board-osk.c
arch/arm/mach-omap1/board-perseus2.c
arch/arm/mach-omap1/board-voiceblue.c
arch/arm/mach-omap2/board-2430sdp.c
arch/arm/mach-omap2/board-apollon.c
arch/arm/mach-pxa/idp.c
arch/arm/mach-pxa/littleton.c
arch/arm/mach-pxa/lubbock.c
arch/arm/mach-pxa/mainstone.c
arch/arm/mach-pxa/zylonite.c
arch/arm/plat-omap/debug-devices.c
drivers/net/smc91x.c
... | ... | @@ -1775,7 +1775,8 @@ |
1775 | 1775 | * o actually GRAB the irq. |
1776 | 1776 | * o GRAB the region |
1777 | 1777 | */ |
1778 | -static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr) | |
1778 | +static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr, | |
1779 | + unsigned long irq_flags) | |
1779 | 1780 | { |
1780 | 1781 | struct smc_local *lp = netdev_priv(dev); |
1781 | 1782 | static int version_printed = 0; |
... | ... | @@ -1941,7 +1942,7 @@ |
1941 | 1942 | } |
1942 | 1943 | |
1943 | 1944 | /* Grab the IRQ */ |
1944 | - retval = request_irq(dev->irq, &smc_interrupt, SMC_IRQ_FLAGS, dev->name, dev); | |
1945 | + retval = request_irq(dev->irq, &smc_interrupt, irq_flags, dev->name, dev); | |
1945 | 1946 | if (retval) |
1946 | 1947 | goto err_out; |
1947 | 1948 | |
1948 | 1949 | |
... | ... | @@ -2123,8 +2124,9 @@ |
2123 | 2124 | static int smc_drv_probe(struct platform_device *pdev) |
2124 | 2125 | { |
2125 | 2126 | struct net_device *ndev; |
2126 | - struct resource *res; | |
2127 | + struct resource *res, *ires; | |
2127 | 2128 | unsigned int __iomem *addr; |
2129 | + unsigned long irq_flags = SMC_IRQ_FLAGS; | |
2128 | 2130 | int ret; |
2129 | 2131 | |
2130 | 2132 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); |
2131 | 2133 | |
... | ... | @@ -2150,12 +2152,17 @@ |
2150 | 2152 | SET_NETDEV_DEV(ndev, &pdev->dev); |
2151 | 2153 | |
2152 | 2154 | ndev->dma = (unsigned char)-1; |
2153 | - ndev->irq = platform_get_irq(pdev, 0); | |
2154 | - if (ndev->irq < 0) { | |
2155 | + | |
2156 | + ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | |
2157 | + if (!ires) { | |
2155 | 2158 | ret = -ENODEV; |
2156 | 2159 | goto out_free_netdev; |
2157 | 2160 | } |
2158 | 2161 | |
2162 | + ndev->irq = ires->start; | |
2163 | + if (SMC_IRQ_FLAGS == -1) | |
2164 | + irq_flags = ires->flags & IRQF_TRIGGER_MASK; | |
2165 | + | |
2159 | 2166 | ret = smc_request_attrib(pdev); |
2160 | 2167 | if (ret) |
2161 | 2168 | goto out_free_netdev; |
... | ... | @@ -2181,7 +2188,7 @@ |
2181 | 2188 | #endif |
2182 | 2189 | |
2183 | 2190 | platform_set_drvdata(pdev, ndev); |
2184 | - ret = smc_probe(ndev, addr); | |
2191 | + ret = smc_probe(ndev, addr, irq_flags); | |
2185 | 2192 | if (ret != 0) |
2186 | 2193 | goto out_iounmap; |
2187 | 2194 |
drivers/net/smc91x.h
... | ... | @@ -54,6 +54,7 @@ |
54 | 54 | #define SMC_outw(v, a, r) writew(v, (a) + (r)) |
55 | 55 | #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) |
56 | 56 | #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) |
57 | +#define SMC_IRQ_FLAGS (-1) /* from resource */ | |
57 | 58 | |
58 | 59 | #elif defined(CONFIG_BLACKFIN) |
59 | 60 | |
... | ... | @@ -158,7 +159,7 @@ |
158 | 159 | #define SMC_outw(v, a, r) writew(v, (a) + (r)) |
159 | 160 | #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) |
160 | 161 | |
161 | -#define SMC_IRQ_FLAGS (0) | |
162 | +#define SMC_IRQ_FLAGS (-1) | |
162 | 163 | |
163 | 164 | #elif defined(CONFIG_SA1100_ASSABET) |
164 | 165 | |
... | ... | @@ -177,6 +178,7 @@ |
177 | 178 | #define SMC_outb(v, a, r) writeb(v, (a) + (r)) |
178 | 179 | #define SMC_insb(a, r, p, l) readsb((a) + (r), p, (l)) |
179 | 180 | #define SMC_outsb(a, r, p, l) writesb((a) + (r), p, (l)) |
181 | +#define SMC_IRQ_FLAGS (-1) /* from resource */ | |
180 | 182 | |
181 | 183 | #elif defined(CONFIG_MACH_LOGICPD_PXA270) |
182 | 184 | |
... | ... | @@ -210,6 +212,7 @@ |
210 | 212 | #define SMC_outl(v, a, r) writel(v, (a) + (r)) |
211 | 213 | #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) |
212 | 214 | #define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l) |
215 | +#define SMC_IRQ_FLAGS (-1) /* from resource */ | |
213 | 216 | |
214 | 217 | /* We actually can't write halfwords properly if not word aligned */ |
215 | 218 | static inline void |
... | ... | @@ -238,6 +241,7 @@ |
238 | 241 | #define SMC_outsw(a, r, p, l) outsw((a) + (r), p, l) |
239 | 242 | #define SMC_outb(v, a, r) writeb(v, (a) + (r)) |
240 | 243 | #define SMC_outw(v, a, r) writew(v, (a) + (r)) |
244 | +#define SMC_IRQ_FLAGS (-1) /* from resource */ | |
241 | 245 | |
242 | 246 | #elif defined(CONFIG_ARCH_OMAP) |
243 | 247 | |
244 | 248 | |
... | ... | @@ -252,18 +256,8 @@ |
252 | 256 | #define SMC_outw(v, a, r) writew(v, (a) + (r)) |
253 | 257 | #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) |
254 | 258 | #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) |
259 | +#define SMC_IRQ_FLAGS (-1) /* from resource */ | |
255 | 260 | |
256 | -#include <asm/mach-types.h> | |
257 | -#include <asm/arch/cpu.h> | |
258 | - | |
259 | -#define SMC_IRQ_FLAGS (( \ | |
260 | - machine_is_omap_h2() \ | |
261 | - || machine_is_omap_h3() \ | |
262 | - || machine_is_omap_h4() \ | |
263 | - || (machine_is_omap_innovator() && !cpu_is_omap1510()) \ | |
264 | - ) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING) | |
265 | - | |
266 | - | |
267 | 261 | #elif defined(CONFIG_SH_SH4202_MICRODEV) |
268 | 262 | |
269 | 263 | #define SMC_CAN_USE_8BIT 0 |
... | ... | @@ -453,8 +447,7 @@ |
453 | 447 | #define SMC_outl(v, a, r) writel(v, (a) + (r)) |
454 | 448 | #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) |
455 | 449 | #define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l) |
456 | - | |
457 | -#define SMC_IRQ_FLAGS (0) | |
450 | +#define SMC_IRQ_FLAGS (-1) /* from resource */ | |
458 | 451 | |
459 | 452 | #else |
460 | 453 |