From patchwork Thu Jul 14 15:52:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 104690 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 16BD7B6F65 for ; Fri, 15 Jul 2011 01:42:01 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QhO2c-00032l-Qk; Thu, 14 Jul 2011 15:41:31 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QhO2c-0008OY-EQ; Thu, 14 Jul 2011 15:41:30 +0000 Received: from mail-iy0-f177.google.com ([209.85.210.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QhO2T-0008OC-GH; Thu, 14 Jul 2011 15:41:26 +0000 Received: by iyn15 with SMTP id 15so367508iyn.36 for ; Thu, 14 Jul 2011 08:41:11 -0700 (PDT) Received: by 10.231.61.202 with SMTP id u10mr2288779ibh.73.1310658071446; Thu, 14 Jul 2011 08:41:11 -0700 (PDT) Received: from localhost.localdomain ([117.82.20.93]) by mx.google.com with ESMTPS id d5sm217915ibi.11.2011.07.14.08.40.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 14 Jul 2011 08:41:10 -0700 (PDT) From: Shawn Guo To: linux-mtd@lists.infradead.org Subject: [PATCH v2] mtd: dataflash: add device tree probe support Date: Thu, 14 Jul 2011 23:52:37 +0800 Message-Id: <1310658757-17018-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> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110714_114121_705285_4B7D2836 X-CRM114-Status: GOOD ( 16.21 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.177 listed in list.dnswl.org] Cc: Artem Bityutskiy , patches@linaro.org, Dmitry Eremin-Solenikov , devicetree-discuss@lists.ozlabs.org, Grant Likely , Shawn Guo , David Woodhouse , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.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 v1: * Add "atmel,at45xxx" into the match table * Add binding document .../devicetree/bindings/mtd/atmel-dataflash.txt | 14 ++++++++++++++ drivers/mtd/devices/mtd_dataflash.c | 13 ++++++++++++- 2 files changed, 26 insertions(+), 1 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..3783962 --- /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,at45xxx", "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..8e091b0 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c @@ -24,6 +24,8 @@ #include #include +#include +#include /* * DataFlash is a kind of SPI flash. Most AT45 chips have two buffers in @@ -98,6 +100,12 @@ struct dataflash { struct mtd_info mtd; }; +static const struct of_device_id dataflash_dt_ids[] = { + { .compatible = "atmel,at45xxx", }, + { .compatible = "atmel,dataflash", }, + { /* sentinel */ } +}; + /* ......................................................................... */ /* @@ -634,6 +642,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 +684,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 +936,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,