* [PATCH 1/4] mtd: mchp23k256: Add OF device ID table [not found] ` <20170517053908.26138-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> @ 2017-05-17 5:39 ` Chris Packham [not found] ` <20170517053908.26138-2-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Chris Packham @ 2017-05-17 5:39 UTC (permalink / raw) To: dwmw2-wEGCiKHe2LqWVfeAwA7xHQ, computersforpeace-Re5JQEeQqe8AvxtiuMwx3w, andrew-g2DYL2Zd6BY, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Chris Packham, Boris Brezillon, Marek Vasut, Richard Weinberger, Cyrille Pitchen, Rob Herring, Mark Rutland, devicetree-u79uwXL29TY76Z2rM5mHXA This allows registering of this device via a Device Tree. Signed-off-by: Chris Packham <chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> --- .../devicetree/bindings/mtd/microchip,mchp23k256.txt | 18 ++++++++++++++++++ drivers/mtd/devices/mchp23k256.c | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt diff --git a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt new file mode 100644 index 000000000000..25e5ad38b0f0 --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt @@ -0,0 +1,18 @@ +* MTD SPI driver for Microchip 23K256 (and similar) serial SRAM + +Required properties: +- #address-cells, #size-cells : Must be present if the device has sub-nodes + representing partitions. +- compatible : Must be "microchip,mchp23k256" +- reg : Chip-Select number +- spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at + +Example: + + spi-sram@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "microchip,mchp23k256"; + reg = <0>; + spi-max-frequency = <20000000>; + }; diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c index e237db9f1bdb..9d8306a15833 100644 --- a/drivers/mtd/devices/mchp23k256.c +++ b/drivers/mtd/devices/mchp23k256.c @@ -19,6 +19,7 @@ #include <linux/sizes.h> #include <linux/spi/flash.h> #include <linux/spi/spi.h> +#include <linux/of_device.h> struct mchp23k256_flash { struct spi_device *spi; @@ -166,9 +167,16 @@ static int mchp23k256_remove(struct spi_device *spi) return mtd_device_unregister(&flash->mtd); } +static const struct of_device_id mchp23k256_of_table[] = { + { .compatible = "microchip,mchp23k256" }, + {} +}; +MODULE_DEVICE_TABLE(of, mchp23k256_of_table); + static struct spi_driver mchp23k256_driver = { .driver = { .name = "mchp23k256", + .of_match_table = of_match_ptr(mchp23k256_of_table), }, .probe = mchp23k256_probe, .remove = mchp23k256_remove, -- 2.11.0.24.ge6920cf -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <20170517053908.26138-2-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org>]
* Re: [PATCH 1/4] mtd: mchp23k256: Add OF device ID table [not found] ` <20170517053908.26138-2-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> @ 2017-05-17 11:44 ` Andrew Lunn 0 siblings, 0 replies; 5+ messages in thread From: Andrew Lunn @ 2017-05-17 11:44 UTC (permalink / raw) To: Chris Packham Cc: dwmw2-wEGCiKHe2LqWVfeAwA7xHQ, computersforpeace-Re5JQEeQqe8AvxtiuMwx3w, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Boris Brezillon, Marek Vasut, Richard Weinberger, Cyrille Pitchen, Rob Herring, Mark Rutland, devicetree-u79uwXL29TY76Z2rM5mHXA On Wed, May 17, 2017 at 05:39:05PM +1200, Chris Packham wrote: > This allows registering of this device via a Device Tree. > > Signed-off-by: Chris Packham <chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> Reviewed-by: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org> Andrew -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024 [not found] <20170517053908.26138-1-chris.packham@alliedtelesis.co.nz> [not found] ` <20170517053908.26138-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> @ 2017-05-17 5:39 ` Chris Packham 2017-05-17 12:17 ` Andrew Lunn 2017-05-18 4:36 ` Chris Packham 1 sibling, 2 replies; 5+ messages in thread From: Chris Packham @ 2017-05-17 5:39 UTC (permalink / raw) To: dwmw2, computersforpeace, andrew, linux-mtd, linux-kernel Cc: Chris Packham, Boris Brezillon, Marek Vasut, Richard Weinberger, Cyrille Pitchen, Rob Herring, Mark Rutland, devicetree The mchp23lcv1024 is software compatible with the mchp23k256, the only difference (from a software point of view) is the size. There is no way to detect the size so we must be told via a Device Tree. Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> --- .../bindings/mtd/microchip,mchp23k256.txt | 2 +- drivers/mtd/devices/mchp23k256.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt index 25e5ad38b0f0..7328eb92a03c 100644 --- a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt +++ b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt @@ -3,7 +3,7 @@ Required properties: - #address-cells, #size-cells : Must be present if the device has sub-nodes representing partitions. -- compatible : Must be "microchip,mchp23k256" +- compatible : Must be one of "microchip,mchp23k256" or "microchip,mchp23lcv1024" - reg : Chip-Select number - spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c index 02c6b9dcbd3e..d1eba587633c 100644 --- a/drivers/mtd/devices/mchp23k256.c +++ b/drivers/mtd/devices/mchp23k256.c @@ -21,6 +21,8 @@ #include <linux/spi/spi.h> #include <linux/of_device.h> +enum chips { mchp23k256, mchp23lcv1024 }; + struct mchp23k256_flash { struct spi_device *spi; struct mutex lock; @@ -128,6 +130,7 @@ static int mchp23k256_probe(struct spi_device *spi) struct mchp23k256_flash *flash; struct flash_platform_data *data; int err; + enum chips chip; flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL); if (!flash) @@ -143,15 +146,28 @@ static int mchp23k256_probe(struct spi_device *spi) data = dev_get_platdata(&spi->dev); + if (spi->dev.of_node) + chip = (enum chips)of_device_get_match_data(&spi->dev); + else + chip = mchp23k256; + mtd_set_of_node(&flash->mtd, spi->dev.of_node); flash->mtd.dev.parent = &spi->dev; flash->mtd.type = MTD_RAM; flash->mtd.flags = MTD_CAP_RAM; flash->mtd.writesize = 1; - flash->mtd.size = SZ_32K; flash->mtd._read = mchp23k256_read; flash->mtd._write = mchp23k256_write; + switch (chip){ + case mchp23lcv1024: + flash->mtd.size = SZ_128K; + break; + default: + flash->mtd.size = SZ_32K; + break; + } + flash->mtd.erasesize = PAGE_SIZE; while (flash->mtd.size & (flash->mtd.erasesize - 1)) flash->mtd.erasesize >>= 1; @@ -172,7 +188,8 @@ static int mchp23k256_remove(struct spi_device *spi) } static const struct of_device_id mchp23k256_of_table[] = { - { .compatible = "microchip,mchp23k256" }, + { .compatible = "microchip,mchp23k256", .data = (void *)mchp23k256 }, + { .compatible = "microchip,mchp23lcv1024", .data = (void *)mchp23lcv1024 }, {} }; MODULE_DEVICE_TABLE(of, mchp23k256_of_table); -- 2.11.0.24.ge6920cf ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024 2017-05-17 5:39 ` [PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024 Chris Packham @ 2017-05-17 12:17 ` Andrew Lunn 2017-05-18 4:36 ` Chris Packham 1 sibling, 0 replies; 5+ messages in thread From: Andrew Lunn @ 2017-05-17 12:17 UTC (permalink / raw) To: Chris Packham Cc: dwmw2, computersforpeace, linux-mtd, linux-kernel, Boris Brezillon, Marek Vasut, Richard Weinberger, Cyrille Pitchen, Rob Herring, Mark Rutland, devicetree > + switch (chip){ Space please, between ) and { Andrew ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024 2017-05-17 5:39 ` [PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024 Chris Packham 2017-05-17 12:17 ` Andrew Lunn @ 2017-05-18 4:36 ` Chris Packham 1 sibling, 0 replies; 5+ messages in thread From: Chris Packham @ 2017-05-18 4:36 UTC (permalink / raw) To: dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org, computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, andrew-g2DYL2Zd6BY@public.gmane.org, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Boris Brezillon, Marek Vasut, Richard Weinberger, Cyrille Pitchen, Rob Herring, Mark Rutland, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On 17/05/17 17:39, Chris Packham wrote: > The mchp23lcv1024 is software compatible with the mchp23k256, the > only difference (from a software point of view) is the size. There > is no way to detect the size so we must be told via a Device Tree. I've just noticed that another difference between the 2 chips is 16-bit vs 24-bit addressing. So that will also need to be handled. > > Signed-off-by: Chris Packham <chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> > --- > .../bindings/mtd/microchip,mchp23k256.txt | 2 +- > drivers/mtd/devices/mchp23k256.c | 21 +++++++++++++++++++-- > 2 files changed, 20 insertions(+), 3 deletions(-) > > diff --git a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt > index 25e5ad38b0f0..7328eb92a03c 100644 > --- a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt > +++ b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt > @@ -3,7 +3,7 @@ > Required properties: > - #address-cells, #size-cells : Must be present if the device has sub-nodes > representing partitions. > -- compatible : Must be "microchip,mchp23k256" > +- compatible : Must be one of "microchip,mchp23k256" or "microchip,mchp23lcv1024" > - reg : Chip-Select number > - spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at > > diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c > index 02c6b9dcbd3e..d1eba587633c 100644 > --- a/drivers/mtd/devices/mchp23k256.c > +++ b/drivers/mtd/devices/mchp23k256.c > @@ -21,6 +21,8 @@ > #include <linux/spi/spi.h> > #include <linux/of_device.h> > > +enum chips { mchp23k256, mchp23lcv1024 }; > + > struct mchp23k256_flash { > struct spi_device *spi; > struct mutex lock; > @@ -128,6 +130,7 @@ static int mchp23k256_probe(struct spi_device *spi) > struct mchp23k256_flash *flash; > struct flash_platform_data *data; > int err; > + enum chips chip; > > flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL); > if (!flash) > @@ -143,15 +146,28 @@ static int mchp23k256_probe(struct spi_device *spi) > > data = dev_get_platdata(&spi->dev); > > + if (spi->dev.of_node) > + chip = (enum chips)of_device_get_match_data(&spi->dev); > + else > + chip = mchp23k256; > + > mtd_set_of_node(&flash->mtd, spi->dev.of_node); > flash->mtd.dev.parent = &spi->dev; > flash->mtd.type = MTD_RAM; > flash->mtd.flags = MTD_CAP_RAM; > flash->mtd.writesize = 1; > - flash->mtd.size = SZ_32K; > flash->mtd._read = mchp23k256_read; > flash->mtd._write = mchp23k256_write; > > + switch (chip){ > + case mchp23lcv1024: > + flash->mtd.size = SZ_128K; > + break; > + default: > + flash->mtd.size = SZ_32K; > + break; > + } > + > flash->mtd.erasesize = PAGE_SIZE; > while (flash->mtd.size & (flash->mtd.erasesize - 1)) > flash->mtd.erasesize >>= 1; > @@ -172,7 +188,8 @@ static int mchp23k256_remove(struct spi_device *spi) > } > > static const struct of_device_id mchp23k256_of_table[] = { > - { .compatible = "microchip,mchp23k256" }, > + { .compatible = "microchip,mchp23k256", .data = (void *)mchp23k256 }, > + { .compatible = "microchip,mchp23lcv1024", .data = (void *)mchp23lcv1024 }, > {} > }; > MODULE_DEVICE_TABLE(of, mchp23k256_of_table); > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-05-18 4:36 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20170517053908.26138-1-chris.packham@alliedtelesis.co.nz> [not found] ` <20170517053908.26138-1-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> 2017-05-17 5:39 ` [PATCH 1/4] mtd: mchp23k256: Add OF device ID table Chris Packham [not found] ` <20170517053908.26138-2-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> 2017-05-17 11:44 ` Andrew Lunn 2017-05-17 5:39 ` [PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024 Chris Packham 2017-05-17 12:17 ` Andrew Lunn 2017-05-18 4:36 ` Chris Packham
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).