Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / lima / lima_dlbu.c
blobc1d5ea35daa7aecbea830adf7f946bc644c5166d
1 // SPDX-License-Identifier: GPL-2.0 OR MIT
2 /* Copyright 2018-2019 Qiang Yu <yuq825@gmail.com> */
4 #include <linux/io.h>
5 #include <linux/device.h>
7 #include "lima_device.h"
8 #include "lima_dlbu.h"
9 #include "lima_vm.h"
10 #include "lima_regs.h"
12 #define dlbu_write(reg, data) writel(data, ip->iomem + reg)
13 #define dlbu_read(reg) readl(ip->iomem + reg)
15 void lima_dlbu_enable(struct lima_device *dev, int num_pp)
17 struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_pp;
18 struct lima_ip *ip = dev->ip + lima_ip_dlbu;
19 int i, mask = 0;
21 for (i = 0; i < num_pp; i++) {
22 struct lima_ip *pp = pipe->processor[i];
24 mask |= 1 << (pp->id - lima_ip_pp0);
27 dlbu_write(LIMA_DLBU_PP_ENABLE_MASK, mask);
30 void lima_dlbu_disable(struct lima_device *dev)
32 struct lima_ip *ip = dev->ip + lima_ip_dlbu;
34 dlbu_write(LIMA_DLBU_PP_ENABLE_MASK, 0);
37 void lima_dlbu_set_reg(struct lima_ip *ip, u32 *reg)
39 dlbu_write(LIMA_DLBU_TLLIST_VBASEADDR, reg[0]);
40 dlbu_write(LIMA_DLBU_FB_DIM, reg[1]);
41 dlbu_write(LIMA_DLBU_TLLIST_CONF, reg[2]);
42 dlbu_write(LIMA_DLBU_START_TILE_POS, reg[3]);
45 static int lima_dlbu_hw_init(struct lima_ip *ip)
47 struct lima_device *dev = ip->dev;
49 dlbu_write(LIMA_DLBU_MASTER_TLLIST_PHYS_ADDR, dev->dlbu_dma | 1);
50 dlbu_write(LIMA_DLBU_MASTER_TLLIST_VADDR, LIMA_VA_RESERVE_DLBU);
52 return 0;
55 int lima_dlbu_resume(struct lima_ip *ip)
57 return lima_dlbu_hw_init(ip);
60 void lima_dlbu_suspend(struct lima_ip *ip)
65 int lima_dlbu_init(struct lima_ip *ip)
67 return lima_dlbu_hw_init(ip);
70 void lima_dlbu_fini(struct lima_ip *ip)