From 0b3b22c918579879cbecdae35ab6f6e150316963 Mon Sep 17 00:00:00 2001 From: Robert Marklund Date: Mon, 21 Mar 2011 17:00:41 +0100 Subject: smsc911x: use shifted register access At least one of the boards using this chip needs a shift in register access. This adds a "shift" field in the platform data to have the chip working in all cases without special ifdef. The approach is similaro to the one used in serial_8250 and other places. Performance-wise no difference is reported. Signed-off-by: Alessandro Rubini Signed-off-by: Robert Marklund --- drivers/net/smsc911x.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c index c6d47d10590..d9a16744e2f 100644 --- a/drivers/net/smsc911x.c +++ b/drivers/net/smsc911x.c @@ -139,12 +139,15 @@ struct smsc911x_data { static inline u32 __smsc911x_reg_read(struct smsc911x_data *pdata, u32 reg) { + void __iomem *addr = pdata->ioaddr; + int shift = pdata->config.shift; + if (pdata->config.flags & SMSC911X_USE_32BIT) - return readl(pdata->ioaddr + reg); + return readl(addr + (reg << shift)); if (pdata->config.flags & SMSC911X_USE_16BIT) - return ((readw(pdata->ioaddr + reg) & 0xFFFF) | - ((readw(pdata->ioaddr + reg + 2) & 0xFFFF) << 16)); + return ((readw(addr + (reg << shift)) & 0xFFFF) | + ((readw(addr + ((reg + 2) << shift)) & 0xFFFF) << 16)); BUG(); return 0; @@ -181,14 +184,17 @@ static inline u32 smsc911x_reg_read(struct smsc911x_data *pdata, u32 reg) static inline void __smsc911x_reg_write(struct smsc911x_data *pdata, u32 reg, u32 val) { + void __iomem *addr = pdata->ioaddr; + int shift = pdata->config.shift; + if (pdata->config.flags & SMSC911X_USE_32BIT) { - writel(val, pdata->ioaddr + reg); + writel(val, addr + (reg << shift)); return; } if (pdata->config.flags & SMSC911X_USE_16BIT) { - writew(val & 0xFFFF, pdata->ioaddr + reg); - writew((val >> 16) & 0xFFFF, pdata->ioaddr + reg + 2); + writew(val & 0xFFFF, addr + (reg << shift)); + writew((val >> 16) & 0xFFFF, addr + ((reg + 2) << shift)); return; } @@ -241,7 +247,8 @@ smsc911x_tx_writefifo(struct smsc911x_data *pdata, unsigned int *buf, } if (pdata->config.flags & SMSC911X_USE_32BIT) { - writesl(pdata->ioaddr + TX_DATA_FIFO, buf, wordcount); + writesl(pdata->ioaddr + (TX_DATA_FIFO << pdata->config.shift), + buf, wordcount); goto out; } @@ -307,7 +314,8 @@ smsc911x_rx_readfifo(struct smsc911x_data *pdata, unsigned int *buf, } if (pdata->config.flags & SMSC911X_USE_32BIT) { - readsl(pdata->ioaddr + RX_DATA_FIFO, buf, wordcount); + readsl(pdata->ioaddr + (RX_DATA_FIFO << pdata->config.shift), + buf, wordcount); goto out; } @@ -2148,7 +2156,8 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev) dev->irq = irq_res->start; irq_flags = irq_res->flags & IRQF_TRIGGER_MASK; - pdata->ioaddr = ioremap_nocache(res->start, res_size); + pdata->ioaddr = ioremap_nocache(res->start, + (res_size << config->shift)); /* copy config parameters across to pdata */ memcpy(&pdata->config, config, sizeof(pdata->config)); -- cgit v1.2.3