diff options
author | Florian Eckert <Eckert.Florian@googlemail.com> | 2016-08-01 11:10:42 +0200 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2016-08-03 15:30:13 +0200 |
commit | 828e25e32569704cbfe9e98c9fa7c533ffbbcb65 (patch) | |
tree | bccba6a4886e190a5714f18cb19bf1c5593c413d /target | |
parent | 2feb9433e237e8e38c9a52c232e6a1c7deb95333 (diff) | |
download | upstream-828e25e32569704cbfe9e98c9fa7c533ffbbcb65.tar.gz upstream-828e25e32569704cbfe9e98c9fa7c533ffbbcb65.tar.bz2 upstream-828e25e32569704cbfe9e98c9fa7c533ffbbcb65.zip |
lantiq: add cpu temperatur sensor driver for xrx200
Signed-off-by: Florian Eckert <Eckert.Florian@googlemail.com>
Diffstat (limited to 'target')
-rw-r--r-- | target/linux/lantiq/config-4.4 | 1 | ||||
-rw-r--r-- | target/linux/lantiq/patches-4.4/0302-xrx200-add-sensors-driver.patch | 168 | ||||
-rw-r--r-- | target/linux/lantiq/xrx200/config-default | 2 |
3 files changed, 171 insertions, 0 deletions
diff --git a/target/linux/lantiq/config-4.4 b/target/linux/lantiq/config-4.4 index cf3ec47429..073b7c7cf7 100644 --- a/target/linux/lantiq/config-4.4 +++ b/target/linux/lantiq/config-4.4 @@ -178,6 +178,7 @@ CONFIG_RTL8366_SMI=y CONFIG_SCHED_HRTICK=y # CONFIG_SCHED_INFO is not set # CONFIG_SCSI_DMA is not set +# CONFIG_SENSORS_LTQ_CPUTEMP is not set # CONFIG_SERIAL_8250 is not set CONFIG_SERIAL_LANTIQ=y # CONFIG_SOC_AMAZON_SE is not set diff --git a/target/linux/lantiq/patches-4.4/0302-xrx200-add-sensors-driver.patch b/target/linux/lantiq/patches-4.4/0302-xrx200-add-sensors-driver.patch new file mode 100644 index 0000000000..628e476a77 --- /dev/null +++ b/target/linux/lantiq/patches-4.4/0302-xrx200-add-sensors-driver.patch @@ -0,0 +1,168 @@ +--- a/drivers/hwmon/Makefile ++++ b/drivers/hwmon/Makefile +@@ -107,6 +107,7 @@ obj-$(CONFIG_SENSORS_LTC4222) += ltc4222 + obj-$(CONFIG_SENSORS_LTC4245) += ltc4245.o + obj-$(CONFIG_SENSORS_LTC4260) += ltc4260.o + obj-$(CONFIG_SENSORS_LTC4261) += ltc4261.o ++obj-$(CONFIG_SENSORS_LTQ_CPUTEMP) += ltq-cputemp.o + obj-$(CONFIG_SENSORS_MAX1111) += max1111.o + obj-$(CONFIG_SENSORS_MAX16065) += max16065.o + obj-$(CONFIG_SENSORS_MAX1619) += max1619.o +--- a/drivers/hwmon/Kconfig ++++ b/drivers/hwmon/Kconfig +@@ -762,6 +762,14 @@ config SENSORS_LTC4261 + This driver can also be built as a module. If so, the module will + be called ltc4261. + ++config SENSORS_LTQ_CPUTEMP ++ bool "Lantiq CPU temperature sensor" ++ depends on LANTIQ ++ default n ++ help ++ If you say yes here you get support for the temperature ++ sensor inside your CPU. ++ + config SENSORS_MAX1111 + tristate "Maxim MAX1111 Serial 8-bit ADC chip and compatibles" + depends on SPI_MASTER +--- /dev/null ++++ b/drivers/hwmon/ltq-cputemp.c +@@ -0,0 +1,138 @@ ++/* Lantiq CPU Temperatur sensor driver for xrx200 ++ * ++ * Copyright (C) 2016 Florian Eckert <feckert@tdt.de> ++ * ++ * 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, see <http://www.gnu.org/licenses/> ++ */ ++ ++#include <linux/module.h> ++#include <linux/init.h> ++#include <linux/of_device.h> ++#include <linux/hwmon.h> ++#include <linux/hwmon-sysfs.h> ++ ++#include <lantiq_soc.h> ++ ++/* gphy1 configuration register contains cpu temperature */ ++#define CGU_GPHY1_CR 0x0040 ++#define CGU_TEMP_PD BIT(19) ++ ++static void ltq_cputemp_enable(void) ++{ ++ ltq_cgu_w32(ltq_cgu_r32(CGU_GPHY1_CR) | CGU_TEMP_PD, CGU_GPHY1_CR); ++} ++ ++static void ltq_cputemp_disable(void) ++{ ++ ltq_cgu_w32(ltq_cgu_r32(CGU_GPHY1_CR) & ~CGU_TEMP_PD, CGU_GPHY1_CR); ++} ++ ++static int ltq_cputemp_read(void) ++{ ++ /* Shift 9 for register alignment and 1 to divide value by 2 */ ++ return (ltq_cgu_r32(CGU_GPHY1_CR) >> 10) & 0xFF; ++} ++ ++static ssize_t show_cputemp(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ int value; ++ ++ value = ltq_cputemp_read(); ++ /* scale temp to millidegree */ ++ value = value * 1000; ++ ++ return sprintf(buf, "%d\n", value); ++} ++ ++static DEVICE_ATTR(temp1_input, S_IRUGO, show_cputemp, NULL); ++ ++static struct attribute *ltq_cputemp_attrs[] = { ++ &dev_attr_temp1_input.attr, ++ NULL ++}; ++ ++ATTRIBUTE_GROUPS(ltq_cputemp); ++ ++static int ltq_cputemp_probe(struct platform_device *pdev) ++{ ++ int value = 0; ++ int ret; ++ struct device *hwmon_dev; ++ ++ hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev, ++ "CPU0", ++ NULL, ++ ltq_cputemp_groups); ++ ++ if (IS_ERR(hwmon_dev)) { ++ dev_err(&pdev->dev, "Failed to register as hwmon device"); ++ ret = PTR_ERR(hwmon_dev); ++ goto error_hwmon; ++ } ++ ++ ltq_cputemp_enable(); ++ value = ltq_cputemp_read(); ++ dev_info(&pdev->dev, "Current CPU die temperature: %d °C", value); ++ ++ return 0; ++ ++error_hwmon: ++ return ret; ++} ++ ++static int ltq_cputemp_release(struct platform_device *pdev) ++{ ++ hwmon_device_unregister(&pdev->dev); ++ ltq_cputemp_disable(); ++ return 0; ++} ++ ++const struct of_device_id ltq_cputemp_match[] = { ++ { .compatible = "lantiq,cputemp" }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, ltq_cputemp_match); ++ ++static struct platform_driver ltq_cputemp_driver = { ++ .probe = ltq_cputemp_probe, ++ .remove = ltq_cputemp_release, ++ .driver = { ++ .name = "ltq-cputemp", ++ .owner = THIS_MODULE, ++ .of_match_table = ltq_cputemp_match, ++ }, ++}; ++ ++int __init init_ltq_cputemp(void) ++{ ++ int ret; ++ ++ ret = platform_driver_register(<q_cputemp_driver); ++ return ret; ++} ++ ++void clean_ltq_cputemp(void) ++{ ++ platform_driver_unregister(<q_cputemp_driver); ++ return; ++} ++ ++module_init(init_ltq_cputemp); ++module_exit(clean_ltq_cputemp); ++ ++MODULE_AUTHOR("Florian Eckert <feckert@tdt.de>"); ++ ++MODULE_DESCRIPTION("Lantiq Temperature Sensor"); ++MODULE_LICENSE("GPL"); diff --git a/target/linux/lantiq/xrx200/config-default b/target/linux/lantiq/xrx200/config-default index bae4f629e2..955461c883 100644 --- a/target/linux/lantiq/xrx200/config-default +++ b/target/linux/lantiq/xrx200/config-default @@ -5,6 +5,7 @@ CONFIG_CRC16=y CONFIG_CRYPTO_DEFLATE=y CONFIG_CRYPTO_LZO=y CONFIG_FIRMWARE_IN_KERNEL=y +CONFIG_HWMON=y CONFIG_ICPLUS_PHY=y CONFIG_INPUT=y CONFIG_INPUT_EVDEV=y @@ -35,6 +36,7 @@ CONFIG_RTL8306_PHY=y CONFIG_RTL8366S_PHY=y CONFIG_RTL8367B_PHY=y CONFIG_RTL8367_PHY=y +CONFIG_SENSORS_LTQ_CPUTEMP=y CONFIG_SWCONFIG_LEDS=y CONFIG_UBIFS_FS=y CONFIG_UBIFS_FS_ADVANCED_COMPR=y |