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 1ZKpor-0001QM-Nl for barebox@lists.infradead.org; Thu, 30 Jul 2015 15:32:32 +0000 Received: from polaris.fritz.box (f053152215.adsl.alicedsl.de [78.53.152.215]) (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 4981FC08C6 for ; Thu, 30 Jul 2015 17:32:07 +0200 (CEST) From: Jan Luebbe Date: Thu, 30 Jul 2015 17:32:01 +0200 Message-Id: <1438270321-945-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 v2] davinci_nand: add support for the NAND controller To: barebox@lists.infradead.org VGhpcyBkcml2ZXIgaXMgYmFzZWQgb24gdGhlIExpbnV4IGRyaXZlciAodjQuMCkuCgpTaWduZWQt b2ZmLWJ5OiBKYW4gTHVlYmJlIDxqbHVlYmJlQGRlYmlhbi5vcmc+Ci0tLQpDaGFuZ2VzIGZyb20g djE6CiAgLSBGaXggc3R5bGUgcHJvYmxlbXMgcmVwb3J0ZWQgYnkgY2hlY2twYXRjaCAocmVwb3J0 ZWQgYnkgQW50b255IFBhdmxvdikuCgogZHJpdmVycy9tdGQvbmFuZC9LY29uZmlnICAgICAgICB8 ICAgNyArCiBkcml2ZXJzL210ZC9uYW5kL01ha2VmaWxlICAgICAgIHwgICAxICsKIGRyaXZlcnMv bXRkL25hbmQvZGF2aW5jaV9uYW5kLmMgfCA4NTYgKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrKysrKysrKwogM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