From: Johan Jonker <jbx6244@gmail.com>
To: Jonas Karlman <jonas@kwiboo.se>, Simon Glass <sjg@chromium.org>
Cc: kever.yang@rock-chips.com, philipp.tomsich@vrull.eu,
u-boot@lists.denx.de
Subject: Re: [PATCH v1 1/6] rockchip: gpio: rk_gpio: use ROCKCHIP_GPIOS_PER_BANK as divider
Date: Sun, 19 Mar 2023 13:55:08 +0100 [thread overview]
Message-ID: <4745a32d-2185-bf91-7ae4-2fe31cbbd0e7@gmail.com> (raw)
In-Reply-To: <68e235e7-f5ed-3688-9b9a-9d731bdfe9e9@kwiboo.se>
On 3/19/23 13:20, Jonas Karlman wrote:
> Hi Johan,
> On 2023-03-19 12:34, Johan Jonker wrote:
>>
>>
>> On 3/18/23 21:20, Simon Glass wrote:
>>> Hi Johan,
>>>
>>> On Thu, 16 Mar 2023 at 10:46, Johan Jonker <jbx6244@gmail.com> wrote:
>>>>
>>>> The current divider to calculate the bank ID can change.
>>>> Use a constant ROCKCHIP_GPIOS_PER_BANK as fixed divider.
>>>
>>
>>> What is the motivation for this patch?
>>
>> The gpio-ranges property format:
>>
>> gpio-ranges = <[pin controller phandle], [GPIO controller offset],
>> [pin controller offset], [number of pins]>;
>>
>> 1: Given the Rockchip TRM not all gpio-banks have 32 pins per bank.
>> 2: The "gpio-ranges" syntax allows multiple items with variable number of pins.
>
> Is there a reason why gpio-ranges is used to determine bank id?
>
> In the series at [1], add support for rk35xx gpio banks, sent yesterday
> I changed this to rely on the dev alias id, same as in the linux driver.
>
> Any reason why using the device alias id won't work for the same purpose
> in u-boot?
Aliases are board/user orientated based on availability.
See discussion elsewhere(by Arnd Bergmann and others, see lore link unknown for now)
All aliases should be moved out of the dtsi files, so there's no guaranty that they are there anymore.
Aliases should follow the Rockchip TRM naming to prevent confusion.(by Heiko)
Special rules apply to mmc aliases: based on availability, reg order and without number gap.
U-Boot/bootloader specific:
Aliases get lost with reduced DT's and are problematic with overlays,etc(ie. it needs special handling on top of that).
Aliases are not in the dtb platdata structure made by dtoc for TPL/SPL.(current drivers don't work yet, but in the future they may)
Best is to have a property inside the node for parsing and reduced nodes.
gpio-ranges is the only option currently available.
(not saying that is perfect, but at least don't invent new properties that needs to be continuously supported as legacy)
>
> [1] https://patchwork.ozlabs.org/project/uboot/patch/20230318235651.826148-3-jonas@kwiboo.se/
>
> Regards,
> Jonas
>
>>
>> ===
>>
>> Theoretical example:
>>
>> gpio-ranges = <&pinctrl 0 32 32>; // 32/32 => bank 1
>>
>> vs.
>>
>> gpio-ranges = <&pinctrl 16 48 16>, // 48/16 => bank 3 vs. 48/32 => bank 1
>> <&pinctrl 0 32 16>; // 32/16 => bank 2 vs. 32/32 => bank 1
>>
>> Both descriptions are valid.
>> The number of pins in the second example is reduced to 16 per item.
>> Using that as divider will give a wrong bank number.
>> Use a constant instead.
>> For the Rockchip situation simple parsing the first item is enough the know it's bank number for now.
>> To do it correct one could parse a list of gpio-range items, but that makes it more complicated.
>>
>> From gpio.txt:
>> Each offset runs from 0 to N. It is perfectly fine to pile any number of
>> ranges with just one pin-to-GPIO line mapping if the ranges are concocted, but
>> in practice these ranges are often lumped in discrete sets.
>>
>>>
>>>>
>>>> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
>>>> ---
>>>> drivers/gpio/rk_gpio.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>
>>>>
>>>> diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
>>>> index f7ad4d68..0a2acf18 100644
>>>> --- a/drivers/gpio/rk_gpio.c
>>>> +++ b/drivers/gpio/rk_gpio.c
>>>> @@ -160,7 +160,7 @@ static int rockchip_gpio_probe(struct udevice *dev)
>>>> 0, &args);
>>>> if (!ret || ret != -ENOENT) {
>>>> uc_priv->gpio_count = args.args[2];
>>>> - priv->bank = args.args[1] / args.args[2];
>>>> + priv->bank = args.args[1] / ROCKCHIP_GPIOS_PER_BANK;
>>>> } else {
>>>> uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK;
>>>> end = strrchr(dev->name, '@');
>>>> --
>>>> 2.20.1
>>>>
>>>
>>> Regards,
>>> SImon
>
next prev parent reply other threads:[~2023-03-19 12:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 16:46 [PATCH v1 1/6] rockchip: gpio: rk_gpio: use ROCKCHIP_GPIOS_PER_BANK as divider Johan Jonker
2023-03-16 16:47 ` [PATCH v1 2/6] arm: dts: rockchip: rk3066a-u-boot: add gpio-ranges Johan Jonker
2023-03-18 20:20 ` Simon Glass
2023-03-19 15:46 ` Jonas Karlman
2023-03-16 16:47 ` [PATCH v1 3/6] arm: dts: rockchip: rk3188-u-boot: " Johan Jonker
2023-03-18 20:20 ` Simon Glass
2023-03-16 16:47 ` [PATCH v1 4/6] arm: dts: rockchip: sync rk3066/rk3188 DT files from linux-next v6.2-rc4 Johan Jonker
2023-03-18 20:20 ` Simon Glass
2023-03-16 16:48 ` [PATCH v1 5/6] rockchip: configs: mk808: change CONFIG_TPL_TEXT_BASE Johan Jonker
2023-03-18 20:20 ` Simon Glass
2023-03-16 16:48 ` [PATCH v1 6/6] rockchip: configs: mk808: enable usb support Johan Jonker
2023-03-18 20:20 ` Simon Glass
2023-03-18 20:20 ` [PATCH v1 1/6] rockchip: gpio: rk_gpio: use ROCKCHIP_GPIOS_PER_BANK as divider Simon Glass
2023-03-19 11:34 ` Johan Jonker
2023-03-19 12:20 ` Jonas Karlman
2023-03-19 12:55 ` Johan Jonker [this message]
2023-03-19 13:51 ` Jonas Karlman
2023-03-19 14:56 ` Jonas Karlman
2023-03-20 1:32 ` Kever Yang
2023-03-20 8:54 ` Johan Jonker
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=4745a32d-2185-bf91-7ae4-2fe31cbbd0e7@gmail.com \
--to=jbx6244@gmail.com \
--cc=jonas@kwiboo.se \
--cc=kever.yang@rock-chips.com \
--cc=philipp.tomsich@vrull.eu \
--cc=sjg@chromium.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox