From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from proxima.lasnet.de ([2a01:198:210:70::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YygRR-0003j6-0r for barebox@lists.infradead.org; Sat, 30 May 2015 13:04:47 +0000 Received: from polaris.fritz.box (f053152068.adsl.alicedsl.de [78.53.152.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: polaris@lasnet.de) by proxima.lasnet.de (Postfix) with ESMTPSA id 183A1C1196 for ; Sat, 30 May 2015 15:04:21 +0200 (CEST) From: Jan Luebbe Date: Sat, 30 May 2015 15:04:11 +0200 Message-Id: <1432991051-20800-1-git-send-email-jluebbe@debian.org> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH] davinci_nand: add support for the NAND controller To: barebox@lists.infradead.org VGhpcyBkcml2ZXIgaXMgYmFzZWQgb24gdGhlIExpbnV4IGRyaXZlciAodjQuMCkuCgpTaWduZWQt b2ZmLWJ5OiBKYW4gTHVlYmJlIDxqbHVlYmJlQGRlYmlhbi5vcmc+Ci0tLQogZHJpdmVycy9tdGQv bmFuZC9LY29uZmlnICAgICAgICB8ICAgNyArCiBkcml2ZXJzL210ZC9uYW5kL01ha2VmaWxlICAg ICAgIHwgICAxICsKIGRyaXZlcnMvbXRkL25hbmQvZGF2aW5jaV9uYW5kLmMgfCA4NjYgKysrKysr KysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKwogMyBmaWxlcyBjaGFuZ2VkLCA4NzQg aW5zZXJ0aW9ucygrKQogY3JlYXRlIG1vZGUgMTAwNjQ0IGRyaXZlcnMvbXRkL25hbmQvZGF2aW5j aV9uYW5kLmMKCmRpZmYgLS1naXQ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zICovCisJLy9zdHJ1Y3QgZGF2aW5jaV9hZW1pZl90 aW1pbmcJKnRpbWluZzsKK307CisKKyNkZWZpbmUgTlJDU1JfT0ZGU0VUICAgICAgICAgICAgMHgw MCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorI2RlZmluZSBB V0NDUl9PRkZTRVQgICAgICAgICAgICAweDA0ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgCisjZGVmaW5lIEExQ1JfT0ZGU0VUICAgICAgICAgICAgIDB4MTAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIAorI2RlZmluZSBBQ1JfQVNJWkVfTUFTSyAgICAgICAgICAweDMgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisjZGVmaW5lIEFDUl9FV19NQVNL ICAgICAgICAgICAgIEJJVCgzMCkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAKKyNkZWZpbmUgQUNSX1NTX01BU0sgICAgICAgICAgICAgQklUKDMxKSAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorCisvKgorICogVGhpcyBpcyBhIGRldmlj ZSBkcml2ZXIgZm9yIHRoZSBOQU5EIGZsYXNoIGNvbnRyb2xsZXIgZm91bmQgb24gdGhlCisgKiB2 YXJpb3VzIERhVmluY2kgZmFtaWx5IGNoaXBzLiAgSXQgaGFuZGxlcyB1cCB0byBmb3VyIFNvQyBj aGlwc2VsZWN0cywKKyAqIGFuZCBzb21lIGZsYXZvcnMgb2Ygc2Vjb25kYXJ5IGNoaXBzZWxlY3Qg KGUuZy4gYmFzZWQgb24gQTEyKSBhcyB1c2VkCisgKiB3aXRoIG11bHRpY2hpcCBwYWNrYW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