xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/mali400/mali/common/mali_l2_cache.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (C) 2010-2014, 2016-2017 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_KERNEL_L2_CACHE_H__
12 #define __MALI_KERNEL_L2_CACHE_H__
13 
14 #include "mali_osk.h"
15 #include "mali_hw_core.h"
16 
17 #define MALI_MAX_NUMBER_OF_L2_CACHE_CORES  3
18 /* Maximum 1 GP and 4 PP for an L2 cache core (Mali-400 MP4) */
19 #define MALI_MAX_NUMBER_OF_GROUPS_PER_L2_CACHE 5
20 
21 /**
22  * Definition of the L2 cache core struct
23  * Used to track a L2 cache unit in the system.
24  * Contains information about the mapping of the registers
25  */
26 struct mali_l2_cache_core {
27 	/* Common HW core functionality */
28 	struct mali_hw_core hw_core;
29 
30 	/* Synchronize L2 cache access */
31 	_mali_osk_spinlock_irq_t *lock;
32 
33 	/* Unique core ID */
34 	u32 core_id;
35 
36 	/* The power domain this L2 cache belongs to */
37 	struct mali_pm_domain *pm_domain;
38 
39 	/* MALI_TRUE if power is on for this L2 cache */
40 	mali_bool power_is_on;
41 
42 	/* A "timestamp" to avoid unnecessary flushes */
43 	u32 last_invalidated_id;
44 
45 	/* Performance counter 0, MALI_HW_CORE_NO_COUNTER for disabled */
46 	u32 counter_src0;
47 
48 	/* Performance counter 1, MALI_HW_CORE_NO_COUNTER for disabled */
49 	u32 counter_src1;
50 
51 	/*
52 	 * Performance counter 0 value base/offset
53 	 * (allows accumulative reporting even after power off)
54 	 */
55 	u32 counter_value0_base;
56 
57 	/*
58 	 * Performance counter 0 value base/offset
59 	 * (allows accumulative reporting even after power off)
60 	 */
61 	u32 counter_value1_base;
62 
63 	/* Used by PM domains to link L2 caches of same domain */
64 	_mali_osk_list_t pm_domain_list;
65 };
66 
67 _mali_osk_errcode_t mali_l2_cache_initialize(void);
68 void mali_l2_cache_terminate(void);
69 
70 struct mali_l2_cache_core *mali_l2_cache_create(
71 	_mali_osk_resource_t *resource, u32 domain_index);
72 void mali_l2_cache_delete(struct mali_l2_cache_core *cache);
73 
mali_l2_cache_get_id(struct mali_l2_cache_core * cache)74 MALI_STATIC_INLINE u32 mali_l2_cache_get_id(struct mali_l2_cache_core *cache)
75 {
76 	MALI_DEBUG_ASSERT_POINTER(cache);
77 	return cache->core_id;
78 }
79 
mali_l2_cache_get_pm_domain(struct mali_l2_cache_core * cache)80 MALI_STATIC_INLINE struct mali_pm_domain *mali_l2_cache_get_pm_domain(
81 	struct mali_l2_cache_core *cache)
82 {
83 	MALI_DEBUG_ASSERT_POINTER(cache);
84 	return cache->pm_domain;
85 }
86 
87 void mali_l2_cache_power_up(struct mali_l2_cache_core *cache);
88 void mali_l2_cache_power_down(struct mali_l2_cache_core *cache);
89 
90 void mali_l2_cache_core_set_counter_src(
91 	struct mali_l2_cache_core *cache, u32 source_id, u32 counter);
92 
mali_l2_cache_core_get_counter_src0(struct mali_l2_cache_core * cache)93 MALI_STATIC_INLINE u32 mali_l2_cache_core_get_counter_src0(
94 	struct mali_l2_cache_core *cache)
95 {
96 	MALI_DEBUG_ASSERT_POINTER(cache);
97 	return cache->counter_src0;
98 }
99 
mali_l2_cache_core_get_counter_src1(struct mali_l2_cache_core * cache)100 MALI_STATIC_INLINE u32 mali_l2_cache_core_get_counter_src1(
101 	struct mali_l2_cache_core *cache)
102 {
103 	MALI_DEBUG_ASSERT_POINTER(cache);
104 	return cache->counter_src1;
105 }
106 
107 void mali_l2_cache_core_get_counter_values(
108 	struct mali_l2_cache_core *cache,
109 	u32 *src0, u32 *value0, u32 *src1, u32 *value1);
110 
111 struct mali_l2_cache_core *mali_l2_cache_core_get_glob_l2_core(u32 index);
112 u32 mali_l2_cache_core_get_glob_num_l2_cores(void);
113 
114 struct mali_group *mali_l2_cache_get_group(
115 	struct mali_l2_cache_core *cache, u32 index);
116 
117 void mali_l2_cache_invalidate(struct mali_l2_cache_core *cache);
118 void mali_l2_cache_invalidate_conditional(
119 	struct mali_l2_cache_core *cache, u32 id);
120 
121 void mali_l2_cache_invalidate_all(void);
122 void mali_l2_cache_invalidate_all_pages(u32 *pages, u32 num_pages);
123 
124 #endif /* __MALI_KERNEL_L2_CACHE_H__ */
125