imx: support for the IIM fusebox
cover imx: support for the IIM fusebox
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.
The last patch in this series adds to the fec NIC driver the ability to fetch the MAC address from the IIM fusebox.
Baruch Siach (5):
imx: move IIM registers to their own header
imx: driver for the IIM fusebox
imx25: add chip specific IIM fusebox defines imx25 3ds: add support for the iim fusebox driver
fec: add support for IIM stored mac address
arch/arm/boards/freescale-mx25-3-stack/3stack.c | 31 +++ arch/arm/mach-imx/Kconfig | 18 ++ arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/iim.c | 291 +++++++++++++++++++++++ arch/arm/mach-imx/imx35.c | 1 + arch/arm/mach-imx/include/mach/iim.h | 42 ++++ arch/arm/mach-imx/include/mach/imx25-regs.h | 6 + arch/arm/mach-imx/include/mach/imx35-regs.h | 18 -- drivers/net/fec_imx.c | 11 + 9 files changed, 401 insertions(+), 18 deletions(-) create mode 100644 arch/arm/mach-imx/iim.c create mode 100644 arch/arm/mach-imx/include/mach/iim.h
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/5 imx: move IIM registers to their own header
This allows the use of IIM registers from code which is not mx35 specific.
--- 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
arch/arm/mach-imx/imx35.c +1 -0
@@ -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"
arch/arm/mach-imx/include/mach/iim.h new file +42 -0
42 lines not on this page · raw message
arch/arm/mach-imx/include/mach/imx35-regs.h +0 -18
@@ -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 */
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/5 imx: driver for the IIM fusebox
In reply to Baruch SiachThis 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.
--- 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
arch/arm/mach-imx/Kconfig +18 -0
@@ -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
arch/arm/mach-imx/Makefile +1 -0
@@ -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
arch/arm/mach-imx/iim.c new file +291 -0
291 lines not on this page · raw message
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/5 imx25: add chip specific IIM fusebox defines
In reply to Baruch Siach--- arch/arm/mach-imx/include/mach/imx25-regs.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
arch/arm/mach-imx/include/mach/imx25-regs.h +5 -0
@@ -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 */
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/5 imx25 3ds: add support for the iim fusebox driver
In reply to Baruch Siach--- arch/arm/boards/freescale-mx25-3-stack/3stack.c | 31 +++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)
arch/arm/boards/freescale-mx25-3-stack/3stack.c +31 -0
@@ -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" );
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/5 fec: add support for IIM stored mac address
In reply to Baruch SiachThis 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.
--- arch/arm/mach-imx/include/mach/imx25-regs.h | 1 + drivers/net/fec_imx.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 0 deletions(-)
arch/arm/mach-imx/include/mach/imx25-regs.h +1 -0
@@ -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)
drivers/net/fec_imx.c +11 -0
@@ -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 ; }
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH 5/5] fec: add support for IIM stored mac address
Quoted 2 lines · Baruch Siach
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_ADDRdefine.
This needs to be ifdeffed because this define is not present for !i.MX25.
Sascha
Quoted 57 lines
Signed-off-by Baruch Siach <[email protected]>--- arch/arm/mach-imx/include/mach/imx25-regs.h | 1 + drivers/net/fec_imx.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 0 deletions(-)arch/arm/mach-imx/include/mach/imx25-regs.h +1
-0@@ -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)drivers/net/fec_imx.c +11
-0@@ -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 ; }Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 5/5] fec: add support for IIM stored mac address
Hi Sascha,
Quoted 6 lines · Sascha Hauer
Quoted 2 lines · Baruch Siach
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_ADDRdefine.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
Quoted 47 lines
Quoted 47 lines
Signed-off-by Baruch Siach <[email protected]>--- arch/arm/mach-imx/include/mach/imx25-regs.h | 1 + drivers/net/fec_imx.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 0 deletions(-)arch/arm/mach-imx/include/mach/imx25-regs.h +1
-0@@ -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)drivers/net/fec_imx.c +11
-0@@ -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 ; }
Signature · 8 lines
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/bareboxSascha Hauer
maintainerRe: [PATCH 5/5] fec: add support for IIM stored mac address
Quoted 4 lines · Baruch Siach
Hi Sascha,
Quoted 1 line · Sascha Hauer
On Sun, Aug 15, 2010 at 04:39:28PM +0300, Baruch Siach wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
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_ADDRdefine.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
Quoted 56 lines
baruch
Quoted 47 lines
Quoted 47 lines
Signed-off-by Baruch Siach <[email protected]>--- arch/arm/mach-imx/include/mach/imx25-regs.h | 1 + drivers/net/fec_imx.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 0 deletions(-)arch/arm/mach-imx/include/mach/imx25-regs.h +1
-0@@ -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)drivers/net/fec_imx.c +11
-0@@ -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 ; }Signature · 3 lines
~. .~ Tk Open Systems =}------------------------------------------------ooO--U--Ooo------------{= - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerHi Baruch,
Quoted 3 lines · Baruch Siach
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 <[email protected]> Date: Mon Aug 16 10:26:52 2010 +0200
i.MX35: add iim support
arch/arm/mach-imx/imx35.c +50 -0
@@ -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 */
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Sascha,
Quoted 11 lines · Sascha Hauer
Quoted 3 lines · Baruch Siach
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
Quoted 79 lines
commit
1d47b8fe08b519e43babb7de802813359bed8e54Author: Sascha Hauer <[email protected]> Date: Mon Aug 16 10:26:52 2010 +0200i.MX35: add iim support
Signed-off-by Sascha Hauer <[email protected]>arch/arm/mach-imx/imx35.c +50
-0@@ -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 */ Signature · 5 lines
-- 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 |
Signature · 8 lines
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox