From: LW@KARO-electronics.de (Lothar Waßmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ARM: mxs: TX28: Setup MAC addresses for both FEC MACs from OTP fuses.
Date: Mon, 21 Mar 2011 17:48:06 +0100 [thread overview]
Message-ID: <49cf2dff25189eb7b7a0ff9eaceefab359f08b2e.1300724245.git.LW@KARO-electronics.de> (raw)
In-Reply-To: <1300726086-23297-1-git-send-email-LW@KARO-electronics.de>
Signed-off-by: Lothar Wa?mann <LW@KARO-electronics.de>
---
arch/arm/mach-mxs/module-tx28.c | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mxs/module-tx28.c b/arch/arm/mach-mxs/module-tx28.c
index 7d44936..7a9e7b6 100644
--- a/arch/arm/mach-mxs/module-tx28.c
+++ b/arch/arm/mach-mxs/module-tx28.c
@@ -74,6 +74,43 @@ static struct fec_platform_data tx28_fec1_data = {
.phy = PHY_INTERFACE_MODE_RMII,
};
+#define HW_OCOTP_CUST0 0x20
+#define HW_OCOTP_CUST(n) (HW_OCOTP_CUST0 + (n) * 0x10)
+#define HW_OCOTP_CTRL 0x00
+#define HW_OCOTP_CTRL_SET (HW_OCOTP_CTRL + 4)
+#define HW_OCOTP_CTRL_CLR (HW_OCOTP_CTRL + 8)
+
+#define BM_OCOTP_CTRL_BUSY (1 << 8)
+#define BM_OCOTP_CTRL_RD_BANK_OPEN (1 << 12)
+
+static int __init tx28_set_mac(int id, unsigned char mac[])
+{
+ int i;
+ void __iomem *ocotp_base = ioremap(MX28_OCOTP_BASE_ADDR, SZ_4K);
+ u32 reg = 0;
+ long timeout = 1000;
+
+ if (ocotp_base == NULL)
+ return -ENOMEM;
+
+ /* set this bit to open the OTP banks for reading */
+ writel(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base + HW_OCOTP_CTRL_SET);
+
+ while (readl(ocotp_base + HW_OCOTP_CTRL) & BM_OCOTP_CTRL_BUSY) {
+ if (timeout-- < 0)
+ return -ETIMEDOUT;
+ udelay(100);
+ }
+
+ for (i = 0; i < ETH_ALEN; i++) {
+ if (i % 4 == 0)
+ reg = readl(ocotp_base + HW_OCOTP_CUST(id * 2 + i / 4));
+ mac[i] = reg >> (24 - ((i % 4) * 8));
+ }
+ iounmap(ocotp_base);
+ return 0;
+}
+
int __init tx28_add_fec0(void)
{
int i, ret;
@@ -139,6 +176,7 @@ int __init tx28_add_fec0(void)
__func__, ret);
goto free_gpios;
}
+ tx28_set_mac(0, tx28_fec0_data.mac);
pr_debug("%s: Registering FEC0 device\n", __func__);
mx28_add_fec(0, &tx28_fec0_data);
return 0;
@@ -165,6 +203,7 @@ int __init tx28_add_fec1(void)
__func__, ret);
return ret;
}
+ tx28_set_mac(1, tx28_fec1_data.mac);
pr_debug("%s: Registering FEC1 device\n", __func__);
mx28_add_fec(1, &tx28_fec1_data);
return 0;
--
1.5.6.5
next prev parent reply other threads:[~2011-03-21 16:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-21 16:48 [PATCH 1/2] ARM: mxs: configure and register the second FEC device on TX28/STK5-V4 Lothar Waßmann
2011-03-21 16:48 ` Lothar Waßmann [this message]
2011-03-22 14:14 ` [PATCH 2/2] ARM: mxs: TX28: Setup MAC addresses for both FEC MACs from OTP fuses Shawn Guo
2011-03-22 14:35 ` Lothar Waßmann
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=49cf2dff25189eb7b7a0ff9eaceefab359f08b2e.1300724245.git.LW@KARO-electronics.de \
--to=lw@karo-electronics.de \
--cc=linux-arm-kernel@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