From patchwork Tue May 9 16:08:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 91644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3004776vqo; Tue, 9 May 2023 09:14:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5vwJG8fY3ysoBfs4XL/j/hYf/GvidbchLd3ire3Rjw+2Qwh5m9ibarmDkvLd1ToNHSCIfS X-Received: by 2002:a05:6a00:23d3:b0:63d:4752:4da3 with SMTP id g19-20020a056a0023d300b0063d47524da3mr18245819pfc.25.1683648844452; Tue, 09 May 2023 09:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683648844; cv=none; d=google.com; s=arc-20160816; b=wBjUlvU8cVyudOlcCDMLSTuCdMjEvfWF+3mKa9XPuoCwq42jLOd9GUz1CoEYmChYc4 hHDZ+cshpvcsYwgFskN+VuGGkxwsa7MJDDnvCLOvILRo7Yyp0XICiMlCgAZR/jGSKnQf VK0huQy51Om3JtcbYS+o+V3lNHt968seuwrYAzhfOpPG7ibhN6qox61iic+MUm9DrJh4 3NCBpZvKnDv/IyGlGYjbN9TnRgN1KlAa6sEkjUn7bs6ymax033Yjr8fXLwV8FBvAruYb ANk8r0ZQARXDEtK/kzrrUPQs3qtfnc+FRpBatzCNjLvaV7qWJeR6Z4QAoqMwrF/fPLpT 4HvQ== 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=9kMsDQBfor4spt7iEDtWMeNz0VMgYY5+MkzcLfMNcc0=; b=pxjTHnjxTjOaNVOygdIVadea7tSKpH+rDmbpkrdCwXyMegVS+rq/d6NzbmrBhitZmx 14SVMiL6BdMzIQDtz4XLs/ofWPHQo7z+AzcyyiTAwhZtFsTdfCLRila5N+22Jhm4J+ka KOTWmDcmA5gYSx3jUXFvMYCnc2X0BAafELWLTUGvEGD4TCaXKRS/FxhFfBXn2EhhkaZG 7qch5OCdln11DMPcOFFiTloQpNqupyVcemLcx2LwZQAacyjHaKSPYEy1/EXsEqnfq0Z6 sx+uf2aai4rlY8QeB+muQB7lJFM3THWEpNnup3620CSzi5wegN+zZ3gNtAyfZzotU7S8 mKPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="Qlps/wnx"; 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 a3-20020a63e843000000b00528ca114e67si1795459pgk.898.2023.05.09.09.13.51; Tue, 09 May 2023 09:14:04 -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=@bootlin.com header.s=gm1 header.b="Qlps/wnx"; 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 S235777AbjEIQJU (ORCPT + 99 others); Tue, 9 May 2023 12:09:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235729AbjEIQJR (ORCPT ); Tue, 9 May 2023 12:09:17 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88C4D2120; Tue, 9 May 2023 09:09:15 -0700 (PDT) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 9152EFF80F; Tue, 9 May 2023 16:09:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683648554; 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=9kMsDQBfor4spt7iEDtWMeNz0VMgYY5+MkzcLfMNcc0=; b=Qlps/wnxI542IxIOJuq0zxgs4sl/Z8DeS7UeaYSSVpCco6nB3QENDvwAbexhpjCb4eCLNn 0Y7ZBycY+Hv7W4CMY4J/BhLIH4q22AQXbYU2YmeVYOt8v7pBi1qCFSk1p8C/7LVocWkrqZ 97H/tl/gDNNJnoIMKg7ijeM4nZ0db79pA/XSbMtbCO+ACY94IBov0FWJBliXj31HFmZqHf WKWZ/8rdBtYrQ8PYzXSnwaq62EGHvff7ZgoOrB3SXV6zkRQjK4VDT30SJ/h796jpAlMOwU z0WcU2MUmd7POgx6uKlOl+dYZOMA11SKZ0RpCJMH95RNAFffEqfFKSWBySsO5g== From: Herve Codina To: Herve Codina , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v4 1/3] dt-bindings: iio: potentiometer: Add the Renesas X9250 potentiometers Date: Tue, 9 May 2023 18:08:50 +0200 Message-Id: <20230509160852.158101-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230509160852.158101-1-herve.codina@bootlin.com> References: <20230509160852.158101-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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765433770825183349?= X-GMAIL-MSGID: =?utf-8?q?1765433770825183349?= The Renesas X9250 is a quad digitally controlled potentiometers. Signed-off-by: Herve Codina Reviewed-by: Krzysztof Kozlowski --- .../iio/potentiometer/renesas,x9250.yaml | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml diff --git a/Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml b/Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml new file mode 100644 index 000000000000..ab5c09c00ff4 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/potentiometer/renesas,x9250.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas X9250 quad potentiometers + +maintainers: + - Herve Codina + +description: + The Renesas X9250 integrates four digitally controlled potentiometers. + On each potentiometer, the X9250T has a 100 kOhms total resistance and the + X9250U has a 50 kOhms total resistance. + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml + +properties: + compatible: + enum: + - renesas,x9250t + - renesas,x9250u + + reg: + maxItems: 1 + + vcc-supply: + description: + Regulator for the VCC power supply. + + avp-supply: + description: + Regulator for the analog V+ power supply. + + avn-supply: + description: + Regulator for the analog V- power supply. + + '#io-channel-cells': + const: 1 + + spi-max-frequency: + maximum: 2000000 + + wp-gpios: + maxItems: 1 + description: + GPIO connected to the write-protect pin. + +required: + - compatible + - reg + - vcc-supply + - avp-supply + - avn-supply + - '#io-channel-cells' + +unevaluatedProperties: false + +examples: + - | + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + potentiometer@0 { + compatible = "renesas,x9250t"; + reg = <0>; + vcc-supply = <&vcc_regulator>; + avp-supply = <&avp_regulator>; + avn-supply = <&avp_regulator>; + wp-gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + spi-max-frequency = <2000000>; + #io-channel-cells = <1>; + }; + }; From patchwork Tue May 9 16:08:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 91654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3017399vqo; Tue, 9 May 2023 09:32:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6dHvj+HOKEHVPRa2ISPV18luxa/ZYMe4CNcQZvUCw0+sKRMxYe/IhHE0v8iXwzjav+DKpd X-Received: by 2002:a05:6a00:1311:b0:63a:fae3:9890 with SMTP id j17-20020a056a00131100b0063afae39890mr17985437pfu.24.1683649928864; Tue, 09 May 2023 09:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683649928; cv=none; d=google.com; s=arc-20160816; b=VvcMWT3IEKdyFTcXkX2wcqEDlm8OUQlVaKfcRvX75bAlnFN9rfHnje8ir2zdNBrfT2 CWihUckffsHWDb6ljJz9O9NBOk0ot1wb/yJ84ctpxJIZYUg69toq1c3XviH9Ybk6Z90I 7Oqd83cnEmCQHTsZnox1V6dDbNLIAYqz9zCV5gXy0qA5Xf7iPsBJeTr84Mv/tiKgegqF Y18i2exUXPMOQCnKq3DsT2ERxgHpJEcFKOBL0OJ6ABTSmYPJSTSIrzhUB8LTWXyv5VJI KRF4T/MfgcJ16otEdUZ25icejYagebI4rHeLKMT82kLeghRH/kwMzj1XmCLDk1WvM9bB 9YAg== 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=ZCRkhFR06vPBPYnYS6pds8F9tYZWCNedEUh6aEbvGHw=; b=Qiyy3lD77nr4aF6B7k6vjI404/cmiY5vN1QJZLECOjstm5e8c+XQWCgc6zyUdmOMJM RYqjNveNocI2DIVwF3LLtHiqX7e1835dCDZq7wRwTvv0haEL5Mu9CTwCYpo8K+fb1Zat J36vr+wk8gyE7EFv1jY/jLebsyOaHvIx2aFSNft/tNUsosHC1Ze/lBf1FlVlf0B1gQp8 4rl5rZO4Gka7hCMancEAkLxLweA4+aNyv/Z6WXUsSKVKm13TuUlR9pZxlavALUbb06gV N4nyPZrwfObzJigU8VXn0P1xmQHSr2mGzmbD2V2LD276cNFQ39q2IAGGiUnpslGSl9ZP 4neg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=K26BywLs; 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 64-20020a630043000000b0051453dfd139si1801796pga.613.2023.05.09.09.31.53; Tue, 09 May 2023 09:32:08 -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=@bootlin.com header.s=gm1 header.b=K26BywLs; 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 S235729AbjEIQJ0 (ORCPT + 99 others); Tue, 9 May 2023 12:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235753AbjEIQJU (ORCPT ); Tue, 9 May 2023 12:09:20 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28182198E; Tue, 9 May 2023 09:09:17 -0700 (PDT) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 0E568FF808; Tue, 9 May 2023 16:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683648556; 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=ZCRkhFR06vPBPYnYS6pds8F9tYZWCNedEUh6aEbvGHw=; b=K26BywLsaW+WXL8J/wyF+28wpw8+j5fhpe0NGB6iboS1/6eb9xf1kfmbenQkA2Dxv2zWbl L4UeDkXPUGoyPaSxhLDfZ/Nb2omwvAYb+CvavlsjNSBRDrYyZheoxEhAicjUMUoM8+jDEK o4yGOY+fXUyIk3Md7SLsvkhx2I1Vmj+eWUKSylX4tpz9CyO9n4CnB0zSmuGniDv1ip40fz LoKZAIkNtcBjPO5If11/IcQL1mMXN5Ao9ncEug+u8DGpudHWReW1mHQyPo2BV9VyqTYr7E fkeJorCecd2BGzBLftLkHMjojsjWCaB6r3WBFAFbOH1UkIaBKHa7DPFWye5nNg== From: Herve Codina To: Herve Codina , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v4 2/3] iio: potentiometer: Add support for the Renesas X9250 potentiometers Date: Tue, 9 May 2023 18:08:51 +0200 Message-Id: <20230509160852.158101-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230509160852.158101-1-herve.codina@bootlin.com> References: <20230509160852.158101-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, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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?1765434907701204282?= X-GMAIL-MSGID: =?utf-8?q?1765434907701204282?= The Renesas X9250 integrates four digitally controlled potentiometers. On each potentiometer, the X9250T has a 100 kOhms total resistance and the X9250U has a 50 kOhms total resistance. Signed-off-by: Herve Codina --- drivers/iio/potentiometer/Kconfig | 10 ++ drivers/iio/potentiometer/Makefile | 1 + drivers/iio/potentiometer/x9250.c | 223 +++++++++++++++++++++++++++++ 3 files changed, 234 insertions(+) create mode 100644 drivers/iio/potentiometer/x9250.c diff --git a/drivers/iio/potentiometer/Kconfig b/drivers/iio/potentiometer/Kconfig index 01dd3f858d99..e6a9a3c67845 100644 --- a/drivers/iio/potentiometer/Kconfig +++ b/drivers/iio/potentiometer/Kconfig @@ -136,4 +136,14 @@ config TPL0102 To compile this driver as a module, choose M here: the module will be called tpl0102. +config 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 x9250. + endmenu diff --git a/drivers/iio/potentiometer/Makefile b/drivers/iio/potentiometer/Makefile index 5ebb8e3bbd76..d11fb739176c 100644 --- a/drivers/iio/potentiometer/Makefile +++ b/drivers/iio/potentiometer/Makefile @@ -15,3 +15,4 @@ obj-$(CONFIG_MCP4131) += mcp4131.o obj-$(CONFIG_MCP4531) += mcp4531.o obj-$(CONFIG_MCP41010) += mcp41010.o obj-$(CONFIG_TPL0102) += tpl0102.o +obj-$(CONFIG_X9250) += x9250.o diff --git a/drivers/iio/potentiometer/x9250.c b/drivers/iio/potentiometer/x9250.c new file mode 100644 index 000000000000..3d4ca18d1f14 --- /dev/null +++ b/drivers/iio/potentiometer/x9250.c @@ -0,0 +1,223 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * + * x9250.c -- Renesas X9250 potentiometers IIO driver + * + * Copyright 2023 CS GROUP France + * + * Author: Herve Codina + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +struct x9250_cfg { + const char *name; + int kohms; +}; + +struct x9250 { + struct spi_device *spi; + const struct x9250_cfg *cfg; + struct gpio_desc *wp_gpio; +}; + +#define X9250_ID 0x50 +#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) +{ + u8 txbuf[3]; + + txbuf[0] = X9250_ID; + txbuf[1] = cmd; + txbuf[2] = val; + + return spi_write_then_read(x9250->spi, txbuf, ARRAY_SIZE(txbuf), NULL, 0); +} + +static int x9250_read8(struct x9250 *x9250, u8 cmd, u8 *val) +{ + u8 txbuf[2]; + + txbuf[0] = X9250_ID; + txbuf[1] = cmd; + + return spi_write_then_read(x9250->spi, txbuf, ARRAY_SIZE(txbuf), val, 1); +} + +#define X9250_CHANNEL(ch) { \ + .type = IIO_RESISTANCE, \ + .indexed = 1, \ + .output = 1, \ + .channel = (ch), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_RAW), \ +} + +static const struct iio_chan_spec x9250_channels[] = { + X9250_CHANNEL(0), + X9250_CHANNEL(1), + X9250_CHANNEL(2), + X9250_CHANNEL(3), +}; + +static int x9250_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct x9250 *x9250 = iio_priv(indio_dev); + int ch = chan->channel; + int ret; + u8 v; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = x9250_read8(x9250, X9250_CMD_RD_WCR(ch), &v); + if (ret) + return ret; + *val = v; + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + *val = 1000 * x9250->cfg->kohms; + *val2 = U8_MAX; + return IIO_VAL_FRACTIONAL; + } + + return -EINVAL; +} + +static int x9250_read_avail(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, long mask) +{ + static const int range[] = {0, 1, 255}; /* min, step, max */ + + switch (mask) { + case IIO_CHAN_INFO_RAW: + *length = ARRAY_SIZE(range); + *vals = range; + *type = IIO_VAL_INT; + return IIO_AVAIL_RANGE; + } + + return -EINVAL; +} + +static int x9250_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct x9250 *x9250 = iio_priv(indio_dev); + int ch = chan->channel; + int ret; + + if (mask != IIO_CHAN_INFO_RAW) + return -EINVAL; + + if (val > U8_MAX || val < 0) + return -EINVAL; + + gpiod_set_value_cansleep(x9250->wp_gpio, 0); + ret = x9250_write8(x9250, X9250_CMD_WR_WCR(ch), val); + gpiod_set_value_cansleep(x9250->wp_gpio, 1); + + return ret; +} + +static const struct iio_info x9250_info = { + .read_raw = x9250_read_raw, + .read_avail = x9250_read_avail, + .write_raw = x9250_write_raw, +}; + +enum x9250_type { + X9250T, + X9250U, +}; + +static const struct x9250_cfg x9250_cfg[] = { + [X9250T] = { .name = "x9250t", .kohms = 100, }, + [X9250U] = { .name = "x9250u", .kohms = 50, }, +}; + +static const char *const x9250_regulator_names[] = { + "vcc", + "avp", + "avn", +}; + +static int x9250_probe(struct spi_device *spi) +{ + struct iio_dev *indio_dev; + struct x9250 *x9250; + int ret; + + ret = devm_regulator_bulk_get_enable(&spi->dev, ARRAY_SIZE(x9250_regulator_names), + x9250_regulator_names); + if (ret) + return dev_err_probe(&spi->dev, ret, "Failed to get regulators\n"); + + /* + * The x9250 needs a 5ms maximum delay after the power-supplies are set + * before performing the first write (1ms for the first read). + */ + usleep_range(5000, 6000); + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*x9250)); + if (!indio_dev) + return -ENOMEM; + + x9250 = iio_priv(indio_dev); + x9250->spi = spi; + x9250->cfg = device_get_match_data(&spi->dev); + if (!x9250->cfg) + x9250->cfg = &x9250_cfg[spi_get_device_id(spi)->driver_data]; + + x9250->wp_gpio = devm_gpiod_get_optional(&spi->dev, "wp", GPIOD_OUT_LOW); + if (IS_ERR(x9250->wp_gpio)) + return dev_err_probe(&spi->dev, PTR_ERR(x9250->wp_gpio), + "failed to get wp gpio\n"); + + indio_dev->info = &x9250_info; + indio_dev->channels = x9250_channels; + indio_dev->num_channels = ARRAY_SIZE(x9250_channels); + indio_dev->name = x9250->cfg->name; + + return devm_iio_device_register(&spi->dev, indio_dev); +} + +static const struct of_device_id x9250_of_match[] = { + { .compatible = "renesas,x9250t", &x9250_cfg[X9250T]}, + { .compatible = "renesas,x9250u", &x9250_cfg[X9250U]}, + { } +}; +MODULE_DEVICE_TABLE(of, x9250_of_match); + +static const struct spi_device_id x9250_id_table[] = { + { "x9250t", X9250T }, + { "x9250u", X9250U }, + { } +}; +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_probe, +}; + +module_spi_driver(x9250_spi_driver); + +MODULE_AUTHOR("Herve Codina "); +MODULE_DESCRIPTION("X9250 ALSA SoC driver"); +MODULE_LICENSE("GPL"); From patchwork Tue May 9 16:08:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 91648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3006337vqo; Tue, 9 May 2023 09:16:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7bBfYfBhr5wL5BS7WLa80TZLFWOelnrKiflde6BW0qS1e+RQ9b3FeSXFZXu8xhozZZMVaQ X-Received: by 2002:a17:902:f54b:b0:1aa:fe52:a827 with SMTP id h11-20020a170902f54b00b001aafe52a827mr20021456plf.13.1683648965180; Tue, 09 May 2023 09:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683648965; cv=none; d=google.com; s=arc-20160816; b=sQ9s5FXqMe+CWZ5xqf8hfyYzye0vCVp8MVmmuoYSk5bS8zQLNAHb30mNm5RBFz0rv0 wh/4lHwkqnfC0/EPLT7+8QrdOBkaWb6tXRBFjQiZ6OAxrN4lCGSYseCJzMTD/CvILZxi OWKDlMgX2qhW38mMvnixlJ6PMosapk7riyTFhxXuExMhw90vX4ng51e+TLlMLMAsCKOW o94gMEQT36xDrAFPyhnUuAaZSgyET4gqws0XQCTf/imZyfS+HgiuxVyBV8ViC6ABCne1 LM8U4PP1B4nIlm4UfUgvTOmeC4uLK0oaSLWaMxotfP3VbrCAFTlqk4ApytTYJSsHpOTf PJag== 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=AMT/NRMGkvesRao22DI/CnATsgCB4x0ohxacGPVBFig=; b=mcm9MWF+HWinUrHeESnvA/fF8CQdWQepBytRdQA1UvET+QRTLO3VJ6Cm4IgZapRjG1 5qhs967y5bkUqRAFu2UcRnUgU56aH3ku9IcbwkTn+XkZNa+HA/P0GupIS2uN/N7ilu69 zxw95EUojnqlFSFbpKm1xQnKiL4+rPW1xc7Z2A1Dmgmkl6bmWBe28D/OobJoUMWkvnkv xPTXcIPPe0aI3Nv31AWZyf3/Dm08uTTj+rKNXmUF1euWBZYzWJC+usxDkN9CStYhWeS9 oA+/HKNiNEEbOfklhuzDYrbKo7/StdbEMY9WgoLOtaZtr7aVe8r4UOfdKmJ1lpSSodTt 6XTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DNwEcu3R; 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 j15-20020a17090a588f00b0025004bcf6casi4948423pji.4.2023.05.09.09.15.49; Tue, 09 May 2023 09:16:05 -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=@bootlin.com header.s=gm1 header.b=DNwEcu3R; 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 S235753AbjEIQJ2 (ORCPT + 99 others); Tue, 9 May 2023 12:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235798AbjEIQJV (ORCPT ); Tue, 9 May 2023 12:09:21 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF2046B5; Tue, 9 May 2023 09:09:19 -0700 (PDT) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id ABB76FF802; Tue, 9 May 2023 16:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683648558; 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=AMT/NRMGkvesRao22DI/CnATsgCB4x0ohxacGPVBFig=; b=DNwEcu3RL6mBBxwzjx2zv1J3gagktt8if0saz4r/gGoQPfx4Ig4ER6xU7frrOy5DXjbQfG MHwGoXiyUijMfVoVxTLDIRRfCkx4LMzvfF1MerzQSCX2rU/iVj07cM/43IthEadMMrzWh4 kN13T4BWHXnQBQ70naWAUzvRDedYgNl6OAvVkHZ3PHrnwlisEk1BS4A29zD414dEX3XMHH Ulw0EcFLw+d5G+fICU5/krijqSZSb6EJMfJtjlI4dYp6/QaF3dlKoagW0bdrjXQmw9eC4A iKPfoBRxuyff09j+w7in4nmkfnU+2UNv6xcCTeKJkbzF3QDrVScf0Obqj8QEhQ== From: Herve Codina To: Herve Codina , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v4 3/3] MAINTAINERS: add the Renesas X9250 driver entry Date: Tue, 9 May 2023 18:08:52 +0200 Message-Id: <20230509160852.158101-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230509160852.158101-1-herve.codina@bootlin.com> References: <20230509160852.158101-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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765433897327911756?= X-GMAIL-MSGID: =?utf-8?q?1765433897327911756?= After contributing the driver, add myself as the maintainer for the Renesas X9250 IIO driver. Signed-off-by: Herve Codina --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7517002b7735..159b3e7ce566 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18046,6 +18046,13 @@ S: Maintained F: Documentation/devicetree/bindings/clock/renesas,versaclock7.yaml F: drivers/clk/clk-versaclock7.c +RENESAS X9250 DIGITAL POTENTIOMETERS DRIVER +M: Herve Codina +L: linux-iio@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/iio/potentiometer/renesas,x9250.yaml +F: drivers/iio/potentiometer/x9250.c + RESET CONTROLLER FRAMEWORK M: Philipp Zabel S: Maintained