blob: 510a62ebfc5f922baff30ddee59f87cf3cd8320d [file] [log] [blame]
Matt Wagantall6d9ebee2011-08-26 12:15:24 -07001/*
2 * MSM architecture CPU clock driver header
Daniel Walker43b39f92010-03-03 08:54:11 -08003 *
4 * Copyright (C) 2007 Google, Inc.
Duy Truong790f06d2013-02-13 16:38:12 -08005 * Copyright (c) 2007-2012, The Linux Foundation. All rights reserved.
Daniel Walker43b39f92010-03-03 08:54:11 -08006 * Author: San Mehat <san@android.com>
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#ifndef __ARCH_ARM_MACH_MSM_ACPUCLOCK_H
20#define __ARCH_ARM_MACH_MSM_ACPUCLOCK_H
21
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070022/**
23 * enum setrate_reason - Reasons for use with acpuclk_set_rate()
24 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025enum setrate_reason {
26 SETRATE_CPUFREQ = 0,
27 SETRATE_SWFI,
28 SETRATE_PC,
29 SETRATE_HOTPLUG,
30 SETRATE_INIT,
31};
32
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070033/**
Matt Wagantallbf430eb2012-03-22 11:45:49 -070034 * struct acpuclk_pdata - Platform data for acpuclk
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070035 */
Matt Wagantallbf430eb2012-03-22 11:45:49 -070036struct acpuclk_pdata {
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070037 unsigned long max_speed_delta_khz;
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070038 unsigned int max_axi_khz;
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070039};
40
41/**
42 * struct acpuclk_data - Function pointers and data for function implementations
43 */
44struct acpuclk_data {
45 unsigned long (*get_rate)(int cpu);
46 int (*set_rate)(int cpu, unsigned long rate, enum setrate_reason);
47 uint32_t switch_time_us;
48 unsigned long power_collapse_khz;
49 unsigned long wait_for_irq_khz;
50};
51
52/**
53 * acpulock_get_rate() - Get a CPU's clock rate in KHz
54 * @cpu: CPU to query the rate of
55 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056unsigned long acpuclk_get_rate(int cpu);
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070057
58/**
59 * acpuclk_set_rate() - Set a CPU's clock rate
60 * @cpu: CPU to set rate of
61 * @rate: Desired rate in KHz
62 * @setrate_reason: Reason for the rate switch
63 *
64 * Returns 0 for success.
65 */
66int acpuclk_set_rate(int cpu, unsigned long rate, enum setrate_reason);
67
68/**
69 * acpuclk_get_switch_time() - Query estimated time in us for a CPU rate switch
70 */
Daniel Walker43b39f92010-03-03 08:54:11 -080071uint32_t acpuclk_get_switch_time(void);
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070072
73/**
74 * acpuclk_power_collapse() - Prepare current CPU clocks for power-collapse
75 *
76 * Returns the previous rate of the CPU in KHz.
77 */
Daniel Walker43b39f92010-03-03 08:54:11 -080078unsigned long acpuclk_power_collapse(void);
Daniel Walker43b39f92010-03-03 08:54:11 -080079
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070080/**
81 * acpuclk_wait_for_irq() - Prepare current CPU clocks for SWFI
82 *
83 * Returns the previous rate of the CPU in KHz.
84 */
85unsigned long acpuclk_wait_for_irq(void);
86
87/**
88 * acpuclk_register() - Register acpuclk_data function implementations
89 * @data: acpuclock API implementations and data
90 */
91void acpuclk_register(struct acpuclk_data *data);
92
Kaushal Kumar86473f02012-06-28 19:35:58 +053093#endif /*__ARCH_ARM_MACH_MSM_ACPUCLOCK_H*/