From patchwork Thu Sep 20 13:45:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10607793 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 3C6696CB for ; Thu, 20 Sep 2018 13:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CF1B2D74D for ; Thu, 20 Sep 2018 13:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2111E2D758; Thu, 20 Sep 2018 13:46:00 +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 C01D92D74D for ; Thu, 20 Sep 2018 13:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731416AbeITT3d (ORCPT ); Thu, 20 Sep 2018 15:29:33 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39435 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbeITT3d (ORCPT ); Thu, 20 Sep 2018 15:29:33 -0400 Received: by mail-pl1-f195.google.com with SMTP id w14-v6so4382779plp.6 for ; Thu, 20 Sep 2018 06:45:59 -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=wJ+e20JFb7CNZ75XebiVJ+fNiWdTFTCThd6HRogpUyY=; b=D9scAJ5RNzpyji+FHY/SMk1VLPoDLi0yiolGx4/+e5AnW+ZfkJMNaZYDOBpCZN0gFH JWEvijSo1WDQpcLiXzqiCb82+3510eF9o0l/JSnJKTyyuT2GZP4idFFFSimzXVGY6WIG TxfralwbekZ1t4HH/h09Yx5bnN8rjDrbZKcT7m1/HgjRMsbYOzjw7tF/BuKehFxJj7KM 1qQHSLVJ5U0EPZkf9w6KhVAbBymui8WyatzJ85xpZ+6U0xSq74GUKLHk3A3kOfbvvxJX MmJLVYD2JsCOcwKJxOZq5HHYHWsG5BYWd+0zEfWeMQuJUrkdA75bnn1hAz1PK5kZ2QKD OLEA== 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=wJ+e20JFb7CNZ75XebiVJ+fNiWdTFTCThd6HRogpUyY=; b=QjjFiLu3OAnSE7dHdFyl364EZ1PjEK23B24R9fNXeXJu5BCAHIkuBEXzzSgZrvUVVB ZqXfEMhXAKif0hFAZ/I7pZhjwrcFcXXooWgzfLbe9TNvtssosYrHhhAOgLNZG9Xz9YPa Tx7Yu9CSDNo0CfIdACEEIGWh0yc/rOpM+VTELLfrfRd/eD0LBiKts63ui729bulUSpxl xv783qR3NmxQlpp/r7lnuxns+SUZvRdb62JphwiA39Zi/JH3v9KWLvfYbn7v4VMP7WPr tiBeOxeiaB1iznL5zTwaIKBgWCFYsODU4SpAAel1D7pwmf6vPu4g/ixDmtV2lWXFLOYm 6NLQ== X-Gm-Message-State: APzg51DT0BMu9E5PcTyGD2JAHE95/3INTVuoiOoF/n1ohPGhC4Jn3p8N 9SKG1lAi6nX8/i6lKRiJPbl/FGKX X-Google-Smtp-Source: ANB0Vdb+Bve12Qo5k72MNEWa2RYbUynhu3pf5GTzPqSF0JyjsSfKGayIvQViGZX0RH2BLR+lVPZlWQ== X-Received: by 2002:a17:902:286a:: with SMTP id e97-v6mr39771482plb.340.1537451158592; Thu, 20 Sep 2018 06:45:58 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id a20-v6sm55948761pfc.14.2018.09.20.06.45.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 06:45:58 -0700 (PDT) From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 10/13] hwmon: (nct6796) Clean up and amend fan/pwm configuration for NCT6796D Date: Thu, 20 Sep 2018 06:45:38 -0700 Message-Id: <1537451141-27242-10-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net> References: <1537451141-27242-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 Now that everything is separated, clean up fan and pwm configuration for NCT6796D. While doing that, take the forgotten configuration register cre0 into account to determine if AUXFANIN2 (fan5) and AUXFANOUT2 (pwm5) are connected. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index d9c2b934321d..c07414dd38dd 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -3505,10 +3505,12 @@ nct6775_check_fan_inputs(struct nct6775_data *data) int cr2d = superio_inb(sioreg, 0x2d); int cr2f = superio_inb(sioreg, 0x2f); bool dsw_en = cr2f & BIT(3); + int cre0; int creb; int cred; superio_select(sioreg, NCT6775_LD_12); + cre0 = superio_inb(sioreg, 0xe0); creb = superio_inb(sioreg, 0xeb); cred = superio_inb(sioreg, 0xed); @@ -3556,27 +3558,24 @@ nct6775_check_fan_inputs(struct nct6775_data *data) pwm6pin |= creb & BIT(2); break; case nct6796: - pwm5pin |= cr2d & BIT(7); fan5pin |= cr1b & BIT(5); + fan5pin |= (cre0 & BIT(3)) && !(cr1b & BIT(0)); + fan5pin |= creb & BIT(5); - if (data->kind != nct6796) { - fan5pin |= creb & BIT(5); - pwm5pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); + fan6pin = (cr2a & BIT(4)) && + (!dsw_en || (cred & BIT(4))); + fan6pin |= creb & BIT(3); - fan6pin = !dsw_en && (cr2d & BIT(1)); - fan6pin |= creb & BIT(3); + fan7pin = !(cr2b & BIT(2)); - pwm6pin = !dsw_en && (cr2d & BIT(0)); - pwm6pin |= creb & BIT(2); - } + pwm5pin |= cr2d & BIT(7); + pwm5pin |= (cre0 & BIT(4)) && !(cr1b & BIT(0)); + pwm5pin |= (creb & BIT(4)) && !(cr2a & BIT(0)); - fan6pin |= (cr2a & BIT(4)) && - (!dsw_en || (cred & BIT(4))); - pwm6pin |= (cr2a & BIT(3)) && (cred & BIT(2)); + pwm6pin = (cr2a & BIT(3)) && (cred & BIT(2)); + pwm6pin |= creb & BIT(2); - fan7pin = !(cr2b & BIT(2)); pwm7pin = !(cr1d & (BIT(2) | BIT(3))); - break; default: /* NCT6779D */ break;