From f154e9ca7696ea316c76d8b5500b6c3a62b91593 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 26 Nov 2014 17:21:54 +0100 Subject: ARM: i.MX: ocotp: Fix MAC address provider for unaligned addresses 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 --- arch/arm/mach-imx/ocotp.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'arch/arm/mach-imx/ocotp.c') diff --git a/arch/arm/mach-imx/ocotp.c b/arch/arm/mach-imx/ocotp.c index 837500fff8..419821b810 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); -- cgit v1.2.3 From 1abc1202d0e60486d89da3b9fdcc70fa4238b6a3 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 26 Nov 2014 17:25:16 +0100 Subject: ARM: i.MX: ocotp: Add i.MX6sx compatible entry Signed-off-by: Sascha Hauer --- arch/arm/mach-imx/ocotp.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/arm/mach-imx/ocotp.c') diff --git a/arch/arm/mach-imx/ocotp.c b/arch/arm/mach-imx/ocotp.c index 419821b810..dd509d6e74 100644 --- a/arch/arm/mach-imx/ocotp.c +++ b/arch/arm/mach-imx/ocotp.c @@ -453,6 +453,8 @@ static int imx_ocotp_probe(struct device_d *dev) static __maybe_unused struct of_device_id imx_ocotp_dt_ids[] = { { .compatible = "fsl,imx6q-ocotp", + }, { + .compatible = "fsl,imx6sx-ocotp", }, { /* sentinel */ } -- cgit v1.2.3