Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10711819imu; Thu, 6 Dec 2018 05:41:08 -0800 (PST) X-Google-Smtp-Source: AFSGD/W125gwxh/b7e/7crUanGmwVwNZ2vU+SferrvsyB+seVDkx8gUz7OKz7b1FFpKY9aQnogF1 X-Received: by 2002:a63:d005:: with SMTP id z5mr24129517pgf.64.1544103668753; Thu, 06 Dec 2018 05:41:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544103668; cv=none; d=google.com; s=arc-20160816; b=yaTbUlw449YXHHfdefKYiFKRQGzQ3zRvtnw4MP3/p1goF1f0GOHTk9anUPVwnrYGRf 13mD40iYTDSFr3Dj0yM89CaRg4dAQT67/rvnpn6dKURkvBk1b6KHBjW4r1qfr2cmFltX qbHjKmRpIuLFrgWFGnLroFiZRKhwt8FDePI8EZbEikG/GlbCIwt0F+Ca6O/On/Q51Bb5 NEXkpjvXTlGVz67wcAAD1GT8MG2Yo8zFsLh+j3O7085OB1o0KHNTUuzaO8Hnid0GJumn DzkidcwSLDRWl92B+/cvSYNGUfdlv0tH5qt5yJ0ENKrVC3UfhmqxlqTCgHQSmpXULFL9 fi7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=3nmJeZCSQ30hmEDeE5BlneD7y6oJs6tWIk726jgwzmY=; b=VVicRjeTYxTB/LgozOq8p2HhILV4xfEI27J+tv0ckCq3ZXMwd82RlZIiYwRp8jXHbv iOQEamkfard0zhqIZKljhHEhzEgKymiOLpjiujhT+BGunYS4KWc6tV7DHVKKux081FDP arWLr6ibrPqcI+BHhziYsXtSiBb+8eQ9oWT09vuhlutRFSBe3Xriquvr2Lx5QVQAAupW XlXvE1IpTZl3GBjZRT2ujZWwAJfmZC49XACcy9u0H7cORaq/icQZtxX3lvlQXGa/j9GC hZHydIpXtDBeNDPza7m8WXkP8K8IIdsG9mOZRAc0vEHhd1FEP6iUh2T2aLDJjJaW58Xj GjCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@analog.onmicrosoft.com header.s=selector1-analog-com header.b=m03G2K0k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q16si305022pfh.138.2018.12.06.05.40.51; Thu, 06 Dec 2018 05:41:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@analog.onmicrosoft.com header.s=selector1-analog-com header.b=m03G2K0k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728797AbeLFNip (ORCPT + 99 others); Thu, 6 Dec 2018 08:38:45 -0500 Received: from mail-eopbgr710065.outbound.protection.outlook.com ([40.107.71.65]:46720 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727704AbeLFNip (ORCPT ); Thu, 6 Dec 2018 08:38:45 -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=3nmJeZCSQ30hmEDeE5BlneD7y6oJs6tWIk726jgwzmY=; b=m03G2K0k0tbCPtpVhGy7s+ChzoHxDhkbs1DYgLUBdjAzUMdrbPbrfD1ljWfgTVREG1mWepKO7Q1kE4kCWN/vuMEwE/aF7DOr8WwG2ZyYjDq8SvjGPPAIue8PoPITO21M6dRfmAtbDScAFDSY2tEvkCjOcIZhyXHqryq4qFVEH3Y= Received: from BN6PR03CA0094.namprd03.prod.outlook.com (2603:10b6:405:6f::32) by BL2PR03MB546.namprd03.prod.outlook.com (2a01:111:e400:c24::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.20; Thu, 6 Dec 2018 13:38:41 +0000 Received: from BY2FFO11FD008.protection.gbl (2a01:111:f400:7c0c::129) by BN6PR03CA0094.outlook.office365.com (2603:10b6:405:6f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1404.19 via Frontend Transport; Thu, 6 Dec 2018 13:38:41 +0000 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 BY2FFO11FD008.mail.protection.outlook.com (10.1.14.159) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1404.13 via Frontend Transport; Thu, 6 Dec 2018 13:38:40 +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 wB6Dcdwg022544 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Thu, 6 Dec 2018 05:38:39 -0800 Received: from mircea-Latitude-E6540.analog.com (10.50.1.101) by NWD2HUBCAS7.ad.analog.com (10.64.69.107) with Microsoft SMTP Server id 14.3.408.0; Thu, 6 Dec 2018 08:38:39 -0500 From: Mircea Caprioru To: CC: , , , , , , , , Stefan Popa , "Mircea Caprioru" Subject: [PATCH] iio:dac:ad5686: Add AD5310R support Date: Thu, 6 Dec 2018 15:38:30 +0200 Message-ID: <20181206133830.20488-1-mircea.caprioru@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain 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)(346002)(396003)(376002)(39860400002)(136003)(2980300002)(189003)(199004)(2906002)(246002)(6306002)(14444005)(478600001)(53416004)(7696005)(72206003)(86362001)(8676002)(6346003)(106466001)(26005)(107886003)(2351001)(77096007)(5660300001)(186003)(7636002)(47776003)(316002)(54906003)(1076002)(966005)(4326008)(50466002)(44832011)(6916009)(51416003)(305945005)(486006)(48376002)(6666004)(356004)(426003)(16586007)(50226002)(2616005)(8936002)(36756003)(336012)(106002)(476003)(126002);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2PR03MB546;H:nwd2mta1.analog.com;FPR:;SPF:Pass;LANG:en;PTR:nwd2mail10.analog.com;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD008;1:BI31W0+2MwA3cBCxl+Z8p3HxX9aobB+Or2RLmLPr5mIbpC3mccTsEPj7aUBlc2REEDxsZH4qKiohRkulnm8sTbAifn0rGYpODDO15QJDyWG/ndK+e00teGzHTKZ/p0YQ X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9bf7846a-75e8-4373-dddf-08d65b802252 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:BL2PR03MB546; X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB546;3:IYAyZWPv43qUaS0wUC5N9GyMMgTciMZ+knjubr/EuHY/czfbxtfVn1gult1XKA2wQJW8oSC3ynjih2fGOTRVcr0bUpFQxG+KcQoVH+JuOiLl9bI7sANHogC8piUF1R6WkF0GnY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gyuHrm/0UAuD9VerIDLbMwSdVl15Ifj62YNqcxTFz7Jw6NG61H2seUfsZu1UQfLPc3dNMREPluQOfau73kA92lrUdmnTdDe/zVCC4aCOAj5/FBCf4MkkVm2HHcIGungtWtDpzdppr+AkvO/3pTw9/YGMxs9Ci92TgGSYYMG0yzpvFS/tLZRU44KC5h5ZjMbOkGXLKB7Wy222L6cfZp1pbOAdPs7RTO1y730b2sHf5mZFfDXYENRFY6QRlpyczbjVSPRhNE5BSNoRzokozDE4p8cor8T1j3A+UCsjdk8SM1YTzmFewtSY/YxY X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231455)(999002)(944501520)(4982022)(52105112)(93006095)(93004095)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BL2PR03MB546;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB546; X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB546;4:gz4gDGMgYla5uHO/p7HCrT24zTQe9fApoEcpAcAeRbtx+JPuBKRp33KWJ8LCWjacXXbPyCJw2JnRnwpIB/TUnk6pEPx/0uy+ZX9PBBIOvDTKNguamWBPewNT0nLbEuVR+hKz6FJuA7DzPGmp1z9KX2WKoT/+1t2gMbK7/x1eT55p68vlhtkf9VidTOOvA8yJFpgVJUsO/XU7MGsdCt3FcRMSRauueh/dXLCZA77cCVArNs2VLp/QmoEZme4OzYoIKLNGBmLa22eHm3PbkqZA8w== X-Forefront-PRVS: 087894CD3C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2PR03MB546;23:VWXQuhChxsuF1EfMD32gjJsfo03cRDfkY/tmOjiwt6?= =?us-ascii?Q?FupZIg0HGPhILzzSNeW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fGbDA+5bLm4So6HF6rjH6KyqhQT8NoENw2RSxZ3b5snN578gVA8RCxs2nq1/T7KKSzKoVrUR5yWg==;5:3bn8QcQIj+UT1K5xvRQ93Hcz/jL065G+Nzmsi85Dh3pI+g8tFA7pgNEH+CgaexdRIK3EQ9FbA8R+i4OPufJzcFh+ZXwE3Om5bdPF5UCaR7qW7LrsJ8pzFcQeJMDF3yDk1Qmb47PvdYq7PlcwsIBXW68sgDSiw7iMC5HnW1WO69g=;7:0ZO5OxMJmlCkqprkVNqI59S+Tll5PqSYeruRQx7ezk0CSMFp0QvcNU7/qfN0DjY7uJalPaCzpeZ7mPb28oE5+s+UhR67NJh5A5yN5jxrsCdmTiJ6+odMiFzXG/DT0R/yddoR17kvRYBb+Lp3zQJWKA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2018 13:38:40.6332 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9bf7846a-75e8-4373-dddf-08d65b802252 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: BL2PR03MB546 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Popa The AD5310R is a single channel DAC with 10-bit precision, which is part of the same family as AD5311R, except that it uses the spi interface instead of i2c. The device has a built-in 2.5V reference which is enabled by default. Another important difference is that the SPI write command operation is 16 bits long. The first four bits represent the command, while the remaining 12 bits are for data. In the control reg, DB9 and DB10 are used for power-down modes, while DB8 is the REF bit. In order to accommodate this change, a new regmap type was defined and checked accordingly. Because AD5310R does not have a readback register, the read_raw operation will return "Operation is not supported". Datasheet: Link: http://www.analog.com/media/en/technical-documentation/data-sheets/AD5310R_5311R.pdf Signed-off-by: Stefan Popa Signed-off-by: Mircea Caprioru --- drivers/iio/dac/ad5686-spi.c | 21 ++++++++++++++++++--- drivers/iio/dac/ad5686.c | 16 ++++++++++++++++ drivers/iio/dac/ad5686.h | 7 +++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index 1df9143f55e9..665fa6bd9ced 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -19,6 +19,12 @@ static int ad5686_spi_write(struct ad5686_state *st, u8 tx_len, *buf; switch (st->chip_info->regmap_type) { + case AD5310_REGMAP: + st->data[0].d16 = cpu_to_be16(AD5310_CMD(cmd) | + val); + buf = &st->data[0].d8[0]; + tx_len = 2; + break; case AD5683_REGMAP: st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) | AD5683_DATA(val)); @@ -56,10 +62,18 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 addr) u8 cmd = 0; int ret; - if (st->chip_info->regmap_type == AD5686_REGMAP) - cmd = AD5686_CMD_READBACK_ENABLE; - else if (st->chip_info->regmap_type == AD5683_REGMAP) + switch (st->chip_info->regmap_type) { + case AD5310_REGMAP: + return -ENOTSUPP; + case AD5683_REGMAP: cmd = AD5686_CMD_READBACK_ENABLE_V2; + break; + case AD5686_REGMAP: + cmd = AD5686_CMD_READBACK_ENABLE; + break; + default: + return -EINVAL; + } st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) | AD5686_ADDR(addr)); @@ -86,6 +100,7 @@ static int ad5686_spi_remove(struct spi_device *spi) } static const struct spi_device_id ad5686_spi_id[] = { + {"ad5310r", ID_AD5310R}, {"ad5672r", ID_AD5672R}, {"ad5676", ID_AD5676}, {"ad5676r", ID_AD5676R}, diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 0e134b13967a..54ff76b93366 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -83,6 +83,10 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, st->pwr_down_mask &= ~(0x3 << (chan->channel * 2)); switch (st->chip_info->regmap_type) { + case AD5310_REGMAP: + shift = 9; + ref_bit_msk = AD5310_REF_BIT_MSK; + break; case AD5683_REGMAP: shift = 13; ref_bit_msk = AD5683_REF_BIT_MSK; @@ -221,6 +225,7 @@ static struct iio_chan_spec name[] = { \ AD5868_CHANNEL(7, 7, bits, _shift), \ } +DECLARE_AD5693_CHANNELS(ad5310r_channels, 10, 2); DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6); DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4); DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0); @@ -232,6 +237,12 @@ DECLARE_AD5693_CHANNELS(ad5692r_channels, 14, 2); DECLARE_AD5693_CHANNELS(ad5691r_channels, 12, 4); static const struct ad5686_chip_info ad5686_chip_info_tbl[] = { + [ID_AD5310R] = { + .channels = ad5310r_channels, + .int_vref_mv = 2500, + .num_channels = 1, + .regmap_type = AD5310_REGMAP, + }, [ID_AD5311R] = { .channels = ad5311r_channels, .int_vref_mv = 2500, @@ -419,6 +430,11 @@ int ad5686_probe(struct device *dev, indio_dev->num_channels = st->chip_info->num_channels; switch (st->chip_info->regmap_type) { + case AD5310_REGMAP: + cmd = AD5686_CMD_CONTROL_REG; + ref_bit_msk = AD5310_REF_BIT_MSK; + st->use_internal_vref = !voltage_uv; + break; case AD5683_REGMAP: cmd = AD5686_CMD_CONTROL_REG; ref_bit_msk = AD5683_REF_BIT_MSK; diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 57b3c61bfb91..19f6917d4738 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -13,7 +13,10 @@ #include #include +#define AD5310_CMD(x) ((x) << 12) + #define AD5683_DATA(x) ((x) << 4) + #define AD5686_ADDR(x) ((x) << 16) #define AD5686_CMD(x) ((x) << 20) @@ -38,6 +41,8 @@ #define AD5686_CMD_CONTROL_REG 0x4 #define AD5686_CMD_READBACK_ENABLE_V2 0x5 + +#define AD5310_REF_BIT_MSK BIT(8) #define AD5683_REF_BIT_MSK BIT(12) #define AD5693_REF_BIT_MSK BIT(12) @@ -45,6 +50,7 @@ * ad5686_supported_device_ids: */ enum ad5686_supported_device_ids { + ID_AD5310R, ID_AD5311R, ID_AD5671R, ID_AD5672R, @@ -72,6 +78,7 @@ enum ad5686_supported_device_ids { }; enum ad5686_regmap_type { + AD5310_REGMAP, AD5683_REGMAP, AD5686_REGMAP, AD5693_REGMAP -- 2.17.1