From patchwork Mon Apr 15 20:24:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 162264 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3368778jan; Mon, 15 Apr 2019 13:25:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaH84b8omJIxcgnsFzmyw6hcK8GYhuCRmj7MTp/biyBxiYTQeCYNmv3J019ucMIGUGtt/s X-Received: by 2002:a17:902:e7:: with SMTP id a94mr77668604pla.114.1555359936029; Mon, 15 Apr 2019 13:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555359936; cv=none; d=google.com; s=arc-20160816; b=nQ1MYQ8pYR86+JyBFskwec+IZe2QDccSsHVSmU7Wruyze7KX1H97+soFhgX3XcmtGm 9eJmCYuDiQVy0KyOZnUvAwPWN+8TBotAIOPu0lKF0vruADQezGk828NfDaD3hmGmJpHB mVSXLKLaKsHwP8pbLAJ7lA3DosZeaaD9FEzaj193NpCKFA3xiDYX3ZAaKbfNvkrY1gHN NoKqDGYx5kSJYI213tdixAdJZHRxf0hg+lw6TGTIsknTAlaz3eSVjSGt/Nq2/8h3XW/8 0WGcju8qbxqQdwTD96KpDYcc2ypY7kNy2otkJoKYqMzUycQqIcLUS9rwAJn0eTzWsMUi sRdg== 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 :message-id:date:subject:cc:to:from; bh=1C10ZICIl+c+ZkRmDV7iGLEZNflGcc+ac4/YsteOqs8=; b=rjKKaCck5H+V3G9piO+jeJ2NGQlJWGpdGCsQJ+wIj89nT35JSCx95/ChDNjy7/oZUp O730G2crovnPLKuFluMJJVboCu5hvQ0Os0ngeTukB+h2ln1j3NDn5boFvO+MSRGCIcEo FN9eZwUz6jUVVchHtBRo8pp0dVC3HMvaVpPd0hzenT8J8bbMOVVN0hh8GqydVFjIaO4z zHgtRU1EAJ2ejCOoMRZU/YRnJ7ZEXlQZlji22znu0x5CLaW9ztnlmQlnimN+/cbm8wFn 38No86CMGB9lZCrQCbNbVxMgOakovO7GWyhP5MUc4nUpQEiseVnR6zK2BtGzY28xHPi9 WkkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-watchdog-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 2si23733923pld.334.2019.04.15.13.25.35 for ; Mon, 15 Apr 2019 13:25:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-watchdog-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-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726319AbfDOUZf (ORCPT ); Mon, 15 Apr 2019 16:25:35 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:47427 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727650AbfDOUZf (ORCPT ); Mon, 15 Apr 2019 16:25:35 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1Macf4-1gjXR22qiY-00cDX5; Mon, 15 Apr 2019 22:25:06 +0200 From: Arnd Bergmann To: Greg Ungerer Cc: Linus Walleij , arm@kernel.org, Arnd Bergmann , Wim Van Sebroeck , Guenter Roeck , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org Subject: [PATCH 1/6] ARM: ks8695: watchdog: stop using mach/*.h Date: Mon, 15 Apr 2019 22:24:13 +0200 Message-Id: <20190415202501.941196-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:3f0N7e03dpDdEs2wFtzwS0wRc0tVAs7W6slwO/9ZNkRveBQIjcS bm4Kk2zlsXHtNp6ivUcyOVN3NHYArHErq8bNj2eKnYJh+VMwm8BYplE1+TMUj3wuEl3UMHu xuwifGzbWpilUzrkx6snzAfW3nWp+Dc8SiAvqtdCc2D0kGJqB/uRVm8Kc3k47bgPHivbyAB LsM+6YV4gTQAJ79yOsakA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:lishDkrJYUI=:Rg/rjkvrXx+dapNCpggbg8 KL2QAoY8mgIU7lQn3xtTlbSJdjVKysqV3KoJmb0RPKVoUF0MKptbJwmi1uqNex14l5fLkAjk1 mOWjJ+OYHFITg7GCwGMtPZZPlMeTWbzlix7c46jz7dHBxhLAtF7dcc07EeMTRzYZ6WNc6jlb0 MEm/Cvr5OuzVTiN4LRfYkiDZ6lgNrb3Jt7/N+ePrJ0sYGxgDV8xHDWJnFkNYAd//PMpCteYfa YH0dIUZGkNq826yDHCevz8KpnnWjruM/9eeQV89/mFpUDlfeThRcv+tGksw0/7v0c+K5HmDFV urSd9qS0ZH7eNid8C+1c+VVWdiV3YXg/ecRYAzijeYqKqleX+k2QHjaOQpADXVkHu8CeSfXcW UKWY1MKoqbfREaBoJyjctjhtRxSyeBb/NPWMjMUb5jglLDbs96ESZ30e7RArj57HPoPHPa9kr r65YOGI6y9G1oSXtdUb+SeTk8o7+zrrlUfI7P4Czu3gdxy80xcaHC3J9qOPqN0RPgVQ0JlnGM y3+/SzwuscWKgiamxQhqxZaakA+DDn/z+BPWX7q5wua9uSX+jD+iJ0GQpOkKKFfxya84at/Um K0M+c+/LKxAHh1JwW/myDO+QXyUmMr45bBJwUfK3U5dUSsGba6GlpjmE9fYfMvOjD+z29qQ2J Mw/m/RAMoAGWIAf2er7eNVgDiCBYL4TToWKlCZFYotTilexwYkNEmH6XL1NRkwPgSPQ0SIM5N s9REX+/W0ovB8/Ft48Lz2xDe/MOni9MGKesk7A== Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org drivers should not rely on machine specific headers but get their information from the platform device. Signed-off-by: Arnd Bergmann --- arch/arm/mach-ks8695/devices.c | 13 ++++++++++++- drivers/watchdog/Kconfig | 2 +- drivers/watchdog/ks8695_wdt.c | 30 +++++++++++++++++------------- 3 files changed, 30 insertions(+), 15 deletions(-) -- 2.20.0 Acked-by: Greg Ungerer diff --git a/arch/arm/mach-ks8695/devices.c b/arch/arm/mach-ks8695/devices.c index 61cf20beb45f..57766817d86f 100644 --- a/arch/arm/mach-ks8695/devices.c +++ b/arch/arm/mach-ks8695/devices.c @@ -169,11 +169,22 @@ void __init ks8696_add_device_hpna(void) /* -------------------------------------------------------------------- * Watchdog * -------------------------------------------------------------------- */ +#define KS8695_TMR_OFFSET (0xF0000 + 0xE400) +#define KS8695_TMR_PA (KS8695_IO_PA + KS8695_TMR_OFFSET) +static struct resource ks8695_wdt_resources[] = { + [0] = { + .name = "tmr", + .start = KS8695_TMR_PA, + .end = KS8695_TMR_PA + 0xf, + .flags = IORESOURCE_MEM, + }, +}; static struct platform_device ks8695_wdt_device = { .name = "ks8695_wdt", .id = -1, - .num_resources = 0, + .resource = ks8695_wdt_resources, + .num_resources = ARRAY_SIZE(ks8695_wdt_resources), }; static void __init ks8695_add_device_watchdog(void) diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 242eea859637..046e01daef57 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -397,7 +397,7 @@ config IXP4XX_WATCHDOG config KS8695_WATCHDOG tristate "KS8695 watchdog" - depends on ARCH_KS8695 + depends on ARCH_KS8695 || COMPILE_TEST help Watchdog timer embedded into KS8695 processor. This will reboot your system when the timeout is reached. diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c index 1e41818a44bc..87c542c2f912 100644 --- a/drivers/watchdog/ks8695_wdt.c +++ b/drivers/watchdog/ks8695_wdt.c @@ -23,10 +23,8 @@ #include #include #include -#include -#define KS8695_TMR_OFFSET (0xF0000 + 0xE400) -#define KS8695_TMR_VA (KS8695_IO_VA + KS8695_TMR_OFFSET) +#define KS8695_CLOCK_RATE 25000000 /* * Timer registers @@ -57,6 +55,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" static unsigned long ks8695wdt_busy; static DEFINE_SPINLOCK(ks8695_lock); +static void __iomem *tmr_reg; /* ......................................................................... */ @@ -69,8 +68,8 @@ static inline void ks8695_wdt_stop(void) spin_lock(&ks8695_lock); /* disable timer0 */ - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); - __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); + tmcon = __raw_readl(tmr_reg + KS8695_TMCON); + __raw_writel(tmcon & ~TMCON_T0EN, tmr_reg + KS8695_TMCON); spin_unlock(&ks8695_lock); } @@ -84,15 +83,15 @@ static inline void ks8695_wdt_start(void) spin_lock(&ks8695_lock); /* disable timer0 */ - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); - __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); + tmcon = __raw_readl(tmr_reg + KS8695_TMCON); + __raw_writel(tmcon & ~TMCON_T0EN, tmr_reg + KS8695_TMCON); /* program timer0 */ - __raw_writel(tval | T0TC_WATCHDOG, KS8695_TMR_VA + KS8695_T0TC); + __raw_writel(tval | T0TC_WATCHDOG, tmr_reg + KS8695_T0TC); /* re-enable timer0 */ - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); - __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); + tmcon = __raw_readl(tmr_reg + KS8695_TMCON); + __raw_writel(tmcon | TMCON_T0EN, tmr_reg + KS8695_TMCON); spin_unlock(&ks8695_lock); } @@ -105,9 +104,9 @@ static inline void ks8695_wdt_reload(void) spin_lock(&ks8695_lock); /* disable, then re-enable timer0 */ - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); - __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); - __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); + tmcon = __raw_readl(tmr_reg + KS8695_TMCON); + __raw_writel(tmcon & ~TMCON_T0EN, tmr_reg + KS8695_TMCON); + __raw_writel(tmcon | TMCON_T0EN, tmr_reg + KS8695_TMCON); spin_unlock(&ks8695_lock); } @@ -238,6 +237,11 @@ static struct miscdevice ks8695wdt_miscdev = { static int ks8695wdt_probe(struct platform_device *pdev) { int res; + struct resource *resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + tmr_reg = devm_ioremap_resource(&pdev->dev, resource); + if (!tmr_reg) + return -ENXIO; if (ks8695wdt_miscdev.parent) return -EBUSY;