From: Nick Chan <towinchenmi@gmail.com>
To: Sven Peter <sven@kernel.org>, Janne Grunau <j@jannau.net>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Neal Gompa <neal@gompa.dev>,
Jassi Brar <jassisinghbrar@gmail.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Hector Martin <marcan@marcan.st>, Joerg Roedel <joro@8bytes.org>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>
Cc: asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
iommu@lists.linux.dev, linux-nvme@lists.infradead.org,
Nick Chan <towinchenmi@gmail.com>
Subject: [PATCH v2 5/9] soc: apple: sart: Add SARTv0 support
Date: Mon, 18 Aug 2025 16:42:58 +0800 [thread overview]
Message-ID: <20250818-t8015-nvme-v2-5-65648cd189e0@gmail.com> (raw)
In-Reply-To: <20250818-t8015-nvme-v2-0-65648cd189e0@gmail.com>
Add support for SARTv0 as found on Apple A11 SoC.
Reviewed-by: Sven Peter <sven@kernel.org>
Signed-off-by: Nick Chan <towinchenmi@gmail.com>
---
drivers/soc/apple/sart.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/soc/apple/sart.c b/drivers/soc/apple/sart.c
index 318f6e518a54f6edb8b97e320519df8f77c7f143..4ff1942b82a74cabeda99540ba63c6e92386986d 100644
--- a/drivers/soc/apple/sart.c
+++ b/drivers/soc/apple/sart.c
@@ -25,6 +25,18 @@
#define APPLE_SART_MAX_ENTRIES 16
+/* SARTv0 registers */
+#define APPLE_SART0_CONFIG(idx) (0x00 + 4 * (idx))
+#define APPLE_SART0_CONFIG_FLAGS GENMASK(28, 24)
+#define APPLE_SART0_CONFIG_SIZE GENMASK(18, 0)
+#define APPLE_SART0_CONFIG_SIZE_SHIFT 12
+#define APPLE_SART0_CONFIG_SIZE_MAX GENMASK(18, 0)
+
+#define APPLE_SART0_PADDR(idx) (0x40 + 4 * (idx))
+#define APPLE_SART0_PADDR_SHIFT 12
+
+#define APPLE_SART0_FLAGS_ALLOW 0xf
+
/* SARTv2 registers */
#define APPLE_SART2_CONFIG(idx) (0x00 + 4 * (idx))
#define APPLE_SART2_CONFIG_FLAGS GENMASK(31, 24)
@@ -71,6 +83,39 @@ struct apple_sart {
unsigned long used_entries;
};
+static void sart0_get_entry(struct apple_sart *sart, int index, u8 *flags,
+ phys_addr_t *paddr, size_t *size)
+{
+ u32 cfg = readl(sart->regs + APPLE_SART0_CONFIG(index));
+ phys_addr_t paddr_ = readl(sart->regs + APPLE_SART0_PADDR(index));
+ size_t size_ = FIELD_GET(APPLE_SART0_CONFIG_SIZE, cfg);
+
+ *flags = FIELD_GET(APPLE_SART0_CONFIG_FLAGS, cfg);
+ *size = size_ << APPLE_SART0_CONFIG_SIZE_SHIFT;
+ *paddr = paddr_ << APPLE_SART0_PADDR_SHIFT;
+}
+
+static void sart0_set_entry(struct apple_sart *sart, int index, u8 flags,
+ phys_addr_t paddr_shifted, size_t size_shifted)
+{
+ u32 cfg;
+
+ cfg = FIELD_PREP(APPLE_SART0_CONFIG_FLAGS, flags);
+ cfg |= FIELD_PREP(APPLE_SART0_CONFIG_SIZE, size_shifted);
+
+ writel(paddr_shifted, sart->regs + APPLE_SART0_PADDR(index));
+ writel(cfg, sart->regs + APPLE_SART0_CONFIG(index));
+}
+
+static struct apple_sart_ops sart_ops_v0 = {
+ .get_entry = sart0_get_entry,
+ .set_entry = sart0_set_entry,
+ .flags_allow = APPLE_SART0_FLAGS_ALLOW,
+ .size_shift = APPLE_SART0_CONFIG_SIZE_SHIFT,
+ .paddr_shift = APPLE_SART0_PADDR_SHIFT,
+ .size_max = APPLE_SART0_CONFIG_SIZE_MAX,
+};
+
static void sart2_get_entry(struct apple_sart *sart, int index, u8 *flags,
phys_addr_t *paddr, size_t *size)
{
@@ -319,6 +364,10 @@ static const struct of_device_id apple_sart_of_match[] = {
.compatible = "apple,t8103-sart",
.data = &sart_ops_v2,
},
+ {
+ .compatible = "apple,t8015-sart",
+ .data = &sart_ops_v0,
+ },
{}
};
MODULE_DEVICE_TABLE(of, apple_sart_of_match);
--
2.50.1
next prev parent reply other threads:[~2025-08-18 8:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-18 8:42 [PATCH v2 0/9] Add support ANS2 NVMe on Apple A11 Nick Chan
2025-08-18 8:42 ` [PATCH v2 1/9] dt-bindings: mailbox: apple,mailbox: Add ASC mailboxes on Apple A11 and T2 Nick Chan
2025-08-20 22:18 ` Rob Herring (Arm)
2025-08-18 8:42 ` [PATCH v2 2/9] soc: apple: mailbox: Add Apple A11 and T2 mailbox support Nick Chan
2025-08-18 8:42 ` [PATCH v2 3/9] dt-bindings: iommu: apple,sart: Add Apple A11 Nick Chan
2025-08-20 22:18 ` Rob Herring (Arm)
2025-08-20 22:20 ` Rob Herring
2025-08-27 13:20 ` Krzysztof Kozlowski
2025-08-29 7:44 ` Sven Peter
2025-08-18 8:42 ` [PATCH v2 4/9] soc: apple: sart: Make allow flags SART version dependent Nick Chan
2025-08-18 8:42 ` Nick Chan [this message]
2025-08-18 8:42 ` [PATCH v2 6/9] dt-bindings: nvme: apple,nvme-ans: Add Apple A11 Nick Chan
2025-08-19 9:18 ` Krzysztof Kozlowski
2025-08-19 10:01 ` Sven Peter
2025-08-19 11:34 ` Krzysztof Kozlowski
2025-08-21 10:25 ` Sven Peter
2025-08-21 13:09 ` Krzysztof Kozlowski
2025-08-21 15:47 ` Sven Peter
2025-08-27 12:25 ` Janne Grunau
2025-08-27 13:19 ` Krzysztof Kozlowski
2025-08-18 8:43 ` [PATCH v2 7/9] nvme: apple: Add Apple A11 support Nick Chan
2025-08-19 8:30 ` Christoph Hellwig
2025-08-19 16:22 ` Nick Chan
2025-08-18 8:43 ` [PATCH v2 8/9] arm64: dts: apple: t8015: Fix PCIE power domains dependencies Nick Chan
2025-08-18 8:43 ` [PATCH v2 9/9] arm64: dts: apple: t8015: Add NVMe nodes Nick Chan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250818-t8015-nvme-v2-5-65648cd189e0@gmail.com \
--to=towinchenmi@gmail.com \
--cc=alyssa@rosenzweig.io \
--cc=asahi@lists.linux.dev \
--cc=axboe@kernel.dk \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=j@jannau.net \
--cc=jassisinghbrar@gmail.com \
--cc=joro@8bytes.org \
--cc=kbusch@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=marcan@marcan.st \
--cc=neal@gompa.dev \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=sagi@grimberg.me \
--cc=sven@kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).