All of lore.kernel.org
 help / color / mirror / Atom feed
From: Billy Tsai <billy_tsai@aspeedtech.com>
To: Guenter Roeck <linux@roeck-us.net>,
	"jdelvare@suse.com" <jdelvare@suse.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"krzysztof.kozlowski+dt@linaro.org" 
	<krzysztof.kozlowski+dt@linaro.org>,
	"joel@jms.id.au" <joel@jms.id.au>,
	"andrew@aj.id.au" <andrew@aj.id.au>,
	"lee@kernel.org" <lee@kernel.org>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"u.kleine-koenig@pengutronix.de" <u.kleine-koenig@pengutronix.de>,
	"corbet@lwn.net" <corbet@lwn.net>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Cc: kernel test robot <lkp@intel.com>
Subject: Re: [v4 5/5] hwmon: Add Aspeed ast2600 TACH support
Date: Tue, 29 Nov 2022 07:08:36 +0000	[thread overview]
Message-ID: <D5F454FE-9C4B-4B7E-8817-637D5FCC047A@aspeedtech.com> (raw)
In-Reply-To: <bf851fa1-af62-5cdc-8cb4-bcf29b73731a@roeck-us.net>

On 2022/11/23, 11:45 PM, "Guenter Roeck" <groeck7@gmail.com on behalf of linux@roeck-us.net> wrote:

    On 11/22/22 22:16, Billy Tsai wrote:
    > > +The driver provides the following sensor accesses in sysfs:
    > > +=============== ======= =====================================================
    > > +fanX_input	ro	provide current fan rotation value in RPM as reported
    > > +			by the fan to the device.
    > > +fanX_div	rw	Fan divisor: Supported value are power of 4 (1, 4, 16
    > > +                        64, ... 4194304)

    > The code doesn't support 1.

The code can support 1.


    > The existence of a status register makes me wonder what is in there.
    > Does the controller report any errors ? If so, it might be worthwile
    > adding attribute(s) for it.

    > > +	if (ret)
    > > +		return ret;
    > > +
    > > +	if (!(val & TACH_ASPEED_FULL_MEASUREMENT))
    > > +		return 0;
    > > +	rpm = aspeed_tach_val_to_rpm(priv, fan_tach_ch,
    > > +				     val & TACH_ASPEED_VALUE_MASK);
    > > +
    > > +	return rpm;

The status register is the TACH_ASPEED_FULL_MEASUREMENT which is used to indicate that
the controller doesn't detect the change in tach pin for a long time.

    > > +static void aspeed_create_fan_tach_channel(struct aspeed_tach_data *priv,
    > > +					   u32 tach_ch)
    > > +{
    > > +	priv->tach_present[tach_ch] = true;
    > > +	priv->tach_channel[tach_ch].limited_inverse = 0;
    > > +	regmap_write_bits(priv->regmap, TACH_ASPEED_CTRL(tach_ch),
    > > +			  TACH_ASPEED_INVERS_LIMIT,
    > > +			  priv->tach_channel[tach_ch].limited_inverse ?
    > > +				  TACH_ASPEED_INVERS_LIMIT :
    > > +				  0);
    > > +
    > What is the purpose of the above code ? limited_inverse is always 0.

    > > +	priv->tach_channel[tach_ch].tach_debounce = DEBOUNCE_3_CLK;
    > > +	regmap_write_bits(priv->regmap, TACH_ASPEED_CTRL(tach_ch),
    > > +			  TACH_ASPEED_DEBOUNCE_MASK,
    > > +			  priv->tach_channel[tach_ch].tach_debounce
    > > +				  << TACH_ASPEED_DEBOUNCE_BIT);
    > > +
    > > +	priv->tach_channel[tach_ch].tach_edge = F2F_EDGES;
    > > +	regmap_write_bits(priv->regmap, TACH_ASPEED_CTRL(tach_ch),
    > > +			  TACH_ASPEED_IO_EDGE_MASK,
    > > +			  priv->tach_channel[tach_ch].tach_edge
    > > +				  << TACH_ASPEED_IO_EDGE_BIT);
    > > +

    > limited_inverse, tach_debounce, and tach_edge are constants.
    > There is no need to keep constants as per-channel variables.

    > > +	priv->tach_channel[tach_ch].divisor = DEFAULT_TACH_DIV;
    > > +	regmap_write_bits(priv->regmap, TACH_ASPEED_CTRL(tach_ch),
    > > +			  TACH_ASPEED_CLK_DIV_T_MASK,
    > > +			  DIV_TO_REG(priv->tach_channel[tach_ch].divisor)
    > > +				  << TACH_ASPEED_CLK_DIV_BIT);
    > > +
    > > +	priv->tach_channel[tach_ch].threshold = 0;
    > > +	regmap_write_bits(priv->regmap, TACH_ASPEED_CTRL(tach_ch),
    > > +			  TACH_ASPEED_THRESHOLD_MASK,
    > > +			  priv->tach_channel[tach_ch].threshold);
    > > +

    > The above applies to threshold as well.

The above code is used to retain the adjustable feature of the controller.
I will remove them until I add the dts property to support them.

    > > +	}
    > > +
    > > +	hwmon = devm_hwmon_device_register_with_info(dev, "aspeed_tach", priv,
    > > +						     &aspeed_tach_chip_info, NULL);
    > > +	ret = PTR_ERR_OR_ZERO(hwmon);
    > > +	if (ret)
    > > +		return dev_err_probe(dev, ret,
    > > +				     "Failed to register hwmon device\n");
    > > +	return 0;

    > Why not return the error ? Either it is an error or it isn't. If it is
    > not an error, dev_err_probe() is not appropriate. If it is, the error
    > should be returned. Either case, if this is on purpose, it needs an
    > explanation.

I have return the return value of the dev_err_probe. Did I miss someting?

Thanks

Best Regards,
Billy Tsai


WARNING: multiple messages have this Message-ID (diff)
From: Billy Tsai <billy_tsai@aspeedtech.com>
To: Guenter Roeck <linux@roeck-us.net>,
	"jdelvare@suse.com" <jdelvare@suse.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"krzysztof.kozlowski+dt@linaro.org"
	<krzysztof.kozlowski+dt@linaro.org>,
	"joel@jms.id.au" <joel@jms.id.au>,
	"andrew@aj.id.au" <andrew@aj.id.au>,
	"lee@kernel.org" <lee@kernel.org>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"u.kleine-koenig@pengutronix.de" <u.kleine-koenig@pengutronix.de>,
	"corbet@lwn.net" <corbet@lwn.net>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Cc: kernel test robot <lkp@intel.com>
Subject: Re: [v4 5/5] hwmon: Add Aspeed ast2600 TACH support
Date: Tue, 29 Nov 2022 07:08:36 +0000	[thread overview]
Message-ID: <D5F454FE-9C4B-4B7E-8817-637D5FCC047A@aspeedtech.com> (raw)
In-Reply-To: <bf851fa1-af62-5cdc-8cb4-bcf29b73731a@roeck-us.net>

On 2022/11/23, 11:45 PM, "Guenter Roeck" <groeck7@gmail.com on behalf of linux@roeck-us.net> wrote:

    On 11/22/22 22:16, Billy Tsai wrote:
    > > +The driver provides the following sensor accesses in sysfs:
    > > +=============== ======= =====================================================
    > > +fanX_input	ro	provide current fan rotation value in RPM as reported
    > > +			by the fan to the device.
    > > +fanX_div	rw	Fan divisor: Supported value are power of 4 (1, 4, 16
    > > +                        64, ... 4194304)

    > The code doesn't support 1.

The code can support 1.


    > The existence of a status register makes me wonder what is in there.
    > Does the controller report any errors ? If so, it might be worthwile
    > adding attribute(s) for it.

    > > +	if (ret)
    > > +		return ret;
    > > +
    > > +	if (!(val & TACH_ASPEED_FULL_MEASUREMENT))
    > > +		return 0;
    > > +	rpm = aspeed_tach_val_to_rpm(priv, fan_tach_ch,
    > > +				     val & TACH_ASPEED_VALUE_MASK);
    > > +
    > > +	return rpm;

The status register is the TACH_ASPEED_FULL_MEASUREMENT which is used to indicate that
the controller doesn't detect the change in tach pin for a long time.

    > > +static void aspeed_create_fan_tach_channel(struct aspeed_tach_data *priv,
    > > +					   u32 tach_ch)
    > > +{
    > > +	priv->tach_present[tach_ch] = true;
    > > +	priv->tach_channel[tach_ch].limited_inverse = 0;
    > > +	regmap_write_bits(priv->regmap, TACH_ASPEED_CTRL(tach_ch),
    > > +			  TACH_ASPEED_INVERS_LIMIT,
    > > +			  priv->tach_channel[tach_ch].limited_inverse ?
    > > +				  TACH_ASPEED_INVERS_LIMIT :
    > > +				  0);
    > > +
    > What is the purpose of the above code ? limited_inverse is always 0.

    > > +	priv->tach_channel[tach_ch].tach_debounce = DEBOUNCE_3_CLK;
    > > +	regmap_write_bits(priv->regmap, TACH_ASPEED_CTRL(tach_ch),
    > > +			  TACH_ASPEED_DEBOUNCE_MASK,
    > > +			  priv->tach_channel[tach_ch].tach_debounce
    > > +				  << TACH_ASPEED_DEBOUNCE_BIT);
    > > +
    > > +	priv->tach_channel[tach_ch].tach_edge = F2F_EDGES;
    > > +	regmap_write_bits(priv->regmap, TACH_ASPEED_CTRL(tach_ch),
    > > +			  TACH_ASPEED_IO_EDGE_MASK,
    > > +			  priv->tach_channel[tach_ch].tach_edge
    > > +				  << TACH_ASPEED_IO_EDGE_BIT);
    > > +

    > limited_inverse, tach_debounce, and tach_edge are constants.
    > There is no need to keep constants as per-channel variables.

    > > +	priv->tach_channel[tach_ch].divisor = DEFAULT_TACH_DIV;
    > > +	regmap_write_bits(priv->regmap, TACH_ASPEED_CTRL(tach_ch),
    > > +			  TACH_ASPEED_CLK_DIV_T_MASK,
    > > +			  DIV_TO_REG(priv->tach_channel[tach_ch].divisor)
    > > +				  << TACH_ASPEED_CLK_DIV_BIT);
    > > +
    > > +	priv->tach_channel[tach_ch].threshold = 0;
    > > +	regmap_write_bits(priv->regmap, TACH_ASPEED_CTRL(tach_ch),
    > > +			  TACH_ASPEED_THRESHOLD_MASK,
    > > +			  priv->tach_channel[tach_ch].threshold);
    > > +

    > The above applies to threshold as well.

The above code is used to retain the adjustable feature of the controller.
I will remove them until I add the dts property to support them.

    > > +	}
    > > +
    > > +	hwmon = devm_hwmon_device_register_with_info(dev, "aspeed_tach", priv,
    > > +						     &aspeed_tach_chip_info, NULL);
    > > +	ret = PTR_ERR_OR_ZERO(hwmon);
    > > +	if (ret)
    > > +		return dev_err_probe(dev, ret,
    > > +				     "Failed to register hwmon device\n");
    > > +	return 0;

    > Why not return the error ? Either it is an error or it isn't. If it is
    > not an error, dev_err_probe() is not appropriate. If it is, the error
    > should be returned. Either case, if this is on purpose, it needs an
    > explanation.

I have return the return value of the dev_err_probe. Did I miss someting?

Thanks

Best Regards,
Billy Tsai

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-11-29  7:08 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  6:16 [v4 0/5] Support pwm/tach driver for aspeed ast26xx Billy Tsai
2022-11-23  6:16 ` Billy Tsai
2022-11-23  6:16 ` [v4 1/5] dt-bindings: mfd: Add aspeed pwm-tach binding Billy Tsai
2022-11-23  6:16   ` Billy Tsai
2022-11-23  8:24   ` Krzysztof Kozlowski
2022-11-23  8:24     ` Krzysztof Kozlowski
2022-11-23  8:27     ` Krzysztof Kozlowski
2022-11-23  8:27       ` Krzysztof Kozlowski
2022-12-09  0:54       ` Billy Tsai
2022-12-09  0:54         ` Billy Tsai
2022-12-09  7:48         ` Krzysztof Kozlowski
2022-12-09  7:48           ` Krzysztof Kozlowski
2023-01-06  3:31           ` Billy Tsai
2023-01-06  3:31             ` Billy Tsai
2023-06-08  6:43     ` Krzysztof Kozlowski
2023-06-08  6:43       ` Krzysztof Kozlowski
     [not found]       ` <SG2PR06MB3365AE9D075601CB62C6E7F78B50A@SG2PR06MB3365.apcprd06.prod.outlook.com>
2023-06-08  7:20         ` Krzysztof Kozlowski
2023-06-08  7:20           ` Krzysztof Kozlowski
2022-11-23 15:07   ` Rob Herring
2022-11-23 15:07     ` Rob Herring
2022-11-23  6:16 ` [v4 2/5] dt-bindings: pwm: Add bindings for aspeed pwm controller Billy Tsai
2022-11-23  6:16   ` Billy Tsai
2022-11-23  8:30   ` Krzysztof Kozlowski
2022-11-23  8:30     ` Krzysztof Kozlowski
2022-11-23 15:07   ` Rob Herring
2022-11-23 15:07     ` Rob Herring
2022-11-23  6:16 ` [v4 3/5] dt-bindings: hwmon: Add bindings for aspeed tach controller Billy Tsai
2022-11-23  6:16   ` Billy Tsai
2022-11-23  8:33   ` Krzysztof Kozlowski
2022-11-23  8:33     ` Krzysztof Kozlowski
2022-11-23 15:21   ` Guenter Roeck
2022-11-23 15:21     ` Guenter Roeck
2022-11-23  6:16 ` [v4 4/5] pwm: Add Aspeed ast2600 PWM support Billy Tsai
2022-11-23  6:16   ` Billy Tsai
2022-11-23  8:43   ` Bagas Sanjaya
2022-11-23  8:43     ` Bagas Sanjaya
2023-04-24 10:12   ` Delphine_CC_Chiu/WYHQ/Wiwynn
2023-04-24 10:12     ` Delphine_CC_Chiu/WYHQ/Wiwynn
2022-11-23  6:16 ` [v4 5/5] hwmon: Add Aspeed ast2600 TACH support Billy Tsai
2022-11-23  6:16   ` Billy Tsai
2022-11-23  8:45   ` Bagas Sanjaya
2022-11-23  8:45     ` Bagas Sanjaya
2022-11-23 15:44   ` Guenter Roeck
2022-11-23 15:44     ` Guenter Roeck
2022-11-29  7:08     ` Billy Tsai [this message]
2022-11-29  7:08       ` Billy Tsai
2022-11-29 15:06       ` Guenter Roeck
2022-11-29 15:06         ` Guenter Roeck
2023-01-17 21:48 ` [v4 0/5] Support pwm/tach driver for aspeed ast26xx Uwe Kleine-König
2023-01-17 21:48   ` Uwe Kleine-König
2023-01-18  1:48   ` Billy Tsai
2023-01-18  1:48     ` Billy Tsai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D5F454FE-9C4B-4B7E-8817-637D5FCC047A@aspeedtech.com \
    --to=billy_tsai@aspeedtech.com \
    --cc=andrew@aj.id.au \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=joel@jms.id.au \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lkp@intel.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.