@@ -1416,49 +1416,12 @@ static int sma1303_probe(struct snd_soc_component *component)
struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
- int ret = 0, i = 0;
- unsigned int status, otp_stat;
+ int ret = 0;
ret += sma1303_add_component_controls(component);
snd_soc_dapm_sync(dapm);
- ret += sma1303_regmap_update_bits(sma1303,
- SMA1303_00_SYSTEM_CTRL,
- SMA1303_RESETBYI2C_MASK, SMA1303_RESETBYI2C_RESET);
-
- ret += sma1303_regmap_read(sma1303, SMA1303_FF_DEVICE_INDEX, &status);
- if (ret < 0) {
- dev_err(sma1303->dev,
- "failed to read, register: %02X, ret: %d\n",
- SMA1303_FF_DEVICE_INDEX, ret);
- return ret;
- }
- sma1303->rev_num = status & SMA1303_REV_NUM_STATUS;
- if (sma1303->rev_num == SMA1303_REV_NUM_TV0)
- dev_info(component->dev, "SMA1303 Trimming Version 0\n");
- else if (sma1303->rev_num == SMA1303_REV_NUM_TV1)
- dev_info(component->dev, "SMA1303 Trimming Version 1\n");
-
- ret += sma1303_regmap_read(sma1303, SMA1303_FB_STATUS2, &otp_stat);
- if (ret < 0)
- dev_err(sma1303->dev,
- "failed to read, register: %02X, ret: %d\n",
- SMA1303_FF_DEVICE_INDEX, ret);
-
- if (((sma1303->rev_num == SMA1303_REV_NUM_TV0) &&
- ((otp_stat & 0x0E) == SMA1303_OTP_STAT_OK_0)) ||
- ((sma1303->rev_num != SMA1303_REV_NUM_TV0) &&
- ((otp_stat & 0x0C) == SMA1303_OTP_STAT_OK_1)))
- dev_info(component->dev, "SMA1303 OTP Status Successful\n");
- else
- dev_info(component->dev, "SMA1303 OTP Status Fail\n");
-
- for (i = 0; i < (unsigned int)ARRAY_SIZE(sma1303_reg_def); i++)
- ret += sma1303_regmap_write(sma1303,
- sma1303_reg_def[i].reg,
- sma1303_reg_def[i].def);
-
ret += sma1303_regmap_write(sma1303,
SMA1303_0A_SPK_VOL, sma1303->init_vol);
@@ -1580,18 +1543,17 @@ static int sma1303_i2c_probe(struct i2c_client *client,
{
struct sma1303_priv *sma1303;
struct device_node *np = client->dev.of_node;
- int ret;
+ int ret, i = 0;
u32 value;
- unsigned int device_info;
-
- sma1303 = devm_kzalloc(&client->dev, sizeof(struct sma1303_priv),
- GFP_KERNEL);
+ unsigned int device_info, status, otp_stat;
+ sma1303 = devm_kzalloc(&client->dev,
+ sizeof(struct sma1303_priv), GFP_KERNEL);
if (!sma1303)
return -ENOMEM;
+ sma1303->dev = &client->dev;
sma1303->regmap = devm_regmap_init_i2c(client, &sma_i2c_regmap);
-
if (IS_ERR(sma1303->regmap)) {
ret = PTR_ERR(sma1303->regmap);
dev_err(&client->dev,
@@ -1671,35 +1633,64 @@ static int sma1303_i2c_probe(struct i2c_client *client,
}
dev_info(&client->dev, "chip version 0x%02X\n", device_info);
- sma1303->last_over_temp = 0xC0;
- sma1303->last_ocp_val = 0x08;
- sma1303->tsdw_cnt = 0;
+ ret += sma1303_regmap_update_bits(sma1303,
+ SMA1303_00_SYSTEM_CTRL,
+ SMA1303_RESETBYI2C_MASK, SMA1303_RESETBYI2C_RESET);
+
+ ret += sma1303_regmap_read(sma1303, SMA1303_FF_DEVICE_INDEX, &status);
+ sma1303->rev_num = status & SMA1303_REV_NUM_STATUS;
+ if (sma1303->rev_num == SMA1303_REV_NUM_TV0)
+ dev_info(&client->dev, "SMA1303 Trimming Version 0\n");
+ else if (sma1303->rev_num == SMA1303_REV_NUM_TV1)
+ dev_info(&client->dev, "SMA1303 Trimming Version 1\n");
+
+ ret += sma1303_regmap_read(sma1303, SMA1303_FB_STATUS2, &otp_stat);
+ if (ret < 0)
+ dev_err(&client->dev,
+ "failed to read, register: %02X, ret: %d\n",
+ SMA1303_FF_DEVICE_INDEX, ret);
+
+ if (((sma1303->rev_num == SMA1303_REV_NUM_TV0) &&
+ ((otp_stat & 0x0E) == SMA1303_OTP_STAT_OK_0)) ||
+ ((sma1303->rev_num != SMA1303_REV_NUM_TV0) &&
+ ((otp_stat & 0x0C) == SMA1303_OTP_STAT_OK_1)))
+ dev_info(&client->dev, "SMA1303 OTP Status Successful\n");
+ else
+ dev_info(&client->dev, "SMA1303 OTP Status Fail\n");
+
+ for (i = 0; i < (unsigned int)ARRAY_SIZE(sma1303_reg_def); i++)
+ ret += sma1303_regmap_write(sma1303,
+ sma1303_reg_def[i].reg,
+ sma1303_reg_def[i].def);
+
+ sma1303->amp_mode = SMA1303_MONO;
+ sma1303->amp_power_status = false;
+ sma1303->check_fault_period = CHECK_PERIOD_TIME;
+ sma1303->check_fault_status = true;
+ sma1303->force_mute_status = false;
sma1303->init_vol = 0x31;
sma1303->cur_vol = sma1303->init_vol;
sma1303->last_bclk = 0;
+ sma1303->last_ocp_val = 0x08;
+ sma1303->last_over_temp = 0xC0;
+ sma1303->tsdw_cnt = 0;
- INIT_DELAYED_WORK(&sma1303->check_fault_work,
- sma1303_check_fault_worker);
+ sma1303->dev = &client->dev;
+ sma1303->kobj = &client->dev.kobj;
mutex_init(&sma1303->lock);
- sma1303->check_fault_period = CHECK_PERIOD_TIME;
- sma1303->dev = &client->dev;
- sma1303->kobj = &client->dev.kobj;
+ INIT_DELAYED_WORK(&sma1303->check_fault_work,
+ sma1303_check_fault_worker);
i2c_set_clientdata(client, sma1303);
- sma1303->amp_mode = SMA1303_MONO;
- sma1303->amp_power_status = false;
- sma1303->force_mute_status = false;
- sma1303->check_fault_status = true;
sma1303->pll_matches = sma1303_pll_matches;
sma1303->num_of_pll_matches =
ARRAY_SIZE(sma1303_pll_matches);
ret = devm_snd_soc_register_component(&client->dev,
&sma1303_component, sma1303_dai, 1);
-
if (ret) {
dev_err(&client->dev, "Failed to register component");
@@ -1708,7 +1699,6 @@ static int sma1303_i2c_probe(struct i2c_client *client,
sma1303->attr_grp = &sma1303_attr_group;
ret = sysfs_create_group(sma1303->kobj, sma1303->attr_grp);
-
if (ret) {
dev_err(&client->dev,
"failed to create attribute group [%d]\n", ret);
Signed-off-by: Kiseok Jo <kiseok.jo@irondevice.com> Reported-by: Mark Brown <broonie@kernel.org> --- sound/soc/codecs/sma1303.c | 106 +++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 58 deletions(-)