Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp2003210ybj; Wed, 6 May 2020 08:58:56 -0700 (PDT) X-Google-Smtp-Source: APiQypI9md78m5JkniK9cJXh9rIbOIJ72EJQZvdMRe90iAZrPDasPY4Mwa/mqmt0WBVPaw+sDowA X-Received: by 2002:a05:6402:1482:: with SMTP id e2mr7537435edv.113.1588780736792; Wed, 06 May 2020 08:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588780736; cv=none; d=google.com; s=arc-20160816; b=t7NS3eLNeRmN8O78wrcQuFbzZ3ZJGMViCfvrs0CDlF2w9zaxedtq+P8mQJPQZufDfa q4Fcw02STvGmg6o4QBekDIwxThABK5Jt5d0dWQ7u2AVF5qsS8mXcbi9+wLtYDDMaThIf 2rYjj7wgIXe87ftndptGKuP948ewDbwz7NOFAjQ5YwQ+bH3TGLXFNVOfxVTGG7duMaiQ H+ybehu66d/e0eHCnR+NTqq+57DUEpOtTFwXyAM46DsQCW7qCPLnRiC/uPa/oNTTpDZ7 4mx46zAgHpvVUNMQZkAxgP0akkSLsAjBO2ZUnCpmrev1UL2t5mU3L2gYJ9/jiLKLTv4j 08PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mKpCjuzdZCHjolVpdDfscU7qJJTtSQZ+t9VhNB43JSw=; b=iKnF0/Ji8dN09/J4v9b6i0hNHtsIYHKQaCEwu53xxXxOrkmZzeAAFP2y2f+XK/vWJn gd+WpRCCX9gGw9SJaEg3CmcUQyZa9lRy4eEJmM5qiXtY63+8+dFUuT5EvS21b4LkoAG6 XrYV0AANiB9bccPhpx9cuPgLXZd49USx4VGPJmM1pwHB1BnVT48N0SuRQjS3gKuAoP6g fwcBtCORWVmH/1Z6wYk+SJ2rGcBdbEGiATUjRQRbI+1nX+HX9yc62ykkWdIxlFdeljnv OClv+2D+nYc9JEoRMEGF6/BiEjBMyvhGDvoJ37n+lRmbcW9c32srJFQD+Rhz7HyQB5wJ YkHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ar4xFgar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s26si1260005edq.433.2020.05.06.08.58.33; Wed, 06 May 2020 08:58:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ar4xFgar; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729874AbgEFP5I (ORCPT + 99 others); Wed, 6 May 2020 11:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728991AbgEFP5H (ORCPT ); Wed, 6 May 2020 11:57:07 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E592C061A0F; Wed, 6 May 2020 08:57:07 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id t11so1286871pgg.2; Wed, 06 May 2020 08:57:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mKpCjuzdZCHjolVpdDfscU7qJJTtSQZ+t9VhNB43JSw=; b=ar4xFgarysgBLcmwqP6yPq87M4Mk0brn0FOWV1bGn5/a7Ohmi2D4WL7MSiwJLQ99wh 7aD+BsOqsENG1cjrXegl6Ig/SvWxVL+mNBQ1Uj+OoCKN5GbXBDaSC2H83Osrb2KLmXCa kZ0N7rQiAFuFIMPrPuS1C3riz9BalKRJ4B/UPUoT9v0CzX1wT2cSGSV9gtH83AXauEX6 bJkuvrAxsnZVxv/G++H99E3hLQdohyPHuNEn/9UgshIM2kx+PXnUchpAXrd7oIAW8gkH cU8rz2/F9wNTD7m+f6W8lWEAOavifuXnJRf6bBq4W+kXBeEQptxW+8WnEA9/l2/F8fj4 NYfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=mKpCjuzdZCHjolVpdDfscU7qJJTtSQZ+t9VhNB43JSw=; b=bdndrDOAOPXCI+N51AQEt7bjGG+aWTCgf41HRQyr+oP0xC69Dsn3AqHRnwJF6wj7Kt sp/ZFysCuwwVaM7UjWN97BbGwi0R/33zLDUCney1/l6X8eIxC9z0RzyB3wVo+tPGZIlg o5g3Ct99cWbC7xGbqF9MMxp+CGPXg9TjEGeh1b6kb+cumLCVOP8RJHhRMnfbxtG7yZIJ EiJpfFrki033pfYg7sXHVYrQ8WRldH2LDjX6sxIo/XVZwhNa2oSroM1v6UqLlMznTh89 ue0PhNEODGSC22DexocCw+z43SExY+V13cAShJITWZa5fftjt5n0gZ30agBosTEYVUmf uZGg== X-Gm-Message-State: AGi0PuY0kiSYxGuXvOyegoqZ3fC24NQW7nLglsbroW+XFHlNseFi0Qvb B1xhFVcO0kk7ubdlia3+BxY= X-Received: by 2002:a63:150:: with SMTP id 77mr7231734pgb.136.1588780626809; Wed, 06 May 2020 08:57:06 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id r31sm1912232pgl.86.2020.05.06.08.57.05 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 May 2020 08:57:06 -0700 (PDT) Date: Wed, 6 May 2020 08:57:04 -0700 From: Guenter Roeck To: Eddie James Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-fsi@lists.ozlabs.org, devicetree@vger.kernel.org, jdelvare@suse.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh+dt@kernel.org Subject: Re: [PATCH 3/3] hwmon: (occ) Add new temperature sensor type Message-ID: <20200506155704.GA30543@roeck-us.net> References: <20200501150833.5251-1-eajames@linux.ibm.com> <20200501150833.5251-4-eajames@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200501150833.5251-4-eajames@linux.ibm.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 01, 2020 at 10:08:33AM -0500, Eddie James wrote: > The latest version of the On-Chip Controller (OCC) has a different > format for the temperature sensor data. Add a new temperature sensor > version to handle this data. > > Signed-off-by: Eddie James For my reference: Acked-by: Guenter Roeck I assume this depends on at least patch 2 of the series, so we'll have to wait for that to be accepted. Guenter > --- > drivers/hwmon/occ/common.c | 75 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 75 insertions(+) > > diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c > index 30e18eb60da7..52af0e728232 100644 > --- a/drivers/hwmon/occ/common.c > +++ b/drivers/hwmon/occ/common.c > @@ -41,6 +41,14 @@ struct temp_sensor_2 { > u8 value; > } __packed; > > +struct temp_sensor_10 { > + u32 sensor_id; > + u8 fru_type; > + u8 value; > + u8 throttle; > + u8 reserved; > +} __packed; > + > struct freq_sensor_1 { > u16 sensor_id; > u16 value; > @@ -307,6 +315,60 @@ static ssize_t occ_show_temp_2(struct device *dev, > return snprintf(buf, PAGE_SIZE - 1, "%u\n", val); > } > > +static ssize_t occ_show_temp_10(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + int rc; > + u32 val = 0; > + struct temp_sensor_10 *temp; > + struct occ *occ = dev_get_drvdata(dev); > + struct occ_sensors *sensors = &occ->sensors; > + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); > + > + rc = occ_update_response(occ); > + if (rc) > + return rc; > + > + temp = ((struct temp_sensor_10 *)sensors->temp.data) + sattr->index; > + > + switch (sattr->nr) { > + case 0: > + val = get_unaligned_be32(&temp->sensor_id); > + break; > + case 1: > + val = temp->value; > + if (val == OCC_TEMP_SENSOR_FAULT) > + return -EREMOTEIO; > + > + /* > + * VRM doesn't return temperature, only alarm bit. This > + * attribute maps to tempX_alarm instead of tempX_input for > + * VRM > + */ > + if (temp->fru_type != OCC_FRU_TYPE_VRM) { > + /* sensor not ready */ > + if (val == 0) > + return -EAGAIN; > + > + val *= 1000; > + } > + break; > + case 2: > + val = temp->fru_type; > + break; > + case 3: > + val = temp->value == OCC_TEMP_SENSOR_FAULT; > + break; > + case 4: > + val = temp->throttle * 1000; > + break; > + default: > + return -EINVAL; > + } > + > + return snprintf(buf, PAGE_SIZE - 1, "%u\n", val); > +} > + > static ssize_t occ_show_freq_1(struct device *dev, > struct device_attribute *attr, char *buf) > { > @@ -745,6 +807,10 @@ static int occ_setup_sensor_attrs(struct occ *occ) > num_attrs += (sensors->temp.num_sensors * 4); > show_temp = occ_show_temp_2; > break; > + case 0x10: > + num_attrs += (sensors->temp.num_sensors * 5); > + show_temp = occ_show_temp_10; > + break; > default: > sensors->temp.num_sensors = 0; > } > @@ -844,6 +910,15 @@ static int occ_setup_sensor_attrs(struct occ *occ) > attr->sensor = OCC_INIT_ATTR(attr->name, 0444, > show_temp, NULL, 3, i); > attr++; > + > + if (sensors->temp.version == 0x10) { > + snprintf(attr->name, sizeof(attr->name), > + "temp%d_max", s); > + attr->sensor = OCC_INIT_ATTR(attr->name, 0444, > + show_temp, NULL, > + 4, i); > + attr++; > + } > } > } >