mtd: mchp23k256: Add OF device ID table

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Thu Jul 13 10:59:03 PDT 2017


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=4db4d35ebda390b5287d758fdd51b26c24fbc26b
Commit:     4db4d35ebda390b5287d758fdd51b26c24fbc26b
Parent:     e3db1289e7432a882823a7effc474aff78868489
Author:     Chris Packham <chris.packham at alliedtelesis.co.nz>
AuthorDate: Thu May 25 11:49:12 2017 +1200
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Thu Jun 1 11:28:53 2017 -0700

    mtd: mchp23k256: Add OF device ID table
    
    This allows registering of this device via a Device Tree.
    
    Signed-off-by: Chris Packham <chris.packham at alliedtelesis.co.nz>
    Reviewed-by: Andrew Lunn <andrew at lunn.ch>
    Tested-by: Andrew Lunn <andrew at lunn.ch>
    Acked-by: Boris Brezillon <boris.brezillon at free-electrons.com>
    Acked-by: Rob Herring <robh at kernel.org>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 .../devicetree/bindings/mtd/microchip,mchp23k256.txt   | 18 ++++++++++++++++++
 drivers/mtd/devices/mchp23k256.c                       |  8 ++++++++
 2 files changed, 26 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
new file mode 100644
index 0000000..25e5ad3
--- /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 at 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 e237db9..9d8306a 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,



More information about the linux-mtd-cvs mailing list