blob: 17dab76a3cc36b373ba1a5933f94454e377a4cea [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* 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#ifndef __KGSL_PWRCTRL_H
14#define __KGSL_PWRCTRL_H
15
16/*****************************************************************************
17** power flags
18*****************************************************************************/
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019#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 Sylvester02e46292011-09-21 14:59:17 -060024#define KGSL_PWRLEVEL_LOW_OFFSET 2
25
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#define KGSL_MAX_CLKS 5
27
28struct platform_device;
29
Suman Tatiraju7fe62a32011-07-14 16:40:37 -070030struct kgsl_busy {
31 struct timeval start;
32 struct timeval stop;
33 int on_time;
34 int time;
35 int on_time_old;
36 int time_old;
37 unsigned int no_nap_cnt;
38};
39
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070040struct kgsl_pwrctrl {
41 int interrupt_num;
42 int have_irq;
43 struct clk *ebi1_clk;
44 struct clk *grp_clks[KGSL_MAX_CLKS];
45 unsigned long power_flags;
46 struct kgsl_pwrlevel pwrlevels[KGSL_MAX_PWRLEVELS];
47 unsigned int active_pwrlevel;
48 int thermal_pwrlevel;
49 unsigned int num_pwrlevels;
50 unsigned int interval_timeout;
51 struct regulator *gpu_reg;
52 uint32_t pcl;
53 unsigned int nap_allowed;
54 const char *regulator_name;
55 const char *irq_name;
56 const char *src_clk_name;
57 s64 time;
Suman Tatiraju7fe62a32011-07-14 16:40:37 -070058 struct kgsl_busy busy;
Suman Tatiraju24569022011-10-27 11:11:12 -070059 unsigned int restore_slumber;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060};
61
62void kgsl_pwrctrl_clk(struct kgsl_device *device, int state);
63void kgsl_pwrctrl_axi(struct kgsl_device *device, int state);
64void kgsl_pwrctrl_pwrrail(struct kgsl_device *device, int state);
65void kgsl_pwrctrl_irq(struct kgsl_device *device, int state);
66int kgsl_pwrctrl_init(struct kgsl_device *device);
67void kgsl_pwrctrl_close(struct kgsl_device *device);
68void kgsl_timer(unsigned long data);
69void kgsl_idle_check(struct work_struct *work);
70void kgsl_pre_hwaccess(struct kgsl_device *device);
71void kgsl_check_suspended(struct kgsl_device *device);
72int kgsl_pwrctrl_sleep(struct kgsl_device *device);
73void kgsl_pwrctrl_wake(struct kgsl_device *device);
74void kgsl_pwrctrl_pwrlevel_change(struct kgsl_device *device,
75 unsigned int level);
76int kgsl_pwrctrl_init_sysfs(struct kgsl_device *device);
77void kgsl_pwrctrl_uninit_sysfs(struct kgsl_device *device);
78void kgsl_pwrctrl_enable(struct kgsl_device *device);
79void kgsl_pwrctrl_disable(struct kgsl_device *device);
80static inline unsigned long kgsl_get_clkrate(struct clk *clk)
81{
82 return (clk != NULL) ? clk_get_rate(clk) : 0;
83}
84
85#endif /* __KGSL_PWRCTRL_H */