diff --git a/meta-facebook/meta-grandteton/recipes-grandteton/plat-utils/files/setup-common-dev.sh b/meta-facebook/meta-grandteton/recipes-grandteton/plat-utils/files/setup-common-dev.sh index f9cedb68cbf..f79eedfb8bd 100755 --- a/meta-facebook/meta-grandteton/recipes-grandteton/plat-utils/files/setup-common-dev.sh +++ b/meta-facebook/meta-grandteton/recipes-grandteton/plat-utils/files/setup-common-dev.sh @@ -331,7 +331,7 @@ fi #VPDB BRICK # only for PVT DISCRETE Config if [ "$vrev" -eq "$VPDB_DISCRETE_PVT" ] && - ( [ "$vsku" -eq "2" ] || [ "$vsku" -eq "5" ] ); then + { [ "$vsku" -eq "2" ] || [ "$vsku" -eq "5" ]; }; then # DISCRETE_PVT has unique sku ( 010 and 101 ) # that specially point out its brick source brick_driver="raa228006" @@ -367,7 +367,6 @@ fi if [ "$vrev" -ge "$VPDB_PVT4" ]; then # ADC Type adc_type_dif="0" - adc_type_sgl="1" adc_type="$(gpio_get VPDB_SKU_ID_4)" adc_dif_sku="$(($(gpio_get VPDB_SKU_ID_6) << 1 | $(gpio_get VPDB_SKU_ID_5)))" adc_sgl_sku="$(gpio_get VPDB_SKU_ID_7)" @@ -399,9 +398,9 @@ if [ "$vrev" -ge "$VPDB_PVT4" ]; then fi else # probe adc sig - if [ $adc_sgl_sku -eq 0 ]; then + if [ "$adc_sgl_sku" -eq 0 ]; then i2c_device_add 36 0x35 max11617 - echo 1 > /sys/bus/i2c/devices/36-0035/iio\:device*/polar_resistor + echo 1 > /sys/bus/i2c/devices/36-0035/iio:device*/polar_resistor else rebind_i2c_dev 36 48 ads1015 fi @@ -492,7 +491,7 @@ hpdb_hsc=$(gpio_get HPDB_SKU_ID_0) # HPDB_BOARD_ID_3 was present in between stage DVT and stage PVT3 # but the value was 1, so if revs in range 11 ~ 15 (DVT ~ PVT3) need to be reconfig. -if [ $hrev -ge 11 ] && [ $hrev -le 15 ]; then +if [ "$hrev" -ge 11 ] && [ "$hrev" -le 15 ]; then kv set hpdb_rev "$(( $(gpio_get HPDB_BOARD_ID_2) << 2 | $(gpio_get HPDB_BOARD_ID_1) << 1 | @@ -502,7 +501,7 @@ if [ $hrev -ge 11 ] && [ $hrev -le 15 ]; then fi # Stage before PVT4 -[ $hrev -lt $HPDB_PVT4 ] && hpdb_hsc=$(gpio_get HPDB_SKU_ID_2) +[ "$hrev" -lt "$HPDB_PVT4" ] && hpdb_hsc=$(gpio_get HPDB_SKU_ID_2) if [ "$hpdb_hsc" -eq "$HPDB_HSC_MAIN" ] && [ "$hrev" -gt 1 ]; then i2cset -f -y 39 0x40 0xD9 0x8b @@ -522,7 +521,6 @@ if [ "$hrev" -ge "$HPDB_PVT4" ]; then # ADC Type adc_type_dif="0" - adc_type_sgl="1" adc_type=$(gpio_get HPDB_SKU_ID_2) adc_dif_sku="$(($(gpio_get HPDB_SKU_ID_4) << 1 | $(gpio_get HPDB_SKU_ID_3)))" adc_sgl_sku=$(gpio_get HPDB_SKU_ID_5) @@ -560,9 +558,9 @@ if [ "$hrev" -ge "$HPDB_PVT4" ]; then fi else # probe adc sig - if [ $adc_sgl_sku -eq 0 ]; then + if [ "$adc_sgl_sku" -eq 0 ]; then rebind_i2c_dev 37 35 max11617 - echo 1 > /sys/bus/i2c/devices/37-0035/iio\:device*/polar_resistor + echo 1 > /sys/bus/i2c/devices/37-0035/iio:device*/polar_resistor else rebind_i2c_dev 37 48 ads1015 fi @@ -935,3 +933,22 @@ if [ "$(is_bmc_por)" -eq 1 ]; then sleep 3 fi +#Enable ADC upper bound value +#ADC0 ~ ADC7 upper bound value +adc0_upper_bound=("25F" "264" "251" "245" "244" "13D" "204" "1D0") +#ADC8 ~ ADC15 upper bound value +adc1_upper_bound=("1BA" " " " " " " " " " " " " " ") + +for i in {0..7}; do + if [[ "${adc0_upper_bound["$i"]}" != " " ]]; then + echo $((0x"${adc0_upper_bound["$i"]}")) > /sys/bus/iio/devices/iio:device0/events/in_voltage"$i"_thresh_rising_value + echo 1 > /sys/bus/iio/devices/iio:device0/events/in_voltage"$i"_thresh_rising_en + fi +done +for i in {0..7}; do + if [[ "${adc1_upper_bound["$i"]}" != " " ]]; then + echo $((0x"${adc1_upper_bound["$i"]}")) > /sys/bus/iio/devices/iio:device1/events/in_voltage"$i"_thresh_rising_value + echo 1 > /sys/bus/iio/devices/iio:device1/events/in_voltage"$i"_thresh_rising_en + fi +done + diff --git a/meta-facebook/meta-grandteton/recipes-kernel/linux/linux-aspeed_5.%.bbappend b/meta-facebook/meta-grandteton/recipes-kernel/linux/linux-aspeed_5.%.bbappend index 6766394defa..c35ad6ed4af 100644 --- a/meta-facebook/meta-grandteton/recipes-kernel/linux/linux-aspeed_5.%.bbappend +++ b/meta-facebook/meta-grandteton/recipes-kernel/linux/linux-aspeed_5.%.bbappend @@ -19,6 +19,7 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/plat_conf:" SRC_URI += "\ file://grandteton.cfg \ + file://0001-iio-adc-aspeed-Extend-the-delay-time-to-meet-ADC-hw-.patch \ " KERNEL_MODULE_AUTOLOAD += " \ diff --git a/meta-facebook/meta-grandteton/recipes-kernel/linux/plat_conf/0001-iio-adc-aspeed-Extend-the-delay-time-to-meet-ADC-hw-.patch b/meta-facebook/meta-grandteton/recipes-kernel/linux/plat_conf/0001-iio-adc-aspeed-Extend-the-delay-time-to-meet-ADC-hw-.patch new file mode 100644 index 00000000000..65c38c0f963 --- /dev/null +++ b/meta-facebook/meta-grandteton/recipes-kernel/linux/plat_conf/0001-iio-adc-aspeed-Extend-the-delay-time-to-meet-ADC-hw-.patch @@ -0,0 +1,68 @@ +From 8bf1e8fd0cad6f78413c6d7b7913092d758fde00 Mon Sep 17 00:00:00 2001 +From: Billy Tsai +Date: Tue, 13 Jun 2023 18:04:47 +0800 +Subject: [PATCH] iio: adc: aspeed: Extend the delay time to meet ADC hw + behavior. + +The patch is intended to extend the delay time when the last channel of +the ADC is enabled. In our ADC, it takes 12 dummy sampling periods to +switch the sampling channel from CH7 to CH0. Therefore, the patch checks +the enable status of channel 7 in order to determine the appropriate delay +period for obtaining the updated ADC values of each channel. + +Signed-off-by: Billy Tsai +Change-Id: I759510c9bddb704a384df83b8109b8e36d696f11 +--- + drivers/iio/adc/aspeed_adc.c | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c +index 6bdbc6b3158e..436cf8ad29c2 100644 +--- a/drivers/iio/adc/aspeed_adc.c ++++ b/drivers/iio/adc/aspeed_adc.c +@@ -120,7 +120,7 @@ struct aspeed_adc_data { + int cv; + bool battery_sensing; + struct adc_gain battery_mode_gain; +- unsigned int enabled_channels_num; ++ unsigned int required_eoc_num; + u16 *upper_bound; + u16 *lower_bound; + bool *upper_en; +@@ -308,18 +308,18 @@ static int aspeed_adc_get_voltage_raw(struct aspeed_adc_data *data, struct iio_c + chan->channel, data->upper_en[chan->channel], + data->upper_bound[chan->channel], data->lower_en[chan->channel], + data->lower_bound[chan->channel], data->sample_period_ns, +- data->enabled_channels_num); ++ data->required_eoc_num); + if (data->upper_en[chan->channel]) { + if (val >= data->upper_bound[chan->channel]) { + ndelay(data->sample_period_ns * +- data->enabled_channels_num); ++ data->required_eoc_num); + val = readw(data->base + chan->address); + } + } + if (data->lower_en[chan->channel]) { + if (val <= data->lower_bound[chan->channel]) { + ndelay(data->sample_period_ns * +- data->enabled_channels_num); ++ data->required_eoc_num); + val = readw(data->base + chan->address); + } + } +@@ -806,7 +806,10 @@ static int aspeed_adc_probe(struct platform_device *pdev) + adc_engine_control_reg_val = + FIELD_GET(ASPEED_ADC_CTRL_CHANNEL, + readl(data->base + ASPEED_REG_ENGINE_CONTROL)); +- data->enabled_channels_num = hweight_long(adc_engine_control_reg_val); ++ data->required_eoc_num = hweight_long(adc_engine_control_reg_val); ++ if (adc_engine_control_reg_val & ++ BIT(data->model_data->num_channels - 1)) ++ data->required_eoc_num += 12; + indio_dev->name = data->model_data->model_name; + indio_dev->info = &aspeed_adc_iio_info; + indio_dev->modes = INDIO_DIRECT_MODE; +-- +2.25.1 +