tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / mali / common / mali_gp.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_GP_H__
12 #define __MALI_GP_H__
13
14 #include "mali_osk.h"
15 #include "mali_gp_job.h"
16 #include "mali_hw_core.h"
17 #include "regs/mali_gp_regs.h"
18
19 struct mali_group;
20
21 /**
22  * Definition of the GP core struct
23  * Used to track a GP core in the system.
24  */
25 struct mali_gp_core
26 {
27         struct mali_hw_core  hw_core;           /**< Common for all HW cores */
28         _mali_osk_irq_t     *irq;               /**< IRQ handler */
29         u32                  counter_src0_used; /**< The selected performance counter 0 when a job is running */
30         u32                  counter_src1_used; /**< The selected performance counter 1 when a job is running */
31 };
32
33 _mali_osk_errcode_t mali_gp_initialize(void);
34 void mali_gp_terminate(void);
35
36 struct mali_gp_core *mali_gp_create(const _mali_osk_resource_t * resource, struct mali_group *group);
37 void mali_gp_delete(struct mali_gp_core *core);
38
39 void mali_gp_stop_bus(struct mali_gp_core *core);
40 _mali_osk_errcode_t mali_gp_stop_bus_wait(struct mali_gp_core *core);
41 void mali_gp_reset_async(struct mali_gp_core *core);
42 _mali_osk_errcode_t mali_gp_reset_wait(struct mali_gp_core *core);
43 void mali_gp_hard_reset(struct mali_gp_core *core);
44 _mali_osk_errcode_t mali_gp_reset(struct mali_gp_core *core);
45
46 void mali_gp_job_start(struct mali_gp_core *core, struct mali_gp_job *job);
47 void mali_gp_resume_with_new_heap(struct mali_gp_core *core, u32 start_addr, u32 end_addr);
48
49 u32 mali_gp_core_get_version(struct mali_gp_core *core);
50
51 struct mali_gp_core *mali_gp_get_global_gp_core(void);
52
53 u32 mali_gp_dump_state(struct mali_gp_core *core, char *buf, u32 size);
54
55 void mali_gp_update_performance_counters(struct mali_gp_core *core, struct mali_gp_job *job, mali_bool suspend);
56
57 /*** Accessor functions ***/
58 MALI_STATIC_INLINE const char *mali_gp_get_hw_core_desc(struct mali_gp_core *core)
59 {
60         return core->hw_core.description;
61 }
62
63 /*** Register reading/writing functions ***/
64 MALI_STATIC_INLINE u32 mali_gp_get_int_stat(struct mali_gp_core *core)
65 {
66         return mali_hw_core_register_read(&core->hw_core, MALIGP2_REG_ADDR_MGMT_INT_STAT);
67 }
68
69 MALI_STATIC_INLINE void mali_gp_mask_all_interrupts(struct mali_gp_core *core)
70 {
71         mali_hw_core_register_write(&core->hw_core, MALIGP2_REG_ADDR_MGMT_INT_MASK, MALIGP2_REG_VAL_IRQ_MASK_NONE);
72 }
73
74 MALI_STATIC_INLINE u32 mali_gp_read_rawstat(struct mali_gp_core *core)
75 {
76         return mali_hw_core_register_read(&core->hw_core, MALIGP2_REG_ADDR_MGMT_INT_RAWSTAT) & MALIGP2_REG_VAL_IRQ_MASK_USED;
77 }
78
79 MALI_STATIC_INLINE u32 mali_gp_read_core_status(struct mali_gp_core *core)
80 {
81         return mali_hw_core_register_read(&core->hw_core, MALIGP2_REG_ADDR_MGMT_STATUS);
82 }
83
84 MALI_STATIC_INLINE void mali_gp_enable_interrupts(struct mali_gp_core *core, u32 irq_exceptions)
85 {
86         /* Enable all interrupts, except those specified in irq_exceptions */
87         mali_hw_core_register_write(&core->hw_core, MALIGP2_REG_ADDR_MGMT_INT_MASK,
88                                     MALIGP2_REG_VAL_IRQ_MASK_USED & ~irq_exceptions);
89 }
90
91 MALI_STATIC_INLINE u32 mali_gp_read_plbu_alloc_start_addr(struct mali_gp_core *core)
92 {
93         return mali_hw_core_register_read(&core->hw_core, MALIGP2_REG_ADDR_MGMT_PLBU_ALLOC_START_ADDR);
94 }
95
96 #endif /* __MALI_GP_H__ */