mali_broadcast.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * This confidential and proprietary software may be used only as
  3. * authorised by a licensing agreement from ARM Limited
  4. * (C) COPYRIGHT 2012-2013 ARM Limited
  5. * ALL RIGHTS RESERVED
  6. * The entire notice above must be reproduced on all authorised
  7. * copies and copies may only be made to the extent permitted
  8. * by a licensing agreement from ARM Limited.
  9. */
  10. #include "mali_broadcast.h"
  11. #include "mali_kernel_common.h"
  12. #include "mali_osk.h"
  13. static const int bcast_unit_reg_size = 0x1000;
  14. static const int bcast_unit_addr_broadcast_mask = 0x0;
  15. static const int bcast_unit_addr_irq_override_mask = 0x4;
  16. struct mali_bcast_unit {
  17. struct mali_hw_core hw_core;
  18. u32 current_mask;
  19. };
  20. struct mali_bcast_unit *mali_bcast_unit_create(const _mali_osk_resource_t *resource)
  21. {
  22. struct mali_bcast_unit *bcast_unit = NULL;
  23. MALI_DEBUG_ASSERT_POINTER(resource);
  24. MALI_DEBUG_PRINT(2, ("Mali Broadcast unit: Creating Mali Broadcast unit: %s\n", resource->description));
  25. bcast_unit = _mali_osk_malloc(sizeof(struct mali_bcast_unit));
  26. if (NULL == bcast_unit) {
  27. MALI_PRINT_ERROR(("Mali Broadcast unit: Failed to allocate memory for Broadcast unit\n"));
  28. return NULL;
  29. }
  30. if (_MALI_OSK_ERR_OK == mali_hw_core_create(&bcast_unit->hw_core, resource, bcast_unit_reg_size)) {
  31. bcast_unit->current_mask = 0;
  32. mali_bcast_reset(bcast_unit);
  33. return bcast_unit;
  34. } else {
  35. MALI_PRINT_ERROR(("Mali Broadcast unit: Failed map broadcast unit\n"));
  36. }
  37. _mali_osk_free(bcast_unit);
  38. return NULL;
  39. }
  40. void mali_bcast_unit_delete(struct mali_bcast_unit *bcast_unit)
  41. {
  42. MALI_DEBUG_ASSERT_POINTER(bcast_unit);
  43. mali_hw_core_delete(&bcast_unit->hw_core);
  44. _mali_osk_free(bcast_unit);
  45. }
  46. void mali_bcast_add_group(struct mali_bcast_unit *bcast_unit, struct mali_group *group)
  47. {
  48. u32 bcast_id;
  49. u32 broadcast_mask;
  50. MALI_DEBUG_ASSERT_POINTER(bcast_unit);
  51. MALI_DEBUG_ASSERT_POINTER(group);
  52. bcast_id = mali_pp_core_get_bcast_id(mali_group_get_pp_core(group));
  53. broadcast_mask = bcast_unit->current_mask;
  54. broadcast_mask |= (bcast_id); /* add PP core to broadcast */
  55. broadcast_mask |= (bcast_id << 16); /* add MMU to broadcast */
  56. /* store mask so we can restore on reset */
  57. bcast_unit->current_mask = broadcast_mask;
  58. }
  59. void mali_bcast_remove_group(struct mali_bcast_unit *bcast_unit, struct mali_group *group)
  60. {
  61. u32 bcast_id;
  62. u32 broadcast_mask;
  63. MALI_DEBUG_ASSERT_POINTER(bcast_unit);
  64. MALI_DEBUG_ASSERT_POINTER(group);
  65. bcast_id = mali_pp_core_get_bcast_id(mali_group_get_pp_core(group));
  66. broadcast_mask = bcast_unit->current_mask;
  67. broadcast_mask &= ~((bcast_id << 16) | bcast_id);
  68. /* store mask so we can restore on reset */
  69. bcast_unit->current_mask = broadcast_mask;
  70. }
  71. void mali_bcast_reset(struct mali_bcast_unit *bcast_unit)
  72. {
  73. MALI_DEBUG_ASSERT_POINTER(bcast_unit);
  74. /* set broadcast mask */
  75. mali_hw_core_register_write(&bcast_unit->hw_core,
  76. bcast_unit_addr_broadcast_mask,
  77. bcast_unit->current_mask);
  78. /* set IRQ override mask */
  79. mali_hw_core_register_write(&bcast_unit->hw_core,
  80. bcast_unit_addr_irq_override_mask,
  81. bcast_unit->current_mask & 0xFF);
  82. }
  83. void mali_bcast_disable(struct mali_bcast_unit *bcast_unit)
  84. {
  85. MALI_DEBUG_ASSERT_POINTER(bcast_unit);
  86. /* set broadcast mask */
  87. mali_hw_core_register_write(&bcast_unit->hw_core,
  88. bcast_unit_addr_broadcast_mask,
  89. 0x0);
  90. /* set IRQ override mask */
  91. mali_hw_core_register_write(&bcast_unit->hw_core,
  92. bcast_unit_addr_irq_override_mask,
  93. 0x0);
  94. }