diff options
Diffstat (limited to 'drivers/net/smc91x.c')
| -rw-r--r-- | drivers/net/smc91x.c | 94 |
1 files changed, 49 insertions, 45 deletions
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c index f2051b209da2..2040965d7724 100644 --- a/drivers/net/smc91x.c +++ b/drivers/net/smc91x.c | |||
| @@ -308,7 +308,7 @@ static void smc_reset(struct net_device *dev) | |||
| 308 | * can't handle it then there will be no recovery except for | 308 | * can't handle it then there will be no recovery except for |
| 309 | * a hard reset or power cycle | 309 | * a hard reset or power cycle |
| 310 | */ | 310 | */ |
| 311 | if (nowait) | 311 | if (lp->cfg.flags & SMC91X_NOWAIT) |
| 312 | cfg |= CONFIG_NO_WAIT; | 312 | cfg |= CONFIG_NO_WAIT; |
| 313 | 313 | ||
| 314 | /* | 314 | /* |
| @@ -1939,8 +1939,11 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr, | |||
| 1939 | if (retval) | 1939 | if (retval) |
| 1940 | goto err_out; | 1940 | goto err_out; |
| 1941 | 1941 | ||
| 1942 | #ifdef SMC_USE_PXA_DMA | 1942 | #ifdef CONFIG_ARCH_PXA |
| 1943 | { | 1943 | # ifdef SMC_USE_PXA_DMA |
| 1944 | lp->cfg.flags |= SMC91X_USE_DMA; | ||
| 1945 | # endif | ||
| 1946 | if (lp->cfg.flags & SMC91X_USE_DMA) { | ||
| 1944 | int dma = pxa_request_dma(dev->name, DMA_PRIO_LOW, | 1947 | int dma = pxa_request_dma(dev->name, DMA_PRIO_LOW, |
| 1945 | smc_pxa_dma_irq, NULL); | 1948 | smc_pxa_dma_irq, NULL); |
| 1946 | if (dma >= 0) | 1949 | if (dma >= 0) |
| @@ -1980,7 +1983,7 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr, | |||
| 1980 | } | 1983 | } |
| 1981 | 1984 | ||
| 1982 | err_out: | 1985 | err_out: |
| 1983 | #ifdef SMC_USE_PXA_DMA | 1986 | #ifdef CONFIG_ARCH_PXA |
| 1984 | if (retval && dev->dma != (unsigned char)-1) | 1987 | if (retval && dev->dma != (unsigned char)-1) |
| 1985 | pxa_free_dma(dev->dma); | 1988 | pxa_free_dma(dev->dma); |
| 1986 | #endif | 1989 | #endif |
| @@ -2050,9 +2053,11 @@ static int smc_enable_device(struct platform_device *pdev) | |||
| 2050 | return 0; | 2053 | return 0; |
| 2051 | } | 2054 | } |
| 2052 | 2055 | ||
| 2053 | static int smc_request_attrib(struct platform_device *pdev) | 2056 | static int smc_request_attrib(struct platform_device *pdev, |
| 2057 | struct net_device *ndev) | ||
| 2054 | { | 2058 | { |
| 2055 | struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib"); | 2059 | struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib"); |
| 2060 | struct smc_local *lp = netdev_priv(ndev); | ||
| 2056 | 2061 | ||
| 2057 | if (!res) | 2062 | if (!res) |
| 2058 | return 0; | 2063 | return 0; |
| @@ -2063,9 +2068,11 @@ static int smc_request_attrib(struct platform_device *pdev) | |||
| 2063 | return 0; | 2068 | return 0; |
| 2064 | } | 2069 | } |
| 2065 | 2070 | ||
| 2066 | static void smc_release_attrib(struct platform_device *pdev) | 2071 | static void smc_release_attrib(struct platform_device *pdev, |
| 2072 | struct net_device *ndev) | ||
| 2067 | { | 2073 | { |
| 2068 | struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib"); | 2074 | struct resource * res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-attrib"); |
| 2075 | struct smc_local *lp = netdev_priv(ndev); | ||
| 2069 | 2076 | ||
| 2070 | if (res) | 2077 | if (res) |
| 2071 | release_mem_region(res->start, ATTRIB_SIZE); | 2078 | release_mem_region(res->start, ATTRIB_SIZE); |
| @@ -2123,27 +2130,14 @@ static int smc_drv_probe(struct platform_device *pdev) | |||
| 2123 | struct net_device *ndev; | 2130 | struct net_device *ndev; |
| 2124 | struct resource *res, *ires; | 2131 | struct resource *res, *ires; |
| 2125 | unsigned int __iomem *addr; | 2132 | unsigned int __iomem *addr; |
| 2133 | unsigned long irq_flags = SMC_IRQ_FLAGS; | ||
| 2126 | int ret; | 2134 | int ret; |
| 2127 | 2135 | ||
| 2128 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); | ||
| 2129 | if (!res) | ||
| 2130 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 2131 | if (!res) { | ||
| 2132 | ret = -ENODEV; | ||
| 2133 | goto out; | ||
| 2134 | } | ||
| 2135 | |||
| 2136 | |||
| 2137 | if (!request_mem_region(res->start, SMC_IO_EXTENT, CARDNAME)) { | ||
| 2138 | ret = -EBUSY; | ||
| 2139 | goto out; | ||
| 2140 | } | ||
| 2141 | |||
| 2142 | ndev = alloc_etherdev(sizeof(struct smc_local)); | 2136 | ndev = alloc_etherdev(sizeof(struct smc_local)); |
| 2143 | if (!ndev) { | 2137 | if (!ndev) { |
| 2144 | printk("%s: could not allocate device.\n", CARDNAME); | 2138 | printk("%s: could not allocate device.\n", CARDNAME); |
| 2145 | ret = -ENOMEM; | 2139 | ret = -ENOMEM; |
| 2146 | goto out_release_io; | 2140 | goto out; |
| 2147 | } | 2141 | } |
| 2148 | SET_NETDEV_DEV(ndev, &pdev->dev); | 2142 | SET_NETDEV_DEV(ndev, &pdev->dev); |
| 2149 | 2143 | ||
| @@ -2152,37 +2146,47 @@ static int smc_drv_probe(struct platform_device *pdev) | |||
| 2152 | */ | 2146 | */ |
| 2153 | 2147 | ||
| 2154 | lp = netdev_priv(ndev); | 2148 | lp = netdev_priv(ndev); |
| 2155 | lp->cfg.irq_flags = SMC_IRQ_FLAGS; | ||
| 2156 | 2149 | ||
| 2157 | #ifdef SMC_DYNAMIC_BUS_CONFIG | 2150 | if (pd) { |
| 2158 | if (pd) | ||
| 2159 | memcpy(&lp->cfg, pd, sizeof(lp->cfg)); | 2151 | memcpy(&lp->cfg, pd, sizeof(lp->cfg)); |
| 2160 | else { | 2152 | lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags); |
| 2161 | lp->cfg.flags = SMC91X_USE_8BIT; | 2153 | } else { |
| 2162 | lp->cfg.flags |= SMC91X_USE_16BIT; | 2154 | lp->cfg.flags |= (SMC_CAN_USE_8BIT) ? SMC91X_USE_8BIT : 0; |
| 2163 | lp->cfg.flags |= SMC91X_USE_32BIT; | 2155 | lp->cfg.flags |= (SMC_CAN_USE_16BIT) ? SMC91X_USE_16BIT : 0; |
| 2156 | lp->cfg.flags |= (SMC_CAN_USE_32BIT) ? SMC91X_USE_32BIT : 0; | ||
| 2157 | lp->cfg.flags |= (nowait) ? SMC91X_NOWAIT : 0; | ||
| 2164 | } | 2158 | } |
| 2165 | 2159 | ||
| 2166 | lp->cfg.flags &= ~(SMC_CAN_USE_8BIT ? 0 : SMC91X_USE_8BIT); | ||
| 2167 | lp->cfg.flags &= ~(SMC_CAN_USE_16BIT ? 0 : SMC91X_USE_16BIT); | ||
| 2168 | lp->cfg.flags &= ~(SMC_CAN_USE_32BIT ? 0 : SMC91X_USE_32BIT); | ||
| 2169 | #endif | ||
| 2170 | |||
| 2171 | ndev->dma = (unsigned char)-1; | 2160 | ndev->dma = (unsigned char)-1; |
| 2172 | 2161 | ||
| 2162 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); | ||
| 2163 | if (!res) | ||
| 2164 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 2165 | if (!res) { | ||
| 2166 | ret = -ENODEV; | ||
| 2167 | goto out_free_netdev; | ||
| 2168 | } | ||
| 2169 | |||
| 2170 | |||
| 2171 | if (!request_mem_region(res->start, SMC_IO_EXTENT, CARDNAME)) { | ||
| 2172 | ret = -EBUSY; | ||
| 2173 | goto out_free_netdev; | ||
| 2174 | } | ||
| 2175 | |||
| 2173 | ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 2176 | ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
| 2174 | if (!ires) { | 2177 | if (!ires) { |
| 2175 | ret = -ENODEV; | 2178 | ret = -ENODEV; |
| 2176 | goto out_free_netdev; | 2179 | goto out_release_io; |
| 2177 | } | 2180 | } |
| 2178 | 2181 | ||
| 2179 | ndev->irq = ires->start; | 2182 | ndev->irq = ires->start; |
| 2180 | if (SMC_IRQ_FLAGS == -1) | ||
| 2181 | lp->cfg.irq_flags = ires->flags & IRQF_TRIGGER_MASK; | ||
| 2182 | 2183 | ||
| 2183 | ret = smc_request_attrib(pdev); | 2184 | if (ires->flags & IRQF_TRIGGER_MASK) |
| 2185 | irq_flags = ires->flags & IRQF_TRIGGER_MASK; | ||
| 2186 | |||
| 2187 | ret = smc_request_attrib(pdev, ndev); | ||
| 2184 | if (ret) | 2188 | if (ret) |
| 2185 | goto out_free_netdev; | 2189 | goto out_release_io; |
| 2186 | #if defined(CONFIG_SA1100_ASSABET) | 2190 | #if defined(CONFIG_SA1100_ASSABET) |
| 2187 | NCR_0 |= NCR_ENET_OSC_EN; | 2191 | NCR_0 |= NCR_ENET_OSC_EN; |
| 2188 | #endif | 2192 | #endif |
| @@ -2197,7 +2201,7 @@ static int smc_drv_probe(struct platform_device *pdev) | |||
| 2197 | goto out_release_attrib; | 2201 | goto out_release_attrib; |
| 2198 | } | 2202 | } |
| 2199 | 2203 | ||
| 2200 | #ifdef SMC_USE_PXA_DMA | 2204 | #ifdef CONFIG_ARCH_PXA |
| 2201 | { | 2205 | { |
| 2202 | struct smc_local *lp = netdev_priv(ndev); | 2206 | struct smc_local *lp = netdev_priv(ndev); |
| 2203 | lp->device = &pdev->dev; | 2207 | lp->device = &pdev->dev; |
| @@ -2205,7 +2209,7 @@ static int smc_drv_probe(struct platform_device *pdev) | |||
| 2205 | } | 2209 | } |
| 2206 | #endif | 2210 | #endif |
| 2207 | 2211 | ||
| 2208 | ret = smc_probe(ndev, addr, lp->cfg.irq_flags); | 2212 | ret = smc_probe(ndev, addr, irq_flags); |
| 2209 | if (ret != 0) | 2213 | if (ret != 0) |
| 2210 | goto out_iounmap; | 2214 | goto out_iounmap; |
| 2211 | 2215 | ||
| @@ -2217,11 +2221,11 @@ static int smc_drv_probe(struct platform_device *pdev) | |||
| 2217 | platform_set_drvdata(pdev, NULL); | 2221 | platform_set_drvdata(pdev, NULL); |
| 2218 | iounmap(addr); | 2222 | iounmap(addr); |
| 2219 | out_release_attrib: | 2223 | out_release_attrib: |
| 2220 | smc_release_attrib(pdev); | 2224 | smc_release_attrib(pdev, ndev); |
| 2221 | out_free_netdev: | ||
| 2222 | free_netdev(ndev); | ||
| 2223 | out_release_io: | 2225 | out_release_io: |
| 2224 | release_mem_region(res->start, SMC_IO_EXTENT); | 2226 | release_mem_region(res->start, SMC_IO_EXTENT); |
| 2227 | out_free_netdev: | ||
| 2228 | free_netdev(ndev); | ||
| 2225 | out: | 2229 | out: |
| 2226 | printk("%s: not found (%d).\n", CARDNAME, ret); | 2230 | printk("%s: not found (%d).\n", CARDNAME, ret); |
| 2227 | 2231 | ||
| @@ -2240,14 +2244,14 @@ static int smc_drv_remove(struct platform_device *pdev) | |||
| 2240 | 2244 | ||
| 2241 | free_irq(ndev->irq, ndev); | 2245 | free_irq(ndev->irq, ndev); |
| 2242 | 2246 | ||
| 2243 | #ifdef SMC_USE_PXA_DMA | 2247 | #ifdef CONFIG_ARCH_PXA |
| 2244 | if (ndev->dma != (unsigned char)-1) | 2248 | if (ndev->dma != (unsigned char)-1) |
| 2245 | pxa_free_dma(ndev->dma); | 2249 | pxa_free_dma(ndev->dma); |
| 2246 | #endif | 2250 | #endif |
| 2247 | iounmap(lp->base); | 2251 | iounmap(lp->base); |
| 2248 | 2252 | ||
| 2249 | smc_release_datacs(pdev,ndev); | 2253 | smc_release_datacs(pdev,ndev); |
| 2250 | smc_release_attrib(pdev); | 2254 | smc_release_attrib(pdev,ndev); |
| 2251 | 2255 | ||
| 2252 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); | 2256 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); |
| 2253 | if (!res) | 2257 | if (!res) |
