From patchwork Thu Mar 30 11:20:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13193972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB92AC761AF for ; Thu, 30 Mar 2023 11:21:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231365AbjC3LVM (ORCPT ); Thu, 30 Mar 2023 07:21:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbjC3LVG (ORCPT ); Thu, 30 Mar 2023 07:21:06 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D42DE449A; Thu, 30 Mar 2023 04:21:05 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id l7so16910555pjg.5; Thu, 30 Mar 2023 04:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680175265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8qPjPY4rOaOWxQnpPT7yX4J8p0DxvMIyZ19Ti3CrP8k=; b=Gasiho6ufA0o9VzpPzQe+TrZ455lvy7seyjfpT/NUjkVtNNlQ1ZNWxxziHbsOPOHmo Zi7nsNzSrsuTY0j7RIX58ajMmQDIb9UzrMAvcbEBjN0biMqeEhh7HN9eAjxIewrwad+L qlvQqLNgYDHhU7WrMWvz42RMnrAEPUEu6MByulFfhhDS24t0GaZM8o4KEo9Xx/GT7QtW inqiL/JXFL+jADh3W5ce20xeqLzH0RWY6R1VMBn1cVR2hYub5umw+/0XfJE2dI9OyFUY qo1f5P2K+wwC+pwaRKjgjc5d+0isfVtmzF6IMEyN9iEzT+5Jc8Cpwd83TZsqQzPkKFRs eOsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680175265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8qPjPY4rOaOWxQnpPT7yX4J8p0DxvMIyZ19Ti3CrP8k=; b=suGly7g5TKGyaIbo6VMHTqQs9Aqt3jRieLY1JjuOdm/v3N1HqNUlEyXtXBrQ812I3e OCBOGOTKXDbRM5NAdargZsgheA5nmWAONeKDPj4NAWPSp5dV4o16qRCoZRk+NOd1/GTW Ux4qXRDPdN4v2qvS86AZukCBe/weU6MECNrAUsSlyP1h2WhagzMvR2bDsBHHD7hfKJbM 7vPpNf7jQVKDxaWvbcgidnSFkgcTXWFVRfhQRiZrK01fvtqDyC/6swr7fsNwgobVgwvh K6fkZvcoBcAB2jvwY871hXGdsor/cxXJBqV+84605mHC2s3hFwvZxIOJDLunODk/F063 nxlA== X-Gm-Message-State: AAQBX9ec0qj7tyzM/odzCQ3BQCDxV1cLVkSHFjqKANuTNJxCRzbfqIYF BCiOMa31hq2V0rGsg3MwkGEqxtWjCMhIog== X-Google-Smtp-Source: AKy350YgchrV5Du27KSVXfAc0YfE8zkjThtjpFHfLMjv53HgSDO9D949xZfLWl4NpVoJRYGjScA8tQ== X-Received: by 2002:a17:902:e545:b0:1a1:bede:5e4a with SMTP id n5-20020a170902e54500b001a1bede5e4amr29179635plf.49.1680175264796; Thu, 30 Mar 2023 04:21:04 -0700 (PDT) Received: from kelvin-ThinkPad-L14-Gen-1.. (94.130.220.35.bc.googleusercontent.com. [35.220.130.94]) by smtp.gmail.com with ESMTPSA id a13-20020a170902ee8d00b0019f11a68c42sm24444851pld.297.2023.03.30.04.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 04:21:04 -0700 (PDT) From: Keguang Zhang To: linux-watchdog@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wim Van Sebroeck , Guenter Roeck , Thomas Bogendoerfer , Yang Ling , Keguang Zhang Subject: [PATCH v2 1/2] MIPS: Loongson32: Remove reset.c Date: Thu, 30 Mar 2023 19:20:50 +0800 Message-Id: <20230330112051.551648-2-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230330112051.551648-1-keguang.zhang@gmail.com> References: <20230330112051.551648-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org The Loongson-1 restart handler will be moved to watchdog driver, then _machine_restart is no longer needed. The _machine_halt and pm_power_off are also unnecessary, which contain no hardware operations. Therefore, remove the entire reset.c and related header file. Update the Makefile accordingly. Signed-off-by: Keguang Zhang --- V1 -> V2: Remove the reference to regs-wdt.h --- .../include/asm/mach-loongson32/loongson1.h | 1 - .../include/asm/mach-loongson32/regs-wdt.h | 15 ------ arch/mips/loongson32/common/Makefile | 2 +- arch/mips/loongson32/common/reset.c | 51 ------------------- 4 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 arch/mips/include/asm/mach-loongson32/regs-wdt.h delete mode 100644 arch/mips/loongson32/common/reset.c diff --git a/arch/mips/include/asm/mach-loongson32/loongson1.h b/arch/mips/include/asm/mach-loongson32/loongson1.h index eb3ddbec1752..50358f1a6181 100644 --- a/arch/mips/include/asm/mach-loongson32/loongson1.h +++ b/arch/mips/include/asm/mach-loongson32/loongson1.h @@ -49,6 +49,5 @@ #include #include #include -#include #endif /* __ASM_MACH_LOONGSON32_LOONGSON1_H */ diff --git a/arch/mips/include/asm/mach-loongson32/regs-wdt.h b/arch/mips/include/asm/mach-loongson32/regs-wdt.h deleted file mode 100644 index c6d345fe13f2..000000000000 --- a/arch/mips/include/asm/mach-loongson32/regs-wdt.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (c) 2011 Zhang, Keguang - * - * Loongson 1 Watchdog Register Definitions. - */ - -#ifndef __ASM_MACH_LOONGSON32_REGS_WDT_H -#define __ASM_MACH_LOONGSON32_REGS_WDT_H - -#define WDT_EN 0x0 -#define WDT_TIMER 0x4 -#define WDT_SET 0x8 - -#endif /* __ASM_MACH_LOONGSON32_REGS_WDT_H */ diff --git a/arch/mips/loongson32/common/Makefile b/arch/mips/loongson32/common/Makefile index 7b49c8260706..f3950d308187 100644 --- a/arch/mips/loongson32/common/Makefile +++ b/arch/mips/loongson32/common/Makefile @@ -3,4 +3,4 @@ # Makefile for common code of loongson1 based machines. # -obj-y += time.o irq.o platform.o prom.o reset.o setup.o +obj-y += time.o irq.o platform.o prom.o setup.o diff --git a/arch/mips/loongson32/common/reset.c b/arch/mips/loongson32/common/reset.c deleted file mode 100644 index 0c7399b303fb..000000000000 --- a/arch/mips/loongson32/common/reset.c +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (c) 2011 Zhang, Keguang - */ - -#include -#include -#include -#include -#include - -#include - -static void __iomem *wdt_reg_base; - -static void ls1x_halt(void) -{ - while (1) { - if (cpu_wait) - cpu_wait(); - } -} - -static void ls1x_restart(char *command) -{ - __raw_writel(0x1, wdt_reg_base + WDT_EN); - __raw_writel(0x1, wdt_reg_base + WDT_TIMER); - __raw_writel(0x1, wdt_reg_base + WDT_SET); - - ls1x_halt(); -} - -static void ls1x_power_off(void) -{ - ls1x_halt(); -} - -static int __init ls1x_reboot_setup(void) -{ - wdt_reg_base = ioremap(LS1X_WDT_BASE, (SZ_4 + SZ_8)); - if (!wdt_reg_base) - panic("Failed to remap watchdog registers"); - - _machine_restart = ls1x_restart; - _machine_halt = ls1x_halt; - pm_power_off = ls1x_power_off; - - return 0; -} - -arch_initcall(ls1x_reboot_setup); From patchwork Thu Mar 30 11:20:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13193973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB57AC761A6 for ; Thu, 30 Mar 2023 11:21:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231204AbjC3LVP (ORCPT ); Thu, 30 Mar 2023 07:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231211AbjC3LVN (ORCPT ); Thu, 30 Mar 2023 07:21:13 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AE369757; Thu, 30 Mar 2023 04:21:10 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id r7-20020a17090b050700b002404be7920aso17553143pjz.5; Thu, 30 Mar 2023 04:21:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680175269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=flDRWY0SXQRWGYI8uX7jYuDz+uuIEnYkNVcdxGhVOsI=; b=Mn71fKPWKew4GV3Y3GsROsed1zcfc+1BIcYGztLPKC0GctJCg+Dwvj2NH7evxApdsz 6HqifP31lg3OxLHgGkqAbe/NPJj6XK1eZk/+YzRYJ+GMXMXrcx6pkVPdt8gB8AjOjtkC LtPTaESeeeQ5BIcQgq7EVfyls4FzwGBET244bz3hJ4VmK+lXYzlHm1Pb3cdRUpXJ6BUZ uOFFcrfG1p6yghsT8yHU1A6Zy4PnFklibtIq9phdquxIzA7LMs3WMChNVFFuswQLtnaa 4JflHBRCBV/Wisnw1+n77WfcN/LgOXvaN7sFXZYwXfdSULUdVS/qkHY420hNMixUyWBM futQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680175269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=flDRWY0SXQRWGYI8uX7jYuDz+uuIEnYkNVcdxGhVOsI=; b=W/DRZEIOpRcxggm3xk6Ms5wD5UjiGwkrqQBevnbLoIt/bHNjDFmlaMgFxCAA7JN7NP RusHmWckh30kDRiYZpXXJSBxE9G5Dr+SDyc77ldFfjxlR33lROo2u2VeezZIV+3I9Fhi IR819KhKc+11qyBxG15X5TdPbd+xgkrQgCRC0Wth7Mfqxoj9rFYs1MnlHm8tMiY4No3w pO4UI22fZ94s6D6Wtkzq2R8CkdhkF2mH+Xj4wc/TkGuEPEHD8l9co31Gc2m9Bexn/K+K R0OK3L0JaJCY7Eybl1ndgEhwZHXAhbuW/hMYXu8ZRQKTrn3kfWZPK/6qFL4G1rQ1oBks nzTQ== X-Gm-Message-State: AAQBX9f+1C7gEJShCv5T2rp3DMjOYiZPJRVdevAAfiu9wKaMBbmL0XYs xC7emceP0xojMPVdGB5/L6yKRTXlKifIFA== X-Google-Smtp-Source: AKy350ZQH0+bj83gJRvuR6lEKxOyEptMg+PH70Io+hn00pQpCUcPe9xlwLm811aChlIejNnY91Go5w== X-Received: by 2002:a17:903:41cd:b0:1a1:b65a:2072 with SMTP id u13-20020a17090341cd00b001a1b65a2072mr29339568ple.59.1680175269202; Thu, 30 Mar 2023 04:21:09 -0700 (PDT) Received: from kelvin-ThinkPad-L14-Gen-1.. (94.130.220.35.bc.googleusercontent.com. [35.220.130.94]) by smtp.gmail.com with ESMTPSA id a13-20020a170902ee8d00b0019f11a68c42sm24444851pld.297.2023.03.30.04.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 04:21:08 -0700 (PDT) From: Keguang Zhang To: linux-watchdog@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wim Van Sebroeck , Guenter Roeck , Thomas Bogendoerfer , Yang Ling , Keguang Zhang Subject: [PATCH v2 2/2] watchdog: loongson1_wdt: Implement restart handler Date: Thu, 30 Mar 2023 19:20:51 +0800 Message-Id: <20230330112051.551648-3-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230330112051.551648-1-keguang.zhang@gmail.com> References: <20230330112051.551648-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Implement restart handler for the Loongson-1 watchdog driver and define the watchdog registers instead of including the legacy header. Signed-off-by: Keguang Zhang Reviewed-by: Guenter Roeck --- V1 -> V2: None --- drivers/watchdog/loongson1_wdt.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/loongson1_wdt.c b/drivers/watchdog/loongson1_wdt.c index bb3d075c0633..a0b6fe62e516 100644 --- a/drivers/watchdog/loongson1_wdt.c +++ b/drivers/watchdog/loongson1_wdt.c @@ -7,7 +7,11 @@ #include #include #include -#include + +/* Loongson 1 Watchdog Register Definitions */ +#define WDT_EN 0x0 +#define WDT_TIMER 0x4 +#define WDT_SET 0x8 #define DEFAULT_HEARTBEAT 30 @@ -66,6 +70,18 @@ static int ls1x_wdt_stop(struct watchdog_device *wdt_dev) return 0; } +static int ls1x_wdt_restart(struct watchdog_device *wdt_dev, + unsigned long action, void *data) +{ + struct ls1x_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev); + + writel(0x1, drvdata->base + WDT_EN); + writel(0x1, drvdata->base + WDT_TIMER); + writel(0x1, drvdata->base + WDT_SET); + + return 0; +} + static const struct watchdog_info ls1x_wdt_info = { .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, .identity = "Loongson1 Watchdog", @@ -77,6 +93,7 @@ static const struct watchdog_ops ls1x_wdt_ops = { .stop = ls1x_wdt_stop, .ping = ls1x_wdt_ping, .set_timeout = ls1x_wdt_set_timeout, + .restart = ls1x_wdt_restart, }; static void ls1x_clk_disable_unprepare(void *data)