Lines Matching refs:sart

52 	void (*get_entry)(struct apple_sart *sart, int index, u8 *flags,
54 void (*set_entry)(struct apple_sart *sart, int index, u8 flags,
71 static void sart2_get_entry(struct apple_sart *sart, int index, u8 *flags, in sart2_get_entry() argument
74 u32 cfg = readl(sart->regs + APPLE_SART2_CONFIG(index)); in sart2_get_entry()
75 phys_addr_t paddr_ = readl(sart->regs + APPLE_SART2_PADDR(index)); in sart2_get_entry()
83 static void sart2_set_entry(struct apple_sart *sart, int index, u8 flags, in sart2_set_entry() argument
91 writel(paddr_shifted, sart->regs + APPLE_SART2_PADDR(index)); in sart2_set_entry()
92 writel(cfg, sart->regs + APPLE_SART2_CONFIG(index)); in sart2_set_entry()
103 static void sart3_get_entry(struct apple_sart *sart, int index, u8 *flags, in sart3_get_entry() argument
106 phys_addr_t paddr_ = readl(sart->regs + APPLE_SART3_PADDR(index)); in sart3_get_entry()
107 size_t size_ = readl(sart->regs + APPLE_SART3_SIZE(index)); in sart3_get_entry()
109 *flags = readl(sart->regs + APPLE_SART3_CONFIG(index)); in sart3_get_entry()
114 static void sart3_set_entry(struct apple_sart *sart, int index, u8 flags, in sart3_set_entry() argument
117 writel(paddr_shifted, sart->regs + APPLE_SART3_PADDR(index)); in sart3_set_entry()
118 writel(size_shifted, sart->regs + APPLE_SART3_SIZE(index)); in sart3_set_entry()
119 writel(flags, sart->regs + APPLE_SART3_CONFIG(index)); in sart3_set_entry()
133 struct apple_sart *sart; in apple_sart_probe() local
136 sart = devm_kzalloc(dev, sizeof(*sart), GFP_KERNEL); in apple_sart_probe()
137 if (!sart) in apple_sart_probe()
140 sart->dev = dev; in apple_sart_probe()
141 sart->ops = of_device_get_match_data(dev); in apple_sart_probe()
143 sart->regs = devm_platform_ioremap_resource(pdev, 0); in apple_sart_probe()
144 if (IS_ERR(sart->regs)) in apple_sart_probe()
145 return PTR_ERR(sart->regs); in apple_sart_probe()
152 sart->ops->get_entry(sart, i, &flags, &paddr, &size); in apple_sart_probe()
157 dev_dbg(sart->dev, in apple_sart_probe()
160 set_bit(i, &sart->protected_entries); in apple_sart_probe()
163 platform_set_drvdata(pdev, sart); in apple_sart_probe()
176 struct apple_sart *sart; in devm_apple_sart_get() local
189 sart = dev_get_drvdata(&sart_pdev->dev); in devm_apple_sart_get()
190 if (!sart) { in devm_apple_sart_get()
203 return sart; in devm_apple_sart_get()
207 static int sart_set_entry(struct apple_sart *sart, int index, u8 flags, in sart_set_entry() argument
210 if (size & ((1 << sart->ops->size_shift) - 1)) in sart_set_entry()
212 if (paddr & ((1 << sart->ops->paddr_shift) - 1)) in sart_set_entry()
215 paddr >>= sart->ops->size_shift; in sart_set_entry()
216 size >>= sart->ops->paddr_shift; in sart_set_entry()
218 if (size > sart->ops->size_max) in sart_set_entry()
221 sart->ops->set_entry(sart, index, flags, paddr, size); in sart_set_entry()
225 int apple_sart_add_allowed_region(struct apple_sart *sart, phys_addr_t paddr, in apple_sart_add_allowed_region() argument
231 if (test_bit(i, &sart->protected_entries)) in apple_sart_add_allowed_region()
233 if (test_and_set_bit(i, &sart->used_entries)) in apple_sart_add_allowed_region()
236 ret = sart_set_entry(sart, i, APPLE_SART_FLAGS_ALLOW, paddr, in apple_sart_add_allowed_region()
239 dev_dbg(sart->dev, in apple_sart_add_allowed_region()
242 clear_bit(i, &sart->used_entries); in apple_sart_add_allowed_region()
246 dev_dbg(sart->dev, "wrote [%pa, 0x%zx] to %d\n", &paddr, size, in apple_sart_add_allowed_region()
251 dev_warn(sart->dev, in apple_sart_add_allowed_region()
259 int apple_sart_remove_allowed_region(struct apple_sart *sart, phys_addr_t paddr, in apple_sart_remove_allowed_region() argument
264 dev_dbg(sart->dev, in apple_sart_remove_allowed_region()
273 if (test_bit(i, &sart->protected_entries)) in apple_sart_remove_allowed_region()
276 sart->ops->get_entry(sart, i, &eflags, &epaddr, &esize); in apple_sart_remove_allowed_region()
281 sart->ops->set_entry(sart, i, 0, 0, 0); in apple_sart_remove_allowed_region()
283 clear_bit(i, &sart->used_entries); in apple_sart_remove_allowed_region()
284 dev_dbg(sart->dev, "cleared entry %d\n", i); in apple_sart_remove_allowed_region()
288 dev_warn(sart->dev, "entry [paddr: 0x%pa, size: 0x%zx] not found\n", in apple_sart_remove_allowed_region()
297 struct apple_sart *sart = dev_get_drvdata(&pdev->dev); in apple_sart_shutdown() local
301 if (test_bit(i, &sart->protected_entries)) in apple_sart_shutdown()
304 sart->ops->set_entry(sart, i, 0, 0, 0); in apple_sart_shutdown()