From patchwork Wed Apr 2 06:44:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14035564 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24157231CAE; Wed, 2 Apr 2025 06:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743576287; cv=none; b=GqbjU/e7lMJvvmzKPLfk6vmB4dGtjSkRClOsvewgZ1230M7gTOph7NfXBqbp1w4mEYu4pc4e8kgnkHQmeqwdlKwFmxgPorqKwrNixLeIomeoAoVGLYtkHUasWUlFql7A29DXXrZi23/QH79i5pWQzJYFH9X5pKGIGpTG0qPdo2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743576287; c=relaxed/simple; bh=w59FUeUJ5lPfldVA7sWBkOtZqptARVo6IrhNG/64huQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=siJUiJodDsaCfP6LJELaPUZiKgV52uHYblfNPRwJjQyOAFYnpgbs6spdS6fjtGKptmULUAa4KjQTfRgNp/4WXYNzUU83YJ3UI5w1GGxN/ShHV5yGnYj4b+UptKMyMuzcuAk7pVo28+qPwqBo0F33bHCXOqOJhTfDVdUfaUQlUCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=L0Eq3dVU; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L0Eq3dVU" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5499659e669so1877428e87.3; Tue, 01 Apr 2025 23:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743576282; x=1744181082; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LlH9M3OOE5qNDtaUmP7iITtLaH6D+OBrVLCEyeDjplA=; b=L0Eq3dVULScAZfDhvtuQha6vnu8sHnGOUxWVyLSbRsS+fTtXJDp/6BX/YletD1S6ud YT+BDUi3gXYc6dYYd6BqsDP6jEVcigAc49l/5Grvenj76nlFZv/fVu34kQkPNLeRGpo0 ISXnynhxFDJrv0z3ifeYA4bN1t286v7CyXaZuNOp0DdZUFRBPikVYf+HBiWIkcl+k2E+ CEE+BStAh4lrfdzV84daoyCauNS41t1Gq5BSO5FJA+d7SZpBlfCSo/PQAYC8SiGWHdJQ kfvBjBpnqhAxQqJFUe/FVnRvapYgn/wMyCaLEQoQOUav3ZzX/RcnQty+hEQer4W5SHNx DsSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743576282; x=1744181082; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LlH9M3OOE5qNDtaUmP7iITtLaH6D+OBrVLCEyeDjplA=; b=arN0AikuE/Qyqjb2GrXs9kmHwEjKCIjY5YdaCGWFSBT5dR2kzaJ+MO6U32OoVBRh9J BrHCuI7YYJJJqAi+Tr5exBAFcez38rfgpJprenSevROwcn98SZwASQFfby3kl5AOUbI6 hWLtJQPeG9XzkMxKvK+A/bdZ9n1VC4N0/AWzkseNJ93hhMyd4MIm1kZiCs4YtcoGQ305 6DUy0cElgAqbpN2K8GDr1lfvrAViShonEzOipSDFoFyNaQaiQfm9+0g9TyxBpTSX6qPh YwTsYTuvYWQRivzlo8y9a7lEhAm/yntZN4+PO5fN/RZVRcbjKu+zar6t08xlYXJ2tzdp jwbw== X-Forwarded-Encrypted: i=1; AJvYcCV0PjPjR2M0G7Oyp9npRbjdw7azFYkTD0jNmu5F5KaSHvUNo8LtIMR1FHVCZeNTBZY/0utGQDMZir62@vger.kernel.org, AJvYcCVAGU4lfGDoeEXegnlL3YT3JrXtgYqd6PVXvaQNS/IEfTCfvBiu7USHQo4hgipkmE9PkicTRZc2nxp15gpW@vger.kernel.org, AJvYcCX/tjllaRaRGw1MWjctV64MbqLnsSzOElsxFhZRpSW7N2Rki910q4OBmjUf/YHQyaAdNq48cTU0Vj6N@vger.kernel.org X-Gm-Message-State: AOJu0Yxbm97k5FbMDXRsiHeL363S3aFl10NaDAaF1Nov3Gxcar5F/cXT w0ublwmMWz8bVIGQMatINUGmCBP5GU/RtIs/G8Mf951X2kYI+6Jw X-Gm-Gg: ASbGncu1+1sbAf1fMEySaAP4kztpz8TdzH+6PztzQY1OWxHkMuIrgal/FVNr7J4/Ubz UIJV3UNprlHTrEYZCQz09jAWIFpj8XDzwIu1DZSaOUucGAXA878Qd03cO3oorTZz9shXo0LCbsU EXatBbNk7PEjpxrV4uQIhPQ6ujQe49+cEMi+WqmUIW1w38rOpvA3SRQOIJHUp0VR+z3galHS8KJ yc7fnpRzYSWOXkHu/0B1SKYdtE2GH+yLckmi/YY6r+7zpmz9WkkRhrjv/1WOF7jRpadp28MLPu8 UkkBdsIAIapikmSNh+0vExzuXCx4Kicca6NdZb3B79tK4+ags9s= X-Google-Smtp-Source: AGHT+IGFT6J2izO71CRheocjLo5evyR65cdzQ6iy3ERf8IGLMKjqQ1niS6wikLh0W4i40nsVElLc6Q== X-Received: by 2002:a05:6512:3c9a:b0:545:2cb6:af31 with SMTP id 2adb3069b0e04-54c0a4bfa6amr1552669e87.15.1743576281785; Tue, 01 Apr 2025 23:44:41 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54b094bb4f8sm1598873e87.36.2025.04.01.23.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 23:44:40 -0700 (PDT) Date: Wed, 2 Apr 2025 09:44:36 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] dt-bindings: Add ROHM BD7970x variants Message-ID: <0a114565e4de52bf8f98c4f9d17943e5148b0112.1743576022.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The ROHM BD79700, BD79701 and BD79702 are subsets of the BD79703 DAC. The main difference is the number of the channels. BD79703 has 6 channels. The BD79702 has 4, BD79701 3 and BD79700 2 channels. Additionally, the BD79700 and BD79701 do not have separate Vfs pin but use the Vcc also for the full-scale voltage. Add properties for the BD79700, BD79701 and BD79702. Signed-off-by: Matti Vaittinen Acked-by: Conor Dooley --- .../bindings/iio/dac/rohm,bd79703.yaml | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml b/Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml index 188b00333dfb..c00fa50e42e8 100644 --- a/Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml +++ b/Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml @@ -5,19 +5,26 @@ $id: http://devicetree.org/schemas/iio/dac/rohm,bd79703.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM BD79703 DAC device driver +title: ROHM BD79700, BD79701, BD79702 and BD79703 DACs maintainers: - Matti Vaittinen description: | - The ROHM BD79703 is a 6 channel, 8-bit DAC. - Datasheet can be found here: + The ROHM BD7970[0,1,2,3] are 8-bit DACs. The BD79700 has 2 channels, + BD79701 3 channels, BD79702 4 channels and BD79703 has 6 channels. + Datasheets for BD79702 and BD79703 can be found from https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf + and for the BD79700 and the BD79701 from + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79700fvm-lb_bd79701fvm-lb-e.pdf properties: compatible: - const: rohm,bd79703 + enum: + - rohm,bd79700 + - rohm,bd79701 + - rohm,bd79702 + - rohm,bd79703 reg: maxItems: 1 @@ -27,19 +34,31 @@ properties: vfs-supply: description: - The regulator to use as a full scale voltage. The voltage should be between 2.7V .. VCC + The regulator to use as a full scale voltage. The voltage should be + between 2.7V .. VCC. Not present on BD79700 and BD79701. vcc-supply: description: - The regulator supplying the operating voltage. Should be between 2.7V ... 5.5V + The regulator supplying the operating voltage. Should be between + 2.7V ... 5.5V. Is used also as a Vfs on BD79700 and BD79701. required: - compatible - reg - spi-max-frequency - - vfs-supply - vcc-supply +if: + properties: + compatible: + contains: + enum: + - rohm,bd79702 + - rohm,bd79703 +then: + required: + - vfs-supply + allOf: - $ref: /schemas/spi/spi-peripheral-props.yaml# From patchwork Wed Apr 2 06:45:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14035565 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8894C3C17; Wed, 2 Apr 2025 06:46:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743576366; cv=none; b=OKMFr4se7QNoijdhH79PRkWUysAWZWI6NRpnOiyLR6UvqG2aIUHYoGmqJ9mFsgGn1JqfGmLpFLCGpQp88U9WswYYyHEDLXotOnGiJyLo2h6gnZZtedDVzaXW2PsjXKUJM3DUGC80O0h7oHA2a9yJVcj8B0oztb8/mvaUU5eaXgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743576366; c=relaxed/simple; bh=NuDLQRs5l0dChPpwOQQfl42OYxc8n6kig9UU+8ovl4k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=syaGrVe6uXBQ8Qe28rBXdo4q+GzBRYNTo3m9cLrOJncOmAkiKtMBFqVv7LbWZOgcN9upaDWKhWA6HaOXM6J9hEr0j/1OlPVwzAo87OWP/BGGx8X7IVQHBvE8XzcQi5wCp8gSGnTJwgwLs2wNxJ3XKcBZrkEE7py+CwZEv784jEE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hIw3jWvM; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hIw3jWvM" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5499659e669so1878441e87.3; Tue, 01 Apr 2025 23:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743576363; x=1744181163; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4EA3jhMqOTPL7EhQ50J1i67Md0hhqleTtmmrsXC2hOk=; b=hIw3jWvMo6HAqC7Gs/6kK9HUjHYlD4mbaemEP4lHZ91qILQ6U0pwJRt0bn3Q/RXehV kc+Mg4jnTrKu/miOBXHLx1ZmhLjJTH+xKJKL3bL9QAZFQmPf7mgT2BDa04ks61fE9XYJ 2r2jPFWAvIvNQcxsrqboEikkdgWaJOLXGJORqzkfZnScCmIVaryJ6vvYxV0cz+Tx3y1C BbNIsO+JX+67eOeMEd39LiCmrd/RSd/KTDe98SPkJRsPJ9tM17VF0E4OlO5ABpJqZWe5 7Ccjjl7QU5tw8lkkts/XlyVluCVIKz3hi8udy94mOtlGkxr6uQSWpdoEuGO14UvOFcmR oT7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743576363; x=1744181163; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4EA3jhMqOTPL7EhQ50J1i67Md0hhqleTtmmrsXC2hOk=; b=dtqYgFdx3bKSXpbl1jwji7HIlSJM+6H6pr8UlaauY+HHWJKu0agZQQdI9opq738wd/ FRKNhNO98lEDsrA6YITXQ1IsBcakWIMptQcCOLy8H813NBqgKBc9OQBVSVq584kjIWTU TT3vkJKgr/uEt5kSZr5jtnAGDLz76pR8qdnvSfCPbIxq60+bTjUBkiNL807TkMOqnyn5 nBBFFmpcU3/mWsAKq22wfw027vxsJaNfyNkn3tsnFHNkIGTm0ihHYbKl+Nov0DhHu0BJ /U4uiGrfe9JzA6d6LqNFU5PunIw7ocZv+cboDy6FFaRDHfPMReRD8YVDB2RhxOP/U/lh UF2w== X-Forwarded-Encrypted: i=1; AJvYcCVZ83Md9e54LNtacLJbRMfuAI5wT4tQAvEtF+I3VPd57Vc8cXGiVDfM941qvT/8eghsCnwO3CukM5af34+g@vger.kernel.org, AJvYcCX2mbG8Xsm+5D+o1iPmgIsbaAKF8SqBvjN2CwrfFxxiyst66yK/JO0ywzhSvCDGPnreKC2PKdy2QUFb@vger.kernel.org, AJvYcCXgNKQfdbWp4TPGbJ+MaIAOtVJV6okcRo9lVr65rDzG7/EhkHo/UgSq/OCnFEMlq1eemp/b9Oipd5SE@vger.kernel.org X-Gm-Message-State: AOJu0YyUcnD+jCKo3tWHkp5RngeJsB8uRF1P/zDoOmXxeAPU/27m8DqD t90Xf90pr4KvPdpQAevwoOgWx7ieDWw/694i4dgjcJ5MCeMLTfybnnqGiw== X-Gm-Gg: ASbGncugE3H/ghj6Q82S3izxtfBQBbm7ChwFmCWgmoP+GLyI9SlnWFogZRIyZV4MOsj j0iBT13sHQkon9hM7pPrBTyP0jCEOOvPO3bEcfisMNsu9XM1WUxUWEQnvJKio2O0o0DWBHT6T7M mR/OUJpGm65oNN3SaMzQxe2d1HrduBn9wS32sdxNDwCdzptAdV9wCjNdyN3xP8zkBLrX0vZi3hp I/2OFMbt9/AkvliSyLLcksRjT4HOEnKAylGr7QgOtJ5PHHLTtr1C5gplLa2q3kEzRlJPsKdkCq7 Fiir7GAsL0xv+PEEyBzFan+a6JuwnRez6T+QrUbHMmFGeP5Ljcc= X-Google-Smtp-Source: AGHT+IH5GCpE6QqU5Mq/4YURzGIUmuOkOuIthVzMwLwK3aArcaQtDZ/O+W0/TUDnugU1nkzcTIbJcQ== X-Received: by 2002:a05:6512:3b25:b0:54a:cc76:1676 with SMTP id 2adb3069b0e04-54c0a52846dmr1605252e87.44.1743576362479; Tue, 01 Apr 2025 23:46:02 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54b094bb0e1sm1551511e87.52.2025.04.01.23.45.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 23:46:01 -0700 (PDT) Date: Wed, 2 Apr 2025 09:45:56 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] iio: dac: bd79703 Store device address to 'address' Message-ID: References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The ROHM BD79703 needs to identify a channel which we are reading from in the SPI transfers. This can be seen as an address for the device. For the bd79703 the address is nicely aligned with the channel number, so the driver uses the channel ID for the SPI transfers. This, however, does not need to be the case. The iio_chan_spec has a separate 'address' field, which we can populate directly with this information. This helps adding new ICs like the ROHM BD79702 where the channel ID is different from this address to be handled by this driver, so we don't need to have separate, IC specific mapping for channel numbers <=> addresses. Make the 'address' field in the iio_chan_spec to contain the SPI protocol address for the channel, and use this value in the transfers. Signed-off-by: Matti Vaittinen --- drivers/iio/dac/rohm-bd79703.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/dac/rohm-bd79703.c b/drivers/iio/dac/rohm-bd79703.c index e998ab51052e..236aa98bf005 100644 --- a/drivers/iio/dac/rohm-bd79703.c +++ b/drivers/iio/dac/rohm-bd79703.c @@ -67,7 +67,7 @@ static int bd79703_write_raw(struct iio_dev *idev, if (val < 0 || val >= 1 << BD79703_DAC_BITS) return -EINVAL; - return regmap_write(data->regmap, chan->channel + 1, val); + return regmap_write(data->regmap, chan->address, val); }; static const struct iio_info bd79703_info = { @@ -82,7 +82,7 @@ static const struct iio_info bd79703_info = { .channel = (_chan), \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ - .address = (_chan), \ + .address = (_chan + 1), \ } static const struct iio_chan_spec bd79703_channels[] = { From patchwork Wed Apr 2 06:46:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14035566 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7895232792; Wed, 2 Apr 2025 06:46:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743576382; cv=none; b=ZnF8d9O8OKJ/kRahY0YzH/WOKLBhYUrVtIZ8v3RoJ0f1P2+BPYJc3H2WGWF6u1QZ5G9YA+3uBRKufKiQCc/mUgAEPxbBs3lj50R4r7uLPaU6SsYwUPOM59OdMhvO3GQVUaAm18+UIy5U9kQi/xD6K114MMka6KiHm1Ibm37feD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743576382; c=relaxed/simple; bh=5Tu6qFtZWZlXL2BchJOllZFpT7StVUWq2Xga5P56KVY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qifg3LwRNfJBpNFIqNVI6+TS1Fgrh5Rhr+z3DHF4f8fdNKaApbeTIB10Lt7QAqP2SLVkaK/2BkMlKHV8ZR3bZq8GnIung0GVSaR7H4o+2IrNt14NnFu5P5mpXsY4J/e7aWvGOjed9oNQRPxyJpSf8O8+6iP5cNj4Cicees9iyUw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MqFGXQ5d; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MqFGXQ5d" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-30db2c2c609so68066031fa.3; Tue, 01 Apr 2025 23:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743576379; x=1744181179; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=jA/5cJRyzUpXOaAYgVofpvVcnYlQLgyR64YPAjaXn4c=; b=MqFGXQ5dYjNQS3k7n15Xv4DJnpIRXLbC2hUW/a7JL0zTwbbXrHx83piaO7ftHy8gmF +J0Cva8jGIcTAMSFZrgtUklWr0qACK+pgZqB/vXOGtPkXz+T8Ld6zQLvdT8Uhy2l4f25 0sNDgEjAOf6+fjkeQutpyWjmuzmJo3d/PERF8lGuKghTPImpWEAfzfd3phRsYxc4W6Rg FTiJtZyMhnMLeM4p2DD2SX/FvsGRTvuLlkh9QaKY4ZiX6Ni1o5wDiSnLKv7bXltZ06m1 9ToQGEfBG2jREWsblykf+FGnPf7SL2ljw7SAgn5lWAXCWhcXSwB99EuPS8BHiyX8LlFQ X5PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743576379; x=1744181179; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jA/5cJRyzUpXOaAYgVofpvVcnYlQLgyR64YPAjaXn4c=; b=ZdB6TRSYh5OdTTSTXzq+GGGuTEfvsPQ9tKLOrlopVfwoiZsAEsQlkqk6Qdg3/q23vA RS59lUmb13yirz1PpZvVUyZJT+p9McGyZ3tSgDugFEudCySbSowx0XvovfzPyz66mwfn Yl/VTbM1Go9VIuXmiOXTct7BYwVs5w2used7MJOKhFpjQoQyw8QZRxh9dnjJl2OdyLac PRmwJHxHVWjRLjkMzbts8cJJsji83PDiSUbBuWaXKGLkhbNZ5x+GrpTY6DcyUlcQf9dq BfLzUxzfLKDchCVvWtA3R7/EwVXyiBtiqfDEF+sN13NS3LJvCe48LdypnJZIfT2nC0Bu BejA== X-Forwarded-Encrypted: i=1; AJvYcCVzYjw9+6d2ac1ChVFeUpcCTCtt3Bch5HBjFY4IxYFpqnJGrtFS/bGHGEszFJHsEFTA/gYGi4hZYS7T@vger.kernel.org, AJvYcCWd73xY1kIMaFybSjGa2w7sg5DKCl2EFD7p1ZmaoYGuLRFsx32Yw+sQWLkj9C2l8Lr94e3KAwB1DEKOfXyn@vger.kernel.org, AJvYcCXvxNhzWWOKNbA3woXF2AupU3i4mitKEPq05Sq2Zi0jOr+lBjVUmj8Kq8ZqPtt9limNkAPqGDc08CrS@vger.kernel.org X-Gm-Message-State: AOJu0Yw/y+daji6FIJgvfwaC0U9jsrubMBcnWvhAROtqe9gLh5SjnUFl rdXG9u6oBvdHFIpDiUX6MEfvNuvPF0dXbLCq7VZO4At/012VQIEO X-Gm-Gg: ASbGnctVFyLp3i3nlEsgHRybu2o8Mdb/GXensG7wCd67ahXpp55Q6DwBWRXe7Rju/j0 op5RroA+pEGIuZR8gXPMQLhzMA+azBaHZzdOzHJd4nci28yhJGa6CpSoQ8I5lrblkoNiUemLXA0 ZnsFHGYeNlWLRAtZaeugOP3DgZGz/6c/HxFb0XZ8oliQ6gtAugRnATfSWLToXFGK8OT8j79SAZz tlOxRr8ltBIDuolotsu5FVkSD51xr7LfL8bSwAtDlPRnJpypoYYoMfmjC/46mPrP0tw8d/56gId 9YoagqXsukkbuJ32tQadWKUu3poW5pY6649N6RcXSIUMYUX15DE= X-Google-Smtp-Source: AGHT+IH3us/H9vhFC2mYeXA90ODjOuqI0X+m8v+9sdO78B95L0RxeTQM6Rmi6GpJRPSkZbkgwoD7nA== X-Received: by 2002:a05:651c:1615:b0:30b:c8b1:dd95 with SMTP id 38308e7fff4ca-30eecd3bdfamr20586391fa.22.1743576378478; Tue, 01 Apr 2025 23:46:18 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-30dd2b8f6bbsm19654271fa.111.2025.04.01.23.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 23:46:17 -0700 (PDT) Date: Wed, 2 Apr 2025 09:46:13 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] dac: bd79703: Add chip data Message-ID: <2cacb4bec5455fe1aa58a0b28d2d91b96a396d1a.1743576022.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Add a chip data structure which allows handling the different variants (ROHM BD79700, BD79701) with different number of channels. Signed-off-by: Matti Vaittinen --- drivers/iio/dac/rohm-bd79703.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/iio/dac/rohm-bd79703.c b/drivers/iio/dac/rohm-bd79703.c index 236aa98bf005..35e1b1134ec6 100644 --- a/drivers/iio/dac/rohm-bd79703.c +++ b/drivers/iio/dac/rohm-bd79703.c @@ -38,11 +38,19 @@ static const struct regmap_config bd79703_regmap_config = { .cache_type = REGCACHE_RBTREE, }; +/* Dynamic driver private data */ struct bd79703_data { struct regmap *regmap; int vfs; }; +/* Static, IC type specific data for different variants */ +struct bd7970x_chip_data { + const char *name; + const struct iio_chan_spec *channels; + int num_channels; +}; + static int bd79703_read_raw(struct iio_dev *idev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -94,13 +102,24 @@ static const struct iio_chan_spec bd79703_channels[] = { BD79703_CHAN(5), }; +static const struct bd7970x_chip_data bd79703_chip_data = { + .name = "bd79703", + .channels = bd79703_channels, + .num_channels = ARRAY_SIZE(bd79703_channels), +}; + static int bd79703_probe(struct spi_device *spi) { + const struct bd7970x_chip_data *cd; struct device *dev = &spi->dev; struct bd79703_data *data; struct iio_dev *idev; int ret; + cd = spi_get_device_match_data(spi); + if (!cd) + return -ENODEV; + idev = devm_iio_device_alloc(dev, sizeof(*data)); if (!idev) return -ENOMEM; @@ -121,11 +140,11 @@ static int bd79703_probe(struct spi_device *spi) return dev_err_probe(dev, ret, "Failed to get Vfs\n"); data->vfs = ret; - idev->channels = bd79703_channels; - idev->num_channels = ARRAY_SIZE(bd79703_channels); + idev->channels = cd->channels; + idev->num_channels = cd->num_channels; idev->modes = INDIO_DIRECT_MODE; idev->info = &bd79703_info; - idev->name = "bd79703"; + idev->name = cd->name; /* Initialize all to output zero */ ret = regmap_write(data->regmap, BD79703_REG_OUT_ALL, 0); @@ -136,13 +155,13 @@ static int bd79703_probe(struct spi_device *spi) } static const struct spi_device_id bd79703_id[] = { - { "bd79703", }, + { "bd79703", (kernel_ulong_t)&bd79703_chip_data }, { } }; MODULE_DEVICE_TABLE(spi, bd79703_id); static const struct of_device_id bd79703_of_match[] = { - { .compatible = "rohm,bd79703", }, + { .compatible = "rohm,bd79703", .data = &bd79703_chip_data }, { } }; MODULE_DEVICE_TABLE(of, bd79703_of_match); From patchwork Wed Apr 2 06:46:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14035567 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B360D3C17; Wed, 2 Apr 2025 06:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743576399; cv=none; b=KNmjlv9icN8OziKsvFyBYdzI4nri6YQCHmy5jv39iouQcnYil5X5IMReElY09wnjsxKKkw5HmZLmU3BvKaV3ZJ6zIy97ovUIxHAPoGYRZOBFhkInT3ukuVN3ygTlEnBSSq3XJDFcJ3XS/Rr6wHmHuZW5+8aBhDNsVujAQwdtUYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743576399; c=relaxed/simple; bh=IUwdUbHeFL0dqDwaq4iIV3I6pbitR6/LH0Nohc/Vqqc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z6/dykrfJqONla0IO6VmVPHvUmnkNy/Rxz9ntwDTazl4AbN062xEICUd3necyM+Dw56zKEmdDSngfZZwjbe6XLdaIz/kU8DRa95LAPmL3iJrujiqtqKKreahdK8jUKBcrGfCSlA3nrtcVZsYe7uHEUtGBYHBTR6opjWeKtlU4MM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c3BFJMR8; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c3BFJMR8" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-54acc0cd458so654492e87.0; Tue, 01 Apr 2025 23:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743576396; x=1744181196; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TApx6q5zRSyJu5vFDntepnYrxk7e4Dyv7PtEpuL5hI4=; b=c3BFJMR8jrQygWYcOi4RH/D7So5ON5G0UTAZJfqdELycOCCO69rYthanBhsQb7ipu2 K0A8kfgFBLkZDcO8QhbKZUkNhIEksB6gh6TWlg7CpXC4KYH7AMY6Bpi9RpS8tChszX66 1hKINopQFEmqqNxalqf9PyoyeEOAMXDv9P5HqIVUy/8wWjz0AIOCbFEab35J/2XZPZTv r0LMK4rUjARMSDulsTKflVeaPIRWco3Y35kefAZtYVFav3hI+fZwZAuDYrenRlv9tMdN megAAZaA0IpxHX87gsieH6OpUOgDP/DCAlAkR9XcxppoWUUro8TO28qtejYGC33SeEgJ a/XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743576396; x=1744181196; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TApx6q5zRSyJu5vFDntepnYrxk7e4Dyv7PtEpuL5hI4=; b=CLeek4db6WO8uH8LdpfR3ycKSgCZ0G7iGTvkDQrtyJ9sk+OT6SuR6mr/uuZESlitnB +D2xYHDGgFOkKgyCH3F4gJfo+lvh0VhsjeUQVccQHZV++sjqyjouqKlgyD/0mvJ83HjM RBsVvaskIw8OMLV9jMGrfdFnZK+ZjHkNTKDCa3ap8Dlgyx0njbzu1wDvnSiSf+9piS6+ ViU01yaEpfi59HdiGR611/S1EzYKhLz7fXwL4wVIatYTVz9N+bHhbPM0q4WARXrs9k0Y dAgFlBJkcol3gdXPNL/32Rq1PoD48OlPvh6L1FjZc/l9Nda0knLqrP3zGaN+iJGNYlIt 9JjA== X-Forwarded-Encrypted: i=1; AJvYcCVyYeCNpPUBfca0doEaxdgiNm6+m9eXL4nZuUl4gVNi1GxfqAsLUgnqjNkRVhEvDavXOFLqyEjS3N03@vger.kernel.org, AJvYcCWQiWBgzAX/DtVGLd7b/XziPVH9bSnlWCLtRfACJn6EZLooma37kAYQ7L0zAsbGo2ONifj/4jIa2XLWZRVw@vger.kernel.org, AJvYcCXN8VyETmbgIuGfhLFfP6dC6+j0ZAbn+ZEOEKfK5Zh2v5JPfldF7GXtmkRZEo/i70pyfrUf5PTRQeJ5@vger.kernel.org X-Gm-Message-State: AOJu0YzOCNgfhSauqhFGOL9XIGMMMsULDWd9/tQJyx0R8aX6j5bn2QfY Sheewg128O++jTEK4c2TPZDH9K079kmVZ9lF7536mXSlXOKk4ccx X-Gm-Gg: ASbGncsDx08LKz7yzxem43809aWCpAsOfX3Jkf6s8Uo6K8HNfIdB/h6gHcHbHTgbY6w U/jjn7dA/OWC43JGlKj1FjmpXNdNZ1RTzXf15iM3qGXjg7eJRpPV2zWKgpfZIOLngLDIC5sXfL4 e5eqk+9z7f/bGSaLpr+MepT6/NOw2nSklZfy7I70cPaNd9d3LoyjNLK6Yp4+/4A0eSDZNmiJ9PU cw7dr8lTCFHlTEf54pgvxEucupMdvo77wS26ofNCazv5MZ/aqSq7DYEJfDCrAJBElOiHHWDn0hf X+VSJI64EFycYhKviRScOAl6cth1Vb+u970cy/Dj8iia0IDO9HM= X-Google-Smtp-Source: AGHT+IHB1cqHIml6QCpYB2EIlpijEXbykwLbiu/6J4VIivRNVo2eFNPbbx98QtlmqxGoDkmvo9h1IQ== X-Received: by 2002:a05:6512:3e08:b0:545:f70:8aa7 with SMTP id 2adb3069b0e04-54c19c6b888mr393715e87.32.1743576395582; Tue, 01 Apr 2025 23:46:35 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54b094bb3fasm1528319e87.25.2025.04.01.23.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 23:46:34 -0700 (PDT) Date: Wed, 2 Apr 2025 09:46:30 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] iio: bd79703: Support BD79700 and BD79701 Message-ID: <845aa45974f6fb81c83046368a24a0674e9a8b0e.1743576022.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The BD79700 and BD79701 look like almost exact subsets of the BD79703. The BD79703 contains 6 channels (channels 0 to 5). The BD79700 provides only 2 channels, matching the BD79703 channels 0 and 1. The BD79701 provides 3 channels (matching BD79703 channels 0, 1, and 2). Furthermore, the BD79700 and BD79701 do not have separate VFS pin but use VCC for the full-scale voltage. Suopport these ICs using the BD79703 driver. Signed-off-by: Matti Vaittinen --- drivers/iio/dac/rohm-bd79703.c | 57 +++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/drivers/iio/dac/rohm-bd79703.c b/drivers/iio/dac/rohm-bd79703.c index 35e1b1134ec6..63a70fbd7e0e 100644 --- a/drivers/iio/dac/rohm-bd79703.c +++ b/drivers/iio/dac/rohm-bd79703.c @@ -49,6 +49,7 @@ struct bd7970x_chip_data { const char *name; const struct iio_chan_spec *channels; int num_channels; + bool has_vfs; }; static int bd79703_read_raw(struct iio_dev *idev, @@ -93,6 +94,17 @@ static const struct iio_info bd79703_info = { .address = (_chan + 1), \ } +static const struct iio_chan_spec bd79700_channels[] = { + BD79703_CHAN(0), + BD79703_CHAN(1), +}; + +static const struct iio_chan_spec bd79701_channels[] = { + BD79703_CHAN(0), + BD79703_CHAN(1), + BD79703_CHAN(2), +}; + static const struct iio_chan_spec bd79703_channels[] = { BD79703_CHAN(0), BD79703_CHAN(1), @@ -102,10 +114,25 @@ static const struct iio_chan_spec bd79703_channels[] = { BD79703_CHAN(5), }; +static const struct bd7970x_chip_data bd79700_chip_data = { + .name = "bd79700", + .channels = bd79700_channels, + .num_channels = ARRAY_SIZE(bd79700_channels), + .has_vfs = false, +}; + +static const struct bd7970x_chip_data bd79701_chip_data = { + .name = "bd79701", + .channels = bd79701_channels, + .num_channels = ARRAY_SIZE(bd79701_channels), + .has_vfs = false, +}; + static const struct bd7970x_chip_data bd79703_chip_data = { .name = "bd79703", .channels = bd79703_channels, .num_channels = ARRAY_SIZE(bd79703_channels), + .has_vfs = true, }; static int bd79703_probe(struct spi_device *spi) @@ -131,15 +158,25 @@ static int bd79703_probe(struct spi_device *spi) return dev_err_probe(dev, PTR_ERR(data->regmap), "Failed to initialize Regmap\n"); - ret = devm_regulator_get_enable(dev, "vcc"); - if (ret) - return dev_err_probe(dev, ret, "Failed to enable VCC\n"); - - ret = devm_regulator_get_enable_read_voltage(dev, "vfs"); - if (ret < 0) - return dev_err_probe(dev, ret, "Failed to get Vfs\n"); - + /* + * BD79703 has a separate VFS pin, whereas the BD79700 and BD79701 use + * VCC for their full-scale output voltage. + */ + if (cd->has_vfs) { + ret = devm_regulator_get_enable(dev, "vcc"); + if (ret) + return dev_err_probe(dev, ret, "Failed to enable VCC\n"); + + ret = devm_regulator_get_enable_read_voltage(dev, "vfs"); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to get Vfs\n"); + } else { + ret = devm_regulator_get_enable_read_voltage(dev, "vcc"); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to get VCC\n"); + } data->vfs = ret; + idev->channels = cd->channels; idev->num_channels = cd->num_channels; idev->modes = INDIO_DIRECT_MODE; @@ -155,12 +192,16 @@ static int bd79703_probe(struct spi_device *spi) } static const struct spi_device_id bd79703_id[] = { + { "bd79700", (kernel_ulong_t)&bd79700_chip_data }, + { "bd79701", (kernel_ulong_t)&bd79701_chip_data }, { "bd79703", (kernel_ulong_t)&bd79703_chip_data }, { } }; MODULE_DEVICE_TABLE(spi, bd79703_id); static const struct of_device_id bd79703_of_match[] = { + { .compatible = "rohm,bd79700", .data = &bd79700_chip_data }, + { .compatible = "rohm,bd79701", .data = &bd79701_chip_data }, { .compatible = "rohm,bd79703", .data = &bd79703_chip_data }, { } }; From patchwork Wed Apr 2 06:46:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14035568 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF9D4233120; Wed, 2 Apr 2025 06:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743576414; cv=none; b=s3ibM9mDNVQMHpITAe8gNirZBbFeR+jDrWid/J/I7gdxEb9OojCAb7L4mZgUiXU8YFsbjbIgwr3+9F8/XGGAtOv9MyQW5pRZ9sW5uT8gnZAq2qLsoV7RWDHRdb+J3y9xMIm6OIjMUfmO/OOwg0lvQDQA0Z3++WaTxbUzm15p3jA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743576414; c=relaxed/simple; bh=nkRavN6buF/gDxrwD8ipXn3zBnd8c92ETh2ZfteLGR8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uAJrU92S2KCwKb/waKursCXLPd482FEiaZoEZRRq1Y6U6sCQ58a43aC7+hrnvU4dxTLd4aIABvt2TDzTC4smwGIKPfnspitE5McvRHFTYwXGGKWV8bhHfb+NrDWAcDn5m+6P/n/7lK/aXYQRA+mCAx+5+yWCBe+m7ZgOBeh+fF0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mM8yFs2r; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mM8yFs2r" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5493b5bc6e8so7368976e87.2; Tue, 01 Apr 2025 23:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743576411; x=1744181211; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ayqc2RZYibXbV7INci6LOKqfBRG/lehCl0hQkPSJT3w=; b=mM8yFs2rmn4ZVe88nac6UjRD/jRF/94wFRGSYoNlxAnKp8YdI89JqPucd8X2ylCA17 gw5TeqYgOQhZU42eOUBItFPJZc76HHmkacajuNowU8kT5L6uLSk9XxTMeV+Uycrd4XK3 2umQaAEEqp3UNgKOEykqEp6xhEwvzNKCXOvJWshIPFNnFgz5rVfDkMpIw6Loqoi9Ktdn RFzFfcwlteHlVycGgn8Ei4iTC6iCJggt+zZB7bkTXoHoZ4VVuOZONIZErE2KenOFaOmu T8H3Gc187O/j4cwDFmn1tdgtNQmoBKLiFiab8NKp31IRE9J/hm3KCPz6z7RP9tFg8Ck8 k/Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743576411; x=1744181211; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ayqc2RZYibXbV7INci6LOKqfBRG/lehCl0hQkPSJT3w=; b=B+90LEJXUPI3NRVgkZtMFjLNMxkwqDs15kHw+rEF1+LJEYibOwuScnKhQjPV8/M2J5 UzmRI5TQ8id9p6Wqj54VLWwIm3tY6G8IF0xbO28GpHEceK+x4XA6+Wm0hmFuBC0KDHMF ixswtW7fEMRBpO+4PTVf2WYSYUM++nqGoErnSKnW+G1PIZV/PeA8sx4Pb/BhoxEylR6T BTdGMLLjob6tgHayiAp8+isqNZbvHKGF9JqE4mac0T79MwBd30elBguiZbIfhcRLfO1V 8f+2sZHnAskwM1VBdQqcvmvQ/Mt2k8hSDU/bIHa/zqGE3f7Bo40wMkC1jEY6amMEMjgu luPQ== X-Forwarded-Encrypted: i=1; AJvYcCUZp3E/Rjk/mmD/kBFyZ59Q9FRQLafFDmMjdb5asql9YndISOMJs+75JoaVwtQ6zGYbljY/yjVbI0qVSAIB@vger.kernel.org, AJvYcCUow+I+x9kGVU+PRAxxVUhys/xn+vJSP5yccTqrTu9t4w9hhI9WKlI79eG8AZB+WGu0VijHFPVTXqMG@vger.kernel.org, AJvYcCUvUsvnvTIwKFMrMvUisSxCiRwDXp6uGnhe7PfMOommwvaGaZE7rjDNFu6j4SIjR0ZrAWLjjalalF5M@vger.kernel.org X-Gm-Message-State: AOJu0Yy1cvQeuICzt1HVywnpTOdYvD9ebfAFsVOSvrO20tlWNdweHWng AAtCKK+PQXfUaEyBWCWaDLNGpnz3O/hCcB55LRBLdqjeBhrCruW84BoSzA== X-Gm-Gg: ASbGncssVBABde2ym0fm2tQ4dVi95JtuNB/EXUpB8AxcPVSErCxDtOc8X351LfigFad es78NQTt3o6iLFhGL6PiOx4COzg70ACUW32XeQh9pPnph5PaZYZuI7kNnJwa+7k0wNTatP6kdel IuO/D+zwA2cCdycEHyWOJ/S52WSXxZ1tw4XcIutbMF7INNabdqfxJKc0K0RWeQGg8hQu2EJjJWa 93VIhhVtFhQxqxdz3yXW68Abk3525VQIEDYjmpA+wt5/y0bObSPSdcb/WrUHPNxjZid77uf/+hG B7vduE9d/NLXQBYtd/ONmNE9DavYjt1Ug3IV3W2ZN9Yd2emDqaQ= X-Google-Smtp-Source: AGHT+IFR9Ck0yqG+KnntspR+Gy2gkKn6NFQkQkePv1P78O/icStSCVvG66ZUA06QNn200dki2vpisw== X-Received: by 2002:a05:6512:3d89:b0:548:526c:fb99 with SMTP id 2adb3069b0e04-54b10dc8aaemr4923042e87.18.1743576410838; Tue, 01 Apr 2025 23:46:50 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54b095a20b1sm1552549e87.246.2025.04.01.23.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 23:46:49 -0700 (PDT) Date: Wed, 2 Apr 2025 09:46:44 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] iio: dac: bd79703: Support ROHM BD79702 Message-ID: <0ba243a63115dd4af03ebf9656c65b8c259a3e34.1743576022.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The ROHM BD79702 is similar to the BD79703, except that it has only 4 channels whereas BD79703 has 6 channels. The channel 'addresses' of the first two channels (used to identify the channel when data is read over SPI) are same for both ICs. The next two channels of the BD79702 have same addresses as the last two channels of the BD79703. This means the BD79702 channel addresses do not follow the channel numbers with a constant offset. Thus, we need to specify the addresses separately, instead of directly deriving them from the channel number with a constant offset. It's worth noting that the data-sheet describes the BD79702 as a device having channels 1,2,5 and 6. The driver however represents channels 0,1,2,3 to the users - with no gaps in the numbering - which may be more familiar view for the application software. Support ROHM BD79702 DAC. Signed-off-by: Matti Vaittinen --- drivers/iio/dac/rohm-bd79703.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/iio/dac/rohm-bd79703.c b/drivers/iio/dac/rohm-bd79703.c index 63a70fbd7e0e..a35c37d2261d 100644 --- a/drivers/iio/dac/rohm-bd79703.c +++ b/drivers/iio/dac/rohm-bd79703.c @@ -84,16 +84,18 @@ static const struct iio_info bd79703_info = { .write_raw = bd79703_write_raw, }; -#define BD79703_CHAN(_chan) { \ +#define BD79703_CHAN_ADDR(_chan, _addr) { \ .type = IIO_VOLTAGE, \ .indexed = 1, \ .output = 1, \ .channel = (_chan), \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ - .address = (_chan + 1), \ + .address = (_addr), \ } +#define BD79703_CHAN(_chan) BD79703_CHAN_ADDR((_chan), (_chan) + 1) + static const struct iio_chan_spec bd79700_channels[] = { BD79703_CHAN(0), BD79703_CHAN(1), @@ -105,6 +107,19 @@ static const struct iio_chan_spec bd79701_channels[] = { BD79703_CHAN(2), }; +/* + * The BD79702 has 4 channels. They aren't mapped to BD79703 channels 0, 1, 2 + * and 3, but to the channels 0, 1, 4, 5. So the addressing used with SPI + * accesses is 1, 2, 5 and 6 for them. Thus, they're not constant offset to + * the channel number as with other IC variants. + */ +static const struct iio_chan_spec bd79702_channels[] = { + BD79703_CHAN_ADDR(0, 1), + BD79703_CHAN_ADDR(1, 2), + BD79703_CHAN_ADDR(2, 5), + BD79703_CHAN_ADDR(3, 6), +}; + static const struct iio_chan_spec bd79703_channels[] = { BD79703_CHAN(0), BD79703_CHAN(1), @@ -128,6 +143,13 @@ static const struct bd7970x_chip_data bd79701_chip_data = { .has_vfs = false, }; +static const struct bd7970x_chip_data bd79702_chip_data = { + .name = "bd79702", + .channels = bd79702_channels, + .num_channels = ARRAY_SIZE(bd79702_channels), + .has_vfs = true, +}; + static const struct bd7970x_chip_data bd79703_chip_data = { .name = "bd79703", .channels = bd79703_channels, @@ -194,6 +216,7 @@ static int bd79703_probe(struct spi_device *spi) static const struct spi_device_id bd79703_id[] = { { "bd79700", (kernel_ulong_t)&bd79700_chip_data }, { "bd79701", (kernel_ulong_t)&bd79701_chip_data }, + { "bd79702", (kernel_ulong_t)&bd79702_chip_data }, { "bd79703", (kernel_ulong_t)&bd79703_chip_data }, { } }; @@ -202,6 +225,7 @@ MODULE_DEVICE_TABLE(spi, bd79703_id); static const struct of_device_id bd79703_of_match[] = { { .compatible = "rohm,bd79700", .data = &bd79700_chip_data }, { .compatible = "rohm,bd79701", .data = &bd79701_chip_data }, + { .compatible = "rohm,bd79702", .data = &bd79702_chip_data }, { .compatible = "rohm,bd79703", .data = &bd79703_chip_data }, { } };