Support for OTP memory
Subsystems (2)
v4 cover Support for OTP memory
Hi all,
This series of the OTP memory support has been updated since v3 with the following main changes:
- The device specific ioctl() has now been eliminated and an OTP_LOCK_AREA ioctl() has been added that uses the new lock_word() operation to perform locking of OTP.
- The read_word/write_word operations are now per-device operations rather than per-region.
- A word_size attribute has been added so that users can get the OTP word size (useful for the area locking).
- Regions can have labels (a bit like partition names).
- The sysfs show/store functions now take a backend module reference before accessing the operations to prevent a possible invalid reference when the backend module is unloaded.
Thanks,
Jamie Iles (4):
drivers/otp: add initial support for OTP memory drivers/otp: add support for Picoxcell PC3X3 OTP
Blackfin: add the OTP device as a platform device drivers/otp: convert bfin otp to generic OTP
Documentation/ABI/testing/sysfs-bus-otp | 93 +++
Documentation/ioctl/ioctl-number.txt | 1 +
arch/blackfin/mach-bf518/boards/ezbrd.c | 10 +
arch/blackfin/mach-bf518/boards/tcm-bf518.c | 10 +
arch/blackfin/mach-bf527/boards/ad7160eval.c | 10 +
arch/blackfin/mach-bf527/boards/cm_bf527.c | 10 +
arch/blackfin/mach-bf527/boards/ezbrd.c | 10 +
arch/blackfin/mach-bf527/boards/ezkit.c | 10 +
arch/blackfin/mach-bf527/boards/tll6527m.c | 10 +
arch/blackfin/mach-bf548/boards/cm_bf548.c | 9 +
arch/blackfin/mach-bf548/boards/ezkit.c | 10 +
drivers/Kconfig | 2 +
drivers/Makefile | 1 +
drivers/char/Kconfig | 28 -
drivers/char/Makefile | 1 -
drivers/otp/Kconfig | 51 ++
drivers/otp/Makefile | 3 +
drivers/{char => otp}/bfin-otp.c | 261 +++----
drivers/otp/otp.c | 1051 ++++++++++++++++++++++++
drivers/otp/otp_pc3x3.c | 1102 ++++++++++++++++++++++++++
include/linux/otp.h | 305 +++++++
21 files changed, 2819 insertions(+), 169 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-bus-otp
create mode 100644 drivers/otp/Kconfig
create mode 100644 drivers/otp/Makefile
rename drivers/{char => otp}/bfin-otp.c (44%)
create mode 100644 drivers/otp/otp.c
create mode 100644 drivers/otp/otp_pc3x3.c
create mode 100644 include/linux/otp.hSignature · 1 line
1.7.4
RFC PATCH v4 1/4 drivers/otp: add initial support for OTP memory
OTP memory is typically found in some embedded devices and can be used for storing boot code, cryptographic keys and other persistent information onchip. This patch adds a generic layer that devices can register OTP with and allows access through a set of character device nodes.
Changes since v3:
- Allow regions to have labels.
- Add a word_size attribute to allow users to query the OTP word size.
- Support the locking of words in OTP through the OTP_LOCK_AREA ioctl() and the lock_word() device operation.
- Move the read_word/write_word operations into the device operations from region operations.
- Take a backend module reference in sysfs show/store function.
Changes since v2:
- Updated ABI documentation.
- Don't put the OTP regions directly in /sys/bus/otp/devices.
- Squash the ioctl addition patch into this one.
- Add CONFIG_OTP_WRITE_ENABLE to allow OTP support to be build without allowing write accesses to OTP.
- Add the "ecc" redundancy format.
- Permit registration of multiple OTP devices.
--- Documentation/ABI/testing/sysfs-bus-otp | 93 +++ Documentation/ioctl/ioctl-number.txt | 1 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/otp/Kconfig | 28 + drivers/otp/Makefile | 1 + drivers/otp/otp.c | 1051 +++++++++++++++++++++++++++++++ include/linux/otp.h | 305 +++++++++ 8 files changed, 1482 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-otp create mode 100644 drivers/otp/Kconfig create mode 100644 drivers/otp/Makefile create mode 100644 drivers/otp/otp.c create mode 100644 include/linux/otp.h
Documentation/ABI/testing/sysfs-bus-otp new file +93 -0
@@ -0,0 +1,93 @@ +What: /sys/bus/otp/ +Date: March 2011 +KernelVersion: 2.6.40+ +Contact: Jamie Iles <[email protected]> +Description: + The otp (One Time Programmable memory) bus presents a number + of devices where each device represents and OTP device in the + system. An OTP device may have a number of regions (which can + be thought of as partitions) and the regions are child + devices. Each region will create a device node which allows + the region to be written with read()/write() calls and the + device on the bus has attributes for controlling the + redundancy format and getting the region size. + +What: /sys/bus/devices/otp#/ +Date: March 2011 +KernelVersion: 2.6.40+ +Contact: Jamie Iles <[email protected]> +Description: + Each otp# directory represents an OTP device in the system. + The device has attributes that affect all of the regions in + the device such as write_enable and the number of regions. + +What: /sys/bus/devices/otp#/otp#N +Date: March 2011 +KernelVersion: 2.6.40+ +Contact: Jamie Iles <[email protected]> +Description: + Each otp#N directory represents a region in the otp# device. + A region may be read from/written to through the character + device node named after the otp#N name. + +What: /sys/bus/devices/otp#/write_enable +Date: March 2011 +KernelVersion: 2.6.40+ +Contact: Jamie Iles <[email protected]> +Description: + This file controls whether the OTP device can be written to. + If set to "enabled" then the regions may be written, the + number of regions may be changed and the format of any region + may be changed. + +What: /sys/bus/devices/otp#/num_regions +Date: March 2011 +KernelVersion: 2.6.40+ +Contact: Jamie Iles <[email protected]> +Description: + This file controls the number of regions in the OTP device. + Valid values are 1, 2, 4 and 8. The number of regions may be + increased but never decreased. Increasing the number of + regions will create new devices on the otp bus. + +What: /sys/bus/devices/otp#/strict_programming +Date: March 2011 +KernelVersion: 2.6.40+ +Contact: Jamie Iles <[email protected]> +Description: + This file indicates whether all words in a redundant format + must be programmed correctly to indicate success. For + example, using the "redundant format", the same word is + written to two locations and wire-OR'd when reading back. + Disabling this will mean that programming will be considered a + success if the word can be read back correctly in its + redundant format even if there are bit errors when programming + the extra redundancy words. + +What: /sys/bus/otp/devices/otp#/otp#N/format +Date: March 2011 +KernelVersion: 2.6.40+ +Contact: Jamie Iles <[email protected]> +Description: + The redundancy format of the region. Valid values are: + - single-ended (1 bit of storage per data bit). + - redundant (2 bits of storage, wire-OR'd per data + bit). + - differential (2 bits of storage, differential + voltage per data bit). + - differential-redundant (4 bits of storage, combining + redundant and differential). + - ecc (transparent to the user) + Depending on the device type, it may be possible to increase + redundancy of a region but care will be needed if there is + data already in the region. + +What: /sys/bus/otp/devices/otp#/otp#N/size +Date: March 2011 +KernelVersion: 2.6.40+ +Contact: Jamie Iles <[email protected]> +Description: + The effective storage size of the region. This is the amount + of data that a user can store in the region taking into + account the number of regions and the redundancy format of the + region itself.
Documentation/ioctl/ioctl-number.txt +1 -0
@@ -150,6 +150,7 @@ Code Seq#(hex) Include File Comments 'M' 00-0F drivers/video/fsl-diu-fb.h conflict! 'N' 00-1F drivers/usb/scanner.h 'O' 00-06 mtd/ubi-user.h UBI +'O' 10-1F include/linux/otp.h OTP 'P' all linux/soundcard.h conflict! 'P' 60-6F sound/sscape_ioctl.h conflict! 'P' 00-0F drivers/usb/class/usblp.c conflict!
drivers/Kconfig +2 -0
@@ -119,4 +119,6 @@ source "drivers/platform/Kconfig" source "drivers/clk/Kconfig" source "drivers/hwspinlock/Kconfig" + +source "drivers/otp/Kconfig" endmenu
drivers/Makefile +1 -0
@@ -119,3 +119,4 @@ obj-y += ieee802154/ obj-y += clk/ obj-$(CONFIG_HWSPINLOCK) += hwspinlock/ +obj-$(CONFIG_OTP) += otp/
drivers/otp/Kconfig new file +28 -0
@@ -0,0 +1,28 @@ +# +# OTP memory configuration +# + +menuconfig OTP + bool "OTP memory support" + help + Say Y here to support OTP (One Time Programmable) memory. This + memory can commonly be used to store boot code, cryptographic keys + and other persistent data. This memory is typically a few KBytes in + size and different devices may have different characteristics. This + provides a character device interface to these devices to allow the + OTP to be programmed and read. + +if OTP + +config OTP_WRITE_ENABLE + bool "Enable writing support of OTP pages" + default n + help + If you say Y here, you will enable support for writing of the + OTP pages. This is dangerous by nature as you can only program + the pages once, so only enable this option when you actually + need it so as to not inadvertently clobber data. + + If unsure, say N. + +endif
drivers/otp/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_OTP) += otp.o
drivers/otp/otp.c new file +1051 -0
1,051 lines not on this page · raw message
include/linux/otp.h new file +305 -0
305 lines not on this page · raw message
Signature · 1 line
1.7.4
RFC PATCH v4 2/4 drivers/otp: add support for Picoxcell PC3X3 OTP
In reply to Jamie IlesThe OTP in PC3X3 is 16KB and can be split into 1, 2, 4 or 8 regions each taking a different redundancy format. The formats increase the redundancy of the memory at the expense of bit storage to help protect against programming errors for devices in the field.
Changes since v3:
- Move the read_word/write_word ops into device ops.
Changes since v2:
- Add support for CONFIG_OTP_WRITE_ENABLE.
--- drivers/otp/Kconfig | 7 + drivers/otp/Makefile | 1 + drivers/otp/otp_pc3x3.c | 1102 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1110 insertions(+), 0 deletions(-) create mode 100644 drivers/otp/otp_pc3x3.c
drivers/otp/Kconfig +7 -0
@@ -25,4 +25,11 @@ config OTP_WRITE_ENABLE If unsure, say N. +config OTP_PC3X3 + tristate "Enable support for Picochip PC3X3 OTP" + depends on ARCH_PICOXCELL + help + Say Y or M here to allow support for the OTP found in PC3X3 devices. + If you say M then the module will be called otp_pc3x3. + endif
drivers/otp/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_OTP) += otp.o +obj-$(CONFIG_OTP_PC3X3) += otp_pc3x3.o
drivers/otp/otp_pc3x3.c new file +1102 -0
1,102 lines not on this page · raw message
Signature · 1 line
1.7.4
RFC PATCH v4 3/4 Blackfin: add the OTP device as a platform device
In reply to Jamie IlesRegister the OTP as a platform device so that we can use the generic OTP subsystem.
--- arch/blackfin/mach-bf518/boards/ezbrd.c | 10 ++++++++++ arch/blackfin/mach-bf518/boards/tcm-bf518.c | 10 ++++++++++ arch/blackfin/mach-bf527/boards/ad7160eval.c | 10 ++++++++++ arch/blackfin/mach-bf527/boards/cm_bf527.c | 10 ++++++++++ arch/blackfin/mach-bf527/boards/ezbrd.c | 10 ++++++++++ arch/blackfin/mach-bf527/boards/ezkit.c | 10 ++++++++++ arch/blackfin/mach-bf527/boards/tll6527m.c | 10 ++++++++++ arch/blackfin/mach-bf548/boards/cm_bf548.c | 9 +++++++++ arch/blackfin/mach-bf548/boards/ezkit.c | 10 ++++++++++ 9 files changed, 89 insertions(+), 0 deletions(-)
arch/blackfin/mach-bf518/boards/ezbrd.c +10 -0
@@ -747,6 +747,12 @@ static struct platform_device bfin_dpmc = { }, }; +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) +static struct platform_device bfin_otp_device = { + .name ="bfin-otp" , +}; +#endif +static struct platform_device *stamp_devices[]__initdata = { &bfin_dpmc,
@@ -814,6 +820,10 @@ static struct platform_device *stamp_devices[] __initdata = {#if defined(CONFIG_MTD_PHYSMAP ) || defined(CONFIG_MTD_PHYSMAP_MODULE ) &ezbrd_flash_device,#endif + +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) + &bfin_otp_device, +#endif };static int __init ezbrd_init (void )
arch/blackfin/mach-bf518/boards/tcm-bf518.c +10 -0
@@ -659,6 +659,12 @@ static struct platform_device bfin_dpmc = { }, }; +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) +static struct platform_device bfin_otp_device = { + .name ="bfin-otp" , +}; +#endif +static struct platform_device *tcm_devices[]__initdata = { &bfin_dpmc,
@@ -719,6 +725,10 @@ static struct platform_device *tcm_devices[] __initdata = {#if defined(CONFIG_MTD_PHYSMAP ) || defined(CONFIG_MTD_PHYSMAP_MODULE ) &tcm_flash_device,#endif + +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) + &bfin_otp_device, +#endif };static int __init tcm_init (void )
arch/blackfin/mach-bf527/boards/ad7160eval.c +10 -0
@@ -731,6 +731,12 @@ static struct platform_device bfin_dpmc = { }, }; +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) +static struct platform_device bfin_otp_device = { + .name ="bfin-otp" , +}; +#endif +static struct platform_device *stamp_devices[]__initdata = { &bfin_dpmc,
@@ -806,6 +812,10 @@ static struct platform_device *stamp_devices[] __initdata = {#if defined(CONFIG_SND_BF5XX_TDM ) || defined(CONFIG_SND_BF5XX_TDM_MODULE ) &bfin_tdm,#endif + +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) + &bfin_otp_device, +#endif };static int __init ad7160eval_init (void )
arch/blackfin/mach-bf527/boards/cm_bf527.c +10 -0
@@ -896,6 +896,12 @@ static struct platform_device bfin_dpmc = { }, }; +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) +static struct platform_device bfin_otp_device = { + .name ="bfin-otp" , +}; +#endif +static struct platform_device *cmbf527_devices[]__initdata = { &bfin_dpmc,
@@ -979,6 +985,10 @@ static struct platform_device *cmbf527_devices[] __initdata = {#if defined(CONFIG_MTD_GPIO_ADDR ) || defined(CONFIG_MTD_GPIO_ADDR_MODULE ) &cm_flash_device,#endif + +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) + &bfin_otp_device, +#endif };static int __init cm_init (void )
arch/blackfin/mach-bf527/boards/ezbrd.c +10 -0
@@ -806,6 +806,12 @@ static struct platform_device bfin_lq035q1_device = { };#endif +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) +static struct platform_device bfin_otp_device = { + .name ="bfin-otp" , +}; +#endif +static struct platform_device *stamp_devices[]__initdata = { &bfin_dpmc,
@@ -873,6 +879,10 @@ static struct platform_device *stamp_devices[] __initdata = {#if defined(CONFIG_MTD_PHYSMAP ) || defined(CONFIG_MTD_PHYSMAP_MODULE ) &ezbrd_flash_device,#endif + +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) + &bfin_otp_device, +#endif };static int __init ezbrd_init (void )
arch/blackfin/mach-bf527/boards/ezkit.c +10 -0
@@ -1115,6 +1115,12 @@ static struct platform_device bfin_dpmc = { }, }; +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) +static struct platform_device bfin_otp_device = { + .name ="bfin-otp" , +}; +#endif +static struct platform_device *stamp_devices[]__initdata = { &bfin_dpmc,
@@ -1218,6 +1224,10 @@ static struct platform_device *stamp_devices[] __initdata = {#if defined(CONFIG_SND_BF5XX_TDM ) || defined(CONFIG_SND_BF5XX_TDM_MODULE ) &bfin_tdm,#endif + +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) + &bfin_otp_device, +#endif };static int __init ezkit_init (void )
arch/blackfin/mach-bf527/boards/tll6527m.c +10 -0
@@ -873,6 +873,12 @@ static struct platform_device bfin_dpmc = { }, }; +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) +static struct platform_device bfin_otp_device = { + .name ="bfin-otp" , +}; +#endif +static struct platform_device *tll6527m_devices[]__initdata = { &bfin_dpmc,
@@ -941,6 +947,10 @@ static struct platform_device *tll6527m_devices[] __initdata = {#if defined(CONFIG_GPIO_DECODER ) || defined(CONFIG_GPIO_DECODER_MODULE ) &spi_decoded_gpio,#endif + +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) + &bfin_otp_device, +#endif };static int __init tll6527m_init (void )
arch/blackfin/mach-bf548/boards/cm_bf548.c +9 -0
@@ -1093,6 +1093,12 @@ static struct platform_device bfin_dpmc = { }, }; +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) +static struct platform_device bfin_otp_device = { + .name ="bfin-otp" , +}; +#endif +static struct platform_device *cm_bf548_devices[]__initdata = { &bfin_dpmc,
@@ -1198,6 +1204,9 @@ static struct platform_device *cm_bf548_devices[] __initdata = { &bfin_can_device,#endif +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) + &bfin_otp_device, +#endif };static int __init cm_bf548_init (void )
arch/blackfin/mach-bf548/boards/ezkit.c +10 -0
@@ -1336,6 +1336,12 @@ static struct platform_device bfin_ac97 = { };#endif +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) +static struct platform_device bfin_otp_device = { + .name ="bfin-otp" , +}; +#endif +static struct platform_device *ezkit_devices[]__initdata = { &bfin_dpmc,
@@ -1461,6 +1467,10 @@ static struct platform_device *ezkit_devices[] __initdata = {#if defined(CONFIG_SND_BF5XX_AC97 ) || defined(CONFIG_SND_BF5XX_AC97_MODULE ) &bfin_ac97,#endif + +#if defined(CONFIG_BFIN_OTP ) || defined(CONFIG_BFIN_OTP_MODULE ) + &bfin_otp_device, +#endif };static int __init ezkit_init (void )
Signature · 1 line
1.7.4
RFC PATCH v4 4/4 drivers/otp: convert bfin otp to generic OTP
In reply to Jamie IlesConvert the blackfin OTP driver to the generic OTP layer.
Changes since v3:
- Use the lock_word device operation to allow OTP are locking through the OTP_LOCK_AREA ioctl().
- Convert read_word/write_word to device operations.
Changes since v2:
- Convert bfin-otp to a platform_driver.
- Hide the ECC and control bits from the character device interface.
---
drivers/char/Kconfig | 28 ----
drivers/char/Makefile | 1 -
drivers/otp/Kconfig | 16 +++
drivers/otp/Makefile | 1 +
drivers/{char => otp}/bfin-otp.c | 261 ++++++++++++++++++--------------------
5 files changed, 138 insertions(+), 169 deletions(-)
rename drivers/{char => otp}/bfin-otp.c (44%)drivers/char/Kconfig +0 -28
@@ -81,34 +81,6 @@ config BRIQ_PANEL It's safe to say N here. -config BFIN_OTP - tristate "Blackfin On-Chip OTP Memory Support" - depends on BLACKFIN && (BF51x || BF52x || BF54x) - default y - help - If you say Y here, you will get support for a character device - interface into the One Time Programmable memory pages that are - stored on the Blackfin processor. This will not get you access - to the secure memory pages however. You will need to write your - own secure code and reader for that. - - To compile this driver as a module, choose M here: the module - will be called bfin-otp. - - If unsure, it is safe to say Y. - -config BFIN_OTP_WRITE_ENABLE - bool "Enable writing support of OTP pages" - depends on BFIN_OTP - default n - help - If you say Y here, you will enable support for writing of the - OTP pages. This is dangerous by nature as you can only program - the pages once, so only enable this option when you actually - need it so as to not inadvertently clobber data. - - If unsure, say N. - config PRINTER tristate "Parallel printer support" depends on PARPORT
drivers/char/Makefile +0 -1
@@ -17,7 +17,6 @@ obj-$(CONFIG_VIOTAPE) += viotape.o obj-$(CONFIG_IBM_BSR) += bsr.o obj-$(CONFIG_SGI_MBCS) += mbcs.o obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o -obj-$(CONFIG_BFIN_OTP) += bfin-otp.o obj-$(CONFIG_PRINTER) += lp.o
drivers/otp/Kconfig +16 -0
@@ -32,4 +32,20 @@ config OTP_PC3X3 Say Y or M here to allow support for the OTP found in PC3X3 devices. If you say M then the module will be called otp_pc3x3. +config BFIN_OTP + tristate "Blackfin On-Chip OTP Memory Support" + depends on BLACKFIN && (BF51x || BF52x || BF54x) + default y + help + If you say Y here, you will get support for a character device + interface into the One Time Programmable memory pages that are + stored on the Blackfin processor. This will not get you access + to the secure memory pages however. You will need to write your + own secure code and reader for that. + + To compile this driver as a module, choose M here: the module + will be called bfin-otp. + + If unsure, it is safe to say Y. + endif
drivers/otp/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_OTP) += otp.o obj-$(CONFIG_OTP_PC3X3) += otp_pc3x3.o +obj-$(CONFIG_BFIN_OTP) += bfin-otp.o
drivers/otp/bfin-otp.c renamed from drivers/char/bfin-otp.c +121 -140
337 lines not on this page · raw message
Signature · 1 line
1.7.4