From patchwork Tue Oct 29 07:38:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13854416 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 9F33520265E for ; Tue, 29 Oct 2024 07:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187544; cv=none; b=VsI7a5B6tejaJHt89bgam4HxhczCNfKiRtZKKjGrPnv4hZkB4FGWc5vb/UrC1ogFNxUejOvHL3nVCQnVGE4jNuGi+C/AT/ppgojrMCqVmxPM6GMkLBpiiJ12Ek7nJey5Ba1JM7B9E4gsL4zIQG5SYVNgcaXpv8m4Wmwpos80wzs= 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.46 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-f46.google.com with SMTP id ffacd0b85a97d-37d49ffaba6so3606620f8f.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=sQK9T4fhJZqNen2RVKU1emLugGV0pPyQAFiA9JxVqMIgNIDyIEnIDGFpV77H5QHYaf kg3DXIz8OiyddpzQPwNMDsLLVwCD1RXxAKVuD+MeY1cavY4bJVQM7S6LYV3iiWdMYSy5 jj+Fv1H2XhYjYttspCOlHA36JN3e0bVH3PRfUoDlaY/9VYCpaST6IheAmuJ+oSIx3GYo lKdcO+RAShqNEcRQFshkvCBTuGKqpgHBxgXGaS55mCXJzbq/Loyu1regWgAck8gy6cnj eQ61okvubU+AEZv6BupYoJbvoEp5DCaPSFwYHIFi4ZR1uCHrovW2KJ9tm1nNCxZv3VsF s27Q== X-Gm-Message-State: AOJu0YyglsAlN54rfkAaYPPlGLBTx349HWrRoIir67xtgyW3Vqj5i0+7 2fQcBRt3VfLK0zw1uL6jZTZR5PQN5F+7HmWNcEXhgP3LUpQzkm+Ep3rEhTFCYfw= 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-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam Depending on board layout, the ad57xx may need control of reset, clear, and ldac pins by the host driver. Add optional bindings for these gpios. 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/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml index c81285d84db7..fe664378c966 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml @@ -31,6 +31,17 @@ properties: gain of two configuration. type: boolean + reset-gpios: + maxItems: 1 + + clear-gpios: + maxItems: 1 + + ldac-gpios: + description: + LDAC pin to be used as a hardware trigger to update the DAC channels. + maxItems: 1 + required: - compatible - reg @@ -44,6 +55,7 @@ unevaluatedProperties: false examples: - | + #include spi { #address-cells = <1>; #size-cells = <0>; @@ -53,6 +65,9 @@ examples: reg = <0>; vss-supply = <&dac_vss>; vdd-supply = <&dac_vdd>; + reset-gpios = <&gpio_bd 16 GPIO_ACTIVE_LOW>; + clear-gpios = <&gpio_bd 17 GPIO_ACTIVE_LOW>; + ldac-gpios = <&gpio_bd 18 GPIO_ACTIVE_HIGH>; }; }; ... From patchwork Tue Oct 29 07:38:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13854417 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 D52CB201111 for ; Tue, 29 Oct 2024 07:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187546; cv=none; b=dhFxan+4Y8l1haHASSAIKBOmZ2s9JC26J8Kr+gb3JkZ9E5pE3Rr/kvOfmmQr1o6Z9SxfOALRuv7xi/FOWKFgQARKkSQGFSJkordeYiQmM3eguqC+jBT9xyk4rty8ZH25IFJaJ1cKqVVYyZuUKXoL9X9YAew2lAQKoCQ7/FtDIm0= 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.42 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-f42.google.com with SMTP id ffacd0b85a97d-37d8901cb98so4165103f8f.0 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=WzmT4sSp+leGdQIfHvoTS/Z/3wzVEHKa8llAO1wLZhCVVxGh2vrxhC7P1csC+4l/o8 shBs+vv6yHBjPX7nupOwA+JzVQHwum0okSk9Nh4kjI3j5MRRKBaRuCP62eq4NRff3+vY hnOhr1ifPTcXf9F4abMjZgbS5XwXMLJ09ZtyXKlh9idaQSdOGf1mJLmgBmNaKVlQDG2t hkU4t+O2zvGqW+G+/ayjDfE4cSs2kKr6MkgC70i1HbUmZuW/49MWHsJvROl8oGq1xICL lZAoKFB5viqqfJHm6wfDDEPTYN2Dm8XHQdVt3oXdhW3SinJ/gKBsnhQob8DzzuFmbIR4 4AFw== X-Gm-Message-State: AOJu0YzDSxbGzLolnegxx/2CRxreQQW43IXFLYoYbSx5cFrrvkXoS1zK EIO+ZidHw75C6AOGyhHSGZMAGA2BruKQDrFC4sIU7QtpTLeqOm/P6RCidftCgbQ= 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-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam Vcc, iovcc, vrefp, and vrefn are needed for the DAC to work. Add them as required bindings for ad5791. 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/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml index fe664378c966..79cb4b78a88a 100644 --- a/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml @@ -26,6 +26,22 @@ properties: vdd-supply: true vss-supply: true + vcc-supply: + description: + Supply that powers the chip. + + iovcc-supply: + description: + Supply for the digital interface. + + vrefp-supply: + description: + Positive referance input voltage range. From 5v to (vdd - 2.5) + + vrefn-supply: + description: + Negative referance input voltage range. From (vss + 2.5) to 0. + adi,rbuf-gain2-en: description: Specify to allow an external amplifier to be connected in a gain of two configuration. @@ -47,6 +63,10 @@ required: - reg - vdd-supply - vss-supply + - vcc-supply + - iovcc-supply + - vrefp-supply + - vrefn-supply allOf: - $ref: /schemas/spi/spi-peripheral-props.yaml# @@ -65,6 +85,10 @@ examples: reg = <0>; vss-supply = <&dac_vss>; vdd-supply = <&dac_vdd>; + vcc-supply = <&dac_vcc>; + iovcc-supply = <&dac_iovcc>; + vrefp-supply = <&dac_vrefp>; + vrefn-supply = <&dac_vrefn>; reset-gpios = <&gpio_bd 16 GPIO_ACTIVE_LOW>; clear-gpios = <&gpio_bd 17 GPIO_ACTIVE_LOW>; ldac-gpios = <&gpio_bd 18 GPIO_ACTIVE_HIGH>; From patchwork Tue Oct 29 07:38:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13854418 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2820E202F92 for ; Tue, 29 Oct 2024 07:39:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187548; cv=none; b=rXEZiwPi+pzUAnGpAHqj7q0xrGxsm2Samk3/sXAanvy/PwqBo3uK3b3h5LV882tR/S2RI0KjiX6sHbAP5hpx/N1nlxTH4lZW6Xib0JfQbkFv7PKA6XR2z5CfboVG1EhYbLPFSPR0Eo3TepzoXhXzLnlUA1FRSDJZHndBHtN8/tg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187548; c=relaxed/simple; bh=IW7rBfJDFC+nKog3s3s8Fih6Q9vHfUoFcdI1qORZ9ao=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rb4Tl3+UnmGDR74QbKXY/YNm3N2SO92YzdfTiqJZflFmHnMSQfNIeLGoMi163uzJD1+1v2Yv+/wF6dXJ/65aSwGJm8BE1g5ePIJTriyspQMNlpzeNRu3USW0t/++7udE6L/m7rdH9iZysUDSYiPTVT4j4UNFJDeCaPFtPxOd9Sg= 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.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="rlx0rM9l" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-37f52925fc8so3642575f8f.1 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=ZmmVV59NlrTGaKR7bZj8bRVe/u+Y/sE1j0L4NH9YHqwjcCOQDWnkSKcGDrxqn0m/4H QMG9B9BwIU43TMKPtZVhD2GF8yXGUk9EfXYNj9vEVZkhgB/pZWN+S/xGy+YMu4LwWY6D zDVdbTQ9cqW323eX1ujTdKt6FfZxX22b1HLWaDk8rzCH8F0QjkrWEeDzhSgOjttxKknv pJSA8O/iWsuG4HdwifncNd7b1aOeTp4Ae9+WVYSYRQztiYQ/3S+uufvMiEiBBvltSKJm xrvcQcdee3BypIDdVaua4c2+UAxhasPrgax2Ij0O3Gw5NXBjfyZDP9VNW4NT/PUTMvmq 6f3A== X-Gm-Message-State: AOJu0YyJGrqQGF9AbepP9XFCNwkZ/6UupWZ9WuaeDJDhAXBKzCxFUFA+ OpgIfzpZ4rBH1Od19VCZSoh3ZBx4u2IIZFzlo7CbGakYBxxZwluxn0+l/Hdy04w= 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-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam Include a chip info struct in device SPI and device OF match tables to provide channel definitions for each particular ADC model and drop device enum. Suggested-by: Nuno Sa Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 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 @@ /** * 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); }; /** @@ -98,13 +101,6 @@ struct ad5791_state { } data[3] __aligned(IIO_DMA_MINALIGN); }; -enum ad5791_supported_device_ids { - ID_AD5760, - ID_AD5780, - ID_AD5781, - ID_AD5791, -}; - static int ad5791_spi_write(struct ad5791_state *st, u8 addr, u32 val) { st->data[0].d32 = cpu_to_be32(AD5791_CMD_WRITE | @@ -228,20 +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[] = { - [ID_AD5760] = { - .get_lin_comp = ad5780_get_lin_comp, - }, - [ID_AD5780] = { - .get_lin_comp = ad5780_get_lin_comp, - }, - [ID_AD5781] = { - .get_lin_comp = ad5791_get_lin_comp, - }, - [ID_AD5791] = { - .get_lin_comp = ad5791_get_lin_comp, - }, -}; static int ad5791_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, @@ -289,30 +271,34 @@ static const struct iio_chan_spec_ext_info ad5791_ext_info[] = { { }, }; -#define AD5791_CHAN(bits, _shift) { \ - .type = IIO_VOLTAGE, \ - .output = 1, \ - .indexed = 1, \ - .address = AD5791_ADDR_DAC0, \ - .channel = 0, \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ - BIT(IIO_CHAN_INFO_OFFSET), \ - .scan_type = { \ - .sign = 'u', \ - .realbits = (bits), \ - .storagebits = 24, \ - .shift = (_shift), \ - }, \ - .ext_info = ad5791_ext_info, \ +#define AD5791_DEFINE_CHIP_INFO(_name, bits, _shift, _lin_comp) \ +static const struct ad5791_chip_info _name##_chip_info = { \ + .name = #_name, \ + .get_lin_comp = &(_lin_comp), \ + .channel = { \ + .type = IIO_VOLTAGE, \ + .output = 1, \ + .indexed = 1, \ + .address = AD5791_ADDR_DAC0, \ + .channel = 0, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ + .scan_type = { \ + .sign = 'u', \ + .realbits = (bits), \ + .storagebits = 24, \ + .shift = (_shift), \ + }, \ + .ext_info = ad5791_ext_info, \ + }, \ } -static const struct iio_chan_spec ad5791_channels[] = { - [ID_AD5760] = AD5791_CHAN(16, 4), - [ID_AD5780] = AD5791_CHAN(18, 2), - [ID_AD5781] = AD5791_CHAN(18, 2), - [ID_AD5791] = AD5791_CHAN(20, 0) -}; +AD5791_DEFINE_CHIP_INFO(ad5760, 16, 4, ad5780_get_lin_comp); +AD5791_DEFINE_CHIP_INFO(ad5780, 18, 2, ad5780_get_lin_comp); +AD5791_DEFINE_CHIP_INFO(ad5781, 18, 2, ad5791_get_lin_comp); +AD5791_DEFINE_CHIP_INFO(ad5790, 20, 0, ad5791_get_lin_comp); +AD5791_DEFINE_CHIP_INFO(ad5791, 20, 0, ad5791_get_lin_comp); static int ad5791_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, @@ -400,9 +386,9 @@ static int ad5791_probe(struct spi_device *spi) if (ret) goto error_disable_reg_neg; - st->chip_info = &ad5791_chip_info_tbl[spi_get_device_id(spi) - ->driver_data]; - + st->chip_info = spi_get_device_match_data(spi); + if (!st->chip_info) + return dev_err_probe(&spi->dev, -EINVAL, "no chip info\n"); st->ctrl = AD5761_CTRL_LINCOMP(st->chip_info->get_lin_comp(st->vref_mv)) | (use_rbuf_gain2 ? 0 : AD5791_CTRL_RBUF) | @@ -416,10 +402,9 @@ static int ad5791_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->info = &ad5791_info; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels - = &ad5791_channels[spi_get_device_id(spi)->driver_data]; + indio_dev->channels = &st->chip_info->channel; indio_dev->num_channels = 1; - indio_dev->name = spi_get_device_id(st->spi)->name; + indio_dev->name = st->chip_info->name; ret = iio_device_register(indio_dev); if (ret) goto error_disable_reg_neg; @@ -448,19 +433,30 @@ static void ad5791_remove(struct spi_device *spi) regulator_disable(st->reg_vss); } +static const struct of_device_id ad5791_of_match[] = { + { .compatible = "adi,ad5760", .data = &ad5760_chip_info }, + { .compatible = "adi,ad5780", .data = &ad5780_chip_info }, + { .compatible = "adi,ad5781", .data = &ad5781_chip_info }, + { .compatible = "adi,ad5790", .data = &ad5790_chip_info }, + { .compatible = "adi,ad5791", .data = &ad5791_chip_info }, + { } +}; +MODULE_DEVICE_TABLE(of, ad5791_of_match); + static const struct spi_device_id ad5791_id[] = { - {"ad5760", ID_AD5760}, - {"ad5780", ID_AD5780}, - {"ad5781", ID_AD5781}, - {"ad5790", ID_AD5791}, - {"ad5791", ID_AD5791}, - {} + { "ad5760", (kernel_ulong_t)&ad5760_chip_info }, + { "ad5780", (kernel_ulong_t)&ad5780_chip_info }, + { "ad5781", (kernel_ulong_t)&ad5781_chip_info }, + { "ad5790", (kernel_ulong_t)&ad5790_chip_info }, + { "ad5791", (kernel_ulong_t)&ad5791_chip_info }, + { } }; MODULE_DEVICE_TABLE(spi, ad5791_id); static struct spi_driver ad5791_driver = { .driver = { .name = "ad5791", + .of_match_table = ad5791_of_match, }, .probe = ad5791_probe, .remove = ad5791_remove, From patchwork Tue Oct 29 07:38:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13854419 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 59D49203700 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=1730187549; cv=none; b=U1XphFqkX6dHk0An2qytCxCDvvEnw841vz/KUrG58Sm4yR6PaqC7yTaQvNu7qDOkm9wppIKuwvXePnsHauUH7KYJt7JSMX0HKEomFalAU9bIJvLojMpKTdutRoDasM7ryV5pjM50Er5qpy1J2Ry+jzPip2RTZgKni5cCM+ldp68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187549; c=relaxed/simple; bh=lgc3ZdvonuJhwFaGdS5M3g6B8YizifcdxdIZV7LNhqw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Fe7pse+5wZlw3WYrj6Htd8UD8Dkiht2EZFdnfK85p5hek34U4YZlc6UC6D4E7BxmXzF88UB6K+jVmYEGD5xb8uViFp6/QWKMpPj9zjWps4/pXskdvjxFlUIOn3zGahyZ3CPviR/dinofPN7XIsjfyFj6j4ziSqmMJW7vrBw6rAA= 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-37d4a5ecc44so3346958f8f.2 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=JGwXKcTUFV8m3nNAcNdfCBdIdrBOqgiMopNVPbXJm2YLEG46SA0Ribz6/tdkbXVrWd ygwgxqqXkBWtbWs1sAjVaLlbe9vVi7TNRh6jo0490EGTqsqC4sG8bIKpK0QAhrJakCo/ ceIMQa5aZCRAQVWIe9PXDPWKBdBoLVuWoEA5STE3Ogp90xmYNsryP8jPMrJGd39uqwma eq15AeTwfud7t8rURmnxdc5AAM3xjnJlvSOJjek8AYFsEVuSuUAR1zVcJQLKa58IKsD5 R1wXSwJ1cLxXAoLAQ9e9Ww0J8/nS2S6uDJuXQGIus82Qa0oauqSQKLrc7QpPi0G1Ab9p PTPQ== X-Gm-Message-State: AOJu0Ywn176qZ3HIpzACY42R0OG4XyjBiqpT3QXppyVtHspcIuv4F7wX hhRK9ivd+S4SCcYv+Ro/j5Zfumlbeu1rAN7PKoBc9yYgFzhDAq9TRjqGhs/TZaY= 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-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam The ad7591 has reset, clr and ldac gpios. For the DAC to output data continuously written to the data register the state of these gpios needs to be set by the driver. Add these gpios to the driver making them optional in case they are fixed on the pcb. Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 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 = iio_priv(indio_dev); + + st->gpio_reset = devm_gpiod_get_optional(&spi->dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(st->gpio_reset)) + return PTR_ERR(st->gpio_reset); + + st->gpio_clear = devm_gpiod_get_optional(&spi->dev, "clear", + GPIOD_OUT_LOW); + if (IS_ERR(st->gpio_clear)) + return PTR_ERR(st->gpio_clear); + + st->gpio_ldac = devm_gpiod_get_optional(&spi->dev, "ldac", + GPIOD_OUT_HIGH); + if (IS_ERR(st->gpio_ldac)) + return PTR_ERR(st->gpio_ldac); + st->reg_vdd = devm_regulator_get(&spi->dev, "vdd"); if (!IS_ERR(st->reg_vdd)) { ret = regulator_enable(st->reg_vdd); @@ -382,9 +405,14 @@ static int ad5791_probe(struct spi_device *spi) dev_warn(&spi->dev, "reference voltage unspecified\n"); } - ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); - if (ret) - goto error_disable_reg_neg; + if (st->gpio_reset) { + fsleep(20); + gpiod_set_value_cansleep(st->gpio_reset, 0); + } else { + ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); + if (ret) + goto error_disable_reg_neg; + } st->chip_info = spi_get_device_match_data(spi); if (!st->chip_info) From patchwork Tue Oct 29 07:38:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13854420 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 882A32038A0 for ; Tue, 29 Oct 2024 07:39:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730187550; cv=none; b=gxtvDd0YfKqct48YEY0hmCke+AiFFZPMs0Xz21BBWW0tjBBjpYHkSIq0dtpcwqA19ryMdVencOqqjVK0yvxWGnu9qj85xJLazAEUGFjs5cV9xFaX94NVmZxFKruMKH2UThKehWgLWg+Jt38pBn0L5TmrpXRSoMATp63B6iBevDc= 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.46 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-f46.google.com with SMTP id 5b1f17b1804b1-4315abed18aso49075755e9.2 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=HQ+JeJ6JZiVWRqlKgZwmg+TRp0LBFgLhpfPf6w2/pXzzR0Zmz7LtNEOd0W4GGF6Zhd aCEuhNFmx7aNwFP9Fufu1UOl9UmibsmKhVejw1hVdTs7fxzdnaYSXxRJfguId9vs9wZt 1ZAEL6s2CyjNtdeyQMsUSBWJ20a335Brb7XGe+hx+QxJOZyRsH2RyTE4WBHq0tIy3C0x HkkraUwZGJiknCa12j7Y5mQS8nLyog7qeLKED52aVyx9uVON06FRGJgZh8L4iGjcS0Uv AvkkECC5ZoYh8ivxTwcXf8w+5q8ksgOXsJR/dy6kQi5EeWHMfQHQxOEO6A19EDnCVz9S u6qg== X-Gm-Message-State: AOJu0Yz55iD55g7rxfy3uBuB4qtz7lctMSFTG9KswPHg4QkrAyUrwKn2 fr7NJqcnnYzm5/cJkJ2hVechrWkbcws5t3GnXVwtO5Z8LsJStKint26VftH+92gEf3qtCjn02f9 /zoQ= 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-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam Simplify probe by using of the devm_regulator_get_enable_read_voltage. Suggested-by: David Lechner Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 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); - st->reg_vdd = devm_regulator_get(&spi->dev, "vdd"); - if (!IS_ERR(st->reg_vdd)) { - ret = regulator_enable(st->reg_vdd); - if (ret) - return ret; - - ret = regulator_get_voltage(st->reg_vdd); - if (ret < 0) - goto error_disable_reg_pos; - - pos_voltage_uv = ret; - } - - st->reg_vss = devm_regulator_get(&spi->dev, "vss"); - if (!IS_ERR(st->reg_vss)) { - ret = regulator_enable(st->reg_vss); - if (ret) - goto error_disable_reg_pos; - - ret = regulator_get_voltage(st->reg_vss); - if (ret < 0) - goto error_disable_reg_neg; - - neg_voltage_uv = ret; - } - st->pwr_down = true; st->spi = spi; @@ -395,7 +369,17 @@ static int ad5791_probe(struct spi_device *spi) use_rbuf_gain2 = device_property_read_bool(&spi->dev, "adi,rbuf-gain2-en"); - if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd)) { + pos_voltage_uv = devm_regulator_get_enable_read_voltage(&spi->dev, "vdd"); + if (pos_voltage_uv < 0 && pos_voltage_uv != -ENODEV) + return dev_err_probe(&spi->dev, pos_voltage_uv, + "failed to get vdd voltage\n"); + + neg_voltage_uv = devm_regulator_get_enable_read_voltage(&spi->dev, "vss"); + if (neg_voltage_uv < 0 && neg_voltage_uv != -ENODEV) + return dev_err_probe(&spi->dev, neg_voltage_uv, + "failed to get vss voltage\n"); + + if (neg_voltage_uv >= 0 && pos_voltage_uv >= 0) { st->vref_mv = (pos_voltage_uv + neg_voltage_uv) / 1000; st->vref_neg_mv = neg_voltage_uv / 1000; } else if (pdata) { @@ -411,7 +395,7 @@ static int ad5791_probe(struct spi_device *spi) } else { ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); if (ret) - goto error_disable_reg_neg; + return dev_err_probe(&spi->dev, ret, "fail to reset\n"); } st->chip_info = spi_get_device_match_data(spi); @@ -425,7 +409,7 @@ static int ad5791_probe(struct spi_device *spi) ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl | AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI); if (ret) - goto error_disable_reg_neg; + return dev_err_probe(&spi->dev, ret, "fail to write ctrl register\n"); spi_set_drvdata(spi, indio_dev); indio_dev->info = &ad5791_info; @@ -435,30 +419,16 @@ static int ad5791_probe(struct spi_device *spi) indio_dev->name = st->chip_info->name; ret = iio_device_register(indio_dev); if (ret) - goto error_disable_reg_neg; + return dev_err_probe(&spi->dev, ret, "unable to register iio device\n"); return 0; - -error_disable_reg_neg: - if (!IS_ERR(st->reg_vss)) - regulator_disable(st->reg_vss); -error_disable_reg_pos: - if (!IS_ERR(st->reg_vdd)) - regulator_disable(st->reg_vdd); - return ret; } static void ad5791_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ad5791_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - if (!IS_ERR(st->reg_vdd)) - regulator_disable(st->reg_vdd); - - if (!IS_ERR(st->reg_vss)) - regulator_disable(st->reg_vss); } static const struct of_device_id ad5791_of_match[] = { From patchwork Tue Oct 29 07:38:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 13854421 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 351522038CE 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-539e3f35268so6049869e87.3 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=vXXq4rBYAE6jgp950hhAm7ym6LQUqtyJ8BSuR+sMjrOvNNxsINrFb+hmNO8C0pWgad 9tgJlHh9Uj6rxuCOd06kQGm8N43zI7aAFBa1ks/lx9QYNQ207u7JCFqHfnjFKuIAoRln oRESvSrGRCJsV0HajknBp7DPXZ9ZI9e0ixCVwInVmk4K8NzNj8EPz5Oi2oq0pL5xl7Mr rk/C5sL1jI4ksKvLGLhkDNf4F0BFgrGU+tz43y65XgJz+Oa+avavcX4wuD/WK17fvLsH 2Tv92tYbDnnp7ylzTtJ04G+K4/sLvAOoUyld8BJWGKPH4EQR8n9hdXBe5FUcL2GjAZEu Eclg== X-Gm-Message-State: AOJu0YxsU89NT+qYPVMYOkQ/BmD1UquSD61Vdiu2emM9UiVTOOY4G8jS AT1BCYx6u0HtwVQO0aJ+2vmtERIsVhI+NTVKmkWnrzmpdZ2lD+haKkUGH+S/dyc= 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-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Axel Haslam Use devm_iio_device_register to automatically free the iio device. since this is the last remaining resource that was not automatically freed, we can drop the ".remove" callback. Suggested-by: David Lechner Signed-off-by: Axel Haslam --- drivers/iio/dac/ad5791.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 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"); - spi_set_drvdata(spi, indio_dev); indio_dev->info = &ad5791_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = &st->chip_info->channel; indio_dev->num_channels = 1; indio_dev->name = st->chip_info->name; - ret = iio_device_register(indio_dev); - if (ret) - return dev_err_probe(&spi->dev, ret, "unable to register iio device\n"); - - return 0; -} - -static void ad5791_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - - iio_device_unregister(indio_dev); + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct of_device_id ad5791_of_match[] = { @@ -457,7 +445,6 @@ static struct spi_driver ad5791_driver = { .of_match_table = ad5791_of_match, }, .probe = ad5791_probe, - .remove = ad5791_remove, .id_table = ad5791_id, }; module_spi_driver(ad5791_driver);