Add support for NXP LPC18xx EEPROM using nvmem
v3 cover Add support for NXP LPC18xx EEPROM using nvmem
This patch series adds support for NXP LPC18xx EEPROM memory found in NXP LPC185x/3x and LPC435x/3x/2x/1x devices.
This patchset is based on tag next-20151116 of the linux-next repository. It has been successfully tested on a LPC4337 CIAA-NXP Board.
EEPROM notes:
------------
EEPROM size is 16384 bytes and it can be entirely read and written/erased with 1 word (4 bytes) granularity. The last page (128 bytes) contains the EEPROM initialization data and is not writable.
Erase/program time is less than 3ms. The EEPROM device requires a ~1500 kHz clock (min 800 kHz, max 1600 kHz) that is generated dividing the system bus clock by the division factor, contained in the divider register (minus 1 encoded).
EEPROM will be kept in Power Down mode except during read/write calls.
Changeset:
---------
v2 -> v3:
* Documented 'resets' property in devicetree bindings.
* Added dynamic power on/off when writing/reading the EEPROM.
* Added check for aligned offset in EEPROM writes.
* Properly remove the driver in the reverse order of initialization.
* Minor fixes.
v1 -> v2:
* Moved dt-bindings to be the first patch.
* Changed compatible name from lpc1850 to lpc1857 as the former doesn't have EEPROM.
* Fix hardware description which contained SoCs models without EEPROM.
* Disabled fast_io and changed mdelay for msleep in regmap writes.
* Replaced BUG_ON() in write function for an -EINVAL return.
* Add patches for defconfig and devicetree files.
Thanks,
Ariel D'Alessandro (4):
DT: nvmem: Add NXP LPC18xx EEPROM memory binding documentation
nvmem: NXP LPC18xx EEPROM memory NVMEM driver
ARM: dts: lpc18xx: add EEPROM memory node
ARM: configs: lpc18xx: enable EEPROM NVMEM driver
.../devicetree/bindings/nvmem/lpc1857-eeprom.txt | 28 ++ arch/arm/boot/dts/lpc18xx.dtsi | 12 + arch/arm/configs/lpc18xx_defconfig | 2 + drivers/nvmem/Kconfig | 9 + drivers/nvmem/Makefile | 2 + drivers/nvmem/lpc18xx_eeprom.c | 288 +++++++++++++++++++++ 6 files changed, 341 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/lpc1857-eeprom.txt create mode 100644 drivers/nvmem/lpc18xx_eeprom.c
Signature · 1 line
2.6.2
PATCH v3 1/4 DT: nvmem: Add NXP LPC18xx EEPROM memory binding documentation
Add the devicetree binding document for NXP LPC18xx EEPROM memory.
--- .../devicetree/bindings/nvmem/lpc1857-eeprom.txt | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/lpc1857-eeprom.txt
Documentation/devicetree/bindings/nvmem/lpc1857-eeprom.txt new file +28 -0
@@ -0,0 +1,28 @@ +* NXP LPC18xx EEPROM memory NVMEM driver + +Required properties: + - compatible: Should be "nxp,lpc1857-eeprom" + - reg: Must contain an entry with the physical base address and length + for each entry in reg-names. + - reg-names: Must include the following entries. + - reg: EEPROM registers. + - mem: EEPROM address space. + - clocks: Must contain an entry for each entry in clock-names. + - clock-names: Must include the following entries. + - eeprom: EEPROM operating clock. + - resets: Should contain a reference to the reset controller asserting + the EEPROM in reset. + - interrupts: Should contain EEPROM interrupt. + +Example: + + eeprom: eeprom at 4000e000 { + compatible = "nxp,lpc1857-eeprom"; + reg = <0x4000e000 0x1000>, + <0x20040000 0x4000>; + reg-names = "reg", "mem"; + clocks = <&ccu1 CLK_CPU_EEPROM>; + clock-names = "eeprom"; + resets = <&rgu 27>; + interrupts = <4>; + };
Signature · 1 line
2.6.2
Rob Herring
maintainerPATCH v3 1/4 DT: nvmem: Add NXP LPC18xx EEPROM memory binding documentation
Quoted 3 lines · Ariel D'Alessandro
Add the devicetree binding document for NXP LPC18xx EEPROM memory.
Signed-off-by Ariel D'Alessandro <[email protected]>
Quoted 42 lines
--- .../devicetree/bindings/nvmem/lpc1857-eeprom.txt | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/lpc1857-eeprom.txtDocumentation/devicetree/bindings/nvmem/lpc1857-eeprom.txt new file +28
-0@@ -0,0 +1,28 @@ +* NXP LPC18xx EEPROM memory NVMEM driver + +Required properties: + - compatible: Should be "nxp,lpc1857-eeprom" + - reg: Must contain an entry with the physical base address and length + for each entry in reg-names. + - reg-names: Must include the following entries. + - reg: EEPROM registers. + - mem: EEPROM address space. + - clocks: Must contain an entry for each entry in clock-names. + - clock-names: Must include the following entries. + - eeprom: EEPROM operating clock. + - resets: Should contain a reference to the reset controller asserting + the EEPROM in reset. + - interrupts: Should contain EEPROM interrupt. + +Example: + + eeprom: eeprom at 4000e000 { + compatible = "nxp,lpc1857-eeprom"; + reg = <0x4000e000 0x1000>, + <0x20040000 0x4000>; + reg-names = "reg", "mem"; + clocks = <&ccu1 CLK_CPU_EEPROM>; + clock-names = "eeprom"; + resets = <&rgu 27>; + interrupts = <4>; + };Signature · 1 line
2.6.2
PATCH v3 2/4 nvmem: NXP LPC18xx EEPROM memory NVMEM driver
In reply to Ariel D'AlessandroThis commit adds support for NXP LPC18xx EEPROM memory found in NXP LPC185x/3x and LPC435x/3x/2x/1x devices.
EEPROM size is 16384 bytes and it can be entirely read and written/erased with 1 word (4 bytes) granularity. The last page (128 bytes) contains the EEPROM initialization data and is not writable.
Erase/program time is less than 3ms. The EEPROM device requires a ~1500 kHz clock (min 800 kHz, max 1600 kHz) that is generated dividing the system bus clock by the division factor, contained in the divider register (minus 1 encoded).
EEPROM will be kept in Power Down mode except during read/write calls.
--- drivers/nvmem/Kconfig | 9 ++ drivers/nvmem/Makefile | 2 + drivers/nvmem/lpc18xx_eeprom.c | 288 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 299 insertions(+) create mode 100644 drivers/nvmem/lpc18xx_eeprom.c
drivers/nvmem/Kconfig +9 -0
@@ -25,6 +25,15 @@ config NVMEM_IMX_OCOTP This driver can also be built as a module. If so, the module will be called nvmem-imx-ocotp. +config NVMEM_LPC18XX_EEPROM + tristate "NXP LPC18XX EEPROM Memory Support" + depends on ARCH_LPC18XX || COMPILE_TEST + help + Say Y here to include support for NXP LPC18xx EEPROM memory found in + NXP LPC185x/3x and LPC435x/3x/2x/1x devices. + To compile this driver as a module, choose M here: the module + will be called nvmem_lpc18xx_eeprom. + config NVMEM_MXS_OCOTP tristate "Freescale MXS On-Chip OTP Memory Support" depends on ARCH_MXS || COMPILE_TEST
drivers/nvmem/Makefile +2 -0
@@ -8,6 +8,8 @@ nvmem_core-y := core.o # Devices obj-$(CONFIG_NVMEM_IMX_OCOTP) += nvmem-imx-ocotp.o nvmem-imx-ocotp-y := imx-ocotp.o +obj-$(CONFIG_NVMEM_LPC18XX_EEPROM) += nvmem_lpc18xx_eeprom.o +nvmem_lpc18xx_eeprom-y := lpc18xx_eeprom.o obj-$(CONFIG_NVMEM_MXS_OCOTP) += nvmem-mxs-ocotp.o nvmem-mxs-ocotp-y := mxs-ocotp.o obj-$(CONFIG_QCOM_QFPROM) += nvmem_qfprom.o
drivers/nvmem/lpc18xx_eeprom.c new file +288 -0
288 lines not on this page · raw message
Signature · 1 line
2.6.2
PATCH v3 3/4 ARM: dts: lpc18xx: add EEPROM memory node
In reply to Ariel D'AlessandroAdd node for the NXP LPC18xx EEPROM memory which can be found in NXP LPC185x/3x and LPC435x/3x/2x/1x devices.
--- arch/arm/boot/dts/lpc18xx.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm/boot/dts/lpc18xx.dtsi +12 -0
@@ -166,6 +166,18 @@ status = "disabled"; }; + eeprom: eeprom at 4000e000 { + compatible = "nxp,lpc1857-eeprom"; + reg = <0x4000e000 0x1000>, + <0x20040000 0x4000>; + reg-names = "reg", "mem"; + clocks = <&ccu1 CLK_CPU_EEPROM>; + clock-names = "eeprom"; + resets = <&rgu 27>; + interrupts = <4>; + status = "disabled"; + }; + mac: ethernet at 40010000 { compatible = "nxp,lpc1850-dwmac", "snps,dwmac-3.611", "snps,dwmac"; reg = <0x40010000 0x2000>;
Signature · 1 line
2.6.2
PATCH v3 4/4 ARM: configs: lpc18xx: enable EEPROM NVMEM driver
In reply to Ariel D'AlessandroEnable NVMEM driver for NXP LPC18xx EEPROM, which can be found in NXP LPC185x/3x and LPC435x/3x/2x/1x devices.
--- arch/arm/configs/lpc18xx_defconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/configs/lpc18xx_defconfig +2 -0
@@ -148,6 +148,8 @@ CONFIG_ARM_PL172_MPMC=y CONFIG_PWM=y CONFIG_PWM_LPC18XX_SCT=y CONFIG_PHY_LPC18XX_USB_OTG=y +CONFIG_NVMEM=y +CONFIG_NVMEM_LPC18XX_EEPROM=y CONFIG_EXT2_FS=y # CONFIG_FILE_LOCKING is not set # CONFIG_DNOTIFY is not set
Signature · 1 line
2.6.2
v3 cover Add support for NXP LPC18xx EEPROM using nvmem
In reply to Ariel D'AlessandroEl 16/11/15 a las 13:19, Ariel D'Alessandro escribi?:
Quoted 6 lines
This patch series adds support for NXP LPC18xx EEPROM memory found in NXP LPC185x/3x and LPC435x/3x/2x/1x devices.
This patchset is based on tag next-20151116 of the linux-next repository. It has been successfully tested on a LPC4337 CIAA-NXP Board.
Forgot to say that there's a known issue related to the nvmem core. It will be solved when the following patch gets submitted and applied.
-------------------------------->cut<----------------------------------
Quoted 1 line
From
8cae10eff8ea8da9c5a8058ff75abeeddd8a8224Mon Sep 17 00:00:00 2001
From: Srinivas Kandagatla <[email protected]>
Date: Mon, 26 Oct 2015 13:30:24 +0000
Subject: [PATCH] nvmem: core: return error for non word aligned bytes
nvmem providers have restrictions on register strides, so return error code when users attempt to read/write buffers with sizes which are not aligned to the word boundary.
Without this patch the userspace would continue to try as it does not get any error from the nvmem core, resulting in a hang.
--- drivers/nvmem/core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/nvmem/core.c +0 -0
@@ -70,6 +70,9 @@ static ssize_t bin_attr_nvmem_read(struct file *filp,
struct kobject *kobj,
if (pos >= nvmem->size)
return 0;+ if (count < nvmem->word_size)
+ return -EINVAL;
+
if (pos + count > nvmem->size)
count = nvmem->size - pos;@@ -95,6 +98,9 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
if (pos >= nvmem->size)
return 0;+ if (count < nvmem->word_size)
+ return -EINVAL;
+
if (pos + count > nvmem->size)
count = nvmem->size - pos;Signature · 7 lines
1.9.1 -------------------------------->cut<---------------------------------- -- Ariel D'Alessandro, VanguardiaSur www.vanguardiasur.com.ar