Skip to content

Commit 4120930

Browse files
Ye ZhangBartosz Golaszewski
authored andcommitted
gpio: rockchip: change the GPIO version judgment logic
Have a list of valid IDs and default to -ENODEV. Signed-off-by: Ye Zhang <ye.zhang@rock-chips.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20241112015408.3139996-3-ye.zhang@rock-chips.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 591ae6b commit 4120930

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

drivers/gpio/gpio-rockchip.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,9 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
667667
clk_prepare_enable(bank->clk);
668668
id = readl(bank->reg_base + gpio_regs_v2.version_id);
669669

670-
/* If not gpio v2, that is default to v1. */
671-
if (id == GPIO_TYPE_V2 || id == GPIO_TYPE_V2_1) {
670+
switch (id) {
671+
case GPIO_TYPE_V2:
672+
case GPIO_TYPE_V2_1:
672673
bank->gpio_regs = &gpio_regs_v2;
673674
bank->gpio_type = GPIO_TYPE_V2;
674675
bank->db_clk = of_clk_get(bank->of_node, 1);
@@ -677,9 +678,14 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
677678
clk_disable_unprepare(bank->clk);
678679
return -EINVAL;
679680
}
680-
} else {
681+
break;
682+
case GPIO_TYPE_V1:
681683
bank->gpio_regs = &gpio_regs_v1;
682684
bank->gpio_type = GPIO_TYPE_V1;
685+
break;
686+
default:
687+
dev_err(bank->dev, "unsupported version ID: 0x%08x\n", id);
688+
return -ENODEV;
683689
}
684690

685691
return 0;

0 commit comments

Comments
 (0)