Lines Matching +full:mtd +full:- +full:ram

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Driver for Microchip 23k256 SPI RAM chips
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
30 struct mtd_info mtd; member
39 #define to_mchp23k256_flash(x) container_of(x, struct mchp23k256_flash, mtd)
51 for (i = flash->caps->addr_width; i > 0; i--, addr >>= 8) in mchp23k256_addr2cmd()
57 return 1 + flash->caps->addr_width; in mchp23k256_cmdsz()
60 static int mchp23k256_write(struct mtd_info *mtd, loff_t to, size_t len, in mchp23k256_write() argument
63 struct mchp23k256_flash *flash = to_mchp23k256_flash(mtd); in mchp23k256_write()
84 mutex_lock(&flash->lock); in mchp23k256_write()
86 ret = spi_sync(flash->spi, &message); in mchp23k256_write()
88 mutex_unlock(&flash->lock); in mchp23k256_write()
94 *retlen += message.actual_length - cmd_len; in mchp23k256_write()
99 static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len, in mchp23k256_read() argument
102 struct mchp23k256_flash *flash = to_mchp23k256_flash(mtd); in mchp23k256_read()
124 mutex_lock(&flash->lock); in mchp23k256_read()
126 ret = spi_sync(flash->spi, &message); in mchp23k256_read()
128 mutex_unlock(&flash->lock); in mchp23k256_read()
134 *retlen += message.actual_length - cmd_len; in mchp23k256_read()
177 flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL); in mchp23k256_probe()
179 return -ENOMEM; in mchp23k256_probe()
181 flash->spi = spi; in mchp23k256_probe()
182 mutex_init(&flash->lock); in mchp23k256_probe()
189 data = dev_get_platdata(&spi->dev); in mchp23k256_probe()
191 flash->caps = of_device_get_match_data(&spi->dev); in mchp23k256_probe()
192 if (!flash->caps) in mchp23k256_probe()
193 flash->caps = &mchp23k256_caps; in mchp23k256_probe()
195 mtd_set_of_node(&flash->mtd, spi->dev.of_node); in mchp23k256_probe()
196 flash->mtd.dev.parent = &spi->dev; in mchp23k256_probe()
197 flash->mtd.type = MTD_RAM; in mchp23k256_probe()
198 flash->mtd.flags = MTD_CAP_RAM; in mchp23k256_probe()
199 flash->mtd.writesize = 1; in mchp23k256_probe()
200 flash->mtd.size = flash->caps->size; in mchp23k256_probe()
201 flash->mtd._read = mchp23k256_read; in mchp23k256_probe()
202 flash->mtd._write = mchp23k256_write; in mchp23k256_probe()
204 err = mtd_device_register(&flash->mtd, data ? data->parts : NULL, in mchp23k256_probe()
205 data ? data->nr_parts : 0); in mchp23k256_probe()
216 WARN_ON(mtd_device_unregister(&flash->mtd)); in mchp23k256_remove()
257 MODULE_DESCRIPTION("MTD SPI driver for MCHP23K256 RAM chips");