From patchwork Wed Jan 8 14:21:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 3454261 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2D83BC02DC for ; Wed, 8 Jan 2014 14:27:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AAE4920103 for ; Wed, 8 Jan 2014 14:26:58 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96A64200E9 for ; Wed, 8 Jan 2014 14:26:53 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0u4e-0001Be-Pc; Wed, 08 Jan 2014 14:25:37 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0u4E-0006im-1d; Wed, 08 Jan 2014 14:25:10 +0000 Received: from 6.mo3.mail-out.ovh.net ([188.165.43.173] helo=mo3.mail-out.ovh.net) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0u44-0006dQ-PU for linux-arm-kernel@lists.infradead.org; Wed, 08 Jan 2014 14:25:04 +0000 Received: from mail408.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo3.mail-out.ovh.net (Postfix) with SMTP id 8A75E102010D for ; Wed, 8 Jan 2014 15:24:37 +0100 (CET) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 8 Jan 2014 16:25:11 +0200 Received: from unknown (HELO bbrezillon-laptop.private.s2ih) (b.brezillon@overkiz.com@80.245.18.66) by ns0.ovh.net with SMTP; 8 Jan 2014 16:25:09 +0200 From: Boris BREZILLON To: Maxime Ripard , Rob Landley , Russell King , David Woodhouse , Grant Likely Subject: [RFC PATCH 3/9] of: mtd: add NAND timings retrieval support Date: Wed, 8 Jan 2014 15:21:58 +0100 Message-Id: <1389190924-26226-4-git-send-email-b.brezillon@overkiz.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389190924-26226-1-git-send-email-b.brezillon@overkiz.com> References: <1389190924-26226-1-git-send-email-b.brezillon@overkiz.com> X-Ovh-Tracer-Id: 6892477755232254144 X-Ovh-Remote: 80.245.18.66 () X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejtddrfedtucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejtddrfedtucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140108_092501_867456_706BA5A3 X-CRM114-Status: GOOD ( 15.38 ) X-Spam-Score: -1.9 (-) Cc: devicetree@vger.kernel.org, linux-doc@vger.kernel.org, dev@linux-sunxi.org, linux-kernel@vger.kernel.org, Boris BREZILLON , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a function to retrieve NAND timings from a given DT node. Signed-off-by: Boris BREZILLON --- drivers/of/of_mtd.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/of_mtd.h | 9 +++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/of/of_mtd.c b/drivers/of/of_mtd.c index a27ec94..52e07fd 100644 --- a/drivers/of/of_mtd.c +++ b/drivers/of/of_mtd.c @@ -83,3 +83,50 @@ bool of_get_nand_on_flash_bbt(struct device_node *np) return of_property_read_bool(np, "nand-on-flash-bbt"); } EXPORT_SYMBOL_GPL(of_get_nand_on_flash_bbt); + +/** + * of_get_nand_timings - Get nand timings for the given device_node + * @np: Pointer to the given device_node + * + * return 0 on success errno other wise + */ +int of_get_nand_timings(struct device_node *np, struct nand_timings *timings) +{ + memset(timings, 0, sizeof(*timings)); + + of_property_read_u32(np, "tCLS-min", &timings->tCLS_min); + of_property_read_u32(np, "tCLH-min", &timings->tCLH_min); + of_property_read_u32(np, "tCS-min", &timings->tCS_min); + of_property_read_u32(np, "tCH-min", &timings->tCH_min); + of_property_read_u32(np, "tWP-min", &timings->tWP_min); + of_property_read_u32(np, "tALS-min", &timings->tALS_min); + of_property_read_u32(np, "tALH-min", &timings->tALH_min); + of_property_read_u32(np, "tDS-min", &timings->tDS_min); + of_property_read_u32(np, "tDH-min", &timings->tDH_min); + of_property_read_u32(np, "tWC-min", &timings->tWC_min); + of_property_read_u32(np, "tWH-min", &timings->tWH_min); + of_property_read_u32(np, "tR-max", &timings->tR_max); + of_property_read_u32(np, "tAR-min", &timings->tAR_min); + of_property_read_u32(np, "tCLR-min", &timings->tCLR_min); + of_property_read_u32(np, "tRR-min", &timings->tRR_min); + of_property_read_u32(np, "tRP-min", &timings->tRP_min); + of_property_read_u32(np, "tWB-max", &timings->tWB_max); + of_property_read_u32(np, "tRC-min", &timings->tRC_min); + of_property_read_u32(np, "tREA-max", &timings->tREA_max); + of_property_read_u32(np, "tRHZ-max", &timings->tRHZ_max); + of_property_read_u32(np, "tCHZ-max", &timings->tCHZ_max); + of_property_read_u32(np, "tRHOH-min", &timings->tRHOH_min); + of_property_read_u32(np, "tRLOH-min", &timings->tRLOH_min); + of_property_read_u32(np, "tCOH-min", &timings->tCOH_min); + of_property_read_u32(np, "tREH-min", &timings->tREH_min); + of_property_read_u32(np, "tWHR-min", &timings->tWHR_min); + of_property_read_u32(np, "tRHW-min", &timings->tRHW_min); + of_property_read_u32(np, "tIR-min", &timings->tIR_min); + of_property_read_u32(np, "tCR-min", &timings->tCR_min); + of_property_read_u32(np, "tADL-min", &timings->tADL_min); + of_property_read_u32(np, "tRST-max", &timings->tRST_max); + of_property_read_u32(np, "tWW-min", &timings->tWW_min); + + return 0; +} +EXPORT_SYMBOL_GPL(of_get_nand_timings); diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h index 6f10e93..ecedb5f 100644 --- a/include/linux/of_mtd.h +++ b/include/linux/of_mtd.h @@ -9,12 +9,15 @@ #ifndef __LINUX_OF_MTD_H #define __LINUX_OF_NET_H +#include + #ifdef CONFIG_OF_MTD #include int of_get_nand_ecc_mode(struct device_node *np); int of_get_nand_bus_width(struct device_node *np); bool of_get_nand_on_flash_bbt(struct device_node *np); +int of_get_nand_timings(struct device_node *np, struct nand_timings *timings); #else /* CONFIG_OF_MTD */ @@ -33,6 +36,12 @@ static inline bool of_get_nand_on_flash_bbt(struct device_node *np) return false; } +static inline int of_get_nand_timings(struct device_node *np, + struct nand_timings *timings) +{ + return -ENOSYS; +} + #endif /* CONFIG_OF_MTD */ #endif /* __LINUX_OF_MTD_H */