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

tpm/st33zp24: Add GPIO ACPI mapping table

In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index() to correctly behave when there no mapping is
provided by firmware.

Here we add explicit mapping between _CRS GpioIo() resources and
their names used in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

authored by

Andy Shevchenko and committed by
Jarkko Sakkinen
2d2e376f 31574d32

+40 -6
+20 -3
drivers/char/tpm/st33zp24/i2c.c
··· 111 111 .recv = st33zp24_i2c_recv, 112 112 }; 113 113 114 + static const struct acpi_gpio_params lpcpd_gpios = { 1, 0, false }; 115 + 116 + static const struct acpi_gpio_mapping acpi_st33zp24_gpios[] = { 117 + { "lpcpd-gpios", &lpcpd_gpios, 1 }, 118 + {}, 119 + }; 120 + 114 121 static int st33zp24_i2c_acpi_request_resources(struct i2c_client *client) 115 122 { 116 123 struct tpm_chip *chip = i2c_get_clientdata(client); ··· 125 118 struct st33zp24_i2c_phy *phy = tpm_dev->phy_id; 126 119 struct gpio_desc *gpiod_lpcpd; 127 120 struct device *dev = &client->dev; 121 + int ret; 122 + 123 + ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_st33zp24_gpios); 124 + if (ret) 125 + return ret; 128 126 129 127 /* Get LPCPD GPIO from ACPI */ 130 - gpiod_lpcpd = devm_gpiod_get_index(dev, "TPM IO LPCPD", 1, 131 - GPIOD_OUT_HIGH); 128 + gpiod_lpcpd = devm_gpiod_get(dev, "lpcpd", GPIOD_OUT_HIGH); 132 129 if (IS_ERR(gpiod_lpcpd)) { 133 130 dev_err(&client->dev, 134 131 "Failed to retrieve lpcpd-gpios from acpi.\n"); ··· 279 268 static int st33zp24_i2c_remove(struct i2c_client *client) 280 269 { 281 270 struct tpm_chip *chip = i2c_get_clientdata(client); 271 + int ret; 282 272 283 - return st33zp24_remove(chip); 273 + ret = st33zp24_remove(chip); 274 + if (ret) 275 + return ret; 276 + 277 + acpi_dev_remove_driver_gpios(ACPI_COMPANION(&client->dev)); 278 + return 0; 284 279 } 285 280 286 281 static const struct i2c_device_id st33zp24_i2c_id[] = {
+20 -3
drivers/char/tpm/st33zp24/spi.c
··· 230 230 .recv = st33zp24_spi_recv, 231 231 }; 232 232 233 + static const struct acpi_gpio_params lpcpd_gpios = { 1, 0, false }; 234 + 235 + static const struct acpi_gpio_mapping acpi_st33zp24_gpios[] = { 236 + { "lpcpd-gpios", &lpcpd_gpios, 1 }, 237 + {}, 238 + }; 239 + 233 240 static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev) 234 241 { 235 242 struct tpm_chip *chip = spi_get_drvdata(spi_dev); ··· 244 237 struct st33zp24_spi_phy *phy = tpm_dev->phy_id; 245 238 struct gpio_desc *gpiod_lpcpd; 246 239 struct device *dev = &spi_dev->dev; 240 + int ret; 241 + 242 + ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_st33zp24_gpios); 243 + if (ret) 244 + return ret; 247 245 248 246 /* Get LPCPD GPIO from ACPI */ 249 - gpiod_lpcpd = devm_gpiod_get_index(dev, "TPM IO LPCPD", 1, 250 - GPIOD_OUT_HIGH); 247 + gpiod_lpcpd = devm_gpiod_get(dev, "lpcpd", GPIOD_OUT_HIGH); 251 248 if (IS_ERR(gpiod_lpcpd)) { 252 249 dev_err(dev, "Failed to retrieve lpcpd-gpios from acpi.\n"); 253 250 phy->io_lpcpd = -1; ··· 396 385 static int st33zp24_spi_remove(struct spi_device *dev) 397 386 { 398 387 struct tpm_chip *chip = spi_get_drvdata(dev); 388 + int ret; 399 389 400 - return st33zp24_remove(chip); 390 + ret = st33zp24_remove(chip); 391 + if (ret) 392 + return ret; 393 + 394 + acpi_dev_remove_driver_gpios(ACPI_COMPANION(&dev->dev)); 395 + return 0; 401 396 } 402 397 403 398 static const struct spi_device_id st33zp24_spi_id[] = {