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 1aGMiG-00017K-Nk for barebox@lists.infradead.org; Tue, 05 Jan 2016 08:11:33 +0000 From: Marc Kleine-Budde Date: Tue, 5 Jan 2016 09:11:03 +0100 Message-Id: <1451981463-23604-4-git-send-email-mkl@pengutronix.de> In-Reply-To: <1451981463-23604-1-git-send-email-mkl@pengutronix.de> References: <1451981463-23604-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 3/3] bootm: add initial FIT support To: barebox@lists.infradead.org Cc: kernel@pengutronix.de RnJvbTogSmFuIEx1ZWJiZSA8amx1QHBlbmd1dHJvbml4LmRlPgoKVGhpcyBpbXBsZW1lbnRhdGlv biBpcyBpbnNwaXJlZCBieSBVLUJvb3QncyBGSVQgc3VwcG9ydC4gSW5zdGVhZCBvZgp1c2luZyBs aWJmZHQgKHdoaWNoIGRvZXMgbm90IGV4aXN0IGluIGJhcmVib3gpLCBjb25maWd1cmF0aW9uIHNp Z25hdHVyZXMKYXJlIHZlcmlmaWVkIGJ5IHVzaW5nIGEgc2ltcGxpZmllZCBEVCBwYXJzZXIgYmFz ZWQgb24gYmFyZWJveCdzIG93bgpjb2RlLgoKQ3VycmVudGx5LCBvbmx5IHNpZ25lZCBjb25maWd1 cmF0aW9ucyB3aXRoIGhhc2hlZCBpbWFnZXMgYXJlIHN1cHBvcnRlZCwKYXMgdGhlIG90aGVyIHZh cmlhbnRzIGFyZSBsZXNzIHVzZWZ1bCBmb3IgdmVyaWZpZWQgYm9vdC4gQ29tcGF0aWJsZSBGSVQK aW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