From: Andrew Jeffery <andrew@aj.id.au>
To: linux-aspeed@lists.ozlabs.org
Subject: [PATCH v1] iio: adc: aspeed: Support deglitch feature.
Date: Tue, 03 Oct 2023 17:22:45 +1030 [thread overview]
Message-ID: <4bee3205-212b-4032-a105-9b8f1fb1fa22@app.fastmail.com> (raw)
In-Reply-To: <SG2PR06MB336555C2C52E24FCCDE72C748BC5A@SG2PR06MB3365.apcprd06.prod.outlook.com>
Hi Billy,
On Mon, 2 Oct 2023, at 19:20, Billy Tsai wrote:
> On Mon, 25 Sep 2023, at 17:48, Billy Tsai wrote:
>> > Create event sysfs for applying the deglitch condition. When
>> > in_voltageY_thresh_rising_en/in_voltageY_thresh_falling_en is set to true,
>> > the driver will use the in_voltageY_thresh_rising_value and
>> > in_voltageY_thresh_falling_value as threshold values. If the ADC value
>> > falls outside this threshold, the driver will wait for the ADC sampling
>> > period and perform an additional read once to achieve the deglitching
>> > purpose.
>> >
>> > Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
>> > ---
>> > drivers/iio/adc/aspeed_adc.c | 193 ++++++++++++++++++++++++++++++++++-
>> > 1 file changed, 189 insertions(+), 4 deletions(-)
>> >
>> > diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c
>> > index 998e8bcc06e1..9e746c81d916 100644
>> > --- a/drivers/iio/adc/aspeed_adc.c
>> > +++ b/drivers/iio/adc/aspeed_adc.c
>> > @@ -95,6 +95,7 @@ struct aspeed_adc_model_data {
>> > bool wait_init_sequence;
>> > bool need_prescaler;
>> > bool bat_sense_sup;
>> > + bool require_extra_eoc;
>
>> What is "eoc"? Can we use a better name or add an explanatory comment?
>
> Hi Andrew,
> This is the signal name for our ADC controller, it means "End Of
> Conversion".
> The appearance of this signal period indicates that the ADC value is
> valid and being updated to the register.
Okay, searching for "conversion" in the datasheet didn't turn up anything like this. It seems I wasn't off-track with asking. If you go forward with the patch in some manner, can you add a comment to the code documenting the meaning of 'eoc'?
>
>> > /* Register ADC clock prescaler with source specified by device tree.
>> > */
>> > spin_lock_init(&data->clk_lock);
>> > snprintf(clk_parent_name, ARRAY_SIZE(clk_parent_name), "%s",
>> > @@ -632,7 +806,14 @@ static int aspeed_adc_probe(struct platform_device
>> > *pdev)
>> > adc_engine_control_reg_val |= ASPEED_ADC_CTRL_CHANNEL;
>> > writel(adc_engine_control_reg_val,
>> > data->base + ASPEED_REG_ENGINE_CONTROL);
>> > -
>> > + adc_engine_control_reg_val =
>> > + FIELD_GET(ASPEED_ADC_CTRL_CHANNEL,
>> > + readl(data->base + ASPEED_REG_ENGINE_CONTROL));
>> > + data->required_eoc_num = hweight_long(adc_engine_control_reg_val);
>> > + if (data->model_data->require_extra_eoc &&
>> > + (adc_engine_control_reg_val &
>> > + BIT(data->model_data->num_channels - 1)))
>> > + data->required_eoc_num += 12;
>
>> Why 12? Why add a value to the number of engines enabled? Have I misunderstood?
>
> This behavior is specified by the hardware. In our ADC, it requires 12
> dummy sampling
> periods to switch the sampling channel from CH7 to CH0. Hence, this
> condition checks
> the enable status of channel 7 to determine the necessary delay period
> for obtaining the
> updated ADC values for each channel.
Okay, I feel using a magic value '12' with what you wrote above as an explanation is asking a bit much of the reader. Again, if you go forward with this patch in some fashion, can you document the meaning of 12 in a comment (and possibly use a macro to name it)?
Cheers,
Andrew
next prev parent reply other threads:[~2023-10-03 6:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 8:18 [PATCH v1] iio: adc: aspeed: Support deglitch feature Billy Tsai
2023-09-28 2:34 ` Andrew Jeffery
2023-10-02 8:50 ` Billy Tsai
2023-10-03 6:52 ` Andrew Jeffery [this message]
2023-10-04 17:44 ` Billy Tsai
2023-09-30 16:45 ` Jonathan Cameron
2023-10-02 2:30 ` Billy Tsai
2023-10-02 9:39 ` Jonathan Cameron
2023-10-04 17:38 ` Billy Tsai
2023-10-05 14:07 ` Jonathan Cameron
[not found] ` <SG2PR06MB33657B698EDFC3D6937997938BD6A@SG2PR06MB3365.apcprd06.prod.outlook.com>
2023-10-17 19:15 ` Jonathan Cameron
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=4bee3205-212b-4032-a105-9b8f1fb1fa22@app.fastmail.com \
--to=andrew@aj.id.au \
--cc=linux-aspeed@lists.ozlabs.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox