mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 0/6] imx: support for the IIM fusebox
@ 2010-08-16 14:10 Baruch Siach
  2010-08-16 14:10 ` [PATCH v2 1/6] imx: move IIM registers to their own header Baruch Siach
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Baruch Siach @ 2010-08-16 14:10 UTC (permalink / raw)
  To: barebox

This patch series adds a driver for the IIM fusebox. As suggested by Sascha 
Hauer, this driver is implemented as a character device, which allows use of 
the standard md/mw commands to access the fuses.

Patches 3 and 6 also add to the fec_imx NIC driver the ability to fetch the MAC 
address from the IIM fusebox.

Changes from v1:

	* Put the imx_iim platform code in the imx25 code instead of the board 
	  code. This avoids code duplication in each board.

	* Move the MAC address fetch code into the imx_iim driver, and use 
	  platform data to pass the MAC address fusebox offset. This avoids 
	  ugly ifdefs in the fec_imx driver.

Baruch Siach (6):
  imx: move IIM registers to their own header
  imx: driver for the IIM fusebox
  imx iim: add mac address support
  imx25: add chip specific IIM fusebox defines
  imx25: add iim platform code
  fec_imx: add support for IIM stored mac address

 arch/arm/mach-imx/Kconfig                   |   18 ++
 arch/arm/mach-imx/Makefile                  |    1 +
 arch/arm/mach-imx/iim.c                     |  311 +++++++++++++++++++++++++++
 arch/arm/mach-imx/imx25.c                   |   44 ++++
 arch/arm/mach-imx/imx35.c                   |    1 +
 arch/arm/mach-imx/include/mach/iim.h        |   55 +++++
 arch/arm/mach-imx/include/mach/imx25-regs.h |    8 +-
 arch/arm/mach-imx/include/mach/imx35-regs.h |   18 --
 drivers/net/fec_imx.c                       |    4 +-
 9 files changed, 439 insertions(+), 21 deletions(-)
 create mode 100644 arch/arm/mach-imx/iim.c
 create mode 100644 arch/arm/mach-imx/include/mach/iim.h


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/6] imx: move IIM registers to their own header
  2010-08-16 14:10 [PATCH v2 0/6] imx: support for the IIM fusebox Baruch Siach
@ 2010-08-16 14:10 ` Baruch Siach
  2010-08-16 14:10 ` [PATCH v2 2/6] imx: driver for the IIM fusebox Baruch Siach
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Baruch Siach @ 2010-08-16 14:10 UTC (permalink / raw)
  To: barebox

This allows the use of IIM registers from code which is not mx35 specific.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 arch/arm/mach-imx/imx35.c                   |    1 +
 arch/arm/mach-imx/include/mach/iim.h        |   42 +++++++++++++++++++++++++++
 arch/arm/mach-imx/include/mach/imx35-regs.h |   18 -----------
 3 files changed, 43 insertions(+), 18 deletions(-)
 create mode 100644 arch/arm/mach-imx/include/mach/iim.h

diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c
index d78a4c5..74d63eb 100644
--- a/arch/arm/mach-imx/imx35.c
+++ b/arch/arm/mach-imx/imx35.c
@@ -18,6 +18,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <mach/imx-regs.h>
+#include <mach/iim.h>
 #include <mach/generic.h>
 
 #include "gpio.h"
diff --git a/arch/arm/mach-imx/include/mach/iim.h b/arch/arm/mach-imx/include/mach/iim.h
new file mode 100644
index 0000000..6e13547
--- /dev/null
+++ b/arch/arm/mach-imx/include/mach/iim.h
@@ -0,0 +1,42 @@
+/*
+ * (c) 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __MACH_IMX_IIM_H
+#define __MACH_IMX_IIM_H
+
+#define IIM_STAT	0x0000
+#define IIM_STATM	0x0004
+#define IIM_ERR		0x0008
+#define IIM_EMASK	0x000C
+#define IIM_FCTL	0x0010
+#define IIM_UA		0x0014
+#define IIM_LA		0x0018
+#define IIM_SDAT	0x001C
+#define IIM_PREV	0x0020
+#define IIM_SREV	0x0024
+#define IIM_PREG_P	0x0028
+#define IIM_SCS0	0x002C
+#define IIM_SCS1	0x0030
+#define IIM_SCS2	0x0034
+#define IIM_SCS3	0x0038
+
+#endif /* __MACH_IMX_IIM_H */
diff --git a/arch/arm/mach-imx/include/mach/imx35-regs.h b/arch/arm/mach-imx/include/mach/imx35-regs.h
index 899e57b..c394a2a 100644
--- a/arch/arm/mach-imx/include/mach/imx35-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx35-regs.h
@@ -76,24 +76,6 @@
 #define PDR0_AUTO_CON		(1 << 0)
 #define PDR0_PER_SEL		(1 << 26)
 
-
-#define IIM_STAT	0x0000
-#define IIM_STATM	0x0004
-#define IIM_ERR		0x0008
-#define IIM_EMASK	0x000C
-#define IIM_FCTL	0x0010
-#define IIM_UA		0x0014
-#define IIM_LA		0x0018
-#define IIM_SDAT	0x001C
-#define IIM_PREV	0x0020
-#define IIM_SREV	0x0024
-#define IIM_PREG_P	0x0028
-#define IIM_SCS0	0x002C
-#define IIM_SCS1	0x0030
-#define IIM_SCS2	0x0034
-#define IIM_SCS3	0x0038
-
-
 /*
  * Adresses and ranges of the external chip select lines
  */
-- 
1.7.1


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 2/6] imx: driver for the IIM fusebox
  2010-08-16 14:10 [PATCH v2 0/6] imx: support for the IIM fusebox Baruch Siach
  2010-08-16 14:10 ` [PATCH v2 1/6] imx: move IIM registers to their own header Baruch Siach
@ 2010-08-16 14:10 ` Baruch Siach
  2010-08-16 14:10 ` [PATCH v2 3/6] imx iim: add mac address support Baruch Siach
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Baruch Siach @ 2010-08-16 14:10 UTC (permalink / raw)
  To: barebox

This driver provides an interface for programming and sensing the IIM fusebox
which is present on some i.MX chips.

Since the IIM io addresses of the controlling registers and each fuse bank are
are not contiguous the driver implementation uses two drivers, imx_iim, and
imx_iim_bank.  The imx_iim is the "parent" driver for a device holding the
map_base address of the control registers.  The imx_iim_bank driver is for
child devices holding the map_base of each fuse bank.  The platform code then,
instantiate one imx_iim_bank device per fuse bank.

Fuses blow is a dangerous operation. Thus, the fuses blow functionality can be
disabled independently at configuration time. On run time this functionality
must be enabled explicitly by setting the permanent_write_enable parameter.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 arch/arm/mach-imx/Kconfig  |   18 +++
 arch/arm/mach-imx/Makefile |    1 +
 arch/arm/mach-imx/iim.c    |  291 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 310 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-imx/iim.c

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 10f01bf..1311ceb 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -364,6 +364,24 @@ config IMX_CLKO
 	  The i.MX SoCs have a Pin which can output different reference frequencies.
 	  Say y here if you want to have the clko command which lets you select the
 	  frequency to output on this pin.
+
+config IMX_IIM
+	tristate "IIM fusebox device"
+	depends on ARCH_IMX25 || ARCH_IMX35
+	help
+	  Device driver for the IC Identification Module (IIM) fusebox. Use the 
+	  regular md/mw commands to program and read the fusebox.
+
+config IMX_IIM_FUSE_BLOW
+	bool "IIM fuses blow support"
+	depends on IMX_IIM
+	help
+	  Enable this option to add permanent programming of the fusebox, using
+	  fuses blowing.
+
+	  Warning: blown fuses can not be unblown. Using this option may damage
+	  your CPU, or make it unbootalbe. Use with care.
+
 endmenu
 
 endif
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 445a879..de62f7e 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_ARCH_IMX27) += speed-imx27.o imx27.o iomux-v1.o
 obj-$(CONFIG_ARCH_IMX31) += speed-imx31.o imx31.o iomux-v2.o
 obj-$(CONFIG_ARCH_IMX35) += speed-imx35.o imx35.o iomux-v3.o
 obj-$(CONFIG_IMX_CLKO)	+= clko.o
+obj-$(CONFIG_IMX_IIM)	+= iim.o
 obj-$(CONFIG_NAND_IMX) += nand.o
 obj-y += speed.o
 
diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c
new file mode 100644
index 0000000..73369b7
--- /dev/null
+++ b/arch/arm/mach-imx/iim.c
@@ -0,0 +1,291 @@
+/*
+ * iim.c - i.MX IIM fusebox driver
+ * 
+ * Provide an interface for programming and sensing the information that are
+ * stored in on-chip fuse elements. This functionality is part of the IC
+ * Identification Module (IIM), which is present on some i.MX CPUs.
+ *
+ * Copyright (c) 2010 Baruch Siach <baruch@tkos.co.il>,
+ * 	Orex Computed Radiography
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <common.h>
+#include <init.h>
+#include <driver.h>
+#include <xfuncs.h>
+#include <errno.h>
+#include <param.h>
+
+#include <asm/io.h>
+
+#include <mach/iim.h>
+
+#define DRIVERNAME	"imx_iim"
+
+static int do_fuse_sense(unsigned long reg_base, unsigned int bank,
+		unsigned int row)
+{
+	u8 err, stat;
+
+	if (bank > 7) {
+		printf("%s: invalid bank number\n", __func__);
+		return -EINVAL;
+	}
+
+	if (row > 0x3ff) {
+		printf("%s: invalid row offset\n", __func__);
+		return -EINVAL;
+	}
+
+	/* clear status and error registers */
+	writeb(3, reg_base + IIM_STATM);
+	writeb(0xfe, reg_base + IIM_ERR);
+
+	/* upper and lower address halves */
+	writeb((bank << 3) | (row >> 7), reg_base + IIM_UA);
+	writeb((row << 1) & 0xf8, reg_base + IIM_LA);
+
+	/* start fuse sensing */
+	writeb(0x08, reg_base + IIM_FCTL);
+
+	/* wait for sense done */
+	while ((readb(reg_base + IIM_STAT) & 0x80) != 0)
+		;
+
+	stat = readb(reg_base + IIM_STAT);
+	writeb(stat, reg_base + IIM_STAT);
+
+	err = readb(reg_base + IIM_ERR);
+	if (err) {
+		printf("%s: sense error (0x%02x)\n", __func__, err);
+		return -EIO;
+	}
+
+	return readb(reg_base + IIM_SDAT);
+}
+
+static ssize_t imx_iim_read(struct cdev *cdev, void *buf, size_t count,
+		ulong offset, ulong flags)
+{
+	ulong size, i;
+	struct device_d *dev = cdev->dev;
+	const char *sense_param;
+	unsigned long explicit_sense = 0;
+
+	if (dev == NULL)
+		return -EINVAL;
+
+	if ((sense_param = dev_get_param(dev, "explicit_sense_enable")))
+		explicit_sense = simple_strtoul(sense_param, NULL, 0);
+
+	size = min((ulong)count, dev->size - offset);
+	if (explicit_sense) {
+		for (i = 0; i < size; i++) {
+			int row_val;
+
+			row_val = do_fuse_sense(dev->parent->map_base,
+				dev->id, (offset+i)*4);
+			if (row_val < 0)
+				return row_val;
+			((u8 *)buf)[i] = (u8)row_val;
+		}
+	} else {
+		for (i = 0; i < size; i++)
+			((u8 *)buf)[i] = ((u8 *)dev->map_base)[(offset+i)*4];
+	}
+
+	return size;
+}
+
+#ifdef CONFIG_IMX_IIM_FUSE_BLOW
+static int do_fuse_blow(unsigned long reg_base, unsigned int bank,
+		unsigned int row, u8 value)
+{
+	int bit, ret = 0;
+	u8 err, stat;
+
+	if (bank > 7) {
+		printf("%s: invalid bank number\n", __func__);
+		return -EINVAL;
+	}
+
+	if (row > 0x3ff) {
+		printf("%s: invalid row offset\n", __func__);
+		return -EINVAL;
+	}
+
+	/* clear status and error registers */
+	writeb(3, reg_base + IIM_STATM);
+	writeb(0xfe, reg_base + IIM_ERR);
+
+	/* unprotect fuse programing */
+	writeb(0xaa, reg_base + IIM_PREG_P);
+
+	/* upper half address register */
+	writeb((bank << 3) | (row >> 7), reg_base + IIM_UA);
+
+	for (bit = 0; bit < 8; bit++) {
+		if (((value >> bit) & 1) == 0)
+			continue;
+
+		/* lower half address register */
+		writeb(((row << 1) | bit), reg_base + IIM_LA);
+
+		/* start fuse programing */
+		writeb(0x71, reg_base + IIM_FCTL);
+
+		/* wait for program done */
+		while ((readb(reg_base + IIM_STAT) & 0x80) != 0)
+			;
+
+		/* clear program done status */
+		stat = readb(reg_base + IIM_STAT);
+		writeb(stat, reg_base + IIM_STAT);
+
+		err = readb(reg_base + IIM_ERR);
+		if (err) {
+			printf("%s: bank %u, row %u, bit %d program error "
+					"(0x%02x)\n", __func__, bank, row, bit, 
+					err);
+			ret = -EIO;
+			goto out;
+		}
+	}
+
+out:
+	/* protect fuse programing */
+	writeb(0, reg_base + IIM_PREG_P);
+	return ret;
+}
+#endif /* CONFIG_IMX_IIM_FUSE_BLOW */
+
+static ssize_t imx_iim_write(struct cdev *cdev, const void *buf, size_t count,
+		ulong offset, ulong flags)
+{
+	ulong size, i;
+	struct device_d *dev = cdev->dev;
+	const char *write_param;
+	unsigned int blow_enable = 0;
+
+	if (dev == NULL)
+		return -EINVAL;
+
+	if ((write_param = dev_get_param(dev, "permanent_write_enable")))
+		blow_enable = simple_strtoul(write_param, NULL, 0);
+
+	size = min((ulong)count, dev->size - offset);
+#ifdef CONFIG_IMX_IIM_FUSE_BLOW
+	if (blow_enable) {
+		for (i = 0; i < size; i++) {
+			int ret;
+
+			ret = do_fuse_blow(dev->parent->map_base, dev->id,
+					(offset+i)*4, ((u8 *)buf)[i]);
+			if (ret < 0)
+				return ret;
+		}
+	} else
+#endif /* CONFIG_IMX_IIM_FUSE_BLOW */
+	{
+		for (i = 0; i < size; i++)
+			((u8 *)dev->map_base)[(offset+i)*4] = ((u8 *)buf)[i];
+	}
+
+	return size;
+}
+
+static struct file_operations imx_iim_ops = {
+	.read	= imx_iim_read,
+	.write	= imx_iim_write,
+	.lseek	= dev_lseek_default,
+};
+
+static int imx_iim_blow_enable_set(struct device_d *dev, struct param_d *param,
+		const char *val)
+{
+	unsigned long blow_enable;
+
+	if (val == NULL)
+		return -EINVAL;
+
+	blow_enable = simple_strtoul(val, NULL, 0);
+	if (blow_enable > 1)
+		return -EINVAL;
+
+	return dev_param_set_generic(dev, param, blow_enable ? "1" : "0");
+}
+
+static int imx_iim_probe(struct device_d *dev)
+{
+	return 0;
+}
+
+static int imx_iim_bank_probe(struct device_d *dev)
+{
+	struct cdev *cdev;
+	struct device_d *parent;
+	int err;
+
+	cdev = xzalloc(sizeof (struct cdev));
+	dev->priv = cdev;
+
+	cdev->dev	= dev;
+	cdev->ops	= &imx_iim_ops;
+	cdev->size	= dev->size;
+	cdev->name	= asprintf(DRIVERNAME "_bank%d", dev->id);
+	if (cdev->name == NULL)
+		return -ENOMEM;
+
+	parent = get_device_by_name(DRIVERNAME "0");
+	if (parent == NULL)
+		return -ENODEV;
+	err = dev_add_child(parent, dev);
+	if (err < 0)
+		return err;
+
+#ifdef CONFIG_IMX_IIM_FUSE_BLOW
+	err = dev_add_param(dev, "permanent_write_enable",
+			imx_iim_blow_enable_set, NULL, 0);
+	if (err < 0)
+		return err;
+	err = dev_set_param(dev, "permanent_write_enable", "0");
+	if (err < 0)
+		return err;
+#endif /* CONFIG_IMX_IIM_FUSE_BLOW */
+
+	err = dev_add_param(dev, "explicit_sense_enable",
+			imx_iim_blow_enable_set, NULL, 0);
+	if (err < 0)
+		return err;
+	err = dev_set_param(dev, "explicit_sense_enable", "0");
+	if (err < 0)
+		return err;
+
+	return devfs_create(cdev);
+}
+
+static struct driver_d imx_iim_driver = {
+	.name	= DRIVERNAME,
+	.probe	= imx_iim_probe,
+};
+
+static struct driver_d imx_iim_bank_driver = {
+	.name	= DRIVERNAME "_bank",
+	.probe	= imx_iim_bank_probe,
+};
+
+static int imx_iim_init(void)
+{
+	register_driver(&imx_iim_driver);
+	register_driver(&imx_iim_bank_driver);
+
+	return 0;
+}
+device_initcall(imx_iim_init);
-- 
1.7.1


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 3/6] imx iim: add mac address support
  2010-08-16 14:10 [PATCH v2 0/6] imx: support for the IIM fusebox Baruch Siach
  2010-08-16 14:10 ` [PATCH v2 1/6] imx: move IIM registers to their own header Baruch Siach
  2010-08-16 14:10 ` [PATCH v2 2/6] imx: driver for the IIM fusebox Baruch Siach
@ 2010-08-16 14:10 ` Baruch Siach
  2010-08-17  6:52   ` Sascha Hauer
  2010-08-16 14:10 ` [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines Baruch Siach
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Baruch Siach @ 2010-08-16 14:10 UTC (permalink / raw)
  To: barebox

---
 arch/arm/mach-imx/iim.c              |   22 +++++++++++++++++++++-
 arch/arm/mach-imx/include/mach/iim.h |   13 +++++++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c
index 73369b7..9d14d35 100644
--- a/arch/arm/mach-imx/iim.c
+++ b/arch/arm/mach-imx/iim.c
@@ -29,6 +29,8 @@
 
 #define DRIVERNAME	"imx_iim"
 
+static unsigned long mac_addr_base;
+
 static int do_fuse_sense(unsigned long reg_base, unsigned int bank,
 		unsigned int row)
 {
@@ -224,6 +226,11 @@ static int imx_iim_blow_enable_set(struct device_d *dev, struct param_d *param,
 
 static int imx_iim_probe(struct device_d *dev)
 {
+	struct imx_iim_platform_data *pdata = dev->platform_data;
+
+	if (pdata)
+		mac_addr_base = pdata->mac_addr_base;
+
 	return 0;
 }
 
@@ -288,4 +295,17 @@ static int imx_iim_init(void)
 
 	return 0;
 }
-device_initcall(imx_iim_init);
+coredevice_initcall(imx_iim_init);
+
+int imx_iim_get_mac(unsigned char *mac)
+{
+	int i;
+
+	if (mac_addr_base == 0)
+		return -EINVAL;
+
+	for (i = 0; i < 6; i++)
+		 mac[i] = readb(mac_addr_base + i*4);
+
+	return 0;
+}
diff --git a/arch/arm/mach-imx/include/mach/iim.h b/arch/arm/mach-imx/include/mach/iim.h
index 6e13547..4d54cc0 100644
--- a/arch/arm/mach-imx/include/mach/iim.h
+++ b/arch/arm/mach-imx/include/mach/iim.h
@@ -39,4 +39,17 @@
 #define IIM_SCS2	0x0034
 #define IIM_SCS3	0x0038
 
+struct imx_iim_platform_data {
+	unsigned long	mac_addr_base;
+};
+
+#ifdef CONFIG_IMX_IIM
+int imx_iim_get_mac(unsigned char *mac);
+#else
+int imx_iim_get_mac(unsigned char *mac)
+{
+	return -EINVAL;
+}
+#endif /* CONFIG_IMX_IIM */
+
 #endif /* __MACH_IMX_IIM_H */
-- 
1.7.1


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines
  2010-08-16 14:10 [PATCH v2 0/6] imx: support for the IIM fusebox Baruch Siach
                   ` (2 preceding siblings ...)
  2010-08-16 14:10 ` [PATCH v2 3/6] imx iim: add mac address support Baruch Siach
@ 2010-08-16 14:10 ` Baruch Siach
  2011-03-03 15:13   ` Eric Benard
  2010-08-16 14:10 ` [PATCH v2 5/6] imx25: add iim platform code Baruch Siach
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Baruch Siach @ 2010-08-16 14:10 UTC (permalink / raw)
  To: barebox

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 arch/arm/mach-imx/include/mach/imx25-regs.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/include/mach/imx25-regs.h b/arch/arm/mach-imx/include/mach/imx25-regs.h
index 7c2b5f9..ac590d9 100644
--- a/arch/arm/mach-imx/include/mach/imx25-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx25-regs.h
@@ -141,7 +141,13 @@
 #define WCR_WDE 0x04
 
 /* IIM fuse definitions */
-#define IIM_UID		0x820
+#define IIM_BANK_SIZE	32	/* excluding alignment padding for each row */
+#define IIM_BANK0_BASE	(IMX_IIM_BASE + 0x800)
+#define IIM_BANK1_BASE	(IMX_IIM_BASE + 0xc00)
+#define IIM_BANK2_BASE	(IMX_IIM_BASE + 0x1000)
+
+#define IIM_UID		(IIM_BANK0_BASE + 0x20)
+#define IIM_MAC_ADDR	(IIM_BANK0_BASE + 0x68)
 
 #endif /* __ASM_ARCH_MX25_REGS_H */
 
-- 
1.7.1


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 5/6] imx25: add iim platform code
  2010-08-16 14:10 [PATCH v2 0/6] imx: support for the IIM fusebox Baruch Siach
                   ` (3 preceding siblings ...)
  2010-08-16 14:10 ` [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines Baruch Siach
@ 2010-08-16 14:10 ` Baruch Siach
  2010-08-16 14:10 ` [PATCH v2 6/6] fec_imx: add support for IIM stored mac address Baruch Siach
  2010-08-17  8:01 ` [PATCH] iim/imx25: fix MAC and UID offsets Baruch Siach
  6 siblings, 0 replies; 14+ messages in thread
From: Baruch Siach @ 2010-08-16 14:10 UTC (permalink / raw)
  To: barebox

---
 arch/arm/mach-imx/imx25.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/imx25.c b/arch/arm/mach-imx/imx25.c
index 70494aa..760f740 100644
--- a/arch/arm/mach-imx/imx25.c
+++ b/arch/arm/mach-imx/imx25.c
@@ -16,7 +16,9 @@
  */
 
 #include <common.h>
+#include <init.h>
 #include <mach/imx-regs.h>
+#include <mach/iim.h>
 #include <asm/io.h>
 
 #include "gpio.h"
@@ -46,3 +48,45 @@ u64 imx_uid(void)
 
 	return uid;
 }
+
+static struct imx_iim_platform_data imx25_iim_pdata = {
+	.mac_addr_base	= IMX_IIM_BASE + IIM_MAC_ADDR,
+};
+
+static struct device_d imx25_iim_dev = {
+	.name		= "imx_iim",
+	.map_base	= IMX_IIM_BASE,
+	.platform_data	= &imx25_iim_pdata,
+};
+
+static struct device_d imx25_iim_bank0_dev = {
+	.name		= "imx_iim_bank",
+	.id		= 0,
+	.map_base	= IIM_BANK0_BASE,
+	.size		= IIM_BANK_SIZE,
+};
+
+static struct device_d imx25_iim_bank1_dev = {
+	.name		= "imx_iim_bank",
+	.id		= 1,
+	.map_base	= IIM_BANK1_BASE,
+	.size		= IIM_BANK_SIZE,
+};
+
+static struct device_d imx25_iim_bank2_dev = {
+	.name		= "imx_iim_bank",
+	.id		= 2,
+	.map_base	= IIM_BANK2_BASE,
+	.size		= IIM_BANK_SIZE,
+};
+
+static int imx25_iim_init(void)
+{
+	register_device(&imx25_iim_dev);
+	register_device(&imx25_iim_bank0_dev);
+	register_device(&imx25_iim_bank1_dev);
+	register_device(&imx25_iim_bank2_dev);
+
+	return 0;
+}
+coredevice_initcall(imx25_iim_init);
-- 
1.7.1


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 6/6] fec_imx: add support for IIM stored mac address
  2010-08-16 14:10 [PATCH v2 0/6] imx: support for the IIM fusebox Baruch Siach
                   ` (4 preceding siblings ...)
  2010-08-16 14:10 ` [PATCH v2 5/6] imx25: add iim platform code Baruch Siach
@ 2010-08-16 14:10 ` Baruch Siach
  2010-08-17  8:01 ` [PATCH] iim/imx25: fix MAC and UID offsets Baruch Siach
  6 siblings, 0 replies; 14+ messages in thread
From: Baruch Siach @ 2010-08-16 14:10 UTC (permalink / raw)
  To: barebox

The mac address information is taken from the imx_iim driver if it's present.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 drivers/net/fec_imx.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 40a7543..9e752f6 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -32,6 +32,7 @@
 #include <mach/imx-regs.h>
 #include <clock.h>
 #include <mach/clock.h>
+#include <mach/iim.h>
 #include <xfuncs.h>
 
 #include "fec_imx.h"
@@ -235,8 +236,7 @@ static void fec_rbd_clean(int last, struct buffer_descriptor *pRbd)
 
 static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
 {
-	/* no eeprom */
-	return -1;
+	return imx_iim_get_mac(mac);
 }
 
 static int fec_set_hwaddr(struct eth_device *dev, unsigned char *mac)
-- 
1.7.1


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 3/6] imx iim: add mac address support
  2010-08-16 14:10 ` [PATCH v2 3/6] imx iim: add mac address support Baruch Siach
@ 2010-08-17  6:52   ` Sascha Hauer
  2010-08-17  8:00     ` [PATCH v3] " Baruch Siach
  0 siblings, 1 reply; 14+ messages in thread
From: Sascha Hauer @ 2010-08-17  6:52 UTC (permalink / raw)
  To: Baruch Siach; +Cc: barebox

On Mon, Aug 16, 2010 at 05:10:35PM +0300, Baruch Siach wrote:
> ---
>  arch/arm/mach-imx/iim.c              |   22 +++++++++++++++++++++-
>  arch/arm/mach-imx/include/mach/iim.h |   13 +++++++++++++
>  2 files changed, 34 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c
> index 73369b7..9d14d35 100644
> --- a/arch/arm/mach-imx/iim.c
> +++ b/arch/arm/mach-imx/iim.c
> @@ -29,6 +29,8 @@
>  
>  #define DRIVERNAME	"imx_iim"
>  
> +static unsigned long mac_addr_base;
> +
>  static int do_fuse_sense(unsigned long reg_base, unsigned int bank,
>  		unsigned int row)
>  {
> @@ -224,6 +226,11 @@ static int imx_iim_blow_enable_set(struct device_d *dev, struct param_d *param,
>  
>  static int imx_iim_probe(struct device_d *dev)
>  {
> +	struct imx_iim_platform_data *pdata = dev->platform_data;
> +
> +	if (pdata)
> +		mac_addr_base = pdata->mac_addr_base;
> +
>  	return 0;
>  }
>  
> @@ -288,4 +295,17 @@ static int imx_iim_init(void)
>  
>  	return 0;
>  }
> -device_initcall(imx_iim_init);
> +coredevice_initcall(imx_iim_init);
> +
> +int imx_iim_get_mac(unsigned char *mac)
> +{
> +	int i;
> +
> +	if (mac_addr_base == 0)
> +		return -EINVAL;
> +
> +	for (i = 0; i < 6; i++)
> +		 mac[i] = readb(mac_addr_base + i*4);
> +
> +	return 0;
> +}
> diff --git a/arch/arm/mach-imx/include/mach/iim.h b/arch/arm/mach-imx/include/mach/iim.h
> index 6e13547..4d54cc0 100644
> --- a/arch/arm/mach-imx/include/mach/iim.h
> +++ b/arch/arm/mach-imx/include/mach/iim.h
> @@ -39,4 +39,17 @@
>  #define IIM_SCS2	0x0034
>  #define IIM_SCS3	0x0038
>  
> +struct imx_iim_platform_data {
> +	unsigned long	mac_addr_base;
> +};
> +
> +#ifdef CONFIG_IMX_IIM
> +int imx_iim_get_mac(unsigned char *mac);
> +#else
> +int imx_iim_get_mac(unsigned char *mac)

static inline please. Otherwise linking fails if this function gets a
second user.

Otherwise the series looks fine. Thanks for your work.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3] imx iim: add mac address support
  2010-08-17  6:52   ` Sascha Hauer
@ 2010-08-17  8:00     ` Baruch Siach
  0 siblings, 0 replies; 14+ messages in thread
From: Baruch Siach @ 2010-08-17  8:00 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

---
 arch/arm/mach-imx/iim.c              |   22 +++++++++++++++++++++-
 arch/arm/mach-imx/include/mach/iim.h |   13 +++++++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/iim.c b/arch/arm/mach-imx/iim.c
index 73369b7..9d14d35 100644
--- a/arch/arm/mach-imx/iim.c
+++ b/arch/arm/mach-imx/iim.c
@@ -29,6 +29,8 @@
 
 #define DRIVERNAME	"imx_iim"
 
+static unsigned long mac_addr_base;
+
 static int do_fuse_sense(unsigned long reg_base, unsigned int bank,
 		unsigned int row)
 {
@@ -224,6 +226,11 @@ static int imx_iim_blow_enable_set(struct device_d *dev, struct param_d *param,
 
 static int imx_iim_probe(struct device_d *dev)
 {
+	struct imx_iim_platform_data *pdata = dev->platform_data;
+
+	if (pdata)
+		mac_addr_base = pdata->mac_addr_base;
+
 	return 0;
 }
 
@@ -288,4 +295,17 @@ static int imx_iim_init(void)
 
 	return 0;
 }
-device_initcall(imx_iim_init);
+coredevice_initcall(imx_iim_init);
+
+int imx_iim_get_mac(unsigned char *mac)
+{
+	int i;
+
+	if (mac_addr_base == 0)
+		return -EINVAL;
+
+	for (i = 0; i < 6; i++)
+		 mac[i] = readb(mac_addr_base + i*4);
+
+	return 0;
+}
diff --git a/arch/arm/mach-imx/include/mach/iim.h b/arch/arm/mach-imx/include/mach/iim.h
index 6e13547..1b290f2 100644
--- a/arch/arm/mach-imx/include/mach/iim.h
+++ b/arch/arm/mach-imx/include/mach/iim.h
@@ -39,4 +39,17 @@
 #define IIM_SCS2	0x0034
 #define IIM_SCS3	0x0038
 
+struct imx_iim_platform_data {
+	unsigned long	mac_addr_base;
+};
+
+#ifdef CONFIG_IMX_IIM
+int imx_iim_get_mac(unsigned char *mac);
+#else
+static inline int imx_iim_get_mac(unsigned char *mac)
+{
+	return -EINVAL;
+}
+#endif /* CONFIG_IMX_IIM */
+
 #endif /* __MACH_IMX_IIM_H */
-- 
1.7.1


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] iim/imx25: fix MAC and UID offsets
  2010-08-16 14:10 [PATCH v2 0/6] imx: support for the IIM fusebox Baruch Siach
                   ` (5 preceding siblings ...)
  2010-08-16 14:10 ` [PATCH v2 6/6] fec_imx: add support for IIM stored mac address Baruch Siach
@ 2010-08-17  8:01 ` Baruch Siach
  6 siblings, 0 replies; 14+ messages in thread
From: Baruch Siach @ 2010-08-17  8:01 UTC (permalink / raw)
  To: barebox

IIM_UID and IIM_MAC_ADDR are now fixed addresses.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
This should be applied on top of the "imx: support for the IIM fusebox" series.

 arch/arm/mach-imx/imx25.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/imx25.c b/arch/arm/mach-imx/imx25.c
index 760f740..e73f8ee 100644
--- a/arch/arm/mach-imx/imx25.c
+++ b/arch/arm/mach-imx/imx25.c
@@ -44,13 +44,13 @@ u64 imx_uid(void)
 	 * values in IIM are big-endian as per AN3682.
 	 */
 	for (i = 0; i < 8; i++)
-		uid |= (u64)readb(IMX_IIM_BASE + IIM_UID + i*4) << (i*8);
+		uid |= (u64)readb(IIM_UID + i*4) << (i*8);
 
 	return uid;
 }
 
 static struct imx_iim_platform_data imx25_iim_pdata = {
-	.mac_addr_base	= IMX_IIM_BASE + IIM_MAC_ADDR,
+	.mac_addr_base	= IIM_MAC_ADDR,
 };
 
 static struct device_d imx25_iim_dev = {
-- 
1.7.1


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines
  2010-08-16 14:10 ` [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines Baruch Siach
@ 2011-03-03 15:13   ` Eric Benard
  2011-03-03 15:31     ` Baruch Siach
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Benard @ 2011-03-03 15:13 UTC (permalink / raw)
  To: Baruch Siach; +Cc: barebox

Hi Baruch,

do you have an example on how to blow fuses on i.MX25 for example for setting 
the mac address or the boot configuration bits ?

Thanks
Eric

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines
  2011-03-03 15:13   ` Eric Benard
@ 2011-03-03 15:31     ` Baruch Siach
  2011-03-03 15:38       ` Eric Benard
  2011-03-03 15:46       ` Sascha Hauer
  0 siblings, 2 replies; 14+ messages in thread
From: Baruch Siach @ 2011-03-03 15:31 UTC (permalink / raw)
  To: Eric Benard; +Cc: barebox

Hi Eric,

On Thu, Mar 03, 2011 at 04:13:31PM +0100, Eric Benard wrote:
> do you have an example on how to blow fuses on i.MX25 for example
> for setting the mac address or the boot configuration bits ?

Here you go:

# allow fuses blow
imx_iim_bank0.permanent_write_enable=1
# put the MAC address 02:4b:b1:71:0f:29
mw -b -d /dev/imx_iim_bank0 26+6 0x02 0x4b 0xb1 0x71 0x0f 0x29
# make the MAC address permanent (not more fuses blow)
mw -b -d /dev/imx_iim_bank0 0+1 0x04
# disallow fuses blow
imx_iim_bank0.permanent_write_enable=0

baruch

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines
  2011-03-03 15:31     ` Baruch Siach
@ 2011-03-03 15:38       ` Eric Benard
  2011-03-03 15:46       ` Sascha Hauer
  1 sibling, 0 replies; 14+ messages in thread
From: Eric Benard @ 2011-03-03 15:38 UTC (permalink / raw)
  To: Baruch Siach; +Cc: barebox

On 03/03/2011 16:31, Baruch Siach wrote:
> Hi Eric,
>
> On Thu, Mar 03, 2011 at 04:13:31PM +0100, Eric Benard wrote:
>> do you have an example on how to blow fuses on i.MX25 for example
>> for setting the mac address or the boot configuration bits ?
>
> Here you go:
>
> # allow fuses blow
> imx_iim_bank0.permanent_write_enable=1
> # put the MAC address 02:4b:b1:71:0f:29
> mw -b -d /dev/imx_iim_bank0 26+6 0x02 0x4b 0xb1 0x71 0x0f 0x29
> # make the MAC address permanent (not more fuses blow)
> mw -b -d /dev/imx_iim_bank0 0+1 0x04
> # disallow fuses blow
> imx_iim_bank0.permanent_write_enable=0
>
many thanks, that's a very good example of a clever usage of mw ;-)

Eric

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines
  2011-03-03 15:31     ` Baruch Siach
  2011-03-03 15:38       ` Eric Benard
@ 2011-03-03 15:46       ` Sascha Hauer
  1 sibling, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2011-03-03 15:46 UTC (permalink / raw)
  To: Baruch Siach; +Cc: barebox

On Thu, Mar 03, 2011 at 05:31:47PM +0200, Baruch Siach wrote:
> Hi Eric,
> 
> On Thu, Mar 03, 2011 at 04:13:31PM +0100, Eric Benard wrote:
> > do you have an example on how to blow fuses on i.MX25 for example
> > for setting the mac address or the boot configuration bits ?
> 
> Here you go:
> 
> # allow fuses blow
> imx_iim_bank0.permanent_write_enable=1
> # put the MAC address 02:4b:b1:71:0f:29
> mw -b -d /dev/imx_iim_bank0 26+6 0x02 0x4b 0xb1 0x71 0x0f 0x29

The +6 is a noop here. mw will write the amount of data given no matter
how big the area is you specify.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-03-03 15:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-16 14:10 [PATCH v2 0/6] imx: support for the IIM fusebox Baruch Siach
2010-08-16 14:10 ` [PATCH v2 1/6] imx: move IIM registers to their own header Baruch Siach
2010-08-16 14:10 ` [PATCH v2 2/6] imx: driver for the IIM fusebox Baruch Siach
2010-08-16 14:10 ` [PATCH v2 3/6] imx iim: add mac address support Baruch Siach
2010-08-17  6:52   ` Sascha Hauer
2010-08-17  8:00     ` [PATCH v3] " Baruch Siach
2010-08-16 14:10 ` [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines Baruch Siach
2011-03-03 15:13   ` Eric Benard
2011-03-03 15:31     ` Baruch Siach
2011-03-03 15:38       ` Eric Benard
2011-03-03 15:46       ` Sascha Hauer
2010-08-16 14:10 ` [PATCH v2 5/6] imx25: add iim platform code Baruch Siach
2010-08-16 14:10 ` [PATCH v2 6/6] fec_imx: add support for IIM stored mac address Baruch Siach
2010-08-17  8:01 ` [PATCH] iim/imx25: fix MAC and UID offsets Baruch Siach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox