From patchwork Mon Oct 28 07:11:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13853096 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 0C67D18FDD5 for ; Mon, 28 Oct 2024 07:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099489; cv=none; b=echiiIWRzQODulcyLQlaxXLtRTn2FqjukXPAa1GMr4e+98Zrg3LXXzASGHywtUIukHjvS8kvxgxUm4lTSQIi545ukxlrmCPJrJ6dRzb3n3ONI4PMZ1EoHI3OEUB7MLXRtcKh1vXW4OB73rr+ssEz9t+4zDIX+XN8p1BNUPlwKOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099489; c=relaxed/simple; bh=aHpLAYxTlMEVHnv2ecw60I7dlQNyB6DdFCFqSwpslz4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hQGzVaOIC01NbNgGfkiizQ3Yg0nbHdfkNJUeObGaiG2Ulflz/Wc+WnbCIq3OvHFCnPWpp5hbWtX7jsbIhUn76BJWxuU413Y/gA1WLMyhToTUDocgkGww3BdwKyboQyQdPEn4vGmWtBgc+/BllptKkz+zfYSphomfNYFddzQQEC8= 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=xs7FcSkJ; arc=none smtp.client-ip=209.85.167.41 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="xs7FcSkJ" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-539f84907caso4056464e87.3 for ; Mon, 28 Oct 2024 00:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730099484; x=1730704284; 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=ULhAbr6+HaJtI9Ia2hfBJx7q7nYh/124R4mEk9Ita7U=; b=xs7FcSkJ3iF//R6RTA/Qv5CqRl47BSc/rqkjYkn64+dXHcJXTyDC/l+BRnGrtSLC11 9SGD60Ok12cs79Qvw/ZyeQa6b3HLRsNTtNEqTqqRRkAiVJCBc+9XaG6+oKXzQDXfE5rI ZwCiMmJuhBG8/qvs0h00AiN/VtTZTtVUU5uMBf5D6XurPSdNx6fPOnolufT8ETjzzcEf 606UenIiyjd7UTdaNk6na9mloNYhdkC2KY0N+K0ijOsO+TVYa9zjgvps2Jlh0DFm+XpJ DoeChvj/HWFNC/AvweRDb8NtS9pcz16zXDd7CjXUbje/PB9ehr9y/WixGcUFbIzNbFFZ jYow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730099484; x=1730704284; 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=ULhAbr6+HaJtI9Ia2hfBJx7q7nYh/124R4mEk9Ita7U=; b=IwswZF1nFP+cz2h6fybfuknQJcQa2Q1OyOq86T4i7ayQlB4oVzwcUlVe5ZJIPsQSjm OrhBFAqg0zvh63UwofJwmqQiHvXwVT1T9DwcsVlyrxxsd+mfa0peZ6Z9saHcF1tdF+cy lJvTR1q+63IBkP3q03KJWJZbQf6QiODfLukhFfW4DIYvu14cZgpbeEyohCxvxtV1Utdd VQUoFfNGXKXABR25V4e1vIyCOhG34RDNoOpNwnHCr7E99HQdFFcrboVRU13VDSGc3lxO 0S/KVrtk0mdpcfyOGe/wDdo6KXbK/M2eSHpVCsm3NgmBj5T96BvJdmvp9lYaXn9X1OOA cGfA== X-Gm-Message-State: AOJu0YzkKeXlX30vjh9rDoDmd/1EnW7owU5nN/Hu+BW7u+mT/ueEuqbe J6qJdqN2JRareBSnh/uwZUKnDVWmngsFPb9z6AY57Z71Omye6po37e9A7l6N0zQ= X-Google-Smtp-Source: AGHT+IGbdENREQEKPa2RMHYjdoBxo4u7k9A3sGOl3vRkVI04r6XfieN6bxSDI1V5Rhnbmxtn43WARA== X-Received: by 2002:a05:6512:3405:b0:539:fcb7:8d53 with SMTP id 2adb3069b0e04-53b34c5fa2cmr2771839e87.46.1730099483949; Mon, 28 Oct 2024 00:11:23 -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-38058b3c236sm8615383f8f.35.2024.10.28.00.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 00:11:23 -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 1/6] dt-bindings: iio: dac: ad5791: Add optional reset, clr and ldac gpios Date: Mon, 28 Oct 2024 08:11:13 +0100 Message-Id: <20241028071118.699951-2-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028071118.699951-1-ahaslam@baylibre.com> References: <20241028071118.699951-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. Signed-off-by: Axel Haslam Reviewed-by: Krzysztof Kozlowski --- .../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 Mon Oct 28 07:11:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13853097 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 54C00190052 for ; Mon, 28 Oct 2024 07:11:27 +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=1730099489; cv=none; b=e1GFUGl9uMP+LfqsEA1nLqT1gL+aocyAL9QF3kADJTQPTTkQO0DIpMWevIiVMtVqptZ0uXK5nN+2XAAEm/JRS2jI4kALnwPZyrNtXnjeRcHrEF5uUzG/KAxJa7Jqj5uo92htXXXAyOZG87q0tv68i+4ZtfXd5pr8t6cHEYhOLkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099489; c=relaxed/simple; bh=NZDbzU20l/rGAlpGDhU1gwOCh0PzSI3BBlQwr/WhlWU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lfnTvOsf+XNnQJAmtABqtmHNjuqYyCEafZ65ILpDGGXlhgdHpb60c1KSguz5X7OiD07WoRWuDhvIu3IuFdMSaCmy3zeVbaKm1dh3EzoOKZ0MSlLiV34XatO6ercq7EXxJyU8a2tIsX2KjBJhxC0cRWI0PM8m3ZPNLGBCNwfJAH0= 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=xv7pYnR/; 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="xv7pYnR/" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4316cce103dso53799885e9.3 for ; Mon, 28 Oct 2024 00:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730099486; x=1730704286; 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=JUb570tUKACa8XabOgBL9RG8mj2LHtV2DgIpDsrIdTg=; b=xv7pYnR/QP13qwerhsagF5qiFSG3vAjjhaAJ9Z9IU6RSMSvzGZZrok0ynVoPAmb1k7 I1fyYKEkkxWurnb58nuABDS9qdCH/+qP3yLgVVGspivGmitO7JP5kCdRfHPx79Nivjt8 WCK26htZT358wrEZj8h8APv3QTX4bwqiUlPZFebjvmxmgARcwhNZ6sbk1w55kJmaHEEw L6UqLkrecAD63Kfe86i9E/8Ugln7VHoHYu/7bxX3T9K5qAdiFBTEyUW0RaeOfaPAY2GO 4hB0lsSw/pv15j5HtAFvAvUxgnGDrhsYzDuRQlpEumJ1tyklF9LR5BuCtQWq9FaXTZZ1 L/aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730099486; x=1730704286; 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=JUb570tUKACa8XabOgBL9RG8mj2LHtV2DgIpDsrIdTg=; b=ZPmQLO1xW9d8+mycZ5d07UGigJH3a49WIY5b8nCDC2IK5pQoIgeU6vaBpONGXwQ49R XmnPPsc1KyawTe06eAywjrOgW2WLMG13mIiAuJhgzkmIjrY2Sgjb40Aj0FRNuYM39Lws 01gUp1K8Ph4rzdTueeU2mRlMfLdnK3gyyee2Y1a+DMYQXdvTmTm6rQGGKYYqx0jBIoNX u/Ie7smwUZ0/0Ml4ldAZX6GZcJ6qX2VPdazVijqsvQy9p6pEj4/jiOb22OJ5AyIj8urg gUKLEn2T6lh2I7VzT25Qyt8Ydlm+OabHBIEChKkpmBWJBqJkCD+TGP8RQIkkl99VRrvP rgCA== X-Gm-Message-State: AOJu0Yyvph6+hUWbFMmGIcI/2Dp71/1flyhgKMXuivX8W0e4cK3E7+j6 Mqe6xfe89dW9ueOHICaa62W0LRpTI8C3HspxllCjvfb5Q+0i9jcuyGtl8NiPCuA= X-Google-Smtp-Source: AGHT+IG1rEbR3wWmOArcj3vZ7viWhOv6JbYzk/JrEFJn2eoVbUVOSacTDBn1DWnGKEpSmxmTCnlLBQ== X-Received: by 2002:a5d:6b8d:0:b0:37d:4c40:699 with SMTP id ffacd0b85a97d-38061141816mr6779939f8f.5.1730099485522; Mon, 28 Oct 2024 00:11:25 -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-38058b3c236sm8615383f8f.35.2024.10.28.00.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 00:11:24 -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 2/6] dt-bindings: iio: dac: ad5791: Add required voltage supplies Date: Mon, 28 Oct 2024 08:11:14 +0100 Message-Id: <20241028071118.699951-3-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028071118.699951-1-ahaslam@baylibre.com> References: <20241028071118.699951-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. Signed-off-by: Axel Haslam Reviewed-by: Krzysztof Kozlowski --- .../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 Mon Oct 28 07:11:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13853098 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 C789F190493 for ; Mon, 28 Oct 2024 07:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099492; cv=none; b=mgHGR4Wpa6BNInWvdZK6jN0N3led/zhw8tSXiHEhNNh4QfUk9mltsvWPwDfw9/UFAu0t/rxg3mjBlEOzkUGpBclJ2+lkmx4p64M+biUlyqfAdB79Ub6WHGyAcHZInrLVxftRRHTcQBhWrARkm/tQ7Qax4Jj8ofcGVYKgqyHSYSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099492; c=relaxed/simple; bh=q0Rk1gyCTVaE9ieBiZ9Ha35zqb9X17plsNeIZIHefeg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hDJpIzqYAzeMiv3YYbs7PwH2KN8++egGQtmd4A6eMlEnoAZ3x8Mco9EynuUOk+uUE+jJNdGsuvOrzIlNzzVdRTnBs8eaLDDdQfMcumSP7sRSs+0VpbnrIJQPh1IPFHSYinW6e8n99FYjjzS/MMbHx4YYJQlNAvYZuUWcEWfuzlg= 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=xNeF7o7d; arc=none smtp.client-ip=209.85.221.48 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="xNeF7o7d" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-37d473c4bb6so3637527f8f.3 for ; Mon, 28 Oct 2024 00:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730099487; x=1730704287; 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=6aJObb17l9QQWEMB2X2r9azU+cKThC8Szkobzv4AFnM=; b=xNeF7o7dKD9Z4tdp8Am/pAMkqzw2NTVhpfjIUMGXz5Tx9nWTx+2EpWGJ26v7wj2dSJ PNvwuNhQ75JxWLPyCY90Ft1fAuthAHnIsbUKn8F/IT/0m0R34+0RugbjV78qhz4xrErf YhtBpPEYOsK3lyIshQGRL7jU71ouT+0sZVeCv1EXa4fMaF0Z6WA1x1wqjB+/JOyJ+0IP 9WutXdPL7EDPJBiN0S7ov0X+hHo/kuTvD/7gX8FuwBXaEpFsnDzoiGWHbXVpG/dPlyq6 MltuQoZgbGTUCFzouxoswhYbWhbK0ZhkxIDRnLv5Dbg++U5+BMMeHZ0az/Rs7dYg4jpp eceg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730099487; x=1730704287; 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=6aJObb17l9QQWEMB2X2r9azU+cKThC8Szkobzv4AFnM=; b=FE/IXDFPH2vZPYIz6zzn3higfABNXUbz9HrbLhSTCSTdcLHbpg9D/LmZzYqX0iAO6h 2RtPLoXp1PDoV7eRjv475UJph601uVX/mGBfw9YM7982obE5LQuaaT5Rnx6mrCiKmuqC lxX4VBxTwThUqR2CoDkPzXsR7HMWxvrLZF8/wxurYd2BRs6fUebjmtnBI5BzSTDPPdAD zM3hItTBUfs28FmwOn6j2zqzL2O2MpJAQqRE11nDsqePx6BGAYuLUNYcLWT0AHuS+BTK klQJnC1Gi+txXck9MZSMOqsjrD2Iy+7mxs1IRSehA85KbQ4hBmMBpGSiJRFMNfTdCQtk A88Q== X-Gm-Message-State: AOJu0YzkGaTua3T3SOufmP5KVvU0KPKvAE5xkFV1Ew5hxao8I9bYvndr 0L7tsc+5vL1W3r8ZcpnieKCH9IWI9lrGGgSaQtd2kQJDJjdFOKd7ourl4jTmvL4= X-Google-Smtp-Source: AGHT+IFEPKa7Esk0IjQZ9kbGemFFEKjcSbzAHz9z0VoU4SdrKcB4GQruoqeO0+NgV2NSQo8GqDf1lw== X-Received: by 2002:a5d:614f:0:b0:37d:50e3:e7 with SMTP id ffacd0b85a97d-38061248aebmr7203636f8f.52.1730099486986; Mon, 28 Oct 2024 00:11:26 -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-38058b3c236sm8615383f8f.35.2024.10.28.00.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 00:11:26 -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 3/6] iio: dac: ad5791: Include chip_info in device match tables Date: Mon, 28 Oct 2024 08:11:15 +0100 Message-Id: <20241028071118.699951-4-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028071118.699951-1-ahaslam@baylibre.com> References: <20241028071118.699951-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 Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 107 +++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 553431bf0232..a11e81211669 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -65,7 +65,9 @@ */ 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 +100,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 +223,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 +270,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 +385,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 +401,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 +432,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 Mon Oct 28 07:11:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13853099 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.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 18D1B191494 for ; Mon, 28 Oct 2024 07:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099492; cv=none; b=PeJEQoFxq40gAL6fPt96/prxM8RzB5UAEeRHJiuD+4Cimbp9uFuJdU97+FvF4vtz3XSlkx4aCbZ1FIJ5lj1lgqToBmyxfqyEivV2HvG5ISPflDQEwy5r6F/3f4ZYq+GDK8Xxpfo1o53GaIlwEhsL5uyhDQFQzjSOCuc0O/GPgh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099492; c=relaxed/simple; bh=jeD799FRio03ooNTV9omrCUjpBjRjM5v4BIatoJOPUQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LFFdPYFsXllnjF1fky2J7N0aXX9L9pedP2WbjH36mpaR21G6cdMrctfxGiCW/zOR1CcmqUyPYhDY6xeaUSD5o35+RA/xTPveyQY3hn6pe1ShA32XjRPtr5AqmS9k+CfC8pv49teqQRz/c2JhnKOKAiMnLuaFkSaVBkrNsTYeR1E= 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=07/wjTCP; arc=none smtp.client-ip=209.85.221.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="07/wjTCP" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-37d538fe5f2so2996511f8f.2 for ; Mon, 28 Oct 2024 00:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730099488; x=1730704288; 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=Wlo+W2TNb5QSDgVIsOz+Qc1bNWYUz0GJAHB54nMHeS4=; b=07/wjTCPJschGnxSQzD081YpGx2qm0CfZXUlIny50oi4BJUvA4/scq706qDH5l58RD d28FzB4+vHhxpI1SZsfc8bDZ/dh6EEg83cMDnaHA0JGe+wID05GhWzsNoz1pu0m8kuCX bmXjzoG7iBsNSkli0z9jA6iCdiOhLmJUYRILLT+7Cq3Q9jLMMevPxz/aOWfxOnG11bDP oYWrLWR+nKrjbwQENiRHjsRdVAOUZiIuwJxg2iX5oeANig5O7t4JBOgR9F7Ud1+1v0I6 +PevyGaar/CQsYrBHuovFgm2XCcYjp8Bf+1VsxcAi/1EN3cpFyAIQJ3Bd7n8+RMtBK62 l75g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730099488; x=1730704288; 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=Wlo+W2TNb5QSDgVIsOz+Qc1bNWYUz0GJAHB54nMHeS4=; b=GRvGnw85YwwNynX04Srv1ghsWhs82KkJebTWFFkgYLhErRf9d+YFwTLbhoG68X4nDw kHXxcTJ2PcLKZdLRQrHHs7UxqQy3pm7dyaxTb1h/FpWkNR1xxi0/cWhGtTlNqv2hpumO 1llCud+3k1ODnWv7B6EpP8q0qF5PYo9BTlh/fKiQCIzMENAkWYD3LeAvx7MASrwcAkoN TYxqxbeCM9GfwtDpG3oV4PMy3kuzNig3PQ14TlxCeVgIpHwydFk8vXNCrXWmz5kzqCve 6Ok7I8Xonm+Y/vwVdM+dABmCOawH0xmEQ6OiIQ37aHdbfLv0/vSBdPpmrwwMoXtLxJco /lMw== X-Gm-Message-State: AOJu0Yzz3anEpAccJiH3sDndDwPcUG5Q7vDuGdOme5in8QWpBAQvx3G3 3yc0nOKHUt76jALEFjvew3rIyz5KBXcaUB2ZqGq/4XSqZ8m2PQSUlcgICa0MQsI= X-Google-Smtp-Source: AGHT+IH+NLBqOtVIa/K+9SIAGMlDhsmTAvwcWoFxxaXBDT19t/CuuxshfkFAHPVDUXuQPdwR6Mf4Uw== X-Received: by 2002:adf:ed48:0:b0:37d:48ec:547 with SMTP id ffacd0b85a97d-380611733d6mr5277355f8f.29.1730099488290; Mon, 28 Oct 2024 00:11:28 -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-38058b3c236sm8615383f8f.35.2024.10.28.00.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 00:11:27 -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 4/6] iio: dac: ad5791: Add reset, clr and ldac gpios Date: Mon, 28 Oct 2024 08:11:16 +0100 Message-Id: <20241028071118.699951-5-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028071118.699951-1-ahaslam@baylibre.com> References: <20241028071118.699951-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. Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index a11e81211669..a7cf19346cf0 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,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; @@ -336,6 +340,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); @@ -381,9 +401,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 Mon Oct 28 07:11:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13853100 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 591BD1917E3 for ; Mon, 28 Oct 2024 07:11:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099493; cv=none; b=ZhseAYnysl2kIwXxWETnOoIBOm6XkNsmGQDB3w+MDWb+PONTsCEgA22qnwWR4vFVhQTuV5juHKiLWHUQgH5eH6YyNjX7tVi2dYCCxGsinVF7rRS8pacpnkOKCcSlD+YRf1o9SZ1jbQxumeo09fKphCfZdmx0655hf5HPVNcqkDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099493; c=relaxed/simple; bh=ZJ9kJOr0i/SOKs0Y9mpLHMOu9+YrWwrP/QA0Z1HEDAA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O1jtLgm33y/WCPeQk9ntplB98hcXrQ2PAXBfUw4H5TJwXsnzR6dZXKWa7QpkXX2O8HhRF4vc5K5LSWECuypSV7gJLtws3/tOuIB+jGk4nmD85Nc8Ri/eU5MxQ2AEBQkKp+90J6rR+I1KPMtExh0iykRabRq1uyvA8cnAY6HAoWQ= 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=PLDJ8yab; arc=none smtp.client-ip=209.85.221.53 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="PLDJ8yab" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-37d462c91a9so2949988f8f.2 for ; Mon, 28 Oct 2024 00:11:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730099489; x=1730704289; 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=YFFQC/6ZDAGH+zO4eJKUZ7fU44MdeYM/24PabqG6WNw=; b=PLDJ8yabU6Sq8h3U8LXwaWfdcWQCGvgyI2hPh7xynFp5a21/XgjmuRlimRpR/3u18w QT1YXO9OT8pkjw6U0jqUu4Mz6WefZvQu6fRNy+Y3vnrLenOo4miPtH37agBOeENOCPqa YccbsKuU5liQRWlAXCbRhCW4OvRZhW/3v8S2ea2p/B55wa9totLWRvOq1wS0lFiP8N8x GAz6If9czugkb+WCWjqTHLlJuU8zQpQAcuuSe64NCZ5f8SVjGACTA2Cpk4x/N1ZIsEyi A/UMatC5hXwBhJjb+pPDc84fQMPZR7y31lxaE9b0niJRVPusB8mUMPd6yglhiRB1x5Tl p7NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730099489; x=1730704289; 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=YFFQC/6ZDAGH+zO4eJKUZ7fU44MdeYM/24PabqG6WNw=; b=UHvXFduDN+V6eQY7urNWJNnlK1f3zTRGJY7lD1V5KwFRz1pFV/3rEfumrMr0bmwHFI nltJxX9vagZDJVmq0Lz1fiIPpJxFTOAdlL9I3Unxk7gYkC3znznlrq9lHKgyJUldLOK3 mkAJ8fjT9K6O3n58NNo52EsWki+cT2eqNH5MsSODFTdaKOTCh7vbDzuv/GmX8zIuvyuX DGedIrQ19yhR4YNir8K3sTb+HBj22R9Xd9sadNgfonL/vBImwszrn90IUx0vtfXLKV/D LwYnSFP+IzemQpOSsUuDIhEj9q/wZs21IoMIePhLEZqE737A4lWncd1dhorug4aFVi6l mJnA== X-Gm-Message-State: AOJu0YyyVuSjNvxdEE8CgbD2qReEFQCn7JqhvjT16wVryZ5RHqO1r04N 5Vtc6uNIj1AjN4jKox8bl6QAjgoi+EYGuxIc6MhmNTamTVqSZaSjdDKjeB8YB7o= X-Google-Smtp-Source: AGHT+IFv+8YyWNT0z8GIRHjCAwECYf2/lmLfWX3o4tF/kRePLXswua5qFOncxvi6eer78+XtDzyKqQ== X-Received: by 2002:a5d:6145:0:b0:37c:d12c:17e5 with SMTP id ffacd0b85a97d-3806112307fmr5507852f8f.23.1730099489544; Mon, 28 Oct 2024 00:11:29 -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-38058b3c236sm8615383f8f.35.2024.10.28.00.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 00:11:28 -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 5/6] iio: dac: ad5791: Use devm_regulator_get_enable_read_voltage Date: Mon, 28 Oct 2024 08:11:17 +0100 Message-Id: <20241028071118.699951-6-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028071118.699951-1-ahaslam@baylibre.com> References: <20241028071118.699951-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 Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 56 +++++++++------------------------------- 1 file changed, 12 insertions(+), 44 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index a7cf19346cf0..cf3d41a10c20 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -356,32 +356,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; @@ -391,7 +365,15 @@ 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, ret, "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, ret, "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) { @@ -407,7 +389,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); @@ -421,7 +403,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; @@ -431,30 +413,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 Mon Oct 28 07:11:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13853101 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.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 56D21191F84 for ; Mon, 28 Oct 2024 07:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099494; cv=none; b=K+Y1l3eAzOZReZvZ297jrPDSCw/w2su1f7d04AEXRrRs3CR//K/ilk4ME0NbOih2sC6mJQ+QbXRZPGNXfFDgljPYm+elAshfHht+EwEcxKQdH0S3hcFjWoI1r7Mzvqe+2Hvvg94/CYbu1qEzgSXGd8/QI94fG+9b5/3w9VPBjrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099494; c=relaxed/simple; bh=iWDYd1b1Wvv6ndrxXc9PuI65UIqXmfta3N5ZMjJj6Xc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uC1dEarxZyqd9HFSkuDIU5FU0VNRh8AqxrHEpUL/IvG5yikZC2D1zk7ArnB0q73x1JoHN8ccxo6fb65aUimTjncQP5EZxqcK523tpbFgG/q57zbKFpY/qwrB31f4G0wd2IISFE87g0h1WXCBO4C+OKyVvBYTCM2+Sh63zuZEwng= 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=jMIhhggk; arc=none smtp.client-ip=209.85.221.47 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="jMIhhggk" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-37ed7eb07a4so3191849f8f.2 for ; Mon, 28 Oct 2024 00:11:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730099491; x=1730704291; 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=nowgTJuac2Yh7X/z94khQScVguetvtBTtzCKLVQFaas=; b=jMIhhggkoeJ2WIkYNg++2nLfEIhjZnTrAQYlMJrDSDqg1zewTDJKn1TKIs2QVDjqLl GJLhJ4cu41WZtX6e+zDuPY4jEQdOrnNgphhefO+30dHtaJvzQGG9Oe4SRsK1/sg0Qeh6 oA+eRjl54HOz7QOtxgHgDaGeLkSxayVivB2CRPx/Tq0XxCin3pDMyJkeCQqRjMlBKdVj bsOorXcPq1c9kPhcxUSKd3UwCsAFWHjtG0hUKB49dSamS2d6lVVo0XzlFxRBeuP7sAR7 x2AQC7ecW6H/11PjMKHVQfx2qFOZcDe2Ijd94EZaUy/RN70F/oPo2eq8v7o98eYCOEmy 3AyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730099491; x=1730704291; 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=nowgTJuac2Yh7X/z94khQScVguetvtBTtzCKLVQFaas=; b=aw0hn9vMNWQpHJqPY+eRhn58dtiB8otJwB+yoPj65rzi3z55fKhW0mTE6CMp+SS7kt 5v8cDBI549c1yHzvO/Gk+5JQJx1Ty/+dURZj3nXkmP8DOJ5HOCA9f34c8dSBXFY1Vl1k cUXGDkrj0ayxHTG8/RLgg6CA66SKKfNqT53K4Ms+6Iy8m7XMJe44RPJLz55pkahO2niz OjWZ2edHkjCUqSxn3cPD389EqsFCagmrJ1azNLOVJJQAWhjQsAbNg+ed4k99zfvtgbCY melGbDAwK81NS2XvABGLfPW6xWAvpmj8qfkv6jJ05aZS9QPyUGCbGDPKyTTPN3Vg3X/U x3JQ== X-Gm-Message-State: AOJu0Yz3QckwZWCK3sbrCMljAGRcUkvL3+S9E2vkDTcxQlLFrCwQf005 YNi8YK4aTXLWkYsAAJkYiJW9QaRxOIOsxpvh5KRohrbHz2sP6vJPPKOz3xyJL0o= X-Google-Smtp-Source: AGHT+IGAkVXhRYlzG5465u6RhebnlFP7K5tzK+c6Ystc8SSucFk35yCRMrvtFQSJh6XMRRrMNs4PAA== X-Received: by 2002:adf:f84d:0:b0:374:b3a3:3f83 with SMTP id ffacd0b85a97d-38061222394mr5179934f8f.53.1730099490785; Mon, 28 Oct 2024 00:11:30 -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-38058b3c236sm8615383f8f.35.2024.10.28.00.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 00:11:30 -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 6/6] iio: dac: ad5791: Use devm_iio_device_register Date: Mon, 28 Oct 2024 08:11:18 +0100 Message-Id: <20241028071118.699951-7-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028071118.699951-1-ahaslam@baylibre.com> References: <20241028071118.699951-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 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 cf3d41a10c20..21332c9aca5d 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -405,24 +405,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[] = { @@ -451,7 +439,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);