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"
8 #include "lima_bcast.h"
11 #define bcast_write(reg, data) writel(data, ip->iomem + reg)
12 #define bcast_read(reg) readl(ip->iomem + reg)
14 void lima_bcast_enable(struct lima_device
*dev
, int num_pp
)
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;
20 for (i
= 0; i
< num_pp
; i
++) {
21 struct lima_ip
*pp
= pipe
->processor
[i
];
23 mask
|= 1 << (pp
->id
- lima_ip_pp0
);
26 bcast_write(LIMA_BCAST_BROADCAST_MASK
, mask
);
29 static int lima_bcast_hw_init(struct lima_ip
*ip
)
31 bcast_write(LIMA_BCAST_BROADCAST_MASK
, ip
->data
.mask
<< 16);
32 bcast_write(LIMA_BCAST_INTERRUPT_MASK
, ip
->data
.mask
);
36 int lima_bcast_resume(struct lima_ip
*ip
)
38 return lima_bcast_hw_init(ip
);
41 void lima_bcast_suspend(struct lima_ip
*ip
)
46 int lima_bcast_init(struct lima_ip
*ip
)
50 for (i
= lima_ip_pp0
; i
<= lima_ip_pp7
; i
++) {
51 if (ip
->dev
->ip
[i
].present
)
52 ip
->data
.mask
|= 1 << (i
- lima_ip_pp0
);
55 return lima_bcast_hw_init(ip
);
58 void lima_bcast_fini(struct lima_ip
*ip
)