From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aGrT8-0000Gx-QV for barebox@lists.infradead.org; Wed, 06 Jan 2016 17:01:58 +0000 From: Marc Kleine-Budde Date: Wed, 6 Jan 2016 18:01:31 +0100 Message-Id: <1452099691-28645-4-git-send-email-mkl@pengutronix.de> In-Reply-To: <1452099691-28645-1-git-send-email-mkl@pengutronix.de> References: <1452099691-28645-1-git-send-email-mkl@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 v2 3/3] bootm: add initial FIT support To: barebox@lists.infradead.org Cc: kernel@pengutronix.de RnJvbTogSmFuIEx1ZWJiZSA8amx1QHBlbmd1dHJvbml4LmRlPgoKVGhpcyBpbXBsZW1lbnRhdGlv biBpcyBpbnNwaXJlZCBieSBVLUJvb3QncyBGSVQgc3VwcG9ydC4gSW5zdGVhZCBvZgp1c2luZyBs aWJmZHQgKHdoaWNoIGRvZXMgbm90IGV4aXN0IGluIGJhcmVib3gpLCBjb25maWd1cmF0aW9uIHNp Z25hdHVyZXMKYXJlIHZlcmlmaWVkIGJ5IHVzaW5nIGEgc2ltcGxpZmllZCBEVCBwYXJzZXIgYmFz ZWQgb24gYmFyZWJveCdzIG93bgpjb2RlLgoKQ3VycmVudGx5LCBvbmx5IHNpZ25lZCBjb25maWd1 cmF0aW9ucyB3aXRoIGhhc2hlZCBpbWFnZXMgYXJlIHN1cHBvcnRlZCwKYXMgdGhlIG90aGVyIHZh cmlhbnRzIGFyZSBsZXNzIHVzZWZ1bCBmb3IgdmVyaWZpZWQgYm9vdC4gQ29tcGF0aWJsZSBGSVQ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