From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from smtp2-g21.free.fr ([212.27.42.2]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OGqOH-00059P-PF for barebox@lists.infradead.org; Tue, 25 May 2010 09:25:39 +0000 From: =?utf-8?q?Eric=20B=C3=A9nard?= Date: Tue, 25 May 2010 11:25:32 +0200 Message-Id: <1274779532-8110-1-git-send-email-eric@eukrea.com> In-Reply-To: <4BFB9224.9030507@pengutronix.de> References: <4BFB9224.9030507@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-bounces@lists.infradead.org Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v5] commands: add i2c commands To: s.hauer@pengutronix.de Cc: barebox@lists.infradead.org dGhlc2VzIGNvbW1hbmRzIGFsbG93IGxvdyBsZXZlbCBhY2Nlc3MgdG8gaTJjIGJ1cyBhbmQgY2Fu IGJlIHVzZWZ1bAp0byBzZXR1cCBhbiBpMmMgZGV2aWNlIHdpdGhvdXQgaGF2aW5nIHRvIGFkZCBj b2RlLCBjb21waWxlIGFuZCBmbGFzaApiYXJlYm94LgoKU2lnbmVkLW9mZi1ieTogRXJpYyBCw6lu YXJkIDxlcmljQGV1a3JlYS5jb20+Ci0tLQp2NSA6Cgl1cGRhdGVkIGFzIHBlciBNYXJjJ3MgY29t bWVudHMKCWJldHRlciBlcnJvciBoYW5kbGluZyBpbiB3cml0ZQoJYmV0dGVyIGRlZmF1bHQgYnVz IGhhbmRsaW5nIGluIHJlYWQgJiB3cml0ZQp2NCA6Cgl1cGRhdGVkIGFzIHBlciBTYXNjaGEgYW5k IE1hcmMncyBjb21tZW50cwoJdXNlIGJ1cyAwIGFzIGEgZGVmYXVsdCBmb3IgaTJjX3JlYWQgJiB3 cml0ZQoJcmVwbGFjZSBt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isJfQor CisJY291bnQgPSBhcmdjIC0gb3B0aW5kOworCisJaWYgKChhZGRyIDwgMCkgfHwgKHJlZyA8IDAp IHx8IChjb3VudCA9PSAwKSB8fCAoYWRkciA+IDB4N0YpKQorCQlyZXR1cm4gQ09NTUFORF9FUlJP Ul9VU0FHRTsKKworCWFkYXB0ZXIgPSBpMmNfZ2V0X2FkYXB0ZXIoYnVzKTsKKwlpZiAoIWFkYXB0 ZXIpCisJCXJldHVybiAtRU5PREVWOworCisJY2xpZW50LmFkYXB0ZXIgPSBhZGFwdGVyOworCWNs aWVudC5hZGRyID0gYWRkcjsKKworCWJ1ZiA9IHhtYWxsb2MoY291bnQpOworCWZvciAoaSA9IDA7 IGkgPCBjb3VudDsgaSsrKQorCQkqKGJ1ZiArIGkpID0gKGNoYXIpIHNpbXBsZV9zdHJ0b2woYXJn dltvcHRpbmQraV0sIE5VTEwsIDE2KTsKKworCXJldCA9IGkyY193cml0ZV9yZWcoJmNsaWVudCwg cmVnLCBidWYsIGNvdW50KTsKKwlpZiAocmV0ICE9IGNvdW50KQorCQlnb3RvIG91dDsKKwlyZXQg PSAwOworCisJaWYgKHZlcmJvc2UpIHsKKwkJcHJpbnRmKCJ3cm90ZSAlaSBieXRlcyBzdGFydGlu ZyBhdCByZWcgMHglMDJ4IHRvIGkyY2RldiAweCUwMnggb24gYnVzICVpXG4iLAorCQkJY291bnQs IHJlZywgYWRkciwgYWRhcHRlci0+bnIpOworCQlmb3IgKGkgPSAwOyBpIDwgY291bnQ7IGkrKykK KwkJCXByaW50ZigiMHglMDJ4ICIsICooYnVmICsgaSkpOworCQlwcmludGYoIlxuIik7CisJfQor CitvdXQ6CisJZnJlZShidWYpOworCXJldHVybiByZXQ7Cit9CisKK3N0YXRpYyBjb25zdCBfX21h eWJlX3VudXNlZCBjaGFyIGNtZF9pMmNfd3JpdGVfaGVscFtdID0KKyJVc2FnZTogaTJjX3dyaXRl IFtPUFRJT05dIC4uLiBoZXhkYXRhc1xuIgorIndyaX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UgJ3InOgorCQkJcmVnID0g c2ltcGxlX3N0cnRvbChvcHRhcmcsIE5VTEwsIDApOworCQkJYnJlYWs7CisJCWNhc2UgJ3YnOgor CQkJdmVyYm9zZSA9IDE7CisJCQlicmVhazsKKwkJfQorCX0KKworCWlmICgoYWRkciA8IDApIHx8 IChyZWcgPCAwKSB8fCAoY291bnQgPT0gMCkgfHwgKGFkZHIgPiAweDdGKSkKKwkJcmV0dXJuIENP TU1BTkRfRVJST1JfVVNBR0U7CisKKwlhZGFwdGVyID0gaTJjX2dldF9hZGFwdGVyKGJ1cyk7CisJ aWYgKCFhZGFwdGVyKQorCQlyZXR1cm4gLUVOT0RFVjsKKworCWNsaWVudC5hZGFwdGVyID0gYWRh cHRlcjsKKwljbGllbnQuYWRkciA9IGFkZHI7CisKKwlidWYgPSB4bWFsbG9jKGNvdW50KTsKKwly ZXQgPSBpMmNfcmVhZF9yZWcoJmNsaWVudCwgcmVnLCBidWYsIGNvdW50KTsKKwlpZiAocmV0ID09 IGNvdW50KSB7CisJCWludCBpOworCQlpZiAodmVyYm9zZSkKKwkJCXByaW50ZigicmVhZCAlaSBi eXRlcyBzdGFydGluZyBhdCByZWcgMHglMDJ4IGZyb20gaTJjZGV2IDB4JTAyeCBvbiBidXMgJWlc biIsCisJCQkJY291bnQsIHJlZywgYWRkciwgYWRhcHRlci0+bnIpOworCQlmb3IgKGkgPSAwOyBp IDwgY291bnQ7IGkrKykKKwkJCXByaW50ZigiMHglMDJ4ICIsICooYnVmICsgaSkpOworCQlwcmlu dGYoIlxuIik7CisJCXJldCA9IDA7CisJfQorCisJZnJlZShidWYpOworCXJldHVybiByZXQ7Cit9 CisKK3N0YXRpYyBjb25zdCBfX21heWJlX3VudXNlZCBjaGFyIGNtZF9pMmNfcmVhZF9oZWxwW10g PQorIlVzYWdlOiBpMmNfcmVhZCBbT1BUSU9OXVxuIgorInJlYWQgaTJjIGRldmljZS5cbiIKKyIg IC1hIDB4PGFkZHI+ICAgaTJjIGRldmljZSBhZGRyZXNzXG4iCisiICAtYiA8YnVzX251bT4gIGky YyBidXMgbnVtYmVyIChkZWZhdWx0ID0gMClcbiIKKyIgIC1yIDB4PHJlZz4gICAgc3RhcnQgcmVn aXN0ZXJcbiIKKyIgIC1jIDxjb3VudD4gICAgYnl0ZSBjb3VudFxuIjsKKworQkFSRUJPWF9DTURf U1RBUlQoaTJjX3JlYWQpCisJLmNtZAkJPSBkb19pMmNfcmVhZCwKKwkudXNhZ2UJCT0gInJlYWQg ZnJvbSBhbiBpMmMgZGV2aWNlIiwKKwlCQVJFQk9YX0NNRF9IRUxQKGNtZF9pMmNfcmVhZF9oZWxw KQorQkFSRUJPWF9DTURfRU5ECi0tIAoxLjYuMy4zCgoKX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX18KYmFyZWJveCBtYWlsaW5nIGxpc3QKYmFyZWJveEBsaXN0 cy5pbmZyYWRlYWQub3JnCmh0dHA6Ly9saXN0cy5pbmZyYWRlYWQub3JnL21haWxtYW4vbGlzdGlu Zm8vYmFyZWJveAo=