From patchwork Sat Sep 15 23:30:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10601603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 641B417D5 for ; Sat, 15 Sep 2018 23:30:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EE4C2A146 for ; Sat, 15 Sep 2018 23:30:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 431782A151; Sat, 15 Sep 2018 23:30:51 +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.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_SBL 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 DA2072A146 for ; Sat, 15 Sep 2018 23:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726188AbeIPEvf (ORCPT ); Sun, 16 Sep 2018 00:51:35 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37450 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbeIPEvf (ORCPT ); Sun, 16 Sep 2018 00:51:35 -0400 Received: by mail-pf1-f195.google.com with SMTP id h69-v6so5897759pfd.4 for ; Sat, 15 Sep 2018 16:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=f6BbZtm21ZHeElLdele9VyHdRemhuQoBdgkIUp6RoNc=; b=in8jRErS/IMfVy0BjTOPqBMtQksFwQbFNU92yDYpkiuGgSeW7G5HZTjtYqkhUKkuNs ke1Ix271c68pWA32Wh5bx/cuZps0gUnKzV05/lHh2TwV0SUvGUS2rtTBNON86JYCQIa6 JC9/qRnfJgcf2K1A0E6253qakafC4ODET/avI5gNtmhr35ydZC7qF8n7jCD7lNH5fkLG xGtj+yvzDsoFdfvwZhmumAAGNnILI/rSFh1RyFOEzHbOKCbGqKgVvBJzvBWO7OPVHpWM BtpQKDMCD+cKiznePBrHzgw/gnHMHwJQrtXBZmc2cIvSJz668Th407aq9Fmkv4oQ9LVX fRZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=f6BbZtm21ZHeElLdele9VyHdRemhuQoBdgkIUp6RoNc=; b=Ua7Kb8Kr77cxLrsnBzY0uyLKLTdE8eQVA0zAokMd1iq7/p5qwV35xPLc5jQaIYUB0D hFZ2ilc7dTGQ7LnYiT5CZ0941ldCpA6jBOcqq4ecLloZDqX2Pu8/eA7uU/tRWiXt6D+Z a/taAtrkVqaOAgcS7IXsgQmCmPpW3tg0IPoqDMgUzycqo4uQdDUL1ffvp6/SXBK977kR NT1fC0mdSur2Lu84CGts3F5YD09Q6t0NB3y5NUK9vQNM7gs2sjcIxAYIBdRnCCZQ7Uos j6bOLJvr+xdlciw6sMXDNwlJIWvNfdOB3LWrhNrhkGrnWLJR4Rpq9/YfskAChesn10/f SBcw== X-Gm-Message-State: APzg51Bpbsk3+RIOYfEsPBooepxNzsTgJFPmzOXl8wErt0TwXi9XYNvG zUAB3Zufr4oBQGFi36TOCamlGwf6 X-Google-Smtp-Source: ANB0VdakVxdSNziz5F94A+Y4Xg423GwFgLU8Y5iK+Sr2qm8VdX8JtZIqYUEO3iz0GQAFK7hY00o8ug== X-Received: by 2002:a63:b812:: with SMTP id p18-v6mr17344134pge.156.1537054249068; Sat, 15 Sep 2018 16:30:49 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id p1-v6sm12810505pfn.53.2018.09.15.16.30.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Sep 2018 16:30:48 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck , Robert Kern Subject: [PATCH v3 2/2] hwmon: (nct6775) Fix RPM output for fan7 on NCT6796D Date: Sat, 15 Sep 2018 16:30:43 -0700 Message-Id: <1537054243-26154-2-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537054243-26154-1-git-send-email-linux@roeck-us.net> References: <1537054243-26154-1-git-send-email-linux@roeck-us.net> 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 fan7 on NCT6796D does not have a fan count register; it only has an RPM register. Switch to using RPM registers to read the fan speed for all chips supporting it to solve the problem for good. Reported-by: Robert Kern Cc: Robert Kern Fixes: 81820059a428 ("hwmon: (nct6775) Add support for NCT6796D") Signed-off-by: Guenter Roeck --- v3: Further minimize changes: Add new dummy function to convert register values into rpm v2: NCT6795D/NCT6796D still have the old RPM registers, only the register at 0x660 is new and has to be used. Minimize required changes by using the 'old' RPM registers where possible. drivers/hwmon/nct6775.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 202a2b422461..af4d8792bbb5 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -502,7 +502,7 @@ static const s8 NCT6779_BEEP_BITS[] = { 30, 31 }; /* intrusion0, intrusion1 */ static const u16 NCT6779_REG_FAN[] = { - 0x4b0, 0x4b2, 0x4b4, 0x4b6, 0x4b8, 0x4ba, 0x660 }; + 0x4c0, 0x4c2, 0x4c4, 0x4c6, 0x4c8, 0x4ca, 0x660 }; static const u16 NCT6779_REG_FAN_PULSES[NUM_FAN] = { 0x644, 0x645, 0x646, 0x647, 0x648, 0x649 }; @@ -924,6 +924,11 @@ static unsigned int fan_from_reg16(u16 reg, unsigned int divreg) return 1350000U / (reg << divreg); } +static unsigned int fan_from_reg_rpm(u16 reg, unsigned int divreg) +{ + return reg; +} + static u16 fan_to_reg(u32 fan, unsigned int divreg) { if (!fan) @@ -1284,7 +1289,7 @@ static bool is_word_sized(struct nct6775_data *data, u16 reg) case nct6795: case nct6796: return reg == 0x150 || reg == 0x153 || reg == 0x155 || - ((reg & 0xfff0) == 0x4b0 && (reg & 0x000f) < 0x0b) || + (reg & 0xfff0) == 0x4c0 || reg == 0x402 || reg == 0x63a || reg == 0x63c || reg == 0x63e || reg == 0x640 || reg == 0x642 || reg == 0x64a || @@ -3868,7 +3873,7 @@ static int nct6775_probe(struct platform_device *pdev) data->ALARM_BITS = NCT6779_ALARM_BITS; data->BEEP_BITS = NCT6779_BEEP_BITS; - data->fan_from_reg = fan_from_reg13; + data->fan_from_reg = fan_from_reg_rpm; data->fan_from_reg_min = fan_from_reg13; data->target_temp_mask = 0xff; data->tolerance_mask = 0x07; @@ -3949,7 +3954,7 @@ static int nct6775_probe(struct platform_device *pdev) data->ALARM_BITS = NCT6791_ALARM_BITS; data->BEEP_BITS = NCT6779_BEEP_BITS; - data->fan_from_reg = fan_from_reg13; + data->fan_from_reg = fan_from_reg_rpm; data->fan_from_reg_min = fan_from_reg13; data->target_temp_mask = 0xff; data->tolerance_mask = 0x07;