@@ -120,12 +120,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;
@@ -146,14 +149,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;
}
@@ -187,7 +193,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;
}
@@ -219,7 +226,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;
}
@@ -2003,7 +2011,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));
@@ -29,6 +29,7 @@ struct smsc911x_platform_config {
unsigned int irq_polarity;
unsigned int irq_type;
unsigned int flags;
+ unsigned int shift; /* for register access */
phy_interface_t phy_interface;
unsigned char mac[6];
};