2 * Copyright (C) 2010-2014 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.
12 * @file mali_platform.h
13 * Platform specific Mali driver functions
16 #ifndef __MALI_PMU_H__
17 #define __MALI_PMU_H__
20 #include "mali_kernel_common.h"
21 #include "mali_hw_core.h"
23 /** @brief MALI inbuilt PMU hardware info and PMU hardware has knowledge of cores power mask
25 struct mali_pmu_core {
26 struct mali_hw_core hw_core;
27 u32 registered_cores_mask;
31 /** @brief Register layout for hardware PMU
34 PMU_REG_ADDR_MGMT_POWER_UP = 0x00, /*< Power up register */
35 PMU_REG_ADDR_MGMT_POWER_DOWN = 0x04, /*< Power down register */
36 PMU_REG_ADDR_MGMT_STATUS = 0x08, /*< Core sleep status register */
37 PMU_REG_ADDR_MGMT_INT_MASK = 0x0C, /*< Interrupt mask register */
38 PMU_REG_ADDR_MGMT_INT_RAWSTAT = 0x10, /*< Interrupt raw status register */
39 PMU_REG_ADDR_MGMT_INT_CLEAR = 0x18, /*< Interrupt clear register */
40 PMU_REG_ADDR_MGMT_SW_DELAY = 0x1C, /*< Switch delay register */
41 PMU_REGISTER_ADDRESS_SPACE_SIZE = 0x28, /*< Size of register space */
42 } pmu_reg_addr_mgmt_addr;
44 #define PMU_REG_VAL_IRQ 1
46 extern struct mali_pmu_core *mali_global_pmu_core;
48 /** @brief Initialisation of MALI PMU
50 * This is called from entry point of the driver in order to create and intialize the PMU resource
52 * @param resource it will be a pointer to a PMU resource
53 * @param number_of_pp_cores Number of found PP resources in configuration
54 * @param number_of_l2_caches Number of found L2 cache resources in configuration
55 * @return The created PMU object, or NULL in case of failure.
57 struct mali_pmu_core *mali_pmu_create(_mali_osk_resource_t *resource);
59 /** @brief It deallocates the PMU resource
61 * This is called on the exit of the driver to terminate the PMU resource
63 * @param pmu Pointer to PMU core object to delete
65 void mali_pmu_delete(struct mali_pmu_core *pmu);
67 /** @brief Set registered cores mask
69 * @param pmu Pointer to PMU core object
70 * @param mask All available/valid domain bits
72 void mali_pmu_set_registered_cores_mask(struct mali_pmu_core *pmu, u32 mask);
74 /** @brief Retrieves the Mali PMU core object (if any)
76 * @return The Mali PMU object, or NULL if no PMU exists.
78 MALI_STATIC_INLINE struct mali_pmu_core *mali_pmu_get_global_pmu_core(void)
80 return mali_global_pmu_core;
83 /** @brief Reset PMU core
85 * @param pmu Pointer to PMU core object to reset
87 void mali_pmu_reset(struct mali_pmu_core *pmu);
89 void mali_pmu_power_up_all(struct mali_pmu_core *pmu);
91 void mali_pmu_power_down_all(struct mali_pmu_core *pmu);
93 /** @brief Returns a mask of the currently powered up domains
95 * @param pmu Pointer to PMU core object
97 MALI_STATIC_INLINE u32 mali_pmu_get_mask(struct mali_pmu_core *pmu)
99 u32 stat = mali_hw_core_register_read(&pmu->hw_core, PMU_REG_ADDR_MGMT_STATUS);
100 return ((~stat) & pmu->registered_cores_mask);
103 /** @brief MALI GPU power down using MALI in-built PMU
105 * Called to power down the specified cores.
107 * @param pmu Pointer to PMU core object to power down
108 * @param mask Mask specifying which power domains to power down
109 * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
111 _mali_osk_errcode_t mali_pmu_power_down(struct mali_pmu_core *pmu, u32 mask);
113 /** @brief MALI GPU power up using MALI in-built PMU
115 * Called to power up the specified cores.
117 * @param pmu Pointer to PMU core object to power up
118 * @param mask Mask specifying which power domains to power up
119 * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
121 _mali_osk_errcode_t mali_pmu_power_up(struct mali_pmu_core *pmu, u32 mask);
123 #endif /* __MALI_PMU_H__ */