From patchwork Mon Oct 28 16:07:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13853724 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 3B3C41DE892 for ; Mon, 28 Oct 2024 16:08:14 +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=1730131696; cv=none; b=nJ/E2Q36dYmfR/f73pMOL0wl1y15G+KGwJs59b+QFlgy9OVFP4Eokg+2ba5rz06J+BUmPG5ZVu47LPlW9XVLhY38j0zholCycU0uvpYJ0oRzwPtAw9rwigWKAYg62FhCT0c/xeoJRo0OTk18TlVgEmogsfcVCbZ3JSI16VwoHVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730131696; c=relaxed/simple; bh=Q3QxaUlS/XDU3QA4rjyNh1tlJnHYfuWKrZr+wanO8+8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XjT7IftWGz36pG0Gsi1YLmQV0CEHIpG1g372aWz+u2TIIPpY++W9W7xRa2UTHE/0F4S0RfB9w5r+tynnXnlni328M5A/OoFssV7Z0KP7ALQuvk+HCWozQ5JTygEHzH3vwC6qbiYDygwa6G8YopLVbhdKqV80PD7NhDOsOFfgm6M= 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=vl9nvToY; 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="vl9nvToY" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-43159c9f617so43982165e9.2 for ; Mon, 28 Oct 2024 09:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730131692; x=1730736492; 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=n29IoiTPJrF6OYmF+KobxTlTWl3cfGwoPoCGp5OEkQg=; b=vl9nvToYMY4xKEq+1xZEPqf0eQ7TXT2I0X4DfaUkP9oaJp7CbOjL6tW5R192jaWX9Y aPJcOkMc4n+DK1CZ8NUhJqL/JfAug/cVq6s+eShvScKxMzL/XCCE0iQoynXYXpveZDpS g3b+4AYLGKz+T8uS7JN7R1F9h0nDYoESIb+LwcgDBF0hxBsQb5uLCvpeJnCy1afwXI5U 9yryOHi8FXF1yj54Dsf9Dl5WYHQq8PuhSig4lLFEiZ2Xfy/Xy9ynTf0WZsJlUP1NE+pW LxR3I/OFALBc8e1hxMwXfI0QwIqNwG606q1I0QfeMsaCT1ywj7zK0dUZFts35rQePucs MHLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730131692; x=1730736492; 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=n29IoiTPJrF6OYmF+KobxTlTWl3cfGwoPoCGp5OEkQg=; b=ByU68HEANZBJFV0s0O/wKuMhVRxxRe8EE/i9cqHMKE9hzGVIWVdsBO3opWYbBpDH+r RnwfzouMyrvXdjpDy/oMxl5tcNNfYJBGkmWBzFbslZtKneQ3v9j6CsRnLnfcrNO0woci 61+S5afZVGMyO8WxxKxR4G+RUaX40RUrBDIwus0mLm4vPyjQMnVCcQAzQ7VjRfc76d/k IEh4yQdHmuU/hG/vQOe6+Lv0Ke0lvSYxrbiNBTc1Prt68SkN5Dh1+jUT6wlhbZSex092 wJ+eIwsPnKdfglwhCEF1ckAsU2jYC3fltOD/lf2qdlyf+VShqEuc8nxsubi2JPPa1fnd wR/w== X-Forwarded-Encrypted: i=1; AJvYcCWn5gPqmGU5XsxreA+BnSxSdZx6iBKO7YMOLRcGv7eejJzDk2L6hCnnVes+jbtlyrppzy2mak7fD+A=@vger.kernel.org X-Gm-Message-State: AOJu0YynnkJaG95s3kSg2ztVa1A/0+dozh7bpzR3nxMeJmspu9UhwmvB 5gcze25gBTVfBPZfVgWZt9wgzuT4QmMbBiUFe0tVtYwYGtTVY5sPTgWogJO1Beo= X-Google-Smtp-Source: AGHT+IGTTNwM36u4ehcBdBp1E2Z/jZ/FarkrASZnPHpMcpoVz+dZV2l3GUoiuK00QJpdOItCIGtw0Q== X-Received: by 2002:a05:600c:5249:b0:431:6052:48c3 with SMTP id 5b1f17b1804b1-4319acacd6amr94080325e9.16.1730131692517; Mon, 28 Oct 2024 09:08:12 -0700 (PDT) Received: from localhost (p200300f65f0c3200f401bf2b6011cd64.dip0.t-ipconnect.de. [2003:f6:5f0c:3200:f401:bf2b:6011:cd64]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b56742asm144128975e9.21.2024.10.28.09.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 09:08:12 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Conor Dooley , David Lechner , Dumitru Ceclan , Jonathan Cameron , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Nuno Sa , Rob Herring Cc: devicetree@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH v2 1/4] dt-bindings: iio: adc: adi,ad7124: Use symbolic name for interrupt flag Date: Mon, 28 Oct 2024 17:07:50 +0100 Message-ID: <20241028160748.489596-7-u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241028160748.489596-6-u.kleine-koenig@baylibre.com> References: <20241028160748.489596-6-u.kleine-koenig@baylibre.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1174; i=u.kleine-koenig@baylibre.com; h=from:subject; bh=Q3QxaUlS/XDU3QA4rjyNh1tlJnHYfuWKrZr+wanO8+8=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBnH7bYmzg7DGHXywqSl6SFLbA8pR5lew2ru+9u+ uVbFRciR4iJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZx+22AAKCRCPgPtYfRL+ TntkB/90uPk+646Eeixz6qfjHKuMuMJglRGThG9GTrZ7MJUv4wxWwmpShyMvEcs43GAEztdWeqG XRfdic1Q/4XebS1GCR7mCiG12IGnqK8xild+9xjKadZ+9imkrDtZxrQbzyaaGnUs8okTQGDnkQl jlqBKwbChv1TIJgWPJXyR6PQoQrP1SkDGZMhuRooWMzJieL8u8JY6lPXSfvPxkN4/NjlsYaG4v+ x5dajhmSeTPd7dKUepQU65M03zR2ufbuC+DYRfioEOZ5BDylqoJzBNgP//yDrShys2m1yiLr2BQ xHNcX25V8f771TNBYllxelcT0ZCbt2Ahpkz4spKLk101fXm/ X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Using IRQ_TYPE_EDGE_FALLING instead of 2 makes the example easier to understand for a human (and adds only little more effort for a parser). Signed-off-by: Uwe Kleine-König --- Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml index 35ed04350e28..de49b571bd57 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml @@ -111,6 +111,7 @@ unevaluatedProperties: false examples: - | + #include spi { #address-cells = <1>; #size-cells = <0>; @@ -119,7 +120,7 @@ examples: compatible = "adi,ad7124-4"; reg = <0>; spi-max-frequency = <5000000>; - interrupts = <25 2>; + interrupts = <25 IRQ_TYPE_EDGE_FALLING>; interrupt-parent = <&gpio>; refin1-supply = <&adc_vref>; clocks = <&ad7124_mclk>; From patchwork Mon Oct 28 16:07:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13853725 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.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 DA8041DED6D for ; Mon, 28 Oct 2024 16:08:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730131699; cv=none; b=YaiCVspvfO9Wuw5TaNuYuntDmy/GiTChKmVhRy9vUJ4Ky0FKQf+O+3yv86HNxCSRKAHyS50MNL1ZU0x2Uf2NP4N0+deyyDfolxbi+7rkgW1WszIsPE7Dyn1lYMDETlUlMDuxGfEHrDi38gpwIw2rinbiRwB/0pilz1vBIUVjDPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730131699; c=relaxed/simple; bh=hgMcpwy9TdCE65oxriQ+FPntRPBuJVE0q16nRMzx8DQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CzR+CetFTiRYXVC6n1RGFFg8mQD2TudpcOL3r/XJ6M4wHDKgBBoS5XRRMG5KX4E+4dKCpweiaE2s1cikUK4qlpTfaO3J4tgz/yjDVR4ZuQdeyhpUYhtgioD4eEcluKhQmqubXml5PqQlwMJKXR/c/Dg3kIYc+SlHwAwZwIXpGec= 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=hwTwN1kV; arc=none smtp.client-ip=209.85.167.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="hwTwN1kV" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-539e63c8678so4505663e87.0 for ; Mon, 28 Oct 2024 09:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730131695; x=1730736495; 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=1ehYyki6INbo9Xh/4EaDRv1pQe+m2uI42PbP7/EkkyU=; b=hwTwN1kVjxQnCab5uCm3k8sRFgRDEBl81/VS8X8xyiQVc0FRfnrqok6iDX3mbECiaw YKK2y4o3LcJgvTwxFPTEC6cokoOEtnEWcnAYqWVcq/rj+aZb+0eM51oqoHiE8ja9tf+y vvvNIowIk/yEcUxcc1J5NsqQthpCFFj6NNOIx0IsAOWUa1rLfk5G8KDuQh9S1qq5Uyb9 lEtehWFSdk6iZZ0S1+BcTsdmlGaZ2yeATXVmNQrGSKyRlvpLLZNGsei+K1KKOEg4lbis eCU9gm86eXmY69Ld6C/cEuJNPL9ompQYbZlsgry4JoFk1jFesD5mrFqJC8iw0WfzkTol 55Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730131695; x=1730736495; 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=1ehYyki6INbo9Xh/4EaDRv1pQe+m2uI42PbP7/EkkyU=; b=Vf4wgf4FQfLvnELwmJ6auej/ikYwjKwNyW/dby4b9zqFejISqo9NAbOKFbtdXtUy6V oM02Jd9ZfECBVXzcrim3G5MJDlFrLi6iaAGyoWuKwj8F95dmuWDT2+TXMe5kQjsq90T8 +0Eouwt0Tob3mlRsuZq7T7G1gtBaPj2r/hMQxnXRjMHsXUzZwAEd4g7OAuqqdEVbVadu /Ys2yXHiIVKaMh6o0+p4YLf9ZSdxkD0tJymc5FqMoGGjwx5WgcOJrsg4ty4k5I/OYySw aVf7/wUY4MlNQxXB2RdiCxxekGbaOdEg1fpcStrdvSjiXY6jPhfwMhZbKSAy0QW3slqn MSxA== X-Forwarded-Encrypted: i=1; AJvYcCUYThGIulUMJg5szNWkZx9DALbbWFkqIioK1V1w+U14k3h6uMSK0jvpY6hhCaCMJUL6e/ONAGNmzIo=@vger.kernel.org X-Gm-Message-State: AOJu0YyaeX1Jmfucv/BTiJohRI1aoCRo5cdwIS2N1sTXWE39WcRu8qMc jzUy+5A1hDUw5EfOgS4ERlwIDo63+1kt7dJD2l/qTc6ynp/zKSmD8jkS4VkU+Bs= X-Google-Smtp-Source: AGHT+IFLpAoDaA5PuthIhIt2oMonRXwUCLN6LZ/2wBc8yQwsZoJ5qBz2LGvUkO2NkdrqpLu+TWvrGg== X-Received: by 2002:a05:6512:3ba3:b0:536:a564:fd48 with SMTP id 2adb3069b0e04-53b348c15a8mr4031277e87.3.1730131694977; Mon, 28 Oct 2024 09:08:14 -0700 (PDT) Received: from localhost (p200300f65f0c3200f401bf2b6011cd64.dip0.t-ipconnect.de. [2003:f6:5f0c:3200:f401:bf2b:6011:cd64]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b56fbd1sm145916995e9.32.2024.10.28.09.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 09:08:14 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Conor Dooley , David Lechner , Dumitru Ceclan , Jonathan Cameron , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Nuno Sa , Rob Herring Cc: devicetree@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH v2 2/4] dt-bindings: iio: adc: adi,ad7124: Allow specifications of a gpio for irq line Date: Mon, 28 Oct 2024 17:07:51 +0100 Message-ID: <20241028160748.489596-8-u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241028160748.489596-6-u.kleine-koenig@baylibre.com> References: <20241028160748.489596-6-u.kleine-koenig@baylibre.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1978; i=u.kleine-koenig@baylibre.com; h=from:subject; bh=hgMcpwy9TdCE65oxriQ+FPntRPBuJVE0q16nRMzx8DQ=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBnH7baQ6qc7828IvvEh96kIK411T6paMu9Ri9yR mQa+RhO2NaJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZx+22gAKCRCPgPtYfRL+ TozKB/9uLGZE0013XxnTuJbXRpJQVsaREztrAksqC/Qv5AeoQvUiHcaym7p96rY46NO/J4aOaj3 HbAzyCBoyMxKelyJJKTUoWZsEccKfJA7TCbZUuw9YWn7s5rxakpsZmt3kMC6jGHfYR8VDpZS/8l o0wga7yZX9QWJCiahabzLsKa6LBbcnN9p2eV602Cf6KEcmodQ4iYJot2+Tvgv2AUBWglRko9H3f ODqYAHu03qF/+XiavPAgVY2Bs6t5bqYgX79HqNayZ6zj6GrHrt60QMFXh/N3nqa9rWlZKZUlygz PUKjzMFNIUF9ZUyWWCze6AwtAAtLp+rJbrBTJlRlq3WFg+Bi X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 For the AD7124 chip the logical irq line (̅R̅D̅Y) is physically on the same pin as the spi MISO output (DOUT) and so reading a register might trigger an interrupt. For correct operation it's critical that the actual state of the pin can be read to judge if an interrupt event is a real one or just a spurious one triggered by toggling the line in its MISO mode. Allow specification of an "rdy-gpios" property that references a GPIO that can be used for that purpose. While this is typically the same GPIO also used (implicitly) as interrupt source, it is still supposed that the interrupt is specified as before and usual. Signed-off-by: Uwe Kleine-König Reviewed-by: Rob Hering (Arm) --- Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml index de49b571bd57..71a40c7ca4bf 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml @@ -37,6 +37,12 @@ properties: description: IRQ line for the ADC maxItems: 1 + rdy-gpios: + description: | + GPIO reading the ̅R̅D̅Y line. Useful to reliably detect the interrupt + condition. + maxItems: 1 + '#address-cells': const: 1 @@ -112,6 +118,7 @@ unevaluatedProperties: false examples: - | #include + #include spi { #address-cells = <1>; #size-cells = <0>; @@ -122,6 +129,7 @@ examples: spi-max-frequency = <5000000>; interrupts = <25 IRQ_TYPE_EDGE_FALLING>; interrupt-parent = <&gpio>; + rdy-gpios = <&gpio 25 GPIO_ACTIVE_LOW>; refin1-supply = <&adc_vref>; clocks = <&ad7124_mclk>; clock-names = "mclk"; From patchwork Mon Oct 28 16:07:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13853726 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 29C6B1DED6F for ; Mon, 28 Oct 2024 16:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730131701; cv=none; b=MDd3AcCZYS57TDMzxqSxaUP1glvqsEyYh7BhLeo1WwJIG3kXKILjtY4/w1fsV6a7Hpi3Gv1h0d6rGw5qMvQgJwDSY4YLE8y5c3plZoC8APsioraywgrfQ4IPHr9ipdKBRNCmp/j1ZJDirKC24zAR8HlGXaOHAzZTai311l9Duwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730131701; c=relaxed/simple; bh=1PjbfDi2WiXCR4YQF91keQyXtP/5XX0xLQMKTfHRFrQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aDAmq7E94ikClGo2d8RoApQisQx0yYw02wyqbx0qFC1kYlVDjLj7qHa10LTnagIOQTdrdYQ1M1inQ7KQd5kLszUL6zwUHYpy2QueSKJvArqbO1GiN/jt1hkZ5G107MFtP0TSyOMeB8hQF374C3cLb5NujK4gSsOfIBNRFmGt7pc= 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=2CB50Nqx; arc=none smtp.client-ip=209.85.208.182 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="2CB50Nqx" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2fb388e64b0so43075951fa.0 for ; Mon, 28 Oct 2024 09:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730131697; x=1730736497; 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=wUsu5FO65zLiIzYZufFdK/BD4939obrHxW8POIWF8hc=; b=2CB50NqxGGLAo3NhR/Rml7TpEPjTYNpadvBJZb7pF1H32edg/4mqPZJez3I/ndZDe9 YTTwSYXQ4Xmhdwv5170iC4CHB8usxaxPi9kWp8QkSyx134xQCwxhxBF7JmliHgbA/lmL Il7XES19ylba0m46bUb0Dn4wgguZ3Fy3cydZGsjWEXOpEGgaw1845Ce2sy9PbG2/q1EB xf7dOn3kcogcfxfJHs048GW1Rh8HyHKp0wH4f9AP6TQ2K0fCf4RFPp60C7d1eJE9ANZO oNFkbOfugQziew0Bdr8eyT/qU7TEBuSkJvIPNg74onKdHCt+TUyc1YnrGXpx7f9V6pvm udLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730131697; x=1730736497; 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=wUsu5FO65zLiIzYZufFdK/BD4939obrHxW8POIWF8hc=; b=TmUMrHqBvWMYEhOJahFp7Cgxq7Zrnj6LDwe9gg3dPYBxwpxYOr9OxyyY2NccFxUuYS MKhTn6TuoYazArrCZXm0iuGIUflZzjGfvGhPEWGD6zvtCj8Lk9czTLYhatOkKkh/e3yB P7L5/kAKdbbTGxWTkE7RKq3jnKYwRyiRAA9evYGUnLczjkR5ghbq7Hd4t5KLOB0v9PjW bviV5yZl/ZK1B5P654nMl0+telBUWA5AwFPG26/1M+yAMYw7Aasu6A6pToE7s2UjzG9I ojJ3cCo+d0eVo5xE0ynflclU4WdP72uenMZzXqW07z3VYn4OhHA1CkLmFrUmFfvEiX2O wlrQ== X-Forwarded-Encrypted: i=1; AJvYcCVvhcYgKb6SGK7by92vdzzgdavFJT9KpOZnz/OKoH1dq4G6bQ1RlaU5mtRaaL5xu7FxawmlSJiyS5s=@vger.kernel.org X-Gm-Message-State: AOJu0YxgMBaOfFQpR/DM96C8Sf6jk2ZNIb9aHoaXBGpZAwyE99H5xgUC Sd5zrqBKOiEP14uRktc8v3fojHnvBb7jo2hnIGEKSRnctDhTEn5Pqw7Xa48dT/8= X-Google-Smtp-Source: AGHT+IH7o1YWzKnQ5bvdNo6Q/BHCkqLAbNNlrmLxFP1lEijk8232M78nJfz/F6glUx7lqCYmW6Qj0A== X-Received: by 2002:a2e:d11:0:b0:2fb:5786:251f with SMTP id 38308e7fff4ca-2fcbe0792b7mr27505701fa.37.1730131696661; Mon, 28 Oct 2024 09:08:16 -0700 (PDT) Received: from localhost (p200300f65f0c3200f401bf2b6011cd64.dip0.t-ipconnect.de. [2003:f6:5f0c:3200:f401:bf2b:6011:cd64]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b13251sm9913799f8f.6.2024.10.28.09.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 09:08:16 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Conor Dooley , David Lechner , Dumitru Ceclan , Jonathan Cameron , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Nuno Sa , Rob Herring Cc: devicetree@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH v2 3/4] iio: adc: ad_sigma_delta: Add support for reading irq status using a GPIO Date: Mon, 28 Oct 2024 17:07:52 +0100 Message-ID: <20241028160748.489596-9-u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241028160748.489596-6-u.kleine-koenig@baylibre.com> References: <20241028160748.489596-6-u.kleine-koenig@baylibre.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3804; i=u.kleine-koenig@baylibre.com; h=from:subject; bh=1PjbfDi2WiXCR4YQF91keQyXtP/5XX0xLQMKTfHRFrQ=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBnH7bdZRlKMt2ZAaypotKzVsdIu+fdIy+h3Jwfz gwxZznQxMSJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZx+23QAKCRCPgPtYfRL+ TjyWB/9b3izawgl7UnP5UDU7yHZRNi1IWYKCO0oEotnJtAGCowG+dYGsZmj9qrIQcOx//nUlVJe Fc65rFnrZ76NG0BpnYmVk/4eNsVKJvDFp5NhpwvoyG0oA9l6e5b/BEEZiBVgTIe9xrfMge6quSV z+SbsNY7up2Y+PLl6yZT1vplgBkKBK4EFv2AGBSpmniMMWbf2MpgZIuKY5mrY99tWrlIdK1x2Az yJJ3FpwH9rsdDcBYzFEqU5V93jX+B/lhZIwNiiBCgBipsmpCn5yBI9L13bK0rXUKw/SlRp+V7wr UzxZDKGunWq8T/4FbWCiqB1izJ64aDlfmmTZ7Eb9xKYoPkji X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Some of the ADCs by Analog signal their irq condition on the MISO line. So typically that line is connected to an SPI controller and a GPIO. The GPIO is used as input and the respective interrupt is enabled when the last SPI transfer is completed. Depending on the GPIO controller the toggling MISO line might make the interrupt pending even while it's masked. In that case the irq handler is called immediately after irq_enable() and so before the device actually pulls that line low which results in non-sense values being reported to the upper layers. The only way to find out if the line was actually pulled low is to read the GPIO. (There is a flag in AD7124's status register that also signals if an interrupt was asserted, but reading that register toggles the MISO line and so might trigger another spurious interrupt.) Add the possibility to specify an interrupt GPIO in the machine description instead of a plain interrupt. This GPIO is used as interrupt source and to check if the irq line is actually active in the irq handler. Signed-off-by: Uwe Kleine-König --- drivers/iio/adc/ad_sigma_delta.c | 35 ++++++++++++++++++++++---- include/linux/iio/adc/ad_sigma_delta.h | 1 + 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index e2bed2d648f2..b5785f2a0abe 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -539,12 +539,29 @@ static irqreturn_t ad_sd_data_rdy_trig_poll(int irq, void *private) { struct ad_sigma_delta *sigma_delta = private; - complete(&sigma_delta->completion); - disable_irq_nosync(irq); - sigma_delta->irq_dis = true; - iio_trigger_poll(sigma_delta->trig); + /* + * AD7124 and a few others use the same physical line for interrupt + * reporting (nRDY) and MISO. + * As MISO toggles when reading a register, this likely results in a + * pending interrupt. This has two consequences: a) The irq might + * trigger immediately after it's enabled even though the conversion + * isn't done yet; and b) checking the STATUS register's nRDY flag is + * off-limits as reading that would trigger another irq event. + * + * So read the MOSI line as GPIO (if available) and only trigger the irq + * if the line is active. + */ - return IRQ_HANDLED; + if (!sigma_delta->rdy_gpiod || gpiod_get_value(sigma_delta->rdy_gpiod)) { + complete(&sigma_delta->completion); + disable_irq_nosync(irq); + sigma_delta->irq_dis = true; + iio_trigger_poll(sigma_delta->trig); + + return IRQ_HANDLED; + } else { + return IRQ_NONE; + } } /** @@ -679,6 +696,14 @@ int ad_sd_init(struct ad_sigma_delta *sigma_delta, struct iio_dev *indio_dev, else sigma_delta->irq_line = spi->irq; + sigma_delta->rdy_gpiod = devm_gpiod_get_optional(&spi->dev, "rdy", GPIOD_IN); + if (IS_ERR(sigma_delta->rdy_gpiod)) + return dev_err_probe(&spi->dev, PTR_ERR(sigma_delta->rdy_gpiod), + "Failed to find rdy gpio\n"); + + if (sigma_delta->rdy_gpiod && !sigma_delta->irq_line) + sigma_delta->irq_line = gpiod_to_irq(sigma_delta->rdy_gpiod); + iio_device_set_drvdata(indio_dev, sigma_delta); return 0; diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h index f8c1d2505940..866b4c21794b 100644 --- a/include/linux/iio/adc/ad_sigma_delta.h +++ b/include/linux/iio/adc/ad_sigma_delta.h @@ -96,6 +96,7 @@ struct ad_sigma_delta { unsigned int active_slots; unsigned int current_slot; unsigned int num_slots; + struct gpio_desc *rdy_gpiod; int irq_line; bool status_appended; /* map slots to channels in order to know what to expect from devices */ From patchwork Mon Oct 28 16:07:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13853727 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 0DE1A1DED6D for ; Mon, 28 Oct 2024 16:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730131702; cv=none; b=frHufGJY2wIuKRzTYYnpOurmeAuBzXiXlfwO8Cqqo/tNAuNzwgtQUDdO/JhFnL3QS+eS1V8xcBkUbIARcb3T0l/KqUKIrn3IrWWNsK/EyqdKVNBC/Va8afaU7UwAasRRDfgPOXa2+PxxWn5ReBNx2w7hQmhOCLLDh9Xe5uJuZsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730131702; c=relaxed/simple; bh=0N01AvBl0uJvKMTxgBJP6kgP/tEGMfe142ivUmjogG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SqGLztPu8gag+uqS4XclOcjIW+KNTgU2oKBxzwIvkjbx0XHKh0ZWtqvuUy+URkH1MY8/ZqBhPkU1yjbU7fLcfEvIlNaSRbZN0MM2WAtZLrKnFuoCDP5tfX4aolo6dhwbbX1jqDweh1uzAa1o4+m0oafckHnemPkg3FKVraz5CQ8= 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=cNeDHi49; arc=none smtp.client-ip=209.85.128.49 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="cNeDHi49" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4316e9f4a40so46403685e9.2 for ; Mon, 28 Oct 2024 09:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730131698; x=1730736498; 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=yDqZMtYQ911IVoh44LgqSLk8tfAEAk1LjxbYN8N2FQM=; b=cNeDHi49IuT3K9ROnYwPOhod8/HZIf7GrQmLs8r4P0t/inI5Konvxqx2idsVwYUKUO KGkPQYPc7mqJcdpXshzd6+M+A3e8rg/1reGn1qj2SSC23i9VqMUF7Ww1EioxW99CPH73 Mw7lCW1OKMprKrG/tCZuFNT+ce3JdG+MttvyDEpaMJndjQyNibqp6dswkgdtkn74nKWV 8MPVx9Hgac6XVnISA8OJGafEDaCO1wW6adzxkInKD0ObxRpnY2qSZNwwV02Z2oA6uocx fgwJxZwv1i01fcQ/tyvnw1oezfDnqsA/vNaXc5I4pjCAKdDWSBxyBPiTFFicWyyjQdMz 6UVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730131698; x=1730736498; 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=yDqZMtYQ911IVoh44LgqSLk8tfAEAk1LjxbYN8N2FQM=; b=wkH/kaHRaKPVIPfLOGRtzRAt7g/XKU7dwy5ZcbqPHfjIzB+kTAI/ZXWLrKzkNh1k0W JErw12pr3rcdUEAcsot4O5hxFNPN5PwNTbsnZ+bjGGpfETTvLb8cz+Pb2bVXSwtCbpTA xNDpJvSh8pHhjNp9/+K1wxanjeVDbsnbxMEsl6K+svx5gpkZkohrlOm9TnOLM1Wc3cFD I3QNRKi+DJhQZaYl+ckIc4XYAa6JKMSgEn26vkAt8iqoexBvje5KOoEncTvHBgc82/rf Zm9skq7ZqZx5uJOTMGeQaCfdTzcOfuZCODzpBIeIfc1cSLaIH/IWTSbrUQ6x2EYazZyr 4LKA== X-Forwarded-Encrypted: i=1; AJvYcCXxynszNtlh5EglLysPQ3YZCDEEaDrBwQArlxLbS6n6JV8cE+erNCIZrwy8nhl7dcMmM4WBc3dzS1w=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5tt7pt3LT82MxMeAaFiGCl/4uDZuZJBbvxTCqx4ba+kUHPw/2 +xJWXy0dGM/J97+m4GKwnF93vm9KZ52Y3qPj85T7SZFy0f7SdCcYpkwnENrLb6g= X-Google-Smtp-Source: AGHT+IE9MmEjtbzZdsfKj2QOyaCwDFePwJfeeepNxFHDAUu5yysG0Dm6iQx0/6I+8sAZYGhDKuaavw== X-Received: by 2002:a05:600c:1c82:b0:430:699b:7d22 with SMTP id 5b1f17b1804b1-4319ad14d14mr85589385e9.26.1730131698361; Mon, 28 Oct 2024 09:08:18 -0700 (PDT) Received: from localhost (p200300f65f0c3200f401bf2b6011cd64.dip0.t-ipconnect.de. [2003:f6:5f0c:3200:f401:bf2b:6011:cd64]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43193594fffsm113281335e9.13.2024.10.28.09.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 09:08:18 -0700 (PDT) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Conor Dooley , David Lechner , Dumitru Ceclan , Jonathan Cameron , Krzysztof Kozlowski , Lars-Peter Clausen , Michael Hennerich , Nuno Sa , Rob Herring Cc: devicetree@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH v2 4/4] iio: adc: ad7124: Disable all channels at probe time Date: Mon, 28 Oct 2024 17:07:53 +0100 Message-ID: <20241028160748.489596-10-u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241028160748.489596-6-u.kleine-koenig@baylibre.com> References: <20241028160748.489596-6-u.kleine-koenig@baylibre.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1375; i=u.kleine-koenig@baylibre.com; h=from:subject; bh=0N01AvBl0uJvKMTxgBJP6kgP/tEGMfe142ivUmjogG8=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBnH7bgOE7iGbMylKJAJvbiBOX3hRV9bssr11z64 7939T0xdzKJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZx+24AAKCRCPgPtYfRL+ TgC+B/44r6pWumnFJVv8sIK1/jyHfPZCcQ7yuo9dHdXU3Xs0gWCaZOI30gRKb/nCh2Na4w8TUEL GIJ/fERJXDUhc9+Xp2z+lrhKkb/Sbg8ztcG2QcAHSZfVDewE2+kCM3/bdOecr96lLvQHzM59x4B ba5NEVL7gOuzgEQpjxUwWX3kewz2leypkjDfd4ejD/PGKrmkv7123qE5CMDobb2s3w6Z7x1FQO9 NoTOAKiI9R/YF8KYZlGuRLvhtDcN+Tt9oFKcDyctDE7b3Yj96eFdRmMQVVt7NA3pyKBku4UMHFe uZntXo5tLoaBzWBx37E50DuxLjsriVZmmItgEU7MPcGY3mqx X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 When during a measurement two channels are enabled, two measurements are done that are reported sequencially in the DATA register. As the code triggered by reading one of the sysfs properties expects that only one channel is enabled it only reads the first data set which might or might not belong to the intended channel. To prevent this situation disable all channels during probe. This fixes a problem in practise because the reset default for channel 0 is enabled. So all measurements before the first measurement on channel 0 (which disables channel 0 at the end) might report wrong values. Fixes: 7b8d045e497a ("iio: adc: ad7124: allow more than 8 channels") Signed-off-by: Uwe Kleine-König Reviewed-by: Nuno Sa --- drivers/iio/adc/ad7124.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index a5d91933f505..749304d38415 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -917,6 +917,9 @@ static int ad7124_setup(struct ad7124_state *st) * set all channels to this default value. */ ad7124_set_channel_odr(st, i, 10); + + /* Disable all channels to prevent unintended conversions. */ + ad_sd_write_reg(&st->sd, AD7124_CHANNEL(i), 2, 0); } ret = ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control);