1 // SPDX-License-Identifier: GPL-2.0 OR MIT
2 /* Copyright 2018-2019 Qiang Yu <yuq825@gmail.com> */
5 #include <linux/device.h>
7 #include "lima_device.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
;
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
);
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
)