From patchwork Mon Jan 7 13:25:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Popa X-Patchwork-Id: 10750579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2D0413B4 for ; Mon, 7 Jan 2019 13:26:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91A01289F9 for ; Mon, 7 Jan 2019 13:26:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8375528A4F; Mon, 7 Jan 2019 13:26:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23554289F9 for ; Mon, 7 Jan 2019 13:26:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727935AbfAGN0N (ORCPT ); Mon, 7 Jan 2019 08:26:13 -0500 Received: from mail-eopbgr740042.outbound.protection.outlook.com ([40.107.74.42]:42336 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727159AbfAGN0M (ORCPT ); Mon, 7 Jan 2019 08:26:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OG7r/pTid2JeCeGdREFS7UVB9QBL6B6XyYCVIqQSxfk=; b=AFnwOnurU6qYDBEJSj94RuMCXsPNDoOyZp4pDTRp+1i9hwZeZBm7Yn61vlZCcyUE35nI0QrRXoLVrozuiKM0dOMiir6SXivq9ypy8fQXY8ok9sSQh7QATQzwhDpSwb7hpgLNejcCZNR1XCe8SVZvJ77zXXBbSbQTcSJw2mhGGZE= Received: from CY4PR03CA0073.namprd03.prod.outlook.com (2603:10b6:910:4d::14) by SN6PR03MB3504.namprd03.prod.outlook.com (2603:10b6:805:3f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.6; Mon, 7 Jan 2019 13:26:05 +0000 Received: from BL2NAM02FT046.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::208) by CY4PR03CA0073.outlook.office365.com (2603:10b6:910:4d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1495.6 via Frontend Transport; Mon, 7 Jan 2019 13:26:05 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BL2NAM02FT046.mail.protection.outlook.com (10.152.76.118) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1471.13 via Frontend Transport; Mon, 7 Jan 2019 13:26:05 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id x07DQ45h032734 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 7 Jan 2019 05:26:04 -0800 Received: from linux.ad.analog.com (10.32.224.122) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Mon, 7 Jan 2019 08:26:03 -0500 From: Stefan Popa To: CC: , , , , , , , Subject: [PATCH 1/2] iio: adc: Add AD7768-1 ADC basic support Date: Mon, 7 Jan 2019 15:25:36 +0200 Message-ID: <1546867536-4116-1-git-send-email-stefan.popa@analog.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(346002)(376002)(136003)(39860400002)(2980300002)(3190300001)(199004)(189003)(51416003)(316002)(2906002)(47776003)(476003)(2616005)(116002)(126002)(356004)(305945005)(486006)(48376002)(26005)(77096007)(186003)(8936002)(246002)(5660300001)(44832011)(4326008)(8676002)(50466002)(966005)(478600001)(426003)(72206003)(107886003)(106002)(50226002)(6916009)(106466001)(575784001)(6306002)(36756003)(336012)(7636002)(16586007)(14444005)(6666004)(4744004)(7696005)(2351001)(54906003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR03MB3504;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;BL2NAM02FT046;1:5vtyhs9PloOA7UcMhYcVc/NxYS/l0duhUnMis3/y2kGwmfiPB3/QKI+rpu+WWTtU/Ck+8EV4nFH5iiFf4quVv9uJ2ZD9/Xz1g/q6oLLbwgPRBkJuYRC1Mx9f/E8D0dEY X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c9590a72-7088-43c3-e970-08d674a3ad3e X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4608076)(4709027)(2017052603328)(7153060);SRVR:SN6PR03MB3504; X-Microsoft-Exchange-Diagnostics: 1;SN6PR03MB3504;3:q+SMFvnQUU9tSY/BIYs7pzhC2leYQrWgirLLPHTrDtPgbHPeGuIo91YqGcrhkNkb24MGAbKBL0kQPUQwIdDNp1Zuk5AjU3DQB6WjZvWGK4Y6jow+pqZnx3rcFxdUUkjwJb5TOTZW7h2GjgRpF1zdrE4EPiv8mAuMlOxqKjmDas6TyKVlFUsc5XR1qqzkBMh9VuoFvRcseZdUB6WOdOcrbIx2uu7AjPMuZAUe7OZSPjEzgfRXs9pZ8tTGxegEyoHzOTfb3x2x7OEYbZ9CbcBKCLcu9V+IXAIUTwSxliP0KZFIgOezQe2LxWD9+OqYzzSWdCuXQGV+9SnGdf6ONExe9XTykxYOfHIpE8ST8jBNkBjUNnZnTG4UMgBrjUplcQ38;25:6vs4vFjkvAKIhdY/LKWgBV9qWvwIwmhWZSdLqWMn9ApFvLN+be0zto9h+VKv9GECw3efTR2mAzKqauckfywYgQm3yC6gvgAG+mDOZZUlmxxhIzyTEX5a331xnMW3fM0VJ1sMkzZGds6CdiKKlxjx4/aaijeygs4igwC9U5rJYwfVcez980hcKCjSnOXlH+/uFJeJzcaH51VOgDBKGfIo4kzabaZhhVk9yaLNoEa5oGaUAyXlzet+EbZ6Wz9LsK83OTMaNCeootcDmDodpwupISq+pwQQ/KvSP66y541eG3CUYGngu0gvWWR2IE8Rp9m2tr3y5agcBM8G5STDRU2qAg== X-MS-TrafficTypeDiagnostic: SN6PR03MB3504: X-Microsoft-Exchange-Diagnostics: 1;SN6PR03MB3504;31:5beAEKMivLaAtxLfTIpJ1hqpaFoi1aCOPIjrpOuwBbkT+D8QyhLnhkCiIqcQ2goIwmzRz+msB5brOK1CP7I6tGxQ2MYI1GJ9qoHvwlEKJAnzdowMd9EYAZrADRnlWbMjz/8H76qNHdbhCtPOQvDVBeVG1GQlPWjmuxvE/fEOFiIVXOqND8a34QP4pIxsS3sTYYcmJMH1znvyGmT9IzdfABlm8u7BXoXxunOupA1VqWI=;20:Zs1QQulBs/Ha3U25lD++nuSknqpaDqLkMyqovrbcnSSEWwlDsAclSooEIlbzqWHkbXnXBT79pqGgIA2Zf5D+TvEruotXrTvVO9FLAWkbjNPnIaP9Xt6tp8XcGSf1zZH8WcYQkFIJ7rqSIgh3NN2q5Py2GlhQzfT+bVFOp2QgUd0835rsszGw4I5RI1CicjIoWd2Ox3HdXVSU7WHsvY2lH6t35GWESUAFXYByu/T1DiwVZCozRZZ1IYSc3Dv42MsYC/CmiMXgVCr4wpQ4uXWtFLbCygLlHz3KlICAjrlx4Iidfo5hhCnJQGBaWtttEeTY6QLjAMLmASasufjzFPhqiFiXA0/i3ouucM1x+YgMdIx85Hp8E0r8eJgmmfJTuz3K1ximrRDFTlG9DotgxTg54vuZutnyRtmrGBsmfe+kDlYZUzNOvTPXt+xqarRNVeX9F4AQjdflGle7I3vmiWKPoeq3tjmb67f0/WWUDbY63UFMNTUEFcswun0DvaIH1vqR X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(8220060)(2401047)(8121501046)(10201501046)(93006095)(93004095)(3231475)(944501520)(4982022)(52105112)(3002001)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(201708071742011)(7699051)(76991095);SRVR:SN6PR03MB3504;BCL:0;PCL:0;RULEID:;SRVR:SN6PR03MB3504; X-Microsoft-Exchange-Diagnostics: 1;SN6PR03MB3504;4:bVaj0zlLPrKoJb0Ir4CJVBwS0xHWq7g5PLQsVjHXytU4I95lctCihyWfgs6trcH5doUd0nVu0WaYav1gs9TWC0DWf5Y4xPveSMyLZJsnp7+lRjB4OrT10/zLM2dLZZ0mZzCSRSo1sKChL9iLwUqi5p25swbxfrbCzISw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OEzVIsIUwE/7U4gk+Z3aHYL8FJb+VBAPtnv6THa08Exiz6ri1s5sHIF1O9MvhxhiwQTneFy9EQ==;5:tGrdxd3hF8gE9QCNbVF31OCfpitWH6oX0Bw2ORLZ/Bmr5avTRGpE8h4zvNQ7lOSzM6cvcwJj6fqwM9ZbhJMndTI91EGLcrqhsC3oq9N5Jiux+0+qX1mbSw6zeSNr7HI9/FjrLwXMfzHZB+TwcV5SDjC/q97gqrn0i2LGvpoomeUWXgjaqY9s8sHKwEmRptHdHMF2B8ovWhTK5VL/VCH4aw==;7:f7rgcX3LTCGUN0sgb2UuUspxSPm1+PQHpQOZj3qOvTRXfEknedVQIJPfCN+VSH54mGWv4vZkMLDmQZQ/w9mPfb4ruVx6BydMG0SFGITe0wAnq9Y89FennaoHouHdlTBFNU9X5XSMUA9g3C9R2GTTHQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2019 13:26:05.3638 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9590a72-7088-43c3-e970-08d674a3ad3e X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.55];Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB3504 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ad7768-1 is a single channel, precision 24-bit analog to digital converter (ADC). This basic patch configures the device in fast mode, with 32 kSPS and leaves the default sinc5 filter. Two data conversion modes are made available. When data is retrieved by using the read_raw attribute, one shot single conversion mode is set. The continuous conversion mode is enabled when the triggered buffer mechanism is used. To assure correct data retrieval, the driver waits for the interrupt triggered by the low to high transition of the DRDY pin. Datasheets: Link: https://www.analog.com/media/en/technical-documentation/data-sheets/ad7768-1.pdf Signed-off-by: Stefan Popa --- MAINTAINERS | 7 + drivers/iio/adc/Kconfig | 13 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7768-1.c | 474 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 495 insertions(+) create mode 100644 drivers/iio/adc/ad7768-1.c diff --git a/MAINTAINERS b/MAINTAINERS index d039f66..3ba3811 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -862,6 +862,13 @@ S: Supported F: drivers/iio/adc/ad7606.c F: Documentation/devicetree/bindings/iio/adc/ad7606.txt +ANALOG DEVICES INC AD7768-1 DRIVER +M: Stefan Popa +L: linux-iio@vger.kernel.org +W: http://ez.analog.com/community/linux-device-drivers +S: Supported +F: drivers/iio/adc/ad7768-1.c + ANALOG DEVICES INC AD9389B DRIVER M: Hans Verkuil L: linux-media@vger.kernel.org diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index f3cc7a3..6c19dfe 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -108,6 +108,19 @@ config AD7766 To compile this driver as a module, choose M here: the module will be called ad7766. +config AD7768_1 + tristate "Analog Devices AD7768-1 ADC driver" + depends on SPI + select IIO_BUFFER + select IIO_TRIGGER + select IIO_TRIGGERED_BUFFER + help + Say yes here to build support for Analog Devices AD7768-1 SPI + simultaneously sampling sigma-delta analog to digital converter (ADC). + + To compile this driver as a module, choose M here: the module will be + called ad7768-1. + config AD7791 tristate "Analog Devices AD7791 ADC driver" depends on SPI diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index ea50313..9d50f7b 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o obj-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o obj-$(CONFIG_AD7606) += ad7606.o obj-$(CONFIG_AD7766) += ad7766.o +obj-$(CONFIG_AD7768_1) += ad7768-1.o obj-$(CONFIG_AD7791) += ad7791.o obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7887) += ad7887.o diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c new file mode 100644 index 0000000..7ba98d603 --- /dev/null +++ b/drivers/iio/adc/ad7768-1.c @@ -0,0 +1,474 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Analog Devices AD7768-1 SPI ADC driver + * + * Copyright 2017 Analog Devices Inc. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +/* AD7768 registers definition */ +#define AD7768_REG_CHIP_TYPE 0x3 +#define AD7768_REG_PROD_ID_L 0x4 +#define AD7768_REG_PROD_ID_H 0x5 +#define AD7768_REG_CHIP_GRADE 0x6 +#define AD7768_REG_SCRATCH_PAD 0x0A +#define AD7768_REG_VENDOR_L 0x0C +#define AD7768_REG_VENDOR_H 0x0D +#define AD7768_REG_INTERFACE_FORMAT 0x14 +#define AD7768_REG_POWER_CLOCK 0x15 +#define AD7768_REG_ANALOG 0x16 +#define AD7768_REG_ANALOG2 0x17 +#define AD7768_REG_CONVERSION 0x18 +#define AD7768_REG_DIGITAL_FILTER 0x19 +#define AD7768_REG_SINC3_DEC_RATE_MSB 0x1A +#define AD7768_REG_SINC3_DEC_RATE_LSB 0x1B +#define AD7768_REG_DUTY_CYCLE_RATIO 0x1C +#define AD7768_REG_SYNC_RESET 0x1D +#define AD7768_REG_GPIO_CONTROL 0x1E +#define AD7768_REG_GPIO_WRITE 0x1F +#define AD7768_REG_GPIO_READ 0x20 +#define AD7768_REG_OFFSET_HI 0x21 +#define AD7768_REG_OFFSET_MID 0x22 +#define AD7768_REG_OFFSET_LO 0x23 +#define AD7768_REG_GAIN_HI 0x24 +#define AD7768_REG_GAIN_MID 0x25 +#define AD7768_REG_GAIN_LO 0x26 +#define AD7768_REG_SPI_DIAG_ENABLE 0x28 +#define AD7768_REG_ADC_DIAG_ENABLE 0x29 +#define AD7768_REG_DIG_DIAG_ENABLE 0x2A +#define AD7768_REG_ADC_DATA 0x2C +#define AD7768_REG_MASTER_STATUS 0x2D +#define AD7768_REG_SPI_DIAG_STATUS 0x2E +#define AD7768_REG_ADC_DIAG_STATUS 0x2F +#define AD7768_REG_DIG_DIAG_STATUS 0x30 +#define AD7768_REG_MCLK_COUNTER 0x31 + +/* AD7768_REG_CONVERSION */ +#define AD7768_CONV_MODE_MSK GENMASK(2, 0) +#define AD7768_CONV_MODE(x) FIELD_PREP(AD7768_CONV_MODE_MSK, x) + +#define AD7768_RD_FLAG_MSK(x) (BIT(6) | ((x) & 0x3F)) +#define AD7768_WR_FLAG_MSK(x) ((x) & 0x3F) + +enum ad7768_conv_mode { + AD7768_CONTINUOUS, + AD7768_ONE_SHOT, + AD7768_SINGLE, + AD7768_PERIODIC, + AD7768_STANDBY +}; + +enum ad7768_pwrmode { + AD7768_ECO_MODE, + AD7768_MED_MODE = 2, + AD7768_FAST_MODE +}; + +static const struct iio_chan_spec ad7768_channels[] = { + { + .type = IIO_VOLTAGE, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), + .indexed = 1, + .channel = 0, + .scan_index = 0, + .scan_type = { + .sign = 'u', + .realbits = 24, + .storagebits = 32, + .shift = 8, + .endianness = IIO_BE, + }, + }, +}; + +struct ad7768_state { + struct spi_device *spi; + struct regulator *vref; + struct mutex lock; + struct completion completion; + struct iio_trigger *trig; + __be16 d16; + __be32 d32; +}; + +enum ad7768_ids { + ID_AD7768_1, +}; + +static int ad7768_spi_reg_read(struct ad7768_state *st, unsigned int addr, + unsigned int len) +{ + struct spi_transfer t[] = { + { + .tx_buf = &st->d16, + .len = 1, + .cs_change = 0, + }, { + .rx_buf = &st->d32, + .len = len, + }, + }; + unsigned int shift; + int ret; + + shift = 32 - (8 * len); + + st->d16 = cpu_to_be16((AD7768_RD_FLAG_MSK(addr) << 8)); + + ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); + if (ret < 0) + return ret; + + return (be32_to_cpu(st->d32) >> shift); +} + +static int ad7768_spi_reg_write(struct ad7768_state *st, + unsigned int addr, + unsigned int val) +{ + st->d16 = cpu_to_be16((AD7768_WR_FLAG_MSK(addr) << 8) | + (val & 0xFF)); + + return spi_write(st->spi, &st->d16, sizeof(st->d16)); +} + +static int ad7768_set_mode(struct ad7768_state *st, + enum ad7768_conv_mode mode) +{ + int regval; + + regval = ad7768_spi_reg_read(st, AD7768_REG_CONVERSION, 1); + if (regval < 0) + return regval; + + regval &= ~AD7768_CONV_MODE_MSK; + regval |= AD7768_CONV_MODE(mode); + + return ad7768_spi_reg_write(st, AD7768_REG_CONVERSION, regval); +} + +static int ad7768_scan_direct(struct iio_dev *indio_dev) +{ + struct ad7768_state *st = iio_priv(indio_dev); + int readval, ret; + + reinit_completion(&st->completion); + + ret = ad7768_set_mode(st, AD7768_ONE_SHOT); + if (ret < 0) + return ret; + + ret = wait_for_completion_timeout(&st->completion, + msecs_to_jiffies(1000)); + if (!ret) + return -ETIMEDOUT; + + readval = ad7768_spi_reg_read(st, AD7768_REG_ADC_DATA, 3); + if (readval < 0) + return readval; + /* + * Any SPI configuration of the AD7768-1 can only be + * performed in continuous conversion mode. + */ + ret = ad7768_set_mode(st, AD7768_CONTINUOUS); + if (ret < 0) + return ret; + + return readval; +} + +static int ad7768_reg_access(struct iio_dev *indio_dev, + unsigned int reg, + unsigned int writeval, + unsigned int *readval) +{ + struct ad7768_state *st = iio_priv(indio_dev); + int ret; + + mutex_lock(&st->lock); + if (readval) { + ret = ad7768_spi_reg_read(st, reg, 1); + if (ret < 0) + goto err_unlock; + *readval = ret; + ret = 0; + } else { + ret = ad7768_spi_reg_write(st, reg, writeval); + } +err_unlock: + mutex_unlock(&st->lock); + + return ret; +} + +static int ad7768_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long info) +{ + struct ad7768_state *st = iio_priv(indio_dev); + int scale_uv, ret; + + switch (info) { + case IIO_CHAN_INFO_RAW: + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + + ret = ad7768_scan_direct(indio_dev); + if (ret == 0) + *val = ret; + + iio_device_release_direct_mode(indio_dev); + if (ret < 0) + return ret; + + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + scale_uv = regulator_get_voltage(st->vref); + if (scale_uv < 0) + return scale_uv; + + *val = (scale_uv * 2) / 1000; + *val2 = chan->scan_type.realbits; + + return IIO_VAL_FRACTIONAL_LOG2; + } + + return -EINVAL; +} + +static const struct iio_info ad7768_info = { + .read_raw = &ad7768_read_raw, + .debugfs_reg_access = &ad7768_reg_access, +}; + +static int ad7768_setup(struct ad7768_state *st) +{ + int ret; + + /* + * Two writes to the SPI_RESET[1:0] bits are required to initiate + * a software reset. The bits must first be set to 11, and then + * to 10. When the sequence is detected, the reset occurs. + * See the datasheet, page 70. + */ + ret = ad7768_spi_reg_write(st, AD7768_REG_SYNC_RESET, 0x3); + if (ret) + return ret; + + ret = ad7768_spi_reg_write(st, AD7768_REG_SYNC_RESET, 0x2); + if (ret) + return ret; + + /* Set power mode to fast */ + return ad7768_spi_reg_write(st, AD7768_REG_POWER_CLOCK, + AD7768_FAST_MODE); +} + +static irqreturn_t ad7768_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct ad7768_state *st = iio_priv(indio_dev); + struct spi_transfer t[] = { + { + .rx_buf = &st->d32, + .len = 3, + }, + }; + int ret; + + mutex_lock(&st->lock); + + ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); + if (ret < 0) + goto err_unlock; + + iio_push_to_buffers_with_timestamp(indio_dev, &st->d32, + iio_get_time_ns(indio_dev)); + + iio_trigger_notify_done(indio_dev->trig); +err_unlock: + mutex_unlock(&st->lock); + + return IRQ_HANDLED; +} + +static irqreturn_t ad7768_interrupt(int irq, void *dev_id) +{ + struct iio_dev *indio_dev = dev_id; + struct ad7768_state *st = iio_priv(indio_dev); + + if (iio_buffer_enabled(indio_dev)) + iio_trigger_poll_chained(st->trig); + else + complete(&st->completion); + + return IRQ_HANDLED; +}; + +static int ad7768_buffer_postenable(struct iio_dev *indio_dev) +{ + struct ad7768_state *st = iio_priv(indio_dev); + + iio_triggered_buffer_postenable(indio_dev); + /* + * Write a 1 to the LSB of the INTERFACE_FORMAT register to enter + * continuous read mode. Subsequent data reads do not require an + * initial 8-bit write to query the ADC_DATA register. + */ + return ad7768_spi_reg_write(st, AD7768_REG_INTERFACE_FORMAT, 0x01); +} + +static int ad7768_buffer_predisable(struct iio_dev *indio_dev) +{ + struct ad7768_state *st = iio_priv(indio_dev); + int ret; + + /* + * To exit continuous read mode, perform a single read of the ADC_DATA + * reg (0x2C), which allows further configuration of the device. + */ + ret = ad7768_spi_reg_read(st, AD7768_REG_ADC_DATA, 3); + if (ret < 0) + return ret; + + return iio_triggered_buffer_predisable(indio_dev); +} + +static const struct iio_buffer_setup_ops ad7768_buffer_ops = { + .postenable = &ad7768_buffer_postenable, + .predisable = &ad7768_buffer_predisable, +}; + +static const struct iio_trigger_ops ad7768_trigger_ops = { + .validate_device = iio_trigger_validate_own_device, +}; + +static void ad7768_regulator_disable(void *data) +{ + struct ad7768_state *st = data; + + regulator_disable(st->vref); +} + +static int ad7768_probe(struct spi_device *spi) +{ + struct ad7768_state *st; + struct iio_dev *indio_dev; + int ret; + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + st = iio_priv(indio_dev); + st->spi = spi; + + st->vref = devm_regulator_get(&spi->dev, "vref"); + if (IS_ERR(st->vref)) + return PTR_ERR(st->vref); + + ret = regulator_enable(st->vref); + if (ret) { + dev_err(&spi->dev, "Failed to enable specified vref supply\n"); + return ret; + } + + ret = devm_add_action_or_reset(&spi->dev, ad7768_regulator_disable, st); + if (ret) + return ret; + + spi_set_drvdata(spi, indio_dev); + mutex_init(&st->lock); + + indio_dev->channels = ad7768_channels; + indio_dev->num_channels = ARRAY_SIZE(ad7768_channels); + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->info = &ad7768_info; + indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_TRIGGERED; + + ret = ad7768_setup(st); + if (ret < 0) { + dev_err(&spi->dev, "AD7768 setup failed\n"); + return ret; + } + + st->trig = devm_iio_trigger_alloc(&spi->dev, "%s-dev%d", + indio_dev->name, indio_dev->id); + if (!st->trig) + return -ENOMEM; + + st->trig->ops = &ad7768_trigger_ops; + st->trig->dev.parent = &spi->dev; + iio_trigger_set_drvdata(st->trig, indio_dev); + ret = devm_iio_trigger_register(&spi->dev, st->trig); + if (ret) + return ret; + + indio_dev->trig = iio_trigger_get(st->trig); + + init_completion(&st->completion); + + ret = devm_request_threaded_irq(&spi->dev, spi->irq, + NULL, + &ad7768_interrupt, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, + indio_dev->name, indio_dev); + if (ret) + return ret; + + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, + &iio_pollfunc_store_time, + &ad7768_trigger_handler, + &ad7768_buffer_ops); + if (ret) + return ret; + + return devm_iio_device_register(&spi->dev, indio_dev); +} + +static const struct spi_device_id ad7768_id_table[] = { + { "ad7768-1", ID_AD7768_1 }, + {} +}; +MODULE_DEVICE_TABLE(spi, ad7768_id_table); + +static const struct of_device_id ad7768_of_match[] = { + { .compatible = "adi,ad7768-1" }, + { }, +}; +MODULE_DEVICE_TABLE(of, ad7768_of_match); + +static struct spi_driver ad7768_driver = { + .driver = { + .name = "ad7768-1", + .of_match_table = ad7768_of_match, + }, + .probe = ad7768_probe, + .id_table = ad7768_id_table, +}; +module_spi_driver(ad7768_driver); + +MODULE_AUTHOR("Stefan Popa "); +MODULE_DESCRIPTION("Analog Devices AD7768-1 ADC driver"); +MODULE_LICENSE("GPL"); From patchwork Mon Jan 7 13:26:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Popa X-Patchwork-Id: 10750581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2905C13B4 for ; Mon, 7 Jan 2019 13:27:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16B6D28A38 for ; Mon, 7 Jan 2019 13:27:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0ACD428A5B; Mon, 7 Jan 2019 13:27:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E62B28A38 for ; Mon, 7 Jan 2019 13:27:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728151AbfAGN1K (ORCPT ); Mon, 7 Jan 2019 08:27:10 -0500 Received: from mail-eopbgr820073.outbound.protection.outlook.com ([40.107.82.73]:14091 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727147AbfAGN1I (ORCPT ); Mon, 7 Jan 2019 08:27:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+fXXnQlYTTE+LBv45EZ3ykFQDtxPvJJ7XUebSfBA7fk=; b=vICCcLDnvAL2PenuvfuIJQBkgalM3JvKUwpn7IEX9XcuQ/SFpQX28V54hpcbw1YuNVsJh3cCmJiDjA2xC8wYjK3NcsSAFSQ7T0izQGA2DGqxqKQh/GMouxRh/kitQaZ5ayRoa29gklQb54oi8vekT2MK3desoBELXx59eNlLtdk= Received: from BN8PR03CA0025.namprd03.prod.outlook.com (2603:10b6:408:94::38) by BL0PR03MB4257.namprd03.prod.outlook.com (2603:10b6:208:6b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.6; Mon, 7 Jan 2019 13:27:02 +0000 Received: from CY1NAM02FT024.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::207) by BN8PR03CA0025.outlook.office365.com (2603:10b6:408:94::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1495.6 via Frontend Transport; Mon, 7 Jan 2019 13:27:02 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.57) smtp.mailfrom=analog.com; gmx.de; dkim=none (message not signed) header.d=none;gmx.de; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.57 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.57; helo=nwd2mta2.analog.com; Received: from nwd2mta2.analog.com (137.71.25.57) by CY1NAM02FT024.mail.protection.outlook.com (10.152.74.210) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1471.13 via Frontend Transport; Mon, 7 Jan 2019 13:27:01 +0000 Received: from NWD2HUBCAS7.ad.analog.com (nwd2hubcas7.ad.analog.com [10.64.69.107]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id x07DR0sI026827 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 7 Jan 2019 05:27:00 -0800 Received: from linux.ad.analog.com (10.32.224.122) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Mon, 7 Jan 2019 08:26:59 -0500 From: Stefan Popa To: , CC: , , , , , , , , , Subject: [PATCH 2/2] dt-bindings: iio: adc: Add docs for AD7768-1 Date: Mon, 7 Jan 2019 15:26:49 +0200 Message-ID: <1546867609-4273-1-git-send-email-stefan.popa@analog.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(39860400002)(136003)(376002)(346002)(2980300002)(3190300001)(189003)(199004)(356004)(6666004)(478600001)(7696005)(336012)(316002)(110136005)(51416003)(4326008)(54906003)(6306002)(16586007)(47776003)(7636002)(305945005)(186003)(116002)(77096007)(106002)(5660300001)(7416002)(966005)(72206003)(26005)(36756003)(8936002)(50466002)(48376002)(246002)(126002)(8676002)(44832011)(486006)(50226002)(106466001)(2906002)(107886003)(476003)(426003)(2616005);DIR:OUT;SFP:1101;SCL:1;SRVR:BL0PR03MB4257;H:nwd2mta2.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail11.analog.com;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;CY1NAM02FT024;1:BDP0C/YXxrn1CkMgzSd/TjpqF6JIHLi4iG+ZJFSmXqQGus3ipSD9nxYiijqhZwxXn9bdXp37vAsF7mVmZK6p2SLmb90VVnPkAlHvzUhwUhOwZEm0pMjGYP/B/CDmrpCg X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2ddaa30d-1096-4b7a-4b0d-08d674a3cecf X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600109)(711020)(4608076)(4709027)(2017052603328)(7153060);SRVR:BL0PR03MB4257; X-Microsoft-Exchange-Diagnostics: 1;BL0PR03MB4257;3:Ef+plt6eJEBx3pTvNM4nrCT4xqPLboKY4223ycYRhxqUuJzw1MjysWiQcRFec068aYPM4VNBAxdl7qb3VixDjR/u5IouVO4DwHw7oyRgVRmn/MJU98k0X1eVnKXjikPwZc4KBlCyIG/r//HZanii5Ioz30eVFSrV86JGUp8Du0tXb2b8eITuNQge7KPxz4C29aAhyDy/soqfXLW+CuBB3Gg8NvTm1Y+AYoApgW2vF7uuV3fKbAad9p6BQ9n/VYnUqwdeuSE+CURmPW48OmMVQKSAsgIvgc+xaxoEQVwY1Pehp9zCu7Ik0lMf6O/WLCYp4wzc5Fbb3oMArxjMn7FVA6ADdL8g1rj/LzNs/WCfPotGth+2H9mmyFsuHonMuuCw;25:Ey8+P6bXttBWr70gm3JYtQkHuGDkh/mUJkHl4ZkI+BENlnMtFxikSh5hne4VSqunwK67zh8XJ/1csKQjxCD3v9l4xmqHr0BlXFT6EEDs6XGr6JKSc2mwQgLNwAUAFjb1K6QYhWsxUyG+ge8M1XNUV8oKWq+yKw1lyJvKmhakiApd5fXtLusGWgZC1Ljj4oHrUVFcSMLgTFDRbhi+8LrY7m/X0rBigr5Cg3ixt40E68vWGALvnaF1dQuRJuE6wmSF9VBx6hC7+hx17iSusBzyMIbaqfGcomPNahUDlRUXqHfYuZaUm6hRWlGXISQMTV4L46HcxQsdFcNTwF76ld/20A== X-MS-TrafficTypeDiagnostic: BL0PR03MB4257: X-Microsoft-Exchange-Diagnostics: 1;BL0PR03MB4257;31:bHWh7rKz8Ct6rPl+3wWkRaiDKxSOIfUTeZxysXmVKWXomv1oY+fg0a4NdmGFvsH/6gVqVBTZ6VK8+oU8srO4gOBPvYOb7AXrnp8IBqnp2/c2TwkHdj0iWwgQvdJa/dnWg+xIARpG017r2WhNMsbn1Od5GnesMApQbWD+Kju0dd8jIC7C4pRSnZp505PZhvlUhVOgN+TlIsH23GqZljjeYzGGjU6AeXwqrkZcLnSzf3Q=;20:ZK3Yc2Ccz23qM52zwgGPixpTbu4xsZXJjHTKReHmrsf5ZJfhVPxMS+DgmfnRWvPXyzGKMw7l9hAIozWwRL72nLFf8NFOv2G2TYQ04g/pkbaLq9BXH9kbe1oeLX9nQlGJQGu+zDM1i4gLYjl13Eso0+oJLyUPoOWAisuoQyn/WSLPQ5dJbJcSNVRNfmrBquY8lcUeDTrJ3rjBiuH2A2BhmqNvZQkCv5xoE8hfw/qLGnkL1PvvU0Va5qOvjTRYVcO6Q6RfdfXTrwtVP8i205IDumq93DbKrc6b4VIrnbmfeI5lNujuOL7IgmBxdkWsmYlMdHL4DbBRayqcua7jhYcC18LHfvurEW5MAKGFQ+wZtf9UrPZAElDyUps2hQxP+KR/Qntv2H4Y/zUX6G5KP7AqLfQTM2hgH8WB0906acq+DGERIEZDGLjoL7gyUN7dJUFC3JFyM3M7C/bwteYEUlOm6diCCx4Td+Tbv63LTgFBxoLOpLB5+1yn2o3OHSGeYfmn X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(8220060)(2401047)(8121501046)(10201501046)(3002001)(93006095)(93004095)(3231475)(944501520)(4982022)(52105112)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699051)(76991095);SRVR:BL0PR03MB4257;BCL:0;PCL:0;RULEID:;SRVR:BL0PR03MB4257; X-Microsoft-Exchange-Diagnostics: 1;BL0PR03MB4257;4:TEUMha9zrIsXL05SR6CNqpkCRH5/28NaiG8JhJelHbw2n68ZzC/jGQ4KKdcz2gp2a/GhEhl1+vO/rfbp4+TrZ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wbV/t5qPxWmN4zYggAT7nJWVDgrPSK5Zp8lUaSgq5LwJlJA8Upnadqu5vVdSMyuXxwYD0URDhvgi0QsaMBhb6m4kMnd1ygon5Kug==;5:zT5Jz7+m7v2WlPEWD0yTXp8iy9Ixrqmaaiu/nRkMSwKQ/ouEiABzB5b2VB04fO5SSSaONI8fb1HuaJfkSdd+PeEnjSdiS7WEN9TD/Tb6tznA+b4TwmydrZ29DKRIqYCLYh7hVKmZsvbGf0DNm2GQ+Z1q110baO9ok61MtaKZ39BQ8+H905UFFQ9mE+GrhIsYVNBMGdRbJuV0DMBXFiwBEA==;7:mDlyYnGjexajkHBESdUa0p3I84EIqesBxF6itoVnzKljqRxlogDmgXgUrJ7Osf13CQKVfbsS40c1nj96WH02GkFZti60+FvDlK4WppcxZKZf8K/xa9xsCGIVvt/NYup1B/9GLxe+M6QpTXUrM918RQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2019 13:27:01.1592 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ddaa30d-1096-4b7a-4b0d-08d674a3cecf X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta2.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR03MB4257 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Document support for AD7768-1 Analog to Digital Converter. Signed-off-by: Stefan Popa --- .../devicetree/bindings/iio/adc/adi,ad7768-1.txt | 34 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.txt diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.txt b/Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.txt new file mode 100644 index 0000000..bf619fa8 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.txt @@ -0,0 +1,34 @@ +Analog Devices AD7768-1 ADC device driver + +Required properties for the AD7768-1: + +- compatible: Must be "adi,ad7768-1" +- reg: SPI chip select number for the device +- spi-max-frequency: Max SPI frequency to use + see: Documentation/devicetree/bindings/spi/spi-bus.txt +- clocks: phandle to the master clock (mclk) + see: Documentation/devicetree/bindings/clock/clock-bindings.txt +- clock-names: Must be "mclk". +- interrupts: IRQ line for the ADC + see: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt +- vref-supply: vref supply can be used as reference for conversion +- adi,sync-in-gpios: must be the device tree identifier of the SYNC-IN pin. A pulse + is always required if the configuration is changed in any way, for example + if the filter decimation rate changes. As the line is active low, it should + be marked GPIO_ACTIVE_LOW. + +Example: + + adc@0 { + compatible = "adi,ad7768-1"; + reg = <0>; + spi-max-frequency = <2000000>; + spi-cpol; + spi-cpha; + vref-supply = <&adc_vref>; + interrupts = <25 IRQ_TYPE_EDGE_RISING>; + interrupt-parent = <&gpio>; + adi,sync-in-gpios = <&gpio 22 GPIO_ACTIVE_LOW>; + clocks = <&ad7768_mclk>; + clock-names = "mclk"; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 3ba3811..e5613b6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -868,6 +868,7 @@ L: linux-iio@vger.kernel.org W: http://ez.analog.com/community/linux-device-drivers S: Supported F: drivers/iio/adc/ad7768-1.c +F: Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.txt ANALOG DEVICES INC AD9389B DRIVER M: Hans Verkuil