Skip to content

Commit b94e757

Browse files
Shawn Guodedekind
authored andcommitted
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>
1 parent f3c8cfc commit b94e757

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
};

‎drivers/mtd/devices/mtd_dataflash.c‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
#include <linux/mutex.h>
1818
#include <linux/err.h>
1919
#include <linux/math64.h>
20+
#include <linux/of.h>
21+
#include <linux/of_device.h>
2022

2123
#include <linux/spi/spi.h>
2224
#include <linux/spi/flash.h>
2325

2426
#include <linux/mtd/mtd.h>
2527
#include <linux/mtd/partitions.h>
2628

27-
2829
/*
2930
* DataFlash is a kind of SPI flash. Most AT45 chips have two buffers in
3031
* each chip, which may be used for double buffered I/O; but this driver
@@ -98,6 +99,16 @@ struct dataflash {
9899
struct mtd_info mtd;
99100
};
100101

102+
#ifdef CONFIG_OF
103+
static const struct of_device_id dataflash_dt_ids[] = {
104+
{ .compatible = "atmel,at45", },
105+
{ .compatible = "atmel,dataflash", },
106+
{ /* sentinel */ }
107+
};
108+
#else
109+
#define dataflash_dt_ids NULL
110+
#endif
111+
101112
/* ......................................................................... */
102113

103114
/*
@@ -634,6 +645,7 @@ add_dataflash_otp(struct spi_device *spi, char *name,
634645
{
635646
struct dataflash *priv;
636647
struct mtd_info *device;
648+
struct mtd_part_parser_data ppdata;
637649
struct flash_platform_data *pdata = spi->dev.platform_data;
638650
char *otp_tag = "";
639651
int err = 0;
@@ -675,7 +687,8 @@ add_dataflash_otp(struct spi_device *spi, char *name,
675687
pagesize, otp_tag);
676688
dev_set_drvdata(&spi->dev, priv);
677689

678-
err = mtd_device_parse_register(device, NULL, 0,
690+
ppdata.of_node = spi->dev.of_node;
691+
err = mtd_device_parse_register(device, NULL, &ppdata,
679692
pdata ? pdata->parts : NULL,
680693
pdata ? pdata->nr_parts : 0);
681694

@@ -926,6 +939,7 @@ static struct spi_driver dataflash_driver = {
926939
.name = "mtd_dataflash",
927940
.bus = &spi_bus_type,
928941
.owner = THIS_MODULE,
942+
.of_match_table = dataflash_dt_ids,
929943
},
930944

931945
.probe = dataflash_probe,

0 commit comments

Comments
 (0)