2 * Copyright (C) 2012 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 static const int bcast_unit_reg_size = 0x1000;
16 static const int bcast_unit_addr_broadcast_mask = 0x0;
17 static const int bcast_unit_addr_irq_override_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, ("Mali Broadcast unit: Creating Mali Broadcast unit: %s\n", resource->description));
31 bcast_unit = _mali_osk_malloc(sizeof(struct mali_bcast_unit));
32 if (NULL == bcast_unit) {
33 MALI_PRINT_ERROR(("Mali Broadcast unit: Failed to allocate memory for Broadcast unit\n"));
37 if (_MALI_OSK_ERR_OK == mali_hw_core_create(&bcast_unit->hw_core, resource, bcast_unit_reg_size)) {
38 bcast_unit->current_mask = 0;
39 mali_bcast_reset(bcast_unit);
43 MALI_PRINT_ERROR(("Mali Broadcast unit: Failed map broadcast unit\n"));
46 _mali_osk_free(bcast_unit);
51 void mali_bcast_unit_delete(struct mali_bcast_unit *bcast_unit)
53 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
55 mali_hw_core_delete(&bcast_unit->hw_core);
56 _mali_osk_free(bcast_unit);
59 void mali_bcast_add_group(struct mali_bcast_unit *bcast_unit, struct mali_group *group)
64 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
65 MALI_DEBUG_ASSERT_POINTER(group);
67 bcast_id = mali_pp_core_get_bcast_id(mali_group_get_pp_core(group));
69 broadcast_mask = bcast_unit->current_mask;
71 broadcast_mask |= (bcast_id); /* add PP core to broadcast */
72 broadcast_mask |= (bcast_id << 16); /* add MMU to broadcast */
74 /* store mask so we can restore on reset */
75 bcast_unit->current_mask = broadcast_mask;
78 void mali_bcast_remove_group(struct mali_bcast_unit *bcast_unit, struct mali_group *group)
83 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
84 MALI_DEBUG_ASSERT_POINTER(group);
86 bcast_id = mali_pp_core_get_bcast_id(mali_group_get_pp_core(group));
88 broadcast_mask = bcast_unit->current_mask;
90 broadcast_mask &= ~((bcast_id << 16) | bcast_id);
92 /* store mask so we can restore on reset */
93 bcast_unit->current_mask = broadcast_mask;
96 void mali_bcast_reset(struct mali_bcast_unit *bcast_unit)
98 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
100 /* set broadcast mask */
101 mali_hw_core_register_write(&bcast_unit->hw_core,
102 bcast_unit_addr_broadcast_mask,
103 bcast_unit->current_mask);
105 /* set IRQ override mask */
106 mali_hw_core_register_write(&bcast_unit->hw_core,
107 bcast_unit_addr_irq_override_mask,
108 bcast_unit->current_mask & 0xFF);
111 void mali_bcast_disable(struct mali_bcast_unit *bcast_unit)
113 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
115 /* set broadcast mask */
116 mali_hw_core_register_write(&bcast_unit->hw_core,
117 bcast_unit_addr_broadcast_mask,
120 /* set IRQ override mask */
121 mali_hw_core_register_write(&bcast_unit->hw_core,
122 bcast_unit_addr_irq_override_mask,