From af699ebb4b257740183c8df2be8e88e4e204a995 Mon Sep 17 00:00:00 2001 From: Jishnu Prakash Date: Wed, 19 Feb 2020 15:20:38 +0530 Subject: [PATCH 1/2] iio: adc: qcom-spmi-adc5: Add SID in ADC IIO channel properties For PMIC7 ADC_TM, the IIO channel structure corresponding to a VADC channel needs to have both SID and actual channel number to avoid confusing channels on two different PMICs with same channel number. Add SID in each VADC IIO channel properties, which will be checked by PMIC7 ADC_TM when mapping VADC channels. Change-Id: Iaa2465f881bf0326e4725071735bbf3ec68fafef Signed-off-by: Jishnu Prakash --- drivers/iio/adc/qcom-spmi-adc5.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c index 901d22d86df8..9d4944efb6af 100644 --- a/drivers/iio/adc/qcom-spmi-adc5.c +++ b/drivers/iio/adc/qcom-spmi-adc5.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. */ #include @@ -941,6 +941,7 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node) adc_chan = &data->adc_chans[prop.channel]; iio_chan->channel = prop.channel; + iio_chan->channel2 = prop.sid; iio_chan->datasheet_name = prop.datasheet_name; iio_chan->extend_name = prop.datasheet_name; iio_chan->info_mask_separate = adc_chan->info_mask; From 380a45aae0c1ceeab6c708fc6451cb60149a8fb1 Mon Sep 17 00:00:00 2001 From: Jishnu Prakash Date: Mon, 17 Feb 2020 23:43:18 +0530 Subject: [PATCH 2/2] thermal: adc-tm: Fix ADC_TM channel mapping Correct channel mapping from VADC's io-channel nodes for PMIC7 ADC. Add compatible property for ADC_TM_IIO node of type PMIC7, as it cannot use the same property as ADC_TM_IIO node of type PMIC5, as channel numbers are computed differently. Change-Id: Ib171e2139b1f4c83e78a5fe7a8d73345f75debf2 Signed-off-by: Jishnu Prakash --- drivers/thermal/qcom/adc-tm.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/qcom/adc-tm.c b/drivers/thermal/qcom/adc-tm.c index 4dbbd5b7567f..d442ee3aae5e 100644 --- a/drivers/thermal/qcom/adc-tm.c +++ b/drivers/thermal/qcom/adc-tm.c @@ -189,6 +189,10 @@ static const struct of_device_id adc_tm_match_table[] = { .compatible = "qcom,adc-tm5-iio", .data = &data_adc_tm5, }, + { + .compatible = "qcom,adc-tm7-iio", + .data = &data_adc_tm7, + }, { .compatible = "qcom,adc-tm7", .data = &data_adc_tm7, @@ -353,8 +357,14 @@ static int adc_tm_get_dt_data(struct platform_device *pdev, while (i < dt_chan_num) { chan_adc = &chan[i]; - if (chan_adc->channel->channel == channel_num) + if (chan_adc->channel->channel == channel_num) { + if ((adc_tm->data == &data_adc_tm7) && + (chan_adc->channel->channel2 != sid)) { + i++; + continue; + } adc_tm->sensor[idx].adc = chan_adc; + } i++; } idx++; @@ -432,7 +442,8 @@ static int adc_tm_probe(struct platform_device *pdev) return ret; } - if (of_device_is_compatible(node, "qcom,adc-tm5-iio")) { + if (of_device_is_compatible(node, "qcom,adc-tm5-iio") || + of_device_is_compatible(node, "qcom,adc-tm7-iio")) { ret = adc_tm_register_tzd(adc_tm, dt_chan_num, false); if (ret) { dev_err(dev, "adc-tm failed to register with of thermal\n");