Message ID | 20230302-max9867-v1-3-aa9f7f25db5e@skidata.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4192510wrd; Thu, 2 Mar 2023 03:59:14 -0800 (PST) X-Google-Smtp-Source: AK7set/dJ1HKBVFcAIp1axHND/ybWBgd2c/ScNXXoZcQKnZESr1EbgqLCcgJCTFO27tWIdQqsRk+ X-Received: by 2002:a17:90b:1645:b0:230:a195:b8ac with SMTP id il5-20020a17090b164500b00230a195b8acmr11037011pjb.7.1677758354697; Thu, 02 Mar 2023 03:59:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677758354; cv=none; d=google.com; s=arc-20160816; b=P7edS9P+gv4ohJV5FqIu+5vBaOVn0iI1M0spZeXHGMaIDQhbC/n0OC5daD9hnee5oG Z2yA+jY0hSbe+0P9Lk8jTpQCmL0SRMOVER01DOjyu96kUxWnnVNIEe88V8DSyBuPWsg6 ZCuClqdgQIL0C8vDtbMAkMoop7M62qlXptNON+9qhMNJB8R21stLK6FXqW16Xl9dP35Z 2X3/SGoM95ev5R2ZBDhXeWFtryA9nlP+eVuG8wNqNLCmg78Y8DKkUvU3rSmUEWjKutMl szl9Y+987RMrKpV+KAUrn/jVguW0L6M2x8s1gCIPVdeSw1TqufrIgSG9tFgfQw7dO7E7 v5yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=sredrf5PjZ7jQFXwhsTWfhRpimvvGAc4wV/iwzTmZq0=; b=yqjPa8loPiQIlTsNByqcJ2G2zWCrfjlSKm+Isq9ZWkYnbPrcij5s5FLdgy9vnIC6Ki wJqKleJn2GfOBg2UTq8lJPvc8zLE95C8PNzbUH8gs80e0VMjyiflkoxlWzKMVUncc+FN qPU24VE4z4I0GuExn+7aiyfXi9VGrDjNxMTAKjvdXWOLAPj1cW9E2Mvu+TqUwMfK9xH7 9BBGe84Dkq/VEAgburWWzEcN6pVsslr0lPIjcN8kAwiVehBW7V5FpwgEQ5r907X8XLHv K4Y7+0DhRGwtreIlVzqVDX8J/j9cUkfIgtQqxhSWQ24AjOzuG17cOh7JjBoc8kMGdn8I 38bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=p3i2oWfX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kl12-20020a170903074c00b0019c9a5e0172si13750625plb.556.2023.03.02.03.59.02; Thu, 02 Mar 2023 03:59:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=p3i2oWfX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbjCBL5m (ORCPT <rfc822;davidbtadokoro@gmail.com> + 99 others); Thu, 2 Mar 2023 06:57:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229871AbjCBL5b (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 2 Mar 2023 06:57:31 -0500 Received: from out-39.mta1.migadu.com (out-39.mta1.migadu.com [IPv6:2001:41d0:203:375::27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 596AD37569 for <linux-kernel@vger.kernel.org>; Thu, 2 Mar 2023 03:57:23 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1677758241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sredrf5PjZ7jQFXwhsTWfhRpimvvGAc4wV/iwzTmZq0=; b=p3i2oWfXX64J/GM40FQzzz9ICV3FS6E6pH4lDCCyy7YOp2GeNRWM0L6LgWvaaDUFYG8nrS JsC4lt9h3nfU1JJGScOJBu6/x+XrQKJnq360TuI5WChEuOL3dC/CGCuPgG3RaxCBz9v/4o SuxS+lrnpNYeCA30kp61Se0VWYaGU0A= From: richard.leitner@linux.dev Date: Thu, 02 Mar 2023 12:55:03 +0100 Subject: [PATCH 3/3] ASoC: maxim,max9867: add "mclk" support MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230302-max9867-v1-3-aa9f7f25db5e@skidata.com> References: <20230302-max9867-v1-0-aa9f7f25db5e@skidata.com> In-Reply-To: <20230302-max9867-v1-0-aa9f7f25db5e@skidata.com> To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Ladislav Michl <ladis@linux-mips.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, Benjamin Bara <benjamin.bara@skidata.com> Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Leitner <richard.leitner@skidata.com> X-Developer-Signature: v=1; a=openpgp-sha256; l=1453; i=richard.leitner@skidata.com; h=from:subject:message-id; bh=t7JeLv5Avx9AQ87GdXmgLhpXQCWm8ePC8Uj/0k4VhNI=; b=owGbwMvMwCX2R2KahkXN7wuMp9WSGFIY+uU7ly5v9/95II6d2/TEmpl/JRpjl/9oubQ0q6J9w9Pg BJ1PHaUsDGJcDLJiiiz2xlzt7rll7ysVdXJh5rAygQxh4OIUgImcimX4p+Rb7Xtxr/wJwSKfq3Jq+z 3TBM53av9zm7Gv/Nbi8hlPpjH8lanmVk9hWxPJdoeZ6dvrUyq+6x84Fxjm/T4//3H/R2tLZgA= X-Developer-Key: i=richard.leitner@skidata.com; a=openpgp; fpr=3F330A87476D76EF79212C6DFC189628387CFBD0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759257144524123865?= X-GMAIL-MSGID: =?utf-8?q?1759257144524123865?= |
Series |
Add "mclk" support for maxim,max9867
|
|
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(-)
Comments
On Thu, Mar 02, 2023 at 12:55:03PM +0100, richard.leitner@linux.dev wrote: > + 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); > + Nothing ever disables the clock - we need a disable in the remove path at least.
On 02.03.2023 14:20, Mark Brown wrote: >> + 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); >> + > Nothing ever disables the clock - we need a disable in the remove path > at least. I don't have the full context of this patch but this diff seems a good candidate for devm_clk_get_enabled().
On Thu, Mar 02, 2023 at 12:20:18PM +0000, Mark Brown wrote: > On Thu, Mar 02, 2023 at 12:55:03PM +0100, richard.leitner@linux.dev wrote: > > > + 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); > > + > > Nothing ever disables the clock - we need a disable in the remove path > at least. Sure. Sorry for missing that. I will send a v2 later today. regards;rl
Hi Claudiu, On Thu, Mar 02, 2023 at 12:45:50PM +0000, Claudiu.Beznea@microchip.com wrote: > On 02.03.2023 14:20, Mark Brown wrote: > >> + 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); > >> + > > Nothing ever disables the clock - we need a disable in the remove path > > at least. > > I don't have the full context of this patch but this diff seems a good > candidate for devm_clk_get_enabled(). Thanks for that pointer, but currently we are thinking of prepare_enable the clock in SND_SOC_BIAS_ON and disable_unprepare it in SND_SOC_BIAS_OFF (similar to wm8731.c). Therefore probe() will only do a devm_clk_get(). Claudiu, Rob: Will this be an acceptable solution? regards;rl
On 02.03.2023 16:46, Richard Leitner wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > Hi Claudiu, > > On Thu, Mar 02, 2023 at 12:45:50PM +0000, Claudiu.Beznea@microchip.com wrote: >> On 02.03.2023 14:20, Mark Brown wrote: >>>> + 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); >>>> + >>> Nothing ever disables the clock - we need a disable in the remove path >>> at least. >> >> I don't have the full context of this patch but this diff seems a good >> candidate for devm_clk_get_enabled(). > > Thanks for that pointer, but currently we are thinking of prepare_enable > the clock in SND_SOC_BIAS_ON and disable_unprepare it in SND_SOC_BIAS_OFF > (similar to wm8731.c). > Therefore probe() will only do a devm_clk_get(). Sounds good for me. > > Claudiu, Rob: Will this be an acceptable solution? > > regards;rl
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; }