Girish Mahadevan | 40abbe1 | 2012-04-25 14:58:13 -0600 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef __ARCH_ARM_MACH_MSM_LPM_RESOURCES_H |
| 15 | #define __ARCH_ARM_MACH_MSM_LPM_RESOURCES_H |
| 16 | |
| 17 | #include "pm.h" |
| 18 | |
| 19 | enum { |
| 20 | MSM_LPM_PXO_OFF = 0, |
| 21 | MSM_LPM_PXO_ON = 1, |
| 22 | }; |
| 23 | |
| 24 | enum { |
| 25 | MSM_LPM_L2_CACHE_HSFS_OPEN = 0, |
| 26 | MSM_LPM_L2_CACHE_GDHS = 1, |
| 27 | MSM_LPM_L2_CACHE_RETENTION = 2, |
| 28 | MSM_LPM_L2_CACHE_ACTIVE = 3, |
| 29 | }; |
| 30 | |
| 31 | struct msm_rpmrs_limits { |
| 32 | uint32_t pxo; |
| 33 | uint32_t l2_cache; |
| 34 | uint32_t vdd_mem_upper_bound; |
| 35 | uint32_t vdd_mem_lower_bound; |
| 36 | uint32_t vdd_dig_upper_bound; |
| 37 | uint32_t vdd_dig_lower_bound; |
| 38 | |
| 39 | uint32_t latency_us[NR_CPUS]; |
| 40 | uint32_t power[NR_CPUS]; |
| 41 | }; |
| 42 | |
| 43 | struct msm_rpmrs_level { |
| 44 | enum msm_pm_sleep_mode sleep_mode; |
| 45 | struct msm_rpmrs_limits rs_limits; |
| 46 | bool available; |
| 47 | uint32_t latency_us; |
| 48 | uint32_t steady_state_power; |
| 49 | uint32_t energy_overhead; |
| 50 | uint32_t time_overhead_us; |
| 51 | }; |
| 52 | |
| 53 | #ifdef CONFIG_MSM_RPM_SMD |
| 54 | |
| 55 | /** |
| 56 | * msm_lpm_level_beyond_limit() - Check if the resources in a low power level |
| 57 | * is beyond the limits of the driver votes received for those resources.This |
| 58 | * function is used by lpm_levels to eliminate any low power level that cannot |
| 59 | * be entered. |
| 60 | * |
| 61 | * @limits: pointer to the resource limits of a low power level. |
| 62 | * |
| 63 | * returns true if the resource limits are beyond driver resource votes. |
| 64 | * false otherwise. |
| 65 | */ |
| 66 | bool msm_lpm_level_beyond_limit(struct msm_rpmrs_limits *limits); |
| 67 | |
| 68 | /** |
| 69 | * msm_lpmrs_enter_sleep() - Enter sleep flushes the sleep votes of low power |
| 70 | * resources to the RPM driver, also configure the MPM if needed depending |
| 71 | * on the low power mode being entered. L2 low power mode is also set in |
| 72 | * this function. |
| 73 | |
Mahesh Sivasubramanian | 2efbc35 | 2012-07-18 14:15:44 -0600 | [diff] [blame] | 74 | * @sclk_count: wakeup counter for RPM. |
Girish Mahadevan | 40abbe1 | 2012-04-25 14:58:13 -0600 | [diff] [blame] | 75 | * @limits: pointer to the resource limits of the low power mode being entered. |
| 76 | * @from_idle: bool to determine if this call being made as a part of |
| 77 | * idle power collapse. |
| 78 | * @notify_rpm: bool that informs if this is an RPM notified power collapse. |
| 79 | * |
| 80 | * returns 0 on success. |
| 81 | */ |
Mahesh Sivasubramanian | 2efbc35 | 2012-07-18 14:15:44 -0600 | [diff] [blame] | 82 | int msm_lpmrs_enter_sleep(uint32_t sclk_count, struct msm_rpmrs_limits *limits, |
Girish Mahadevan | 40abbe1 | 2012-04-25 14:58:13 -0600 | [diff] [blame] | 83 | bool from_idle, bool notify_rpm); |
| 84 | |
| 85 | /** |
| 86 | * msm_lpmrs_exit_sleep() - Exit sleep, reset the MPM and L2 mode. |
Girish Mahadevan | 40abbe1 | 2012-04-25 14:58:13 -0600 | [diff] [blame] | 87 | * @ limits: pointer to resource limits of the most recent low power mode. |
| 88 | * @from_idle: bool to determine if this call being made as a part of |
| 89 | * idle power collapse. |
| 90 | * @notify_rpm: bool that informs if this is an RPM notified power collapse. |
Girish Mahadevan | a9964a5 | 2012-06-29 10:14:09 -0600 | [diff] [blame] | 91 | * @collapsed: bool that informs if the Krait was power collapsed. |
Girish Mahadevan | 40abbe1 | 2012-04-25 14:58:13 -0600 | [diff] [blame] | 92 | */ |
Girish Mahadevan | a9964a5 | 2012-06-29 10:14:09 -0600 | [diff] [blame] | 93 | void msm_lpmrs_exit_sleep(struct msm_rpmrs_limits *limits, |
| 94 | bool from_idle, bool notify_rpm, bool collapsed); |
Girish Mahadevan | 40abbe1 | 2012-04-25 14:58:13 -0600 | [diff] [blame] | 95 | /** |
| 96 | * msm_lpmrs_module_init() - Init function that parses the device tree to |
| 97 | * get the low power resource attributes and registers with RPM driver for |
| 98 | * callback notification. |
| 99 | * |
| 100 | * returns 0 on success. |
| 101 | */ |
| 102 | int __init msm_lpmrs_module_init(void); |
| 103 | |
| 104 | #else |
| 105 | static inline bool msm_lpm_level_beyond_limit(struct msm_rpmrs_limits *limits) |
| 106 | { |
| 107 | return true; |
| 108 | } |
| 109 | |
Mahesh Sivasubramanian | 2efbc35 | 2012-07-18 14:15:44 -0600 | [diff] [blame] | 110 | static inline int msm_lpmrs_enter_sleep(uint32_t sclk_count, |
| 111 | struct msm_rpmrs_limits *limits, bool from_idle, bool notify_rpm) |
Girish Mahadevan | 40abbe1 | 2012-04-25 14:58:13 -0600 | [diff] [blame] | 112 | { |
| 113 | return 0; |
| 114 | } |
| 115 | |
Girish Mahadevan | a9964a5 | 2012-06-29 10:14:09 -0600 | [diff] [blame] | 116 | static inline void msm_lpmrs_exit_sleep(struct msm_rpmrs_limits *limits, |
| 117 | bool from_idle, bool notify_rpm, bool collapsed) |
Girish Mahadevan | 40abbe1 | 2012-04-25 14:58:13 -0600 | [diff] [blame] | 118 | { |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | static inline int __init msm_lpmrs_module_init(void) |
| 123 | { |
| 124 | return 0; |
| 125 | } |
| 126 | #endif /* CONFIG_MSM_RPM_SMD */ |
| 127 | |
| 128 | #endif |