blob: c3ade1a3d59bf58b7b8d57f68ebee41e2c867496 [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*****************************************************************************/
19#define KGSL_PWRFLAGS_POWER_ON 0
20#define KGSL_PWRFLAGS_CLK_ON 1
21#define KGSL_PWRFLAGS_AXI_ON 2
22#define KGSL_PWRFLAGS_IRQ_ON 3
23
24#define KGSL_PWRFLAGS_ON 1
25#define KGSL_PWRFLAGS_OFF 0
26
27#define KGSL_PWRLEVEL_TURBO 0
28#define KGSL_PWRLEVEL_NOMINAL 1
29#define KGSL_MAX_CLKS 5
30
31struct platform_device;
32
Suman Tatiraju7fe62a32011-07-14 16:40:37 -070033struct kgsl_busy {
34 struct timeval start;
35 struct timeval stop;
36 int on_time;
37 int time;
38 int on_time_old;
39 int time_old;
40 unsigned int no_nap_cnt;
41};
42
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070043struct kgsl_pwrctrl {
44 int interrupt_num;
45 int have_irq;
46 struct clk *ebi1_clk;
47 struct clk *grp_clks[KGSL_MAX_CLKS];
48 unsigned long power_flags;
49 struct kgsl_pwrlevel pwrlevels[KGSL_MAX_PWRLEVELS];
50 unsigned int active_pwrlevel;
51 int thermal_pwrlevel;
52 unsigned int num_pwrlevels;
53 unsigned int interval_timeout;
54 struct regulator *gpu_reg;
55 uint32_t pcl;
56 unsigned int nap_allowed;
57 const char *regulator_name;
58 const char *irq_name;
59 const char *src_clk_name;
60 s64 time;
Suman Tatiraju7fe62a32011-07-14 16:40:37 -070061 struct kgsl_busy busy;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062};
63
64void kgsl_pwrctrl_clk(struct kgsl_device *device, int state);
65void kgsl_pwrctrl_axi(struct kgsl_device *device, int state);
66void kgsl_pwrctrl_pwrrail(struct kgsl_device *device, int state);
67void kgsl_pwrctrl_irq(struct kgsl_device *device, int state);
68int kgsl_pwrctrl_init(struct kgsl_device *device);
69void kgsl_pwrctrl_close(struct kgsl_device *device);
70void kgsl_timer(unsigned long data);
71void kgsl_idle_check(struct work_struct *work);
72void kgsl_pre_hwaccess(struct kgsl_device *device);
73void kgsl_check_suspended(struct kgsl_device *device);
74int kgsl_pwrctrl_sleep(struct kgsl_device *device);
75void kgsl_pwrctrl_wake(struct kgsl_device *device);
76void kgsl_pwrctrl_pwrlevel_change(struct kgsl_device *device,
77 unsigned int level);
78int kgsl_pwrctrl_init_sysfs(struct kgsl_device *device);
79void kgsl_pwrctrl_uninit_sysfs(struct kgsl_device *device);
80void kgsl_pwrctrl_enable(struct kgsl_device *device);
81void kgsl_pwrctrl_disable(struct kgsl_device *device);
82static inline unsigned long kgsl_get_clkrate(struct clk *clk)
83{
84 return (clk != NULL) ? clk_get_rate(clk) : 0;
85}
86
87#endif /* __KGSL_PWRCTRL_H */