mtd: devices: add support for microchip 48l640 EERAM
Subsystems (2)
v2 cover mtd: devices: add support for microchip 48l640 EERAM
add support for microchip 48l640 eeram connected via SPI. Patch 1 introduces devicetree documentation and patch 2 the driver.
Changes in v2:
as Rob helped, fix warnings from running command
'make DT_CHECKER_FLAGS=-m dt_binding_check'
- fix build warnings
- add Fabios Tested-by
Heiko Schocher (2):
mtd: devices: add devicetree documentation for microchip 48l640
mtd: devices: add support for microchip 48l640 EERAM
.../bindings/mtd/microchip,mchp48l640.yaml | 45 +++ drivers/mtd/devices/Kconfig | 6 + drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/mchp48l640.c | 374 ++++++++++++++++++ 4 files changed, 426 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/microchip,mchp48l640.yaml create mode 100644 drivers/mtd/devices/mchp48l640.c
Signature · 1 line
2.30.2
PATCH v2 1/2 mtd: devices: add devicetree documentation for microchip 48l640
The Microchip 48l640 is a 8KByte EERAM connected via SPI. Add devicetree bindings documentation.
---
Changes in v2:
as Rob helped, fix warnings from running command
'make DT_CHECKER_FLAGS=-m dt_binding_check'
.../bindings/mtd/microchip,mchp48l640.yaml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/microchip,mchp48l640.yaml
Documentation/devicetree/bindings/mtd/microchip,mchp48l640.yaml new file +45 -0
@@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/mtd/microchip,mchp48l640.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: MTD SPI driver for Microchip 48l640 (and similar) serial EERAM + +maintainers: + - Heiko Schocher <[email protected]> + +description: | + The Microchip 48l640 is a 8KByte EERAM connected via SPI. + + datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/20006055B.pdf + +properties: + compatible: + items: + - const: microchip,48l640 + + reg: + maxItems: 1 + + spi-max-frequency: true + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + spi-eeram@0 { + compatible = "microchip,48l640"; + reg = <0>; + spi-max-frequency = <20000000>; + }; + }; +...
Signature · 1 line
2.30.2
PATCH v2 2/2 mtd: devices: add support for microchip 48l640 EERAM
In reply to Heiko SchocherThe Microchip 48l640 is a 8KByte EERAM connected via SPI.
---
I tried to use drivers/mtd/devices/mchp23k256.c but this driver does not use any status register and there seems slight differences in registers (no write enable register for example), so I decided to make a new driver.
This driver sets the continuous mode bit in Status register, which states you can write continuous ... but after writting 32 bytes the chip goes into an undefined state, so driver now writes data in 32 byte chunks.
I also tried to use regmap, but it leads in a lot of more code, and as this chip has only spi interface it makes no sense, or?
Tested this driver on board imx8mp-phyboard-pollux-rdk board, which is already in mainline.
Made some tbot tests, which write at random offset random length bytes with dd and and random content. Reread the data after a reboot and compare with the written data. Works fine.
Changes in v2:
- fix build warnings
- add Fabios Tested-by
drivers/mtd/devices/Kconfig | 6 + drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/mchp48l640.c | 374 +++++++++++++++++++++++++++++++ 3 files changed, 381 insertions(+) create mode 100644 drivers/mtd/devices/mchp48l640.c
drivers/mtd/devices/Kconfig +6 -0
@@ -89,6 +89,12 @@ config MTD_MCHP23K256 platform data, or a device tree description if you want to specify device partitioning +config MTD_MCHP48L640 + tristate "Microchip 48L640 EERAM" + depends on SPI_MASTER + help + This enables access to Microchip 48L640 EERAM chips, using SPI. + config MTD_SPEAR_SMI tristate "SPEAR MTD NOR Support through SMI controller" depends on PLAT_SPEAR || COMPILE_TEST
drivers/mtd/devices/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_MTD_LART) += lart.o obj-$(CONFIG_MTD_BLOCK2MTD) += block2mtd.o obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o obj-$(CONFIG_MTD_MCHP23K256) += mchp23k256.o +obj-$(CONFIG_MTD_MCHP48L640) += mchp48l640.o obj-$(CONFIG_MTD_SPEAR_SMI) += spear_smi.o obj-$(CONFIG_MTD_SST25L) += sst25l.o obj-$(CONFIG_MTD_BCM47XXSFLASH) += bcm47xxsflash.o
drivers/mtd/devices/mchp48l640.c new file +374 -0
374 lines not on this page · raw message
Signature · 1 line
2.30.2
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Heiko,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on mtd/mtd/next]
[also build test WARNING on mtd/mtd/fixes linux/master linus/master v5.13-rc3 next-20210528] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Heiko-Schocher/mtd-devices-add-support-for-microchip-48l640-EERAM/20210529-182943 base: https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next config: arc-allyesconfig (attached as .config) compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/eccf3abb95a75cb12c0506c6db8d129b69c71a9c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Heiko-Schocher/mtd-devices-add-support-for-microchip-48l640-EERAM/20210529-182943 git checkout eccf3abb95a75cb12c0506c6db8d129b69c71a9c
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from include/linux/printk.h:409,
from include/linux/kernel.h:17,
from include/linux/delay.h:22,
from drivers/mtd/devices/mchp48l640.c:14:
drivers/mtd/devices/mchp48l640.c: In function 'mchp48l640_read':
>> drivers/mtd/devices/mchp48l640.c:280:28: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
280 | dev_dbg(&flash->spi->dev, "read len: %ld from: %llx", len, from);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dynamic_debug.h:129:15: note: in definition of macro '__dynamic_func_call'
129 | func(&id, ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/linux/dynamic_debug.h:161:2: note: in expansion of macro '_dynamic_func_call'
161 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \
| ^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:123:2: note: in expansion of macro 'dynamic_dev_dbg'
123 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
include/linux/dev_printk.h:123:23: note: in expansion of macro 'dev_fmt'
123 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/mtd/devices/mchp48l640.c:280:2: note: in expansion of macro 'dev_dbg'
280 | dev_dbg(&flash->spi->dev, "read len: %ld from: %llx", len, from);
| ^~~~~~~
drivers/mtd/devices/mchp48l640.c:280:41: note: format string is defined here
280 | dev_dbg(&flash->spi->dev, "read len: %ld from: %llx", len, from);
| ~~^
| |
| long int
| %dvim +280 drivers/mtd/devices/mchp48l640.c
265
266 static int mchp48l640_read(struct mtd_info *mtd, loff_t from, size_t len,
267 size_t *retlen, unsigned char *buf)
268 {
269 struct mchp48l640_flash *flash = to_mchp48l640_flash(mtd);
270 int ret;
271 size_t wlen = 0;
272 loff_t woff = from;
273 size_t ws;
274 size_t page_sz = flash->caps->page_size;
275
276 /*
277 * we set PRO bit (page rollover), but if read length > page size
278 * does result in total chaos in result ...
279 */
> 280 dev_dbg(&flash->spi->dev, "read len: %ld from: %llx", len, from);
281 while (wlen < len) {
282 ws = min((len - wlen), page_sz);
283 ret = mchp48l640_read_page(mtd, woff, ws, retlen, &buf[wlen]);
284 if (ret)
285 return ret;
286 wlen += ws;
287 woff += ws;
288 }
289
290 return ret;
291 };
292
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]