From patchwork Fri Nov 18 01:06:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Feng X-Patchwork-Id: 22026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp722910wrr; Thu, 17 Nov 2022 17:35:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf46erLqblmEuQ/hpJUnBQtRXXIbfwKYAC6+j3xI7j+qkKHgxXfoy2z8gGvKeKSIscKi4snb X-Received: by 2002:a05:6402:3205:b0:467:3015:ad42 with SMTP id g5-20020a056402320500b004673015ad42mr4417715eda.259.1668735342206; Thu, 17 Nov 2022 17:35:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668735342; cv=none; d=google.com; s=arc-20160816; b=mjAO3jS4/D/rx7N02kpHVw2YlFUYrOoVwO9pnV1qSEZ1zR4g3bg2carMZNYBbVW818 vrjf9Tzswg6vzpqnk4AZiw8RFaZ9Qxa8zBFJanpQ02sz7vXiQc5+WvUsUMhhhIzcSP/L epIY8iqKDz+mGRj9/NBHsETVtI1o5rfdgP0iCyo+QkTYJG0HAbrYcrL6UinlZ0moTUah bUnrHl0Cz7IsfevlwoV/2LAICP/UZ8fLcDHY/IIAVuUzPixWYykdahtRZ/887MUNpF6B N8DAJ7F/u25sedM15cADQ1DHYygg9cAauEIrOlwdwcxavEXtC9Ke5Zibz1BBOZek24La KiCA== 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=bR7Anf881dnh6w0d+l7wfCE74TAAHW7dHkc3TUo/2B8=; b=G+ElFDvf7DCCtbUSDUiHcXOKP1LvF7LQuaTsDGu8BWob7G+dgqOIVei1uSq+4DBd4k Kn3D7VTCIROFxSwy+lSkjxZXEJA7bCyLS2QOrG/CB8qkbMg7Dd+c7ShWfyQk62iAz+fv 7nLP+r7XTdAexSe0iIMNzRlIDzyvzsfZBF/IusXRh1lN1rqnXaN2AZryY17GeB5mRnAs rlUlabM2bib5LfFL1DqrJ2wfcUGwsqyVEctv+TUKM2xZ/oxjJuzzGL8GhjrcAjrXKSSR eWE7ATZUueZvi5G9H77FlLMPkbcITPzGKia1tN2u8qQba+v+kLeY+9ARVAdIY+g3cH44 eK1Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cf21-20020a170906b2d500b0078e0e850902si1619359ejb.868.2022.11.17.17.35.18; Thu, 17 Nov 2022 17:35:42 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235011AbiKRBch convert rfc822-to-8bit (ORCPT + 99 others); Thu, 17 Nov 2022 20:32:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240775AbiKRBcX (ORCPT ); Thu, 17 Nov 2022 20:32:23 -0500 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 610866E54B; Thu, 17 Nov 2022 17:32:22 -0800 (PST) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id D244624E188; Fri, 18 Nov 2022 09:06:38 +0800 (CST) Received: from EXMBX072.cuchost.com (172.16.6.82) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 18 Nov 2022 09:06:38 +0800 Received: from ubuntu.localdomain (183.27.96.116) by EXMBX072.cuchost.com (172.16.6.82) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 18 Nov 2022 09:06:38 +0800 From: Hal Feng To: , , CC: Conor Dooley , Palmer Dabbelt , "Rob Herring" , Krzysztof Kozlowski , Stephen Boyd , "Michael Turquette" , Philipp Zabel , Emil Renner Berthing , Hal Feng , Subject: [PATCH v2 13/14] reset: starfive: Add StarFive JH7110 reset driver Date: Fri, 18 Nov 2022 09:06:26 +0800 Message-ID: <20221118010627.70576-14-hal.feng@starfivetech.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118010627.70576-1-hal.feng@starfivetech.com> References: <20221118010627.70576-1-hal.feng@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.96.116] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX072.cuchost.com (172.16.6.82) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749795830100893767?= X-GMAIL-MSGID: =?utf-8?q?1749795830100893767?= Add auxiliary driver to support StarFive JH7110 system and always-on resets. Signed-off-by: Hal Feng --- drivers/reset/starfive/Kconfig | 8 +++ drivers/reset/starfive/Makefile | 1 + .../reset/starfive/reset-starfive-jh7110.c | 67 +++++++++++++++++++ .../reset/starfive/reset-starfive-jh71x0.h | 7 ++ 4 files changed, 83 insertions(+) create mode 100644 drivers/reset/starfive/reset-starfive-jh7110.c diff --git a/drivers/reset/starfive/Kconfig b/drivers/reset/starfive/Kconfig index 9d15c4110e40..fab1a081af17 100644 --- a/drivers/reset/starfive/Kconfig +++ b/drivers/reset/starfive/Kconfig @@ -10,3 +10,11 @@ config RESET_STARFIVE_JH7100 default SOC_STARFIVE help This enables the reset controller driver for the StarFive JH7100 SoC. + +config RESET_STARFIVE_JH7110 + bool "StarFive JH7110 Reset Driver" + depends on AUXILIARY_BUS && CLK_STARFIVE_JH7110_SYS + select RESET_STARFIVE_JH71X0 + default CLK_STARFIVE_JH7110_SYS + help + This enables the reset controller driver for the StarFive JH7110 SoC. diff --git a/drivers/reset/starfive/Makefile b/drivers/reset/starfive/Makefile index f6aa12466fad..7a44b66fb9d5 100644 --- a/drivers/reset/starfive/Makefile +++ b/drivers/reset/starfive/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_RESET_STARFIVE_JH71X0) += reset-starfive-jh71x0.o obj-$(CONFIG_RESET_STARFIVE_JH7100) += reset-starfive-jh7100.o +obj-$(CONFIG_RESET_STARFIVE_JH7110) += reset-starfive-jh7110.o diff --git a/drivers/reset/starfive/reset-starfive-jh7110.c b/drivers/reset/starfive/reset-starfive-jh7110.c new file mode 100644 index 000000000000..00f3b4ecfb02 --- /dev/null +++ b/drivers/reset/starfive/reset-starfive-jh7110.c @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Reset driver for the StarFive JH7110 SoC + * + * Copyright (C) 2022 StarFive Technology Co., Ltd. + * Copyright (C) 2022 Hal Feng + */ + +#include + +#include "reset-starfive-jh71x0.h" + +#include + +static int jh7110_reset_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + struct reset_info *info = (struct reset_info *)(id->driver_data); + void __iomem *base = dev_get_drvdata(adev->dev.parent); + + if (!info || !base) + return -ENODEV; + + return reset_starfive_jh71x0_register(&adev->dev, adev->dev.parent->of_node, + base + info->assert_offset, + base + info->status_offset, + info->asserted, + info->nr_resets, + false); +} + +static const struct reset_info jh7110_sys_info = { + .nr_resets = JH7110_SYSRST_END, + .assert_offset = 0x2F8, + .status_offset = 0x308, + .asserted = NULL, +}; + +static const struct reset_info jh7110_aon_info = { + .nr_resets = JH7110_AONRST_END, + .assert_offset = 0x38, + .status_offset = 0x3C, + .asserted = NULL, +}; + +static const struct auxiliary_device_id jh7110_reset_ids[] = { + { + .name = "clk_starfive_jh71x0.reset-sys", + .driver_data = (kernel_ulong_t)&jh7110_sys_info, + }, + { + .name = "clk_starfive_jh71x0.reset-aon", + .driver_data = (kernel_ulong_t)&jh7110_aon_info, + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(auxiliary, jh7110_reset_ids); + +static struct auxiliary_driver jh7110_reset_driver = { + .probe = jh7110_reset_probe, + .id_table = jh7110_reset_ids, +}; +module_auxiliary_driver(jh7110_reset_driver); + +MODULE_DESCRIPTION("StarFive JH7110 Reset Driver"); +MODULE_AUTHOR("Hal Feng "); +MODULE_LICENSE("GPL"); diff --git a/drivers/reset/starfive/reset-starfive-jh71x0.h b/drivers/reset/starfive/reset-starfive-jh71x0.h index e6b27110de48..63a94ee1b395 100644 --- a/drivers/reset/starfive/reset-starfive-jh71x0.h +++ b/drivers/reset/starfive/reset-starfive-jh71x0.h @@ -6,6 +6,13 @@ #ifndef __RESET_STARFIVE_JH71X0_H #define __RESET_STARFIVE_JH71X0_H +struct reset_info { + unsigned int nr_resets; + unsigned int assert_offset; + unsigned int status_offset; + const u32 *asserted; +}; + int reset_starfive_jh71x0_register(struct device *dev, struct device_node *of_node, void __iomem *assert, void __iomem *status, const u32 *asserted, unsigned int nr_resets,