From patchwork Sun Jun 23 16:41:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E9D917D2 for ; Sun, 23 Jun 2019 16:42:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A67128A8C for ; Sun, 23 Jun 2019 16:42:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DBAB28AD1; Sun, 23 Jun 2019 16:42:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B2AE228A8C for ; Sun, 23 Jun 2019 16:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rIY4xJgqJL8lj0pO1UNqtUo1dyMmNIjigHEyzP7811w=; b=fGilZgCIJNwKa88gWy3oc1/2+s 71/2sGQRo6KB4K07iilf6XF9PduR3m7rxabcWPAHP+636YStHoBFldBX2b+uxGBljIX/GxGPcsMqh 7fTf1D3im6or1Eq60qSqOdk6VN099mhR/p2FXaFE10yPsJGRebu8sxeEYtXiJ1GoLUhT+yI1UZzMr Bqh1xyQcGL2ILBNALeKMwFEMESZv3B0ly8cjEl8VoTAFkz9RY1yzyQ7uepLyCLxFDC99bk5FAprgm sVbVjLbby/XbThCzZK6xkaMsKSwtq+nBjIoBdpLZvW6HlFXZuLxquC7ztcxM1QAx1Q/3If6RKEgqH y/QrgL2w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5Zd-0002oI-Hy; Sun, 23 Jun 2019 16:42:37 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5ZG-0002UT-PA for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:16 +0000 Received: by mail-pg1-x543.google.com with SMTP id w10so5771651pgj.7 for ; Sun, 23 Jun 2019 09:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zPNVR7pGpaDNHjObNtKjy5ol22Mjb0O+wvgCUguxj4M=; b=FatigfnLmHqFsL7YC0OQ1HJ09wRzljDgz0ZqDWEAnXr0a3vmMXZp7k7MgxED2pGUQv bbeclohb1iPALVvJbPWB7W2dfGv3UQyp6KtYw3dTWRohnkUZklF137GbAvVzVMG78Q4c FDts9QzbCnnkdIbP6s9SqkQ/cTBk0Exrbq07QYXHEOvEMzMJRyGefHl4+ktWvJufJA7a yZgKStRtgohOl66zrWb5/+Pou4hqqTZvi47/rxkYWaPCoWaAEhIJGZpZnBUZC6EKYNTO QqvHl3wRfNUcvsP4TYNxFpNOAWAjkhlYvqbr2MNg7Y03URYku9PA3Z3mkQj4TcRmJcQp t1cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zPNVR7pGpaDNHjObNtKjy5ol22Mjb0O+wvgCUguxj4M=; b=DUKdGQDH4teIW1uyyACjzoTG5Z3W8eMPP3FQlKRmllMv9d8ZC44juhmctBzTKRD7tl 4egWG8zkdwQkiU5xRIopxBfkvtipg5XtUXK/0efsLPT8F66Qv+XXN1HnbRSwv4UOzynd K8K9RUlKbfIRXyNvBpLsC3JZ8OWIUzPMOYrJr86meN9vJAO+lzJ1OKRL98Gem9H1prlC +hVZCtu5k9WSt8+ftrdno323G5kmbXFDzUZYibFoCQeca/gEvKpe75gG6R/1xcLM/dtu LwgbygwQ4gAvetRgBNIrslSwZ1+mmJmGvgyeejwHoVvZDuRfHVMi10cwYQvIOZYiXWMt dDwg== X-Gm-Message-State: APjAAAW1DxE6ibIuBDcp5eNFFpKADp0ACUYzNek++yV/5JBVSOL4veJ7 5mzL4MV8TwYI4a6DMB1BNEA= X-Google-Smtp-Source: APXvYqzgXXB5mStrhkzan4KG83X85VVzIkYWjQhk0oUFo284KlLsFL8+4uVLRmeHxQx2CDuv77AJHg== X-Received: by 2002:a17:90a:7f02:: with SMTP id k2mr19641473pjl.78.1561308133116; Sun, 23 Jun 2019 09:42:13 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id y185sm8560343pfy.110.2019.06.23.09.42.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:12 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 01/11] thermal: sun8i: add thermal driver for h6 Date: Sun, 23 Jun 2019 12:41:56 -0400 Message-Id: <20190623164206.7467-2-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094214_819755_2FC4E707 X-CRM114-Status: GOOD ( 28.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the support for allwinner thermal sensor, within allwinner SoC. It will register sensors for thermal framework and use device tree to bind cooling device. Signed-off-by: Yangtao Li --- MAINTAINERS | 7 + drivers/thermal/Kconfig | 14 ++ drivers/thermal/Makefile | 1 + drivers/thermal/sun8i_thermal.c | 405 ++++++++++++++++++++++++++++++++ 4 files changed, 427 insertions(+) create mode 100644 drivers/thermal/sun8i_thermal.c diff --git a/MAINTAINERS b/MAINTAINERS index 36a84614d6c3..67e7fcfaded2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -674,6 +674,13 @@ L: linux-crypto@vger.kernel.org S: Maintained F: drivers/crypto/sunxi-ss/ +ALLWINNER THERMAL DRIVER +M: Yangtao Li +L: linux-pm@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/thermal/sun8i-thermal.yaml +F: drivers/thermal/sun8i_thermal.c + ALLWINNER VPU DRIVER M: Maxime Ripard M: Paul Kocialkowski diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 9966364a6deb..f8b73b32b92d 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -262,6 +262,20 @@ config SPEAR_THERMAL Enable this to plug the SPEAr thermal sensor driver into the Linux thermal framework. +config SUN8I_THERMAL + tristate "Allwinner sun8i thermal driver" + depends on ARCH_SUNXI || COMPILE_TEST + depends on HAS_IOMEM + depends on NVMEM + depends on OF + depends on RESET_CONTROLLER + help + Support for the sun8i thermal sensor driver into the Linux thermal + framework. + + To compile this driver as a module, choose M here: the + module will be called sun8i-thermal. + config ROCKCHIP_THERMAL tristate "Rockchip thermal driver" depends on ARCH_ROCKCHIP || COMPILE_TEST diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index 74a37c7f847a..fa6f8b206281 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -31,6 +31,7 @@ thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o obj-y += broadcom/ obj-$(CONFIG_THERMAL_MMIO) += thermal_mmio.o obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o +obj-$(CONFIG_SUN8I_THERMAL) += sun8i_thermal.o obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o obj-$(CONFIG_RCAR_GEN3_THERMAL) += rcar_gen3_thermal.o diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c new file mode 100644 index 000000000000..d6918c62682b --- /dev/null +++ b/drivers/thermal/sun8i_thermal.c @@ -0,0 +1,405 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Thermal sensor driver for Allwinner SOC + * Copyright (C) 2019 Yangtao Li + * + * Based on the work of Icenowy Zheng + * Based on the work of Ondrej Jirman + * Based on the work of Josef Gajdusek + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_SENSOR_NUM 4 + +#define SUN50I_H6_SENSOR_NUM 2 +#define SUN50I_H6_OFFSET -2794 +#define SUN50I_H6_SCALE -67 + +#define FT_TEMP_MASK GENMASK(11, 0) +#define TEMP_CALIB_MASK GENMASK(11, 0) +#define TEMP_TO_REG 672 +#define CALIBRATE_DEFAULT 0x800 + +#define SUN50I_THS_CTRL0 0x00 +#define SUN50I_H6_THS_ENABLE 0x04 +#define SUN50I_H6_THS_PC 0x08 +#define SUN50I_H6_THS_DIC 0x10 +#define SUN50I_H6_THS_DIS 0x20 +#define SUN50I_H6_THS_MFC 0x30 +#define SUN50I_H6_THS_TEMP_CALIB 0xa0 +#define SUN50I_H6_THS_TEMP_DATA 0xc0 + +#define SUN50I_THS_CTRL0_T_ACQ(x) ((GENMASK(15, 0) & (x)) << 16) +#define SUN50I_THS_FILTER_EN BIT(2) +#define SUN50I_THS_FILTER_TYPE(x) (GENMASK(1, 0) & (x)) +#define SUN50I_H6_THS_PC_TEMP_PERIOD(x) ((GENMASK(19, 0) & (x)) << 12) +#define SUN50I_H6_THS_DATA_IRQ_STS(x) BIT(x) + +/* millidegree celsius */ +#define SUN50I_H6_FT_DEVIATION 7000 + +struct ths_device; + +struct tsensor { + struct ths_device *tmdev; + struct thermal_zone_device *tzd; + int id; +}; + +struct ths_device { + struct device *dev; + struct regmap *regmap; + struct reset_control *reset; + struct clk *bus_clk; + struct tsensor sensor[MAX_SENSOR_NUM]; +}; + +/* Temp Unit: millidegree Celsius */ +static int sun8i_ths_reg2temp(struct ths_device *tmdev, + int reg) +{ + return (reg + SUN50I_H6_OFFSET) * SUN50I_H6_SCALE; +} + +static int sun8i_ths_get_temp(void *data, int *temp) +{ + struct tsensor *s = data; + struct ths_device *tmdev = s->tmdev; + int val; + + regmap_read(tmdev->regmap, SUN50I_H6_THS_TEMP_DATA + + 0x4 * s->id, &val); + + /* ths have no data yet */ + if (!val) + return -EBUSY; + + *temp = sun8i_ths_reg2temp(tmdev, val); + /* + * XX - According to the original sdk, there are some platforms(rarely) + * that add a fixed offset value after calculating the temperature + * value. We can't simply put it on the formula for calculating the + * temperature above, because the formula for calculating the + * temperature above is also used when the sensor is calibrated. If + * do this, the correct calibration formula is hard to know. + */ + *temp += SUN50I_H6_FT_DEVIATION; + + return 0; +} + +static const struct thermal_zone_of_device_ops ths_ops = { + .get_temp = sun8i_ths_get_temp, +}; + +static const struct regmap_config config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + .fast_io = true, +}; + +static irqreturn_t sun50i_h6_irq_thread(int irq, void *data) +{ + struct ths_device *tmdev = data; + int i, state; + + regmap_read(tmdev->regmap, SUN50I_H6_THS_DIS, &state); + + for (i = 0; i < SUN50I_H6_SENSOR_NUM; i++) { + + if (state & SUN50I_H6_THS_DATA_IRQ_STS(i)) { + /* clear data irq pending */ + regmap_write(tmdev->regmap, SUN50I_H6_THS_DIS, + SUN50I_H6_THS_DATA_IRQ_STS(i)); + + thermal_zone_device_update(tmdev->sensor[i].tzd, + THERMAL_EVENT_UNSPECIFIED); + } + } + + return IRQ_HANDLED; +} + +static int sun50i_ths_calibrate(struct ths_device *tmdev) +{ + struct nvmem_cell *calcell; + struct device *dev = tmdev->dev; + u16 *caldata; + size_t callen; + int ft_temp; + int i, ret = 0; + + calcell = devm_nvmem_cell_get(dev, "calib"); + if (IS_ERR(calcell)) { + if (PTR_ERR(calcell) == -EPROBE_DEFER) + return -EPROBE_DEFER; + /* + * Even if the external calibration data stored in sid is + * not accessible, the THS hardware can still work, although + * the data won't be so accurate. + * + * The default value of calibration register is 0x800 for + * every sensor, and the calibration value is usually 0x7xx + * or 0x8xx, so they won't be away from the default value + * for a lot. + * + * So here we do not return error if the calibartion data is + * not available, except the probe needs deferring. + */ + goto out; + } + + caldata = nvmem_cell_read(calcell, &callen); + if (IS_ERR(caldata)) { + ret = PTR_ERR(caldata); + goto out; + } + + if (!caldata[0] || callen < 2 + 2 * SUN50I_H6_SENSOR_NUM) { + ret = -EINVAL; + goto out_free; + } + + /* + * efuse layout: + * + * 0 11 16 32 + * +-------+-------+-------+ + * |temp| |sensor0|sensor1| + * +-------+-------+-------+ + * + * The calibration data on the H6 is the ambient temperature and + * sensor values that are filled during the factory test stage. + * + * The unit of stored FT temperature is 0.1 degreee celusis. + * Through the stored ambient temperature and the data read + * by the sensor, after a certain calculation, the calibration + * value to be compensated can be obtained. + */ + ft_temp = caldata[0] & FT_TEMP_MASK; + + for (i = 0; i < SUN50I_H6_SENSOR_NUM; i++) { + int reg = (int)caldata[i + 1]; + int sensor_temp = sun8i_ths_reg2temp(tmdev, reg); + int delta, cdata, calib_offest; + + /* + * To calculate the calibration value: + * + * X(in Celsius) = Ts - ft_temp + * delta = X * 10000 / TEMP_TO_REG + * cdata = CALIBRATE_DEFAULT - delta + * + * cdata: calibration value + */ + delta = (sensor_temp - ft_temp * 100) * 10 / TEMP_TO_REG; + cdata = CALIBRATE_DEFAULT - delta; + if (cdata & ~TEMP_CALIB_MASK) { + /* + * Calibration value more than 12-bit, but calibration + * register is 12-bit. In this case, ths hardware can + * still work without calibration, although the data + * won't be so accurate. + */ + dev_warn(dev, "sensor%d is not calibrated.\n", i); + + continue; + } + + calib_offest = SUN50I_H6_THS_TEMP_CALIB + (i / 2) * 0x4; + + if (i % 2) { + int val; + + regmap_read(tmdev->regmap, calib_offest, &val); + val = (val & TEMP_CALIB_MASK) | (cdata << 16); + regmap_write(tmdev->regmap, calib_offest, val); + } else { + regmap_write(tmdev->regmap, calib_offest, cdata); + } + } + +out_free: + kfree(caldata); +out: + return ret; +} + +static int sun8i_ths_resource_init(struct ths_device *tmdev) +{ + struct device *dev = tmdev->dev; + struct platform_device *pdev = to_platform_device(dev); + struct resource *mem; + void __iomem *base; + int ret; + + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(dev, mem); + if (IS_ERR(base)) + return PTR_ERR(base); + + tmdev->regmap = devm_regmap_init_mmio(dev, base, &config); + if (IS_ERR(tmdev->regmap)) + return PTR_ERR(tmdev->regmap); + + tmdev->reset = devm_reset_control_get(dev, 0); + if (IS_ERR(tmdev->reset)) + return PTR_ERR(tmdev->reset); + + tmdev->bus_clk = devm_clk_get(&pdev->dev, "bus"); + if (IS_ERR(tmdev->bus_clk)) + return PTR_ERR(tmdev->bus_clk); + + ret = reset_control_deassert(tmdev->reset); + if (ret) + return ret; + + ret = clk_prepare_enable(tmdev->bus_clk); + if (ret) + goto assert_reset; + + ret = sun50i_ths_calibrate(tmdev); + if (ret) + goto bus_disable; + + return 0; + +bus_disable: + clk_disable_unprepare(tmdev->bus_clk); +assert_reset: + reset_control_assert(tmdev->reset); + + return ret; +} + +static int sun50i_thermal_init(struct ths_device *tmdev) +{ + int val; + + /* + * clkin = 24MHz + * T acquire = clkin / (x + 1) + * = 20us + */ + regmap_write(tmdev->regmap, SUN50I_THS_CTRL0, + SUN50I_THS_CTRL0_T_ACQ(479)); + /* average over 4 samples */ + regmap_write(tmdev->regmap, SUN50I_H6_THS_MFC, + SUN50I_THS_FILTER_EN | + SUN50I_THS_FILTER_TYPE(1)); + /* period = (x + 1) * 4096 / clkin; ~10ms */ + regmap_write(tmdev->regmap, SUN50I_H6_THS_PC, + SUN50I_H6_THS_PC_TEMP_PERIOD(58)); + /* enable sensor */ + val = GENMASK(SUN50I_H6_SENSOR_NUM - 1, 0); + regmap_write(tmdev->regmap, SUN50I_H6_THS_ENABLE, val); + /* thermal data interrupt enable */ + val = GENMASK(SUN50I_H6_SENSOR_NUM - 1, 0); + regmap_write(tmdev->regmap, SUN50I_H6_THS_DIC, val); + + return 0; +} + +static int sun8i_ths_register(struct ths_device *tmdev) +{ + struct thermal_zone_device *tzd; + int i; + + for (i = 0; i < SUN50I_H6_SENSOR_NUM; i++) { + tmdev->sensor[i].tmdev = tmdev; + tmdev->sensor[i].id = i; + tmdev->sensor[i].tzd = + devm_thermal_zone_of_sensor_register(tmdev->dev, + i, + &tmdev->sensor[i], + &ths_ops); + if (IS_ERR(tmdev->sensor[i].tzd)) + return PTR_ERR(tzd); + } + + return 0; +} + +static int sun8i_ths_probe(struct platform_device *pdev) +{ + struct ths_device *tmdev; + struct device *dev = &pdev->dev; + int ret, irq; + + tmdev = devm_kzalloc(dev, sizeof(*tmdev), GFP_KERNEL); + if (!tmdev) + return -ENOMEM; + + tmdev->dev = dev; + platform_set_drvdata(pdev, tmdev); + + ret = sun8i_ths_resource_init(tmdev); + if (ret) + return ret; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + ret = sun50i_thermal_init(tmdev); + if (ret) + return ret; + + ret = sun8i_ths_register(tmdev); + if (ret) + return ret; + + /* + * Avoid entering the interrupt handler, the thermal device is not + * registered yet, we deffer the registration of the interrupt to + * the end. + */ + ret = devm_request_threaded_irq(dev, irq, NULL, + sun50i_h6_irq_thread, + IRQF_ONESHOT, "ths", tmdev); + if (ret) + return ret; + + return ret; +} + +static int sun8i_ths_remove(struct platform_device *pdev) +{ + struct ths_device *tmdev = platform_get_drvdata(pdev); + + clk_disable_unprepare(tmdev->bus_clk); + reset_control_assert(tmdev->reset); + + return 0; +} + +static const struct of_device_id of_ths_match[] = { + { .compatible = "allwinner,sun50i-h6-ths"}, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, of_ths_match); + +static struct platform_driver ths_driver = { + .probe = sun8i_ths_probe, + .remove = sun8i_ths_remove, + .driver = { + .name = "sun8i-thermal", + .of_match_table = of_ths_match, + }, +}; +module_platform_driver(ths_driver); + +MODULE_DESCRIPTION("Thermal sensor driver for Allwinner SOC"); +MODULE_LICENSE("GPL v2"); From patchwork Sun Jun 23 16:41:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7996614E5 for ; Sun, 23 Jun 2019 16:43:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6805328A8C for ; Sun, 23 Jun 2019 16:43:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BE0B28AD1; Sun, 23 Jun 2019 16:43:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 07A1A28A8C for ; Sun, 23 Jun 2019 16:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=oRcgj3XPTxVHB38gWdqtBj/z3dsHsyl0r6wWHVAl+ds=; b=mEmYkChaNS8Z9Z5kWapn2ONr/V pcK21jL7wkxDZeSmInLG8N7WICgTmx7Vlcx3gQoMuU7mK2qFYIVu19rG6rE30QyEho/E6n7P0W9+F kmVmab+HFDcQvUMwJV9nolZv7kC826inZY2I7l3JMNDHVPn8RuDEDren4lb6ML7LiHlw1nG0gL8/m 7eT2+3eAgChBmMJfoFh3y1nMn1axVrXEAFDq4tRBasZP4IGajgmeZhlDKoOC0oQ1c2adYJizSkfyB PPOGNsGHoLkv0gXe2QIXwUmNDFoHb7fJCCtjr9XIyOP430gyG6xsK/PX61/i+U+Jr7gXT38aEjOck d6FaoXQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5a6-00035B-8b; Sun, 23 Jun 2019 16:43:06 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5ZH-0002V1-P3 for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:17 +0000 Received: by mail-pf1-x442.google.com with SMTP id d126so6118400pfd.2 for ; Sun, 23 Jun 2019 09:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GJ1/rKutIQEKHvyH14ecs6l1ZdLbW/7MgqbbW+zZyME=; b=aPkTDQYg6YxMR3LTtRqUOO2PX5D4buJBQKeJG5SSksdp94O1WOG6qh7fzioBgPa3I9 hC6vdUBCy3i4vqfbfzBTA/md92U4B/cEKPIelHy0Q3bl9TkucGocmA290racdD5hqA+D /l1E+fld70hWvvHqRU9W0Hl0SiUJelPC8gB4jRE1AXcm9za3kNhEYLxEjdVMP2lVRP/u q68qtw9uV3ZNjoh+qa2qr3NpaKh/sVlNciRaVcdWxwiQLWsDJGeP9N42hO1pWYH9u6hW wM1OpitX/5R8JL7GRo8ez064bZhvDxyKXToUaaYc1pEbJS8fEUhWqhXsCOJnA7JigVzr RVlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GJ1/rKutIQEKHvyH14ecs6l1ZdLbW/7MgqbbW+zZyME=; b=MqhXAqJB5wjGQIOP2hTG+2ZiTxage1yBNzJMJJcCUE3BD/bRujVWFXYUUla3fRWCZQ hILtvyfL/WZ32MpUTBZ+ZqlQp66EUPHw2db4dFxS1ozLYDqTF4iF0t9I+ILAgOIcZtJ+ YPWMt5z/C1U6OnGH//RFpOBHWsjUa7Wl6VtWldWN3fKBNjbEC7beOgYbgGkR3SZGGgaf +iYFjfp1k+AFs3Z2I+TX3rwXg/DWKqaVAN7Yts63VZS4X/fIiidIH92SPPj3/IxDu4yI 8DeHT54+FpnJI/hM3ZhpjaODnAtk1pz4WEFSWmmqQTPZBXEIyTEXLc4y75nYSPU/io5l Xm5Q== X-Gm-Message-State: APjAAAUjJ1comXdB56TsTICneLpMEDYlP5VOKTuU9hW9He7xac7nhpDs Wr4LN0c3xLgiuDkeMdKGdGc= X-Google-Smtp-Source: APXvYqzr3IL15+QRlPgzFQhfOuJbPNix+LH7PczxPb49B9YhZvIzUrQxfMsNEB8dxxedXBBzTMPQWw== X-Received: by 2002:a63:4553:: with SMTP id u19mr28484919pgk.420.1561308134980; Sun, 23 Jun 2019 09:42:14 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id k16sm9059855pfa.87.2019.06.23.09.42.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:14 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 02/11] dt-bindings: thermal: add binding document for h6 thermal controller Date: Sun, 23 Jun 2019 12:41:57 -0400 Message-Id: <20190623164206.7467-3-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094215_851643_DA262E61 X-CRM114-Status: GOOD ( 12.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds binding document for allwinner h6 thermal controller. Signed-off-by: Yangtao Li --- .../bindings/thermal/sun8i-thermal.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/sun8i-thermal.yaml diff --git a/Documentation/devicetree/bindings/thermal/sun8i-thermal.yaml b/Documentation/devicetree/bindings/thermal/sun8i-thermal.yaml new file mode 100644 index 000000000000..2c5acc61ed03 --- /dev/null +++ b/Documentation/devicetree/bindings/thermal/sun8i-thermal.yaml @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/thermal/sun8i-thermal.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Allwinner SUN8I Thermal Controller Device Tree Bindings + +maintainers: + - Yangtao Li + +description: |- + This describes the device tree binding for the Allwinner thermal + controller which measures the on-SoC temperatures. + +properties: + compatible: + enum: + - allwinner,sun50i-h6-ths + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + resets: + maxItems: 1 + + clocks: + minItems: 1 + maxItems: 1 + + clock-names: + const: bus + + '#thermal-sensor-cells': + const: 1 + + nvmem-cells: + items: + - description: ths calibrate data + + nvmem-cell-names: + items: + - const: calib + +required: + - compatible + - reg + - reset + - clocks + - clock-names + - interrupts + - '#thermal-sensor-cells' + +examples: + - | + ths: ths@5070400 { + compatible = "allwinner,sun50i-h6-ths"; + reg = <0x05070400 0x100>; + clocks = <&ccu CLK_BUS_THS>; + clock-names = "bus"; + resets = <&ccu RST_BUS_THS>; + interrupts = ; + nvmem-cells = <&tsen_calib>; + nvmem-cell-names = "calib"; + #thermal-sensor-cells = <1>; + }; + +... From patchwork Sun Jun 23 16:41:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D63F14E5 for ; Sun, 23 Jun 2019 16:43:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68F7928A8C for ; Sun, 23 Jun 2019 16:43:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C12228AD1; Sun, 23 Jun 2019 16:43:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0F4A228A8C for ; Sun, 23 Jun 2019 16:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=SMx233gUr4JAUgu/vipagl37Ky3RwshNq+0Tlgo24AM=; b=G4KN/2JF+qhR6yiMYA7fb8bWHw /92Sqq1Aj/6z8j5qbxDsYkIqKy0q6eTR8WtimWzkaGyjLfhiKgcG6KrmDAVAz45c8D11zWvdNbCBE x1ZI7ahcenZlyJRdvp8T81skNqC7Ph5UBve+rNRB/hj3f9RsMWCUidbs8C3In6+YEo1PUbxqKFnhX /CbzDPxUBBpVQ6s7LaTyaueOBOVvp2Z63P4w7mCB4Lzqjv8hxJEIUkPPqd2NcBXbbbLLzHOeDJlWX 47yo+jRoqUBEkO/LO+ihTIrRjdiSD/qStJT51YMSmJKP6k3Rv3ZiP+VQydg4PvI6CJ/fDo7hxI806 /b08QR2w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5aQ-0003Mi-6U; Sun, 23 Jun 2019 16:43:26 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5ZJ-0002XA-U8 for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:19 +0000 Received: by mail-pg1-x542.google.com with SMTP id w10so5771698pgj.7 for ; Sun, 23 Jun 2019 09:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l52fWtW3aoPkxwNQa5fIqgZrHE13Sc/TSQJ/idB7mO0=; b=e522gMpk4cJiXZ8WanDck6Eu2glNq4tzW8JKnszog3QBvg4Ippfq8hNQnuBo94orbX u2gMCzLLiqfDEbsZASmbJ/LDbnQHM3WuwjsSQks2HwbcjZwW8bYclLUg8YNHN4cRskuG 1mxiV6/zUeI2UHI4i07lZEVAddmJg3NlXLYI0Cea4XUSP2KJCoRdXJCu5ywoyQBBrO4J gSDJzHwbDUQ41U4Hp9VyyQS5koSpmaIYzZII/KVK+V0OGPFxqs7Nb+IC82AvHAMrHN62 NMkiDDwZjezT0qG3aFg6JiCw+YhtJ2roIWJnfE6wpzAZTmn7ZmgEwFn1BGH1knsQvnET Lwug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l52fWtW3aoPkxwNQa5fIqgZrHE13Sc/TSQJ/idB7mO0=; b=FFMjtPNVBkU9N8hxg4PN3m2JYAXZzjVRUP8fbxOCuzLC6PqBnGHHeCPA9s2M94FUJj 8Ru7lCANDOHtJires87l4CAsMtTEkABdbWnBtcitvgAzAKBsy31N7ydEGFovGBBM1Ifq v+WRT4j3cmRUEewmC976H5Sh6NqeDgK5DGtuzPanPNDmy1tMwSba8EWRYm1caaz7BtJw 2hwwd9YJvTT44+QQOhl9FE/t+pv6iNGyoth6aF03rAIJk+VSkVhWVGx42HrUTbS/8m/f sQFWPXA+nOjfub7GWdaPqEDUSpw2cR/gF5Hd+WHCKM+Y7tqIj7QEmiSVR+sWff2pTtgE 6QsA== X-Gm-Message-State: APjAAAVTdXe8AfDwGLJRP3Mqj7rPyEq3qAxkz2IVqH8ac08FHCnnAr3B p/onlV2qMDzCwBOwdoqx1Ls= X-Google-Smtp-Source: APXvYqxwcVFm4cX8NcFvvREnvAiZRJODJ0isOyybQ/E6r9Z7HRNVzLSobEYtQ42YhiYekF7fI++91Q== X-Received: by 2002:a63:8341:: with SMTP id h62mr17783424pge.206.1561308137073; Sun, 23 Jun 2019 09:42:17 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id m6sm9744878pjl.18.2019.06.23.09.42.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:16 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 03/11] thermal: fix indentation in makefile Date: Sun, 23 Jun 2019 12:41:58 -0400 Message-Id: <20190623164206.7467-4-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094218_009116_F6063E36 X-CRM114-Status: UNSURE ( 9.14 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To unify code style. Signed-off-by: Yangtao Li --- drivers/thermal/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index fa6f8b206281..d7eafb5ef8ef 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_THERMAL) += thermal_sys.o thermal_sys-y += thermal_core.o thermal_sysfs.o \ - thermal_helpers.o + thermal_helpers.o # interface to/from other layers providing sensors thermal_sys-$(CONFIG_THERMAL_HWMON) += thermal_hwmon.o @@ -25,11 +25,11 @@ thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o # devfreq cooling -thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o +thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o # platform thermal drivers obj-y += broadcom/ -obj-$(CONFIG_THERMAL_MMIO) += thermal_mmio.o +obj-$(CONFIG_THERMAL_MMIO) += thermal_mmio.o obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o obj-$(CONFIG_SUN8I_THERMAL) += sun8i_thermal.o obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o @@ -50,7 +50,7 @@ obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal/ obj-y += st/ obj-$(CONFIG_QCOM_TSENS) += qcom/ obj-y += tegra/ -obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o +obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o obj-$(CONFIG_ZX2967_THERMAL) += zx2967_thermal.o From patchwork Sun Jun 23 16:41:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2931D14E5 for ; Sun, 23 Jun 2019 16:43:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1682D28A8C for ; Sun, 23 Jun 2019 16:43:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0958D28AD1; Sun, 23 Jun 2019 16:43:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 078F528A8C for ; Sun, 23 Jun 2019 16:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=cEBmKqs7gHrlFw8iTZwZVZDc7olLe+pcWdmwmUZ5+iM=; b=iLMy+9meZdDo01hM2St2/jKmim C0og7vtoPfh96qtCP7W4qdufhD7rlQb7r0wY/xd9Y2sthO5Hc5OicZ5ifrTIWA7MEZIOxa+DY/qm6 AWoX+N+7VFcrysipAM0L8OIrS8YdXg9EIayvE5BN3txxZ3sZcF+ROaJXavQBo+jg2FbcZgUePKI+P asiFKyJmSxZ4AGIZH13mNBdj/ff71NoeFsDpJqfUFW/5N3ogwon/ytOqOVKhkT4mUusNDXmII6eAH oyn9QtK607ribQSVbV/YXpy3UYwQxAPdvgW0UKEOy4iuQKp/Q4ta/e9L+TcwIDzTHKyjejGaibYa2 Omr5M5Zg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5ap-0003bb-6N; Sun, 23 Jun 2019 16:43:51 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5ZL-0002Z3-Mf for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:21 +0000 Received: by mail-pg1-x544.google.com with SMTP id y72so5774687pgd.8 for ; Sun, 23 Jun 2019 09:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=61YRhTYZzpPAbsdw4ql6MdZ8eDEIqaY2tionq5H4meo=; b=Wzrz9SjgCzNqQkzWoSMQqAL1h3gNd+lI94LXDB/ydu9Z8V5mO205tsym53MOSa7sW5 +6rdMWKOr4rPzevDBAEwwn3hxXiQFvYk7nzcRCamQ4cpeaOe1lTnd39tYp3QLHotHkrf H9Gqqwx9cuvPLmydJrXROfFy7XQX4E0veSpIcrt3VPWOIaWnog2/DdVzcC9SoN7Ly/2y y6hbEuiD/dwWJZzid73WhW7L5OeZao0Pqcdwye2c8fGjKNNck19ziC0E0bgNsHHxISq8 pxrC+K9DVFBjw6xaWwof4EPLGizmWrDNoNj4VJC5mOVV8FoklOpLkYrV4791DFZ69Tll znPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=61YRhTYZzpPAbsdw4ql6MdZ8eDEIqaY2tionq5H4meo=; b=rNxko5h4nNM2jts63ama7LogGXQ6XkcQU9nNVT3BNxvNodTn1q2g4nFedWLHq3wZjN RWc6B6el6aoJHH7a0Vb3xdvBJhRnkJbLOR/yKQnRVwoG5ZXLRJoYUf9LojzUUsoBjKtF d71YNhO0k4CYRLFAlP9kbKs37TBmHUGSPYCaFwbBQC11nnWqwjnXv7lMpIV5tlnrrTc1 lXYGJIVADbu9n7m/xHlNR8wYGWmz83Jx/2rkRIUukZbXCgZExf6LIrGPec8aOzsaOeig J+0UYk1KkcorkginmjRCfPxZHdjZF5pT/XCHqoUfQRURzZDIAnODmnZbcd4I5UA1Dfsq mIMQ== X-Gm-Message-State: APjAAAUWLYXq6uYDAozN9qWpBENJRPXG1mOoF031XV3sZqUurTooo32y lu9vQhMKSQ1+8Zwd1v0Y/OM= X-Google-Smtp-Source: APXvYqzRoYiCci88ppuvAJgfSh+3g9qZBEaERQz6llUSQx4SEJvBp6v+YlGwm14rPG59UsiG008gBQ== X-Received: by 2002:a17:90a:1c1:: with SMTP id 1mr19678268pjd.72.1561308138834; Sun, 23 Jun 2019 09:42:18 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id k22sm8405914pfk.157.2019.06.23.09.42.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:18 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 04/11] thermal: sun8i: get ths sensor number from device compatible Date: Sun, 23 Jun 2019 12:41:59 -0400 Message-Id: <20190623164206.7467-5-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094219_808684_E76834DA X-CRM114-Status: GOOD ( 15.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP For different socs, the number of ths sensors is different. So we need to do some work in order to support more soc. Signed-off-by: Yangtao Li --- drivers/thermal/sun8i_thermal.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index d6918c62682b..c37e1c51a543 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -22,7 +22,6 @@ #define MAX_SENSOR_NUM 4 -#define SUN50I_H6_SENSOR_NUM 2 #define SUN50I_H6_OFFSET -2794 #define SUN50I_H6_SCALE -67 @@ -57,7 +56,12 @@ struct tsensor { int id; }; +struct ths_thermal_chip { + int sensor_num; +}; + struct ths_device { + const struct ths_thermal_chip *chip; struct device *dev; struct regmap *regmap; struct reset_control *reset; @@ -117,7 +121,7 @@ static irqreturn_t sun50i_h6_irq_thread(int irq, void *data) regmap_read(tmdev->regmap, SUN50I_H6_THS_DIS, &state); - for (i = 0; i < SUN50I_H6_SENSOR_NUM; i++) { + for (i = 0; i < tmdev->chip->sensor_num; i++) { if (state & SUN50I_H6_THS_DATA_IRQ_STS(i)) { /* clear data irq pending */ @@ -167,7 +171,7 @@ static int sun50i_ths_calibrate(struct ths_device *tmdev) goto out; } - if (!caldata[0] || callen < 2 + 2 * SUN50I_H6_SENSOR_NUM) { + if (!caldata[0] || callen < 2 + 2 * tmdev->chip->sensor_num) { ret = -EINVAL; goto out_free; } @@ -190,7 +194,7 @@ static int sun50i_ths_calibrate(struct ths_device *tmdev) */ ft_temp = caldata[0] & FT_TEMP_MASK; - for (i = 0; i < SUN50I_H6_SENSOR_NUM; i++) { + for (i = 0; i < tmdev->chip->sensor_num; i++) { int reg = (int)caldata[i + 1]; int sensor_temp = sun8i_ths_reg2temp(tmdev, reg); int delta, cdata, calib_offest; @@ -303,10 +307,10 @@ static int sun50i_thermal_init(struct ths_device *tmdev) regmap_write(tmdev->regmap, SUN50I_H6_THS_PC, SUN50I_H6_THS_PC_TEMP_PERIOD(58)); /* enable sensor */ - val = GENMASK(SUN50I_H6_SENSOR_NUM - 1, 0); + val = GENMASK(tmdev->chip->sensor_num - 1, 0); regmap_write(tmdev->regmap, SUN50I_H6_THS_ENABLE, val); /* thermal data interrupt enable */ - val = GENMASK(SUN50I_H6_SENSOR_NUM - 1, 0); + val = GENMASK(tmdev->chip->sensor_num - 1, 0); regmap_write(tmdev->regmap, SUN50I_H6_THS_DIC, val); return 0; @@ -317,7 +321,7 @@ static int sun8i_ths_register(struct ths_device *tmdev) struct thermal_zone_device *tzd; int i; - for (i = 0; i < SUN50I_H6_SENSOR_NUM; i++) { + for (i = 0; i < tmdev->chip->sensor_num; i++) { tmdev->sensor[i].tmdev = tmdev; tmdev->sensor[i].id = i; tmdev->sensor[i].tzd = @@ -343,6 +347,10 @@ static int sun8i_ths_probe(struct platform_device *pdev) return -ENOMEM; tmdev->dev = dev; + tmdev->chip = of_device_get_match_data(&pdev->dev); + if (!tmdev->chip) + return -EINVAL; + platform_set_drvdata(pdev, tmdev); ret = sun8i_ths_resource_init(tmdev); @@ -385,8 +393,12 @@ static int sun8i_ths_remove(struct platform_device *pdev) return 0; } +static const struct ths_thermal_chip sun50i_h6_ths = { + .sensor_num = 2, +}; + static const struct of_device_id of_ths_match[] = { - { .compatible = "allwinner,sun50i-h6-ths"}, + { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, of_ths_match); From patchwork Sun Jun 23 16:42:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29D4C14E5 for ; Sun, 23 Jun 2019 16:44:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1831828A8C for ; Sun, 23 Jun 2019 16:44:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0992528AD1; Sun, 23 Jun 2019 16:44:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9809F28A8C for ; Sun, 23 Jun 2019 16:44:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=362ghglf1NS2nHOHwHbZwVLkW69TT3RbYXxaNK2WwcM=; b=cpvXGU5nB7NQnSR20aHLcsAjSE LIvqyRSePpDYlT1GixvGrZs3s1WMgW8gXbqMHi6YaDIO/NLzkMrWtbGh5EHeoVHwI7Gc9hCrZwedR yQ5du1iwhyZzEQyptpne6hjcQXBxKau0k4sM47uYpeYdB70b/vtLvGo0VnVcUFj2R+YqaH8FlXZKs DCRzG9opxpm5oQVB7HpihEk1eC9vseoWOyyYaMF4l3jvGh3p8HGhbpcynRPRojKZ109Fwnh1f7Je+ pklyKWzYiBsN1N0NWBHtVvw0wmMlJ3G5rNq46H408VADT3LHyZTCL5+GODS+GnF48YH9kyMYHQylK 9E1OTO5A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5b9-0003rN-R2; Sun, 23 Jun 2019 16:44:11 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5ZN-0002b7-Lh for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:23 +0000 Received: by mail-pg1-x544.google.com with SMTP id s27so5795350pgl.2 for ; Sun, 23 Jun 2019 09:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9UNcpWLQ0SBIIcBRxbN1qX4s3ChEMbjvtnWO+dtNEsA=; b=q7GZ/jpCAu9MK3iPRrcZ9ANkg2i3u6OpwBfpBxftNrbB7qb5Ql/dv/7UGy8QXCCGpy GiGyjFSWSWxOwbxw3caI4V/cmdLbmXW63FudgJkGpzzRJsXBhSZ1oIcSv5VoS0sgYpmT wKshYQ+CHPlieOztlOpzZaI86gqTUced4iJPd7tSBo/mzcRsYUdjvXC2dB8u8KVi7a7o Ad48cjNJiPK/Q5LWyupyPXWmQ32wJAU3q8xCbrm4bSi+5gJJdf6+g+Or/gdUlua2/v82 yAmGhMZ0tWH3/3vnG0wz4DebTviCokra90Eq2UiRVcArotY86r1DhHK+Sogw5UxpNXEM bv5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9UNcpWLQ0SBIIcBRxbN1qX4s3ChEMbjvtnWO+dtNEsA=; b=BT4chqiuqP1bHjuBqS1rAc+vwdaUEtPdlbU0AIf4ZNdGUyQ+RbU19OayKgTmb1qW85 C2nFnytcWhwUG023HrO1V9T84gjkNKGVzatmLrY0o43vVTuBRLUogYUaj5lJrYYLCq8s /4Z6yk5fMGLyiYZtkxWYB22VL+w5DRMUZc+jMyG+k1daVksAvJcmEW4DqDUGi4YLNXe9 /4OKWp1ro1052WJDAz2X12gLuorqp4FYNz2hG49bsSMpQm4B7G93v1EY9XYwRLSz1YRb lSQcoKVIIBgwMke77moERR7pmHxUZtM2YIQ0vxV4NB0QkUgCW24cQhZufdYJe6GuG4HQ 5dRA== X-Gm-Message-State: APjAAAWCWn5I3HU1SjMTJJeIhUCy1JJfiQqDJY3gTrUx020F/GprCPff k0m1DsX0pNE7CmQWu2S5x+0= X-Google-Smtp-Source: APXvYqy7Clm/F/UW+Jya2jGhzAWsBCgiuAG/VXNp/xiWo2mAetLliQqzE0GZg6EIu+TjhZV50wTfIg== X-Received: by 2002:a17:90a:bb01:: with SMTP id u1mr19254865pjr.92.1561308141132; Sun, 23 Jun 2019 09:42:21 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id z186sm9183351pfz.7.2019.06.23.09.42.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:20 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 05/11] thermal: sun8i: rework for sun8i_ths_get_temp() Date: Sun, 23 Jun 2019 12:42:00 -0400 Message-Id: <20190623164206.7467-6-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094221_843600_08B5CD56 X-CRM114-Status: GOOD ( 14.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP For different socs, the way they get and calculate the temperature is roughly the same. So get the difference from device compatible. Difference point: 1) temperature calculation formula parameters 2) ths data register start address Signed-off-by: Yangtao Li --- drivers/thermal/sun8i_thermal.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index c37e1c51a543..e473a5651436 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -22,9 +22,6 @@ #define MAX_SENSOR_NUM 4 -#define SUN50I_H6_OFFSET -2794 -#define SUN50I_H6_SCALE -67 - #define FT_TEMP_MASK GENMASK(11, 0) #define TEMP_CALIB_MASK GENMASK(11, 0) #define TEMP_TO_REG 672 @@ -58,6 +55,10 @@ struct tsensor { struct ths_thermal_chip { int sensor_num; + int offset; + int scale; + int ft_deviation; + int temp_data_base; }; struct ths_device { @@ -73,7 +74,7 @@ struct ths_device { static int sun8i_ths_reg2temp(struct ths_device *tmdev, int reg) { - return (reg + SUN50I_H6_OFFSET) * SUN50I_H6_SCALE; + return (reg + tmdev->chip->offset) * tmdev->chip->scale; } static int sun8i_ths_get_temp(void *data, int *temp) @@ -82,7 +83,7 @@ static int sun8i_ths_get_temp(void *data, int *temp) struct ths_device *tmdev = s->tmdev; int val; - regmap_read(tmdev->regmap, SUN50I_H6_THS_TEMP_DATA + + regmap_read(tmdev->regmap, tmdev->chip->temp_data_base + 0x4 * s->id, &val); /* ths have no data yet */ @@ -98,7 +99,7 @@ static int sun8i_ths_get_temp(void *data, int *temp) * temperature above is also used when the sensor is calibrated. If * do this, the correct calibration formula is hard to know. */ - *temp += SUN50I_H6_FT_DEVIATION; + *temp += tmdev->chip->ft_deviation; return 0; } @@ -395,6 +396,10 @@ static int sun8i_ths_remove(struct platform_device *pdev) static const struct ths_thermal_chip sun50i_h6_ths = { .sensor_num = 2, + .offset = -2794, + .scale = -67, + .ft_deviation = SUN50I_H6_FT_DEVIATION, + .temp_data_base = SUN50I_H6_THS_TEMP_DATA, }; static const struct of_device_id of_ths_match[] = { From patchwork Sun Jun 23 16:42:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B5D517D2 for ; Sun, 23 Jun 2019 16:45:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBF1328A8C for ; Sun, 23 Jun 2019 16:45:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBD2828AD1; Sun, 23 Jun 2019 16:45:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8DF7E28A8C for ; Sun, 23 Jun 2019 16:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=LEKcRynB8rEFiGMn9Kp7kYI3bJVw9XnBp8clklvySNc=; b=YiyjgOLGuFDT4oExQ6GjkwdZTb hc7qnfUOoOv2Ax7aOHEZrTrLDlgfLTOBUUOUSAGInyEkLwFZmf3PpZSuaTGlYKGxnnwQdQTMZ9UFD 4CDxDYcVn9QXo8SGOKy1kzf7CjsZZMg4Fc6VJuoymh6P4aUFIPMeHJpUldI7Etb0rXV3V9E8neGKx AANzDFcT4eBm6zccxRJXDARHu3lslD6qgO5rNuHdLtss4i7/TEc00MkUQWAufZCMxevVBAced5dl2 CpDL6JZtuyifDUoeVVjGlyHRKzETyzgw0AbuOHgO6BSmhbZMdaQFsZA68aHJ09Pwa+3NHtM+FKRiR FHrDRjUA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5bv-0004Rw-DZ; Sun, 23 Jun 2019 16:44:59 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5ZQ-0002dj-En for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:30 +0000 Received: by mail-pl1-x643.google.com with SMTP id m7so5477897pls.8 for ; Sun, 23 Jun 2019 09:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QeuzSFtFULNoQbGg4hqLSd4xmo0B4o8ksbknu1n0KZM=; b=WX3Yrc0OvQ8B4sl+cSv2hgv3FAi1TFu+BMpDsDcgG2niFAPlDuUCFFhgZT32h1myEe OtI8aFmwrPENLyEXeOboC0R5ChT8PcsJwGPZdcnK3obduopK7EL8O618V8I3vX87FsGM W+SifyHWCKQJGj9xfXnzDbwRP+jNnE/bFXZgvpt3bw7BxHfNUZmo+7zeM6pjWJHXyh59 5nF4UUTVWkTN3xE34blNimLRleCmmRIMDrVgnf3u251YCFwHLS9r0nQs/ukEinAW4XTE iIpCgUsg22Bwbo+a6b9zUJ3sewCrvqe41ug9HGsuSntXfo2ffqGkG7r/D6iJaaZIFqCb /Glg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QeuzSFtFULNoQbGg4hqLSd4xmo0B4o8ksbknu1n0KZM=; b=oHmufp1jTtveUtJMjFW0xFUWbx82d3pEwuAFLe5aXMR+tgv6IO7iJ58ZWWwyc2zedt +XUbCmNDGWhd3d7EemLaix7f3Cj4StspYrRLZ5xM0sQ+Nxv/87AnfQCy7qeuqzrRcT3p YzgCdmksNsgaDjx+TLvNt5yjleHvwssE5RycZ2vRS1ML+FhnzDRjBUU6GqxmW8598aP+ BOTx4+JewRNcRdcdqSIZA3nhDy9+BShn4xxFF2aBUZb0Lq3pAaChdrvm9wAJZ/kewWJz oXQVbVg5yDK+3FTb0QuzQU4osveOJ2FJ4HNWXGx38YnYI3NcsAtJJym0Yg0ouGDHfhKf mQAQ== X-Gm-Message-State: APjAAAWRnkYg/AhboGS701dQEdzLVin1Y3r+lBBEnzLOGT6g0hzDsddQ m6G23kX5hdKVbyPmjKAInwU= X-Google-Smtp-Source: APXvYqwmAwNO0tRQc1DYoa+hJd5YtKf6VLWWVmJUG+ZzCkzrIkvCUZwARJRuxYe6faj0d1GPkbIWBg== X-Received: by 2002:a17:902:6b02:: with SMTP id o2mr48701805plk.133.1561308143647; Sun, 23 Jun 2019 09:42:23 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id e6sm9766388pfn.71.2019.06.23.09.42.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:23 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 06/11] thermal: sun8i: get ths init func from device compatible Date: Sun, 23 Jun 2019 12:42:01 -0400 Message-Id: <20190623164206.7467-7-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094225_262949_CBB82D65 X-CRM114-Status: GOOD ( 12.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP There are some differences in register initialization for different socs. So we get different initialization functions from device compatible. Signed-off-by: Yangtao Li --- drivers/thermal/sun8i_thermal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index e473a5651436..59acbbac76e4 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -59,6 +59,7 @@ struct ths_thermal_chip { int scale; int ft_deviation; int temp_data_base; + int (*init)(struct ths_device *tmdev); }; struct ths_device { @@ -362,7 +363,7 @@ static int sun8i_ths_probe(struct platform_device *pdev) if (irq < 0) return irq; - ret = sun50i_thermal_init(tmdev); + ret = tmdev->chip->init(tmdev); if (ret) return ret; @@ -400,6 +401,7 @@ static const struct ths_thermal_chip sun50i_h6_ths = { .scale = -67, .ft_deviation = SUN50I_H6_FT_DEVIATION, .temp_data_base = SUN50I_H6_THS_TEMP_DATA, + .init = sun50i_thermal_init, }; static const struct of_device_id of_ths_match[] = { From patchwork Sun Jun 23 16:42:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50B8614E5 for ; Sun, 23 Jun 2019 16:44:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D49A28A8C for ; Sun, 23 Jun 2019 16:44:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EC5928AD1; Sun, 23 Jun 2019 16:44:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C499728A8C for ; Sun, 23 Jun 2019 16:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fnNjNawex3kfv7sqmXB/N3/+3OBHsFoY9YesgmFx6Ms=; b=dP/Cd+SOeDl3frVTzWbLUE8h06 +lKWl7KplYhVHcjFz1uORkOTBlyoLUNjEM8YD1zOxWWXW7NUs4VH9zCxqGAlKMyf1Ac97DqxuCiin 9n4ARxmq7+TlPjg5jou6T0/TmOw4FZj2UDKh90T0+GJaTW0ypIGUccsi51J6gPON837zs9hP5qn5l mPba9zlXTE7LHLMR9SVsOFfu2VsV1fQdZLDY+CTX7LA4yAs4AsW/DFYMT1nvDYSvtv6WKmWSsWzpN eR3DjNU8QxvpuMN41Ue8dTa+XhWo6xCCxxAPj3qr3/gkNbTbQvtqRb+gjDpIX/P90ihh+pOYOhklu +EzPN5LA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5bX-00049C-38; Sun, 23 Jun 2019 16:44:35 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5ZT-0002g0-BL for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:30 +0000 Received: by mail-pg1-x541.google.com with SMTP id l19so5774575pgh.9 for ; Sun, 23 Jun 2019 09:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wEqIKiIjMDW4aKJ2RgXaFik3U88pUoE48jM/nfBTuhA=; b=OvgjTayEeWn9V1P+UsSgcRUgHzKlA20WHH1U2kasI2U4zb1dZGsyz8z+mFheACxqL1 kPQOapIXQt8yaWoIMb9oE6e8TmtvbvSh0mKDrymGbV6gADJwZzIR14jVItFURLk/R1O4 +GScwEEjNqEtdFG/g4cvA6puWFeFqK8UA8P6UhcnIk1zjq0E2eP5akr8PRqW2ZIUSbTx 1ltLgVyXxvuDz8eJtBiiJtFFEgqCocluxqoAs7ahM06e73JXU346rRymL3oOaaneDdSB GguJpVfIgppIARigTk4XyddmTJ6SS8LyjzNMqcjcAQpIDW4PpUFX5jAPUxqtvjAC9y5x +blg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wEqIKiIjMDW4aKJ2RgXaFik3U88pUoE48jM/nfBTuhA=; b=eiJ6x6dTUGVKN46/StPEcBsIPkaCY83HAZMOz8IdElANmq/X3TszPp+ITNLGuPcpMS p/WpdPvNdBfrVGFxryFgfTk/btmP83amP74KFf8q9WL7JfraBTceBtXM0qBDUqgwZW2j 3xk2bQGS839YkK+gLUSmQgqUVOJInPb/d5fustpg2cSUl/kTalkCj591psn02lrIJ3IH VFLZ6D9kc3xh17kvd67BXaG4RkZYfJ8KxuzSzoJLH5HRMb7NS2CT65QFDkcQgmtkQzKe XFJhg9WgvQvqcRG/SGImwZXeNaVbizN+ACX6fs9+feJkynXjwGBBk2SV9rsoPLRARJrh sbJQ== X-Gm-Message-State: APjAAAVtThw2i+l5LdGn/vMummiAULCRNSujxVjIQHDoEzlx+edkKMPB tRLsCY8A7vfh8VN+4Uqqf8c= X-Google-Smtp-Source: APXvYqzqdPeNJDKT2GHT0UxSYGePTtYbn2c7WuA7YrqBRcCXj1cMwuqZDcNhsdj2Me9OR655VE0O4g== X-Received: by 2002:a63:a046:: with SMTP id u6mr12950599pgn.122.1561308146440; Sun, 23 Jun 2019 09:42:26 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id a3sm9503098pfo.49.2019.06.23.09.42.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:25 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 07/11] thermal: sun8i: rework for ths irq handler func Date: Sun, 23 Jun 2019 12:42:02 -0400 Message-Id: <20190623164206.7467-8-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094227_508815_F1293EEB X-CRM114-Status: GOOD ( 13.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Here, we do something to prepare for the subsequent support of multiple platforms. 1) rename sun50i_h6_irq_thread to sun8i_irq_thread, because this function should be suitable for all platforms. 2) introduce irq_ack callback to mask interrupt register differences. Signed-off-by: Yangtao Li --- drivers/thermal/sun8i_thermal.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index 59acbbac76e4..ed1c19bb27cf 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -60,6 +60,7 @@ struct ths_thermal_chip { int ft_deviation; int temp_data_base; int (*init)(struct ths_device *tmdev); + int (*irq_ack)(struct ths_device *tmdev); }; struct ths_device { @@ -116,23 +117,34 @@ static const struct regmap_config config = { .fast_io = true, }; -static irqreturn_t sun50i_h6_irq_thread(int irq, void *data) +static int sun50i_h6_irq_ack(struct ths_device *tmdev) { - struct ths_device *tmdev = data; - int i, state; + int i, state, ret = 0; regmap_read(tmdev->regmap, SUN50I_H6_THS_DIS, &state); for (i = 0; i < tmdev->chip->sensor_num; i++) { - if (state & SUN50I_H6_THS_DATA_IRQ_STS(i)) { - /* clear data irq pending */ regmap_write(tmdev->regmap, SUN50I_H6_THS_DIS, SUN50I_H6_THS_DATA_IRQ_STS(i)); + ret |= BIT(i); + } + } + + return ret; +} +static irqreturn_t sun8i_irq_thread(int irq, void *data) +{ + struct ths_device *tmdev = data; + int i, state; + + state = tmdev->chip->irq_ack(tmdev); + + for (i = 0; i < tmdev->chip->sensor_num; i++) { + if (state & BIT(i)) thermal_zone_device_update(tmdev->sensor[i].tzd, THERMAL_EVENT_UNSPECIFIED); - } } return IRQ_HANDLED; @@ -377,7 +389,7 @@ static int sun8i_ths_probe(struct platform_device *pdev) * the end. */ ret = devm_request_threaded_irq(dev, irq, NULL, - sun50i_h6_irq_thread, + sun8i_irq_thread, IRQF_ONESHOT, "ths", tmdev); if (ret) return ret; @@ -402,6 +414,7 @@ static const struct ths_thermal_chip sun50i_h6_ths = { .ft_deviation = SUN50I_H6_FT_DEVIATION, .temp_data_base = SUN50I_H6_THS_TEMP_DATA, .init = sun50i_thermal_init, + .irq_ack = sun50i_h6_irq_ack, }; static const struct of_device_id of_ths_match[] = { From patchwork Sun Jun 23 16:42:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011829 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCF746C5 for ; Sun, 23 Jun 2019 16:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE1382880C for ; Sun, 23 Jun 2019 16:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EC252884E; Sun, 23 Jun 2019 16:45:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4CF072880C for ; Sun, 23 Jun 2019 16:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fHOV1r2TlnZE6Wbip8pzN3dctLKA+7DuyXPYiAeNTPA=; b=dVbiAWq0Q/bibV8Bt28bl5bcql bRXBu0v6707MHtl5qOrik7UOWaFdu+curUYa7RYitrJyksqUlqSNSHCYUS2XQzqRCgKqnD2iR/8SK 2YfVzdco94AylgCrmK0oZmh+EJMmY+FI7Rt56z9+IbNDGG0MHIIoRUzRbY2IzUDtwm0S5pNuolV9P mZWWUIWtbs0viiBEHFVdJn6c0eYx2g2j2gyAR3lC5rmq+TXZJhMr/114ZP0NrPRq9pKq2Iywk3+CY wbQJ7UZ+FjfcFBsFIipoT0/cRYhgU2BOSPQOxQNh+fxbvwKVNntq+IUhHoZ1xSeI4bgoovXF+DgpL LNW7XPBg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5cG-0005vO-Gq; Sun, 23 Jun 2019 16:45:20 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5ZW-0002hy-Je for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:32 +0000 Received: by mail-pl1-x641.google.com with SMTP id k8so5512473plt.3 for ; Sun, 23 Jun 2019 09:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ddH5x5C4Xtp9rpA7ryYSwYalCmUTcgexoa3qISyw2Ug=; b=tsMXbUAgFpwgrGExbojVFp6U+eGCSeVvQ9COwf0RIP4o6x6lu/cIpPJiU6z+BFl/nK 9uFezX6fSwPv9SbDVCJn3nhgK/wYhAFSTfVVRRAhcNasUfzmZNRNBq5NprqM6MXbisSq rP+DULOHG0lJXd/9kgnzSrzrblAND0GWor0omm6c0+wmv5e+fOLhzGZjm7zOzgfuEABy EfrYFjcW3IBzwSMs9sbgOeJ77y8uOu5Y7HxeZXjGZXnEXTILq1rFPK51guGEWRnO8mqK Fl40iQX/QBS5ZgxCR5H+2+oJHs4rCVb6WIRs3UE5BrsYv6TcH8ldw/s+ObnC9wRjr8gT JZNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ddH5x5C4Xtp9rpA7ryYSwYalCmUTcgexoa3qISyw2Ug=; b=pk4Gl62lf84sE6KZEYIsiEyzvQgoMOU2trzprVtfmUVqmQyS77Qh/eD9UTNYnUduoe H/r1gYnVh4rTRbJkQ7CSXNpWIC70J4MtsoK1ir9ZEJDvzeLtjUsIDw3UAPyp4aTP5Qhx ndibyDeyE0wWFMigauzzwrxrcnRANogqBz1/fUeL4qKdWD45FFQdY1b8yjWtCARgB9ys B5wYZd+DX6w7cp/D4pV8I7HjsT/ueB1vkhJKqRZ7IJVuYDM78hZULu5kKBLpotL2WhYQ GM9fVE4vVSIcM3YT2b/TbbY8++gIA5X2BQUy6eSx49IYWzF1FCfC8fqo2KOl+5X08RSx aO7g== X-Gm-Message-State: APjAAAUjuTRK8KiLTCXcNqNDxMyt3jsBVR80fjkkaVu/Mi9Pkg/ZCdxk JpBS8YhPSnSuhhuZDn11sek= X-Google-Smtp-Source: APXvYqykivldidC6OTPZpmATBM7ATqQAb23IP4aVg9WLyjsROhNPDhwqIZxuE7cbseWPK8Nr0H/tlQ== X-Received: by 2002:a17:902:27e6:: with SMTP id i35mr142206227plg.190.1561308149084; Sun, 23 Jun 2019 09:42:29 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id l13sm7708993pjq.20.2019.06.23.09.42.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:28 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 08/11] thermal: sun8i: support ahb clocks Date: Sun, 23 Jun 2019 12:42:03 -0400 Message-Id: <20190623164206.7467-9-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094230_924386_39ED8328 X-CRM114-Status: GOOD ( 13.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP H3 has extra clock, so introduce something in ths_thermal_chip/ths_device and adds the process of the clock. This is pre-work for supprt it. Signed-off-by: Yangtao Li --- drivers/thermal/sun8i_thermal.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index ed1c19bb27cf..04f53ffb6a14 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -54,6 +54,7 @@ struct tsensor { }; struct ths_thermal_chip { + bool has_ahb_clk; int sensor_num; int offset; int scale; @@ -69,6 +70,7 @@ struct ths_device { struct regmap *regmap; struct reset_control *reset; struct clk *bus_clk; + struct clk *ahb_clk; struct tsensor sensor[MAX_SENSOR_NUM]; }; @@ -280,6 +282,12 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev) if (IS_ERR(tmdev->bus_clk)) return PTR_ERR(tmdev->bus_clk); + if (tmdev->chip->has_ahb_clk) { + tmdev->ahb_clk = devm_clk_get(&pdev->dev, "ahb"); + if (IS_ERR(tmdev->ahb_clk)) + return PTR_ERR(tmdev->ahb_clk); + } + ret = reset_control_deassert(tmdev->reset); if (ret) return ret; @@ -288,12 +296,18 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev) if (ret) goto assert_reset; - ret = sun50i_ths_calibrate(tmdev); + ret = clk_prepare_enable(tmdev->ahb_clk); if (ret) goto bus_disable; + ret = sun50i_ths_calibrate(tmdev); + if (ret) + goto ahb_disable; + return 0; +ahb_disable: + clk_disable_unprepare(tmdev->ahb_clk); bus_disable: clk_disable_unprepare(tmdev->bus_clk); assert_reset: @@ -401,6 +415,7 @@ static int sun8i_ths_remove(struct platform_device *pdev) { struct ths_device *tmdev = platform_get_drvdata(pdev); + clk_disable_unprepare(tmdev->ahb_clk); clk_disable_unprepare(tmdev->bus_clk); reset_control_assert(tmdev->reset); From patchwork Sun Jun 23 16:42:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8519E17D2 for ; Sun, 23 Jun 2019 16:45:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70D962880C for ; Sun, 23 Jun 2019 16:45:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 606412884E; Sun, 23 Jun 2019 16:45:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 010DF2880C for ; Sun, 23 Jun 2019 16:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=delwVf4j5pxkYPdwvDOUSRhS2DZlyj5OIcFRAaGOy+s=; b=gx/B7kU69g78YZeuSg0KUDl7Jl SerLJKExGpysWaciYXww7LFLfYvmHOiqbw1fJGehou0vw4/H82dUL2uFW2nRMIomrBP1xjRSr6avW L9sGs0IFqr5lH2f1E2hYTw6VQqBoAuLbu0mGxhkOa0o0KpRSN0kmWPu4qXLeGHYBPXudYbuhYcOPI Z2WJg5kgpljJaKc3pDgwA96We1LStE/wH7KwZ9q2t/1QPS8t2LJAayel4/DjpD/TqqVZbnFHEZphF r3JNyhcX+woe2vSVCgkOdddepDJ4Yag3mLmNxut3QrIS5rNTIpe8NBYvJIer3HoaXSLK3d2c716Kv CfAy8sXA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5cd-0006Ba-8x; Sun, 23 Jun 2019 16:45:43 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5ZY-0002kM-Hd for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:34 +0000 Received: by mail-pg1-x543.google.com with SMTP id y72so5774811pgd.8 for ; Sun, 23 Jun 2019 09:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RTcK3pbraTehLFDRf/5iQTqAdMG2KSczJRXJiBCvB5Y=; b=J79n+G0FL6XsNrisl6wbrkk+LaSJR6g3/f6ISU3BTLA9JY3Gqkm4YYdTSvx/+5Kqg7 kbr1y5dzXFGY1CYoZ83vKdhe7nZ7CKTdLOBaDy/ML+spf/jCjKex5kzhqJeI0IPbN3N0 yxwnVWyDo28A2xTdG5uWbE1xAfskgvDsey1vfABp8IHb7J7YnXcj8Y8Zlvaiz49r1b3L fGNKV8818ts9AVqoiVfZU1XtTPsUtfmFVkjgmtVGGiVuSofPy0kZbll+M8ozOW+x+JPa PRBDcTuudkpmeEV4rk5FT8U1nNgL7daeNWgAMoZeaBYmT2mk/vxpb9lzrniT2jLpukwd HhRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RTcK3pbraTehLFDRf/5iQTqAdMG2KSczJRXJiBCvB5Y=; b=Y0CGRCjvqVx14reAibuAm7OnwlfPKImKDIYCo9hFWUqp1E0h+G+41FzttF9/bPrLiI 9eiCzCRaj/hQsgs9DtY8rivDiWfBORzdulV1VEi6kZaw87O6AuK0MLHINSiz/FoUeZVm bw82JqIJY8/XIIJToOFPKeLeaxaEfwuzzDIJr5M/nIGJoyWLXcozIE43s0wTtT7gIyVY uRBDTxBcqjD520dnd7sJde73y7XmlAMKp6mtFj9r43qL8lFEByUv1z9477ZL2R3CYsU/ +sk7HiycdlUOd+7W0mlAKVmgrnHLifr24jqwlWBrG1Xr321JMxxCP5ggyi3491JzX0/N fnng== X-Gm-Message-State: APjAAAVZr6cSZ2NqjEt3T4g2emIdAVQJg6MVKQDy/EXv2GA+pw2Cs1Uv n9K2iNgdV8UyoBHve18wr1Q= X-Google-Smtp-Source: APXvYqzGanD57O3MhuhLaVMM/J9OguOZ9knpULHKCKx5u7OSJ407HPyX7xnw3TY+8qmoUkfWdIvHGw== X-Received: by 2002:a65:418d:: with SMTP id a13mr29100398pgq.332.1561308151893; Sun, 23 Jun 2019 09:42:31 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id w3sm8457242pgl.31.2019.06.23.09.42.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:31 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 09/11] thermal: sun8i: rework for ths calibrate func Date: Sun, 23 Jun 2019 12:42:04 -0400 Message-Id: <20190623164206.7467-10-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094233_308448_29B75157 X-CRM114-Status: GOOD ( 18.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Here, we do something to prepare for the subsequent support of multiple platforms. 1) rename sun50i_ths_calibrate to sun8i_ths_calibrate, because this function should be suitable for all platforms now. 2) introduce calibrate callback to mask calibration method differences. Signed-off-by: Yangtao Li --- drivers/thermal/sun8i_thermal.c | 86 ++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index 04f53ffb6a14..260b24340f5b 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -60,6 +60,8 @@ struct ths_thermal_chip { int scale; int ft_deviation; int temp_data_base; + int (*calibrate)(struct ths_device *tmdev, + u16 *caldata, int callen); int (*init)(struct ths_device *tmdev); int (*irq_ack)(struct ths_device *tmdev); }; @@ -152,45 +154,14 @@ static irqreturn_t sun8i_irq_thread(int irq, void *data) return IRQ_HANDLED; } -static int sun50i_ths_calibrate(struct ths_device *tmdev) +static int sun50i_h6_ths_calibrate(struct ths_device *tmdev, + u16 *caldata, int callen) { - struct nvmem_cell *calcell; struct device *dev = tmdev->dev; - u16 *caldata; - size_t callen; - int ft_temp; - int i, ret = 0; - - calcell = devm_nvmem_cell_get(dev, "calib"); - if (IS_ERR(calcell)) { - if (PTR_ERR(calcell) == -EPROBE_DEFER) - return -EPROBE_DEFER; - /* - * Even if the external calibration data stored in sid is - * not accessible, the THS hardware can still work, although - * the data won't be so accurate. - * - * The default value of calibration register is 0x800 for - * every sensor, and the calibration value is usually 0x7xx - * or 0x8xx, so they won't be away from the default value - * for a lot. - * - * So here we do not return error if the calibartion data is - * not available, except the probe needs deferring. - */ - goto out; - } + int i, ft_temp; - caldata = nvmem_cell_read(calcell, &callen); - if (IS_ERR(caldata)) { - ret = PTR_ERR(caldata); - goto out; - } - - if (!caldata[0] || callen < 2 + 2 * tmdev->chip->sensor_num) { - ret = -EINVAL; - goto out_free; - } + if (!caldata[0] || callen < 2 + 2 * tmdev->chip->sensor_num) + return -EINVAL; /* * efuse layout: @@ -251,7 +222,45 @@ static int sun50i_ths_calibrate(struct ths_device *tmdev) } } -out_free: + return 0; +} + +static int sun8i_ths_calibrate(struct ths_device *tmdev) +{ + struct nvmem_cell *calcell; + struct device *dev = tmdev->dev; + u16 *caldata; + size_t callen; + int ret = 0; + + calcell = devm_nvmem_cell_get(dev, "calib"); + if (IS_ERR(calcell)) { + if (PTR_ERR(calcell) == -EPROBE_DEFER) + return -EPROBE_DEFER; + /* + * Even if the external calibration data stored in sid is + * not accessible, the THS hardware can still work, although + * the data won't be so accurate. + * + * The default value of calibration register is 0x800 for + * every sensor, and the calibration value is usually 0x7xx + * or 0x8xx, so they won't be away from the default value + * for a lot. + * + * So here we do not return error if the calibartion data is + * not available, except the probe needs deferring. + */ + goto out; + } + + caldata = nvmem_cell_read(calcell, &callen); + if (IS_ERR(caldata)) { + ret = PTR_ERR(caldata); + goto out; + } + + tmdev->chip->calibrate(tmdev, caldata, callen); + kfree(caldata); out: return ret; @@ -300,7 +309,7 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev) if (ret) goto bus_disable; - ret = sun50i_ths_calibrate(tmdev); + ret = sun8i_ths_calibrate(tmdev); if (ret) goto ahb_disable; @@ -428,6 +437,7 @@ static const struct ths_thermal_chip sun50i_h6_ths = { .scale = -67, .ft_deviation = SUN50I_H6_FT_DEVIATION, .temp_data_base = SUN50I_H6_THS_TEMP_DATA, + .calibrate = sun50i_h6_ths_calibrate, .init = sun50i_thermal_init, .irq_ack = sun50i_h6_irq_ack, }; From patchwork Sun Jun 23 16:42:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011833 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CFB517D2 for ; Sun, 23 Jun 2019 16:45:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67C1628A8C for ; Sun, 23 Jun 2019 16:45:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5ABB428AD1; Sun, 23 Jun 2019 16:45:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0109D28A8C for ; Sun, 23 Jun 2019 16:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/3iARik4MAfgesQPUnJrefBn8MgSiHmd9AiIeqlIXEw=; b=P3E5bI3DOT8YCpbS0+5BieNs80 xCfX74tfP4cqBjGGkiPnQ588W58IQcvglmwna8Y5iK1gVei/Vt31ueI5o0EgWXkJFxIQiIrN3Nak5 avj6l63WBMGVs45+80yOrQ21gQLQJHM9K8lY4dL0L2ydJAt1/9a9IxfmHQXaMNvAF3yzxg3RQlN2G vvIo/1K96KdIA4xiwAEKXKyBKcuVBcecOJK8NlFqszh44KMKZm6ARzaoYLeBERdB7a7SKcIP98U5a /czQuI6feyrsESa63rXzOYpaZXVNFk1+M/BD6O2LjGobghrC6sc97wK0gZFrDDQFd3hub42v/nPXP 8AClFYwg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5cs-0006Q4-G0; Sun, 23 Jun 2019 16:45:58 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5Za-0002lP-1S for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:35 +0000 Received: by mail-pf1-x42c.google.com with SMTP id q10so6104538pff.9 for ; Sun, 23 Jun 2019 09:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vc2TrqpD10fc/Gfq4unesnc+WEyy7mH5ktLy+6dZnog=; b=na5YZxEqKvs5q15uC5P1TVCCMSkxBW5asCpG+6XNTePIxjvDEvT+nm/nJ7Mhtz5n20 IOL8H362bj7nNRmdZxlMJuiG43M5be4/MzEz/4tbEjzcZIhVOpUlTVZQD3SkHTx+r9gD vhAV2xRiKaGcRlZ0j5RsCsvmR4GdP+CxJnSyGdkB3YcG2lDyALrhAZKPreixUBDpkOPe KbhdYO+xaP7XWzoUy9L27kkSPZymBFpNFsOzgZypoZfhhSN/vKyRxfU630VyVWxq8iV8 Fn+epGdLDRGIJdu/0IBsiiuui42sm5NKERE9jBgfZZyF+QvXmeFWmLs5x5oGd5IgyUFO k15w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Vc2TrqpD10fc/Gfq4unesnc+WEyy7mH5ktLy+6dZnog=; b=MgHxb4dgDDKscK2VpGG3NsYID1Z90SElm8yh14ZuGFnei1xCuvhLoWuAkwRO78q4x4 8uAoE8vifMML7mZFotqwfbSB1rUwkvW3CswvmlSuJdxrCYPpxl9W6zhZ0PCuUpoH8IOD jE3NAWrPsUiApjBJfIkewzrPs9mPVE0cjWj4sHKlMxlrLepmPGRZmIMl3fRML9fxYpDc MD+kItl/WlFQOr7fCdW9PKc6g73xJu+vM5tU2xp6FySB3WPnZjbj7HpMOPjMD+MUzhru q1i5X0u1GiCQMdtm1luhvoZGYumCGf27QhyRBvMLqs07+1GilrWdTCeOoBPbzRIYYSs9 jKGQ== X-Gm-Message-State: APjAAAWtMhRbiaski/4psCIYeqAqwVlBNaG1cQg7PEQ3e7tIbd91egBr Ms9l+IBXI6mYnwlZnuD2V5U= X-Google-Smtp-Source: APXvYqyN7ZztOZynAS2zVYioqIvY15L9IUm9DgxfrduwN8r28+SgkhFt/Fx4DayR43s+eDagPc/BCg== X-Received: by 2002:a17:90a:ac11:: with SMTP id o17mr19898276pjq.134.1561308153126; Sun, 23 Jun 2019 09:42:33 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id j2sm10687361pfn.135.2019.06.23.09.42.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:32 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 10/11] dt-bindings: thermal: add binding document for h3 thermal controller Date: Sun, 23 Jun 2019 12:42:05 -0400 Message-Id: <20190623164206.7467-11-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094234_204844_CBB6514B X-CRM114-Status: GOOD ( 11.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds binding document for allwinner h3 thermal controller. Signed-off-by: Yangtao Li --- .../bindings/thermal/sun8i-thermal.yaml | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/sun8i-thermal.yaml b/Documentation/devicetree/bindings/thermal/sun8i-thermal.yaml index 2c5acc61ed03..1eaf68b5dd5a 100644 --- a/Documentation/devicetree/bindings/thermal/sun8i-thermal.yaml +++ b/Documentation/devicetree/bindings/thermal/sun8i-thermal.yaml @@ -16,6 +16,7 @@ description: |- properties: compatible: enum: + - allwinner,sun8i-h3-ths - allwinner,sun50i-h6-ths reg: @@ -29,13 +30,22 @@ properties: clocks: minItems: 1 - maxItems: 1 + maxItems: 2 clock-names: - const: bus + items: + - const: bus + - const: ahb '#thermal-sensor-cells': - const: 1 + enum: [ 0, 1 ] + description: | + Definition depends on soc version: + + For "allwinner,sun8i-h3-ths", + value must be 0. + For "allwinner,sun50i-h6-ths", + value must be 1. nvmem-cells: items: @@ -55,6 +65,19 @@ required: - '#thermal-sensor-cells' examples: + - | + ths: ths@1c25000 { + compatible = "allwinner,sun8i-h3-ths"; + reg = <0x01c25000 0x400>; + clocks = <&ccu CLK_BUS_THS>, <&ccu CLK_THS>; + clock-names = "bus", "ahb"; + resets = <&ccu RST_BUS_THS>; + interrupts = ; + nvmem-cells = <&tsen_calib>; + nvmem-cell-names = "calib"; + #thermal-sensor-cells = <0>; + }; + - | ths: ths@5070400 { compatible = "allwinner,sun50i-h6-ths"; From patchwork Sun Jun 23 16:42:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 11011835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD2666C5 for ; Sun, 23 Jun 2019 16:46:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA6ED28A8C for ; Sun, 23 Jun 2019 16:46:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E08128AD1; Sun, 23 Jun 2019 16:46:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4312F28A8C for ; Sun, 23 Jun 2019 16:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=l9S4FCU21DACti9jgYQuCP8qRKps9BncpHtEQ8pMqv4=; b=IHOs+TNnP/IwpAH9PPtnnNbRuO mEU8FIYWTb41CkXYuUqcHGmFqAXnJH77KjvvYKZtcpBUCGnbhxMspM1Tnw1sLhefJca8nEGKoKgCY Rplti9NynIaC6KrAfD+SCnrIzvGCKVqDlpNPXheifg5ltmhGwRS96zx4Jx1ntzmlSKglu3nUM1wkI OFMdI5Y+q+wWfbflFZeLs+FEmyIFtWY/Rozh0fsxhPhmRR0FPm/s2LaiFHDzd7bWFoogEq2RRcgsg oZbbMv2JtO7DJRgzxHc3zmAboOOMfeN4Vi1yvu2oNbVuRaQIQ6oEOHDaPOj7f8WqYTqriIm9XznGx 7GLwEedA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hf5dE-0006eu-7i; Sun, 23 Jun 2019 16:46:20 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hf5Za-0002mC-OU for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2019 16:42:36 +0000 Received: by mail-pg1-x541.google.com with SMTP id z19so2825428pgl.12 for ; Sun, 23 Jun 2019 09:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Wt7RMWJEU5nf2APAW5wITney1vGRi8ExyzwA2ly5tbM=; b=DO56xL8GNC3pRjMbczek/js2aH+Jr00XhhADU2CusMADs20FUQ6om0QfFNRcH7bIok utY8iKwz2gs/7WHR18tlrl+XRM9KtdS9MZyCglgz5ZWErisPeGVp+BPEcw81Ezw1KyjP +I7gFX+cYEvLyjmwJRHb04L6mRZ4LjmdVX+GURXCGE4Ky2HFiZkXGwRma8nQVRg7xzb1 OpjjtLiiCN+Zc/sg6Vk26H04UbcX2a5L9ZDyAyFJkne9LJuc3SjKpjccxQ4NfVaSg62X sX8QGDvadx5+1F6N6uKmqbh/oIFj9SbUUmdqZyIvf9VMIoiCKn8bIS68Io+mfdDuE05u 4YKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Wt7RMWJEU5nf2APAW5wITney1vGRi8ExyzwA2ly5tbM=; b=L51O/MKIA3P0KBq22DMCRaQRLksdWce3+Y/IrETZ7S0VU4O0diAZtTjWYpRX4o+h/y Yfhu/4nAS+/fpcl7nAGhGYiCPnD6HLfE6tHgluWPUiXpzeDw6gMTxOI1vK8UtrKKPmxy m76G2y9ixoNh9+O7QU3S122St9kZuZxmAvjxkLcdhRHdi4WofeEUOXdZvzJfpyCCy3MY 0S/KPl1Wv4qVsJEL/JvhAEqTl0MhiQWcANCNheP5jFiNdsqzRZGV/nP8XKEbh3VciqwG /THa9IJFSODd4MkPkS5xJ2MqTEUmPxFysYumw+sl/ZhR+45IcXonMWrNiZRwzCVWHWOw FyMA== X-Gm-Message-State: APjAAAV47xBAknRSJaKFro4Q0N4aqTSnSNeogdINhpXhovXDswnEyGV1 9+fReQG94HjDbrJhpEtzgiM= X-Google-Smtp-Source: APXvYqyPdz3cE/WXdIcDs7kmAR8F/niCfqMamQH54dQcogysOpQv1BP/blKrSSByCMUg+zO2djgwVA== X-Received: by 2002:a17:90a:7f02:: with SMTP id k2mr19642846pjl.78.1561308154262; Sun, 23 Jun 2019 09:42:34 -0700 (PDT) Received: from localhost (68.168.130.77.16clouds.com. [68.168.130.77]) by smtp.gmail.com with ESMTPSA id y17sm4923619pfe.148.2019.06.23.09.42.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 09:42:33 -0700 (PDT) From: Yangtao Li To: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab+samsung@kernel.org, linus.walleij@linaro.org, nicolas.ferre@microchip.com, paulmck@linux.ibm.com Subject: [PATCH v4 11/11] thermal: sun8i: add thermal driver for h3 Date: Sun, 23 Jun 2019 12:42:06 -0400 Message-Id: <20190623164206.7467-12-tiny.windzz@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190623164206.7467-1-tiny.windzz@gmail.com> References: <20190623164206.7467-1-tiny.windzz@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190623_094235_349924_67BB4D5B X-CRM114-Status: GOOD ( 14.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yangtao Li , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the support for allwinner h3 thermal sensor. Signed-off-by: Yangtao Li --- drivers/thermal/sun8i_thermal.c | 72 +++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index 260b24340f5b..c8ee291f3b17 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -27,6 +27,14 @@ #define TEMP_TO_REG 672 #define CALIBRATE_DEFAULT 0x800 +#define SUN8I_THS_CTRL0 0x00 +#define SUN8I_THS_CTRL2 0x40 +#define SUN8I_THS_IC 0x44 +#define SUN8I_THS_IS 0x48 +#define SUN8I_THS_MFC 0x70 +#define SUN8I_THS_TEMP_CALIB 0x74 +#define SUN8I_THS_TEMP_DATA 0x80 + #define SUN50I_THS_CTRL0 0x00 #define SUN50I_H6_THS_ENABLE 0x04 #define SUN50I_H6_THS_PC 0x08 @@ -36,6 +44,9 @@ #define SUN50I_H6_THS_TEMP_CALIB 0xa0 #define SUN50I_H6_THS_TEMP_DATA 0xc0 +#define SUN8I_THS_CTRL0_T_ACQ0(x) (GENMASK(15, 0) & (x)) +#define SUN8I_THS_CTRL2_T_ACQ1(x) ((GENMASK(15, 0) & (x)) << 16) + #define SUN50I_THS_CTRL0_T_ACQ(x) ((GENMASK(15, 0) & (x)) << 16) #define SUN50I_THS_FILTER_EN BIT(2) #define SUN50I_THS_FILTER_TYPE(x) (GENMASK(1, 0) & (x)) @@ -121,6 +132,21 @@ static const struct regmap_config config = { .fast_io = true, }; +static int sun8i_h3_irq_ack(struct ths_device *tmdev) +{ + int state, ret = 0; + + regmap_read(tmdev->regmap, SUN8I_THS_IS, &state); + + if (state & BIT(8)) { + regmap_write(tmdev->regmap, SUN8I_THS_IS, + BIT(8)); + ret |= BIT(1); + } + + return ret; +} + static int sun50i_h6_irq_ack(struct ths_device *tmdev) { int i, state, ret = 0; @@ -154,6 +180,14 @@ static irqreturn_t sun8i_irq_thread(int irq, void *data) return IRQ_HANDLED; } +static int sun8i_h3_ths_calibrate(struct ths_device *tmdev, + u16 *caldata, int callen) +{ + regmap_write(tmdev->regmap, SUN8I_THS_TEMP_CALIB, *caldata); + + return 0; +} + static int sun50i_h6_ths_calibrate(struct ths_device *tmdev, u16 *caldata, int callen) { @@ -325,6 +359,32 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev) return ret; } +static int sun8i_h3_thermal_init(struct ths_device *tmdev) +{ + /* average over 4 samples */ + regmap_write(tmdev->regmap, SUN8I_THS_MFC, + SUN50I_THS_FILTER_EN | + SUN50I_THS_FILTER_TYPE(1)); + /* + * period = (x + 1) * 4096 / clkin; ~10ms + * enable data interrupt + */ + regmap_write(tmdev->regmap, SUN8I_THS_IC, + SUN50I_H6_THS_PC_TEMP_PERIOD(58) | BIT(8)); + /* + * clkin = 24MHz + * T acquire = clkin / (x + 1) + * = 20us + * enable sensor + */ + regmap_write(tmdev->regmap, SUN8I_THS_CTRL0, + SUN8I_THS_CTRL0_T_ACQ0(479)); + regmap_write(tmdev->regmap, SUN8I_THS_CTRL2, + SUN8I_THS_CTRL2_T_ACQ1(479) | BIT(0)); + + return 0; +} + static int sun50i_thermal_init(struct ths_device *tmdev) { int val; @@ -431,6 +491,17 @@ static int sun8i_ths_remove(struct platform_device *pdev) return 0; } +static const struct ths_thermal_chip sun8i_h3_ths = { + .sensor_num = 1, + .offset = -1794, + .scale = -121, + .has_ahb_clk = true, + .temp_data_base = SUN8I_THS_TEMP_DATA, + .calibrate = sun8i_h3_ths_calibrate, + .init = sun8i_h3_thermal_init, + .irq_ack = sun8i_h3_irq_ack, +}; + static const struct ths_thermal_chip sun50i_h6_ths = { .sensor_num = 2, .offset = -2794, @@ -443,6 +514,7 @@ static const struct ths_thermal_chip sun50i_h6_ths = { }; static const struct of_device_id of_ths_match[] = { + { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths }, { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths }, { /* sentinel */ }, };