Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Alban Bedel and committed by
Bartosz Golaszewski
84cb463d 4071437c

+12 -2
+12 -2
drivers/gpio/gpio-kempld.c
··· 25 25 struct kempld_gpio_data { 26 26 struct gpio_chip chip; 27 27 struct kempld_device_data *pld; 28 + u8 out_lvl_reg; 28 29 }; 29 30 30 31 /* ··· 72 71 struct kempld_device_data *pld = gpio->pld; 73 72 74 73 kempld_get_mutex(pld); 75 - kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL, offset, value); 74 + kempld_gpio_bitop(pld, gpio->out_lvl_reg, offset, value); 76 75 kempld_release_mutex(pld); 77 76 78 77 return 0; ··· 97 96 struct kempld_device_data *pld = gpio->pld; 98 97 99 98 kempld_get_mutex(pld); 100 - kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL, offset, value); 99 + kempld_gpio_bitop(pld, gpio->out_lvl_reg, offset, value); 101 100 kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR, offset, 1); 102 101 kempld_release_mutex(pld); 103 102 ··· 153 152 gpio = devm_kzalloc(dev, sizeof(*gpio), GFP_KERNEL); 154 153 if (!gpio) 155 154 return -ENOMEM; 155 + 156 + /* Starting with version 2.8 there is a dedicated register for the 157 + * output state, earlier versions share the register used to read 158 + * the line level. 159 + */ 160 + if (pld->info.spec_major > 2 || pld->info.spec_minor >= 8) 161 + gpio->out_lvl_reg = KEMPLD_GPIO_OUT_LVL; 162 + else 163 + gpio->out_lvl_reg = KEMPLD_GPIO_LVL; 156 164 157 165 gpio->pld = pld; 158 166