Skip to content

Commit f6c8367

Browse files
anderssondlezcano
authored andcommitted
thermal/drivers/qcom/spmi-adc-tm5: Add support for HC variant
The variant of the ADC Thermal Monitor block found in e.g. PM8998 is "HC", add support for this variant to the ADC TM5 driver in order to support using VADC channels as thermal_zones on SDM845 et al. Signed-off-by: Bjorn Andersson <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent db03874 commit f6c8367

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

drivers/thermal/qcom/qcom-spmi-adc-tm5.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct adc_tm5_data {
8282
const u32 full_scale_code_volt;
8383
unsigned int *decimation;
8484
unsigned int *hw_settle;
85+
bool is_hc;
8586
};
8687

8788
enum adc_tm5_cal_method {
@@ -146,6 +147,14 @@ static const struct adc_tm5_data adc_tm5_data_pmic = {
146147
64000, 128000 },
147148
};
148149

150+
static const struct adc_tm5_data adc_tm_hc_data_pmic = {
151+
.full_scale_code_volt = 0x70e4,
152+
.decimation = (unsigned int []) { 256, 512, 1024 },
153+
.hw_settle = (unsigned int []) { 0, 100, 200, 300, 400, 500, 600, 700,
154+
1000, 2000, 4000, 6000, 8000, 10000 },
155+
.is_hc = true,
156+
};
157+
149158
static int adc_tm5_read(struct adc_tm5_chip *adc_tm, u16 offset, u8 *data, int len)
150159
{
151160
return regmap_bulk_read(adc_tm->regmap, adc_tm->base + offset, data, len);
@@ -375,6 +384,29 @@ static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm)
375384
return 0;
376385
}
377386

387+
static int adc_tm_hc_init(struct adc_tm5_chip *chip)
388+
{
389+
unsigned int i;
390+
u8 buf[2];
391+
int ret;
392+
393+
for (i = 0; i < chip->nchannels; i++) {
394+
if (chip->channels[i].channel >= ADC_TM5_NUM_CHANNELS) {
395+
dev_err(chip->dev, "Invalid channel %d\n", chip->channels[i].channel);
396+
return -EINVAL;
397+
}
398+
}
399+
400+
buf[0] = chip->decimation;
401+
buf[1] = chip->avg_samples | ADC_TM5_FAST_AVG_EN;
402+
403+
ret = adc_tm5_write(chip, ADC_TM5_ADC_DIG_PARAM, buf, sizeof(buf));
404+
if (ret)
405+
dev_err(chip->dev, "block write failed: %d\n", ret);
406+
407+
return ret;
408+
}
409+
378410
static int adc_tm5_init(struct adc_tm5_chip *chip)
379411
{
380412
u8 buf[4], channels_available;
@@ -591,7 +623,10 @@ static int adc_tm5_probe(struct platform_device *pdev)
591623
return ret;
592624
}
593625

594-
ret = adc_tm5_init(adc_tm);
626+
if (adc_tm->data->is_hc)
627+
ret = adc_tm_hc_init(adc_tm);
628+
else
629+
ret = adc_tm5_init(adc_tm);
595630
if (ret) {
596631
dev_err(dev, "adc-tm init failed\n");
597632
return ret;
@@ -612,6 +647,10 @@ static const struct of_device_id adc_tm5_match_table[] = {
612647
.compatible = "qcom,spmi-adc-tm5",
613648
.data = &adc_tm5_data_pmic,
614649
},
650+
{
651+
.compatible = "qcom,spmi-adc-tm-hc",
652+
.data = &adc_tm_hc_data_pmic,
653+
},
615654
{ }
616655
};
617656
MODULE_DEVICE_TABLE(of, adc_tm5_match_table);

0 commit comments

Comments
 (0)