mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 09:02:21 -04:00
iio: adc: Add battery channel definition for ADC
Defines a constant for the battery sensing channel, typically the last channel of the ADC. Clarifies channel usage and improves code readability. Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
committed by
Jonathan Cameron
parent
e163b09491
commit
a28069be7d
@@ -75,6 +75,8 @@
|
||||
|
||||
#define ASPEED_ADC_INIT_POLLING_TIME 500
|
||||
#define ASPEED_ADC_INIT_TIMEOUT 500000
|
||||
/* Battery sensing is typically on the last channel */
|
||||
#define ASPEED_ADC_BATTERY_CHANNEL 7
|
||||
/*
|
||||
* When the sampling rate is too high, the ADC may not have enough charging
|
||||
* time, resulting in a low voltage value. Thus, the default uses a slow
|
||||
@@ -285,7 +287,7 @@ static int aspeed_adc_read_raw(struct iio_dev *indio_dev,
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
if (data->battery_sensing && chan->channel == 7) {
|
||||
if (data->battery_sensing && chan->channel == ASPEED_ADC_BATTERY_CHANNEL) {
|
||||
adc_engine_control_reg_val =
|
||||
readl(data->base + ASPEED_REG_ENGINE_CONTROL);
|
||||
writel(adc_engine_control_reg_val |
|
||||
@@ -309,7 +311,7 @@ static int aspeed_adc_read_raw(struct iio_dev *indio_dev,
|
||||
return IIO_VAL_INT;
|
||||
|
||||
case IIO_CHAN_INFO_OFFSET:
|
||||
if (data->battery_sensing && chan->channel == 7)
|
||||
if (data->battery_sensing && chan->channel == ASPEED_ADC_BATTERY_CHANNEL)
|
||||
*val = (data->cv * data->battery_mode_gain.mult) /
|
||||
data->battery_mode_gain.div;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user