Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * MSM architecture CPU clock driver header |
Daniel Walker | 43b39f9 | 2010-03-03 08:54:11 -0800 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2007 Google, Inc. |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 5 | * Copyright (c) 2007-2011, Code Aurora Forum. All rights reserved. |
Daniel Walker | 43b39f9 | 2010-03-03 08:54:11 -0800 | [diff] [blame] | 6 | * 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 Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 22 | /** |
| 23 | * enum setrate_reason - Reasons for use with acpuclk_set_rate() |
| 24 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | enum setrate_reason { |
| 26 | SETRATE_CPUFREQ = 0, |
| 27 | SETRATE_SWFI, |
| 28 | SETRATE_PC, |
| 29 | SETRATE_HOTPLUG, |
| 30 | SETRATE_INIT, |
| 31 | }; |
| 32 | |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 33 | /** |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 34 | * struct acpuclk_soc_data - SoC data for acpuclk_init() |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 35 | */ |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 36 | struct acpuclk_soc_data { |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 37 | unsigned long max_speed_delta_khz; |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 38 | unsigned int max_axi_khz; |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 39 | int (*init)(struct acpuclk_soc_data *); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | /** |
| 43 | * struct acpuclk_data - Function pointers and data for function implementations |
| 44 | */ |
| 45 | struct acpuclk_data { |
| 46 | unsigned long (*get_rate)(int cpu); |
| 47 | int (*set_rate)(int cpu, unsigned long rate, enum setrate_reason); |
| 48 | uint32_t switch_time_us; |
| 49 | unsigned long power_collapse_khz; |
| 50 | unsigned long wait_for_irq_khz; |
| 51 | }; |
| 52 | |
| 53 | /** |
| 54 | * acpulock_get_rate() - Get a CPU's clock rate in KHz |
| 55 | * @cpu: CPU to query the rate of |
| 56 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 57 | unsigned long acpuclk_get_rate(int cpu); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * acpuclk_set_rate() - Set a CPU's clock rate |
| 61 | * @cpu: CPU to set rate of |
| 62 | * @rate: Desired rate in KHz |
| 63 | * @setrate_reason: Reason for the rate switch |
| 64 | * |
| 65 | * Returns 0 for success. |
| 66 | */ |
| 67 | int acpuclk_set_rate(int cpu, unsigned long rate, enum setrate_reason); |
| 68 | |
| 69 | /** |
| 70 | * acpuclk_get_switch_time() - Query estimated time in us for a CPU rate switch |
| 71 | */ |
Daniel Walker | 43b39f9 | 2010-03-03 08:54:11 -0800 | [diff] [blame] | 72 | uint32_t acpuclk_get_switch_time(void); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * acpuclk_power_collapse() - Prepare current CPU clocks for power-collapse |
| 76 | * |
| 77 | * Returns the previous rate of the CPU in KHz. |
| 78 | */ |
Daniel Walker | 43b39f9 | 2010-03-03 08:54:11 -0800 | [diff] [blame] | 79 | unsigned long acpuclk_power_collapse(void); |
Daniel Walker | 43b39f9 | 2010-03-03 08:54:11 -0800 | [diff] [blame] | 80 | |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 81 | /** |
| 82 | * acpuclk_wait_for_irq() - Prepare current CPU clocks for SWFI |
| 83 | * |
| 84 | * Returns the previous rate of the CPU in KHz. |
| 85 | */ |
| 86 | unsigned long acpuclk_wait_for_irq(void); |
| 87 | |
| 88 | /** |
| 89 | * acpuclk_register() - Register acpuclk_data function implementations |
| 90 | * @data: acpuclock API implementations and data |
| 91 | */ |
| 92 | void acpuclk_register(struct acpuclk_data *data); |
| 93 | |
| 94 | /** |
| 95 | * acpuclk_init() - acpuclock driver initialization function |
| 96 | * |
| 97 | * Return 0 for success. |
| 98 | */ |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 99 | int acpuclk_init(struct acpuclk_soc_data *); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 100 | |
| 101 | /* SoC-specific acpuclock initialization functions. */ |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 102 | extern struct acpuclk_soc_data acpuclk_7x27_soc_data; |
| 103 | extern struct acpuclk_soc_data acpuclk_7x27a_soc_data; |
| 104 | extern struct acpuclk_soc_data acpuclk_7x27aa_soc_data; |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 105 | extern struct acpuclk_soc_data acpuclk_7x30_soc_data; |
| 106 | extern struct acpuclk_soc_data acpuclk_8x50_soc_data; |
| 107 | extern struct acpuclk_soc_data acpuclk_8x60_soc_data; |
| 108 | extern struct acpuclk_soc_data acpuclk_8960_soc_data; |
| 109 | extern struct acpuclk_soc_data acpuclk_9xxx_soc_data; |
Matt Wagantall | 44f672e | 2011-09-07 20:31:16 -0700 | [diff] [blame] | 110 | extern struct acpuclk_soc_data acpuclk_9615_soc_data; |
Tianyi Gou | 7c6b81f | 2011-12-07 23:09:08 -0800 | [diff] [blame] | 111 | extern struct acpuclk_soc_data acpuclk_8930_soc_data; |
Matt Wagantall | 44f672e | 2011-09-07 20:31:16 -0700 | [diff] [blame] | 112 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 113 | #endif |