add support for FRAM
Subsystems (3)
v4 cover add support for FRAM
Adds support for Cypress FRAMs.
Jiri Prchal (5):
nvmem: eeprom: at25: add support for FRAM
nvmem: eeprom: at25: add support for FRAM
nvmem: eeprom: add documentation for FRAM
nvmem: eeprom: at25: export FRAM serial num
nvmem: eeprom: add documentation of sysfs sernum file
.../ABI/testing/sysfs-class-spi-eeprom | 6 + .../devicetree/bindings/eeprom/at25.yaml | 31 +++- drivers/misc/eeprom/Kconfig | 5 +- drivers/misc/eeprom/at25.c | 167 ++++++++++++++---- drivers/nvmem/core.c | 4 + include/linux/nvmem-provider.h | 1 + 6 files changed, 176 insertions(+), 38 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-spi-eeprom
--
v2: fixes in some files
v3: resend and added more recipients
v4: resend
v5: fixes up to Greg comments, add documentation
---
2.25.1
PATCH v5 1/5 nvmem: eeprom: at25: add support for FRAM
Added enum and string for FRAM to expose it as "fram".
---
v2: no change here
v3: resend and added more recipients
v4: resend
v5: no change here
--- drivers/nvmem/core.c | 4 ++++ include/linux/nvmem-provider.h | 1 + 2 files changed, 5 insertions(+)
drivers/nvmem/core.c +4 -0
@@ -180,6 +180,7 @@ static const char * const nvmem_type_str[] = { [NVMEM_TYPE_EEPROM] = "EEPROM", [NVMEM_TYPE_OTP] = "OTP", [NVMEM_TYPE_BATTERY_BACKED] = "Battery backed", + [NVMEM_TYPE_FRAM] = "FRAM", };#ifdef CONFIG_DEBUG_LOCK_ALLOC
@@ -359,6 +360,9 @@ static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem,if (!config->base_dev)return -EINVAL ; +if (config->type ==NVMEM_TYPE_FRAM ) + bin_attr_nvmem_eeprom_compat.attr.name ="fram" ; + nvmem->eeprom = bin_attr_nvmem_eeprom_compat; nvmem->eeprom.attr.mode =nvmem_bin_attr_get_umode (nvmem); nvmem->eeprom.size = nvmem->size;
include/linux/nvmem-provider.h +1 -0
@@ -25,6 +25,7 @@ enum nvmem_type {NVMEM_TYPE_EEPROM ,NVMEM_TYPE_OTP ,NVMEM_TYPE_BATTERY_BACKED , + NVMEM_TYPE_FRAM, };#define NVMEM_DEVID_NONE (-1)
Signature · 1 line
2.25.1
PATCH v5 2/5 nvmem: eeprom: at25: add support for FRAM
In reply to Jiri PrchalAdded support for Cypress FRAMs.
These frams have ID and some of them have serial number too. Size of them is recognized by ID. They don't have pages, it could be read or written at once, but it's limited in this driver to io limit 4096.
---
v2: fixed warning at %zd at int
v3: resend and added more recipients
v4: resend
v5: used in-kernel function int_pow
--- drivers/misc/eeprom/Kconfig | 5 +- drivers/misc/eeprom/at25.c | 141 ++++++++++++++++++++++++++++-------- 2 files changed, 114 insertions(+), 32 deletions(-)
drivers/misc/eeprom/Kconfig +3 -2
@@ -32,12 +32,13 @@ config EEPROM_AT24 will be called at24. config EEPROM_AT25 - tristate "SPI EEPROMs from most vendors" + tristate "SPI EEPROMs (FRAMs) from most vendors" depends on SPI && SYSFS select NVMEM select NVMEM_SYSFS help - Enable this driver to get read/write support to most SPI EEPROMs, + Enable this driver to get read/write support to most SPI EEPROMs + and Cypress FRAMs, after you configure the board init code to know about each eeprom on your target board.
drivers/misc/eeprom/at25.c +111 -30
219 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 3/5 nvmem: eeprom: add documentation for FRAM
In reply to Jiri PrchalAdded dt binding documentation.
---
v2: fixed dt_binding_check warnings thanks to Rob Herring
v3: resend and added more recipients
v4: resend
v5: no change here
--- .../devicetree/bindings/eeprom/at25.yaml | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/eeprom/at25.yaml +25 -6
@@ -4,14 +4,16 @@ $id: "http://devicetree.org/schemas/eeprom/at25.yaml#" $schema: "http://devicetree.org/meta-schemas/core.yaml#" -title: SPI EEPROMs compatible with Atmel's AT25 +title: SPI EEPROMs or FRAMs compatible with Atmel's AT25 maintainers: - Christian Eggers <[email protected]> properties: $nodename: - pattern: "^eeprom@[0-9a-f]{1,2}$" + anyOf: + - pattern: "^eeprom@[0-9a-f]{1,2}$" + - pattern: "^fram@[0-9a-f]{1,2}$" # There are multiple known vendors who manufacture EEPROM chips compatible # with Atmel's AT25. The compatible string requires two items where the
@@ -31,6 +33,7 @@ properties: - microchip,25lc040 - st,m95m02 - st,m95256 + - cypress,fm25 - const: atmel,at25
@@ -48,7 +51,7 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 enum: [1, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072] description: - Size of the eeprom page. + Size of the eeprom page. FRAMs don't have pages. size: $ref: /schemas/types.yaml#/definitions/uint32
@@ -101,9 +104,19 @@ required: - compatible - reg - spi-max-frequency - - pagesize - - size - - address-width + +allOf: + - if: + properties: + compatible: + not: + contains: + const: cypress,fm25 + then: + required: + - pagesize + - size + - address-width additionalProperties: false
@@ -126,4 +139,10 @@ examples: size = <32768>; address-width = <16>; }; + + fram@1 { + compatible = "cypress,fm25", "atmel,at25"; + reg = <1>; + spi-max-frequency = <40000000>; + }; };
Signature · 1 line
2.25.1
PATCH v5 4/5 nvmem: eeprom: at25: export FRAM serial num
In reply to Jiri PrchalThis exports serial number of FRAM in sysfs file named "sernum". Formatted in hex, each byte separated by space. Example:
$ cat /sys/class/spi_master/spi0/spi0.0/sernum 0000a43644f2ae6c
---
v2: no change here
v3: resend and added more recipients
v4: resend
v5: reworked up on Greg comments: no spaces in string, sysfs done correctly
--- drivers/misc/eeprom/at25.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/misc/eeprom/at25.c +27 -1
@@ -39,6 +39,7 @@ struct at25_data {struct nvmem_config nvmem_config;struct nvmem_device *nvmem;int has_sernum; +char *sernum; };#define AT25_WREN 0x06/* latch the write enable */
@@ -173,6 +174,25 @@ static int fm25_aux_read(struct at25_data *at25, char *buf, uint8_t command,return status; } +static ssize_t sernum_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct at25_data *at25; +int i; + + at25 =dev_get_drvdata (dev); +for (i =FM25_SN_LEN -1 ; i >=0 ; i--) + buf +=sprintf (buf,"%02x" , at25->sernum[i]); +sprintf (buf,"\n" ); +return (2 *FM25_SN_LEN +1 ); +} +static DEVICE_ATTR(sernum, 0440, sernum_show, NULL); + +static struct attribute *sernum_attrs[] = { + &dev_attr_sernum.attr, +NULL , +}; +ATTRIBUTE_GROUPS (sernum); +static int at25_ee_write (void *priv,unsigned int off,void *val,size_t count) {struct at25_data *at25 = priv;
@@ -417,8 +437,13 @@ static int at25_probe(struct spi_device *spi)else at25->chip.flags |=EE_ADDR2 ; -if (id[8 ]) +if (id[8 ]) { at25->has_sernum =1 ; + at25->sernum =kzalloc (FM25_SN_LEN ,GFP_KERNEL ); +if (!at25->sernum) +return -ENOMEM ; +fm25_aux_read (at25, at25->sernum,FM25_RDSN ,FM25_SN_LEN ); + }else at25->has_sernum =0 ;
@@ -472,6 +497,7 @@ static struct spi_driver at25_driver = { .driver = { .name = "at25", .of_match_table = at25_of_match, + .dev_groups = sernum_groups, }, .probe = at25_probe, };
Signature · 1 line
2.25.1
PATCH v5 5/5 nvmem: eeprom: add documentation of sysfs sernum file
In reply to Jiri PrchalAdded sysfs sernum file documentation.
---
v5: new
--- Documentation/ABI/testing/sysfs-class-spi-eeprom | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-spi-eeprom
Documentation/ABI/testing/sysfs-class-spi-eeprom new file +6 -0
@@ -0,0 +1,6 @@ +What: /sys/class/spi_master/spi<bus>/spi<bus>.<dev>/sernum +Date: May 2021 +KernelVersion: 5.12.1 +Contact: Jiri Prchal <[email protected]> +Description: + Exports serial number of Cypress FRAM (FM25VN). 8 bytes as is in chip in hex string.
--
2.25.1
Greg Kroah-Hartman
maintainerQuoted 5 lines · Jiri Prchal
Adds support for Cypress FRAMs.
Jiri Prchal (5):
nvmem: eeprom: at25: add support for FRAM
nvmem: eeprom: at25: add support for FRAM
You have 2 commits here with identical subject lines, yet they do different things :(
Please fix up and make them properly unique.
thanks,
greg k-h