Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3667427lfo; Mon, 23 May 2022 10:50:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxdtK8wg9Ixedxz+ON8EMg+Nm16Youkour+YL7AWKtEzOtwj7HWnVrBzTGrdI92LAgR3Ng X-Received: by 2002:a17:902:a50f:b0:162:28c6:bfac with SMTP id s15-20020a170902a50f00b0016228c6bfacmr5024256plq.99.1653328212305; Mon, 23 May 2022 10:50:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653328212; cv=none; d=google.com; s=arc-20160816; b=d1kXlLNGzutlvYR73m8ClcVbKXhwGGLg9dSyxT9CwKVYmmBeBV1Fp8YQHV99v61KVS bccxqQAqFck+jqFmq0BLRO99Ekm0rKqjNaPuH8dx7LYQLUD018PN7xzCJE2eoiMerfrE oSnRlVcX/nQWo2xAkLbrFZRiwf7iCnO/YkDwNTgviS3eD/qfC04jhze9Td8HG+qgLoa2 hf4Skb+J6/PAtpqOEBKz04w/zaKyBnKcQ0r7QzLrEZtES7YkfG6pgFBWOuFOIzywTdyF gOW2kaUAQF+YyZ1uGhOjd+kuIKK/R7H8ZRShE+2YkzxD5wK9r0vNSiFIu4VeClgycZBv Q0FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iMf6NG6z/iFUmL1/3yr80ROF4C/cmjgzSuNZ8nWjW/Y=; b=X0k6tR0ab6xO6ms8/sB1NlCkdy1shePBxf/Ci5WR9uUi28HkpMeBiDUZRXhMeBa5TX ztZKNVLJkZuY/RKAPMzhzZqQJjY8lfzJrCyIZRcyQxYU5eYi9t3qb/5AJTsOgwhnM9tL 3uuQT1HUYl5ZkObyk2M3n8/Lqwxjrgff47237d41k2eMk8PiVRhzTiV+ErBTgd5YDphm ACepBA0mDE12mKwz0HhnSfs6xqJGNVVjVGXw5KurdvhLDpN7O0SJJZ3QBqz1Vt9BtpZq rDii4/SPU618h950Z0r80/dsteMtE6uvCdS2GWKWWvSqhOWo+n/uLi1yhBnFkhvBZPwq G/1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wv2rH1WD; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id qe13-20020a17090b4f8d00b001cb7af1047esi16259030pjb.100.2022.05.23.10.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 10:50:12 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wv2rH1WD; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 734B5AEE27; Mon, 23 May 2022 10:49:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243710AbiEWRrF (ORCPT + 99 others); Mon, 23 May 2022 13:47:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242980AbiEWR2Q (ORCPT ); Mon, 23 May 2022 13:28:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0718B8DDCF; Mon, 23 May 2022 10:25:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4497CB80FF4; Mon, 23 May 2022 17:25:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DC88C385A9; Mon, 23 May 2022 17:24:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653326699; bh=8C4PATx0O8Jqsari8A1PCzDaVw8WREZnXuzovcN9IPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wv2rH1WD3yL0QR3bgKS6I4dqQWJZW6viNVYb0eMpV/7kjr2xXjkvSlOd/8s5BvZnA dQ6QF3bRL8dvDZeUKcdwscjGCZ0PIqQjC/pyyPgtr7TF5m8m3Msa35j9IgEn1aE0WS 6liMOl8vY03Vtih6Q8DFlpvltltz61UhpHQrvOag= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Richter , Terry Bowman , Jean Delvare , Guenter Roeck , Wim Van Sebroeck , Mario Limonciello Subject: [PATCH 5.17 012/158] Watchdog: sp5100_tco: Move timer initialization into function Date: Mon, 23 May 2022 19:02:49 +0200 Message-Id: <20220523165832.639720507@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165830.581652127@linuxfoundation.org> References: <20220523165830.581652127@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Terry Bowman commit abd71a948f7aab47ca49d3e7fe6afa6c48c8aae0 upstream. Refactor driver's timer initialization into new function. This is needed inorder to support adding new device layouts while using common timer initialization. Co-developed-by: Robert Richter Signed-off-by: Robert Richter Signed-off-by: Terry Bowman Tested-by: Jean Delvare Reviewed-by: Jean Delvare Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20220202153525.1693378-2-terry.bowman@amd.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Cc: Mario Limonciello Signed-off-by: Greg Kroah-Hartman --- drivers/watchdog/sp5100_tco.c | 65 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 29 deletions(-) --- a/drivers/watchdog/sp5100_tco.c +++ b/drivers/watchdog/sp5100_tco.c @@ -223,6 +223,41 @@ static u32 sp5100_tco_read_pm_reg32(u8 i return val; } +static int sp5100_tco_timer_init(struct sp5100_tco *tco) +{ + struct watchdog_device *wdd = &tco->wdd; + struct device *dev = wdd->parent; + u32 val; + + val = readl(SP5100_WDT_CONTROL(tco->tcobase)); + if (val & SP5100_WDT_DISABLED) { + dev_err(dev, "Watchdog hardware is disabled\n"); + return -ENODEV; + } + + /* + * Save WatchDogFired status, because WatchDogFired flag is + * cleared here. + */ + if (val & SP5100_WDT_FIRED) + wdd->bootstatus = WDIOF_CARDRESET; + + /* Set watchdog action to reset the system */ + val &= ~SP5100_WDT_ACTION_RESET; + writel(val, SP5100_WDT_CONTROL(tco->tcobase)); + + /* Set a reasonable heartbeat before we stop the timer */ + tco_timer_set_timeout(wdd, wdd->timeout); + + /* + * Stop the TCO before we change anything so we don't race with + * a zeroed timer. + */ + tco_timer_stop(wdd); + + return 0; +} + static int sp5100_tco_setupdevice(struct device *dev, struct watchdog_device *wdd) { @@ -348,35 +383,7 @@ static int sp5100_tco_setupdevice(struct /* Setup the watchdog timer */ tco_timer_enable(tco); - val = readl(SP5100_WDT_CONTROL(tco->tcobase)); - if (val & SP5100_WDT_DISABLED) { - dev_err(dev, "Watchdog hardware is disabled\n"); - ret = -ENODEV; - goto unreg_region; - } - - /* - * Save WatchDogFired status, because WatchDogFired flag is - * cleared here. - */ - if (val & SP5100_WDT_FIRED) - wdd->bootstatus = WDIOF_CARDRESET; - /* Set watchdog action to reset the system */ - val &= ~SP5100_WDT_ACTION_RESET; - writel(val, SP5100_WDT_CONTROL(tco->tcobase)); - - /* Set a reasonable heartbeat before we stop the timer */ - tco_timer_set_timeout(wdd, wdd->timeout); - - /* - * Stop the TCO before we change anything so we don't race with - * a zeroed timer. - */ - tco_timer_stop(wdd); - - release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE); - - return 0; + ret = sp5100_tco_timer_init(tco); unreg_region: release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE);