From patchwork Tue Feb 6 17:25:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 197552 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1696250dyb; Tue, 6 Feb 2024 09:27:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsIhK9ejifGsOSCtuPPPeYQ83Q9b1PByw+hwuSJD0RcVdkj9kVJiQdsPWNJQ+U02WsuAxS X-Received: by 2002:a05:6358:4b46:b0:178:7c7a:d441 with SMTP id ks6-20020a0563584b4600b001787c7ad441mr188449rwc.31.1707240456414; Tue, 06 Feb 2024 09:27:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240456; cv=pass; d=google.com; s=arc-20160816; b=C0H9Tl43uXXTqKdT79LzpN9UvoD2iAUNCEuj/TRYlzyprVxpaMcUbQoc6v3xrcDRWw 5l+Oidm0iYg7Fnoa4Mny6i+1bFBCXRA/FkRw56pBJOSYwCiiXCfJwB0Ww1+imJSn0xA3 T8okFI7GHbI8laH3SFCFRCNIoJ4IcXkb/3gr/i1j9Ir6OvRqIVnDdZrtPD+6jNItKl7X 77qHTOCDz1OtiLJ2zp/p2nIsZfsmcw7tUjp+54HqVUp411pTrPzVGYhipnlfeDcQ6FeX F0D+OuW1V90UCQbZuAQLpUGR72tX4eWRxYaEOwesC2eaXQah4rhEW8qqzDz4PLnT/K4Z aACA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dhp8UZm2JwOSFCZ1rISqGYvHQLQ2QqVB/JsYTkrLcX0=; fh=PktsIdU2D8v3j6+o3kPYwZHTtyO4p5FpHsibGN2s2HY=; b=z+CAwyRrPQiJWJ7ApodivVKKZqnRpAfHPP1WrXCUO4DhSt+ZvZQgjaSkUsQOb+lBBP YYox2Bp41b4c6ONd7H4R0h/wpB866khtLxg5hLccV5IzBTIKm+NM6k/x5akVLEO9wOzh FU7NfMW5mYj6F38dfgo46zcxPxLV8YUoIx2o+KifK4EgYxtyophce4/XX6GZXB9/Pduk 4uKWQsAMS2ybBLivVxwBgEMf4dj+tYVO3SxWzXldwlnfedf0XxVwe6rt8PFVg4kfWAsx 2LiiarbyCHAyzAEfh3BH9/ha0GO0PMkoJDrlWsOz4CVcXNosb1dHtdrcC6cNUz8y8TG2 lGvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=LXCUuUpB; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-55367-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55367-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXHAKV4VywaoEyGXCbmbpbWjQwBRMpSEOaKfA25ythb8ENzkcx/0X8J3073d57ExDuHg76RK70hLyUj4KrzrHKyYzDPQg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id r19-20020a63ec53000000b005cdec41efddsi1948934pgj.150.2024.02.06.09.27.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:27:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55367-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=LXCUuUpB; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-55367-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55367-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2385C286E69 for ; Tue, 6 Feb 2024 17:27:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9D6012B71; Tue, 6 Feb 2024 17:26:54 +0000 (UTC) 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="LXCUuUpB" Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (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 CA2468F7D for ; Tue, 6 Feb 2024 17:26:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240410; cv=none; b=E3WUkOpR5xfWJo9cS5/StmuNvMfSwnayW1ElcnYs1jCJBtC7hVxyDUZSVvi/Qn9DzFzPmP6xjha/a4Q18fvCISEZvt4D6IokvWMiiRWCKktOOw9m5ts9qVRU8+hVpjntV52jpAnB33ynk+YNDqCiu0YTFoZrQ3ZLqxkSJfLYW7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240410; c=relaxed/simple; bh=EidOcuoZW3ufSG/U+3UtA9DRjyVDFhllbJMEYhp2DsM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bmpeyMC/3HafIlFTqdz535AWdpnNnWK4uchnEnJ+4J8jlFdpADF6XbL3bA0TRxKJuELxik7o5dPK6AoQ6QcGCc9TmrW91Vg+c5dbLjmI6LO0GUi9QICYq7TSyg3ua0xIqnKyFE2qHdLfaqCn/OaZWuco4zYlvGzhbPJDLfkwQxg= 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=LXCUuUpB; arc=none smtp.client-ip=209.85.160.50 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 Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-21959190723so1815514fac.1 for ; Tue, 06 Feb 2024 09:26:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1707240407; x=1707845207; 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=dhp8UZm2JwOSFCZ1rISqGYvHQLQ2QqVB/JsYTkrLcX0=; b=LXCUuUpBIotkPKF5QGBwzPdQGrY0XinVFcgH2718G3nlDLXHtNUlIDScKO54HuosEr f8cpllgMJLMzzhClHlZO4eBgygng5GgYvzV8lOsyL0Bdk7/n2qggkpFNZYqTIbTmfoA2 i4j+N14ZK/AUembetRd0wUkXlhcij6v13EqkDN/wzg6gH9xiWgARrPBSxOtEnq5jm11e 7iVJS7ZQRmsbAZbODzuX0jcrxDLcdYCtZ90+pkHMfxZETTrRGqJ4KRwo1Qo88MymSipG rVCIi0X9VFfld5WJEl2MVbELNdJd4wdoroMyq1GADFUu1PudB+xazVGPT8MYe7hsVUek /tmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240407; x=1707845207; 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=dhp8UZm2JwOSFCZ1rISqGYvHQLQ2QqVB/JsYTkrLcX0=; b=BwZaOk4xFLeGicO5/lS7ikoZQ+yDBvr+Y5rhrVskY/v8K03gLWZsTNOq6z0xfNL48M jt7SDIRSxUsTBKEYMlJ7FgYWckJMRTs9wb73IRF3P+J7JLjkkU7JIqY5Ya1bOK122sDf b6Oq1TLnvv8DMsDvsBTmDwi+aFBMzJu0EEMxGaEBEIUns/BWvjAZfuyql4k9xW9XdmHW ZtnFOURTClwPeweJ2Tjlskz+ceWwklUor11sEoFy0FsqXX+7GOIj+Uwp6xTqHPxAEjE3 I9CcWVJHS6uRoKtljjSqGY0uSgy8TrCITSGyQhkbPKMzVE5gm7Sy8J7bsebEWaPv1Vxj KT9g== X-Gm-Message-State: AOJu0Yz7eMhrNsrt4qddOytqkDs27PN/0UOHOR03zZW7VaTFq2u1uG3o p5yZFvPtSg4PKuTgzbcF1ZJAe1PrbWpkHcuaQkB2cohjE2CF5L7AFUL3lS/plgw= X-Received: by 2002:a05:6870:970f:b0:210:cd75:8e34 with SMTP id n15-20020a056870970f00b00210cd758e34mr3845774oaq.17.1707240406797; Tue, 06 Feb 2024 09:26:46 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX+EU8lCf+JNmDlH/8bTZ9vSvI3juhTQGpHJy91a3FNy0M0q14XoZWh4GZ80yeHp5r/7YQCOgH9dM+jgGioWgy2s5x1p74CQEXyQH66ehWG/SiPHBaIZAoYBCwuSdNY0E3YdAYEEi6/O9RNVma+wwHm8T8kKbNS5Qym6bsGtRL8gbjwYFMhbvtWvbQ7ekj5FKIX2r8LXzz3cAsuHnFQb1LtZkgZiGhHLEM5JV7S3Dagj+l51TfWdegyYj0McLdHOwx5wRpNN7nTZjunLxWzbiLofN0VGTYsfcnyV+LOqFeZnJUq0/H0BUB79Skhx43pqrFiYo/mbkoWkoKXhoYNtHrNyWcvtNB4uvNFEyQhIUxhw/z8SuKcMsnk22QFnvytqe7T Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id ea9-20020a056870070900b0021998dc2bf1sm510172oab.36.2024.02.06.09.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:26:46 -0800 (PST) From: David Lechner To: linux-iio@vger.kernel.org Cc: David Lechner , Michael Hennerich , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?utf-8?q?Nuno_S=C3=A1?= , Liam Girdwood , Mark Brown , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] dt-bindings: iio: adc: add ad7944 ADCs Date: Tue, 6 Feb 2024 11:25:59 -0600 Message-ID: <20240206-ad7944-mainline-v1-1-bf115fa9474f@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206-ad7944-mainline-v1-0-bf115fa9474f@baylibre.com> References: <20240206-ad7944-mainline-v1-0-bf115fa9474f@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171368723705395 X-GMAIL-MSGID: 1790171368723705395 This adds a new binding for the Analog Devices, Inc. AD7944, AD7985, and AD7986 ADCs. Signed-off-by: David Lechner --- .../devicetree/bindings/iio/adc/adi,ad7944.yaml | 231 +++++++++++++++++++++ MAINTAINERS | 8 + 2 files changed, 239 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7944.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7944.yaml new file mode 100644 index 000000000000..a023adbeba42 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7944.yaml @@ -0,0 +1,231 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ad7944.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices PulSAR LFCSP Analog to Digital Converters + +maintainers: + - Michael Hennerich + - Nuno Sá + +description: | + A family of pin-compatible single channel differential analog to digital + converters with SPI support in a LFCSP package. + + * https://www.analog.com/en/products/ad7944.html + * https://www.analog.com/en/products/ad7985.html + * https://www.analog.com/en/products/ad7986.html + +$ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + enum: + - adi,ad7944 + - adi,ad7985 + - adi,ad7986 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 111111111 + + spi-cpha: true + + adi,spi-mode: + $ref: /schemas/types.yaml#/definitions/string + enum: [ 3-wire, 4-wire, chain ] + default: 4-wire + description: + This chip can operate in a 3-wire mode where SDI is tied to VIO, a 4-wire + mode where SDI acts as the CS line, or a chain mode where SDI of one chip + is tied to the SDO of the next chip in the chain and the SDI of the last + chip in the chain is tied to GND. + + avdd-supply: + description: A 2.5V supply that powers the analog circuitry. + + dvdd-supply: + description: A 2.5V supply that powers the digital circuitry. + + vio-supply: + description: + A 1.8V to 2.7V supply for the digital inputs and outputs. + + bvdd-supply: + description: + A voltage supply for the buffered power. When using an external reference + without an internal buffer (PDREF high, REFIN low), this should be + connected to the same supply as ref-supply. Otherwise, when using an + internal reference or an external reference with an internal buffer, this + is connected to a 5V supply. + + ref-supply: + description: + Voltage regulator for the reference voltage (REF). This property is + omitted when using an internal reference. + + refin-supply: + description: + Voltage regulator for the reference buffer input (REFIN). When using an + external buffer with internal reference, this should be connected to a + 1.2V external reference voltage supply. + + adi,reference: + $ref: /schemas/types.yaml#/definitions/string + enum: [ internal, internal-buffer, external ] + default: internal + description: | + This property is used to specify the reference voltage source. + + * internal: PDREF is wired low. The internal 4.096V reference voltage is + used. The REF pin outputs 4.096V and REFIN outputs 1.2V. + * internal-buffer: PDREF is wired high. REFIN is supplied with 1.2V. The + buffered internal 4.096V reference voltage is used. The REF pin outputs + 4.096V. + * external: PDREF is wired high and REFIN is wired low. The supply + connnected the REF pin is used as the reference voltage. + + cnv-gpios: + description: + The Convert Input (CNV). This input has multiple functions. It initiates + the conversions and selects the SPI mode of the device (chain or CS). In + 3-wire mode, this property is omitted if the CNV pin is connected to the + CS line of the SPI controller. + maxItems: 1 + + turbo-gpios: + description: + GPIO connected to the TURBO line. If omitted, it is assumed that the TURBO + line is hard-wired and the state is determined by the adi,always-turbo + property. + maxItems: 1 + + adi,always-turbo: + type: boolean + description: + When present, this property indicates that the TURBO line is hard-wired + and the state is always high. If neither this property nor turbo-gpios is + present, the TURBO line is assumed to be hard-wired and the state is + always low. + + interrupts: + description: + The SDO pin can also function as a busy indicator. This node should be + connected to an interrupt that is triggered when the SDO line goes low + while the SDI line is high and the CNV line is low (3-wire mode) or the + SDI line is low and the CNV line is high (4-wire mode); or when the SDO + line goes high while the SDI and CNV lines are high (chain mode), + maxItems: 1 + +required: + - compatible + - reg + - avdd-supply + - dvdd-supply + - vio-supply + - bvdd-supply + +allOf: + # ref-supply is only used for external reference voltage + - if: + not: + required: + - adi,reference + then: + properties: + ref-supply: false + else: + if: + properties: + adi,reference: + const: external + then: + required: + - ref-supply + else: + properties: + ref-supply: false + # refin-supply is only used for internal buffer reference voltage + - if: + not: + required: + - adi,reference + then: + properties: + refin-supply: false + else: + if: + properties: + adi,reference: + const: internal-buffer + then: + required: + - refin-supply + else: + properties: + refin-supply: false + # in 3-wire mode, cnv-gpios is optional, for other modes it is required + - if: + not: + required: + - adi,spi-mode + then: + required: + - cnv-gpios + else: + if: + properties: + adi,spi-mode: + enum: [ 4-wire, chain ] + then: + required: + - cnv-gpios + # chain mode doesn't work when TRUBO is enabled + - if: + properties: + adi,spi-mode: + const: chain + required: + - adi,spi-mode + then: + properties: + adi,always-turbo: false + # turbo-gpios and adi,always-turbo are mutually exclusive + - if: + required: + - turbo-gpios + then: + properties: + adi,always-turbo: false + - if: + required: + - adi,always-turbo + then: + properties: + turbo-gpios: false + +unevaluatedProperties: false + +examples: + - | + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + adc@0 { + compatible = "adi,ad7944"; + reg = <0>; + spi-cpha; + spi-max-frequency = <111111111>; + avdd-supply = <&supply_2_5V>; + dvdd-supply = <&supply_2_5V>; + vio-supply = <&supply_1_8V>; + bvdd-supply = <&supply_5V>; + cnv-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; + turbo-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 00d354af10f5..4f1e658e1e0d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -451,6 +451,14 @@ W: http://wiki.analog.com/AD7879 W: https://ez.analog.com/linux-software-drivers F: drivers/input/touchscreen/ad7879.c +AD7944 ADC DRIVER (AD7944/AD7985/AD7986) +M: Michael Hennerich +M: Nuno Sá +R: David Lechner +S: Supported +W: https://ez.analog.com/linux-software-drivers +F: Documentation/devicetree/bindings/iio/adc/adi,ad7944.yaml + ADAFRUIT MINI I2C GAMEPAD M: Anshul Dalal L: linux-input@vger.kernel.org From patchwork Tue Feb 6 17:26:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 197553 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1696299dyb; Tue, 6 Feb 2024 09:27:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBT5q8vKv1wcHo1y2jNvWS3wgXFYfEh28aGJzzVujXoW+ChtiwsvoSpI+rm5Dh6yEce/Xk X-Received: by 2002:ad4:5962:0:b0:686:9d71:da24 with SMTP id eq2-20020ad45962000000b006869d71da24mr3931284qvb.8.1707240462516; Tue, 06 Feb 2024 09:27:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240462; cv=pass; d=google.com; s=arc-20160816; b=oPztz4M53BJ0tmxQ6b5rglgbZrgAr/daXQ97ieGhsCUtCwZNtuljMKi8YQ2Hvubp7C f6CTsXd9MU1FfwPMjjnSzgkGx9kRljcD3mGPywj3IOJnLYVNyj7lXDYTQs8c5KdmRecd YV9lA0XbOue9KT35foOdHQHEHRfu4lFZEzyJ07h/xivPSgyanzSDf0iEpgzD1SPs1Ihe 5OZY283Q+VXg2QKAlUcd90BB8ewHNNhFTQWYzx6eARJ1N7SybUCW0DXNen4dqNNwmgR1 uKjq0+LWzUIyUEHqQdE46I2wP/nils4toAH5tpWZn+/Vrs4aE5C7CZiWnRiBftzjQr41 J3/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=8g2rdQmtRie8AcqF2+eOMTdU5EzOPlbdREIl+iEY+OE=; fh=ot9hlPiVkjjHijPHm05fsyzRc4Vcr44f8QKVm5RkuuI=; b=FVu0Co8CjG/sX2Kc+9+D61RWRH34hTAEWHVmYlwmnfIhvA+LgP3lHP+HlVF0rl9SeD ntrTQB71MlFta4fhS/RRlVFp0/kLsv6Si1P28XigYbrQsDJop5AOxqPVfhE8HjmaZNZ9 PwpUkMIIXw4ZEXvTUeACEr8PCDZkzQvuxQKJpXQQBT3s+BeQbKq41d6ukvWvhSwPYJUL Dszbd+MjcBl8R9hhkLY2LIEHBq4rAvF8ax9xi+EiL1pxHQ2bUJ5Ki6sOwBcjupG+RPEJ cao/rqknenmg042wSsjv0mBVLscXq9mp67eVIeQHXucouLnHmOtSBBooIkdRDuznuL8n /bwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=XOeyTAn9; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-55368-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55368-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCV+X0DSX/8pjSQfoklwZWoN5KTJkX4mxwVvwtSZvbJFDv81MpFHbOzmVfngavyj/4cDvqz+75maMzNZUpprHvnSttaIpA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jp15-20020ad45f8f000000b0068c7fa45187si3116034qvb.52.2024.02.06.09.27.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:27:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55368-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=XOeyTAn9; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-55368-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55368-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 419A71C22BC6 for ; Tue, 6 Feb 2024 17:27:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC67B12E68; Tue, 6 Feb 2024 17:26:55 +0000 (UTC) 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="XOeyTAn9" Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.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 9A4FF9475 for ; Tue, 6 Feb 2024 17:26:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240410; cv=none; b=TDxcZpWPTD3juqfDDhCoapQCU+LoRbqF2AoQD0sDh1gy1D2uCDdxA6EoP8lBxKT1956e68nSYriof318XOr/jw1s3/X51YjHw4R3UoYLmab1b8D7g4P1P6TJGWPVcGv06X4TH7qiasV8TIEEFTWp0V3y7t8G3oVCDAJQ8K8IiUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240410; c=relaxed/simple; bh=XazVMLOJbAM/gRdK8X+BC5+I8+DqhQnRcd7DYAIkeH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YM1eNnC6O0CKtmFytWSOgwB6wT8MoGFVcE0D91AaujIn85CJ9FG7u8VfWwD1jm/Y2ab4yqPI2YxmZTXy8Y3mhIjBRMGJbm8323hfxJbVWGQjkhcSLjvplaTxJGybyOhXPMXA/64jLhTjZEx23FNII0sA/Xij30vK7zlHUaoxF1w= 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=XOeyTAn9; arc=none smtp.client-ip=209.85.160.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 Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-21920c78c9fso2523632fac.1 for ; Tue, 06 Feb 2024 09:26:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1707240407; x=1707845207; 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=8g2rdQmtRie8AcqF2+eOMTdU5EzOPlbdREIl+iEY+OE=; b=XOeyTAn9EeoaanKtTiBWfhS5XDR6SzgSEMxwi0EGyd/lgfNI6I0etzXZzolkgerQdp DswXPSBGDoxM12AFCv3VOTNXxAsvYfG7xZ/PhL2fODTV1VOQvARmpgyocETPVVi0CjKl B6TQjFxkHbO0bc0z+NwRq9QbuQhf5Blmu7f3K13BetPI4smQKpqE3frn3l0GCWRBN4No O/bY+UWPlBGZUFXO5u9lvcSZe+TuFp7IDHgWou+I8fv1Q9Cd3DiID8rBv/FU+BqKCPdW WeuTzlmaMh7Qy1a67bkiffrH72qSvUDl+VockJy8Ff3qo7VMCmhJgZvWeFB9H4jd0k6b RojQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240407; x=1707845207; 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=8g2rdQmtRie8AcqF2+eOMTdU5EzOPlbdREIl+iEY+OE=; b=VU0jQ7eOi/7FbfX94DK6hrhfXZEMcbhB626HBNjj1fM5CeLMz5BCgxKUkT0vv2YwD9 2FLjJSd59JNY/YFcqL5NTpc6a+9/tBndUir7KRZXhzk5hgyY9HrjxuVu6GUPKOf/eV1D MykVGsrbQRKkqWZNqmez907xlLFohM7sFx7/q78tp7/AYcTwdMohMlhBVMpd7NFzm4ib yzUUnR5WLmyUpPacEfBH/IZSkVoBC52w4JQjSe8ebLb+yqhwXEhsNid7jC2P+HuWqZ31 s6fDQF+y++cttr9aXUUoBEa/4NPNz3y2e6nna015KMuvKJRu80r3AGkwckcX0hT7Mxy2 TNpA== X-Gm-Message-State: AOJu0YzwNyC214+Fkl5oytLd3xY/nmvDCZbHSVN9/aEukH2omW30A9+5 zr7YLl+6DOQqKHa+uVbnjgd4Vwe/52fNVBzQ0Ac01d0zNc/qg1oTXqf5qTvgQE0= X-Received: by 2002:a05:6870:c0e:b0:218:f80e:a30b with SMTP id le14-20020a0568700c0e00b00218f80ea30bmr3962702oab.16.1707240407607; Tue, 06 Feb 2024 09:26:47 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVpU7Qgz3FFw52Gd/dutoeA3z4EKBnZC+7llD48XgyvHsu21orxd0Eehc2v4IEcS9ICTWTLORnUzd0ntaj72wjQKX5DX3bBe7fHDfD2Vk27ZKTM0G3H8sg4+um539fx0YuYtFsXDIleFB9Bm3FtNBPmbryphsIKcpZYs/Ml1CrPet4z5/kEBrnzOHLz6aqXyjrBbcy5wDEv1PPLkJjvQt4QciXDCM0Ja8JuBF+5AOm6AMSgefVJC2/vHLZ4SkNHy8QBnJIx4Y3b8R1/hDzgDN4v+wBtbepWjDzjIqvuqUzMu+3SZshcBQO/Cegy1c/lLk9bWdu9whfDFJ7gWYyN0JcpCh/QeOtBvzRrJq7xg5Lqs0luOhaW3TuPAYEk82a76bZL Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id ea9-20020a056870070900b0021998dc2bf1sm510172oab.36.2024.02.06.09.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:26:47 -0800 (PST) From: David Lechner To: linux-iio@vger.kernel.org Cc: David Lechner , Michael Hennerich , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?utf-8?q?Nuno_S=C3=A1?= , Liam Girdwood , Mark Brown , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] iio: adc: ad7944: add driver for AD7944/AD7985/AD7986 Date: Tue, 6 Feb 2024 11:26:00 -0600 Message-ID: <20240206-ad7944-mainline-v1-2-bf115fa9474f@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206-ad7944-mainline-v1-0-bf115fa9474f@baylibre.com> References: <20240206-ad7944-mainline-v1-0-bf115fa9474f@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171375381285663 X-GMAIL-MSGID: 1790171375381285663 This adds a driver for the Analog Devices Inc. AD7944, AD7985, and AD7986 ADCs. These are a family of pin-compatible ADCs that can sample at rates up to 2.5 MSPS. The initial driver adds support for sampling at lower rates using the usual IIO triggered buffer and can handle all 3 possible reference voltage configurations. Signed-off-by: David Lechner --- MAINTAINERS | 1 + drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7944.c | 397 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 409 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 4f1e658e1e0d..83d8367595f1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -458,6 +458,7 @@ R: David Lechner S: Supported W: https://ez.analog.com/linux-software-drivers F: Documentation/devicetree/bindings/iio/adc/adi,ad7944.yaml +F: drivers/iio/adc/ad7944.c ADAFRUIT MINI I2C GAMEPAD M: Anshul Dalal diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 59ae1d17b50d..93fbe6f8e306 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -280,6 +280,16 @@ config AD7923 To compile this driver as a module, choose M here: the module will be called ad7923. +config AD7944 + tristate "Analog Devices AD7944 and similar ADCs driver" + depends on SPI + help + Say yes here to build support for Analog Devices + AD7944, AD7985, AD7986 ADCs. + + To compile this driver as a module, choose M here: the + module will be called ad7944 + config AD7949 tristate "Analog Devices AD7949 and similar ADCs driver" depends on SPI diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 5a26ab6f1109..52d803b92cd7 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_AD7780) += ad7780.o obj-$(CONFIG_AD7791) += ad7791.o obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7887) += ad7887.o +obj-$(CONFIG_AD7944) += ad7944.o obj-$(CONFIG_AD7949) += ad7949.o obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_AD9467) += ad9467.o diff --git a/drivers/iio/adc/ad7944.c b/drivers/iio/adc/ad7944.c new file mode 100644 index 000000000000..67b525fb8e59 --- /dev/null +++ b/drivers/iio/adc/ad7944.c @@ -0,0 +1,397 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Analog Devices AD7944/85/86 PulSAR ADC family driver. + * + * Copyright 2024 Analog Devices, Inc. + * Copyright 2024 Baylibre, SAS + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define AD7944_INTERNAL_REF_MV 4096 + +struct ad7944_timing_spec { + /* Normal mode minimum CNV pulse width in nanoseconds. */ + unsigned int cnv_ns; + /* TURBO mode minimum CNV pulse width in nanoseconds. */ + unsigned int turbo_cnv_ns; +}; + +struct ad7944_adc { + struct spi_device *spi; + /* Chip-specific timing specifications. */ + const struct ad7944_timing_spec *t; + /* GPIO connected to CNV pin. */ + struct gpio_desc *cnv; + /* Optional GPIO to enable turbo mode. */ + struct gpio_desc *turbo; + /* Indicates TURBO is hard-wired to be always enabled. */ + bool always_turbo; + /* Reference voltage (millivolts). */ + unsigned int ref_mv; + + /* + * DMA (thus cache coherency maintenance) requires the + * transfer buffers to live in their own cache lines. + */ + struct { + union { + u16 u16; + u32 u32; + } raw; + u64 timestamp __aligned(8); + } sample __aligned(IIO_DMA_MINALIGN); +}; + +static const struct ad7944_timing_spec ad7944_timing_spec = { + .cnv_ns = 420, + .turbo_cnv_ns = 320, +}; + +static const struct ad7944_timing_spec ad7986_timing_spec = { + .cnv_ns = 500, + .turbo_cnv_ns = 400, +}; + +struct ad7944_chip_info { + const char *name; + const struct ad7944_timing_spec *t; + const struct iio_chan_spec channels[2]; +}; + +#define AD7944_DEFINE_CHIP_INFO(_name, _t, _bits, _sign) \ +static const struct ad7944_chip_info _name##_chip_info = { \ + .name = #_name, \ + .t = &_t##_timing_spec, \ + .channels = { \ + { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .differential = 1, \ + .channel = 0, \ + .channel2 = 1, \ + .scan_index = 0, \ + .scan_type.sign = _sign, \ + .scan_type.realbits = _bits, \ + .scan_type.storagebits = _bits > 16 ? 32 : 16, \ + .scan_type.endianness = IIO_CPU, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) \ + | BIT(IIO_CHAN_INFO_SCALE), \ + }, \ + IIO_CHAN_SOFT_TIMESTAMP(1), \ + }, \ +} + +AD7944_DEFINE_CHIP_INFO(ad7944, ad7944, 14, 'u'); +AD7944_DEFINE_CHIP_INFO(ad7985, ad7944, 16, 'u'); +AD7944_DEFINE_CHIP_INFO(ad7986, ad7986, 18, 's'); + +/** + * ad7944_4_wire_mode_conversion - Perform a 4-wire mode conversion and acquisition + * @adc: The ADC device structure + * @chan: The channel specification + * Return: 0 on success, a negative error code on failure + * + * Upon successful return adc->sample.raw will contain the conversion result. + */ +static int ad7944_4_wire_mode_conversion(struct ad7944_adc *adc, + const struct iio_chan_spec *chan) +{ + unsigned int t_cnv_ns = adc->always_turbo ? adc->t->turbo_cnv_ns + : adc->t->cnv_ns; + struct spi_transfer xfers[] = { + { + /* + * NB: can get better performance from some SPI + * controllers if we use the same bits_per_word + * in every transfer. + */ + .bits_per_word = chan->scan_type.realbits, + /* + * CS has to be high for full conversion time to avoid + * triggering the busy indication. + */ + .cs_off = 1, + .delay = { + .value = t_cnv_ns, + .unit = SPI_DELAY_UNIT_NSECS, + }, + + }, + { + .rx_buf = &adc->sample.raw, + .len = BITS_TO_BYTES(chan->scan_type.storagebits), + .bits_per_word = chan->scan_type.realbits, + }, + }; + int ret; + + /* + * In 4-wire mode, the CNV line is held high for the entire conversion + * and acquisition process. + */ + gpiod_set_value_cansleep(adc->cnv, 1); + + ret = spi_sync_transfer(adc->spi, xfers, ARRAY_SIZE(xfers)); + if (ret) + return ret; + + gpiod_set_value_cansleep(adc->cnv, 0); + + return 0; +} + +static int ad7944_single_conversion(struct ad7944_adc *adc, + const struct iio_chan_spec *chan, + int *val) +{ + int ret; + + ret = ad7944_4_wire_mode_conversion(adc, chan); + if (ret) + return ret; + + if (chan->scan_type.storagebits > 16) + *val = adc->sample.raw.u32; + else + *val = adc->sample.raw.u16; + + if (chan->scan_type.sign == 's') + *val = sign_extend32(*val, chan->scan_type.realbits - 1); + + return IIO_VAL_INT; +} + +static int ad7944_read_raw(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + int *val, int *val2, long info) +{ + struct ad7944_adc *adc = iio_priv(indio_dev); + int ret; + + switch (info) { + case IIO_CHAN_INFO_RAW: + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + + ret = ad7944_single_conversion(adc, chan, val); + iio_device_release_direct_mode(indio_dev); + return ret; + + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_VOLTAGE: + *val = adc->ref_mv; + *val2 = chan->scan_type.realbits; + + return IIO_VAL_FRACTIONAL_LOG2; + default: + return -EINVAL; + } + + default: + return -EINVAL; + } +} + +static const struct iio_info ad7944_iio_info = { + .read_raw = &ad7944_read_raw, +}; + +static irqreturn_t ad7944_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct ad7944_adc *adc = iio_priv(indio_dev); + int ret; + + ret = ad7944_4_wire_mode_conversion(adc, &indio_dev->channels[0]); + if (ret) + goto out; + + iio_push_to_buffers_with_timestamp(indio_dev, &adc->sample.raw, + indio_dev->scan_timestamp); + +out: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +static const char * const ad7944_power_supplies[] = { + "avdd", "dvdd", "bvdd", "vio" +}; + +static void ad7944_ref_disable(void *ref) +{ + regulator_disable(ref); +} + +static int ad7944_probe(struct spi_device *spi) +{ + const struct ad7944_chip_info *chip_info; + struct iio_dev *indio_dev; + struct ad7944_adc *adc; + struct regulator *ref; + const char *str_val; + int ret; + + /* adi,spi-mode property defaults to "4-wire" if not present */ + if (device_property_read_string(&spi->dev, "adi,spi-mode", &str_val) < 0) + str_val = "4-wire"; + + if (strcmp(str_val, "4-wire")) + return dev_err_probe(&spi->dev, -EINVAL, + "only \"4-wire\" mode is currently supported\n"); + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); + if (!indio_dev) + return -ENOMEM; + + adc = iio_priv(indio_dev); + adc->spi = spi; + + chip_info = spi_get_device_match_data(spi); + if (!chip_info) + return dev_err_probe(&spi->dev, -EINVAL, "no chip info\n"); + + adc->t = chip_info->t; + + /* + * Some chips use unusual word sizes, so check now instead of waiting + * for the first xfer. + */ + if (!spi_is_bpw_supported(spi, chip_info->channels[0].scan_type.realbits)) + return dev_err_probe(&spi->dev, -EINVAL, + "SPI host does not support %d bits per word\n", + chip_info->channels[0].scan_type.realbits); + + ret = devm_regulator_bulk_get_enable(&spi->dev, + ARRAY_SIZE(ad7944_power_supplies), + ad7944_power_supplies); + if (ret) + return dev_err_probe(&spi->dev, ret, + "failed to get and enable supplies\n"); + + /* adi,reference property defaults to "internal" if not present */ + if (device_property_read_string(&spi->dev, "adi,reference", &str_val) < 0) + str_val = "internal"; + + /* sort out what is being used for the reference voltage */ + if (strcmp(str_val, "internal") == 0) { + /* internal reference is used */ + adc->ref_mv = AD7944_INTERNAL_REF_MV; + } else if (strcmp(str_val, "internal-buffer") == 0) { + /* external 1.2V REFIN and internal buffer is used */ + ret = devm_regulator_get_enable_optional(&spi->dev, "refin"); + if (ret) + return dev_err_probe(&spi->dev, ret, + "failed to get and enable REFIN supply\n"); + + adc->ref_mv = AD7944_INTERNAL_REF_MV; + } else if (strcmp(str_val, "external") == 0) { + /* external reference is used */ + ref = devm_regulator_get_optional(&spi->dev, "ref"); + if (IS_ERR(ref)) + return dev_err_probe(&spi->dev, PTR_ERR(ref), + "failed to get REF supply\n"); + + ret = regulator_enable(ref); + if (ret) + return dev_err_probe(&spi->dev, ret, + "failed to enable REF supply\n"); + + ret = devm_add_action_or_reset(&spi->dev, + ad7944_ref_disable, ref); + if (ret) + return ret; + + ret = regulator_get_voltage(ref); + if (ret < 0) + return dev_err_probe(&spi->dev, ret, + "failed to get REF voltage\n"); + + adc->ref_mv = ret / 1000; + } else { + return dev_err_probe(&spi->dev, -EINVAL, + "invalid adi,reference property: %s\n", + str_val); + } + + adc->cnv = devm_gpiod_get(&spi->dev, "cnv", GPIOD_OUT_LOW); + if (IS_ERR(adc->cnv)) + return dev_err_probe(&spi->dev, PTR_ERR(adc->cnv), + "failed to get CNV GPIO\n"); + + adc->turbo = devm_gpiod_get_optional(&spi->dev, "turbo", GPIOD_OUT_LOW); + if (IS_ERR(adc->turbo)) + return dev_err_probe(&spi->dev, PTR_ERR(adc->turbo), + "failed to get TURBO GPIO\n"); + + if (device_property_present(&spi->dev, "adi,always-turbo")) + adc->always_turbo = true; + + if (adc->turbo && adc->always_turbo) + return dev_err_probe(&spi->dev, -EINVAL, + "cannot have both turbo-gpios and adi,always-turbo\n"); + + indio_dev->name = chip_info->name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &ad7944_iio_info; + indio_dev->channels = chip_info->channels; + indio_dev->num_channels = ARRAY_SIZE(chip_info->channels); + + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, + iio_pollfunc_store_time, + ad7944_trigger_handler, NULL); + if (ret) + return ret; + + return devm_iio_device_register(&spi->dev, indio_dev); +} + +static const struct of_device_id ad7944_of_match[] = { + { .compatible = "adi,ad7944", .data = &ad7944_chip_info }, + { .compatible = "adi,ad7985", .data = &ad7985_chip_info }, + { .compatible = "adi,ad7986", .data = &ad7986_chip_info }, + { } +}; +MODULE_DEVICE_TABLE(of, ad7944_of_match); + +static const struct spi_device_id ad7944_spi_id[] = { + { "ad7944", (kernel_ulong_t)&ad7944_chip_info }, + { "ad7985", (kernel_ulong_t)&ad7985_chip_info }, + { "ad7986", (kernel_ulong_t)&ad7986_chip_info }, + { } + +}; +MODULE_DEVICE_TABLE(spi, ad7944_spi_id); + +static struct spi_driver ad7944_driver = { + .driver = { + .name = "ad7944", + .of_match_table = ad7944_of_match, + }, + .probe = ad7944_probe, + .id_table = ad7944_spi_id, +}; +module_spi_driver(ad7944_driver); + +MODULE_AUTHOR("David Lechner "); +MODULE_DESCRIPTION("Analog Devices AD7944 PulSAR ADC family driver"); +MODULE_LICENSE("GPL");