Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp4023909ybh; Tue, 17 Mar 2020 10:46:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsqmLeGPzua+M/o/8pSNA0k3qtWURbmgyJJvVADRCQuqKC9yDx43s2lgDVkN4soZ68LpKqD X-Received: by 2002:a9d:4810:: with SMTP id c16mr370009otf.248.1584467189539; Tue, 17 Mar 2020 10:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584467189; cv=none; d=google.com; s=arc-20160816; b=zLLySgebtpUl6F3ObvutvdVHb3XQ6/5pdr4raxpk2PfDJnNh/aZU9c6VnwQH/vIvu5 FtytqvRaAyi2q/70QyVKTjFPKwJ3JrLFzltBnZJK1W3a+TEhpjxYSyLho3LtwMihOYW9 4vHY4rKATjkEY9WkAMJTRbseKbg85+Iedn3AxzzDeXiXbyNVVclg0Nka89zYsQRX1dMl /S6DCBWWjzmB9eHQPybOBluFUk+eZWYeKD/MdUnQwFEVmNaMEKganBalt1iJTHzhKvPq SM+6v/My0YNshKRLt9ZbwuBS1obZdDWMrN+K0w8eMwQW8tJdc14kV4g6rIBwcunCrsFp sOJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=HFObV0SspXma1gLo5gg6wz6AEKM5WgviBnCNdKtRKgU=; b=cteJSMyJVJYAQAXMY222Oi2I4v4ReQ4BgEjKhHZGtdel+3eDUA677Q4H1J9H2xvxCu 6h/plbkhZUKAMAeYYyvgIKFs+F019REe/pAteJhdUsgJ62jMvYBVkyQlbTWWkhzKXDyD jFO/l7GxHBgm3Wtl51uzDL8NguP9haebdsLke6/YIKnqcx01arXuLCwQwOF+u/dtfQyc 72cOD8R4IFFaDnc1eERCYDgLrdZ+9o7rg8Rg2yat5I3GCJyEd/VzIL8dwUrTJUMdcyRf SA0odYFp68d4jjidw6OTCQQK8XtuibNiS9RuHoCeBQNMH8gyVmlpB19O3DmD5e0EHYbZ XTuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=ne+bVIFR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m20si2042084otf.46.2020.03.17.10.46.16; Tue, 17 Mar 2020 10:46:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=ne+bVIFR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726692AbgCQRoU (ORCPT + 99 others); Tue, 17 Mar 2020 13:44:20 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:33695 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbgCQRoT (ORCPT ); Tue, 17 Mar 2020 13:44:19 -0400 Received: by mail-ot1-f65.google.com with SMTP id x26so5549278otk.0 for ; Tue, 17 Mar 2020 10:44:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gateworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HFObV0SspXma1gLo5gg6wz6AEKM5WgviBnCNdKtRKgU=; b=ne+bVIFRKWbvsEFwYhkf7+KIi+MANbz/V+ZJeByU8P2/DmFk2G4m83PxdKxp14ZcyZ zpwcxW3Q/0jmHunemkBhZeEPnLWnDHgffP+YxHm5MkqUx4TxPhzxRkGStLVz3DvPpdNB dwmc58QWAwjatkC+hkCLDQC8XLreSV1Hlay2BRDjaFXacT1hvgKONvUPE37D7idzZkRI F6m6NaZmFEw/Um4fSpLT/yA30FyLmtbJvMvIcFAsjkflCF0WJsKXcFwO+qfw0n3hzJJd 3oZs9wrI7l5TRThsC9zKWUtQM37zdpS32x5ieEgBUMAJdGFtZiY7INTl8fohCEaDHjKk YtWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HFObV0SspXma1gLo5gg6wz6AEKM5WgviBnCNdKtRKgU=; b=C90SVqMoeUM7gXxQQzYAld2qEgSb18yL6VET2ApCCXUWufqVTPm5J6M5iyX+N759P4 667/TFnC/5fUIFyfV/LcIiIOaukXIKAoBmPlWlKoocRKo6T914ehDB6F7Q3uhrrUP7Uz 3hpZl3JQfmBxJYzNPyyoAWPbWWr5qRtuHSxrFAtq6xZ9d89QOz+y/DGRWvsAGV+jxIvA RAMV0RWmdDWf1hIdBlE6MY1jqUMnPn5An1CZuRfxqDZ/S6GxTHTzKuccZ4BLi6sjY0eT yCYgbgfUsNKeTipvy7dM3Gl1amKV/aMcwqaGA1eCWCerfs0v+VTMrnRydVTfmg8IWuo8 XjIA== X-Gm-Message-State: ANhLgQ1j179bz3neeMpe3A2E0DoiynEF99H6QOO8MvSNO+i/pDqE9fMb 2xuN2ai25FpKhKDFU0S88p1zWNq7XTrATslcIBT/Pw== X-Received: by 2002:a05:6830:1e06:: with SMTP id s6mr385357otr.28.1584467057819; Tue, 17 Mar 2020 10:44:17 -0700 (PDT) MIME-Version: 1.0 References: <1584464453-28200-1-git-send-email-tharvey@gateworks.com> <1584464453-28200-4-git-send-email-tharvey@gateworks.com> <8570eb47-d446-9fcb-1033-682114c9ca59@roeck-us.net> In-Reply-To: <8570eb47-d446-9fcb-1033-682114c9ca59@roeck-us.net> From: Tim Harvey Date: Tue, 17 Mar 2020 10:44:06 -0700 Message-ID: Subject: Re: [PATCH v6 3/3] hwmon: add Gateworks System Controller support To: Guenter Roeck Cc: Lee Jones , Jean Delvare , Linux HWMON List , Rob Herring , Frank Rowand , Device Tree Mailing List , open list , Robert Jones Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 17, 2020 at 10:18 AM Guenter Roeck wrote: > > On 3/17/20 10:00 AM, Tim Harvey wrote: > > The Gateworks System Controller has a hwmon sub-component that exposes > > up to 16 ADC's, some of which are temperature sensors, others which are > > voltage inputs. The ADC configuration (register mapping and name) is > > configured via device-tree and varies board to board. > > > > Cc: Guenter Roeck > > Signed-off-by: Tim Harvey > > --- > > v6: > > - fix size of info field > > - improve pwm output control documentation > > - include unit suffix in divider and offset > > - change adc subnode name to gsc-adc > > - change fan base to fan subnode > > - change adc type to mode > > - fix voltage offset scaling > > > > v5: > > - fix various checkpatch issues > > - correct gsc-hwmon.rst in MAINTAINERS > > - encorporate Gunter's feedback: > > - switch to SENSOR_DEVICE_ATTR_{RW,RO} > > - use tmp value to avoid excessive pointer deference > > - simplify shift operation > > - scale voffset once > > - simplify is_visible function > > - remove empty line at end of file > > > > v4: > > - adjust for uV offset from device-tree > > - remove unnecessary optional write function > > - remove register range check > > - change dev_err prints to use gsc dev > > - hard-code resolution/scaling for raw adcs > > - describe units of ADC resolution > > - move to using pwm_auto_point_{pwm,temp} for FAN PWM > > - ensure space before/after operators > > - remove unnecessary parens > > - remove more debugging > > - add default case and comment for type_voltage > > - remove unnecessary index bounds checks for channel > > - remove unnecessary clearing of struct fields > > - added Documentation/hwmon/gsc-hwmon.rst > > > > v3: > > - add voltage_raw input type and supporting fields > > - add channel validation to is_visible function > > - remove unnecessary channel validation from read/write functions > > > > v2: > > - change license comment style > > - remove DEBUG > > - simplify regmap_bulk_read err check > > - remove break after returns in switch statement > > - fix fan setpoint buffer address > > - remove unnecessary parens > > - consistently use struct device *dev pointer > > - change license/comment block > > - add validation for hwmon child node props > > - move parsing of of to own function > > - use strlcpy to ensure null termination > > - fix static array sizes and removed unnecessary initializers > > - dynamically allocate channels > > - fix fan input label > > - support platform data > > - fixed whitespace issues > > --- > > Documentation/hwmon/gsc-hwmon.rst | 53 +++++ > > Documentation/hwmon/index.rst | 1 + > > MAINTAINERS | 3 + > > drivers/hwmon/Kconfig | 9 + > > drivers/hwmon/Makefile | 1 + > > drivers/hwmon/gsc-hwmon.c | 372 ++++++++++++++++++++++++++++++++ > > include/linux/platform_data/gsc_hwmon.h | 44 ++++ > > 7 files changed, 483 insertions(+) > > create mode 100644 Documentation/hwmon/gsc-hwmon.rst > > create mode 100644 drivers/hwmon/gsc-hwmon.c > > create mode 100644 include/linux/platform_data/gsc_hwmon.h > > > > diff --git a/Documentation/hwmon/gsc-hwmon.rst b/Documentation/hwmon/gsc-hwmon.rst > > new file mode 100644 > > index 00000000..ffac392 > > --- /dev/null > > +++ b/Documentation/hwmon/gsc-hwmon.rst > > @@ -0,0 +1,53 @@ > > +.. SPDX-License-Identifier: GPL-2.0 > > + > > +Kernel driver gsc-hwmon > > +======================= > > + > > +Supported chips: Gateworks GSC > > +Datasheet: http://trac.gateworks.com/wiki/gsc > > +Author: Tim Harvey > > + > > +Description: > > +------------ > > + > > +This driver supports hardware monitoring for the temperature sensor, > > +various ADC's connected to the GSC, and optional FAN controller available > > +on some boards. > > + > > + > > +Voltage Monitoring > > +------------------ > > + > > +The voltage inputs are scaled either internally or by the driver depending > > +on the GSC version and firmware. The values returned by the driver do not need > > +further scaling. The voltage input labels provide the voltage rail name: > > + > > +inX_input Measured voltage (mV). > > +inX_label Name of voltage rail. > > + > > + > > +Temperature Monitoring > > +---------------------- > > + > > +Temperatures are measured with 12-bit or 10-bit resolution and are scaled > > +either internally or by the driver depending on the GSC version and firmware. > > +The values returned by the driver reflect millidegree Celcius: > > + > > +tempX_input Measured temperature. > > +tempX_label Name of temperature input. > > + > > + > > +PWM Output Control > > +------------------ > > + > > +The GSC features 1 PWM output that operates in automatic mode where the > > +PWM value will be scalled depending on 6 temperature boundaries. > > +The tempeature boundaries are read-write and in millidegree Celcius and the > > +read-only PWM values range from 0 (off) to 255 (full speed). > > +Fan speed will be set to minimum (off) when the temperature sensor reads > > +less than pwm1_auto_point1_temp and maximum when the temperature sensor > > +equals or exceeds pwm1_auto_point6_temp. > > + > > +pwm1_auto_point[1-6]_pwm PWM value. > > +pwm1_auto_point[1-6]_temp Temperature boundary. > > + > > diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst > > index 43cc605..a4fab69 100644 > > --- a/Documentation/hwmon/index.rst > > +++ b/Documentation/hwmon/index.rst > > @@ -58,6 +58,7 @@ Hardware Monitoring Kernel Drivers > > ftsteutates > > g760a > > g762 > > + gsc-hwmon > > gl518sm > > hih6130 > > ibmaem > > diff --git a/MAINTAINERS b/MAINTAINERS > > index bb79b60..3f15542 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -6846,6 +6846,9 @@ S: Maintained > > F: Documentation/devicetree/bindings/mfd/gateworks-gsc.yaml > > F: drivers/mfd/gateworks-gsc.c > > F: include/linux/mfd/gsc.h > > +F: Documentation/hwmon/gsc-hwmon.rst > > +F: drivers/hwmon/gsc-hwmon.c > > +F: include/linux/platform_data/gsc_hwmon.h > > > > GCC PLUGINS > > M: Kees Cook > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig > > index 23dfe84..99dae13 100644 > > --- a/drivers/hwmon/Kconfig > > +++ b/drivers/hwmon/Kconfig > > @@ -494,6 +494,15 @@ config SENSORS_F75375S > > This driver can also be built as a module. If so, the module > > will be called f75375s. > > > > +config SENSORS_GSC > > + tristate "Gateworks System Controller ADC" > > + depends on MFD_GATEWORKS_GSC > > + help > > + Support for the Gateworks System Controller A/D converters. > > + > > + To compile this driver as a module, choose M here: > > + the module will be called gsc-hwmon. > > + > > config SENSORS_MC13783_ADC > > tristate "Freescale MC13783/MC13892 ADC" > > depends on MFD_MC13XXX > > diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile > > index 6db5db9..259cba7 100644 > > --- a/drivers/hwmon/Makefile > > +++ b/drivers/hwmon/Makefile > > @@ -71,6 +71,7 @@ obj-$(CONFIG_SENSORS_G760A) += g760a.o > > obj-$(CONFIG_SENSORS_G762) += g762.o > > obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o > > obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o > > +obj-$(CONFIG_SENSORS_GSC) += gsc-hwmon.o > > obj-$(CONFIG_SENSORS_GPIO_FAN) += gpio-fan.o > > obj-$(CONFIG_SENSORS_HIH6130) += hih6130.o > > obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o > > diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c > > new file mode 100644 > > index 00000000..c498786 > > --- /dev/null > > +++ b/drivers/hwmon/gsc-hwmon.c > > @@ -0,0 +1,372 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Driver for Gateworks System Controller Hardware Monitor module > > + * > > + * Copyright (C) 2020 Gateworks Corporation > > + */ > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > + > > +#define GSC_HWMON_MAX_TEMP_CH 16 > > +#define GSC_HWMON_MAX_IN_CH 16 > > + > > +#define GSC_HWMON_RESOLUTION 12 > > +#define GSC_HWMON_VREF 2500 > > + > > +struct gsc_hwmon_data { > > + struct gsc_dev *gsc; > > + struct device *dev; > > What is 'dev' used for ? I don't think it is necessary. > Agreed - will remove. Thanks! Tim