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 merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ve42e-0001QY-Jt for barebox@lists.infradead.org; Wed, 06 Nov 2013 14:25:12 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Ve42H-0008LN-AH for barebox@lists.infradead.org; Wed, 06 Nov 2013 15:24:45 +0100 Received: from jbe by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1Ve42H-0002J3-8H for barebox@lists.infradead.org; Wed, 06 Nov 2013 15:24:45 +0100 From: Juergen Beisert Date: Wed, 6 Nov 2013 15:24:41 +0100 Message-Id: <1383747881-15698-4-git-send-email-jbe@pengutronix.de> In-Reply-To: <1383747881-15698-1-git-send-email-jbe@pengutronix.de> References: <1383747881-15698-1-git-send-email-jbe@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 3/3] FPGA: provide a handler to program ALTERA FPGAs To: barebox@lists.infradead.org VGhpcyBoYW5kbGVyIHVzZXMgYSByZWd1bGFyIFNQSSBtYXN0ZXIgYW5kIGEgZmV3IEdQSU8gdG8g cHJvZ3JhbSBhbiBBTFRFUkEgRlBHQQppbiBzZXJpYWwgbW9kZS4KClNpZ25lZC1vZmYtYnk6IEp1 ZXJnZW4gQmVpc2VydCA8amJlQHBlbmd1dHJvbml4LmRlPgotLS0KIGRyaXZlcnMvS2NvbmZpZyAg ICAgICAgICAgICAgfCAgIDEgKwogZHJpdmVycy9NYWtlZmlsZSAgICAgICAgICAgICB8ICAgMSAr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