imx: support for the IIM fusebox
v2 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.
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/6 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 v2 2/6 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 v2 3/6 imx iim: add mac address support
In reply to Baruch Siach--- arch/arm/mach-imx/iim.c | 22 +++++++++++++++++++++- arch/arm/mach-imx/include/mach/iim.h | 13 +++++++++++++ 2 files changed, 34 insertions(+), 1 deletions(-)
arch/arm/mach-imx/iim.c +21 -1
@@ -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 ; +}
arch/arm/mach-imx/include/mach/iim.h +13 -0
@@ -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 */
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH v2 3/6] imx iim: add mac address support
Quoted 55 lines · Baruch Siach
--- arch/arm/mach-imx/iim.c | 22 +++++++++++++++++++++- arch/arm/mach-imx/include/mach/iim.h | 13 +++++++++++++ 2 files changed, 34 insertions(+), 1 deletions(-)arch/arm/mach-imx/iim.c +21
-1@@ -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 ; +}arch/arm/mach-imx/include/mach/iim.h +0
-0@@ -39,4 +39,17 @@#define IIM_SCS2 0x0034
arch/arm/mach-imx/include/mach/iim.h line 49
Quoted 10 lines
arch/arm/mach-imx/include/mach/iim.h +8
-0#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
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
PATCH v3 1/1 imx iim: add mac address support
--- arch/arm/mach-imx/iim.c | 22 +++++++++++++++++++++- arch/arm/mach-imx/include/mach/iim.h | 13 +++++++++++++ 2 files changed, 34 insertions(+), 1 deletions(-)
arch/arm/mach-imx/iim.c +21 -1
@@ -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 ; +}
arch/arm/mach-imx/include/mach/iim.h +13 -0
@@ -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 */
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 4/6 imx25: add chip specific IIM fusebox defines
In reply to Baruch Siach--- arch/arm/mach-imx/include/mach/imx25-regs.h | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
arch/arm/mach-imx/include/mach/imx25-regs.h +7 -1
@@ -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 */
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines
Hi Eric,
Quoted 2 lines · Eric Benard
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
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/bareboxRe: [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines
Quoted 8 lines · Baruch Siach
Hi Eric,
Quoted 2 lines · Eric Benard
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:
Quoted 9 lines
# 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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH v2 4/6] imx25: add chip specific IIM fusebox defines
In reply to Baruch SiachQuoted 6 lines · Baruch Siach
Hi Eric,
Quoted 2 lines · Eric Benard
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 ?
Quoted 6 lines
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
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
PATCH v2 5/6 imx25: add iim platform code
In reply to Baruch Siach--- arch/arm/mach-imx/imx25.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)
arch/arm/mach-imx/imx25.c +44 -0
@@ -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);
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 6/6 fec_imx: add support for IIM stored mac address
In reply to Baruch SiachThe mac address information is taken from the imx_iim driver if it's present.
--- drivers/net/fec_imx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/fec_imx.c +2 -2
@@ -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)
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/1 iim/imx25: fix MAC and UID offsets
In reply to Baruch SiachIIM_UID and IIM_MAC_ADDR are now fixed addresses.
---
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(-)
arch/arm/mach-imx/imx25.c +2 -2
@@ -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 = {
Signature · 7 lines
1.7.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox