Re: [PATCH 4/7] thermal: mediatek: add thermal controller offset
On Tue, 2019-02-05 at 16:53 -0800, Eduardo Valentin wrote: > On Fri, Feb 01, 2019 at 03:38:10PM +0800, michael@mediatek.com wrote: > > From: Michael Kao > > > > One thermal controller can read four sensors at most, > > so we need to add controller_offset for the project with > > more than four sensors to reuse the same register settings. > > > > Signed-off-by: Michael Kao > > --- > > drivers/thermal/mtk_thermal.c | 79 > > +-- > > 1 file changed, 54 insertions(+), 25 deletions(-) > > > > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c > > index 45c6587..e5cf3f4 100644 > > --- a/drivers/thermal/mtk_thermal.c > > +++ b/drivers/thermal/mtk_thermal.c > > @@ -105,6 +105,9 @@ > > /* The number of sensing points per bank */ > > #define MT8173_NUM_SENSORS_PER_ZONE4 > > > > +/* The number of controller in the MT8173 */ > > +#define MT8173_NUM_CONTROLLER 1 > > + > > /* The calibration coefficient of sensor */ > > #define MT8173_CALIBRATION 165 > > > > @@ -150,6 +153,9 @@ enum { > > /* The number of sensing points per bank */ > > #define MT2701_NUM_SENSORS_PER_ZONE3 > > > > +/* The number of controller in the MT2701 */ > > +#define MT2701_NUM_CONTROLLER 1 > > + > > /* The calibration coefficient of sensor */ > > #define MT2701_CALIBRATION 165 > > > > @@ -168,6 +174,9 @@ enum { > > /* The number of sensing points per bank */ > > #define MT2712_NUM_SENSORS_PER_ZONE4 > > > > +/* The number of controller in the MT2712 */ > > +#define MT2712_NUM_CONTROLLER 1 > > + > > /* The calibration coefficient of sensor */ > > #define MT2712_CALIBRATION 165 > > > > @@ -176,6 +185,7 @@ enum { > > #define MT7622_NUM_ZONES 1 > > #define MT7622_NUM_SENSORS_PER_ZONE1 > > #define MT7622_TS1 0 > > +#define MT7622_NUM_CONTROLLER 1 > > > > /* The calibration coefficient of sensor */ > > #define MT7622_CALIBRATION 165 > > @@ -201,6 +211,8 @@ struct mtk_thermal_data { > > const int *msr; > > const int *adcpnp; > > const int cali_val; > > + const int num_controller; > > + const int *controller_offset; > > struct thermal_bank_cfg bank_data[]; > > }; > > > > @@ -240,6 +252,7 @@ struct mtk_thermal { > > }; > > > > static const int mt8173_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 > > }; > > +static const int mt8173_tc_offset[MT8173_NUM_CONTROLLER] = { 0x0, }; > > > > static const int mt8173_vts_index[MT8173_NUM_SENSORS] = { > > VTS1, VTS2, VTS3, VTS4, VTSABB > > @@ -259,6 +272,7 @@ struct mtk_thermal { > > }; > > > > static const int mt2701_mux_values[MT2701_NUM_SENSORS] = { 0, 1, 16 }; > > +static const int mt2701_tc_offset[MT2701_NUM_CONTROLLER] = { 0x0, }; > > > > static const int mt2701_vts_index[MT2701_NUM_SENSORS] = { > > VTS1, VTS2, VTS3 > > @@ -278,6 +292,7 @@ struct mtk_thermal { > > }; > > > > static const int mt2712_mux_values[MT2712_NUM_SENSORS] = { 0, 1, 2, 3 }; > > +static const int mt2712_tc_offset[MT2712_NUM_CONTROLLER] = { 0x0, }; > > > > static const int mt2712_vts_index[MT2712_NUM_SENSORS] = { > > VTS1, VTS2, VTS3, VTS4 > > @@ -289,6 +304,7 @@ struct mtk_thermal { > > static const int mt7622_adcpnp[MT7622_NUM_SENSORS_PER_ZONE] = { > > TEMP_ADCPNP0, }; > > static const int mt7622_mux_values[MT7622_NUM_SENSORS] = { 0, }; > > static const int mt7622_vts_index[MT7622_NUM_SENSORS] = { VTS1 }; > > +static const int mt7622_tc_offset[MT7622_NUM_CONTROLLER] = { 0x0, }; > > > > /** > > * The MT8173 thermal controller has four banks. Each bank can read up to > > @@ -309,6 +325,8 @@ struct mtk_thermal { > > .num_sensors = MT8173_NUM_SENSORS, > > .vts_index = mt8173_vts_index, > > .cali_val = MT8173_CALIBRATION, > > + .num_controller = MT8173_NUM_CONTROLLER, > > + .controller_offset = mt8173_tc_offset, > > .bank_data = { > > { > > .num_sensors = 2, > > @@ -345,6 +363,8 @@ struct mtk_thermal { > > .num_sensors = MT2701_NUM_SENSORS, > > .vts_index = mt2701_vts_index, > > .cali_val = MT2701_CALIBRATION, > > + .num_controller = MT2701_NUM_CONTROLLER, > > + .controller_offset = mt2701_tc_offset, > > .bank_data = { > > { > > .num_sensors = 3, > > @@ -372,6 +392,8 @@ struct mtk_thermal { > > .num_sensors = MT2712_NUM_SENSORS, > > .vts_index = mt2712_vts_index, > > .cali_val = MT2712_CALIBRATION, > > + .num_controller = MT2712_NUM_CONTROLLER, > > + .controller_offset = mt2712_tc_offset, > > .bank_data = { > > { > > .num_sensors = 4, > > @@ -393,6 +415,8 @@ struct mtk_thermal { > > .num_sensors = MT7622_NUM_SENSORS, > > .vts_index = mt7622_vts_index, > > .cali_val = MT7622_CALIBRATION, > > + .num_controller = MT7622_NUM_CONTROLLER, > > + .controller_offset = mt7622_tc_offset, > > .bank_data = { > >
Re: [PATCH 4/7] thermal: mediatek: add thermal controller offset
On Fri, Feb 01, 2019 at 03:38:10PM +0800, michael@mediatek.com wrote: > From: Michael Kao > > One thermal controller can read four sensors at most, > so we need to add controller_offset for the project with > more than four sensors to reuse the same register settings. > > Signed-off-by: Michael Kao > --- > drivers/thermal/mtk_thermal.c | 79 > +-- > 1 file changed, 54 insertions(+), 25 deletions(-) > > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c > index 45c6587..e5cf3f4 100644 > --- a/drivers/thermal/mtk_thermal.c > +++ b/drivers/thermal/mtk_thermal.c > @@ -105,6 +105,9 @@ > /* The number of sensing points per bank */ > #define MT8173_NUM_SENSORS_PER_ZONE 4 > > +/* The number of controller in the MT8173 */ > +#define MT8173_NUM_CONTROLLER1 > + > /* The calibration coefficient of sensor */ > #define MT8173_CALIBRATION 165 > > @@ -150,6 +153,9 @@ enum { > /* The number of sensing points per bank */ > #define MT2701_NUM_SENSORS_PER_ZONE 3 > > +/* The number of controller in the MT2701 */ > +#define MT2701_NUM_CONTROLLER1 > + > /* The calibration coefficient of sensor */ > #define MT2701_CALIBRATION 165 > > @@ -168,6 +174,9 @@ enum { > /* The number of sensing points per bank */ > #define MT2712_NUM_SENSORS_PER_ZONE 4 > > +/* The number of controller in the MT2712 */ > +#define MT2712_NUM_CONTROLLER1 > + > /* The calibration coefficient of sensor */ > #define MT2712_CALIBRATION 165 > > @@ -176,6 +185,7 @@ enum { > #define MT7622_NUM_ZONES 1 > #define MT7622_NUM_SENSORS_PER_ZONE 1 > #define MT7622_TS1 0 > +#define MT7622_NUM_CONTROLLER1 > > /* The calibration coefficient of sensor */ > #define MT7622_CALIBRATION 165 > @@ -201,6 +211,8 @@ struct mtk_thermal_data { > const int *msr; > const int *adcpnp; > const int cali_val; > + const int num_controller; > + const int *controller_offset; > struct thermal_bank_cfg bank_data[]; > }; > > @@ -240,6 +252,7 @@ struct mtk_thermal { > }; > > static const int mt8173_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 }; > +static const int mt8173_tc_offset[MT8173_NUM_CONTROLLER] = { 0x0, }; > > static const int mt8173_vts_index[MT8173_NUM_SENSORS] = { > VTS1, VTS2, VTS3, VTS4, VTSABB > @@ -259,6 +272,7 @@ struct mtk_thermal { > }; > > static const int mt2701_mux_values[MT2701_NUM_SENSORS] = { 0, 1, 16 }; > +static const int mt2701_tc_offset[MT2701_NUM_CONTROLLER] = { 0x0, }; > > static const int mt2701_vts_index[MT2701_NUM_SENSORS] = { > VTS1, VTS2, VTS3 > @@ -278,6 +292,7 @@ struct mtk_thermal { > }; > > static const int mt2712_mux_values[MT2712_NUM_SENSORS] = { 0, 1, 2, 3 }; > +static const int mt2712_tc_offset[MT2712_NUM_CONTROLLER] = { 0x0, }; > > static const int mt2712_vts_index[MT2712_NUM_SENSORS] = { > VTS1, VTS2, VTS3, VTS4 > @@ -289,6 +304,7 @@ struct mtk_thermal { > static const int mt7622_adcpnp[MT7622_NUM_SENSORS_PER_ZONE] = { > TEMP_ADCPNP0, }; > static const int mt7622_mux_values[MT7622_NUM_SENSORS] = { 0, }; > static const int mt7622_vts_index[MT7622_NUM_SENSORS] = { VTS1 }; > +static const int mt7622_tc_offset[MT7622_NUM_CONTROLLER] = { 0x0, }; > > /** > * The MT8173 thermal controller has four banks. Each bank can read up to > @@ -309,6 +325,8 @@ struct mtk_thermal { > .num_sensors = MT8173_NUM_SENSORS, > .vts_index = mt8173_vts_index, > .cali_val = MT8173_CALIBRATION, > + .num_controller = MT8173_NUM_CONTROLLER, > + .controller_offset = mt8173_tc_offset, > .bank_data = { > { > .num_sensors = 2, > @@ -345,6 +363,8 @@ struct mtk_thermal { > .num_sensors = MT2701_NUM_SENSORS, > .vts_index = mt2701_vts_index, > .cali_val = MT2701_CALIBRATION, > + .num_controller = MT2701_NUM_CONTROLLER, > + .controller_offset = mt2701_tc_offset, > .bank_data = { > { > .num_sensors = 3, > @@ -372,6 +392,8 @@ struct mtk_thermal { > .num_sensors = MT2712_NUM_SENSORS, > .vts_index = mt2712_vts_index, > .cali_val = MT2712_CALIBRATION, > + .num_controller = MT2712_NUM_CONTROLLER, > + .controller_offset = mt2712_tc_offset, > .bank_data = { > { > .num_sensors = 4, > @@ -393,6 +415,8 @@ struct mtk_thermal { > .num_sensors = MT7622_NUM_SENSORS, > .vts_index = mt7622_vts_index, > .cali_val = MT7622_CALIBRATION, > + .num_controller = MT7622_NUM_CONTROLLER, > + .controller_offset = mt7622_tc_offset, > .bank_data = { > { > .num_sensors = 1, > @@ -523,19 +547,23 @@ static int mtk_read_temp(void *data, int *temperature) > }; > > static void mtk_thermal_init_bank(struct mtk_thermal *mt, int num, > - u32 apmi
Re: [PATCH 4/7] thermal: mediatek: add thermal controller offset
Hi Michael, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on soc-thermal/next] [also build test WARNING on v5.0-rc4] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/michael-kao-mediatek-com/Add-Mediatek-thermal-dirver-for-mt8183/20190204-131145 base: https://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' All warnings (new ones prefixed by >>): >> drivers/thermal/mtk_thermal.c:558:50: sparse: warning: incorrect type in >> initializer (different address spaces) drivers/thermal/mtk_thermal.c:558:50: sparse:expected void *controller_base drivers/thermal/mtk_thermal.c:558:50: sparse:got void [noderef] * >> drivers/thermal/mtk_thermal.c:566:62: sparse: warning: incorrect type in >> argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:566:62: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:566:62: sparse:got void * drivers/thermal/mtk_thermal.c:574:41: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:574:41: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:574:41: sparse:got void * drivers/thermal/mtk_thermal.c:578:32: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:578:32: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:578:32: sparse:got void * drivers/thermal/mtk_thermal.c:581:37: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:581:37: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:581:37: sparse:got void * drivers/thermal/mtk_thermal.c:584:44: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:584:44: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:584:44: sparse:got void * drivers/thermal/mtk_thermal.c:587:37: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:587:37: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:587:37: sparse:got void * drivers/thermal/mtk_thermal.c:588:37: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:588:37: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:588:37: sparse:got void * drivers/thermal/mtk_thermal.c:603:59: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:603:59: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:603:59: sparse:got void * drivers/thermal/mtk_thermal.c:607:32: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:607:32: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:607:32: sparse:got void * drivers/thermal/mtk_thermal.c:611:32: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:611:32: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:611:32: sparse:got void * drivers/thermal/mtk_thermal.c:614:59: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:614:59: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:614:59: sparse:got void * drivers/thermal/mtk_thermal.c:618:32: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:618:32: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:618:32: sparse:got void * drivers/thermal/mtk_thermal.c:622:32: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:622:32: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:622:32: sparse:got void * drivers/thermal/mtk_thermal.c:626:32: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:626:32: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:626:32: sparse:got void * drivers/thermal/mtk_thermal.c:629:37: sparse: warning: incorrect type in argument 2 (different address spaces) drivers/thermal/mtk_thermal.c:629:37: sparse:expected void volatile [noderef] *addr drivers/thermal/mtk_thermal.c:629:37: sparse:go