From nobody Mon Nov 25 07:52:58 2024 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 AA5CE202F61 for ; Tue, 29 Oct 2024 07:39:02 +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=1730187544; cv=none; b=tFqK7z2bz4fa2a+V4YDIcOMzgUfAWkkThTb9PRhN/xghclGg3RAGqWWzjQdzcW4Pbc3+z5/3JsBcj7qaye4JoYZSuuJyBViWrbnUX69FqEHA5sh5iHdBQTfp5zydl6Jb5Ic7P6Za1c6vKgtFtLeNI4br8ITLsza9N71NAYuAH6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187544; c=relaxed/simple; bh=5KsorQSJgZeTJd1wUS9Cebj4jWXpxz/aBH8FLYD4+HU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hOSNK1CK+si6MJ2cHxBPflXK3sYGIOEojp3c8H1RfynrI0C2bsuhJjKJxrAi8ADE7QZWi2VcqQoMNcXGrKqChdZL3MgeJ0lCNRAcHzXHyQl0Tll4KZ//MKW/ntrAXdp3Nti3i0PJKkuygwRgMA31o2mjJrWVQVgc5G7w8qbVSGU= 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=LkEUZVaz; 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="LkEUZVaz" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-37d49ffaba6so3606619f8f.0 for ; Tue, 29 Oct 2024 00:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730187541; x=1730792341; 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=st9um2/AfYYcoCBp73pspcb++48Yu2jLzSVNVtzZmUw=; b=LkEUZVazbcDMqFVp4oc8wZhFHVw0BN/Xehi+VX8KED5eWO68cYh98BcwGOu498ouWq TtarIMzzvFOxixRTEuv4uc4W/wiVpjAMI5oJZiqM1KkzxrkLyQkbGXIIS7nn2d4ycQoY 5ympZpcnntMsHWQN2vcEUlQZ26ayEfdQXwGhF7oIphMpboZqfW68oHsEg0dDmKt5JarA WFjPz8yVOKxsZaF6a/ifFnslh2fBB9Yd2MwiEwPP2qdHQvVhzc45g1sSyn3jr4mBpKTg ZHYtlHN6L3SWABoKlgO6QEq4DgPrksm9gosf6BaRNPPF6SeW5tvj6IblzxxHT1zKfq60 A6Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730187541; x=1730792341; 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=st9um2/AfYYcoCBp73pspcb++48Yu2jLzSVNVtzZmUw=; b=a8/N/P1H4lcsq0XPZ4ZD7UpTachqwbAELzJEmtEyQEJ1PV77f+10DOmxZJ39sVNNvQ wLZR45Ox5ue/ZwyffKiRM7JnPXKP+vMQ6dSgtiaJh6ZmUndwmiXZPJCVs/u9aH7Nw/2A cS8UrOwVDQRM4JJGVj6Ja/HUJ8Q8BFReOMm1R6c2Vvlm1sESH4iEk9NODApyFpqa7o1O 3T1zqVL2z/pW2XmRDfZGyWMNLnaYCB+U0rkz6MQG1ozt+ZV8gS/D3SdWeber7iZEBpi2 RVj9Yh+swNPyN1g4v5WfANZan7UFTHca2MqhL22DGiLgQ7euoM6juZhgmTETF1brWc3c RCdw== X-Forwarded-Encrypted: i=1; AJvYcCVc6dPtojbafDsV6wzl8gMLfipZSXHI4xfmy258f39B+S0meeIvzJZZYnvNvsgQhnQHK+ZVamG9ndfJis0=@vger.kernel.org X-Gm-Message-State: AOJu0Yyucu5JUQTWekeWKhvw5g9VZ4otkBCZtL7u484QS/1LFkjBVT85 HARyFLZ6Dddjg4eUMH7eIT7DQVG25rEYk1TiI4aBwDxLDepJwtyv+4sP0vLdjrY= X-Google-Smtp-Source: AGHT+IGbUlhfPKvrjzJQWDaPkc53rwcJ2pi1RJFhGDGbUz2U7WeyKmGEC8fiWSl6/vyb71XnnECg2A== X-Received: by 2002:a05:6000:1f11:b0:37c:c4bc:181c with SMTP id ffacd0b85a97d-380610e6bbfmr7704435f8f.11.1730187540947; Tue, 29 Oct 2024 00:39:00 -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-38058b714fesm11692939f8f.71.2024.10.29.00.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 00:39:00 -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 1/6] dt-bindings: iio: dac: ad5791: Add optional reset, clr and ldac gpios Date: Tue, 29 Oct 2024 08:38:52 +0100 Message-Id: <20241029073857.753782-2-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029073857.753782-1-ahaslam@baylibre.com> References: <20241029073857.753782-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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: Krzysztof Kozlowski Signed-off-by: Axel Haslam Reviewed-by: David Lechner --- .../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/Do= cumentation/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 =20 + 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 =20 examples: - | + #include spi { #address-cells =3D <1>; #size-cells =3D <0>; @@ -53,6 +65,9 @@ examples: reg =3D <0>; vss-supply =3D <&dac_vss>; vdd-supply =3D <&dac_vdd>; + reset-gpios =3D <&gpio_bd 16 GPIO_ACTIVE_LOW>; + clear-gpios =3D <&gpio_bd 17 GPIO_ACTIVE_LOW>; + ldac-gpios =3D <&gpio_bd 18 GPIO_ACTIVE_HIGH>; }; }; ... --=20 2.34.1 From nobody Mon Nov 25 07:52:58 2024 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 EF336202F70 for ; Tue, 29 Oct 2024 07:39:03 +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=1730187546; cv=none; b=mt2JIXX5l+PQGGhDMxfeY78PACc3j16gEIeI+XkAJ25pTWQB7JuXL52ozzxIoaViavsxLcsGZ+15qX2GiofFovCOH0rGFfAGUfAPIfT1CaXdGBDOR+KqMDGNddbP1hXHUeCcP6uysw2o4VYVc9H5hFqIDEgbIMpYRYfWiKgv1nA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187546; c=relaxed/simple; bh=jafJk2l8LB6j7r+ISNKS+BYGrzbzmOwpI3CE3mDkURs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kgARvSCZzIWYIbOPSHn6OxpJo5ON5AYX7AhcSlUzmzS8iqhOHQYdhV3Pyy2uahH8O1myyHOx2tLLbuSyyPH4vlf0uqfwiDqqakMt9MQNe6l9a6oiv2oDgLBjzFK0gwGG7lWleINgUID+JWUTyYoe3c3FycQnxW7NbW/LaJc2n20= 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=KOAITw3B; 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="KOAITw3B" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-37d3ecad390so4449556f8f.1 for ; Tue, 29 Oct 2024 00:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730187542; x=1730792342; 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=ByBkxKFO1zAiwfUD51XRICDpnS7esWzb+iP98wAku88=; b=KOAITw3BtyqCiVBp2psb89nhskAlcs6IzCOKLx7SWFHZDhslzkuHGPoZkyBtiME2kU 8vUxZ8Is1iaZL5PQuhNJK0s0m9TlPhggCfXnxxFPQlUGqkytAfCXCzNg/fRgFTROqu4w fFv12YgAWroaPRflE5iJrOnZiBpZhVlLQQM8uNEC1j3W7FBvnLY4slE+dRzDBRvUsQVS ZH1BpoBPbvvbLoi+79R9HuN5tf7cDNnFCGuQQR7ltby/BqZcYiZ27JWKmtJwoSBtubyb rvj4mF4BSQhNZeLTKl5rPiHKFUGugf00/4kNgWFl3DGEblMdFTyQxwjSGWAo5dU7AEp8 TXyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730187542; x=1730792342; 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=ByBkxKFO1zAiwfUD51XRICDpnS7esWzb+iP98wAku88=; b=IsPCh5IjJhuC5Ao57hz591mPgsMB7WS80F6FSO1dlcSNsywdWbkSv7WhbhhXxmOpn8 pkTVnO26Jmy3+xrsNf40wV8uwjxfPvXWaNr+KJYP0Ju9hsAS7rr9sbEBkTVQ9ViWHMal /TfW0Pzt8zk8JjF2IeIEQ0Zwlg5CGcA6XckKd0tbJGOGz6R3lyCqrDxY+pAr8wg6c6rz edQ29PXzv4mqc8owlt1Cd3Qy4D2blJRbrCcmsRAMshmczThpgyKM17uauWgA6AqsO5U5 yD6kiIgaK94t+wy7uUVLQ80EHev9o7iYaty/xXyTi864srNtcaAL/7aCSxdFrP9ffpA1 1Dqg== X-Forwarded-Encrypted: i=1; AJvYcCVHCY6sHXpcXZsbkVsBs6RRpJXbInRTPGZHh+UnutQnyhfVFWamfrcdF3BNWei4+OimI3EpaYTnube6goo=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9IWup9N24iVSpUXGvywYMXqtBpBZglUWY1gfsjJ0sjjE8c3qO HFu/fz5ucqNReLuGFF45koW/BVAEXJ0RJJ8J3z0ZJcJ7T6WKieS7jV8RNCVh3uY= X-Google-Smtp-Source: AGHT+IGsOTbqoT0AU7JxWkeKxYQBH4Tl4G3UGLLILEaIH0T/p3AFPiOJZfClYLH6CLSMd920jcG8Eg== X-Received: by 2002:adf:e742:0:b0:37d:4610:dca with SMTP id ffacd0b85a97d-38186a22c7dmr734577f8f.31.1730187542265; Tue, 29 Oct 2024 00:39:02 -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-38058b714fesm11692939f8f.71.2024.10.29.00.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 00:39:01 -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 2/6] dt-bindings: iio: dac: ad5791: Add required voltage supplies Date: Tue, 29 Oct 2024 08:38:53 +0100 Message-Id: <20241029073857.753782-3-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029073857.753782-1-ahaslam@baylibre.com> References: <20241029073857.753782-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Axel Haslam Vcc, iovcc, vrefp, and vrefn are needed for the DAC to work. Add them as required bindings for ad5791. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Axel Haslam Reviewed-by: David Lechner --- .../bindings/iio/dac/adi,ad5791.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml b/Do= cumentation/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 =20 + 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 =20 allOf: - $ref: /schemas/spi/spi-peripheral-props.yaml# @@ -65,6 +85,10 @@ examples: reg =3D <0>; vss-supply =3D <&dac_vss>; vdd-supply =3D <&dac_vdd>; + vcc-supply =3D <&dac_vcc>; + iovcc-supply =3D <&dac_iovcc>; + vrefp-supply =3D <&dac_vrefp>; + vrefn-supply =3D <&dac_vrefn>; reset-gpios =3D <&gpio_bd 16 GPIO_ACTIVE_LOW>; clear-gpios =3D <&gpio_bd 17 GPIO_ACTIVE_LOW>; ldac-gpios =3D <&gpio_bd 18 GPIO_ACTIVE_HIGH>; --=20 2.34.1 From nobody Mon Nov 25 07:52:58 2024 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 187C5202F8B for ; Tue, 29 Oct 2024 07:39:04 +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=1730187547; cv=none; b=D3DOa1w6vmzFzy6haklC4z9Y2xK+f8zcYOyf5dJyKJOubG0mwxb/UyEz+69GfHoER1wHkzGHwJRTuhRg5XAb9TuCg9mcodu10Wazt34RTPd8hrIykTX+fYgQL6CsNdYwlVv4k0+OaNtSqfjSCD0hD0znMiJ4LuofW2TO8ZaX0Qo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187547; c=relaxed/simple; bh=IW7rBfJDFC+nKog3s3s8Fih6Q9vHfUoFcdI1qORZ9ao=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hD/LgKox86ZAtGlzk8LC4K6CLyVGK1p3EvrTA3KllixIOHrt+L4IwEUPVpdSo2j7w9rw1H4LEaGSeVxkZuLwcf69UYxRYEagpezaWpeqwEH2WS/3uWaxbkMow6vVcCJhHI/8wkiMyzQUhto7IF5q0X1Ibc4XuBbJlfksfvGAIkc= 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=rlx0rM9l; 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="rlx0rM9l" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-37ec4e349f4so3688584f8f.0 for ; Tue, 29 Oct 2024 00:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730187543; x=1730792343; 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=QGjr3jCM4WIEDdHWWWRVwSpY3SH8z2NT/sPqnMjB+CM=; b=rlx0rM9l98BEBMVL6WCwX84E2801iAa8K9X7auXvhI+2BKro6QqtoBxcmqwztPr53p 0yMVePRAvHm6R5fYNQnIQGk6A6uNEVX9OjD60T2PxEWMb5k02ufZTLu6ypMQDGFiQl4L wx0T0FlV+E6WWaCKFFBPAG51EhA+VAdwVnt8bpLtgW2b/5T/sKPfWwZvynOT3F1M/T7U +CrtGekE3UZDodtJv8ZYkEASchElswvDThh16Ovf1WdY5NObwbG+y+/4U7LBHPQi/4fu QEuWIiP3fMF4MYtiEoxVyi23GGpWKa2nUq8lVNR8YwuozJVFf1VzsdEDc9tM+ASy/Agd etog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730187543; x=1730792343; 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=QGjr3jCM4WIEDdHWWWRVwSpY3SH8z2NT/sPqnMjB+CM=; b=Xf3DUzLVfQvDpy6facVerqhUI7HjGiNFvzVGoy/kP4TjDYAcFf5gX10P7+6117ulvR kVvpnIsLMX7HtvYZUHnb/0T3g6rZgBkidWB5YgC1k0Kp7vMLaRO+dCRuqHoBmIwjwFdH /4WXDzGrWkpRWQQsQvsX/MPylpmfB7MCQ0GNF3dhO3QHoflMmisbf11v5t632qmW4jDp cxdnI/77GZOZQvcGtxJFlcRE6mnj+SKWmIXpm1ndnkL0eU1lzMtQFwNAqPRoJHlMwtXQ 5D7Ui1au4g3GRTjjxsvp4vE2e8VAo4BIOCqASNpLnT5Wi/40lDFNil8pemLOg757E9Sc +9Xg== X-Forwarded-Encrypted: i=1; AJvYcCVcO15FSU9Jtj/N4ToF3p9z5SKJM6DjkRVnnD8U4MLryGfV6JP4l5g0v9zU/Mj1xTdaiQgkllpm8BMR07Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzobxNqxdRm/cbYQHVzSmZn6S3hGPLdqBQNhY79dCsN1GR+xGbY 6Pd2P4q22wfAXIEjdsonzS1ThmIeVkHjJbDZC9VLGww23coPjy8eVNfal4+Fn+8= X-Google-Smtp-Source: AGHT+IG7DEIOkZmGbruw9L+flf9HSU7FIfvkxW5iIso8YxWUFRncRG4s4ANz3+2mfN0voS1hwmwfdQ== X-Received: by 2002:adf:fd0a:0:b0:37d:2ceb:ef92 with SMTP id ffacd0b85a97d-38061162d5amr7713512f8f.27.1730187543481; Tue, 29 Oct 2024 00:39:03 -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-38058b714fesm11692939f8f.71.2024.10.29.00.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 00:39:02 -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: Tue, 29 Oct 2024 08:38:54 +0100 Message-Id: <20241029073857.753782-4-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029073857.753782-1-ahaslam@baylibre.com> References: <20241029073857.753782-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: David Lechner --- 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 @@ =20 /** * 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); }; =20 /** @@ -98,13 +101,6 @@ struct ad5791_state { } data[3] __aligned(IIO_DMA_MINALIGN); }; =20 -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 =3D 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[] =3D { - [ID_AD5760] =3D { - .get_lin_comp =3D ad5780_get_lin_comp, - }, - [ID_AD5780] =3D { - .get_lin_comp =3D ad5780_get_lin_comp, - }, - [ID_AD5781] =3D { - .get_lin_comp =3D ad5791_get_lin_comp, - }, - [ID_AD5791] =3D { - .get_lin_comp =3D ad5791_get_lin_comp, - }, -}; =20 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[] =3D { { }, }; =20 -#define AD5791_CHAN(bits, _shift) { \ - .type =3D IIO_VOLTAGE, \ - .output =3D 1, \ - .indexed =3D 1, \ - .address =3D AD5791_ADDR_DAC0, \ - .channel =3D 0, \ - .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE) | \ - BIT(IIO_CHAN_INFO_OFFSET), \ - .scan_type =3D { \ - .sign =3D 'u', \ - .realbits =3D (bits), \ - .storagebits =3D 24, \ - .shift =3D (_shift), \ - }, \ - .ext_info =3D ad5791_ext_info, \ +#define AD5791_DEFINE_CHIP_INFO(_name, bits, _shift, _lin_comp) \ +static const struct ad5791_chip_info _name##_chip_info =3D { \ + .name =3D #_name, \ + .get_lin_comp =3D &(_lin_comp), \ + .channel =3D { \ + .type =3D IIO_VOLTAGE, \ + .output =3D 1, \ + .indexed =3D 1, \ + .address =3D AD5791_ADDR_DAC0, \ + .channel =3D 0, \ + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ + .scan_type =3D { \ + .sign =3D 'u', \ + .realbits =3D (bits), \ + .storagebits =3D 24, \ + .shift =3D (_shift), \ + }, \ + .ext_info =3D ad5791_ext_info, \ + }, \ } =20 -static const struct iio_chan_spec ad5791_channels[] =3D { - [ID_AD5760] =3D AD5791_CHAN(16, 4), - [ID_AD5780] =3D AD5791_CHAN(18, 2), - [ID_AD5781] =3D AD5791_CHAN(18, 2), - [ID_AD5791] =3D 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); =20 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; =20 - st->chip_info =3D &ad5791_chip_info_tbl[spi_get_device_id(spi) - ->driver_data]; - + st->chip_info =3D spi_get_device_match_data(spi); + if (!st->chip_info) + return dev_err_probe(&spi->dev, -EINVAL, "no chip info\n"); =20 st->ctrl =3D 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 =3D &ad5791_info; indio_dev->modes =3D INDIO_DIRECT_MODE; - indio_dev->channels - =3D &ad5791_channels[spi_get_device_id(spi)->driver_data]; + indio_dev->channels =3D &st->chip_info->channel; indio_dev->num_channels =3D 1; - indio_dev->name =3D spi_get_device_id(st->spi)->name; + indio_dev->name =3D st->chip_info->name; ret =3D 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); } =20 +static const struct of_device_id ad5791_of_match[] =3D { + { .compatible =3D "adi,ad5760", .data =3D &ad5760_chip_info }, + { .compatible =3D "adi,ad5780", .data =3D &ad5780_chip_info }, + { .compatible =3D "adi,ad5781", .data =3D &ad5781_chip_info }, + { .compatible =3D "adi,ad5790", .data =3D &ad5790_chip_info }, + { .compatible =3D "adi,ad5791", .data =3D &ad5791_chip_info }, + { } +}; +MODULE_DEVICE_TABLE(of, ad5791_of_match); + static const struct spi_device_id ad5791_id[] =3D { - {"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); =20 static struct spi_driver ad5791_driver =3D { .driver =3D { .name =3D "ad5791", + .of_match_table =3D ad5791_of_match, }, .probe =3D ad5791_probe, .remove =3D ad5791_remove, --=20 2.34.1 From nobody Mon Nov 25 07:52:58 2024 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59DE1203702 for ; Tue, 29 Oct 2024 07:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187548; cv=none; b=VOcj3WjvUScKNjBONuc8eozaxBHZKbfia7sKifMvmvUQHd09aEtRgfK+az3Qw01swPw0vxa5llNKVCuy9ROYeg54a5Ch9B7/q8Bt3WjQiLafWL+HB0QkdblroGdNjEX9VkAZGxaBx3wzm3lu432i2JmNtGm0+TnusX+LukRnunY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187548; c=relaxed/simple; bh=lgc3ZdvonuJhwFaGdS5M3g6B8YizifcdxdIZV7LNhqw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qrV+1/781O9lV8Djf2zKDgyUS/NQ9WSHESa5fcrwbtuxbrz+p2ePBZJM0DjpsVJs0eNXF1nZqv3EUcCAQwAW7i7K4tdBcXn3fqivqBMkEaFIzup+neMRJiVvhQxqFqV8xUMnqBR9qZRpvyZm5Pf9SnDyE2w2ed2ZTnH4PYT+Jkw= 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=xsNcgShk; arc=none smtp.client-ip=209.85.221.44 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="xsNcgShk" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-37d70df0b1aso4109006f8f.3 for ; Tue, 29 Oct 2024 00:39:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730187545; x=1730792345; 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=f6+OsC9+LoXLR+j3K6I0JJSao5QQ/Zax5Bndg5L11B8=; b=xsNcgShkNcseJg+YQUzGMjpD2YOqRl+yQT2OpeAKwSqKv7FMkKl1WjJR6mF66eZPrS xNulAykMihM2hUoaUImwP40Nm5Wtiq1M0yNzx8bghTc4wPr50l6ty4LYEn0QofgWYlJe wk4VKt6ZpxglErrAf7S9obzjl9SQRECgxuluZu55dEsi0NTvyOsCKEHpokoD8cUqDUw8 Nsgzg2fdKbPwQhMiFjtO5Sq2UuTcnwYcLlXstjCP1sQNyYlyySjaoKkrQjpZoL/Y4GDS F/JOWKV6HcXZwwwm0OdV94dUQwo9++cD2PKqF9M4ZwbxWN7NM1QUSiBkx0t3oqb90rpT ODQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730187545; x=1730792345; 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=f6+OsC9+LoXLR+j3K6I0JJSao5QQ/Zax5Bndg5L11B8=; b=oJk5W0tl5kuZL8BT/C9Ih07G8686leKhEz66TsEZR32smjOXkLLd7AJjr32xQZ+v3B 4NfLtecFWRus3hGtJ21hz5RHTH9TV7HZXaF1E4wwLCWkZBpTZB7+sShaHBkZqcHvMjbL 7eGG4J6nmFak5TRYdgsmcoY6DlVA0oAQOoT+L6jIdgHkEFtXBJHqixfYjMNce9CjjnYv ewkM9TQWrboVVweBTrm1nZO9HJ4He5ndBe6dhyZnmz+DADh3EOB0/FvZn5PU23O6Xy3T HAlo3ja2hBrNkHudy3aiCO0OFTsawaThlk1y2RiJKGW0++W9SJMB3BW5LNeCst/4bOVZ qSvA== X-Forwarded-Encrypted: i=1; AJvYcCXq3pSMAjBLuCcJj+PFoxrN6GoOd4n3wTZvNB9AeG8Mxs/tibNCZxTHDPsjSMrYHYlY+WxJWziXyGBcMow=@vger.kernel.org X-Gm-Message-State: AOJu0YwyVYd7ghuwJ1ucOq5wW2TZzdUEI1s95Q4GzOaTzB36dexJMYNY V6stQYThJm36FaFPhiJ7wr914JEir3uBp4W0D9vCkXl3WhFFnUbXZiV9nUqoGYI= X-Google-Smtp-Source: AGHT+IHAE7eZN+Eog3lt2T5PRj6/6N6+17FYiNk3ptAKBpVkQC3Djm2jkgzh/D+1INJFk+3xjoxEDA== X-Received: by 2002:a5d:484a:0:b0:37d:8084:160b with SMTP id ffacd0b85a97d-38061127f9cmr7578370f8f.23.1730187544626; Tue, 29 Oct 2024 00:39:04 -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-38058b714fesm11692939f8f.71.2024.10.29.00.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 00:39:03 -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: Tue, 29 Oct 2024 08:38:55 +0100 Message-Id: <20241029073857.753782-5-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029073857.753782-1-ahaslam@baylibre.com> References: <20241029073857.753782-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: David Lechner --- 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 =3D iio_priv(indio_dev); + + st->gpio_reset =3D 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 =3D 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 =3D 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 =3D devm_regulator_get(&spi->dev, "vdd"); if (!IS_ERR(st->reg_vdd)) { ret =3D 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"); } =20 - ret =3D 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 =3D ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); + if (ret) + goto error_disable_reg_neg; + } =20 st->chip_info =3D spi_get_device_match_data(spi); if (!st->chip_info) --=20 2.34.1 From nobody Mon Nov 25 07:52:58 2024 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.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 8115120371F for ; Tue, 29 Oct 2024 07:39:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187550; cv=none; b=uUhCoRF1efinrLCHTcpC2NEYsTvis0dcSQuEsTyD7GG4CD0VyqpNYrsxFr5G2W9Ouj86Y+MzuizvohCwNQsHGJSW/bGoIsUOAePlpgaA66MWlzxCBM6VZGLQfmY+CPDCksfclk9H3vkj03xEf5wo62U4Fmv9lhsIOGGsUYQvCGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187550; c=relaxed/simple; bh=drc+y5kdHBFZW+y0Q/S5OpgzW7o6OSlxfTOYC3K65Q4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N3je+UCgJhHDbDv5c6QnwE1Z7hNcXZGaoxbPu44euCEHpkSGcXVVBdMkrIe9tG0SVh/yov+hCS0Jj56mXOnPbuqAmxCG20Yje6pdXAp7zi6x5/xBUccavNPHIbNk6z1JLshfzWZlc7JIL7H2a1dxNGG6hqDAUu2hpxQfY9oeAI0= 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=fHfepmax; arc=none smtp.client-ip=209.85.128.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="fHfepmax" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-431548bd1b4so49051915e9.3 for ; Tue, 29 Oct 2024 00:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730187546; x=1730792346; 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=hgMBz/tynDf3qwEmbHc2DggdoWRxT1U8YZ1gh4qnbFU=; b=fHfepmax1bjN3eYdiBWW7SN8uScHnfsRu65+YF1DDpsjTvfrnKRbh8tWYIgvZwFi94 +HIEvenh/u5ZRfhoTjzhQN+IxjJOjd5xQ0WMBot8nFXPX+wWurWd8lN+kKPPWQmdmw1F W2dOh7q3UTWqF7ts+9tlSwjmyK0bccckS7KSoWqFkrz+7YaruW5CuPMdoFXORqVNVEu3 dzDFYMNKnjWD3JfvxB9S9fzYZx3u1anWXdmXP63+g6Hcf4EkMomI/b2GVdItsM5LN10i gJa/aRu/F4XDuT0b68Hp2T5ZE79Xw7wb7R1mcqIFZwKzdpsktne/cc/Fnh6kPoLNqaUn j0Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730187546; x=1730792346; 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=hgMBz/tynDf3qwEmbHc2DggdoWRxT1U8YZ1gh4qnbFU=; b=ubkLO8TArC60iiijKTSbrIr1YD2hPylchqbbxP/yDxbmdEx01NYuvHdB2VenQP9ekN 7OMjSoQB2MRAMTFhEVvI5gnktUBC+xFCODfkvTqc2U+0NfS3UWM3ze6JBXmgqfrXMY29 ky/VJ+/grVr5iTwQF5dO3QD5p8/VraENW8FejUuHmzCHvVmeHbCbKTWwcGaxY6vWUzhr E2xkMdf+Jf0rvAeZUzACxwvuSGUq8Iz3QQ0GiD2UL7XyggeDqbIX/ltW+GoMnS/ay105 PhL5AzpSNMt/BhAEdrBIldH86wfS2N6Cv5KIWJ2tH+q7lHR251A1rJS27tDZCXYznYOY Ogbw== X-Forwarded-Encrypted: i=1; AJvYcCUmJx/udnjN7svaOhZpTZ7a93O4DNJKf3Lm4Ne+DciiGBlZRj4WWMlkQwWezsv3lf56IxiuHaT26EHy4ug=@vger.kernel.org X-Gm-Message-State: AOJu0YwAvpb+c8kCKx/nWaNbnI9zMF0Q6Evhbvl3gHYc+jr8N0mW+B6D 7HdXpF8hmzijGjilRcvwBAca6vjUeb484D6DKn2OsPyIPmakeziJIM+X7gtZ04k= X-Google-Smtp-Source: AGHT+IFfCheA8r50+46P+2FOGewVJdGU/O4icZhdT047JlLHmBFzBvNTn/xJP1LESIbRZyVbf43h/Q== X-Received: by 2002:a5d:4b4b:0:b0:37d:62ed:b66b with SMTP id ffacd0b85a97d-3806120a6cemr7339765f8f.52.1730187545833; Tue, 29 Oct 2024 00:39:05 -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-38058b714fesm11692939f8f.71.2024.10.29.00.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 00:39:05 -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: Tue, 29 Oct 2024 08:38:56 +0100 Message-Id: <20241029073857.753782-6-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029073857.753782-1-ahaslam@baylibre.com> References: <20241029073857.753782-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Axel Haslam Simplify probe by using of the devm_regulator_get_enable_read_voltage. Suggested-by: David Lechner Signed-off-by: Axel Haslam Reviewed-by: David Lechner --- 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); =20 - st->reg_vdd =3D devm_regulator_get(&spi->dev, "vdd"); - if (!IS_ERR(st->reg_vdd)) { - ret =3D regulator_enable(st->reg_vdd); - if (ret) - return ret; - - ret =3D regulator_get_voltage(st->reg_vdd); - if (ret < 0) - goto error_disable_reg_pos; - - pos_voltage_uv =3D ret; - } - - st->reg_vss =3D devm_regulator_get(&spi->dev, "vss"); - if (!IS_ERR(st->reg_vss)) { - ret =3D regulator_enable(st->reg_vss); - if (ret) - goto error_disable_reg_pos; - - ret =3D regulator_get_voltage(st->reg_vss); - if (ret < 0) - goto error_disable_reg_neg; - - neg_voltage_uv =3D ret; - } - st->pwr_down =3D true; st->spi =3D spi; =20 @@ -395,7 +369,17 @@ static int ad5791_probe(struct spi_device *spi) use_rbuf_gain2 =3D device_property_read_bool(&spi->dev, "adi,rbuf-gain2-en"); =20 - if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd)) { + pos_voltage_uv =3D devm_regulator_get_enable_read_voltage(&spi->dev, "vdd= "); + if (pos_voltage_uv < 0 && pos_voltage_uv !=3D -ENODEV) + return dev_err_probe(&spi->dev, pos_voltage_uv, + "failed to get vdd voltage\n"); + + neg_voltage_uv =3D devm_regulator_get_enable_read_voltage(&spi->dev, "vss= "); + if (neg_voltage_uv < 0 && neg_voltage_uv !=3D -ENODEV) + return dev_err_probe(&spi->dev, neg_voltage_uv, + "failed to get vss voltage\n"); + + if (neg_voltage_uv >=3D 0 && pos_voltage_uv >=3D 0) { st->vref_mv =3D (pos_voltage_uv + neg_voltage_uv) / 1000; st->vref_neg_mv =3D neg_voltage_uv / 1000; } else if (pdata) { @@ -411,7 +395,7 @@ static int ad5791_probe(struct spi_device *spi) } else { ret =3D 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"); } =20 st->chip_info =3D spi_get_device_match_data(spi); @@ -425,7 +409,7 @@ static int ad5791_probe(struct spi_device *spi) ret =3D 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"); =20 spi_set_drvdata(spi, indio_dev); indio_dev->info =3D &ad5791_info; @@ -435,30 +419,16 @@ static int ad5791_probe(struct spi_device *spi) indio_dev->name =3D st->chip_info->name; ret =3D 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"); =20 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; } =20 static void ad5791_remove(struct spi_device *spi) { struct iio_dev *indio_dev =3D spi_get_drvdata(spi); - struct ad5791_state *st =3D iio_priv(indio_dev); =20 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); } =20 static const struct of_device_id ad5791_of_match[] =3D { --=20 2.34.1 From nobody Mon Nov 25 07:52:58 2024 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.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 3298A202F66 for ; Tue, 29 Oct 2024 07:39:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187551; cv=none; b=VRrrRl5s/FsNcurMtlsZ7liCsfb0gbPpG5/NvJHjsdg4vQpa9JvkbDfp97L61xDMXNe1p4SY5bXy4hpEdJOR6ym4bFIrh6kFfEhvCVntBQo4CQEiGnNDr4i3Ncdcbr2BCs4cBOF8HxrNgLiZHQUleZXd7/qDx7VqKklSy/XXQ3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187551; c=relaxed/simple; bh=0LS4Nk7GxQswpk0mdmgm07qQ4l3m0gGDqtMeepATNMo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cIuqNuiFk46quRFOtTkoAPmbppTdYflrVCTadJgG000pLkUFDfvjMJsZFFD3Px3vcbScRsTguth+5PkMfryfKQJoXSimx9rkkU/Cgy4D5ULuEI/ltHkk2EQxVT5aMMaoMtsnSQbRfdJOW4TDmUHE/z59wu8VSyb0Q4bjzFw+S8c= 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=fbcy3+bk; arc=none smtp.client-ip=209.85.167.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="fbcy3+bk" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-53a0c160b94so5672390e87.2 for ; Tue, 29 Oct 2024 00:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730187547; x=1730792347; 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=b6Vvaw4QQl678ABTGYPX4ibvi1CFPbTWqdFOgu4tkL8=; b=fbcy3+bkpLx1BiBqPj3IlB9tBQxsKlZHDtIgUqULePLjp0PLP0yHEOty2cxsQ6p1RD r03/e6oaftcjHUZTiy9nvsz18UGopD8r2A52rnbm+K6RnYUuCueJDkTWmxk0ImKnjZB9 Q1V2y1r5ChIazP98EdUlZblANaJGC+zQd+eAqcfVSHDf/PZZPFrj+siXTK3Auz0J/4Ww 8DKnH0sKnoCzseDYlV2EH5CYZfpCgSFl21mHGGU1qw0le75y7mSb6mNNw9YjLsOdfngc dJFJ3ktC69EiofRXkNDVVfe3+cqg4/JlIHD7iZMlT+hiWGjMDW41R1lvLGfPju5zAP3v NJEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730187547; x=1730792347; 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=b6Vvaw4QQl678ABTGYPX4ibvi1CFPbTWqdFOgu4tkL8=; b=JkQoK91F7Rw/3y0K1RQp3bsKLTicCIine63UkDQ0u7GjZUdRyabcTGEGo7GbuBI/k9 tAlSWNdkkB2elsdRZZxF5ksDbLHmYV4m04t9bevsutU2xsQtrSCPnFYWjluKbv+0XWy6 VqyXF8oRt34DwQ7IiVaCaFyAF876XcfWl0Bx7NSL4CbATDUp4ZRSz53rLk+TR5hvoroG zHHEnYDwgRphHXsz7N/4j8vVS6Hb6nA7sKj3el80icrpIbWVX1VdYrpmKcuEYbhz2ZLU FofLYqZxTwBT622ClR5UyQHKVERJl5lYDEsHcYgVp4yYYUk4xia+CdWCf8GISfPX3vFZ hITQ== X-Forwarded-Encrypted: i=1; AJvYcCUKkVy7q/iHbfBEbWidkASChfFVxI+omx2oPu/7r8QnnRLl0Y36Di9/+luUw+ZRJ5tf+/FnsP7CD8Vl1mE=@vger.kernel.org X-Gm-Message-State: AOJu0YxLY5eQHU7XZ+GQbyFfpZ+91XL40YoaYpogt5brNHueShl9u9+u DlDlXf0M/UaP9Ir8oCl3VigU8OCpTUwg429I0GOnCONncb+qVtPsOOQhg5JqDVQ= X-Google-Smtp-Source: AGHT+IFZE6j7vlkB96lH6neBxbdHVX2qml3l5Zo78hM65bkBjrNAS5Ve75+Y/ZU10cnIOJEUj6Twkw== X-Received: by 2002:a05:6512:3ba7:b0:536:796b:4d94 with SMTP id 2adb3069b0e04-53b3491cf63mr4722710e87.41.1730187547070; Tue, 29 Oct 2024 00:39:07 -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-38058b714fesm11692939f8f.71.2024.10.29.00.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 00:39:06 -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: Tue, 29 Oct 2024 08:38:57 +0100 Message-Id: <20241029073857.753782-7-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029073857.753782-1-ahaslam@baylibre.com> References: <20241029073857.753782-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: David Lechner --- 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"); =20 - spi_set_drvdata(spi, indio_dev); indio_dev->info =3D &ad5791_info; indio_dev->modes =3D INDIO_DIRECT_MODE; indio_dev->channels =3D &st->chip_info->channel; indio_dev->num_channels =3D 1; indio_dev->name =3D st->chip_info->name; - ret =3D 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 =3D spi_get_drvdata(spi); - - iio_device_unregister(indio_dev); + return devm_iio_device_register(&spi->dev, indio_dev); } =20 static const struct of_device_id ad5791_of_match[] =3D { @@ -457,7 +445,6 @@ static struct spi_driver ad5791_driver =3D { .of_match_table =3D ad5791_of_match, }, .probe =3D ad5791_probe, - .remove =3D ad5791_remove, .id_table =3D ad5791_id, }; module_spi_driver(ad5791_driver); --=20 2.34.1