Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp170277imu; Wed, 12 Dec 2018 14:20:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/XBG9V9AmN+y3t9iMXrfbcYmaXGcvcx50CDGdu8Qrf6pBSmJ4Z0+ucF29gEFfGYwfgyafm0 X-Received: by 2002:a62:43c1:: with SMTP id l62mr22324455pfi.22.1544653234638; Wed, 12 Dec 2018 14:20:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544653234; cv=none; d=google.com; s=arc-20160816; b=kSa/TponJLj7SpON3lj7O6/UFmPirFC6wIysWLZjOC9uQNce1XArDRfVzPgqKjqseb Mnv9RRytPoXY7TVueoSfVzCvAtOsSq17ZGss7oEyRPajK489dbzUzFpUAqrBFyMz0/ih FJsDdLb1YEMLg8gx4xAtNO3x/+Yma981xRhPEJVmL6PX6ZxfRpK35Dpu9GbptPNefQmD DIwzBh69xY1i9RJg1Rwo8NDEdhAcnKwa+ReiO7NnLZrNr+Cw0BBvQRsIgIzqcD65C6CI BWaH2DW+XbJy0EyNgEgxlQmb3uLbSm7TWy1FOZmnljIuEJ4wew00W9IHGJ+tXjbc4WMI ZkTA== 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; bh=H4qA9cDxe/Ufo9FrWis+Z/7T9dlzOpAFd453C5di8Wg=; b=nppa8ppiE+nvLRPvIu9X6TKhMAmf5JZLpXxKdjLr3yzuj24B+ankDtwiy2g6RxbhaE J04AazkuZX100cwq16MRBK/rpd6xM26gp8E83UN5vBEhdIypD+X68OyuRpiCkV5XI/tZ Nx3sD7wRdN3RyMtSICxEKs4wPKssMjtf8IApPEFvscjo00MYH41BTXP1h7VJFhZWceFT 0lTf6xN+aOuHrjFgruBQZlXLcj4l9foDXVXUheRDUst/F5CQIRjmp4TKIbiqn/B85V7W pdQ6T4woUPONYvWH3KinYeRoDzUzU2wszk38pev75KHkpMZAwTkFhxEAaYbiiWwt2Jyt pOhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=uhnZLXn9; 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 t75si10969pfa.170.2018.12.12.14.20.19; Wed, 12 Dec 2018 14:20:34 -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; dkim=pass header.i=@crapouillou.net header.s=mail header.b=uhnZLXn9; 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 S1726437AbeLLWQu (ORCPT + 99 others); Wed, 12 Dec 2018 17:16:50 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:40702 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728544AbeLLWQt (ORCPT ); Wed, 12 Dec 2018 17:16:49 -0500 From: Paul Cercueil To: Thierry Reding , Rob Herring , Mark Rutland , Daniel Lezcano , Thomas Gleixner , Ralf Baechle , Paul Burton , James Hogan , Jonathan Corbet Cc: Mathieu Malaterre , Ezequiel Garcia , PrasannaKumar Muralidharan , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-mips@vger.kernel.org, linux-doc@vger.kernel.org, linux-clk@vger.kernel.org, od@zcrc.me, Paul Cercueil Subject: [PATCH v8 08/26] watchdog: jz4740: Use regmap provided by TCU driver Date: Wed, 12 Dec 2018 23:09:03 +0100 Message-Id: <20181212220922.18759-9-paul@crapouillou.net> In-Reply-To: <20181212220922.18759-1-paul@crapouillou.net> References: <20181212220922.18759-1-paul@crapouillou.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1544652588; bh=H4qA9cDxe/Ufo9FrWis+Z/7T9dlzOpAFd453C5di8Wg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=uhnZLXn9rySE3zUZ8SV78go0RtaSqDRYwxpjdBmgm9VAljjE6UlMoxBRa5YYfO/NQ2bHN+rGPDXuZ8nHZkhKz9KSObBrMDGHreRiYbdcboKVfcek7xZfWOQsE/2+oEXIAIZ0zVCebFsrSaRmik30lQ9c8y5PJm6QFzvLP1qchko= 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 Reviewed-by: Guenter Roeck --- Notes: v6: New patch v7: No change v8: No change drivers/watchdog/jz4740_wdt.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) 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