xref: /openbmc/linux/drivers/gpu/drm/lima/lima_bcast.c (revision 022db5d6)
1 // SPDX-License-Identifier: GPL-2.0 OR MIT
2 /* Copyright 2018-2019 Qiang Yu <yuq825@gmail.com> */
3 
4 #include <linux/io.h>
5 #include <linux/device.h>
6 
7 #include "lima_device.h"
8 #include "lima_bcast.h"
9 #include "lima_regs.h"
10 
11 #define bcast_write(reg, data) writel(data, ip->iomem + reg)
12 #define bcast_read(reg) readl(ip->iomem + reg)
13 
lima_bcast_enable(struct lima_device * dev,int num_pp)14 void lima_bcast_enable(struct lima_device *dev, int num_pp)
15 {
16 	struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_pp;
17 	struct lima_ip *ip = dev->ip + lima_ip_bcast;
18 	int i, mask = bcast_read(LIMA_BCAST_BROADCAST_MASK) & 0xffff0000;
19 
20 	for (i = 0; i < num_pp; i++) {
21 		struct lima_ip *pp = pipe->processor[i];
22 
23 		mask |= 1 << (pp->id - lima_ip_pp0);
24 	}
25 
26 	bcast_write(LIMA_BCAST_BROADCAST_MASK, mask);
27 }
28 
lima_bcast_hw_init(struct lima_ip * ip)29 static int lima_bcast_hw_init(struct lima_ip *ip)
30 {
31 	bcast_write(LIMA_BCAST_BROADCAST_MASK, ip->data.mask << 16);
32 	bcast_write(LIMA_BCAST_INTERRUPT_MASK, ip->data.mask);
33 	return 0;
34 }
35 
lima_bcast_resume(struct lima_ip * ip)36 int lima_bcast_resume(struct lima_ip *ip)
37 {
38 	return lima_bcast_hw_init(ip);
39 }
40 
lima_bcast_suspend(struct lima_ip * ip)41 void lima_bcast_suspend(struct lima_ip *ip)
42 {
43 
44 }
45 
lima_bcast_mask_irq(struct lima_ip * ip)46 int lima_bcast_mask_irq(struct lima_ip *ip)
47 {
48 	bcast_write(LIMA_BCAST_BROADCAST_MASK, 0);
49 	bcast_write(LIMA_BCAST_INTERRUPT_MASK, 0);
50 	return 0;
51 }
52 
lima_bcast_reset(struct lima_ip * ip)53 int lima_bcast_reset(struct lima_ip *ip)
54 {
55 	return lima_bcast_hw_init(ip);
56 }
57 
lima_bcast_init(struct lima_ip * ip)58 int lima_bcast_init(struct lima_ip *ip)
59 {
60 	int i;
61 
62 	for (i = lima_ip_pp0; i <= lima_ip_pp7; i++) {
63 		if (ip->dev->ip[i].present)
64 			ip->data.mask |= 1 << (i - lima_ip_pp0);
65 	}
66 
67 	return lima_bcast_hw_init(ip);
68 }
69 
lima_bcast_fini(struct lima_ip * ip)70 void lima_bcast_fini(struct lima_ip *ip)
71 {
72 
73 }
74 
75