From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XQvGU-0007Mq-Tb for barebox@lists.infradead.org; Mon, 08 Sep 2014 09:29:41 +0000 From: Steffen Trumtrar Date: Mon, 8 Sep 2014 11:29:08 +0200 Message-Id: <1410168551-6588-3-git-send-email-s.trumtrar@pengutronix.de> In-Reply-To: <1410168551-6588-1-git-send-email-s.trumtrar@pengutronix.de> References: <1410168551-6588-1-git-send-email-s.trumtrar@pengutronix.de> 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 v4 2/5] Firmware: provide a handler to program Altera FPGAs To: barebox@lists.infradead.org Cc: Juergen Beisert , Steffen Trumtrar RnJvbTogSnVlcmdlbiBCZWlzZXJ0IDxqYmVAcGVuZ3V0cm9uaXguZGU+CgpUaGlzIGhhbmRsZXIg dXNlcyBhIHJlZ3VsYXIgU1BJIG1hc3RlciBhbmQgYSBmZXcgR1BJT3MgdG8gcHJvZ3JhbSBhbgpB bHRlcmEgRlBHQSBpbiBzZXJpYWwgbW9kZS4KClNpZ25lZC1vZmYtYnk6IEp1ZXJnZW4gQmVpc2Vy dCA8amJlQHBlbmd1dHJvbml4LmRlPgpTaWduZWQtb2ZmLWJ5OiBTYXNjaGEgSGF1ZXIgPHMuaGF1 ZXJAcGVuZ3V0cm9uaXguZGU+ClNpZ25lZC1vZmYtYnk6IFN0ZWZmZW4gVHJ1bXRyYXIgPHMudHJ1 bXRyYXJAcGVuZ3V0cm9uaXguZGU+Ci0tLQoKTm90ZXM6CiAgICBDaGFuZ2VzIHNpbmNlIHYzOgoJ LSBmaXggc29tZSB0eXBvcw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