From patchwork Thu Dec 14 07:49:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naga Sureshkumar Relli X-Patchwork-Id: 848397 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eFBMI5Is"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="tsmseF+1"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yy5N03LMWz9t3V for ; Thu, 14 Dec 2017 18:50:45 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SjZFnLqotS556VAZZrbYoVLQtdG0eo/iUrVOgfJ4PmU=; b=eFBMI5Is//LtRs TO0dLUaKNq72mNRZaxbBTfIHD6CWCISGKzMkE4Tvb8Q5V6OEhX5XDI1p/e/E4yfSBIrsOpTytZcfm tOEuSjCHgHR9iWs9dbBoD1ep2M0QtwCf+8HFlh8nnKTLDOV8sWO3P+0tYvuZV19cDEDagOkJKwQPb YdfOJZMZTJY1RnGFsvW1blN3e6sgV4E7wSFP7pClHpLEbdFVP0JXTqnntc7lMblLjLLWjgFBL1AET 3SvyL/lT+hrJUBEGkkcX270AKU3qIoom2UFRe5k/HrseoFHBMZ1A3k74YPbQgMuq2FvvdVluQgICl 1kIUtWvoSeKcaXgJS37Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ePOHs-0003IV-Dq; Thu, 14 Dec 2017 07:50:36 +0000 Received: from mail-dm3nam03on0073.outbound.protection.outlook.com ([104.47.41.73] helo=NAM03-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ePOHf-0001PK-V8 for linux-mtd@lists.infradead.org; Thu, 14 Dec 2017 07:50:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=i+s3R5lejwesIDTUEeUkYxYYCgzLXTlN/TxkWW7P40g=; b=tsmseF+1N5yQ8TZA4EDEJJt1D3mMZkIQWke339jL17zv2iklTR+c8Jyn0IIvPKR/mPMpgQWvf5DqxwNimeFnscTpDR0imDJiNaY7U9UAi5r7Vd2SMtMgcHOGaepk3ww7jK6ETAPlPNQF82+pIvSgXLH40AoXR722d+AA2BP+97s= Received: from MWHPR0201CA0081.namprd02.prod.outlook.com (10.167.161.22) by DM5PR02MB3386.namprd02.prod.outlook.com (10.164.152.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Thu, 14 Dec 2017 07:50:00 +0000 Received: from SN1NAM02FT026.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::208) by MWHPR0201CA0081.outlook.office365.com (2603:10b6:301:75::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.302.9 via Frontend Transport; Thu, 14 Dec 2017 07:49:59 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by SN1NAM02FT026.mail.protection.outlook.com (10.152.72.97) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.302.6 via Frontend Transport; Thu, 14 Dec 2017 07:49:55 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:54501 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1ePOHD-0005ng-1t; Wed, 13 Dec 2017 23:49:55 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1ePOHC-0002IA-WE; Wed, 13 Dec 2017 23:49:55 -0800 Received: from xsj-pvapsmtp01 (maildrop.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id vBE7njSU010755; Wed, 13 Dec 2017 23:49:45 -0800 Received: from [172.23.37.108] (helo=xhdnagasure40.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1ePOH3-0002Gl-1e; Wed, 13 Dec 2017 23:49:45 -0800 From: Naga Sureshkumar Relli To: , , , , Subject: [PATCH v8 1/2] mtd: arasan: Add device tree binding documentation Date: Thu, 14 Dec 2017 13:19:05 +0530 Message-ID: <20171214074906.2147-2-nagasure@xilinx.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20171214074906.2147-1-nagasure@xilinx.com> References: <20171214074906.2147-1-nagasure@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23526.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(396003)(376002)(39860400002)(2980300002)(438002)(189003)(199004)(81166006)(77096006)(5660300001)(2906002)(356003)(63266004)(8676002)(50226002)(7696005)(81156014)(110136005)(36756003)(106466001)(54906003)(39060400002)(2201001)(51416003)(106002)(16586007)(76176011)(9786002)(316002)(305945005)(2950100002)(478600001)(36386004)(1076002)(48376002)(50466002)(47776003)(8936002)(6666003)(59450400001)(4326008)(107986001)(5001870100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR02MB3386; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM02FT026; 1:X1HDc4eHKtLQqOdu9oxTeoKkEnI6o49j3gvws6cwq5IaFMSwUhvyiwz5zrOMBM9c6aPxOGG9AQmkd6T+b3zE7MgdLJLR5tv7ywx3ZdwyJMeBJ5nhX/dsZ4y3IuGNABiA MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ac67fe3-ceea-446f-6cb8-08d542c74697 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307); SRVR:DM5PR02MB3386; X-Microsoft-Exchange-Diagnostics: 1; DM5PR02MB3386; 3:+ekB5FSS1XlxizeMTZtzhhFptx3WSLztHQyyk3ue/5ZAPO6LXsE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RcgW1xuepmM3jGlE99clziaZJQ1kY2joN5TMwedGQsp06FNQfGdpq1CijrhjjhgqVwfiq/L0JNSlMYK4h3jiInO6F0+81P2bWjv7GLffeyzESEUCDVBAepCBfgI/ELmFg9ghZEIIBVA0qw7uixZaAlb35zWsHPQXCVYhgqEwu+uA7CCc694C/LS30HNXJfMgoBsTvq8+2ggNbZYFU1Nbyr/+WJtgOv+MSex+T659V5A12MEvU3pEvS3R2qst34fhy/YvdOiklxXxRwRgaxZR/jjZu1zl9IdMxp3w25eGy930cN94++LaGNNXV23vMFlyIgfGSZN8QRT0zeXNf6dhJ42vcb2OOc/RlwFbXURQA2EWx0QBGgrPgQTTo11BM5IaWfixL5u3tGrZkpJecJBwHcLkWNF X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(93006095)(93004095)(3231023)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(6072148)(201708071742011); SRVR:DM5PR02MB3386; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM5PR02MB3386; X-Microsoft-Exchange-Diagnostics: 1; DM5PR02MB3386; 4:S53FzLOQRq2dw4O7ZEOFD0O1VqOjlJxUz+l6dbCONAdcd+yXlgo1DisQpSCuwIuXgv6N8yKFyxbD2xnMcVKyOXbtwF7P6GP7kC5hT6bMbyczA2d4V7KtjM0jETFBaS5mzeENI8YAJ7+wcw8aUTMtfJaKJ0BNBxaRgAYUVEl0Pr6h8UQlOGeTa4az3NFNOwLYQFVvNkcQsrNAWNjg5zbJl1s43sGarA/si5xFM29XKpnpiUtnxBdCgNJG7VH28tv9ZvQQ6OKBfeIJueyY9Ae2YBeKKQSGVkDDTc4o0K/bF5bcPEF6xCdIZEMb8yEog1BO X-Forefront-PRVS: 05214F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oldC4VH64aQaDEImOYuKyoOG27h8cfOZl9XbvRFpE= X-Microsoft-Exchange-Diagnostics: 1; DM5PR02MB3386; 6:rif4AszIj2KuCCRW+M+AK/Snau6rWaYU7RbSjPMnNAJ83i2aSLwzqXdy1/esGVEeTkwpOBHc0gS9BOhJ7ydqVTZpNQmUbNVrs36xgnD7gReRbIK3svulRXzznJPGHN2HjfbHqsoKC4tZp+2kuFo9GzMU24qiCpDF8fZpqY9SRwJaLVZVs5YE5zqorALSAvlicz4zzqid92ixL6M3FTldbXlx+HBYGlyIHMFnDDIMK6nYx3igDQXGAlvilO/TkaJXn5JDv0RuxXTmcoD0L4n7V+YQFn7ttEJ6KS0rd2aDq/JEEQ4S9PuNfnTRBYI2hj9WFyIxpf9TV1nEJFRI9z4Xv3JxBQkasAYXsfaBLQ6vvfg=; 5:oJDqJ98IbQD26FpYiL4sWSl/ackgAVKk8vbINlOcP5OGXKchkO3UirkMt3a9rnFCzmSB2U3fCyyF9qvh8Vs4/moGa+GQ5dBurldA8M+WrHPLOKZeIJxzGWsrFziA7fx7bzFzlDpU5YOtyjlHzSGj398nN0oZBqdrzjh1R7b22to=; 24:7iKTCiQyrjniRzEAShBKnQJDe/3U14ENHMusy+cMDZFTWytnduuKkaFe2vnzlFtFuC/rZKXH/OyPDFxG46x4WYCAt25+XEMqw5oURDZ3IEk=; 7:XI7HvUSVLiqCwti2LMx8DMW73ArEiMg0cr6IqjPeOcoTb8POghZZhQJuHq/5a79AKBE2pvSN+vh9JvwizypOXSXSIOATsnm/w1K48BRGE+LcqcQGxX7GNReAq7kC0KqqbpLfr4mXfXeIrCewXndTSwr54hT2zvjKM80+bIvUZurjvTLB+AZ4lfCW1GvTyxO47xx8Ru+g7jcyhJx0esJOQI1FSXlnspSqQ+G2Sj54DP1UYImaonKLHidYUl+uAcvi SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2017 07:49:55.9921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ac67fe3-ceea-446f-6cb8-08d542c74697 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB3386 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171213_235024_440527_43A17B79 X-CRM114-Status: GOOD ( 10.73 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [104.47.41.73 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [104.47.41.73 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nagasuresh12@gmail.com, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, punnaia@xilinx.com, michals@xilinx.com, dwmw2@infradead.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch adds the dts binding document for arasan nand flash controller. Signed-off-by: Naga Sureshkumar Relli Signed-off-by: Punnaiah Choudary Kalluri --- Changes in v8: - Updated compatible and clock-names as per Boris comments Changes in v7: - Corrected the acronyms those should be in caps changes in v6: - Removed num-cs property - Separated nandchip from nand controller changes in v5: - None Changes in v4: - Added num-cs property - Added clock support Changes in v3: - None Changes in v2: - None --- .../devicetree/bindings/mtd/arasan_nand.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/arasan_nand.txt diff --git a/Documentation/devicetree/bindings/mtd/arasan_nand.txt b/Documentation/devicetree/bindings/mtd/arasan_nand.txt new file mode 100644 index 000000000000..1a870153a909 --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/arasan_nand.txt @@ -0,0 +1,38 @@ +Arasan NAND Flash Controller with ONFI 3.1 support + +Required properties: +- compatible: Should be "xlnx,zynqmp-nand" or "arasan,nfc-v3p10" +- reg: Memory map for module access +- interrupt-parent: Interrupt controller the interrupt is routed through +- interrupts: Should contain the interrupt for the device +- clock-name: List of input clocks - "sys", "flash" + (See clock bindings for details) +- clocks: Clock phandles (see clock bindings for details) + +Optional properties: +- arasan,has-mdma: Enables DMA support + +For NAND partition information please refer the below file +Documentation/devicetree/bindings/mtd/partition.txt + +Example: + nand0: nand@ff100000 { + compatible = "xlnx,zynqmp-nand", "arasan,nfc-v3p10" + reg = <0x0 0xff100000 0x1000>; + clock-name = "sys", "flash" + clocks = <&misc_clk &misc_clk>; + interrupt-parent = <&gic>; + interrupts = <0 14 4>; + arasan,has-mdma; + #address-cells = <1>; + #size-cells = <0> + + nand@0 { + reg = <0> + partition@0 { + label = "filesystem"; + reg = <0x0 0x0 0x1000000>; + }; + (...) + }; + }; From patchwork Thu Dec 14 07:49:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naga Sureshkumar Relli X-Patchwork-Id: 848398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EROxDfwR"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="x3HK/SU+"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yy5NC18Dfz9t2M for ; Thu, 14 Dec 2017 18:51:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xyhRBj/g1S/w6iFSULgkogJlw0+qdxqh+9Zk4LTdZqs=; b=EROxDfwRo4kS5C C5DYffHAIT7F+9bkoIUR2vlIpdC0eUFHdNYbxqTO4uM7ZeRiPy5O/Lw+REnXoqK55tWofEPQMI5ix 5zqo+tOrIUaa6onymUJ6KBaUv4M/3VMoenM0ksU4Xf3lfyuHRDY/xS32z8Maw8fDAekFc3WckwnS2 aVqJppdVNVIZKr+JxmJXVhjbHOR4+1IUSJ7Zo5/gS8KDDQqFlgPBoq2SfmIP9euICxOlPRMblX9fd OdbFyXgBKtn1LtIm35gVlW86TCeVgnrAcBHb0oXZt1lfQTGnGP611RCr+3j23MhxibJEEJLfOFT7X NYwmhIFS7qE3kSz1DRuA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ePOIE-0003cI-9P; Thu, 14 Dec 2017 07:50:58 +0000 Received: from mail-co1nam03on0042.outbound.protection.outlook.com ([104.47.40.42] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ePOHh-0001qT-Lf for linux-mtd@lists.infradead.org; Thu, 14 Dec 2017 07:50:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=g8+cikeUtFdtqj+hfhjRZrlZ1E3/T9G5DZUUVg9gVq0=; b=x3HK/SU+MUipwyHk3lFlR7Zx+kk/K6vXmTB8N+TCcE2mN499bjPD9BznE10gaNoBt5Z9m4dmVBt3fiK1DheIGQyP7+dOQAVKopDFiQSpETa3aMRghxYSkGM4fenNIc4r0MoLavR8RsyWVy+AiTeugnF4Nn5rtkv7gf2FYwOlvY8= Received: from SN4PR0201CA0007.namprd02.prod.outlook.com (2603:10b6:803:2b::17) by DM2PR02MB1338.namprd02.prod.outlook.com (2a01:111:e400:50c8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Thu, 14 Dec 2017 07:49:59 +0000 Received: from SN1NAM02FT032.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::207) by SN4PR0201CA0007.outlook.office365.com (2603:10b6:803:2b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.302.9 via Frontend Transport; Thu, 14 Dec 2017 07:49:59 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT032.mail.protection.outlook.com (10.152.72.126) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.302.6 via Frontend Transport; Thu, 14 Dec 2017 07:49:55 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1ePOHD-0003sz-3v; Wed, 13 Dec 2017 23:49:55 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1ePOHD-0002IA-1Y; Wed, 13 Dec 2017 23:49:55 -0800 Received: from xsj-pvapsmtp01 (smtp2.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id vBE7nnwH010767; Wed, 13 Dec 2017 23:49:49 -0800 Received: from [172.23.37.108] (helo=xhdnagasure40.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1ePOH6-0002Gl-Bc; Wed, 13 Dec 2017 23:49:49 -0800 From: Naga Sureshkumar Relli To: , , , , Subject: [PATCH v8 2/2] mtd: nand: Add support for Arasan NAND Flash Controller Date: Thu, 14 Dec 2017 13:19:06 +0530 Message-ID: <20171214074906.2147-3-nagasure@xilinx.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20171214074906.2147-1-nagasure@xilinx.com> References: <20171214074906.2147-1-nagasure@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23526.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(396003)(346002)(39860400002)(376002)(2980300002)(438002)(189003)(199004)(50466002)(106466001)(356003)(77096006)(36386004)(5660300001)(59450400001)(63266004)(4326008)(76176011)(478600001)(51416003)(1076002)(47776003)(7696005)(5890100001)(48376002)(16586007)(316002)(81156014)(81166006)(36756003)(8676002)(2906002)(110136005)(2201001)(575784001)(106002)(54906003)(9786002)(6666003)(305945005)(53946003)(2950100002)(8936002)(39060400002)(50226002)(107986001)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR02MB1338; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; PTR:unknown-60-83.xilinx.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM02FT032; 1:Z2WLj4rb5Pf0NPRgF6X/tkbxM8S9QK1uqAjT76CkgbwvslK4HtZdtGy21RJwRGVZ9uxoIDUUG19+qiJDLFot+A+Mky0mZsox6CUrlBw/3g6UugKfvK5EDXHMxkNqLx61 MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6074a0e0-093f-4174-5ff2-08d542c7469f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307); SRVR:DM2PR02MB1338; X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB1338; 3:Q9Wy52iZFfXNRZjVAREeq1+uph3Q359BhlVCZ5jEILdXYWnO0e/cstme7N5t8xibS5rWlBYG+7jGWC4CfPtS5HMC9c0oJB/tj1DY7sQU9lKlGM6XOWoJeGtccolZsd0WVLgEgnNrVN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KqP1VIuueK5tf3iR4OVeOuoobpo7iWN58Kwao3SHckIujaGO+zxL73wl0j5HiU+wdArDb/hlxrHUsIj9Zmx5NB+ij8BpDY3H4xsNMfiKkwlnUGhNF3rdsTUN2mP/DRAscWdbwgXkcmyefU74eXL7mjppllQqdEBVRSw8FtsHtL+bLvXUKvYob/7HbrKcD5aoYbpmmLd8RzC1PzuHvx5+SNiUYn+Na1qqcr2Ue/m5Nn4nq77HXb5Up1NE2jhNQqjAn+ickd31aY/RbP7BqD8YMOOWYuGb8tuIkzN0hVHv2hCdRDcZ9oDBJX0B9byGqY6p25gBnqSP//43jPAacQpmdbVRjODuw7y X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592)(211171220733660); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93004095)(3231023)(3002001)(6055026)(6041248)(20161123558100)(20161123560025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(201708071742011); SRVR:DM2PR02MB1338; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM2PR02MB1338; X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB1338; 4:VYgq7voAZxaWTsOat9sFlj+2lTBvrUlOvrLP8ZobZB4YcsykFtFBuZos+eG6NC2sSni4H9pvoeYDG0A4PJVMd9D5BZp4QKWraoCmvB03x0uKAF/tqO62qjs3VQulKWLcMEPtqhndAgtLZFIjQOidn0JutZLz4VWsUw9sj/Zv/phBJ6Y4dCWXolMv7MhcCmYy47QmQ1hHbr270ko6bURc/aoAb/jgGVZpVgdSepeYWq0biVkjn2r0a7fDWkKgHYF5zaRX3v+wmozdC/dvcnBAawwqvJJpDngJWmg3acu8K8uJXAxG6bnioi2IaC/W8n5uYeVmn7hLq0Nu7Dgw3v+OUWHkCIHc0HzdFbVF5ivpTkM= X-Forefront-PRVS: 05214FD68E X-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put: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2017 07:49:55.9172 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6074a0e0-093f-4174-5ff2-08d542c7469f X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR02MB1338 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171213_235026_264369_AC769458 X-CRM114-Status: GOOD ( 15.97 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [104.47.40.42 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [104.47.40.42 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nagasuresh12@gmail.com, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, punnaia@xilinx.com, michals@xilinx.com, dwmw2@infradead.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Added the basic driver for Arasan NAND Flash Controller used in Zynq UltraScale+ MPSoC. It supports only Hw ECC and upto 24bit correction. Signed-off-by: Naga Sureshkumar Relli Signed-off-by: Punnaiah Choudary Kalluri --- Changes in v8: - Implemented setup_data_interface hook - fixed checkpatch --strict warnings - Added anfc_config_ecc in read_page_hwecc - Fixed returning status value by reading flash status in read_byte() instead of reading previous value. Changes in v7: - Implemented Marek suggestions and comments - Corrected the acronyms those should be in caps - Modified kconfig/Make file to keep arasan entry in sorted order - Added is_vmlloc_addr check - Used ioread/write32_rep variants to avoid compilation error for intel platforms - separated PIO and DMA mode read/write functions - Minor cleanup Chnages in v6: - Addressed most of the Brian and Boris comments - Separated the nandchip from the nand controller - Removed the ecc lookup table from driver - Now use framework nand waitfunction and readoob - Fixed the compiler warning - Adapted the new frameowrk changes related to ecc and ooblayout - Disabled the clocks after the nand_reelase - Now using only one completion object - Boris suggessions like adapting cmd_ctrl and rework on read/write byte are not implemented and i will patch them later - Also check_erased_ecc_chunk for erase and check for is_vmalloc_addr will implement later once the basic driver is mainlined. Changes in v5: - Renamed the driver filei as arasan_nand.c - Fixed all comments relaqted coding style - Fixed comments related to propagating the errors - Modified the anfc_write_page_hwecc as per the write_page prototype Changes in v4: - Added support for onfi timing mode configuration - Added clock supppport - Added support for multiple chipselects Changes in v3: - Removed unused variables - Avoided busy loop and used jifies based implementation - Fixed compiler warnings "right shift count >= width of type" - Removed unneeded codei and improved error reporting - Added onfi version check to ensure reading the valid address cycles Changes in v2: - Added missing of.h to avoid kbuild system report erro --- drivers/mtd/nand/Kconfig | 8 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/arasan_nand.c | 1020 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1029 insertions(+) create mode 100644 drivers/mtd/nand/arasan_nand.c diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index 3f2036f31da4..bdc97510f758 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig @@ -40,6 +40,14 @@ config MTD_SM_COMMON tristate default n +config MTD_NAND_ARASAN + tristate "Support for Arasan Nand Flash controller" + depends on HAS_IOMEM + depends on HAS_DMA + help + Enables the driver for the Arasan NAND Flash controller on + Zynq UltraScale+ MPSoC. + config MTD_NAND_DENALI tristate diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 6e2db700d923..b96965a95daf 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_MTD_NAND_ECC) += nand_ecc.o obj-$(CONFIG_MTD_NAND_BCH) += nand_bch.o obj-$(CONFIG_MTD_SM_COMMON) += sm_common.o +obj-$(CONFIG_MTD_NAND_ARASAN) += arasan_nand.o obj-$(CONFIG_MTD_NAND_CAFE) += cafe_nand.o obj-$(CONFIG_MTD_NAND_AMS_DELTA) += ams-delta.o obj-$(CONFIG_MTD_NAND_DENALI) += denali.o diff --git a/drivers/mtd/nand/arasan_nand.c b/drivers/mtd/nand/arasan_nand.c new file mode 100644 index 000000000000..a9ed1dbb09de --- /dev/null +++ b/drivers/mtd/nand/arasan_nand.c @@ -0,0 +1,1020 @@ +/* + * Arasan NAND Flash Controller Driver + * + * Copyright (C) 2014 - 2017 Xilinx, Inc. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "arasan_nand" +#define EVNT_TIMEOUT_MSEC 1000 + +#define PKT_OFST 0x00 +#define MEM_ADDR1_OFST 0x04 +#define MEM_ADDR2_OFST 0x08 +#define CMD_OFST 0x0C +#define PROG_OFST 0x10 +#define INTR_STS_EN_OFST 0x14 +#define INTR_SIG_EN_OFST 0x18 +#define INTR_STS_OFST 0x1C +#define READY_STS_OFST 0x20 +#define DMA_ADDR1_OFST 0x24 +#define FLASH_STS_OFST 0x28 +#define DATA_PORT_OFST 0x30 +#define ECC_OFST 0x34 +#define ECC_ERR_CNT_OFST 0x38 +#define ECC_SPR_CMD_OFST 0x3C +#define ECC_ERR_CNT_1BIT_OFST 0x40 +#define ECC_ERR_CNT_2BIT_OFST 0x44 +#define DMA_ADDR0_OFST 0x50 +#define DATA_INTERFACE_OFST 0x6C + +#define PKT_CNT_SHIFT 12 + +#define ECC_ENABLE BIT(31) +#define DMA_EN_MASK GENMASK(27, 26) +#define DMA_ENABLE 0x2 +#define DMA_EN_SHIFT 26 +#define REG_PAGE_SIZE_SHIFT 23 +#define REG_PAGE_SIZE_512 0 +#define REG_PAGE_SIZE_1K 5 +#define REG_PAGE_SIZE_2K 1 +#define REG_PAGE_SIZE_4K 2 +#define REG_PAGE_SIZE_8K 3 +#define REG_PAGE_SIZE_16K 4 +#define CMD2_SHIFT 8 +#define ADDR_CYCLES_SHIFT 28 + +#define XFER_COMPLETE BIT(2) +#define READ_READY BIT(1) +#define WRITE_READY BIT(0) +#define MBIT_ERROR BIT(3) + +#define PROG_PGRD BIT(0) +#define PROG_ERASE BIT(2) +#define PROG_STATUS BIT(3) +#define PROG_PGPROG BIT(4) +#define PROG_RDID BIT(6) +#define PROG_RDPARAM BIT(7) +#define PROG_RST BIT(8) +#define PROG_GET_FEATURE BIT(9) +#define PROG_SET_FEATURE BIT(10) + +#define PG_ADDR_SHIFT 16 +#define BCH_MODE_SHIFT 25 +#define BCH_EN_SHIFT 27 +#define ECC_SIZE_SHIFT 16 + +#define MEM_ADDR_MASK GENMASK(7, 0) +#define BCH_MODE_MASK GENMASK(27, 25) + +#define CS_MASK GENMASK(31, 30) +#define CS_SHIFT 30 + +#define PAGE_ERR_CNT_MASK GENMASK(16, 8) +#define PKT_ERR_CNT_MASK GENMASK(7, 0) + +#define NVDDR_MODE BIT(9) +#define NVDDR_TIMING_MODE_SHIFT 3 + +#define ONFI_ID_LEN 8 +#define TEMP_BUF_SIZE 1024 +#define NVDDR_MODE_PACKET_SIZE 8 +#define SDR_MODE_PACKET_SIZE 4 + +#define ONFI_DATA_INTERFACE_NVDDR BIT(4) +#define EVENT_MASK (XFER_COMPLETE | READ_READY | WRITE_READY | MBIT_ERROR) + +#define SDR_MODE_DEFLT_FREQ 80000000 + +/** + * struct anfc_nand_chip - Defines the nand chip related information + * @node: used to store NAND chips into a list. + * @chip: NAND chip information structure. + * @bch: Bch / Hamming mode enable/disable. + * @bchmode: Bch mode. + * @eccval: Ecc config value. + * @raddr_cycles: Row address cycle information. + * @caddr_cycles: Column address cycle information. + * @pktsize: Packet size for read / write operation. + * @csnum: chipselect number to be used. + * @spktsize: Packet size in ddr mode for status operation. + * @inftimeval: Data interface and timing mode information + */ +struct anfc_nand_chip { + struct list_head node; + struct nand_chip chip; + bool bch; + u32 bchmode; + u32 eccval; + u16 raddr_cycles; + u16 caddr_cycles; + u32 pktsize; + int csnum; + u32 spktsize; + u32 inftimeval; +}; + +/** + * struct anfc - Defines the Arasan NAND flash driver instance + * @controller: base controller structure. + * @chips: list of all nand chips attached to the ctrler. + * @dev: Pointer to the device structure. + * @base: Virtual address of the NAND flash device. + * @curr_cmd: Current command issued. + * @clk_sys: Pointer to the system clock. + * @clk_flash: Pointer to the flash clock. + * @dma: Dma enable/disable. + * @iswriteoob: Identifies if oob write operation is required. + * @buf: Buffer used for read/write byte operations. + * @irq: irq number + * @bufshift: Variable used for indexing buffer operation + * @csnum: Chip select number currently inuse. + * @event: Completion event for nand status events. + * @status: Status of the flash device + */ +struct anfc { + struct nand_hw_control controller; + struct list_head chips; + struct device *dev; + void __iomem *base; + int curr_cmd; + struct clk *clk_sys; + struct clk *clk_flash; + bool dma; + bool iswriteoob; + u8 buf[TEMP_BUF_SIZE]; + int irq; + u32 bufshift; + int csnum; + struct completion event; + int status; +}; + +static int anfc_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + struct nand_chip *nand = mtd_to_nand(mtd); + + if (section) + return -ERANGE; + + oobregion->length = nand->ecc.total; + oobregion->offset = mtd->oobsize - oobregion->length; + + return 0; +} + +static int anfc_ooblayout_free(struct mtd_info *mtd, int section, + struct mtd_oob_region *oobregion) +{ + struct nand_chip *nand = mtd_to_nand(mtd); + + if (section) + return -ERANGE; + + oobregion->offset = 2; + oobregion->length = mtd->oobsize - nand->ecc.total - 2; + + return 0; +} + +static const struct mtd_ooblayout_ops anfc_ooblayout_ops = { + .ecc = anfc_ooblayout_ecc, + .free = anfc_ooblayout_free, +}; + +static inline struct anfc_nand_chip *to_anfc_nand(struct nand_chip *nand) +{ + return container_of(nand, struct anfc_nand_chip, chip); +} + +static inline struct anfc *to_anfc(struct nand_hw_control *ctrl) +{ + return container_of(ctrl, struct anfc, controller); +} + +static u8 anfc_page(u32 pagesize) +{ + switch (pagesize) { + case 512: + return REG_PAGE_SIZE_512; + case 1024: + return REG_PAGE_SIZE_1K; + case 2048: + return REG_PAGE_SIZE_2K; + case 4096: + return REG_PAGE_SIZE_4K; + case 8192: + return REG_PAGE_SIZE_8K; + case 16384: + return REG_PAGE_SIZE_16K; + default: + break; + } + + return 0; +} + +static inline void anfc_enable_intrs(struct anfc *nfc, u32 val) +{ + writel(val, nfc->base + INTR_STS_EN_OFST); + writel(val, nfc->base + INTR_SIG_EN_OFST); +} + +static inline void anfc_config_ecc(struct anfc *nfc, int on) +{ + u32 val; + + val = readl(nfc->base + CMD_OFST); + if (on) + val |= ECC_ENABLE; + else + val &= ~ECC_ENABLE; + writel(val, nfc->base + CMD_OFST); +} + +static inline void anfc_config_dma(struct anfc *nfc, int on) +{ + u32 val; + + val = readl(nfc->base + CMD_OFST); + val &= ~DMA_EN_MASK; + if (on) + val |= DMA_ENABLE << DMA_EN_SHIFT; + writel(val, nfc->base + CMD_OFST); +} + +static inline int anfc_wait_for_event(struct anfc *nfc) +{ + return wait_for_completion_timeout(&nfc->event, + msecs_to_jiffies(EVNT_TIMEOUT_MSEC)); +} + +static inline void anfc_setpktszcnt(struct anfc *nfc, u32 pktsize, + u32 pktcount) +{ + writel(pktsize | (pktcount << PKT_CNT_SHIFT), nfc->base + PKT_OFST); +} + +static inline void anfc_set_eccsparecmd(struct anfc *nfc, + struct anfc_nand_chip *achip, u8 cmd1, + u8 cmd2) +{ + writel(cmd1 | (cmd2 << CMD2_SHIFT) | + (achip->caddr_cycles << ADDR_CYCLES_SHIFT), + nfc->base + ECC_SPR_CMD_OFST); +} + +static void anfc_setpagecoladdr(struct anfc *nfc, u32 page, u16 col) +{ + u32 val; + + writel(col | (page << PG_ADDR_SHIFT), nfc->base + MEM_ADDR1_OFST); + + val = readl(nfc->base + MEM_ADDR2_OFST); + val = (val & ~MEM_ADDR_MASK) | + ((page >> PG_ADDR_SHIFT) & MEM_ADDR_MASK); + writel(val, nfc->base + MEM_ADDR2_OFST); +} + +static void anfc_prepare_cmd(struct anfc *nfc, u8 cmd1, u8 cmd2, u8 dmamode, + u32 pagesize, u8 addrcycles) +{ + u32 regval; + + regval = cmd1 | (cmd2 << CMD2_SHIFT); + if (dmamode && nfc->dma) + regval |= DMA_ENABLE << DMA_EN_SHIFT; + regval |= addrcycles << ADDR_CYCLES_SHIFT; + regval |= anfc_page(pagesize) << REG_PAGE_SIZE_SHIFT; + writel(regval, nfc->base + CMD_OFST); +} + +static int anfc_write_oob(struct mtd_info *mtd, struct nand_chip *chip, + int page) +{ + struct anfc *nfc = to_anfc(chip->controller); + + nfc->iswriteoob = true; + chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page); + chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); + nfc->iswriteoob = false; + + return 0; +} + +static void anfc_rw_buf_dma(struct mtd_info *mtd, uint8_t *buf, int len, + int operation, u32 prog) +{ + dma_addr_t paddr; + struct nand_chip *chip = mtd_to_nand(mtd); + struct anfc *nfc = to_anfc(chip->controller); + struct anfc_nand_chip *achip = to_anfc_nand(chip); + u32 eccintr = 0, dir; + u32 pktsize = len, pktcount = 1; + + if (nfc->curr_cmd == NAND_CMD_READ0 || + (nfc->curr_cmd == NAND_CMD_SEQIN && !nfc->iswriteoob)) { + pktsize = achip->pktsize; + pktcount = DIV_ROUND_UP(mtd->writesize, pktsize); + } + anfc_setpktszcnt(nfc, pktsize, pktcount); + + if (!achip->bch && nfc->curr_cmd == NAND_CMD_READ0) + eccintr = MBIT_ERROR; + + if (operation) + dir = DMA_FROM_DEVICE; + else + dir = DMA_TO_DEVICE; + + paddr = dma_map_single(nfc->dev, buf, len, dir); + if (dma_mapping_error(nfc->dev, paddr)) { + dev_err(nfc->dev, "Read buffer mapping error"); + return; + } + writel(paddr, nfc->base + DMA_ADDR0_OFST); + writel((paddr >> 32), nfc->base + DMA_ADDR1_OFST); + anfc_enable_intrs(nfc, (XFER_COMPLETE | eccintr)); + writel(prog, nfc->base + PROG_OFST); + anfc_wait_for_event(nfc); + dma_unmap_single(nfc->dev, paddr, len, dir); +} + +static void anfc_rw_buf_pio(struct mtd_info *mtd, uint8_t *buf, int len, + int operation, int prog) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + struct anfc *nfc = to_anfc(chip->controller); + struct anfc_nand_chip *achip = to_anfc_nand(chip); + u32 *bufptr = (u32 *)buf; + u32 cnt = 0, intr = 0; + u32 pktsize = len, pktcount = 1; + + anfc_config_dma(nfc, 0); + + if (nfc->curr_cmd == NAND_CMD_READ0 || + (nfc->curr_cmd == NAND_CMD_SEQIN && !nfc->iswriteoob)) { + pktsize = achip->pktsize; + pktcount = DIV_ROUND_UP(mtd->writesize, pktsize); + } + anfc_setpktszcnt(nfc, pktsize, pktcount); + + if (!achip->bch && nfc->curr_cmd == NAND_CMD_READ0) + intr = MBIT_ERROR; + + if (operation) + intr |= READ_READY; + else + intr |= WRITE_READY; + + anfc_enable_intrs(nfc, intr); + writel(prog, nfc->base + PROG_OFST); + + while (cnt < pktcount) { + anfc_wait_for_event(nfc); + cnt++; + if (cnt == pktcount) + anfc_enable_intrs(nfc, XFER_COMPLETE); + if (operation) + ioread32_rep(nfc->base + DATA_PORT_OFST, bufptr, + pktsize / 4); + else + iowrite32_rep(nfc->base + DATA_PORT_OFST, bufptr, + pktsize / 4); + bufptr += (pktsize / 4); + if (cnt < pktcount) + anfc_enable_intrs(nfc, intr); + } + + anfc_wait_for_event(nfc); +} + +static void anfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + struct anfc *nfc = to_anfc(chip->controller); + + if (nfc->dma && !is_vmalloc_addr(buf)) + anfc_rw_buf_dma(mtd, buf, len, 1, PROG_PGRD); + else + anfc_rw_buf_pio(mtd, buf, len, 1, PROG_PGRD); +} + +static void anfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + struct anfc *nfc = to_anfc(chip->controller); + + if (nfc->dma && !is_vmalloc_addr(buf)) + anfc_rw_buf_dma(mtd, (char *)buf, len, 0, PROG_PGPROG); + else + anfc_rw_buf_pio(mtd, (char *)buf, len, 0, PROG_PGPROG); +} + +static int anfc_read_page_hwecc(struct mtd_info *mtd, + struct nand_chip *chip, uint8_t *buf, + int oob_required, int page) +{ + u32 val; + struct anfc *nfc = to_anfc(chip->controller); + struct anfc_nand_chip *achip = to_anfc_nand(chip); + u8 *ecc_code = chip->buffers->ecccode; + u8 *p = buf; + int eccsize = chip->ecc.size; + int eccbytes = chip->ecc.bytes; + int eccsteps = chip->ecc.steps; + int stat = 0, i; + + anfc_set_eccsparecmd(nfc, achip, NAND_CMD_RNDOUT, NAND_CMD_RNDOUTSTART); + anfc_config_ecc(nfc, 1); + + chip->read_buf(mtd, buf, mtd->writesize); + + val = readl(nfc->base + ECC_ERR_CNT_OFST); + val = ((val & PAGE_ERR_CNT_MASK) >> 8); + if (achip->bch) { + mtd->ecc_stats.corrected += val; + } else { + val = readl(nfc->base + ECC_ERR_CNT_1BIT_OFST); + mtd->ecc_stats.corrected += val; + val = readl(nfc->base + ECC_ERR_CNT_2BIT_OFST); + mtd->ecc_stats.failed += val; + /* Clear ecc error count register 1Bit, 2Bit */ + writel(0x0, nfc->base + ECC_ERR_CNT_1BIT_OFST); + writel(0x0, nfc->base + ECC_ERR_CNT_2BIT_OFST); + } + + if (oob_required) + chip->ecc.read_oob(mtd, chip, page); + + anfc_config_ecc(nfc, 0); + + if (val) { + chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); + mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0, + chip->ecc.total); + for (i = 0 ; eccsteps; eccsteps--, i += eccbytes, + p += eccsize) { + stat = nand_check_erased_ecc_chunk(p, + chip->ecc.size, + &ecc_code[i], + eccbytes, + NULL, 0, + chip->ecc.strength); + } + if (stat < 0) + stat = 0; + else + mtd->ecc_stats.corrected += stat; + return stat; + } + + return 0; +} + +static int anfc_write_page_hwecc(struct mtd_info *mtd, + struct nand_chip *chip, const uint8_t *buf, + int oob_required, int page) +{ + int ret; + struct anfc *nfc = to_anfc(chip->controller); + struct anfc_nand_chip *achip = to_anfc_nand(chip); + u8 *ecc_calc = chip->buffers->ecccalc; + + anfc_set_eccsparecmd(nfc, achip, NAND_CMD_RNDIN, 0); + anfc_config_ecc(nfc, 1); + + chip->write_buf(mtd, buf, mtd->writesize); + + if (oob_required) { + chip->waitfunc(mtd, chip); + chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); + chip->read_buf(mtd, ecc_calc, mtd->oobsize); + ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, + 0, chip->ecc.total); + if (ret) + return ret; + chip->ecc.write_oob(mtd, chip, page); + } + anfc_config_ecc(nfc, 0); + + return 0; +} + +static u8 anfc_read_byte(struct mtd_info *mtd) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + struct anfc *nfc = to_anfc(chip->controller); + + if (nfc->curr_cmd == NAND_CMD_STATUS) + return readl(nfc->base + FLASH_STS_OFST); + else + return nfc->buf[nfc->bufshift++]; +} + +static int anfc_extra_init(struct anfc *nfc, struct anfc_nand_chip *achip) +{ + int mode, err; + unsigned int feature[2]; + u32 inftimeval; + struct nand_chip *chip = &achip->chip; + struct mtd_info *mtd = nand_to_mtd(chip); + bool change_sdr_clk = false; + + if (!chip->onfi_version || + !(le16_to_cpu(chip->onfi_params.opt_cmd) + & ONFI_OPT_CMD_SET_GET_FEATURES)) + return -EINVAL; + + /* + * If the controller is already in the same mode as flash device + * then no need to change the timing mode again. + */ + if (readl(nfc->base + DATA_INTERFACE_OFST) == achip->inftimeval) + return 0; + + memset(feature, 0, NVDDR_MODE_PACKET_SIZE); + /* Get nvddr timing modes */ + mode = onfi_get_sync_timing_mode(chip) & 0xff; + if (!mode) { + mode = fls(onfi_get_async_timing_mode(chip)) - 1; + inftimeval = mode; + if (mode >= 2 && mode <= 5) + change_sdr_clk = true; + } else { + mode = fls(mode) - 1; + inftimeval = NVDDR_MODE | (mode << NVDDR_TIMING_MODE_SHIFT); + mode |= ONFI_DATA_INTERFACE_NVDDR; + } + feature[0] = mode; + chip->select_chip(mtd, achip->csnum); + err = chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_TIMING_MODE, + (uint8_t *)feature); + chip->select_chip(mtd, -1); + if (err) + return err; + /* + * SDR timing modes 2-5 will not work for the arasan nand when + * freq > 90 MHz, so reduce the freq in SDR modes 2-5 to < 90Mhz + */ + if (change_sdr_clk) { + clk_disable_unprepare(nfc->clk_sys); + err = clk_set_rate(nfc->clk_sys, SDR_MODE_DEFLT_FREQ); + if (err) { + dev_err(nfc->dev, "Can't set the clock rate\n"); + return err; + } + err = clk_prepare_enable(nfc->clk_sys); + if (err) { + dev_err(nfc->dev, "Unable to enable sys clock.\n"); + clk_disable_unprepare(nfc->clk_sys); + return err; + } + } + achip->inftimeval = inftimeval; + if (mode & ONFI_DATA_INTERFACE_NVDDR) + achip->spktsize = NVDDR_MODE_PACKET_SIZE; + return 0; +} + +static int anfc_ecc_init(struct mtd_info *mtd, + struct nand_ecc_ctrl *ecc) +{ + u32 ecc_addr; + unsigned int bchmode, steps; + struct nand_chip *chip = mtd_to_nand(mtd); + struct anfc_nand_chip *achip = to_anfc_nand(chip); + + ecc->mode = NAND_ECC_HW; + ecc->read_page = anfc_read_page_hwecc; + ecc->write_page = anfc_write_page_hwecc; + ecc->write_oob = anfc_write_oob; + mtd_set_ooblayout(mtd, &anfc_ooblayout_ops); + + steps = mtd->writesize / chip->ecc_step_ds; + + switch (chip->ecc_strength_ds) { + case 12: + bchmode = 0x1; + break; + case 8: + bchmode = 0x2; + break; + case 4: + bchmode = 0x3; + break; + case 24: + bchmode = 0x4; + break; + default: + bchmode = 0x0; + } + + if (!bchmode) + ecc->total = 3 * steps; + else + ecc->total = + DIV_ROUND_UP(fls(8 * chip->ecc_step_ds) * + chip->ecc_strength_ds * steps, 8); + + ecc->strength = chip->ecc_strength_ds; + ecc->size = chip->ecc_step_ds; + ecc->bytes = ecc->total / steps; + ecc->steps = steps; + achip->bchmode = bchmode; + achip->bch = achip->bchmode; + ecc_addr = mtd->writesize + (mtd->oobsize - ecc->total); + + achip->eccval = ecc_addr | (ecc->total << ECC_SIZE_SHIFT) | + (achip->bch << BCH_EN_SHIFT); + + if (chip->ecc_step_ds >= 1024) + achip->pktsize = 1024; + else + achip->pktsize = 512; + + return 0; +} + +static void anfc_cmd_function(struct mtd_info *mtd, + unsigned int cmd, int column, int page_addr) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + struct anfc_nand_chip *achip = to_anfc_nand(chip); + struct anfc *nfc = to_anfc(chip->controller); + bool wait = false; + u32 addrcycles, prog; + + nfc->bufshift = 0; + nfc->curr_cmd = cmd; + + if (page_addr == -1) + page_addr = 0; + if (column == -1) + column = 0; + + switch (cmd) { + case NAND_CMD_RESET: + anfc_prepare_cmd(nfc, cmd, 0, 0, 0, 0); + prog = PROG_RST; + wait = true; + break; + case NAND_CMD_SEQIN: + addrcycles = achip->raddr_cycles + achip->caddr_cycles; + anfc_prepare_cmd(nfc, cmd, NAND_CMD_PAGEPROG, 1, + mtd->writesize, addrcycles); + anfc_setpagecoladdr(nfc, page_addr, column); + break; + case NAND_CMD_READOOB: + column += mtd->writesize; + case NAND_CMD_READ0: + case NAND_CMD_READ1: + addrcycles = achip->raddr_cycles + achip->caddr_cycles; + anfc_prepare_cmd(nfc, NAND_CMD_READ0, NAND_CMD_READSTART, 1, + mtd->writesize, addrcycles); + anfc_setpagecoladdr(nfc, page_addr, column); + break; + case NAND_CMD_RNDOUT: + anfc_prepare_cmd(nfc, cmd, NAND_CMD_RNDOUTSTART, 1, + mtd->writesize, 2); + anfc_setpagecoladdr(nfc, page_addr, column); + break; + case NAND_CMD_PARAM: + anfc_prepare_cmd(nfc, cmd, 0, 0, 0, 1); + anfc_setpagecoladdr(nfc, page_addr, column); + anfc_rw_buf_pio(mtd, nfc->buf, + (4 * sizeof(struct nand_onfi_params)), + 1, PROG_RDPARAM); + break; + case NAND_CMD_READID: + anfc_prepare_cmd(nfc, cmd, 0, 0, 0, 1); + anfc_setpagecoladdr(nfc, page_addr, column); + anfc_rw_buf_pio(mtd, nfc->buf, ONFI_ID_LEN, 1, PROG_RDID); + break; + case NAND_CMD_ERASE1: + addrcycles = achip->raddr_cycles; + prog = PROG_ERASE; + anfc_prepare_cmd(nfc, cmd, NAND_CMD_ERASE2, 0, 0, addrcycles); + column = page_addr & 0xffff; + page_addr = (page_addr >> PG_ADDR_SHIFT) & 0xffff; + anfc_setpagecoladdr(nfc, page_addr, column); + wait = true; + break; + case NAND_CMD_STATUS: + anfc_prepare_cmd(nfc, cmd, 0, 0, 0, 0); + anfc_setpktszcnt(nfc, achip->spktsize / 4, 1); + anfc_setpagecoladdr(nfc, page_addr, column); + prog = PROG_STATUS; + wait = true; + break; + case NAND_CMD_GET_FEATURES: + anfc_prepare_cmd(nfc, cmd, 0, 0, 0, 1); + anfc_setpagecoladdr(nfc, page_addr, column); + anfc_rw_buf_pio(mtd, nfc->buf, achip->spktsize, 1, + PROG_GET_FEATURE); + break; + case NAND_CMD_SET_FEATURES: + anfc_prepare_cmd(nfc, cmd, 0, 0, 0, 1); + anfc_setpagecoladdr(nfc, page_addr, column); + break; + default: + return; + } + + if (wait) { + anfc_enable_intrs(nfc, XFER_COMPLETE); + writel(prog, nfc->base + PROG_OFST); + anfc_wait_for_event(nfc); + } + if (nfc->curr_cmd == NAND_CMD_STATUS) + nfc->status = readl(nfc->base + FLASH_STS_OFST); +} + +static void anfc_select_chip(struct mtd_info *mtd, int num) +{ + u32 val; + struct nand_chip *chip = mtd_to_nand(mtd); + struct anfc_nand_chip *achip = to_anfc_nand(chip); + struct anfc *nfc = to_anfc(chip->controller); + + if (num == -1) + return; + + val = readl(nfc->base + MEM_ADDR2_OFST); + val &= (val & ~(CS_MASK | BCH_MODE_MASK)); + val |= (achip->csnum << CS_SHIFT) | (achip->bchmode << BCH_MODE_SHIFT); + writel(val, nfc->base + MEM_ADDR2_OFST); + nfc->csnum = achip->csnum; + writel(achip->eccval, nfc->base + ECC_OFST); + writel(achip->inftimeval, nfc->base + DATA_INTERFACE_OFST); +} + +static irqreturn_t anfc_irq_handler(int irq, void *ptr) +{ + struct anfc *nfc = ptr; + u32 status; + + status = readl(nfc->base + INTR_STS_OFST); + if (status & EVENT_MASK) { + complete(&nfc->event); + writel((status & EVENT_MASK), nfc->base + INTR_STS_OFST); + writel(0, nfc->base + INTR_STS_EN_OFST); + writel(0, nfc->base + INTR_SIG_EN_OFST); + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + +static int anfc_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip, + int addr, uint8_t *subfeature_param) +{ + struct anfc_nand_chip *achip = to_anfc_nand(chip); + int status; + + if (!chip->onfi_version) + return -EINVAL; + + if (!(le16_to_cpu(chip->onfi_params.opt_cmd) & + ONFI_OPT_CMD_SET_GET_FEATURES)) + return -EINVAL; + + chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1); + anfc_rw_buf_pio(mtd, subfeature_param, achip->spktsize, + 0, PROG_SET_FEATURE); + status = chip->waitfunc(mtd, chip); + if (status & NAND_STATUS_FAIL) + return -EIO; + + return 0; +} + +static int anfc_setup_data_interface(struct mtd_info *mtd, int csline, + const struct nand_data_interface *conf) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + struct anfc *nfc = to_anfc(chip->controller); + int err; + struct anfc_nand_chip *achip = to_anfc_nand(chip); + + if (csline == NAND_DATA_IFACE_CHECK_ONLY) + return 0; + + clk_disable_unprepare(nfc->clk_sys); + err = clk_set_rate(nfc->clk_sys, SDR_MODE_DEFLT_FREQ); + if (err) { + dev_err(nfc->dev, "Can't set the clock rate\n"); + return err; + } + err = clk_prepare_enable(nfc->clk_sys); + if (err) { + dev_err(nfc->dev, "Unable to enable sys clock.\n"); + clk_disable_unprepare(nfc->clk_sys); + return err; + } + achip->inftimeval = 0; + anfc_extra_init(nfc, achip); + + return 0; +} + +static int anfc_nand_chip_init(struct anfc *nfc, + struct anfc_nand_chip *anand_chip, + struct device_node *np) +{ + struct nand_chip *chip = &anand_chip->chip; + struct mtd_info *mtd = nand_to_mtd(chip); + int ret; + + ret = of_property_read_u32(np, "reg", &anand_chip->csnum); + if (ret) { + dev_err(nfc->dev, "can't get chip-select\n"); + return -ENXIO; + } + + mtd->name = devm_kasprintf(nfc->dev, GFP_KERNEL, "arasan_nand.%d", + anand_chip->csnum); + mtd->dev.parent = nfc->dev; + + chip->cmdfunc = anfc_cmd_function; + chip->chip_delay = 30; + chip->controller = &nfc->controller; + chip->read_buf = anfc_read_buf; + chip->write_buf = anfc_write_buf; + chip->read_byte = anfc_read_byte; + chip->options = NAND_BUSWIDTH_AUTO | NAND_NO_SUBPAGE_WRITE; + chip->bbt_options = NAND_BBT_USE_FLASH; + chip->select_chip = anfc_select_chip; + chip->onfi_set_features = anfc_onfi_set_features; + chip->setup_data_interface = anfc_setup_data_interface; + nand_set_flash_node(chip, np); + + anand_chip->spktsize = SDR_MODE_PACKET_SIZE; + ret = nand_scan_ident(mtd, 1, NULL); + if (ret) { + dev_err(nfc->dev, "nand_scan_ident for NAND failed\n"); + return ret; + } + if (chip->onfi_version) { + anand_chip->raddr_cycles = chip->onfi_params.addr_cycles & 0xf; + anand_chip->caddr_cycles = + (chip->onfi_params.addr_cycles >> 4) & 0xf; + } else { + /* For non-ONFI devices, configuring the address cyles as 5 */ + anand_chip->raddr_cycles = 3; + anand_chip->caddr_cycles = 2; + } + + ret = anfc_ecc_init(mtd, &chip->ecc); + if (ret) + return ret; + + ret = nand_scan_tail(mtd); + if (ret) { + dev_err(nfc->dev, "nand_scan_tail for NAND failed\n"); + return ret; + } + + return mtd_device_register(mtd, NULL, 0); +} + +static int anfc_probe(struct platform_device *pdev) +{ + struct anfc *nfc; + struct anfc_nand_chip *anand_chip; + struct device_node *np = pdev->dev.of_node, *child; + struct resource *res; + int err; + + nfc = devm_kzalloc(&pdev->dev, sizeof(*nfc), GFP_KERNEL); + if (!nfc) + return -ENOMEM; + + init_waitqueue_head(&nfc->controller.wq); + INIT_LIST_HEAD(&nfc->chips); + init_completion(&nfc->event); + nfc->dev = &pdev->dev; + platform_set_drvdata(pdev, nfc); + nfc->csnum = -1; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + nfc->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(nfc->base)) + return PTR_ERR(nfc->base); + nfc->dma = of_property_read_bool(pdev->dev.of_node, + "arasan,has-mdma"); + nfc->irq = platform_get_irq(pdev, 0); + if (nfc->irq < 0) { + dev_err(&pdev->dev, "platform_get_irq failed\n"); + return -ENXIO; + } + dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); + err = devm_request_irq(&pdev->dev, nfc->irq, anfc_irq_handler, + 0, "arasannfc", nfc); + if (err) + return err; + nfc->clk_sys = devm_clk_get(&pdev->dev, "sys"); + if (IS_ERR(nfc->clk_sys)) { + dev_err(&pdev->dev, "sys clock not found.\n"); + return PTR_ERR(nfc->clk_sys); + } + + nfc->clk_flash = devm_clk_get(&pdev->dev, "flash"); + if (IS_ERR(nfc->clk_flash)) { + dev_err(&pdev->dev, "flash clock not found.\n"); + return PTR_ERR(nfc->clk_flash); + } + + err = clk_prepare_enable(nfc->clk_sys); + if (err) { + dev_err(&pdev->dev, "Unable to enable sys clock.\n"); + return err; + } + + err = clk_prepare_enable(nfc->clk_flash); + if (err) { + dev_err(&pdev->dev, "Unable to enable flash clock.\n"); + goto clk_dis_sys; + } + + for_each_available_child_of_node(np, child) { + anand_chip = devm_kzalloc(&pdev->dev, sizeof(*anand_chip), + GFP_KERNEL); + if (!anand_chip) { + of_node_put(child); + err = -ENOMEM; + goto nandchip_clean_up; + } + + err = anfc_nand_chip_init(nfc, anand_chip, child); + if (err) { + devm_kfree(&pdev->dev, anand_chip); + continue; + } + + list_add_tail(&anand_chip->node, &nfc->chips); + } + + return 0; + +nandchip_clean_up: + list_for_each_entry(anand_chip, &nfc->chips, node) + nand_release(nand_to_mtd(&anand_chip->chip)); + clk_disable_unprepare(nfc->clk_flash); +clk_dis_sys: + clk_disable_unprepare(nfc->clk_sys); + + return err; +} + +static int anfc_remove(struct platform_device *pdev) +{ + struct anfc *nfc = platform_get_drvdata(pdev); + struct anfc_nand_chip *anand_chip; + + list_for_each_entry(anand_chip, &nfc->chips, node) + nand_release(nand_to_mtd(&anand_chip->chip)); + + clk_disable_unprepare(nfc->clk_sys); + clk_disable_unprepare(nfc->clk_flash); + + return 0; +} + +static const struct of_device_id anfc_ids[] = { + { .compatible = "arasan,nfc-v3p10" }, + { .compatible = "xlnx,zynqmp-nand" }, + { } +}; +MODULE_DEVICE_TABLE(of, anfc_ids); + +static struct platform_driver anfc_driver = { + .driver = { + .name = DRIVER_NAME, + .of_match_table = anfc_ids, + }, + .probe = anfc_probe, + .remove = anfc_remove, +}; +module_platform_driver(anfc_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Xilinx, Inc"); +MODULE_DESCRIPTION("Arasan NAND Flash Controller Driver");