mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 07/11] ARM: i.MX: ocotp: Fix MAC address provider for unaligned addresses
Date: Wed, 26 Nov 2014 17:29:50 +0100	[thread overview]
Message-ID: <1417019394-23683-8-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1417019394-23683-1-git-send-email-s.hauer@pengutronix.de>

The current algorithm assumes the MAC address starts at a 4 byte
aligned address. Unfortunately this is not always the case. On the
i.MX6sx the MAC Address for the second FEC starts at offset 0x632.
The register space for the fuse map has holes, only the 16 byte
aligned words contain data. This means we have to skip the holes.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/ocotp.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-imx/ocotp.c b/arch/arm/mach-imx/ocotp.c
index 837500f..419821b 100644
--- a/arch/arm/mach-imx/ocotp.c
+++ b/arch/arm/mach-imx/ocotp.c
@@ -320,6 +320,14 @@ static struct file_operations imx6_ocotp_ops = {
 	.lseek	= dev_lseek_default,
 };
 
+static uint32_t inc_offset(uint32_t offset)
+{
+	if ((offset & 0x3) == 0x3)
+		return offset + 0xd;
+	else
+		return offset + 1;
+}
+
 static void imx_ocotp_init_dt(struct device_d *dev, void __iomem *base)
 {
 	char mac[6];
@@ -336,21 +344,24 @@ static void imx_ocotp_init_dt(struct device_d *dev, void __iomem *base)
 
 	while (len >= MAC_ADDRESS_PROPLEN) {
 		struct device_node *rnode;
-		uint32_t phandle, offset, value;
+		uint32_t phandle, offset;
 
 		phandle = be32_to_cpup(prop++);
 
 		rnode = of_find_node_by_phandle(phandle);
 		offset = be32_to_cpup(prop++);
 
-		value = readl(base + offset + 0x10);
-		mac[0] = (value >> 8);
-		mac[1] = value;
-		value = readl(base + offset);
-		mac[2] = value >> 24;
-		mac[3] = value >> 16;
-		mac[4] = value >> 8;
-		mac[5] = value;
+		mac[5] = readb(base + offset);
+		offset = inc_offset(offset);
+		mac[4] = readb(base + offset);
+		offset = inc_offset(offset);
+		mac[3] = readb(base + offset);
+		offset = inc_offset(offset);
+		mac[2] = readb(base + offset);
+		offset = inc_offset(offset);
+		mac[1] = readb(base + offset);
+		offset = inc_offset(offset);
+		mac[0] = readb(base + offset);
 
 		of_eth_register_ethaddr(rnode, mac);
 
-- 
2.1.3


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

  parent reply	other threads:[~2014-11-26 16:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-26 16:29 Add i.MX6 SoloX support Sascha Hauer
2014-11-26 16:29 ` [PATCH 01/11] mci: imx-esdhc: Fix Interrupt enable register for i.MX6sx Sascha Hauer
2014-11-26 16:29 ` [PATCH 02/11] mci: imx-esdhc: Add i.MX6sl compatible Sascha Hauer
2014-11-26 16:29 ` [PATCH 03/11] serial: i.MX: Use "per" clk Sascha Hauer
2014-11-26 16:29 ` [PATCH 04/11] net: fec_imx: Add i.MX6sx compatible entry Sascha Hauer
2014-11-26 16:29 ` [PATCH 05/11] imx-usb-loader: Add i.MX6sx support Sascha Hauer
2014-11-26 16:29 ` [PATCH 06/11] pinctrl: Add i.MX6sx compatible entry Sascha Hauer
2014-11-26 16:29 ` Sascha Hauer [this message]
2014-11-26 16:29 ` [PATCH 08/11] ARM: i.MX: ocotp: " Sascha Hauer
2014-11-26 16:29 ` [PATCH 09/11] ARM: i.MX: Add i.MX6sx support Sascha Hauer
2014-11-26 16:29 ` [PATCH 10/11] ARM: i.MX: Add i.MX6sx sabresdb support Sascha Hauer
2014-11-26 17:06   ` Lucas Stach
2014-11-27 10:26     ` Sascha Hauer
2014-11-26 16:29 ` [PATCH 11/11] ARM: i.MX: update imx_v7_defconfig 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=1417019394-23683-8-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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