Received: by 10.192.165.148 with SMTP id m20csp1976294imm; Thu, 26 Apr 2018 04:56:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+uEs2moX9iiKhJ6H7GzFmJAUVrajkcI2OgCB3D5osKx2waDyLO81lQnout/OHWOwMKdKCH X-Received: by 2002:a17:902:40d:: with SMTP id 13-v6mr28076092ple.117.1524743819451; Thu, 26 Apr 2018 04:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524743819; cv=none; d=google.com; s=arc-20160816; b=pK6BxfosuxZFa4gGbehD0wrX1hc+GSCR6EgD6QYTVoIhh0JeJoaXbqOBgQo/ESgime O2oJjOGdVp06qC5V1PuYcX0hCcdfJqMRYK0wyCS73qD8+DRzdssekOHmbOygGlcFwVkF AZ91uSR+Lgxr8+7dRko8vdfDoEBmO2nE7qA6rO2F796gu7/3FXxy5pupFRf7RkJy0Vwt zCkFp0IGHUEhqQHpCCo0lTaCeXOwIlY0qk/P/dmje267RX5JglN0VXZk7G0ZWDeFz49x Tor+h4BYY12+kN+NafrDDbF37a5Pma6sGFWuB+WliUO45LMAT9XMUtBMrjz4mfqSYeE6 RKFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=2bKgq+l7lza2CRLUXlpzVZTDrWo9t+IuPI2yDQdJCA0=; b=R7T7PkTXwyZyb4gDy0E/db7Rhk9ltiXzZIZC+IMFm417Ir9wPRShZtEzBoOuTq584t U5dO1MKPKTNAEW39Kbcj5MOAvRJeMi4EghTEhZNEoAazm5HHmES4Ay0hCoGorfrjcnCo g2NvEzwKgCbivlGawiJ+JremF/WsOBhSEo7tFS51TIo8im9Qa3tefSOi63sDVrxhDcCj 4GnbvRCdMUNNwtrJQMeS3nPZ/EB1+icrr5Jkjq1XDQe+OC2r7ghxCinJMDQ1ML5u2reN MBfsP1rt0rhxzh3+1BlqFmd8RdBvxaBIzXVwL4AJWBKLRChhyX3qOk623WPUvWD8zQez j6Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=T05A40wR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f191si15459883pgc.660.2018.04.26.04.56.45; Thu, 26 Apr 2018 04:56:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@samsung.com header.s=mail20170921 header.b=T05A40wR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756253AbeDZLyw (ORCPT + 99 others); Thu, 26 Apr 2018 07:54:52 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:21400 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755410AbeDZLwl (ORCPT ); Thu, 26 Apr 2018 07:52:41 -0400 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180426115239epoutp03f81e4533d3da0175ec2dc3f22c65d63f~o_jBqQ2WD2115421154epoutp03B; Thu, 26 Apr 2018 11:52:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180426115239epoutp03f81e4533d3da0175ec2dc3f22c65d63f~o_jBqQ2WD2115421154epoutp03B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1524743559; bh=2bKgq+l7lza2CRLUXlpzVZTDrWo9t+IuPI2yDQdJCA0=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=T05A40wRcn0dyS5i8QCvuqmca9VCz4hDZXg8tdF6olNhDo3FBSWdNa5FUQENq6JxV zZ3h3PABFMvNZzMqrZj3JK/TF3o3ePsT55Gc+WpuGNTcU79Otg52Pu7hZyolZIOHQ/ puC+C3lTPdVb28+5kctmY2hMSPyKiyHhO9A2msM8= Received: from epsmges2p4.samsung.com (unknown [182.195.42.72]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20180426115239epcas2p47c19d96bcddf8a1e7f8b37bee189dd1f~o_jBj3e_T0791507915epcas2p40; Thu, 26 Apr 2018 11:52:39 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 23.B4.04079.78DB1EA5; Thu, 26 Apr 2018 20:52:39 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20180426115239epcas2p2dc72353efa8375b7f70a41c570fba789~o_jBNzCz_0690506905epcas2p2E; Thu, 26 Apr 2018 11:52:39 +0000 (GMT) X-AuditID: b6c32a48-c49ff70000000fef-23-5ae1bd87229c Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 91.3B.03817.78DB1EA5; Thu, 26 Apr 2018 20:52:39 +0900 (KST) Received: from AMDC3058.DIGITAL.local ([106.120.53.102]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P7S00GD7JMBQG00@mmp2.samsung.com>; Thu, 26 Apr 2018 20:52:39 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Eduardo Valentin Cc: Zhang Rui , linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com Subject: [PATCH 16/18] thermal: exynos: cleanup code for enabling threshold interrupts Date: Thu, 26 Apr 2018 13:51:31 +0200 Message-id: <1524743493-28113-17-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1524743493-28113-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFIsWRmVeSWpSXmKPExsWy7bCmhW773odRBr1TlC02zljPajH/yjVW i8u75rBZfO49wmgx4/w+JosnD/vYHNg8ds66y+6xeM9LJo++LasYPT5vkgtgieKySUnNySxL LdK3S+DK+DnrPVvBf72KtnOHWBoYd6p1MXJySAiYSEw4c4qli5GLQ0hgB6PE0R032CGc74wS 07/fYOti5ACr2n8pACK+gVGif/9BqKJfjBIr2mezgoxiE7CSmNi+ihHEFhHQkjhxaTsTSBGz wBxGiVkNu1lAJgkLREh0HY0AqWERUJX48f0EM4jNK+ApcfD3PVaIk+QkTh6bDGZzAsUvHGkC O09CoJFNYmZ/P1SRi8Sbd2eZIWxhiVfHt7BD2NISz1ZtZIRoaGaU+LZjD1TRBEaJPeuFIGxr icPHL4INYhbgk+g4/Jcd4k1eiY42qBIPib2f50PtcpTovzyXCeJjoGd+Xr7BOIFRagEjwypG sdSC4tz01GKjAhO94sTc4tK8dL3k/NxNjOAY1PLYwXjgnM8hRgEORiUe3oCFD6KEWBPLiitz DzFKcDArifDGtz6MEuJNSaysSi3Kjy8qzUktPsQozcGiJM7b4HsmSkggPbEkNTs1tSC1CCbL xMEp1cDIoXfvj9L3Ga4ygbVuZuu/ZDfuDlS1T2HYsV3i9gwdhnidPctYlJ2eTLeUU6i+78Jz dW9OksutlcEbg4vLfW6cTuo0XXjbXHmJ8esHyhmLXVILSl/oeH3UfKQ7cdHuJRzXpthoPz+e 81bg9fSp6gtO1j28LCxu+HzZhJdz9tvsYrug+OtK7mxvJZbijERDLeai4kQAGlHRYL0CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgluLIzCtJLcpLzFFi42I5/e+xoG773odRBo/+cFlsnLGe1WL+lWus Fpd3zWGz+Nx7hNFixvl9TBZPHvaxObB57Jx1l91j8Z6XTB59W1YxenzeJBfAEsVlk5Kak1mW WqRvl8CV8XPWe7aC/3oVbecOsTQw7lTrYuTgkBAwkdh/KaCLkZNDSGAdo0TTC5MuRi4g+xej xONJy1hAEmwCVhIT21cxgtgiAloSJy5tZwIpYhaYwyjxfMUcJpBBwgIREl1HI0BqWARUJX58 P8EMYvMKeEoc/H2PFcSWEJCTOHlsMpjNCRS/cKSJBWKxh8T9vvdsExh5FjAyrGKUTC0ozk3P LTYqMMpLLdcrTswtLs1L10vOz93ECAyXbYe1+ncwPl4Sf4hRgINRiYc3YOGDKCHWxLLiytxD jBIczEoivPGtD6OEeFMSK6tSi/Lji0pzUosPMUpzsCiJ8/LnH4sUEkhPLEnNTk0tSC2CyTJx cEo1MHIvZc2xuzrbXSd1xf7P9asD16Wsdrm249F9Q+/eTpXES7busVtNZpiJVsxtSvT1XbKR 5/WKpwcf1jfden5hTc36T994BHfHHt41xyIl7fosy5qmxWe8V/akcsfL+FZdSEgMCih4qTfx huQp5tPmqy8s21S3lM3DwXrZ/FLvhmVXjb4yRToJXlZiKc5INNRiLipOBAAMagPAEwIAAA== X-CMS-MailID: 20180426115239epcas2p2dc72353efa8375b7f70a41c570fba789 X-Msg-Generator: CA CMS-TYPE: 102P X-CMS-RootMailID: 20180426115239epcas2p2dc72353efa8375b7f70a41c570fba789 X-RootMTR: 20180426115239epcas2p2dc72353efa8375b7f70a41c570fba789 References: <1524743493-28113-1-git-send-email-b.zolnierkie@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cleanup code for enabling threshold interrupts in ->tmu_control method implementations. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/thermal/samsung/exynos_tmu.c | 101 ++++++++++++----------------------- 1 file changed, 34 insertions(+), 67 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index abe0737..9639acf 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -76,9 +76,6 @@ #define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12 #define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 -#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4 -#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8 -#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12 #define EXYNOS_TMU_INTEN_FALL0_SHIFT 16 #define EXYNOS_EMUL_TIME 0x57F0 @@ -136,13 +133,6 @@ #define EXYNOS7_TMU_TEMP_MASK 0x1ff #define EXYNOS7_PD_DET_EN_SHIFT 23 #define EXYNOS7_TMU_INTEN_RISE0_SHIFT 0 -#define EXYNOS7_TMU_INTEN_RISE1_SHIFT 1 -#define EXYNOS7_TMU_INTEN_RISE2_SHIFT 2 -#define EXYNOS7_TMU_INTEN_RISE3_SHIFT 3 -#define EXYNOS7_TMU_INTEN_RISE4_SHIFT 4 -#define EXYNOS7_TMU_INTEN_RISE5_SHIFT 5 -#define EXYNOS7_TMU_INTEN_RISE6_SHIFT 6 -#define EXYNOS7_TMU_INTEN_RISE7_SHIFT 7 #define EXYNOS7_EMUL_DATA_SHIFT 7 #define EXYNOS7_EMUL_DATA_MASK 0x1ff @@ -615,29 +605,27 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tz = data->tzd; - unsigned int con, interrupt_en; + unsigned int con, interrupt_en = 0, i; con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); if (on) { - con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT); - interrupt_en = - (of_thermal_is_trip_valid(tz, 3) - << EXYNOS_TMU_INTEN_RISE3_SHIFT) | - (of_thermal_is_trip_valid(tz, 2) - << EXYNOS_TMU_INTEN_RISE2_SHIFT) | - (of_thermal_is_trip_valid(tz, 1) - << EXYNOS_TMU_INTEN_RISE1_SHIFT) | - (of_thermal_is_trip_valid(tz, 0) - << EXYNOS_TMU_INTEN_RISE0_SHIFT); + for (i = 0; i < data->ntrip; i++) { + if (!of_thermal_is_trip_valid(tz, i)) + continue; + + interrupt_en |= + (1 << (EXYNOS_TMU_INTEN_RISE0_SHIFT + i * 4)); + } if (data->soc != SOC_ARCH_EXYNOS4210) interrupt_en |= interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT; - } else { + + con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT); + } else con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT); - interrupt_en = 0; /* Disable all interrupts */ - } + writel(interrupt_en, data->base + EXYNOS_TMU_REG_INTEN); writel(con, data->base + EXYNOS_TMU_REG_CONTROL); } @@ -646,36 +634,25 @@ static void exynos5433_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tz = data->tzd; - unsigned int con, interrupt_en, pd_det_en; + unsigned int con, interrupt_en = 0, pd_det_en, i; con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); if (on) { - con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT); - interrupt_en = - (of_thermal_is_trip_valid(tz, 7) - << EXYNOS7_TMU_INTEN_RISE7_SHIFT) | - (of_thermal_is_trip_valid(tz, 6) - << EXYNOS7_TMU_INTEN_RISE6_SHIFT) | - (of_thermal_is_trip_valid(tz, 5) - << EXYNOS7_TMU_INTEN_RISE5_SHIFT) | - (of_thermal_is_trip_valid(tz, 4) - << EXYNOS7_TMU_INTEN_RISE4_SHIFT) | - (of_thermal_is_trip_valid(tz, 3) - << EXYNOS7_TMU_INTEN_RISE3_SHIFT) | - (of_thermal_is_trip_valid(tz, 2) - << EXYNOS7_TMU_INTEN_RISE2_SHIFT) | - (of_thermal_is_trip_valid(tz, 1) - << EXYNOS7_TMU_INTEN_RISE1_SHIFT) | - (of_thermal_is_trip_valid(tz, 0) - << EXYNOS7_TMU_INTEN_RISE0_SHIFT); + for (i = 0; i < data->ntrip; i++) { + if (!of_thermal_is_trip_valid(tz, i)) + continue; + + interrupt_en |= + (1 << (EXYNOS7_TMU_INTEN_RISE0_SHIFT + i)); + } interrupt_en |= interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT; - } else { + + con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT); + } else con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT); - interrupt_en = 0; /* Disable all interrupts */ - } pd_det_en = on ? EXYNOS5433_PD_DET_EN : 0; @@ -688,37 +665,27 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tz = data->tzd; - unsigned int con, interrupt_en; + unsigned int con, interrupt_en = 0, i; con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); if (on) { - con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT); - con |= (1 << EXYNOS7_PD_DET_EN_SHIFT); - interrupt_en = - (of_thermal_is_trip_valid(tz, 7) - << EXYNOS7_TMU_INTEN_RISE7_SHIFT) | - (of_thermal_is_trip_valid(tz, 6) - << EXYNOS7_TMU_INTEN_RISE6_SHIFT) | - (of_thermal_is_trip_valid(tz, 5) - << EXYNOS7_TMU_INTEN_RISE5_SHIFT) | - (of_thermal_is_trip_valid(tz, 4) - << EXYNOS7_TMU_INTEN_RISE4_SHIFT) | - (of_thermal_is_trip_valid(tz, 3) - << EXYNOS7_TMU_INTEN_RISE3_SHIFT) | - (of_thermal_is_trip_valid(tz, 2) - << EXYNOS7_TMU_INTEN_RISE2_SHIFT) | - (of_thermal_is_trip_valid(tz, 1) - << EXYNOS7_TMU_INTEN_RISE1_SHIFT) | - (of_thermal_is_trip_valid(tz, 0) - << EXYNOS7_TMU_INTEN_RISE0_SHIFT); + for (i = 0; i < data->ntrip; i++) { + if (!of_thermal_is_trip_valid(tz, i)) + continue; + + interrupt_en |= + (1 << (EXYNOS7_TMU_INTEN_RISE0_SHIFT + i)); + } interrupt_en |= interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT; + + con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT); + con |= (1 << EXYNOS7_PD_DET_EN_SHIFT); } else { con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT); con &= ~(1 << EXYNOS7_PD_DET_EN_SHIFT); - interrupt_en = 0; /* Disable all interrupts */ } writel(interrupt_en, data->base + EXYNOS7_TMU_REG_INTEN); -- 1.9.1