From patchwork Wed Nov 20 14:47:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11254033 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0F9913A4 for ; Wed, 20 Nov 2019 14:49:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D05DD20872 for ; Wed, 20 Nov 2019 14:49:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qN8TZxtq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731066AbfKTOtW (ORCPT ); Wed, 20 Nov 2019 09:49:22 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46713 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728049AbfKTOtW (ORCPT ); Wed, 20 Nov 2019 09:49:22 -0500 Received: by mail-wr1-f67.google.com with SMTP id b3so48201wrs.13 for ; Wed, 20 Nov 2019 06:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JjokDUYttILXu1Ard3/OhbVu0xrFQleV/PAtkmHmq8o=; b=qN8TZxtqMHnM8MJqi/wvebI4aZLmggzgMIyQ5Q2SanFmH3Vfd11b2QHFBhLmXjnIvj WjixZqcgZRUyRYxq6n6f9PAUUjMudKYPKIO8On4RtFszrcJNUIORNCocfVsBdpz7mnYh j4X6eRvVQCkLHG3iCkQSGT0UjcheEdUcC7ekLwWLt1OqUcPLxWIqnuxH8P9ESfXeO8dC 2pYDUVr3kL2QWSWektkLZDfAllex4Y+RAddnHvnfGDyD+GZA9PxTow7cWy01eUd+08wl GMGtEtWK4EyU1KLGxG3XT6Ly8Hp+1zchzd4UizEJ/RB0apPs+azq8JMkOKJchTMLVCcE qdZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JjokDUYttILXu1Ard3/OhbVu0xrFQleV/PAtkmHmq8o=; b=lRvZ4FlFKAutGdgocWxybE4IpA+z4tifhBs+4zhwfUKaPma2tWu+kJFAJ4ycvcjyhU elnwAmDj+/uy/FDA4TnM6gugkDMNjUNWEEo3zGtky1IEnZqBV7GD/sLJSxsc/xyHD/5O +bTaL4Rcc6qVxUcB5Ik+m1vfIy8qo2mepvfex3pq79rKlcitQTMW+mdDslSkrG7lUwnW D73AJJy43qQjAZ1iGB4l7dDfyHdCHTb6dq9ziCkM5JeA/SAM90WIiVf+rT9f1eL+aFfE ZcjKkM+mjjyadOrvtpjQyTZXPdSq7659ZcdH32hWn3vAsa7jWUiDJALUymfDdqdJPINf MSDQ== X-Gm-Message-State: APjAAAU6BsMUBm/wafhrsPXetQHf0w/OLXovRTGnsDH0EhXQctaePI1R WN3yyuC2m8fC4ofVwkX3RsE= X-Google-Smtp-Source: APXvYqwTKmyAbq1FpZgjLAzL6oW8ZJf5QafyChrwfYm/hlKODKaDCbkVfdbVHXhzzEWspYPzH28S0w== X-Received: by 2002:a05:6000:12c4:: with SMTP id l4mr3739211wrx.110.1574261359636; Wed, 20 Nov 2019 06:49:19 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id b2sm5822120wrr.76.2019.11.20.06.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:49:18 -0800 (PST) From: Andrea Merello To: jic23@kernel.org Cc: Andrea Merello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Colin Ian King , Patrick Havelange , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v3 1/9] iio: max31856: add option for setting mains filter rejection frequency Date: Wed, 20 Nov 2019 15:47:48 +0100 Message-Id: <20191120144756.28424-2-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120144756.28424-1-andrea.merello@gmail.com> References: <20191111153517.13862-1-andrea.merello@gmail.com> <20191120144756.28424-1-andrea.merello@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This sensor has an embedded notch filter for reducing interferences caused by the power mains. This filter can be tuned to reject either 50Hz or 60Hz (and harmonics). Currently the said setting is left alone (the sensor defaults to 60Hz). This patch introduces a IIO attribute that allows the user to set the said filter to the desired frequency. NOTE: this has been intentionally not tied to any DT property to allow the configuration of this setting from userspace, e.g. with a GUI or by reading a configuration file, or maybe reading a GPIO tied to a physical switch or accessing some device that can autodetect the line frequency. Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Colin Ian King Cc: Patrick Havelange Cc: Matt Weber Cc: Matt Ranostay Cc: Chuhong Yuan Cc: Daniel Gomez Cc: linux-iio@vger.kernel.org Signed-off-by: Andrea Merello Reviewed-by: Matt Ranostay --- drivers/iio/temperature/max31856.c | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/iio/temperature/max31856.c b/drivers/iio/temperature/max31856.c index 73ed550e3fc9..d97ba9ee1598 100644 --- a/drivers/iio/temperature/max31856.c +++ b/drivers/iio/temperature/max31856.c @@ -23,6 +23,7 @@ #define MAX31856_CR0_1SHOT BIT(6) #define MAX31856_CR0_OCFAULT BIT(4) #define MAX31856_CR0_OCFAULT_MASK GENMASK(5, 4) +#define MAX31856_CR0_FILTER_50HZ BIT(0) #define MAX31856_TC_TYPE_MASK GENMASK(3, 0) #define MAX31856_FAULT_OVUV BIT(1) #define MAX31856_FAULT_OPEN BIT(0) @@ -63,6 +64,7 @@ static const struct iio_chan_spec max31856_channels[] = { struct max31856_data { struct spi_device *spi; u32 thermocouple_type; + bool filter_50hz; }; static int max31856_read(struct max31856_data *data, u8 reg, @@ -123,6 +125,11 @@ static int max31856_init(struct max31856_data *data) reg_cr0_val &= ~MAX31856_CR0_1SHOT; reg_cr0_val |= MAX31856_CR0_AUTOCONVERT; + if (data->filter_50hz) + reg_cr0_val |= MAX31856_CR0_FILTER_50HZ; + else + reg_cr0_val &= ~MAX31856_CR0_FILTER_50HZ; + return max31856_write(data, MAX31856_CR0_REG, reg_cr0_val); } @@ -249,12 +256,54 @@ static ssize_t show_fault_oc(struct device *dev, return show_fault(dev, MAX31856_FAULT_OPEN, buf); } +static ssize_t show_filter(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct max31856_data *data = iio_priv(indio_dev); + + return sprintf(buf, "%d\n", data->filter_50hz ? 50 : 60); +} + +static ssize_t set_filter(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct max31856_data *data = iio_priv(indio_dev); + unsigned int freq; + int ret; + + ret = kstrtouint(buf, 10, &freq); + if (ret) + return ret; + + switch (freq) { + case 50: + data->filter_50hz = true; + break; + case 60: + data->filter_50hz = false; + break; + default: + return -EINVAL; + } + + max31856_init(data); + return len; +} + static IIO_DEVICE_ATTR(fault_ovuv, 0444, show_fault_ovuv, NULL, 0); static IIO_DEVICE_ATTR(fault_oc, 0444, show_fault_oc, NULL, 0); +static IIO_DEVICE_ATTR(in_temp_filter_notch_center_frequency, 0644, + show_filter, set_filter, 0); static struct attribute *max31856_attributes[] = { &iio_dev_attr_fault_ovuv.dev_attr.attr, &iio_dev_attr_fault_oc.dev_attr.attr, + &iio_dev_attr_in_temp_filter_notch_center_frequency.dev_attr.attr, NULL, }; @@ -280,6 +329,7 @@ static int max31856_probe(struct spi_device *spi) data = iio_priv(indio_dev); data->spi = spi; + data->filter_50hz = false; spi_set_drvdata(spi, indio_dev); From patchwork Wed Nov 20 14:47:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11254035 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A797A1871 for ; Wed, 20 Nov 2019 14:49:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8774120731 for ; Wed, 20 Nov 2019 14:49:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kZ54j4MI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728049AbfKTOtX (ORCPT ); Wed, 20 Nov 2019 09:49:23 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39539 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730794AbfKTOtX (ORCPT ); Wed, 20 Nov 2019 09:49:23 -0500 Received: by mail-wr1-f66.google.com with SMTP id l7so107356wrp.6 for ; Wed, 20 Nov 2019 06:49:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dW+Z64oSlVI0UEL1kpDuI9nX6HWNagHFv6yFzU7lfsA=; b=kZ54j4MIcnixX+Jyj/zwgwTcJv8op1dzPr9PhED+vFvPQf5pZSZeoHUAcj+ej6gsIj /d+m9rfPPNcnrGpzNcUgcxzLO/T1Fqr/rwMsOKx66HsfCJhO8izvdjmpI0X/55PqH90x 97j+9MqjiVO9y8Fmc0DEjK+/vuF+AnCWR8BLAMj1i3+sbinAVK2iPErWRLWy/r4v86wy HhvIfqC0PUEXBrHetwyVbWD3YMNbw9Sq5H+hGn5DIfnk347e/McFkzMV5GozI9qu7zhJ 7kbdckrwwBfKMvlBd4IwMsrUliFLw6FICVvgqCba1loh+KB2J1vFSjYYvYjWS56R+CkR 1Xig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dW+Z64oSlVI0UEL1kpDuI9nX6HWNagHFv6yFzU7lfsA=; b=Vqi/6AGL3Loi8XOhn/YK/MA/m7DgraT3+MBqknv4kaNiy1QV7pH9T7UEavv2W9pK3T aPVUErgbA4/lztpGaae65ge5Ywpv15VgFKp88SleJr79zGigQIuYQdEmZ2O77Pbe3YDL xXHE+ZHP3dDpfFjrB6ZLg/TbyyX4LKqEW34uURYUDwzjMBculv3xagqtbiBhdaP9+8M4 R13GYX1YL6TD86TJzca77YxmRheybtJiKUI+K3EcY4uUM1DD4TsYwvUUYzw6cbrYhkQS bqg733A5VheQguohGycFoq5HYkIO9SZlwHaVOgrddwAfmMi7+rl8+oh1gyc3bpcQwcQ3 /0Hw== X-Gm-Message-State: APjAAAWtagK1pllXIUcFkQ9w4Nzk81SEx5RXrH8N8XNuGJqfqNy+2t/R 6xBHvuCJ5wfi9jSawfJ1udE= X-Google-Smtp-Source: APXvYqzeZh5CQ/NCYrYnSjkxNurSJjJjvk6DXnxhsGD8Y7m1T+u4Yvqy4kqcAlIZ19SweZiyVlXpvA== X-Received: by 2002:a5d:538d:: with SMTP id d13mr4027419wrv.304.1574261360745; Wed, 20 Nov 2019 06:49:20 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id b2sm5822120wrr.76.2019.11.20.06.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:49:20 -0800 (PST) From: Andrea Merello To: jic23@kernel.org Cc: Andrea Merello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Colin Ian King , Patrick Havelange , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v3 2/9] Documentation: ABI: document IIO in_temp_filter_notch_center_frequency file Date: Wed, 20 Nov 2019 15:47:49 +0100 Message-Id: <20191120144756.28424-3-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120144756.28424-1-andrea.merello@gmail.com> References: <20191111153517.13862-1-andrea.merello@gmail.com> <20191120144756.28424-1-andrea.merello@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org max31856 IIO driver introduced a new attribute "in_temp_filter_notch_center_frequency". This patch adds it to the list of documented ABI for sysfs-bus-iio Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Colin Ian King Cc: Patrick Havelange Cc: Matt Weber Cc: Matt Ranostay Cc: Chuhong Yuan Cc: Daniel Gomez Cc: linux-iio@vger.kernel.org Signed-off-by: Andrea Merello --- Documentation/ABI/testing/sysfs-bus-iio | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index faaa2166d741..94f7eb675108 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1726,3 +1726,10 @@ Contact: linux-iio@vger.kernel.org Description: List of valid periods (in seconds) for which the light intensity must be above the threshold level before interrupt is asserted. + +What: /sys/bus/iio/devices/iio:deviceX/in_filter_notch_center_frequency +KernelVersion: 5.5 +Contact: linux-iio@vger.kernel.org +Description: + Center frequency in Hz for a notch filter. Used i.e. for line + noise suppression. From patchwork Wed Nov 20 14:47:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11254043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B99CE138C for ; Wed, 20 Nov 2019 14:49:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9961D20714 for ; Wed, 20 Nov 2019 14:49:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bfRJs+XE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731296AbfKTOt1 (ORCPT ); Wed, 20 Nov 2019 09:49:27 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51228 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730794AbfKTOt1 (ORCPT ); Wed, 20 Nov 2019 09:49:27 -0500 Received: by mail-wm1-f68.google.com with SMTP id q70so7243884wme.1 for ; Wed, 20 Nov 2019 06:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n3e+Yxxp4U4zcH4iEUPGzxMAsFWhfr3JeTuPoN9dLqI=; b=bfRJs+XE6hYcmBKJnEBN3Nr+nvX372q7tJPoqC/Gh2zpuiXvtJscjbV58ejvbJ7AaM CLv2hug412ZhBDcN2DwB2PlCHpJ1pReYn0yvMEKoskjGYiKbRzUSs/1qhGgrJgiBPMOb ss0rP2hzA/5vgnV3+Vd0ufMPQnwzPLweWIrOyNNxzTvlSDWnU3Zv0uSNEbB7E9NDumxX 3+qJpAXVXvcMzF8O8QXR+0nzqT2iawA8A4soSGEnoyHw2IKDmTiYfqvfVsadfxSdItsw smino/v0qrGA1A0GXIV1bsOLbkhCZttApHg/AiadVP3HmHVZbWy44UN6lmhnP21j7I3E jmFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n3e+Yxxp4U4zcH4iEUPGzxMAsFWhfr3JeTuPoN9dLqI=; b=N0dy/3DBu/snm9gMNfmVHGVAlHVcFvJlaNyBEi+Crp9d8zYC3f3v6xv0zTXDHbvtt4 NsW9OvNIyM2r1n3POkPfT1TYTYBiGzPrxY6q32s6kAqjfssMsRya1eo4+nCpkpxdRSuA w9YCtjmhLBm4wpRh7XikbHS7FGqxwT41BPWkiaMcbz+/36YpWQSHi1rtllNTjPBOt50O oMRjsGtL0yXKZ9kMq48Kcxngedg/r6j/kAaPIpfxI0euZFZ4PKfifFbNb0yOgtbZhsZr on9/9UVLc4cse3UI/HBCSxaLGEsxXYcF04CAAt3gBnZZfMw3Rp19Bi+hWwujmurSDI31 5mPA== X-Gm-Message-State: APjAAAVPopEYqTBwygo3cdJAAqX4Wlu1Z3oncWUWK5LVMogecTqK/iYj /HdIEyv0EFrT8v6vmwU6vUk= X-Google-Smtp-Source: APXvYqwEqK+UIWFBBjY1EhiiTonIsCtjTGcD/xSFEx4D5p5GBaJtYrmMp4rvFom25PJWyA+FSw0Kpw== X-Received: by 2002:a05:600c:2919:: with SMTP id i25mr3588254wmd.158.1574261361934; Wed, 20 Nov 2019 06:49:21 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id b2sm5822120wrr.76.2019.11.20.06.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:49:21 -0800 (PST) From: Andrea Merello To: jic23@kernel.org Cc: Andrea Merello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Colin Ian King , Patrick Havelange , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v3 3/9] iio: max31856: add support for configuring the HW averaging Date: Wed, 20 Nov 2019 15:47:50 +0100 Message-Id: <20191120144756.28424-4-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120144756.28424-1-andrea.merello@gmail.com> References: <20191111153517.13862-1-andrea.merello@gmail.com> <20191120144756.28424-1-andrea.merello@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This sensor can perform samples averaging in hardware, but currently the driver leaves this setting alone (default is no averaging). This patch binds this HW setting to the "oversampling_ratio" IIO attribute and allows the user to set the averaging as desired (the HW supports averaging of 2, 5, 8 or 16 samples; in-between values are rounded up). Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Colin Ian King Cc: Patrick Havelange Cc: Matt Weber Cc: Matt Ranostay Cc: Chuhong Yuan Cc: Daniel Gomez Cc: linux-iio@vger.kernel.org Signed-off-by: Andrea Merello --- drivers/iio/temperature/max31856.c | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/iio/temperature/max31856.c b/drivers/iio/temperature/max31856.c index d97ba9ee1598..8457ca9ae326 100644 --- a/drivers/iio/temperature/max31856.c +++ b/drivers/iio/temperature/max31856.c @@ -12,6 +12,7 @@ #include #include #include +#include #include /* * The MSB of the register value determines whether the following byte will @@ -24,6 +25,8 @@ #define MAX31856_CR0_OCFAULT BIT(4) #define MAX31856_CR0_OCFAULT_MASK GENMASK(5, 4) #define MAX31856_CR0_FILTER_50HZ BIT(0) +#define MAX31856_AVERAGING_MASK GENMASK(6, 4) +#define MAX31856_AVERAGING_SHIFT 4 #define MAX31856_TC_TYPE_MASK GENMASK(3, 0) #define MAX31856_FAULT_OVUV BIT(1) #define MAX31856_FAULT_OPEN BIT(0) @@ -51,6 +54,8 @@ static const struct iio_chan_spec max31856_channels[] = { .type = IIO_TEMP, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_type = + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO) }, { /* Cold Junction Temperature */ .type = IIO_TEMP, @@ -58,6 +63,8 @@ static const struct iio_chan_spec max31856_channels[] = { .modified = 1, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_type = + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO) }, }; @@ -65,6 +72,7 @@ struct max31856_data { struct spi_device *spi; u32 thermocouple_type; bool filter_50hz; + int averaging; }; static int max31856_read(struct max31856_data *data, u8 reg, @@ -109,6 +117,10 @@ static int max31856_init(struct max31856_data *data) reg_cr1_val &= ~MAX31856_TC_TYPE_MASK; reg_cr1_val |= data->thermocouple_type; + + reg_cr1_val &= ~MAX31856_AVERAGING_MASK; + reg_cr1_val |= data->averaging << MAX31856_AVERAGING_SHIFT; + ret = max31856_write(data, MAX31856_CR1_REG, reg_cr1_val); if (ret) return ret; @@ -217,6 +229,9 @@ static int max31856_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT_PLUS_MICRO; } break; + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + *val = 1 << data->averaging; + return IIO_VAL_INT; default: ret = -EINVAL; break; @@ -225,6 +240,33 @@ static int max31856_read_raw(struct iio_dev *indio_dev, return ret; } +static int max31856_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct max31856_data *data = iio_priv(indio_dev); + int msb; + + switch (mask) { + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + if (val > 16 || val < 1) + return -EINVAL; + msb = fls(val) - 1; + /* Round up to next 2pow if needed */ + if (BIT(msb) < val) + msb++; + + data->averaging = msb; + max31856_init(data); + break; + + default: + return -EINVAL; + } + + return 0; +} + static ssize_t show_fault(struct device *dev, u8 faultbit, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); @@ -313,6 +355,7 @@ static const struct attribute_group max31856_group = { static const struct iio_info max31856_info = { .read_raw = max31856_read_raw, + .write_raw = max31856_write_raw, .attrs = &max31856_group, }; From patchwork Wed Nov 20 14:47:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11254039 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0045313A4 for ; Wed, 20 Nov 2019 14:49:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D4D74206F4 for ; Wed, 20 Nov 2019 14:49:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b+xYT7WV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731125AbfKTOtZ (ORCPT ); Wed, 20 Nov 2019 09:49:25 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39432 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729932AbfKTOtZ (ORCPT ); Wed, 20 Nov 2019 09:49:25 -0500 Received: by mail-wm1-f65.google.com with SMTP id t26so8119056wmi.4 for ; Wed, 20 Nov 2019 06:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kI+6z7y49c6+W2tZw/F82eQLktjdxraputejG6O/yos=; b=b+xYT7WVEbv9Otm7uYIaVc/U/SKtsCTG6O7qEgDOHmN+0EI4GOblIzttf/WZju4sSD V8iZe8Aeazq4vJLLFwYl/Fq2bbb9aFCPABrX2qEC595AF22vgbo9gYIYN0+nSMWMvq+U Tp9A86ECBQtCYFF9jaSGSKZGnkiIXJq4F52JYCNuGd/J/rXEZaosZecqFVNmuvOY1uGy UzmEIGUKs+57+Ry50jQ8ybWzG/TZzWUFqYckVdu50MhlDsDowCbXtP3tWlED9uf//hI+ ypQMIFK/xqoW8IMjvwTXNON3RrC9TBYcnIdoRqt0vwkL6bIYpMoDGt+i1K+d5wNJY143 Pieg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kI+6z7y49c6+W2tZw/F82eQLktjdxraputejG6O/yos=; b=PRoF30BU9kmHd335FPpJ2xCVBKENMbkbNkFdM/XXgNI/fGTlsq/uYjgTW0tKDPxBNc Uo4JPpmRWD+3NwcF9/Qvc1jk0q9h9tw5OutfRTmbCw8U9BapNcqQQrqSQnrQwvR6+OYt aMB0fA4OFu9BgGQ2P9GXfHr5PLIaphm+brHCSNzf7E71rqwgzD5fZbKpexlf9YOyei6L ueCnfV80qQcZg8Wo8+W+0QJO+2l5imGVMUcYQwLWaarCTjsMN60l6Z6XDXmvch+cfnTw RSaJSjzTtBE9+kQTcbzkdO2qwL+Tgnqohk1Jy/ATq+Q9UlAn97K7g3NBR2yoi8KAV7WZ znaw== X-Gm-Message-State: APjAAAWtgFXKYplu6lbw4naYnwyotYGHXI5S4xxN7fPmrUsCLU57KA+T l62iyoJsNPpYO8SIUuKmtSI= X-Google-Smtp-Source: APXvYqyA754sNmRl6zVbgNqLCDnQAPlj8lCFC/IQNwacCFN9hc/14702KqkTlIBun1Pz9Y50wX7s5w== X-Received: by 2002:a1c:16:: with SMTP id 22mr3865056wma.0.1574261362954; Wed, 20 Nov 2019 06:49:22 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id b2sm5822120wrr.76.2019.11.20.06.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:49:22 -0800 (PST) From: Andrea Merello To: jic23@kernel.org Cc: Andrea Merello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Colin Ian King , Patrick Havelange , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v3 4/9] RFC: iio: core: add char type for sysfs attributes Date: Wed, 20 Nov 2019 15:47:51 +0100 Message-Id: <20191120144756.28424-5-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120144756.28424-1-andrea.merello@gmail.com> References: <20191111153517.13862-1-andrea.merello@gmail.com> <20191120144756.28424-1-andrea.merello@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This patch introduces IIO_VAL_CHAR type for standard IIO attributes to allow for attributes that needs to be represented by character rather than a number. This is preparatory for introducing a new attribute whose purpose is to describe thermocouple type, that can be i.e. "J", "K", etc.. The char-type value is stored in the first "value" integer that is passed to the .[read/write]_raw() callbacks. Note that in order to make it possible for the IIO core to correctly parse this type (actually, to avoid integer parsing), it became mandatory for any driver that wish to use IIO_VAL_CHAR on a writable attribute to implement .write_raw_get_fmt(). Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Colin Ian King Cc: Patrick Havelange Cc: Matt Weber Cc: Matt Ranostay Cc: Chuhong Yuan Cc: Daniel Gomez Cc: linux-iio@vger.kernel.org Signed-off-by: Andrea Merello --- drivers/iio/industrialio-core.c | 22 ++++++++++++++++++---- include/linux/iio/types.h | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index f72c2dc5f703..958b5c48a86f 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -596,6 +596,8 @@ static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type, } return l; } + case IIO_VAL_CHAR: + return snprintf(buf, len, "%c", (char)vals[0]); default: return 0; } @@ -837,7 +839,8 @@ static ssize_t iio_write_channel_info(struct device *dev, struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); int ret, fract_mult = 100000; - int integer, fract; + int integer, fract = 0; + bool is_char = false; /* Assumes decimal - precision based on number of digits */ if (!indio_dev->info->write_raw) @@ -855,13 +858,24 @@ static ssize_t iio_write_channel_info(struct device *dev, case IIO_VAL_INT_PLUS_NANO: fract_mult = 100000000; break; + case IIO_VAL_CHAR: + is_char = true; + break; default: return -EINVAL; } - ret = iio_str_to_fixpoint(buf, fract_mult, &integer, &fract); - if (ret) - return ret; + if (is_char) { + char ch; + + if (sscanf(buf, "%c", &ch) != 1) + return -EINVAL; + integer = ch; + } else { + ret = iio_str_to_fixpoint(buf, fract_mult, &integer, &fract); + if (ret) + return ret; + } ret = indio_dev->info->write_raw(indio_dev, this_attr->c, integer, fract, this_attr->address); diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index fa824e160f35..8e0026da38c9 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -25,6 +25,7 @@ enum iio_event_info { #define IIO_VAL_INT_MULTIPLE 5 #define IIO_VAL_FRACTIONAL 10 #define IIO_VAL_FRACTIONAL_LOG2 11 +#define IIO_VAL_CHAR 12 enum iio_available_type { IIO_AVAIL_LIST, From patchwork Wed Nov 20 14:47:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11254041 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2437B13A4 for ; Wed, 20 Nov 2019 14:49:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 047F5206F4 for ; Wed, 20 Nov 2019 14:49:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ns3EXHNL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731140AbfKTOt0 (ORCPT ); Wed, 20 Nov 2019 09:49:26 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37790 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731027AbfKTOt0 (ORCPT ); Wed, 20 Nov 2019 09:49:26 -0500 Received: by mail-wm1-f67.google.com with SMTP id b17so8137369wmj.2 for ; Wed, 20 Nov 2019 06:49:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zkPpLeXVv17KBi+qQEqu0qt8LLruco7K41VlVb/OnZ4=; b=ns3EXHNLKAyigbcJYt3Sl//QwRtR3nhzvVF7UAvihlu7LdUXlRgYOHYhmyV+5AHHiY sgeqAlO/IzLfBsBJ1/lNBiY2qWV82xe/Sj47d9sb7f3nl5YUey3mKFSeDXxArMk/9bjy Zi4usijU53coj+3gZI7EaOecuOpJPFeREWBknL2SCtxNCh6miD2aNofwy0bCG8cEQaYX /FQQVgUh4p1vQOPH1e51GCIOUB7Rse05R5y9sHnL6TwexPIjMdiA0Qn7BmhiRiLBeXAW HGpCrCClvvFQonNpmcedj4hSmJn/O6wABSN3DU1dtsEt7R7ZKtHP3PeUv6ApK6F72lfx kmoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zkPpLeXVv17KBi+qQEqu0qt8LLruco7K41VlVb/OnZ4=; b=Jun3RabpVy2GNUVT+LBc7ILJZAYxzYxqB8J1wTJSJ9viOB9uKj6bvNiPFKhIzanv+4 nJT9AMwqrysWlNXdZIfiJHhEljrqLG+3iIDe3iy8DcP6tKgnZsVZHJQw4v6598FluR2O ZGUeHHLUe+4v6HBvsUWq9f0hEvmm7DDZO7Jfa10KmTaaLTBRzIPQtcXsLVEnGSAQl+GG ogywfB48t9yvPE5bfvj6RpV3QKq5dI3EQxfnIuv9IuGJYqWyKPV70NpSTEVpegFQaT+L EO9iNC5B3FH6XvbJhfHxZ161EJxDizlp1GnWePXnxJ56Hj124yn2St1vXlHjuw2VFgct hHtg== X-Gm-Message-State: APjAAAU7QVH9VJOeEak6krcU6GocXYyUwrsa6LIxTpDud0fYtdv0Gy44 KmQ1tCpqd3eU+ww0u1bWMhg= X-Google-Smtp-Source: APXvYqwMjmUiprvPfWErIS9FeTwtr/mfblG5GFT9IvRUD3K81HrhI6V9Jl6N22LaHvIVuGKZrhsQ1A== X-Received: by 2002:a1c:4c10:: with SMTP id z16mr3483999wmf.24.1574261364182; Wed, 20 Nov 2019 06:49:24 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id b2sm5822120wrr.76.2019.11.20.06.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:49:23 -0800 (PST) From: Andrea Merello To: jic23@kernel.org Cc: Andrea Merello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Colin Ian King , Patrick Havelange , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v3 5/9] iio: core: add thermocouple_type standard attribute Date: Wed, 20 Nov 2019 15:47:52 +0100 Message-Id: <20191120144756.28424-6-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120144756.28424-1-andrea.merello@gmail.com> References: <20191111153517.13862-1-andrea.merello@gmail.com> <20191120144756.28424-1-andrea.merello@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org We have a couple of thermocouple IIO drivers, supporting several chips. Some of them support only one specific thermocouple type (e.g. "K", "J"), one of them can be configured to work with several different thermocouple types. In certain applications thermocouples could be externally connected to the chip by the user. This patch introduces a new IIO standard attribute to report the supported thermocouple type and, where applicable, to allow it to be dynamically set using sysfs. Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Colin Ian King Cc: Patrick Havelange Cc: Matt Weber Cc: Matt Ranostay Cc: Chuhong Yuan Cc: Daniel Gomez Cc: linux-iio@vger.kernel.org Signed-off-by: Andrea Merello --- drivers/iio/industrialio-core.c | 1 + include/linux/iio/types.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 958b5c48a86f..fa2c3b321bfd 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -161,6 +161,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_DEBOUNCE_TIME] = "debounce_time", [IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity", [IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio", + [IIO_CHAN_INFO_THERMOCOUPLE_TYPE] = "thermocouple_type", }; /** diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index 8e0026da38c9..e6fd3645963c 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -58,6 +58,7 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_DEBOUNCE_TIME, IIO_CHAN_INFO_CALIBEMISSIVITY, IIO_CHAN_INFO_OVERSAMPLING_RATIO, + IIO_CHAN_INFO_THERMOCOUPLE_TYPE, }; #endif /* _IIO_TYPES_H_ */ From patchwork Wed Nov 20 14:47:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11254045 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B82613A4 for ; Wed, 20 Nov 2019 14:49:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7CEF320872 for ; Wed, 20 Nov 2019 14:49:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D4RW4tyv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729157AbfKTOt2 (ORCPT ); Wed, 20 Nov 2019 09:49:28 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:56136 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729932AbfKTOt1 (ORCPT ); Wed, 20 Nov 2019 09:49:27 -0500 Received: by mail-wm1-f65.google.com with SMTP id b11so7234110wmb.5 for ; Wed, 20 Nov 2019 06:49:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zdMYiFuOvyNlGLkZxBQQ30nIniyERoe33IWXlfbDnCs=; b=D4RW4tyvGi/OLqZZwZaS3AW2yybHCu4REsnd6l2QqtqxOg2PyU760s9uoojEAUelbQ 3Z6YFTCx2xuKHVmHD++3SAJlMXdLEMc9KXBt5LHfeBsqrC7nWiNSVT0bL8gLOOcVoJdV awKeJ3E2Ddc3PU8U2otjvbVlSbEYNTDKpl3cyoledmAM2mrxVvTgPfxa3heZKkhgxcUY bKoMblukb6BSytBPzpVK26DcbxRdxtFHxwYLtPwJ2h7p1whBCZE7lgMmpB8Fxnxf/7VV o+Pj8L5Iq0kct7IzNR3VlX0ZDdlnEwLWblKtoc3agJnCk+UG1vqGA2stsnVwxBfDfgBZ IztA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zdMYiFuOvyNlGLkZxBQQ30nIniyERoe33IWXlfbDnCs=; b=j2yJd3dAcUajt9H8RzSZL7pHZprJe9BXU0JiudSIMRF1Nelx427UexOxqC36YGLsFV PcZGUqJMELMM8mh8bk8Z0JtKpOc5D9EOvrI2O2eDxdHOqKMyHXtmSY2c3FoP1sSHvnJy h1J7Emli8s/rsqxHnHjCVPluM+hYxbpF8sretjfHu+QQdB8A7NnQaLN/gF82o7DgClzA 9rEHf7M4MJx7G/Nro0ITdgFq2ht5BNj/tH+quNEldgGINVN3Tb1PLcf18qRI+T1ab9FL D23kDygxSyU08tAFmubW49Crs5lUfLaDu/MViuykADEZ5zeJckCCsIwh9Z+tJnv1joqa Ok2w== X-Gm-Message-State: APjAAAXjLeFwBxg1yCNo/JzbumIsjCW8fFag8yT9o9x2m2y+UTY+EMT1 OV1Cjr83ShpK4psPSe+Qnho= X-Google-Smtp-Source: APXvYqyU2+N0mA/ChX3rchSysSEgWcOOmRHL7IDYEa82fspJYlefkdAaNK1euzeB8Z9AkTeADg3Lcw== X-Received: by 2002:a05:600c:2103:: with SMTP id u3mr3884101wml.150.1574261365379; Wed, 20 Nov 2019 06:49:25 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id b2sm5822120wrr.76.2019.11.20.06.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:49:24 -0800 (PST) From: Andrea Merello To: jic23@kernel.org Cc: Andrea Merello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Colin Ian King , Patrick Havelange , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v3 6/9] Documentation: ABI: document IIO thermocouple_type file Date: Wed, 20 Nov 2019 15:47:53 +0100 Message-Id: <20191120144756.28424-7-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120144756.28424-1-andrea.merello@gmail.com> References: <20191111153517.13862-1-andrea.merello@gmail.com> <20191120144756.28424-1-andrea.merello@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org IIO core layer gained a new sysfs standard attribute "thermocouple_type". This patch adds it to the list of documented ABI for sysfs-bus-iio Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Colin Ian King Cc: Patrick Havelange Cc: Matt Weber Cc: Matt Ranostay Cc: Chuhong Yuan Cc: Daniel Gomez Cc: linux-iio@vger.kernel.org Signed-off-by: Andrea Merello --- Documentation/ABI/testing/sysfs-bus-iio | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 94f7eb675108..d3e53a6d8331 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1733,3 +1733,9 @@ Contact: linux-iio@vger.kernel.org Description: Center frequency in Hz for a notch filter. Used i.e. for line noise suppression. + +What: /sys/bus/iio/devices/iio:deviceX/in_temp_thermocouple_type +KernelVersion: 5.5 +Contact: linux-iio@vger.kernel.org +Description: + One of the following thermocouple types: B, E, J, K, N, R, S, T. From patchwork Wed Nov 20 14:47:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11254047 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 325A914ED for ; Wed, 20 Nov 2019 14:49:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 129D1206F4 for ; Wed, 20 Nov 2019 14:49:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ip0YhmoN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731027AbfKTOt2 (ORCPT ); Wed, 20 Nov 2019 09:49:28 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42400 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731257AbfKTOt2 (ORCPT ); Wed, 20 Nov 2019 09:49:28 -0500 Received: by mail-wr1-f65.google.com with SMTP id a15so82708wrf.9 for ; Wed, 20 Nov 2019 06:49:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kvZ1Nd4oryJTOXaM5v9Kg50ST7ylgE1lXo/BkAjpRdg=; b=Ip0YhmoNmAlsXVCBQKZGvfF6ZbxnrTQlj5+05zWdyZB6segJPJGkjVk14RHCD0dE8u Rds0ubueK9iw9Ve72IyHkuSDoMuOxJqPnSAVSsFROCLUJABvCcehYb1FS4Gy8vGCj1aq HgFOFU8BzrAsPxYAJ/fVGxor4FPPmNS/Lh9qbxVJByZnpd6wnvdCAPdaxXb91CHr2pZu eby+N1hhDYseRbA8X1uyVTuaXWbtnVjU5jUt9RFPDjhle/iONCPI28Tm37DeBtBitB4M mWtOKmBM8AyrgckGaWluHspkqa3pDv21Kx1tlMvnoxXOAKEI9uWt4sAeXOKdnYgGFtBW Z+sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kvZ1Nd4oryJTOXaM5v9Kg50ST7ylgE1lXo/BkAjpRdg=; b=I/lu3JdTpOppNl7yJmYv4eWxBVOSBYmXnVm+tjdmymMVV4RjOjRuZWAobvNUi0SKbt Nd3Qotz23u5rSyRf4owbPwHEpnd3PdMonMVd7nqxyp2igjgaS2QzL4v7kxdVDeMWIs6j 0ie4R36CH3AefaLtEYRrUkGPT5ieBGjh42pm29tyfG3KykFIM1bwM516ZNS4wpZwJLx7 uDZTYvUj884bxk4xUthNMtI7jvwim1uCy0wKCfAsT607sTRL//hLnVtJX5rlZQlHQcAs 2xSEqlpO2JONLIdcZC4s/BmP67V4I9JxqXFmvvq3CfPXp3UL8rMIpIZa9/aXNAb7g051 8nkg== X-Gm-Message-State: APjAAAW7TfBHTgjzVltg8aq8sAVXZPi+5CKNVgWwcg9vSrsQQbhtK79a 3VudVj/1bmD5IFSH9LjJPg4= X-Google-Smtp-Source: APXvYqxrEvRKEWZMfF2QD7KGAx/Glti6fpO4xt6g+a3df1guuRzX8NKLV7jdhXqU8O0dvgExXjUUag== X-Received: by 2002:a5d:6b51:: with SMTP id x17mr4031036wrw.148.1574261366434; Wed, 20 Nov 2019 06:49:26 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id b2sm5822120wrr.76.2019.11.20.06.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:49:25 -0800 (PST) From: Andrea Merello To: jic23@kernel.org Cc: Andrea Merello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Colin Ian King , Patrick Havelange , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v3 7/9] iio: max31856: add support for runtime-configuring the thermocouple type Date: Wed, 20 Nov 2019 15:47:54 +0100 Message-Id: <20191120144756.28424-8-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120144756.28424-1-andrea.merello@gmail.com> References: <20191111153517.13862-1-andrea.merello@gmail.com> <20191120144756.28424-1-andrea.merello@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org The sensor support various thermocouple types (e.g. J, K, N, ...). The driver allows to configure this parameter using a DT property. This is useful when i.e. the thermocouple is physically tied to the sensor and it is usually not removed, or when it is at least known in advance which sensor will be connected to the circuit. However, if the user can randomly connect any kind of thermocouples (i.e. the device exposes a connector, and the user is free to connect its own sensors), it would be more appropriate to provide a mechanism to dynamically switch from one thermocouple type to another. This can be i.e. handled in userspace by a GUI, a configuration file or a program that detects the thermocouple type by reading a GPIO, or a eeprom on the probe, or whatever. This patch adds a IIO attribute that can be used to override, at run-time, the DT-provided setting (which serves as default). Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Colin Ian King Cc: Patrick Havelange Cc: Matt Weber Cc: Matt Ranostay Cc: Chuhong Yuan Cc: Daniel Gomez Cc: linux-iio@vger.kernel.org Signed-off-by: Andrea Merello --- drivers/iio/temperature/max31856.c | 41 +++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/iio/temperature/max31856.c b/drivers/iio/temperature/max31856.c index 8457ca9ae326..4952e89c00bb 100644 --- a/drivers/iio/temperature/max31856.c +++ b/drivers/iio/temperature/max31856.c @@ -6,6 +6,7 @@ * Copyright (C) 2018-2019 Rockwell Collins */ +#include #include #include #include @@ -53,7 +54,8 @@ static const struct iio_chan_spec max31856_channels[] = { { /* Thermocouple Temperature */ .type = IIO_TEMP, .info_mask_separate = - BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_THERMOCOUPLE_TYPE), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO) }, @@ -75,6 +77,10 @@ struct max31856_data { int averaging; }; +const char max31856_tc_types[] = { + 'B', 'E', 'J', 'K', 'N', 'R', 'S', 'T' +}; + static int max31856_read(struct max31856_data *data, u8 reg, u8 val[], unsigned int read_size) { @@ -232,6 +238,9 @@ static int max31856_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_OVERSAMPLING_RATIO: *val = 1 << data->averaging; return IIO_VAL_INT; + case IIO_CHAN_INFO_THERMOCOUPLE_TYPE: + *val = max31856_tc_types[data->thermocouple_type]; + return IIO_VAL_CHAR; default: ret = -EINVAL; break; @@ -240,6 +249,18 @@ static int max31856_read_raw(struct iio_dev *indio_dev, return ret; } +static int max31856_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_THERMOCOUPLE_TYPE: + return IIO_VAL_CHAR; + default: + return IIO_VAL_INT; + } +} + static int max31856_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) @@ -259,7 +280,24 @@ static int max31856_write_raw(struct iio_dev *indio_dev, data->averaging = msb; max31856_init(data); break; + case IIO_CHAN_INFO_THERMOCOUPLE_TYPE: + { + int tc_type = -1; + int i; + + for (i = 0; i < ARRAY_SIZE(max31856_tc_types); i++) { + if (max31856_tc_types[i] == toupper(val)) { + tc_type = i; + break; + } + } + if (tc_type < 0) + return -EINVAL; + data->thermocouple_type = tc_type; + max31856_init(data); + break; + } default: return -EINVAL; } @@ -356,6 +394,7 @@ static const struct attribute_group max31856_group = { static const struct iio_info max31856_info = { .read_raw = max31856_read_raw, .write_raw = max31856_write_raw, + .write_raw_get_fmt = max31856_write_raw_get_fmt, .attrs = &max31856_group, }; From patchwork Wed Nov 20 14:47:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11254049 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BAE3A138C for ; Wed, 20 Nov 2019 14:49:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92423206DA for ; Wed, 20 Nov 2019 14:49:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DnJ6Im0F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731420AbfKTOtb (ORCPT ); Wed, 20 Nov 2019 09:49:31 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:34339 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729932AbfKTOta (ORCPT ); Wed, 20 Nov 2019 09:49:30 -0500 Received: by mail-wm1-f67.google.com with SMTP id j18so5313487wmk.1; Wed, 20 Nov 2019 06:49:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SDuzEyv/KU+kJTNU1MX2E+5z7wOJJryFHRQ9Hq8mD28=; b=DnJ6Im0FBkpkZPNRyob5Ja80ztK3k856m/CzwrivEYu6buCuhr+3w355OTjfUh+tqZ 5zAXoP7cw4QQuQA+xGFT9/Oh7uEorR9AgYPwCggnAnsousz2iItPrb/wFYP6LXoTqFJC FF2bB1l4smmocRqTjqMDFY+MxNiHzUhKXpoAbeDxPmtL1+545dKK56CTd0lNPYyeyMd1 Q+SMB+U/rkqkPi+G54pSsS/pON79yMqru9KgIiEPrtxtPzUQzHSlz9pM5i8LRUp2+fH4 prt6aSFHlZouodQkfi4Wg+Pzk7BcwYhj/A9aXNkfRnVAaN+M7PP5NgkSUv8A+r4PqmpM TGHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SDuzEyv/KU+kJTNU1MX2E+5z7wOJJryFHRQ9Hq8mD28=; b=eKuN7ghSLKIJndOK2hxF3CfaLdwbT8lY/DIIAtHVWnVxF+WxqIAKLTuQPocMIrJ0Vw DVc59Wk9Ph3YJIW4E8dWP9qs4DIFXYXMM5Bky9YvsRXxF+KIhTJc14tfGYdjP2nA7jEB olQWSYahdQgXzdns+B/oXD+8pAxUWWaeZP8gpPY5eZHwE8scJqQx0Y/L/5dRd8z+xLiE KEl1VpAlAf+0EtMXuxm2BDUibs603sZCPH9V4paofwpgoQt1l0MPlbIaOA0Fia9Hzcrq iP1JntoioW3rqpG5IlZr7r9Ik2qV3V6NAFt6OSE8+yWzcV7TXNBjPVuu//YeR6cHBePN MEwg== X-Gm-Message-State: APjAAAXGRaolqlo4ZSXLhZxJp9zPcEfueYYfu6yGDqyVFCxPiE7/XD7r itWmGuAg2BkhJo3TeixjoB0= X-Google-Smtp-Source: APXvYqy0i3WR9TvovXLASrOVv3UvaEW75ldDidda6jDKdLEyXXCVJTLDRoWBFl0dStR3RGRRTEgOdA== X-Received: by 2002:a05:600c:2549:: with SMTP id e9mr3558941wma.177.1574261367586; Wed, 20 Nov 2019 06:49:27 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id b2sm5822120wrr.76.2019.11.20.06.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:49:26 -0800 (PST) From: Andrea Merello To: jic23@kernel.org Cc: Andrea Merello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Colin Ian King , Patrick Havelange , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org, Rob Herring , Mark Rutland , devicetree@vger.kernel.org Subject: [v3 8/9] RFC/RFT: iio: maxim_thermocouple: add thermocouple_type sysfs attribute Date: Wed, 20 Nov 2019 15:47:55 +0100 Message-Id: <20191120144756.28424-9-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120144756.28424-1-andrea.merello@gmail.com> References: <20191111153517.13862-1-andrea.merello@gmail.com> <20191120144756.28424-1-andrea.merello@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org We added a sysfs ABI for getting/setting the type of a thermocouple. This driver supports chips that support specific fixed thermocouple types; we cannot set it, but still we can add this sysfs attribute in RO mode to read-back the thermocouple type. This driver supports actually several chips: - max6675 - max31855[k/j/n/s/t/e/r]asa family Max6675 supports only K-type thermocouples, so we can just report that. Each chip in max31855 family supports just one specific thermocouple type (in the obvious way: i.e. max31855jasa supports J-type). This driver did accept a generic SPI ID and OF compatible "max31855" which does not give any clue about which chip is really involved (and unfortunately it seems we have no way to detect it). This patch introduces a new set of, more specific, SPI IDs and OF compatible strings to better match the chip type. The old, generic, "max31855" binding is kept for compatibility reasons, but this patch aims to deprecate it, so, should we hit it, a warning is spit. In such case the reported thermocouple type in sysfs is '?', because we have no way to know. Regarding the implementation: the thermocouple type information is stored in the driver private data and I've kept only two maxim_thermocouple_chip types in order to avoid a lot of duplications (seven chip types with just a different thermocouple type). RFT because I have no real HW to test this. Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Colin Ian King Cc: Patrick Havelange Cc: Matt Weber Cc: Matt Ranostay Cc: Chuhong Yuan Cc: Daniel Gomez Cc: linux-iio@vger.kernel.org Cc: Rob Herring Cc: Mark Rutland Cc: devicetree@vger.kernel.org Signed-off-by: Andrea Merello --- drivers/iio/temperature/maxim_thermocouple.c | 44 ++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c index d1360605209c..9906b31fe863 100644 --- a/drivers/iio/temperature/maxim_thermocouple.c +++ b/drivers/iio/temperature/maxim_thermocouple.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -24,13 +25,25 @@ enum { MAX6675, MAX31855, + MAX31855K, + MAX31855J, + MAX31855N, + MAX31855S, + MAX31855T, + MAX31855E, + MAX31855R, +}; + +const char maxim_tc_types[] = { + 'K', '?', 'K', 'J', 'N', 'S', 'T', 'E', 'R' }; static const struct iio_chan_spec max6675_channels[] = { { /* thermocouple temperature */ .type = IIO_TEMP, .info_mask_separate = - BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_THERMOCOUPLE_TYPE), .scan_index = 0, .scan_type = { .sign = 's', @@ -48,7 +61,8 @@ static const struct iio_chan_spec max31855_channels[] = { .type = IIO_TEMP, .address = 2, .info_mask_separate = - BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_THERMOCOUPLE_TYPE), .scan_index = 0, .scan_type = { .sign = 's', @@ -110,6 +124,7 @@ struct maxim_thermocouple_data { const struct maxim_thermocouple_chip *chip; u8 buffer[16] ____cacheline_aligned; + char tc_type; }; static int maxim_thermocouple_read(struct maxim_thermocouple_data *data, @@ -196,6 +211,10 @@ static int maxim_thermocouple_read_raw(struct iio_dev *indio_dev, ret = IIO_VAL_INT; } break; + case IIO_CHAN_INFO_THERMOCOUPLE_TYPE: + *val = data->tc_type; + ret = IIO_VAL_CHAR; + break; } return ret; @@ -210,8 +229,9 @@ static int maxim_thermocouple_probe(struct spi_device *spi) const struct spi_device_id *id = spi_get_device_id(spi); struct iio_dev *indio_dev; struct maxim_thermocouple_data *data; + const int chip_type = (id->driver_data == MAX6675) ? MAX6675 : MAX31855; const struct maxim_thermocouple_chip *chip = - &maxim_thermocouple_chips[id->driver_data]; + &maxim_thermocouple_chips[chip_type]; int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*data)); @@ -229,6 +249,7 @@ static int maxim_thermocouple_probe(struct spi_device *spi) data = iio_priv(indio_dev); data->spi = spi; data->chip = chip; + data->tc_type = maxim_tc_types[id->driver_data]; ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, @@ -236,12 +257,22 @@ static int maxim_thermocouple_probe(struct spi_device *spi) if (ret) return ret; + if (id->driver_data == MAX31855) + dev_warn(&spi->dev, "generic max31855 ID is deprecated\nplease use more specific part type"); + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct spi_device_id maxim_thermocouple_id[] = { {"max6675", MAX6675}, {"max31855", MAX31855}, + {"max31855k", MAX31855K}, + {"max31855j", MAX31855J}, + {"max31855n", MAX31855N}, + {"max31855s", MAX31855S}, + {"max31855t", MAX31855T}, + {"max31855e", MAX31855E}, + {"max31855r", MAX31855R}, {}, }; MODULE_DEVICE_TABLE(spi, maxim_thermocouple_id); @@ -249,6 +280,13 @@ MODULE_DEVICE_TABLE(spi, maxim_thermocouple_id); static const struct of_device_id maxim_thermocouple_of_match[] = { { .compatible = "maxim,max6675" }, { .compatible = "maxim,max31855" }, + { .compatible = "maxim,max31855k" }, + { .compatible = "maxim,max31855j" }, + { .compatible = "maxim,max31855n" }, + { .compatible = "maxim,max31855s" }, + { .compatible = "maxim,max31855t" }, + { .compatible = "maxim,max31855e" }, + { .compatible = "maxim,max31855r" }, { }, }; MODULE_DEVICE_TABLE(of, maxim_thermocouple_of_match); From patchwork Wed Nov 20 14:47:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11254051 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDE8F14ED for ; Wed, 20 Nov 2019 14:49:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C417820872 for ; Wed, 20 Nov 2019 14:49:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HnBsOQHc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731589AbfKTOtb (ORCPT ); Wed, 20 Nov 2019 09:49:31 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40148 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730794AbfKTOtb (ORCPT ); Wed, 20 Nov 2019 09:49:31 -0500 Received: by mail-wr1-f68.google.com with SMTP id q15so99851wrw.7; Wed, 20 Nov 2019 06:49:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ztGpHglCy1aKGdb4ZiLGlUvE1egif9nfiCGe0G8RTOg=; b=HnBsOQHcmy4vcrGpS/FMwlS1MBKtzsNw3X2VWNEDxtBEs5glgXLVrJigpFmRs5QxfB 5vf0VKTtlupGmOcANVFTcP4UagTnTluSdMmE8o6ce8ZQgHNC3rcxZkyQgicz7rkrrPnl K+qtuPT3MZmn9rLehplw6CFIfuaLtykZpvGoe5QmVQxj8gkItBOqZY2jpaxyXN+CAa0l tpfex1KtdQvaRUiM/KN9zOPhDn6PeWJwr7zMnGllR4eq196enSSXpx8ZUABj882SM4sZ RqIOg51rHVuYnp3O4KHArnLHPXte1J8rcwso+FuxX3T364AMaRe6hZ6BgFX+N84KDH5I 5AuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ztGpHglCy1aKGdb4ZiLGlUvE1egif9nfiCGe0G8RTOg=; b=HMdQc7on7zsDHdjwrXQNbONHI912pO3770VTehSeS6MkT3GizIPFebabCnxwnzttUt SH2bAVJCQI0o5RUW603XG/qvY3CpqFotC5HGQ+vB62KpYjqWDOTTs35Uekb+/cvImAUI KvNF/Qp6B5IzEuzM3LgiyNx39Ehe1U5Ek/+V3dRZWzhmJ4KNc9CVcufF4zujmRVpEBRl lvnRdnnJRazw44EQD8yT3ReVcxByNf0X0aT4LXGtj+noLdUz4Fi1xkwkpL4reRiY1xg3 MxWid+TllhVH6zxv+KzacUcz0jOPGiSKJkuIJ8EXjvm45wAuEulkxEytx9y0yzzc8qZn bvWA== X-Gm-Message-State: APjAAAUDJD44WlUdNBugBNdKU5dJMi6nJT74oBxYic185IX14h79okko xaVcp9VFnMoGHu9HevjaJ1c= X-Google-Smtp-Source: APXvYqx/ox+sabVqmKDxnF4qeAAGRMVmMmZmHlVXcUImDFrfRFJDGQl/0/ZG2AjDSdBsI0NRlwwnZg== X-Received: by 2002:adf:e8cf:: with SMTP id k15mr4018601wrn.256.1574261368790; Wed, 20 Nov 2019 06:49:28 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id b2sm5822120wrr.76.2019.11.20.06.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 06:49:28 -0800 (PST) From: Andrea Merello To: jic23@kernel.org Cc: Andrea Merello , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Colin Ian King , Patrick Havelange , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org, Rob Herring , Mark Rutland , devicetree@vger.kernel.org Subject: [v3 9/9] dt-bindings: iio: maxim_thermocouple: document new 'compatible' strings Date: Wed, 20 Nov 2019 15:47:56 +0100 Message-Id: <20191120144756.28424-10-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191120144756.28424-1-andrea.merello@gmail.com> References: <20191111153517.13862-1-andrea.merello@gmail.com> <20191120144756.28424-1-andrea.merello@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Now the maxim_thermocouple has new, more specific, 'compatible' strings for better distinguish the various supported chips. This patch updates the DT bindings documentation accordingly Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Colin Ian King Cc: Patrick Havelange Cc: Matt Weber Cc: Matt Ranostay Cc: Chuhong Yuan Cc: Daniel Gomez Cc: linux-iio@vger.kernel.org Cc: Rob Herring Cc: Mark Rutland Cc: devicetree@vger.kernel.org Signed-off-by: Andrea Merello Acked-by: Rob Herring --- .../bindings/iio/temperature/maxim_thermocouple.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/temperature/maxim_thermocouple.txt b/Documentation/devicetree/bindings/iio/temperature/maxim_thermocouple.txt index 28bc5c4d965b..bb85cd0e039c 100644 --- a/Documentation/devicetree/bindings/iio/temperature/maxim_thermocouple.txt +++ b/Documentation/devicetree/bindings/iio/temperature/maxim_thermocouple.txt @@ -5,7 +5,10 @@ Maxim thermocouple support Required properties: - - compatible: must be "maxim,max31855" or "maxim,max6675" + - compatible: must be "maxim,max6675" or one of the following: + "maxim,max31855k", "maxim,max31855j", "maxim,max31855n", + "maxim,max31855s", "maxim,max31855t", "maxim,max31855e", + "maxim,max31855r"; the generic "max,max31855" is deprecated. - reg: SPI chip select number for the device - spi-max-frequency: must be 4300000 - spi-cpha: must be defined for max6675 to enable SPI mode 1 @@ -15,7 +18,7 @@ Required properties: Example: max31855@0 { - compatible = "maxim,max31855"; + compatible = "maxim,max31855k"; reg = <0>; spi-max-frequency = <4300000>; };