From patchwork Fri Feb 3 11:14:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 52464 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp780264wrn; Fri, 3 Feb 2023 03:18:13 -0800 (PST) X-Google-Smtp-Source: AK7set+/tMQsjH8I461ab+ITv0oA1l9jVdyZsPBmXopzqqunFjJxrEP2b+lSZeWeMeMfgyO/ClsL X-Received: by 2002:a17:903:228b:b0:194:d7d5:f3b7 with SMTP id b11-20020a170903228b00b00194d7d5f3b7mr4762720plh.35.1675423092872; Fri, 03 Feb 2023 03:18:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675423092; cv=none; d=google.com; s=arc-20160816; b=g9vSMldOOCBhzy1cnbnZhJVNU5wp7Bs1qr3US63qE9EE1aF8tkvuNW0Fh6VrKhkbtS dUajaBp9kYcO/liWSvlIvNIAeXkGso1esc+xDDfwkDfn36vxHG6h6MTEIKQhH3bx3rlf 6AoFa7ep2F5Qo4JgHTYZC4cIvksIxW7GCYa8Yedk92HkC3N6KpRtYazc8fmiIGn680q9 2ETLR1K+kXynxrPRB76HdfYisamq2MiWDqs52iFbX2bHYFUJ/YetzdXCcEV4zGvImdh8 hNEw+nbErBljzZNjlfN0AAYicGXdgu/feCxsQc0gczPHK9b2O1gfoEEoT33AVa2KcGLs XnYA== 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=Ge7sHeo6XljC/uKf8NYIO4UCkI+QIvq5OQ52h7yZfUg=; b=UsZgo3mkLUoAZ80L3I89NM6AyuM5DdX5USj8xaquAVEj94hN9xslYwjMz9yFE8UpPW xI6P+IjD4HVJ6o4sMvVeUNHjKL78dVdgza3EpSP08plvOQpXa70ZhhBk/NgayrOozGH+ HFBtkIMjirp0cLNDJZHjnz9GtjiGbHB65GAb+oDWuNTIvCfyXwcganjfyGcG/5Nm5fwf i9/mdxqwEnCBdrs4yD8tF5GT3f6mGvfq6vg7BH5cmCTI8LMcgvpnrbIC4HRue+Z9w+TN kmvTlxMzNG/vEazB/RHEB/RlrtMFaHkSlr+piDqi56Rl0v4ITULENoeF6f6kqOc6X4MX BhqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UbXmpiwI; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a170902d88700b00194c49857acsi1982007plz.226.2023.02.03.03.18.00; Fri, 03 Feb 2023 03:18:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UbXmpiwI; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232740AbjBCLOr (ORCPT + 99 others); Fri, 3 Feb 2023 06:14:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232295AbjBCLOi (ORCPT ); Fri, 3 Feb 2023 06:14:38 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 277508FB6F; Fri, 3 Feb 2023 03:14:37 -0800 (PST) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 172631C001B; Fri, 3 Feb 2023 11:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1675422875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ge7sHeo6XljC/uKf8NYIO4UCkI+QIvq5OQ52h7yZfUg=; b=UbXmpiwIu3ZB6+OqqIWbGfPOjGbwGfKL7KdYSW+SquC2V9jkSdxG2VQr36U0xLtXJiaCCk JPkt1o9C1KOTlid8qdIFFC9lY6wh1pRvaru66d2cKX+5TkWj3qZQ6N2tEYNwEHd+mSd4SD iBC8b8U7B4vjHQA75eRogPEumGJPiGirVL+jb0P60e1AomONNedYXVHEKDALaKTp0euAqb H1C5FQ68496XDVXAHxMPc9UM1pESp1GEtmm+BAtdjKXtRnW1FhttXF06RKqwPfVcybzDIt 241ZpWs6fGx78aYg6F0dDm0HSONM1ss1dtweSpC1wW848jNZ4ZRLNDSShXF8vg== From: Herve Codina To: Herve Codina , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH 1/3] dt-bindings: sound: Add the Renesas X9250 potentiometers Date: Fri, 3 Feb 2023 12:14:20 +0100 Message-Id: <20230203111422.142479-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230203111422.142479-1-herve.codina@bootlin.com> References: <20230203111422.142479-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1756808445279571758?= X-GMAIL-MSGID: =?utf-8?q?1756808445279571758?= The Renesas X9250 is a quad digitally controlled potentiometers. Signed-off-by: Herve Codina --- .../bindings/sound/renesas,x9250.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/renesas,x9250.yaml diff --git a/Documentation/devicetree/bindings/sound/renesas,x9250.yaml b/Documentation/devicetree/bindings/sound/renesas,x9250.yaml new file mode 100644 index 000000000000..ad29ef465a18 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/renesas,x9250.yaml @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/renesas,x9250.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas X9250 quad potentiometers + +maintainers: + - Herve Codina + +description: | + The Renesas X9250 is a quad digitally controlled potentiometers. + + In the audio path, it can be present on amplifiers designs and it can be used + in ALSA as an auxiliary audio device to control these amplifiers. + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml + - $ref: dai-common.yaml# + +properties: + compatible: + const: renesas,x9250 + + reg: + description: + SPI device address. + maxItems: 1 + + spi-max-frequency: + maximum: 2000000 + +patternProperties: + "^renesas,cmd[0-3]-invert$": + description: + The related command is inverted meaning that the minimum command value + set the wiper to Rh and the maximum command value set the wiper to Rl. + Without this property, the minimum command value set the wiper to Rl and + the maximum to Rh. + type: boolean + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + x9250@0 { + compatible = "renesas,x9250"; + reg = <0>; + spi-max-frequency = <2000000>; + renesas,cmd3-invert; + }; + }; From patchwork Fri Feb 3 11:14:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 52466 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp781188wrn; Fri, 3 Feb 2023 03:20:36 -0800 (PST) X-Google-Smtp-Source: AK7set+gfBwrd1Um57szj1e3h8a1B43mTD3cxdds4J/M9U+PEcISYpWjzeJT0R2E568P177J15r5 X-Received: by 2002:a05:6a20:7d84:b0:be:b137:9d15 with SMTP id v4-20020a056a207d8400b000beb1379d15mr13471873pzj.36.1675423236125; Fri, 03 Feb 2023 03:20:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675423236; cv=none; d=google.com; s=arc-20160816; b=gGKG4MeSh1wqyoQpbFOl1gixMfALy/ZDUv7OSwhkXdOkZs/t7ePqbz93Y57pJJGkAv NTHXVk6lmILSD1/gh8rtWTDmT+pRgz7pJyP5vpJuEXZNqVkmD5SUfOfxWzqQ67969XPf jPz/aRXNXtMJ0WjwqO9OxKaCYTlAtOzgZKL44vjQe7mYOFajZQdv0ySgYVQfoKPhDMB0 9PC7B9z+6uFOUmOZ7ozr+JR/BfDPOa9FDWdMymAhaQf8QaQk8rEMJoYojc3BLKcvo8qx 0OdXYZNl5Efl21QP16mTcQ9SomI8ZRgeNdTUBXny2bGj5qcmneSHGBjZwF/cK6gSRbAX vybw== 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=/B138WsRSYzV/E8WT0lEWOcdHSuB7G8fsLebv6AbPjI=; b=zO87hRifgeVz7Z6vdqru65oLuxxwv86qMbYpMY2uZauUgTfbsCkEHE5cxMyGwFr16t vUIPWsqS1pKpf6yuHVvbplZYobahMq6Q6d3xTqiJhLeYVg6F5I/6JfeZJvlwlS4ExtX8 TDh9tHTA9Rw/XxvUDa6BO4OGdXs9b5ga/64kHxIvuxCG2FZ1eZm+6jzDn/1h4/QBefXN GN0VelzbLhE9HDhj2IfnqjodFyWnin1OLs1t+pcmsPXcp9YzgQi6kK2e7abivW6wFGlq WHPiHoA9AsSdMJnT+x2NgroSzJsTIq8B40Z9SNUejocu7w3crKYsAXbhkw0vXrYeQet7 TraQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bJXqoxVt; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w191-20020a6382c8000000b004f1d9a1e295si2394203pgd.531.2023.02.03.03.20.22; Fri, 03 Feb 2023 03:20:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bJXqoxVt; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232554AbjBCLOx (ORCPT + 99 others); Fri, 3 Feb 2023 06:14:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230180AbjBCLOk (ORCPT ); Fri, 3 Feb 2023 06:14:40 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824CC79639; Fri, 3 Feb 2023 03:14:38 -0800 (PST) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id ECB891C0018; Fri, 3 Feb 2023 11:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1675422877; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/B138WsRSYzV/E8WT0lEWOcdHSuB7G8fsLebv6AbPjI=; b=bJXqoxVtEdLVSsEfkNhCZgLZ2isvARJIOyyihsuwupTJ6KB+aEkxJIxjIGI2QrfAw9DWmE KP5g+KD2tOqoSA3apz5T9Bb4Fi5T0wWyKC4S5DJJS2rqWX2WvpIirFm0YqFSbZPJ4gUfkF DkM1K9t5nj3fbRBSFEMyKrVcL0XPtjJUWur6IuwtPd1PqEJM4G1fd3D2BWK4LSjxmVE+av BpoNUR3T+WFUuODVlZezKdb4MyYe53z2RHB3Dt1cuHmQeqg+CqDvWAHURxe+jRehMJ1rOr SVaLddTP83RMblqrMdu/NtKhTo9qqy9EBt/PCOLUDnrg6+DnMfuvIEBaMNSuOQ== From: Herve Codina To: Herve Codina , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH 2/3] ASoC: codecs: Add support for the Renesas X9250 potentiometers Date: Fri, 3 Feb 2023 12:14:21 +0100 Message-Id: <20230203111422.142479-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230203111422.142479-1-herve.codina@bootlin.com> References: <20230203111422.142479-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1756808595471377488?= X-GMAIL-MSGID: =?utf-8?q?1756808595471377488?= The Renesas X9250 is a quad digitally controlled potentiometers. Signed-off-by: Herve Codina --- sound/soc/codecs/Kconfig | 11 ++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/x9250.c | 276 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 289 insertions(+) create mode 100644 sound/soc/codecs/x9250.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 5531bf8d4b3f..19afa0067305 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -314,6 +314,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_WM9713 imply SND_SOC_WSA881X imply SND_SOC_WSA883X + imply SND_SOC_X9250 imply SND_SOC_ZL38060 help Normally ASoC codec drivers are only built if a machine driver which @@ -2053,6 +2054,16 @@ config SND_SOC_WSA883X This enables support for Qualcomm WSA8830/WSA8835 Class-D Smart Speaker Amplifier. +config SND_SOC_X9250 + tristate "Renesas X9250 quad controlled potentiometers" + depends on SPI + help + Enable support for the Renesas X9250 quad controlled + potentiometers. + + To compile this driver as a module, choose M here: the module + will be called snd-soc-x9250. + config SND_SOC_ZL38060 tristate "Microsemi ZL38060 Connected Home Audio Processor" depends on SPI_MASTER diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index bcf95de654fd..a1d6de6a18f6 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -346,6 +346,7 @@ snd-soc-wm9713-objs := wm9713.o snd-soc-wm-hubs-objs := wm_hubs.o snd-soc-wsa881x-objs := wsa881x.o snd-soc-wsa883x-objs := wsa883x.o +snd-soc-x9250-objs := x9250.o snd-soc-zl38060-objs := zl38060.o # Amp snd-soc-max9877-objs := max9877.o @@ -708,6 +709,7 @@ obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o obj-$(CONFIG_SND_SOC_WSA881X) += snd-soc-wsa881x.o obj-$(CONFIG_SND_SOC_WSA883X) += snd-soc-wsa883x.o +obj-$(CONFIG_SND_SOC_X9250) += snd-soc-x9250.o obj-$(CONFIG_SND_SOC_ZL38060) += snd-soc-zl38060.o # Amp diff --git a/sound/soc/codecs/x9250.c b/sound/soc/codecs/x9250.c new file mode 100644 index 000000000000..14f80009f085 --- /dev/null +++ b/sound/soc/codecs/x9250.c @@ -0,0 +1,276 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// x9250.c -- Renesas X9250 ALSA SoC driver +// +// Copyright 2023 CS GROUP France +// +// Author: Herve Codina + +#include +#include +#include +#include +#include + +#define X9250_NB_CHANNEL 4 + +struct x9250 { + struct spi_device *spi; + u8 spi_tx_buf[3]; /* Cannot use stack area for SPI (dma-safe memory) */ + u8 spi_rx_buf[3]; /* Cannot use stack area for SPI (dma-safe memory) */ + int cmd_inv; +}; + +#define X9250_CMD_RD_WCR(_p) (0x90 | (_p)) +#define X9250_CMD_WR_WCR(_p) (0xa0 | (_p)) + +static int x9250_write8(struct x9250 *x9250, u8 cmd, u8 val) +{ + struct spi_transfer xfer = { + .tx_buf = &x9250->spi_tx_buf, + .len = 3, + }; + + BUILD_BUG_ON(sizeof(x9250->spi_tx_buf) < 3); + + x9250->spi_tx_buf[0] = 0x50; + x9250->spi_tx_buf[1] = cmd; + x9250->spi_tx_buf[2] = val; + + return spi_sync_transfer(x9250->spi, &xfer, 1); +} + +static int x9250_read8(struct x9250 *x9250, u8 cmd, u8 *val) +{ + struct spi_transfer xfer = { + .tx_buf = &x9250->spi_tx_buf, + .rx_buf = &x9250->spi_rx_buf, + .len = 3, + }; + int ret; + + BUILD_BUG_ON(sizeof(x9250->spi_tx_buf) < 3); + BUILD_BUG_ON(sizeof(x9250->spi_rx_buf) < 3); + + x9250->spi_tx_buf[0] = 0x50; + x9250->spi_tx_buf[1] = cmd; + + ret = spi_sync_transfer(x9250->spi, &xfer, 1); + if (ret) + return ret; + + *val = x9250->spi_rx_buf[2]; + return 0; +} + +static const struct snd_soc_dapm_widget x9250_dapm_widgets[] = { + SND_SOC_DAPM_INPUT("IN0"), + SND_SOC_DAPM_INPUT("IN1"), + SND_SOC_DAPM_INPUT("IN2"), + SND_SOC_DAPM_INPUT("IN3"), + + SND_SOC_DAPM_PGA("CH0 PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("CH1 PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("CH2 PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("CH3 PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + + SND_SOC_DAPM_OUTPUT("OUT0"), + SND_SOC_DAPM_OUTPUT("OUT1"), + SND_SOC_DAPM_OUTPUT("OUT2"), + SND_SOC_DAPM_OUTPUT("OUT3"), +}; + +static const struct snd_soc_dapm_route x9250_dapm_routes[] = { + { "CH0 PGA", NULL, "IN0" }, + { "CH1 PGA", NULL, "IN1" }, + { "CH2 PGA", NULL, "IN2" }, + { "CH3 PGA", NULL, "IN3" }, + + { "OUT0", NULL, "CH0 PGA" }, + { "OUT1", NULL, "CH1 PGA" }, + { "OUT2", NULL, "CH2 PGA" }, + { "OUT3", NULL, "CH3 PGA" }, +}; + +static int x8250_kctrl_cmd_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct x9250 *x9250 = snd_soc_component_get_drvdata(component); + int min = mc->min; + int max = mc->max; + unsigned int mask = (1 << fls(max)) - 1; + unsigned int invert = mc->invert; + int ret; + u8 val; + u8 wcr; + + wcr = mc->reg; + if (wcr > 4) + return -EINVAL; + + ret = x9250_read8(x9250, X9250_CMD_RD_WCR(wcr), &val); + if (ret) + return ret; + + ucontrol->value.integer.value[0] = (val & mask) - min; + if (invert) + ucontrol->value.integer.value[0] = max - ucontrol->value.integer.value[0]; + + return 0; +} + +static int x8250_kctrl_cmd_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct x9250 *x9250 = snd_soc_component_get_drvdata(component); + int min = mc->min; + int max = mc->max; + unsigned int mask = (1 << fls(max)) - 1; + unsigned int invert = mc->invert; + unsigned int val; + int ret; + u8 wcr; + u8 tmp; + + wcr = mc->reg; + if (wcr > 4) + return -EINVAL; + + val = ucontrol->value.integer.value[0]; + if (val < 0) + return -EINVAL; + if (val > max - min) + return -EINVAL; + + val = (val + min) & mask; + if (invert) + val = max - val; + + ret = x9250_read8(x9250, X9250_CMD_RD_WCR(wcr), &tmp); + if (ret) + return ret; + + if (tmp == val) + return 0; + + ret = x9250_write8(x9250, X9250_CMD_WR_WCR(wcr), val); + if (ret) + return ret; + + return 1; /* The value changed */ +} + +static const struct snd_kcontrol_new x9250_controls_std[] = { + SOC_SINGLE_EXT("CMD0", 0, 0, 255, 0, x8250_kctrl_cmd_get, x8250_kctrl_cmd_put), + SOC_SINGLE_EXT("CMD1", 1, 0, 255, 0, x8250_kctrl_cmd_get, x8250_kctrl_cmd_put), + SOC_SINGLE_EXT("CMD2", 2, 0, 255, 0, x8250_kctrl_cmd_get, x8250_kctrl_cmd_put), + SOC_SINGLE_EXT("CMD3", 3, 0, 255, 0, x8250_kctrl_cmd_get, x8250_kctrl_cmd_put), +}; + +static const struct snd_kcontrol_new x9250_controls_inv[] = { + SOC_SINGLE_EXT("CMD0", 0, 0, 255, 1, x8250_kctrl_cmd_get, x8250_kctrl_cmd_put), + SOC_SINGLE_EXT("CMD1", 1, 0, 255, 1, x8250_kctrl_cmd_get, x8250_kctrl_cmd_put), + SOC_SINGLE_EXT("CMD2", 2, 0, 255, 1, x8250_kctrl_cmd_get, x8250_kctrl_cmd_put), + SOC_SINGLE_EXT("CMD3", 3, 0, 255, 1, x8250_kctrl_cmd_get, x8250_kctrl_cmd_put), +}; + +static int x9250_component_probe(struct snd_soc_component *component) +{ + struct x9250 *x9250 = snd_soc_component_get_drvdata(component); + struct snd_kcontrol_new control[X9250_NB_CHANNEL]; + int ret; + u8 wcr; + int i; + + /* Check arrays compatibility */ + BUILD_BUG_ON(ARRAY_SIZE(x9250_controls_std) != X9250_NB_CHANNEL); + BUILD_BUG_ON(ARRAY_SIZE(x9250_controls_inv) != X9250_NB_CHANNEL); + BUILD_BUG_ON(sizeof(control[0]) != sizeof(x9250_controls_std[0])); + BUILD_BUG_ON(sizeof(control[0]) != sizeof(x9250_controls_inv[0])); + + for (i = 0; i < X9250_NB_CHANNEL; i++) { + if (x9250->cmd_inv & (1 << i)) { + wcr = 0xff; + memcpy(&control[i], &x9250_controls_inv[i], sizeof(control[i])); + } else { + wcr = 0x00; + memcpy(&control[i], &x9250_controls_std[i], sizeof(control[i])); + } + ret = x9250_write8(x9250, X9250_CMD_WR_WCR(i), wcr); + if (ret) + return ret; + } + + return snd_soc_add_component_controls(component, control, ARRAY_SIZE(control)); +} + +static const struct snd_soc_component_driver x9250_component_driver = { + .probe = x9250_component_probe, + .dapm_widgets = x9250_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(x9250_dapm_widgets), + .dapm_routes = x9250_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(x9250_dapm_routes), +}; + +static int x9250_spi_probe(struct spi_device *spi) +{ + struct x9250 *x9250; + int ret; + + spi->bits_per_word = 8; + ret = spi_setup(spi); + if (ret < 0) + return ret; + + x9250 = devm_kzalloc(&spi->dev, sizeof(*x9250), GFP_KERNEL); + if (x9250 == NULL) + return -ENOMEM; + + x9250->spi = spi; + + x9250->cmd_inv = 0; + if (of_property_read_bool(spi->dev.of_node, "renesas,cmd0-invert")) + x9250->cmd_inv |= (1 << 0); + if (of_property_read_bool(spi->dev.of_node, "renesas,cmd1-invert")) + x9250->cmd_inv |= (1 << 1); + if (of_property_read_bool(spi->dev.of_node, "renesas,cmd2-invert")) + x9250->cmd_inv |= (1 << 2); + if (of_property_read_bool(spi->dev.of_node, "renesas,cmd3-invert")) + x9250->cmd_inv |= (1 << 3); + + spi_set_drvdata(spi, x9250); + + return devm_snd_soc_register_component(&spi->dev, &x9250_component_driver, + NULL, 0); +} + +static const struct of_device_id x9250_of_match[] = { + { .compatible = "renesas,x9250", }, + { } +}; +MODULE_DEVICE_TABLE(of, x9250_of_match); + +static const struct spi_device_id x9250_id_table[] = { + { "x9250", 0 }, + { } +}; +MODULE_DEVICE_TABLE(spi, x9250_id_table); + +static struct spi_driver x9250_spi_driver = { + .driver = { + .name = "x9250", + .of_match_table = x9250_of_match, + }, + .id_table = x9250_id_table, + .probe = x9250_spi_probe, +}; + +module_spi_driver(x9250_spi_driver); + +MODULE_AUTHOR("Herve Codina "); +MODULE_DESCRIPTION("X9250 ALSA SoC driver"); +MODULE_LICENSE("GPL"); From patchwork Fri Feb 3 11:14:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 52465 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp781187wrn; Fri, 3 Feb 2023 03:20:36 -0800 (PST) X-Google-Smtp-Source: AK7set/cKuuhkVto98ygHLY1seF5uJkNQfXO1u3R8w6XRZwNXgND7q8P7UQR72LzzJUYlH7ueown X-Received: by 2002:a17:903:230f:b0:196:8071:2178 with SMTP id d15-20020a170903230f00b0019680712178mr11178333plh.46.1675423235871; Fri, 03 Feb 2023 03:20:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675423235; cv=none; d=google.com; s=arc-20160816; b=C2TM6UTJRvC6ful3xHYDf7r8X3ljaIyt1fIJla9axuwi4GNqdAP+qvQxDzaWh2RqHR Of/aPhA+6rWw+G3JufDo3STarucZWr70Nk9htUl9XsD2MZBKqdreiRi+pE3MYSdtGjmM 1SGp51kl2tsAHjRK3xpmqm+0hkgkkasIjefmHGgU7Zv1lUfT7t1d5xykqOuZeSExjxJi +wWPcYvXKDpBnsN35GR3Z0UnML82Mqc7ixXftjDA0ytdAl8PHwsKFHMCdVUUreHBfQvg XaeauazU0AhYpeTInS1fW0qP0DCT7HA6UqB9YDE+HkFGg7ap2/8+/oN5Gj5bMOTCT+qU v2Vg== 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=W42MFx6suAptLaA0wWjwDvw0VhASANBKLIIJxJFCArs=; b=djaqJUpvW/lJuQex5/GQ7s53gE4j8sqpIj3GkExIssO0sJ++K5x91KxX8vuthlLwds Kqeu4TgdPK+/sxll6a5McJfL8iAYwGUyHzuDdMQZt3o/8dpSCRCP02lp/b4/ALWOhe/k oAwl4odBZAKBkkFLcLDndA108Ulmi1bdwoFaG4PYPXU5HBZeIlJfESSbNl2wgTfJLamN nU1CgCyIv/k/h58RwM5FDLDe95dtVFmne4d47t+/88KkdQqBXPrCsBxUUQL/Sn/5rIs1 3yMfo2dyqzYRuToame41LNzAJtLPL5cLAJTznSMalRBdRi5eERCclN81xAu4GPv3x4r+ c4kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dUKST8CV; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a170902cecb00b001967580f630si2639009plg.133.2023.02.03.03.20.23; Fri, 03 Feb 2023 03:20:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dUKST8CV; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232636AbjBCLO4 (ORCPT + 99 others); Fri, 3 Feb 2023 06:14:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232408AbjBCLOl (ORCPT ); Fri, 3 Feb 2023 06:14:41 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5DCC903A9; Fri, 3 Feb 2023 03:14:39 -0800 (PST) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 4ED591C0014; Fri, 3 Feb 2023 11:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1675422878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W42MFx6suAptLaA0wWjwDvw0VhASANBKLIIJxJFCArs=; b=dUKST8CVaLqp2JzjKoME7qSaZpaytThUwJzR5CkybjwsmyII+N0Wgjo40ZqXHchEfutqu9 0w+4TVJTLzP9SjJVqDFv/9doCyaCC6PlbzhIM0jZqtvGxoZaK3WO8iZZPkTsq4eJNU8sJg 7My+8gqxxZxZewu8S8C7rlsdk/+cL23JpHEjbHAa+CgXOLSd7xXWu2Xpm4LKk7dI3H5AaS 3TCpEAhhD57fxMEgs1vKIaeDZT5Zm5DDcFQrm1cTkD5nuhgY2pm33i7/nBbrM5HAvd6C7m 0HFFgBF/aD3f5+AUVk8O1Dxbb4a9ff34a6JiUdHA2LfWEP6v6ygg/Ebny8fTDA== From: Herve Codina To: Herve Codina , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH 3/3] MAINTAINERS: add the Renesas X9250 ASoC entry Date: Fri, 3 Feb 2023 12:14:22 +0100 Message-Id: <20230203111422.142479-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230203111422.142479-1-herve.codina@bootlin.com> References: <20230203111422.142479-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1756808595191488162?= X-GMAIL-MSGID: =?utf-8?q?1756808595191488162?= After contributing the driver, add myself as the maintainer for the Renesas X9250 ASoC driver. Signed-off-by: Herve Codina --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 31115a7e01c1..cd22e8e06561 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17905,6 +17905,13 @@ S: Maintained F: Documentation/devicetree/bindings/clock/renesas,versaclock7.yaml F: drivers/clk/clk-versaclock7.c +RENESAS X9250 ASoC DRIVER +M: Herve Codina +L: alsa-devel@alsa-project.org (moderated for non-subscribers) +S: Maintained +F: Documentation/devicetree/bindings/sound/renesas,x9250.yaml +F: sound/soc/codecs/x9250.c + RESET CONTROLLER FRAMEWORK M: Philipp Zabel S: Maintained