From patchwork Mon Oct 16 20:54:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 115988 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4110243qgn; Mon, 16 Oct 2017 13:56:35 -0700 (PDT) X-Received: by 10.84.133.163 with SMTP id f32mr8989687plf.387.1508187395179; Mon, 16 Oct 2017 13:56:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508187395; cv=none; d=google.com; s=arc-20160816; b=RdV2XH3o/LTvoKeqsnCpn/Rie/WhhD2rZxa2i1JEiHIWV+USsTw+TbFG9eiF3c6Z9V BkG7SdpSr7HJZJytnoFkP19OattcTKdDpmB5rRADLWqjq/pRHHt0MsGEFZ+q37Xyl4sv NfbZJkXP0VSqkE5fU8UksAfzbivKIM6iqAAhrEP05DTFHLRUX/zIvsEVCxjhrcjstv7s 3uHcdmL74L6CL4PHRSsGKZ7+OhroWncKkr+RtXBJDCRmgYuH8oJY24RNsJe4T1TTnks+ CPAtg7V8ZPw71QjuEIkoxyobqz6lXsPPILck7NHV3daZVyd4m9bvfFHQLE+vCIE5IfBC ABlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=DQkTia++oI253MfnPcOrWxUvZGPOGy9PQ/i9C5g5UdA=; b=ia+LoJdTndcJUf+c9naDPGpgV33tiI+bZHznJ3+jaLx+CzVD/9KlG2wEsrUTpn1yEm ayNoKt6AKrcQF/u4iVAdwVAxhJk5J47zFjiOVwHcsfnfTIv5mBxMoPFRdZKnSG6sTuNN 0CSY/kagB1YqaYpF+iwBN1ZreDbjcTUl1b2LAHH7JmjyoRfoJ4U8wNOoFxdwyylTfH2X xVWTJT+ljio7lO52mcX106EeEs8rdOB1Aapn10x4K+n9COWwMHPvsCT5MUclZRVIrQgw WK3Y2ZU64anwdDYN2ZOLQPZ6LOTGHoaQE+5wWCA6eK22qqWKRdhlbLIlizqbX08ZEZqg iPJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LRAC4vNk; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si4854514pfc.233.2017.10.16.13.56.35 for ; Mon, 16 Oct 2017 13:56:35 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LRAC4vNk; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757490AbdJPU4e (ORCPT ); Mon, 16 Oct 2017 16:56:34 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:55536 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755144AbdJPU4e (ORCPT ); Mon, 16 Oct 2017 16:56:34 -0400 Received: by mail-lf0-f54.google.com with SMTP id p184so18467373lfe.12 for ; Mon, 16 Oct 2017 13:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=3qrfYvTugVfAi4tKBxa58D6k1dLlPlQfkF0VcLeWeBQ=; b=LRAC4vNkglUY08jMuvxUJP5vbnnD6IpM2p85fthnykrZGLKphrETwJG+bHi8VxYq06 8rPJ73e91AQE1WV3dyLBjE4OSx1LmmaGmg5XbsA+XdJWnGy0lNxNaujM3k9obx1mGpqe 4Cd+HtAyDDYTJs/2MOfmHVXJz8koHN7SCOcI0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3qrfYvTugVfAi4tKBxa58D6k1dLlPlQfkF0VcLeWeBQ=; b=ZQkvMwfu9bcqwRdJhHZSZOLbA/k4Ze09t74LfYL5JKdhsT5q6FMBcZwlFvBmpWbBGb dAbFpfSKPbt+/JPhK77RCr4l0E1w9K980NhVj2twsBj97a/i5qfIRxKNbZTkkJdBSNzv +DqixdxKaCUFLUwkFao3E3XhKYsP5MusNoncQ7sHPm+Pe8k2ut+dqGBUsySuoHG62BEl BHvcZLFj8/gWAkW9GFfivbDbMIVGzqeBx+Ao7keADuPNHtMHYSTkMMQvlFZiVIWgGjp7 xb8L8uLMLueWq/bG3iFGDCibaYM++WuaAD3SKG1rthrDv+gklpM8zXx5tsL9k4HEAKzS A+9A== X-Gm-Message-State: AMCzsaXaGLwp5r8WOMR8DIHIGQNcvXyjq+uLj3H8GiYv+IQ+b/kOQcrn +b7AgW3T2E+2J/6NNICCisa0QQ== X-Google-Smtp-Source: AOwi7QBu3LkoBIuYaAVDZEx6oryGUAkbcaw+zqOPanotspuJsQLwbMEOIzhJcyobJPOlDNSPVqB7fQ== X-Received: by 10.46.92.199 with SMTP id q190mr4815741ljb.88.1508187392601; Mon, 16 Oct 2017 13:56:32 -0700 (PDT) Received: from localhost.localdomain (c-5f7c71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.124.95]) by smtp.gmail.com with ESMTPSA id s88sm2131227lje.40.2017.10.16.13.56.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 13:56:31 -0700 (PDT) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck , Jonas Jensen , Andrew Jeffery , Joel Stanley Cc: linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org, Linus Walleij , devicetree@vger.kernel.org Subject: [PATCH 1/5 v2] watchdog: gemini/ftwdt010: rename DT bindings Date: Mon, 16 Oct 2017 22:54:23 +0200 Message-Id: <20171016205427.4297-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.6 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The device tree bindings are in two copies and also should be consolidated into a single Faraday Technology FTWDT010 binding since we uncovered that this IP part is a standard IP from Faraday. Cc: devicetree@vger.kernel.org Acked-by: Rob Herring Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Collect Rob's ACK. --- .../bindings/watchdog/cortina,gemini-watchdog.txt | 17 ----------------- ...{cortina,gemin-watchdog.txt => faraday,ftwdt010.txt} | 11 ++++++++--- 2 files changed, 8 insertions(+), 20 deletions(-) delete mode 100644 Documentation/devicetree/bindings/watchdog/cortina,gemini-watchdog.txt rename Documentation/devicetree/bindings/watchdog/{cortina,gemin-watchdog.txt => faraday,ftwdt010.txt} (55%) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Guenter Roeck diff --git a/Documentation/devicetree/bindings/watchdog/cortina,gemini-watchdog.txt b/Documentation/devicetree/bindings/watchdog/cortina,gemini-watchdog.txt deleted file mode 100644 index bc4b865d178b..000000000000 --- a/Documentation/devicetree/bindings/watchdog/cortina,gemini-watchdog.txt +++ /dev/null @@ -1,17 +0,0 @@ -Cortina Systems Gemini SoC Watchdog - -Required properties: -- compatible : must be "cortina,gemini-watchdog" -- reg : shall contain base register location and length -- interrupts : shall contain the interrupt for the watchdog - -Optional properties: -- timeout-sec : the default watchdog timeout in seconds. - -Example: - -watchdog@41000000 { - compatible = "cortina,gemini-watchdog"; - reg = <0x41000000 0x1000>; - interrupts = <3 IRQ_TYPE_LEVEL_HIGH>; -}; diff --git a/Documentation/devicetree/bindings/watchdog/cortina,gemin-watchdog.txt b/Documentation/devicetree/bindings/watchdog/faraday,ftwdt010.txt similarity index 55% rename from Documentation/devicetree/bindings/watchdog/cortina,gemin-watchdog.txt rename to Documentation/devicetree/bindings/watchdog/faraday,ftwdt010.txt index bc4b865d178b..9ecdb502e605 100644 --- a/Documentation/devicetree/bindings/watchdog/cortina,gemin-watchdog.txt +++ b/Documentation/devicetree/bindings/watchdog/faraday,ftwdt010.txt @@ -1,7 +1,12 @@ -Cortina Systems Gemini SoC Watchdog +Faraday Technology FTWDT010 watchdog + +This is an IP part from Faraday Technology found in the Gemini +SoCs and others. Required properties: -- compatible : must be "cortina,gemini-watchdog" +- compatible : must be one of + "faraday,ftwdt010" + "cortina,gemini-watchdog", "faraday,ftwdt010" - reg : shall contain base register location and length - interrupts : shall contain the interrupt for the watchdog @@ -11,7 +16,7 @@ Optional properties: Example: watchdog@41000000 { - compatible = "cortina,gemini-watchdog"; + compatible = "faraday,ftwdt010"; reg = <0x41000000 0x1000>; interrupts = <3 IRQ_TYPE_LEVEL_HIGH>; }; From patchwork Mon Oct 16 20:54:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 115989 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4110420qgn; Mon, 16 Oct 2017 13:56:50 -0700 (PDT) X-Received: by 10.159.255.70 with SMTP id u6mr9947117pls.25.1508187410368; Mon, 16 Oct 2017 13:56:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508187410; cv=none; d=google.com; s=arc-20160816; b=d0cq4D1Px8MPm+RfcNONgGe9xE/3NS0+Hs2N3+S7E6lSzHbZqNzbtswy6TxJMtbRh/ prehOi7YJCTfpsx/a4Zm3SVXxkMlb0MO23LQDQk3bRxzvefLqRA7LWA7Bpij5F9FmcQS NYxp0a65t2hEbMyu0LHoXTfjF2yh5nPfCzf/qnsZgKOnzm00hOMjuKCnDdmfkbSWSH02 h4stVc2rFhBmBt4hbsGkfsI4aFAOGlz3bbpJwaxpZbYoepK1kaGqbFzbBe+PQ0SOoKtA z5pWKmkHM/LBGUNmUrg3iduKRzt+r9yq8RP9CeFhA9FGG7/s74vwQmtAJhUrqfIP1Hm7 lN/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Q2JDPMrz1e5iyuB6nli0Xui7Wv7LdoeO7O1xpdR9BAI=; b=fEi3z/jC496O5RR59V4LEZvZv1aR9Aclap47GUwUu+0ehRssb95lHisSx9xNtIFv74 t5hjb+GMZ2Rq3WKNzCpbwCuNIc24qUyFOlgQTkxDKhnLxBKG1fUZJRCP1qvQZH1rGwsM 0HFNVTdAINPbKxp/TCXJovDMP03LvYRw2NI9Sn6ShEg4ypqSdwcz+JRzVo66LIm71WxK rFaBY8R0cuIzQwlIEh+lK0I6on2291KL1ZzepOWYKFZa45SNhXTvPkXYvZicHTGwiJTK MFqGHUVZTgLC2fzrxATWn0JhpLvGRrp2+arAuQWGLWHMUFH3YiqfOT92CRPY0zAje/i3 raBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fbcLbhLg; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si533400pff.595.2017.10.16.13.56.50 for ; Mon, 16 Oct 2017 13:56:50 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fbcLbhLg; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756553AbdJPU4u (ORCPT ); Mon, 16 Oct 2017 16:56:50 -0400 Received: from mail-lf0-f47.google.com ([209.85.215.47]:50203 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755144AbdJPU4t (ORCPT ); Mon, 16 Oct 2017 16:56:49 -0400 Received: by mail-lf0-f47.google.com with SMTP id a132so18451708lfa.7 for ; Mon, 16 Oct 2017 13:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K/0a6J2UyGrQnQSliaZVt1s+MOYFFwdyq/Daxk/LOmg=; b=fbcLbhLg9F1MSTRpOFkK/VyeBCHCMi32qOO/RTGWswgKxtN+iznmw0Ux1b+la4l2YF VP5CSj+B8BWMyY8z8HCQmpU3XyT0RUOGxIxzxYuPtYDM9WTbImaXmwVVGw0rTmQMjfoC NdpKiAxexYeYMuFek2kMBjW/ZfHCW6DG6ZNRQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K/0a6J2UyGrQnQSliaZVt1s+MOYFFwdyq/Daxk/LOmg=; b=KKVijUC4pJv60p0fyVOo+AW6ivSCc079Wu9i2zXx2l+bUSF6vMYjDcJlSIEneWdQFP KTKCRDyXk0jS0SjqpRif4koeHyZMzinTnfaZoPnKe2YurvLIjMh4VWTSjJ+gda6N4dfc SAxty1Fbra4Uqdobb01CsdV9cm+YYZahWqNumA8HwnsNQpILZfcAeJ5i+ro5ouNg8Y2M 5tTqAqi6iPUxHFK3AaIed9aAs1ABkfHFM/7Fkz+9C1Wcit1L9f474+ygGBNRrmV7090D ZQcPObpdxU4vrn5UN5TLWU2KVwi5+dn8PZteVhX5iAlP74dhG/oT1+9+pq+X//MnjjJu G+wA== X-Gm-Message-State: AMCzsaV0A8VX7uOHtyxpt6RFKQMi0W0GmWnSvJWfq2Wffa8WQJmzfbCn 9esd5e1wEPsyt/lW45drVknUUA== X-Google-Smtp-Source: ABhQp+Qpdb+BK5CMXbOYCBwHIA8LtmvhPjVI+SY/y6h7kQXevWivgVoGyQQraYDB4jPbg0jvskOhrA== X-Received: by 10.25.213.194 with SMTP id m185mr3314580lfg.175.1508187407644; Mon, 16 Oct 2017 13:56:47 -0700 (PDT) Received: from localhost.localdomain (c-5f7c71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.124.95]) by smtp.gmail.com with ESMTPSA id s88sm2131227lje.40.2017.10.16.13.56.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 13:56:46 -0700 (PDT) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck , Jonas Jensen , Andrew Jeffery , Joel Stanley Cc: linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org, Linus Walleij Subject: [PATCH 2/5 v2] watchdog: gemini/ftwdt010: rename driver and symbols Date: Mon, 16 Oct 2017 22:54:24 +0200 Message-Id: <20171016205427.4297-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016205427.4297-1-linus.walleij@linaro.org> References: <20171016205427.4297-1-linus.walleij@linaro.org> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org This renames all the driver files and symbols for the Gemini watchdog to FTWDT010 as it has been revealed that this IP block is a generic watchdog timer from Faraday Technology used in several SoC designs. Select this driver by default for the Gemini, it is a sensible driver to always have enabled. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Fixed speling in commit message, rebased. --- drivers/watchdog/Kconfig | 14 +-- drivers/watchdog/Makefile | 2 +- drivers/watchdog/{gemini_wdt.c => ftwdt010_wdt.c} | 117 +++++++++++----------- 3 files changed, 68 insertions(+), 65 deletions(-) rename drivers/watchdog/{gemini_wdt.c => ftwdt010_wdt.c} (50%) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Guenter Roeck diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index c722cbfdc7e6..fd44a542036a 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -321,16 +321,18 @@ config 977_WATCHDOG Not sure? It's safe to say N. -config GEMINI_WATCHDOG - tristate "Gemini watchdog" - depends on ARCH_GEMINI +config FTWDT010_WATCHDOG + tristate "Faraday Technology FTWDT010 watchdog" + depends on ARM || COMPILE_TEST select WATCHDOG_CORE + default ARCH_GEMINI help - Say Y here if to include support for the watchdog timer - embedded in the Cortina Systems Gemini family of devices. + Say Y here if to include support for the Faraday Technology + FTWDT010 watchdog timer embedded in the Cortina Systems Gemini + family of devices. To compile this driver as a module, choose M here: the - module will be called gemini_wdt. + module will be called ftwdt010_wdt. config IXP4XX_WATCHDOG tristate "IXP4xx Watchdog" diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 56adf9fa67d0..df91d7db821c 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -45,7 +45,7 @@ obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o obj-$(CONFIG_TWL4030_WATCHDOG) += twl4030_wdt.o obj-$(CONFIG_21285_WATCHDOG) += wdt285.o obj-$(CONFIG_977_WATCHDOG) += wdt977.o -obj-$(CONFIG_GEMINI_WATCHDOG) += gemini_wdt.o +obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o diff --git a/drivers/watchdog/gemini_wdt.c b/drivers/watchdog/ftwdt010_wdt.c similarity index 50% rename from drivers/watchdog/gemini_wdt.c rename to drivers/watchdog/ftwdt010_wdt.c index 8155aa619e4c..637ffd812f0b 100644 --- a/drivers/watchdog/gemini_wdt.c +++ b/drivers/watchdog/ftwdt010_wdt.c @@ -1,5 +1,5 @@ /* - * Watchdog driver for Cortina Systems Gemini SoC + * Watchdog driver for Faraday Technology FTWDT010 * * Copyright (C) 2017 Linus Walleij * @@ -22,10 +22,10 @@ #include #include -#define GEMINI_WDCOUNTER 0x0 -#define GEMINI_WDLOAD 0x4 -#define GEMINI_WDRESTART 0x8 -#define GEMINI_WDCR 0xC +#define FTWDT010_WDCOUNTER 0x0 +#define FTWDT010_WDLOAD 0x4 +#define FTWDT010_WDRESTART 0x8 +#define FTWDT010_WDCR 0xC #define WDRESTART_MAGIC 0x5AB9 @@ -35,79 +35,79 @@ #define WDT_CLOCK 5000000 /* 5 MHz */ -struct gemini_wdt { +struct ftwdt010_wdt { struct watchdog_device wdd; struct device *dev; void __iomem *base; }; static inline -struct gemini_wdt *to_gemini_wdt(struct watchdog_device *wdd) +struct ftwdt010_wdt *to_ftwdt010_wdt(struct watchdog_device *wdd) { - return container_of(wdd, struct gemini_wdt, wdd); + return container_of(wdd, struct ftwdt010_wdt, wdd); } -static int gemini_wdt_start(struct watchdog_device *wdd) +static int ftwdt010_wdt_start(struct watchdog_device *wdd) { - struct gemini_wdt *gwdt = to_gemini_wdt(wdd); + struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); - writel(wdd->timeout * WDT_CLOCK, gwdt->base + GEMINI_WDLOAD); - writel(WDRESTART_MAGIC, gwdt->base + GEMINI_WDRESTART); + writel(wdd->timeout * WDT_CLOCK, gwdt->base + FTWDT010_WDLOAD); + writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART); /* set clock before enabling */ writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST, - gwdt->base + GEMINI_WDCR); + gwdt->base + FTWDT010_WDCR); writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST | WDCR_ENABLE, - gwdt->base + GEMINI_WDCR); + gwdt->base + FTWDT010_WDCR); return 0; } -static int gemini_wdt_stop(struct watchdog_device *wdd) +static int ftwdt010_wdt_stop(struct watchdog_device *wdd) { - struct gemini_wdt *gwdt = to_gemini_wdt(wdd); + struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); - writel(0, gwdt->base + GEMINI_WDCR); + writel(0, gwdt->base + FTWDT010_WDCR); return 0; } -static int gemini_wdt_ping(struct watchdog_device *wdd) +static int ftwdt010_wdt_ping(struct watchdog_device *wdd) { - struct gemini_wdt *gwdt = to_gemini_wdt(wdd); + struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); - writel(WDRESTART_MAGIC, gwdt->base + GEMINI_WDRESTART); + writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART); return 0; } -static int gemini_wdt_set_timeout(struct watchdog_device *wdd, +static int ftwdt010_wdt_set_timeout(struct watchdog_device *wdd, unsigned int timeout) { wdd->timeout = timeout; if (watchdog_active(wdd)) - gemini_wdt_start(wdd); + ftwdt010_wdt_start(wdd); return 0; } -static irqreturn_t gemini_wdt_interrupt(int irq, void *data) +static irqreturn_t ftwdt010_wdt_interrupt(int irq, void *data) { - struct gemini_wdt *gwdt = data; + struct ftwdt010_wdt *gwdt = data; watchdog_notify_pretimeout(&gwdt->wdd); return IRQ_HANDLED; } -static const struct watchdog_ops gemini_wdt_ops = { - .start = gemini_wdt_start, - .stop = gemini_wdt_stop, - .ping = gemini_wdt_ping, - .set_timeout = gemini_wdt_set_timeout, +static const struct watchdog_ops ftwdt010_wdt_ops = { + .start = ftwdt010_wdt_start, + .stop = ftwdt010_wdt_stop, + .ping = ftwdt010_wdt_ping, + .set_timeout = ftwdt010_wdt_set_timeout, .owner = THIS_MODULE, }; -static const struct watchdog_info gemini_wdt_info = { +static const struct watchdog_info ftwdt010_wdt_info = { .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT, @@ -115,11 +115,11 @@ static const struct watchdog_info gemini_wdt_info = { }; -static int gemini_wdt_probe(struct platform_device *pdev) +static int ftwdt010_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; - struct gemini_wdt *gwdt; + struct ftwdt010_wdt *gwdt; unsigned int reg; int irq; int ret; @@ -138,8 +138,8 @@ static int gemini_wdt_probe(struct platform_device *pdev) return -EINVAL; gwdt->dev = dev; - gwdt->wdd.info = &gemini_wdt_info; - gwdt->wdd.ops = &gemini_wdt_ops; + gwdt->wdd.info = &ftwdt010_wdt_info; + gwdt->wdd.ops = &ftwdt010_wdt_ops; gwdt->wdd.min_timeout = 1; gwdt->wdd.max_timeout = 0xFFFFFFFF / WDT_CLOCK; gwdt->wdd.parent = dev; @@ -151,14 +151,14 @@ static int gemini_wdt_probe(struct platform_device *pdev) gwdt->wdd.timeout = 13U; watchdog_init_timeout(&gwdt->wdd, 0, dev); - reg = readw(gwdt->base + GEMINI_WDCR); + reg = readw(gwdt->base + FTWDT010_WDCR); if (reg & WDCR_ENABLE) { /* Watchdog was enabled by the bootloader, disable it. */ reg &= ~WDCR_ENABLE; - writel(reg, gwdt->base + GEMINI_WDCR); + writel(reg, gwdt->base + FTWDT010_WDCR); } - ret = devm_request_irq(dev, irq, gemini_wdt_interrupt, 0, + ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0, "watchdog bark", gwdt); if (ret) return ret; @@ -171,59 +171,60 @@ static int gemini_wdt_probe(struct platform_device *pdev) /* Set up platform driver data */ platform_set_drvdata(pdev, gwdt); - dev_info(dev, "Gemini watchdog driver enabled\n"); + dev_info(dev, "FTWDT010 watchdog driver enabled\n"); return 0; } -static int __maybe_unused gemini_wdt_suspend(struct device *dev) +static int __maybe_unused ftwdt010_wdt_suspend(struct device *dev) { - struct gemini_wdt *gwdt = dev_get_drvdata(dev); + struct ftwdt010_wdt *gwdt = dev_get_drvdata(dev); unsigned int reg; - reg = readw(gwdt->base + GEMINI_WDCR); + reg = readw(gwdt->base + FTWDT010_WDCR); reg &= ~WDCR_ENABLE; - writel(reg, gwdt->base + GEMINI_WDCR); + writel(reg, gwdt->base + FTWDT010_WDCR); return 0; } -static int __maybe_unused gemini_wdt_resume(struct device *dev) +static int __maybe_unused ftwdt010_wdt_resume(struct device *dev) { - struct gemini_wdt *gwdt = dev_get_drvdata(dev); + struct ftwdt010_wdt *gwdt = dev_get_drvdata(dev); unsigned int reg; if (watchdog_active(&gwdt->wdd)) { - reg = readw(gwdt->base + GEMINI_WDCR); + reg = readw(gwdt->base + FTWDT010_WDCR); reg |= WDCR_ENABLE; - writel(reg, gwdt->base + GEMINI_WDCR); + writel(reg, gwdt->base + FTWDT010_WDCR); } return 0; } -static const struct dev_pm_ops gemini_wdt_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(gemini_wdt_suspend, - gemini_wdt_resume) +static const struct dev_pm_ops ftwdt010_wdt_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(ftwdt010_wdt_suspend, + ftwdt010_wdt_resume) }; #ifdef CONFIG_OF -static const struct of_device_id gemini_wdt_match[] = { +static const struct of_device_id ftwdt010_wdt_match[] = { + { .compatible = "faraday,ftwdt010" }, { .compatible = "cortina,gemini-watchdog" }, {}, }; -MODULE_DEVICE_TABLE(of, gemini_wdt_match); +MODULE_DEVICE_TABLE(of, ftwdt010_wdt_match); #endif -static struct platform_driver gemini_wdt_driver = { - .probe = gemini_wdt_probe, +static struct platform_driver ftwdt010_wdt_driver = { + .probe = ftwdt010_wdt_probe, .driver = { - .name = "gemini-wdt", - .of_match_table = of_match_ptr(gemini_wdt_match), - .pm = &gemini_wdt_dev_pm_ops, + .name = "ftwdt010-wdt", + .of_match_table = of_match_ptr(ftwdt010_wdt_match), + .pm = &ftwdt010_wdt_dev_pm_ops, }, }; -module_platform_driver(gemini_wdt_driver); +module_platform_driver(ftwdt010_wdt_driver); MODULE_AUTHOR("Linus Walleij"); -MODULE_DESCRIPTION("Watchdog driver for Gemini"); +MODULE_DESCRIPTION("Watchdog driver for Faraday Technology FTWDT010"); MODULE_LICENSE("GPL"); From patchwork Mon Oct 16 20:54:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 115990 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4110459qgn; Mon, 16 Oct 2017 13:56:53 -0700 (PDT) X-Received: by 10.84.133.132 with SMTP id f4mr4591130plf.197.1508187413435; Mon, 16 Oct 2017 13:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508187413; cv=none; d=google.com; s=arc-20160816; b=z3DFP3GFKC9Pf5CWV7nv3ApKmTOn3kEw6zAHXRMDWRmvOUvXExGrcFatEtYrLji352 RI//8GHnlhYsDNv3b+73XN3ngSTBwXiqUMMXOy85O+L+xPnvlhzI3fBll2BmrMtOutsc ulUiW//E5BGWZNEmW33X4jgaLbQaivppiMN5GSEZz6aJxxbrVR3DMBmg7rp1uJnx8IXY V+jbCfjTim/jumV4JHRcsStDLjJC7atY6qLD8p4Kmg+eyRoq5DjJt6JHvE3jNKTSL/3Z 2gC93nB1um3vZAe+t4wK/svIy7GmrreRbaGH2E8X08Gzly+/efncTuCcJlxo9DmJelQm Yt4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=foFCpQt4kL9VzngFO5Xm2Se9UphMHwcivrYPLWquyLI=; b=MNS2jnWJ1E4S2+PIBBgpvzvBdnKjqsc/jiF4usYC3pLKwIEbo6pWMykJz9ohaIudMz AYgNt0f6NfPENDVMOS0owaiWBMJqbAFOjGoOXonLYe1mwVEZLaki6mpk+5uhCyYApam7 koqM1Ovt72PXe+SOgAAO9oFHFFNPGbJ/HADjMtcJowDSB4tHu0xw+SPM+5PfLfUXnGFL O8uXLKixuJI/JWP5+Jjwl63Iy+aqFE6gleF80vLfP+nWbQgUW2IEN9jpT2bpnbksmA5x w1Jj94Ys1C6er/SIM5aATB0MGidb+MVZAFfcEjIFqIGT4BX3FWlZmGlIQ0gAbj4RwAzw tVeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Zwwt+UI8; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si533400pff.595.2017.10.16.13.56.53 for ; Mon, 16 Oct 2017 13:56:53 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Zwwt+UI8; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756675AbdJPU4x (ORCPT ); Mon, 16 Oct 2017 16:56:53 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:52110 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755144AbdJPU4w (ORCPT ); Mon, 16 Oct 2017 16:56:52 -0400 Received: by mail-lf0-f41.google.com with SMTP id r129so18496637lff.8 for ; Mon, 16 Oct 2017 13:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9A+BNOiDa3aYLS3oENhnKHPLSc8SUB0rAx6vyyhxbwY=; b=Zwwt+UI8P3DiHBO/jpZyreHRlWYnxCLy/m9cS6Bd1fwdF8v2JzMcoXUaKIwbCqAkfY UnEMh8lnDMj38TOR4phzMFf0wK4YYqKYI1bgFFLZ5gKmvqvKlLL2Mr9xP3Sn00TryCGN I84iSTk2/NQG5N2oDHzDXCBhEvyaLri+e9l9w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9A+BNOiDa3aYLS3oENhnKHPLSc8SUB0rAx6vyyhxbwY=; b=PRnqkEHTff7m3uuNK/1pZmLBUUAsx/OVECbA467gF37732ilifpBPTOWe3DD7D0LYu qrR16gmMIy5rj3+Ejk5O3ycG5oHH+6DUdvihBBEdGxiXtFsLWXwkC+m17Siswb7Ps9Ez wwWcOA+D/sAelZ4IcYdu81FOld0FmpYdXM7mJ6CoEwBq/DpOz92bWgOCAuhXdiqEFeAV W2pjljSyGQK/+zAEaC4nlAl4tErdEgwPYWDHbopApliprlzzKKYnjOHb6jmL/X8ziNhk 22NAO2wJUT5B7n/D/geLfYDx8uBZ0f/9j1b4jsbHZhyjpy6E0tOTHYqLePtlMS9uCSUh UwNg== X-Gm-Message-State: AMCzsaWPM9NTIMhsUwB/dtV75eu/JWKFQDLbCl3/r8nMEQqtFEm5oeoA wUG+1Zk6a+lVBesZZ34/eF1Ysw== X-Google-Smtp-Source: ABhQp+QX/KHsUrc0LV7KnoCqP6tRMflJgFCjSgIojbMMyBhJ5XDOLaMufQuy2i11hw9t1/HpjlAbTA== X-Received: by 10.25.40.149 with SMTP id o143mr3483891lfo.237.1508187411093; Mon, 16 Oct 2017 13:56:51 -0700 (PDT) Received: from localhost.localdomain (c-5f7c71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.124.95]) by smtp.gmail.com with ESMTPSA id s88sm2131227lje.40.2017.10.16.13.56.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 13:56:50 -0700 (PDT) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck , Jonas Jensen , Andrew Jeffery , Joel Stanley Cc: linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org, Linus Walleij Subject: [PATCH 3/5 v2] watchdog: ftwdt010: Make interrupt optional Date: Mon, 16 Oct 2017 22:54:25 +0200 Message-Id: <20171016205427.4297-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016205427.4297-1-linus.walleij@linaro.org> References: <20171016205427.4297-1-linus.walleij@linaro.org> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The Moxart does not appear to be using the interrupt from the watchdog timer, maybe it's not even routed, so as to support more architectures with this driver, make the interrupt optional. While we are at it: actually enable the use of the interrupt if present by setting the right bit in the control register and define the missing control register bits. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Fix surplus flag assignment of enable |= WDCR_CLOCK_5MHZ --- drivers/watchdog/ftwdt010_wdt.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Guenter Roeck diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c index 637ffd812f0b..a9c2912ee280 100644 --- a/drivers/watchdog/ftwdt010_wdt.c +++ b/drivers/watchdog/ftwdt010_wdt.c @@ -30,6 +30,8 @@ #define WDRESTART_MAGIC 0x5AB9 #define WDCR_CLOCK_5MHZ BIT(4) +#define WDCR_WDEXT BIT(3) +#define WDCR_WDINTR BIT(2) #define WDCR_SYS_RST BIT(1) #define WDCR_ENABLE BIT(0) @@ -39,6 +41,7 @@ struct ftwdt010_wdt { struct watchdog_device wdd; struct device *dev; void __iomem *base; + bool has_irq; }; static inline @@ -50,14 +53,17 @@ struct ftwdt010_wdt *to_ftwdt010_wdt(struct watchdog_device *wdd) static int ftwdt010_wdt_start(struct watchdog_device *wdd) { struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); + u32 enable; writel(wdd->timeout * WDT_CLOCK, gwdt->base + FTWDT010_WDLOAD); writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART); /* set clock before enabling */ - writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST, - gwdt->base + FTWDT010_WDCR); - writel(WDCR_CLOCK_5MHZ | WDCR_SYS_RST | WDCR_ENABLE, - gwdt->base + FTWDT010_WDCR); + enable = WDCR_CLOCK_5MHZ | WDCR_SYS_RST; + writel(enable, gwdt->base + FTWDT010_WDCR); + if (gwdt->has_irq) + enable |= WDCR_WDINTR; + enable |= WDCR_ENABLE; + writel(enable, gwdt->base + FTWDT010_WDCR); return 0; } @@ -133,10 +139,6 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) if (IS_ERR(gwdt->base)) return PTR_ERR(gwdt->base); - irq = platform_get_irq(pdev, 0); - if (!irq) - return -EINVAL; - gwdt->dev = dev; gwdt->wdd.info = &ftwdt010_wdt_info; gwdt->wdd.ops = &ftwdt010_wdt_ops; @@ -158,10 +160,14 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) writel(reg, gwdt->base + FTWDT010_WDCR); } - ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0, - "watchdog bark", gwdt); - if (ret) - return ret; + irq = platform_get_irq(pdev, 0); + if (irq) { + ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0, + "watchdog bark", gwdt); + if (ret) + return ret; + gwdt->has_irq = true; + } ret = devm_watchdog_register_device(dev, &gwdt->wdd); if (ret) { From patchwork Mon Oct 16 20:54:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 115991 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4110489qgn; Mon, 16 Oct 2017 13:56:56 -0700 (PDT) X-Received: by 10.101.88.142 with SMTP id d14mr8925650pgu.36.1508187416695; Mon, 16 Oct 2017 13:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508187416; cv=none; d=google.com; s=arc-20160816; b=MXEiDjIHuiOg0+hu5OuIGJUkBOrkPVp/WyqcGXCBm67740uJ/WWGk4z955PI0W+Ck5 dVXtK5GErUiGChblGEZ4nwdaqg+bOlWjT88FhSOVCs8cbgIdkgyu6ynKvWLbmToBcPUY Qn/q0FFXJ/KZuY9p7xmuVE0GrLZZW6jGPdcZm0Q17ky2qYMnciXnVMxS9BKDbajIh4yl uouJzZL7AvlMETtFePqxjeHXpH71JrtKBlCGxO17dElhvdbROkrDWyit2ZM0v9tRW+d5 zOKeIl1+swYmdrd9OhnuhySX45z4cR1HfHJdcDh2wBlDvyie94eh1qie6YG+76nbnB2C wHjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Th6gTiO8k2w3M7WWHYcJmkTEg2+iKKTtNBVi9vVAmc8=; b=IaIUlCzrERqqAI64uh0ngGWDeLYdgM71NLMzmUqBRkLfrIpKHldArl9YLweWV8I50/ Q/dDSvQEGbKBoIKJK/6RcLUUmD6Xy8jnCH7xxT0NDoWiK7Pco6DqKMCCGkmBoAdV2Mnn 1XIUzTbOA0EBnXRPGq4o/mDI4pv03tcuJaBQZ0S5GinTONI+vrBULotpbosy9FftAzaj DxXcUqYvfuCW03aMfoCkp4oVFWINmXUTzIP3KkWzUz8l4ugDiQweBoNNK2BT5baG0RA/ 7P8SqhVLvzZnzU8HQsKBQyhktywn4vsLhHlWETnub/xg8U7uCW5CSskbL3e7q6AsYbGL 25SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WmLchNpJ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si533400pff.595.2017.10.16.13.56.56 for ; Mon, 16 Oct 2017 13:56:56 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WmLchNpJ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756681AbdJPU44 (ORCPT ); Mon, 16 Oct 2017 16:56:56 -0400 Received: from mail-lf0-f48.google.com ([209.85.215.48]:57005 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754256AbdJPU4z (ORCPT ); Mon, 16 Oct 2017 16:56:55 -0400 Received: by mail-lf0-f48.google.com with SMTP id 90so18477098lfs.13 for ; Mon, 16 Oct 2017 13:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G7Sw8uKwb6WrA4VDLGB9FInQ9PQivMaZriugftJaVOs=; b=WmLchNpJ5hPbARZthJSEuqp66hTe0XOwlcf1paLCMjDenZL4+Au1ozczE0IR6N1Mfd ZwTs/uBFIVRbTX8nf8TwHJcya88wtgORav6kYoekiXD+ThtNlnQ+lJbO0tdSmC+Sn0Z9 4Z8onsmtfEvKBEKAsKj4jWk0K2KbP+TQCxLFA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G7Sw8uKwb6WrA4VDLGB9FInQ9PQivMaZriugftJaVOs=; b=QeVrTJ6Yy/4TZJBwzFkR444qw8ShfDa0UTXp7mVi5LfKW5LcT+yCRAgrKDySPyzOt6 d4s3m7Sb5yvLEnNgrB92ZAzaOEeysNdLID/V3KyIJJsJKqJLdL7j01QFVdWKsmxncT4H YmpuafLzUhEPLKupRGoG/TM3umS0HO+waQpbdLH31OnvmLld2D2goLla/UNuNM2+Lb51 RvY/uwkJBnYC5js4hqzuyh4rTbyLhqpNiXN00ZeEmO8Gud7Yre5XVhV/QydAVQOz02IP bg8WF43IeSt89ufrLypfxDqeuuTj8MXwA3zy51bvrwf1VuKCYuTdeW98hmpfKKSP3TCU RWOw== X-Gm-Message-State: AMCzsaXTNXVHBNn/gIsUm/1DpkUUVHzCYMRRiv62IQKe23FAGdhlqorr RTe5/Y8fouwdJ52kLZreVfGzWA== X-Google-Smtp-Source: ABhQp+SkW6vT1hHPno0+b1gQPI5uRgzhyb5eIQESoBWPeHV2lSneJrzulBIbiSuJ88RMJyI+GaHHmw== X-Received: by 10.25.67.4 with SMTP id q4mr3296293lfa.69.1508187414068; Mon, 16 Oct 2017 13:56:54 -0700 (PDT) Received: from localhost.localdomain (c-5f7c71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.124.95]) by smtp.gmail.com with ESMTPSA id s88sm2131227lje.40.2017.10.16.13.56.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 13:56:53 -0700 (PDT) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck , Jonas Jensen , Andrew Jeffery , Joel Stanley Cc: linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org, Linus Walleij Subject: [PATCH 4/5 v2] watchdog: ftwdt010: Add clock support Date: Mon, 16 Oct 2017 22:54:26 +0200 Message-Id: <20171016205427.4297-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016205427.4297-1-linus.walleij@linaro.org> References: <20171016205427.4297-1-linus.walleij@linaro.org> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The Gemini platform now provides a proper clock look-up for this and other IPs, so add clock support to the driver. This also aids in using the same driver with other platforms such as MOXA ART. The IP has two clock inputs: PCLK (the IP peripheral clock) and EXTCLK (an external clock). We are a bit elaborate around this: on Gemini the EXTCLK is used by default today and it's 5MHz, and on MOXA ART the PCLK is used. On Aspeed the EXTCLK is used and it's 1MHz. So add some clever code to fall back to platform defaults if PCLK or EXTCLK is not provided by the device tree. Take this opportunity to implement .remove() for the driver that stops the watchdog and disables the clocks. Add credits that this code is inspired by MOXA ART. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Strictly require the clock framework - Sort header files in alphabetic order - Fix the error path to properly disable the clocks - Fix spelling in commit message - Be minimalist with informational messages and cut down on error messages --- drivers/watchdog/Kconfig | 1 + drivers/watchdog/ftwdt010_wdt.c | 79 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 71 insertions(+), 9 deletions(-) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index fd44a542036a..245cff03c992 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -324,6 +324,7 @@ config 977_WATCHDOG config FTWDT010_WATCHDOG tristate "Faraday Technology FTWDT010 watchdog" depends on ARM || COMPILE_TEST + depends on COMMON_CLK select WATCHDOG_CORE default ARCH_GEMINI help diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c index a9c2912ee280..21c3ac7f557a 100644 --- a/drivers/watchdog/ftwdt010_wdt.c +++ b/drivers/watchdog/ftwdt010_wdt.c @@ -5,6 +5,8 @@ * * Inspired by the out-of-tree drivers from OpenWRT: * Copyright (C) 2009 Paulius Zaleckas + * Inspired by the MOXA ART driver from Jonas Jensen: + * Copyright (C) 2013 Jonas Jensen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -12,12 +14,14 @@ */ #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -29,19 +33,21 @@ #define WDRESTART_MAGIC 0x5AB9 -#define WDCR_CLOCK_5MHZ BIT(4) +#define WDCR_EXTCLK BIT(4) #define WDCR_WDEXT BIT(3) #define WDCR_WDINTR BIT(2) #define WDCR_SYS_RST BIT(1) #define WDCR_ENABLE BIT(0) -#define WDT_CLOCK 5000000 /* 5 MHz */ - struct ftwdt010_wdt { struct watchdog_device wdd; struct device *dev; void __iomem *base; bool has_irq; + struct clk *pclk; + struct clk *extclk; + unsigned int clk_freq; + bool use_extclk; }; static inline @@ -55,10 +61,12 @@ static int ftwdt010_wdt_start(struct watchdog_device *wdd) struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); u32 enable; - writel(wdd->timeout * WDT_CLOCK, gwdt->base + FTWDT010_WDLOAD); + writel(wdd->timeout * gwdt->clk_freq, gwdt->base + FTWDT010_WDLOAD); writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART); /* set clock before enabling */ - enable = WDCR_CLOCK_5MHZ | WDCR_SYS_RST; + enable = WDCR_SYS_RST; + if (gwdt->use_extclk) + enable |= WDCR_EXTCLK; writel(enable, gwdt->base + FTWDT010_WDCR); if (gwdt->has_irq) enable |= WDCR_WDINTR; @@ -124,6 +132,7 @@ static const struct watchdog_info ftwdt010_wdt_info = { static int ftwdt010_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; struct resource *res; struct ftwdt010_wdt *gwdt; unsigned int reg; @@ -139,11 +148,40 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) if (IS_ERR(gwdt->base)) return PTR_ERR(gwdt->base); + gwdt->use_extclk = of_property_read_bool(np, "faraday,use-extclk"); + + gwdt->pclk = devm_clk_get(dev, "PCLK"); + if (IS_ERR(gwdt->pclk)) + return PTR_ERR(gwdt->pclk); + ret = clk_prepare_enable(gwdt->pclk); + if (ret) + return ret; + if (!gwdt->use_extclk) + gwdt->clk_freq = clk_get_rate(gwdt->pclk); + + /* Only enable and get frequency from EXTCLK if it's in use */ + if (gwdt->use_extclk) { + gwdt->extclk = devm_clk_get(dev, "EXTCLK"); + if (IS_ERR(gwdt->extclk)) { + ret = PTR_ERR(gwdt->extclk); + goto out_disable_pclk; + } + ret = clk_prepare_enable(gwdt->extclk); + if (ret) + goto out_disable_pclk; + gwdt->clk_freq = clk_get_rate(gwdt->extclk); + } + + if (gwdt->clk_freq == 0) { + ret = -EINVAL; + goto out_disable_extclk; + } + gwdt->dev = dev; gwdt->wdd.info = &ftwdt010_wdt_info; gwdt->wdd.ops = &ftwdt010_wdt_ops; gwdt->wdd.min_timeout = 1; - gwdt->wdd.max_timeout = 0xFFFFFFFF / WDT_CLOCK; + gwdt->wdd.max_timeout = UINT_MAX / gwdt->clk_freq; gwdt->wdd.parent = dev; /* @@ -165,19 +203,41 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) ret = devm_request_irq(dev, irq, ftwdt010_wdt_interrupt, 0, "watchdog bark", gwdt); if (ret) - return ret; + goto out_disable_extclk; gwdt->has_irq = true; } ret = devm_watchdog_register_device(dev, &gwdt->wdd); if (ret) { dev_err(&pdev->dev, "failed to register watchdog\n"); - return ret; + goto out_disable_extclk; } /* Set up platform driver data */ platform_set_drvdata(pdev, gwdt); - dev_info(dev, "FTWDT010 watchdog driver enabled\n"); + dev_info(dev, "FTWDT010 watchdog driver @%uHz\n", + gwdt->clk_freq); + + return 0; + +out_disable_extclk: + if (gwdt->use_extclk) + clk_disable_unprepare(gwdt->extclk); +out_disable_pclk: + if (!IS_ERR(gwdt->pclk)) + clk_disable_unprepare(gwdt->pclk); + + return ret; +} + +static int ftwdt010_wdt_remove(struct platform_device *pdev) +{ + struct ftwdt010_wdt *gwdt = platform_get_drvdata(pdev); + + writel(0, gwdt->base + FTWDT010_WDCR); + clk_disable_unprepare(gwdt->pclk); + if (gwdt->use_extclk) + clk_disable_unprepare(gwdt->extclk); return 0; } @@ -224,6 +284,7 @@ MODULE_DEVICE_TABLE(of, ftwdt010_wdt_match); static struct platform_driver ftwdt010_wdt_driver = { .probe = ftwdt010_wdt_probe, + .remove = ftwdt010_wdt_remove, .driver = { .name = "ftwdt010-wdt", .of_match_table = of_match_ptr(ftwdt010_wdt_match), From patchwork Mon Oct 16 20:54:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 115992 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4110511qgn; Mon, 16 Oct 2017 13:56:58 -0700 (PDT) X-Received: by 10.99.4.133 with SMTP id 127mr8950688pge.72.1508187418728; Mon, 16 Oct 2017 13:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508187418; cv=none; d=google.com; s=arc-20160816; b=kWsTPIKL+gv7YVChDCkZJKF/1W4I5pCQUTP4ermEozgps/XPiIeXSJGZ/djTW40zrh zcdkSVb3BQi4ssZglC75sFnjUw63fknT10B9JhXSQbfSCBiBIWi/drfNwzY9UDb5mK/V 7pUJ+u8GvcdgoXlOAf9X+54ox+LyBVoWAAme0PqdbXoTdxIcqdn7tEdTh5c6G+2Usedn ujnb7KNLf5WDx4JVJ3OaHBOZhyAz7N4Bjv4GZ0iJ020bWQj/Uf1xyFWjAjzaUcZWqTD5 faMjMqM85j+tiOF2z0/TA29qr3xQxEZUxdCSCNwMI2ptj6M34lT+TA1zYkM01jxk4fO0 U6Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ru7YUIKmLtuQLQJnkPx3BLoL8uVNm6RZlzrnrd/M+TU=; b=wGlq9t8WSX3anMaoFPshFyKEAcwBn0Vbb96Y8CibSRn5frs+VCaQ8M16KoqBoG78uS GYaAPY/6/wxt6t1W0DfvuJARxDrMqFcDg4cSbvqPEFGpsqjzPirk6l/7x3oCIgRbU4ii I6VLf4/X7kBiQdJTU0ErbmYIzXpEWFPG5N8dsmvgkKrf4SqYqqWdvTdemqxkvwtvgE49 Xqg1YcREK3tKoW1q9HPt6oriZb3n8z4dtVugR8Pv/6kl1rrn81t/iHNGa5LQA2UMcSzy Cfj0AGmlIA/ktCZoH8+5kR0x+rN20D7i21DnvDf9mW7g6bKROz8Bw8Uegd2/ITSlIiHO wBrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UZSXIneS; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si533400pff.595.2017.10.16.13.56.58 for ; Mon, 16 Oct 2017 13:56:58 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UZSXIneS; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755144AbdJPU46 (ORCPT ); Mon, 16 Oct 2017 16:56:58 -0400 Received: from mail-lf0-f51.google.com ([209.85.215.51]:43816 "EHLO mail-lf0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754256AbdJPU45 (ORCPT ); Mon, 16 Oct 2017 16:56:57 -0400 Received: by mail-lf0-f51.google.com with SMTP id a16so18494392lfk.0 for ; Mon, 16 Oct 2017 13:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Wg/OI1Wni53JoqMtXH7/Y38F2v6dFRpG8nX/7YUIhxM=; b=UZSXIneSHYq9OUtArQPNn0HMC8PjhZQM63SgIBspXyoqJgayI2DrPzviWkYSojxXJX Nw/M/gcxWQ/dOerRgu5DjN6SkBxI0wqYAaq4lrOjWCodCrFUIn4UhJnELM2TllKrn06W xEfTdwugt/zKjtgns4D43xqdw/bLQFZYKQmMM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Wg/OI1Wni53JoqMtXH7/Y38F2v6dFRpG8nX/7YUIhxM=; b=gGYbPwUEOYG/tyF7MfIFQtIrjhbwbjCevko/AnRTbUIzLZ3XcwF/i133ThFKiGHd7a 3pu7dPaHb01KJWDCjU/PI6SdTNo3FXv3RGYM59a/4JkIiOSDrPi5E4i7bLLvXOgV2fM+ WWfNYWpdpIIvkZWntSKT0Ccyes2h3Z0YPfovAb6v/zlBseFfRQ4TjIXcCENx4kXLCK8I 6Rme5q3uDs+bqnKhdIRJGwIRSdvSe4PL8pmHvBDEA4XC4igq8zWcjpigJao8+rb3gs+c PZXbmM2Ls56axiViVy+BEzk7SV1XD4RPgI0N0oHVEFOF/+dcND9+YDc27Trl4AuoINig 33VQ== X-Gm-Message-State: AMCzsaXt0/R76f5tTC36CQ7byca7Zol0Af/43FgALsZKlrlRfX/5O5dp E6DLlmHUt5a47xr79UH0K6v/Cw== X-Google-Smtp-Source: ABhQp+RRm7a/gEVARdqyUuD5Bgvr92fv3AU0xB4AxCvferDgmRcpc3B7uELovEMJaofOsL/+rZUDMw== X-Received: by 10.25.151.206 with SMTP id z197mr3308214lfd.3.1508187416546; Mon, 16 Oct 2017 13:56:56 -0700 (PDT) Received: from localhost.localdomain (c-5f7c71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.124.95]) by smtp.gmail.com with ESMTPSA id s88sm2131227lje.40.2017.10.16.13.56.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 13:56:55 -0700 (PDT) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck , Jonas Jensen , Andrew Jeffery , Joel Stanley Cc: linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org, Linus Walleij Subject: [PATCH 5/5 v2] watchdog: ftwdt010: Add restart support Date: Mon, 16 Oct 2017 22:54:27 +0200 Message-Id: <20171016205427.4297-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016205427.4297-1-linus.walleij@linaro.org> References: <20171016205427.4297-1-linus.walleij@linaro.org> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org This enables the Faraday FTWDT010 to restart the system, if need be. Set the restart priority for the watchdog to 128. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebased, no changes. --- drivers/watchdog/ftwdt010_wdt.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Guenter Roeck diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c index 21c3ac7f557a..0be7c2db642d 100644 --- a/drivers/watchdog/ftwdt010_wdt.c +++ b/drivers/watchdog/ftwdt010_wdt.c @@ -56,6 +56,22 @@ struct ftwdt010_wdt *to_ftwdt010_wdt(struct watchdog_device *wdd) return container_of(wdd, struct ftwdt010_wdt, wdd); } +static int ftwdt010_wdt_restart(struct watchdog_device *wdd, + unsigned long action, void *data) +{ + struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); + u32 enable; + + writel(1, gwdt->base + FTWDT010_WDLOAD); + writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART); + enable = WDCR_SYS_RST | WDCR_ENABLE; + if (gwdt->use_extclk) + enable |= WDCR_EXTCLK; + writel(enable, gwdt->base + FTWDT010_WDCR); + + return 0; +} + static int ftwdt010_wdt_start(struct watchdog_device *wdd) { struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); @@ -118,6 +134,7 @@ static const struct watchdog_ops ftwdt010_wdt_ops = { .stop = ftwdt010_wdt_stop, .ping = ftwdt010_wdt_ping, .set_timeout = ftwdt010_wdt_set_timeout, + .restart = ftwdt010_wdt_restart, .owner = THIS_MODULE, }; @@ -190,6 +207,7 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) */ gwdt->wdd.timeout = 13U; watchdog_init_timeout(&gwdt->wdd, 0, dev); + watchdog_set_restart_priority(&gwdt->wdd, 128); reg = readw(gwdt->base + FTWDT010_WDCR); if (reg & WDCR_ENABLE) {