From patchwork Fri Oct 7 15:22:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pantelis Antoniou X-Patchwork-Id: 679414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3srDJm1xJDz9s3v for ; Sat, 8 Oct 2016 02:41:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b=btc2TV/G; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bsXFe-0004If-Qd; Fri, 07 Oct 2016 15:39:58 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bsXBu-0008OD-1m for linux-mtd@bombadil.infradead.org; Fri, 07 Oct 2016 15:36:06 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by casper.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bsX0z-0008Nj-HG for linux-mtd@lists.infradead.org; Fri, 07 Oct 2016 15:24:50 +0000 Received: by mail-wm0-x233.google.com with SMTP id i130so46105790wmg.1 for ; Fri, 07 Oct 2016 08:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nk7a+3jyVE6r90czByk90dIcupmeKqRhxZ7v1TEX+i0=; b=btc2TV/GjlIC9hU/1X9lE4VR/3etpTYZ8MDTv+wcN9L3v40KakOP/z+7oVeooLTYaq qVPGtZB6w23uVOxU2kkf3IgcZuc0aMo6nfrKkfTg4BRlG6YvFLIIXKPPI24wrJRuEOzr EHKQHCmE3TrqM7oRUvXv0Jg6eRm9f11a0uOWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nk7a+3jyVE6r90czByk90dIcupmeKqRhxZ7v1TEX+i0=; b=enVV74dMOdozHiWYrjBfzZCOpK45LIPNNGbf0AFrr8dk5FBQShYFR1uXr4I+IRjCGf TgQSd1JoyBKBDy9CgooGjJ27oyWokbPbevuieilrIKRXJyPHP2ijk8v3HtEAq82QlAkm UoppA6/kA664DYog3JtPnsDkcVwf85BasDsDfuQyXjAN/SFsq8gtPyKL3d+f6xKe+7w3 pZq2WPnwNwTAJdQNuRzUUzpWodlO/rlLZd7jbtJqZHusudybc3VKCDCz2MS5SHhGPbUv NU7EyGgU05xD4xB1BeHVrwsDjcDKImJLKeKXhXnJZMrV5fE3Q7Ry4rs6eB4gAolOtuph NP/A== X-Gm-Message-State: AA6/9RmOHm8sjOXmNxZ6aFcskn4c8dE4TW42U8lTuTmNrSWM+NxB5vso140Dxjv62v3I2g== X-Received: by 10.28.95.87 with SMTP id t84mr18826678wmb.51.1475853871983; Fri, 07 Oct 2016 08:24:31 -0700 (PDT) Received: from localhost.localdomain ([195.97.110.117]) by smtp.gmail.com with ESMTPSA id f2sm3491056wjr.2.2016.10.07.08.24.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Oct 2016 08:24:31 -0700 (PDT) From: Pantelis Antoniou To: Lee Jones Subject: [PATCH 7/7] hwmon: ptx1kbf: Add PTX1K I2CS BootFPGA sensor driver Date: Fri, 7 Oct 2016 18:22:04 +0300 Message-Id: <1475853724-22557-8-git-send-email-pantelis.antoniou@konsulko.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1475853724-22557-1-git-send-email-pantelis.antoniou@konsulko.com> References: <1475853724-22557-1-git-send-email-pantelis.antoniou@konsulko.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161007_162449_690928_C50D94D1 X-CRM114-Status: GOOD ( 24.85 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-2.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:233 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Jean Delvare , linux-hwmon@vger.kernel.org, linux-watchdog@vger.kernel.org, Georgi Vlaev , Frank Rowand , Pantelis Antoniou , linux-kernel@vger.kernel.org, JawaharBalaji Thirumalaisamy , Wim Van Sebroeck , Rob Herring , linux-mtd@lists.infradead.org, Brian Norris , David Woodhouse , Guenter Roeck MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Georgi Vlaev The drivers allows reading CPU, PCH and DIMM modules teperatures from the I2CS FPGA via the SMLink1 to the PCH. Signed-off-by: Georgi Vlaev Signed-off-by: Guenter Roeck [Ported from Juniper kernel] Signed-off-by: Pantelis Antoniou --- drivers/hwmon/Kconfig | 17 ++++++ drivers/hwmon/Makefile | 1 + drivers/hwmon/jnx_ptx1kbf_hwmon.c | 123 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 drivers/hwmon/jnx_ptx1kbf_hwmon.c diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index b9348d2..5b66c7b 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -674,6 +674,23 @@ config SENSORS_JNX_FAN This driver can also be built as a module. If so, the module will be called jnx-fan. +config SENSORS_JNX_PTX1KBF + tristate "Juniper Networks PTX1000 I2CS BootFPGA thermal sensors" + depends on MFD_JUNIPER_PTX1KBF + help + If you say yes here you get support for the hardware + monitoring features of the Juniper Networks PTX1000 I2CS BootFPGA + on the LPC bus. The CPU's digital thermal sensor can be read over + the PECI interface. PECI is connected to the PCH and the PCH's + Management Engine (ME) can be configured to poll CPU and DIMM + temperatures over the PECI interface. Then, it is possible for an + external I2C master (in the I2CS FPGA) to read CPU, DIMM and PCH + temperatures from the PCH over SMLink1 (which is connected to the board + I2C tree). + + This driver can also be built as a module. If so, the module + will be called jnx_ptx1kbf_hwmon. + config SENSORS_POWR1220 tristate "Lattice POWR1220 Power Monitoring" depends on I2C diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index eea631e..a3dedef 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_SENSORS_INA3221) += ina3221.o obj-$(CONFIG_SENSORS_IT87) += it87.o obj-$(CONFIG_SENSORS_JC42) += jc42.o obj-$(CONFIG_SENSORS_JNX_FAN) += jnx-fan.o +obj-$(CONFIG_SENSORS_JNX_PTX1KBF) += jnx_ptx1kbf_hwmon.o obj-$(CONFIG_SENSORS_JZ4740) += jz4740-hwmon.o obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o obj-$(CONFIG_SENSORS_K10TEMP) += k10temp.o diff --git a/drivers/hwmon/jnx_ptx1kbf_hwmon.c b/drivers/hwmon/jnx_ptx1kbf_hwmon.c new file mode 100644 index 0000000..a9d6562 --- /dev/null +++ b/drivers/hwmon/jnx_ptx1kbf_hwmon.c @@ -0,0 +1,123 @@ +/* + * Juniper Networks PTX1K RCB I2CS Boot FPGA hwmon driver + * + * Copyright (C) 2014 Juniper Networks. All rights reserved. + * Author: Georgi Vlaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "jnx-ptx1kbf-hwmon" + +struct bf_hwmon { + void __iomem *base; +}; + +static const char *const bf_temp_label[] = { + "CPU", "PCH", "DIMM1", "DIMM2" +}; + +static ssize_t bf_show_temp(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct bf_hwmon *hwmon = dev_get_drvdata(dev); + int channel = to_sensor_dev_attr(attr)->index; + + return sprintf(buf, "%d\n", be16_to_cpu(ioread16(hwmon->base + + BOOT_FPGA_CPU_TEMP_MSB + (channel * 2)))); +} + +static ssize_t bf_show_label(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int channel = to_sensor_dev_attr(attr)->index; + + return sprintf(buf, "%s\n", bf_temp_label[channel]); +} + +/* CPU Temp */ +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, bf_show_temp, NULL, 0); +static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, bf_show_label, NULL, 0); +/* PCH Temp */ +static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, bf_show_temp, NULL, 1); +static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, bf_show_label, NULL, 1); +/* DIMM1 Temp */ +static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, bf_show_temp, NULL, 2); +static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, bf_show_label, NULL, 2); +/* DIMM2 Temp */ +static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, bf_show_temp, NULL, 3); +static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, bf_show_label, NULL, 3); + +static struct attribute *bf_attrs[] = { + &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_temp1_label.dev_attr.attr, + &sensor_dev_attr_temp2_input.dev_attr.attr, + &sensor_dev_attr_temp2_label.dev_attr.attr, + &sensor_dev_attr_temp3_input.dev_attr.attr, + &sensor_dev_attr_temp3_label.dev_attr.attr, + &sensor_dev_attr_temp4_input.dev_attr.attr, + &sensor_dev_attr_temp4_label.dev_attr.attr, + NULL +}; + +ATTRIBUTE_GROUPS(bf); + +static int bf_hwmon_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device *hwmon_dev; + struct bf_hwmon *hwmon; + struct resource *mem; + + hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL); + if (!hwmon) + return -ENOMEM; + + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!mem) { + dev_err(&pdev->dev, "Failed to get platform mmio resource\n"); + return -ENOENT; + } + + hwmon->base = devm_ioremap_nocache(dev, mem->start, resource_size(mem)); + if (IS_ERR(hwmon->base)) { + dev_err(dev, "Failed to ioremap mmio memory\n"); + return PTR_ERR(hwmon->base); + } + + hwmon_dev = devm_hwmon_device_register_with_groups(dev, "jnx_ptx1kbf", + hwmon, bf_groups); + return PTR_ERR_OR_ZERO(hwmon_dev); +} + +static struct platform_driver bf_hwmon_driver = { + .probe = bf_hwmon_probe, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +module_platform_driver(bf_hwmon_driver); + +MODULE_DESCRIPTION("Juniper Networks PTX1K RCB I2CS Boot FPGA hwmon driver"); +MODULE_AUTHOR("Georgi Vlaev "); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:" DRVNAME);