Re: [PATCH v2] thermal: exynos: Add the support for Exynos5433 TMU
Hi Chanwoo, > Hi Eduardo and Lukasz, > > I checked this patch merged on linux-next.git. > But, this patch is not merged on Linux 4.1-rc1. This is indeed strange. Eduardo do you have any idea why this patch is missing? > > Thanks, > Chanwoo Choi > > On 03/18/2015 04:39 PM, Lukasz Majewski wrote: > > Hi Chanwoo, > > > >> Hi Lukasz, > >> > >> Genlty Ping. > > > > I've got your patches at the back of my head :-) > > > > I will try to review them today or tomorrow. > > > >> > >> Best Regards, > >> Chanwoo Choi > >> -- Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2] thermal: exynos: Add the support for Exynos5433 TMU
Hi Eduardo and Lukasz, I checked this patch merged on linux-next.git. But, this patch is not merged on Linux 4.1-rc1. Thanks, Chanwoo Choi On 03/18/2015 04:39 PM, Lukasz Majewski wrote: > Hi Chanwoo, > >> Hi Lukasz, >> >> Genlty Ping. > > I've got your patches at the back of my head :-) > > I will try to review them today or tomorrow. > >> >> Best Regards, >> Chanwoo Choi >> >> On 03/10/2015 11:23 AM, Chanwoo Choi wrote: >>> This patch adds the support for Exynos5433's TMU (Thermal >>> Management Unit). Exynos5433 has a little different register bit >>> fields as following description: >>> - Support the eight trip points for rising/falling interrupt by >>> using two registers >>> - Read the calibration type (1-point or 2-point) and sensor id from >>> TRIMINFO register >>> - Use a little different register address >>> >>> Cc: Zhang Rui >>> Cc: Eduardo Valentin >>> Cc: Lukasz Majewski >>> Signed-off-by: Chanwoo Choi >>> --- >>> Changes from v1: >>> (https://lkml.org/lkml/2015/2/26/234) >>> - Add exynos5433_tmu_control() instead of using >>> exynos7_tmu_control() on both Exynos5433 and Exynos7. >>> - Separate the patches related to devicetree and then send send >>> Exnos5433's tmu patches[1] with other Exynos5433 devicetree patches. >>> [1] https://lkml.org/lkml/2015/3/9/1036 >>> >>> drivers/thermal/samsung/exynos_tmu.c | 187 >>> ++- >>> drivers/thermal/samsung/exynos_tmu.h | 1 + 2 files changed, 186 >>> insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/thermal/samsung/exynos_tmu.c >>> b/drivers/thermal/samsung/exynos_tmu.c index 1d30b09..531f4b17 >>> 100644 --- a/drivers/thermal/samsung/exynos_tmu.c >>> +++ b/drivers/thermal/samsung/exynos_tmu.c >>> @@ -97,6 +97,32 @@ >>> #define EXYNOS4412_MUX_ADDR_VALUE 6 >>> #define EXYNOS4412_MUX_ADDR_SHIFT 20 >>> >>> +/* Exynos5433 specific registers */ >>> +#define EXYNOS5433_TMU_REG_CONTROL10x024 >>> +#define EXYNOS5433_TMU_SAMPLING_INTERVAL 0x02c >>> +#define EXYNOS5433_TMU_COUNTER_VALUE0 0x030 >>> +#define EXYNOS5433_TMU_COUNTER_VALUE1 0x034 >>> +#define EXYNOS5433_TMU_REG_CURRENT_TEMP1 0x044 >>> +#define EXYNOS5433_THD_TEMP_RISE3_00x050 >>> +#define EXYNOS5433_THD_TEMP_RISE7_40x054 >>> +#define EXYNOS5433_THD_TEMP_FALL3_00x060 >>> +#define EXYNOS5433_THD_TEMP_FALL7_40x064 >>> +#define EXYNOS5433_TMU_REG_INTEN 0x0c0 >>> +#define EXYNOS5433_TMU_REG_INTPEND 0x0c8 >>> +#define EXYNOS5433_TMU_EMUL_CON0x110 >>> +#define EXYNOS5433_TMU_PD_DET_EN 0x130 >>> + >>> +#define EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT16 >>> +#define EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT23 >>> +#define EXYNOS5433_TRIMINFO_SENSOR_ID_MASK \ >>> + (0xf << >>> EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT) +#define >>> EXYNOS5433_TRIMINFO_CALIB_SEL_MASK BIT(23) + >>> +#define EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING 0 >>> +#define EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING 1 >>> + >>> +#define EXYNOS5433_PD_DET_EN 1 >>> + >>> /*exynos5440 specific registers*/ >>> #define EXYNOS5440_TMU_S0_7_TRIM 0x000 >>> #define EXYNOS5440_TMU_S0_7_CTRL 0x020 >>> @@ -484,6 +510,101 @@ out: >>> return ret; >>> } >>> >>> +static int exynos5433_tmu_initialize(struct platform_device *pdev) >>> +{ >>> + struct exynos_tmu_data *data = platform_get_drvdata(pdev); >>> + struct exynos_tmu_platform_data *pdata = data->pdata; >>> + struct thermal_zone_device *tz = data->tzd; >>> + unsigned int status, trim_info; >>> + unsigned int rising_threshold = 0, falling_threshold = 0; >>> + unsigned long temp, temp_hist; >>> + int ret = 0, threshold_code, i, sensor_id, cal_type; >>> + >>> + status = readb(data->base + EXYNOS_TMU_REG_STATUS); >>> + if (!status) { >>> + ret = -EBUSY; >>> + goto out; >>> + } >>> + >>> + trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); >>> + sanitize_temp_error(data, trim_info); >>> + >>> + /* Read the temperature sensor id */ >>> + sensor_id = (trim_info & >>> EXYNOS5433_TRIMINFO_SENSOR_ID_MASK) >>> + >> >>> EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT; >>> + dev_info(&pdev->dev, "Temperature sensor ID: 0x%x\n", >>> sensor_id); + >>> + /* Read the calibration mode */ >>> + writel(trim_info, data->base + EXYNOS_TMU_REG_TRIMINFO); >>> + cal_type = (trim_info & EXYNOS5433_TRIMINFO_CALIB_SEL_MASK) >>> + >> >>> EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT; + >>> + switch (cal_type) { >>> + case EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING: >>> + pdata->cal_type = TYPE_ONE_POINT_TRIMMING; >>> + break; >>> + case EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING: >>> + pdata->cal_type = TYPE_TWO_POINT_TRIMMING; >>> + break; >>> + default: >>> + pdata->cal_type = TYPE_ONE_POI
Re: [PATCH v2] thermal: exynos: Add the support for Exynos5433 TMU
Hi Chanwoo, > This patch adds the support for Exynos5433's TMU (Thermal Management > Unit). Exynos5433 has a little different register bit fields as > following description: > - Support the eight trip points for rising/falling interrupt by using > two registers > - Read the calibration type (1-point or 2-point) and sensor id from > TRIMINFO register > - Use a little different register address > > Cc: Zhang Rui > Cc: Eduardo Valentin > Cc: Lukasz Majewski > Signed-off-by: Chanwoo Choi > --- > Changes from v1: > (https://lkml.org/lkml/2015/2/26/234) > - Add exynos5433_tmu_control() instead of using exynos7_tmu_control() > on both Exynos5433 and Exynos7. > - Separate the patches related to devicetree and then send send > Exnos5433's tmu patches[1] with other Exynos5433 devicetree patches. > [1] https://lkml.org/lkml/2015/3/9/1036 > > drivers/thermal/samsung/exynos_tmu.c | 187 > ++- > drivers/thermal/samsung/exynos_tmu.h | 1 + 2 files changed, 186 > insertions(+), 2 deletions(-) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c index 1d30b09..531f4b17 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -97,6 +97,32 @@ > #define EXYNOS4412_MUX_ADDR_VALUE 6 > #define EXYNOS4412_MUX_ADDR_SHIFT 20 > > +/* Exynos5433 specific registers */ > +#define EXYNOS5433_TMU_REG_CONTROL1 0x024 > +#define EXYNOS5433_TMU_SAMPLING_INTERVAL 0x02c > +#define EXYNOS5433_TMU_COUNTER_VALUE00x030 > +#define EXYNOS5433_TMU_COUNTER_VALUE10x034 > +#define EXYNOS5433_TMU_REG_CURRENT_TEMP1 0x044 > +#define EXYNOS5433_THD_TEMP_RISE3_0 0x050 > +#define EXYNOS5433_THD_TEMP_RISE7_4 0x054 > +#define EXYNOS5433_THD_TEMP_FALL3_0 0x060 > +#define EXYNOS5433_THD_TEMP_FALL7_4 0x064 > +#define EXYNOS5433_TMU_REG_INTEN 0x0c0 > +#define EXYNOS5433_TMU_REG_INTPEND 0x0c8 > +#define EXYNOS5433_TMU_EMUL_CON 0x110 > +#define EXYNOS5433_TMU_PD_DET_EN 0x130 > + > +#define EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT 16 > +#define EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT 23 > +#define EXYNOS5433_TRIMINFO_SENSOR_ID_MASK \ > + (0xf << EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT) > +#define EXYNOS5433_TRIMINFO_CALIB_SEL_MASK BIT(23) > + > +#define EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING 0 > +#define EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING 1 > + > +#define EXYNOS5433_PD_DET_EN 1 > + > /*exynos5440 specific registers*/ > #define EXYNOS5440_TMU_S0_7_TRIM 0x000 > #define EXYNOS5440_TMU_S0_7_CTRL 0x020 > @@ -484,6 +510,101 @@ out: > return ret; > } > > +static int exynos5433_tmu_initialize(struct platform_device *pdev) > +{ > + struct exynos_tmu_data *data = platform_get_drvdata(pdev); > + struct exynos_tmu_platform_data *pdata = data->pdata; > + struct thermal_zone_device *tz = data->tzd; > + unsigned int status, trim_info; > + unsigned int rising_threshold = 0, falling_threshold = 0; > + unsigned long temp, temp_hist; > + int ret = 0, threshold_code, i, sensor_id, cal_type; > + > + status = readb(data->base + EXYNOS_TMU_REG_STATUS); > + if (!status) { > + ret = -EBUSY; > + goto out; > + } > + > + trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); > + sanitize_temp_error(data, trim_info); > + > + /* Read the temperature sensor id */ > + sensor_id = (trim_info & EXYNOS5433_TRIMINFO_SENSOR_ID_MASK) > + >> > EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT; > + dev_info(&pdev->dev, "Temperature sensor ID: 0x%x\n", > sensor_id); + > + /* Read the calibration mode */ > + writel(trim_info, data->base + EXYNOS_TMU_REG_TRIMINFO); > + cal_type = (trim_info & EXYNOS5433_TRIMINFO_CALIB_SEL_MASK) > + >> > EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT; + > + switch (cal_type) { > + case EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING: > + pdata->cal_type = TYPE_ONE_POINT_TRIMMING; > + break; > + case EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING: > + pdata->cal_type = TYPE_TWO_POINT_TRIMMING; > + break; > + default: > + pdata->cal_type = TYPE_ONE_POINT_TRIMMING; > + break; > + }; > + > + dev_info(&pdev->dev, "Calibration type is %d-point > calibration\n", > + cal_type ? 2 : 1); > + > + /* Write temperature code for rising and falling threshold */ > + for (i = 0; i < of_thermal_get_ntrips(tz); i++) { > + int rising_reg_offset, falling_reg_offset; > + int j = 0; > + > + switch (i) { > + case 0: > + case 1: > + case 2: > + case 3: > + rising_reg_offset = > EXYNOS5433_THD_TEMP_RISE
Re: [PATCH v2] thermal: exynos: Add the support for Exynos5433 TMU
Hi Chanwoo, > Hi Lukasz, > > Genlty Ping. I've got your patches at the back of my head :-) I will try to review them today or tomorrow. > > Best Regards, > Chanwoo Choi > > On 03/10/2015 11:23 AM, Chanwoo Choi wrote: > > This patch adds the support for Exynos5433's TMU (Thermal > > Management Unit). Exynos5433 has a little different register bit > > fields as following description: > > - Support the eight trip points for rising/falling interrupt by > > using two registers > > - Read the calibration type (1-point or 2-point) and sensor id from > > TRIMINFO register > > - Use a little different register address > > > > Cc: Zhang Rui > > Cc: Eduardo Valentin > > Cc: Lukasz Majewski > > Signed-off-by: Chanwoo Choi > > --- > > Changes from v1: > > (https://lkml.org/lkml/2015/2/26/234) > > - Add exynos5433_tmu_control() instead of using > > exynos7_tmu_control() on both Exynos5433 and Exynos7. > > - Separate the patches related to devicetree and then send send > > Exnos5433's tmu patches[1] with other Exynos5433 devicetree patches. > > [1] https://lkml.org/lkml/2015/3/9/1036 > > > > drivers/thermal/samsung/exynos_tmu.c | 187 > > ++- > > drivers/thermal/samsung/exynos_tmu.h | 1 + 2 files changed, 186 > > insertions(+), 2 deletions(-) > > > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > > b/drivers/thermal/samsung/exynos_tmu.c index 1d30b09..531f4b17 > > 100644 --- a/drivers/thermal/samsung/exynos_tmu.c > > +++ b/drivers/thermal/samsung/exynos_tmu.c > > @@ -97,6 +97,32 @@ > > #define EXYNOS4412_MUX_ADDR_VALUE 6 > > #define EXYNOS4412_MUX_ADDR_SHIFT 20 > > > > +/* Exynos5433 specific registers */ > > +#define EXYNOS5433_TMU_REG_CONTROL10x024 > > +#define EXYNOS5433_TMU_SAMPLING_INTERVAL 0x02c > > +#define EXYNOS5433_TMU_COUNTER_VALUE0 0x030 > > +#define EXYNOS5433_TMU_COUNTER_VALUE1 0x034 > > +#define EXYNOS5433_TMU_REG_CURRENT_TEMP1 0x044 > > +#define EXYNOS5433_THD_TEMP_RISE3_00x050 > > +#define EXYNOS5433_THD_TEMP_RISE7_40x054 > > +#define EXYNOS5433_THD_TEMP_FALL3_00x060 > > +#define EXYNOS5433_THD_TEMP_FALL7_40x064 > > +#define EXYNOS5433_TMU_REG_INTEN 0x0c0 > > +#define EXYNOS5433_TMU_REG_INTPEND 0x0c8 > > +#define EXYNOS5433_TMU_EMUL_CON0x110 > > +#define EXYNOS5433_TMU_PD_DET_EN 0x130 > > + > > +#define EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT16 > > +#define EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT23 > > +#define EXYNOS5433_TRIMINFO_SENSOR_ID_MASK \ > > + (0xf << > > EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT) +#define > > EXYNOS5433_TRIMINFO_CALIB_SEL_MASK BIT(23) + > > +#define EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING 0 > > +#define EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING 1 > > + > > +#define EXYNOS5433_PD_DET_EN 1 > > + > > /*exynos5440 specific registers*/ > > #define EXYNOS5440_TMU_S0_7_TRIM 0x000 > > #define EXYNOS5440_TMU_S0_7_CTRL 0x020 > > @@ -484,6 +510,101 @@ out: > > return ret; > > } > > > > +static int exynos5433_tmu_initialize(struct platform_device *pdev) > > +{ > > + struct exynos_tmu_data *data = platform_get_drvdata(pdev); > > + struct exynos_tmu_platform_data *pdata = data->pdata; > > + struct thermal_zone_device *tz = data->tzd; > > + unsigned int status, trim_info; > > + unsigned int rising_threshold = 0, falling_threshold = 0; > > + unsigned long temp, temp_hist; > > + int ret = 0, threshold_code, i, sensor_id, cal_type; > > + > > + status = readb(data->base + EXYNOS_TMU_REG_STATUS); > > + if (!status) { > > + ret = -EBUSY; > > + goto out; > > + } > > + > > + trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); > > + sanitize_temp_error(data, trim_info); > > + > > + /* Read the temperature sensor id */ > > + sensor_id = (trim_info & > > EXYNOS5433_TRIMINFO_SENSOR_ID_MASK) > > + >> > > EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT; > > + dev_info(&pdev->dev, "Temperature sensor ID: 0x%x\n", > > sensor_id); + > > + /* Read the calibration mode */ > > + writel(trim_info, data->base + EXYNOS_TMU_REG_TRIMINFO); > > + cal_type = (trim_info & EXYNOS5433_TRIMINFO_CALIB_SEL_MASK) > > + >> > > EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT; + > > + switch (cal_type) { > > + case EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING: > > + pdata->cal_type = TYPE_ONE_POINT_TRIMMING; > > + break; > > + case EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING: > > + pdata->cal_type = TYPE_TWO_POINT_TRIMMING; > > + break; > > + default: > > + pdata->cal_type = TYPE_ONE_POINT_TRIMMING; > > + break; > > + }; > > + > > + dev_info(&pdev->dev, "Calibration type is %d-point > > calibration\n", > > + cal_type ? 2 : 1); > > + > > + /* Write temper
Re: [PATCH v2] thermal: exynos: Add the support for Exynos5433 TMU
Hi Lukasz, Genlty Ping. Best Regards, Chanwoo Choi On 03/10/2015 11:23 AM, Chanwoo Choi wrote: > This patch adds the support for Exynos5433's TMU (Thermal Management Unit). > Exynos5433 has a little different register bit fields as following > description: > - Support the eight trip points for rising/falling interrupt by using two > registers > - Read the calibration type (1-point or 2-point) and sensor id from TRIMINFO > register > - Use a little different register address > > Cc: Zhang Rui > Cc: Eduardo Valentin > Cc: Lukasz Majewski > Signed-off-by: Chanwoo Choi > --- > Changes from v1: > (https://lkml.org/lkml/2015/2/26/234) > - Add exynos5433_tmu_control() instead of using exynos7_tmu_control() on both > Exynos5433 and Exynos7. > - Separate the patches related to devicetree and then send send Exnos5433's > tmu > patches[1] with other Exynos5433 devicetree patches. > [1] https://lkml.org/lkml/2015/3/9/1036 > > drivers/thermal/samsung/exynos_tmu.c | 187 > ++- > drivers/thermal/samsung/exynos_tmu.h | 1 + > 2 files changed, 186 insertions(+), 2 deletions(-) > > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index 1d30b09..531f4b17 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -97,6 +97,32 @@ > #define EXYNOS4412_MUX_ADDR_VALUE 6 > #define EXYNOS4412_MUX_ADDR_SHIFT 20 > > +/* Exynos5433 specific registers */ > +#define EXYNOS5433_TMU_REG_CONTROL1 0x024 > +#define EXYNOS5433_TMU_SAMPLING_INTERVAL 0x02c > +#define EXYNOS5433_TMU_COUNTER_VALUE00x030 > +#define EXYNOS5433_TMU_COUNTER_VALUE10x034 > +#define EXYNOS5433_TMU_REG_CURRENT_TEMP1 0x044 > +#define EXYNOS5433_THD_TEMP_RISE3_0 0x050 > +#define EXYNOS5433_THD_TEMP_RISE7_4 0x054 > +#define EXYNOS5433_THD_TEMP_FALL3_0 0x060 > +#define EXYNOS5433_THD_TEMP_FALL7_4 0x064 > +#define EXYNOS5433_TMU_REG_INTEN 0x0c0 > +#define EXYNOS5433_TMU_REG_INTPEND 0x0c8 > +#define EXYNOS5433_TMU_EMUL_CON 0x110 > +#define EXYNOS5433_TMU_PD_DET_EN 0x130 > + > +#define EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT 16 > +#define EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT 23 > +#define EXYNOS5433_TRIMINFO_SENSOR_ID_MASK \ > + (0xf << EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT) > +#define EXYNOS5433_TRIMINFO_CALIB_SEL_MASK BIT(23) > + > +#define EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING 0 > +#define EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING 1 > + > +#define EXYNOS5433_PD_DET_EN 1 > + > /*exynos5440 specific registers*/ > #define EXYNOS5440_TMU_S0_7_TRIM 0x000 > #define EXYNOS5440_TMU_S0_7_CTRL 0x020 > @@ -484,6 +510,101 @@ out: > return ret; > } > > +static int exynos5433_tmu_initialize(struct platform_device *pdev) > +{ > + struct exynos_tmu_data *data = platform_get_drvdata(pdev); > + struct exynos_tmu_platform_data *pdata = data->pdata; > + struct thermal_zone_device *tz = data->tzd; > + unsigned int status, trim_info; > + unsigned int rising_threshold = 0, falling_threshold = 0; > + unsigned long temp, temp_hist; > + int ret = 0, threshold_code, i, sensor_id, cal_type; > + > + status = readb(data->base + EXYNOS_TMU_REG_STATUS); > + if (!status) { > + ret = -EBUSY; > + goto out; > + } > + > + trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); > + sanitize_temp_error(data, trim_info); > + > + /* Read the temperature sensor id */ > + sensor_id = (trim_info & EXYNOS5433_TRIMINFO_SENSOR_ID_MASK) > + >> EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT; > + dev_info(&pdev->dev, "Temperature sensor ID: 0x%x\n", sensor_id); > + > + /* Read the calibration mode */ > + writel(trim_info, data->base + EXYNOS_TMU_REG_TRIMINFO); > + cal_type = (trim_info & EXYNOS5433_TRIMINFO_CALIB_SEL_MASK) > + >> EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT; > + > + switch (cal_type) { > + case EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING: > + pdata->cal_type = TYPE_ONE_POINT_TRIMMING; > + break; > + case EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING: > + pdata->cal_type = TYPE_TWO_POINT_TRIMMING; > + break; > + default: > + pdata->cal_type = TYPE_ONE_POINT_TRIMMING; > + break; > + }; > + > + dev_info(&pdev->dev, "Calibration type is %d-point calibration\n", > + cal_type ? 2 : 1); > + > + /* Write temperature code for rising and falling threshold */ > + for (i = 0; i < of_thermal_get_ntrips(tz); i++) { > + int rising_reg_offset, falling_reg_offset; > + int j = 0; > + > + switch (i) { > + case 0: > + case 1: > + case 2
[PATCH v2] thermal: exynos: Add the support for Exynos5433 TMU
This patch adds the support for Exynos5433's TMU (Thermal Management Unit). Exynos5433 has a little different register bit fields as following description: - Support the eight trip points for rising/falling interrupt by using two registers - Read the calibration type (1-point or 2-point) and sensor id from TRIMINFO register - Use a little different register address Cc: Zhang Rui Cc: Eduardo Valentin Cc: Lukasz Majewski Signed-off-by: Chanwoo Choi --- Changes from v1: (https://lkml.org/lkml/2015/2/26/234) - Add exynos5433_tmu_control() instead of using exynos7_tmu_control() on both Exynos5433 and Exynos7. - Separate the patches related to devicetree and then send send Exnos5433's tmu patches[1] with other Exynos5433 devicetree patches. [1] https://lkml.org/lkml/2015/3/9/1036 drivers/thermal/samsung/exynos_tmu.c | 187 ++- drivers/thermal/samsung/exynos_tmu.h | 1 + 2 files changed, 186 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 1d30b09..531f4b17 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -97,6 +97,32 @@ #define EXYNOS4412_MUX_ADDR_VALUE 6 #define EXYNOS4412_MUX_ADDR_SHIFT 20 +/* Exynos5433 specific registers */ +#define EXYNOS5433_TMU_REG_CONTROL10x024 +#define EXYNOS5433_TMU_SAMPLING_INTERVAL 0x02c +#define EXYNOS5433_TMU_COUNTER_VALUE0 0x030 +#define EXYNOS5433_TMU_COUNTER_VALUE1 0x034 +#define EXYNOS5433_TMU_REG_CURRENT_TEMP1 0x044 +#define EXYNOS5433_THD_TEMP_RISE3_00x050 +#define EXYNOS5433_THD_TEMP_RISE7_40x054 +#define EXYNOS5433_THD_TEMP_FALL3_00x060 +#define EXYNOS5433_THD_TEMP_FALL7_40x064 +#define EXYNOS5433_TMU_REG_INTEN 0x0c0 +#define EXYNOS5433_TMU_REG_INTPEND 0x0c8 +#define EXYNOS5433_TMU_EMUL_CON0x110 +#define EXYNOS5433_TMU_PD_DET_EN 0x130 + +#define EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT16 +#define EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT23 +#define EXYNOS5433_TRIMINFO_SENSOR_ID_MASK \ + (0xf << EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT) +#define EXYNOS5433_TRIMINFO_CALIB_SEL_MASK BIT(23) + +#define EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING 0 +#define EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING 1 + +#define EXYNOS5433_PD_DET_EN 1 + /*exynos5440 specific registers*/ #define EXYNOS5440_TMU_S0_7_TRIM 0x000 #define EXYNOS5440_TMU_S0_7_CTRL 0x020 @@ -484,6 +510,101 @@ out: return ret; } +static int exynos5433_tmu_initialize(struct platform_device *pdev) +{ + struct exynos_tmu_data *data = platform_get_drvdata(pdev); + struct exynos_tmu_platform_data *pdata = data->pdata; + struct thermal_zone_device *tz = data->tzd; + unsigned int status, trim_info; + unsigned int rising_threshold = 0, falling_threshold = 0; + unsigned long temp, temp_hist; + int ret = 0, threshold_code, i, sensor_id, cal_type; + + status = readb(data->base + EXYNOS_TMU_REG_STATUS); + if (!status) { + ret = -EBUSY; + goto out; + } + + trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); + sanitize_temp_error(data, trim_info); + + /* Read the temperature sensor id */ + sensor_id = (trim_info & EXYNOS5433_TRIMINFO_SENSOR_ID_MASK) + >> EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT; + dev_info(&pdev->dev, "Temperature sensor ID: 0x%x\n", sensor_id); + + /* Read the calibration mode */ + writel(trim_info, data->base + EXYNOS_TMU_REG_TRIMINFO); + cal_type = (trim_info & EXYNOS5433_TRIMINFO_CALIB_SEL_MASK) + >> EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT; + + switch (cal_type) { + case EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING: + pdata->cal_type = TYPE_ONE_POINT_TRIMMING; + break; + case EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING: + pdata->cal_type = TYPE_TWO_POINT_TRIMMING; + break; + default: + pdata->cal_type = TYPE_ONE_POINT_TRIMMING; + break; + }; + + dev_info(&pdev->dev, "Calibration type is %d-point calibration\n", + cal_type ? 2 : 1); + + /* Write temperature code for rising and falling threshold */ + for (i = 0; i < of_thermal_get_ntrips(tz); i++) { + int rising_reg_offset, falling_reg_offset; + int j = 0; + + switch (i) { + case 0: + case 1: + case 2: + case 3: + rising_reg_offset = EXYNOS5433_THD_TEMP_RISE3_0; + falling_reg_offset = EXYNOS5433_THD_TEMP_FALL3_0; + j = i; + break; +