From patchwork Fri Jul 15 08:38:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 2709 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id D6F8323F55 for ; Fri, 15 Jul 2011 08:27:18 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8D502A18690 for ; Fri, 15 Jul 2011 08:27:18 +0000 (UTC) Received: by qyk30 with SMTP id 30so746033qyk.11 for ; Fri, 15 Jul 2011 01:27:18 -0700 (PDT) Received: by 10.229.217.3 with SMTP id hk3mr2734057qcb.38.1310718437965; Fri, 15 Jul 2011 01:27:17 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs40565qcb; Fri, 15 Jul 2011 01:27:17 -0700 (PDT) Received: by 10.42.76.66 with SMTP id d2mr3349701ick.449.1310718437179; Fri, 15 Jul 2011 01:27:17 -0700 (PDT) Received: from mail-iy0-f178.google.com (mail-iy0-f178.google.com [209.85.210.178]) by mx.google.com with ESMTPS id l18si1402498ibi.120.2011.07.15.01.27.15 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jul 2011 01:27:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.178 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) client-ip=209.85.210.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.178 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) smtp.mail=shawn.guo@linaro.org Received: by iyb26 with SMTP id 26so1061250iyb.37 for ; Fri, 15 Jul 2011 01:27:15 -0700 (PDT) Received: by 10.42.161.201 with SMTP id u9mr3333382icx.192.1310718434790; Fri, 15 Jul 2011 01:27:14 -0700 (PDT) Received: from localhost.localdomain ([121.236.240.37]) by mx.google.com with ESMTPS id d5sm669696ibi.62.2011.07.15.01.27.06 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jul 2011 01:27:13 -0700 (PDT) From: Shawn Guo To: linux-mtd@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, devicetree-discuss@lists.ozlabs.org, Dmitry Eremin-Solenikov , Mike Frysinger , patches@linaro.org, Shawn Guo , Grant Likely , David Woodhouse , Artem Bityutskiy Subject: [PATCH v3] mtd: dataflash: add device tree probe support Date: Fri, 15 Jul 2011 16:38:56 +0800 Message-Id: <1310719136-21565-1-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1310283313-32087-1-git-send-email-shawn.guo@linaro.org> References: <1310283313-32087-1-git-send-email-shawn.guo@linaro.org> It adds device tree probe support for mtd_dataflash driver. Signed-off-by: Shawn Guo Cc: Grant Likely Cc: David Woodhouse Cc: Artem Bityutskiy --- Changes since v2: * Change compatible string to "at45" from "at45xxx" * Add "#ifdef CONFIG_OF" for dataflash_dt_ids Changes since v1: * Add "atmel,at45xxx" into the match table * Add binding document .../devicetree/bindings/mtd/atmel-dataflash.txt | 14 ++++++++++++++ drivers/mtd/devices/mtd_dataflash.c | 18 ++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/atmel-dataflash.txt diff --git a/Documentation/devicetree/bindings/mtd/atmel-dataflash.txt b/Documentation/devicetree/bindings/mtd/atmel-dataflash.txt new file mode 100644 index 0000000..ef66ddd --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/atmel-dataflash.txt @@ -0,0 +1,14 @@ +* Atmel Data Flash + +Required properties: +- compatible : "atmel,", "atmel,", "atmel,dataflash". + +Example: + +flash@1 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "atmel,at45db321d", "atmel,at45", "atmel,dataflash"; + spi-max-frequency = <25000000>; + reg = <1>; +}; diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c index 8f6b02c..c86fa57 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include @@ -24,7 +26,6 @@ #include #include - /* * DataFlash is a kind of SPI flash. Most AT45 chips have two buffers in * each chip, which may be used for double buffered I/O; but this driver @@ -98,6 +99,16 @@ struct dataflash { struct mtd_info mtd; }; +#ifdef CONFIG_OF +static const struct of_device_id dataflash_dt_ids[] = { + { .compatible = "atmel,at45", }, + { .compatible = "atmel,dataflash", }, + { /* sentinel */ } +}; +#else +#define dataflash_dt_ids NULL +#endif + /* ......................................................................... */ /* @@ -634,6 +645,7 @@ add_dataflash_otp(struct spi_device *spi, char *name, { struct dataflash *priv; struct mtd_info *device; + struct mtd_part_parser_data ppdata; struct flash_platform_data *pdata = spi->dev.platform_data; char *otp_tag = ""; int err = 0; @@ -675,7 +687,8 @@ add_dataflash_otp(struct spi_device *spi, char *name, pagesize, otp_tag); dev_set_drvdata(&spi->dev, priv); - err = mtd_device_parse_register(device, NULL, 0, + ppdata.of_node = spi->dev.of_node; + err = mtd_device_parse_register(device, NULL, &ppdata, pdata ? pdata->parts : NULL, pdata ? pdata->nr_parts : 0); @@ -926,6 +939,7 @@ static struct spi_driver dataflash_driver = { .name = "mtd_dataflash", .bus = &spi_bus_type, .owner = THIS_MODULE, + .of_match_table = dataflash_dt_ids, }, .probe = dataflash_probe,