mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-28 07:54:36 -05:00
soc: apple: sart: Add SARTv0 support
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> Link: https://lore.kernel.org/r/20250821-t8015-nvme-v3-5-14a4178adf68@gmail.com Signed-off-by: Sven Peter <sven@kernel.org>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user