diff options
author | Amit Daniel Kachhap <amit.kachhap@linaro.org> | 2012-08-16 07:41:44 -0400 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2012-09-24 02:44:38 -0400 |
commit | 17be868e04a1b98d72756ce7b51a95d03e7df49b (patch) | |
tree | e335041f7a0aea00841366304e1d4402c0df9f97 | |
parent | 7e0b55e60659972a563e68fbfdccabf78e25afc7 (diff) |
ARM: exynos: add thermal sensor driver platform data support
Add necessary default platform data support needed for TMU driver. The
supplied dt/non-dt values are tested for origen exynos4210 and smdk exynos5250
platforms and only compile tested for exynos4412.
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: SangWook Ju <sw.ju@samsung.com>
Cc: Durgadoss <durgadoss.r@intel.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: jonghwa lee <jonghwa3.lee@samsung.com>
Cc: Kyungmin Park <kmpark@infradead.org>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r-- | drivers/thermal/exynos_thermal.c | 111 |
1 files changed, 110 insertions, 1 deletions
diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index e79cdc9935b7..03a99e444dbd 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c | |||
@@ -723,14 +723,121 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id) | |||
723 | static struct thermal_sensor_conf exynos_sensor_conf = { | 723 | static struct thermal_sensor_conf exynos_sensor_conf = { |
724 | .name = "exynos-therm", | 724 | .name = "exynos-therm", |
725 | .read_temperature = (int (*)(void *))exynos_tmu_read, | 725 | .read_temperature = (int (*)(void *))exynos_tmu_read, |
726 | }; | ||
727 | |||
728 | #if defined(CONFIG_CPU_EXYNOS4210) | ||
729 | static struct exynos_tmu_platform_data const exynos4210_default_tmu_data = { | ||
730 | .threshold = 80, | ||
731 | .trigger_levels[0] = 5, | ||
732 | .trigger_levels[1] = 20, | ||
733 | .trigger_levels[2] = 30, | ||
734 | .trigger_level0_en = 1, | ||
735 | .trigger_level1_en = 1, | ||
736 | .trigger_level2_en = 1, | ||
737 | .trigger_level3_en = 0, | ||
738 | .gain = 15, | ||
739 | .reference_voltage = 7, | ||
740 | .cal_type = TYPE_ONE_POINT_TRIMMING, | ||
741 | .freq_tab[0] = { | ||
742 | .freq_clip_max = 800 * 1000, | ||
743 | .temp_level = 85, | ||
744 | }, | ||
745 | .freq_tab[1] = { | ||
746 | .freq_clip_max = 200 * 1000, | ||
747 | .temp_level = 100, | ||
748 | }, | ||
749 | .freq_tab_count = 2, | ||
750 | .type = SOC_ARCH_EXYNOS4210, | ||
751 | }; | ||
752 | #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data) | ||
753 | #else | ||
754 | #define EXYNOS4210_TMU_DRV_DATA (NULL) | ||
755 | #endif | ||
756 | |||
757 | #if defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412) | ||
758 | static struct exynos_tmu_platform_data const exynos_default_tmu_data = { | ||
759 | .trigger_levels[0] = 85, | ||
760 | .trigger_levels[1] = 103, | ||
761 | .trigger_levels[2] = 110, | ||
762 | .trigger_level0_en = 1, | ||
763 | .trigger_level1_en = 1, | ||
764 | .trigger_level2_en = 1, | ||
765 | .trigger_level3_en = 0, | ||
766 | .gain = 8, | ||
767 | .reference_voltage = 16, | ||
768 | .noise_cancel_mode = 4, | ||
769 | .cal_type = TYPE_ONE_POINT_TRIMMING, | ||
770 | .efuse_value = 55, | ||
771 | .freq_tab[0] = { | ||
772 | .freq_clip_max = 800 * 1000, | ||
773 | .temp_level = 85, | ||
774 | }, | ||
775 | .freq_tab[1] = { | ||
776 | .freq_clip_max = 200 * 1000, | ||
777 | .temp_level = 103, | ||
778 | }, | ||
779 | .freq_tab_count = 2, | ||
780 | .type = SOC_ARCH_EXYNOS, | ||
781 | }; | ||
782 | #define EXYNOS_TMU_DRV_DATA (&exynos_default_tmu_data) | ||
783 | #else | ||
784 | #define EXYNOS_TMU_DRV_DATA (NULL) | ||
785 | #endif | ||
786 | |||
787 | #ifdef CONFIG_OF | ||
788 | static const struct of_device_id exynos_tmu_match[] = { | ||
789 | { | ||
790 | .compatible = "samsung,exynos4210-tmu", | ||
791 | .data = (void *)EXYNOS4210_TMU_DRV_DATA, | ||
792 | }, | ||
793 | { | ||
794 | .compatible = "samsung,exynos5250-tmu", | ||
795 | .data = (void *)EXYNOS_TMU_DRV_DATA, | ||
796 | }, | ||
797 | {}, | ||
798 | }; | ||
799 | MODULE_DEVICE_TABLE(of, exynos_tmu_match); | ||
800 | #else | ||
801 | #define exynos_tmu_match NULL | ||
802 | #endif | ||
803 | |||
804 | static struct platform_device_id exynos_tmu_driver_ids[] = { | ||
805 | { | ||
806 | .name = "exynos4210-tmu", | ||
807 | .driver_data = (kernel_ulong_t)EXYNOS4210_TMU_DRV_DATA, | ||
808 | }, | ||
809 | { | ||
810 | .name = "exynos5250-tmu", | ||
811 | .driver_data = (kernel_ulong_t)EXYNOS_TMU_DRV_DATA, | ||
812 | }, | ||
813 | { }, | ||
814 | }; | ||
815 | MODULE_DEVICE_TABLE(platform, exynos4_tmu_driver_ids); | ||
816 | |||
817 | static inline struct exynos_tmu_platform_data *exynos_get_driver_data( | ||
818 | struct platform_device *pdev) | ||
819 | { | ||
820 | #ifdef CONFIG_OF | ||
821 | if (pdev->dev.of_node) { | ||
822 | const struct of_device_id *match; | ||
823 | match = of_match_node(exynos_tmu_match, pdev->dev.of_node); | ||
824 | if (!match) | ||
825 | return NULL; | ||
826 | return (struct exynos_tmu_platform_data *) match->data; | ||
827 | } | ||
828 | #endif | ||
829 | return (struct exynos_tmu_platform_data *) | ||
830 | platform_get_device_id(pdev)->driver_data; | ||
726 | } | 831 | } |
727 | ; | ||
728 | static int __devinit exynos_tmu_probe(struct platform_device *pdev) | 832 | static int __devinit exynos_tmu_probe(struct platform_device *pdev) |
729 | { | 833 | { |
730 | struct exynos_tmu_data *data; | 834 | struct exynos_tmu_data *data; |
731 | struct exynos_tmu_platform_data *pdata = pdev->dev.platform_data; | 835 | struct exynos_tmu_platform_data *pdata = pdev->dev.platform_data; |
732 | int ret, i; | 836 | int ret, i; |
733 | 837 | ||
838 | if (!pdata) | ||
839 | pdata = exynos_get_driver_data(pdev); | ||
840 | |||
734 | if (!pdata) { | 841 | if (!pdata) { |
735 | dev_err(&pdev->dev, "No platform init data supplied.\n"); | 842 | dev_err(&pdev->dev, "No platform init data supplied.\n"); |
736 | return -ENODEV; | 843 | return -ENODEV; |
@@ -899,9 +1006,11 @@ static struct platform_driver exynos_tmu_driver = { | |||
899 | .name = "exynos-tmu", | 1006 | .name = "exynos-tmu", |
900 | .owner = THIS_MODULE, | 1007 | .owner = THIS_MODULE, |
901 | .pm = EXYNOS_TMU_PM, | 1008 | .pm = EXYNOS_TMU_PM, |
1009 | .of_match_table = exynos_tmu_match, | ||
902 | }, | 1010 | }, |
903 | .probe = exynos_tmu_probe, | 1011 | .probe = exynos_tmu_probe, |
904 | .remove = __devexit_p(exynos_tmu_remove), | 1012 | .remove = __devexit_p(exynos_tmu_remove), |
1013 | .id_table = exynos_tmu_driver_ids, | ||
905 | }; | 1014 | }; |
906 | 1015 | ||
907 | module_platform_driver(exynos_tmu_driver); | 1016 | module_platform_driver(exynos_tmu_driver); |