All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Six <mario.six@gdsys.cc>
To: u-boot@lists.denx.de
Subject: [U-Boot] Regression: gpio: pca953x_gpio: Make live-tree compatible
Date: Thu, 1 Mar 2018 08:26:58 +0100	[thread overview]
Message-ID: <CAN1kZor1gY-Fo8AD+wLXPT8A-OQBeNoZ0=rPD2_qJ-e-hRxmxQ@mail.gmail.com> (raw)
In-Reply-To: <f360103e-36a1-f8e8-9948-af02187f362a@parkeon.com>

(Adding Simon, because of DM)

Hi Martin,

On Wed, Feb 28, 2018 at 7:27 PM, Martin Fuzzey <mfuzzey@parkeon.com> wrote:
> Hi,
>
> since this commit:
>
> commit f62ca2cd2ab8171f603960da9203ceb6ee8a1efd
> Author: Mario Six <mario.six@gdsys.cc>
> Date:   Mon Jan 15 11:07:45 2018 +0100
>
>     gpio: pca953x_gpio: Make live-tree compatible
>
>
> I am getting the error message "__of_translate_address: Bad cell count for
> pcal6524 at 1"
>
> I don't think the patch
>
> -       addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
> +       addr = dev_read_addr(dev);
>
> is correct since it replaces a simple lookup of the value "reg" property
> with an attempted translation to a CPU address (which fails for I2C)
>

I see the issue on one of our boards as well, but the weird thing is that the
translation should not happen: the I2C bus has no ranges property, which
should, according to the DeviceTree specification, cause the translation
routine to not attempt a translation (because a missing ranges property implies
that the device's address space is not translatable). I'll take a look at the
code; maybe it's a Linux-specific exception that was imported with the code
that I was not aware of.

The dev_read_addr() is the go-to function for drivers to get device addresses
(and have all issues like translation and the like taken care of
automatically), so it would be nice to keep it in my opinion. Hence, fixing
the underlying issue is probably preferable.

> This does not cause the driver probe to fail since dev_read_addr() returns
> FDT_ADDR_T_NONE (== -1)  and is followed by
>
>     if (addr == 0)
>         return -ENODEV;
>
>     info->addr = addr;
>
> Although addr is stored in the driver data the only thing it is used for is
> to build the bank name
>
>     snprintf(name, sizeof(name), "gpio@%x_", info->addr);
>
> I'm not even sure that using the value of the "reg" property as before is
> really a good idea - what happens if we have multiple chips with same
> address on seperate busses?
>

We have that exact case on some of our boards. It works, but it's pretty
annoying if you want to use the gpio command: When setting values of GPIOs, it
only ever affects the first device the command comes across.

I have a potential solution for that, see below.

> Maybe it would be better to use the DT node name? But would that break
> existing configurations by renaming the device?

I have a patch I use on our boards that looks for a "label" string property in
the DT, which is then used for the bank name if it's there, and falls back to
the "gpio@%x_" in the case it's not there. If you think it's useful, I could
send the patch to the mailing list?

>
>
> Regards,
>
> Martin
>

Best regards,

Mario

  reply	other threads:[~2018-03-01  7:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 18:27 [U-Boot] Regression: gpio: pca953x_gpio: Make live-tree compatible Martin Fuzzey
2018-03-01  7:26 ` Mario Six [this message]
2018-03-01  8:01   ` Mario Six
2018-03-01 10:07     ` Martin Fuzzey
2018-03-01 13:42       ` Mario Six
2018-03-01 16:41         ` Martin Fuzzey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN1kZor1gY-Fo8AD+wLXPT8A-OQBeNoZ0=rPD2_qJ-e-hRxmxQ@mail.gmail.com' \
    --to=mario.six@gdsys.cc \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.