tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / mali / common / mali_pp.h
1 /*
2  * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
3  *
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.
6  *
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.
9  */
10
11 #ifndef __MALI_PP_H__
12 #define __MALI_PP_H__
13
14 #include "mali_osk.h"
15 #include "mali_pp_job.h"
16 #include "mali_hw_core.h"
17
18 struct mali_group;
19
20 #define MALI_MAX_NUMBER_OF_PP_CORES        9
21
22 /**
23  * Definition of the PP core struct
24  * Used to track a PP core in the system.
25  */
26 struct mali_pp_core
27 {
28         struct mali_hw_core  hw_core;           /**< Common for all HW cores */
29         _mali_osk_irq_t     *irq;               /**< IRQ handler */
30         u32                  core_id;           /**< Unique core ID */
31         u32                  counter_src0_used; /**< The selected performance counter 0 when a job is running */
32         u32                  counter_src1_used; /**< The selected performance counter 1 when a job is running */
33 };
34
35 _mali_osk_errcode_t mali_pp_initialize(void);
36 void mali_pp_terminate(void);
37
38 struct mali_pp_core *mali_pp_create(const _mali_osk_resource_t * resource, struct mali_group *group, mali_bool is_virtual);
39 void mali_pp_delete(struct mali_pp_core *core);
40
41 void mali_pp_stop_bus(struct mali_pp_core *core);
42 _mali_osk_errcode_t mali_pp_stop_bus_wait(struct mali_pp_core *core);
43 void mali_pp_reset_async(struct mali_pp_core *core);
44 _mali_osk_errcode_t mali_pp_reset_wait(struct mali_pp_core *core);
45 _mali_osk_errcode_t mali_pp_reset(struct mali_pp_core *core);
46 _mali_osk_errcode_t mali_pp_hard_reset(struct mali_pp_core *core);
47
48 void mali_pp_job_start(struct mali_pp_core *core, struct mali_pp_job *job, u32 sub_job, mali_bool restart_virtual);
49
50 u32 mali_pp_core_get_version(struct mali_pp_core *core);
51
52 MALI_STATIC_INLINE u32 mali_pp_core_get_id(struct mali_pp_core *core)
53 {
54         MALI_DEBUG_ASSERT_POINTER(core);
55         return core->core_id;
56 }
57
58 struct mali_pp_core* mali_pp_get_global_pp_core(u32 index);
59 u32 mali_pp_get_glob_num_pp_cores(void);
60
61 /* Debug */
62 u32 mali_pp_dump_state(struct mali_pp_core *core, char *buf, u32 size);
63
64 void mali_pp_update_performance_counters(struct mali_pp_core *core, struct mali_pp_job *job, u32 subjob);
65
66 MALI_STATIC_INLINE const char *mali_pp_get_hw_core_desc(struct mali_pp_core *core)
67 {
68         return core->hw_core.description;
69 }
70
71 /*** Register reading/writing functions ***/
72 MALI_STATIC_INLINE u32 mali_pp_get_int_stat(struct mali_pp_core *core)
73 {
74         return mali_hw_core_register_read(&core->hw_core, MALI200_REG_ADDR_MGMT_INT_STATUS);
75 }
76
77 MALI_STATIC_INLINE u32 mali_pp_read_rawstat(struct mali_pp_core *core)
78 {
79         return mali_hw_core_register_read(&core->hw_core, MALI200_REG_ADDR_MGMT_INT_RAWSTAT) & MALI200_REG_VAL_IRQ_MASK_USED;
80 }
81
82 MALI_STATIC_INLINE void mali_pp_mask_all_interrupts(struct mali_pp_core *core)
83 {
84         mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_INT_MASK, MALI200_REG_VAL_IRQ_MASK_NONE);
85 }
86
87 MALI_STATIC_INLINE void mali_pp_clear_hang_interrupt(struct mali_pp_core *core)
88 {
89         mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_INT_CLEAR, MALI200_REG_VAL_IRQ_HANG);
90 }
91
92 MALI_STATIC_INLINE void mali_pp_enable_interrupts(struct mali_pp_core *core)
93 {
94         mali_hw_core_register_write(&core->hw_core, MALI200_REG_ADDR_MGMT_INT_MASK, MALI200_REG_VAL_IRQ_MASK_USED);
95 }
96
97 MALI_STATIC_INLINE void mali_pp_write_addr_stack(struct mali_pp_core *core, struct mali_pp_job *job)
98 {
99         u32 addr = mali_pp_job_get_addr_stack(job, core->core_id);
100         mali_hw_core_register_write_relaxed(&core->hw_core, MALI200_REG_ADDR_STACK, addr);
101 }
102
103 #endif /* __MALI_PP_H__ */