blob: 591582f32d4d57435e55206d167cdd489f8833c4 [file] [log] [blame]
Nicholas Flintham1e3d3112013-04-10 10:48:38 +01001/* Copyright (c) 2010-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#ifndef __KGSL_PWRCTRL_H
14#define __KGSL_PWRCTRL_H
15
16#define KGSL_PWRFLAGS_ON 1
17#define KGSL_PWRFLAGS_OFF 0
18
19#define KGSL_PWRLEVEL_TURBO 0
20#define KGSL_PWRLEVEL_NOMINAL 1
21#define KGSL_PWRLEVEL_LAST_OFFSET 2
22
23#define KGSL_MAX_CLKS 5
24
25struct platform_device;
26
27struct kgsl_busy {
28 struct timeval start;
29 struct timeval stop;
30 int on_time;
31 int time;
32 int on_time_old;
33 int time_old;
34 unsigned int no_nap_cnt;
35};
36
37struct kgsl_pwrctrl {
38 int interrupt_num;
39 struct clk *ebi1_clk;
40 struct clk *grp_clks[KGSL_MAX_CLKS];
41 unsigned long power_flags;
42 struct kgsl_pwrlevel pwrlevels[KGSL_MAX_PWRLEVELS];
43 unsigned int active_pwrlevel;
44 int thermal_pwrlevel;
45 unsigned int default_pwrlevel;
46 unsigned int num_pwrlevels;
47 unsigned int interval_timeout;
48 bool strtstp_sleepwake;
49 struct regulator *gpu_reg;
50 struct regulator *gpu_dig;
51 uint32_t pcl;
52 unsigned int nap_allowed;
53 unsigned int idle_needed;
54 const char *irq_name;
55 s64 time;
56 struct kgsl_busy busy;
57 unsigned int restore_slumber;
58};
59
60void kgsl_pwrctrl_irq(struct kgsl_device *device, int state);
61int kgsl_pwrctrl_init(struct kgsl_device *device);
62void kgsl_pwrctrl_close(struct kgsl_device *device);
63void kgsl_timer(unsigned long data);
64void kgsl_idle_check(struct work_struct *work);
65void kgsl_pre_hwaccess(struct kgsl_device *device);
66void kgsl_check_suspended(struct kgsl_device *device);
67int kgsl_pwrctrl_sleep(struct kgsl_device *device);
68void kgsl_pwrctrl_wake(struct kgsl_device *device);
69void kgsl_pwrctrl_pwrlevel_change(struct kgsl_device *device,
70 unsigned int level);
71int kgsl_pwrctrl_init_sysfs(struct kgsl_device *device);
72void kgsl_pwrctrl_uninit_sysfs(struct kgsl_device *device);
73void kgsl_pwrctrl_enable(struct kgsl_device *device);
74void kgsl_pwrctrl_disable(struct kgsl_device *device);
75static inline unsigned long kgsl_get_clkrate(struct clk *clk)
76{
77 return (clk != NULL) ? clk_get_rate(clk) : 0;
78}
79
80void kgsl_pwrctrl_set_state(struct kgsl_device *device, unsigned int state);
81void kgsl_pwrctrl_request_state(struct kgsl_device *device, unsigned int state);
82#endif