From nobody Mon Nov 25 09:47:38 2024 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.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 08D0318FDD2 for ; Mon, 28 Oct 2024 07:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099488; cv=none; b=ZFYKAbX9xcJUk7ZppsY+Lw9B/hWLpGj1fHgg7snReQB6IE5PE7/Rg1c8A3h81XZBx7qjTJlCeZWTqMjsbVTqbCazH89ootXIpKqM1F/OfnYN1zyeN9RRmTbx0hb9HgTWy/r7oUGKm6JIwr+q5fbTRPQU2ZDPxEtPkHpjFecnI1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099488; c=relaxed/simple; bh=aHpLAYxTlMEVHnv2ecw60I7dlQNyB6DdFCFqSwpslz4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PR43vzsWJg1Hu0uWFnTtrFstKCfch0m+DsE6/Dg0fNHiVvCfUVlPaarEn7rv19RcioQkt2rESBvOaMNjr6YyqLHxUY2bj7IXqXRDW7Wisg2MrKTtnfWVDkgGCiqH+hJYITluRdJwZq1OfncxSJsW97beamhWxKkGgqYuXEyiB9k= 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.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="xs7FcSkJ" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-539f4d8ef66so5224571e87.1 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=l2En8NXGRm+NSQuovXK6cVGJQ64a/nJiacyUio5jvMTFZ+xQLi3ugm+O14AI4Ut3p9 RXbrO+xENuUgBLCtYH+ecCpNYuiweLD0PKkQgU0klQA/0TGjewdrIROJKyjU98SVeBv4 k1GrqiSnA4lS1a2niWdsWPoKCCW04eiJsiBnvL7wJyEBHArwlsZHIDGp5Ivt8FogUJrJ q6K6AnQ10ub8RSInGOzFEQIKPCLFnjzGIa7WpICX7KKN1wCbiwcWBIXdEkjx8jN56m52 tUFTTdGm0H6cM7jzpOPrYJpROYB0mu9kpJpm+f6XyawtO/mKSjyEyUeCYIBdv0ofwyb8 dJJQ== X-Forwarded-Encrypted: i=1; AJvYcCXD7RQUGyKiBDSTPwpw8AY4MCQA/I8+pRo/uOYVXLillZVwAnLECdd4Yex259xAZ0Gj/kXI55Uag75xBXE=@vger.kernel.org X-Gm-Message-State: AOJu0YxyCbGmoZ+86j9ndrgPpDqqCCKnfevF6ytKfzP5ku3e6nQrY2Mu NAVhkB8jK9L8xph58A34qYVmLZq345R84lSZ9Znpnr0O8k2jvOdVYR2DlDBXdoM= 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-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. 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/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 09:47:38 2024 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.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 4B51C190051 for ; Mon, 28 Oct 2024 07:11:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099491; cv=none; b=cWgJSnxPkUn/ZQOfoLvFm04VVYhq+Jd9Xb4lU3Zb2lRG0+3rdTgKg11cTwDN92z9jOJ+HFytW1GKKepSZGZJlOGQ2tOEMN2CmkdsSidHm39qZlEbcvc8F64oCvBvYYDIpoeoz4JAb1kh+0vFAZjMlkG70F896s1DwqZZL+kRGYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099491; c=relaxed/simple; bh=NZDbzU20l/rGAlpGDhU1gwOCh0PzSI3BBlQwr/WhlWU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=u/t4ef4Th55IO/VsfGOVsc2WwKisI95FV0wE7IZjOeIMPirHT1a0yJZuzTm9D2qYT0WE7f0Y6WPHcyi0HkTrdkWA1EbOhLsiwgCuRJqBngpOGxAJ6MBU8KbjFx8YpbEnmhbPKynzpDHxzqaTgtY72KOKVaTXjXfbrhO6YpPp5Lk= 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.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="xv7pYnR/" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-43162cf1eaaso54104245e9.0 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=BeNnFCwY7ts5V+czuXYmZYssSIqlGcfC53ntXlqF4Xtfl9r3IOt9TA09pQrT9Boyax TtZrmuduXQmVo/LL9Fzv4qvbVnvGTRH3lG5lYn+b4nX3BhciVvq4dje2YxVbvaEXayPP FDdRIqrPl5fJWSnAqXm3scS30P6Jjcud+U7WUqfvMNvN+ElvgD5bflQsoH8ghR0yWemY g0MClVmyIXxL2bfbsvSD4icjz8LfUytOHsmUx+SGFxGWjSfimpIK31u91WDLnlysGN4o 9USDm46I+46IBTmghwx6C3enPOJWm0PcyKaxiCTY9TY2SzdmLm9XE26JZxHHTFaK3Zwb nvoQ== X-Forwarded-Encrypted: i=1; AJvYcCW6CPy2zxjWpKFzit4DqNA9qrhIKpnBEpeuDxrI4kpXgN0q9nVHruZWnK/0xmp5NSHdClJ8WWkvC/IWvAc=@vger.kernel.org X-Gm-Message-State: AOJu0YzTUv9RIdpOlqxrgPSxrDVpxT73S9FGrjG1sb6fWHXyicG5ewEZ eNCLkT2MZvOrVVfUe5QGUUTmCz8QsqiPiw3lH7K2tGStkufyVU+k+0k30KIuqGLJ/MTeXyEYABT 20iI= 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-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. 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/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 09:47:38 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 A9ED919047F for ; Mon, 28 Oct 2024 07:11:28 +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=1730099491; cv=none; b=O1NWPAhNeI4M75qkKvcXwecDTby0TswkcpcSYjA4iHvpEJ5AT7r2mIuCoeZprsODXtsWeFwHL/vMWuBZP72kvnUo/EqxfkD16SX2y2+2MsUlWjWAmBnow0L3jNRKnl144Q6j3ovQS6M7tmD9c8MutNETpAPjGfhlA/iyZ3301po= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099491; c=relaxed/simple; bh=q0Rk1gyCTVaE9ieBiZ9Ha35zqb9X17plsNeIZIHefeg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S+OycLQNA66c5BUyFFMKvCqmTaEvupkqL39mx5CLx0+C4uY+jBG+9Q3aws8IbgFgxWBFvz292gJbrEIhnnAwBSGx3y3Wr0vfm+cVZWiMOyuAopGy/Yzv9WjAsXKuv/g+7Va0RuzyzEKZfx6u1USn13OnQFAG90plBynPyTkCUzg= 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.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="xNeF7o7d" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3807dd08cfcso23446f8f.1 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=G/InM4AI/fIdjmHocc0IU7PkknqlUGOp8lHzmHIVE1gUeMAi41Gw2NvbVKX2ffxP2P hk9asq7dFqSB88JSubSd63k2/iUSy/LiO9ya/tDqC+OzpGRQTbnDvkOi2lRc88FRqu50 +HyChkxY+CfK3MBcaOPHwrPnRo6mIGcAISYdBx3irBocldsTs7f7iiRnEPk85Je+Jbpb WzILF7f8EwhT2G/p3T79FYFw/cj6oxCHmYFG9QtX8Dw5fPNQJFGyfN9LuGyI98S+s5dH QHzYMm3Rxc/qlx+x4Q4A/7ZWDTe9q6Pf6Is6ZiRggYK5GjQy+JjtZgzvupHYY53/EMcR /ggw== X-Forwarded-Encrypted: i=1; AJvYcCVpqJKJWqV8ovhPJyOEIfk0YLPXzkX8hPalkLGPCmvGAUYUDWjku63BW4p817WPxtJs46fGnq3Z9vn7RVU=@vger.kernel.org X-Gm-Message-State: AOJu0YwaoQm6fb44n7PgFD4jLTY2d8e6MhI+klw0MGm+x+b3/ZCndZBf TU6O4HWNTxQY5x6c3teEN34gRJPwNsq0DiH0Cf97rm/lXM7irWKKwTdxI8MA6tg= 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-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 --- 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 @@ */ =20 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 +100,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 +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[] =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 +270,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 +385,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 +401,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 +432,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 09:47:38 2024 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 F2627191489 for ; Mon, 28 Oct 2024 07:11:29 +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=ED25o+giDwHn22ZoYMkdohkvFdhugjM8qF3TBuuRbaoxYMwA+mcVf6DhH1j6Wr99FjQLPzX2LwsZ7qf/1nl6UMFiETLDd1CllRBAqN97R4HNeC/qrY8ySbqXY3MlQKB+xb1JdVfef6fEGNVdRgOshy0/bUtEQoz3eLzN34D5zVc= 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.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="07/wjTCP" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-37d63a79bb6so2823217f8f.0 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=jGDssPa7B4Eb8AJgFqGcpNp7/rAtvS4mY9de76s5/9EUxo1swliYkZJFt8SeMBODkB 5SbL30MsVmonv4VKhDx/2+sBC6l7J/iBXChznz6S/36n1nQOjyR1BUVDS7STLptFoAj3 HkSTI4tawWjvnYmdbNak7RpLrueEWgmY/MO+jt7AU9uF/Hh0GWEx7QO4kLEqMYg/9KFS 9/stz0Xs8WkRu5J6hsgVJGu3tVhIgbYbTIshU4qNHwpD5Emeo+GFNIBQULeX+3Lx3EhX r/MpE1Gp8nYuE10QbV5IuTEJIgrr4hSorh9f+mmQRc2x1EqAGqTYZmAx9YS1wD04o0dM ap6w== X-Forwarded-Encrypted: i=1; AJvYcCWA4Y28OOWbQia85Cbz5DYCZ6nu4wU5HuQIfkTIlojnvScuHz1AflE26JzUuY4+5swAQt+UKPJuH+vCQ1Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yyh14tQLcQZthKaGZ4mifk/gXk9bob8bdUHEz58J2V76TmifSdg 0y3+r63Qjhxzcn4XknpJZMVvCn3FfvuoV3Vve2HP6tHL5klICLhK5dBZ8IC/uuU= 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-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 --- 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 =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); @@ -381,9 +401,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 09:47:38 2024 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AEB31917D0 for ; Mon, 28 Oct 2024 07:11:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730099493; cv=none; b=vBMkV8C8+Qt0Ft7lJMBWa8vPrc8YvZPP6aXGJC+IkaI/pZjkWwic3/dU3PPiFBhRuKdXzPbSAzpkuJekmyhJ2lenoAjUWc4Pc31mxLr6FYXaBzq2rToL5eIPzLv3ifLY5uhoC/k1K5kYgJR5LMHSYrl6D1L4RVK7X4YWWtliPss= 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.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="PLDJ8yab" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-37d49ffaba6so2797050f8f.0 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=Rz+fuNWxGFnrwcFGxCW2j7aT4NPaw3Z7kuYl67KB+C8j6IBm6mIc/w9K2GlvQrIEZM Znmq6JByfH5yx08DjrKjia2tzizjgFqNj9cqdiJUIZ4OdMhVtgQOKFHa+w1ghXjEqNDI v6j0g3QsYFPhp+JSYvWUwJ+69FtT6h49Kj2ioALI4WqXRGKoky4ylFMaG7jr9ieCDlVw +jcqNBTL/nVBCy73tPd9oo6LRQA0HxMNWdrEjO6gEUkBDybTddwpNnHkpddBGrf0afkS v/dhQnKIGQ/27RRmtJBir+fRBzsUDD0Zqbb+9R13Fo4DvRkX9RhUvOVCvJmd2h3RTgQB wMjA== X-Forwarded-Encrypted: i=1; AJvYcCWfC/Fco94bRhaBsIn0GCtL5IGv6TYJ9oAGYt9YZhU8njG7gDIuWkItbkBIzFrOCX1a+loReAvK+K4PPbI=@vger.kernel.org X-Gm-Message-State: AOJu0YxH2iTs0kQU3eJypciNQvtsvv1ZgaJM/hYgmahinISs9X2clI9e eB94i+BoKiJ4t12XKYZDxChmNpIE9666BFcgy7qjRPNzA+//3hdDroQNqz5rD2g= 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-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 --- 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); =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 @@ -391,7 +365,15 @@ 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, ret, "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, ret, "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) { @@ -407,7 +389,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); @@ -421,7 +403,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; @@ -431,30 +413,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 09:47:38 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 706BC18FDDF for ; Mon, 28 Oct 2024 07:11:32 +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=1730099494; cv=none; b=lgRUv2uZMLHBDVxdigf62NfrmZE7ZFSelF8hIPh2sQeggfDdePbNIHk14HOXfdWSUV2xEMmuBqL9YEz/3ohrjUeh5qggEM49VDhaoVF/R0jr5IyUdrVXscSA+2kVLF72ZyFRrq/9caAaUyIUF2zd02D6Ef+UWemGEActsZtiP84= 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.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="jMIhhggk" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-37d4ba20075so2755788f8f.0 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=Hk6N80gh9cFCTgQAapKILcGjekeaXuG7a0gLDBr+yzNPuVIPkK/fT1NiryKM8SIjKH ivhZtl+wwiKHgj+hGUPA7jOxC/nXrP3M+nAHqd+x6LRs/pJOc4gc4tQmTsneZk+Ro7wn Jz6ibqmgcM98pJhvqOIXWzg38u7cD1td3xLBMuMkFFADyJqRkiIid05nWzNfHFlf5cZV 8yz1HgiGRj5vhI2Gj6y7CgLMlCTMq/7LaoMjDWceQPCWxUBQprBohHaf7zHQo4S6hue7 92Be1C3izCqsKQc1HgSVrD3liFMbqk1rZiDHZLSqShD8hXrqnCcA1pv/TyFQBbXTdE9Z vK8g== X-Forwarded-Encrypted: i=1; AJvYcCXtq7ywIBoytuliWKzb1V+t5l/XqpaAGfD1PPi+wtuyW1yKakM5JMQjg+//NxJgslR9gKOKlXqgqtvbP/8=@vger.kernel.org X-Gm-Message-State: AOJu0YyROdmfDKPUWFWCRFkDxMiXGpmLk5oT3silllHEx+ZCtscf927l CkkPeVaOlYM7GFaqgYzgGhSjR+Z2hMsis7acnGtiZUcCZ9JySy0XEgBhYuXRM/k= 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-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 --- 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"); =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 { @@ -451,7 +439,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