Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Apr 2014 11:16:07 -0300
From:      Luiz Otavio O Souza <loos.br@gmail.com>
To:        "freebsd-embedded@freebsd.org" <freebsd-embedded@freebsd.org>
Cc:        Nathan Whitehorn <nwhitehorn@freebsd.org>
Subject:   Fix gpio specifiers decoding (respect #gpio-cells)
Message-ID:  <CAJ8CS7qP2FvcL45Mff4iSm9NrjSGsQWqykjwud2Cx9ENz87wbA@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
--f46d0438933faa55ca04f7b65f6b
Content-Type: text/plain; charset=UTF-8

I've been working to reduce the changes we need to decode a linux DTS
file (from the GPIO point of view).

The attached patch now respects the GPIO controller #gpio-cells (which
previously was only able to decode gpio specifiers if #gpio-cells =
3). This now make possible read linux like gpio specifiers
(#gpio-cells = 2) without any change to code.

Following linux, it also adds a new ofw_bus method that allows the
GPIO controller to implement its own mapping to gpio specifier,
allowing the specifier to be GPIO controller specific (rk30xx_gpio.c
comes to my mind...).

This patch also passes the gpio specifier flag as an ivar variable
which is visible to child that can now act upon.

Thoughts ?

Luiz

--f46d0438933faa55ca04f7b65f6b
Content-Type: text/plain; charset=US-ASCII; name="gpio-cells.diff"
Content-Disposition: attachment; filename="gpio-cells.diff"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_hucp8oo10

SW5kZXg6IHN5cy9kZXYvZ3Bpby9ncGlvYnVzdmFyLmgKPT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gc3lzL2Rldi9n
cGlvL2dwaW9idXN2YXIuaAkocmV2aXNpb24gMjY0NTUwKQorKysgc3lzL2Rldi9ncGlvL2dwaW9i
dXN2YXIuaAkod29ya2luZyBjb3B5KQpAQCAtNjAsMTAgKzYwLDEwIEBACiAJaW50CQkqc2NfcGlu
c19tYXBwZWQ7IC8qIG1hcmsgbWFwcGVkIHBpbnMgKi8KIH07CiAKLQogc3RydWN0IGdwaW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XYgb24gdGhlIGJ1cy4gVXNlZCBmb3IgYnVzCkBAIC0xNzAsNCArMTg5LDEzIEBA
CiAJcGNlbGxfdCAqaW50ZXJydXB0OwogfSBERUZBVUxUIG9md19idXNfZGVmYXVsdF9tYXBfaW50
cjsKIAotCisjIE1hcCB0aGUgR1BJTyBjb250cm9sbGVyIHNwZWNpZmljIGdwaW8tc3BlY2lmaWVy
IHRvIEdQSU8gcGluIGFuZCBmbGFncy4KK01FVEhPRCBpbnQgbWFwX2dwaW9zIHsKKwlkZXZpY2Vf
dCBidXM7CisJcGhhbmRsZV90IGRldjsKKwlwaGFuZGxlX3QgZ3BhcmVudDsKKwlpbnQgZ2NlbGxz
OworCXBjZWxsX3QgKmdwaW9zOworCXVpbnQzMl90ICpwaW47CisJdWludDMyX3QgKmZsYWdzOwor
fSBERUZBVUxUIG9md19idXNfZGVmYXVsdF9tYXBfZ3Bpb3M7Cg==
--f46d0438933faa55ca04f7b65f6b--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ8CS7qP2FvcL45Mff4iSm9NrjSGsQWqykjwud2Cx9ENz87wbA>