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

ASoC: wm0010: Convert to GPIO descriptors

This converts the WM0010 codec to use GPIO descriptors.
It's a pretty straight-forward conversion also switching over
the single in-tree user in the S3C Cragganmore module
for S3C 6410.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20231208-descriptors-sound-wlf-v1-1-c4dab6f521ec@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Linus Walleij and committed by
Mark Brown
b53d4777 2cc14f52

+23 -43
+13 -3
arch/arm/mach-s3c/mach-crag6410-module.c
··· 32 32 33 33 #include "crag6410.h" 34 34 35 + static struct gpiod_lookup_table wm0010_gpiod_table = { 36 + .dev_id = "spi0.0", /* SPI device name */ 37 + .table = { 38 + /* Active high for Glenfarclas Rev 2 */ 39 + GPIO_LOOKUP("GPION", 6, 40 + "reset", GPIO_ACTIVE_HIGH), 41 + { }, 42 + }, 43 + }; 44 + 35 45 static struct wm0010_pdata wm0010_pdata = { 36 - .gpio_reset = S3C64XX_GPN(6), 37 - .reset_active_high = 1, /* Active high for Glenfarclas Rev 2 */ 46 + /* Intentionally left blank */ 38 47 }; 39 48 40 49 static struct spi_board_info wm1253_devs[] = { ··· 346 337 { .id = 0x21, .rev = 0xff, .name = "1275-EV1 Mortlach" }, 347 338 { .id = 0x25, .rev = 0xff, .name = "1274-EV1 Glencadam" }, 348 339 { .id = 0x31, .rev = 0xff, .name = "1253-EV1 Tomatin", 349 - .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) }, 340 + .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs), 341 + .gpiod_table = &wm0010_gpiod_table }, 350 342 { .id = 0x32, .rev = 0xff, .name = "XXXX-EV1 Caol Illa" }, 351 343 { .id = 0x33, .rev = 0xff, .name = "XXXX-EV1 Oban" }, 352 344 { .id = 0x34, .rev = 0xff, .name = "WM0010-6320-CS42 Balblair",
-6
include/sound/wm0010.h
··· 11 11 #define WM0010_PDATA_H 12 12 13 13 struct wm0010_pdata { 14 - int gpio_reset; 15 - 16 - /* Set if there is an inverter between the GPIO controlling 17 - * the reset signal and the device. 18 - */ 19 - int reset_active_high; 20 14 int irq_flags; 21 15 }; 22 16
+10 -34
sound/soc/codecs/wm0010.c
··· 18 18 #include <linux/firmware.h> 19 19 #include <linux/delay.h> 20 20 #include <linux/fs.h> 21 - #include <linux/gpio.h> 21 + #include <linux/gpio/consumer.h> 22 22 #include <linux/regulator/consumer.h> 23 23 #include <linux/mutex.h> 24 24 #include <linux/workqueue.h> ··· 94 94 95 95 struct wm0010_pdata pdata; 96 96 97 - int gpio_reset; 98 - int gpio_reset_value; 97 + struct gpio_desc *reset; 99 98 100 99 struct regulator_bulk_data core_supplies[2]; 101 100 struct regulator *dbvdd; ··· 173 174 case WM0010_STAGE2: 174 175 case WM0010_FIRMWARE: 175 176 /* Remember to put chip back into reset */ 176 - gpio_set_value_cansleep(wm0010->gpio_reset, 177 - wm0010->gpio_reset_value); 177 + gpiod_set_value_cansleep(wm0010->reset, 1); 178 178 /* Disable the regulators */ 179 179 regulator_disable(wm0010->dbvdd); 180 180 regulator_bulk_disable(ARRAY_SIZE(wm0010->core_supplies), ··· 608 610 } 609 611 610 612 /* Release reset */ 611 - gpio_set_value_cansleep(wm0010->gpio_reset, !wm0010->gpio_reset_value); 613 + gpiod_set_value_cansleep(wm0010->reset, 0); 612 614 spin_lock_irqsave(&wm0010->irq_lock, flags); 613 615 wm0010->state = WM0010_OUT_OF_RESET; 614 616 spin_unlock_irqrestore(&wm0010->irq_lock, flags); ··· 861 863 862 864 static int wm0010_spi_probe(struct spi_device *spi) 863 865 { 864 - unsigned long gpio_flags; 865 866 int ret; 866 867 int trigger; 867 868 int irq; ··· 900 903 return ret; 901 904 } 902 905 903 - if (wm0010->pdata.gpio_reset) { 904 - wm0010->gpio_reset = wm0010->pdata.gpio_reset; 905 - 906 - if (wm0010->pdata.reset_active_high) 907 - wm0010->gpio_reset_value = 1; 908 - else 909 - wm0010->gpio_reset_value = 0; 910 - 911 - if (wm0010->gpio_reset_value) 912 - gpio_flags = GPIOF_OUT_INIT_HIGH; 913 - else 914 - gpio_flags = GPIOF_OUT_INIT_LOW; 915 - 916 - ret = devm_gpio_request_one(wm0010->dev, wm0010->gpio_reset, 917 - gpio_flags, "wm0010 reset"); 918 - if (ret < 0) { 919 - dev_err(wm0010->dev, 920 - "Failed to request GPIO for DSP reset: %d\n", 921 - ret); 922 - return ret; 923 - } 924 - } else { 925 - dev_err(wm0010->dev, "No reset GPIO configured\n"); 926 - return -EINVAL; 927 - } 906 + wm0010->reset = devm_gpiod_get(wm0010->dev, "reset", GPIOD_OUT_HIGH); 907 + if (IS_ERR(wm0010->reset)) 908 + return dev_err_probe(wm0010->dev, PTR_ERR(wm0010->reset), 909 + "could not get RESET GPIO\n"); 910 + gpiod_set_consumer_name(wm0010->reset, "wm0010 reset"); 928 911 929 912 wm0010->state = WM0010_POWER_OFF; 930 913 ··· 949 972 { 950 973 struct wm0010_priv *wm0010 = spi_get_drvdata(spi); 951 974 952 - gpio_set_value_cansleep(wm0010->gpio_reset, 953 - wm0010->gpio_reset_value); 975 + gpiod_set_value_cansleep(wm0010->reset, 1); 954 976 955 977 irq_set_irq_wake(wm0010->irq, 0); 956 978