lima_bcast.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // SPDX-License-Identifier: GPL-2.0 OR MIT
  2. /* Copyright 2018-2019 Qiang Yu <yuq825@gmail.com> */
  3. #include <linux/io.h>
  4. #include <linux/device.h>
  5. #include "lima_device.h"
  6. #include "lima_bcast.h"
  7. #include "lima_regs.h"
  8. #define bcast_write(reg, data) writel(data, ip->iomem + reg)
  9. #define bcast_read(reg) readl(ip->iomem + reg)
  10. void lima_bcast_enable(struct lima_device *dev, int num_pp)
  11. {
  12. struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_pp;
  13. struct lima_ip *ip = dev->ip + lima_ip_bcast;
  14. int i, mask = bcast_read(LIMA_BCAST_BROADCAST_MASK) & 0xffff0000;
  15. for (i = 0; i < num_pp; i++) {
  16. struct lima_ip *pp = pipe->processor[i];
  17. mask |= 1 << (pp->id - lima_ip_pp0);
  18. }
  19. bcast_write(LIMA_BCAST_BROADCAST_MASK, mask);
  20. }
  21. static int lima_bcast_hw_init(struct lima_ip *ip)
  22. {
  23. bcast_write(LIMA_BCAST_BROADCAST_MASK, ip->data.mask << 16);
  24. bcast_write(LIMA_BCAST_INTERRUPT_MASK, ip->data.mask);
  25. return 0;
  26. }
  27. int lima_bcast_resume(struct lima_ip *ip)
  28. {
  29. return lima_bcast_hw_init(ip);
  30. }
  31. void lima_bcast_suspend(struct lima_ip *ip)
  32. {
  33. }
  34. int lima_bcast_init(struct lima_ip *ip)
  35. {
  36. int i;
  37. for (i = lima_ip_pp0; i <= lima_ip_pp7; i++) {
  38. if (ip->dev->ip[i].present)
  39. ip->data.mask |= 1 << (i - lima_ip_pp0);
  40. }
  41. return lima_bcast_hw_init(ip);
  42. }
  43. void lima_bcast_fini(struct lima_ip *ip)
  44. {
  45. }