From patchwork Fri Jan 10 12:39:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andras Szemzo X-Patchwork-Id: 13934543 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99124E77188 for ; Fri, 10 Jan 2025 12:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qB1xcx8fQahq0nBIxDCGp3CXkr4tqCwK++Yz6DDYXCg=; b=tvar2rFXJRv+JT LWOfxYdrMXMbMuphxo+vDjLIKpLYnJcono0nwnR/wYdyxInl+cOUz9rILtlpcALkxURdff3ImgFcH W4kxHxfHlyQs3MhKfuXRFVcEzmO1vnEJByW+qq9kkdj7+XRqWC7l/9RjHc7p9KkN9YEjPIO/2dgih SSFg4IH2EqxwHOvYMEy8DK6fzxK0jAAsdZgQU1Qm4tJKcxt9i7rEDTdscutrF+v3pQdjlztozQaul spm6Fi/ZxDwTmEubYFLf4SRzb+cJKVU8bebJgyeFkV8agfrBZX4LVC/cKwvWRusXgl0iS0aa/J35q 2+TxP0AyhMciiHrtDvgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tWEcA-0000000FNc4-144T; Fri, 10 Jan 2025 12:59:50 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tWEIU-0000000FJ1D-3w4J; Fri, 10 Jan 2025 12:39:32 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-43618283dedso19979925e9.3; Fri, 10 Jan 2025 04:39:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736512769; x=1737117569; darn=lists.infradead.org; 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=yUSKtDxpYUB0G5u44s+MtVvA5eK94sL+CVnm4h5Hbb0=; b=Wnv4Bt/EVD5Z9avDG2x7Q1pl0w+h2wOVSDnPbKirOc01JTvv8gQInYeS6IEMZw93rX SBl4xo9OfW4epX4uJaUrdIg7TimY7ise/HMrlR9mPTHMZV10eWSdwKSwcfPI5YV2usnT hehcdiOT8tGIOcOWMmh39RaZkeqjjHRjhIAWnU7nYIG8yFH3aAmc7SWolbeAqtTc33jR Amy8xX5/7n4U5jYUH1K+ZHofKM5W4uKKX0zg/0Liy5vafRXFL6NRF3f/muH1LjspNwYO 0q0KvSCG+0iRkZrUzJVH/YrYsai3YGq/3kdyQiFIG08LvUNnlp4P59axQE/7XQO8or7f GpVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736512769; x=1737117569; 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=yUSKtDxpYUB0G5u44s+MtVvA5eK94sL+CVnm4h5Hbb0=; b=FnpFvyl3/RQLgKLjsbquWx0oEYvxZdSuiqOg65VY1qHC/Lbo+OOPHNFdgRedF/ipnG oswT/mjS4JjJEzzGCldHV61iS056KYEcn9OU7JPjwRpJJ48qbkLoFucquz0OzkZ1u3kh bhIYJg3+B7mBeVQRu8MJEt+pCor9Ao4ZDOyEIJVS6yRfH+Aa+5dmSWQyFhVDXI7c2AAl C5+O9xzE8g5d1xLKZHQh94MI75Y7YCsOQnATqGQe8F3yk8LupAUayBmGl7kLB0qbGVeT ArjMyvRqeMh/2MY3Uenq/xoNbLAXMUerWzlxoxjPbJiSEDIxsxIi4jcLGmxJXsS+sZMl s88w== X-Forwarded-Encrypted: i=1; AJvYcCUgbwuJX1OBrF56d7c6tzOiGtf8WwrBZLtWWC4n6J4dLZnphxT4NF/6hZbVQt2/cKUlfM5WkkoJTHOJAFCp62zk@lists.infradead.org, AJvYcCVpdiqsNf60N93caxlKQfYRON9CK24nXl09eYz4C3xOr944qSOMyFuqyVA9MLzOXwJ6BHoDKj8KDmXi@lists.infradead.org, AJvYcCXHDFwkwTyWJZaOmIZxd+y/4mfKbq6eN1HmUqcIUSd3wNBpDef6PaSdbCJytrtFPLvZeqtCPN8M0NIBphM=@lists.infradead.org X-Gm-Message-State: AOJu0Ywi6hRKDvqXY+DQ4ne4Z7fV/XRhLNa7jIj6ZAi3pd7QpPIACIpy ySvkyCbzlBNP79RemsuQvH7L48+Vfed9sXbj/Z/eMbYHkBPJYRUK X-Gm-Gg: ASbGncuwsWNflRsSL38GABsswdHymsgpc87sWOON0xDRuuCTNXfQgJewgoSBjuO5vYc AFlytqK3gOqdLB/LURo/XO87WgA0wbW5+EgZtlpqcG83O145nTq56zyxAcCEBV1H3z290815U3u Ks4q05ZukTKb0c9DMex6l2l7U+/5LASSQh0XDHriQErvdT03tJm6kEqwcjUVULzpmctKIJDDj+t /X24moJ47ETZwdNRxR83JPZg7Hx6Y1W5weaFXbGZOibn69EAPK3cvKC698+ZrSalV/kmq7z9cIs pimTF+Ste2I= X-Google-Smtp-Source: AGHT+IFTgEN5UJlFq7sBCmdgeoA7UGiB+lm0UDSMol2G3trBcljxqzM+QxvHHhfLr6Xw5bNGFHDEog== X-Received: by 2002:a05:600c:3b86:b0:435:32e:8270 with SMTP id 5b1f17b1804b1-436e26c7ebamr106896935e9.14.1736512769053; Fri, 10 Jan 2025 04:39:29 -0800 (PST) Received: from localhost.localdomain (185.174.17.62.zt.hu. [185.174.17.62]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2da6401sm86738715e9.2.2025.01.10.04.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 04:39:28 -0800 (PST) From: Andras Szemzo To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Linus Walleij , Philipp Zabel , Maxime Ripard Cc: Vinod Koul , Kishon Vijay Abraham I , Ulf Hansson , Paul Walmsley , Palmer Dabbelt , Albert Ou , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Florian Fainelli , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-gpio@vger.kernel.org, linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH 01/12] clk: sunxi-ng: allow key feature in ccu reset Date: Fri, 10 Jan 2025 13:39:12 +0100 Message-Id: <20250110123923.270626-2-szemzo.andras@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250110123923.270626-1-szemzo.andras@gmail.com> References: <20250110123923.270626-1-szemzo.andras@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250110_043930_975052_5ADC45BA X-CRM114-Status: GOOD ( 14.22 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Some newer SoCs, like V853 has reset registers, what can be write only with fixed key value. Move this value from ccu_mux and reuse in the reset code. Signed-off-by: Andras Szemzo --- drivers/clk/sunxi-ng/ccu_common.h | 2 ++ drivers/clk/sunxi-ng/ccu_mux.c | 4 +--- drivers/clk/sunxi-ng/ccu_reset.c | 7 +++++++ drivers/clk/sunxi-ng/ccu_reset.h | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu_common.h b/drivers/clk/sunxi-ng/ccu_common.h index dd330426a6e5..36132cb8b920 100644 --- a/drivers/clk/sunxi-ng/ccu_common.h +++ b/drivers/clk/sunxi-ng/ccu_common.h @@ -23,6 +23,8 @@ /* MMC timing mode switch bit */ #define CCU_MMC_NEW_TIMING_MODE BIT(30) +#define CCU_KEY_VALUE 0x16aa0000 + struct device_node; struct ccu_common { diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu_mux.c index d7ffbdeee9e0..127269ab20ea 100644 --- a/drivers/clk/sunxi-ng/ccu_mux.c +++ b/drivers/clk/sunxi-ng/ccu_mux.c @@ -12,8 +12,6 @@ #include "ccu_gate.h" #include "ccu_mux.h" -#define CCU_MUX_KEY_VALUE 0x16aa0000 - static u16 ccu_mux_get_prediv(struct ccu_common *common, struct ccu_mux_internal *cm, int parent_index) @@ -196,7 +194,7 @@ int ccu_mux_helper_set_parent(struct ccu_common *common, /* The key field always reads as zero. */ if (common->features & CCU_FEATURE_KEY_FIELD) - reg |= CCU_MUX_KEY_VALUE; + reg |= CCU_KEY_VALUE; reg &= ~GENMASK(cm->width + cm->shift - 1, cm->shift); writel(reg | (index << cm->shift), common->base + common->reg); diff --git a/drivers/clk/sunxi-ng/ccu_reset.c b/drivers/clk/sunxi-ng/ccu_reset.c index 55bc7c7cda0f..a9aee35c6617 100644 --- a/drivers/clk/sunxi-ng/ccu_reset.c +++ b/drivers/clk/sunxi-ng/ccu_reset.c @@ -9,6 +9,7 @@ #include #include "ccu_reset.h" +#include "ccu_common.h" static int ccu_reset_assert(struct reset_controller_dev *rcdev, unsigned long id) @@ -21,6 +22,9 @@ static int ccu_reset_assert(struct reset_controller_dev *rcdev, spin_lock_irqsave(ccu->lock, flags); reg = readl(ccu->base + map->reg); + if (map->features & CCU_FEATURE_KEY_FIELD) + reg |= CCU_KEY_VALUE; + writel(reg & ~map->bit, ccu->base + map->reg); spin_unlock_irqrestore(ccu->lock, flags); @@ -39,6 +43,9 @@ static int ccu_reset_deassert(struct reset_controller_dev *rcdev, spin_lock_irqsave(ccu->lock, flags); reg = readl(ccu->base + map->reg); + if (map->features & CCU_FEATURE_KEY_FIELD) + reg |= CCU_KEY_VALUE; + writel(reg | map->bit, ccu->base + map->reg); spin_unlock_irqrestore(ccu->lock, flags); diff --git a/drivers/clk/sunxi-ng/ccu_reset.h b/drivers/clk/sunxi-ng/ccu_reset.h index 941276a8ec2e..3fd5d427c26c 100644 --- a/drivers/clk/sunxi-ng/ccu_reset.h +++ b/drivers/clk/sunxi-ng/ccu_reset.h @@ -12,6 +12,7 @@ struct ccu_reset_map { u16 reg; u32 bit; + u32 features; };