* [PATCH 1/5] imx: move IIM registers to their own header
2010-08-15 13:39 [PATCH 0/5] imx: support for the IIM fusebox Baruch Siach
@ 2010-08-15 13:39 ` Baruch Siach
2010-08-15 13:39 ` [PATCH 2/5] imx: driver for the IIM fusebox Baruch Siach
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Baruch Siach @ 2010-08-15 13:39 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] 11+ messages in thread
* [PATCH 2/5] imx: driver for the IIM fusebox
2010-08-15 13:39 [PATCH 0/5] imx: support for the IIM fusebox Baruch Siach
2010-08-15 13:39 ` [PATCH 1/5] imx: move IIM registers to their own header Baruch Siach
@ 2010-08-15 13:39 ` Baruch Siach
2010-08-15 13:39 ` [PATCH 3/5] imx25: add chip specific IIM fusebox defines Baruch Siach
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Baruch Siach @ 2010-08-15 13:39 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] 11+ messages in thread
* [PATCH 3/5] imx25: add chip specific IIM fusebox defines
2010-08-15 13:39 [PATCH 0/5] imx: support for the IIM fusebox Baruch Siach
2010-08-15 13:39 ` [PATCH 1/5] imx: move IIM registers to their own header Baruch Siach
2010-08-15 13:39 ` [PATCH 2/5] imx: driver for the IIM fusebox Baruch Siach
@ 2010-08-15 13:39 ` Baruch Siach
2010-08-15 13:39 ` [PATCH 4/5] imx25 3ds: add support for the iim fusebox driver Baruch Siach
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Baruch Siach @ 2010-08-15 13:39 UTC (permalink / raw)
To: barebox
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
arch/arm/mach-imx/include/mach/imx25-regs.h | 5 +++++
1 files changed, 5 insertions(+), 0 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..f8908f2 100644
--- a/arch/arm/mach-imx/include/mach/imx25-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx25-regs.h
@@ -143,5 +143,10 @@
/* 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)
+
#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] 11+ messages in thread
* [PATCH 4/5] imx25 3ds: add support for the iim fusebox driver
2010-08-15 13:39 [PATCH 0/5] imx: support for the IIM fusebox Baruch Siach
` (2 preceding siblings ...)
2010-08-15 13:39 ` [PATCH 3/5] imx25: add chip specific IIM fusebox defines Baruch Siach
@ 2010-08-15 13:39 ` Baruch Siach
2010-08-15 13:39 ` [PATCH 5/5] fec: add support for IIM stored mac address Baruch Siach
2010-08-16 8:33 ` [PATCH 0/5] imx: support for the IIM fusebox Sascha Hauer
5 siblings, 0 replies; 11+ messages in thread
From: Baruch Siach @ 2010-08-15 13:39 UTC (permalink / raw)
To: barebox
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
arch/arm/boards/freescale-mx25-3-stack/3stack.c | 31 +++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boards/freescale-mx25-3-stack/3stack.c b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
index cd228cc..7b96dc8 100644
--- a/arch/arm/boards/freescale-mx25-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
@@ -37,6 +37,7 @@
#include <mach/imx-flash-header.h>
#include <mach/iomux-mx25.h>
#include <mach/generic.h>
+#include <mach/iim.h>
#include <linux/err.h>
#include <i2c/i2c.h>
#include <i2c/mc34704.h>
@@ -244,6 +245,32 @@ static int imx25_3ds_fec_init(void)
}
late_initcall(imx25_3ds_fec_init);
+static struct device_d imx_iim_dev = {
+ .name = "imx_iim",
+ .map_base = IMX_IIM_BASE,
+};
+
+static struct device_d imx_iim_bank0_dev = {
+ .name = "imx_iim_bank",
+ .id = 0,
+ .map_base = IIM_BANK0_BASE,
+ .size = IIM_BANK_SIZE,
+};
+
+static struct device_d imx_iim_bank1_dev = {
+ .name = "imx_iim_bank",
+ .id = 1,
+ .map_base = IIM_BANK1_BASE,
+ .size = IIM_BANK_SIZE,
+};
+
+static struct device_d imx_iim_bank2_dev = {
+ .name = "imx_iim_bank",
+ .id = 2,
+ .map_base = IIM_BANK2_BASE,
+ .size = IIM_BANK_SIZE,
+};
+
static int imx25_devices_init(void)
{
#ifdef CONFIG_USB
@@ -259,6 +286,10 @@ static int imx25_devices_init(void)
if (readl(IMX_CCM_BASE + CCM_RCSR) & (1 << 14))
nand_info.width = 2;
+ register_device(&imx_iim_dev);
+ register_device(&imx_iim_bank0_dev);
+ register_device(&imx_iim_bank1_dev);
+ register_device(&imx_iim_bank2_dev);
register_device(&nand_dev);
devfs_add_partition("nand0", 0x00000, 0x40000, PARTITION_FIXED, "self_raw");
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 5/5] fec: add support for IIM stored mac address
2010-08-15 13:39 [PATCH 0/5] imx: support for the IIM fusebox Baruch Siach
` (3 preceding siblings ...)
2010-08-15 13:39 ` [PATCH 4/5] imx25 3ds: add support for the iim fusebox driver Baruch Siach
@ 2010-08-15 13:39 ` Baruch Siach
2010-08-16 8:45 ` Sascha Hauer
2010-08-16 8:33 ` [PATCH 0/5] imx: support for the IIM fusebox Sascha Hauer
5 siblings, 1 reply; 11+ messages in thread
From: Baruch Siach @ 2010-08-15 13:39 UTC (permalink / raw)
To: barebox
This patch adds support for i.MX25 only, because that's what I have. Extending
this to other i.MX chip should be trivial, given the right IIM_MAC_ADDR define.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
arch/arm/mach-imx/include/mach/imx25-regs.h | 1 +
drivers/net/fec_imx.c | 11 +++++++++++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-imx/include/mach/imx25-regs.h b/arch/arm/mach-imx/include/mach/imx25-regs.h
index f8908f2..ddd3e04 100644
--- a/arch/arm/mach-imx/include/mach/imx25-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx25-regs.h
@@ -142,6 +142,7 @@
/* IIM fuse definitions */
#define IIM_UID 0x820
+#define IIM_MAC_ADDR 0x868
#define IIM_BANK_SIZE 32 /* excluding alignment padding for each row */
#define IIM_BANK0_BASE (IMX_IIM_BASE + 0x800)
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 40a7543..c29119c 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/generic.h>
#include <xfuncs.h>
#include "fec_imx.h"
@@ -235,6 +236,16 @@ static void fec_rbd_clean(int last, struct buffer_descriptor *pRbd)
static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
{
+ int i;
+
+ if (cpu_is_mx25()) {
+ /* get MAC address from the IMM fusebox */
+ for (i = 0; i < 6; i++)
+ mac[i] = readb(IMX_IIM_BASE + IIM_MAC_ADDR + i*4);
+
+ return 0;
+ }
+
/* no eeprom */
return -1;
}
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] fec: add support for IIM stored mac address
2010-08-15 13:39 ` [PATCH 5/5] fec: add support for IIM stored mac address Baruch Siach
@ 2010-08-16 8:45 ` Sascha Hauer
2010-08-16 8:52 ` Baruch Siach
0 siblings, 1 reply; 11+ messages in thread
From: Sascha Hauer @ 2010-08-16 8:45 UTC (permalink / raw)
To: Baruch Siach; +Cc: barebox
On Sun, Aug 15, 2010 at 04:39:28PM +0300, Baruch Siach wrote:
> This patch adds support for i.MX25 only, because that's what I have. Extending
> this to other i.MX chip should be trivial, given the right IIM_MAC_ADDR define.
This needs to be ifdeffed because this define is not present for
!i.MX25.
Sascha
>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> arch/arm/mach-imx/include/mach/imx25-regs.h | 1 +
> drivers/net/fec_imx.c | 11 +++++++++++
> 2 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-imx/include/mach/imx25-regs.h b/arch/arm/mach-imx/include/mach/imx25-regs.h
> index f8908f2..ddd3e04 100644
> --- a/arch/arm/mach-imx/include/mach/imx25-regs.h
> +++ b/arch/arm/mach-imx/include/mach/imx25-regs.h
> @@ -142,6 +142,7 @@
>
> /* IIM fuse definitions */
> #define IIM_UID 0x820
> +#define IIM_MAC_ADDR 0x868
>
> #define IIM_BANK_SIZE 32 /* excluding alignment padding for each row */
> #define IIM_BANK0_BASE (IMX_IIM_BASE + 0x800)
> diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
> index 40a7543..c29119c 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/generic.h>
> #include <xfuncs.h>
>
> #include "fec_imx.h"
> @@ -235,6 +236,16 @@ static void fec_rbd_clean(int last, struct buffer_descriptor *pRbd)
>
> static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
> {
> + int i;
> +
> + if (cpu_is_mx25()) {
> + /* get MAC address from the IMM fusebox */
> + for (i = 0; i < 6; i++)
> + mac[i] = readb(IMX_IIM_BASE + IIM_MAC_ADDR + i*4);
> +
> + return 0;
> + }
> +
> /* no eeprom */
> return -1;
> }
> --
> 1.7.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
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] 11+ messages in thread
* Re: [PATCH 5/5] fec: add support for IIM stored mac address
2010-08-16 8:45 ` Sascha Hauer
@ 2010-08-16 8:52 ` Baruch Siach
2010-08-16 9:02 ` Sascha Hauer
0 siblings, 1 reply; 11+ messages in thread
From: Baruch Siach @ 2010-08-16 8:52 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Hi Sascha,
On Mon, Aug 16, 2010 at 10:45:06AM +0200, Sascha Hauer wrote:
> On Sun, Aug 15, 2010 at 04:39:28PM +0300, Baruch Siach wrote:
> > This patch adds support for i.MX25 only, because that's what I have. Extending
> > this to other i.MX chip should be trivial, given the right IIM_MAC_ADDR define.
>
> This needs to be ifdeffed because this define is not present for
> !i.MX25.
OK. I hoped we can avoid the ugly ifdef, but, obviously, this is not possible
here.
baruch
> > Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> > ---
> > arch/arm/mach-imx/include/mach/imx25-regs.h | 1 +
> > drivers/net/fec_imx.c | 11 +++++++++++
> > 2 files changed, 12 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/arm/mach-imx/include/mach/imx25-regs.h b/arch/arm/mach-imx/include/mach/imx25-regs.h
> > index f8908f2..ddd3e04 100644
> > --- a/arch/arm/mach-imx/include/mach/imx25-regs.h
> > +++ b/arch/arm/mach-imx/include/mach/imx25-regs.h
> > @@ -142,6 +142,7 @@
> >
> > /* IIM fuse definitions */
> > #define IIM_UID 0x820
> > +#define IIM_MAC_ADDR 0x868
> >
> > #define IIM_BANK_SIZE 32 /* excluding alignment padding for each row */
> > #define IIM_BANK0_BASE (IMX_IIM_BASE + 0x800)
> > diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
> > index 40a7543..c29119c 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/generic.h>
> > #include <xfuncs.h>
> >
> > #include "fec_imx.h"
> > @@ -235,6 +236,16 @@ static void fec_rbd_clean(int last, struct buffer_descriptor *pRbd)
> >
> > static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
> > {
> > + int i;
> > +
> > + if (cpu_is_mx25()) {
> > + /* get MAC address from the IMM fusebox */
> > + for (i = 0; i < 6; i++)
> > + mac[i] = readb(IMX_IIM_BASE + IIM_MAC_ADDR + i*4);
> > +
> > + return 0;
> > + }
> > +
> > /* no eeprom */
> > return -1;
> > }
--
~. .~ 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] 11+ messages in thread
* Re: [PATCH 5/5] fec: add support for IIM stored mac address
2010-08-16 8:52 ` Baruch Siach
@ 2010-08-16 9:02 ` Sascha Hauer
0 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2010-08-16 9:02 UTC (permalink / raw)
To: Baruch Siach; +Cc: barebox
On Mon, Aug 16, 2010 at 11:52:54AM +0300, Baruch Siach wrote:
> Hi Sascha,
>
> On Mon, Aug 16, 2010 at 10:45:06AM +0200, Sascha Hauer wrote:
> > On Sun, Aug 15, 2010 at 04:39:28PM +0300, Baruch Siach wrote:
> > > This patch adds support for i.MX25 only, because that's what I have. Extending
> > > this to other i.MX chip should be trivial, given the right IIM_MAC_ADDR define.
> >
> > This needs to be ifdeffed because this define is not present for
> > !i.MX25.
>
> OK. I hoped we can avoid the ugly ifdef, but, obviously, this is not possible
> here.
Well, we could. You could provide platform data to the iim device,
telling the iim driver where to find the mac address and a
imx_iim_get_mac() function. This function returns -EINVAL when the
platform data is missing.
Sascha
>
> baruch
>
> > > Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> > > ---
> > > arch/arm/mach-imx/include/mach/imx25-regs.h | 1 +
> > > drivers/net/fec_imx.c | 11 +++++++++++
> > > 2 files changed, 12 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/arch/arm/mach-imx/include/mach/imx25-regs.h b/arch/arm/mach-imx/include/mach/imx25-regs.h
> > > index f8908f2..ddd3e04 100644
> > > --- a/arch/arm/mach-imx/include/mach/imx25-regs.h
> > > +++ b/arch/arm/mach-imx/include/mach/imx25-regs.h
> > > @@ -142,6 +142,7 @@
> > >
> > > /* IIM fuse definitions */
> > > #define IIM_UID 0x820
> > > +#define IIM_MAC_ADDR 0x868
> > >
> > > #define IIM_BANK_SIZE 32 /* excluding alignment padding for each row */
> > > #define IIM_BANK0_BASE (IMX_IIM_BASE + 0x800)
> > > diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
> > > index 40a7543..c29119c 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/generic.h>
> > > #include <xfuncs.h>
> > >
> > > #include "fec_imx.h"
> > > @@ -235,6 +236,16 @@ static void fec_rbd_clean(int last, struct buffer_descriptor *pRbd)
> > >
> > > static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
> > > {
> > > + int i;
> > > +
> > > + if (cpu_is_mx25()) {
> > > + /* get MAC address from the IMM fusebox */
> > > + for (i = 0; i < 6; i++)
> > > + mac[i] = readb(IMX_IIM_BASE + IIM_MAC_ADDR + i*4);
> > > +
> > > + return 0;
> > > + }
> > > +
> > > /* no eeprom */
> > > return -1;
> > > }
>
> --
> ~. .~ Tk Open Systems
> =}------------------------------------------------ooO--U--Ooo------------{=
> - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
>
--
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] 11+ messages in thread
* Re: [PATCH 0/5] imx: support for the IIM fusebox
2010-08-15 13:39 [PATCH 0/5] imx: support for the IIM fusebox Baruch Siach
` (4 preceding siblings ...)
2010-08-15 13:39 ` [PATCH 5/5] fec: add support for IIM stored mac address Baruch Siach
@ 2010-08-16 8:33 ` Sascha Hauer
2010-08-16 8:47 ` Baruch Siach
5 siblings, 1 reply; 11+ messages in thread
From: Sascha Hauer @ 2010-08-16 8:33 UTC (permalink / raw)
To: Baruch Siach; +Cc: barebox
Hi Baruch,
On Sun, Aug 15, 2010 at 04:39:23PM +0300, Baruch Siach wrote:
> 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.
Much better, thanks. I just tested this on an i.MX35 and it works fine.
I used the following patch to add support for the i.MX35. I think it's
better to put the IIM device info into a i.MX35 specific file. The
device does not need any platform data, and it is much code duplicated
into each board otherwise. Maybe you can do this change for the i.MX25
aswell.
Sascha
commit 1d47b8fe08b519e43babb7de802813359bed8e54
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date: Mon Aug 16 10:26:52 2010 +0200
i.MX35: add iim support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c
index 74d63eb..72851f7 100644
--- a/arch/arm/mach-imx/imx35.c
+++ b/arch/arm/mach-imx/imx35.c
@@ -16,6 +16,7 @@
*/
#include <common.h>
+#include <init.h>
#include <asm/io.h>
#include <mach/imx-regs.h>
#include <mach/iim.h>
@@ -39,3 +40,52 @@ int imx_silicon_revision()
return (reg & 0xFF);
}
+
+#ifdef CONFIG_IMX_IIM
+#define IIM_BANK_SIZE 32 /* excluding alignment padding for each row */
+
+static struct device_d imx_iim_dev = {
+ .name = "imx_iim",
+ .map_base = IMX_IIM_BASE,
+};
+
+static struct device_d imx_iim_bank0_dev = {
+ .name = "imx_iim_bank",
+ .id = 0,
+ .map_base = IMX_IIM_BASE + 0x800,
+ .size = IIM_BANK_SIZE,
+};
+
+static struct device_d imx_iim_bank1_dev = {
+ .name = "imx_iim_bank",
+ .id = 1,
+ .map_base = IMX_IIM_BASE + 0xc00,
+ .size = IIM_BANK_SIZE,
+};
+
+static struct device_d imx_iim_bank2_dev = {
+ .name = "imx_iim_bank",
+ .id = 2,
+ .map_base = IMX_IIM_BASE + 0x1000,
+ .size = IIM_BANK_SIZE,
+};
+
+static int imx35_iim_init(void)
+{
+ uint32_t reg;
+
+ /* Start the clock */
+ reg = readl(IMX_CCM_BASE + CCM_CGR3);
+ reg |= (3 << 2);
+ writel(reg, IMX_CCM_BASE + CCM_CGR3);
+
+ register_device(&imx_iim_dev);
+ register_device(&imx_iim_bank0_dev);
+ register_device(&imx_iim_bank1_dev);
+ register_device(&imx_iim_bank2_dev);
+
+ return 0;
+}
+
+device_initcall(imx35_iim_init);
+#endif /* CONFIG_IMX_IIM */
--
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] 11+ messages in thread
* Re: [PATCH 0/5] imx: support for the IIM fusebox
2010-08-16 8:33 ` [PATCH 0/5] imx: support for the IIM fusebox Sascha Hauer
@ 2010-08-16 8:47 ` Baruch Siach
0 siblings, 0 replies; 11+ messages in thread
From: Baruch Siach @ 2010-08-16 8:47 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Hi Sascha,
On Mon, Aug 16, 2010 at 10:33:30AM +0200, Sascha Hauer wrote:
> On Sun, Aug 15, 2010 at 04:39:23PM +0300, Baruch Siach wrote:
> > 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.
>
> Much better, thanks. I just tested this on an i.MX35 and it works fine.
> I used the following patch to add support for the i.MX35. I think it's
> better to put the IIM device info into a i.MX35 specific file. The
> device does not need any platform data, and it is much code duplicated
> into each board otherwise. Maybe you can do this change for the i.MX25
> aswell.
OK. I'll fold the platform code into patch 3, and send as a reply to that
patch. You can then drop no. 4.
baruch
> commit 1d47b8fe08b519e43babb7de802813359bed8e54
> Author: Sascha Hauer <s.hauer@pengutronix.de>
> Date: Mon Aug 16 10:26:52 2010 +0200
>
> i.MX35: add iim support
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
>
> diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c
> index 74d63eb..72851f7 100644
> --- a/arch/arm/mach-imx/imx35.c
> +++ b/arch/arm/mach-imx/imx35.c
> @@ -16,6 +16,7 @@
> */
>
> #include <common.h>
> +#include <init.h>
> #include <asm/io.h>
> #include <mach/imx-regs.h>
> #include <mach/iim.h>
> @@ -39,3 +40,52 @@ int imx_silicon_revision()
>
> return (reg & 0xFF);
> }
> +
> +#ifdef CONFIG_IMX_IIM
> +#define IIM_BANK_SIZE 32 /* excluding alignment padding for each row */
> +
> +static struct device_d imx_iim_dev = {
> + .name = "imx_iim",
> + .map_base = IMX_IIM_BASE,
> +};
> +
> +static struct device_d imx_iim_bank0_dev = {
> + .name = "imx_iim_bank",
> + .id = 0,
> + .map_base = IMX_IIM_BASE + 0x800,
> + .size = IIM_BANK_SIZE,
> +};
> +
> +static struct device_d imx_iim_bank1_dev = {
> + .name = "imx_iim_bank",
> + .id = 1,
> + .map_base = IMX_IIM_BASE + 0xc00,
> + .size = IIM_BANK_SIZE,
> +};
> +
> +static struct device_d imx_iim_bank2_dev = {
> + .name = "imx_iim_bank",
> + .id = 2,
> + .map_base = IMX_IIM_BASE + 0x1000,
> + .size = IIM_BANK_SIZE,
> +};
> +
> +static int imx35_iim_init(void)
> +{
> + uint32_t reg;
> +
> + /* Start the clock */
> + reg = readl(IMX_CCM_BASE + CCM_CGR3);
> + reg |= (3 << 2);
> + writel(reg, IMX_CCM_BASE + CCM_CGR3);
> +
> + register_device(&imx_iim_dev);
> + register_device(&imx_iim_bank0_dev);
> + register_device(&imx_iim_bank1_dev);
> + register_device(&imx_iim_bank2_dev);
> +
> + return 0;
> +}
> +
> +device_initcall(imx35_iim_init);
> +#endif /* CONFIG_IMX_IIM */
>
> --
> 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 |
--
~. .~ 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] 11+ messages in thread