Tarun Karra | f8e5cd2 | 2012-01-09 14:10:09 -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 | 02e4629 | 2011-09-21 14:59:17 -0600 | [diff] [blame] | 24 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | #define KGSL_MAX_CLKS 5 |
| 26 | |
| 27 | struct platform_device; |
| 28 | |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 29 | struct kgsl_busy { |
| 30 | struct timeval start; |
| 31 | struct timeval stop; |
| 32 | int on_time; |
| 33 | int time; |
| 34 | int on_time_old; |
| 35 | int time_old; |
| 36 | unsigned int no_nap_cnt; |
| 37 | }; |
| 38 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 39 | struct kgsl_pwrctrl { |
| 40 | int interrupt_num; |
| 41 | int have_irq; |
| 42 | struct clk *ebi1_clk; |
| 43 | struct clk *grp_clks[KGSL_MAX_CLKS]; |
| 44 | unsigned long power_flags; |
| 45 | struct kgsl_pwrlevel pwrlevels[KGSL_MAX_PWRLEVELS]; |
| 46 | unsigned int active_pwrlevel; |
| 47 | int thermal_pwrlevel; |
| 48 | unsigned int num_pwrlevels; |
| 49 | unsigned int interval_timeout; |
| 50 | struct regulator *gpu_reg; |
| 51 | uint32_t pcl; |
| 52 | unsigned int nap_allowed; |
| 53 | const char *regulator_name; |
| 54 | const char *irq_name; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 55 | s64 time; |
Suman Tatiraju | 7fe62a3 | 2011-07-14 16:40:37 -0700 | [diff] [blame] | 56 | struct kgsl_busy busy; |
Suman Tatiraju | 2456902 | 2011-10-27 11:11:12 -0700 | [diff] [blame] | 57 | unsigned int restore_slumber; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 60 | void kgsl_pwrctrl_irq(struct kgsl_device *device, int state); |
Tarun Karra | f8e5cd2 | 2012-01-09 14:10:09 -0700 | [diff] [blame] | 61 | void kgsl_pwrctrl_clk(struct kgsl_device *device, int state); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 62 | int kgsl_pwrctrl_init(struct kgsl_device *device); |
| 63 | void kgsl_pwrctrl_close(struct kgsl_device *device); |
| 64 | void kgsl_timer(unsigned long data); |
| 65 | void kgsl_idle_check(struct work_struct *work); |
| 66 | void kgsl_pre_hwaccess(struct kgsl_device *device); |
| 67 | void kgsl_check_suspended(struct kgsl_device *device); |
| 68 | int kgsl_pwrctrl_sleep(struct kgsl_device *device); |
| 69 | void kgsl_pwrctrl_wake(struct kgsl_device *device); |
| 70 | void kgsl_pwrctrl_pwrlevel_change(struct kgsl_device *device, |
| 71 | unsigned int level); |
| 72 | int kgsl_pwrctrl_init_sysfs(struct kgsl_device *device); |
| 73 | void kgsl_pwrctrl_uninit_sysfs(struct kgsl_device *device); |
| 74 | void kgsl_pwrctrl_enable(struct kgsl_device *device); |
| 75 | void kgsl_pwrctrl_disable(struct kgsl_device *device); |
Tarun Karra | f8e5cd2 | 2012-01-09 14:10:09 -0700 | [diff] [blame] | 76 | void kgsl_pwrctrl_stop_work(struct kgsl_device *device); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 77 | static inline unsigned long kgsl_get_clkrate(struct clk *clk) |
| 78 | { |
| 79 | return (clk != NULL) ? clk_get_rate(clk) : 0; |
| 80 | } |
| 81 | |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 82 | void kgsl_pwrctrl_set_state(struct kgsl_device *device, unsigned int state); |
| 83 | void kgsl_pwrctrl_request_state(struct kgsl_device *device, unsigned int state); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 84 | #endif /* __KGSL_PWRCTRL_H */ |