Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010-2011, 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_RPM_RESOURCES_H |
| 15 | #define __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H |
| 16 | |
| 17 | #include <mach/rpm.h> |
| 18 | #include "pm.h" |
| 19 | |
| 20 | |
| 21 | struct msm_rpmrs_limits { |
| 22 | uint32_t pxo; |
| 23 | uint32_t l2_cache; |
| 24 | uint32_t vdd_mem_upper_bound; |
| 25 | uint32_t vdd_mem; |
| 26 | uint32_t vdd_dig_upper_bound; |
| 27 | uint32_t vdd_dig; |
| 28 | |
| 29 | uint32_t latency_us[NR_CPUS]; |
| 30 | uint32_t power[NR_CPUS]; |
| 31 | }; |
| 32 | |
| 33 | enum { |
| 34 | MSM_RPMRS_PXO_OFF = 0, |
| 35 | MSM_RPMRS_PXO_ON = 1, |
| 36 | }; |
| 37 | |
| 38 | enum { |
| 39 | MSM_RPMRS_L2_CACHE_HSFS_OPEN = 0, |
| 40 | MSM_RPMRS_L2_CACHE_GDHS = 1, |
| 41 | MSM_RPMRS_L2_CACHE_RETENTION = 2, |
| 42 | MSM_RPMRS_L2_CACHE_ACTIVE = 3, |
| 43 | }; |
| 44 | |
Praveen Chidambaram | 9dfa871 | 2011-09-14 16:25:01 -0600 | [diff] [blame] | 45 | enum { |
| 46 | MSM_RPMRS_MASK_RPM_CTL_CPU_HALT = 1, |
| 47 | MSM_RPMRS_MASK_RPM_CTL_MULTI_TIER = 2, |
| 48 | }; |
| 49 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 50 | #define MSM_RPMRS_LIMITS(_pxo, _l2, _vdd_upper_b, _vdd) { \ |
| 51 | MSM_RPMRS_PXO_##_pxo, \ |
| 52 | MSM_RPMRS_L2_CACHE_##_l2, \ |
| 53 | MSM_RPMRS_VDD_MEM_##_vdd_upper_b, \ |
| 54 | MSM_RPMRS_VDD_MEM_##_vdd, \ |
| 55 | MSM_RPMRS_VDD_DIG_##_vdd_upper_b, \ |
| 56 | MSM_RPMRS_VDD_DIG_##_vdd, \ |
| 57 | {0}, {0}, \ |
| 58 | } |
| 59 | |
| 60 | struct msm_rpmrs_level { |
| 61 | enum msm_pm_sleep_mode sleep_mode; |
| 62 | struct msm_rpmrs_limits rs_limits; |
| 63 | bool available; |
| 64 | uint32_t latency_us; |
| 65 | uint32_t steady_state_power; |
| 66 | uint32_t energy_overhead; |
| 67 | uint32_t time_overhead_us; |
| 68 | }; |
| 69 | |
| 70 | int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req, int count); |
| 71 | int msm_rpmrs_set_noirq(int ctx, struct msm_rpm_iv_pair *req, int count); |
Praveen Chidambaram | 9dfa871 | 2011-09-14 16:25:01 -0600 | [diff] [blame] | 72 | int msm_rpmrs_set_bits_noirq(int ctx, struct msm_rpm_iv_pair *req, int count, |
| 73 | int *mask); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 74 | |
| 75 | static inline int msm_rpmrs_set_nosleep( |
| 76 | int ctx, struct msm_rpm_iv_pair *req, int count) |
| 77 | { |
| 78 | unsigned long flags; |
| 79 | int rc; |
| 80 | |
| 81 | local_irq_save(flags); |
| 82 | rc = msm_rpmrs_set_noirq(ctx, req, count); |
| 83 | local_irq_restore(flags); |
| 84 | |
| 85 | return rc; |
| 86 | } |
| 87 | |
| 88 | int msm_rpmrs_clear(int ctx, struct msm_rpm_iv_pair *req, int count); |
| 89 | int msm_rpmrs_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, int count); |
| 90 | |
| 91 | static inline int msm_rpmrs_clear_nosleep( |
| 92 | int ctx, struct msm_rpm_iv_pair *req, int count) |
| 93 | { |
| 94 | unsigned long flags; |
| 95 | int rc; |
| 96 | |
| 97 | local_irq_save(flags); |
| 98 | rc = msm_rpmrs_clear_noirq(ctx, req, count); |
| 99 | local_irq_restore(flags); |
| 100 | |
| 101 | return rc; |
| 102 | } |
| 103 | |
| 104 | void msm_rpmrs_show_resources(void); |
| 105 | |
| 106 | struct msm_rpmrs_limits *msm_rpmrs_lowest_limits( |
| 107 | bool from_idle, enum msm_pm_sleep_mode sleep_mode, uint32_t latency_us, |
| 108 | uint32_t sleep_us); |
| 109 | |
| 110 | int msm_rpmrs_enter_sleep(uint32_t sclk_count, struct msm_rpmrs_limits *limits, |
| 111 | bool from_idle, bool notify_rpm); |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 112 | void msm_rpmrs_exit_sleep(struct msm_rpmrs_limits *limits, bool from_idle, |
| 113 | bool notify_rpm, bool collapsed); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 114 | |
| 115 | int msm_rpmrs_levels_init(struct msm_rpmrs_level *levels, int size); |
| 116 | |
| 117 | #endif /* __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H */ |