diff mbox series

[3/3] ASoC: maxim,max9867: add "mclk" support

Message ID 20230302-max9867-v1-3-aa9f7f25db5e@skidata.com
State New
Headers show
Series Add "mclk" support for maxim,max9867 | expand

Commit Message

Richard Leitner March 2, 2023, 11:55 a.m. UTC
From: Benjamin Bara <benjamin.bara@skidata.com>

Add basic support for the codecs mclk by enabling it during probing.

Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
---
 sound/soc/codecs/max9867.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c
index e161ab037bf7..b92dd61bb2b2 100644
--- a/sound/soc/codecs/max9867.c
+++ b/sound/soc/codecs/max9867.c
@@ -6,6 +6,7 @@ 
 // Copyright 2018 Ladislav Michl <ladis@linux-mips.org>
 //
 
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
@@ -16,6 +17,7 @@ 
 #include "max9867.h"
 
 struct max9867_priv {
+	struct clk *mclk;
 	struct regmap *regmap;
 	const struct snd_pcm_hw_constraint_list *constraints;
 	unsigned int sysclk, pclk;
@@ -663,8 +665,18 @@  static int max9867_i2c_probe(struct i2c_client *i2c)
 	dev_info(&i2c->dev, "device revision: %x\n", reg);
 	ret = devm_snd_soc_register_component(&i2c->dev, &max9867_component,
 			max9867_dai, ARRAY_SIZE(max9867_dai));
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(&i2c->dev, "Failed to register component: %d\n", ret);
+		return ret;
+	}
+
+	max9867->mclk = devm_clk_get(&i2c->dev, "mclk");
+	if (IS_ERR(max9867->mclk))
+		return PTR_ERR(max9867->mclk);
+	ret = clk_prepare_enable(max9867->mclk);
+	if (ret < 0)
+		dev_err(&i2c->dev, "Failed to enable MCLK: %d\n", ret);
+
 	return ret;
 }