From patchwork Fri May 19 18:05:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9737875 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6986A6034C for ; Fri, 19 May 2017 18:06:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52C0728503 for ; Fri, 19 May 2017 18:06:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 479D228576; Fri, 19 May 2017 18:06:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2B0028503 for ; Fri, 19 May 2017 18:06:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755536AbdESSGa (ORCPT ); Fri, 19 May 2017 14:06:30 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:49822 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753908AbdESSGM (ORCPT ); Fri, 19 May 2017 14:06:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4uAp6KM18nxknfr+IthD3oUIkqUhxWsmQpKWSb6g17A=; b=LMJfWBhRiaboJm3IP2u50mHSH QfSgH2FzLDkWhDgmIYxl+O+A6fGsdD8+SuSk2ki8Iz53K6gSoEzVuv73NoBt/40+sPard0G2kNUPQ sFZlPS6bbUTmYFsS6EbFUG4tNRmnLJEwRTUL5+xuHktLHWks1joGfrstU327WiqXaNWK7+7LKpSLe +S1pI1NCR8x7DJNdwgzDdQ/zH9wLHS5XWnTAFd4DKVbSt337xXRAy7BGd6gX5t+61Su9HeEmjjISX AOSDQQyfbSwXEtKpbJzhXnQwyflyPmQsus3H1kgEbZs2/OhGiPnl1gaasywmJzWr0B8wO6ahevurg /ZJ6HFW+w==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:33174 helo=localhost) by bh-25.webhostbox.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1dBmHx-003VQv-Ov; Fri, 19 May 2017 18:06:11 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 3/4] hwmon: (nct6775) Improve fan detection Date: Fri, 19 May 2017 11:05:59 -0700 Message-Id: <1495217160-32336-3-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495217160-32336-1-git-send-email-linux@roeck-us.net> References: <1495217160-32336-1-git-send-email-linux@roeck-us.net> X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Recent chips support multiple pins for fan speed inputs and fan control outputs. Examine all of them to determine supported fan controls. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 9d8d25c54415..769daa78c560 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -105,6 +105,7 @@ MODULE_PARM_DESC(fan_debounce, "Enable debouncing for fan RPM signal"); #define NCT6775_LD_ACPI 0x0a #define NCT6775_LD_HWM 0x0b #define NCT6775_LD_VID 0x0d +#define NCT6775_LD_12 0x12 #define SIO_REG_LDSEL 0x07 /* Logical device select */ #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ @@ -3392,6 +3393,8 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm5pin = false; pwm6pin = false; } else { /* NCT6779D, NCT6791D, NCT6792D, or NCT6793D */ + int regval_1b, regval_2a, regval_eb; + regval = superio_inb(sioreg, 0x1c); fan3pin = !(regval & BIT(5)); @@ -3402,17 +3405,43 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm4pin = !(regval & BIT(1)); pwm5pin = !(regval & BIT(2)); - fan4min = fan4pin; - - if (data->kind == nct6791 || data->kind == nct6792 || - data->kind == nct6793) { - regval = superio_inb(sioreg, 0x2d); - fan6pin = (regval & BIT(1)); - pwm6pin = (regval & BIT(0)); - } else { /* NCT6779D */ + regval = superio_inb(sioreg, 0x2d); + switch (data->kind) { + case nct6791: + case nct6792: + fan6pin = regval & BIT(1); + pwm6pin = regval & BIT(0); + break; + case nct6793: + regval_1b = superio_inb(sioreg, 0x1b); + regval_2a = superio_inb(sioreg, 0x2a); + + if (!pwm5pin) + pwm5pin = regval & BIT(7); + fan6pin = regval & BIT(1); + pwm6pin = regval & BIT(0); + if (!fan5pin) + fan5pin = regval_1b & BIT(5); + + superio_select(sioreg, NCT6775_LD_12); + regval_eb = superio_inb(sioreg, 0xeb); + if (!fan5pin) + fan5pin = regval_eb & BIT(5); + if (!pwm5pin) + pwm5pin = (regval_eb & BIT(4)) && + !(regval_2a & BIT(0)); + if (!fan6pin) + fan6pin = regval_eb & BIT(3); + if (!pwm6pin) + pwm6pin = regval_eb & BIT(2); + break; + default: /* NCT6779D */ fan6pin = false; pwm6pin = false; + break; } + + fan4min = fan4pin; } /* fan 1 and 2 (0x03) are always present */