From patchwork Wed Aug 2 03:32:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huqiang Qin X-Patchwork-Id: 129587 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp183665vqx; Tue, 1 Aug 2023 20:50:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlGDtXMYHLe+HVaImJxY6RHFNAdXh/oN4Ry6rTGWdYk1MQ7BZiU2g1NgelUOaRY8kLfil1c7 X-Received: by 2002:a05:6a00:1249:b0:674:6dd4:8337 with SMTP id u9-20020a056a00124900b006746dd48337mr17269454pfi.12.1690948235940; Tue, 01 Aug 2023 20:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690948235; cv=none; d=google.com; s=arc-20160816; b=yPFGnNesitUvMtRsqIyqGnYati/9QWdPGB9e0iGMGUSPuL1jhdONd6+nVHT/3to18h t0mdQ6EVLheGC0Pp/BV9RfGNE5CaR5VV0/Vbc+2WpE36D8wmrRRV67rR672q9r0KGM+i BAOtdjSF+FoEoHIKPV+73Q0sMT5SCh6ilgMPm0/D3dQuq2x8beyH5QCmSgvJZDIUiT2E 0eFbV8Ke+ee0qT34OSn5P2R66HpKsIjmRXHrXwFfokkeoafp/spHXAz42YvuMKPIAQ9P Xywkrv0vr6iNgo8/OPCVNtqOjzpWgzFY/JHRE/wJp5K7xqFLBikwlmnik3OgQRuOtKum vfvw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SQMQjnZADkemdwHNJcY4Jula6NTZWb3afwBJ+DSh9DA=; fh=lHtUygPuyDqDXmLQa3x6TuiEioC8bNshDFp//Fz2cIM=; b=1KVHibW5KnGfSxIyHxNmFiMwEAnrHY2XZhaRGWpu4Yj2grHiN3KyiBTiwr5UUBunBD thGgx0pcFf6vVri0e7cmNCoVm7A8jkP6mn4tXDL6I4gR5IA17wPVkKQNrMTlBXEQmIjG mvxBomkH2gO49SxJrXg31YzmTgreswJAuBnpdR7nU3yv1Ek72edm4P60DKnrRcSDhVxt CgjvW8t203MIdF+bBj5W5dHHIj0yF7uHDaorWSZ3fpa1B/E3uUOjQcSPsO1g+atPPKK3 IfbFs0OTX0JZCwdMzjmwpReKYtIJHXZpfBBcSD+sPx7ucDdSG7isekcZYQv1hipVhPtq FSpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amlogic.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z33-20020a056a001da100b006870878c6dbsi1142911pfw.191.2023.08.01.20.50.23; Tue, 01 Aug 2023 20:50:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amlogic.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232181AbjHBDeB (ORCPT + 99 others); Tue, 1 Aug 2023 23:34:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232146AbjHBDde (ORCPT ); Tue, 1 Aug 2023 23:33:34 -0400 Received: from mail-sh.amlogic.com (mail-sh.amlogic.com [58.32.228.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E7B71B6; Tue, 1 Aug 2023 20:32:49 -0700 (PDT) Received: from rd02-sz.amlogic.software (10.28.11.83) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.2507.13; Wed, 2 Aug 2023 11:32:29 +0800 From: Huqiang Qin To: , , , , , , , , CC: , , , , , Huqiang Qin Subject: [PATCH V2 2/4] watchdog: Add a new struct for Amlogic-GXBB driver Date: Wed, 2 Aug 2023 11:32:20 +0800 Message-ID: <20230802033222.4024946-3-huqiang.qin@amlogic.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230802033222.4024946-1-huqiang.qin@amlogic.com> References: <20230802033222.4024946-1-huqiang.qin@amlogic.com> MIME-Version: 1.0 X-Originating-IP: [10.28.11.83] X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773087737467001409 X-GMAIL-MSGID: 1773087737467001409 Add a new structure wdt_params to describe the watchdog difference of different chips. Signed-off-by: Huqiang Qin Reviewed-by: Dmitry Rokosov --- V1 -> V2: Rename rst_shift to rst and use the BIT() macro to build its initial value. drivers/watchdog/meson_gxbb_wdt.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c index 35d80cb39856..18180d91543e 100644 --- a/drivers/watchdog/meson_gxbb_wdt.c +++ b/drivers/watchdog/meson_gxbb_wdt.c @@ -22,7 +22,6 @@ #define GXBB_WDT_CTRL_CLKDIV_EN BIT(25) #define GXBB_WDT_CTRL_CLK_EN BIT(24) -#define GXBB_WDT_CTRL_EE_RESET BIT(21) #define GXBB_WDT_CTRL_EN BIT(18) #define GXBB_WDT_CTRL_DIV_MASK (BIT(18) - 1) @@ -45,6 +44,10 @@ struct meson_gxbb_wdt { struct clk *clk; }; +struct wdt_params { + u32 rst; +}; + static int meson_gxbb_wdt_start(struct watchdog_device *wdt_dev) { struct meson_gxbb_wdt *data = watchdog_get_drvdata(wdt_dev); @@ -140,8 +143,12 @@ static const struct dev_pm_ops meson_gxbb_wdt_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(meson_gxbb_wdt_suspend, meson_gxbb_wdt_resume) }; +static const struct wdt_params gxbb_params = { + .rst = BIT(21), +}; + static const struct of_device_id meson_gxbb_wdt_dt_ids[] = { - { .compatible = "amlogic,meson-gxbb-wdt", }, + { .compatible = "amlogic,meson-gxbb-wdt", .data = &gxbb_params, }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, meson_gxbb_wdt_dt_ids); @@ -150,6 +157,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct meson_gxbb_wdt *data; + struct wdt_params *params; u32 ctrl_reg; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); @@ -164,6 +172,8 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev) if (IS_ERR(data->clk)) return PTR_ERR(data->clk); + params = (struct wdt_params *)of_device_get_match_data(dev); + platform_set_drvdata(pdev, data); data->wdt_dev.parent = dev; @@ -191,7 +201,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev) /* Setup with 1ms timebase */ ctrl_reg |= ((clk_get_rate(data->clk) / 1000) & GXBB_WDT_CTRL_DIV_MASK) | - GXBB_WDT_CTRL_EE_RESET | + params->rst | GXBB_WDT_CTRL_CLK_EN | GXBB_WDT_CTRL_CLKDIV_EN;