Skip to content

Commit 84cb463

Browse files
Alban BedelBartosz Golaszewski
authored andcommitted
gpio: kempld: Add support for PLD version >= 2.8
Starting with version 2.8 there is a dedicated register to configure the output level. Read the PLD version in the probe and select the correct register to use for the set operations. Signed-off-by: Alban Bedel <alban.bedel@lht.dlh.de> Link: https://patch.msgid.link/20260311143120.2179347-3-alban.bedel@lht.dlh.de Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent 4071437 commit 84cb463

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

drivers/gpio/gpio-kempld.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
struct kempld_gpio_data {
2626
struct gpio_chip chip;
2727
struct kempld_device_data *pld;
28+
u8 out_lvl_reg;
2829
};
2930

3031
/*
@@ -71,7 +72,7 @@ static int kempld_gpio_set(struct gpio_chip *chip, unsigned int offset,
7172
struct kempld_device_data *pld = gpio->pld;
7273

7374
kempld_get_mutex(pld);
74-
kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL, offset, value);
75+
kempld_gpio_bitop(pld, gpio->out_lvl_reg, offset, value);
7576
kempld_release_mutex(pld);
7677

7778
return 0;
@@ -96,7 +97,7 @@ static int kempld_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
9697
struct kempld_device_data *pld = gpio->pld;
9798

9899
kempld_get_mutex(pld);
99-
kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL, offset, value);
100+
kempld_gpio_bitop(pld, gpio->out_lvl_reg, offset, value);
100101
kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR, offset, 1);
101102
kempld_release_mutex(pld);
102103

@@ -153,6 +154,15 @@ static int kempld_gpio_probe(struct platform_device *pdev)
153154
if (!gpio)
154155
return -ENOMEM;
155156

157+
/* Starting with version 2.8 there is a dedicated register for the
158+
* output state, earlier versions share the register used to read
159+
* the line level.
160+
*/
161+
if (pld->info.spec_major > 2 || pld->info.spec_minor >= 8)
162+
gpio->out_lvl_reg = KEMPLD_GPIO_OUT_LVL;
163+
else
164+
gpio->out_lvl_reg = KEMPLD_GPIO_LVL;
165+
156166
gpio->pld = pld;
157167

158168
platform_set_drvdata(pdev, gpio);

0 commit comments

Comments
 (0)