Skip to content

Commit b3296f9

Browse files
haobui-rvcbroonie
authored andcommitted
ASoC: da7213: Extend support for the MCK in range [2, 50] MHz
According to DA7212 HW manual, the codec's PLL input divider can operate with MCLK range from 2MHz to 50MHz but current driver only set the minimum supported MCLK frequency to 5MHz. That cause 11.025kHz audio which is corresponding to MCLK of 2.8224MHz (11.025kHz * 256) unable to play in case audio-simple-card is used. Signed-off-by: Hao Bui <[email protected]> Co-developed-by: Claudiu Beznea <[email protected]> Signed-off-by: Claudiu Beznea <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 1e1a2ef commit b3296f9

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

sound/soc/codecs/da7213.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <sound/pcm.h>
2121
#include <sound/pcm_params.h>
2222
#include <linux/pm_runtime.h>
23+
#include <linux/units.h>
2324
#include <sound/soc.h>
2425
#include <sound/initval.h>
2526
#include <sound/tlv.h>
@@ -1559,7 +1560,7 @@ static int da7213_set_component_sysclk(struct snd_soc_component *component,
15591560
if (freq == 0)
15601561
return 0;
15611562

1562-
if (((freq < 5000000) && (freq != 32768)) || (freq > 54000000)) {
1563+
if (((freq < da7213->fin_min_rate) && (freq != 32768)) || (freq > 54000000)) {
15631564
dev_err(component->dev, "Unsupported MCLK value %d\n",
15641565
freq);
15651566
return -EINVAL;
@@ -1858,20 +1859,23 @@ static int da7213_set_bias_level(struct snd_soc_component *component,
18581859
return 0;
18591860
}
18601861

1862+
#define DA7213_FIN_MIN_RATE (5 * MEGA)
1863+
#define DA7212_FIN_MIN_RATE (2 * MEGA)
1864+
18611865
#if defined(CONFIG_OF)
18621866
/* DT */
18631867
static const struct of_device_id da7213_of_match[] = {
1864-
{ .compatible = "dlg,da7212", },
1865-
{ .compatible = "dlg,da7213", },
1868+
{ .compatible = "dlg,da7212", .data = (void *)DA7212_FIN_MIN_RATE },
1869+
{ .compatible = "dlg,da7213", .data = (void *)DA7213_FIN_MIN_RATE },
18661870
{ }
18671871
};
18681872
MODULE_DEVICE_TABLE(of, da7213_of_match);
18691873
#endif
18701874

18711875
#ifdef CONFIG_ACPI
18721876
static const struct acpi_device_id da7213_acpi_match[] = {
1873-
{ "DLGS7212", 0},
1874-
{ "DLGS7213", 0},
1877+
{ "DLGS7212", DA7212_FIN_MIN_RATE },
1878+
{ "DLGS7213", DA7213_FIN_MIN_RATE },
18751879
{ },
18761880
};
18771881
MODULE_DEVICE_TABLE(acpi, da7213_acpi_match);
@@ -2167,6 +2171,10 @@ static int da7213_i2c_probe(struct i2c_client *i2c)
21672171
if (!da7213)
21682172
return -ENOMEM;
21692173

2174+
da7213->fin_min_rate = (uintptr_t)i2c_get_match_data(i2c);
2175+
if (!da7213->fin_min_rate)
2176+
return -EINVAL;
2177+
21702178
i2c_set_clientdata(i2c, da7213);
21712179

21722180
/* Get required supplies */

sound/soc/codecs/da7213.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ struct da7213_priv {
600600
struct clk *mclk;
601601
unsigned int mclk_rate;
602602
unsigned int out_rate;
603+
unsigned int fin_min_rate;
603604
int clk_src;
604605
bool master;
605606
bool alc_calib_auto;

0 commit comments

Comments
 (0)