From patchwork Wed Jan 29 14:34:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 3551641 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 425EFC02DC for ; Wed, 29 Jan 2014 14:35:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97C2D2017A for ; Wed, 29 Jan 2014 14:35:46 +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 6E7732015A for ; Wed, 29 Jan 2014 14:35:45 +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 1W8WEV-0002HY-6b; Wed, 29 Jan 2014 14:35:15 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8WES-00052n-8P; Wed, 29 Jan 2014 14:35:12 +0000 Received: from mail-ea0-x22e.google.com ([2a00:1450:4013:c01::22e]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8WEC-0004ww-Aa; Wed, 29 Jan 2014 14:34:58 +0000 Received: by mail-ea0-f174.google.com with SMTP id b10so965957eae.33 for ; Wed, 29 Jan 2014 06:34:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lz1gxhRIjrnVqXjaK7o4gyn90ZbpdUUyjegh4TCu1yU=; b=g/wHq04wg/4MKU4bO0tjO6GCKm8tffYIetA+NNlo1rf9ihY7n+NedwtOcjdN24iq/K woNrTOgv0mAxruy31uwOPVjxlSBjsUGleG5ocDtwXD2AXe8QkqNPI11Z4vb/V1iyMjXs Em7J7gcXVPrnPFDTjJ9Ur5nji7gnWnM+b0zU8aMn0nG6s+h7k9LL1GylTO5MJbGRuk6A gnLNHh6O+kzJQe/iOe0W+kfQdLXNCT3TBDjagzzdnA7dH8tfLh9khjiiZ8G58ZbeZfUF o0THnR7JEHKiO0VzktZhFkxaqZDlJZo1bSg4EIcwfgHq1LmE0fS6ZRGjzoAwArcKhLqe dVcA== X-Received: by 10.15.56.132 with SMTP id y4mr3572427eew.61.1391006074347; Wed, 29 Jan 2014 06:34:34 -0800 (PST) Received: from bbrezillon-laptop.int.overkiz.com ([80.245.18.66]) by mx.google.com with ESMTPSA id o43sm9435426eef.12.2014.01.29.06.34.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 06:34:33 -0800 (PST) From: Boris BREZILLON To: Maxime Ripard , Rob Landley , Russell King , David Woodhouse , Grant Likely , Brian Norris , Jason Gunthorpe , Arnd Bergmann Subject: [RFC PATCH v2 02/14] of: mtd: add NAND ECC level requirements retrieval Date: Wed, 29 Jan 2014 15:34:12 +0100 Message-Id: <1391006064-28890-3-git-send-email-b.brezillon.dev@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391006064-28890-1-git-send-email-b.brezillon.dev@gmail.com> References: <1391006064-28890-1-git-send-email-b.brezillon.dev@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140129_093456_552799_6BD88C43 X-CRM114-Status: GOOD ( 12.30 ) X-Spam-Score: -2.0 (--) Cc: devicetree@vger.kernel.org, Boris BREZILLON , linux-doc@vger.kernel.org, dev@linux-sunxi.org, linux-kernel@vger.kernel.org, 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.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Some chip do not support automatic retrieval of ECC level requirements. Provide an helper function to retrieve these requirements from DT. Signed-off-by: Boris BREZILLON --- drivers/of/of_mtd.c | 25 +++++++++++++++++++++++++ include/linux/of_mtd.h | 7 +++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/of/of_mtd.c b/drivers/of/of_mtd.c index a27ec94..e8ced61 100644 --- a/drivers/of/of_mtd.c +++ b/drivers/of/of_mtd.c @@ -50,6 +50,31 @@ int of_get_nand_ecc_mode(struct device_node *np) EXPORT_SYMBOL_GPL(of_get_nand_ecc_mode); /** + * of_get_nand_ecc_level - Get nand ecc level for the given device_node + * @np: Pointer to the given device_node + * @strengh: ECC strength + * @blk_size: ECC block size + * + * The function gets ecc level requirements from property 'nand-ecc-level'. + * Return 0 on success, -errno otherwise. + */ +int of_get_nand_ecc_level(struct device_node *np, u32 *strengh, u32 *blk_size) +{ + int err; + + err = of_property_read_u32_index(np, "nand-ecc-level", 0, strengh); + if (err < 0) + return err; + + err = of_property_read_u32_index(np, "nand-ecc-level", 1, blk_size); + if (err < 0) + return err; + + return 0; +} +EXPORT_SYMBOL_GPL(of_get_nand_ecc_level); + +/** * of_get_nand_bus_width - Get nand bus witdh for given device_node * @np: Pointer to the given device_node * diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h index 6f10e93..3bd8c3b 100644 --- a/include/linux/of_mtd.h +++ b/include/linux/of_mtd.h @@ -13,6 +13,7 @@ #include int of_get_nand_ecc_mode(struct device_node *np); +int of_get_nand_ecc_level(struct device_node *np, u32 *strengh, u32 *blk_size); int of_get_nand_bus_width(struct device_node *np); bool of_get_nand_on_flash_bbt(struct device_node *np); @@ -23,6 +24,12 @@ static inline int of_get_nand_ecc_mode(struct device_node *np) return -ENOSYS; } +static inline int of_get_nand_ecc_level(struct device_node *np, u32 *strengh, + u32 *blk_size) +{ + return -ENOSYS; +} + static inline int of_get_nand_bus_width(struct device_node *np) { return -ENOSYS;