···991010/**1111 * struct max9768_pdata - optional platform specific MAX9768 configuration1212- * @shdn_gpio: GPIO to SHDN pin. If not valid, pin must be hardwired HIGH1313- * @mute_gpio: GPIO to MUTE pin. If not valid, control for mute won't be added1412 * @flags: configuration flags, e.g. set classic PWM mode (check datasheet1513 * regarding "filterless modulation" which is default).1614 */1715struct max9768_pdata {1818- int shdn_gpio;1919- int mute_gpio;2016 unsigned flags;2117#define MAX9768_FLAG_CLASSIC_PWM (1 << 0)2218};
+21-20
sound/soc/codecs/max9768.c
···99#include <linux/module.h>1010#include <linux/i2c.h>1111#include <linux/slab.h>1212-#include <linux/gpio.h>1212+#include <linux/gpio/consumer.h>1313#include <linux/regmap.h>14141515#include <sound/core.h>···27272828struct max9768 {2929 struct regmap *regmap;3030- int mute_gpio;3131- int shdn_gpio;3030+ struct gpio_desc *mute;3131+ struct gpio_desc *shdn;3232 u32 flags;3333};3434···4242{4343 struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);4444 struct max9768 *max9768 = snd_soc_component_get_drvdata(c);4545- int val = gpio_get_value_cansleep(max9768->mute_gpio);4545+ int val = gpiod_get_value_cansleep(max9768->mute);46464747 ucontrol->value.integer.value[0] = !val;4848···5555 struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);5656 struct max9768 *max9768 = snd_soc_component_get_drvdata(c);57575858- gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]);5858+ gpiod_set_value_cansleep(max9768->mute, !ucontrol->value.integer.value[0]);59596060 return 0;6161}···138138 return ret;139139 }140140141141- if (gpio_is_valid(max9768->mute_gpio)) {141141+ if (max9768->mute) {142142 ret = snd_soc_add_component_controls(component, max9768_mute,143143 ARRAY_SIZE(max9768_mute));144144 if (ret)···171171{172172 struct max9768 *max9768;173173 struct max9768_pdata *pdata = client->dev.platform_data;174174- int err;175174176175 max9768 = devm_kzalloc(&client->dev, sizeof(*max9768), GFP_KERNEL);177176 if (!max9768)178177 return -ENOMEM;179178180180- if (pdata) {181181- /* Mute on powerup to avoid clicks */182182- err = devm_gpio_request_one(&client->dev, pdata->mute_gpio,183183- GPIOF_INIT_HIGH, "MAX9768 Mute");184184- max9768->mute_gpio = err ?: pdata->mute_gpio;179179+ /* Mute on powerup to avoid clicks */180180+ max9768->mute = devm_gpiod_get_optional(&client->dev,181181+ "mute",182182+ GPIOD_OUT_HIGH);183183+ if (IS_ERR(max9768->mute))184184+ return PTR_ERR(max9768->mute);185185+ gpiod_set_consumer_name(max9768->mute, "MAX9768 Mute");185186186186- /* Activate chip by releasing shutdown, enables I2C */187187- err = devm_gpio_request_one(&client->dev, pdata->shdn_gpio,188188- GPIOF_INIT_HIGH, "MAX9768 Shutdown");189189- max9768->shdn_gpio = err ?: pdata->shdn_gpio;187187+ /* Activate chip by releasing shutdown, enables I2C */188188+ max9768->shdn = devm_gpiod_get_optional(&client->dev,189189+ "shutdown",190190+ GPIOD_OUT_HIGH);191191+ if (IS_ERR(max9768->shdn))192192+ return PTR_ERR(max9768->shdn);193193+ gpiod_set_consumer_name(max9768->shdn, "MAX9768 Shutdown");190194195195+ if (pdata)191196 max9768->flags = pdata->flags;192192- } else {193193- max9768->shdn_gpio = -EINVAL;194194- max9768->mute_gpio = -EINVAL;195195- }196197197198 i2c_set_clientdata(client, max9768);198199
···3344#include <linux/acpi.h>55#include <linux/delay.h>66-#include <linux/gpio.h>76#include <linux/i2c.h>87#include <linux/module.h>98#include <linux/mod_devicetable.h>109#include <linux/of.h>1111-#include <linux/of_gpio.h>1210#include <linux/pm.h>1311#include <linux/regmap.h>1412#include <linux/slab.h>···557559558560 /* voltage/current slot & gpio configuration */559561 max98373_slot_config(&i2c->dev, max98373);560560-561561- /* Power on device */562562- if (gpio_is_valid(max98373->reset_gpio)) {563563- ret = devm_gpio_request(&i2c->dev, max98373->reset_gpio,564564- "MAX98373_RESET");565565- if (ret) {566566- dev_err(&i2c->dev, "%s: Failed to request gpio %d\n",567567- __func__, max98373->reset_gpio);568568- return -EINVAL;569569- }570570- gpio_direction_output(max98373->reset_gpio, 0);571571- msleep(50);572572- gpio_direction_output(max98373->reset_gpio, 1);573573- msleep(20);574574- }575562576563 /* Check Revision ID */577564 ret = regmap_read(max98373->regmap,
+19-16
sound/soc/codecs/max98373.c
···1212#include <sound/pcm.h>1313#include <sound/pcm_params.h>1414#include <sound/soc.h>1515-#include <linux/gpio.h>1515+#include <linux/gpio/consumer.h>1616#include <linux/of.h>1717-#include <linux/of_gpio.h>1817#include <sound/tlv.h>1918#include "max98373.h"2019···477478 max98373->i_slot = value & 0xF;478479 else479480 max98373->i_slot = 1;480480- if (dev->of_node) {481481- max98373->reset_gpio = of_get_named_gpio(dev->of_node,482482- "maxim,reset-gpio", 0);483483- if (!gpio_is_valid(max98373->reset_gpio)) {484484- dev_err(dev, "Looking up %s property in node %s failed %d\n",485485- "maxim,reset-gpio", dev->of_node->full_name,486486- max98373->reset_gpio);487487- } else {488488- dev_dbg(dev, "maxim,reset-gpio=%d",489489- max98373->reset_gpio);490490- }491491- } else {492492- /* this makes reset_gpio as invalid */493493- max98373->reset_gpio = -1;481481+482482+ /* This will assert RESET */483483+ max98373->reset = devm_gpiod_get_optional(dev,484484+ "maxim,reset",485485+ GPIOD_OUT_HIGH);486486+ if (IS_ERR(max98373->reset)) {487487+ dev_err(dev, "error %ld looking up RESET GPIO line\n",488488+ PTR_ERR(max98373->reset));489489+ return;490490+ }491491+492492+ /* Cycle reset */493493+ if (max98373->reset) {494494+ gpiod_set_consumer_name(max98373->reset ,"MAX98373_RESET");495495+ gpiod_direction_output(max98373->reset, 1);496496+ msleep(50);497497+ gpiod_direction_output(max98373->reset, 0);498498+ msleep(20);494499 }495500496501 if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value))
+1-1
sound/soc/codecs/max98373.h
···213213214214struct max98373_priv {215215 struct regmap *regmap;216216- int reset_gpio;216216+ struct gpio_desc *reset;217217 unsigned int v_slot;218218 unsigned int i_slot;219219 unsigned int spkfb_slot;