Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5575399pxb; Mon, 28 Mar 2022 14:26:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7I8WI34gJ3DbIAio3tGQmBSLHPUu3a8FYt4hp6AxN+BgJ6qCygiAu/7VAITVgFjl4s4z3 X-Received: by 2002:a05:6102:f12:b0:325:a293:cd96 with SMTP id v18-20020a0561020f1200b00325a293cd96mr5485792vss.6.1648502786998; Mon, 28 Mar 2022 14:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648502786; cv=none; d=google.com; s=arc-20160816; b=qNGcdx4+N0CMIqPsEY10U7pRupMw+/iRj+ZqTkO8OMzMPCK9iTMWromZmcihUqp5Ev PKjCkeoaHcR7C9vPEtS5RnWPYNfydx5/K6sqAo6FHm2xnQon6hqgclqJD6Pm6XMGHvOU eqfW8AyjnBq75f2M4in30ovBBsGW5qeGmz12pOMkej4d7xihBJmaY45d6KPiSNYb7LEf thl4mE0TtMDangwXarjYeCNkWsmdcju5y2sQL1Q+gTpmSbmqueDld7R71ECjdAznzFa3 DBWYDEcLKmJH9aa1wBbHKliFERW3NxB5azxxd5eG58T7LU3KTYnj88NC3/m1qDfw65bn j9Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=0izGFsz6GTIJ5k2/n2+LlCxCAa9dPx6ye+X401jvCCo=; b=d7N6G1LxaGsFdbDTmNcKVCai51caH37XPVMeW54vdL1+bNKJulYgF500HtyWKiSo8Z EulNLp/77CRzs0NV1rgyyFDSD1cNL9XFuh/mwiGTAAmDBahUANkWrXkmNYMOj5NIMVS7 bUy/z0EjMDUH1tO+1mtDt8UZjD9XuIboXC8g3JIRQcwWeZk6PfsjMI9g2WOrWDMjjyOV fpSzMWZhC/YpBnE/r4lYCfg5eemyJj/ATOYH461OyiDS8Rs8AMnw6GQcOU0MdLW6IEQ2 a/aIgheNXRsb2kUe3B4MspCFY0Bl3j7F+z9zUBGp75+ZREIjKdzMDNIz8XelSoMxAH1F XPjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=LA0PS2Wz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x15-20020a05610223cf00b003256132b16dsi3253493vsr.90.2022.03.28.14.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:26:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=LA0PS2Wz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5DCC33A5E0; Mon, 28 Mar 2022 14:10:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235745AbiC1LqB (ORCPT + 99 others); Mon, 28 Mar 2022 07:46:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243460AbiC1Lgd (ORCPT ); Mon, 28 Mar 2022 07:36:33 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4D9F201BB; Mon, 28 Mar 2022 04:28:14 -0700 (PDT) Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 18E1B2223A; Mon, 28 Mar 2022 13:28:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1648466893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0izGFsz6GTIJ5k2/n2+LlCxCAa9dPx6ye+X401jvCCo=; b=LA0PS2WzebEJVJScqJ1xVF2JEHiJGr2Rpc6A7e6LUh/msDLe1WTf0AZJuHkUhnqESnQh0g KV3h8UtNVnC8KTxYm5ylF0GRycj60zu9SwMX4uQTHSAOtB8Ovo5UbriTEX5jAkUmZTBUwT u9IWuJdw3C2E48QWNF4fAeScOCYpn8k= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 28 Mar 2022 13:28:12 +0200 From: Michael Walle To: Guenter Roeck Cc: Jean Delvare , Rob Herring , Krzysztof Kozlowski , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 4/4] hwmon: add driver for the Microchip LAN966x SoC In-Reply-To: <4455ca4c-1ebb-41df-5f04-72a48e8ca7dc@roeck-us.net> References: <20220326192347.2940747-1-michael@walle.cc> <20220326192347.2940747-5-michael@walle.cc> <2442b460-4c6d-0ac9-af08-ae4c25aed812@roeck-us.net> <9aab54bc48284c9e20cd76085cb9d83a@walle.cc> <4455ca4c-1ebb-41df-5f04-72a48e8ca7dc@roeck-us.net> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <4e5c78ce651c258a4be33c01ec07a0c3@walle.cc> X-Sender: michael@walle.cc X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 2022-03-27 20:22, schrieb Guenter Roeck: > On 3/27/22 07:18, Michael Walle wrote: >> Am 2022-03-27 03:34, schrieb Guenter Roeck: >> >>>> +    /* >>>> +     * Data is given in pulses per second. According to the hwmon >>>> ABI we >>>> +     * have to assume two pulses per revolution. >>> >>> The hwmon ABI doesn't make any such assumptions. It wants to see RPM, >>> that is all. Pulses per revolution is a fan property. >> >> There is fanY_pulses according to >> Documentation/ABI/testing/sysfs-class-hwmon: >> >>   Should only be created if the chip has a register to configure >>   the number of pulses. In the absence of such a register (and >>   thus attribute) the value assumed by all devices is 2 pulses >>   per fan revolution. >> >> The hardware returns just the pulses per second. Doesn't that >> mean I have to divide that value by two? >> > > The above refers to hardware which reports RPM. > > It is up to the driver to calculate and return RPM. How you do it is > your > decision. Drivers should report the most likely correct RPM value to > userspace, one that rarely needs manual adjustment. Almost all fans > report two pulses per revolution, so normally that assumption is used > to convert PPM to RPM. That isn't mandated (or supposed to be mandated) > by the ABI. I would call it common sense. > > I'll be happy to accept a patch clarifying this. Where would that go? into the sysfs abi description of the fanY_input? >>>> +     */ >>>> +    *val = FIELD_GET(FAN_CNT_DATA, data) * 60 / 2; >> >> .. otherwise this should then be >> *val = FIELD_GET(FAN_CNT_DATA, data) * 60; >> > > If you really want to do this, make sure it is well documented that > users > will need to adjust the fan speed via sensors3.conf to get the real fan > speed. > >> >>>> + >>>> +    return 0; >>>> +} >>>> + >>>> +static int lan966x_hwmon_read_pwm(struct device *dev, long *val) >>>> +{ >>>> +    struct lan966x_hwmon *hwmon = dev_get_drvdata(dev); >>>> +    unsigned int data; >>>> +    int ret; >>>> + >>>> +    ret = regmap_read(hwmon->regmap_fan, FAN_CFG, &data); >>>> +    if (ret < 0) >>>> +        return ret; >>>> + >>>> +    *val = FIELD_GET(FAN_CFG_DUTY_CYCLE, data); >>>> + >>>> +    return 0; >>>> +} >>>> + >>>> +static int lan966x_hwmon_read_pwm_freq(struct device *dev, long >>>> *val) >>>> +{ >>>> +    struct lan966x_hwmon *hwmon = dev_get_drvdata(dev); >>>> +    unsigned long rate = clk_get_rate(hwmon->clk); >>> >>> Is that a dynamic frequency ? If not, it would be better to read it >>> once >>> and store it in struct lan966x_hwmon. >> >> yes it is configurable, actually. See lan966x_hwmon_write_pwm_freq(). >> > > That is the pwm frequency, not the clock frequency. I don't see any > code which updates the clock frequency reported by > clk_get_rate(hwmon->clk), > ie I don't see a call to clk_set_rate(). Ahh sorry, missunderstood you. Yeah, in v2 it will be read during probe. -michael