mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 00:53:34 +02:00
ASoC: codec: tpa6130a2: Convert to GPIO descriptors
Merge series from "Peng Fan (OSS)" <peng.fan@oss.nxp.com>: Per Mark's comments in [1], each driver in one patchset and not merge the changes to one driver in one patch, so worked out three patches. - Sort the included headers. - Drop sound/tpa6130a2-plat.h because no user is creating the device using platform data - Covert to GPIO descriptors Checking the DTS polarity, all users are using GPIOD_ACTIVE_HIGH. so all should work as expected with this patch. I not have hardware to test, just my best effort to do this. [1] https://lore.kernel.org/all/66db9962-d773-4c7a-bf59-4698eca9eedc@sirena.org.uk/
This commit is contained in:
commit
c27c313026
|
|
@ -23896,7 +23896,6 @@ F: Documentation/devicetree/bindings/sound/ti,tlv320*.yaml
|
|||
F: Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml
|
||||
F: include/sound/tas2*.h
|
||||
F: include/sound/tlv320*.h
|
||||
F: include/sound/tpa6130a2-plat.h
|
||||
F: sound/pci/hda/tas2781_hda_i2c.c
|
||||
F: sound/soc/codecs/pcm1681.c
|
||||
F: sound/soc/codecs/pcm1789*.*
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* TPA6130A2 driver platform header
|
||||
*
|
||||
* Copyright (C) Nokia Corporation
|
||||
*
|
||||
* Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
|
||||
*/
|
||||
|
||||
#ifndef TPA6130A2_PLAT_H
|
||||
#define TPA6130A2_PLAT_H
|
||||
|
||||
struct tpa6130a2_platform_data {
|
||||
int power_gpio;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -7,19 +7,17 @@
|
|||
* Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/slab.h>
|
||||
#include <sound/tpa6130a2-plat.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/tlv.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/regmap.h>
|
||||
|
||||
#include "tpa6130a2.h"
|
||||
|
||||
|
|
@ -33,7 +31,7 @@ struct tpa6130a2_data {
|
|||
struct device *dev;
|
||||
struct regmap *regmap;
|
||||
struct regulator *supply;
|
||||
int power_gpio;
|
||||
struct gpio_desc *power_gpio;
|
||||
enum tpa_model id;
|
||||
};
|
||||
|
||||
|
|
@ -49,8 +47,7 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
|
|||
return ret;
|
||||
}
|
||||
/* Power on */
|
||||
if (data->power_gpio >= 0)
|
||||
gpio_set_value(data->power_gpio, 1);
|
||||
gpiod_set_value(data->power_gpio, 1);
|
||||
|
||||
/* Sync registers */
|
||||
regcache_cache_only(data->regmap, false);
|
||||
|
|
@ -59,8 +56,7 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
|
|||
dev_err(data->dev,
|
||||
"Failed to sync registers: %d\n", ret);
|
||||
regcache_cache_only(data->regmap, true);
|
||||
if (data->power_gpio >= 0)
|
||||
gpio_set_value(data->power_gpio, 0);
|
||||
gpiod_set_value(data->power_gpio, 0);
|
||||
ret2 = regulator_disable(data->supply);
|
||||
if (ret2 != 0)
|
||||
dev_err(data->dev,
|
||||
|
|
@ -76,8 +72,7 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
|
|||
regcache_cache_only(data->regmap, true);
|
||||
|
||||
/* Power off */
|
||||
if (data->power_gpio >= 0)
|
||||
gpio_set_value(data->power_gpio, 0);
|
||||
gpiod_set_value(data->power_gpio, 0);
|
||||
|
||||
ret = regulator_disable(data->supply);
|
||||
if (ret != 0) {
|
||||
|
|
@ -209,18 +204,10 @@ static const struct regmap_config tpa6130a2_regmap_config = {
|
|||
.cache_type = REGCACHE_RBTREE,
|
||||
};
|
||||
|
||||
static const struct i2c_device_id tpa6130a2_id[] = {
|
||||
{ "tpa6130a2", TPA6130A2 },
|
||||
{ "tpa6140a2", TPA6140A2 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, tpa6130a2_id);
|
||||
|
||||
static int tpa6130a2_probe(struct i2c_client *client)
|
||||
{
|
||||
struct device *dev;
|
||||
struct tpa6130a2_data *data;
|
||||
struct tpa6130a2_platform_data *pdata = client->dev.platform_data;
|
||||
struct device_node *np = client->dev.of_node;
|
||||
const char *regulator;
|
||||
unsigned int version;
|
||||
|
|
@ -238,10 +225,13 @@ static int tpa6130a2_probe(struct i2c_client *client)
|
|||
if (IS_ERR(data->regmap))
|
||||
return PTR_ERR(data->regmap);
|
||||
|
||||
if (pdata) {
|
||||
data->power_gpio = pdata->power_gpio;
|
||||
} else if (np) {
|
||||
data->power_gpio = of_get_named_gpio(np, "power-gpio", 0);
|
||||
if (np) {
|
||||
data->power_gpio = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(data->power_gpio)) {
|
||||
return dev_err_probe(dev, PTR_ERR(data->power_gpio),
|
||||
"Failed to request power GPIO\n");
|
||||
}
|
||||
gpiod_set_consumer_name(data->power_gpio, "tpa6130a2 enable");
|
||||
} else {
|
||||
dev_err(dev, "Platform data not set\n");
|
||||
dump_stack();
|
||||
|
|
@ -252,17 +242,6 @@ static int tpa6130a2_probe(struct i2c_client *client)
|
|||
|
||||
data->id = (uintptr_t)i2c_get_match_data(client);
|
||||
|
||||
if (data->power_gpio >= 0) {
|
||||
ret = devm_gpio_request(dev, data->power_gpio,
|
||||
"tpa6130a2 enable");
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Failed to request power GPIO (%d)\n",
|
||||
data->power_gpio);
|
||||
return ret;
|
||||
}
|
||||
gpio_direction_output(data->power_gpio, 0);
|
||||
}
|
||||
|
||||
switch (data->id) {
|
||||
default:
|
||||
dev_warn(dev, "Unknown TPA model (%d). Assuming 6130A2\n",
|
||||
|
|
@ -318,7 +297,6 @@ static struct i2c_driver tpa6130a2_i2c_driver = {
|
|||
.of_match_table = of_match_ptr(tpa6130a2_of_match),
|
||||
},
|
||||
.probe = tpa6130a2_probe,
|
||||
.id_table = tpa6130a2_id,
|
||||
};
|
||||
|
||||
module_i2c_driver(tpa6130a2_i2c_driver);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user