From patchwork Sun Oct 23 14:33:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 8036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp17480wru; Sun, 23 Oct 2022 07:35:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WtmK9QGiF5EOSW0/SnutesC9Amf9K6QnUKkJSOzj8jLjthM9/HAkebbuU1KboU1Q+ZiUs X-Received: by 2002:a17:902:e88e:b0:183:dcb7:c4fc with SMTP id w14-20020a170902e88e00b00183dcb7c4fcmr28274973plg.32.1666535737846; Sun, 23 Oct 2022 07:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666535737; cv=none; d=google.com; s=arc-20160816; b=vyrk1GvyIHAdHWgRmohM8ygkL54k4cBr2we1xo5ugPL1QWDxbBanzCocotTJs2l2Oo BY32WMSaBNMzslFCp7E6iWxSHw5LGWrEaXqQKHKKc8s/wwX1vfVREuAHF72OqtTz9Kvk 7AQD51LX+kZiav87LbWjsb8ZUIl3LcAR8gQRNB83faJL/pZRFbvnud2jcJwTY3RCcJDh tEj2AIFXZiXfLiVVHz9Kw/vVmqizgo6vWjuvXF9QZOSmGF2Ey+4U4/0hrBa9z71fUYaI v/rV8FmA+QgcNfNpqQtnv+lNbuz/CGgCR6Nt2aOnPAyDvZMRmnkkofTG8Klt22IQb7dH fJWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UT0ZSJttMO+IN7qAwXeIN59Jy0agrsi51doQcQVju30=; b=PWrlH0BXSjycdcYbK2FK2Ukd11d1VPjC7elw7+f965cdoSFuC3QEVsasW1P/JN+8kx 8f9m57WEgFqYqKttBwEr1S8zCd9uVdpHurg3oBHXw159PxdpdjdsK++007uGZaFpTGnT CO1oB/C2cqTpdJGxfeNZuvaFMonFgwO6Ogk9zQi3/o/VkSpQaSskU8rl9FBSUOs6EzSy hStFMUSg2K8D1B04BZdHp3J1vNEm1hMztW8Qyw7coQy0TMv5E4vsY1vsDl+0yw3jKnVb H+Pwh4xJv80QKfluSNu0w2jRFmVsNf9K9ES5NIQU5ORWpbuaccQhBNuXOxdvCXno/j/C vuZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=a4R41X2e; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t64-20020a635f43000000b0044fb0824e52si33465966pgb.171.2022.10.23.07.35.24; Sun, 23 Oct 2022 07:35:37 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=a4R41X2e; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230210AbiJWOdh (ORCPT + 99 others); Sun, 23 Oct 2022 10:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbiJWOdf (ORCPT ); Sun, 23 Oct 2022 10:33:35 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 551FC1032; Sun, 23 Oct 2022 07:33:34 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bu30so11847941wrb.8; Sun, 23 Oct 2022 07:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UT0ZSJttMO+IN7qAwXeIN59Jy0agrsi51doQcQVju30=; b=a4R41X2eIL3ukRmoZio82gBdHf1RipQIToHH1XoKU3wVW61b9R8bZ2B9FnJPaaMC+N EYBvlP5agU5pbx5jgmaT3golS5rSSFTKyRns8NvC5zP2DonVnHtoGe6eTgKPlW+ZnaJr tCBTXCM2niXy3frrsfQ9vUIvFUR/oe3QWesIB5EyJc1QvACAyzfz1j9LHiHeiiessVZm Uxr1n1nd+3eKlDfP7YvuOq6gEG+FkWXoaxdp7Azn6v9v32FT33VCFdJ8auptHYDlHHWT DfdY0z4B9rMKPX39CPMoj0vv4wQKNISpojmcLGTyhgTYu6NS8T828O1hptghMVlieq8u OjcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UT0ZSJttMO+IN7qAwXeIN59Jy0agrsi51doQcQVju30=; b=pyIX9I645VoFxpgDMiNfvphGY+RrbbYRIHhmtG4vhlTbw5h6n6K7pIFE0ppExu78iJ pjiXZY27P6M1zI5D+Yb+Cdr3RhdO5Slcj+1s69YC/VTk/2cgMQq7m1HB1hXrN3icZfUJ Hb6Tb9cESW6bKk0Ds+Z4AkObve6ctovHzE5ikwG7l9bVZClvkHgJFFqohG6iOiTBes+j 8Dt9FxQOc/BZEs3bXdBxmnHz0K+I3VdI1qL16acBpfD56gC3xj5ceVgdfsBJy8RTegx0 E4kGOFmgevbQe0RjV5yeIhPxthVUtg31uVMhoTnbrwcLQwSIJdIN7YAXvDf6eCRswV/L CKXw== X-Gm-Message-State: ACrzQf32Tu+YF8ZMC7XIf80Vc0dgzLD7LSg/+NLL/qNOTwnPqWI1TEoV YpnJ1nYlN2w/1exrZ11wkdM= X-Received: by 2002:a05:6000:4084:b0:22e:5b99:4c4a with SMTP id da4-20020a056000408400b0022e5b994c4amr19057178wrb.538.1666535612756; Sun, 23 Oct 2022 07:33:32 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id c1-20020adfed81000000b00226dba960b4sm24235577wro.3.2022.10.23.07.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:33:32 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 1/9] ASoC: jz4740-i2s: Handle independent FIFO flush bits Date: Sun, 23 Oct 2022 15:33:20 +0100 Message-Id: <20221023143328.160866-2-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> References: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747489377718753163?= X-GMAIL-MSGID: =?utf-8?q?1747489377718753163?= On the JZ4740, there is a single bit that flushes (empties) both the transmit and receive FIFO. Later SoCs have independent flush bits for each FIFO. Independent FIFOs can be flushed before the snd_soc_dai_active() check because it won't disturb other active streams. This ensures that the FIFO we're about to use is always flushed before starting up. With shared FIFOs we can't do that because if another substream is active, flushing its FIFO would cause underrun errors. This also fixes a bug: since we were only setting the JZ4740's flush bit, which corresponds to the TX FIFO flush bit on other SoCs, other SoCs were not having their RX FIFO flushed at all. Fixes: 967beb2e8777 ("ASoC: jz4740: Add jz4780 support") Reviewed-by: Paul Cercueil Cc: stable@vger.kernel.org Signed-off-by: Aidan MacDonald --- v5 -> v6: Cc'd stable. sound/soc/jz4740/jz4740-i2s.c | 39 ++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index c4c1e89b47c1..83cb81999c6f 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -55,7 +55,8 @@ #define JZ_AIC_CTRL_MONO_TO_STEREO BIT(11) #define JZ_AIC_CTRL_SWITCH_ENDIANNESS BIT(10) #define JZ_AIC_CTRL_SIGNED_TO_UNSIGNED BIT(9) -#define JZ_AIC_CTRL_FLUSH BIT(8) +#define JZ_AIC_CTRL_TFLUSH BIT(8) +#define JZ_AIC_CTRL_RFLUSH BIT(7) #define JZ_AIC_CTRL_ENABLE_ROR_INT BIT(6) #define JZ_AIC_CTRL_ENABLE_TUR_INT BIT(5) #define JZ_AIC_CTRL_ENABLE_RFS_INT BIT(4) @@ -90,6 +91,8 @@ enum jz47xx_i2s_version { struct i2s_soc_info { enum jz47xx_i2s_version version; struct snd_soc_dai_driver *dai; + + bool shared_fifo_flush; }; struct jz4740_i2s { @@ -116,19 +119,44 @@ static inline void jz4740_i2s_write(const struct jz4740_i2s *i2s, writel(value, i2s->base + reg); } +static inline void jz4740_i2s_set_bits(const struct jz4740_i2s *i2s, + unsigned int reg, uint32_t bits) +{ + uint32_t value = jz4740_i2s_read(i2s, reg); + value |= bits; + jz4740_i2s_write(i2s, reg, value); +} + static int jz4740_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); - uint32_t conf, ctrl; + uint32_t conf; int ret; + /* + * When we can flush FIFOs independently, only flush the FIFO + * that is starting up. We can do this when the DAI is active + * because it does not disturb other active substreams. + */ + if (!i2s->soc_info->shared_fifo_flush) { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + jz4740_i2s_set_bits(i2s, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_TFLUSH); + else + jz4740_i2s_set_bits(i2s, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_RFLUSH); + } + if (snd_soc_dai_active(dai)) return 0; - ctrl = jz4740_i2s_read(i2s, JZ_REG_AIC_CTRL); - ctrl |= JZ_AIC_CTRL_FLUSH; - jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl); + /* + * When there is a shared flush bit for both FIFOs, the TFLUSH + * bit flushes both FIFOs. Flushing while the DAI is active would + * cause FIFO underruns in other active substreams so we have to + * guard this behind the snd_soc_dai_active() check. + */ + if (i2s->soc_info->shared_fifo_flush) + jz4740_i2s_set_bits(i2s, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_TFLUSH); ret = clk_prepare_enable(i2s->clk_i2s); if (ret) @@ -443,6 +471,7 @@ static struct snd_soc_dai_driver jz4740_i2s_dai = { static const struct i2s_soc_info jz4740_i2s_soc_info = { .version = JZ_I2S_JZ4740, .dai = &jz4740_i2s_dai, + .shared_fifo_flush = true, }; static const struct i2s_soc_info jz4760_i2s_soc_info = { From patchwork Sun Oct 23 14:33:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 8037 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp17549wru; Sun, 23 Oct 2022 07:35:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM73Hnz10Dyr3KPtyPf/aFcDIF/w7WvhI6aDnwIcJLZiYeTIvcCPqx2/17DY1jZfuuF8q74b X-Received: by 2002:a17:903:1c9:b0:186:91fa:59ad with SMTP id e9-20020a17090301c900b0018691fa59admr6312252plh.35.1666535747310; Sun, 23 Oct 2022 07:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666535747; cv=none; d=google.com; s=arc-20160816; b=1B/Bj4pGLjxGzokEM75w9m7loZEA6mBag7WiFJGX+S56uA9SbST2cshkGYNG8Ukxsj WNrgsJYsp4+gnNOXfEafVVPBfh1gVHmD2XMFhLZu2ovme/QPzgnFurj+G7bg4ISPK+6Y fTrBfVxoG5Jsj5qhXcu4j7iUUgnrOZPkRIJY5VXPF1WCwpZ8JidV+P1hoNFrqdrt5yBa HlXtgY/RHMgY5jl7WPpSNSTrx/wUTz1RPHePCgLrMQ2aSQxfibIq+jiwEn8zdO2ePaAc UWIzc6PwBfygYUBS6G3xQ79VmhaylnmU/zohRuJL2UUT3NraUPonrnC1VJDfA6ytOv8C MBYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ua+FwbDcAn/zYyqw249yK6lna19o3nAvvkXKqxMQ6wo=; b=UQcwKJ1HUmAiLp/qpugg5f47Xcy2HyqpRI8HoJGbOhlclyiSpQ6+dhpQF7K2B/bQ3l UWa2IFwD0bBVT2MBF76tpyCzhQBkAKhOAh2CnvYEaxPy5HmpuMM9Ajlqqcv1ehBPfOyH WQSHMIbKtvFq5Sge21/m4pRV+5/ygR/2myuiVqwkCM1Bvzv8/hii5LLB0aUFKAk+ZOdZ 3S/oZG8ppbbHaL9ee807hmp82vMk+OJ+9Eh1/BAE2VfqgegO4jEgClL7a+E4PjcK4X+F UP/E89XymQp5s4hb1aRrHVgxjenwYflTji7Wt6MEfscut62S/kVu2Tw2OrvbwS0LCUuL 20tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BE0N5+F3; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 38-20020a630d66000000b004616889d5c2si33339157pgn.495.2022.10.23.07.35.34; Sun, 23 Oct 2022 07:35:47 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=BE0N5+F3; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230248AbiJWOdk (ORCPT + 99 others); Sun, 23 Oct 2022 10:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbiJWOdg (ORCPT ); Sun, 23 Oct 2022 10:33:36 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B79B61B31; Sun, 23 Oct 2022 07:33:35 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id v1so11821384wrt.11; Sun, 23 Oct 2022 07:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ua+FwbDcAn/zYyqw249yK6lna19o3nAvvkXKqxMQ6wo=; b=BE0N5+F3cEOaEJky6hm6Cpk+6yOJ45QkDTbBkv1Ii5xVrzVrMrf4MArmIyMXwXJVrv mz20bkYR82oQh3vU2moZ7QVoCXFNkO4Wab8ZMEuMr5iBowwZcblJjmVUBixUkypCM0ei yHOxMZGri40QmmkTJ6r5QFgzzMga5aACumugo/AkfcZPCSlPawR+DpqcnHIGcp9C4wLb AoHydIdGPQGQp3xxnSHSXzlX+cHn5gj/FZX8dpQRqJpcgjmVXAK2wBkMY+k3uOT75SZc ox00CVEQOAmWKkte9BGazsq5Zxdppz9OBwGx9CV5LaNtkAEa3p4FSK0EHHYKu+/oQ47n 0+fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ua+FwbDcAn/zYyqw249yK6lna19o3nAvvkXKqxMQ6wo=; b=SEDkBLzcHzrbuyesezGSy3aiiYktCXinZJRhMGg5DClpUdSjx32aABfIwi1PfSuOgJ JZ/uLdzG95mFjs556498tlvp30pW4euhciZgAM9X40JshdWWpBWPtPigoaD/8Vv8K4Ms OYoTlRk/u1O63JFFBnGbVS75dfJMzu0fNlYf93ZN+WE0yyS3eAH2OSiCjF3CAMR0bXeg we8GA1P5mH5+qWK0CZr2CdDnWKn8wG+6pmO1XKF0UZgTTWDvxmLVu5K0dhoYfvZx4qOT 7Q51++Oe/EIAOXzw+Au/4b7zvCLBRMq4Zi794A06y17q3KZTyt6VQVZmcD9gW+qJtvR/ Fz0g== X-Gm-Message-State: ACrzQf31UKXo66ohpKOTSpIq40oS7o+Q7EPT+y8kp05VP60b+hQ3F6N4 Ob8zVJRvEKXrjBmnZ/eutR4= X-Received: by 2002:a5d:5a82:0:b0:224:f744:1799 with SMTP id bp2-20020a5d5a82000000b00224f7441799mr18328050wrb.582.1666535614087; Sun, 23 Oct 2022 07:33:34 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id iv13-20020a05600c548d00b003b4fdbb6319sm5679489wmb.21.2022.10.23.07.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:33:33 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/9] ASoC: jz4740-i2s: Convert to regmap API Date: Sun, 23 Oct 2022 15:33:21 +0100 Message-Id: <20221023143328.160866-3-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> References: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747489387616961672?= X-GMAIL-MSGID: =?utf-8?q?1747489387616961672?= Using regmap for accessing the AIC registers makes the driver a little easier to read, and later refactors can take advantage of regmap APIs to further simplify the driver. Reviewed-by: Paul Cercueil Signed-off-by: Aidan MacDonald --- sound/soc/jz4740/Kconfig | 1 + sound/soc/jz4740/jz4740-i2s.c | 106 ++++++++++++---------------------- 2 files changed, 39 insertions(+), 68 deletions(-) diff --git a/sound/soc/jz4740/Kconfig b/sound/soc/jz4740/Kconfig index e72f826062e9..dd3b4507fbe6 100644 --- a/sound/soc/jz4740/Kconfig +++ b/sound/soc/jz4740/Kconfig @@ -3,6 +3,7 @@ config SND_JZ4740_SOC_I2S tristate "SoC Audio (I2S protocol) for Ingenic JZ4740 SoC" depends on MIPS || COMPILE_TEST depends on HAS_IOMEM + select REGMAP_MMIO select SND_SOC_GENERIC_DMAENGINE_PCM help Say Y if you want to use I2S protocol and I2S codec on Ingenic JZ4740 diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index 83cb81999c6f..f3c0d7c0415e 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -96,7 +97,7 @@ struct i2s_soc_info { }; struct jz4740_i2s { - void __iomem *base; + struct regmap *regmap; struct clk *clk_aic; struct clk *clk_i2s; @@ -107,31 +108,10 @@ struct jz4740_i2s { const struct i2s_soc_info *soc_info; }; -static inline uint32_t jz4740_i2s_read(const struct jz4740_i2s *i2s, - unsigned int reg) -{ - return readl(i2s->base + reg); -} - -static inline void jz4740_i2s_write(const struct jz4740_i2s *i2s, - unsigned int reg, uint32_t value) -{ - writel(value, i2s->base + reg); -} - -static inline void jz4740_i2s_set_bits(const struct jz4740_i2s *i2s, - unsigned int reg, uint32_t bits) -{ - uint32_t value = jz4740_i2s_read(i2s, reg); - value |= bits; - jz4740_i2s_write(i2s, reg, value); -} - static int jz4740_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); - uint32_t conf; int ret; /* @@ -141,9 +121,9 @@ static int jz4740_i2s_startup(struct snd_pcm_substream *substream, */ if (!i2s->soc_info->shared_fifo_flush) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - jz4740_i2s_set_bits(i2s, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_TFLUSH); + regmap_set_bits(i2s->regmap, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_TFLUSH); else - jz4740_i2s_set_bits(i2s, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_RFLUSH); + regmap_set_bits(i2s->regmap, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_RFLUSH); } if (snd_soc_dai_active(dai)) @@ -156,16 +136,13 @@ static int jz4740_i2s_startup(struct snd_pcm_substream *substream, * guard this behind the snd_soc_dai_active() check. */ if (i2s->soc_info->shared_fifo_flush) - jz4740_i2s_set_bits(i2s, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_TFLUSH); + regmap_set_bits(i2s->regmap, JZ_REG_AIC_CTRL, JZ_AIC_CTRL_TFLUSH); ret = clk_prepare_enable(i2s->clk_i2s); if (ret) return ret; - conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); - conf |= JZ_AIC_CONF_ENABLE; - jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf); - + regmap_set_bits(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_ENABLE); return 0; } @@ -173,14 +150,11 @@ static void jz4740_i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); - uint32_t conf; if (snd_soc_dai_active(dai)) return; - conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); - conf &= ~JZ_AIC_CONF_ENABLE; - jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf); + regmap_clear_bits(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_ENABLE); clk_disable_unprepare(i2s->clk_i2s); } @@ -189,8 +163,6 @@ static int jz4740_i2s_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); - - uint32_t ctrl; uint32_t mask; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) @@ -198,38 +170,30 @@ static int jz4740_i2s_trigger(struct snd_pcm_substream *substream, int cmd, else mask = JZ_AIC_CTRL_ENABLE_CAPTURE | JZ_AIC_CTRL_ENABLE_RX_DMA; - ctrl = jz4740_i2s_read(i2s, JZ_REG_AIC_CTRL); - switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - ctrl |= mask; + regmap_set_bits(i2s->regmap, JZ_REG_AIC_CTRL, mask); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - ctrl &= ~mask; + regmap_clear_bits(i2s->regmap, JZ_REG_AIC_CTRL, mask); break; default: return -EINVAL; } - jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl); - return 0; } static int jz4740_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); - - uint32_t format = 0; - uint32_t conf; - - conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); - - conf &= ~(JZ_AIC_CONF_BIT_CLK_MASTER | JZ_AIC_CONF_SYNC_CLK_MASTER); + const unsigned int conf_mask = JZ_AIC_CONF_BIT_CLK_MASTER | + JZ_AIC_CONF_SYNC_CLK_MASTER; + unsigned int conf = 0, format = 0; switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { case SND_SOC_DAIFMT_BP_FP: @@ -265,8 +229,8 @@ static int jz4740_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf); - jz4740_i2s_write(i2s, JZ_REG_AIC_I2S_FMT, format); + regmap_update_bits(i2s->regmap, JZ_REG_AIC_CONF, conf_mask, conf); + regmap_write(i2s->regmap, JZ_REG_AIC_I2S_FMT, format); return 0; } @@ -279,9 +243,9 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, uint32_t ctrl, div_reg; int div; - ctrl = jz4740_i2s_read(i2s, JZ_REG_AIC_CTRL); + regmap_read(i2s->regmap, JZ_REG_AIC_CTRL, &ctrl); + regmap_read(i2s->regmap, JZ_REG_AIC_CLK_DIV, &div_reg); - div_reg = jz4740_i2s_read(i2s, JZ_REG_AIC_CLK_DIV); div = clk_get_rate(i2s->clk_i2s) / (64 * params_rate(params)); switch (params_format(params)) { @@ -318,8 +282,8 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, } } - jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl); - jz4740_i2s_write(i2s, JZ_REG_AIC_CLK_DIV, div_reg); + regmap_write(i2s->regmap, JZ_REG_AIC_CTRL, ctrl); + regmap_write(i2s->regmap, JZ_REG_AIC_CLK_DIV, div_reg); return 0; } @@ -356,13 +320,9 @@ static int jz4740_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, static int jz4740_i2s_suspend(struct snd_soc_component *component) { struct jz4740_i2s *i2s = snd_soc_component_get_drvdata(component); - uint32_t conf; if (snd_soc_component_active(component)) { - conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); - conf &= ~JZ_AIC_CONF_ENABLE; - jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf); - + regmap_clear_bits(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_ENABLE); clk_disable_unprepare(i2s->clk_i2s); } @@ -374,7 +334,6 @@ static int jz4740_i2s_suspend(struct snd_soc_component *component) static int jz4740_i2s_resume(struct snd_soc_component *component) { struct jz4740_i2s *i2s = snd_soc_component_get_drvdata(component); - uint32_t conf; int ret; ret = clk_prepare_enable(i2s->clk_aic); @@ -388,9 +347,7 @@ static int jz4740_i2s_resume(struct snd_soc_component *component) return ret; } - conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); - conf |= JZ_AIC_CONF_ENABLE; - jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf); + regmap_set_bits(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_ENABLE); } return 0; @@ -423,8 +380,8 @@ static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) JZ_AIC_CONF_INTERNAL_CODEC; } - jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, JZ_AIC_CONF_RESET); - jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf); + regmap_write(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_RESET); + regmap_write(i2s->regmap, JZ_REG_AIC_CONF, conf); return 0; } @@ -523,11 +480,19 @@ static const struct of_device_id jz4740_of_matches[] = { }; MODULE_DEVICE_TABLE(of, jz4740_of_matches); +static const struct regmap_config jz4740_i2s_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = JZ_REG_AIC_FIFO, +}; + static int jz4740_i2s_dev_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct jz4740_i2s *i2s; struct resource *mem; + void __iomem *regs; int ret; i2s = devm_kzalloc(dev, sizeof(*i2s), GFP_KERNEL); @@ -536,9 +501,9 @@ static int jz4740_i2s_dev_probe(struct platform_device *pdev) i2s->soc_info = device_get_match_data(dev); - i2s->base = devm_platform_get_and_ioremap_resource(pdev, 0, &mem); - if (IS_ERR(i2s->base)) - return PTR_ERR(i2s->base); + regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem); + if (IS_ERR(regs)) + return PTR_ERR(regs); i2s->playback_dma_data.maxburst = 16; i2s->playback_dma_data.addr = mem->start + JZ_REG_AIC_FIFO; @@ -554,6 +519,11 @@ static int jz4740_i2s_dev_probe(struct platform_device *pdev) if (IS_ERR(i2s->clk_i2s)) return PTR_ERR(i2s->clk_i2s); + i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs, + &jz4740_i2s_regmap_config); + if (IS_ERR(i2s->regmap)) + return PTR_ERR(i2s->regmap); + platform_set_drvdata(pdev, i2s); ret = devm_snd_soc_register_component(dev, &jz4740_i2s_component, From patchwork Sun Oct 23 14:33:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 8039 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp17639wru; Sun, 23 Oct 2022 07:36:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7t0ecrUNUuNhcziR/EQvfqxn3EOUoTOye1VNTX+AdRR2CfVU40BUK92VDRZMmYWJd6aM4B X-Received: by 2002:a17:90b:2752:b0:20d:6790:19fb with SMTP id qi18-20020a17090b275200b0020d679019fbmr70108048pjb.117.1666535762691; Sun, 23 Oct 2022 07:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666535762; cv=none; d=google.com; s=arc-20160816; b=WxlbYXOaKVRtUZrAVQd5D7Xc/krMPJGIoYOLCbOR5J4VdmeNhCl7FzuKTlLhthz3A9 o41mbLxMxNEyIfxIGY9iKVt8I7gocqdFwylnWZBJxKFChwNRIasLp4yPmoW6Mq40CzN2 aquCsdugASUrljwfiD7kIn0z31+rKRDyQIU34FhPyFI3C1pwwDpVywxzled5+yljgWa+ UWw75N4P86GpHGxBNcGuC6JIchoRwA3aBZTAbxEWqhwNYSOGGXcX2Hy02Q5IqLJQYY45 kyO8sIP914JEMGG0MOj3RKW1l65QfbhOV24M+rdBo8Cf3f8oW+2gmZC6Xsnpil9LesH5 YN8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5HhPHTWcHqQfajKCJskET6/mbnRPhMXC0Dz2f8v2WQ8=; b=1AGuv2I709uY15Qq10tn66inkuZ1dM5re0pcuAsdawMeIUP1qr6QtcyyPb56oSOw8O dp8ZEL/K3uW4DvOuehRzK5wFePGLUI1z2AVKwHuSzMJ5XaFR9dUy2mn3Y4XS5IhzDqmB slqUpdSVncp4Fllw0PInBv4UXt5jqJMEN2FWGtLdSjPlwC7FDlcowGr2G57ne8rsyQ2Y mJ8Rbd3P7VI45sLj8ijWtV48aEe68xv5UgEYLO1HOLojcYC57tLbXNgLjlqafH2oxoH+ xpopSmd9EQBEaD59WvOD3HB3j1B9oCS7V68V+6GyQmg505xLj9al+juJ/sHVfeyVvozk PvkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gZVaHBh0; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 37-20020a630d65000000b0046b15902616si34485920pgn.270.2022.10.23.07.35.50; Sun, 23 Oct 2022 07:36:02 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=gZVaHBh0; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbiJWOdr (ORCPT + 99 others); Sun, 23 Oct 2022 10:33:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbiJWOdi (ORCPT ); Sun, 23 Oct 2022 10:33:38 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1794F61B3C; Sun, 23 Oct 2022 07:33:37 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id y16so1375858wrt.12; Sun, 23 Oct 2022 07:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5HhPHTWcHqQfajKCJskET6/mbnRPhMXC0Dz2f8v2WQ8=; b=gZVaHBh04DZfb/qmfq7dwyr3qKuZOs3FQOdn9ZxMeL0bFlstSXmMgTqGrszNWqScs8 XyZj/nZ+u6kwuC7N60JXVy1HnMj9hDESqtxNQu6bhev4t1GcMK9FTCf2FFh9BgKzKEhb bl2T5uWN2YAK+0McuL2QWTbOtSNTCrFklPmdsmtCe8Gc9DfneYmR2B1a+bRrwiSc5J87 bqBWkAe8quWpINKv59yMg/bINYY07bWUIiyZbFE/MYIZKexTzKl5bThbTnUKDRiTA7I8 W7NDrgfJJgBMQ5hynFGqe6pJWAtlvLXROqxwPKO0Gn72d01Nm5qeuKDKxab1msPS0kSK r7Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5HhPHTWcHqQfajKCJskET6/mbnRPhMXC0Dz2f8v2WQ8=; b=DG4RduUOaha5JqAW5yjfNfYqFx8/q924QW+b4z5XU2U7RDV44035vGwaGg9Op/zbcm ufBbgA33Eq+SfVNxH0ymDsfa2CpFgUDOAmMudYuaMfnF+CLNq0DiRQkhUa6v8hgbcToQ Lydrw4vHFVPGcYXxLP/XQQeiqLA5jvOwMYfahVW//AwjsGQlXmAhSMOh0r2jG/OMvN8S uHltReTYReQj57WGr2T8sBAYsd2qBSXJnwTuwGhuQWi4VdzW2BZjO6FOhfFtZoyrWIgp 2/GTMf2oBp4b7o3KqrxluOzhZx2QP5DT+zJbdMCrmtMPEQ4/RwKcqyp8e7H6nELVTEZz h88g== X-Gm-Message-State: ACrzQf0U/lcjUV1/Fd8LRJ4SMdmxTCYPSb1dilwdyAdaxsqJ1xfIhEh2 fkZ8Q01oT4PqpSRL3cjTuaM= X-Received: by 2002:a05:6000:1446:b0:22f:5e89:d9de with SMTP id v6-20020a056000144600b0022f5e89d9demr18431864wrx.106.1666535615357; Sun, 23 Oct 2022 07:33:35 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id j11-20020a05600c190b00b003b47e8a5d22sm5603903wmq.23.2022.10.23.07.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:33:34 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 3/9] ASoC: jz4740-i2s: Simplify using regmap fields Date: Sun, 23 Oct 2022 15:33:22 +0100 Message-Id: <20221023143328.160866-4-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> References: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747489403759578626?= X-GMAIL-MSGID: =?utf-8?q?1747489403759578626?= The differences between register fields on different SoC versions can be abstracted away using the regmap field API. This is easier to understand and extend than comparisons based on the version ID. Since the version IDs are unused after this change, remove them at the same time, and remove unused macros. Reviewed-by: Paul Cercueil Signed-off-by: Aidan MacDonald --- sound/soc/jz4740/jz4740-i2s.c | 135 +++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 58 deletions(-) diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index f3c0d7c0415e..b0bbcd025241 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -34,8 +34,6 @@ #define JZ_REG_AIC_CLK_DIV 0x30 #define JZ_REG_AIC_FIFO 0x34 -#define JZ_AIC_CONF_FIFO_RX_THRESHOLD_MASK (0xf << 12) -#define JZ_AIC_CONF_FIFO_TX_THRESHOLD_MASK (0xf << 8) #define JZ_AIC_CONF_OVERFLOW_PLAY_LAST BIT(6) #define JZ_AIC_CONF_INTERNAL_CODEC BIT(5) #define JZ_AIC_CONF_I2S BIT(4) @@ -44,11 +42,6 @@ #define JZ_AIC_CONF_SYNC_CLK_MASTER BIT(1) #define JZ_AIC_CONF_ENABLE BIT(0) -#define JZ_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET 12 -#define JZ_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET 8 -#define JZ4760_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET 24 -#define JZ4760_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET 16 - #define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK (0x7 << 19) #define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK (0x7 << 16) #define JZ_AIC_CTRL_ENABLE_RX_DMA BIT(15) @@ -76,29 +69,25 @@ #define JZ_AIC_I2S_STATUS_BUSY BIT(2) -#define JZ_AIC_CLK_DIV_MASK 0xf -#define I2SDIV_DV_SHIFT 0 -#define I2SDIV_DV_MASK (0xf << I2SDIV_DV_SHIFT) -#define I2SDIV_IDV_SHIFT 8 -#define I2SDIV_IDV_MASK (0xf << I2SDIV_IDV_SHIFT) - -enum jz47xx_i2s_version { - JZ_I2S_JZ4740, - JZ_I2S_JZ4760, - JZ_I2S_JZ4770, - JZ_I2S_JZ4780, -}; - struct i2s_soc_info { - enum jz47xx_i2s_version version; struct snd_soc_dai_driver *dai; + struct reg_field field_rx_fifo_thresh; + struct reg_field field_tx_fifo_thresh; + struct reg_field field_i2sdiv_capture; + struct reg_field field_i2sdiv_playback; + bool shared_fifo_flush; }; struct jz4740_i2s { struct regmap *regmap; + struct regmap_field *field_rx_fifo_thresh; + struct regmap_field *field_tx_fifo_thresh; + struct regmap_field *field_i2sdiv_capture; + struct regmap_field *field_i2sdiv_playback; + struct clk *clk_aic; struct clk *clk_i2s; @@ -239,12 +228,12 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); + struct regmap_field *div_field; unsigned int sample_size; - uint32_t ctrl, div_reg; + uint32_t ctrl; int div; regmap_read(i2s->regmap, JZ_REG_AIC_CTRL, &ctrl); - regmap_read(i2s->regmap, JZ_REG_AIC_CLK_DIV, &div_reg); div = clk_get_rate(i2s->clk_i2s) / (64 * params_rate(params)); @@ -267,23 +256,16 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, else ctrl &= ~JZ_AIC_CTRL_MONO_TO_STEREO; - div_reg &= ~I2SDIV_DV_MASK; - div_reg |= (div - 1) << I2SDIV_DV_SHIFT; + div_field = i2s->field_i2sdiv_playback; } else { ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK; ctrl |= sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET; - if (i2s->soc_info->version >= JZ_I2S_JZ4770) { - div_reg &= ~I2SDIV_IDV_MASK; - div_reg |= (div - 1) << I2SDIV_IDV_SHIFT; - } else { - div_reg &= ~I2SDIV_DV_MASK; - div_reg |= (div - 1) << I2SDIV_DV_SHIFT; - } + div_field = i2s->field_i2sdiv_capture; } regmap_write(i2s->regmap, JZ_REG_AIC_CTRL, ctrl); - regmap_write(i2s->regmap, JZ_REG_AIC_CLK_DIV, div_reg); + regmap_field_write(div_field, div - 1); return 0; } @@ -356,7 +338,6 @@ static int jz4740_i2s_resume(struct snd_soc_component *component) static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); - uint32_t conf; int ret; ret = clk_prepare_enable(i2s->clk_aic); @@ -366,22 +347,14 @@ static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data, &i2s->capture_dma_data); - if (i2s->soc_info->version >= JZ_I2S_JZ4760) { - conf = (7 << JZ4760_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET) | - (8 << JZ4760_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET) | - JZ_AIC_CONF_OVERFLOW_PLAY_LAST | - JZ_AIC_CONF_I2S | - JZ_AIC_CONF_INTERNAL_CODEC; - } else { - conf = (7 << JZ_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET) | - (8 << JZ_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET) | - JZ_AIC_CONF_OVERFLOW_PLAY_LAST | - JZ_AIC_CONF_I2S | - JZ_AIC_CONF_INTERNAL_CODEC; - } - regmap_write(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_RESET); - regmap_write(i2s->regmap, JZ_REG_AIC_CONF, conf); + + 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; } @@ -426,14 +399,20 @@ static struct snd_soc_dai_driver jz4740_i2s_dai = { }; static const struct i2s_soc_info jz4740_i2s_soc_info = { - .version = JZ_I2S_JZ4740, - .dai = &jz4740_i2s_dai, - .shared_fifo_flush = true, + .dai = &jz4740_i2s_dai, + .field_rx_fifo_thresh = REG_FIELD(JZ_REG_AIC_CONF, 12, 15), + .field_tx_fifo_thresh = REG_FIELD(JZ_REG_AIC_CONF, 8, 11), + .field_i2sdiv_capture = REG_FIELD(JZ_REG_AIC_CLK_DIV, 0, 3), + .field_i2sdiv_playback = REG_FIELD(JZ_REG_AIC_CLK_DIV, 0, 3), + .shared_fifo_flush = true, }; static const struct i2s_soc_info jz4760_i2s_soc_info = { - .version = JZ_I2S_JZ4760, - .dai = &jz4740_i2s_dai, + .dai = &jz4740_i2s_dai, + .field_rx_fifo_thresh = REG_FIELD(JZ_REG_AIC_CONF, 24, 27), + .field_tx_fifo_thresh = REG_FIELD(JZ_REG_AIC_CONF, 16, 20), + .field_i2sdiv_capture = REG_FIELD(JZ_REG_AIC_CLK_DIV, 0, 3), + .field_i2sdiv_playback = REG_FIELD(JZ_REG_AIC_CLK_DIV, 0, 3), }; static struct snd_soc_dai_driver jz4770_i2s_dai = { @@ -455,13 +434,19 @@ static struct snd_soc_dai_driver jz4770_i2s_dai = { }; static const struct i2s_soc_info jz4770_i2s_soc_info = { - .version = JZ_I2S_JZ4770, - .dai = &jz4770_i2s_dai, + .dai = &jz4770_i2s_dai, + .field_rx_fifo_thresh = REG_FIELD(JZ_REG_AIC_CONF, 24, 27), + .field_tx_fifo_thresh = REG_FIELD(JZ_REG_AIC_CONF, 16, 20), + .field_i2sdiv_capture = REG_FIELD(JZ_REG_AIC_CLK_DIV, 8, 11), + .field_i2sdiv_playback = REG_FIELD(JZ_REG_AIC_CLK_DIV, 0, 3), }; static const struct i2s_soc_info jz4780_i2s_soc_info = { - .version = JZ_I2S_JZ4780, - .dai = &jz4770_i2s_dai, + .dai = &jz4770_i2s_dai, + .field_rx_fifo_thresh = REG_FIELD(JZ_REG_AIC_CONF, 24, 27), + .field_tx_fifo_thresh = REG_FIELD(JZ_REG_AIC_CONF, 16, 20), + .field_i2sdiv_capture = REG_FIELD(JZ_REG_AIC_CLK_DIV, 8, 11), + .field_i2sdiv_playback = REG_FIELD(JZ_REG_AIC_CLK_DIV, 0, 3), }; static const struct snd_soc_component_driver jz4740_i2s_component = { @@ -480,6 +465,36 @@ static const struct of_device_id jz4740_of_matches[] = { }; MODULE_DEVICE_TABLE(of, jz4740_of_matches); +static int jz4740_i2s_init_regmap_fields(struct device *dev, + struct jz4740_i2s *i2s) +{ + i2s->field_rx_fifo_thresh = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->soc_info->field_rx_fifo_thresh); + if (IS_ERR(i2s->field_rx_fifo_thresh)) + return PTR_ERR(i2s->field_rx_fifo_thresh); + + i2s->field_tx_fifo_thresh = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->soc_info->field_tx_fifo_thresh); + if (IS_ERR(i2s->field_tx_fifo_thresh)) + return PTR_ERR(i2s->field_tx_fifo_thresh); + + i2s->field_i2sdiv_capture = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->soc_info->field_i2sdiv_capture); + if (IS_ERR(i2s->field_i2sdiv_capture)) + return PTR_ERR(i2s->field_i2sdiv_capture); + + i2s->field_i2sdiv_playback = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->soc_info->field_i2sdiv_playback); + if (IS_ERR(i2s->field_i2sdiv_playback)) + return PTR_ERR(i2s->field_i2sdiv_playback); + + return 0; +} + static const struct regmap_config jz4740_i2s_regmap_config = { .reg_bits = 32, .reg_stride = 4, @@ -524,6 +539,10 @@ static int jz4740_i2s_dev_probe(struct platform_device *pdev) if (IS_ERR(i2s->regmap)) return PTR_ERR(i2s->regmap); + ret = jz4740_i2s_init_regmap_fields(dev, i2s); + if (ret) + return ret; + platform_set_drvdata(pdev, i2s); ret = devm_snd_soc_register_component(dev, &jz4740_i2s_component, From patchwork Sun Oct 23 14:33:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 8038 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp17621wru; Sun, 23 Oct 2022 07:36:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nl6XQt+ny+OY5hGt9ugWUpFzCbAM8Lu9XYjrgkB3of+nz6D8Xg6V6J8FyU/tA3h5yqf3g X-Received: by 2002:a17:902:b601:b0:186:9f20:f6a4 with SMTP id b1-20020a170902b60100b001869f20f6a4mr2862107pls.38.1666535759852; Sun, 23 Oct 2022 07:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666535759; cv=none; d=google.com; s=arc-20160816; b=dxCY1Yq6IRQE6wcjSeVxtpbNsFMPLRIrUsQ/1BThEk5TRJOA3jmaBYg/G8xGStVia2 YZIDPN7s74RXtzhnZWlczmRfOnqmHmw3qU0Hg6tCHwLJ/0IMdGfhDzBb+7UC3KwlVgJu j8nCJpmnch+XDdS8L9soeGQAyO/g5sNDZ/xiYzeYauizFFmirGqfHTSDGQDApzORP5U1 8yKhrTMRiQ1fmtUlHH30LzMHU8Ied1Yyu8m8vvtws8dwHIHC/ThrUquZKcGdoR8CBlev +tAI7qO38Al9UdDR7A/bdIJESfGX+i4rqRw5PUrLfjJVymwD6hYb7527+LfXD6TLK+ew GrHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yagE6PfAWV1c7o+BEcxE7EzZidDlQUomGLf1in/WfkM=; b=1ElXbrg1aJDf/sL1QEwM0IhtVW5aNfg4n/j0eBPRDlHEhMW2lw8hKUDtm98oQ2s7O0 1S4bAjkMSEYFyysAVdPOn/I58s5tW+zZ/TZy77NCPgO1trRndDE42AbGZceuVnBWdnfv VIHgKgItraCDriitTKjTEtbweOSnxY0YeXIRQAx05Av9+NO6LbJPin2EEtfUvvah2fp3 gHAHajW/WwMpBRpfvy/i+QSWZsO5fVGidaETiifHxIorRnHFfCrluk0Wwo3gozay0Mcv KUnNzI1xXorw0t8gfvsxcQ7TYF61nocJ0PZDlC3saJzK/kiYpW+vX6Pk/KDGWW0Ct2MW qGsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Zy8H6eKZ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a12-20020a170902900c00b00186abd0c784si31344plp.217.2022.10.23.07.35.46; Sun, 23 Oct 2022 07:35:59 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=Zy8H6eKZ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229707AbiJWOdo (ORCPT + 99 others); Sun, 23 Oct 2022 10:33:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230216AbiJWOdi (ORCPT ); Sun, 23 Oct 2022 10:33:38 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 143F061B39; Sun, 23 Oct 2022 07:33:37 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bu30so11848062wrb.8; Sun, 23 Oct 2022 07:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yagE6PfAWV1c7o+BEcxE7EzZidDlQUomGLf1in/WfkM=; b=Zy8H6eKZB+FQ4I7VGkb+tY3m9TLER0iULJcO2taPxrxxwuUJaQLZ/wez+a11a5aZCZ sCV/ScsX03su9YQBJwbBw9XCFOnpkeHtDGPqSQ3GVWi02F4V7jFRDkkejzug5nlDOsFq Td1DG19OibxKTK52pcQyysCuqlFz05kzHv0iT7ufJERlUd36HZwQTGRPpgTxS1GrLl8U U+KXZQPew75mQKQ+R0yZ7hiv1/QuePiZI4ol59bRHJ+IXXf8fYMrk/tAQKXns0Zk3IWJ bvWL23Ife3D39mF/Nl+KVWbfUcLIm7GRSY+UcG+AcaTYgHrUYSGwzpFL9nECiQG6mum7 dZTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yagE6PfAWV1c7o+BEcxE7EzZidDlQUomGLf1in/WfkM=; b=gCz8SpKQgJ3NyXutPuCX6YzI+5Xc7Rvjjl5lXNtwRP9jDL+n3QuOuiW9GrakP/TSSv FgdNOhEm/qSZt0SqQfgCMYgI2xdyN0aFL1nk1fe2f2vkYhCaVmNILaG3Aqwa4oQ/Zymj KMb3vwfI34j8esSHDSRgH++G7gpNc0qVwPgySkrVnQvSvoInkMnBOMLjQqpIH2uN2Frj Iz7JF1qt6zAGSh4BCB8tZNG3vslGUY2y9m+/GUNBwiYbI6EjPPYoVudr8TcP4vLgV+v2 H0AuVIBn+f6+rZ0uqNVf3XSxqhEh5mld4dLuXPaPQ+06Tf4t9Ko5zRCmfguUOKGAA5KC 1/nA== X-Gm-Message-State: ACrzQf2JiBTuN1fCmX15W679V2vMBVv2jdP8fVOtbogKCeG1z7byk/3b W7PxOoU+HTVxjnXhJAnd+ew= X-Received: by 2002:a05:6000:50a:b0:225:210c:a7e4 with SMTP id a10-20020a056000050a00b00225210ca7e4mr18207884wrf.704.1666535616636; Sun, 23 Oct 2022 07:33:36 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id c17-20020a5d4cd1000000b002362f6fcaf5sm2925381wrt.48.2022.10.23.07.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:33:36 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/9] ASoC: jz4740-i2s: Use FIELD_PREP() macros in hw_params callback Date: Sun, 23 Oct 2022 15:33:23 +0100 Message-Id: <20221023143328.160866-5-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> References: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747489400830851248?= X-GMAIL-MSGID: =?utf-8?q?1747489400830851248?= Get rid of a couple of macros and improve readability by using FIELD_PREP() and GENMASK() for the sample size setting. Acked-by: Paul Cercueil Reviewed-by: Paul Cercueil Signed-off-by: Aidan MacDonald --- sound/soc/jz4740/jz4740-i2s.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index b0bbcd025241..4767abea425f 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -3,6 +3,7 @@ * Copyright (C) 2010, Lars-Peter Clausen */ +#include #include #include #include @@ -42,8 +43,8 @@ #define JZ_AIC_CONF_SYNC_CLK_MASTER BIT(1) #define JZ_AIC_CONF_ENABLE BIT(0) -#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK (0x7 << 19) -#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK (0x7 << 16) +#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE GENMASK(21, 19) +#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE GENMASK(18, 16) #define JZ_AIC_CTRL_ENABLE_RX_DMA BIT(15) #define JZ_AIC_CTRL_ENABLE_TX_DMA BIT(14) #define JZ_AIC_CTRL_MONO_TO_STEREO BIT(11) @@ -59,9 +60,6 @@ #define JZ_AIC_CTRL_ENABLE_PLAYBACK BIT(1) #define JZ_AIC_CTRL_ENABLE_CAPTURE BIT(0) -#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET 19 -#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET 16 - #define JZ_AIC_I2S_FMT_DISABLE_BIT_CLK BIT(12) #define JZ_AIC_I2S_FMT_DISABLE_BIT_ICLK BIT(13) #define JZ_AIC_I2S_FMT_ENABLE_SYS_CLK BIT(4) @@ -249,8 +247,9 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ctrl &= ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK; - ctrl |= sample_size << JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET; + ctrl &= ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE; + ctrl |= FIELD_PREP(JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE, sample_size); + if (params_channels(params) == 1) ctrl |= JZ_AIC_CTRL_MONO_TO_STEREO; else @@ -258,8 +257,8 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, div_field = i2s->field_i2sdiv_playback; } else { - ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK; - ctrl |= sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET; + ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE; + ctrl |= FIELD_PREP(JZ_AIC_CTRL_INPUT_SAMPLE_SIZE, sample_size); div_field = i2s->field_i2sdiv_capture; } From patchwork Sun Oct 23 14:33:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 8033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp17270wru; Sun, 23 Oct 2022 07:35:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7vWQ96Qi0bxalyy/cBhDnWz/Q9dUr3bBQn1++fnn1QK6gAM+8CbC7Qza3qt+Ra3wtyic49 X-Received: by 2002:a65:6ccd:0:b0:439:2033:6ee with SMTP id g13-20020a656ccd000000b00439203306eemr24869753pgw.271.1666535706361; Sun, 23 Oct 2022 07:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666535706; cv=none; d=google.com; s=arc-20160816; b=QjGVm7Lf2rFP+suCMFErMBwL8mpt34a3VbxJyvcZCXplVWA6LwQjDkYapYfhoPFawm Vv+5ipEdZPS3AggfiopdUv8uTS4P6LvgebjUnURQkdqJcTlknoK5nS95q89OTUErbGGN qy6OfnbW7vsjlOaw5YvpeL5UFoTk1CPfzBk1m8tfKrTtUHSZqB9wgA4czUyC+ZIi2CM4 MLIjjXGLTxMrxRqeCvdpdRaxaTabe6o3OcHeWElIye3aXDNqDlKPTCpvn/4olNFKiC+W EHJIG62mM8OwzRUPGXN/9Vh8OqdovnBnYOTzGzFMuJ9qLFk358lPz1WCFJXD5EuZxIcl KWDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZPVuUDMde4iT9AFYS7nsIkkUonhoCr0Fb8M7bh3R14c=; b=t9qmkPrrOu5yV1t82cd6AKiY2aDGsorZEDAiAtFR6SdydAptwxL9ZDH7ijTNAmpCd5 X8vJVcUzKnhpf/5uZ6oPdLJbPWdQe9fOtouDBdDA/dp3QO+w5Z5t2pw0fN8CSxcoaBNw J6ZdrJtV9n6YEFH7z7mj+htLGe3JZnk4SxjsNs93BzwyiGH3apeG/jCWLLnQ5UwScsp7 ZL2E2qOsduUXPRgT8urr5eu/L1E4bVW7c5aQmTlmSzX33WKpjSTusMpGWB0FTIVqd/jm VdC4zNfnZ3uojl1uhFik5mQdTjz9Q0ZLh02OSXs8tQKRBCCX6NUsX+YZSgqBdKUNn+vZ Uhdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=axlbN88z; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a17090a2c0600b00212fa424170si2838815pjd.130.2022.10.23.07.34.53; Sun, 23 Oct 2022 07:35:06 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=axlbN88z; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbiJWOdw (ORCPT + 99 others); Sun, 23 Oct 2022 10:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230226AbiJWOdj (ORCPT ); Sun, 23 Oct 2022 10:33:39 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47B2D61D4B; Sun, 23 Oct 2022 07:33:38 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id v1so11821505wrt.11; Sun, 23 Oct 2022 07:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZPVuUDMde4iT9AFYS7nsIkkUonhoCr0Fb8M7bh3R14c=; b=axlbN88z42NeyE9gww1dFYP+qpXMECN3tXcq/dmWjoR7QBfnKv8sAf7zy6oqZpkGJK fS4+Fb50bYSBaJxYSKsFYgh6aOqJBl2eVfDlQxFg3nygMMN0zpLGY1NH6v+9ueEaObih GvRXstIvxK22ja+OuKvM1KszAOLGI+ffJD8Tn4X42APvrxRqo1ARkmLdNXpWFktwYbuy ivWm8xJFmcZB0aSorqYMakPU3QnEtZ3G4M8Pq7gdiLFMVGI/H2mEH6C5SFAuekUQ7sam we+cvj4ThPxB70kRh+LNxFGkWga0SHGP0txJVZIICeo648JL0fWxzgZ/6ZFBdLwRaqis licw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZPVuUDMde4iT9AFYS7nsIkkUonhoCr0Fb8M7bh3R14c=; b=kRsqrprjDH6Q/W7y07UaYsd0SVBkwZS39J9XGFM0VxgCilMrt5W9S5IPNySG/tY+DS 7/TEqpxNZL5ZmS7wq8o3j0XGm86sD4MmkQIJu4J24sIE6xq2tJSHHAY2BJEktPyDsop0 z+KSy0fGFq1xKT2QpmzgcHi50fpVKu7riMwxT6MIPBjWxVksZyeX0Nznvu/PVyo8noAS mkMI1+2wjUke0C3diTdGy4iFZnZqZ6IcNzUv23utl5gcIcPYooSzfaMhMEEsWk+8qCIP mM1cJE2qY+MReRTKY571J06adCOh6LTxA1nvONwHXmMjGpehyXr6AN9e85ZdqsDO7uML S3Zg== X-Gm-Message-State: ACrzQf27TuyJBLRdPC1mloGrLwyfOfMZvA5voWKyEL6dvB93aVrDSxPr oWzf/xXXlTLwF6Q1Lhw3410= X-Received: by 2002:a5d:42c5:0:b0:236:60ed:9abf with SMTP id t5-20020a5d42c5000000b0023660ed9abfmr4416189wrr.454.1666535617850; Sun, 23 Oct 2022 07:33:37 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id hg16-20020a05600c539000b003c6b70a4d69sm8300046wmb.42.2022.10.23.07.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:33:37 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 5/9] ASoC: jz4740-i2s: Align macro values and sort includes Date: Sun, 23 Oct 2022 15:33:24 +0100 Message-Id: <20221023143328.160866-6-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> References: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UPPERCASE_50_75 autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747489345073706465?= X-GMAIL-MSGID: =?utf-8?q?1747489345073706465?= Some purely cosmetic changes: line up all the macro values to make things easier to read and sort the includes alphabetically. Acked-by: Paul Cercueil Signed-off-by: Aidan MacDonald --- sound/soc/jz4740/jz4740-i2s.c | 66 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index 4767abea425f..c3235e993ffb 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -4,6 +4,9 @@ */ #include +#include +#include +#include #include #include #include @@ -13,11 +16,6 @@ #include #include -#include -#include - -#include - #include #include #include @@ -35,37 +33,37 @@ #define JZ_REG_AIC_CLK_DIV 0x30 #define JZ_REG_AIC_FIFO 0x34 -#define JZ_AIC_CONF_OVERFLOW_PLAY_LAST BIT(6) -#define JZ_AIC_CONF_INTERNAL_CODEC BIT(5) -#define JZ_AIC_CONF_I2S BIT(4) -#define JZ_AIC_CONF_RESET BIT(3) -#define JZ_AIC_CONF_BIT_CLK_MASTER BIT(2) -#define JZ_AIC_CONF_SYNC_CLK_MASTER BIT(1) -#define JZ_AIC_CONF_ENABLE BIT(0) - -#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE GENMASK(21, 19) -#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE GENMASK(18, 16) -#define JZ_AIC_CTRL_ENABLE_RX_DMA BIT(15) -#define JZ_AIC_CTRL_ENABLE_TX_DMA BIT(14) -#define JZ_AIC_CTRL_MONO_TO_STEREO BIT(11) -#define JZ_AIC_CTRL_SWITCH_ENDIANNESS BIT(10) -#define JZ_AIC_CTRL_SIGNED_TO_UNSIGNED BIT(9) +#define JZ_AIC_CONF_OVERFLOW_PLAY_LAST BIT(6) +#define JZ_AIC_CONF_INTERNAL_CODEC BIT(5) +#define JZ_AIC_CONF_I2S BIT(4) +#define JZ_AIC_CONF_RESET BIT(3) +#define JZ_AIC_CONF_BIT_CLK_MASTER BIT(2) +#define JZ_AIC_CONF_SYNC_CLK_MASTER BIT(1) +#define JZ_AIC_CONF_ENABLE BIT(0) + +#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE GENMASK(21, 19) +#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE GENMASK(18, 16) +#define JZ_AIC_CTRL_ENABLE_RX_DMA BIT(15) +#define JZ_AIC_CTRL_ENABLE_TX_DMA BIT(14) +#define JZ_AIC_CTRL_MONO_TO_STEREO BIT(11) +#define JZ_AIC_CTRL_SWITCH_ENDIANNESS BIT(10) +#define JZ_AIC_CTRL_SIGNED_TO_UNSIGNED BIT(9) #define JZ_AIC_CTRL_TFLUSH BIT(8) #define JZ_AIC_CTRL_RFLUSH BIT(7) -#define JZ_AIC_CTRL_ENABLE_ROR_INT BIT(6) -#define JZ_AIC_CTRL_ENABLE_TUR_INT BIT(5) -#define JZ_AIC_CTRL_ENABLE_RFS_INT BIT(4) -#define JZ_AIC_CTRL_ENABLE_TFS_INT BIT(3) -#define JZ_AIC_CTRL_ENABLE_LOOPBACK BIT(2) -#define JZ_AIC_CTRL_ENABLE_PLAYBACK BIT(1) -#define JZ_AIC_CTRL_ENABLE_CAPTURE BIT(0) - -#define JZ_AIC_I2S_FMT_DISABLE_BIT_CLK BIT(12) -#define JZ_AIC_I2S_FMT_DISABLE_BIT_ICLK BIT(13) -#define JZ_AIC_I2S_FMT_ENABLE_SYS_CLK BIT(4) -#define JZ_AIC_I2S_FMT_MSB BIT(0) - -#define JZ_AIC_I2S_STATUS_BUSY BIT(2) +#define JZ_AIC_CTRL_ENABLE_ROR_INT BIT(6) +#define JZ_AIC_CTRL_ENABLE_TUR_INT BIT(5) +#define JZ_AIC_CTRL_ENABLE_RFS_INT BIT(4) +#define JZ_AIC_CTRL_ENABLE_TFS_INT BIT(3) +#define JZ_AIC_CTRL_ENABLE_LOOPBACK BIT(2) +#define JZ_AIC_CTRL_ENABLE_PLAYBACK BIT(1) +#define JZ_AIC_CTRL_ENABLE_CAPTURE BIT(0) + +#define JZ_AIC_I2S_FMT_DISABLE_BIT_CLK BIT(12) +#define JZ_AIC_I2S_FMT_DISABLE_BIT_ICLK BIT(13) +#define JZ_AIC_I2S_FMT_ENABLE_SYS_CLK BIT(4) +#define JZ_AIC_I2S_FMT_MSB BIT(0) + +#define JZ_AIC_I2S_STATUS_BUSY BIT(2) struct i2s_soc_info { struct snd_soc_dai_driver *dai; From patchwork Sun Oct 23 14:33:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 8040 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp17774wru; Sun, 23 Oct 2022 07:36:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6c9h2GGeqmoGXdgkEANWu03ho3YNW3hSuprdzIV0y+pg8sb53KPaZhLlpL/a/8pKpYIOM7 X-Received: by 2002:a17:902:b20c:b0:186:6abc:6954 with SMTP id t12-20020a170902b20c00b001866abc6954mr16608329plr.111.1666535779731; Sun, 23 Oct 2022 07:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666535779; cv=none; d=google.com; s=arc-20160816; b=WksVxkICutFXlGg5AyPc1RCgUCmfhywaaYjdcWzQ/1vjzhfto4ZDZr8r9J0wMx/Wdr rKOTBedn6bRQBWX3Hn52EhLfN8Ra2eIyHduzz+sut8f4Iv8R0xZJkyCt9sFja37bwNjv o9mQCh9m5jEZe8Ep8SGwuAEJwkZ3XyJ6O8VtwLD6BpGyvcVdkTbCD47Xx8E1iLeAdQot EI66kNxAr5gJSA5Qagec2+cyALDBOm0R1Wc9hJks4fCIeSdmWpwVIBkzI7lPd9ri1Ivd Bf9qLDlgeg4X/fT1S0F2bdxBVQp/R7uu54VFcv7LRIkjkLdv2kRQGYypnKGOc/+3Tt5v W+FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xgkOKKf/r2OGCWExBVS97xfrlAiQor24qr6UWM7ySCA=; b=X3VKxjask84CYDONyzWjRcNbXRNAKc8/OsoMi3iPdWYWfUAJYKwFirD/Jy+nIJgutI 6fY/sF5VaOfk5JH8p7qhRbWkXJbJVnSfRPVr9trtiNBAdAWaD7/fywK1MhuGqqRpO04S A7f7y8DyTCLf06mnEGrP8XZfhn3SdzjQ57TWn/+PgHEXcdBxa5YFrqnfk/ard6ynM/7P VMBuH0QxKf4lHtncsZWeWOdT6pedReQl8tiUJnTRZsCLoAQ9E94Rf21d9uKOc6al9bZM fy3INGP6D/AuL5bKxKYWkoQuom8bzu8BMxwddGhX1+oYn2soUsONsgKsV2eX0qt1lYuk lmNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d5znD320; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 186-20020a6216c3000000b0053e8d0c9909si217795pfw.221.2022.10.23.07.36.07; Sun, 23 Oct 2022 07:36:19 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=d5znD320; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230311AbiJWOd7 (ORCPT + 99 others); Sun, 23 Oct 2022 10:33:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230258AbiJWOdp (ORCPT ); Sun, 23 Oct 2022 10:33:45 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 861FB61B37; Sun, 23 Oct 2022 07:33:40 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id l14so4849148wrw.2; Sun, 23 Oct 2022 07:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xgkOKKf/r2OGCWExBVS97xfrlAiQor24qr6UWM7ySCA=; b=d5znD320WrBQPpNajiAV1FbaEXpWVRYEuHhL6yMAAcFsweM463/MFJk4or+SFApB8W R3ixebCz8X1OHntpr3Vm7QMSPfrmEnggUU9JJfYAQg5YugGPKFrcnKh0YE9roeMppJhr lRzOBdqBraKyILIm1OebYLb8G6Cqj7U32oXA+lkgB1R9IubrISzsnxT9heUFKhbYkzNf NqcgAxvuzmz1HIDabVBEZt25X8JKO8D1fj5ZK5lO3OrzD/9TPu7bDHskcy68HL8Lj5ev +kZliRjd2mxF5GOuKgmU70wn0aLY1kRFcYfA6Vuxbcq8jVXhKcbuv5GmEDCh3U5Urpkn ElvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xgkOKKf/r2OGCWExBVS97xfrlAiQor24qr6UWM7ySCA=; b=WL/UmEByH2tdEMwacejNvBZ0OiZBkx9fu1aqljM0UTejMwK3E5yhnNuVz48ckHeKH9 3jCMhKrjFBnAIUpZcrmnyWl7GUubj+uoEg0+yzKeP7Ya69pAsBT+L6lLKKwxoBjLjdQB +Jb+0Oae1NDRqCa9AnW4vW3+7n17fZ09zv14WKZZGoMe8m8Rn+ek/rgQhUGlDrkZUCGa yJrIqGVEPs1OvqGQD+pwacUCKTBH9EMC0PGrwdqZs6EcI7m5i53h2J19+Bp9psIP/T8q 8NxLn34lOyKLOfmAas7Kgaaqjl1m2mz3JT+CL5jWxekGWsKOUR4NZ3ckuZf4xDb/ql6I xgbg== X-Gm-Message-State: ACrzQf2SOj28nLpYFBx6jYzzRM7F7ztRVH7v7mYGKW0kVyCH9MMi+QQb ufRdS9oDgdFx9Hm0s0b8Z0K1cbh90FA= X-Received: by 2002:a5d:4bcd:0:b0:236:6b67:a5be with SMTP id l13-20020a5d4bcd000000b002366b67a5bemr1858078wrt.81.1666535619095; Sun, 23 Oct 2022 07:33:39 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id f18-20020adff452000000b0022584c82c80sm23726047wrp.19.2022.10.23.07.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:33:38 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 6/9] ASoC: jz4740-i2s: Support S20_LE and S24_LE sample formats Date: Sun, 23 Oct 2022 15:33:25 +0100 Message-Id: <20221023143328.160866-7-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> References: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747489421706146968?= X-GMAIL-MSGID: =?utf-8?q?1747489421706146968?= The audio controller on JZ47xx SoCs can transfer 20- and 24-bit samples in the FIFO, so allow those formats to be used with the I2S driver. Although the FIFO doesn't care about the in-memory sample format, we only support 4-byte format variants because the DMA controller on these SoCs cannot transfer in 3-byte multiples. Reviewed-by: Paul Cercueil Signed-off-by: Aidan MacDonald --- sound/soc/jz4740/jz4740-i2s.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index c3235e993ffb..fd35a8a51f60 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -237,9 +237,15 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, case SNDRV_PCM_FORMAT_S8: sample_size = 0; break; - case SNDRV_PCM_FORMAT_S16: + case SNDRV_PCM_FORMAT_S16_LE: sample_size = 1; break; + case SNDRV_PCM_FORMAT_S20_LE: + sample_size = 3; + break; + case SNDRV_PCM_FORMAT_S24_LE: + sample_size = 4; + break; default: return -EINVAL; } @@ -374,7 +380,9 @@ static const struct snd_soc_dai_ops jz4740_i2s_dai_ops = { }; #define JZ4740_I2S_FMTS (SNDRV_PCM_FMTBIT_S8 | \ - SNDRV_PCM_FMTBIT_S16_LE) + SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_S20_LE | \ + SNDRV_PCM_FMTBIT_S24_LE) static struct snd_soc_dai_driver jz4740_i2s_dai = { .probe = jz4740_i2s_dai_probe, From patchwork Sun Oct 23 14:33:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 8035 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp17472wru; Sun, 23 Oct 2022 07:35:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46y/mL255wSI7nlux75AGlBk3JCH4cC//7yy13ND3QQ5CLlYaEPCxj3WWncpRMnopwe6Ok X-Received: by 2002:a63:450c:0:b0:443:94a1:3703 with SMTP id s12-20020a63450c000000b0044394a13703mr23704942pga.565.1666535736464; Sun, 23 Oct 2022 07:35:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666535736; cv=none; d=google.com; s=arc-20160816; b=NoaNWLT4Z8dhkreX/WIyo5wmGMfl19UFeng/NJggraHMNPxdXF4Iv6GsRPHACMLCpQ HDz3fVb3zA2aXPPHH4nxUlZSdqGGUPyEOz3Rb6actxf2rueAECnUtEQzjSbYCu77WDI+ 8YEAcZkmbPXZi6IAtLT6tLk87zOSKKzfnDZs+RSY95NblxQ6eYOwCXshi99u+XDHBwcH nng0uLRcQM6P0/u8E8ETlw8BstiTwwjG51BeX8UvE/UXT+UR3G6HWhDG5tB+GWlGbbN0 j4Dj/oW85/kEATjdo0tB5mLMUjzXdJ/fu8UTCq0Bd6EG05uS7HO0JUXToFqb/0JhXx7q y6qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pvKXzpxFzZWAwh4ulfZ9nH6QQVrhwgz8YLgYLKE7oQk=; b=wWyC2qr/njnFrUMCWii7vyd6LOFj10MgnpXA+COfCS9oDxFIIqZkFGuSK4hKshBKJi 2+4+2B4lxtKVZBIhP7uHknvbuhzFlU0Li0W3QsMj09zJ/Q/jdd9HnExWcKXmwrUUmR2E 3myPCyafdye0YFQIl5aIC8yVry8BOSDb+BgO4zcYRgaE77NsnnEPwDpKoXsbnxy1yggu FrZEhwjTzr8/GucSvvWHWC0Y1dhqeqDTDDf34HuPIWizm3aMYHHKJytf70DLfei6slWr YnfoTfj+K1SXLLle+ycXFIzZknAX0n5vXxubcEMN94ntO0iclP9m37Ql3lZRNp41BFyy aSjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MiAv+zhV; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h3-20020a170902f54300b0017693dbd8cdsi847540plf.551.2022.10.23.07.35.23; Sun, 23 Oct 2022 07:35:36 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=MiAv+zhV; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229956AbiJWOd4 (ORCPT + 99 others); Sun, 23 Oct 2022 10:33:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbiJWOdp (ORCPT ); Sun, 23 Oct 2022 10:33:45 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C43DD61D65; Sun, 23 Oct 2022 07:33:41 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id m29-20020a05600c3b1d00b003c6bf423c71so8348950wms.0; Sun, 23 Oct 2022 07:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pvKXzpxFzZWAwh4ulfZ9nH6QQVrhwgz8YLgYLKE7oQk=; b=MiAv+zhVnlxmLdsRupQuYxZ+FUIDw9Fj/el8pUwCqfG4qpwFptaKXOgIZ3I2VqjkjZ biPuyIRR20VekRI4LcN+B89C4XYiGOmLicys+PnEUSFspnnqkDUJiK5yW8GhA1GPe0SV xkQsFftWaV3+6oOAvUIqUqJLlinN2RypA76M9QbkIo/regxEFAyvc35MIatgg0kR8tLf PxNpcjmFvCbtn1avOhGUn3eam5WA9Yf3TlUdKoLQXIxkrBUZoJBnqQKCJoQ1bO/8b6N8 JgiWjxgbJ5kvOxcHUUUDO7ul8vG87dAiK7hptPQe1rovWUJBRHa8iXzcyCGhdkfMps26 j9/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pvKXzpxFzZWAwh4ulfZ9nH6QQVrhwgz8YLgYLKE7oQk=; b=mcs9S2hr34bVlIdaBgOeqZsGeKdduXgXFNRHEzznOrLzOD75LGjDGZn3eqroraM6Nc VrgHkCSsRJDwcq9bTim0hI+j8qdrsooDsYaGMYw19qaTUs3FYN+9l2O1fFLwIhTkvD6z oyJTKjUVhszqwDztkoZ4SnoaCwe41Xs5TitkIXZetuXgstLwTkhmJDzdQnsamZS9zdrs fsU8g3fau4n4HSmwXazMZrj6VbrRYwpK5KKwHRyK31uLi4zIbWasof3VI3FYUQ0l833s 7ZGqBGiy5loptNW5C2oxubwWqLhk5EvEjjTgwGh6FFEe2hzS/p2Z1mmuBPy8VEVWp4BL ziSw== X-Gm-Message-State: ACrzQf3C7mzFvvKAC8W/TmgEAFMb+/4jyUBtD0eQdJScVqVSaCqhLbhK 9B581JyRJgM9Cr39t23DGeIDh2vYLTo= X-Received: by 2002:a05:600c:358f:b0:3c6:da94:66f9 with SMTP id p15-20020a05600c358f00b003c6da9466f9mr18888398wmq.142.1666535620335; Sun, 23 Oct 2022 07:33:40 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id l24-20020a1c7918000000b003b50428cf66sm8463974wme.33.2022.10.23.07.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:33:39 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 7/9] ASoC: jz4740-i2s: Support continuous sample rate Date: Sun, 23 Oct 2022 15:33:26 +0100 Message-Id: <20221023143328.160866-8-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> References: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747489376268788556?= X-GMAIL-MSGID: =?utf-8?q?1747489376268788556?= The I2S controller on JZ47xx SoCs doesn't impose restrictions on sample rate and the driver doesn't make any assumptions about it, so the DAI should advertise a continuous sample rate range. Acked-by: Paul Cercueil Signed-off-by: Aidan MacDonald --- sound/soc/jz4740/jz4740-i2s.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index fd35a8a51f60..201368f828ff 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -390,13 +390,13 @@ static struct snd_soc_dai_driver jz4740_i2s_dai = { .playback = { .channels_min = 1, .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000_48000, + .rates = SNDRV_PCM_RATE_CONTINUOUS, .formats = JZ4740_I2S_FMTS, }, .capture = { .channels_min = 2, .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000_48000, + .rates = SNDRV_PCM_RATE_CONTINUOUS, .formats = JZ4740_I2S_FMTS, }, .symmetric_rate = 1, @@ -426,13 +426,13 @@ static struct snd_soc_dai_driver jz4770_i2s_dai = { .playback = { .channels_min = 1, .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000_48000, + .rates = SNDRV_PCM_RATE_CONTINUOUS, .formats = JZ4740_I2S_FMTS, }, .capture = { .channels_min = 2, .channels_max = 2, - .rates = SNDRV_PCM_RATE_8000_48000, + .rates = SNDRV_PCM_RATE_CONTINUOUS, .formats = JZ4740_I2S_FMTS, }, .ops = &jz4740_i2s_dai_ops, From patchwork Sun Oct 23 14:33:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 8034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp17436wru; Sun, 23 Oct 2022 07:35:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Vi2smvbvJExDtp68hObsdP5uUrlKbj54eLSTxA1dEzEGxMxNgVULbpBkvw7Od46nx5Zcn X-Received: by 2002:a17:90a:ba90:b0:20d:3434:7f56 with SMTP id t16-20020a17090aba9000b0020d34347f56mr33634516pjr.105.1666535730042; Sun, 23 Oct 2022 07:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666535730; cv=none; d=google.com; s=arc-20160816; b=R50xesc2wuPjFr2v+h55YOUF1NVaDWBSP5cB9pZAysdLd2sOBCw+OMmu4Hz4/jDtkq igQxQnUdPXnY704AsrA+SeqYuhJfI+iNQ2C2s/wobvYqd8dKKidhkgeI4nMYZv9+1y9x hT7MCpbZw4/sJww3hMNYGdOKx5KfBdpfUWRSsyld7YrSAR8C+Iudv4TZsGwV96LIVeh3 Up9asAqOloH9Kjhapj/jhC/WZwzPao2uDi8PzfQGzAhC3dIyfztf9VQ5VIhV2QDTKzuk 2RWIW3ZhiZUFZglOYhX9LKfYzRhiQGXrtC6piQeb2YxSmr7wz3U8L+3/7XIJ9fAnELqu SSQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iboSBornxxq5IGUmNwjcHJMSvR6JYlZCJH/3I/odZvU=; b=JrR6HhwQP1Sw/aaYMGR0AG/O3GyWs/8DHGzQpX8biDbRCrc9Z1D9Q0amtqInS47kiY 16iIicdsvun2QMPrLObv0ixumGOwSTO718n/148TLZ1b51R+g83GmV3E/ngtH2E4/ee1 3x3yLHW0rCHK6err9rYRRK/PSXB2zfN0f7GHc1BXB8l6BxHyp2jnUeAuA8j2WKgPVVly zzL36NDWuzjgMS+3Huzs3Yjztxjr5Njr0d9pk/96WZc+PIgNFJcFfyh0t18EEwdyW5sv u71wYIWnplRxM5bcRTKlJYDkdBr/IJJL2cUwWzRZjqC2U+9mjXFmrHLPttOwTAqr0jV5 gOGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=a0DWRLL2; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a170903028400b001783bb340bfsi4902296plr.2.2022.10.23.07.35.17; Sun, 23 Oct 2022 07:35:30 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=a0DWRLL2; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbiJWOeL (ORCPT + 99 others); Sun, 23 Oct 2022 10:34:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230266AbiJWOdq (ORCPT ); Sun, 23 Oct 2022 10:33:46 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EF98625F9; Sun, 23 Oct 2022 07:33:43 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id jb18so1680273wmb.4; Sun, 23 Oct 2022 07:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iboSBornxxq5IGUmNwjcHJMSvR6JYlZCJH/3I/odZvU=; b=a0DWRLL2JY+JO6dqzjcB2ClTvgkWANjY32AL4ej94RFeRL2DR4yLJU5Ipl7ijWc5+Q HvylTzAJXnREsUmtZnWTse1fmSC3mej7u2CcEQMxQ25Dr9o7Tlar6iRmG4G2DSpUHDQy xZ0YThOx9tX3gALv7DdT/TOjk/O4nF04jN491r7vLGOUFJEKVpZYdcBf24sHLLJ0QoVX 5VyChncf0aZGHuAsLJXRl+eiMa/gWfBVcvFe4h/Vp7ILOca0BIPmaLz2pc8xuqEKoI66 axspR8iYJhkvddtzbSVExcoGoTQXf4PjmoUAGtDIormS5Uoc/tvOdFl0maAcEOZFI8GV h7XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iboSBornxxq5IGUmNwjcHJMSvR6JYlZCJH/3I/odZvU=; b=ZI9waAoFpyi59H5jZ0C0Cf2fUwSFa5TtFzMYLatNBIh8QxSRDdpJA4odM4M7xiiVRq /a2uqTtwl3cqzw0E0fYKe5wd+sANbNHBaQ0T5hgIl8gS+yooBW85+NsUbsl8yTReckok V1dyJnrjgZMjSG7iDtUmQie9XK/mWow64VIQ7N2pkvKwhuo5FiFMiLWY6fZQe7SEgVuS gXbg8pc877qKiObbnl9/DN/2y0a49BbwgCoGYzPWrImqDdQN3PGZYMRfkG7SUsvgfKYS 6zxa1Jcc6P3u4wc8rVPztTHqmhZD4gN5TMeYlQLptr0FOieVHtfmuiqtOSnou1J+BLc6 0pEQ== X-Gm-Message-State: ACrzQf1/0pIpn+jQmHmisEjYW0OXi+osj21CCYZZpCGvAD6BT4tSbYvc z5C6Bia7d5feSmBqzYiOGVDJy1Inv9Y= X-Received: by 2002:a05:600c:3147:b0:3c6:f871:1fec with SMTP id h7-20020a05600c314700b003c6f8711fecmr19700599wmo.71.1666535621633; Sun, 23 Oct 2022 07:33:41 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id b13-20020a5d4d8d000000b0023660f6cecfsm3702290wru.80.2022.10.23.07.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:33:41 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 8/9] ASoC: jz4740-i2s: Move component functions near the component driver Date: Sun, 23 Oct 2022 15:33:27 +0100 Message-Id: <20221023143328.160866-9-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> References: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747489369390383885?= X-GMAIL-MSGID: =?utf-8?q?1747489369390383885?= Move the component suspend/resume functions near the definition of the component driver to emphasize that they're unrelated to the DAI functions. Acked-by: Paul Cercueil Signed-off-by: Aidan MacDonald --- sound/soc/jz4740/jz4740-i2s.c | 72 +++++++++++++++++------------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index 201368f828ff..ac04b17c2787 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -302,42 +302,6 @@ static int jz4740_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, return ret; } -static int jz4740_i2s_suspend(struct snd_soc_component *component) -{ - struct jz4740_i2s *i2s = snd_soc_component_get_drvdata(component); - - if (snd_soc_component_active(component)) { - regmap_clear_bits(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_ENABLE); - clk_disable_unprepare(i2s->clk_i2s); - } - - clk_disable_unprepare(i2s->clk_aic); - - return 0; -} - -static int jz4740_i2s_resume(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; - - if (snd_soc_component_active(component)) { - ret = clk_prepare_enable(i2s->clk_i2s); - if (ret) { - clk_disable_unprepare(i2s->clk_aic); - return ret; - } - - regmap_set_bits(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_ENABLE); - } - - return 0; -} - static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); @@ -454,6 +418,42 @@ static const struct i2s_soc_info jz4780_i2s_soc_info = { .field_i2sdiv_playback = REG_FIELD(JZ_REG_AIC_CLK_DIV, 0, 3), }; +static int jz4740_i2s_suspend(struct snd_soc_component *component) +{ + struct jz4740_i2s *i2s = snd_soc_component_get_drvdata(component); + + if (snd_soc_component_active(component)) { + regmap_clear_bits(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_ENABLE); + clk_disable_unprepare(i2s->clk_i2s); + } + + clk_disable_unprepare(i2s->clk_aic); + + return 0; +} + +static int jz4740_i2s_resume(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; + + if (snd_soc_component_active(component)) { + ret = clk_prepare_enable(i2s->clk_i2s); + if (ret) { + clk_disable_unprepare(i2s->clk_aic); + return ret; + } + + regmap_set_bits(i2s->regmap, JZ_REG_AIC_CONF, JZ_AIC_CONF_ENABLE); + } + + return 0; +} + static const struct snd_soc_component_driver jz4740_i2s_component = { .name = "jz4740-i2s", .suspend = jz4740_i2s_suspend, From patchwork Sun Oct 23 14:33:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 8041 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp17963wru; Sun, 23 Oct 2022 07:36:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6uL87DXg5pO/uLk+AJhLFDitalAIh2B2HAgkd0deAKg5AfbFjF5LBSLhRyTWyBAWGLaBIw X-Received: by 2002:a65:6041:0:b0:449:8b9c:8d29 with SMTP id a1-20020a656041000000b004498b9c8d29mr23811381pgp.335.1666535807041; Sun, 23 Oct 2022 07:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666535807; cv=none; d=google.com; s=arc-20160816; b=A7z7FNDfVZgnIqHaNFsqYQPlKxPyD4GmWxXXwkMsfK94ftNHUMBmd0b0LOvyxDFa+y 1bKNNa76ja6NBeG40ev4okAMmQReP09Ku4rEsX0Q+dZKAtdlKSYXbUQnKzEQuPmeFm8p fs8vJkcETsyFTtFdua9hNt4mcL283r3K0zrVODDXtZtWRsxIbEqQpx9whQDGnLiGwxxA RvQkaRiiOQmcQcMK0qi16pYilb2ntPrfvOM9iA39bFfZs1RIdhtFe0heqWlDnx5OsUtO xIcKJFAAlzbUHnxhyO8mwWw0VVarO9cUzRCFEhkokrTFYufMt/O9lZ50FR04KTr9rxdP q3SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yKcyGQjHmAJtNmBYOXlBo9pb7HsrytrHyz7qgBwYjhw=; b=A+qj1SWnREk4uQi1nwIhyg7J1SH5d2I0RwppEL4OhFQ1oSXdd4Wh8SG/MLRyR7ZULg dxpZLssNsRYKEaDvNrfMHzIiNzIqD3yVxxK0G4vUy9glpMIzlDcyEuZmnpnGasbXlv2x G3oNFPNI+mNCmorvrIzF0wwhZDrdEb6YW3cnHVsDQOxersKU6+uriMxhw0Lvv0a3tn1d FaHrtDyaZCaewD37RBgu2X2fqF2ZxGpYV3AEJZPA/owkCmP/+gM4M4+ZgIiuUxY4qZ1I 5r+AGlYonjH9i0xl7IluU0hyFXwBXG/Lv9Nu2NIXB6zwDo7Y8dVFMXLcFJ4w3oWDu8Vk Q7TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Zvuc+9Ww; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp8-20020a056a00348800b0053dd073fc8dsi28102402pfb.175.2022.10.23.07.36.34; Sun, 23 Oct 2022 07:36:47 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=Zvuc+9Ww; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbiJWOeO (ORCPT + 99 others); Sun, 23 Oct 2022 10:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230231AbiJWOdy (ORCPT ); Sun, 23 Oct 2022 10:33:54 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD29B659F9; Sun, 23 Oct 2022 07:33:44 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id j15so1301601wrq.3; Sun, 23 Oct 2022 07:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yKcyGQjHmAJtNmBYOXlBo9pb7HsrytrHyz7qgBwYjhw=; b=Zvuc+9WwEZdn3+oKyWUWeHWDi/YfGTZb1u1GwBxKUlcv0jfkZlXEpl4HTvEzUqokJq jPVI6zHQSyBzvBjaMTO/Kk0I1hO33tDP7Jm8Wynpmd3vQhDBXMBN7s9+nutIvRL0DFIN sSleOII1Y5QLenCixFn+Balet89evCr6TbpvJU4eXRNFpU2Ef/Ztiw97soIcQA0r+7fF AqhHPA8YlYjg/H0TM0xvwV6f56VDypR4RXPiGHckcuqWSEt+eDwBQibmfYxRX2wIj3zT A3uMpgrXG8DMWOgkNKNxSiTDV9J01GkhMSoU5orzD2L3cZNJHOxNQ8SQKhnC1mpI9OUl 4AhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yKcyGQjHmAJtNmBYOXlBo9pb7HsrytrHyz7qgBwYjhw=; b=yEqu5SZpe4gzUegMakQNpBc5kzhJJxP+BNvimkyHAPegr3PFby/RRnDQb417oVBFJi x9ZxfFKKI/QCWVDxpJaWD27Ca33AFDyGyn8j8d10fxBwyTyTmYkew+qDLyBJZxo+8Ccp u9YRKkicVliiOonB7zhflfqN/t8dK6rLn5d8+rwRwT5fQJXkMeuVR3iwrAB+a7Hd5au1 qGfgYiPWXMJeXPo43PHxZ33RLFjKlp0F3qte0MJL4HCWm9eb9gYkn/GptmsYDURyVy6O MHOa1+xWXmnHdM9J1lQb7JEmOSzvv3TopgipXsATAWfkHva0l/yaTN0rvphjpEmf3bfm iF2g== X-Gm-Message-State: ACrzQf26zlG4z1IDJKdZbuco3jbIgSWiUar4a0ML/FFXpxCQsq1nXyY0 mzkAtNIkYiFigEsKjzu01Lo= X-Received: by 2002:a5d:4f12:0:b0:22e:3920:a09c with SMTP id c18-20020a5d4f12000000b0022e3920a09cmr17811204wru.95.1666535622868; Sun, 23 Oct 2022 07:33:42 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id o13-20020adfcf0d000000b0022cce7689d3sm7614395wrj.36.2022.10.23.07.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:33:42 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 9/9] ASoC: jz4740-i2s: Refactor DAI probe/remove ops as component ops Date: Sun, 23 Oct 2022 15:33:28 +0100 Message-Id: <20221023143328.160866-10-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> References: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747489450662687827?= X-GMAIL-MSGID: =?utf-8?q?1747489450662687827?= 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. Reviewed-by: Paul Cercueil Signed-off-by: Aidan MacDonald --- 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 ac04b17c2787..b620d4462d90 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -305,32 +305,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; } @@ -350,7 +328,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, @@ -386,7 +363,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, @@ -454,8 +430,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,