From patchwork Thu Oct 31 07:17:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13857640 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 A512C14883F for ; Thu, 31 Oct 2024 07:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359075; cv=none; b=Gxp9Rp+BPj22TvKVPnFsuddkVPZuFfIy/zMN7RUJenSYcWnssh8+/1o9h9Wl4tO1YN0sceSPw/JxKiPt8HH5qU9mFzgPv2XKGDvRnsobi19nM2xjQWoewNWnvtlUwVLhbFk+iqF8O4S8UtMkPc0Lf1IRf5u+aiKBMvDu30qaIqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359075; c=relaxed/simple; bh=xu4vcOByqa0T+o0Mtg/VMSPa5suwUETcqrDuyfDGNgQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oG+qg/13ItS6VzHu1FQGieOTtQDAAQABGHbpJ24i+f01aAcg08gwUjVlJ+6xl1xfmNareq72IZV+C8CjojA42MPnh6Uy9nCkDsRPeTGCbYvCpZ7K4J0BEIjjUBxy4yDn4IQa97PLW1mYV4KDNtpWZ9VSJcwYYRWSnQptuHyBdkk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=LlMyQyNf; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="LlMyQyNf" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-37d49a7207cso458195f8f.0 for ; Thu, 31 Oct 2024 00:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359071; x=1730963871; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m6z7u9n04i1CD+dVrnwMZN3subLaG04bfZd3Fni/4JM=; b=LlMyQyNfYnMucYPqFikZvNwyXYu4Yd4ozfSFZTRxmq3hBmBHZgDZpzf1Pevq7xwQb0 2sl6nlXojLiVtjy4LhsNSxTYYKrK5Yhhlmt/1PZ5hXY4WZ70wABFA15EHH6jp/ObSSo+ 01foXQyha3AV4txE76kCG1zE2CagYyhHOT+y42WeOk4sTHNRWKT9R2foD4PTjS8D879J Xd9oJHKyFh9JOv9+dIq4ek9bIdD+jGmPrSHtl9PbQOcnBRkgTqCDAnQL/c09ZTZz1v6c kqxpZ+poh6Kktjhl5wAJV4FUzwTQMuoFys996EaRZdnkMen/7NNn7PM9jgC88GlQCD49 iZgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359071; x=1730963871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m6z7u9n04i1CD+dVrnwMZN3subLaG04bfZd3Fni/4JM=; b=ucJFhq4my+DqguKIUqXgCDlCLytUofrWwJtfAhwKxl3CaGrB+A1vhSWnNbNZDu/sXH YU0FX+OxcH8R9+DbW1SYqTmIzUAlWiL0r+2HmHIMbtE52vikuyResM6AnurwghXV/Hzm OrhshU0/hkEq1N99l1k5Q6HE7x+/wAybevu1hkRCZHyeE6Rv0dVF8Z/9npDwpQ7yUidR LeCnOzp1A4EFdWumsfEvjtX9pyTNnvdifM2rEAyPoPZ2nUn4etfbLnvsaRWKDcJrIF2G fqbNOSp4+GmspmlcOUNG/NDEc7BcEhbWFV7amFNJluNdT7aI64gcwAI03LeB8StzwUep /16g== X-Gm-Message-State: AOJu0YyAAI7nQq/zUGGt9re5c/EoTTmVWdVOAcg2PYZiNig//NOMwvtK 8fiDq0TkzUmpzwTmqe2KVPuXLXAKuHkbW4q/dkTzotPwyzJ+5RG9L7JdV0Ieiuo= X-Google-Smtp-Source: AGHT+IHqsSrRK3WaqLyPzOG0cz8hA2PrJwrsarp3k2DUiOAi+1UO9m3fvc3ksKyJ1vyEA2H50edTtA== X-Received: by 2002:adf:e543:0:b0:37d:54d0:1f20 with SMTP id ffacd0b85a97d-38061158e30mr12973741f8f.24.1730359070881; Thu, 31 Oct 2024 00:17:50 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:50 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam , Krzysztof Kozlowski Subject: [PATCH v3 1/6] dt-bindings: iio: dac: ad5791: Add optional reset, clr and ldac gpios Date: Thu, 31 Oct 2024 08:17:41 +0100 Message-Id: <20241031071746.848694-2-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam Depending on board layout, the ad57xx may need control of reset, clear, and ldac pins by the host driver. Add optional bindings for these gpios. Reviewed-by: David Lechner Reviewed-by: Krzysztof Kozlowski Signed-off-by: Axel Haslam --- .../devicetree/bindings/iio/dac/adi,ad5791.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml index c81285d84db7..fe664378c966 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml @@ -31,6 +31,17 @@ properties: gain of two configuration. type: boolean + reset-gpios: + maxItems: 1 + + clear-gpios: + maxItems: 1 + + ldac-gpios: + description: + LDAC pin to be used as a hardware trigger to update the DAC channels. + maxItems: 1 + required: - compatible - reg @@ -44,6 +55,7 @@ unevaluatedProperties: false examples: - | + #include spi { #address-cells = <1>; #size-cells = <0>; @@ -53,6 +65,9 @@ examples: reg = <0>; vss-supply = <&dac_vss>; vdd-supply = <&dac_vdd>; + reset-gpios = <&gpio_bd 16 GPIO_ACTIVE_LOW>; + clear-gpios = <&gpio_bd 17 GPIO_ACTIVE_LOW>; + ldac-gpios = <&gpio_bd 18 GPIO_ACTIVE_HIGH>; }; }; ... From patchwork Thu Oct 31 07:17:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13857641 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 E5C93148FF6 for ; Thu, 31 Oct 2024 07:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359076; cv=none; b=iEYUUfZbrGkygG7jv+a/xYqtq4GEiLSmld7qIZEFbB3nt8twawYIBG1IbP36bo3wNQt1qLrcDw8iIxgYpE9fTtzR6xDWVCvrvTfR9GGL3hNN9w4ZJq+WHXYRTHAb8f6AM7bfk81Yyp2kn1mBaNJnv+R0uEAIUl+3JZsbj5bBkZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359076; c=relaxed/simple; bh=np8Q2QVfQltUi41eXVufgARgz5a+zr3MKMZbbDyqKkI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VwUZ+8BFJ4c9Busa+yAqTxl6yPaLUcR2zXb+RRK5WAZJ+93U/MuiFMEGtcQ3FypgrKE8CEvUrbZwkMLr6KIk8ZWS+zWdM2pfiztoW39VEQqLK8X+2aOQyhtbyCz3L/RnHb6BZ/wOwDt+Ej38QQPkDBG/P3w5TNuWmZ/GtI06lHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=SxSUVrM4; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="SxSUVrM4" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-37d8901cb98so1072884f8f.0 for ; Thu, 31 Oct 2024 00:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359072; x=1730963872; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6XokXFUnFUJYwTRpNxF4QEO2NzHATnQ3nu28Wn+V/kw=; b=SxSUVrM4fAUILA9cth/SWarYnL4MtdrKyRVQa96SpQnIowveED4X91Mi7WflpU6XeX gW3vX0vuI/E6I8NpGouWb6BKtDfiU+Rg81aA00NzjSNvY/X7LBouUaKUFQyt9ndYKRpB QZzoNleGguRy3J3jEfNRZgmSb6KlQ19zbS2k3u2oJuDok6viEE3uzg94mmN8F/7WubbV /JNkXlIOyyhtbs0P6tk901dP/jGKTaBIaTAU2cNnGI0MCIIR7MvKAz9ZcHiGPu7AaYpQ BOUpQbQcyEkCUXswpWptL1AP9+V2giIPdBLHwTBj8RzjwiLty8uJF8EQ/FYcz5avDQiS Rszg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359072; x=1730963872; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6XokXFUnFUJYwTRpNxF4QEO2NzHATnQ3nu28Wn+V/kw=; b=EF2/0Q7e0PNOzSV34TyVWKUMyne8DL2Fxf2Pl4HUui8wVR3KK2woFVU00DiFOjovWi 7RzI46tw8qBrRtLdIdwDudlt38d4iel45/pnJCBeoUlx8tlay4giEy/ojvqYy60O9bBY xoAh+9LeuQkS/8xHE0dhDUYIt5nLGPu/9vEPpNHc0M4v0lAu9DwnUFkkOm6M+zZ5UoNZ sxTyn+tKXDnV4TiaaSYrLtKPhH6gwbJUECGikCZCrsYN9yOFuD/A93xjwV4QsNdQ7zaU nSOW8rhgUsMOu3Y2dhUqcTzMq31U2Oxior5hM9x4dMR4xhqgWkV9Cte0XL40L7SptCQ3 8/jQ== X-Gm-Message-State: AOJu0Yz3T1p+1Habr3XgfD025Faqd6RuicHOJjrwZL94fCGn+RN4ylXl NgwmIXHs6N5ZqYj2Oieq4dFHdZH0C3oTALBv+UlP6nG3mYr1oWNvqupuvtNDN5Q= X-Google-Smtp-Source: AGHT+IHwQ7oBgfvFPEWdP5rY03R7404nWDkpFlRIwBt15xycWEIbwG4Y8/p8O6RKEwgky5rkwhtGjg== X-Received: by 2002:a05:6000:1869:b0:374:c6b6:c656 with SMTP id ffacd0b85a97d-381c14c3469mr1015819f8f.21.1730359072176; Thu, 31 Oct 2024 00:17:52 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:51 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam , Krzysztof Kozlowski Subject: [PATCH v3 2/6] dt-bindings: iio: dac: ad5791: Add required voltage supplies Date: Thu, 31 Oct 2024 08:17:42 +0100 Message-Id: <20241031071746.848694-3-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam Vcc, iovcc, vrefp, and vrefn are needed for the DAC to work. Add them as required bindings for ad5791. Reviewed-by: David Lechner Reviewed-by: Krzysztof Kozlowski Signed-off-by: Axel Haslam --- .../bindings/iio/dac/adi,ad5791.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml index fe664378c966..79cb4b78a88a 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml @@ -26,6 +26,22 @@ properties: vdd-supply: true vss-supply: true + vcc-supply: + description: + Supply that powers the chip. + + iovcc-supply: + description: + Supply for the digital interface. + + vrefp-supply: + description: + Positive referance input voltage range. From 5v to (vdd - 2.5) + + vrefn-supply: + description: + Negative referance input voltage range. From (vss + 2.5) to 0. + adi,rbuf-gain2-en: description: Specify to allow an external amplifier to be connected in a gain of two configuration. @@ -47,6 +63,10 @@ required: - reg - vdd-supply - vss-supply + - vcc-supply + - iovcc-supply + - vrefp-supply + - vrefn-supply allOf: - $ref: /schemas/spi/spi-peripheral-props.yaml# @@ -65,6 +85,10 @@ examples: reg = <0>; vss-supply = <&dac_vss>; vdd-supply = <&dac_vdd>; + vcc-supply = <&dac_vcc>; + iovcc-supply = <&dac_iovcc>; + vrefp-supply = <&dac_vrefp>; + vrefn-supply = <&dac_vrefn>; reset-gpios = <&gpio_bd 16 GPIO_ACTIVE_LOW>; clear-gpios = <&gpio_bd 17 GPIO_ACTIVE_LOW>; ldac-gpios = <&gpio_bd 18 GPIO_ACTIVE_HIGH>; From patchwork Thu Oct 31 07:17:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13857642 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 7BD42149C6F for ; Thu, 31 Oct 2024 07:17:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359078; cv=none; b=aMMhQaeoiuoQ12Ge9kjR8U6st0FuZqozidjeAU9899TfwKLZ+oyq+s4ChxAWzL7flLSZprwcPaQ5P8z7mel124wPMSv6no12L8Rkug/KRd/YsUkU4kkKlZAFCxhins9FwGH0CrfXl7ljQ8j6EMH4XyjguF/LeX6DDfVwD/y6NbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359078; c=relaxed/simple; bh=j6d0colaxPKycD+GQrCgSDLkv20Xcns4fpDxmhAFBNg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=otAqlg8k6JgMEOGo7NIJ2T9DJBBhWidn9ZXVRvYoJCRI2tWCSYdgFVKUKcGtZSPUcZT9NYgotdH+tNDZ0eOQXBQO9qp87RmqqfxA0IK9LtQVb/1eEuCdVHkp/1omuZoIy3GP5Ks7uAq9hLQHAIuLJwyt4df7F19YlCCvytP4snU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=rvsYjor/; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="rvsYjor/" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-37ec4e349f4so393611f8f.0 for ; Thu, 31 Oct 2024 00:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359074; x=1730963874; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NH5MUt/+cbzy9bnDTQWkFoXyedi+6bP21xIeET9Apek=; b=rvsYjor/Om2bO7suxr9Cx5PntCLvajHVWLdchLch+UKKc/OfeQoo+YdFT7VahF9zsl 6Ep6iVOq5YWaUeivyj5fUBbalRZaEUaZmp85LDUAQeLb9uKPTzcCGrME1nriG8zo6kha Gd1AT/kpM2Amp0UxOW3TTfibjh44TgyhGADPKccI8hqyiMYBagfMKwYMnzcrHl8YYT0g P9Odlyp9dWyd5caifoGewGuzQzBzJ7d2EeTU2kL8n/ECytlbJiHoumbl+DmlqEpeL32E CrjLJnmCz+afRr6m7umGB9wHhdB6VrFKQEi1Nwp4uVNQ2CITcG+ZZ5/JxrCmW8649+kD TDHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359074; x=1730963874; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NH5MUt/+cbzy9bnDTQWkFoXyedi+6bP21xIeET9Apek=; b=UkEp1wDxJQk1YFAiNXlJirLyLv7ja/m90Wi12wqJ9Ukspx/7/3R5D0eoD3b2e7Ca7j 15iPnD58OHsw3xHxwAja9P0hPisPVd/cKFhpqLDOUI9zRBmDpk7cW+8/BL6d3LUi/I6A ETkOeNcBPF2PS37fVdP46IU3oxE2UWNWruoGlkRL0NwYaYtjpoF6Mzuc9DmlVqV1zTvA l7ceqw5XTzx6b0EcK5cQBFKhI7KiqKCfhkdiyFlV/rDjtb+UKaM7vF0RMGtiq8j9xB+O a7ovnMimh1mjOTBlbg1jew3SGcPPnoSj91DXNZY1kkf5qDuk8dIuTP7SswQNDKy4dHtB qypQ== X-Gm-Message-State: AOJu0YxG6LjBHnODZUqSItfNwm+V+A3jiDQbBne3YLSEtbQujAanHst5 X+b62rPjhXtaiew6zuVenY5B3FbdjmKcfi/rQVpfmrsqtcOn9wD0ZIOcb88QmjaLH/tq5NDxisf pvkE= X-Google-Smtp-Source: AGHT+IFqvelwoSi19crIY7cSvQsHBQH6NsXHxPWvECq3yNRMlEGXT2iQ4rFHd5MRgRYaRlPogLspsg== X-Received: by 2002:a5d:4285:0:b0:374:af19:7992 with SMTP id ffacd0b85a97d-380610f8e2fmr12888771f8f.7.1730359073687; Thu, 31 Oct 2024 00:17:53 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:53 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam Subject: [PATCH v3 3/6] iio: dac: ad5791: Include chip_info in device match tables Date: Thu, 31 Oct 2024 08:17:43 +0100 Message-Id: <20241031071746.848694-4-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam Include a chip info struct in device SPI and device OF match tables to provide channel definitions for each particular ADC model and drop device enum. Suggested-by: Nuno Sa Reviewed-by: David Lechner Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 110 +++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 57 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 553431bf0232..f6b9a40241f3 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -61,11 +61,14 @@ /** * struct ad5791_chip_info - chip specific information + * @name: name of the dac chip + * @channel: channel specification * @get_lin_comp: function pointer to the device specific function */ - struct ad5791_chip_info { - int (*get_lin_comp) (unsigned int span); + const char *name; + const struct iio_chan_spec channel; + int (*get_lin_comp)(unsigned int span); }; /** @@ -98,13 +101,6 @@ struct ad5791_state { } data[3] __aligned(IIO_DMA_MINALIGN); }; -enum ad5791_supported_device_ids { - ID_AD5760, - ID_AD5780, - ID_AD5781, - ID_AD5791, -}; - static int ad5791_spi_write(struct ad5791_state *st, u8 addr, u32 val) { st->data[0].d32 = cpu_to_be32(AD5791_CMD_WRITE | @@ -228,20 +224,6 @@ static int ad5780_get_lin_comp(unsigned int span) else return AD5780_LINCOMP_10_20; } -static const struct ad5791_chip_info ad5791_chip_info_tbl[] = { - [ID_AD5760] = { - .get_lin_comp = ad5780_get_lin_comp, - }, - [ID_AD5780] = { - .get_lin_comp = ad5780_get_lin_comp, - }, - [ID_AD5781] = { - .get_lin_comp = ad5791_get_lin_comp, - }, - [ID_AD5791] = { - .get_lin_comp = ad5791_get_lin_comp, - }, -}; static int ad5791_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, @@ -289,30 +271,34 @@ static const struct iio_chan_spec_ext_info ad5791_ext_info[] = { { }, }; -#define AD5791_CHAN(bits, _shift) { \ - .type = IIO_VOLTAGE, \ - .output = 1, \ - .indexed = 1, \ - .address = AD5791_ADDR_DAC0, \ - .channel = 0, \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ - BIT(IIO_CHAN_INFO_OFFSET), \ - .scan_type = { \ - .sign = 'u', \ - .realbits = (bits), \ - .storagebits = 24, \ - .shift = (_shift), \ - }, \ - .ext_info = ad5791_ext_info, \ +#define AD5791_DEFINE_CHIP_INFO(_name, bits, _shift, _lin_comp) \ +static const struct ad5791_chip_info _name##_chip_info = { \ + .name = #_name, \ + .get_lin_comp = &(_lin_comp), \ + .channel = { \ + .type = IIO_VOLTAGE, \ + .output = 1, \ + .indexed = 1, \ + .address = AD5791_ADDR_DAC0, \ + .channel = 0, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ + .scan_type = { \ + .sign = 'u', \ + .realbits = (bits), \ + .storagebits = 24, \ + .shift = (_shift), \ + }, \ + .ext_info = ad5791_ext_info, \ + }, \ } -static const struct iio_chan_spec ad5791_channels[] = { - [ID_AD5760] = AD5791_CHAN(16, 4), - [ID_AD5780] = AD5791_CHAN(18, 2), - [ID_AD5781] = AD5791_CHAN(18, 2), - [ID_AD5791] = AD5791_CHAN(20, 0) -}; +AD5791_DEFINE_CHIP_INFO(ad5760, 16, 4, ad5780_get_lin_comp); +AD5791_DEFINE_CHIP_INFO(ad5780, 18, 2, ad5780_get_lin_comp); +AD5791_DEFINE_CHIP_INFO(ad5781, 18, 2, ad5791_get_lin_comp); +AD5791_DEFINE_CHIP_INFO(ad5790, 20, 0, ad5791_get_lin_comp); +AD5791_DEFINE_CHIP_INFO(ad5791, 20, 0, ad5791_get_lin_comp); static int ad5791_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, @@ -400,9 +386,9 @@ static int ad5791_probe(struct spi_device *spi) if (ret) goto error_disable_reg_neg; - st->chip_info = &ad5791_chip_info_tbl[spi_get_device_id(spi) - ->driver_data]; - + st->chip_info = spi_get_device_match_data(spi); + if (!st->chip_info) + return dev_err_probe(&spi->dev, -EINVAL, "no chip info\n"); st->ctrl = AD5761_CTRL_LINCOMP(st->chip_info->get_lin_comp(st->vref_mv)) | (use_rbuf_gain2 ? 0 : AD5791_CTRL_RBUF) | @@ -416,10 +402,9 @@ static int ad5791_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->info = &ad5791_info; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels - = &ad5791_channels[spi_get_device_id(spi)->driver_data]; + indio_dev->channels = &st->chip_info->channel; indio_dev->num_channels = 1; - indio_dev->name = spi_get_device_id(st->spi)->name; + indio_dev->name = st->chip_info->name; ret = iio_device_register(indio_dev); if (ret) goto error_disable_reg_neg; @@ -448,19 +433,30 @@ static void ad5791_remove(struct spi_device *spi) regulator_disable(st->reg_vss); } +static const struct of_device_id ad5791_of_match[] = { + { .compatible = "adi,ad5760", .data = &ad5760_chip_info }, + { .compatible = "adi,ad5780", .data = &ad5780_chip_info }, + { .compatible = "adi,ad5781", .data = &ad5781_chip_info }, + { .compatible = "adi,ad5790", .data = &ad5790_chip_info }, + { .compatible = "adi,ad5791", .data = &ad5791_chip_info }, + { } +}; +MODULE_DEVICE_TABLE(of, ad5791_of_match); + static const struct spi_device_id ad5791_id[] = { - {"ad5760", ID_AD5760}, - {"ad5780", ID_AD5780}, - {"ad5781", ID_AD5781}, - {"ad5790", ID_AD5791}, - {"ad5791", ID_AD5791}, - {} + { "ad5760", (kernel_ulong_t)&ad5760_chip_info }, + { "ad5780", (kernel_ulong_t)&ad5780_chip_info }, + { "ad5781", (kernel_ulong_t)&ad5781_chip_info }, + { "ad5790", (kernel_ulong_t)&ad5790_chip_info }, + { "ad5791", (kernel_ulong_t)&ad5791_chip_info }, + { } }; MODULE_DEVICE_TABLE(spi, ad5791_id); static struct spi_driver ad5791_driver = { .driver = { .name = "ad5791", + .of_match_table = ad5791_of_match, }, .probe = ad5791_probe, .remove = ad5791_remove, From patchwork Thu Oct 31 07:17:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13857643 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 7DD0714AD1A for ; Thu, 31 Oct 2024 07:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359078; cv=none; b=BVUI/46aWRqPcM1G2JAy5N0r93Cm8qInWigDtXpC62kfLkCznxRLVxmZdFfCurT4+cLhJMXn8TCD/Lb7d5mBcTavi+usTqfUi+h2vt5q6IQN9QvR/TKLHb07k16bwDkBgq58DWv413SwEI3iK8odQLPlmiGH3tzuNoYeXOzP3YQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359078; c=relaxed/simple; bh=Op2p8Q2E5igZsGlkYWqymbzX2Ifj7PSmb49r/ALp7lU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f4vdDIszu6oef+LksvnH4+84CPUDqY5XHWYy3MMpZJHrnbpv4MexhjLAof9HgzYt1aorPGLgaaBU64MSu3mGj3n77wMOdjb571p4uCA4FH1pN+WjC+EXHBks8jGyI65135LC0feHWGZHQXGHrQrPUqVQPiZzp1L7T3PUP3y4+X4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=cMW1ujZN; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="cMW1ujZN" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-37f52925fc8so340872f8f.1 for ; Thu, 31 Oct 2024 00:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359075; x=1730963875; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I1pq/Bgv4QeCrwiPVa9U9DPj0A/SeEyPL96AcSHmLho=; b=cMW1ujZNbrhUsB95uM8iS5Y66yMmzaqHwBPFll+On9vBj8euqJESQl596o9IleEmWd ePwZ+Qrrk9gMDKteXQ3ULgYEU7hB7urb1vmNX5XBb2N5TbWea9ZP6N+uipU8fuYVRcWq f3N+3xdXiiVYWgjbb7OpCv+sHvWKMrm7iN0v9+4eSuMsgdXT1ODczUlmmimjiz5bU7l+ CQKKrSxoPqEfcDNTGwJF7EAWhP/H2K2B3nm7xBc766OumapcsWVNKOkgv0INh2YaPg32 2pld/G1OgP9ozhnNCpimS5bZtUb0xvHGfcLVrRepiCKzJKgy8blka6baWqheMK5/MTIs t0eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359075; x=1730963875; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I1pq/Bgv4QeCrwiPVa9U9DPj0A/SeEyPL96AcSHmLho=; b=LCCNieL9tqrNBdtVxGrrRNK6LYH3cCmv+S6Jdqwf1/IlL6nBDsajtQ7WkhwmRdRX9m gOKnbrV//HzHZyEfEtGMb8HXfKKFNMK4sivR+5VK3mnZjPbXmwxHI8hgOAPD2CG68bYV CQGA7zB1TkmR8bqR2TXWljYDeyepLMCzAie/fGIG5KB4SaJBRAohnX6rz1r/53gdsAeU ySV/q7M1zU5QgL225DA7+fTogtFBEwMZ/aOGw4REmeMwmjZeXZEjx2T+tlvN8BMMpV/7 kgj4LR4m8NkWiikl4WyKpboq6Y+WJRt4Q5gEFGwwnCHGg/bhdpOK8Jp2bm8pNIGLIcd0 OlmQ== X-Gm-Message-State: AOJu0YzBE+9+1NXc3khaXyf2iGdDWbWbT8OhQjTHxvpu5z7wujl7HVFb dpI0zTydhp2YKwALEEbdkOIWnnvyjS8cd2hLo8Aaz/VHvOqjGGOCQV5t/A6ELi4= X-Google-Smtp-Source: AGHT+IGW7kCzNAoBXXZ34GznNmWRMdGAze3cMSGQu0oer+FnmY9AH27Byjv+q+Uux4qqJf3Mcgy/wA== X-Received: by 2002:a5d:6a4e:0:b0:37d:4e74:689 with SMTP id ffacd0b85a97d-380611ed135mr13359122f8f.47.1730359075031; Thu, 31 Oct 2024 00:17:55 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:54 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam Subject: [PATCH v3 4/6] iio: dac: ad5791: Add reset, clr and ldac gpios Date: Thu, 31 Oct 2024 08:17:44 +0100 Message-Id: <20241031071746.848694-5-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam The ad7591 has reset, clr and ldac gpios. For the DAC to output data continuously written to the data register the state of these gpios needs to be set by the driver. Add these gpios to the driver making them optional in case they are fixed on the pcb. Reviewed-by: David Lechner Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index f6b9a40241f3..c5d4d755d57a 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +77,9 @@ struct ad5791_chip_info { * @spi: spi_device * @reg_vdd: positive supply regulator * @reg_vss: negative supply regulator + * @gpio_reset: reset gpio + * @gpio_clear: clear gpio + * @gpio_ldac: load dac gpio * @chip_info: chip model specific constants * @vref_mv: actual reference voltage used * @vref_neg_mv: voltage of the negative supply @@ -88,6 +92,9 @@ struct ad5791_state { struct spi_device *spi; struct regulator *reg_vdd; struct regulator *reg_vss; + struct gpio_desc *gpio_reset; + struct gpio_desc *gpio_clear; + struct gpio_desc *gpio_ldac; const struct ad5791_chip_info *chip_info; unsigned short vref_mv; unsigned int vref_neg_mv; @@ -337,6 +344,22 @@ static int ad5791_probe(struct spi_device *spi) if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); + + st->gpio_reset = devm_gpiod_get_optional(&spi->dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(st->gpio_reset)) + return PTR_ERR(st->gpio_reset); + + st->gpio_clear = devm_gpiod_get_optional(&spi->dev, "clear", + GPIOD_OUT_LOW); + if (IS_ERR(st->gpio_clear)) + return PTR_ERR(st->gpio_clear); + + st->gpio_ldac = devm_gpiod_get_optional(&spi->dev, "ldac", + GPIOD_OUT_HIGH); + if (IS_ERR(st->gpio_ldac)) + return PTR_ERR(st->gpio_ldac); + st->reg_vdd = devm_regulator_get(&spi->dev, "vdd"); if (!IS_ERR(st->reg_vdd)) { ret = regulator_enable(st->reg_vdd); @@ -382,9 +405,14 @@ static int ad5791_probe(struct spi_device *spi) dev_warn(&spi->dev, "reference voltage unspecified\n"); } - ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); - if (ret) - goto error_disable_reg_neg; + if (st->gpio_reset) { + fsleep(20); + gpiod_set_value_cansleep(st->gpio_reset, 0); + } else { + ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); + if (ret) + goto error_disable_reg_neg; + } st->chip_info = spi_get_device_match_data(spi); if (!st->chip_info) From patchwork Thu Oct 31 07:17:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13857644 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 0D96514F9F8 for ; Thu, 31 Oct 2024 07:17:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359080; cv=none; b=hh81CFihaJwaDWpq1gWw0UauUOHkhDGIcTrQxNWJVmKMhqOhO0YLZ8zuhBHn7NgPfls+JV/+HOeZBTw7GGWjSx/oZj5LVBC9bPv/VEPdoZwLf2w+f9J9t/GphWN+jsEq1lsaY71sfWndZQIxvQVtvXU0k7Xz0vleEIJCxyHhb6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359080; c=relaxed/simple; bh=hRRz6Z3zhjYmY795aPCQsEcsvIGIKzWS3nJb+c+XP1I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ThQ120nOBTW2xcm/2TthDqzc/HeUBtx+fE4TQiBXbLi00UNUtMja2tzjb0RuD2oSRe0cbiEOIrckcQhot1yzqD/BHex0W1PHEvKTByJpAMBRrYJ1pV4IzcmAudbPKILO7+7lmudBBQrUXKqFYgff/WDYpXYrI3sU4sZGQdqZA1o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=X9h3U7uu; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="X9h3U7uu" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-43158625112so4914955e9.3 for ; Thu, 31 Oct 2024 00:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359076; x=1730963876; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BeRlMEUtBMXjfsJVHTeMu8lQ8IK1457+K1awnOuwaZk=; b=X9h3U7uu0eCiI6Ccz3GK3TAbR2t5XRQCjn4GLKQkgP+IVY5+eLrbgCKzEaZX7tncxb lTWcL1iU1LwTxsmolYHjvfTWPVmrmXPlsrB70lNcaBoMU/8Zl8HDW5YFEg5t4f1zO7+u GZ4ZbfYU04vyEaMKn12pkm3nM1l4gRGJO450xptGZ1n7d9rcFfBRpBSHRfHCxzZUtKz1 E11mqt2Nvcd8KDMInp0hqOMCdtv6oTXwQjXk/BUNermy57l0a8Cx8xm7PlRHWwV8Ww6+ rmwfWjLDXcC0hYEtwWZaarpXwMARe8UlDsD8OdbBDfx3yEKqptod1V4fE+UzB2bKDUgg nOBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359076; x=1730963876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BeRlMEUtBMXjfsJVHTeMu8lQ8IK1457+K1awnOuwaZk=; b=AVod188PJlLYZkGMXqml6i1Vne7JSjKxgp/Wr/uOfX+0DJI2IRQ9JEHnCCA1p3iXB5 Opgo5gePRo8gaa3KJp3MvyToSzHwXAd5W14C8A+7QqwtUtoGZfEY+gnKAoIhf6TKUWVi zgN+JEazcR5doGsRjrN4m43ODUY26+rg61cdo/2qb2Le1jANsnvek10/htfmZAR+0RLG aEr8zP/bPXJS1AHEJ2NQlvXZx9azQ/HXmstqvYj18TXE5YbYqzR2GbLpBUm9nA6UfXoV 8mBxLkvPiNHf0hgnRKBxvC9lYhSD48izjTrUNtDiGxtKR5ymOjz58s9wYYhOFdtW0qMC SMVQ== X-Gm-Message-State: AOJu0YwIFV4mFjR3FJAOT6x2P4d6Tgey8NPtcrd6VBiEALNJZzAmY9G7 sNEkfHI4d0Bs8VUVBoKvppKPoP/G7CY8JE4DSImblOOdV90PC/Lxu8zdoVaTFYo= X-Google-Smtp-Source: AGHT+IFXvK55d0CGj9OJo4gCkJhWNNTnKajsdZ89N392DRFUQyDEd53HDsOaPmhrhw5rLrryeaaweQ== X-Received: by 2002:a05:600c:3556:b0:431:5f1b:a7c4 with SMTP id 5b1f17b1804b1-4319ad29d0bmr169902125e9.34.1730359076424; Thu, 31 Oct 2024 00:17:56 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:55 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam Subject: [PATCH v3 5/6] iio: dac: ad5791: Use devm_regulator_get_enable_read_voltage Date: Thu, 31 Oct 2024 08:17:45 +0100 Message-Id: <20241031071746.848694-6-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam Simplify probe by using of the devm_regulator_get_enable_read_voltage. Suggested-by: David Lechner Reviewed-by: David Lechner Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 58 ++++++++++------------------------------ 1 file changed, 14 insertions(+), 44 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index c5d4d755d57a..92d47e766fd3 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -360,32 +360,6 @@ static int ad5791_probe(struct spi_device *spi) if (IS_ERR(st->gpio_ldac)) return PTR_ERR(st->gpio_ldac); - st->reg_vdd = devm_regulator_get(&spi->dev, "vdd"); - if (!IS_ERR(st->reg_vdd)) { - ret = regulator_enable(st->reg_vdd); - if (ret) - return ret; - - ret = regulator_get_voltage(st->reg_vdd); - if (ret < 0) - goto error_disable_reg_pos; - - pos_voltage_uv = ret; - } - - st->reg_vss = devm_regulator_get(&spi->dev, "vss"); - if (!IS_ERR(st->reg_vss)) { - ret = regulator_enable(st->reg_vss); - if (ret) - goto error_disable_reg_pos; - - ret = regulator_get_voltage(st->reg_vss); - if (ret < 0) - goto error_disable_reg_neg; - - neg_voltage_uv = ret; - } - st->pwr_down = true; st->spi = spi; @@ -395,7 +369,17 @@ static int ad5791_probe(struct spi_device *spi) use_rbuf_gain2 = device_property_read_bool(&spi->dev, "adi,rbuf-gain2-en"); - if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd)) { + pos_voltage_uv = devm_regulator_get_enable_read_voltage(&spi->dev, "vdd"); + if (pos_voltage_uv < 0 && pos_voltage_uv != -ENODEV) + return dev_err_probe(&spi->dev, pos_voltage_uv, + "failed to get vdd voltage\n"); + + neg_voltage_uv = devm_regulator_get_enable_read_voltage(&spi->dev, "vss"); + if (neg_voltage_uv < 0 && neg_voltage_uv != -ENODEV) + return dev_err_probe(&spi->dev, neg_voltage_uv, + "failed to get vss voltage\n"); + + if (neg_voltage_uv >= 0 && pos_voltage_uv >= 0) { st->vref_mv = (pos_voltage_uv + neg_voltage_uv) / 1000; st->vref_neg_mv = neg_voltage_uv / 1000; } else if (pdata) { @@ -411,7 +395,7 @@ static int ad5791_probe(struct spi_device *spi) } else { ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); if (ret) - goto error_disable_reg_neg; + return dev_err_probe(&spi->dev, ret, "fail to reset\n"); } st->chip_info = spi_get_device_match_data(spi); @@ -425,7 +409,7 @@ static int ad5791_probe(struct spi_device *spi) ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl | AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI); if (ret) - goto error_disable_reg_neg; + return dev_err_probe(&spi->dev, ret, "fail to write ctrl register\n"); spi_set_drvdata(spi, indio_dev); indio_dev->info = &ad5791_info; @@ -435,30 +419,16 @@ static int ad5791_probe(struct spi_device *spi) indio_dev->name = st->chip_info->name; ret = iio_device_register(indio_dev); if (ret) - goto error_disable_reg_neg; + return dev_err_probe(&spi->dev, ret, "unable to register iio device\n"); return 0; - -error_disable_reg_neg: - if (!IS_ERR(st->reg_vss)) - regulator_disable(st->reg_vss); -error_disable_reg_pos: - if (!IS_ERR(st->reg_vdd)) - regulator_disable(st->reg_vdd); - return ret; } static void ad5791_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ad5791_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - if (!IS_ERR(st->reg_vdd)) - regulator_disable(st->reg_vdd); - - if (!IS_ERR(st->reg_vss)) - regulator_disable(st->reg_vss); } static const struct of_device_id ad5791_of_match[] = { From patchwork Thu Oct 31 07:17:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13857645 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 72A51154BEA for ; Thu, 31 Oct 2024 07:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359081; cv=none; b=JDZ5rb/3yEC253tdT02OwOg7XZZw3lDzepvp+pmLPTSvFXP6+3pK/fpzKgNcpo7X35kJrjRVPUtBK+KS2VeeJyQUb74iHJ22U7uYPCMmB71f4RV3JYl5ytwWuyyY/y1H/e30zEsBoG1TaLp07jdhah8zMVM5rg3yY4lBhQtR+dM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359081; c=relaxed/simple; bh=Wpo8Oj/klmyH5vH0z1jaegb5OcJIFZ72Wg0pt5glQAc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HU3PC8AccPW4vcr5n/IUcejeR1TfTlO7vXIOH6JmbWfEMONOoAcBpypgHXJdj6c9VaMPyTAfHBxlO1+R/z7m2toFapl+Jwcw3HbeiWf0+YRFV1gw7IDvS+oxp1JP4xOyr1q/9/2TyLjoaAB67rTTUxoEEVScCj89c01UwBaCbAk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=SLmNCP0p; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="SLmNCP0p" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4314fa33a35so4814845e9.1 for ; Thu, 31 Oct 2024 00:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359078; x=1730963878; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ta8KKdF2jcNVKVs5pCv9tj8EzXOBx+/a1iWRb1D6Seo=; b=SLmNCP0pbhwRhyQijQmytLoOPxPwgYWw6lRGZ841HjhOHC030QRUGftl9jVcK/77/r n3D4Uy2s0V3LNcm3w9JKgNL31pOmIHGm7N9D7RKKxXLaamunoXVGzkftDvkNhydly/vT 6CCF8hfbDTT4y61/U5UORJKqiNQqdehlXxuv1mAYgmewffpUMZH9sPMjHgAI6XXlRbu8 ubQpFiVpG+6+wTcDVapuEqFExWBlXX7xMT0eJpj+rl2K22/8pcw7ITIBfxvqJq6Ui+Kg XeDZ6Z6wH34oDsX6j/lpc9hHIbJo+1vgzGsN4bPAuILjwwjcV1ULO5qz8ODlGL6rRxwq FjVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359078; x=1730963878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ta8KKdF2jcNVKVs5pCv9tj8EzXOBx+/a1iWRb1D6Seo=; b=IlSLnzjF0ieCvlYg988UJndqIliaIs9PD9aeLMZY6qjMLfuV/p81wnLECJ/zo6/K9L eaYq9/kr8EaVLG5TtcLvTv2txkxSUQV0uqxv4eQ2ZLVmg3G7Rn52AhHchfowAB3/cMJl HII2d7msfPRANT6reLN/Qn+YqrPcKZIODkOeNU6c7YD6jGJznUSIza8u8w5csw/JMhEh oe+sCxUQX0nIfqsKVwPOXlUEfoqDP3Kqd0S8BFVadqHp5N/83U58qbuQ/uGBarqXp/I6 wMG7PV06ECnlyOQ3xqt/R4RPi4KpBPEhsTP33qvhs7ZubMTdrA2QlpxTBiMt9Ac4TEn6 x0Bw== X-Gm-Message-State: AOJu0YwMv6SSpBHXqwVHOXqAa4OAZDPeW+yNaN6k70kajg5QYIZdRKSd 4Bjs/sIa8qmVMzDQBS/ULMVgK11wWm2C1h0XfAJQHYHD9oRxPi5hayHrGa/6EMU= X-Google-Smtp-Source: AGHT+IFApzsnUKOt+RjkBsEFLWnDMKMhhkMDsz9e5PgIwP+GShRdVqxyiVYzdBFrvcfuDkSiF/a0ww== X-Received: by 2002:a05:600c:4ecd:b0:431:6060:8b22 with SMTP id 5b1f17b1804b1-431bb9855a2mr50657975e9.10.1730359077813; Thu, 31 Oct 2024 00:17:57 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:56 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam Subject: [PATCH v3 6/6] iio: dac: ad5791: Use devm_iio_device_register Date: Thu, 31 Oct 2024 08:17:46 +0100 Message-Id: <20241031071746.848694-7-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam Use devm_iio_device_register to automatically free the iio device. since this is the last remaining resource that was not automatically freed, we can drop the ".remove" callback. Suggested-by: David Lechner Reviewed-by: David Lechner Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 92d47e766fd3..57374f78f6b8 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -411,24 +411,12 @@ static int ad5791_probe(struct spi_device *spi) if (ret) return dev_err_probe(&spi->dev, ret, "fail to write ctrl register\n"); - spi_set_drvdata(spi, indio_dev); indio_dev->info = &ad5791_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = &st->chip_info->channel; indio_dev->num_channels = 1; indio_dev->name = st->chip_info->name; - ret = iio_device_register(indio_dev); - if (ret) - return dev_err_probe(&spi->dev, ret, "unable to register iio device\n"); - - return 0; -} - -static void ad5791_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - - iio_device_unregister(indio_dev); + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct of_device_id ad5791_of_match[] = { @@ -457,7 +445,6 @@ static struct spi_driver ad5791_driver = { .of_match_table = ad5791_of_match, }, .probe = ad5791_probe, - .remove = ad5791_remove, .id_table = ad5791_id, }; module_spi_driver(ad5791_driver);