summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/aw88261.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/aw88261.c')
-rw-r--r--sound/soc/codecs/aw88261.c44
1 files changed, 14 insertions, 30 deletions
diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c
index a697b5006b45..a78ceedd0334 100644
--- a/sound/soc/codecs/aw88261.c
+++ b/sound/soc/codecs/aw88261.c
@@ -10,7 +10,6 @@
#include <linux/i2c.h>
#include <linux/firmware.h>
-#include <linux/of_gpio.h>
#include <linux/regmap.h>
#include <sound/soc.h>
#include "aw88261.h"
@@ -20,7 +19,7 @@
static const struct regmap_config aw88261_remap_config = {
.val_bits = 16,
.reg_bits = 8,
- .max_register = AW88261_REG_MAX - 1,
+ .max_register = AW88261_REG_MAX,
.reg_format_endian = REGMAP_ENDIAN_LITTLE,
.val_format_endian = REGMAP_ENDIAN_BIG,
};
@@ -477,7 +476,7 @@ static int aw88261_dev_reg_update(struct aw88261 *aw88261,
return ret;
}
-static char *aw88261_dev_get_prof_name(struct aw_device *aw_dev, int index)
+static int aw88261_dev_get_prof_name(struct aw_device *aw_dev, int index, char **prof_name)
{
struct aw_prof_info *prof_info = &aw_dev->prof_info;
struct aw_prof_desc *prof_desc;
@@ -485,12 +484,14 @@ static char *aw88261_dev_get_prof_name(struct aw_device *aw_dev, int index)
if ((index >= aw_dev->prof_info.count) || (index < 0)) {
dev_err(aw_dev->dev, "index[%d] overflow count[%d]",
index, aw_dev->prof_info.count);
- return NULL;
+ return -EINVAL;
}
prof_desc = &aw_dev->prof_info.prof_desc[index];
- return prof_info->prof_name_list[prof_desc->id];
+ *prof_name = prof_info->prof_name_list[prof_desc->id];
+
+ return 0;
}
static int aw88261_dev_get_prof_data(struct aw_device *aw_dev, int index,
@@ -515,8 +516,8 @@ static int aw88261_dev_fw_update(struct aw88261 *aw88261)
char *prof_name;
int ret;
- prof_name = aw88261_dev_get_prof_name(aw_dev, aw_dev->prof_index);
- if (!prof_name) {
+ ret = aw88261_dev_get_prof_name(aw_dev, aw_dev->prof_index, &prof_name);
+ if (ret) {
dev_err(aw_dev->dev, "get prof name failed");
return -EINVAL;
}
@@ -818,9 +819,8 @@ static int aw88261_profile_info(struct snd_kcontrol *kcontrol,
{
struct snd_soc_component *codec = snd_soc_kcontrol_component(kcontrol);
struct aw88261 *aw88261 = snd_soc_component_get_drvdata(codec);
- const char *prof_name;
- char *name;
- int count;
+ char *prof_name, *name;
+ int count, ret;
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
@@ -839,8 +839,8 @@ static int aw88261_profile_info(struct snd_kcontrol *kcontrol,
name = uinfo->value.enumerated.name;
count = uinfo->value.enumerated.item;
- prof_name = aw88261_dev_get_prof_name(aw88261->aw_pa, count);
- if (!prof_name) {
+ ret = aw88261_dev_get_prof_name(aw88261->aw_pa, count, &prof_name);
+ if (ret) {
strscpy(uinfo->value.enumerated.name, "null",
strlen("null") + 1);
return 0;
@@ -1174,26 +1174,16 @@ static const struct snd_soc_component_driver soc_codec_dev_aw88261 = {
.remove = aw88261_codec_remove,
};
-static void aw88261_hw_reset(struct aw88261 *aw88261)
-{
- gpiod_set_value_cansleep(aw88261->reset_gpio, 0);
- usleep_range(AW88261_1000_US, AW88261_1000_US + 10);
- gpiod_set_value_cansleep(aw88261->reset_gpio, 1);
- usleep_range(AW88261_1000_US, AW88261_1000_US + 10);
-}
-
static void aw88261_parse_channel_dt(struct aw88261 *aw88261)
{
struct aw_device *aw_dev = aw88261->aw_pa;
struct device_node *np = aw_dev->dev->of_node;
u32 channel_value = AW88261_DEV_DEFAULT_CH;
- u32 sync_enable = false;
- of_property_read_u32(np, "sound-channel", &channel_value);
- of_property_read_u32(np, "sync-flag", &sync_enable);
+ of_property_read_u32(np, "awinic,audio-channel", &channel_value);
+ aw88261->phase_sync = of_property_read_bool(np, "awinic,sync-flag");
aw_dev->channel = channel_value;
- aw88261->phase_sync = sync_enable;
}
static int aw88261_init(struct aw88261 **aw88261, struct i2c_client *i2c, struct regmap *regmap)
@@ -1255,12 +1245,6 @@ static int aw88261_i2c_probe(struct i2c_client *i2c)
i2c_set_clientdata(i2c, aw88261);
- aw88261->reset_gpio = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_LOW);
- if (IS_ERR(aw88261->reset_gpio))
- dev_info(&i2c->dev, "reset gpio not defined\n");
- else
- aw88261_hw_reset(aw88261);
-
aw88261->regmap = devm_regmap_init_i2c(i2c, &aw88261_remap_config);
if (IS_ERR(aw88261->regmap)) {
ret = PTR_ERR(aw88261->regmap);