Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5444360imm; Tue, 21 Aug 2018 11:49:48 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxB/36DhHSXBlHy5Ys0N8SOG23baQwZvQ3fNDfaH0FynZFkYISkpYQIYhiOZv/Vh/iXa9/C X-Received: by 2002:a62:9042:: with SMTP id a63-v6mr54380548pfe.52.1534877388140; Tue, 21 Aug 2018 11:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534877388; cv=none; d=google.com; s=arc-20160816; b=RCf84XKrVWyWXP4lITfeEB3MrABU1w/Jxw/sssq60X1TygXEPa2SzWaTRUp0q9eddU +mpmIcH4nHO9cb4fA8cLO9IjHDgwmwsF70MKm6wlGLjbY6v0WGji2nIkgC+K51teiOCN W/bS4E6mjifwrVGt+GklSyapz/CsYeRDtOdWbEOJkKWbk7wqq9/RxwQZDSOFZcs0BuiF Om4fBuAMmO/g2tNh/VIb92J7VUbo8Xf8MS5wTGopVVcTFTVklj8VM8owYdQJXfJS1dSe 7Pq3lSf3PuHufL0epJ0ZnWCv2LOYgC+25F6E5ShmsJlt43heA+jh0JWjks/ZKU+2nivE ZhaQ== 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=fM3Kfrs201BnoBmqhC8GaYnqHG2NjHRAaBZsVsmcIMg=; b=CqsRl8gRnM/iIwh3PtdJuSzGvmwmrPaHPqbdY5yfJ9EHyIDO73/EN7ihBg/OM+sQ2I bphCk+EXwJ+fd+ZZk9CW1v8btiG4L4pmSQ0D+wNNZZLK3GaT9vsanc8ftpOHfVEMH6Iw JGicghSb/jModK6kKQYcU9EFaxEwYcTPoypSptneR/b9EoSpYVGmz3s+qr10S6fz2C2j D1AgzRmlJ5wHTDId3Ibi0Y9RWKQqBXkj4hC73lhT8ihj2iMdbqo6VE5YP+3CzzC7J+lq lYVYZ/mK+Wxq5mELSuswBB/5JCUKE/Hf+IvKxtb3eXE+DQk8LiozyDdDxtJOrlif6s1l cGKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=YyiCkrXY; 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 5-v6si12360331pgf.18.2018.08.21.11.49.31; Tue, 21 Aug 2018 11:49:48 -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=YyiCkrXY; 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 S1728171AbeHUUiI (ORCPT + 99 others); Tue, 21 Aug 2018 16:38:08 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:57628 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728050AbeHUUiH (ORCPT ); Tue, 21 Aug 2018 16:38:07 -0400 From: Paul Cercueil To: Thomas Gleixner , Daniel Lezcano , Rob Herring , Thierry Reding , Mark Rutland , Ralf Baechle , Paul Burton , Jonathan Corbet Cc: od@zcrc.me, Mathieu Malaterre , 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 v7 09/24] watchdog: jz4740: Use regmap provided by TCU driver Date: Tue, 21 Aug 2018 19:16:20 +0200 Message-Id: <20180821171635.22740-10-paul@crapouillou.net> In-Reply-To: <20180821171635.22740-1-paul@crapouillou.net> References: <20180821171635.22740-1-paul@crapouillou.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1534871824; bh=fM3Kfrs201BnoBmqhC8GaYnqHG2NjHRAaBZsVsmcIMg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=YyiCkrXYD4izhOEM90Fe3Pkdk74ZMWvwwI9qz1vfUVUroAHblbYatgELySBPe3dTThcLBaBws1v/akD69NUN8uR3SHQKoHNdxAgjCn7zb7kUR1KuSF7x2QqTOmH268SMXl3raCZHNSQKq0rBw2tGezWG9F94WhWmw+J4RuLdk/8= 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 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