2 * Copyright (C) 2012-2015 ARM Limited. All rights reserved.
4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
7 * A copy of the licence is included with the program, and can also be obtained from Free Software
8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
11 #include "mali_broadcast.h"
12 #include "mali_kernel_common.h"
15 #define MALI_BROADCAST_REGISTER_SIZE 0x1000
16 #define MALI_BROADCAST_REG_BROADCAST_MASK 0x0
17 #define MALI_BROADCAST_REG_INTERRUPT_MASK 0x4
19 struct mali_bcast_unit {
20 struct mali_hw_core hw_core;
24 struct mali_bcast_unit *mali_bcast_unit_create(const _mali_osk_resource_t *resource)
26 struct mali_bcast_unit *bcast_unit = NULL;
28 MALI_DEBUG_ASSERT_POINTER(resource);
29 MALI_DEBUG_PRINT(2, ("Broadcast: Creating Mali Broadcast unit: %s\n",
30 resource->description));
32 bcast_unit = _mali_osk_malloc(sizeof(struct mali_bcast_unit));
33 if (NULL == bcast_unit) {
34 MALI_PRINT_ERROR(("Broadcast: Failed to allocate memory for Broadcast unit\n"));
38 if (_MALI_OSK_ERR_OK == mali_hw_core_create(&bcast_unit->hw_core,
39 resource, MALI_BROADCAST_REGISTER_SIZE)) {
40 bcast_unit->current_mask = 0;
41 mali_bcast_reset(bcast_unit);
45 MALI_PRINT_ERROR(("Broadcast: Failed map broadcast unit\n"));
48 _mali_osk_free(bcast_unit);
53 void mali_bcast_unit_delete(struct mali_bcast_unit *bcast_unit)
55 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
56 mali_hw_core_delete(&bcast_unit->hw_core);
57 _mali_osk_free(bcast_unit);
60 /* Call this function to add the @group's id into bcast mask
61 * Note: redundant calling this function with same @group
62 * doesn't make any difference as calling it once
64 void mali_bcast_add_group(struct mali_bcast_unit *bcast_unit,
65 struct mali_group *group)
70 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
71 MALI_DEBUG_ASSERT_POINTER(group);
73 bcast_id = mali_pp_core_get_bcast_id(mali_group_get_pp_core(group));
75 broadcast_mask = bcast_unit->current_mask;
77 broadcast_mask |= (bcast_id); /* add PP core to broadcast */
78 broadcast_mask |= (bcast_id << 16); /* add MMU to broadcast */
80 /* store mask so we can restore on reset */
81 bcast_unit->current_mask = broadcast_mask;
84 /* Call this function to remove @group's id from bcast mask
85 * Note: redundant calling this function with same @group
86 * doesn't make any difference as calling it once
88 void mali_bcast_remove_group(struct mali_bcast_unit *bcast_unit,
89 struct mali_group *group)
94 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
95 MALI_DEBUG_ASSERT_POINTER(group);
97 bcast_id = mali_pp_core_get_bcast_id(mali_group_get_pp_core(group));
99 broadcast_mask = bcast_unit->current_mask;
101 broadcast_mask &= ~((bcast_id << 16) | bcast_id);
103 /* store mask so we can restore on reset */
104 bcast_unit->current_mask = broadcast_mask;
107 void mali_bcast_reset(struct mali_bcast_unit *bcast_unit)
109 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
112 ("Broadcast: setting mask 0x%08X + 0x%08X (reset)\n",
113 bcast_unit->current_mask,
114 bcast_unit->current_mask & 0xFF));
116 /* set broadcast mask */
117 mali_hw_core_register_write(&bcast_unit->hw_core,
118 MALI_BROADCAST_REG_BROADCAST_MASK,
119 bcast_unit->current_mask);
121 /* set IRQ override mask */
122 mali_hw_core_register_write(&bcast_unit->hw_core,
123 MALI_BROADCAST_REG_INTERRUPT_MASK,
124 bcast_unit->current_mask & 0xFF);
127 void mali_bcast_disable(struct mali_bcast_unit *bcast_unit)
129 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
131 MALI_DEBUG_PRINT(4, ("Broadcast: setting mask 0x0 + 0x0 (disable)\n"));
133 /* set broadcast mask */
134 mali_hw_core_register_write(&bcast_unit->hw_core,
135 MALI_BROADCAST_REG_BROADCAST_MASK,
138 /* set IRQ override mask */
139 mali_hw_core_register_write(&bcast_unit->hw_core,
140 MALI_BROADCAST_REG_INTERRUPT_MASK,