From 46aad84190d9f2ea2f9e8c251e1b971519306044 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Wed, 11 Feb 2015 17:01:07 +0200 Subject: mtd: nand: sunxi: fix generic nand binding reference Signed-off-by: Baruch Siach Acked-by: Boris Brezillon Signed-off-by: Brian Norris --- Documentation/devicetree/bindings/mtd/sunxi-nand.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/mtd/sunxi-nand.txt b/Documentation/devicetree/bindings/mtd/sunxi-nand.txt index 0273adb8638c..086d6f44c4b9 100644 --- a/Documentation/devicetree/bindings/mtd/sunxi-nand.txt +++ b/Documentation/devicetree/bindings/mtd/sunxi-nand.txt @@ -21,7 +21,7 @@ Optional properties: - nand-ecc-mode : one of the supported ECC modes ("hw", "hw_syndrome", "soft", "soft_bch" or "none") -see Documentation/devicetree/mtd/nand.txt for generic bindings. +see Documentation/devicetree/bindings/mtd/nand.txt for generic bindings. Examples: -- cgit v1.2.3-59-g8ed1b From 0542e135fa8c56cd03c02d74089750ae9195eb22 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Sat, 28 Feb 2015 01:25:17 -0800 Subject: Documentation: devicetree: fix spelling in pxa3xx-nand binding Signed-off-by: Brian Norris --- Documentation/devicetree/bindings/mtd/pxa3xx-nand.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/mtd/pxa3xx-nand.txt b/Documentation/devicetree/bindings/mtd/pxa3xx-nand.txt index de8b517a5521..4f833e3c4f51 100644 --- a/Documentation/devicetree/bindings/mtd/pxa3xx-nand.txt +++ b/Documentation/devicetree/bindings/mtd/pxa3xx-nand.txt @@ -14,7 +14,7 @@ Optional properties: - marvell,nand-enable-arbiter: Set to enable the bus arbiter - marvell,nand-keep-config: Set to keep the NAND controller config as set by the bootloader - - num-cs: Number of chipselect lines to usw + - num-cs: Number of chipselect lines to use - nand-on-flash-bbt: boolean to enable on flash bbt option if not present false - nand-ecc-strength: number of bits to correct per ECC step -- cgit v1.2.3-59-g8ed1b From a62c24d75529118d10c45350c3b75715d52ff574 Mon Sep 17 00:00:00 2001 From: Dan Ehrenberg Date: Thu, 2 Apr 2015 15:15:11 -0700 Subject: mtd: part: Add sysfs variable for offset of partition This patch makes a sysfs variable called 'offset' on each partition which contains the offset in bytes from the beginning of the master device that the partition starts. Signed-off-by: Dan Ehrenberg Signed-off-by: Brian Norris --- Documentation/ABI/testing/sysfs-class-mtd | 10 ++++++++++ drivers/mtd/mtdpart.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'Documentation') diff --git a/Documentation/ABI/testing/sysfs-class-mtd b/Documentation/ABI/testing/sysfs-class-mtd index 76ee192f80a0..3b5c3bca9186 100644 --- a/Documentation/ABI/testing/sysfs-class-mtd +++ b/Documentation/ABI/testing/sysfs-class-mtd @@ -222,3 +222,13 @@ Description: The number of blocks that are marked as reserved, if any, in this partition. These are typically used to store the in-flash bad block table (BBT). + +What: /sys/class/mtd/mtdX/offset +Date: March 2015 +KernelVersion: 4.1 +Contact: linux-mtd@lists.infradead.org +Description: + For a partition, the offset of that partition from the start + of the master device in bytes. This attribute is absent on + main devices, so it can be used to distinguish between + partitions and devices that aren't partitions. diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index a19ec5a4e409..be8034086701 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -554,6 +554,30 @@ out_register: return slave; } +static ssize_t mtd_partition_offset_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mtd_info *mtd = dev_get_drvdata(dev); + struct mtd_part *part = PART(mtd); + return snprintf(buf, PAGE_SIZE, "%lld\n", part->offset); +} + +static DEVICE_ATTR(offset, S_IRUGO, mtd_partition_offset_show, NULL); + +static const struct attribute *mtd_partition_attrs[] = { + &dev_attr_offset.attr, + NULL +}; + +static int mtd_add_partition_attrs(struct mtd_part *new) +{ + int ret = sysfs_create_files(&new->mtd.dev.kobj, mtd_partition_attrs); + if (ret) + printk(KERN_WARNING + "mtd: failed to create partition attrs, err=%d\n", ret); + return ret; +} + int mtd_add_partition(struct mtd_info *master, const char *name, long long offset, long long length) { @@ -603,6 +627,8 @@ int mtd_add_partition(struct mtd_info *master, const char *name, add_mtd_device(&new->mtd); + mtd_add_partition_attrs(new); + return ret; err_inv: mutex_unlock(&mtd_partitions_mutex); @@ -620,6 +646,8 @@ int mtd_del_partition(struct mtd_info *master, int partno) list_for_each_entry_safe(slave, next, &mtd_partitions, list) if ((slave->master == master) && (slave->mtd.index == partno)) { + sysfs_remove_files(&slave->mtd.dev.kobj, + mtd_partition_attrs); ret = del_mtd_device(&slave->mtd); if (ret < 0) break; @@ -663,6 +691,7 @@ int add_mtd_partitions(struct mtd_info *master, mutex_unlock(&mtd_partitions_mutex); add_mtd_device(&slave->mtd); + mtd_add_partition_attrs(slave); cur_offset = slave->offset + slave->mtd.size; } -- cgit v1.2.3-59-g8ed1b From 8ff16cf77ce314c20d7bd57c788f5b7719b450e1 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Fri, 27 Mar 2015 10:29:49 -0700 Subject: Documentation: devicetree: m25p80: add "nor-jedec" binding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Almost all flash that are "compatible" with m25p80 support the JEDEC READ ID opcode (0x9F), and in fact, that is often the only thing that is used to differentiate them. Let's add a compatible string that represents this lowest common denominator of compatibility. Device trees can still specify manufacturer/device names in addition, but (until some reason is found to differentiate between them through device tree) software will likely want to bind just against the generic name, and avoid unnecessarily growing its device ID binding tables. This is related to the work of commit a5b7616c55e1 ("mtd: m25p80,spi-nor: Fix module aliases for m25p80"), which showed that maintaining these device tables as stable device-tree/modalias binding tables is not a worthwhile burden for mostly-comptatible flash. At the same time, let's update the binding doc to point to the m25p_ids[] ID list instead of spi_nor_ids[]. The former can be used for device tree bindings, but the latter cannot. In the future, we should pare down the m25p_ids[] list to only those IDs which are actually used in device trees. Signed-off-by: Brian Norris Cc: Rafał Miłecki Reviewed-by: Marek Vasut --- Documentation/devicetree/bindings/mtd/m25p80.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'Documentation') diff --git a/Documentation/devicetree/bindings/mtd/m25p80.txt b/Documentation/devicetree/bindings/mtd/m25p80.txt index 4611aa83531b..f20b111b502a 100644 --- a/Documentation/devicetree/bindings/mtd/m25p80.txt +++ b/Documentation/devicetree/bindings/mtd/m25p80.txt @@ -3,10 +3,13 @@ Required properties: - #address-cells, #size-cells : Must be present if the device has sub-nodes representing partitions. -- compatible : Should be the manufacturer and the name of the chip. Bear in mind - the DT binding is not Linux-only, but in case of Linux, see the - "spi_nor_ids" table in drivers/mtd/spi-nor/spi-nor.c for the list - of supported chips. +- compatible : May include a device-specific string consisting of the + manufacturer and name of the chip. Bear in mind the DT binding + is not Linux-only, but in case of Linux, see the "m25p_ids" + table in drivers/mtd/devices/m25p80.c for the list of supported + chips. + Must also include "nor-jedec" for any SPI NOR flash that can be + identified by the JEDEC READ ID opcode (0x9F). - reg : Chip-Select number - spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at @@ -22,7 +25,7 @@ Example: flash: m25p80@0 { #address-cells = <1>; #size-cells = <1>; - compatible = "spansion,m25p80"; + compatible = "spansion,m25p80", "nor-jedec"; reg = <0>; spi-max-frequency = <40000000>; m25p,fast-read; -- cgit v1.2.3-59-g8ed1b