aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/smc91x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/smc91x.c')
-rw-r--r--drivers/net/smc91x.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index d0ef80ae018a..97bdb2a43bc8 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -1997,6 +1997,8 @@ err_out:
1997 1997
1998static int smc_enable_device(struct platform_device *pdev) 1998static int smc_enable_device(struct platform_device *pdev)
1999{ 1999{
2000 struct net_device *ndev = platform_get_drvdata(pdev);
2001 struct smc_local *lp = netdev_priv(ndev);
2000 unsigned long flags; 2002 unsigned long flags;
2001 unsigned char ecor, ecsr; 2003 unsigned char ecor, ecsr;
2002 void __iomem *addr; 2004 void __iomem *addr;
@@ -2039,7 +2041,7 @@ static int smc_enable_device(struct platform_device *pdev)
2039 * Set the appropriate byte/word mode. 2041 * Set the appropriate byte/word mode.
2040 */ 2042 */
2041 ecsr = readb(addr + (ECSR << SMC_IO_SHIFT)) & ~ECSR_IOIS8; 2043 ecsr = readb(addr + (ECSR << SMC_IO_SHIFT)) & ~ECSR_IOIS8;
2042 if (!SMC_CAN_USE_16BIT) 2044 if (!SMC_16BIT(lp))
2043 ecsr |= ECSR_IOIS8; 2045 ecsr |= ECSR_IOIS8;
2044 writeb(ecsr, addr + (ECSR << SMC_IO_SHIFT)); 2046 writeb(ecsr, addr + (ECSR << SMC_IO_SHIFT));
2045 local_irq_restore(flags); 2047 local_irq_restore(flags);
@@ -2124,10 +2126,11 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
2124 */ 2126 */
2125static int smc_drv_probe(struct platform_device *pdev) 2127static int smc_drv_probe(struct platform_device *pdev)
2126{ 2128{
2129 struct smc91x_platdata *pd = pdev->dev.platform_data;
2130 struct smc_local *lp;
2127 struct net_device *ndev; 2131 struct net_device *ndev;
2128 struct resource *res, *ires; 2132 struct resource *res, *ires;
2129 unsigned int __iomem *addr; 2133 unsigned int __iomem *addr;
2130 unsigned long irq_flags = SMC_IRQ_FLAGS;
2131 int ret; 2134 int ret;
2132 2135
2133 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs"); 2136 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs");
@@ -2152,6 +2155,27 @@ static int smc_drv_probe(struct platform_device *pdev)
2152 } 2155 }
2153 SET_NETDEV_DEV(ndev, &pdev->dev); 2156 SET_NETDEV_DEV(ndev, &pdev->dev);
2154 2157
2158 /* get configuration from platform data, only allow use of
2159 * bus width if both SMC_CAN_USE_xxx and SMC91X_USE_xxx are set.
2160 */
2161
2162 lp = netdev_priv(ndev);
2163 lp->cfg.irq_flags = SMC_IRQ_FLAGS;
2164
2165#ifdef SMC_DYNAMIC_BUS_CONFIG
2166 if (pd)
2167 memcpy(&lp->cfg, pd, sizeof(lp->cfg));
2168 else {
2169 lp->cfg.flags = SMC91X_USE_8BIT;
2170 lp->cfg.flags |= SMC91X_USE_16BIT;
2171 lp->cfg.flags |= SMC91X_USE_32BIT;
2172 }
2173
2174 lp->cfg.flags &= ~(SMC_CAN_USE_8BIT ? 0 : SMC91X_USE_8BIT);
2175 lp->cfg.flags &= ~(SMC_CAN_USE_16BIT ? 0 : SMC91X_USE_16BIT);
2176 lp->cfg.flags &= ~(SMC_CAN_USE_32BIT ? 0 : SMC91X_USE_32BIT);
2177#endif
2178
2155 ndev->dma = (unsigned char)-1; 2179 ndev->dma = (unsigned char)-1;
2156 2180
2157 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 2181 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -2162,7 +2186,7 @@ static int smc_drv_probe(struct platform_device *pdev)
2162 2186
2163 ndev->irq = ires->start; 2187 ndev->irq = ires->start;
2164 if (SMC_IRQ_FLAGS == -1) 2188 if (SMC_IRQ_FLAGS == -1)
2165 irq_flags = ires->flags & IRQF_TRIGGER_MASK; 2189 lp->cfg.irq_flags = ires->flags & IRQF_TRIGGER_MASK;
2166 2190
2167 ret = smc_request_attrib(pdev); 2191 ret = smc_request_attrib(pdev);
2168 if (ret) 2192 if (ret)
@@ -2170,6 +2194,7 @@ static int smc_drv_probe(struct platform_device *pdev)
2170#if defined(CONFIG_SA1100_ASSABET) 2194#if defined(CONFIG_SA1100_ASSABET)
2171 NCR_0 |= NCR_ENET_OSC_EN; 2195 NCR_0 |= NCR_ENET_OSC_EN;
2172#endif 2196#endif
2197 platform_set_drvdata(pdev, ndev);
2173 ret = smc_enable_device(pdev); 2198 ret = smc_enable_device(pdev);
2174 if (ret) 2199 if (ret)
2175 goto out_release_attrib; 2200 goto out_release_attrib;
@@ -2188,8 +2213,7 @@ static int smc_drv_probe(struct platform_device *pdev)
2188 } 2213 }
2189#endif 2214#endif
2190 2215
2191 platform_set_drvdata(pdev, ndev); 2216 ret = smc_probe(ndev, addr, lp->cfg.irq_flags);
2192 ret = smc_probe(ndev, addr, irq_flags);
2193 if (ret != 0) 2217 if (ret != 0)
2194 goto out_iounmap; 2218 goto out_iounmap;
2195 2219