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 1XPXOP-0007Ws-O4 for barebox@lists.infradead.org; Thu, 04 Sep 2014 13:48:07 +0000 From: Steffen Trumtrar Date: Thu, 4 Sep 2014 15:47:15 +0200 Message-Id: <1409838437-3625-3-git-send-email-s.trumtrar@pengutronix.de> In-Reply-To: <1409838437-3625-1-git-send-email-s.trumtrar@pengutronix.de> References: <1409838437-3625-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 v3 2/4] 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+Ci0tLQpDaGFuZ2VzIHNpbmNlIHYyOgoJLSB1c2UgdWRlbGF5 CgktIGNoZWNrIGdwaW9f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