Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751837AbdIOCKz (ORCPT ); Thu, 14 Sep 2017 22:10:55 -0400 Received: from regular1.263xmail.com ([211.150.99.139]:60715 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751771AbdIOCKa (ORCPT ); Thu, 14 Sep 2017 22:10:30 -0400 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-RL-SENDER: wxt@rock-chips.com X-FST-TO: wxt@rock-chips.com X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: wxt@rock-chips.com X-UNIQUE-TAG: <557022cc56cf8c6f7f5bb83d3a53cc81> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Subject: Re: [PATCH 2/5] thermal: rockchip: Support the RV1108 SoC in thermal driver To: Rocky Hao Cc: rui.zhang@intel.com, edubezval@gmail.com, heiko@sntech.de, robh+dt@kernel.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, huangtao@rock-chips.com, devicetree@vger.kernel.org, linux-pm@vger.kernel.org, shawn.lin@rock-chips.com, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, cl@rock-chips.com, william.wu@rock-chips.com, jay.xu@rock-chips.com, xxx@rock-chips.com, linux-arm-kernel@lists.infradead.org, wxt@rock-chips.com References: <1503570475-7850-1-git-send-email-rocky.hao@rock-chips.com> <1503570475-7850-3-git-send-email-rocky.hao@rock-chips.com> From: Caesar Wang Message-ID: <341e8e9b-21c7-f418-b744-8c18737cb026@rock-chips.com> Date: Fri, 15 Sep 2017 10:10:03 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1503570475-7850-3-git-send-email-rocky.hao@rock-chips.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3240 Lines: 122 Hi Rocky, 在 2017年08月24日 18:27, Rocky Hao 写道: > RV1108 SOC has one Temperature Sensor for CPU. > > Signed-off-by: Rocky Hao > --- > drivers/thermal/rockchip_thermal.c | 67 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 67 insertions(+) > > diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c > index 9da3e1819210..299a8ade71fa 100644 > --- a/drivers/thermal/rockchip_thermal.c > +++ b/drivers/thermal/rockchip_thermal.c > @@ -242,6 +242,45 @@ struct tsadc_table { > int temp; > }; > > +static const struct tsadc_table rv1108_table[] = { > + {0, -40000}, > + {374, -40000}, > + {382, -35000}, > + {389, -30000}, > + {397, -25000}, > + {405, -20000}, > + {413, -15000}, > + {421, -10000}, > + {429, -5000}, > + {436, 0}, > + {444, 5000}, > + {452, 10000}, > + {460, 15000}, > + {468, 20000}, > + {476, 25000}, > + {483, 30000}, > + {491, 35000}, > + {499, 40000}, > + {507, 45000}, > + {515, 50000}, > + {523, 55000}, > + {531, 60000}, > + {539, 65000}, > + {547, 70000}, > + {555, 75000}, > + {562, 80000}, > + {570, 85000}, > + {578, 90000}, > + {586, 95000}, > + {594, 100000}, > + {602, 105000}, > + {610, 110000}, > + {618, 115000}, > + {626, 120000}, > + {634, 125000}, > + {TSADCV2_DATA_MASK, 125000}, > +}; > + From the RV1108 TRM said, this table was used for the negative temperature coefficient. But the default table is positive temperature coefficient, why? I think you don't need to use the negative temperature coefficient. > static const struct tsadc_table rk3228_code_table[] = { > {0, -40000}, > {588, -40000}, > @@ -779,6 +818,30 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs, > writel_relaxed(val, regs + TSADCV2_INT_EN); > } > > +static const struct rockchip_tsadc_chip rv1108_tsadc_data = { > + .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ > + .chn_num = 1, /* one channel for tsadc */ > + > + .tshut_mode = TSHUT_MODE_GPIO, /* default TSHUT via GPIO give PMIC */ > + .tshut_polarity = TSHUT_LOW_ACTIVE, /* default TSHUT LOW ACTIVE */ > + .tshut_temp = 95000, > + > + .initialize = rk_tsadcv2_initialize, > + .irq_ack = rk_tsadcv3_irq_ack, > + .control = rk_tsadcv3_control, If you will use the positive temperature coefficient, we need change it. .control = rk_tsadcv2_control, > + .get_temp = rk_tsadcv2_get_temp, > + .set_alarm_temp = rk_tsadcv2_alarm_temp, > + .set_tshut_temp = rk_tsadcv2_tshut_temp, > + .set_tshut_mode = rk_tsadcv2_tshut_mode, > + > + .table = { > + .id = rv1108_table, > + .length = ARRAY_SIZE(rv1108_table), > + .data_mask = TSADCV2_DATA_MASK, > + .mode = ADC_INCREMENT, Ditto -Caesar > + }, > +}; > + > static const struct rockchip_tsadc_chip rk3228_tsadc_data = { > .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */ > .chn_num = 1, /* one channel for tsadc */ > @@ -928,6 +991,10 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs, > > static const struct of_device_id of_rockchip_thermal_match[] = { > { > + .compatible = "rockchip,rv1108-tsadc", > + .data = (void *)&rv1108_tsadc_data, > + }, > + { > .compatible = "rockchip,rk3228-tsadc", > .data = (void *)&rk3228_tsadc_data, > },