Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp957059imu; Tue, 20 Nov 2018 09:23:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/XtpyP0BcxkE8/k28OtD1E/Hta5fUxym7Mle04MI+SNVMKXPDlol2XDjPVLx6MtinYrVSGy X-Received: by 2002:a17:902:4c08:: with SMTP id a8mr3165339ple.74.1542734587886; Tue, 20 Nov 2018 09:23:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542734587; cv=none; d=google.com; s=arc-20160816; b=IJbeCjytmtpwPEIrIn3Xp/xEY+WtMKp/7BA8zyBdV0/gCLMw0qHHbOokGPphRUdtr0 QwBM7jArSmlx66e44mgEywDhxQllz8ZBMRnGOgCsr7uQA0mCrN0v9HyOikZYY2B8UeQP Vxh24FmY6ycs6mO9jnk74YkjGVV4alnbnSfGxgflfd790jGpeVBKgCDeEHC8QwntLc3p ng2V1HrxIdm4G6qoG2+lnvxaCi3NlHzBsKT3HlbbBvPFMsaoVsRvpyyPZd5YlF87XEy5 rJq38tVEKSjoBA+d20ZnGM5nUQuzVVpmVuEf0s8lB7DRU1176AchHsgeZugHBLEPc2vT OhVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/tcCnIIlreqQrqtIO6A/Gi6SaLRgtCxgApV/fB6nESM=; b=wq003zK/m358/s/45HzlefAX/rlkIxRkObOxFEUqTifbF1WlU3tKVcyr6aHw7dz4UF 1yRoo4UUuuwj2RuioP8EmOkVKokBHMnYFuOB0hsjYv8wHXlSUEzcfoJmyhgNKP+Isgtu OEieNKQap7gseQ8ZWIDJS5i1WzYI0xgIx0ZXgw5tMLYbkU4+qTxhrsS9beu4WtuMMa8X r9iG9p7xjJ/oS+MQKGCdjgWgUO7qZ/1ykKafG1gOyqZa48snCDfmsr3+UVL/ULH6tjwL SjZAyfK9QuYNM54CP1j3N3nSaUcoxTcqzCD4AkuNoKbbtTHME+INL8HuNwYBFgDTJl4i RupQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g83si20764766pfb.278.2018.11.20.09.22.41; Tue, 20 Nov 2018 09:23:07 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730454AbeKUDuT (ORCPT + 99 others); Tue, 20 Nov 2018 22:50:19 -0500 Received: from anholt.net ([50.246.234.109]:50648 "EHLO anholt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730415AbeKUDuS (ORCPT ); Tue, 20 Nov 2018 22:50:18 -0500 Received: from localhost (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id B989310A15F5; Tue, 20 Nov 2018 09:20:04 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at anholt.net Received: from anholt.net ([127.0.0.1]) by localhost (kingsolver.anholt.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Me05flsQgnvf; Tue, 20 Nov 2018 09:20:01 -0800 (PST) Received: from eliezer.anholt.net (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 1B0B910A0396; Tue, 20 Nov 2018 09:20:01 -0800 (PST) Received: by eliezer.anholt.net (Postfix, from userid 1000) id 197242FE1FEA; Tue, 20 Nov 2018 09:20:00 -0800 (PST) From: Eric Anholt To: Florian Fainelli , Rob Herring , Mark Rutland , Wim Van Sebroeck , Guenter Roeck , linux-watchdog@vger.kernel.org Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stefan Wahren , bcm-kernel-feedback-list@broadcom.com, Eric Anholt Subject: [PATCH 4/8] soc: bcm: bcm2835-pm: Make some little accessor macros for the mmio area. Date: Tue, 20 Nov 2018 09:19:56 -0800 Message-Id: <20181120172000.15102-5-eric@anholt.net> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120172000.15102-1-eric@anholt.net> References: <20181120172000.15102-1-eric@anholt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is more legible than trying to remember to set PM_PASSWORD on everything. Signed-off-by: Eric Anholt --- drivers/soc/bcm/bcm2835-pm.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/soc/bcm/bcm2835-pm.c b/drivers/soc/bcm/bcm2835-pm.c index decc316fbe40..e504381556cf 100644 --- a/drivers/soc/bcm/bcm2835-pm.c +++ b/drivers/soc/bcm/bcm2835-pm.c @@ -32,6 +32,9 @@ #define PM_RSTC_WRCFG_FULL_RESET 0x00000020 #define PM_RSTC_RESET 0x00000102 +#define PM_READ(reg) readl(pm->base + (reg)) +#define PM_WRITE(reg, val) writel(PM_PASSWORD | (val), pm->base + (reg)) + /* * The Raspberry Pi firmware uses the RSTS register to know which partition * to boot from. The partition value is spread into bits 0, 2, 4, 6, 8, 10. @@ -54,7 +57,7 @@ static bool bcm2835_wdt_is_running(struct bcm2835_pm *pm) { uint32_t cur; - cur = readl(pm->base + PM_RSTC); + cur = PM_READ(PM_RSTC); return !!(cur & PM_RSTC_WRCFG_FULL_RESET); } @@ -67,11 +70,9 @@ static int bcm2835_wdt_start(struct watchdog_device *wdog) spin_lock_irqsave(&pm->lock, flags); - writel(PM_PASSWORD | (SECS_TO_WDOG_TICKS(wdog->timeout) & - PM_WDOG_TIME_SET), pm->base + PM_WDOG); - cur = readl(pm->base + PM_RSTC); - writel(PM_PASSWORD | (cur & PM_RSTC_WRCFG_CLR) | - PM_RSTC_WRCFG_FULL_RESET, pm->base + PM_RSTC); + PM_WRITE(PM_WDOG, SECS_TO_WDOG_TICKS(wdog->timeout) & PM_WDOG_TIME_SET); + cur = PM_READ(PM_RSTC); + PM_WRITE(PM_RSTC, (cur & PM_RSTC_WRCFG_CLR) | PM_RSTC_WRCFG_FULL_RESET); spin_unlock_irqrestore(&pm->lock, flags); @@ -82,7 +83,7 @@ static int bcm2835_wdt_stop(struct watchdog_device *wdog) { struct bcm2835_pm *pm = watchdog_get_drvdata(wdog); - writel(PM_PASSWORD | PM_RSTC_RESET, pm->base + PM_RSTC); + PM_WRITE(PM_RSTC, PM_RSTC_RESET); return 0; } @@ -90,7 +91,7 @@ static unsigned int bcm2835_wdt_get_timeleft(struct watchdog_device *wdog) { struct bcm2835_pm *pm = watchdog_get_drvdata(wdog); - uint32_t ret = readl(pm->base + PM_WDOG); + uint32_t ret = PM_READ(PM_WDOG); return WDOG_TICKS_TO_SECS(ret & PM_WDOG_TIME_SET); } @@ -100,7 +101,7 @@ static void __bcm2835_restart(struct bcm2835_pm *pm) /* use a timeout of 10 ticks (~150us) */ writel(10 | PM_PASSWORD, pm->base + PM_WDOG); - val = readl(pm->base + PM_RSTC); + val = PM_READ(PM_RSTC); val &= PM_RSTC_WRCFG_CLR; val |= PM_PASSWORD | PM_RSTC_WRCFG_FULL_RESET; writel(val, pm->base + PM_RSTC); @@ -159,7 +160,7 @@ static void bcm2835_power_off(void) * from the normal (full) reset. bootcode.bin will not reboot after a * hard reset. */ - val = readl(pm->base + PM_RSTS); + val = PM_READ(PM_RSTS); val |= PM_PASSWORD | PM_RSTS_RASPBERRYPI_HALT; writel(val, pm->base + PM_RSTS); -- 2.19.1