Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1804327rdh; Sat, 25 Nov 2023 03:55:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6sDRBN3hLSG+OsB11OGgKq59Y0dptag7mj5ctYdeEhASOLyfOO21VhwluF7X74z10JZAC X-Received: by 2002:a05:6a20:9191:b0:187:e3e8:e8d4 with SMTP id v17-20020a056a20919100b00187e3e8e8d4mr7553435pzd.53.1700913327026; Sat, 25 Nov 2023 03:55:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700913327; cv=none; d=google.com; s=arc-20160816; b=X5xLieCdPcLFlFyieOnIWweuKLGxd+6DCWGyHp3B0qVtrhvQzuDwZTOOZlZJI2xAfu c4RessQz+3QRZ7EX2PoMk+lPMmmpsBy8G7zOjQQ1dP/K2ewiEOFKOOElvf/0S+8hHQPT BkPH+P0K1LGJMPPKMvzsnS0gI0KIbsXm3TAuoI8ieAeZNSJeTYZC0qzLFWNNuZcWB8qj u6Xsf+hIIRS2pbeaZHGNMwpqprqiObwbMWHVamAWxZSJJnWdtprnq/NDDHyD48VOxS6Y YYYpts22tmEMCWjXLgZCC1ENV6jSiROc8GzvE+Ngww5HLA3IJwT8V/6dJC6GJq6Y8L/6 mlSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=VjoAQdrJlyucZgCB5XwzbgMabrtPSPnwCcmkjxg9epU=; fh=TYCtaxIVAeXNNmydIskzX+Ifz00588UTPX8DoqzCiKA=; b=PxJmxlAVmZElLciSE/5DuSkC1h5EdTV7XEozJYI4ojKoqKFi4TBVfkuDsBWpFObIrs oYuJ0668b8qVhwrUGahawKthqSV6xOg4qUJlmKfmfkla9UCDoH+X04isxeuAtnmaAaZF w8dhjTrjDSxq40T6Hq1du0TDb5P69cteTlEBRB0oHTSkMMgdAdSdNAo1ga8IxamqVACP OiC0FaFOmjFpqofH7lCtkZuRYmRZAfMkUINskCgRhN+Gc9E7FO7qX4StNkzMaVTOIBw/ Pd+0CzpbqW42uyrZvjZagbZJNaC2ai5hFV9Go/FpNaTE6JvbDIzTIuroxlZeDBFflohi ZEjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bbmw9pH5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id fj11-20020a056a003a0b00b006cbf66f3119si3443565pfb.4.2023.11.25.03.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 03:55:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bbmw9pH5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 17F9780239C6; Sat, 25 Nov 2023 03:55:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231802AbjKYLzH (ORCPT + 99 others); Sat, 25 Nov 2023 06:55:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjKYLzG (ORCPT ); Sat, 25 Nov 2023 06:55:06 -0500 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF8F10EB for ; Sat, 25 Nov 2023 03:55:11 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-50baa2a278bso423603e87.0 for ; Sat, 25 Nov 2023 03:55:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700913310; x=1701518110; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=VjoAQdrJlyucZgCB5XwzbgMabrtPSPnwCcmkjxg9epU=; b=Bbmw9pH5nZZzTea+vjRB6fF6fvqoJUdmA/g4T9w1OOYuUeRyf/El9L2mdm4/M8GAis mtPdNAk9O856M04VuwFUkPXPSrqpSXCnWj3zPtVtgVmerNMEr07RIiJ6DMRFu4IbN6xe oKF7BNmomzrjDtMSOyzirzl0qofsEEwR1eq55OI4imuiay6PNUWO+B45LBUY2f27nLDN eUCgI/TkJMwk2sbA1lwDjOLe7xM3c1zkDJzIo/pQW3qbPogOfJhGb0kjCbJp0Q1r5O7D VGIvDecg6ugskSSfhiVIVZ0qo6MIejxLytRKCcEBb7cQki6H4bBrr4xmvokppm0arDaR Nb5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700913310; x=1701518110; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VjoAQdrJlyucZgCB5XwzbgMabrtPSPnwCcmkjxg9epU=; b=RPenv2xPtrP52RliUCh3F19n+x1QP1MHUXFI6LA7yMj5PqVyNzApH/mnJKeAs9bdrU i3bRSU2ygz1aNT9B1mFAgbRzECi8jhvhBKGcaCK77MfHjshJFHqxmZqB71C1I2ol/aS1 WLcdTOrVdqBipXf21a1aLeB/AmmVer01eEobFDBWtVfGC1vmAaUlGiY0/R8icXdFEkhy OIuwsBrBsVAK5H+8zeOCWzgM6Z8Jzx63/iM6X4BfOwCiU5MQ2MWDSVjkrLz4zedMcnwi nTIIQ/maX63RMTkZ/06HNofMvxp/Q6L3r9ZQLLZ0MIFAxXQqfkxBiJQynNth+8fLXebK YT+g== X-Gm-Message-State: AOJu0Ywn8nxhtKKhNzT08BVxgYcwonMKhw3pMLQNuhGRVc4uypCmNjoI jWUDpCl10Pph2hHp+LmkvOtAXw== X-Received: by 2002:a05:6512:3a85:b0:50b:a6c7:e8b0 with SMTP id q5-20020a0565123a8500b0050ba6c7e8b0mr1102022lfu.26.1700913309934; Sat, 25 Nov 2023 03:55:09 -0800 (PST) Received: from [192.168.201.100] (178235187180.dynamic-4-waw-k-2-3-0.vectranet.pl. [178.235.187.180]) by smtp.gmail.com with ESMTPSA id a18-20020a170906191200b009e6cedc8bf5sm3348915eje.29.2023.11.25.03.55.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 25 Nov 2023 03:55:09 -0800 (PST) Message-ID: Date: Sat, 25 Nov 2023 12:55:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/5] ASoC: codecs: Add WCD939x Soundwire slave driver Content-Language: en-US To: Neil Armstrong , Srinivas Kandagatla , Banajit Goswami , Andy Gross , Bjorn Andersson , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai Cc: linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231123-topic-sm8650-upstream-wcd939x-codec-v1-0-21d4ad9276de@linaro.org> <20231123-topic-sm8650-upstream-wcd939x-codec-v1-4-21d4ad9276de@linaro.org> From: Konrad Dybcio Autocrypt: addr=konrad.dybcio@linaro.org; keydata= xsFNBF9ALYUBEADWAhxdTBWrwAgDQQzc1O/bJ5O7b6cXYxwbBd9xKP7MICh5YA0DcCjJSOum BB/OmIWU6X+LZW6P88ZmHe+KeyABLMP5s1tJNK1j4ntT7mECcWZDzafPWF4F6m4WJOG27kTJ HGWdmtO+RvadOVi6CoUDqALsmfS3MUG5Pj2Ne9+0jRg4hEnB92AyF9rW2G3qisFcwPgvatt7 TXD5E38mLyOPOUyXNj9XpDbt1hNwKQfiidmPh5e7VNAWRnW1iCMMoKqzM1Anzq7e5Afyeifz zRcQPLaqrPjnKqZGL2BKQSZDh6NkI5ZLRhhHQf61fkWcUpTp1oDC6jWVfT7hwRVIQLrrNj9G MpPzrlN4YuAqKeIer1FMt8cq64ifgTzxHzXsMcUdclzq2LTk2RXaPl6Jg/IXWqUClJHbamSk t1bfif3SnmhA6TiNvEpDKPiT3IDs42THU6ygslrBxyROQPWLI9IL1y8S6RtEh8H+NZQWZNzm UQ3imZirlPjxZtvz1BtnnBWS06e7x/UEAguj7VHCuymVgpl2Za17d1jj81YN5Rp5L9GXxkV1 aUEwONM3eCI3qcYm5JNc5X+JthZOWsbIPSC1Rhxz3JmWIwP1udr5E3oNRe9u2LIEq+wH/toH kpPDhTeMkvt4KfE5m5ercid9+ZXAqoaYLUL4HCEw+HW0DXcKDwARAQABzShLb25yYWQgRHli Y2lvIDxrb25yYWQuZHliY2lvQGxpbmFyby5vcmc+wsGOBBMBCAA4FiEEU24if9oCL2zdAAQV R4cBcg5dfFgFAmQ5bqwCGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQR4cBcg5dfFjO BQ//YQV6fkbqQCceYebGg6TiisWCy8LG77zV7DB0VMIWJv7Km7Sz0QQrHQVzhEr3trNenZrf yy+o2tQOF2biICzbLM8oyQPY8B///KJTWI2khoB8IJSJq3kNG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5HnVF76UQXh3a9zpwh3dk8i bhN/URmCOTH+LHNJYN/MxY8wuukq877DWB7k86pBs5IDLAXmW8v3gIDWyIcgYqb2v8QO2Mqx YMqL7UZxVLul4/JbllsQB8F/fNI8AfttmAQL9cwo6C8yDTXKdho920W4WUR9k8NT/OBqWSyk bGqMHex48FVZhexNPYOd58EY9/7mL5u0sJmo+jTeb4JBgIbFPJCFyng4HwbniWgQJZ1WqaUC nas9J77uICis2WH7N8Bs9jy0wQYezNzqS+FxoNXmDQg2jetX8en4bO2Di7Pmx0jXA4TOb9TM izWDgYvmBE8= In-Reply-To: <20231123-topic-sm8650-upstream-wcd939x-codec-v1-4-21d4ad9276de@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sat, 25 Nov 2023 03:55:24 -0800 (PST) On 23.11.2023 15:49, Neil Armstrong wrote: > Add Soundwire Slave driver for the WCD9390/WCD9395 Audio Codec. > > The WCD9390/WCD9395 Soundwire Slaves will be used by the > main WCD9390/WCD9395 Audio Codec driver to access registers > and configure Soundwire RX and TX ports. > > Signed-off-by: Neil Armstrong > --- [...] > +static struct wcd939x_sdw_ch_info wcd939x_sdw_tx_ch_info[] = { > + WCD_SDW_CH(WCD939X_ADC1, WCD939X_ADC_1_4_PORT, BIT(0)), > + WCD_SDW_CH(WCD939X_ADC2, WCD939X_ADC_1_4_PORT, BIT(1)), > + WCD_SDW_CH(WCD939X_ADC3, WCD939X_ADC_1_4_PORT, BIT(2)), > + WCD_SDW_CH(WCD939X_ADC4, WCD939X_ADC_1_4_PORT, BIT(3)), > + // TOFIX support ADC3/4 & DMIC0/1 on port 2 Well, fix it or drop it :D > + //WCD_SDW_CH(WCD939X_ADC3, WCD939X_ADC_DMIC_1_2_PORT, BIT(0)), > + //WCD_SDW_CH(WCD939X_ADC4, WCD939X_ADC_DMIC_1_2_PORT, BIT(1)), > + //WCD_SDW_CH(WCD939X_DMIC0, WCD939X_ADC_DMIC_1_2_PORT, BIT(2)), > + //WCD_SDW_CH(WCD939X_DMIC1, WCD939X_ADC_DMIC_1_2_PORT, BIT(3)), > + WCD_SDW_CH(WCD939X_DMIC0, WCD939X_DMIC_0_3_MBHC_PORT, BIT(0)), > + WCD_SDW_CH(WCD939X_DMIC1, WCD939X_DMIC_0_3_MBHC_PORT, BIT(1)), > + WCD_SDW_CH(WCD939X_MBHC, WCD939X_DMIC_0_3_MBHC_PORT, BIT(2)), > + WCD_SDW_CH(WCD939X_DMIC2, WCD939X_DMIC_0_3_MBHC_PORT, BIT(2)), > + WCD_SDW_CH(WCD939X_DMIC3, WCD939X_DMIC_0_3_MBHC_PORT, BIT(3)), > + WCD_SDW_CH(WCD939X_DMIC4, WCD939X_DMIC_3_7_PORT, BIT(0)), > + WCD_SDW_CH(WCD939X_DMIC5, WCD939X_DMIC_3_7_PORT, BIT(1)), > + WCD_SDW_CH(WCD939X_DMIC6, WCD939X_DMIC_3_7_PORT, BIT(2)), > + WCD_SDW_CH(WCD939X_DMIC7, WCD939X_DMIC_3_7_PORT, BIT(3)), > +}; [...] > + > +int wcd939x_swr_get_current_bank(struct sdw_slave *sdev) > +{ > + int bank; > + > + bank = sdw_read(sdev, SDW_SCP_CTRL); > + > + return ((bank & 0x40) ? 1 : 0); bool conversion? Also, 0x40 == BIT(6), can you look up what it means and #define it? [...] > + > +static int wcd9390_bus_config(struct sdw_slave *slave, > + struct sdw_bus_params *params) > +{ > + sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank), > + 0x01); similar, BIT(0) [...] > + { WCD939X_EAR_STATUS_REG_2, 0x08 }, > + { WCD939X_FLYBACK_NEW_CTRL_2, 0x00 }, //?? > + { WCD939X_FLYBACK_NEW_CTRL_3, 0x00 }, //?? > + { WCD939X_FLYBACK_NEW_CTRL_4, 0x44 }, //?? drop //s [...] > +static bool wcd939x_volatile_register(struct device *dev, unsigned int reg) > +{ > + if (reg <= WCD939X_BASE) > + return false; Maybe move this check to readonly_register > + > + if (wcd939x_readonly_register(dev, reg)) > + return true; and call readonly for .volatile_reg as well? [...] > + /** > + * Port map index starts with 0, however the data port for this codec > + * are from index 1 > + */ This is not kerneldoc > + if (of_property_read_bool(dev->of_node, "qcom,tx-port-mapping")) { > + wcd->is_tx = true; > + ret = of_property_read_u32_array(dev->of_node, > + "qcom,tx-port-mapping", > + &pdev->m_port_map[1], > + WCD939X_MAX_TX_SWR_PORTS); > + } else { > + ret = of_property_read_u32_array(dev->of_node, > + "qcom,rx-port-mapping", > + &pdev->m_port_map[1], > + WCD939X_MAX_RX_SWR_PORTS); > + } This is used in wcd9380 and will be used in wcd9370 when that happens some day, maybe it'd be worth to commonize it as qcom_{rx/tx}_portmap_get? [...] > +static const struct sdw_device_id wcd9390_slave_id[] = { > + SDW_SLAVE_ENTRY(0x0217, 0x10e, 0), 0x10e - WCD9380 or 9385 slave? an inline comment at the end of the line would be cool! Konrad