From patchwork Fri Mar 11 23:08:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 519 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:43:17 -0000 Delivered-To: patches@linaro.org Received: by 10.224.67.207 with SMTP id s15cs76507qai; Fri, 11 Mar 2011 15:08:31 -0800 (PST) Received: by 10.236.108.198 with SMTP id q46mr3591626yhg.385.1299884911234; Fri, 11 Mar 2011 15:08:31 -0800 (PST) Received: from mail-gy0-f178.google.com (mail-gy0-f178.google.com [209.85.160.178]) by mx.google.com with ESMTPS id 68si11811559yhl.149.2011.03.11.15.08.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Mar 2011 15:08:31 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.178 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) client-ip=209.85.160.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.178 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) smtp.mail=mathieu.poirier@linaro.org Received: by mail-gy0-f178.google.com with SMTP id 12so253225gyd.37 for ; Fri, 11 Mar 2011 15:08:30 -0800 (PST) Received: by 10.90.135.8 with SMTP id i8mr498335agd.113.1299884910474; Fri, 11 Mar 2011 15:08:30 -0800 (PST) Received: from localhost.localdomain (S0106002369de4dac.cg.shawcable.net [70.73.24.112]) by mx.google.com with ESMTPS id i10sm5945021anh.32.2011.03.11.15.08.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Mar 2011 15:08:29 -0800 (PST) From: mathieu.poirier@linaro.org To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, patches@linaro.org, linus.walleij@stericsson.com Subject: [PATCH 05/10] smsc911x: use shifted register access Date: Fri, 11 Mar 2011 16:08:07 -0700 Message-Id: <1299884892-6766-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1299884892-6766-1-git-send-email-mathieu.poirier@linaro.org> References: <1299884892-6766-1-git-send-email-mathieu.poirier@linaro.org> From: Alessandro Rubini 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 --- drivers/net/smsc911x.c | 27 ++++++++++++++++++--------- include/linux/smsc911x.h | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c index 64bfdae..a21c551 100644 --- a/drivers/net/smsc911x.c +++ b/drivers/net/smsc911x.c @@ -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)); diff --git a/include/linux/smsc911x.h b/include/linux/smsc911x.h index 7144e8a..cff97bc 100644 --- a/include/linux/smsc911x.h +++ b/include/linux/smsc911x.h @@ -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]; };