From patchwork Mon Nov 11 15:35:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11237239 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 7D2E017E6 for ; Mon, 11 Nov 2019 15:35:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5AD35214E0 for ; Mon, 11 Nov 2019 15:35:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gt9tsZCO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbfKKPff (ORCPT ); Mon, 11 Nov 2019 10:35:35 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38947 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbfKKPfe (ORCPT ); Mon, 11 Nov 2019 10:35:34 -0500 Received: by mail-wm1-f68.google.com with SMTP id t26so13655805wmi.4 for ; Mon, 11 Nov 2019 07:35:33 -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=gS+fX6HocMZQrA2Zetea25BkJrtv5feCZObhATZvhqo=; b=gt9tsZCOb9423YgCV6u0uUq0iI2XXmySZNNqH7xa2WYRTPondr4OjOuW/VY/MlSpQl 18gTpp2lzavzC7pUrhrvQnzZjbDAPFuH3BmHeLQPuXZ5YPOJj51I/MsDbPePmVwqQIm5 Rq0XveZuYQfKoHPHU3Cbb435g/41aapmmyC2AuChozeJKb0urz60C7fy8SFlPKuzKY2e XpyTvgXoBu5F25bO+ZV6RXnmNkI4dW+UZuDS0KyRzDuCWi3laxrD4zhAAm4/JJ/yk5E9 2p/A7viuI0Z/ut+dR3zHxBCHeGNWNqDpGMqat530WgGhFDCIOX4It1UFte4ztJjWkdIv oRzA== 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=gS+fX6HocMZQrA2Zetea25BkJrtv5feCZObhATZvhqo=; b=PZvaPOnd1PeFDPvnUPGU25XLCtFhgchidyWMFbF5ClKXKZbre/6Nzp6TucTgnLmQOb tEy/0kAUd6x1/pF8y02wHI6e1/8kX69AW3s687CnjOF7qFiLAA5iPyCTK7WMlSbicgGo ZLQHGj11+Fb5yOiNQhegyLdaS0jMRMTt+/wWxVdOPMdnz4jRXCBCTqEvOY4ASRu9jGqJ epJIUxJBcV2JjJpW5rxyAjzTpYidoXgSP75NxYYI4o0IkWH8bYQcyIknPGfSWif5fuWZ 57NN+/PLpBDhDBJ8Ag1MrMG/RdhG8KKECwiWjDqMbfdE9zhea7ffCNssbuOyQvhVyLRt dN7g== X-Gm-Message-State: APjAAAUM1kvISDTQXX+liIJ0nuIf4Z6SZDnqltMv5k3saq+qagt5TCAN 6p/Z0ko6eVh8EI5PpC8XsZ8= X-Google-Smtp-Source: APXvYqySaUlfhDLlyMxvizvbrw+9Dp+QFYy2JSx7mmyxJ38PUmqnEHYSZDcFrOqBAHX2v1PaSHDj/A== X-Received: by 2002:a7b:c858:: with SMTP id c24mr22120264wml.174.1573486532406; Mon, 11 Nov 2019 07:35:32 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w81sm23965657wmg.5.2019.11.11.07.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 07:35:31 -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 , Paresh Chaudhary , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v2 1/9] iio: max31856: add option for setting mains filter rejection frequency Date: Mon, 11 Nov 2019 16:35:09 +0100 Message-Id: <20191111153517.13862-2-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111153517.13862-1-andrea.merello@gmail.com> References: <20190923121714.13672-1-andrea.merello@gmail.com> <20191111153517.13862-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: Paresh Chaudhary 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 Mon Nov 11 15:35:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11237243 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 7E80C16B1 for ; Mon, 11 Nov 2019 15:35:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D41621D7F for ; Mon, 11 Nov 2019 15:35:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pg9whhrv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727027AbfKKPfg (ORCPT ); Mon, 11 Nov 2019 10:35:36 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38714 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727032AbfKKPff (ORCPT ); Mon, 11 Nov 2019 10:35:35 -0500 Received: by mail-wr1-f65.google.com with SMTP id i12so8213560wro.5 for ; Mon, 11 Nov 2019 07:35:34 -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=IqboxVSwo0zc15MKnl74vo/KbesEjxX4qRyDh6yzeR8=; b=pg9whhrvOfax5w5SAUTqdImvM5ttK/AoVzHUWrIe/jJbuGH9lwt51Qq56W3iUd0yiC GNr30ClZUItFDZevOI0tZkMbo4NrRO5/yAOOHkM/YhdKwe1/U9Q1K1jonJ0lOTAs1+Yp HxO/UKy28JOkUbBLtwig7o0jCWYsf5NccfGB8ujXnRZxq1a1QTX54e4oHBrkKg0ZOLJ8 nWqRSm9vFlTR5sds0rkR9jx3uIESaQ9R3z7avJ4cvZUGMiHMGtQ0evdFToAsFOxvsui7 QkFwgZM9hdmll32pttu9+hJQZ1s7XGV8bEJK5ucwlUpZMoHPmJekVUKA4vfOjhlfWUIW ympA== 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=IqboxVSwo0zc15MKnl74vo/KbesEjxX4qRyDh6yzeR8=; b=EDqUmETXZY/l1utPT9O/y8362Z9fFJCMb/grt+ahXAYzHigyrv3GFoKaRwI8fmW6X1 WntSnUno1Von9OP/i/J3AylUWQTIWkpRUKOJLMdK3g/GpeOeW2ObWGkS6b5CUZB5s6Wp R0ouBxdvaCh+05Hr0YYr71xG6QE5vZfc1JbtRww7db7PC/vdYHlkG+fU2X2ZkKTqCTXD 3l5OS98FbQ1aszIvJXeL3FXEtQlmuWlSEsMGkMnSKdRI3JHMvXtGatq2t4e44A6dNPP5 oSM46pH42JIbKphyLRJjGQ4SU+SLMSG5f/XbVmlJml0jiDaibe2jAMwzxfkjBG9YcnSv CD0w== X-Gm-Message-State: APjAAAVFsRPR9K1JF7V6gnnj4lD883AzR20NwxSvC4i1LmSg6YgXLg0K CbZejs0YJQ48UIlshem/P8s= X-Google-Smtp-Source: APXvYqzfS9YC8+J9qmHQBv5stklzcoKZDJtq0T3CWlVMyucHhFg9G7K9SQ4+HIsJfLpBQJiar+SAGw== X-Received: by 2002:adf:9ec7:: with SMTP id b7mr21688962wrf.221.1573486533570; Mon, 11 Nov 2019 07:35:33 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w81sm23965657wmg.5.2019.11.11.07.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 07:35:33 -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 , Paresh Chaudhary , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v2 2/9] Documentation: ABI: document IIO in_temp_filter_notch_center_frequency file Date: Mon, 11 Nov 2019 16:35:10 +0100 Message-Id: <20191111153517.13862-3-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111153517.13862-1-andrea.merello@gmail.com> References: <20190923121714.13672-1-andrea.merello@gmail.com> <20191111153517.13862-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: Paresh Chaudhary 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 Mon Nov 11 15:35:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11237245 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 5F0DE16B1 for ; Mon, 11 Nov 2019 15:35:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D7FC2184C for ; Mon, 11 Nov 2019 15:35:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aORACKzi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727036AbfKKPfh (ORCPT ); Mon, 11 Nov 2019 10:35:37 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51812 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbfKKPfh (ORCPT ); Mon, 11 Nov 2019 10:35:37 -0500 Received: by mail-wm1-f68.google.com with SMTP id q70so13815132wme.1 for ; Mon, 11 Nov 2019 07:35:35 -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=PVezXAejdva/nQbIcOFCt57jKE7cejAQgFATjaQOuZw=; b=aORACKzikbOHDtI+Tbc0XoVy/5/LxPmadClYCIevhPI7Ixb/cpgBP9D/guAnmiW+l5 Cus8qNvlUy+4BvRCqKFt5RbFnYTX+cR5op6/M0nqQrpRvcgCnj/ThQMRzSLAkmKDCnb7 nboBZ2DHU3DVsRDWUnJurY/h15MGwJsqCjg0v69klK/eTm+ZTx8EDTgm38qZkJtSbEGK 4RQ0eCiOnA7jXbPHm4z9fUFplH1rvEmt4xJO+nxx6LrWWiEDZodMWyzuD7LYQIfwxi9k YXHpLolL9kpIcakqgdQxGbZHAevML4jieDIIljsktCa72RtbbFE+DN6P2KrqhaYQleml FywQ== 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=PVezXAejdva/nQbIcOFCt57jKE7cejAQgFATjaQOuZw=; b=SSeNzIee71HauNItADa12hAJ/4c9IPvENAB2c4uJE2fgOrUS87XfQ7tABtNdDAbXrF wKhIFMsgJC30fQNHBEwNbsOMV7qAPOlsy5Mm8f5f1jjTUhDG+2ovFFkzNy0f3X7krAEz Mg8FB/ADiVYQYORinqqzc+MBhQG4kF4wn5pEPUd6YexXoS5meJgzWhunBSsElOsQ7Gn2 u6hGE7jj9sA5PeAOqPt1DxTxXoJPWHjdsmAfF0z7sURky7qLdDqzk7CkkOIiYZ9sSJ0C xe+93Lv6RI1aBcSXUo29do7NrFalhn4LvjNW4U+UHIn6C5k5/MEJPAZj5HoTqVZ+gBqI lh1Q== X-Gm-Message-State: APjAAAXQpTi9Gw7V7BI1RTU0iarQ+2jPu+DvtQQqR+LeDwBtucbX2eop LMSJ31OBJvYojKrtWDC+UWA= X-Google-Smtp-Source: APXvYqxQ6qaY2vJ+3xwqdc7lfAOAeCrHrFVlHbTI+L0Mzaua/BTHD2n4wIAzhPjMOeRnN1dMWXwFXA== X-Received: by 2002:a7b:cf32:: with SMTP id m18mr21379125wmg.166.1573486534788; Mon, 11 Nov 2019 07:35:34 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w81sm23965657wmg.5.2019.11.11.07.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 07:35:34 -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 , Paresh Chaudhary , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v2 3/9] iio: max31856: add support for configuring the HW averaging Date: Mon, 11 Nov 2019 16:35:11 +0100 Message-Id: <20191111153517.13862-4-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111153517.13862-1-andrea.merello@gmail.com> References: <20190923121714.13672-1-andrea.merello@gmail.com> <20191111153517.13862-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: Paresh Chaudhary 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 | 46 +++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/iio/temperature/max31856.c b/drivers/iio/temperature/max31856.c index d97ba9ee1598..9f0f4f65dccd 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) @@ -50,7 +53,10 @@ 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) }, { /* Cold Junction Temperature */ .type = IIO_TEMP, @@ -58,6 +64,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 +73,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 +118,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 +230,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 +241,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 +356,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 Mon Nov 11 15:35:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11237247 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 2130B1390 for ; Mon, 11 Nov 2019 15:35:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00B8821783 for ; Mon, 11 Nov 2019 15:35:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="binb7/yI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727020AbfKKPfi (ORCPT ); Mon, 11 Nov 2019 10:35:38 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38721 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727032AbfKKPfi (ORCPT ); Mon, 11 Nov 2019 10:35:38 -0500 Received: by mail-wr1-f65.google.com with SMTP id i12so8213716wro.5 for ; Mon, 11 Nov 2019 07:35:36 -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=Zb7NkXBDvMsy7r5r4A8ZILqQNRPS4JGTch9zuj9udhk=; b=binb7/yIL022nAvMGnDrIdp2YcMVj1FNBKfZ+wKxwlU2LKrcRAHfvEywhcjwNwGhvH 6Afps8XBY06cx0dRjgx2U6T00EbuHAe0n1zxSN5HrUDKy0ajho/V7iJ2tduRHIPbsPw8 Dv+ASTzvkwQUyqbS/+shVh5/W/vEMXkwfZ6PV9Yd8+UCCHQ4Q3vMN1GYMYitIVtkcH9A oUgxeG17NNQbv96rL+AYroQE5VNJJpOLeEHnD2xMqA7UNXiLDVqA7FD+qZzK2XoRigu8 On4vd1jdHFo3S9q0QFmxDMfBR0JqPD/3/b8Pq5GzF++HHF1RXOOSxN2JpcWmgVbscZm1 YRzw== 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=Zb7NkXBDvMsy7r5r4A8ZILqQNRPS4JGTch9zuj9udhk=; b=l3X1mt7oLR6i0xbzL2JWJZRfdAwP63f02b3D//zrkHEU3jMlOZYsXf1IXQlot2n279 CK2xw06IrzArfUicl9B2ADTwjLLDKk0VCTb2t0Y3C5KOA3XQp7vF05kW/6g7X5fDnbBL j2JjlgACKrAyVRJkQJ6B+8EKugcx0Bv9uzqGEc3m8mZ0kiDZqh4TqxpNkk1PPTUT7Fcc +7ZWFXslo/XoEJFHRznV0ItDMuUExr8+ljM+/0ey9WcwXxSOvgPoznHwBrTbCBx+4+Xu Q5+KemogX5LASHVkuV3YSW6hrD+VOcUm1TJ12dnPn34tb4rJz/fEMSI93PqJzUoTLh07 AnEQ== X-Gm-Message-State: APjAAAUThbEZJfwAjb1eO9m+qnOP+cw900w4vcTmXqpC4Fq8An9G45ad d8fhUxc9Q2T8nRHp6TWkd68= X-Google-Smtp-Source: APXvYqxQOJm6XUey5rtZ/hSPad69wD/IqB2HbqJDHyMLFg9VdyLMa2e8YjdRALg9XzgJt7Wt+UyF5g== X-Received: by 2002:adf:e94e:: with SMTP id m14mr22079939wrn.233.1573486535834; Mon, 11 Nov 2019 07:35:35 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w81sm23965657wmg.5.2019.11.11.07.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 07:35:35 -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 , Paresh Chaudhary , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v2 4/9] RFC: iio: core: add char type for sysfs attributes Date: Mon, 11 Nov 2019 16:35:12 +0100 Message-Id: <20191111153517.13862-5-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111153517.13862-1-andrea.merello@gmail.com> References: <20190923121714.13672-1-andrea.merello@gmail.com> <20191111153517.13862-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: Paresh Chaudhary 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 Mon Nov 11 15:35:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11237249 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 6EA5217E6 for ; Mon, 11 Nov 2019 15:35:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C5B72190F for ; Mon, 11 Nov 2019 15:35:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RyqjkVHF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbfKKPfi (ORCPT ); Mon, 11 Nov 2019 10:35:38 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:55151 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbfKKPfi (ORCPT ); Mon, 11 Nov 2019 10:35:38 -0500 Received: by mail-wm1-f68.google.com with SMTP id z26so13790370wmi.4 for ; Mon, 11 Nov 2019 07:35:37 -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=/FQlNKVcxb71DgL7lhZKnTFvgXDTr4/CG+zCoXM2wAk=; b=RyqjkVHFb0vxcP5YXMvMLGjBn0GUvaYygxcfbTD9vCbWSEMb/krEhjefgV5bR/svG+ 46obvSFbPTqLy8KAGxM5IbtRAVBf53UNqHnhoPT9Q0hD9oNulvcozBNy0eW8w6Klnjbf tWICT80ey1QSdFiMBw2Wy9ZyXzu0jHndxuKCVZOVHs3F45H0A0qElEopyw3A4BCN1ouw PJFxvvzElGOJQPmB3iyJYwmeIEilWb/TDLEe3re3WyZS0rx+JDx0tV5T4W+rPW6ZFH9j x2On46M4mPYG0EROC1bWFD2EZIbEQ4I6pj7+e5Z4GlsHrjTP+ncbBhWtGBn8rBnOVzTa aI0A== 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=/FQlNKVcxb71DgL7lhZKnTFvgXDTr4/CG+zCoXM2wAk=; b=dKDMfXUHIXmZ1ME/H08LmweqeeDqObEjL4zFPvqsL/S8RGSLN95xIOteAyucl1FV8O Cg8RkhQiYpuxuGMO9xq8uGQYcbHI7jso5UsC3dmXtT9XKr9kIABaQeYfK/uwHwaGYrPV XTItMt0pVvfWrPYTPgDrcdWZ5fgXQpwXrjCiUP0VezuYYzcFHhAycyjjmXOlqt6RJs4b huBtFs8QuJmJbzNotHpPvBy5YEghl0wMSEWKMVaaV/y0aAVa6WdauetFSFHU2XdL911w Oh8M+bFU09UF4960ODGMwawfsr92GWakOeKd18FC/IWoi2S3PHJXFQN8VZtCH5j/ynAs YTRg== X-Gm-Message-State: APjAAAWPWvUOOFeNabEaEvBV4MKNZp4SurLCLolAM0jxLEWPKan4W0mR xjRGPfqQRkNAV+8ZDv3oLtM= X-Google-Smtp-Source: APXvYqzAjHd8YK2Lgh3vAVZcAxvQhw/ikvHfe7vifAFcDYM6urooyukzOWFQb3xlSkyOTbDTs3HACA== X-Received: by 2002:a1c:6542:: with SMTP id z63mr21432814wmb.29.1573486536926; Mon, 11 Nov 2019 07:35:36 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w81sm23965657wmg.5.2019.11.11.07.35.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 07:35:36 -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 , Paresh Chaudhary , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v2 5/9] iio: core: add thermocouple_type standard attribute Date: Mon, 11 Nov 2019 16:35:13 +0100 Message-Id: <20191111153517.13862-6-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111153517.13862-1-andrea.merello@gmail.com> References: <20190923121714.13672-1-andrea.merello@gmail.com> <20191111153517.13862-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: Paresh Chaudhary 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 Mon Nov 11 15:35:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11237251 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 13E9F1390 for ; Mon, 11 Nov 2019 15:35:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E636E2196E for ; Mon, 11 Nov 2019 15:35:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kIOrsFjS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727046AbfKKPfk (ORCPT ); Mon, 11 Nov 2019 10:35:40 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55151 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbfKKPfk (ORCPT ); Mon, 11 Nov 2019 10:35:40 -0500 Received: by mail-wm1-f65.google.com with SMTP id z26so13790475wmi.4 for ; Mon, 11 Nov 2019 07:35:38 -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=c4UaxyvklkVUid1A0WwdmyjZMCmwAFkWblBVGXHBIG4=; b=kIOrsFjScJCngxyWvA3HUU+Ko2BUMp9vKgM47xy5iBhnJhuaZOV2Nxf/zqWizLncj/ 5qdAQkRJHvp5FAsI7ofGUJTR5DcNX1ZnXycOHKjaq9Rm5qE7tlA04v4KLULAFDXfl25C juPoHzgm2vWDm6LX+X7+h2k076zc2jGWD2NCohaZlJ9eJHhkE5GiyCvSKOC+2VrAyJqq uHUhIBriEOwYgSoiDN5/C8tIk9e2s2bvXBVcvJ5Lk/VuglVbEu+03yOSz/xh1gOr49RD Bj7jLogUqSNu+/eZNNPvjtygVG4pYbZe5NKq3lO7gqFK5W+0X59HXCI5WMt+kcd+sxrk rR/Q== 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=c4UaxyvklkVUid1A0WwdmyjZMCmwAFkWblBVGXHBIG4=; b=qIoavex+7FY8PXP+gynKvuYwCiTa2xkMNQJ3/1zjNSc6VoyH7sRCwWX4Na/HLlMAhQ TBsoJJvnEItGUOV44AoM3i8YjJ0VL0eH2/inq2Foffr3w7GK5kkQ+AFO3uItZjujvGi5 PG8yI67ldyFW+xgn5eqLswSZ/dHE3u78jJ5KROnbuR4luY9BsiUTaDPhJ6z50/KucKcr CK6B/hUIJxZpa/56xE+abuocvXR33TAP+MS4f/aV5QHFOgTNikU2VDfK14+KNFFzYzY3 9yg7CXeSSqbtUuEIzkKXqnSj92+AsvzxTSJle/EZYFPyx69k+aWF8AFDPYxhMEKTAS1/ O99A== X-Gm-Message-State: APjAAAVa5yo2wcDNt654Xpzwp9ZC+01a9oP5JVtL04LRi9mo2MXcR4ov qwkFVRAP/d68MqUu4lg350o= X-Google-Smtp-Source: APXvYqw2fRzpHSbD4K4Gsekt9z3gbEqd1FZRpCmBgMU8tADa/phjC+xHthMwhlsSRsUnv6N8q6tD3Q== X-Received: by 2002:a1c:e915:: with SMTP id q21mr10218235wmc.164.1573486538315; Mon, 11 Nov 2019 07:35:38 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w81sm23965657wmg.5.2019.11.11.07.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 07:35:37 -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 , Paresh Chaudhary , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v2 6/9] Documentation: ABI: document IIO thermocouple_type file Date: Mon, 11 Nov 2019 16:35:14 +0100 Message-Id: <20191111153517.13862-7-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111153517.13862-1-andrea.merello@gmail.com> References: <20190923121714.13672-1-andrea.merello@gmail.com> <20191111153517.13862-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: Paresh Chaudhary 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..2cf2c800dba2 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: + Thermocouple type i.e. J, K, R, ... From patchwork Mon Nov 11 15:35:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11237255 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 1056117E6 for ; Mon, 11 Nov 2019 15:35:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E3107214E0 for ; Mon, 11 Nov 2019 15:35:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pnBRLuov" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726889AbfKKPfm (ORCPT ); Mon, 11 Nov 2019 10:35:42 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55701 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbfKKPfl (ORCPT ); Mon, 11 Nov 2019 10:35:41 -0500 Received: by mail-wm1-f65.google.com with SMTP id b11so13775600wmb.5 for ; Mon, 11 Nov 2019 07:35:40 -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=TlAES4qzhyzzXCjCC1cceNgc3QMqW/GMvwOBs7FohH8=; b=pnBRLuovZ+uQzhGbB1klowspj8dvYwwu1u56e2KddtXNw2poWY5CqDZnYfEeo/5M6A sg67+AvWLL9llhip3L+SDnYfvPh6Xgua1hDTUNl2pCKehXu4HEh6ZBG1BrhTJygLwSKi fb+uq/LkO3KZ3E+MVWOxB1t3ZB1OOtMCMov1wQap+aOFZOD8VKLOenQuUY/zfPJAIhFE euwmwyfTM0P2PAloKGdP/pToxHHCXf5C6a+owYFO80OMi55DhCpiTyzXd9D6ZB+aOtgZ TuuypMcyxGThh3Pbh4gmXjmCmgQ4tMuJKrz9Pzb5fLJrpTIqryNQwvNr7F2G4tqNI8XE kGuA== 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=TlAES4qzhyzzXCjCC1cceNgc3QMqW/GMvwOBs7FohH8=; b=bAmfoT9TOUzq9FCLPgB0LIz9doMze3WAbNiMNzDHhZLwl5FO1tbAXG7P7jSNtn9fzZ 7IvMgr9Bea4nnL0wWWFZnbrWHHvkUTX+/JANwsweDT+JEfMiiqxYSHGBGcOOcrcxhBzS 1My26netIt7W9cA/tPSq/WL6wOMoADLPGRaOmvnOtupDxGd+i9kKCCdyQQWLGyZdGgrc rInts1xs4ZZAh8oZU4ystUi0zRJVj0dNDIbp/93h34I/iT7gnBXejcY0aijfWx3BC3Yv TC25zHYAln6fotWHTrT59ZaO19yfUQBNSMVG0PzWQG4uJOZkkADfPnLui0TtGgYiXO/L PQhg== X-Gm-Message-State: APjAAAXtxVY6Hqp1TueNn1sJXvTvN2abAjDjsdxzFmtg7BtAl9pV/ni+ dAnETKLRg8/gsIZXsWD1/X8= X-Google-Smtp-Source: APXvYqzdOjOlEG8ROkJtBr7x1bpCudNKpccQvizYYiVnzSVrZR0X+zV1TtbgBAJFnePP9AQcId7NtQ== X-Received: by 2002:a7b:c858:: with SMTP id c24mr22120745wml.174.1573486539365; Mon, 11 Nov 2019 07:35:39 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w81sm23965657wmg.5.2019.11.11.07.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 07:35:38 -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 , Paresh Chaudhary , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org Subject: [v2 7/9] iio: max31856: add support for runtime-configuring the thermocouple type Date: Mon, 11 Nov 2019 16:35:15 +0100 Message-Id: <20191111153517.13862-8-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111153517.13862-1-andrea.merello@gmail.com> References: <20190923121714.13672-1-andrea.merello@gmail.com> <20191111153517.13862-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: Paresh Chaudhary 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 | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/iio/temperature/max31856.c b/drivers/iio/temperature/max31856.c index 9f0f4f65dccd..6689eab174df 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 @@ -76,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) { @@ -233,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; @@ -241,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) @@ -260,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; } @@ -333,7 +370,6 @@ static ssize_t set_filter(struct device *dev, default: return -EINVAL; } - max31856_init(data); return len; } @@ -357,6 +393,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 Mon Nov 11 15:35:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11237257 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 7FAF11390 for ; Mon, 11 Nov 2019 15:35:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54B3A2196E for ; Mon, 11 Nov 2019 15:35:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hf+4XNVx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727054AbfKKPfn (ORCPT ); Mon, 11 Nov 2019 10:35:43 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41798 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727041AbfKKPfn (ORCPT ); Mon, 11 Nov 2019 10:35:43 -0500 Received: by mail-wr1-f66.google.com with SMTP id p4so15109326wrm.8; Mon, 11 Nov 2019 07:35:41 -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=woAoUEBHeVD99sqm9R/oLGqEsn7RdEquFOXTAzsNI9E=; b=Hf+4XNVxss3dRGKXHsghyNvGYybc0vBmGYQnzMXyEvSYwh9w4gycxnzg2/e+kW4JPk j05hP1eQy35FoK0wdYJvi+zyHXx2vn8yf357YwSK38lIr3obDR4PghTGkWsqf3I21O4o 9AoEUQbkq6Q7zcssFjr1UH3Ofxfo9Et+k7+TwZ9oFoVKqwZG4LcU/S5BWaUNVBBnmXtm bzAUYbEr1gS5llBtwxe0sIM7NuvsZdFBRm7O/u8jAmO23WVmQ1qTw2dCH0n4D/IJ6sEe yU4ckNo5YEtQjdYswfyV2+r9cDQnucaHLEq3m1OlSsBBFu3CSxfGT+ul9517pBPyS2AA qnVw== 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=woAoUEBHeVD99sqm9R/oLGqEsn7RdEquFOXTAzsNI9E=; b=Zxf/IlBzsYRiMLOEjmuf3260CabVWvaTVKwf3hFETsowdc/D3Rntx5bo3A/CW/Ct7E UvSf4W0ehGUDTTxh6tZd/fDnZnP3O7f3EBno5i3SJpJAPOUUWKkvB2Hr2b7eBG+uKz7U M6EEuKnB019DkrFyBxKbTb9EFyhW+0bqGxDcYQJsO8Hreb5iKELL6BoGxhTrfDF6uRut a5UIQnRVbzYkK+FqIP0x2N400b1vV2YYYrCy5Xvd2E8yZFq5jDIozjdvcTdaLgqPKQMS oeN82OHp3Wre8zmgCfe0+Cb9SJwx/b3xVgXjuDeaakP5bdx7gIqTcS1mSASFtmq1iGF9 Y5Rw== X-Gm-Message-State: APjAAAWOv4KMcGQ2UTNO10lM33VstL/yL2peYwcQnB+FR3udvP3TIrlN w6QKTdk71nl5QFx5GgCfPT8= X-Google-Smtp-Source: APXvYqxpjY2SQeglpZhzovZKv+yE64CDIhDiwNUnh+eT1Nd50lpWRchIofpZcmiT8EDz2uECm+hDtA== X-Received: by 2002:a5d:4584:: with SMTP id p4mr22205791wrq.345.1573486540599; Mon, 11 Nov 2019 07:35:40 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w81sm23965657wmg.5.2019.11.11.07.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 07:35:40 -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 , Paresh Chaudhary , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org, Rob Herring , Mark Rutland , devicetree@vger.kernel.org Subject: [v2 8/9] RFC/RFT: iio: maxim_thermocouple: add thermocouple_type sysfs attribute Date: Mon, 11 Nov 2019 16:35:16 +0100 Message-Id: <20191111153517.13862-9-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111153517.13862-1-andrea.merello@gmail.com> References: <20190923121714.13672-1-andrea.merello@gmail.com> <20191111153517.13862-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: Paresh Chaudhary 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 | 45 ++++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c index d1360605209c..6fa5ae9fb4ec 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,8 +211,11 @@ 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 +228,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 +248,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 +256,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 +279,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 Mon Nov 11 15:35:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 11237259 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 4754B1390 for ; Mon, 11 Nov 2019 15:35:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 257372190F for ; Mon, 11 Nov 2019 15:35:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="olV39VV2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727058AbfKKPfo (ORCPT ); Mon, 11 Nov 2019 10:35:44 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36364 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbfKKPfo (ORCPT ); Mon, 11 Nov 2019 10:35:44 -0500 Received: by mail-wr1-f66.google.com with SMTP id r10so15142950wrx.3; Mon, 11 Nov 2019 07:35:42 -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=rD8E1HPF+kOqPGWZ3GSIUtW8sHwcCfuIMp81Lz9qagk=; b=olV39VV2bMicVYtgEJMOEP/I/sVYYRwQT2FNCGB1ptoPCUallX/tABIsl3iUdZvpYs eo/QGZPWAvkq/L9wgbTJDg7biGY0HXEG14HcW+5UA71IU1smWMNepR6dMMwWoPfH/UzZ xOBETnYiFv/Os1mE9BNgvFVafWye2Y5X8iccT2W+kLeeQBZ869cmiLcAt3cf+96URuM1 iDjKSk0XkP1RJC8fkhkKhwRk5F8opKWauO9tYb+4zqi68vRfCMV5kz7e8BF2VS3GUZ3q 1oW+v7ijQ+6L0dyQkKhM1LgSNZa4c+PJDY5DGsShaLCVcGhASWcsqzn5TLqN+GXfnQew H0ig== 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=rD8E1HPF+kOqPGWZ3GSIUtW8sHwcCfuIMp81Lz9qagk=; b=jNvDW+NufJOeNQLuwvahwKJ6WaMAULmyAfm89FmNU10xXJgjdw4v6RwRQ4Wxxw+sUd DBn6srB57TwConNftabF4ClRBEyhggdGwuwnm2cm4+/Y4OfuSzWI3PRVqimc/kuJS8Lm kikUTZgEkQWE5SSz9ttCYTjhkD8K87okaKFJZneYVM0iHrakQzd7w2Owvh44q+Ju8OH0 ftn5WQXysQTZ/TW8TWkubrXfQRRnSwyxT53/T0kwuQ5BMbbIUEJ1JiGLOmjUSr4Ledpg N4l5ubvcHOILzCWG3fsRadYTzCIzXEir3JUGkXhuLcWTpUYYNq86dR/cPLJC4wQ63pZx y4jg== X-Gm-Message-State: APjAAAWedOd8/v66iKd8ik7+HbjvwTTRdEL10+u57b/n0Ns9f1K86PUv 9qVhTJy7rg76x393mSrDTdQ= X-Google-Smtp-Source: APXvYqzlisNq1rGjkud0bmNturkoWzuTDKeymsCfDn0F5kl3m+JUf4GWYBbqVaM75zrttJ2gk/2gzg== X-Received: by 2002:adf:fd91:: with SMTP id d17mr21001670wrr.214.1573486541905; Mon, 11 Nov 2019 07:35:41 -0800 (PST) Received: from NewMoon.iit.local ([90.147.180.254]) by smtp.gmail.com with ESMTPSA id w81sm23965657wmg.5.2019.11.11.07.35.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 07:35:41 -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 , Paresh Chaudhary , Matt Weber , Matt Ranostay , Chuhong Yuan , Daniel Gomez , linux-iio@vger.kernel.org, Rob Herring , Mark Rutland , devicetree@vger.kernel.org Subject: [v2 9/9] dt-bindings: iio: maxim_thermocouple: document new 'compatible' strings Date: Mon, 11 Nov 2019 16:35:17 +0100 Message-Id: <20191111153517.13862-10-andrea.merello@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191111153517.13862-1-andrea.merello@gmail.com> References: <20190923121714.13672-1-andrea.merello@gmail.com> <20191111153517.13862-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: Paresh Chaudhary 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>; };