Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: dataflash: add device tree probe support

It adds device tree probe support for mtd_dataflash driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>

authored by

Shawn Guo and committed by
Artem Bityutskiy
b94e757c f3c8cfc2

+30 -2
+14
Documentation/devicetree/bindings/mtd/atmel-dataflash.txt
··· 1 + * Atmel Data Flash 2 + 3 + Required properties: 4 + - compatible : "atmel,<model>", "atmel,<series>", "atmel,dataflash". 5 + 6 + Example: 7 + 8 + flash@1 { 9 + #address-cells = <1>; 10 + #size-cells = <1>; 11 + compatible = "atmel,at45db321d", "atmel,at45", "atmel,dataflash"; 12 + spi-max-frequency = <25000000>; 13 + reg = <1>; 14 + };
+16 -2
drivers/mtd/devices/mtd_dataflash.c
··· 17 17 #include <linux/mutex.h> 18 18 #include <linux/err.h> 19 19 #include <linux/math64.h> 20 + #include <linux/of.h> 21 + #include <linux/of_device.h> 20 22 21 23 #include <linux/spi/spi.h> 22 24 #include <linux/spi/flash.h> 23 25 24 26 #include <linux/mtd/mtd.h> 25 27 #include <linux/mtd/partitions.h> 26 - 27 28 28 29 /* 29 30 * DataFlash is a kind of SPI flash. Most AT45 chips have two buffers in ··· 98 97 99 98 struct mtd_info mtd; 100 99 }; 100 + 101 + #ifdef CONFIG_OF 102 + static const struct of_device_id dataflash_dt_ids[] = { 103 + { .compatible = "atmel,at45", }, 104 + { .compatible = "atmel,dataflash", }, 105 + { /* sentinel */ } 106 + }; 107 + #else 108 + #define dataflash_dt_ids NULL 109 + #endif 101 110 102 111 /* ......................................................................... */ 103 112 ··· 645 634 { 646 635 struct dataflash *priv; 647 636 struct mtd_info *device; 637 + struct mtd_part_parser_data ppdata; 648 638 struct flash_platform_data *pdata = spi->dev.platform_data; 649 639 char *otp_tag = ""; 650 640 int err = 0; ··· 687 675 pagesize, otp_tag); 688 676 dev_set_drvdata(&spi->dev, priv); 689 677 690 - err = mtd_device_parse_register(device, NULL, 0, 678 + ppdata.of_node = spi->dev.of_node; 679 + err = mtd_device_parse_register(device, NULL, &ppdata, 691 680 pdata ? pdata->parts : NULL, 692 681 pdata ? pdata->nr_parts : 0); 693 682 ··· 939 926 .name = "mtd_dataflash", 940 927 .bus = &spi_bus_type, 941 928 .owner = THIS_MODULE, 929 + .of_match_table = dataflash_dt_ids, 942 930 }, 943 931 944 932 .probe = dataflash_probe,