1f245451e98cd5b8ae88debe5910cd8fd6d54bc0
[cascardo/linux.git] / arch / arm / mach-exynos / include / mach / busfreq_exynos5.h
1 /* linux/arch/arm/mach-exynos/include/mach/busfreq_exynos5.h
2  *
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *              http://www.samsung.com
5  *
6  * EXYNOS5 - BUSFreq support
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11 */
12
13 #ifndef __ASM_ARCH_BUSFREQ_H
14 #define __ASM_ARCH_BUSFREQ_H __FILE__
15
16 #include <linux/notifier.h>
17
18 #include <mach/ppmu.h>
19
20 #define MAX_LOAD                100
21 #define LOAD_HISTORY_SIZE       5
22 #define DIVIDING_FACTOR         10000
23
24 #define TIMINGROW_OFFSET        0x34
25
26 extern unsigned int exynos_result_of_asv;
27 extern unsigned int exynos_result_mif_asv;
28 extern bool exynos_lot_id;
29 extern bool exynos_lot_is_nzvpu;
30 extern bool int_vol_lock;
31 extern bool g3d_vol_lock;
32
33 enum busfreq_level_idx {
34         LV_0,
35         LV_1,
36         LV_2,
37         LV_3,
38         LV_4,
39         LV_5,
40         LV_6,
41         LV_INT_END = LV_4,
42         LV_MIF_END = LV_6,
43 };
44
45 struct opp;
46 struct device;
47 struct busfreq_table;
48
49 struct busfreq_data {
50         bool use;
51         struct device *dev[PPMU_TYPE_END];
52         struct delayed_work worker;
53         unsigned long curr_freq[PPMU_TYPE_END];
54         unsigned long max_freq[PPMU_TYPE_END];
55         unsigned long min_freq[PPMU_TYPE_END];
56         struct regulator *vdd_reg[PPMU_TYPE_END];
57         unsigned int sampling_rate;
58         struct kobject *busfreq_kobject;
59         struct busfreq_table *table[PPMU_TYPE_END];
60         unsigned long long time_in_state[PPMU_TYPE_END][LV_INT_END];
61         unsigned long long last_time[PPMU_TYPE_END];
62         unsigned int load_history[PPMU_END][LOAD_HISTORY_SIZE];
63         int index;
64
65         struct notifier_block exynos_buspm_notifier;
66         struct notifier_block exynos_reboot_notifier;
67         struct notifier_block exynos_request_notifier;
68         struct attribute_group busfreq_attr_group;
69         int (*init)     (struct device *dev, struct busfreq_data *data);
70         void (*monitor) (struct busfreq_data *data, struct opp **mif_opp,
71                         struct opp **int_opp);
72         void (*target)  (struct busfreq_data *data,
73                         enum ppmu_type type, int index);
74         unsigned int (*get_int_volt) (unsigned long freq);
75         int (*get_table_index) (unsigned long freq, enum ppmu_type type);
76         void (*busfreq_prepare) (int index);
77         void (*busfreq_post) (int index);
78         void (*busfreq_suspend) (void);
79         void (*busfreq_resume) (void);
80
81         /* Dividers calculated at boot/probe-time */
82         unsigned int lex_divtable[LV_INT_END];
83         unsigned int r0x_divtable[LV_INT_END];
84         unsigned int r1x_divtable[LV_INT_END];
85         unsigned int cdrex_divtable[LV_MIF_END];
86         unsigned int cdrex2_divtable[LV_MIF_END];
87 };
88
89 struct busfreq_table {
90         unsigned int idx;
91         unsigned int mem_clk;
92         unsigned int volt;
93         unsigned int clk_topdiv;
94         unsigned int clk_dmc0div;
95         unsigned int clk_dmc1div;
96 };
97
98 void exynos_request_apply(unsigned long freq);
99 unsigned long step_down(struct busfreq_data *data,
100                                 enum ppmu_type type, int step);
101 int exynos5250_init(struct device *dev, struct busfreq_data *data);
102 void exynos5250_prepare(int index);
103 void exynos5250_post(int index);
104
105 #endif /* __ASM_ARCH_BUSFREQ_H */