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.

ASoC: Convert some Maxim codecs to use GPIO

Merge series from Linus Walleij <linus.walleij@linaro.org>:

The Maxim devices are pretty straight-forward to convert
over to use GPIO descriptors, so let's do it.

+42 -66
-4
include/sound/max9768.h
··· 9 9 10 10 /** 11 11 * struct max9768_pdata - optional platform specific MAX9768 configuration 12 - * @shdn_gpio: GPIO to SHDN pin. If not valid, pin must be hardwired HIGH 13 - * @mute_gpio: GPIO to MUTE pin. If not valid, control for mute won't be added 14 12 * @flags: configuration flags, e.g. set classic PWM mode (check datasheet 15 13 * regarding "filterless modulation" which is default). 16 14 */ 17 15 struct max9768_pdata { 18 - int shdn_gpio; 19 - int mute_gpio; 20 16 unsigned flags; 21 17 #define MAX9768_FLAG_CLASSIC_PWM (1 << 0) 22 18 };
+21 -20
sound/soc/codecs/max9768.c
··· 9 9 #include <linux/module.h> 10 10 #include <linux/i2c.h> 11 11 #include <linux/slab.h> 12 - #include <linux/gpio.h> 12 + #include <linux/gpio/consumer.h> 13 13 #include <linux/regmap.h> 14 14 15 15 #include <sound/core.h> ··· 27 27 28 28 struct max9768 { 29 29 struct regmap *regmap; 30 - int mute_gpio; 31 - int shdn_gpio; 30 + struct gpio_desc *mute; 31 + struct gpio_desc *shdn; 32 32 u32 flags; 33 33 }; 34 34 ··· 42 42 { 43 43 struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); 44 44 struct max9768 *max9768 = snd_soc_component_get_drvdata(c); 45 - int val = gpio_get_value_cansleep(max9768->mute_gpio); 45 + int val = gpiod_get_value_cansleep(max9768->mute); 46 46 47 47 ucontrol->value.integer.value[0] = !val; 48 48 ··· 55 55 struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); 56 56 struct max9768 *max9768 = snd_soc_component_get_drvdata(c); 57 57 58 - gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]); 58 + gpiod_set_value_cansleep(max9768->mute, !ucontrol->value.integer.value[0]); 59 59 60 60 return 0; 61 61 } ··· 138 138 return ret; 139 139 } 140 140 141 - if (gpio_is_valid(max9768->mute_gpio)) { 141 + if (max9768->mute) { 142 142 ret = snd_soc_add_component_controls(component, max9768_mute, 143 143 ARRAY_SIZE(max9768_mute)); 144 144 if (ret) ··· 171 171 { 172 172 struct max9768 *max9768; 173 173 struct max9768_pdata *pdata = client->dev.platform_data; 174 - int err; 175 174 176 175 max9768 = devm_kzalloc(&client->dev, sizeof(*max9768), GFP_KERNEL); 177 176 if (!max9768) 178 177 return -ENOMEM; 179 178 180 - if (pdata) { 181 - /* Mute on powerup to avoid clicks */ 182 - err = devm_gpio_request_one(&client->dev, pdata->mute_gpio, 183 - GPIOF_INIT_HIGH, "MAX9768 Mute"); 184 - max9768->mute_gpio = err ?: pdata->mute_gpio; 179 + /* Mute on powerup to avoid clicks */ 180 + max9768->mute = devm_gpiod_get_optional(&client->dev, 181 + "mute", 182 + GPIOD_OUT_HIGH); 183 + if (IS_ERR(max9768->mute)) 184 + return PTR_ERR(max9768->mute); 185 + gpiod_set_consumer_name(max9768->mute, "MAX9768 Mute"); 185 186 186 - /* Activate chip by releasing shutdown, enables I2C */ 187 - err = devm_gpio_request_one(&client->dev, pdata->shdn_gpio, 188 - GPIOF_INIT_HIGH, "MAX9768 Shutdown"); 189 - max9768->shdn_gpio = err ?: pdata->shdn_gpio; 187 + /* Activate chip by releasing shutdown, enables I2C */ 188 + max9768->shdn = devm_gpiod_get_optional(&client->dev, 189 + "shutdown", 190 + GPIOD_OUT_HIGH); 191 + if (IS_ERR(max9768->shdn)) 192 + return PTR_ERR(max9768->shdn); 193 + gpiod_set_consumer_name(max9768->shdn, "MAX9768 Shutdown"); 190 194 195 + if (pdata) 191 196 max9768->flags = pdata->flags; 192 - } else { 193 - max9768->shdn_gpio = -EINVAL; 194 - max9768->mute_gpio = -EINVAL; 195 - } 196 197 197 198 i2c_set_clientdata(client, max9768); 198 199
-1
sound/soc/codecs/max98357a.c
··· 8 8 #include <linux/delay.h> 9 9 #include <linux/device.h> 10 10 #include <linux/err.h> 11 - #include <linux/gpio.h> 12 11 #include <linux/gpio/consumer.h> 13 12 #include <linux/kernel.h> 14 13 #include <linux/mod_devicetable.h>
-17
sound/soc/codecs/max98373-i2c.c
··· 3 3 4 4 #include <linux/acpi.h> 5 5 #include <linux/delay.h> 6 - #include <linux/gpio.h> 7 6 #include <linux/i2c.h> 8 7 #include <linux/module.h> 9 8 #include <linux/mod_devicetable.h> 10 9 #include <linux/of.h> 11 - #include <linux/of_gpio.h> 12 10 #include <linux/pm.h> 13 11 #include <linux/regmap.h> 14 12 #include <linux/slab.h> ··· 557 559 558 560 /* voltage/current slot & gpio configuration */ 559 561 max98373_slot_config(&i2c->dev, max98373); 560 - 561 - /* Power on device */ 562 - if (gpio_is_valid(max98373->reset_gpio)) { 563 - ret = devm_gpio_request(&i2c->dev, max98373->reset_gpio, 564 - "MAX98373_RESET"); 565 - if (ret) { 566 - dev_err(&i2c->dev, "%s: Failed to request gpio %d\n", 567 - __func__, max98373->reset_gpio); 568 - return -EINVAL; 569 - } 570 - gpio_direction_output(max98373->reset_gpio, 0); 571 - msleep(50); 572 - gpio_direction_output(max98373->reset_gpio, 1); 573 - msleep(20); 574 - } 575 562 576 563 /* Check Revision ID */ 577 564 ret = regmap_read(max98373->regmap,
+19 -16
sound/soc/codecs/max98373.c
··· 12 12 #include <sound/pcm.h> 13 13 #include <sound/pcm_params.h> 14 14 #include <sound/soc.h> 15 - #include <linux/gpio.h> 15 + #include <linux/gpio/consumer.h> 16 16 #include <linux/of.h> 17 - #include <linux/of_gpio.h> 18 17 #include <sound/tlv.h> 19 18 #include "max98373.h" 20 19 ··· 477 478 max98373->i_slot = value & 0xF; 478 479 else 479 480 max98373->i_slot = 1; 480 - if (dev->of_node) { 481 - max98373->reset_gpio = of_get_named_gpio(dev->of_node, 482 - "maxim,reset-gpio", 0); 483 - if (!gpio_is_valid(max98373->reset_gpio)) { 484 - dev_err(dev, "Looking up %s property in node %s failed %d\n", 485 - "maxim,reset-gpio", dev->of_node->full_name, 486 - max98373->reset_gpio); 487 - } else { 488 - dev_dbg(dev, "maxim,reset-gpio=%d", 489 - max98373->reset_gpio); 490 - } 491 - } else { 492 - /* this makes reset_gpio as invalid */ 493 - max98373->reset_gpio = -1; 481 + 482 + /* This will assert RESET */ 483 + max98373->reset = devm_gpiod_get_optional(dev, 484 + "maxim,reset", 485 + GPIOD_OUT_HIGH); 486 + if (IS_ERR(max98373->reset)) { 487 + dev_err(dev, "error %ld looking up RESET GPIO line\n", 488 + PTR_ERR(max98373->reset)); 489 + return; 490 + } 491 + 492 + /* Cycle reset */ 493 + if (max98373->reset) { 494 + gpiod_set_consumer_name(max98373->reset ,"MAX98373_RESET"); 495 + gpiod_direction_output(max98373->reset, 1); 496 + msleep(50); 497 + gpiod_direction_output(max98373->reset, 0); 498 + msleep(20); 494 499 } 495 500 496 501 if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value))
+1 -1
sound/soc/codecs/max98373.h
··· 213 213 214 214 struct max98373_priv { 215 215 struct regmap *regmap; 216 - int reset_gpio; 216 + struct gpio_desc *reset; 217 217 unsigned int v_slot; 218 218 unsigned int i_slot; 219 219 unsigned int spkfb_slot;
+1 -2
sound/soc/codecs/max98388.c
··· 3 3 4 4 #include <linux/acpi.h> 5 5 #include <linux/delay.h> 6 - #include <linux/gpio.h> 6 + #include <linux/gpio/consumer.h> 7 7 #include <linux/i2c.h> 8 8 #include <linux/module.h> 9 9 #include <linux/mod_devicetable.h> 10 10 #include <linux/of.h> 11 - #include <linux/of_gpio.h> 12 11 #include <linux/pm_runtime.h> 13 12 #include <linux/regmap.h> 14 13 #include <linux/slab.h>
-1
sound/soc/codecs/max98396.c
··· 7 7 #include <sound/pcm_params.h> 8 8 #include <linux/regulator/consumer.h> 9 9 #include <sound/soc.h> 10 - #include <linux/gpio.h> 11 10 #include <sound/tlv.h> 12 11 #include "max98396.h" 13 12
-2
sound/soc/codecs/max98520.c
··· 11 11 #include <sound/pcm.h> 12 12 #include <sound/pcm_params.h> 13 13 #include <sound/soc.h> 14 - #include <linux/gpio.h> 15 14 #include <linux/gpio/consumer.h> 16 15 #include <linux/of.h> 17 - #include <linux/of_gpio.h> 18 16 #include <sound/tlv.h> 19 17 #include "max98520.h" 20 18
-2
sound/soc/codecs/max98927.c
··· 15 15 #include <sound/pcm.h> 16 16 #include <sound/pcm_params.h> 17 17 #include <sound/soc.h> 18 - #include <linux/gpio.h> 19 18 #include <linux/gpio/consumer.h> 20 - #include <linux/of_gpio.h> 21 19 #include <sound/tlv.h> 22 20 #include "max98927.h" 23 21