From 006d28e963f0ad4e5d1bcb1e1c4238902fe80f74 Mon Sep 17 00:00:00 2001 From: Anson Huang Date: Fri, 1 Jul 2011 10:58:18 +0800 Subject: [PATCH] ENGR00152291-1 [MX6]Add anatop thermal driver Currently only support temperature reading, and since the chip need calibration, and they will write the calibration parameter into fuse later, we need to wait for it and improve this thermal sensor's accuracy. Also, cooling device will be added later. Signed-off-by: Anson Huang --- arch/arm/mach-mx6/Kconfig | 2 + arch/arm/mach-mx6/board-mx6q_sabreauto.c | 5 +- arch/arm/mach-mx6/devices-imx6q.h | 5 +- arch/arm/plat-mxc/devices/Kconfig | 3 ++ arch/arm/plat-mxc/devices/Makefile | 1 + .../devices/platform-imx-anatop-thermal.c | 47 +++++++++++++++++++ .../plat-mxc/include/mach/anatop_thermal.h | 29 ++++++++++++ .../plat-mxc/include/mach/devices-common.h | 10 ++++ 8 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 arch/arm/plat-mxc/devices/platform-imx-anatop-thermal.c create mode 100644 arch/arm/plat-mxc/include/mach/anatop_thermal.h diff --git a/arch/arm/mach-mx6/Kconfig b/arch/arm/mach-mx6/Kconfig index de2743e25b01..389a9c01cc49 100644 --- a/arch/arm/mach-mx6/Kconfig +++ b/arch/arm/mach-mx6/Kconfig @@ -8,6 +8,7 @@ config ARCH_MX6Q select ARM_GIC select IMX_HAVE_PLATFORM_IMX_UART select IMX_HAVE_PLATFORM_FEC + select IMX_HAVE_PLATFORM_IMX_ANATOP_THERMAL config FORCE_MAX_ZONEORDER int "MAX_ORDER" @@ -26,6 +27,7 @@ config MACH_MX6Q_SABREAUTO select IMX_HAVE_PLATFORM_SPI_IMX select IMX_HAVE_PLATFORM_IMX_I2C select IMX_HAVE_PLATFORM_VIV_GPU + select IMX_HAVE_PLATFORM_IMX_ANATOP_THERMAL help Include support for i.MX 6Quad SABRE Automotive Infotainment platform. This includes specific configurations for the board and its peripherals. diff --git a/arch/arm/mach-mx6/board-mx6q_sabreauto.c b/arch/arm/mach-mx6/board-mx6q_sabreauto.c index 6851a1f47b2c..fd337471656f 100644 --- a/arch/arm/mach-mx6/board-mx6q_sabreauto.c +++ b/arch/arm/mach-mx6/board-mx6q_sabreauto.c @@ -140,7 +140,6 @@ static iomux_v3_cfg_t mx6q_sabreauto_pads[] = { MX6Q_PAD_GPIO_5__I2C3_SCL, MX6Q_PAD_GPIO_16__I2C3_SDA, }; - static const struct esdhc_platform_data mx6q_sabreauto_sd3_data __initconst = { .cd_gpio = MX6Q_SABREAUTO_SD3_CD, .wp_gpio = MX6Q_SABREAUTO_SD3_WP, @@ -151,6 +150,9 @@ static const struct esdhc_platform_data mx6q_sabreauto_sd4_data __initconst = { .always_present = 1, }; +static const struct anatop_thermal_platform_data mx6q_sabreauto_anatop_thermal_data __initconst = { + .name = "anatop_thermal", +}; static inline void mx6q_sabreauto_init_uart(void) { @@ -232,6 +234,7 @@ static void __init mx6_board_init(void) i2c_register_board_info(2, mxc_i2c2_board_info, ARRAY_SIZE(mxc_i2c2_board_info)); + imx6q_add_anatop_thermal_imx(1, &mx6q_sabreauto_anatop_thermal_data); imx6q_add_sdhci_usdhc_imx(3, &mx6q_sabreauto_sd4_data); imx_add_viv_gpu("gc2000", &imx6_gc2000_data, &imx6q_gc2000_pdata); } diff --git a/arch/arm/mach-mx6/devices-imx6q.h b/arch/arm/mach-mx6/devices-imx6q.h index 65a2e444ebd5..e46f6566ff3b 100644 --- a/arch/arm/mach-mx6/devices-imx6q.h +++ b/arch/arm/mach-mx6/devices-imx6q.h @@ -23,7 +23,10 @@ extern const struct imx_imx_uart_1irq_data imx6q_imx_uart_data[] __initconst; #define imx6q_add_imx_uart(id, pdata) \ imx_add_imx_uart_1irq(&imx6q_imx_uart_data[id], pdata) -extern struct platform_device anatop_thermal_device; +extern const struct imx_anatop_thermal_imx_data +imx6q_anatop_thermal_imx_data __initconst; +#define imx6q_add_anatop_thermal_imx(id, pdata) \ + imx_add_anatop_thermal_imx(&imx6q_anatop_thermal_imx_data, pdata) extern const struct imx_fec_data imx6q_fec_data __initconst; #define imx6q_add_fec(pdata) \ diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig index 8bfc234ab7ff..cbd21149f636 100755 --- a/arch/arm/plat-mxc/devices/Kconfig +++ b/arch/arm/plat-mxc/devices/Kconfig @@ -133,3 +133,6 @@ config IMX_HAVE_PLATFORM_IMX_SPDIF config IMX_HAVE_PLATFORM_VIV_GPU bool + +config IMX_HAVE_PLATFORM_IMX_ANATOP_THERMAL + bool diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile index b4c68e44051e..da3657d13a5e 100755 --- a/arch/arm/plat-mxc/devices/Makefile +++ b/arch/arm/plat-mxc/devices/Makefile @@ -46,3 +46,4 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SPDIF) += platform-imx-spdif.o obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SPDIF) += platform-imx-spdif-dai.o obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SPDIF) += platform-imx-spdif-audio.o obj-$(CONFIG_IMX_HAVE_PLATFORM_VIV_GPU) += platform-viv_gpu.o +obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_ANATOP_THERMAL) += platform-imx-anatop-thermal.o diff --git a/arch/arm/plat-mxc/devices/platform-imx-anatop-thermal.c b/arch/arm/plat-mxc/devices/platform-imx-anatop-thermal.c new file mode 100644 index 000000000000..b96bc6fa7846 --- /dev/null +++ b/arch/arm/plat-mxc/devices/platform-imx-anatop-thermal.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. + */ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#include +#include + +#define imx_anatop_thermal_imx_data_entry_single(soc) \ + { \ + .iobase = ANATOP_BASE_ADDR, \ + } + +#ifdef CONFIG_SOC_IMX6Q +const struct imx_anatop_thermal_imx_data imx6q_anatop_thermal_imx_data __initconst = + imx_anatop_thermal_imx_data_entry_single(MX6Q); +#endif /* ifdef CONFIG_SOC_IMX6Q */ + +struct platform_device *__init imx_add_anatop_thermal_imx( + const struct imx_anatop_thermal_imx_data *data, + const struct anatop_thermal_platform_data *pdata) +{ + struct resource res[] = { + { + .start = data->iobase, + .end = data->iobase + SZ_4K - 1, + .flags = IORESOURCE_MEM, + }, + }; + + return imx_add_platform_device("anatop_thermal", 0, + res, ARRAY_SIZE(res), NULL, 0); +} diff --git a/arch/arm/plat-mxc/include/mach/anatop_thermal.h b/arch/arm/plat-mxc/include/mach/anatop_thermal.h new file mode 100644 index 000000000000..7549bc5941b0 --- /dev/null +++ b/arch/arm/plat-mxc/include/mach/anatop_thermal.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef __ASM_ARCH_IMX_ANATOP_THERMAL_H +#define __ASM_ARCH_IMX_ANATOP_THERMAL_H + +/** + * struct anatop_thermal_platform_data - optional platform data for thermal on i.MX + * + */ + +struct anatop_thermal_platform_data { + char *name; +}; +#endif /* __ASM_ARCH_IMX_ANATOP_THERMAL_H */ diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h index 2ee4e6cd33a8..a94367163449 100755 --- a/arch/arm/plat-mxc/include/mach/devices-common.h +++ b/arch/arm/plat-mxc/include/mach/devices-common.h @@ -457,6 +457,16 @@ struct platform_device *__init imx_add_viv_gpu( const char *name, const struct imx_viv_gpu_data *data, const struct viv_gpu_platform_data *pdata); + +#include +struct imx_anatop_thermal_imx_data { + int id; + resource_size_t iobase; + resource_size_t irq; +}; +struct platform_device *__init imx_add_anatop_thermal_imx( + const struct imx_anatop_thermal_imx_data *data, + const struct anatop_thermal_platform_data *pdata); struct platform_device *__init imx_add_perfmon( const struct imx_perfmon_data *data); const struct mxc_gpu_platform_data *pdata); -- 2.39.2