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 | /** |
| 34 | * struct acpuclk_platform_data - Platform data for acpuclk_init() |
| 35 | */ |
| 36 | struct acpuclk_platform_data { |
| 37 | uint32_t acpu_switch_time_us; |
| 38 | unsigned long max_speed_delta_khz; |
| 39 | uint32_t vdd_switch_time_us; |
| 40 | unsigned int max_axi_khz; |
| 41 | unsigned int max_vdd; |
| 42 | int (*acpu_set_vdd) (int mvolts); |
| 43 | int (*init)(struct acpuclk_platform_data *); |
| 44 | }; |
| 45 | |
| 46 | /** |
| 47 | * struct acpuclk_data - Function pointers and data for function implementations |
| 48 | */ |
| 49 | struct acpuclk_data { |
| 50 | unsigned long (*get_rate)(int cpu); |
| 51 | int (*set_rate)(int cpu, unsigned long rate, enum setrate_reason); |
| 52 | uint32_t switch_time_us; |
| 53 | unsigned long power_collapse_khz; |
| 54 | unsigned long wait_for_irq_khz; |
| 55 | }; |
| 56 | |
| 57 | /** |
| 58 | * acpulock_get_rate() - Get a CPU's clock rate in KHz |
| 59 | * @cpu: CPU to query the rate of |
| 60 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 61 | unsigned long acpuclk_get_rate(int cpu); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame^] | 62 | |
| 63 | /** |
| 64 | * acpuclk_set_rate() - Set a CPU's clock rate |
| 65 | * @cpu: CPU to set rate of |
| 66 | * @rate: Desired rate in KHz |
| 67 | * @setrate_reason: Reason for the rate switch |
| 68 | * |
| 69 | * Returns 0 for success. |
| 70 | */ |
| 71 | int acpuclk_set_rate(int cpu, unsigned long rate, enum setrate_reason); |
| 72 | |
| 73 | /** |
| 74 | * acpuclk_get_switch_time() - Query estimated time in us for a CPU rate switch |
| 75 | */ |
Daniel Walker | 43b39f9 | 2010-03-03 08:54:11 -0800 | [diff] [blame] | 76 | uint32_t acpuclk_get_switch_time(void); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame^] | 77 | |
| 78 | /** |
| 79 | * acpuclk_power_collapse() - Prepare current CPU clocks for power-collapse |
| 80 | * |
| 81 | * Returns the previous rate of the CPU in KHz. |
| 82 | */ |
Daniel Walker | 43b39f9 | 2010-03-03 08:54:11 -0800 | [diff] [blame] | 83 | unsigned long acpuclk_power_collapse(void); |
Daniel Walker | 43b39f9 | 2010-03-03 08:54:11 -0800 | [diff] [blame] | 84 | |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame^] | 85 | /** |
| 86 | * acpuclk_wait_for_irq() - Prepare current CPU clocks for SWFI |
| 87 | * |
| 88 | * Returns the previous rate of the CPU in KHz. |
| 89 | */ |
| 90 | unsigned long acpuclk_wait_for_irq(void); |
| 91 | |
| 92 | /** |
| 93 | * acpuclk_register() - Register acpuclk_data function implementations |
| 94 | * @data: acpuclock API implementations and data |
| 95 | */ |
| 96 | void acpuclk_register(struct acpuclk_data *data); |
| 97 | |
| 98 | /** |
| 99 | * acpuclk_init() - acpuclock driver initialization function |
| 100 | * |
| 101 | * Return 0 for success. |
| 102 | */ |
| 103 | int acpuclk_init(struct acpuclk_platform_data *); |
| 104 | |
| 105 | /* SoC-specific acpuclock initialization functions. */ |
| 106 | int acpuclk_7201_init(struct acpuclk_platform_data *); |
| 107 | int acpuclk_7x30_init(struct acpuclk_platform_data *); |
| 108 | int acpuclk_8x50_init(struct acpuclk_platform_data *); |
| 109 | int acpuclk_8x60_init(struct acpuclk_platform_data *); |
| 110 | int acpuclk_8960_init(struct acpuclk_platform_data *); |
| 111 | int acpuclk_9xxx_init(struct acpuclk_platform_data *); |
| 112 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 113 | #endif |