mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/7] smc911x: add 16bit bus width support
Date: Sat,  1 Sep 2012 10:52:40 +0200	[thread overview]
Message-ID: <1346489564-16176-3-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1346489564-16176-1-git-send-email-plagnioj@jcrosoft.com>

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/net/smc911x.c |   34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 2583235..917f994 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -76,7 +76,13 @@ static inline u32 smc911x_reg_read(struct smc911x_priv *priv, u32 reg)
 	return priv->reg_read(priv, reg);
 }
 
-static inline u32 __smc911x_reg_read(struct smc911x_priv *priv, u32 reg)
+static inline u32 __smc911x_reg_readw(struct smc911x_priv *priv, u32 reg)
+{
+	return ((readw(priv->base + reg) & 0xFFFF) |
+		((readw(priv->base + reg + 2) & 0xFFFF) << 16));
+}
+
+static inline u32 __smc911x_reg_readl(struct smc911x_priv *priv, u32 reg)
 {
 	return readl(priv->base + reg);
 }
@@ -87,7 +93,14 @@ static inline void smc911x_reg_write(struct smc911x_priv *priv, u32 reg,
 	priv->reg_write(priv, reg, val);
 }
 
-static inline void __smc911x_reg_write(struct smc911x_priv *priv, u32 reg,
+static inline void __smc911x_reg_writew(struct smc911x_priv *priv, u32 reg,
+					u32 val)
+{
+	writew(val & 0xFFFF, priv->base + reg);
+	writew((val >> 16) & 0xFFFF, priv->base + reg + 2);
+}
+
+static inline void __smc911x_reg_writel(struct smc911x_priv *priv, u32 reg,
 					u32 val)
 {
 	writel(val, priv->base + reg);
@@ -390,12 +403,23 @@ static int smc911x_probe(struct device_d *dev)
 	struct eth_device *edev;
 	struct smc911x_priv *priv;
 	uint32_t val;
-	int i;
+	int i, is_32bit;
 
 	priv = xzalloc(sizeof(*priv));
+	is_32bit = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
+	if (!is_32bit)
+		is_32bit = 1;
+	else
+		is_32bit = is_32bit == IORESOURCE_MEM_32BIT;
 	priv->base = dev_request_mem_region(dev, 0);
-	priv->reg_read = __smc911x_reg_read;
-	priv->reg_write = __smc911x_reg_write;
+
+	if (is_32bit) {
+		priv->reg_read = __smc911x_reg_readl;
+		priv->reg_write = __smc911x_reg_writel;
+	} else {
+		priv->reg_read = __smc911x_reg_readw;
+		priv->reg_write = __smc911x_reg_writew;
+	}
 
 	val = smc911x_reg_read(priv, BYTE_TEST);
 	if(val != 0x87654321) {
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-09-01  8:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-01  8:47 [PATCH 0/7 v3] smsc911x: runtime configuration improvement Jean-Christophe PLAGNIOL-VILLARD
2012-09-01  8:52 ` [PATCH 1/7] smc911x: move register define to smc911x.h Jean-Christophe PLAGNIOL-VILLARD
2012-09-01  8:52   ` [PATCH 2/7] smc911x: introduce read/write ops Jean-Christophe PLAGNIOL-VILLARD
2012-09-01  8:52   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-09-01  8:52   ` [PATCH 4/7] smc911x: add support to pass the shift via platform data Jean-Christophe PLAGNIOL-VILLARD
2012-09-01  8:52   ` [PATCH 5/7] smc911x: improve detection handle Jean-Christophe PLAGNIOL-VILLARD
2012-09-01  8:52   ` [PATCH 6/7] smc911x: update chip detection Jean-Christophe PLAGNIOL-VILLARD
2012-09-01  8:52   ` [PATCH 7/7] smc911x: check if the device is ready before using it Jean-Christophe PLAGNIOL-VILLARD
2012-09-03  7:49 ` [PATCH 0/7 v3] smsc911x: runtime configuration improvement Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2012-08-29  4:27 [PATCH 0/7 2] " Jean-Christophe PLAGNIOL-VILLARD
2012-08-29  5:06 ` [PATCH 1/7] smc911x: move register define to smc911x.h Jean-Christophe PLAGNIOL-VILLARD
2012-08-29  5:06   ` [PATCH 3/7] smc911x: add 16bit bus width support Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 17:25 [PATCH 0/7] smsc911x: runtime configuration improvement Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 17:32 ` [PATCH 1/7] smc911x: move register define to smc911x.h Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 17:32   ` [PATCH 3/7] smc911x: add 16bit bus width support Jean-Christophe PLAGNIOL-VILLARD
2012-08-14 20:21     ` Sascha Hauer
2012-08-15  4:30       ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-27 14:20         ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346489564-16176-3-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox