2 * Copyright (C) 2011-2016 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.
15 #include "mali_pp_job.h"
16 #include "mali_hw_core.h"
20 #define MALI_MAX_NUMBER_OF_PP_CORES 9
23 * Definition of the PP core struct
24 * Used to track a PP core in the system.
27 struct mali_hw_core hw_core; /**< Common for all HW cores */
28 _mali_osk_irq_t *irq; /**< IRQ handler */
29 u32 core_id; /**< Unique core ID */
30 u32 bcast_id; /**< The "flag" value used by the Mali-450 broadcast and DLBU unit */
33 _mali_osk_errcode_t mali_pp_initialize(void);
34 void mali_pp_terminate(void);
36 struct mali_pp_core *mali_pp_create(const _mali_osk_resource_t *resource, struct mali_group *group, mali_bool is_virtual, u32 bcast_id);
37 void mali_pp_delete(struct mali_pp_core *core);
39 void mali_pp_stop_bus(struct mali_pp_core *core);
40 _mali_osk_errcode_t mali_pp_stop_bus_wait(struct mali_pp_core *core);
41 void mali_pp_reset_async(struct mali_pp_core *core);
42 _mali_osk_errcode_t mali_pp_reset_wait(struct mali_pp_core *core);
43 _mali_osk_errcode_t mali_pp_reset(struct mali_pp_core *core);
44 _mali_osk_errcode_t mali_pp_hard_reset(struct mali_pp_core *core);
46 void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 sub_job, mali_bool restart_virtual);
48 u32 mali_pp_core_get_version(struct mali_pp_core *core);
50 MALI_STATIC_INLINE u32 mali_pp_core_get_id(struct mali_pp_core *core)
52 MALI_DEBUG_ASSERT_POINTER(core);
56 MALI_STATIC_INLINE u32 mali_pp_core_get_bcast_id(struct mali_pp_core *core)
58 MALI_DEBUG_ASSERT_POINTER(core);
59 return core->bcast_id;
62 struct mali_pp_core *mali_pp_get_global_pp_core(u32 index);
63 u32 mali_pp_get_glob_num_pp_cores(void);
66 u32 mali_pp_dump_state(struct mali_pp_core *core, char *buf, u32 size);
69 * Put instrumented HW counters from the core(s) to the job object (if enabled)
71 * parent and child is always the same, except for virtual jobs on Mali-450.
72 * In this case, the counters will be enabled on the virtual core (parent),
73 * but values need to be read from the child cores.
75 * @param parent The core used to see if the counters was enabled
76 * @param child The core to actually read the values from
77 * @job Job object to update with counter values (if enabled)
78 * @subjob Which subjob the counters are applicable for (core ID for virtual jobs)
80 void mali_pp_update_performance_counters(struct mali_pp_core *parent, struct mali_pp_core *child, struct mali_pp_job *job, u32 subjob);
82 MALI_STATIC_INLINE const char *mali_pp_core_description(struct mali_pp_core *core)
84 return core->hw_core.description;
87 MALI_STATIC_INLINE enum mali_interrupt_result mali_pp_get_interrupt_result(struct mali_pp_core *core)
89 u32 rawstat_used = mali_hw_core_register_read(&core->hw_core, MALI200_REG_ADDR_MGMT_INT_RAWSTAT) &
90 MALI200_REG_VAL_IRQ_MASK_USED;
91 if (0 == rawstat_used) {
92 return MALI_INTERRUPT_RESULT_NONE;
93 } else if (MALI200_REG_VAL_IRQ_END_OF_FRAME == rawstat_used) {
94 return MALI_INTERRUPT_RESULT_SUCCESS;
97 return MALI_INTERRUPT_RESULT_ERROR;
100 MALI_STATIC_INLINE u32 mali_pp_get_rawstat(struct mali_pp_core *core)
102 MALI_DEBUG_ASSERT_POINTER(core);
103 return mali_hw_core_register_read(&core->hw_core,
104 MALI200_REG_ADDR_MGMT_INT_RAWSTAT);
108 MALI_STATIC_INLINE u32 mali_pp_is_active(struct mali_pp_core *core)
110 u32 status = mali_hw_core_register_read(&core->hw_core, MALI200_REG_ADDR_MGMT_STATUS);
111 return (status & MALI200_REG_VAL_STATUS_RENDERING_ACTIVE) ? MALI_TRUE : MALI_FALSE;
114 MALI_STATIC_INLINE void mali_pp_mask_all_interrupts(struct mali_pp_core *core)
116 mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_INT_MASK, MALI200_REG_VAL_IRQ_MASK_NONE);
119 MALI_STATIC_INLINE void mali_pp_enable_interrupts(struct mali_pp_core *core)
121 mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_INT_MASK, MALI200_REG_VAL_IRQ_MASK_USED);
124 MALI_STATIC_INLINE void mali_pp_write_addr_renderer_list(struct mali_pp_core *core,
125 struct mali_pp_job *job, u32 subjob)
127 u32 addr = mali_pp_job_get_addr_frame(job, subjob);
128 mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_FRAME, addr);
132 MALI_STATIC_INLINE void mali_pp_write_addr_stack(struct mali_pp_core *core, struct mali_pp_job *job)
134 u32 addr = mali_pp_job_get_addr_stack(job, core->core_id);
135 mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_STACK, addr);
138 #endif /* __MALI_PP_H__ */