X-Received: by 2002:a17:906:79c4:b0:6cf:5489:da57 with SMTP id m4-20020a17090679c400b006cf5489da57mr671111ejo.48.1645638713697; Wed, 23 Feb 2022 09:51:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645638713; cv=none; d=google.com; s=arc-20160816; b=M/B6+Ddu5qsYvIzScqIgikz9R9SBWVJKGYgCUqdiwj+J9cpM3qTsaRx/Gim41s9vSW B7cfKi0QM+WfYuoVAotgm85h0kZKlAVfTs+miyjlxdJOtp/GcO2VGQHtErj58CcIC/w/ HaKwdOeklyPfCPTnndtaie9DmrKGdv7X/4ffpcQ8CYPHLVM8fCpJLFd1ZldqzjoXhU0D hYSkK2lWCE9TNkvQKKzygH3xXgIBmxNChiRLYW6Ob7w9eTCXbHu4B8Jo2ikx76l2rw+1 3rOvBaBHaBGpdRgxPgCjXKwGht1+iUs0hzEiY13blLue4XSPnZo7w8L6RNonkaWWvM/z XMqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=MCt65LTa8zW6DS3Nb8ZpZQR8g7aGxwmOYcejdqUg5PU=; b=fEpVFBprGzntgWqHSRL/+F+9FennTtt3hAy3xvPGbfvL0z8k3MeWPYXw1J5FQilBMq X2psrykevFfbJ4gTzgYEMFeE4UAN3LqEAZvmA6OwCWxbWL0AdGoa/KnX1Q6ONOYE8bxa mx33DVGTdeCugvuDD/l6M2L8eX0pWXnT37iqV40cEx81DxroKU77o1vdXcMfe0I7cc6g m5xC8YdWYTmboN4pLBaxLEDljcYFBtCkULqGCMhtpeF4UQTebJjLAqmiu/r79MLkkaO/ xiDQwQvOXVG0O7yX87ClvIdfWc0Ot967oeMBIqMFhaQdkcXiFp14Z6cjjyXRIaw3R6qB hrig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hZjKkv1g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 2si116341ejl.719.2022.02.23.09.51.30; Wed, 23 Feb 2022 09:51:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hZjKkv1g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242904AbiBWQge (ORCPT + 99 others); Wed, 23 Feb 2022 11:36:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242896AbiBWQgc (ORCPT ); Wed, 23 Feb 2022 11:36:32 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D8F656C06; Wed, 23 Feb 2022 08:35:52 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id e13so1557745plh.3; Wed, 23 Feb 2022 08:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MCt65LTa8zW6DS3Nb8ZpZQR8g7aGxwmOYcejdqUg5PU=; b=hZjKkv1gvycJnJIzNRcDfYHHryzx2OGSF8uprtAAuYsdshuAIWZUHki2WcHYGKurH6 2IPxLjvUxQYkcQESkbga/T0NZaGW4kiU2SKyu5rVIpQTW5zThLGODxhfsO6mLrK9amik VwZk1+01aRfsjb7UD3NWqVj6CpHn1K3DZDllQfiw1dM8DyKaHwwbSJejSWSR9dVD18gV fvhHfO6SYGzP73YcbCx75PaHdDJp84Q8JHRqd5RsNhfBzP471/yWbsUUuIDM1hjpzpyc M87GyigX3YXmrzaa4ZRET7vGGj9vI6KCQMe+NfWYKFItZQm1eTpy3qCTRViVGqqO8zMC oO0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MCt65LTa8zW6DS3Nb8ZpZQR8g7aGxwmOYcejdqUg5PU=; b=PLiktwDIfQ/6LQPUdU996jKqylMLnM0TSL1HgxNq7CGVO1DwB762rGOKvpTeb9UMfI nWETMRYtDDdAxq2WtQJxfc7XmSK1rq/e9lyWQ4uy85G7WN+E0Ono30eEJYkyec6/xDyN InmUCdmeQJjZ2AhboVE8YCtBu2cp34wJb0nbrkvc22wpp0623pgAbbYdFuqFGP0SFf0U 0Egc4GR4PAqUuN4C1O7e0vrsb1rXO+8brMczFsk0LgR8n6SHD77Du6grntoLGf0h1are 51x3MtjqDoIsUj/d+kptXjQAJyxb5jS5c936p6/CA2W5Ft/X/q5NDNL0h+RCyFQ/X4Gq wV1w== X-Gm-Message-State: AOAM531fflG5u56UBx1ooHCVw/7WIjwb+1UBUgp/JUczVDVZGNcKmC4A yVtCiHW4O033pBvoBFRbwOa1m9qJtZd48GMc X-Received: by 2002:a17:902:a98b:b0:14f:ae28:c660 with SMTP id bh11-20020a170902a98b00b0014fae28c660mr431352plb.94.1645634152030; Wed, 23 Feb 2022 08:35:52 -0800 (PST) Received: from localhost.localdomain ([27.7.190.133]) by smtp.gmail.com with ESMTPSA id q93-20020a17090a4fe600b001b9ba2a1dc3sm3455106pjh.25.2022.02.23.08.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 08:35:51 -0800 (PST) From: Jagath Jog J To: jic23@kernel.org, lars@metafoo.de, andy.shevchenko@gmail.com, sst@poczta.fm, robh+dt@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 6/7] iio: potentiometer: Add support for Maxim DS3502 Date: Wed, 23 Feb 2022 22:05:24 +0530 Message-Id: <20220223163525.13399-7-jagathjog1996@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220223163525.13399-1-jagathjog1996@gmail.com> References: <20220223163525.13399-1-jagathjog1996@gmail.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The DS3502 is a 7-bit, nonvolatile digital potentiometer featuring an output voltage range of up to 15.5V. DS3502 support is added into existing DS1803 driver. Datasheet: https://datasheets.maximintegrated.com/en/ds/DS3502.pdf Signed-off-by: Jagath Jog J --- drivers/iio/potentiometer/Kconfig | 6 ++--- drivers/iio/potentiometer/ds1803.c | 37 +++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/drivers/iio/potentiometer/Kconfig b/drivers/iio/potentiometer/Kconfig index 832df8da2bc6..01dd3f858d99 100644 --- a/drivers/iio/potentiometer/Kconfig +++ b/drivers/iio/potentiometer/Kconfig @@ -27,11 +27,11 @@ config AD5272 module will be called ad5272. config DS1803 - tristate "Maxim Integrated DS1803 Digital Potentiometer driver" + tristate "Maxim Integrated DS1803 and similar Digital Potentiometer driver" depends on I2C help - Say yes here to build support for the Maxim Integrated DS1803 - digital potentiometer chip. + Say yes here to build support for the Maxim Integrated DS1803 and + DS3502 digital potentiometer chip. To compile this driver as a module, choose M here: the module will be called ds1803. diff --git a/drivers/iio/potentiometer/ds1803.c b/drivers/iio/potentiometer/ds1803.c index 878188351f8f..81456b7d314b 100644 --- a/drivers/iio/potentiometer/ds1803.c +++ b/drivers/iio/potentiometer/ds1803.c @@ -1,12 +1,15 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Maxim Integrated DS1803 digital potentiometer driver + * Maxim Integrated DS1803 and similar digital potentiometer driver * Copyright (c) 2016 Slawomir Stepien + * Copyright (c) 2022 Jagath Jog J * * Datasheet: https://datasheets.maximintegrated.com/en/ds/DS1803.pdf + * Datasheet: https://datasheets.maximintegrated.com/en/ds/DS3502.pdf * * DEVID #Wipers #Positions Resistor Opts (kOhm) i2c address * ds1803 2 256 10, 50, 100 0101xxx + * ds3502 1 128 10 01010xx */ #include @@ -19,11 +22,13 @@ #define DS1803_WIPER_0 0xA9 #define DS1803_WIPER_1 0xAA +#define DS3502_WR_IVR 0x00 enum ds1803_type { DS1803_010, DS1803_050, DS1803_100, + DS3502, }; struct ds1803_cfg { @@ -57,6 +62,10 @@ static const struct iio_chan_spec ds1803_channels[] = { DS1803_CHANNEL(1, DS1803_WIPER_1), }; +static const struct iio_chan_spec ds3502_channels[] = { + DS1803_CHANNEL(0, DS3502_WR_IVR), +}; + static int ds1803_read(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val) @@ -73,6 +82,21 @@ static int ds1803_read(struct iio_dev *indio_dev, return ret; } +static int ds3502_read(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val) +{ + struct ds1803_data *data = iio_priv(indio_dev); + int ret; + + ret = i2c_smbus_read_byte_data(data->client, chan->address); + if (ret < 0) + return ret; + + *val = ret; + return ret; +} + static const struct ds1803_cfg ds1803_cfg[] = { [DS1803_010] = { .wipers = 2, @@ -98,6 +122,14 @@ static const struct ds1803_cfg ds1803_cfg[] = { .num_channels = ARRAY_SIZE(ds1803_channels), .read = ds1803_read, }, + [DS3502] = { + .wipers = 1, + .avail = { 0, 1, 127 }, + .kohms = 10, + .channels = ds3502_channels, + .num_channels = ARRAY_SIZE(ds3502_channels), + .read = ds3502_read, + }, }; static int ds1803_read_raw(struct iio_dev *indio_dev, @@ -199,6 +231,7 @@ static const struct of_device_id ds1803_dt_ids[] = { { .compatible = "maxim,ds1803-010", .data = &ds1803_cfg[DS1803_010] }, { .compatible = "maxim,ds1803-050", .data = &ds1803_cfg[DS1803_050] }, { .compatible = "maxim,ds1803-100", .data = &ds1803_cfg[DS1803_100] }, + { .compatible = "maxim,ds3502", .data = &ds1803_cfg[DS3502] }, {} }; MODULE_DEVICE_TABLE(of, ds1803_dt_ids); @@ -207,6 +240,7 @@ static const struct i2c_device_id ds1803_id[] = { { "ds1803-010", DS1803_010 }, { "ds1803-050", DS1803_050 }, { "ds1803-100", DS1803_100 }, + { "ds3502", DS3502 }, {} }; MODULE_DEVICE_TABLE(i2c, ds1803_id); @@ -223,5 +257,6 @@ static struct i2c_driver ds1803_driver = { module_i2c_driver(ds1803_driver); MODULE_AUTHOR("Slawomir Stepien "); +MODULE_AUTHOR("Jagath Jog J "); MODULE_DESCRIPTION("DS1803 digital potentiometer"); MODULE_LICENSE("GPL v2"); -- 2.17.1