From patchwork Tue Sep 25 09:02:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 147406 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp472060lji; Tue, 25 Sep 2018 02:03:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV63KWZHafdoXInwzvUdzbXFXSmsDgy++JJOabS1+M+qlBf3jVTtQSsC3+pNjTMeVBW/FV142 X-Received: by 2002:a62:798f:: with SMTP id u137-v6mr35972pfc.23.1537866224435; Tue, 25 Sep 2018 02:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537866224; cv=none; d=google.com; s=arc-20160816; b=C6YM828EnCEAEijZ4ZhFGz0teSatyfuNkhyIlj0J7Nk+Lu4m35ToSIPzpqnGH63wqd fvqvacw40pdMe+bb+KMCHs9eeKYC+otbndXPbMeORKRSPaIds5UeksUTddXt4mMC5j9W wOh+cEP3tJRbtVhLt6dPcCGEwVfdA8dXSHHUGz5L9PilAjtpxMfFnYODPLqVp5xvlYor /T7eYz0d8fP4vmMJWZwFQQF+b7M6Lz5oVq9A5SS94z/oPa6qh/iJuzntnmpcgp/AWsEa 4OO6Vj5vtxuhOMKKEN/Y3asNRmgKtAKzmnfQGEN/6eEZh5fZwVXjkI7/eXggs4V/s/8M 5OqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=OZ13DAcracUk8ECXRhZzoH+2ruBFRvOw19LoCvex9TQ=; b=qyjY9ENbziEWA9Ae36wcx9upQqUTRH4jURCJKWGmuhaz3szt5gO/8A+42av7pbOgh8 7jAbZg84xvzuOdfC76xyvm06dtfEWCrnB2XTv0aQ8wNIdjH7kVTsw1pC4ztb5jAUY0zy +WwyeymENtqTsA6R11jOh7XSJ7MYwj2fKwXY9QykK9yeHhbxXkqxmwPcXoZm3Scz9+PQ pO2PbSwco5nS4u8RsQN85swBwkwxTEZZCBMF2nmtkjjVIcj7L8KAzb7Bj1j/k0s8bWkc zEqwH0hoxs0RTg2aXQYWzhl6aJmyH1BLRYnECJ18g2MH0dnCrDbLNCHbJ5yOaF1v9F0f 6Gqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TX+zyk2y; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 12-v6si1893959pgv.351.2018.09.25.02.03.43; Tue, 25 Sep 2018 02:03:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TX+zyk2y; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728328AbeIYPKP (ORCPT + 10 others); Tue, 25 Sep 2018 11:10:15 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:34164 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728317AbeIYPKO (ORCPT ); Tue, 25 Sep 2018 11:10:14 -0400 Received: by mail-wm1-f65.google.com with SMTP id j25-v6so12031985wmc.1 for ; Tue, 25 Sep 2018 02:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OZ13DAcracUk8ECXRhZzoH+2ruBFRvOw19LoCvex9TQ=; b=TX+zyk2yMB85ok2KiqzJvZnSaiL9mgIg40Cql/dIOJgkjKtACF146jhkyKkuqVe5MW MMk8FW7QNx98TzIo+hNdYV5yDiVV1X0bV5+59jVE2ln28Y1Y74DobGx55stxdKmXOSOI lc01di//q6BRsnZchp2qAOhPKhA50VB9ID/pY= 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=OZ13DAcracUk8ECXRhZzoH+2ruBFRvOw19LoCvex9TQ=; b=HbLer+wYurkGwbldEKjYBsZg5XEjW9Th50KtIkxVYhLTY3jBLLC3i4004lkXkYJjcT CAZKqFt3y3dNKxfZkg2VC4EYUsKtyYZIkbrZZ8URjtgycLStGWxJ6V5uvvxFOIyN1SXG sP7U33uEe9qDylawCfz8OROwXMGm28lm0AZtmZfM8IgyCW43nb2PSrKgVL9iT30I76SF 71MRUBe52TgxqyUW+QUbYbQlGkbzn61sGIZmEerCu57KkzOTF8t2ZbZ6TEE2GgMizfhB jDQ655A8iHpyfgDiRZc6SVi2wPphqgq2no2mSIUCD+CS/tdWtkIZER+F2IPDmTHl/8jH o+jw== X-Gm-Message-State: ABuFfoirIc+1B+aad/8V4PYdPT6jTsS8epmWXkvpeGNEWT2LwxjnAyk+ 3uA3T8EgfbNCoi3JPXuGg00pXw== X-Received: by 2002:a1c:f11a:: with SMTP id p26-v6mr68368wmh.92.1537866220410; Tue, 25 Sep 2018 02:03:40 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.03.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:03:35 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 01/14] thermal/drivers/hisi: Change the platform data pointer to sensor ops Date: Tue, 25 Sep 2018 11:02:59 +0200 Message-Id: <1537866192-12320-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Group the temperature sensor specific ops into a single structure and assign it to hisi thermal data structure. Change the platform data pointer to reference the specific sensor ops instead of the probe functions. Moving out those allow to split the code to self-encapsulate the sensor object. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 60 ++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 26 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 761d055..9794cfe 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -64,11 +64,18 @@ struct hisi_thermal_sensor { uint32_t thres_temp; }; -struct hisi_thermal_data { +struct hisi_thermal_data; + +struct hisi_thermal_ops { int (*get_temp)(struct hisi_thermal_data *data); int (*enable_sensor)(struct hisi_thermal_data *data); int (*disable_sensor)(struct hisi_thermal_data *data); int (*irq_handler)(struct hisi_thermal_data *data); + int (*probe)(struct hisi_thermal_data *data); +}; + +struct hisi_thermal_data { + const struct hisi_thermal_ops *ops; struct platform_device *pdev; struct clk *clk; struct hisi_thermal_sensor sensor; @@ -374,11 +381,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) struct resource *res; int ret; - data->get_temp = hi6220_thermal_get_temp; - data->enable_sensor = hi6220_thermal_enable_sensor; - data->disable_sensor = hi6220_thermal_disable_sensor; - data->irq_handler = hi6220_thermal_irq_handler; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); data->regs = devm_ioremap_resource(dev, res); if (IS_ERR(data->regs)) { @@ -409,11 +411,6 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data) struct device *dev = &pdev->dev; struct resource *res; - data->get_temp = hi3660_thermal_get_temp; - data->enable_sensor = hi3660_thermal_enable_sensor; - data->disable_sensor = hi3660_thermal_disable_sensor; - data->irq_handler = hi3660_thermal_irq_handler; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); data->regs = devm_ioremap_resource(dev, res); if (IS_ERR(data->regs)) { @@ -435,7 +432,7 @@ static int hisi_thermal_get_temp(void *__data, int *temp) struct hisi_thermal_data *data = __data; struct hisi_thermal_sensor *sensor = &data->sensor; - *temp = data->get_temp(data); + *temp = data->ops->get_temp(data); dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n", sensor->id, *temp, sensor->thres_temp); @@ -453,7 +450,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) struct hisi_thermal_sensor *sensor = &data->sensor; int temp = 0; - data->irq_handler(data); + data->ops->irq_handler(data); hisi_thermal_get_temp(data, &temp); @@ -502,14 +499,30 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, return 0; } +static const struct hisi_thermal_ops hi6220_ops = { + .get_temp = hi6220_thermal_get_temp, + .enable_sensor = hi6220_thermal_enable_sensor, + .disable_sensor = hi6220_thermal_disable_sensor, + .irq_handler = hi6220_thermal_irq_handler, + .probe = hi6220_thermal_probe, +}; + +static const struct hisi_thermal_ops hi3660_ops = { + .get_temp = hi3660_thermal_get_temp, + .enable_sensor = hi3660_thermal_enable_sensor, + .disable_sensor = hi3660_thermal_disable_sensor, + .irq_handler = hi3660_thermal_irq_handler, + .probe = hi3660_thermal_probe, +}; + static const struct of_device_id of_hisi_thermal_match[] = { { .compatible = "hisilicon,tsensor", - .data = hi6220_thermal_probe + .data = &hi6220_ops, }, { .compatible = "hisilicon,hi3660-tsensor", - .data = hi3660_thermal_probe + .data = &hi3660_ops, }, { /* end */ } }; @@ -527,7 +540,6 @@ static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, static int hisi_thermal_probe(struct platform_device *pdev) { struct hisi_thermal_data *data; - int (*platform_probe)(struct hisi_thermal_data *); struct device *dev = &pdev->dev; int ret; @@ -538,13 +550,9 @@ static int hisi_thermal_probe(struct platform_device *pdev) data->pdev = pdev; platform_set_drvdata(pdev, data); - platform_probe = of_device_get_match_data(dev); - if (!platform_probe) { - dev_err(dev, "failed to get probe func\n"); - return -EINVAL; - } + data->ops = of_device_get_match_data(dev); - ret = platform_probe(data); + ret = data->ops->probe(data); if (ret) return ret; @@ -555,7 +563,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) return ret; } - ret = data->enable_sensor(data); + ret = data->ops->enable_sensor(data); if (ret) { dev_err(dev, "Failed to setup the sensor: %d\n", ret); return ret; @@ -583,7 +591,7 @@ static int hisi_thermal_remove(struct platform_device *pdev) hisi_thermal_toggle_sensor(sensor, false); - data->disable_sensor(data); + data->ops->disable_sensor(data); return 0; } @@ -593,7 +601,7 @@ static int hisi_thermal_suspend(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - data->disable_sensor(data); + data->ops->disable_sensor(data); return 0; } @@ -602,7 +610,7 @@ static int hisi_thermal_resume(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - return data->enable_sensor(data); + return data->ops->enable_sensor(data); } #endif From patchwork Tue Sep 25 09:03:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 147409 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp472341lji; Tue, 25 Sep 2018 02:04:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV60ns0UtqkbHANxKx15//y15YErHG0skkm1TC/xsQeQgK/gVqsjf7D4ZZsOiFPy42Rt6PmpW X-Received: by 2002:a17:902:b287:: with SMTP id u7-v6mr71488plr.123.1537866243118; Tue, 25 Sep 2018 02:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537866243; cv=none; d=google.com; s=arc-20160816; b=B1Pa9IOF6Pk+mWrtVa2qbNjAgwjOyfa4xk69aNxNMtEDdAS0C4dxnXiHGiVSHWZH1+ /fxw7mpitUP17zCAtyIaXzbpyTQJojhiud2k24MBf18K6gtK1OoIvudBNlo57P6qxtiF wGaFUs/TTvCLQFs9Fx8F49RNumkF9Fy+6Z0cltthxOVDScQp+CilbEuqzzZkHUMwd5ea 9yWQ6dtTIX11kwO6jw1WYAIW/sxPNVofDxwvvE7JEXcSqTaLVkgaA0xgfWTYcT4FR4ic psSN+jxYPU0rnTLn1lf1wPVvc3qaUEY7MqH3B7kLflpK5GgDUvp+ah4oVysPRaAeA7Pj nFPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=n7P2OSw8y61wcHZXfde/sCT0rh4Lfv8tdnBhTgzGYnU=; b=s5IwoeSXnQh1jXeg1SgMMRSnjJ/q9Tgj86MHIVu9CnR7jFPuJ6Upof5wCI/PjqEJHN O5ZvjJIyyONfeyLr+v029KKgNbTZ3n+IOM78UTZSxN7VobKy+xEJz54C7VrE0Iwap7YN qqb+3eAalcVm2+CeJa2qAQU8mD1Y1T7v5Wven8JbWGJeZoU5qdHK0FJrKjfVD5Aej8wC 9zECCoe1tnk0GPcZmPZi7TbpYMSAiYkUKV7d+zIuQQnA0HGusPOLNEmww1qbR3kaFZQ+ SyslS5gGUtLKKtPcFK5lyYJqsDgiwizbN66nhVEVuu4NeE1CWlyzyYKV+VNVyb2GjV8o KYoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LQ/xRaZn"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb8-v6si1602909plb.178.2018.09.25.02.04.02; Tue, 25 Sep 2018 02:04:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LQ/xRaZn"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728659AbeIYPKd (ORCPT + 10 others); Tue, 25 Sep 2018 11:10:33 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36461 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbeIYPKd (ORCPT ); Tue, 25 Sep 2018 11:10:33 -0400 Received: by mail-wr1-f66.google.com with SMTP id e1-v6so22478473wrt.3 for ; Tue, 25 Sep 2018 02:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n7P2OSw8y61wcHZXfde/sCT0rh4Lfv8tdnBhTgzGYnU=; b=LQ/xRaZnZ/dByBF9rTFaqMOVQLxUFJsdsQuNwcwYXVMOiE7ZzLbROcZKTmIbOpZ7TN AFsSF6M724qkJoYhG7DpaOM+diUc+jLwuKIRT6vYf8jSkGcQ/mOc6zEjdMH5c8j2Kgyd bpbUEU+Zci6i7DYhWpNqC+AEv/rWss5sWztRg= 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=n7P2OSw8y61wcHZXfde/sCT0rh4Lfv8tdnBhTgzGYnU=; b=fpu7F0aApoJ6sQ+EUXXKTX/O1+5IGJ9mMv6Zk3qD2NsJvdoHdnstuG5BF9S8DkALCh 3cYRmdyqfdIIDpgvS+XSVPIbGDwz6+z61+vNRLdLON3D3VBGyxYJngoM6cL+OAhOmYVa gAk2pz8T1sj/O9mWatKwzzcELl+VNpyK9gU5b54krCs3ipA/3E9DlO4UulrXxOf/CW63 J5exDniiIOJGpXyIc4kbhPtHosOmLKjojze+rDtW4VQtRByGAxlBE+FgZPnqge+SXqXI K+gv7SAH/DR0UNThcebAgqSaBkQ+JMAju1Ow/FXIhBe7H4+ugpCGOm6+C4bQgLr/MXVi djhg== X-Gm-Message-State: ABuFfogJ/I05kmC60AYclxIx3wvTft/GY655+X34xP3qYeXCqA7ta9Ty wsS0lsAMnZPg3IndlfE/H6SIyg== X-Received: by 2002:adf:8425:: with SMTP id 34-v6mr12377wrf.153.1537866239922; Tue, 25 Sep 2018 02:03:59 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.03.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:03:52 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 04/14] thermal/drivers/hisi: Factor out the probe functions Date: Tue, 25 Sep 2018 11:03:02 +0200 Message-Id: <1537866192-12320-5-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The hi6220 and the hi3660 probe functions are doing almost the same operations, they can share 90% of their code. Factor out the probe functions by moving the common code in the common probe function. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 567fde6..7287818 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -391,16 +391,8 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) { struct platform_device *pdev = data->pdev; struct device *dev = &pdev->dev; - struct resource *res; int ret; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - data->regs = devm_ioremap_resource(dev, res); - if (IS_ERR(data->regs)) { - dev_err(dev, "failed to get io address\n"); - return PTR_ERR(data->regs); - } - data->clk = devm_clk_get(dev, "thermal_clk"); if (IS_ERR(data->clk)) { ret = PTR_ERR(data->clk); @@ -409,10 +401,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) return ret; } - data->irq = platform_get_irq(pdev, 0); - if (data->irq < 0) - return data->irq; - data->sensor.id = HI6220_DEFAULT_SENSOR; return 0; @@ -420,21 +408,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) static int hi3660_thermal_probe(struct hisi_thermal_data *data) { - struct platform_device *pdev = data->pdev; - struct device *dev = &pdev->dev; - struct resource *res; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - data->regs = devm_ioremap_resource(dev, res); - if (IS_ERR(data->regs)) { - dev_err(dev, "failed to get io address\n"); - return PTR_ERR(data->regs); - } - - data->irq = platform_get_irq(pdev, 0); - if (data->irq < 0) - return data->irq; - data->sensor.id = HI3660_DEFAULT_SENSOR; return 0; @@ -553,6 +526,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) { struct hisi_thermal_data *data; struct device *dev = &pdev->dev; + struct resource *res; int ret; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); @@ -564,6 +538,17 @@ static int hisi_thermal_probe(struct platform_device *pdev) data->sensor.data = data; data->ops = of_device_get_match_data(dev); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + data->regs = devm_ioremap_resource(dev, res); + if (IS_ERR(data->regs)) { + dev_err(dev, "failed to get io address\n"); + return PTR_ERR(data->regs); + } + + data->irq = platform_get_irq(pdev, 0); + if (data->irq < 0) + return data->irq; + ret = data->ops->probe(data); if (ret) return ret; From patchwork Tue Sep 25 09:03:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 147410 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp472725lji; Tue, 25 Sep 2018 02:04:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV637r0gfn1JvS7+Ogss04KaIETQugITeHcarCXYMjBlQPvFrPOTYcMASROo/ukw7OSQoSH/E X-Received: by 2002:a62:7616:: with SMTP id r22-v6mr125529pfc.14.1537866264604; Tue, 25 Sep 2018 02:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537866264; cv=none; d=google.com; s=arc-20160816; b=Vwt9ajmevBLTAaVuLz0m1ODQ/7tUeB43yJkLf1bvaFIq/7quIkXmek8n+0EBnGBUSU kk0gtpxlCv1nhtGMz3fuBLT1pvSyt15S8qhfnXkji8BSZcFBhtoGgDV8KgmtCnI1Y3rB weJ+hrwkKEmChcSKfxliHpiQUBOVFW8VGPsdxEpDIneQq49nCeAQTZ4OHx/ydoI6HOsq 0qPdRDknVmAU1QX9T65RXFI7GmmvhZWWk7OLs4TimXUQtVGhEmgWI8iRFSpVWDK3gIyR Iv0WMENuDp+y3isJDCEK6jOpL/rI1jYHRGvCJwYXxuap8AtBzAYwfEZkgt7wkpP439Qw WMYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=B/n+YtvzBVLiSdVatyBy/SAfk8TXmG/YGKWWQu5FHyA=; b=dQ1SJLj5088UNjU2Fxud7EyNCi+o0q8oCNTnh53fi/gU6xYGB2q7cBhoFzqdiwRg+5 Unskf5BF3oOZF8lW/O9SY2EUqcm1aWmguPsWjuvUT3M6ef8LP0yJNAoAmI+zmqVrdjGU j7JInQlc/fkFhezby0oIT+zB3H7Yw3e2HbYuBMPXX+JxTe+GZc9pu92I/dvyNgxaOr87 h6BxFWr3fk8LHGtfxIjAaDsa17u0JD77L3kn1yPMgFVzhJoPoe3M4cMLwCuD9B/BzFYk 7RJw6XAawYhVGb9AuNSnE1/ZlXMA/rxjyVi4IMkzprkyLoJpHVNH94X050smfmFrTpgt ePvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KM+fLMLg; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15-v6si1932374pgr.336.2018.09.25.02.04.24; Tue, 25 Sep 2018 02:04:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KM+fLMLg; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbeIYPKy (ORCPT + 10 others); Tue, 25 Sep 2018 11:10:54 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33445 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727678AbeIYPKt (ORCPT ); Tue, 25 Sep 2018 11:10:49 -0400 Received: by mail-wr1-f67.google.com with SMTP id f10-v6so1444222wrs.0 for ; Tue, 25 Sep 2018 02:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B/n+YtvzBVLiSdVatyBy/SAfk8TXmG/YGKWWQu5FHyA=; b=KM+fLMLgAtVQ6xfbHs0UQ7I/JbpTkxZz5SZVWDJdJ+JmlMxOk9U46qFHjE/DWvHi1p OokmN5ZIS8bWWyoEPYrmf42HIgs4P8DEqvVivJBZinAowF0rt4V92+qC2ynHUF62dcEb OzQoR0KNoHJWvpOCTkwgX8ZvGe6hYsgMDhcVk= 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=B/n+YtvzBVLiSdVatyBy/SAfk8TXmG/YGKWWQu5FHyA=; b=J2WcM1ipLec3KnbcKBwMeLOjAKJIrT86E4h+sEuRwc6NbVQZoF+d3/+bAdFew2Bdab 4c0sVbW0r7kFgCV2eT31p91E4c1GZJN0P9NhkS4/qoLpINcxYCNl+ZVLhQWatXArl4r/ CqIdVroBnUx7Tt9ouumS9TnxSeODW8gYO42Uvjl7c3RhOOHyyQaiL5ugYjHPlKKrfRv2 JW2geFuivEhdET33uPN/pP5uWIYzev9hOn8RisS9duurZKwzS8wJzBmDEKYVoTp20hae bl+pjcrW17SWluGeXkQ7ZrpnwotGSTDnJohZbEcAnVz+v0F6qeAstVnS/jNG6lscMAzd bWFQ== X-Gm-Message-State: ABuFfogvtD6MsO2O4qEwOnyHqoFP/XDVqSGfZsQ0i9xfyFE0xFeeD8CW FGTC+qBM11X+A8kOfjKKUzshzQ== X-Received: by 2002:a5d:5391:: with SMTP id d17-v6mr11507wrv.191.1537866254938; Tue, 25 Sep 2018 02:04:14 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:03 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 05/14] thermal/drivers/hisi: Prepare to support multiple sensors Date: Tue, 25 Sep 2018 11:03:03 +0200 Message-Id: <1537866192-12320-6-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Convert the 'sensor' field to a pointer and propagate the change in the file. Havintg a pointer, gives us the opportunity to define multiple sensors. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 7287818..87b82fb 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -77,10 +77,11 @@ struct hisi_thermal_ops { struct hisi_thermal_data { const struct hisi_thermal_ops *ops; - struct hisi_thermal_sensor sensor; + struct hisi_thermal_sensor *sensor; struct platform_device *pdev; struct clk *clk; void __iomem *regs; + int nr_sensors; int irq; }; @@ -401,14 +402,29 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) return ret; } - data->sensor.id = HI6220_DEFAULT_SENSOR; + data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); + if (!data->sensor) + return -ENOMEM; + + data->sensor[0].id = HI6220_DEFAULT_SENSOR; + data->sensor[0].data = data; + data->nr_sensors = 1; return 0; } static int hi3660_thermal_probe(struct hisi_thermal_data *data) { - data->sensor.id = HI3660_DEFAULT_SENSOR; + struct platform_device *pdev = data->pdev; + struct device *dev = &pdev->dev; + + data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); + if (!data->sensor) + return -ENOMEM; + + data->sensor[0].id = HI3660_DEFAULT_SENSOR; + data->sensor[0].data = data; + data->nr_sensors = 1; return 0; } @@ -433,7 +449,7 @@ static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) { struct hisi_thermal_data *data = dev; - struct hisi_thermal_sensor *sensor = &data->sensor; + struct hisi_thermal_sensor *sensor = &data->sensor[0]; int temp = 0; data->ops->irq_handler(sensor); @@ -444,7 +460,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", temp, sensor->thres_temp); - thermal_zone_device_update(data->sensor.tzd, + thermal_zone_device_update(data->sensor[0].tzd, THERMAL_EVENT_UNSPECIFIED); } else { @@ -535,7 +551,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) data->pdev = pdev; platform_set_drvdata(pdev, data); - data->sensor.data = data; data->ops = of_device_get_match_data(dev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -553,13 +568,13 @@ static int hisi_thermal_probe(struct platform_device *pdev) if (ret) return ret; - ret = hisi_thermal_register_sensor(pdev, &data->sensor); + ret = hisi_thermal_register_sensor(pdev, &data->sensor[0]); if (ret) { dev_err(dev, "failed to register thermal sensor: %d\n", ret); return ret; } - ret = data->ops->enable_sensor(&data->sensor); + ret = data->ops->enable_sensor(&data->sensor[0]); if (ret) { dev_err(dev, "Failed to setup the sensor: %d\n", ret); return ret; @@ -575,7 +590,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) } } - hisi_thermal_toggle_sensor(&data->sensor, true); + hisi_thermal_toggle_sensor(&data->sensor[0], true); return 0; } @@ -583,11 +598,11 @@ static int hisi_thermal_probe(struct platform_device *pdev) static int hisi_thermal_remove(struct platform_device *pdev) { struct hisi_thermal_data *data = platform_get_drvdata(pdev); - struct hisi_thermal_sensor *sensor = &data->sensor; + struct hisi_thermal_sensor *sensor = &data->sensor[0]; hisi_thermal_toggle_sensor(sensor, false); - data->ops->disable_sensor(&data->sensor); + data->ops->disable_sensor(sensor); return 0; } @@ -597,7 +612,7 @@ static int hisi_thermal_suspend(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - data->ops->disable_sensor(&data->sensor); + data->ops->disable_sensor(&data->sensor[0]); return 0; } @@ -606,7 +621,7 @@ static int hisi_thermal_resume(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - return data->ops->enable_sensor(&data->sensor); + return data->ops->enable_sensor(&data->sensor[0]); } #endif From patchwork Tue Sep 25 09:03:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 147411 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp472826lji; Tue, 25 Sep 2018 02:04:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV616Ypl12Oc7ak14dAMGzNTHapaAjYKqpHA5qaHGO6xg9KxEqtN45T5RF+UWeDzCKhBO0qaw X-Received: by 2002:a63:5c5d:: with SMTP id n29-v6mr55333pgm.253.1537866270670; Tue, 25 Sep 2018 02:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537866270; cv=none; d=google.com; s=arc-20160816; b=m8eXiBXuXlZ+6DO61PfA2hCh4CZ1ZLbVUmviQrukGLDJKtsEcbpil98M9x61tsjHJN 21oGFTS7mPO8MTywYOoH1yWf2WOmEPRUxH8RoDaEo4ccHRthKkBNECF9swvKUI7vrR7L rzDacJTQdd01RqRNP8EjSrdHa53/Iwqtb4XyoqX632yDvbktN0LgcQQzAUCniEXb5qLZ 009RCZzB8Wn8RWx+ld9z8l5Xa6iz0BnUL+7R6oFPQTx9vTL/I3AKJkIfVOn4PTe81buN eouyOufO7SJO+OyxsANecPxkT+sCRVn7GlEk6HZCeNNixFSkoMbchMUEuHb/ZL4lavTm KhQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=WEayJ7v/hmTPrXvagArEZzBi0kAZmXnqnjkohn08PO0=; b=hyjziWwur3tZ0z+Ds1xh841hZHbgaKCWQ6ZwHRhdnW3gdLGj/b8I49jxvq9itXTM9Q hVfGXqCQvZXHvkNaqyo3aiRXBpz4zUMfLB6u4kkrhwog4n6ZrBHkalYF9dZS5uFKL8mb RyNWmYxFJMuIhNwfcg6BySY9d87PvGO0NUowaJ31aNqgq8iz00bYRblJwg/jeyBvASR9 X6vXKT+NZkl37KPdG0uBFsf0yIWYwCtjZKGhYsAeWuPi1vazuzX0eGowyTEcyc0Rn3Rp IHBPQPwvXdy2m+Od68OjXUAqcyJUveqRnpxKCKEJnd8Qi2JcTXxnEt/fmnMmy2tvOuLN 5/KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sb0oe1lb; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15-v6si1932374pgr.336.2018.09.25.02.04.30; Tue, 25 Sep 2018 02:04:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sb0oe1lb; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727767AbeIYPLB (ORCPT + 10 others); Tue, 25 Sep 2018 11:11:01 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35565 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727606AbeIYPLB (ORCPT ); Tue, 25 Sep 2018 11:11:01 -0400 Received: by mail-wr1-f68.google.com with SMTP id o16so9159722wrx.2 for ; Tue, 25 Sep 2018 02:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WEayJ7v/hmTPrXvagArEZzBi0kAZmXnqnjkohn08PO0=; b=Sb0oe1lbClXkht5v1ucQ3Geuyw1Ij5+Gor0f/HIPYD6vunyMzaHIsQXNOU94M6JgPR /xx/ji5DaC/y69kOUsBpzHZwzBe+f6wfR7nTUaRL1GqcYR/Qszu4BTwADC/H6Sz5Ctp8 oOPFPbXb2d2JxKGgMgBxIA2m5jg18jipV/6E0= 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=WEayJ7v/hmTPrXvagArEZzBi0kAZmXnqnjkohn08PO0=; b=L5MkF73s6ggOxRs5Y8mBIOrmfe8JUGvh7dQHCdVGLxKnjLjN3hCQhg6PF2Gxrg+SSV bop6RYFuC7Ivou+4IRGJvqorEoN12Ihsp4Zkmk/L6gLdsJhQAe1l2nLbFc574nUH59ot n+d2CQ/WH+nTZkHhUBwZzHxX/VLC32zrx+oIWY5lGQV6doLBGt1eqyVSNDB0HHevGsCl rVLgn7nHZ1+O39LvE8ZmYptPof2QAzVS9nQi+pw+3RZJd095sM7ZUZ0poOlg9adeGuOU mDGKHny78olV8P05Er5Z8MTI9VwEkAjT3KhhjKdDy6JC849/XlyeYQpMuiN/Py/qCXCy NYLA== X-Gm-Message-State: ABuFfogMY5xkzfAg9lz3BEFzD+8ixhs33Oe3CC4CJe6GuV/fzTMSe4ro adqQxEtsCVC7NmVvrGD6c4S2Vw== X-Received: by 2002:a5d:448d:: with SMTP id j13-v6mr40153wrq.236.1537866266930; Tue, 25 Sep 2018 02:04:26 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:25 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 06/14] thermal/drivers/hisi: Add multiple sensors support Date: Tue, 25 Sep 2018 11:03:04 +0200 Message-Id: <1537866192-12320-7-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Change the code as it is dealing with several sensors. For git-bisect compatibility (compilation and booting), assume the DT is not yet changed and we have a single interrupt. Next changes will support multiple interrupt sorted by their name. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 79 +++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 32 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 87b82fb..a5756f6 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -448,8 +448,8 @@ static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) { - struct hisi_thermal_data *data = dev; - struct hisi_thermal_sensor *sensor = &data->sensor[0]; + struct hisi_thermal_sensor *sensor = dev; + struct hisi_thermal_data *data = sensor->data; int temp = 0; data->ops->irq_handler(sensor); @@ -457,15 +457,17 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) hisi_thermal_get_temp(sensor, &temp); if (temp >= sensor->thres_temp) { - dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", - temp, sensor->thres_temp); + dev_crit(&data->pdev->dev, + "sensor <%d> THERMAL ALARM: %d > %d\n", + sensor->id, temp, sensor->thres_temp); - thermal_zone_device_update(data->sensor[0].tzd, + thermal_zone_device_update(sensor->tzd, THERMAL_EVENT_UNSPECIFIED); } else { - dev_crit(&data->pdev->dev, "THERMAL ALARM stopped: %d < %d\n", - temp, sensor->thres_temp); + dev_crit(&data->pdev->dev, + "sensor <%d> THERMAL ALARM stopped: %d < %d\n", + sensor->id, temp, sensor->thres_temp); } return IRQ_HANDLED; @@ -543,7 +545,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) struct hisi_thermal_data *data; struct device *dev = &pdev->dev; struct resource *res; - int ret; + int i, ret; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) @@ -560,37 +562,41 @@ static int hisi_thermal_probe(struct platform_device *pdev) return PTR_ERR(data->regs); } - data->irq = platform_get_irq(pdev, 0); - if (data->irq < 0) - return data->irq; - ret = data->ops->probe(data); if (ret) return ret; - ret = hisi_thermal_register_sensor(pdev, &data->sensor[0]); - if (ret) { - dev_err(dev, "failed to register thermal sensor: %d\n", ret); - return ret; - } + for (i = 0; i < data->nr_sensors; i++) { + struct hisi_thermal_sensor *sensor = &data->sensor[i]; - ret = data->ops->enable_sensor(&data->sensor[0]); - if (ret) { - dev_err(dev, "Failed to setup the sensor: %d\n", ret); - return ret; - } + ret = hisi_thermal_register_sensor(pdev, sensor); + if (ret) { + dev_err(dev, "failed to register thermal sensor: %d\n", + ret); + return ret; + } + + data->irq = platform_get_irq(pdev, 0); + if (data->irq < 0) + return data->irq; - if (data->irq) { ret = devm_request_threaded_irq(dev, data->irq, NULL, - hisi_thermal_alarm_irq_thread, - IRQF_ONESHOT, "hisi_thermal", data); + hisi_thermal_alarm_irq_thread, + IRQF_ONESHOT, "hisi_thermal", + sensor); if (ret < 0) { dev_err(dev, "failed to request alarm irq: %d\n", ret); return ret; } - } - hisi_thermal_toggle_sensor(&data->sensor[0], true); + ret = data->ops->enable_sensor(sensor); + if (ret) { + dev_err(dev, "Failed to setup the sensor: %d\n", ret); + return ret; + } + + hisi_thermal_toggle_sensor(sensor, true); + } return 0; } @@ -598,11 +604,14 @@ static int hisi_thermal_probe(struct platform_device *pdev) static int hisi_thermal_remove(struct platform_device *pdev) { struct hisi_thermal_data *data = platform_get_drvdata(pdev); - struct hisi_thermal_sensor *sensor = &data->sensor[0]; + int i; - hisi_thermal_toggle_sensor(sensor, false); + for (i = 0; i < data->nr_sensors; i++) { + struct hisi_thermal_sensor *sensor = &data->sensor[i]; - data->ops->disable_sensor(sensor); + hisi_thermal_toggle_sensor(sensor, false); + data->ops->disable_sensor(sensor); + } return 0; } @@ -611,8 +620,10 @@ static int hisi_thermal_remove(struct platform_device *pdev) static int hisi_thermal_suspend(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); + int i; - data->ops->disable_sensor(&data->sensor[0]); + for (i = 0; i < data->nr_sensors; i++) + data->ops->disable_sensor(&data->sensor[i]); return 0; } @@ -620,8 +631,12 @@ static int hisi_thermal_suspend(struct device *dev) static int hisi_thermal_resume(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); + int i, ret = 0; + + for (i = 0; i < data->nr_sensors; i++) + ret |= data->ops->enable_sensor(&data->sensor[i]); - return data->ops->enable_sensor(&data->sensor[0]); + return ret; } #endif From patchwork Tue Sep 25 09:03:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 147412 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp472857lji; Tue, 25 Sep 2018 02:04:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Vg2tvFJrUrZ04gJjMiJvzZq98nrYzXcOz6Dz19FSVGeNlJL6sfrauZGmt7EWupV+jMC38 X-Received: by 2002:a63:6746:: with SMTP id b67-v6mr89548pgc.310.1537866272459; Tue, 25 Sep 2018 02:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537866272; cv=none; d=google.com; s=arc-20160816; b=dsZzeK/1xHSLEdVSfAwOMTw6cGLKT672JAY4drv9ycn74hbRYlqhVa2FGW8fcJBeoy JftMXUURo73t2aUqZD7sZxX4ilMPPFktlfngIJaT11caPJEU8NtUqVVycGlspeRNzSbs 0VqpaGebIs6lh4ZOZVYKeEmfQ/eXxwob959Ghnb85QGLH1Vddc/GmNopfAEUUqutzcDG 0Ca3YwjT1uoa4Nkj3NzE+OLjrPUUroPklZZYSHCLP7zwRmNAYNpbqWHQ79+j0VjhjTBG IO0TaY3kkWXcADUwJRRnsST+wmQmW+9W7orrWnijQ7A7CT5PH82dVkBwGfskwkfuNZWu nM1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=twKUT5AkgFgWw/t/b6bDn1W7sM2Rq3ji9heE8FRQKeo=; b=Ymy3YEjBEbyM9HW6CzEyeNnUrBjRFtqCyF++F3ESbcfzFan8+2vxl5ucZt6thcmGNs +EDDnSWeo8NIkRPWMYRR4rzc6gvF/TSm8MHz7w0GaGYzB5e/APYUeBZq8MhjxN3RoIz4 TgSLfB50a/IFZ+lYwhOnuCV+/nyNae7AhgFxzpRYQmN3tDwum7fAKKU3frEsh2Y46njg 9Gqntgf/KH+vCXYx5G5dIdncwTSZwf5RjW0KmrOxVVCe/fkg0Fkqxhgjz2aAAi5X8zU0 cRUHLLt4M0z1QGS9D9apwK/NrwzVnj/B4ne4q2R8QQ2YAnKhP8bFvlraZKJW1bxvgWcH AxCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bwrASE8S; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12-v6si1696321pfj.244.2018.09.25.02.04.32; Tue, 25 Sep 2018 02:04:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bwrASE8S; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726927AbeIYPLC (ORCPT + 10 others); Tue, 25 Sep 2018 11:11:02 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44198 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbeIYPLC (ORCPT ); Tue, 25 Sep 2018 11:11:02 -0400 Received: by mail-wr1-f67.google.com with SMTP id v16-v6so22463242wro.11 for ; Tue, 25 Sep 2018 02:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=twKUT5AkgFgWw/t/b6bDn1W7sM2Rq3ji9heE8FRQKeo=; b=bwrASE8SJsryrgfQp4OcrgICX1ooVdFQ8ivP+hUg1MrkP2Piwfyyl56tQV7tpvs4vJ J2dxuWJ4Ixf9xZgYy09bXWorJ6l0ku8qJ5Kq7fPRKZN6n9ORds4a0M1+v5yEniW1APBH y/DKqJudolhwzSHhpJTNylGgZSsOgYIq3GBuM= 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=twKUT5AkgFgWw/t/b6bDn1W7sM2Rq3ji9heE8FRQKeo=; b=A+rf5hSj5I2B5g/U8iZ9nScIlKQjvCnGhWL30j4ZW6pvYIkn3eKKq5Tv5NGQbwcVBJ 33PkFtAnC1Mc7E+mQu3+BcR5rpVeRwoZm1lMAMtlEpXqQW0rGJvvliArXnHyqc/7nur1 doH7D19/sfj+3+aaPghc5XXtgqlAyqs0j791GENgd6Wioou0om3lyd33niNrRCYbNpFn vpx1gZd9bUctjCEypZWsgbZ9fA+G8ItobEnjFHANqX4cZiuU6wI5Met5CvOUZiN2gsNa 9jcMZB4o8RJoBBNpRoHg1rhzw0wIGKpx1xX7Gz5gaI0db9ZZgxH1m/28efBGXKIGwRPj KT0g== X-Gm-Message-State: ABuFfog01Vriqbdcz8hQtgzMuAuhqo9CDyfef7i3IliO7N0bBtDhRkXi jyPFwZTS+ff8zclczW5wFtJdMA== X-Received: by 2002:a5d:4185:: with SMTP id m5-v6mr97633wrp.8.1537866268768; Tue, 25 Sep 2018 02:04:28 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:28 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 07/14] thermal/drivers/hisi: Replace macro name with relevant sensor location Date: Tue, 25 Sep 2018 11:03:05 +0200 Message-Id: <1537866192-12320-8-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Change the macro name in order to give a better indication of the sensor location. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index a5756f6..a542cb3 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -55,8 +55,8 @@ #define HI3660_TEMP_STEP (205) #define HI3660_TEMP_LAG (4000) -#define HI6220_DEFAULT_SENSOR 2 -#define HI3660_DEFAULT_SENSOR 1 +#define HI6220_CLUSTER0_SENSOR 2 +#define HI3660_BIG_SENSOR 1 struct hisi_thermal_data; @@ -406,7 +406,7 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) if (!data->sensor) return -ENOMEM; - data->sensor[0].id = HI6220_DEFAULT_SENSOR; + data->sensor[0].id = HI6220_CLUSTER0_SENSOR; data->sensor[0].data = data; data->nr_sensors = 1; @@ -422,7 +422,7 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data) if (!data->sensor) return -ENOMEM; - data->sensor[0].id = HI3660_DEFAULT_SENSOR; + data->sensor[0].id = HI3660_BIG_SENSOR; data->sensor[0].data = data; data->nr_sensors = 1; From patchwork Tue Sep 25 09:03:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 147415 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp473123lji; Tue, 25 Sep 2018 02:04:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV62BGM4H8hEdKlnjYZimx1c51nJYKp7IIIsDoBzVAOrDKikobhEq3XgcTrBhRZy0GFkidlPr X-Received: by 2002:a63:e5e:: with SMTP id 30-v6mr90662pgo.320.1537866290058; Tue, 25 Sep 2018 02:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537866290; cv=none; d=google.com; s=arc-20160816; b=os2C+VLyng1FUURBEJVWEUqgHQhNr0C8AAYZ0IfuOhQjXjNFlSp2IDCvdcN/XJ6BT+ OQVKTyn8ek4uCBd8+A0hdkWCiPN2Vg6ELoY7EHsphPUJFVXFd+CtiQApkMJ9CkM1PPhk OI/DV/+r6fOVD0E9Q7YdjkPli4YXYmk8kHXB9WYg0ZV0HvwEfs4GUUUOerHKXgpizbID ywB1hbu4IwXX4xwhLI9b8hG30ZyO/6pl8UBas6+db3D1dUcmJiu8vWtx9t6JAKa82iBS qi2GFPa1GIYqTbrmdogYUiXEyKjCNR5fMDtBc7+tckTYm611aJrkTm0TkTy2hZC9Rizk QE4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=FjybuiDBSw9NEcO9lVDeNrywfT+itTu22LbecoDEATI=; b=o5/vrp2+gdXWqxY6hnVoV/D2uKZGb4FcylZ6CX/4DJg4QtKB2zHtZlJZZyGuiPYfbZ 4JD2ouNQrDqTrxKOeRBGfMYCk0nJ7uUU0KDDiH65xzbou/2nC/uhIjEvvvyxL2P1YclO rTkXfxY0SzqglVd5mkM29b4Q7Er5Bc7/SIIThiEDeAAJ3uJ8XkNmNT5oXRC2e+4Vsnz6 HxEcicaZIdlaBoIw8M9F9a6OgBVjsnaKoZp3XU36Oqk2T/tHTh+IO++qjWvlrdE9P2T8 4R3c0mIUmMyd10SH2RRdqrolhQX6yzNgkWt1UwZh1rjLh57T2jMDrRhUXw+G3AJducQp 7oHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bZX5Iqq+; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b124-v6si1888940pgc.45.2018.09.25.02.04.49; Tue, 25 Sep 2018 02:04:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bZX5Iqq+; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbeIYPLS (ORCPT + 10 others); Tue, 25 Sep 2018 11:11:18 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39791 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727823AbeIYPLS (ORCPT ); Tue, 25 Sep 2018 11:11:18 -0400 Received: by mail-wr1-f66.google.com with SMTP id s14-v6so22456529wrw.6 for ; Tue, 25 Sep 2018 02:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FjybuiDBSw9NEcO9lVDeNrywfT+itTu22LbecoDEATI=; b=bZX5Iqq+b+ebjBjrTvEni6eoWVpbN44VEylr0iEpPtrISQsPBJ+t86e/AERKMVtKr6 yNfuI/lHspqvFYZmN7WAOvBdg53P8O63wJXVxSGHKCBMArTB/hDeflvQ7F6tmQiIzQMu 8qMgf3qWrKBcZoGHdlM48fT9x61DQ8wq9Xqq4= 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=FjybuiDBSw9NEcO9lVDeNrywfT+itTu22LbecoDEATI=; b=dr7/iAGVZbtF7qPiMaY+PyUfInLhCUZdJMfLZx9+kycW01VwfLd2K3Hh3n+t4RsJRM 7533+ePf3qkwmFCVHOdiYVAfeQlU1MbtS6u34auJG1mbQ2Cs9TTerUdwZfLqy4Zd++uK 0hJzift+FjLsg5zNZ+sbJpS3qmRrirNBy6+9f84eYZbXeO4I9vGcjJu+THdCuitUJ7wB qlGQ0N7r8/XFbf4J1XYNpMiEq+w6sY5tMWjKzJT/PM9EG5vC7FeA8fsCq0qCf67mpoCQ MxgX7o4m8NBcqRJVsSvglz6QgJrxDG7ukI/yANuUbcPebKa4FT4zcps8lyD+tCWxAvz2 d+cg== X-Gm-Message-State: ABuFfogo3ObWm8b/I6dHosipxdbfo8/s1jaa6gL7atQDK98GZb9Lldkw L/vU7cZdvOtP4LIqGugD8Cqcow== X-Received: by 2002:adf:fdca:: with SMTP id i10-v6mr37238wrs.276.1537866284739; Tue, 25 Sep 2018 02:04:44 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:36 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui , Rob Herring , Mark Rutland , Wei Xu , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-arm-kernel@lists.infradead.org (moderated list:ARM/HISILICON SOC SUPPORT) Subject: [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors Date: Tue, 25 Sep 2018 11:03:08 +0200 Message-Id: <1537866192-12320-11-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add the missing interrupts for the temperature sensors as well as their names. Signed-off-by: Daniel Lezcano --- Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt | 8 ++++++-- arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt index 3edfae3..4cb8add 100644 --- a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt @@ -29,7 +29,11 @@ for Hi3660: tsensor: tsensor@fff30000 { compatible = "hisilicon,hi3660-tsensor"; reg = <0x0 0xfff30000 0x0 0x1000>; - interrupts = ; - interrupt-names = "tsensor_a73"; + interrupts = , + , + , + ; + interrupt-names = "tsensor_a73", "tsensor_a53", + "tsensor_g3d", "tsensor_modem"; #thermal-sensor-cells = <1>; }; diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi index bf8a479..dd398cb 100644 --- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi @@ -1080,8 +1080,12 @@ tsensor: tsensor@fff30000 { compatible = "hisilicon,hi3660-tsensor"; reg = <0x0 0xfff30000 0x0 0x1000>; - interrupts = ; - interrupt-names = "tsensor_a73"; + interrupts = , + , + , + ; + interrupt-names = "tsensor_a73", "tsensor_a53", + "tsensor_g3d", "tsensor_modem"; #thermal-sensor-cells = <1>; }; From patchwork Tue Sep 25 09:03:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 147418 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp473303lji; Tue, 25 Sep 2018 02:05:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV61YIk1YUqL5MWLuZ55Px/YwE6JJAuAjrjYOfmBLQWUu0ne1REcphnvAsrAmmJfPdLhNzdV9 X-Received: by 2002:a62:9683:: with SMTP id s3-v6mr13887pfk.191.1537866302322; Tue, 25 Sep 2018 02:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537866302; cv=none; d=google.com; s=arc-20160816; b=SdRMnWRNsWNMmq2A1UTRjlBq4zDw7BMlm6rzpkSX2uwANcByR1DUJWFsKqt7Pkhh52 7+Qdg0Aqg5mLNc5y4mB/cImXg0UUApvFjFb/Gd87CVcCtxVDRJvs4LkHV39H3Ss/Nv6Z 4W4kNNKF/0M7ur616G7wgeVdoFWRUWIrhLHTsqKKZlsRCgfE3HcK+EWVqWlFaSLJWlqy iqskLRBxCh0IWBaq7juYc54Wie08KHDh6U1S7HE/odDD/xFwdxMK0IkgiWWSD7HF/EOQ dwjOBv4rmQHPrbo5ruzJb2QGo2EBPKTFsa1ldlpwm7gx0rK+Q32TLl8w73VXMudd7hJ5 gMtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=UxB+GfDnTMjmOE1hd6mzvwMVcjkzKsZWm7O8IKgj40I=; b=Iod4869YNsfxBkMOt3mgwW1HtutRfc5PVR25UlgnFqlFeHDnUaf17EGVvKvVEU6sGN c7W0TI1w9JdIO3FRMixM9qYYy8gO/WGIdYosxhWXPff5v2hXRIMhxqOw8dOjq+JSd46T Ry9fadx/oe6FZoVnRnDIGb9qT1b8GEANx1noUMgkckeWD8yENO35Sja/IrYeI+O8erdq LfeJxZ0O1rI+VjGQiCYF/lF0png3DXNiI8lDQSB5sms8PESANA/EfrA3AlFRA1LrJdaq 5UFS2rr799H4RcLRsskgKhxk1XATVN1oa8cGxbhYCcD9PFzsYofakMRUkLxOKMhRkxSi 6EKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="e3cGzg/5"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p126-v6si1807051pfb.77.2018.09.25.02.05.02; Tue, 25 Sep 2018 02:05:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="e3cGzg/5"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727550AbeIYPLc (ORCPT + 10 others); Tue, 25 Sep 2018 11:11:32 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42365 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728916AbeIYPLc (ORCPT ); Tue, 25 Sep 2018 11:11:32 -0400 Received: by mail-wr1-f66.google.com with SMTP id b11-v6so6263949wru.9 for ; Tue, 25 Sep 2018 02:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UxB+GfDnTMjmOE1hd6mzvwMVcjkzKsZWm7O8IKgj40I=; b=e3cGzg/5ZKmcHoe7SSPCL70kclr+7cbEHw/gHo/lBo4C03IhBJkg5X2aC0Mdt0+6LL fH20z4P33tGqwCx6Wi9oEnfmaBZyFlFxToUm1b/kL4DtGH9Y0/+fDAKuwymHCt77vfkh +M5YnvdqKhs58yE5vtzmv3U/2bqAHBgZTUQUg= 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=UxB+GfDnTMjmOE1hd6mzvwMVcjkzKsZWm7O8IKgj40I=; b=Py7/hmhUUeDs6AeDLZ01x/M88AmX4wTI948cboYwF8rTp5FjRK0a68vQBdBT/31ULT SshLbyJz2OIYksOJqicLUqkPRtLOBt8O6AZYK0f4PI8TPVP4FdJ4CQgoQw/L/AY/wDd3 xYNLVsY6KQdiDESgmQ+wzknh/XfwakvSLdGN1YBj1nm5vHTsGB/jeLu5JtXADnI8lbPc ezypiOIRSQPAA7NdwQKaQ8m3W+FidR8KFeLLuKGKrNvvRDigIYLH96SJkYw6r+dW/VcX 3oJr29Q+ukN16BTCfKzhMlE2iq42EvIprrCVR3yEMSWkzY0PRhhOhf0U3Gn189m8ZzBF JhOw== X-Gm-Message-State: ABuFfoj7NJHh3V2PKiOOWHlMVT3j/nLfIkwyNxpOYuJQQAowVQT8mAcW FeA4N9nNa+hdDvuwsFsi/ZNUTA== X-Received: by 2002:adf:a925:: with SMTP id u34-v6mr16176wrc.175.1537866298105; Tue, 25 Sep 2018 02:04:58 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:57 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Wei Xu , Rob Herring , Mark Rutland , linux-arm-kernel@lists.infradead.org (moderated list:ARM/HISILICON SOC SUPPORT), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH 13/14] ARM64: dts: hisilicon: Add dual clusters thermal zones for hi3660 Date: Tue, 25 Sep 2018 11:03:11 +0200 Message-Id: <1537866192-12320-14-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add a thermal zone for the little cluster, so we can handle two sensors managing each a cluster on the SoC. Signed-off-by: Daniel Lezcano --- arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 97 ++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 34 deletions(-) -- 2.7.4 diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi index dd398cb..6df7d9f 100644 --- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi @@ -1090,42 +1090,71 @@ }; thermal-zones { + tz_a53: tz_a53 { + polling-delay = <1000>; + polling-delay-passive = <100>; + sustainable-power = <4500>; + + /* sensor ID */ + thermal-sensors = <&tsensor 0>; + + trips { + a53_temp_threshold: trip-point@0 { + temperature = <65000>; + hysteresis = <1000>; + type = "passive"; + }; + + a53_temp_target: trip-point@1 { + temperature = <75000>; + hysteresis = <1000>; + type = "passive"; + }; + }; - cls0: cls0 { - polling-delay = <1000>; - polling-delay-passive = <100>; - sustainable-power = <4500>; - - /* sensor ID */ - thermal-sensors = <&tsensor 1>; - - trips { - threshold: trip-point@0 { - temperature = <65000>; - hysteresis = <1000>; - type = "passive"; - }; - - target: trip-point@1 { - temperature = <75000>; - hysteresis = <1000>; - type = "passive"; - }; - }; - - cooling-maps { + cooling-maps { map0 { - trip = <&target>; - contribution = <1024>; - cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; - }; - map1 { - trip = <&target>; - contribution = <512>; - cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; - }; - }; - }; + trip = <&a53_temp_target>; + contribution = <512>; + cooling-device = <&cpu0 + THERMAL_NO_LIMIT + THERMAL_NO_LIMIT>; + }; + }; + }; + + tz_a73: tz_a73 { + polling-delay = <1000>; + polling-delay-passive = <100>; + sustainable-power = <4500>; + + /* sensor ID */ + thermal-sensors = <&tsensor 1>; + + trips { + a73_temp_threshold: trip-point@0 { + temperature = <65000>; + hysteresis = <1000>; + type = "passive"; + }; + + a73_temp_target: trip-point@1 { + temperature = <75000>; + hysteresis = <1000>; + type = "passive"; + }; + }; + + cooling-maps { + map0 { + trip = <&a73_temp_target>; + contribution = <1024>; + cooling-device = <&cpu4 + THERMAL_NO_LIMIT + THERMAL_NO_LIMIT>; + }; + }; + }; }; }; }; From patchwork Tue Sep 25 09:03:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 147419 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp473344lji; Tue, 25 Sep 2018 02:05:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV60l5Jxv+mRR0TPRENNP9lf7vfCnnJlQPldn5JweBskSFB1/3fSiOyuqPqQNutsi1FE585K8 X-Received: by 2002:a17:902:a985:: with SMTP id bh5-v6mr67849plb.193.1537866305041; Tue, 25 Sep 2018 02:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537866305; cv=none; d=google.com; s=arc-20160816; b=oQCs3vmOq1097rGKCHrqS6rLRdRmP0KKIALn7h9N/KMelBeXjjI+PQ2ZBFm9N4KzGB sg5fruTcddozPItE6lks9ne2nra9vJGPEremzcBjMmeyBMncpmmUL/3BNN67SqnO5dWe d7sRko7NkG3KfEo9EEWWtRhttOMO5l6REo08t6IRuwVLtgxIm05plX1JUwG1ETkKCbiZ P3uyL9fAEnSu0TJCpftl7F2RoJq0a1vy9z6YSaZpgyGWKhUuEX6MDM3oMdlg6sN0Y+Gn 1HenbP1vqeD0En1GNA/zn8MoRysjnaAVKs7oIPgJEZm8z1DZEMB81Jw+rX4PIZtPkXf0 McQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=2c10kVYZmaRE2YAvTe8xN2YzBOeCiX1ots/Bs3skCvA=; b=lhhsTyJefVFUBMKJE6XDKJ+kbb5jf+JzJQ1XV9t9XsWr5dGCpvimLYKpOpSZ5+mVbd 0wt+zr9imAoJoV+MxRqHrdbCJ9i1KKhbcDKfI4ogjGUxAiDTDXrNzd1aT3HnQptGINYE 286HuMEwKE5NzKN7f2G8KtgjVXt81kYS4tVQe4gDSh19hn0JL9p4yhcqWBGsyqBr0P+K jAwpVmHCbpf8lE61aZd1a5EsafXvJPWCKnghFY8utw7G436yoEM2cVVmokwI+Qz9rd9U 4ez7X04QRFB7n2dQVYjJ+Fh5z3RA7gKJ9VbG83s7UTLM+ibIRbSTyorx5FbuejPaWsLh gE2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dI792yem; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10-v6si1586774pgv.374.2018.09.25.02.05.04; Tue, 25 Sep 2018 02:05:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dI792yem; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728953AbeIYPLf (ORCPT + 10 others); Tue, 25 Sep 2018 11:11:35 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43707 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728915AbeIYPLe (ORCPT ); Tue, 25 Sep 2018 11:11:34 -0400 Received: by mail-wr1-f68.google.com with SMTP id z14-v6so4966917wrs.10 for ; Tue, 25 Sep 2018 02:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2c10kVYZmaRE2YAvTe8xN2YzBOeCiX1ots/Bs3skCvA=; b=dI792yemZWGQzfz6P+lbysSZCE+Qgm0Rv/p1vw0/yIWguhd24AI/9xNBXL9QAOe8qi WmZ2mtf3GKG2j1FO+o/ZogAfHEpMC4FUXdtEOO9K5a54yUzDUgIdJ5g6rJuz2bxVn08M y9PhFzkYxxDDrDOe9lyWawRU33so4h6KCxHzs= 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=2c10kVYZmaRE2YAvTe8xN2YzBOeCiX1ots/Bs3skCvA=; b=NSdq3h+7DLjMcjRqBeDVjsqY47xWYxj+0Lr3X7v7LqB+IS2xrmHWpIJHkKGKblR/BN usUrGXrdl69EpsWxK1TPVVdsF2Nza9+GZK1otb6GlhQgShE2EkakO3Rp8uvT2MJgYBEo qVATInpOyB/Bd3JTvwtZSLJKH+h+kCvU0EgsrVHeyv5nhTS10Bii30HY8miA6p8fDkkg Z3vUN6vJ32U2lUeqhQj2hn8oVBKr06tLF/hVFwAwMp5J3t2jw8ncXe8ZDyxxG0C3GgoH y/FDW5dN5lW0oqF7IOeHTLRoFXYa/ARY38gmQukI3sxl9tYQ6ZR9iOVW5qigeK0Jq5Fe udUA== X-Gm-Message-State: ABuFfojBkzoszhA8YjBJvc1MbzVfZkhOa5HITmCcyCwnPOCT4Ff5WFBS s8clC9HuNrH1D4PLukRkb9PRZw== X-Received: by 2002:a5d:5391:: with SMTP id d17-v6mr14805wrv.191.1537866300122; Tue, 25 Sep 2018 02:05:00 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:59 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 14/14] thermal/drivers/hisi: Add the dual clusters sensors for hi3660 Date: Tue, 25 Sep 2018 11:03:12 +0200 Message-Id: <1537866192-12320-15-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The code is ready to support multiple sensors on the hi3660. The DT defines a thermal zone per cluster. Add the little cluster sensor and let it bind with the thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index ba89cb9..c4111a9 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -424,14 +424,20 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data) struct platform_device *pdev = data->pdev; struct device *dev = &pdev->dev; - data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); + data->nr_sensors = 2; + + data->sensor = devm_kzalloc(dev, sizeof(*data->sensor) * + data->nr_sensors, GFP_KERNEL); if (!data->sensor) return -ENOMEM; data->sensor[0].id = HI3660_BIG_SENSOR; data->sensor[0].irq_name = "tsensor_a73"; data->sensor[0].data = data; - data->nr_sensors = 1; + + data->sensor[1].id = HI3660_LITTLE_SENSOR; + data->sensor[1].irq_name = "tsensor_a53"; + data->sensor[1].data = data; return 0; } @@ -443,8 +449,8 @@ static int hisi_thermal_get_temp(void *__data, int *temp) *temp = data->ops->get_temp(sensor); - dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n", - sensor->id, *temp, sensor->thres_temp); + dev_dbg(&data->pdev->dev, "tzd=%p, id=%d, temp=%d, thres=%d\n", + sensor->tzd, sensor->id, *temp, sensor->thres_temp); return 0; }