Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2529639imm; Thu, 9 Aug 2018 14:47:47 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxotZQ/5BHfbtsi5aI7wG8TMj3fylv+X79w+wLCVKavnKyg3DjVzh/Zk6VbIL9jWp8lN1Lt X-Received: by 2002:a65:5286:: with SMTP id y6-v6mr3748305pgp.65.1533851267418; Thu, 09 Aug 2018 14:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533851267; cv=none; d=google.com; s=arc-20160816; b=0WJZxErcKTOaBv/8gEJskY4RGw4YGQ1MiUL8xNwDble4UyHdPZKlqW/Y738ScvRReO zr1OPQgsw/WtKNmqs0zRc84tQaYeKS9K0hdgYieydrn9wR09sUqHnFtMrf4l+jIVBGd1 TEJTIwI4o/MkyEOjxIWeBExOi7vlyfruVcpUweqVlq2E/VmsSBwtTjLB7YDM0DAhvSVF XOBqFSIGOLKgWychz6n50fZWluhGSIBosZN6ISVRZQqyk5Rw/Fv3AjLbjXb8YIMjM1Lk lLE/ppx6Xrh4HefZHt+ER4son99qABR4ak4X+MyMxVFXweNqe5rtSD+vZ/rMmqK4lbO1 KmqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=87ziouG9OPvJJj8X32FDe4hrWYE2Ha95FkDCkgxH2qE=; b=YmfLYCrX2xw3tEZ5lMkgylfI+SLRxCzwZLBJUdVlH5OwGUU/XTb4WRCpv7t7e+eOAS RtjdUdxpRjZttbk4hInZIHE8HAt6ITeha64DC7MchpTThR++o/Nbmdce3X9BRR/bBUOL O8KjmbLFHNFGwNV/nQEQtsjwC1AMtBCbzXVJKx3UY/UPqVjsWdIfo1oK9U1NMId7L9Q9 JeANm8I47NifcOuWshlAekVYEDYBS0jVOn/Lmcx+zlJ2C+kZu5RgoFz25DQltUm47HCn zIJxqaR+9v3QqHc6WQ32cmTNC2cf35bKYzZX9Oj4fB2UXjWJP6SCL6Y0Feo7RB/GGHf3 8fiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=jN4Kungc; 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=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u12-v6si6696536pgr.267.2018.08.09.14.47.33; Thu, 09 Aug 2018 14:47:47 -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=@crapouillou.net header.s=mail header.b=jN4Kungc; 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=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727671AbeHJALw (ORCPT + 99 others); Thu, 9 Aug 2018 20:11:52 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:60464 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727268AbeHJALw (ORCPT ); Thu, 9 Aug 2018 20:11:52 -0400 From: Paul Cercueil To: Rob Herring , Mark Rutland , Thierry Reding , Daniel Lezcano , Thomas Gleixner , Wim Van Sebroeck , Guenter Roeck , Ralf Baechle , Paul Burton , James Hogan , Jonathan Corbet , Lee Jones , Mathieu Malaterre , Ezequiel Garcia Cc: linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-mips@linux-mips.org, linux-doc@vger.kernel.org, linux-clk@vger.kernel.org, Paul Cercueil Subject: [PATCH v6 09/24] watchdog: jz4740: Use regmap provided by TCU driver Date: Thu, 9 Aug 2018 23:43:59 +0200 Message-Id: <20180809214414.20905-10-paul@crapouillou.net> In-Reply-To: <20180809214414.20905-1-paul@crapouillou.net> References: <20180809214414.20905-1-paul@crapouillou.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1533851104; bh=87ziouG9OPvJJj8X32FDe4hrWYE2Ha95FkDCkgxH2qE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=jN4KungcSnXbjCw+EwjsmxZuoZ8XgSWKjtdtCt/eKPMyWxC+l6aEdOesaOGs9OVz6BzQMXiKNxqXMMtg9aU3ex2Xs6IdNXqgfz0XbMmDzRV5gjK/ZYTBRo+WovDTg1T9a6i5UmbfNDaMDOpF6RJqsWFFwDpPPbTD+sdeyZKl1h0= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since we broke the ABI by changing the clock, the driver was also updated to use the regmap provided by the TCU driver. Signed-off-by: Paul Cercueil --- drivers/watchdog/jz4740_wdt.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) v6: New patch diff --git a/drivers/watchdog/jz4740_wdt.c b/drivers/watchdog/jz4740_wdt.c index 1d504ecf45e1..0f54306aee25 100644 --- a/drivers/watchdog/jz4740_wdt.c +++ b/drivers/watchdog/jz4740_wdt.c @@ -13,6 +13,7 @@ * */ +#include #include #include #include @@ -25,10 +26,7 @@ #include #include #include - -#define JZ_REG_WDT_TIMER_DATA 0x0 -#define JZ_REG_WDT_COUNTER_ENABLE 0x4 -#define JZ_REG_WDT_TIMER_COUNTER 0x8 +#include #define DEFAULT_HEARTBEAT 5 #define MAX_HEARTBEAT 2048 @@ -48,7 +46,7 @@ MODULE_PARM_DESC(heartbeat, struct jz4740_wdt_drvdata { struct watchdog_device wdt; - void __iomem *base; + struct regmap *map; struct clk *clk; unsigned long clk_rate; }; @@ -57,7 +55,7 @@ static int jz4740_wdt_ping(struct watchdog_device *wdt_dev) { struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev); - writew(0x0, drvdata->base + JZ_REG_WDT_TIMER_COUNTER); + regmap_write(drvdata->map, TCU_REG_WDT_TCNT, 0); return 0; } @@ -67,12 +65,12 @@ static int jz4740_wdt_set_timeout(struct watchdog_device *wdt_dev, struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev); u16 timeout_value = (u16)(drvdata->clk_rate * new_timeout); - writeb(0x0, drvdata->base + JZ_REG_WDT_COUNTER_ENABLE); + regmap_write(drvdata->map, TCU_REG_WDT_TCER, 0); - writew((u16)timeout_value, drvdata->base + JZ_REG_WDT_TIMER_DATA); - writew(0x0, drvdata->base + JZ_REG_WDT_TIMER_COUNTER); + regmap_write(drvdata->map, TCU_REG_WDT_TDR, timeout_value); + regmap_write(drvdata->map, TCU_REG_WDT_TCNT, 0); - writeb(0x1, drvdata->base + JZ_REG_WDT_COUNTER_ENABLE); + regmap_write(drvdata->map, TCU_REG_WDT_TCER, TCU_WDT_TCER_TCEN); wdt_dev->timeout = new_timeout; return 0; @@ -96,7 +94,7 @@ static int jz4740_wdt_stop(struct watchdog_device *wdt_dev) { struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev); - writeb(0x0, drvdata->base + JZ_REG_WDT_COUNTER_ENABLE); + regmap_write(drvdata->map, TCU_REG_WDT_TCER, 0); clk_disable_unprepare(drvdata->clk); return 0; @@ -138,7 +136,6 @@ static int jz4740_wdt_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct jz4740_wdt_drvdata *drvdata; struct watchdog_device *jz4740_wdt; - struct resource *res; long rate; int ret; @@ -174,10 +171,11 @@ static int jz4740_wdt_probe(struct platform_device *pdev) watchdog_set_nowayout(jz4740_wdt, nowayout); watchdog_set_drvdata(jz4740_wdt, drvdata); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - drvdata->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(drvdata->base)) - return PTR_ERR(drvdata->base); + drvdata->map = dev_get_regmap(dev->parent, NULL); + if (!drvdata->map) { + dev_err(dev, "regmap not found\n"); + return -EINVAL; + } ret = devm_watchdog_register_device(&pdev->dev, &drvdata->wdt); if (ret < 0) -- 2.11.0