Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5580597pxb; Mon, 28 Mar 2022 14:30:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4uUNOA0W6duTSTC/UqslearXDKdWDChOLl7Nf7A9h391X4e89KHr8c5Oznc+vyI3e11Rk X-Received: by 2002:a05:6870:4596:b0:da:b3f:2b1d with SMTP id y22-20020a056870459600b000da0b3f2b1dmr602847oao.188.1648503051628; Mon, 28 Mar 2022 14:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648503051; cv=none; d=google.com; s=arc-20160816; b=yy0rRHN3Whq0tdUczXXbHraLqN+EL3ih6cZYHXhQnXu64Ylgj/mZ7Trge0A31EBFto fsCljF2KrhKThwwzd9jGDlshLK+pC7O8hXYndd+6tlX1/CpLjikibe8artSdGAEp07/v HuFreMR5jhkt7F53ABqloNJ5ZT1Gmv6Nxb/FKdnF23+x72o/mbUuugPG7qH5irenrOyR GoEoRO4w6Sasv/ZPfPoZMVdLG3tz4aN3Ds98ReF0KCoP+USvrSyEhwQjbZakHW5mzg0c Jg8o3SUkd63dffm3aJoiAgEdzRSNRy45G3KJR5xENrFI6pK0ecUg0pI8I6k66D+W/fnk qy8Q== 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=PxpDUOFhL1SUBSr62jPOsTrvlFFA+tZHwHKSyP7WhK4=; b=xg6w26ojf1GKq9kb+a5/1FJ/kpQK3AZPNLzFnAXjeDb5qlo1DmReb7wgcJkfiUY6+p SOa8cUMkI3lOSw70BL7A/DicWagEo9/Rrx7Ufbqv+7v6lCzOsXBfHF3EqpIZou+wMJgS fEelvkqwkiJeti/FiVarouQQLBp6giF6aAmS5stxXCmgvIfqfQ71fsDvMbutf8X752j7 J9u648Zxts9Mohrg6odLxoiwl7HDvuMQE3dyOt+CYbjXPZuL0/dMrNnqMiP62OBuA2iH Y+fnTEbi8QLaU/Z2eTQw6FPGQmNRO4nGSFIRGkhpTO7SkXeCrfmcwAvRI7z2/m7Yvuje 9Y6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=H2SpbtP2; 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 126-20020aca0684000000b002f737ad0f1asi9072977oig.115.2022.03.28.14.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:30:51 -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=H2SpbtP2; 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 78E52BDD; Mon, 28 Mar 2022 14:13:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235723AbiC0OUK (ORCPT + 99 others); Sun, 27 Mar 2022 10:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235719AbiC0OUJ (ORCPT ); Sun, 27 Mar 2022 10:20:09 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 034702BC6; Sun, 27 Mar 2022 07:18:30 -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 565A42223E; Sun, 27 Mar 2022 16:18:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1648390708; 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=PxpDUOFhL1SUBSr62jPOsTrvlFFA+tZHwHKSyP7WhK4=; b=H2SpbtP2QOiCk5fjg/c5u3qOTsQcD+LpFr571qZLPTdAsN7QXMTnMX50tKKAKW95kh9Jvo 2r4sbkKxaCIYEF5Fps5LD67IQ9tt0S8kIryN6M7fvaN17MVUncArPt4M4/KubUfZu2XwO+ 8w6RtVP8UZjktefKXNKeahygcJedMUs= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 27 Mar 2022 16:18:28 +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: <2442b460-4c6d-0ac9-af08-ae4c25aed812@roeck-us.net> References: <20220326192347.2940747-1-michael@walle.cc> <20220326192347.2940747-5-michael@walle.cc> <2442b460-4c6d-0ac9-af08-ae4c25aed812@roeck-us.net> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <9aab54bc48284c9e20cd76085cb9d83a@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 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? >> + */ >> + *val = FIELD_GET(FAN_CNT_DATA, data) * 60 / 2; .. otherwise this should then be *val = FIELD_GET(FAN_CNT_DATA, data) * 60; >> + >> + 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(). -michael