From patchwork Fri Jul 8 16:02:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 12911348 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AE77C433EF for ; Fri, 8 Jul 2022 16:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238591AbiGHQCg (ORCPT ); Fri, 8 Jul 2022 12:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239021AbiGHQC1 (ORCPT ); Fri, 8 Jul 2022 12:02:27 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EA697478B; Fri, 8 Jul 2022 09:02:26 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id h17so18000807wrx.0; Fri, 08 Jul 2022 09:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BZiUZmT0tfqSNYrVDB3ZIcuUNgROO7bIhmSFmAv1IU0=; b=k6MRafTIjLFT1JtE4D9aEJAzuM2l4LHSD4LFUev0WAz/qxJcFYLmLFPd8T3HUi+GmM WXPH4YdtZEsMaIroLkgE7WPNusU/6W4LjIv3aeCTx5zofkvZtLOPr65PLDW0vSWv1W3R rfCi3UZpFbAZkZF0LpCNYsPR0+Q+i7Qqk6jvb/c+HTCqHeURueg52FbQYt9/dyICsSY6 6R+4aaVMXH3GUwIdxTgFW7NHadDkP7Id3PxrWR7XaixVjPIxcVzgKCOhLFizC4S6YIQ4 8xFhUifbVMbugJSITvDtO6Wjv69aeGeK3wY8L/VxcTHvyrQTOeCNxlae3ONObLkDMS0q 88OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BZiUZmT0tfqSNYrVDB3ZIcuUNgROO7bIhmSFmAv1IU0=; b=4E2eCxLApeyr1qbID2gUflpEbNiCq/7ySKMOcmXh9c3VdHjmexA7/x+wfRvcjVWm++ dSlHP1irV2RKbnv2K2pngxmyBgYDQpvI+OnXQ8tbb+rX8KP1qQQzBlYkSQbRq2C3sa+b u6oht/sDuoj8JfgnDy3Q6tawTPjbrpTydh6+9hnG7lXpCpojCI91wi6f2XWomqCIvxv0 xiA1vjM6B5ykF82vVcapOQ59L4R24lXuq27csXn1AT+MYhpfivocOso4lm+zgaTkop4o nqlfC/aoH4J3R1zEALK/Iu7r2Udu4Sz7TEGjFgnqB82C+RD9v8IoP4t1oeyvjs3aTJYs /kIw== X-Gm-Message-State: AJIora/7fKDc8b3tgxyFdXG5Gtq9H3dDj6Qm24fo6QDQtG1gipRlRiDF J/0TTW6Etl8VUpQU1hAn1fQ= X-Google-Smtp-Source: AGRyM1tuHwQHC7pZ7s1H59Nugqp3lsiCjlDeqN1LoHU5yuofAm0gZ09wOdaDS3o1h9QbDqE/CssYzw== X-Received: by 2002:adf:979b:0:b0:21d:868a:7f2f with SMTP id s27-20020adf979b000000b0021d868a7f2fmr3980444wrb.409.1657296144573; Fri, 08 Jul 2022 09:02:24 -0700 (PDT) Received: from localhost (92.40.203.144.threembb.co.uk. [92.40.203.144]) by smtp.gmail.com with ESMTPSA id by13-20020a056000098d00b0021b89f8662esm17612622wrb.13.2022.07.08.09.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 09:02:24 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 11/11] ASoC: jz4740-i2s: Refactor DAI probe/remove ops as component ops Date: Fri, 8 Jul 2022 17:02:44 +0100 Message-Id: <20220708160244.21933-12-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220708160244.21933-1-aidanmacdonald.0x0@gmail.com> References: <20220708160244.21933-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Move most of the DAI probe/remove logic into component ops. This makes things more consistent because the AIC clock is now managed solely from the component side. And it makes it easier to add codec switching support later on. Signed-off-by: Aidan MacDonald Reviewed-by: Paul Cercueil --- sound/soc/jz4740/jz4740-i2s.c | 54 +++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index 5db73f12efcf..d99a19bc5166 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -306,32 +306,10 @@ static int jz4740_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); - int ret; - - ret = clk_prepare_enable(i2s->clk_aic); - if (ret) - return ret; snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data, &i2s->capture_dma_data); - regmap_write(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_RESET); - - regmap_write(i2s->regmap, JZ_REG_AIC_CONF, - JZ_AIC_CONF_OVERFLOW_PLAY_LAST | - JZ_AIC_CONF_I2S | JZ_AIC_CONF_INTERNAL_CODEC); - - regmap_field_write(i2s->field_rx_fifo_thresh, 7); - regmap_field_write(i2s->field_tx_fifo_thresh, 8); - - return 0; -} - -static int jz4740_i2s_dai_remove(struct snd_soc_dai *dai) -{ - struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); - - clk_disable_unprepare(i2s->clk_aic); return 0; } @@ -351,7 +329,6 @@ static const struct snd_soc_dai_ops jz4740_i2s_dai_ops = { static struct snd_soc_dai_driver jz4740_i2s_dai = { .probe = jz4740_i2s_dai_probe, - .remove = jz4740_i2s_dai_remove, .playback = { .channels_min = 1, .channels_max = 2, @@ -389,7 +366,6 @@ static const struct i2s_soc_info jz4760_i2s_soc_info = { static struct snd_soc_dai_driver jz4770_i2s_dai = { .probe = jz4740_i2s_dai_probe, - .remove = jz4740_i2s_dai_remove, .playback = { .channels_min = 1, .channels_max = 2, @@ -459,8 +435,38 @@ static int jz4740_i2s_resume(struct snd_soc_component *component) return 0; } +static int jz4740_i2s_probe(struct snd_soc_component *component) +{ + struct jz4740_i2s *i2s = snd_soc_component_get_drvdata(component); + int ret; + + ret = clk_prepare_enable(i2s->clk_aic); + if (ret) + return ret; + + regmap_write(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_RESET); + + regmap_write(i2s->regmap, JZ_REG_AIC_CONF, + JZ_AIC_CONF_OVERFLOW_PLAY_LAST | + JZ_AIC_CONF_I2S | JZ_AIC_CONF_INTERNAL_CODEC); + + regmap_field_write(i2s->field_rx_fifo_thresh, 7); + regmap_field_write(i2s->field_tx_fifo_thresh, 8); + + return 0; +} + +static void jz4740_i2s_remove(struct snd_soc_component *component) +{ + struct jz4740_i2s *i2s = snd_soc_component_get_drvdata(component); + + clk_disable_unprepare(i2s->clk_aic); +} + static const struct snd_soc_component_driver jz4740_i2s_component = { .name = "jz4740-i2s", + .probe = jz4740_i2s_probe, + .remove = jz4740_i2s_remove, .suspend = jz4740_i2s_suspend, .resume = jz4740_i2s_resume, .legacy_dai_naming = 1,