sde_hw_qdss.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved.
  4. */
  5. #define pr_fmt(fmt) "[drm:%s:%d] " fmt, __func__, __LINE__
  6. #include <linux/mutex.h>
  7. #include <linux/platform_device.h>
  8. #include "sde_kms.h"
  9. #include "sde_dbg.h"
  10. #include "sde_hw_qdss.h"
  11. #define QDSS_CONFIG 0x0
  12. static struct sde_qdss_cfg *_qdss_offset(enum sde_qdss qdss,
  13. struct sde_mdss_cfg *m,
  14. void __iomem *addr,
  15. struct sde_hw_blk_reg_map *b)
  16. {
  17. int i;
  18. for (i = 0; i < m->qdss_count; i++) {
  19. if (qdss == m->qdss[i].id) {
  20. b->base_off = addr;
  21. b->blk_off = m->qdss[i].base;
  22. b->length = m->qdss[i].len;
  23. b->hw_rev = m->hw_rev;
  24. b->log_mask = SDE_DBG_MASK_QDSS;
  25. return &m->qdss[i];
  26. }
  27. }
  28. return ERR_PTR(-EINVAL);
  29. }
  30. static void sde_hw_qdss_enable_qdss_events(struct sde_hw_qdss *hw_qdss,
  31. bool enable)
  32. {
  33. struct sde_hw_blk_reg_map *c = &hw_qdss->hw;
  34. u32 val;
  35. val = enable ? 0x100 : 0;
  36. if (c)
  37. SDE_REG_WRITE(c, QDSS_CONFIG, val);
  38. }
  39. static void _setup_qdss_ops(struct sde_hw_qdss_ops *ops)
  40. {
  41. ops->enable_qdss_events = sde_hw_qdss_enable_qdss_events;
  42. }
  43. struct sde_hw_blk_reg_map *sde_hw_qdss_init(enum sde_qdss idx,
  44. void __iomem *addr,
  45. struct sde_mdss_cfg *m)
  46. {
  47. struct sde_hw_qdss *c;
  48. struct sde_qdss_cfg *cfg;
  49. c = kzalloc(sizeof(*c), GFP_KERNEL);
  50. if (!c)
  51. return ERR_PTR(-ENOMEM);
  52. cfg = _qdss_offset(idx, m, addr, &c->hw);
  53. if (IS_ERR_OR_NULL(cfg)) {
  54. kfree(c);
  55. return ERR_PTR(-EINVAL);
  56. }
  57. c->idx = idx;
  58. c->caps = cfg;
  59. _setup_qdss_ops(&c->ops);
  60. sde_dbg_reg_register_dump_range(SDE_DBG_NAME, cfg->name, c->hw.blk_off,
  61. c->hw.blk_off + c->hw.length, c->hw.xin_id);
  62. return &c->hw;
  63. }
  64. void sde_hw_qdss_destroy(struct sde_hw_blk_reg_map *hw)
  65. {
  66. if (hw)
  67. kfree(to_sde_hw_qdss(hw));
  68. }