summaryrefslogtreecommitdiff
path: root/include/asm-arm/arch-mxc/dvfs.h
blob: 7f140cb3c7a3cca17c3517fe70caab8f89f8512f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
 * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
 */

/*
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */

/*!
 * @file arch-mxc/dvfs.h
 *
 * @brief MXC dvfs header file.
 *
 * @ingroup PM_MX31 PM_MXC91321 PM_MXC91311
 */
#ifndef __ASM_ARCH_MXC_DVFS_H__
#define __ASM_ARCH_MXC_DVFS_H__

#include "dvfs_dptc_struct.h"

/*!
 * If value equal to FSVAI bits indicates working point decrease
 */
#define DVFS_DECREASE		(unsigned long)0x2

/*!
 * If value equal to FSVAI bits indicates working point increase
 */
#define DVFS_INCREASE		(unsigned long)0x1

/*!
 * If value equal to FSVAI bits indicates working point increase to maximum
 */
#define DVFS_EMERG		(unsigned long)0x3

/*!
 * This function is called for module initialization.
 * It initializes the driver data structures and sets up the DVFS hardware.
 *
 * @param    params    pointer to the DVFS & DPTC driver parameters structure.
 *
 * @return   0 to indicate success else returns a negative number.
 *
 */
int __init init_dvfs_controller(dvfs_dptc_params_s * params);

/*!
 * This function enables the DVFS module. this function updates the DVFS
 * thresholds, updates the PMIC, unmasks the DVFS interrupt and enables
 * the DVFS module
 *
 * @param    params    pointer to the DVFS & DPTC driver parameters structure.
 *
 * @return      0 if DVFS module was enabled else returns -EINVAL.
 */
int start_dvfs(dvfs_dptc_params_s * params);

/*!
 * This function disables the DVFS module.
 *
 * @param    params    pointer to the DVFS & DPTC driver parameters structure.
 *
 * @return      0 if DVFS module was enabled else returns -EINVAL.
 */
int stop_dvfs(dvfs_dptc_params_s * params);

/*!
 * This function turns on/off SW general purpose bits.
 * The argument's 4 LSBs represent the status of the bits.
 *
 * @param   arg  status of the SW general purpose bits
 *
 * @return 0 on success
 */
int set_sw_gp(unsigned char arg);

/*!
 * This function sets DVFS to monitor WFI signal
 *
 * @param   arg  0 - turn WFI off, 1 - turn WFI on
 * @return  0 on success, error code on fail
 */
int set_wfi(unsigned char arg);

#ifndef CONFIG_MXC_DVFS_SDMA
/*!
 * This function is the DVFS Interrupt handler.
 * @param    params    pointer to the DVFS & DPTC driver parameters structure.
 */
void dvfs_irq(dvfs_dptc_params_s * params);
#endif

/*!
 * This function changes the frequency if DVFS HW is disabled.
 * It gets id of the required state supported by DVFS table and
 * updates CCM.
 *
 * @param    dvfs_state_id  id of the DVFS state.
 * @return   0 on success, error code on fail
 */
int dvfs_set_state(int dvfs_state_id);

/*
 * Update tables of frequencies for DPM usage
 *
 * @param    dvfs_dptc_tables_ptr    pointer to the DVFS &
 *                                   DPTC translation table.
 */
void dvfs_update_freqs_table(dvfs_dptc_tables_s * dvfs_dptc_tables_ptr);

/*!
 * Read the DVSUP bits from the CCM
 */
unsigned long dvfs_get_dvsup(void);

/*!
 * This contains the array with values of supported frequencies in Hz.
 * The structure is used by DPM.
 */
extern dvfs_states_table *dvfs_states_tbl;

/*!
 * This define DVFS log buffer sample size (in bits)
 */
#define DVFS_LB_SAMPLE_SIZE 4

/*!
 * This define DVFS log buffer samples
 */
#define DVFS_LB_SIZE 1600

/*!
 * This define DVFS SDMA buffer descriptors number
 */
#define DVFS_LB_SDMA_BD 10

/*!
 * This defines default DVFS down threshold
 */
#define DVFS_DNTHR  18

/*!
 * This defines default DVFS up threshold
 */
#define DVFS_UPTHR  30

/*!
 * This defines default DVFS panic threshold
 */
#define DVFS_PNCTHR 63

#endif