Re: [PATCH V6 23/30] thermal: exynos: Add driver support for exynos5440 TMU sensor
Hi Eduardo, On Thu, Jun 20, 2013 at 7:36 AM, Eduardo Valentin wrote: > On 17-06-2013 02:46, Amit Daniel Kachhap wrote: >> This patch modifies TMU controller to add changes needed to work with >> exynos5440 platform. This sensor registers 3 instance of the tmu controller >> with the thermal zone and hence reports 3 temperature output. This controller >> supports upto five trip points. For critical threshold the driver uses the >> core driver thermal framework for shutdown. >> >> Acked-by: Jonghwa Lee >> Acked-by: Kukjin Kim >> Signed-off-by: Jungseok Lee >> Signed-off-by: Amit Daniel Kachhap >> --- >> .../devicetree/bindings/thermal/exynos-thermal.txt | 24 - >> drivers/thermal/samsung/exynos_thermal_common.h|2 +- >> drivers/thermal/samsung/exynos_tmu.c | 54 >> +--- >> drivers/thermal/samsung/exynos_tmu.h |6 ++ >> drivers/thermal/samsung/exynos_tmu_data.h | 36 + >> 5 files changed, 112 insertions(+), 10 deletions(-) >> >> diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> index 0ea33f7..e6386ea 100644 >> --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt >> @@ -6,6 +6,7 @@ >> "samsung,exynos4412-tmu" >> "samsung,exynos4210-tmu" >> "samsung,exynos5250-tmu" >> +"samsung,exynos5440-tmu" >> - interrupt-parent : The phandle for the interrupt controller >> - reg : Address range of the thermal registers. For soc's which has multiple >> instances of TMU and some registers are shared across all TMU's like >> @@ -16,7 +17,7 @@ >> - clocks : The main clock for TMU device >> - clock-names : Thermal system clock name >> >> -Example: >> +Example 1): >> >> tmu@100C { >> compatible = "samsung,exynos4412-tmu"; >> @@ -27,3 +28,24 @@ Example: >> clock-names = "tmu_apbif"; >> status = "disabled"; >> }; >> + >> +Example 2): >> + >> + tmuctrl_0: tmuctrl@160118 { >> + compatible = "samsung,exynos5440-tmu"; >> + reg = <0x160118 0x230>, <0x160368 0x10>; >> + interrupts = <0 58 0>; >> + clocks = <&clock 21>; >> + clock-names = "tmu_apbif"; >> + }; >> + >> +Note: For multi-instance tmu each instance should have an alias correctly >> +numbered in "aliases" node. >> + >> +Example: >> + >> +aliases { >> + tmuctrl0 = &tmuctrl_0; >> + tmuctrl1 = &tmuctrl_1; >> + tmuctrl2 = &tmuctrl_2; >> +}; >> diff --git a/drivers/thermal/samsung/exynos_thermal_common.h >> b/drivers/thermal/samsung/exynos_thermal_common.h >> index 0c189d6..7d7c29a 100644 >> --- a/drivers/thermal/samsung/exynos_thermal_common.h >> +++ b/drivers/thermal/samsung/exynos_thermal_common.h >> @@ -27,7 +27,7 @@ >> #define SENSOR_NAME_LEN 16 >> #define MAX_TRIP_COUNT 8 >> #define MAX_COOLING_DEVICE 4 >> -#define MAX_THRESHOLD_LEVS 4 >> +#define MAX_THRESHOLD_LEVS 5 >> >> #define ACTIVE_INTERVAL 500 >> #define IDLE_INTERVAL 1 >> diff --git a/drivers/thermal/samsung/exynos_tmu.c >> b/drivers/thermal/samsung/exynos_tmu.c >> index 150a869..db4035d 100644 >> --- a/drivers/thermal/samsung/exynos_tmu.c >> +++ b/drivers/thermal/samsung/exynos_tmu.c >> @@ -156,7 +156,26 @@ static int exynos_tmu_initialize(struct platform_device >> *pdev) >> __raw_writel(1, data->base + reg->triminfo_ctrl); >> >> /* Save trimming info in order to perform calibration */ >> - trim_info = readl(data->base + reg->triminfo_data); >> + if (data->soc == SOC_ARCH_EXYNOS5440) { > > should this become some bit at your pdata->features? TMU_SUPPORTS(pdata, > TRIMINFO) for instance? Initially I also thought of getting rid of SOC checks completely but they have been retained in some rare cases. Here this a limitation in the h/w and very specific to exynos5440. So not sure if this can be added as a feature. > >> + /* >> + * For exynos5440 soc triminfo value is swapped between TMU0 >> and >> + * TMU2, so the below logic is needed. >> + */ >> + switch (data->id) { >> + case 0: >> + trim_info = readl(data->base + >> + EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data); >> + break; >> + case 1: >> + trim_info = readl(data->base + reg->triminfo_data); >> + break; >> + case 2: >> + trim_info = readl(data->base - >> + EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data); >> + } >> + } else { >> + trim_info = readl(data->base + reg->triminfo_data); >> + } >> data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK; >> data->temp_erro
Re: [PATCH V6 23/30] thermal: exynos: Add driver support for exynos5440 TMU sensor
On 17-06-2013 02:46, Amit Daniel Kachhap wrote: > This patch modifies TMU controller to add changes needed to work with > exynos5440 platform. This sensor registers 3 instance of the tmu controller > with the thermal zone and hence reports 3 temperature output. This controller > supports upto five trip points. For critical threshold the driver uses the > core driver thermal framework for shutdown. > > Acked-by: Jonghwa Lee > Acked-by: Kukjin Kim > Signed-off-by: Jungseok Lee > Signed-off-by: Amit Daniel Kachhap > --- > .../devicetree/bindings/thermal/exynos-thermal.txt | 24 - > drivers/thermal/samsung/exynos_thermal_common.h|2 +- > drivers/thermal/samsung/exynos_tmu.c | 54 > +--- > drivers/thermal/samsung/exynos_tmu.h |6 ++ > drivers/thermal/samsung/exynos_tmu_data.h | 36 + > 5 files changed, 112 insertions(+), 10 deletions(-) > > diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > index 0ea33f7..e6386ea 100644 > --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt > @@ -6,6 +6,7 @@ > "samsung,exynos4412-tmu" > "samsung,exynos4210-tmu" > "samsung,exynos5250-tmu" > +"samsung,exynos5440-tmu" > - interrupt-parent : The phandle for the interrupt controller > - reg : Address range of the thermal registers. For soc's which has multiple > instances of TMU and some registers are shared across all TMU's like > @@ -16,7 +17,7 @@ > - clocks : The main clock for TMU device > - clock-names : Thermal system clock name > > -Example: > +Example 1): > > tmu@100C { > compatible = "samsung,exynos4412-tmu"; > @@ -27,3 +28,24 @@ Example: > clock-names = "tmu_apbif"; > status = "disabled"; > }; > + > +Example 2): > + > + tmuctrl_0: tmuctrl@160118 { > + compatible = "samsung,exynos5440-tmu"; > + reg = <0x160118 0x230>, <0x160368 0x10>; > + interrupts = <0 58 0>; > + clocks = <&clock 21>; > + clock-names = "tmu_apbif"; > + }; > + > +Note: For multi-instance tmu each instance should have an alias correctly > +numbered in "aliases" node. > + > +Example: > + > +aliases { > + tmuctrl0 = &tmuctrl_0; > + tmuctrl1 = &tmuctrl_1; > + tmuctrl2 = &tmuctrl_2; > +}; > diff --git a/drivers/thermal/samsung/exynos_thermal_common.h > b/drivers/thermal/samsung/exynos_thermal_common.h > index 0c189d6..7d7c29a 100644 > --- a/drivers/thermal/samsung/exynos_thermal_common.h > +++ b/drivers/thermal/samsung/exynos_thermal_common.h > @@ -27,7 +27,7 @@ > #define SENSOR_NAME_LEN 16 > #define MAX_TRIP_COUNT 8 > #define MAX_COOLING_DEVICE 4 > -#define MAX_THRESHOLD_LEVS 4 > +#define MAX_THRESHOLD_LEVS 5 > > #define ACTIVE_INTERVAL 500 > #define IDLE_INTERVAL 1 > diff --git a/drivers/thermal/samsung/exynos_tmu.c > b/drivers/thermal/samsung/exynos_tmu.c > index 150a869..db4035d 100644 > --- a/drivers/thermal/samsung/exynos_tmu.c > +++ b/drivers/thermal/samsung/exynos_tmu.c > @@ -156,7 +156,26 @@ static int exynos_tmu_initialize(struct platform_device > *pdev) > __raw_writel(1, data->base + reg->triminfo_ctrl); > > /* Save trimming info in order to perform calibration */ > - trim_info = readl(data->base + reg->triminfo_data); > + if (data->soc == SOC_ARCH_EXYNOS5440) { should this become some bit at your pdata->features? TMU_SUPPORTS(pdata, TRIMINFO) for instance? > + /* > + * For exynos5440 soc triminfo value is swapped between TMU0 and > + * TMU2, so the below logic is needed. > + */ > + switch (data->id) { > + case 0: > + trim_info = readl(data->base + > + EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data); > + break; > + case 1: > + trim_info = readl(data->base + reg->triminfo_data); > + break; > + case 2: > + trim_info = readl(data->base - > + EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data); > + } > + } else { > + trim_info = readl(data->base + reg->triminfo_data); > + } > data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK; > data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) & > EXYNOS_TMU_TEMP_MASK); > @@ -201,7 +220,8 @@ static int exynos_tmu_initialize(struct platform_device > *pdev) > reg->threshold_th0 + i * sizeof(reg->threshold_th0)); > > writel(reg->inten_rise_mask, data->base + reg->tmu_intclear); > - } else if (data->soc == SOC_ARCH_EXYNOS) { > + } else
[PATCH V6 23/30] thermal: exynos: Add driver support for exynos5440 TMU sensor
This patch modifies TMU controller to add changes needed to work with exynos5440 platform. This sensor registers 3 instance of the tmu controller with the thermal zone and hence reports 3 temperature output. This controller supports upto five trip points. For critical threshold the driver uses the core driver thermal framework for shutdown. Acked-by: Jonghwa Lee Acked-by: Kukjin Kim Signed-off-by: Jungseok Lee Signed-off-by: Amit Daniel Kachhap --- .../devicetree/bindings/thermal/exynos-thermal.txt | 24 - drivers/thermal/samsung/exynos_thermal_common.h|2 +- drivers/thermal/samsung/exynos_tmu.c | 54 +--- drivers/thermal/samsung/exynos_tmu.h |6 ++ drivers/thermal/samsung/exynos_tmu_data.h | 36 + 5 files changed, 112 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt index 0ea33f7..e6386ea 100644 --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt @@ -6,6 +6,7 @@ "samsung,exynos4412-tmu" "samsung,exynos4210-tmu" "samsung,exynos5250-tmu" + "samsung,exynos5440-tmu" - interrupt-parent : The phandle for the interrupt controller - reg : Address range of the thermal registers. For soc's which has multiple instances of TMU and some registers are shared across all TMU's like @@ -16,7 +17,7 @@ - clocks : The main clock for TMU device - clock-names : Thermal system clock name -Example: +Example 1): tmu@100C { compatible = "samsung,exynos4412-tmu"; @@ -27,3 +28,24 @@ Example: clock-names = "tmu_apbif"; status = "disabled"; }; + +Example 2): + + tmuctrl_0: tmuctrl@160118 { + compatible = "samsung,exynos5440-tmu"; + reg = <0x160118 0x230>, <0x160368 0x10>; + interrupts = <0 58 0>; + clocks = <&clock 21>; + clock-names = "tmu_apbif"; + }; + +Note: For multi-instance tmu each instance should have an alias correctly +numbered in "aliases" node. + +Example: + +aliases { + tmuctrl0 = &tmuctrl_0; + tmuctrl1 = &tmuctrl_1; + tmuctrl2 = &tmuctrl_2; +}; diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h index 0c189d6..7d7c29a 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.h +++ b/drivers/thermal/samsung/exynos_thermal_common.h @@ -27,7 +27,7 @@ #define SENSOR_NAME_LEN16 #define MAX_TRIP_COUNT 8 #define MAX_COOLING_DEVICE 4 -#define MAX_THRESHOLD_LEVS 4 +#define MAX_THRESHOLD_LEVS 5 #define ACTIVE_INTERVAL 500 #define IDLE_INTERVAL 1 diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 150a869..db4035d 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -156,7 +156,26 @@ static int exynos_tmu_initialize(struct platform_device *pdev) __raw_writel(1, data->base + reg->triminfo_ctrl); /* Save trimming info in order to perform calibration */ - trim_info = readl(data->base + reg->triminfo_data); + if (data->soc == SOC_ARCH_EXYNOS5440) { + /* +* For exynos5440 soc triminfo value is swapped between TMU0 and +* TMU2, so the below logic is needed. +*/ + switch (data->id) { + case 0: + trim_info = readl(data->base + + EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data); + break; + case 1: + trim_info = readl(data->base + reg->triminfo_data); + break; + case 2: + trim_info = readl(data->base - + EXYNOS5440_EFUSE_SWAP_OFFSET + reg->triminfo_data); + } + } else { + trim_info = readl(data->base + reg->triminfo_data); + } data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK; data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) & EXYNOS_TMU_TEMP_MASK); @@ -201,7 +220,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev) reg->threshold_th0 + i * sizeof(reg->threshold_th0)); writel(reg->inten_rise_mask, data->base + reg->tmu_intclear); - } else if (data->soc == SOC_ARCH_EXYNOS) { + } else if (data->soc == SOC_ARCH_EXYNOS || + data->soc == SOC_ARCH_EXYNOS5440) { /* Write temperature code for rising and falling threshold */ for (i = 0; i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) { @@ -241,14 +261,