[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c6mvxcgono3s2jtotks6sfqojenj2nmvf4b5fau5uc6gmlmerb@oi34wxnqna4n>
Date: Fri, 23 Aug 2024 15:32:01 +0200
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: Ye Zhang <ye.zhang@...k-chips.com>
Cc: linus.walleij@...aro.org, brgl@...ev.pl, heiko@...ech.de,
linux-gpio@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org, linux-kernel@...r.kernel.org, mika.westerberg@...ux.intel.com,
andriy.shevchenko@...ux.intel.com, tao.huang@...k-chips.com, finley.xiao@...k-chips.com,
tim.chen@...k-chips.com, elaine.zhang@...k-chips.com, detlev.casanova@...labora.com
Subject: Re: [PATCH v2] gpio: rockchip: support new version gpio
Hi,
On Fri, Aug 23, 2024 at 11:43:11AM GMT, Ye Zhang wrote:
> The next version gpio controller on SoCs like rk3576 which support four
> OS operation and four interrupts
>
> Signed-off-by: Ye Zhang <ye.zhang@...k-chips.com>
> ---
> drivers/gpio/gpio-rockchip.c | 40 ++++++++++++++++++++++++------------
> 1 file changed, 27 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
> index 25ddf6a82c09..5289c94d5c60 100644
> --- a/drivers/gpio/gpio-rockchip.c
> +++ b/drivers/gpio/gpio-rockchip.c
> @@ -29,6 +29,7 @@
> #define GPIO_TYPE_V1 (0) /* GPIO Version ID reserved */
> #define GPIO_TYPE_V2 (0x01000C2B) /* GPIO Version ID 0x01000C2B */
> #define GPIO_TYPE_V2_1 (0x0101157C) /* GPIO Version ID 0x0101157C */
> +#define GPIO_TYPE_V2_2 (0x010219C8) /* GPIO Version ID 0x010219C8 */
The comments for anything but the V1 define are redundant.
[...]
> @@ -648,13 +655,20 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
>
> id = readl(bank->reg_base + gpio_regs_v2.version_id);
>
> - /* If not gpio v2, that is default to v1. */
> - if (id == GPIO_TYPE_V2 || id == GPIO_TYPE_V2_1) {
> + switch (id) {
> + case GPIO_TYPE_V2:
> + case GPIO_TYPE_V2_1:
> bank->gpio_regs = &gpio_regs_v2;
> bank->gpio_type = GPIO_TYPE_V2;
> - } else {
> + break;
> + case GPIO_TYPE_V2_2:
> + bank->gpio_regs = &gpio_regs_v2;
> + bank->gpio_type = GPIO_TYPE_V2_2;
> + break;
Can't this just be handled like GPIO_TYPE_V2_1 (i.e. reusing the V2
case)? Also it looks risky to use >= on gpio_type. GPIO_TYPE_V2_2
looks like a simple enum, but it contains the ID. Is it guranteed to
be increasing? In that case any ID > GPIO_TYPE_V2_2 should not
default to GPIO_TYPE_V1?
> + default:
> bank->gpio_regs = &gpio_regs_v1;
> bank->gpio_type = GPIO_TYPE_V1;
> + pr_info("Note: Use default GPIO_TYPE_V1!\n");
Can we have a list of valid V1 IDs and default to -ENODEV?
Greetings,
-- Sebastian
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists