2 * Copyright (C) 2011-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
21 struct mali_hw_core hw_core;
25 struct mali_bcast_unit *mali_bcast_unit_create(const _mali_osk_resource_t *resource)
27 struct mali_bcast_unit *bcast_unit = NULL;
29 MALI_DEBUG_ASSERT_POINTER(resource);
30 MALI_DEBUG_PRINT(2, ("Mali Broadcast unit: Creating Mali Broadcast unit: %s\n", resource->description));
32 bcast_unit = _mali_osk_malloc(sizeof(struct mali_bcast_unit));
33 if (NULL == bcast_unit)
38 if (_MALI_OSK_ERR_OK == mali_hw_core_create(&bcast_unit->hw_core, resource, bcast_unit_reg_size))
40 bcast_unit->current_mask = 0;
41 mali_bcast_reset(bcast_unit);
47 MALI_PRINT_ERROR(("Mali Broadcast unit: Failed to allocate memory for Broadcast unit\n"));
53 void mali_bcast_unit_delete(struct mali_bcast_unit *bcast_unit)
55 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
57 mali_hw_core_delete(&bcast_unit->hw_core);
58 _mali_osk_free(bcast_unit);
61 void mali_bcast_add_group(struct mali_bcast_unit *bcast_unit, struct mali_group *group)
66 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
67 MALI_DEBUG_ASSERT_POINTER(group);
69 core_id = mali_pp_core_get_id(mali_group_get_pp_core(group));
70 broadcast_mask = bcast_unit->current_mask;
72 /* set the bit corresponding to the group's core's id to 1 */
73 core_id = 1 << core_id;
74 broadcast_mask |= (core_id); /* add PP core to broadcast */
75 broadcast_mask |= (core_id << 16); /* add MMU to broadcast */
77 /* store mask so we can restore on reset */
78 bcast_unit->current_mask = broadcast_mask;
80 mali_bcast_reset(bcast_unit);
83 void mali_bcast_remove_group(struct mali_bcast_unit *bcast_unit, struct mali_group *group)
88 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
89 MALI_DEBUG_ASSERT_POINTER(group);
91 core_id = mali_pp_core_get_id(mali_group_get_pp_core(group));
92 broadcast_mask = bcast_unit->current_mask;
94 /* set the bit corresponding to the group's core's id to 0 */
95 core_id = 1 << core_id;
96 broadcast_mask &= ~((core_id << 16) | core_id);
98 /* store mask so we can restore on reset */
99 bcast_unit->current_mask = broadcast_mask;
101 mali_bcast_reset(bcast_unit);
104 void mali_bcast_reset(struct mali_bcast_unit *bcast_unit)
106 MALI_DEBUG_ASSERT_POINTER(bcast_unit);
108 /* set broadcast mask */
109 mali_hw_core_register_write(&bcast_unit->hw_core,
110 bcast_unit_addr_broadcast_mask,
111 bcast_unit->current_mask);
113 /* set IRQ override mask */
114 mali_hw_core_register_write(&bcast_unit->hw_core,
115 bcast_unit_addr_irq_override_mask,
116 bcast_unit->current_mask & 0xFF);