Lucille Sylvester | 6e36241 | 2011-12-09 16:21:42 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 | #ifndef __KGSL_PWRCTRL_H |
| 14 | #define __KGSL_PWRCTRL_H |
| 15 | |
| 16 | /***************************************************************************** |
| 17 | ** power flags |
| 18 | *****************************************************************************/ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 19 | #define KGSL_PWRFLAGS_ON 1 |
| 20 | #define KGSL_PWRFLAGS_OFF 0 |
| 21 | |
| 22 | #define KGSL_PWRLEVEL_TURBO 0 |
| 23 | #define KGSL_PWRLEVEL_NOMINAL 1 |
Lucille Sylvester | 6e36241 | 2011-12-09 16:21:42 -0700 | [diff] [blame] | 24 | #define KGSL_PWRLEVEL_LAST_OFFSET 2 |
Lucille Sylvester | 02e4629 | 2011-09-21 14:59:17 -0600 | [diff] [blame] | 25 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 26 | #define KGSL_MAX_CLKS 5 |
| 27 | |
| 28 | struct platform_device; |
| 29 | |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 30 | struct kgsl_clk_stats { |
| 31 | unsigned int old_clock_time[KGSL_MAX_PWRLEVELS]; |
| 32 | unsigned int clock_time[KGSL_MAX_PWRLEVELS]; |
| 33 | unsigned int on_time_old; |
| 34 | ktime_t start; |
| 35 | ktime_t stop; |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 36 | unsigned int no_nap_cnt; |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 37 | unsigned int elapsed; |
| 38 | unsigned int elapsed_old; |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 39 | }; |
| 40 | |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame^] | 41 | /** |
| 42 | * struct kgsl_pwrctrl - Power control settings for a KGSL device |
| 43 | * @interrupt_num - The interrupt number for the device |
| 44 | * @ebi1_clk - Pointer to the EBI clock structure |
| 45 | * @grp_clks - Array of clocks structures that we control |
| 46 | * @power_flags - Control flags for power |
| 47 | * @pwrlevels - List of supported power levels |
| 48 | * @active_pwrlevel - The currently active power level |
| 49 | * @thermal_pwrlevel - maximum powerlevel constraint from thermal |
| 50 | * @max_pwrlevel - maximum allowable powerlevel per the user |
| 51 | * @min_pwrlevel - minimum allowable powerlevel per the user |
| 52 | * @num_pwrlevels - number of available power levels |
| 53 | * @interval_timeout - timeout in jiffies to be idle before a power event |
| 54 | * @strtstp_sleepwake - true if the device supports low latency GPU start/stop |
| 55 | * @gpu_reg - pointer to the regulator structure for gpu_reg |
| 56 | * @gpu_cx - pointer to the regulator structure for gpu_cx |
| 57 | * @pcl - bus scale identifier |
| 58 | * @nap_allowed - true if the device supports naps |
| 59 | * @idle_needed - true if the device needs a idle before clock change |
| 60 | * @irq_name - resource name for the IRQ |
| 61 | * @restore_slumber - Flag to indicate that we are in a suspend/restore sequence |
| 62 | * @clk_stats - structure of clock statistics |
| 63 | */ |
| 64 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 65 | struct kgsl_pwrctrl { |
| 66 | int interrupt_num; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 67 | struct clk *ebi1_clk; |
| 68 | struct clk *grp_clks[KGSL_MAX_CLKS]; |
| 69 | unsigned long power_flags; |
| 70 | struct kgsl_pwrlevel pwrlevels[KGSL_MAX_PWRLEVELS]; |
| 71 | unsigned int active_pwrlevel; |
| 72 | int thermal_pwrlevel; |
Lucille Sylvester | 67b4c53 | 2012-02-08 11:24:31 -0800 | [diff] [blame] | 73 | unsigned int default_pwrlevel; |
Jordan Crouse | 2ddfc8a | 2012-11-27 11:33:06 -0700 | [diff] [blame^] | 74 | unsigned int max_pwrlevel; |
| 75 | unsigned int min_pwrlevel; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 76 | unsigned int num_pwrlevels; |
| 77 | unsigned int interval_timeout; |
Lynus Vaz | fe4bede | 2012-04-06 11:53:30 -0700 | [diff] [blame] | 78 | bool strtstp_sleepwake; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 79 | struct regulator *gpu_reg; |
Pu Chen | 1205378 | 2012-07-24 17:04:27 -0700 | [diff] [blame] | 80 | struct regulator *gpu_cx; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 81 | uint32_t pcl; |
| 82 | unsigned int nap_allowed; |
Kedar Joshi | c11d098 | 2012-02-07 10:59:49 +0530 | [diff] [blame] | 83 | unsigned int idle_needed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 84 | const char *irq_name; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 85 | s64 time; |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 86 | unsigned int restore_slumber; |
Suman Tatiraju | 2bdd056 | 2012-01-26 14:49:46 -0800 | [diff] [blame] | 87 | struct kgsl_clk_stats clk_stats; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 90 | void kgsl_pwrctrl_irq(struct kgsl_device *device, int state); |
| 91 | int kgsl_pwrctrl_init(struct kgsl_device *device); |
| 92 | void kgsl_pwrctrl_close(struct kgsl_device *device); |
| 93 | void kgsl_timer(unsigned long data); |
| 94 | void kgsl_idle_check(struct work_struct *work); |
| 95 | void kgsl_pre_hwaccess(struct kgsl_device *device); |
| 96 | void kgsl_check_suspended(struct kgsl_device *device); |
| 97 | int kgsl_pwrctrl_sleep(struct kgsl_device *device); |
| 98 | void kgsl_pwrctrl_wake(struct kgsl_device *device); |
| 99 | void kgsl_pwrctrl_pwrlevel_change(struct kgsl_device *device, |
| 100 | unsigned int level); |
| 101 | int kgsl_pwrctrl_init_sysfs(struct kgsl_device *device); |
| 102 | void kgsl_pwrctrl_uninit_sysfs(struct kgsl_device *device); |
| 103 | void kgsl_pwrctrl_enable(struct kgsl_device *device); |
| 104 | void kgsl_pwrctrl_disable(struct kgsl_device *device); |
| 105 | static inline unsigned long kgsl_get_clkrate(struct clk *clk) |
| 106 | { |
| 107 | return (clk != NULL) ? clk_get_rate(clk) : 0; |
| 108 | } |
| 109 | |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 110 | void kgsl_pwrctrl_set_state(struct kgsl_device *device, unsigned int state); |
| 111 | void kgsl_pwrctrl_request_state(struct kgsl_device *device, unsigned int state); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 112 | #endif /* __KGSL_PWRCTRL_H */ |