From nobody Mon Dec 2 14:52:58 2024 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 978281487C1 for ; Thu, 31 Oct 2024 07:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359076; cv=none; b=rZeb1kQKMJA1ZABYIEnNqCNuvGFtQmgNPAnTIe/HPWeZm2ejVOoexLL8wONw49Ix/gtsSoi3sDOQlflR7yE9aSjvCRc1VwtZuLzrNQfkQj+RmVQiWTOHH92JVfRei1pH41zoAOKdUeiOUOXU4nphYai1Mk6bUp/D8vDd0pp0UkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359076; c=relaxed/simple; bh=xu4vcOByqa0T+o0Mtg/VMSPa5suwUETcqrDuyfDGNgQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WDHMEp1I007Lv0wGMcqxfTNNaMoB9cs0/elMVAQ8YcNB/Ea7VsQF5b7+NIHWfModrnZRl/eZEMk8o5a9+IHTCXdnpuArGoMS9ZFX4zN4l7aueOZ2sde5B1fLWtmOtoYGyyrflJJhCLSnd+dVbA2PMdYun/8ucvnLdq+JCKHkdRI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=LlMyQyNf; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="LlMyQyNf" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-37d6a2aa748so343581f8f.1 for ; Thu, 31 Oct 2024 00:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359071; x=1730963871; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m6z7u9n04i1CD+dVrnwMZN3subLaG04bfZd3Fni/4JM=; b=LlMyQyNfYnMucYPqFikZvNwyXYu4Yd4ozfSFZTRxmq3hBmBHZgDZpzf1Pevq7xwQb0 2sl6nlXojLiVtjy4LhsNSxTYYKrK5Yhhlmt/1PZ5hXY4WZ70wABFA15EHH6jp/ObSSo+ 01foXQyha3AV4txE76kCG1zE2CagYyhHOT+y42WeOk4sTHNRWKT9R2foD4PTjS8D879J Xd9oJHKyFh9JOv9+dIq4ek9bIdD+jGmPrSHtl9PbQOcnBRkgTqCDAnQL/c09ZTZz1v6c kqxpZ+poh6Kktjhl5wAJV4FUzwTQMuoFys996EaRZdnkMen/7NNn7PM9jgC88GlQCD49 iZgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359071; x=1730963871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m6z7u9n04i1CD+dVrnwMZN3subLaG04bfZd3Fni/4JM=; b=A0nA8bilh/FJf2ePYJYcWmw0a15rteCQsRT3S7Qhhid4ambJhO1Z2dIKMhfczdafcL XZ7u3MfwBwyOiVdTAb/I+lm5rUhX8wYlNvLBjnkGW0nlUPnSw8OZIcZqYyR16XgUhb+o 6Ka6RuKw52xMemUlqMPFvC2KJcYc+GrQ78BrkaqP0HV+JW97PDPaxQyX4ZDpXJBa/Gvb XKr/jy8BVa+hwSkTvA+RYIHlCIQFIobBWVS235T3wRhCBJAi5HedUbu6KIQgBHZwyMyx PeOhk62TRk6rzKS4YPZWTwv4ZjHYP5vwLZWdKblMIsOOtI4H37F1GO/aFjqZIq0aP+QS Gm0g== X-Forwarded-Encrypted: i=1; AJvYcCW45SJq8rhh9vyfPoatio9+W8qwuQeVnn8DB3RVU0rTlyMv5oh2Ip6NY6dNQLqpibFMDzf0ZDBm+EeDS3Q=@vger.kernel.org X-Gm-Message-State: AOJu0YwoVau7ttW5gBY3tAP/XmEnsj0Q8tm6nBRtLrcWX939MTUrJ3PC NR4ewhqu5xaYtMYIV9Tj4dPaPpb5Kqa4af0VRkg081zRx4MKSmsCbrRtQtTgucA= X-Google-Smtp-Source: AGHT+IHqsSrRK3WaqLyPzOG0cz8hA2PrJwrsarp3k2DUiOAi+1UO9m3fvc3ksKyJ1vyEA2H50edTtA== X-Received: by 2002:adf:e543:0:b0:37d:54d0:1f20 with SMTP id ffacd0b85a97d-38061158e30mr12973741f8f.24.1730359070881; Thu, 31 Oct 2024 00:17:50 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:50 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam , Krzysztof Kozlowski Subject: [PATCH v3 1/6] dt-bindings: iio: dac: ad5791: Add optional reset, clr and ldac gpios Date: Thu, 31 Oct 2024 08:17:41 +0100 Message-Id: <20241031071746.848694-2-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-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: David Lechner Reviewed-by: Krzysztof Kozlowski Signed-off-by: Axel Haslam --- .../devicetree/bindings/iio/dac/adi,ad5791.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml b/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 Dec 2 14: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 D892014884D for ; Thu, 31 Oct 2024 07:17:53 +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=1730359076; cv=none; b=OqoCsTmP0TJQh4T20/txOfMwcFwa09R1J75qy8W/2cxN12yRiY7AgHzRxDq96eRYdmA4yJ1VcsaZjS+uvnxTQhYTbqETq7e1OEiwheF/AmxgHMSEH2ixHvTtzn3OIGJUSLjzeFw90bnnaPmdnefANu/tMc79TWJakoVhOmA3Tmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359076; c=relaxed/simple; bh=np8Q2QVfQltUi41eXVufgARgz5a+zr3MKMZbbDyqKkI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VwUZ+8BFJ4c9Busa+yAqTxl6yPaLUcR2zXb+RRK5WAZJ+93U/MuiFMEGtcQ3FypgrKE8CEvUrbZwkMLr6KIk8ZWS+zWdM2pfiztoW39VEQqLK8X+2aOQyhtbyCz3L/RnHb6BZ/wOwDt+Ej38QQPkDBG/P3w5TNuWmZ/GtI06lHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=SxSUVrM4; arc=none smtp.client-ip=209.85.221.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="SxSUVrM4" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-37d3ecad390so1059332f8f.1 for ; Thu, 31 Oct 2024 00:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359072; x=1730963872; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6XokXFUnFUJYwTRpNxF4QEO2NzHATnQ3nu28Wn+V/kw=; b=SxSUVrM4fAUILA9cth/SWarYnL4MtdrKyRVQa96SpQnIowveED4X91Mi7WflpU6XeX gW3vX0vuI/E6I8NpGouWb6BKtDfiU+Rg81aA00NzjSNvY/X7LBouUaKUFQyt9ndYKRpB QZzoNleGguRy3J3jEfNRZgmSb6KlQ19zbS2k3u2oJuDok6viEE3uzg94mmN8F/7WubbV /JNkXlIOyyhtbs0P6tk901dP/jGKTaBIaTAU2cNnGI0MCIIR7MvKAz9ZcHiGPu7AaYpQ BOUpQbQcyEkCUXswpWptL1AP9+V2giIPdBLHwTBj8RzjwiLty8uJF8EQ/FYcz5avDQiS Rszg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359072; x=1730963872; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6XokXFUnFUJYwTRpNxF4QEO2NzHATnQ3nu28Wn+V/kw=; b=A2nS6vVj9oCNkX9jCjxZCRWDuuKf+OIMz+xUxLXVGYFzI+w7gNfACk9t6UeeSWMmRf +dBxUfQDzt268w9TAHOnCnVokjUci1CJF4daAdLlVB5DT0vsPRcLThSyEkm+56ubQ5Uy /hHVhNkECBwL95nCk1taT4HG8ligS1UA11d0m9yPGJgqNK9VBLOG+5NFZ2bH2ohKo76X kaZqOV3B90lJVNAmYmib1H+NjFwnFk1bxarGqkANpUsrPg9qiInypEtAquvtWQQ0yI0f TzntfFBvtXvC35F/xVlMXns9FLSe5Hv+nWi4icoUAlnNEw6bG5lt92BfjDzBBvR/5iK9 1Txw== X-Forwarded-Encrypted: i=1; AJvYcCW1qKw6wUXJJun31VOr+5Fiy9HeGEUIGM/AebgguDNxj1vXkqFklxHpUDUxAyr+LmYwO/4UHSImHdu363o=@vger.kernel.org X-Gm-Message-State: AOJu0YyIq1Lr09TGD2CPpbMIZGcBBfgnfTqNUTGMnE3sj0AVokJb/iuP SbAweTLM6JpEkcsj5vts4X7Y7SxngWOUlfRUnLxyh+1rJ2opVLzOnGkLtYIKY34= X-Google-Smtp-Source: AGHT+IHwQ7oBgfvFPEWdP5rY03R7404nWDkpFlRIwBt15xycWEIbwG4Y8/p8O6RKEwgky5rkwhtGjg== X-Received: by 2002:a05:6000:1869:b0:374:c6b6:c656 with SMTP id ffacd0b85a97d-381c14c3469mr1015819f8f.21.1730359072176; Thu, 31 Oct 2024 00:17:52 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:51 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam , Krzysztof Kozlowski Subject: [PATCH v3 2/6] dt-bindings: iio: dac: ad5791: Add required voltage supplies Date: Thu, 31 Oct 2024 08:17:42 +0100 Message-Id: <20241031071746.848694-3-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-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: David Lechner Reviewed-by: Krzysztof Kozlowski Signed-off-by: Axel Haslam --- .../bindings/iio/dac/adi,ad5791.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml b/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 Dec 2 14: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 563BD149C54 for ; Thu, 31 Oct 2024 07:17:55 +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=1730359077; cv=none; b=bopD2d3CE+0o4Q/uqwfj+lyCZOVqC9CZYOqImHw3Qt6FeAxBgSAMx9/gjlXnhU7BzfIZGKaDnSGEegJPiWCm91zLOKHX3sBYYmj4fx0nQAPIn44jx2/gIuewyMdk3GEHAQ93D+ug0IkREVpgUa62T9I8tXBuoQKRsu714wGGqh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359077; c=relaxed/simple; bh=j6d0colaxPKycD+GQrCgSDLkv20Xcns4fpDxmhAFBNg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kgkQ+zTtSPvW2ekb1MIfd23k2afSugMSJqo8/JfmgLbtqHbRl5Kn8Q9p1UzaYK1eYWYUNsgi1n+7Ec8mgrmVem+PV+Ch0fwF8jW11kjTD2kxFW8Tm6MpLpEwk4SPF5P/q5UhqXQObCKgim+W4aqc0hp3Zl9eD1dtMMMoKgJX7+c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=rvsYjor/; arc=none smtp.client-ip=209.85.221.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="rvsYjor/" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-37d47eff9acso394707f8f.3 for ; Thu, 31 Oct 2024 00:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359074; x=1730963874; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NH5MUt/+cbzy9bnDTQWkFoXyedi+6bP21xIeET9Apek=; b=rvsYjor/Om2bO7suxr9Cx5PntCLvajHVWLdchLch+UKKc/OfeQoo+YdFT7VahF9zsl 6Ep6iVOq5YWaUeivyj5fUBbalRZaEUaZmp85LDUAQeLb9uKPTzcCGrME1nriG8zo6kha Gd1AT/kpM2Amp0UxOW3TTfibjh44TgyhGADPKccI8hqyiMYBagfMKwYMnzcrHl8YYT0g P9Odlyp9dWyd5caifoGewGuzQzBzJ7d2EeTU2kL8n/ECytlbJiHoumbl+DmlqEpeL32E CrjLJnmCz+afRr6m7umGB9wHhdB6VrFKQEi1Nwp4uVNQ2CITcG+ZZ5/JxrCmW8649+kD TDHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359074; x=1730963874; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NH5MUt/+cbzy9bnDTQWkFoXyedi+6bP21xIeET9Apek=; b=X2snHfBSw11ME3nCAly5WaMew1s/ybREQOsSGuAG+ezd8G/IskLdmRtAF/vOIadGQ3 35gVLZhdkPpmeODYwJUo9iFr8JpgXnPc8PNHwbh8hSpn5iSHIMYgIDFDjs+XmzR3leFW 1jIcn68hzwBmoETCJmL6mk7hhOfceDWQa92whOZiQ6Ldo/PONOnml2TA1AXpcesQGDRz yPen1kvQG8pk0/nW8a6ChjYZjRKIxzjbwMw97R8KoTX3EeYvNWcTNPKVs2x48eW0HeKW fweTp65K46WpGSw4dLg704m14OYfuGWXdhJUpgRqTck/H9QEuXkTuFuQ4ZzRHb6bW79H RyTA== X-Forwarded-Encrypted: i=1; AJvYcCW6mtS2K23Cx1BLmk6kUeW4Pg1K/IaJ92lfNqYeuFVYppK8+vKZojFXLz9IAu93+aHa/ySrimCw/OBT2w4=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7+QP1A8AJR9fVMwN0I55hDvzrhVewOqA1QvVMXPk4/+M3CK2U O6KLdS/LUHHPKDSSx0puOiKBiiqaimbc01iQQOObIJ9Mf/IngPSdd8rLbNPfZP4= X-Google-Smtp-Source: AGHT+IFqvelwoSi19crIY7cSvQsHBQH6NsXHxPWvECq3yNRMlEGXT2iQ4rFHd5MRgRYaRlPogLspsg== X-Received: by 2002:a5d:4285:0:b0:374:af19:7992 with SMTP id ffacd0b85a97d-380610f8e2fmr12888771f8f.7.1730359073687; Thu, 31 Oct 2024 00:17:53 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:53 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam Subject: [PATCH v3 3/6] iio: dac: ad5791: Include chip_info in device match tables Date: Thu, 31 Oct 2024 08:17:43 +0100 Message-Id: <20241031071746.848694-4-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-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 Reviewed-by: David Lechner Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 110 +++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 57 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 553431bf0232..f6b9a40241f3 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -61,11 +61,14 @@ =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 Dec 2 14:52:58 2024 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3E02149005 for ; Thu, 31 Oct 2024 07:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359079; cv=none; b=Qp9gx15z6xnZ3bcrRZgJ+HOA8m5m5pxl+ZsHyjfH6PAUOuRuytIXss4yeGp2qy3YOw5YgeoDNxnioGbMl6UYePFiLyVhfGrguR2LehHSYaSGvdkzYkZill8HfuoRBKQqkzvKL9mwTMUaKtsXkB905XKLW3PsPbwUikkEsW2OKfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359079; c=relaxed/simple; bh=Op2p8Q2E5igZsGlkYWqymbzX2Ifj7PSmb49r/ALp7lU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gJ388S4uOpk96kDDNIbTc3Ui90/UwM0TXusfOiIk+XGOOMuisgJPYqEaK6fQo5NThE+ysuqbBq+BpkGGdQ2aIQoyk+QJES+EF6kW6Wimrq/q0hrYcDycxawTm0e+jm0FZQScg23Wwuh9Suiyao3G1n6GDFGGzgJ64xSxmdtBr+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=cMW1ujZN; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="cMW1ujZN" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-37ec4e349f4so393624f8f.0 for ; Thu, 31 Oct 2024 00:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359075; x=1730963875; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I1pq/Bgv4QeCrwiPVa9U9DPj0A/SeEyPL96AcSHmLho=; b=cMW1ujZNbrhUsB95uM8iS5Y66yMmzaqHwBPFll+On9vBj8euqJESQl596o9IleEmWd ePwZ+Qrrk9gMDKteXQ3ULgYEU7hB7urb1vmNX5XBb2N5TbWea9ZP6N+uipU8fuYVRcWq f3N+3xdXiiVYWgjbb7OpCv+sHvWKMrm7iN0v9+4eSuMsgdXT1ODczUlmmimjiz5bU7l+ CQKKrSxoPqEfcDNTGwJF7EAWhP/H2K2B3nm7xBc766OumapcsWVNKOkgv0INh2YaPg32 2pld/G1OgP9ozhnNCpimS5bZtUb0xvHGfcLVrRepiCKzJKgy8blka6baWqheMK5/MTIs t0eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359075; x=1730963875; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I1pq/Bgv4QeCrwiPVa9U9DPj0A/SeEyPL96AcSHmLho=; b=kGSAoaAmae92DzTgVpVqA3mwPuBY7+Fv/KotbiEJ65KWyxEFkCuBNHTHfZJyCGLmUm 67dYBoVt/lmAKG4QFBB5FK/WN5EhHHL8CD7JA+kJ+XBn1+fEmn5pH8YUuSpMulTm2gOF bv03LGB7J3VAAOt3bDeLh+bIokkq9vmm4KF8M/5+Xq8fPAtRgER2NhUtbe6/Yz8v37km 96dSEWWf4SUQ7hgJGs5I818BbDII2bPg6kx0jUutmAEriSS7bNDlrFis20ZW4pBnTQe7 Fcld810tAJ8rG8mysztIzmVsjFdRXKh8+c22tB7w7UDph1ipI2vO9avZ0RSGFWY1ydcJ MtlQ== X-Forwarded-Encrypted: i=1; AJvYcCVBAcuU5LoCueY5MnGe8ggFOeNuDjXHpBHidt7kh2PLN82AVBtal9OPiNMbAxI+CoabMaptW3LEx8uv1M4=@vger.kernel.org X-Gm-Message-State: AOJu0YxFUURGrxlVYU2CwuHNEhTRKYgPYdOdWA7zGv7pTU6uUpEiGE7I WCd4QSEuUhyLOOG2+u/y/zhpv9q3bbx81O4BHBWnbM/zSZpyyHRlypc7L+v98TE= X-Google-Smtp-Source: AGHT+IGW7kCzNAoBXXZ34GznNmWRMdGAze3cMSGQu0oer+FnmY9AH27Byjv+q+Uux4qqJf3Mcgy/wA== X-Received: by 2002:a5d:6a4e:0:b0:37d:4e74:689 with SMTP id ffacd0b85a97d-380611ed135mr13359122f8f.47.1730359075031; Thu, 31 Oct 2024 00:17:55 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:54 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam Subject: [PATCH v3 4/6] iio: dac: ad5791: Add reset, clr and ldac gpios Date: Thu, 31 Oct 2024 08:17:44 +0100 Message-Id: <20241031071746.848694-5-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-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. Reviewed-by: David Lechner Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index f6b9a40241f3..c5d4d755d57a 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +77,9 @@ struct ad5791_chip_info { * @spi: spi_device * @reg_vdd: positive supply regulator * @reg_vss: negative supply regulator + * @gpio_reset: reset gpio + * @gpio_clear: clear gpio + * @gpio_ldac: load dac gpio * @chip_info: chip model specific constants * @vref_mv: actual reference voltage used * @vref_neg_mv: voltage of the negative supply @@ -88,6 +92,9 @@ struct ad5791_state { struct spi_device *spi; struct regulator *reg_vdd; struct regulator *reg_vss; + struct gpio_desc *gpio_reset; + struct gpio_desc *gpio_clear; + struct gpio_desc *gpio_ldac; const struct ad5791_chip_info *chip_info; unsigned short vref_mv; unsigned int vref_neg_mv; @@ -337,6 +344,22 @@ static int ad5791_probe(struct spi_device *spi) if (!indio_dev) return -ENOMEM; st =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 Dec 2 14:52:58 2024 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F206150981 for ; Thu, 31 Oct 2024 07:17:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359081; cv=none; b=Fq5xkP80JlprZfSKffTLldG85ZuEOZsCVEraZVrj8nQjLeADpq8PW0pfbJn43zM3uaB9oS9S2OCXznI7TxlZ0AUQx8PyHJNefvitvwtdt84dtifvh4Puq9j7kLUB0qprhXgY8Tk4QJtx3KL1hVHWiR1ryPm88CPFyZ//9Q9D/No= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359081; c=relaxed/simple; bh=hRRz6Z3zhjYmY795aPCQsEcsvIGIKzWS3nJb+c+XP1I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lxCrs7TsRmFR7Wb2QBhbp44IRdXfCHqf3AqEituGPz9G3XvjEOEXfHPlUYf+RrjN5GIamYLR7uBQ895DiywV7ulmY3hFOFkdqqmi+X188Mm4wiFBviRxYP/kLDDv40q9qBuoxq4ckqGwUqfBSuiNu7mq2yN10KJb+VccgLBW5UE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=X9h3U7uu; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="X9h3U7uu" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-43155abaf0bso5081235e9.0 for ; Thu, 31 Oct 2024 00:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359076; x=1730963876; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BeRlMEUtBMXjfsJVHTeMu8lQ8IK1457+K1awnOuwaZk=; b=X9h3U7uu0eCiI6Ccz3GK3TAbR2t5XRQCjn4GLKQkgP+IVY5+eLrbgCKzEaZX7tncxb lTWcL1iU1LwTxsmolYHjvfTWPVmrmXPlsrB70lNcaBoMU/8Zl8HDW5YFEg5t4f1zO7+u GZ4ZbfYU04vyEaMKn12pkm3nM1l4gRGJO450xptGZ1n7d9rcFfBRpBSHRfHCxzZUtKz1 E11mqt2Nvcd8KDMInp0hqOMCdtv6oTXwQjXk/BUNermy57l0a8Cx8xm7PlRHWwV8Ww6+ rmwfWjLDXcC0hYEtwWZaarpXwMARe8UlDsD8OdbBDfx3yEKqptod1V4fE+UzB2bKDUgg nOBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359076; x=1730963876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BeRlMEUtBMXjfsJVHTeMu8lQ8IK1457+K1awnOuwaZk=; b=v4uxSwkw9u949Vpl0q6x7SrynN4BUZireoCHd/xH57G6W0QYIGRVnxRz8TAjp/8y0b Uq1Kg5yD9D9o5ed0dbuLIquxbU0Ff9xyyIocqbHTjSev78ppp+l5z+mAhICiHetu2v37 pEuLzESePNHeEDTleev6qA7k+SXnx+gmPWwGXNz+x2Bpqw+h8JO9CKSHP6pg45zxz7J7 ULWqYDQ860qz10QxyZKj4g7+PPy66D6CW5aVXfO7PF82v6GUSn7cmIdrzQYm3bJTPTSG SHxFvGgckAzPyxJ05uBQqqH9Ri10gXop6AggTeFD5yJsG7qNrDPUDtyEkI+fw4Mwemro X2sw== X-Forwarded-Encrypted: i=1; AJvYcCUPF7DYQe5iuIhJBpeYmqAtAje+1uAiJPHlIA0A7Fwgr5J5taNylTm6mf2OeVWNuIH1emNUJPm3DNFcOu0=@vger.kernel.org X-Gm-Message-State: AOJu0YzxHn8HaY6o7wHLvD4vpQO3tkt07X/sL2OWCnGu8yokZxOxxPkV cIg+DQe9a3jM3B6sHcBY8zC9PiBThaEEkS1+gtU3EgrwtQ3KC8cQ4RaPVZuHSgg= X-Google-Smtp-Source: AGHT+IFXvK55d0CGj9OJo4gCkJhWNNTnKajsdZ89N392DRFUQyDEd53HDsOaPmhrhw5rLrryeaaweQ== X-Received: by 2002:a05:600c:3556:b0:431:5f1b:a7c4 with SMTP id 5b1f17b1804b1-4319ad29d0bmr169902125e9.34.1730359076424; Thu, 31 Oct 2024 00:17:56 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:55 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam Subject: [PATCH v3 5/6] iio: dac: ad5791: Use devm_regulator_get_enable_read_voltage Date: Thu, 31 Oct 2024 08:17:45 +0100 Message-Id: <20241031071746.848694-6-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-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 Reviewed-by: David Lechner Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 58 ++++++++++------------------------------ 1 file changed, 14 insertions(+), 44 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index c5d4d755d57a..92d47e766fd3 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -360,32 +360,6 @@ static int ad5791_probe(struct spi_device *spi) if (IS_ERR(st->gpio_ldac)) return PTR_ERR(st->gpio_ldac); =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 Dec 2 14:52:58 2024 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.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 5A51114AD0D for ; Thu, 31 Oct 2024 07:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359081; cv=none; b=smj4LHWxqPZfbOGBxeunnTUNLz1k10XQP8lsu0+ux2YLnqAKVd+BgOLPxR3R3Spz1M4YlZgkRRMjq+pNPuBr6zGZdYGYLcXEg2nP9oEZBIxDycsHGPrU4k/c1kYJeJM48DBFlim1Rok3RLDYPb82dIOuwlyq1+I6SvNFfdVhC0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730359081; c=relaxed/simple; bh=Wpo8Oj/klmyH5vH0z1jaegb5OcJIFZ72Wg0pt5glQAc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HU3PC8AccPW4vcr5n/IUcejeR1TfTlO7vXIOH6JmbWfEMONOoAcBpypgHXJdj6c9VaMPyTAfHBxlO1+R/z7m2toFapl+Jwcw3HbeiWf0+YRFV1gw7IDvS+oxp1JP4xOyr1q/9/2TyLjoaAB67rTTUxoEEVScCj89c01UwBaCbAk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=SLmNCP0p; arc=none smtp.client-ip=209.85.128.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="SLmNCP0p" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4316f3d3c21so4738125e9.3 for ; Thu, 31 Oct 2024 00:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1730359078; x=1730963878; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ta8KKdF2jcNVKVs5pCv9tj8EzXOBx+/a1iWRb1D6Seo=; b=SLmNCP0pbhwRhyQijQmytLoOPxPwgYWw6lRGZ841HjhOHC030QRUGftl9jVcK/77/r n3D4Uy2s0V3LNcm3w9JKgNL31pOmIHGm7N9D7RKKxXLaamunoXVGzkftDvkNhydly/vT 6CCF8hfbDTT4y61/U5UORJKqiNQqdehlXxuv1mAYgmewffpUMZH9sPMjHgAI6XXlRbu8 ubQpFiVpG+6+wTcDVapuEqFExWBlXX7xMT0eJpj+rl2K22/8pcw7ITIBfxvqJq6Ui+Kg XeDZ6Z6wH34oDsX6j/lpc9hHIbJo+1vgzGsN4bPAuILjwwjcV1ULO5qz8ODlGL6rRxwq FjVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730359078; x=1730963878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ta8KKdF2jcNVKVs5pCv9tj8EzXOBx+/a1iWRb1D6Seo=; b=MR/Ok/IHY2Ydu6hORrxcjNV4c2OqIzOTTNyjZSqavloKNgcLlwo5CcJymEmWpa7Nxp pLRUrzN3Xsvjm53ZII5fnILIoe0sOKF9oPwfvyoHIZcL3SzPRPtWJUqQj63xAqkhU1b3 uuEcWjOCJM6dGNqnd2CjOARYv6ETYhQRGL9t6W61RjSx0asRABfgnGdKr2yF0zaYx+WN WQRqIBZlzdlKB4yd5WtdrT0Y3A1dY1f3dRDMKXJzVVqj6muyk3mmPB997/W5OgwJiQ1P qHQaZ3hH/5M+l9MnTJzUxGuVNnA4goO8vt/43vvgInhMS0ZYQpH7KagVSUGEGCuYZ8Jp L0+w== X-Forwarded-Encrypted: i=1; AJvYcCWyh3pKB2txPqv1ygBy6Krt34/RIkp0wSH9mk4WIm2sFaUVrt+vKM4QmPB5sXrCJ5GsA8GVStl3C9YkH7E=@vger.kernel.org X-Gm-Message-State: AOJu0YzmMZUHY1L/Qj5Ml69KnxFo7faE+uURSlYcZqvCAjuwxuUQ5eWc FdxVmferUs0rsfcLCvIs2zqEEu7ruYMzD6eCd+DA2+Q0jcruOJTyXdkU6F3lyAs= X-Google-Smtp-Source: AGHT+IFApzsnUKOt+RjkBsEFLWnDMKMhhkMDsz9e5PgIwP+GShRdVqxyiVYzdBFrvcfuDkSiF/a0ww== X-Received: by 2002:a05:600c:4ecd:b0:431:6060:8b22 with SMTP id 5b1f17b1804b1-431bb9855a2mr50657975e9.10.1730359077813; Thu, 31 Oct 2024 00:17:57 -0700 (PDT) Received: from axelh-ThinkPad-T450s.home (lfbn-nic-1-251-169.w2-15.abo.wanadoo.fr. [2.15.94.169]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e694sm1187547f8f.86.2024.10.31.00.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 00:17:56 -0700 (PDT) From: ahaslam@baylibre.com To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Axel Haslam Subject: [PATCH v3 6/6] iio: dac: ad5791: Use devm_iio_device_register Date: Thu, 31 Oct 2024 08:17:46 +0100 Message-Id: <20241031071746.848694-7-ahaslam@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031071746.848694-1-ahaslam@baylibre.com> References: <20241031071746.848694-1-ahaslam@baylibre.com> Precedence: bulk X-Mailing-List: linux-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 Reviewed-by: David Lechner Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 92d47e766fd3..57374f78f6b8 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -411,24 +411,12 @@ static int ad5791_probe(struct spi_device *spi) if (ret) return dev_err_probe(&spi->dev, ret, "fail to write ctrl register\n"); =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