lima_dlbu.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_dlbu.h"
  7. #include "lima_vm.h"
  8. #include "lima_regs.h"
  9. #define dlbu_write(reg, data) writel(data, ip->iomem + reg)
  10. #define dlbu_read(reg) readl(ip->iomem + reg)
  11. void lima_dlbu_enable(struct lima_device *dev, int num_pp)
  12. {
  13. struct lima_sched_pipe *pipe = dev->pipe + lima_pipe_pp;
  14. struct lima_ip *ip = dev->ip + lima_ip_dlbu;
  15. int i, mask = 0;
  16. for (i = 0; i < num_pp; i++) {
  17. struct lima_ip *pp = pipe->processor[i];
  18. mask |= 1 << (pp->id - lima_ip_pp0);
  19. }
  20. dlbu_write(LIMA_DLBU_PP_ENABLE_MASK, mask);
  21. }
  22. void lima_dlbu_disable(struct lima_device *dev)
  23. {
  24. struct lima_ip *ip = dev->ip + lima_ip_dlbu;
  25. dlbu_write(LIMA_DLBU_PP_ENABLE_MASK, 0);
  26. }
  27. void lima_dlbu_set_reg(struct lima_ip *ip, u32 *reg)
  28. {
  29. dlbu_write(LIMA_DLBU_TLLIST_VBASEADDR, reg[0]);
  30. dlbu_write(LIMA_DLBU_FB_DIM, reg[1]);
  31. dlbu_write(LIMA_DLBU_TLLIST_CONF, reg[2]);
  32. dlbu_write(LIMA_DLBU_START_TILE_POS, reg[3]);
  33. }
  34. static int lima_dlbu_hw_init(struct lima_ip *ip)
  35. {
  36. struct lima_device *dev = ip->dev;
  37. dlbu_write(LIMA_DLBU_MASTER_TLLIST_PHYS_ADDR, dev->dlbu_dma | 1);
  38. dlbu_write(LIMA_DLBU_MASTER_TLLIST_VADDR, LIMA_VA_RESERVE_DLBU);
  39. return 0;
  40. }
  41. int lima_dlbu_resume(struct lima_ip *ip)
  42. {
  43. return lima_dlbu_hw_init(ip);
  44. }
  45. void lima_dlbu_suspend(struct lima_ip *ip)
  46. {
  47. }
  48. int lima_dlbu_init(struct lima_ip *ip)
  49. {
  50. return lima_dlbu_hw_init(ip);
  51. }
  52. void lima_dlbu_fini(struct lima_ip *ip)
  53. {
  54. }