diff options
253 files changed, 6938 insertions, 4145 deletions
diff --git a/Documentation/ABI/testing/sysfs-devices-lpss_ltr b/Documentation/ABI/testing/sysfs-devices-lpss_ltr new file mode 100644 index 000000000000..ea9298d9bbaf --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-lpss_ltr | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | What: /sys/devices/.../lpss_ltr/ | ||
| 2 | Date: March 2013 | ||
| 3 | Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 4 | Description: | ||
| 5 | The /sys/devices/.../lpss_ltr/ directory is only present for | ||
| 6 | devices included into the Intel Lynxpoint Low Power Subsystem | ||
| 7 | (LPSS). If present, it contains attributes containing the LTR | ||
| 8 | mode and the values of LTR registers of the device. | ||
| 9 | |||
| 10 | What: /sys/devices/.../lpss_ltr/ltr_mode | ||
| 11 | Date: March 2013 | ||
| 12 | Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 13 | Description: | ||
| 14 | The /sys/devices/.../lpss_ltr/ltr_mode attribute contains an | ||
| 15 | integer number (0 or 1) indicating whether or not the devices' | ||
| 16 | LTR functionality is working in the software mode (1). | ||
| 17 | |||
| 18 | This attribute is read-only. If the device's runtime PM status | ||
| 19 | is not "active", attempts to read from this attribute cause | ||
| 20 | -EAGAIN to be returned. | ||
| 21 | |||
| 22 | What: /sys/devices/.../lpss_ltr/auto_ltr | ||
| 23 | Date: March 2013 | ||
| 24 | Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 25 | Description: | ||
| 26 | The /sys/devices/.../lpss_ltr/auto_ltr attribute contains the | ||
| 27 | current value of the device's AUTO_LTR register (raw) | ||
| 28 | represented as an 8-digit hexadecimal number. | ||
| 29 | |||
| 30 | This attribute is read-only. If the device's runtime PM status | ||
| 31 | is not "active", attempts to read from this attribute cause | ||
| 32 | -EAGAIN to be returned. | ||
| 33 | |||
| 34 | What: /sys/devices/.../lpss_ltr/sw_ltr | ||
| 35 | Date: March 2013 | ||
| 36 | Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 37 | Description: | ||
| 38 | The /sys/devices/.../lpss_ltr/auto_ltr attribute contains the | ||
| 39 | current value of the device's SW_LTR register (raw) represented | ||
| 40 | as an 8-digit hexadecimal number. | ||
| 41 | |||
| 42 | This attribute is read-only. If the device's runtime PM status | ||
| 43 | is not "active", attempts to read from this attribute cause | ||
| 44 | -EAGAIN to be returned. | ||
diff --git a/Documentation/ABI/testing/sysfs-devices-power_resources_wakeup b/Documentation/ABI/testing/sysfs-devices-power_resources_wakeup new file mode 100644 index 000000000000..e0588feeb6e1 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-power_resources_wakeup | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | What: /sys/devices/.../power_resources_wakeup/ | ||
| 2 | Date: April 2013 | ||
| 3 | Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 4 | Description: | ||
| 5 | The /sys/devices/.../power_resources_wakeup/ directory is only | ||
| 6 | present for device objects representing ACPI device nodes that | ||
| 7 | require ACPI power resources for wakeup signaling. | ||
| 8 | |||
| 9 | If present, it contains symbolic links to device directories | ||
| 10 | representing ACPI power resources that need to be turned on for | ||
| 11 | the given device node to be able to signal wakeup. The names of | ||
| 12 | the links are the same as the names of the directories they | ||
| 13 | point to. | ||
diff --git a/Documentation/ABI/testing/sysfs-firmware-acpi b/Documentation/ABI/testing/sysfs-firmware-acpi index dd930c8db41f..ce9bee98b43b 100644 --- a/Documentation/ABI/testing/sysfs-firmware-acpi +++ b/Documentation/ABI/testing/sysfs-firmware-acpi | |||
| @@ -18,6 +18,32 @@ Description: | |||
| 18 | yoffset: The number of pixels between the top of the screen | 18 | yoffset: The number of pixels between the top of the screen |
| 19 | and the top edge of the image. | 19 | and the top edge of the image. |
| 20 | 20 | ||
| 21 | What: /sys/firmware/acpi/hotplug/ | ||
| 22 | Date: February 2013 | ||
| 23 | Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 24 | Description: | ||
| 25 | There are separate hotplug profiles for different classes of | ||
| 26 | devices supported by ACPI, such as containers, memory modules, | ||
| 27 | processors, PCI root bridges etc. A hotplug profile for a given | ||
| 28 | class of devices is a collection of settings defining the way | ||
| 29 | that class of devices will be handled by the ACPI core hotplug | ||
| 30 | code. Those profiles are represented in sysfs as subdirectories | ||
| 31 | of /sys/firmware/acpi/hotplug/. | ||
| 32 | |||
| 33 | The following setting is available to user space for each | ||
| 34 | hotplug profile: | ||
| 35 | |||
| 36 | enabled: If set, the ACPI core will handle notifications of | ||
| 37 | hotplug events associated with the given class of | ||
| 38 | devices and will allow those devices to be ejected with | ||
| 39 | the help of the _EJ0 control method. Unsetting it | ||
| 40 | effectively disables hotplug for the correspoinding | ||
| 41 | class of devices. | ||
| 42 | |||
| 43 | The value of the above attribute is an integer number: 1 (set) | ||
| 44 | or 0 (unset). Attempts to write any other values to it will | ||
| 45 | cause -EINVAL to be returned. | ||
| 46 | |||
| 21 | What: /sys/firmware/acpi/interrupts/ | 47 | What: /sys/firmware/acpi/interrupts/ |
| 22 | Date: February 2008 | 48 | Date: February 2008 |
| 23 | Contact: Len Brown <lenb@kernel.org> | 49 | Contact: Len Brown <lenb@kernel.org> |
diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt index 72f70b16d299..a3585eac83b6 100644 --- a/Documentation/cpu-freq/cpu-drivers.txt +++ b/Documentation/cpu-freq/cpu-drivers.txt | |||
| @@ -108,8 +108,9 @@ policy->governor must contain the "default policy" for | |||
| 108 | cpufreq_driver.target is called with | 108 | cpufreq_driver.target is called with |
| 109 | these values. | 109 | these values. |
| 110 | 110 | ||
| 111 | For setting some of these values, the frequency table helpers might be | 111 | For setting some of these values (cpuinfo.min[max]_freq, policy->min[max]), the |
| 112 | helpful. See the section 2 for more information on them. | 112 | frequency table helpers might be helpful. See the section 2 for more information |
| 113 | on them. | ||
| 113 | 114 | ||
| 114 | SMP systems normally have same clock source for a group of cpus. For these the | 115 | SMP systems normally have same clock source for a group of cpus. For these the |
| 115 | .init() would be called only once for the first online cpu. Here the .init() | 116 | .init() would be called only once for the first online cpu. Here the .init() |
| @@ -184,10 +185,10 @@ the reference implementation in drivers/cpufreq/longrun.c | |||
| 184 | As most cpufreq processors only allow for being set to a few specific | 185 | As most cpufreq processors only allow for being set to a few specific |
| 185 | frequencies, a "frequency table" with some functions might assist in | 186 | frequencies, a "frequency table" with some functions might assist in |
| 186 | some work of the processor driver. Such a "frequency table" consists | 187 | some work of the processor driver. Such a "frequency table" consists |
| 187 | of an array of struct cpufreq_freq_table entries, with any value in | 188 | of an array of struct cpufreq_frequency_table entries, with any value in |
| 188 | "index" you want to use, and the corresponding frequency in | 189 | "index" you want to use, and the corresponding frequency in |
| 189 | "frequency". At the end of the table, you need to add a | 190 | "frequency". At the end of the table, you need to add a |
| 190 | cpufreq_freq_table entry with frequency set to CPUFREQ_TABLE_END. And | 191 | cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END. And |
| 191 | if you want to skip one entry in the table, set the frequency to | 192 | if you want to skip one entry in the table, set the frequency to |
| 192 | CPUFREQ_ENTRY_INVALID. The entries don't need to be in ascending | 193 | CPUFREQ_ENTRY_INVALID. The entries don't need to be in ascending |
| 193 | order. | 194 | order. |
diff --git a/Documentation/cpu-freq/governors.txt b/Documentation/cpu-freq/governors.txt index c7a2eb8450c2..66f9cc310686 100644 --- a/Documentation/cpu-freq/governors.txt +++ b/Documentation/cpu-freq/governors.txt | |||
| @@ -167,6 +167,27 @@ of load evaluation and helping the CPU stay at its top speed when truly | |||
| 167 | busy, rather than shifting back and forth in speed. This tunable has no | 167 | busy, rather than shifting back and forth in speed. This tunable has no |
| 168 | effect on behavior at lower speeds/lower CPU loads. | 168 | effect on behavior at lower speeds/lower CPU loads. |
| 169 | 169 | ||
| 170 | powersave_bias: this parameter takes a value between 0 to 1000. It | ||
| 171 | defines the percentage (times 10) value of the target frequency that | ||
| 172 | will be shaved off of the target. For example, when set to 100 -- 10%, | ||
| 173 | when ondemand governor would have targeted 1000 MHz, it will target | ||
| 174 | 1000 MHz - (10% of 1000 MHz) = 900 MHz instead. This is set to 0 | ||
| 175 | (disabled) by default. | ||
| 176 | When AMD frequency sensitivity powersave bias driver -- | ||
| 177 | drivers/cpufreq/amd_freq_sensitivity.c is loaded, this parameter | ||
| 178 | defines the workload frequency sensitivity threshold in which a lower | ||
| 179 | frequency is chosen instead of ondemand governor's original target. | ||
| 180 | The frequency sensitivity is a hardware reported (on AMD Family 16h | ||
| 181 | Processors and above) value between 0 to 100% that tells software how | ||
| 182 | the performance of the workload running on a CPU will change when | ||
| 183 | frequency changes. A workload with sensitivity of 0% (memory/IO-bound) | ||
| 184 | will not perform any better on higher core frequency, whereas a | ||
| 185 | workload with sensitivity of 100% (CPU-bound) will perform better | ||
| 186 | higher the frequency. When the driver is loaded, this is set to 400 | ||
| 187 | by default -- for CPUs running workloads with sensitivity value below | ||
| 188 | 40%, a lower frequency is chosen. Unloading the driver or writing 0 | ||
| 189 | will disable this feature. | ||
| 190 | |||
| 170 | 191 | ||
| 171 | 2.5 Conservative | 192 | 2.5 Conservative |
| 172 | ---------------- | 193 | ---------------- |
| @@ -191,6 +212,12 @@ governor but for the opposite direction. For example when set to its | |||
| 191 | default value of '20' it means that if the CPU usage needs to be below | 212 | default value of '20' it means that if the CPU usage needs to be below |
| 192 | 20% between samples to have the frequency decreased. | 213 | 20% between samples to have the frequency decreased. |
| 193 | 214 | ||
| 215 | sampling_down_factor: similar functionality as in "ondemand" governor. | ||
| 216 | But in "conservative", it controls the rate at which the kernel makes | ||
| 217 | a decision on when to decrease the frequency while running in any | ||
| 218 | speed. Load for frequency increase is still evaluated every | ||
| 219 | sampling rate. | ||
| 220 | |||
| 194 | 3. The Governor Interface in the CPUfreq Core | 221 | 3. The Governor Interface in the CPUfreq Core |
| 195 | ============================================= | 222 | ============================================= |
| 196 | 223 | ||
diff --git a/Documentation/cpuidle/driver.txt b/Documentation/cpuidle/driver.txt index 7a9e09ece931..1b0d81d92583 100644 --- a/Documentation/cpuidle/driver.txt +++ b/Documentation/cpuidle/driver.txt | |||
| @@ -15,11 +15,17 @@ has mechanisms in place to support actual entry-exit into CPU idle states. | |||
| 15 | cpuidle driver initializes the cpuidle_device structure for each CPU device | 15 | cpuidle driver initializes the cpuidle_device structure for each CPU device |
| 16 | and registers with cpuidle using cpuidle_register_device. | 16 | and registers with cpuidle using cpuidle_register_device. |
| 17 | 17 | ||
| 18 | If all the idle states are the same, the wrapper function cpuidle_register | ||
| 19 | could be used instead. | ||
| 20 | |||
| 18 | It can also support the dynamic changes (like battery <-> AC), by using | 21 | It can also support the dynamic changes (like battery <-> AC), by using |
| 19 | cpuidle_pause_and_lock, cpuidle_disable_device and cpuidle_enable_device, | 22 | cpuidle_pause_and_lock, cpuidle_disable_device and cpuidle_enable_device, |
| 20 | cpuidle_resume_and_unlock. | 23 | cpuidle_resume_and_unlock. |
| 21 | 24 | ||
| 22 | Interfaces: | 25 | Interfaces: |
| 26 | extern int cpuidle_register(struct cpuidle_driver *drv, | ||
| 27 | const struct cpumask *const coupled_cpus); | ||
| 28 | extern int cpuidle_unregister(struct cpuidle_driver *drv); | ||
| 23 | extern int cpuidle_register_driver(struct cpuidle_driver *drv); | 29 | extern int cpuidle_register_driver(struct cpuidle_driver *drv); |
| 24 | extern void cpuidle_unregister_driver(struct cpuidle_driver *drv); | 30 | extern void cpuidle_unregister_driver(struct cpuidle_driver *drv); |
| 25 | extern int cpuidle_register_device(struct cpuidle_device *dev); | 31 | extern int cpuidle_register_device(struct cpuidle_device *dev); |
diff --git a/Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt b/Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt new file mode 100644 index 000000000000..0715695e94a9 --- /dev/null +++ b/Documentation/devicetree/bindings/cpufreq/arm_big_little_dt.txt | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | Generic ARM big LITTLE cpufreq driver's DT glue | ||
| 2 | ----------------------------------------------- | ||
| 3 | |||
| 4 | This is DT specific glue layer for generic cpufreq driver for big LITTLE | ||
| 5 | systems. | ||
| 6 | |||
| 7 | Both required and optional properties listed below must be defined | ||
| 8 | under node /cpus/cpu@x. Where x is the first cpu inside a cluster. | ||
| 9 | |||
| 10 | FIXME: Cpus should boot in the order specified in DT and all cpus for a cluster | ||
| 11 | must be present contiguously. Generic DT driver will check only node 'x' for | ||
| 12 | cpu:x. | ||
| 13 | |||
| 14 | Required properties: | ||
| 15 | - operating-points: Refer to Documentation/devicetree/bindings/power/opp.txt | ||
| 16 | for details | ||
| 17 | |||
| 18 | Optional properties: | ||
| 19 | - clock-latency: Specify the possible maximum transition latency for clock, | ||
| 20 | in unit of nanoseconds. | ||
| 21 | |||
| 22 | Examples: | ||
| 23 | |||
| 24 | cpus { | ||
| 25 | #address-cells = <1>; | ||
| 26 | #size-cells = <0>; | ||
| 27 | |||
| 28 | cpu@0 { | ||
| 29 | compatible = "arm,cortex-a15"; | ||
| 30 | reg = <0>; | ||
| 31 | next-level-cache = <&L2>; | ||
| 32 | operating-points = < | ||
| 33 | /* kHz uV */ | ||
| 34 | 792000 1100000 | ||
| 35 | 396000 950000 | ||
| 36 | 198000 850000 | ||
| 37 | >; | ||
| 38 | clock-latency = <61036>; /* two CLK32 periods */ | ||
| 39 | }; | ||
| 40 | |||
| 41 | cpu@1 { | ||
| 42 | compatible = "arm,cortex-a15"; | ||
| 43 | reg = <1>; | ||
| 44 | next-level-cache = <&L2>; | ||
| 45 | }; | ||
| 46 | |||
| 47 | cpu@100 { | ||
| 48 | compatible = "arm,cortex-a7"; | ||
| 49 | reg = <100>; | ||
| 50 | next-level-cache = <&L2>; | ||
| 51 | operating-points = < | ||
| 52 | /* kHz uV */ | ||
| 53 | 792000 950000 | ||
| 54 | 396000 750000 | ||
| 55 | 198000 450000 | ||
| 56 | >; | ||
| 57 | clock-latency = <61036>; /* two CLK32 periods */ | ||
| 58 | }; | ||
| 59 | |||
| 60 | cpu@101 { | ||
| 61 | compatible = "arm,cortex-a7"; | ||
| 62 | reg = <101>; | ||
| 63 | next-level-cache = <&L2>; | ||
| 64 | }; | ||
| 65 | }; | ||
diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt index 4416ccc33472..051f764bedb8 100644 --- a/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt | |||
| @@ -32,7 +32,7 @@ cpus { | |||
| 32 | 396000 950000 | 32 | 396000 950000 |
| 33 | 198000 850000 | 33 | 198000 850000 |
| 34 | >; | 34 | >; |
| 35 | transition-latency = <61036>; /* two CLK32 periods */ | 35 | clock-latency = <61036>; /* two CLK32 periods */ |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | cpu@1 { | 38 | cpu@1 { |
diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt new file mode 100644 index 000000000000..caff1a57436f --- /dev/null +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | |||
| 2 | Exynos5440 cpufreq driver | ||
| 3 | ------------------- | ||
| 4 | |||
| 5 | Exynos5440 SoC cpufreq driver for CPU frequency scaling. | ||
| 6 | |||
| 7 | Required properties: | ||
| 8 | - interrupts: Interrupt to know the completion of cpu frequency change. | ||
| 9 | - operating-points: Table of frequencies and voltage CPU could be transitioned into, | ||
| 10 | in the decreasing order. Frequency should be in KHz units and voltage | ||
| 11 | should be in microvolts. | ||
| 12 | |||
| 13 | Optional properties: | ||
| 14 | - clock-latency: Clock monitor latency in microsecond. | ||
| 15 | |||
| 16 | All the required listed above must be defined under node cpufreq. | ||
| 17 | |||
| 18 | Example: | ||
| 19 | -------- | ||
| 20 | cpufreq@160000 { | ||
| 21 | compatible = "samsung,exynos5440-cpufreq"; | ||
| 22 | reg = <0x160000 0x1000>; | ||
| 23 | interrupts = <0 57 0>; | ||
| 24 | operating-points = < | ||
| 25 | 1000000 975000 | ||
| 26 | 800000 925000>; | ||
| 27 | clock-latency = <100000>; | ||
| 28 | }; | ||
diff --git a/MAINTAINERS b/MAINTAINERS index ea8f65fc6fa3..75f6282d342b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -2203,12 +2203,34 @@ F: drivers/net/ethernet/ti/cpmac.c | |||
| 2203 | 2203 | ||
| 2204 | CPU FREQUENCY DRIVERS | 2204 | CPU FREQUENCY DRIVERS |
| 2205 | M: Rafael J. Wysocki <rjw@sisk.pl> | 2205 | M: Rafael J. Wysocki <rjw@sisk.pl> |
| 2206 | M: Viresh Kumar <viresh.kumar@linaro.org> | ||
| 2206 | L: cpufreq@vger.kernel.org | 2207 | L: cpufreq@vger.kernel.org |
| 2207 | L: linux-pm@vger.kernel.org | 2208 | L: linux-pm@vger.kernel.org |
| 2208 | S: Maintained | 2209 | S: Maintained |
| 2210 | T: git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git | ||
| 2209 | F: drivers/cpufreq/ | 2211 | F: drivers/cpufreq/ |
| 2210 | F: include/linux/cpufreq.h | 2212 | F: include/linux/cpufreq.h |
| 2211 | 2213 | ||
| 2214 | CPU FREQUENCY DRIVERS - ARM BIG LITTLE | ||
| 2215 | M: Viresh Kumar <viresh.kumar@linaro.org> | ||
| 2216 | M: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com> | ||
| 2217 | L: cpufreq@vger.kernel.org | ||
| 2218 | L: linux-pm@vger.kernel.org | ||
| 2219 | W: http://www.arm.com/products/processors/technologies/biglittleprocessing.php | ||
| 2220 | S: Maintained | ||
| 2221 | F: drivers/cpufreq/arm_big_little.h | ||
| 2222 | F: drivers/cpufreq/arm_big_little.c | ||
| 2223 | F: drivers/cpufreq/arm_big_little_dt.c | ||
| 2224 | |||
| 2225 | CPUIDLE DRIVERS | ||
| 2226 | M: Rafael J. Wysocki <rjw@sisk.pl> | ||
| 2227 | M: Daniel Lezcano <daniel.lezcano@linaro.org> | ||
| 2228 | L: linux-pm@vger.kernel.org | ||
| 2229 | S: Maintained | ||
| 2230 | T: git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git | ||
| 2231 | F: drivers/cpuidle/* | ||
| 2232 | F: include/linux/cpuidle.h | ||
| 2233 | |||
| 2212 | CPUID/MSR DRIVER | 2234 | CPUID/MSR DRIVER |
| 2213 | M: "H. Peter Anvin" <hpa@zytor.com> | 2235 | M: "H. Peter Anvin" <hpa@zytor.com> |
| 2214 | S: Maintained | 2236 | S: Maintained |
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index a39e3214ea3d..006f9838dd43 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
| @@ -2163,7 +2163,6 @@ endmenu | |||
| 2163 | menu "CPU Power Management" | 2163 | menu "CPU Power Management" |
| 2164 | 2164 | ||
| 2165 | if ARCH_HAS_CPUFREQ | 2165 | if ARCH_HAS_CPUFREQ |
| 2166 | |||
| 2167 | source "drivers/cpufreq/Kconfig" | 2166 | source "drivers/cpufreq/Kconfig" |
| 2168 | 2167 | ||
| 2169 | config CPU_FREQ_IMX | 2168 | config CPU_FREQ_IMX |
| @@ -2173,30 +2172,6 @@ config CPU_FREQ_IMX | |||
| 2173 | help | 2172 | help |
| 2174 | This enables the CPUfreq driver for i.MX CPUs. | 2173 | This enables the CPUfreq driver for i.MX CPUs. |
| 2175 | 2174 | ||
| 2176 | config CPU_FREQ_SA1100 | ||
| 2177 | bool | ||
| 2178 | |||
| 2179 | config CPU_FREQ_SA1110 | ||
| 2180 | bool | ||
| 2181 | |||
| 2182 | config CPU_FREQ_INTEGRATOR | ||
| 2183 | tristate "CPUfreq driver for ARM Integrator CPUs" | ||
| 2184 | depends on ARCH_INTEGRATOR && CPU_FREQ | ||
| 2185 | default y | ||
| 2186 | help | ||
| 2187 | This enables the CPUfreq driver for ARM Integrator CPUs. | ||
| 2188 | |||
| 2189 | For details, take a look at <file:Documentation/cpu-freq>. | ||
| 2190 | |||
| 2191 | If in doubt, say Y. | ||
| 2192 | |||
| 2193 | config CPU_FREQ_PXA | ||
| 2194 | bool | ||
| 2195 | depends on CPU_FREQ && ARCH_PXA && PXA25x | ||
| 2196 | default y | ||
| 2197 | select CPU_FREQ_DEFAULT_GOV_USERSPACE | ||
| 2198 | select CPU_FREQ_TABLE | ||
| 2199 | |||
| 2200 | config CPU_FREQ_S3C | 2175 | config CPU_FREQ_S3C |
| 2201 | bool | 2176 | bool |
| 2202 | help | 2177 | help |
diff --git a/arch/arm/configs/kirkwood_defconfig b/arch/arm/configs/kirkwood_defconfig index 13482ea58b09..93f3794ba5cb 100644 --- a/arch/arm/configs/kirkwood_defconfig +++ b/arch/arm/configs/kirkwood_defconfig | |||
| @@ -56,7 +56,6 @@ CONFIG_AEABI=y | |||
| 56 | CONFIG_ZBOOT_ROM_TEXT=0x0 | 56 | CONFIG_ZBOOT_ROM_TEXT=0x0 |
| 57 | CONFIG_ZBOOT_ROM_BSS=0x0 | 57 | CONFIG_ZBOOT_ROM_BSS=0x0 |
| 58 | CONFIG_CPU_IDLE=y | 58 | CONFIG_CPU_IDLE=y |
| 59 | CONFIG_CPU_IDLE_KIRKWOOD=y | ||
| 60 | CONFIG_NET=y | 59 | CONFIG_NET=y |
| 61 | CONFIG_PACKET=y | 60 | CONFIG_PACKET=y |
| 62 | CONFIG_UNIX=y | 61 | CONFIG_UNIX=y |
diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c index 0c6381516a5a..48f1228c611c 100644 --- a/arch/arm/mach-at91/cpuidle.c +++ b/arch/arm/mach-at91/cpuidle.c | |||
| @@ -27,8 +27,6 @@ | |||
| 27 | 27 | ||
| 28 | #define AT91_MAX_STATES 2 | 28 | #define AT91_MAX_STATES 2 |
| 29 | 29 | ||
| 30 | static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device); | ||
| 31 | |||
| 32 | /* Actual code that puts the SoC in different idle states */ | 30 | /* Actual code that puts the SoC in different idle states */ |
| 33 | static int at91_enter_idle(struct cpuidle_device *dev, | 31 | static int at91_enter_idle(struct cpuidle_device *dev, |
| 34 | struct cpuidle_driver *drv, | 32 | struct cpuidle_driver *drv, |
| @@ -47,7 +45,6 @@ static int at91_enter_idle(struct cpuidle_device *dev, | |||
| 47 | static struct cpuidle_driver at91_idle_driver = { | 45 | static struct cpuidle_driver at91_idle_driver = { |
| 48 | .name = "at91_idle", | 46 | .name = "at91_idle", |
| 49 | .owner = THIS_MODULE, | 47 | .owner = THIS_MODULE, |
| 50 | .en_core_tk_irqen = 1, | ||
| 51 | .states[0] = ARM_CPUIDLE_WFI_STATE, | 48 | .states[0] = ARM_CPUIDLE_WFI_STATE, |
| 52 | .states[1] = { | 49 | .states[1] = { |
| 53 | .enter = at91_enter_idle, | 50 | .enter = at91_enter_idle, |
| @@ -61,20 +58,9 @@ static struct cpuidle_driver at91_idle_driver = { | |||
| 61 | }; | 58 | }; |
| 62 | 59 | ||
| 63 | /* Initialize CPU idle by registering the idle states */ | 60 | /* Initialize CPU idle by registering the idle states */ |
| 64 | static int at91_init_cpuidle(void) | 61 | static int __init at91_init_cpuidle(void) |
| 65 | { | 62 | { |
| 66 | struct cpuidle_device *device; | 63 | return cpuidle_register(&at91_idle_driver, NULL); |
| 67 | |||
| 68 | device = &per_cpu(at91_cpuidle_device, smp_processor_id()); | ||
| 69 | device->state_count = AT91_MAX_STATES; | ||
| 70 | |||
| 71 | cpuidle_register_driver(&at91_idle_driver); | ||
| 72 | |||
| 73 | if (cpuidle_register_device(device)) { | ||
| 74 | printk(KERN_ERR "at91_init_cpuidle: Failed registering\n"); | ||
| 75 | return -EIO; | ||
| 76 | } | ||
| 77 | return 0; | ||
| 78 | } | 64 | } |
| 79 | 65 | ||
| 80 | device_initcall(at91_init_cpuidle); | 66 | device_initcall(at91_init_cpuidle); |
diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile index fb5c1aa98a63..dd1ffccc75e9 100644 --- a/arch/arm/mach-davinci/Makefile +++ b/arch/arm/mach-davinci/Makefile | |||
| @@ -37,7 +37,6 @@ obj-$(CONFIG_MACH_MITYOMAPL138) += board-mityomapl138.o | |||
| 37 | obj-$(CONFIG_MACH_OMAPL138_HAWKBOARD) += board-omapl138-hawk.o | 37 | obj-$(CONFIG_MACH_OMAPL138_HAWKBOARD) += board-omapl138-hawk.o |
| 38 | 38 | ||
| 39 | # Power Management | 39 | # Power Management |
| 40 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o | ||
| 41 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o | 40 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o |
| 42 | obj-$(CONFIG_SUSPEND) += pm.o sleep.o | 41 | obj-$(CONFIG_SUSPEND) += pm.o sleep.o |
| 43 | obj-$(CONFIG_HAVE_CLK) += pm_domain.o | 42 | obj-$(CONFIG_HAVE_CLK) += pm_domain.o |
diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c index 5ac9e9384b15..36aef3a7dedb 100644 --- a/arch/arm/mach-davinci/cpuidle.c +++ b/arch/arm/mach-davinci/cpuidle.c | |||
| @@ -25,7 +25,6 @@ | |||
| 25 | 25 | ||
| 26 | #define DAVINCI_CPUIDLE_MAX_STATES 2 | 26 | #define DAVINCI_CPUIDLE_MAX_STATES 2 |
| 27 | 27 | ||
| 28 | static DEFINE_PER_CPU(struct cpuidle_device, davinci_cpuidle_device); | ||
| 29 | static void __iomem *ddr2_reg_base; | 28 | static void __iomem *ddr2_reg_base; |
| 30 | static bool ddr2_pdown; | 29 | static bool ddr2_pdown; |
| 31 | 30 | ||
| @@ -50,14 +49,10 @@ static void davinci_save_ddr_power(int enter, bool pdown) | |||
| 50 | 49 | ||
| 51 | /* Actual code that puts the SoC in different idle states */ | 50 | /* Actual code that puts the SoC in different idle states */ |
| 52 | static int davinci_enter_idle(struct cpuidle_device *dev, | 51 | static int davinci_enter_idle(struct cpuidle_device *dev, |
| 53 | struct cpuidle_driver *drv, | 52 | struct cpuidle_driver *drv, int index) |
| 54 | int index) | ||
| 55 | { | 53 | { |
| 56 | davinci_save_ddr_power(1, ddr2_pdown); | 54 | davinci_save_ddr_power(1, ddr2_pdown); |
| 57 | 55 | cpu_do_idle(); | |
| 58 | index = cpuidle_wrap_enter(dev, drv, index, | ||
| 59 | arm_cpuidle_simple_enter); | ||
| 60 | |||
| 61 | davinci_save_ddr_power(0, ddr2_pdown); | 56 | davinci_save_ddr_power(0, ddr2_pdown); |
| 62 | 57 | ||
| 63 | return index; | 58 | return index; |
| @@ -66,7 +61,6 @@ static int davinci_enter_idle(struct cpuidle_device *dev, | |||
| 66 | static struct cpuidle_driver davinci_idle_driver = { | 61 | static struct cpuidle_driver davinci_idle_driver = { |
| 67 | .name = "cpuidle-davinci", | 62 | .name = "cpuidle-davinci", |
| 68 | .owner = THIS_MODULE, | 63 | .owner = THIS_MODULE, |
| 69 | .en_core_tk_irqen = 1, | ||
| 70 | .states[0] = ARM_CPUIDLE_WFI_STATE, | 64 | .states[0] = ARM_CPUIDLE_WFI_STATE, |
| 71 | .states[1] = { | 65 | .states[1] = { |
| 72 | .enter = davinci_enter_idle, | 66 | .enter = davinci_enter_idle, |
| @@ -81,12 +75,8 @@ static struct cpuidle_driver davinci_idle_driver = { | |||
| 81 | 75 | ||
| 82 | static int __init davinci_cpuidle_probe(struct platform_device *pdev) | 76 | static int __init davinci_cpuidle_probe(struct platform_device *pdev) |
| 83 | { | 77 | { |
| 84 | int ret; | ||
| 85 | struct cpuidle_device *device; | ||
| 86 | struct davinci_cpuidle_config *pdata = pdev->dev.platform_data; | 78 | struct davinci_cpuidle_config *pdata = pdev->dev.platform_data; |
| 87 | 79 | ||
| 88 | device = &per_cpu(davinci_cpuidle_device, smp_processor_id()); | ||
| 89 | |||
| 90 | if (!pdata) { | 80 | if (!pdata) { |
| 91 | dev_err(&pdev->dev, "cannot get platform data\n"); | 81 | dev_err(&pdev->dev, "cannot get platform data\n"); |
| 92 | return -ENOENT; | 82 | return -ENOENT; |
| @@ -96,20 +86,7 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev) | |||
| 96 | 86 | ||
| 97 | ddr2_pdown = pdata->ddr2_pdown; | 87 | ddr2_pdown = pdata->ddr2_pdown; |
| 98 | 88 | ||
| 99 | ret = cpuidle_register_driver(&davinci_idle_driver); | 89 | return cpuidle_register(&davinci_idle_driver, NULL); |
| 100 | if (ret) { | ||
| 101 | dev_err(&pdev->dev, "failed to register driver\n"); | ||
| 102 | return ret; | ||
| 103 | } | ||
| 104 | |||
| 105 | ret = cpuidle_register_device(device); | ||
| 106 | if (ret) { | ||
| 107 | dev_err(&pdev->dev, "failed to register device\n"); | ||
| 108 | cpuidle_unregister_driver(&davinci_idle_driver); | ||
| 109 | return ret; | ||
| 110 | } | ||
| 111 | |||
| 112 | return 0; | ||
| 113 | } | 90 | } |
| 114 | 91 | ||
| 115 | static struct platform_driver davinci_cpuidle_driver = { | 92 | static struct platform_driver davinci_cpuidle_driver = { |
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig index 70f94c87479d..d5dde0727339 100644 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig | |||
| @@ -72,10 +72,12 @@ config SOC_EXYNOS5440 | |||
| 72 | bool "SAMSUNG EXYNOS5440" | 72 | bool "SAMSUNG EXYNOS5440" |
| 73 | default y | 73 | default y |
| 74 | depends on ARCH_EXYNOS5 | 74 | depends on ARCH_EXYNOS5 |
| 75 | select ARCH_HAS_OPP | ||
| 75 | select ARM_ARCH_TIMER | 76 | select ARM_ARCH_TIMER |
| 76 | select AUTO_ZRELADDR | 77 | select AUTO_ZRELADDR |
| 77 | select PINCTRL | 78 | select PINCTRL |
| 78 | select PINCTRL_EXYNOS5440 | 79 | select PINCTRL_EXYNOS5440 |
| 80 | select PM_OPP | ||
| 79 | help | 81 | help |
| 80 | Enable EXYNOS5440 SoC support | 82 | Enable EXYNOS5440 SoC support |
| 81 | 83 | ||
diff --git a/arch/arm/mach-exynos/cpuidle.c b/arch/arm/mach-exynos/cpuidle.c index fcfe0251aa3e..498a7a23e260 100644 --- a/arch/arm/mach-exynos/cpuidle.c +++ b/arch/arm/mach-exynos/cpuidle.c | |||
| @@ -58,7 +58,6 @@ static DEFINE_PER_CPU(struct cpuidle_device, exynos4_cpuidle_device); | |||
| 58 | static struct cpuidle_driver exynos4_idle_driver = { | 58 | static struct cpuidle_driver exynos4_idle_driver = { |
| 59 | .name = "exynos4_idle", | 59 | .name = "exynos4_idle", |
| 60 | .owner = THIS_MODULE, | 60 | .owner = THIS_MODULE, |
| 61 | .en_core_tk_irqen = 1, | ||
| 62 | }; | 61 | }; |
| 63 | 62 | ||
| 64 | /* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ | 63 | /* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */ |
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index c4ce0906d76a..cb70961b6239 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile | |||
| @@ -30,7 +30,7 @@ obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o | |||
| 30 | obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o | 30 | obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o |
| 31 | 31 | ||
| 32 | ifeq ($(CONFIG_CPU_IDLE),y) | 32 | ifeq ($(CONFIG_CPU_IDLE),y) |
| 33 | obj-y += cpuidle.o | 33 | obj-$(CONFIG_SOC_IMX5) += cpuidle-imx5.o |
| 34 | obj-$(CONFIG_SOC_IMX6Q) += cpuidle-imx6q.o | 34 | obj-$(CONFIG_SOC_IMX6Q) += cpuidle-imx6q.o |
| 35 | endif | 35 | endif |
| 36 | 36 | ||
diff --git a/arch/arm/mach-imx/cpufreq.c b/arch/arm/mach-imx/cpufreq.c index d8c75c3c925d..387dc4cceca2 100644 --- a/arch/arm/mach-imx/cpufreq.c +++ b/arch/arm/mach-imx/cpufreq.c | |||
| @@ -87,13 +87,12 @@ static int mxc_set_target(struct cpufreq_policy *policy, | |||
| 87 | 87 | ||
| 88 | freqs.old = clk_get_rate(cpu_clk) / 1000; | 88 | freqs.old = clk_get_rate(cpu_clk) / 1000; |
| 89 | freqs.new = freq_Hz / 1000; | 89 | freqs.new = freq_Hz / 1000; |
| 90 | freqs.cpu = 0; | ||
| 91 | freqs.flags = 0; | 90 | freqs.flags = 0; |
| 92 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 91 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 93 | 92 | ||
| 94 | ret = set_cpu_freq(freq_Hz); | 93 | ret = set_cpu_freq(freq_Hz); |
| 95 | 94 | ||
| 96 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 95 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 97 | 96 | ||
| 98 | return ret; | 97 | return ret; |
| 99 | } | 98 | } |
| @@ -145,14 +144,11 @@ static int mxc_cpufreq_init(struct cpufreq_policy *policy) | |||
| 145 | imx_freq_table[i].frequency = CPUFREQ_TABLE_END; | 144 | imx_freq_table[i].frequency = CPUFREQ_TABLE_END; |
| 146 | 145 | ||
| 147 | policy->cur = clk_get_rate(cpu_clk) / 1000; | 146 | policy->cur = clk_get_rate(cpu_clk) / 1000; |
| 148 | policy->min = policy->cpuinfo.min_freq = cpu_freq_khz_min; | ||
| 149 | policy->max = policy->cpuinfo.max_freq = cpu_freq_khz_max; | ||
| 150 | 147 | ||
| 151 | /* Manual states, that PLL stabilizes in two CLK32 periods */ | 148 | /* Manual states, that PLL stabilizes in two CLK32 periods */ |
| 152 | policy->cpuinfo.transition_latency = 2 * NANOSECOND / CLK32_FREQ; | 149 | policy->cpuinfo.transition_latency = 2 * NANOSECOND / CLK32_FREQ; |
| 153 | 150 | ||
| 154 | ret = cpufreq_frequency_table_cpuinfo(policy, imx_freq_table); | 151 | ret = cpufreq_frequency_table_cpuinfo(policy, imx_freq_table); |
| 155 | |||
| 156 | if (ret < 0) { | 152 | if (ret < 0) { |
| 157 | printk(KERN_ERR "%s: failed to register i.MXC CPUfreq with error code %d\n", | 153 | printk(KERN_ERR "%s: failed to register i.MXC CPUfreq with error code %d\n", |
| 158 | __func__, ret); | 154 | __func__, ret); |
diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c new file mode 100644 index 000000000000..5a47e3c6172f --- /dev/null +++ b/arch/arm/mach-imx/cpuidle-imx5.c | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2012 Freescale Semiconductor, Inc. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License version 2 as | ||
| 6 | * published by the Free Software Foundation. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include <linux/cpuidle.h> | ||
| 10 | #include <linux/module.h> | ||
| 11 | #include <asm/system_misc.h> | ||
| 12 | |||
| 13 | static int imx5_cpuidle_enter(struct cpuidle_device *dev, | ||
| 14 | struct cpuidle_driver *drv, int index) | ||
| 15 | { | ||
| 16 | arm_pm_idle(); | ||
| 17 | return index; | ||
| 18 | } | ||
| 19 | |||
| 20 | static struct cpuidle_driver imx5_cpuidle_driver = { | ||
| 21 | .name = "imx5_cpuidle", | ||
| 22 | .owner = THIS_MODULE, | ||
| 23 | .states[0] = { | ||
| 24 | .enter = imx5_cpuidle_enter, | ||
| 25 | .exit_latency = 2, | ||
| 26 | .target_residency = 1, | ||
| 27 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
| 28 | .name = "IMX5 SRPG", | ||
| 29 | .desc = "CPU state retained,powered off", | ||
| 30 | }, | ||
| 31 | .state_count = 1, | ||
| 32 | }; | ||
| 33 | |||
| 34 | int __init imx5_cpuidle_init(void) | ||
| 35 | { | ||
| 36 | return cpuidle_register(&imx5_cpuidle_driver, NULL); | ||
| 37 | } | ||
diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c index d533e2695f0e..23ddfb693b2d 100644 --- a/arch/arm/mach-imx/cpuidle-imx6q.c +++ b/arch/arm/mach-imx/cpuidle-imx6q.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * published by the Free Software Foundation. | 6 | * published by the Free Software Foundation. |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include <linux/clockchips.h> | ||
| 10 | #include <linux/cpuidle.h> | 9 | #include <linux/cpuidle.h> |
| 11 | #include <linux/module.h> | 10 | #include <linux/module.h> |
| 12 | #include <asm/cpuidle.h> | 11 | #include <asm/cpuidle.h> |
| @@ -21,10 +20,6 @@ static DEFINE_SPINLOCK(master_lock); | |||
| 21 | static int imx6q_enter_wait(struct cpuidle_device *dev, | 20 | static int imx6q_enter_wait(struct cpuidle_device *dev, |
| 22 | struct cpuidle_driver *drv, int index) | 21 | struct cpuidle_driver *drv, int index) |
| 23 | { | 22 | { |
| 24 | int cpu = dev->cpu; | ||
| 25 | |||
| 26 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu); | ||
| 27 | |||
| 28 | if (atomic_inc_return(&master) == num_online_cpus()) { | 23 | if (atomic_inc_return(&master) == num_online_cpus()) { |
| 29 | /* | 24 | /* |
| 30 | * With this lock, we prevent other cpu to exit and enter | 25 | * With this lock, we prevent other cpu to exit and enter |
| @@ -43,26 +38,13 @@ idle: | |||
| 43 | cpu_do_idle(); | 38 | cpu_do_idle(); |
| 44 | done: | 39 | done: |
| 45 | atomic_dec(&master); | 40 | atomic_dec(&master); |
| 46 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu); | ||
| 47 | 41 | ||
| 48 | return index; | 42 | return index; |
| 49 | } | 43 | } |
| 50 | 44 | ||
| 51 | /* | ||
| 52 | * For each cpu, setup the broadcast timer because local timer | ||
| 53 | * stops for the states other than WFI. | ||
| 54 | */ | ||
| 55 | static void imx6q_setup_broadcast_timer(void *arg) | ||
| 56 | { | ||
| 57 | int cpu = smp_processor_id(); | ||
| 58 | |||
| 59 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ON, &cpu); | ||
| 60 | } | ||
| 61 | |||
| 62 | static struct cpuidle_driver imx6q_cpuidle_driver = { | 45 | static struct cpuidle_driver imx6q_cpuidle_driver = { |
| 63 | .name = "imx6q_cpuidle", | 46 | .name = "imx6q_cpuidle", |
| 64 | .owner = THIS_MODULE, | 47 | .owner = THIS_MODULE, |
| 65 | .en_core_tk_irqen = 1, | ||
| 66 | .states = { | 48 | .states = { |
| 67 | /* WFI */ | 49 | /* WFI */ |
| 68 | ARM_CPUIDLE_WFI_STATE, | 50 | ARM_CPUIDLE_WFI_STATE, |
| @@ -70,7 +52,8 @@ static struct cpuidle_driver imx6q_cpuidle_driver = { | |||
| 70 | { | 52 | { |
| 71 | .exit_latency = 50, | 53 | .exit_latency = 50, |
| 72 | .target_residency = 75, | 54 | .target_residency = 75, |
| 73 | .flags = CPUIDLE_FLAG_TIME_VALID, | 55 | .flags = CPUIDLE_FLAG_TIME_VALID | |
| 56 | CPUIDLE_FLAG_TIMER_STOP, | ||
| 74 | .enter = imx6q_enter_wait, | 57 | .enter = imx6q_enter_wait, |
| 75 | .name = "WAIT", | 58 | .name = "WAIT", |
| 76 | .desc = "Clock off", | 59 | .desc = "Clock off", |
| @@ -88,8 +71,5 @@ int __init imx6q_cpuidle_init(void) | |||
| 88 | /* Set chicken bit to get a reliable WAIT mode support */ | 71 | /* Set chicken bit to get a reliable WAIT mode support */ |
| 89 | imx6q_set_chicken_bit(); | 72 | imx6q_set_chicken_bit(); |
| 90 | 73 | ||
| 91 | /* Configure the broadcast timer on each cpu */ | 74 | return cpuidle_register(&imx6q_cpuidle_driver, NULL); |
| 92 | on_each_cpu(imx6q_setup_broadcast_timer, NULL, 1); | ||
| 93 | |||
| 94 | return imx_cpuidle_init(&imx6q_cpuidle_driver); | ||
| 95 | } | 75 | } |
diff --git a/arch/arm/mach-imx/cpuidle.c b/arch/arm/mach-imx/cpuidle.c deleted file mode 100644 index d4cb511a44a8..000000000000 --- a/arch/arm/mach-imx/cpuidle.c +++ /dev/null | |||
| @@ -1,80 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2012 Freescale Semiconductor, Inc. | ||
| 3 | * Copyright 2012 Linaro Ltd. | ||
| 4 | * | ||
| 5 | * The code contained herein is licensed under the GNU General Public | ||
| 6 | * License. You may obtain a copy of the GNU General Public License | ||
| 7 | * Version 2 or later at the following locations: | ||
| 8 | * | ||
| 9 | * http://www.opensource.org/licenses/gpl-license.html | ||
| 10 | * http://www.gnu.org/copyleft/gpl.html | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/cpuidle.h> | ||
| 14 | #include <linux/err.h> | ||
| 15 | #include <linux/hrtimer.h> | ||
| 16 | #include <linux/io.h> | ||
| 17 | #include <linux/kernel.h> | ||
| 18 | #include <linux/slab.h> | ||
| 19 | |||
| 20 | static struct cpuidle_device __percpu * imx_cpuidle_devices; | ||
| 21 | |||
| 22 | static void __init imx_cpuidle_devices_uninit(void) | ||
| 23 | { | ||
| 24 | int cpu_id; | ||
| 25 | struct cpuidle_device *dev; | ||
| 26 | |||
| 27 | for_each_possible_cpu(cpu_id) { | ||
| 28 | dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id); | ||
| 29 | cpuidle_unregister_device(dev); | ||
| 30 | } | ||
| 31 | |||
| 32 | free_percpu(imx_cpuidle_devices); | ||
| 33 | } | ||
| 34 | |||
| 35 | int __init imx_cpuidle_init(struct cpuidle_driver *drv) | ||
| 36 | { | ||
| 37 | struct cpuidle_device *dev; | ||
| 38 | int cpu_id, ret; | ||
| 39 | |||
| 40 | if (drv->state_count > CPUIDLE_STATE_MAX) { | ||
| 41 | pr_err("%s: state_count exceeds maximum\n", __func__); | ||
| 42 | return -EINVAL; | ||
| 43 | } | ||
| 44 | |||
| 45 | ret = cpuidle_register_driver(drv); | ||
| 46 | if (ret) { | ||
| 47 | pr_err("%s: Failed to register cpuidle driver with error: %d\n", | ||
| 48 | __func__, ret); | ||
| 49 | return ret; | ||
| 50 | } | ||
| 51 | |||
| 52 | imx_cpuidle_devices = alloc_percpu(struct cpuidle_device); | ||
| 53 | if (imx_cpuidle_devices == NULL) { | ||
| 54 | ret = -ENOMEM; | ||
| 55 | goto unregister_drv; | ||
| 56 | } | ||
| 57 | |||
| 58 | /* initialize state data for each cpuidle_device */ | ||
| 59 | for_each_possible_cpu(cpu_id) { | ||
| 60 | dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id); | ||
| 61 | dev->cpu = cpu_id; | ||
| 62 | dev->state_count = drv->state_count; | ||
| 63 | |||
| 64 | ret = cpuidle_register_device(dev); | ||
| 65 | if (ret) { | ||
| 66 | pr_err("%s: Failed to register cpu %u, error: %d\n", | ||
| 67 | __func__, cpu_id, ret); | ||
| 68 | goto uninit; | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | return 0; | ||
| 73 | |||
| 74 | uninit: | ||
| 75 | imx_cpuidle_devices_uninit(); | ||
| 76 | |||
| 77 | unregister_drv: | ||
| 78 | cpuidle_unregister_driver(drv); | ||
| 79 | return ret; | ||
| 80 | } | ||
diff --git a/arch/arm/mach-imx/cpuidle.h b/arch/arm/mach-imx/cpuidle.h index e092d1359d94..786f98ecc145 100644 --- a/arch/arm/mach-imx/cpuidle.h +++ b/arch/arm/mach-imx/cpuidle.h | |||
| @@ -10,18 +10,16 @@ | |||
| 10 | * http://www.gnu.org/copyleft/gpl.html | 10 | * http://www.gnu.org/copyleft/gpl.html |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #include <linux/cpuidle.h> | ||
| 14 | |||
| 15 | #ifdef CONFIG_CPU_IDLE | 13 | #ifdef CONFIG_CPU_IDLE |
| 16 | extern int imx_cpuidle_init(struct cpuidle_driver *drv); | 14 | extern int imx5_cpuidle_init(void); |
| 17 | extern int imx6q_cpuidle_init(void); | 15 | extern int imx6q_cpuidle_init(void); |
| 18 | #else | 16 | #else |
| 19 | static inline int imx_cpuidle_init(struct cpuidle_driver *drv) | 17 | static inline int imx5_cpuidle_init(void) |
| 20 | { | 18 | { |
| 21 | return -ENODEV; | 19 | return 0; |
| 22 | } | 20 | } |
| 23 | static inline int imx6q_cpuidle_init(void) | 21 | static inline int imx6q_cpuidle_init(void) |
| 24 | { | 22 | { |
| 25 | return -ENODEV; | 23 | return 0; |
| 26 | } | 24 | } |
| 27 | #endif | 25 | #endif |
diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c index f67fd7ee8127..82e79c658eb2 100644 --- a/arch/arm/mach-imx/pm-imx5.c +++ b/arch/arm/mach-imx/pm-imx5.c | |||
| @@ -149,33 +149,6 @@ static void imx5_pm_idle(void) | |||
| 149 | imx5_cpu_do_idle(); | 149 | imx5_cpu_do_idle(); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | static int imx5_cpuidle_enter(struct cpuidle_device *dev, | ||
| 153 | struct cpuidle_driver *drv, int idx) | ||
| 154 | { | ||
| 155 | int ret; | ||
| 156 | |||
| 157 | ret = imx5_cpu_do_idle(); | ||
| 158 | if (ret < 0) | ||
| 159 | return ret; | ||
| 160 | |||
| 161 | return idx; | ||
| 162 | } | ||
| 163 | |||
| 164 | static struct cpuidle_driver imx5_cpuidle_driver = { | ||
| 165 | .name = "imx5_cpuidle", | ||
| 166 | .owner = THIS_MODULE, | ||
| 167 | .en_core_tk_irqen = 1, | ||
| 168 | .states[0] = { | ||
| 169 | .enter = imx5_cpuidle_enter, | ||
| 170 | .exit_latency = 2, | ||
| 171 | .target_residency = 1, | ||
| 172 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
| 173 | .name = "IMX5 SRPG", | ||
| 174 | .desc = "CPU state retained,powered off", | ||
| 175 | }, | ||
| 176 | .state_count = 1, | ||
| 177 | }; | ||
| 178 | |||
| 179 | static int __init imx5_pm_common_init(void) | 152 | static int __init imx5_pm_common_init(void) |
| 180 | { | 153 | { |
| 181 | int ret; | 154 | int ret; |
| @@ -193,8 +166,7 @@ static int __init imx5_pm_common_init(void) | |||
| 193 | /* Set the registers to the default cpu idle state. */ | 166 | /* Set the registers to the default cpu idle state. */ |
| 194 | mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE); | 167 | mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE); |
| 195 | 168 | ||
| 196 | imx_cpuidle_init(&imx5_cpuidle_driver); | 169 | return imx5_cpuidle_init(); |
| 197 | return 0; | ||
| 198 | } | 170 | } |
| 199 | 171 | ||
| 200 | void __init imx51_pm_init(void) | 172 | void __init imx51_pm_init(void) |
diff --git a/arch/arm/mach-integrator/Makefile b/arch/arm/mach-integrator/Makefile index 5521d18bf19a..d14d6b76f4c2 100644 --- a/arch/arm/mach-integrator/Makefile +++ b/arch/arm/mach-integrator/Makefile | |||
| @@ -9,5 +9,4 @@ obj-$(CONFIG_ARCH_INTEGRATOR_AP) += integrator_ap.o | |||
| 9 | obj-$(CONFIG_ARCH_INTEGRATOR_CP) += integrator_cp.o | 9 | obj-$(CONFIG_ARCH_INTEGRATOR_CP) += integrator_cp.o |
| 10 | 10 | ||
| 11 | obj-$(CONFIG_PCI) += pci_v3.o pci.o | 11 | obj-$(CONFIG_PCI) += pci_v3.o pci.o |
| 12 | obj-$(CONFIG_CPU_FREQ_INTEGRATOR) += cpu.o | ||
| 13 | obj-$(CONFIG_INTEGRATOR_IMPD1) += impd1.o | 12 | obj-$(CONFIG_INTEGRATOR_IMPD1) += impd1.o |
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h index d6ba13e1c540..14522d077c88 100644 --- a/arch/arm/mach-omap2/common.h +++ b/arch/arm/mach-omap2/common.h | |||
| @@ -249,7 +249,6 @@ extern int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state); | |||
| 249 | extern int omap4_finish_suspend(unsigned long cpu_state); | 249 | extern int omap4_finish_suspend(unsigned long cpu_state); |
| 250 | extern void omap4_cpu_resume(void); | 250 | extern void omap4_cpu_resume(void); |
| 251 | extern int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state); | 251 | extern int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state); |
| 252 | extern u32 omap4_mpuss_read_prev_context_state(void); | ||
| 253 | #else | 252 | #else |
| 254 | static inline int omap4_enter_lowpower(unsigned int cpu, | 253 | static inline int omap4_enter_lowpower(unsigned int cpu, |
| 255 | unsigned int power_state) | 254 | unsigned int power_state) |
| @@ -277,10 +276,6 @@ static inline int omap4_finish_suspend(unsigned long cpu_state) | |||
| 277 | static inline void omap4_cpu_resume(void) | 276 | static inline void omap4_cpu_resume(void) |
| 278 | {} | 277 | {} |
| 279 | 278 | ||
| 280 | static inline u32 omap4_mpuss_read_prev_context_state(void) | ||
| 281 | { | ||
| 282 | return 0; | ||
| 283 | } | ||
| 284 | #endif | 279 | #endif |
| 285 | 280 | ||
| 286 | struct omap_sdrc_params; | 281 | struct omap_sdrc_params; |
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c index 80392fca86c6..cca045c95fbf 100644 --- a/arch/arm/mach-omap2/cpuidle34xx.c +++ b/arch/arm/mach-omap2/cpuidle34xx.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/cpuidle.h> | 26 | #include <linux/cpuidle.h> |
| 27 | #include <linux/export.h> | 27 | #include <linux/export.h> |
| 28 | #include <linux/cpu_pm.h> | 28 | #include <linux/cpu_pm.h> |
| 29 | #include <asm/cpuidle.h> | ||
| 29 | 30 | ||
| 30 | #include "powerdomain.h" | 31 | #include "powerdomain.h" |
| 31 | #include "clockdomain.h" | 32 | #include "clockdomain.h" |
| @@ -99,11 +100,15 @@ static struct omap3_idle_statedata omap3_idle_data[] = { | |||
| 99 | }, | 100 | }, |
| 100 | }; | 101 | }; |
| 101 | 102 | ||
| 102 | /* Private functions */ | 103 | /** |
| 103 | 104 | * omap3_enter_idle - Programs OMAP3 to enter the specified state | |
| 104 | static int __omap3_enter_idle(struct cpuidle_device *dev, | 105 | * @dev: cpuidle device |
| 105 | struct cpuidle_driver *drv, | 106 | * @drv: cpuidle driver |
| 106 | int index) | 107 | * @index: the index of state to be entered |
| 108 | */ | ||
| 109 | static int omap3_enter_idle(struct cpuidle_device *dev, | ||
| 110 | struct cpuidle_driver *drv, | ||
| 111 | int index) | ||
| 107 | { | 112 | { |
| 108 | struct omap3_idle_statedata *cx = &omap3_idle_data[index]; | 113 | struct omap3_idle_statedata *cx = &omap3_idle_data[index]; |
| 109 | 114 | ||
| @@ -149,22 +154,6 @@ return_sleep_time: | |||
| 149 | } | 154 | } |
| 150 | 155 | ||
| 151 | /** | 156 | /** |
| 152 | * omap3_enter_idle - Programs OMAP3 to enter the specified state | ||
| 153 | * @dev: cpuidle device | ||
| 154 | * @drv: cpuidle driver | ||
| 155 | * @index: the index of state to be entered | ||
| 156 | * | ||
| 157 | * Called from the CPUidle framework to program the device to the | ||
| 158 | * specified target state selected by the governor. | ||
| 159 | */ | ||
| 160 | static inline int omap3_enter_idle(struct cpuidle_device *dev, | ||
| 161 | struct cpuidle_driver *drv, | ||
| 162 | int index) | ||
| 163 | { | ||
| 164 | return cpuidle_wrap_enter(dev, drv, index, __omap3_enter_idle); | ||
| 165 | } | ||
| 166 | |||
| 167 | /** | ||
| 168 | * next_valid_state - Find next valid C-state | 157 | * next_valid_state - Find next valid C-state |
| 169 | * @dev: cpuidle device | 158 | * @dev: cpuidle device |
| 170 | * @drv: cpuidle driver | 159 | * @drv: cpuidle driver |
| @@ -271,11 +260,9 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev, | |||
| 271 | return ret; | 260 | return ret; |
| 272 | } | 261 | } |
| 273 | 262 | ||
| 274 | static DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev); | ||
| 275 | |||
| 276 | static struct cpuidle_driver omap3_idle_driver = { | 263 | static struct cpuidle_driver omap3_idle_driver = { |
| 277 | .name = "omap3_idle", | 264 | .name = "omap3_idle", |
| 278 | .owner = THIS_MODULE, | 265 | .owner = THIS_MODULE, |
| 279 | .states = { | 266 | .states = { |
| 280 | { | 267 | { |
| 281 | .enter = omap3_enter_idle_bm, | 268 | .enter = omap3_enter_idle_bm, |
| @@ -348,8 +335,6 @@ static struct cpuidle_driver omap3_idle_driver = { | |||
| 348 | */ | 335 | */ |
| 349 | int __init omap3_idle_init(void) | 336 | int __init omap3_idle_init(void) |
| 350 | { | 337 | { |
| 351 | struct cpuidle_device *dev; | ||
| 352 | |||
| 353 | mpu_pd = pwrdm_lookup("mpu_pwrdm"); | 338 | mpu_pd = pwrdm_lookup("mpu_pwrdm"); |
| 354 | core_pd = pwrdm_lookup("core_pwrdm"); | 339 | core_pd = pwrdm_lookup("core_pwrdm"); |
| 355 | per_pd = pwrdm_lookup("per_pwrdm"); | 340 | per_pd = pwrdm_lookup("per_pwrdm"); |
| @@ -358,16 +343,5 @@ int __init omap3_idle_init(void) | |||
| 358 | if (!mpu_pd || !core_pd || !per_pd || !cam_pd) | 343 | if (!mpu_pd || !core_pd || !per_pd || !cam_pd) |
| 359 | return -ENODEV; | 344 | return -ENODEV; |
| 360 | 345 | ||
| 361 | cpuidle_register_driver(&omap3_idle_driver); | 346 | return cpuidle_register(&omap3_idle_driver, NULL); |
| 362 | |||
| 363 | dev = &per_cpu(omap3_idle_dev, smp_processor_id()); | ||
| 364 | dev->cpu = 0; | ||
| 365 | |||
| 366 | if (cpuidle_register_device(dev)) { | ||
| 367 | printk(KERN_ERR "%s: CPUidle register device failed\n", | ||
| 368 | __func__); | ||
| 369 | return -EIO; | ||
| 370 | } | ||
| 371 | |||
| 372 | return 0; | ||
| 373 | } | 347 | } |
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c index d639aef0deda..5a286b56205e 100644 --- a/arch/arm/mach-omap2/cpuidle44xx.c +++ b/arch/arm/mach-omap2/cpuidle44xx.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * OMAP4 CPU idle Routines | 2 | * OMAP4+ CPU idle Routines |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2011 Texas Instruments, Inc. | 4 | * Copyright (C) 2011-2013 Texas Instruments, Inc. |
| 5 | * Santosh Shilimkar <santosh.shilimkar@ti.com> | 5 | * Santosh Shilimkar <santosh.shilimkar@ti.com> |
| 6 | * Rajendra Nayak <rnayak@ti.com> | 6 | * Rajendra Nayak <rnayak@ti.com> |
| 7 | * | 7 | * |
| @@ -14,8 +14,8 @@ | |||
| 14 | #include <linux/cpuidle.h> | 14 | #include <linux/cpuidle.h> |
| 15 | #include <linux/cpu_pm.h> | 15 | #include <linux/cpu_pm.h> |
| 16 | #include <linux/export.h> | 16 | #include <linux/export.h> |
| 17 | #include <linux/clockchips.h> | ||
| 18 | 17 | ||
| 18 | #include <asm/cpuidle.h> | ||
| 19 | #include <asm/proc-fns.h> | 19 | #include <asm/proc-fns.h> |
| 20 | 20 | ||
| 21 | #include "common.h" | 21 | #include "common.h" |
| @@ -24,13 +24,13 @@ | |||
| 24 | #include "clockdomain.h" | 24 | #include "clockdomain.h" |
| 25 | 25 | ||
| 26 | /* Machine specific information */ | 26 | /* Machine specific information */ |
| 27 | struct omap4_idle_statedata { | 27 | struct idle_statedata { |
| 28 | u32 cpu_state; | 28 | u32 cpu_state; |
| 29 | u32 mpu_logic_state; | 29 | u32 mpu_logic_state; |
| 30 | u32 mpu_state; | 30 | u32 mpu_state; |
| 31 | }; | 31 | }; |
| 32 | 32 | ||
| 33 | static struct omap4_idle_statedata omap4_idle_data[] = { | 33 | static struct idle_statedata omap4_idle_data[] = { |
| 34 | { | 34 | { |
| 35 | .cpu_state = PWRDM_POWER_ON, | 35 | .cpu_state = PWRDM_POWER_ON, |
| 36 | .mpu_state = PWRDM_POWER_ON, | 36 | .mpu_state = PWRDM_POWER_ON, |
| @@ -53,11 +53,12 @@ static struct clockdomain *cpu_clkdm[NR_CPUS]; | |||
| 53 | 53 | ||
| 54 | static atomic_t abort_barrier; | 54 | static atomic_t abort_barrier; |
| 55 | static bool cpu_done[NR_CPUS]; | 55 | static bool cpu_done[NR_CPUS]; |
| 56 | static struct idle_statedata *state_ptr = &omap4_idle_data[0]; | ||
| 56 | 57 | ||
| 57 | /* Private functions */ | 58 | /* Private functions */ |
| 58 | 59 | ||
| 59 | /** | 60 | /** |
| 60 | * omap4_enter_idle_coupled_[simple/coupled] - OMAP4 cpuidle entry functions | 61 | * omap_enter_idle_[simple/coupled] - OMAP4PLUS cpuidle entry functions |
| 61 | * @dev: cpuidle device | 62 | * @dev: cpuidle device |
| 62 | * @drv: cpuidle driver | 63 | * @drv: cpuidle driver |
| 63 | * @index: the index of state to be entered | 64 | * @index: the index of state to be entered |
| @@ -66,7 +67,7 @@ static bool cpu_done[NR_CPUS]; | |||
| 66 | * specified low power state selected by the governor. | 67 | * specified low power state selected by the governor. |
| 67 | * Returns the amount of time spent in the low power state. | 68 | * Returns the amount of time spent in the low power state. |
| 68 | */ | 69 | */ |
| 69 | static int omap4_enter_idle_simple(struct cpuidle_device *dev, | 70 | static int omap_enter_idle_simple(struct cpuidle_device *dev, |
| 70 | struct cpuidle_driver *drv, | 71 | struct cpuidle_driver *drv, |
| 71 | int index) | 72 | int index) |
| 72 | { | 73 | { |
| @@ -77,12 +78,11 @@ static int omap4_enter_idle_simple(struct cpuidle_device *dev, | |||
| 77 | return index; | 78 | return index; |
| 78 | } | 79 | } |
| 79 | 80 | ||
| 80 | static int omap4_enter_idle_coupled(struct cpuidle_device *dev, | 81 | static int omap_enter_idle_coupled(struct cpuidle_device *dev, |
| 81 | struct cpuidle_driver *drv, | 82 | struct cpuidle_driver *drv, |
| 82 | int index) | 83 | int index) |
| 83 | { | 84 | { |
| 84 | struct omap4_idle_statedata *cx = &omap4_idle_data[index]; | 85 | struct idle_statedata *cx = state_ptr + index; |
| 85 | int cpu_id = smp_processor_id(); | ||
| 86 | 86 | ||
| 87 | local_fiq_disable(); | 87 | local_fiq_disable(); |
| 88 | 88 | ||
| @@ -109,8 +109,6 @@ static int omap4_enter_idle_coupled(struct cpuidle_device *dev, | |||
| 109 | } | 109 | } |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu_id); | ||
| 113 | |||
| 114 | /* | 112 | /* |
| 115 | * Call idle CPU PM enter notifier chain so that | 113 | * Call idle CPU PM enter notifier chain so that |
| 116 | * VFP and per CPU interrupt context is saved. | 114 | * VFP and per CPU interrupt context is saved. |
| @@ -149,11 +147,10 @@ static int omap4_enter_idle_coupled(struct cpuidle_device *dev, | |||
| 149 | * Call idle CPU cluster PM exit notifier chain | 147 | * Call idle CPU cluster PM exit notifier chain |
| 150 | * to restore GIC and wakeupgen context. | 148 | * to restore GIC and wakeupgen context. |
| 151 | */ | 149 | */ |
| 152 | if (omap4_mpuss_read_prev_context_state()) | 150 | if ((cx->mpu_state == PWRDM_POWER_RET) && |
| 151 | (cx->mpu_logic_state == PWRDM_POWER_OFF)) | ||
| 153 | cpu_cluster_pm_exit(); | 152 | cpu_cluster_pm_exit(); |
| 154 | 153 | ||
| 155 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu_id); | ||
| 156 | |||
| 157 | fail: | 154 | fail: |
| 158 | cpuidle_coupled_parallel_barrier(dev, &abort_barrier); | 155 | cpuidle_coupled_parallel_barrier(dev, &abort_barrier); |
| 159 | cpu_done[dev->cpu] = false; | 156 | cpu_done[dev->cpu] = false; |
| @@ -163,49 +160,38 @@ fail: | |||
| 163 | return index; | 160 | return index; |
| 164 | } | 161 | } |
| 165 | 162 | ||
| 166 | /* | ||
| 167 | * For each cpu, setup the broadcast timer because local timers | ||
| 168 | * stops for the states above C1. | ||
| 169 | */ | ||
| 170 | static void omap_setup_broadcast_timer(void *arg) | ||
| 171 | { | ||
| 172 | int cpu = smp_processor_id(); | ||
| 173 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ON, &cpu); | ||
| 174 | } | ||
| 175 | |||
| 176 | static DEFINE_PER_CPU(struct cpuidle_device, omap4_idle_dev); | ||
| 177 | |||
| 178 | static struct cpuidle_driver omap4_idle_driver = { | 163 | static struct cpuidle_driver omap4_idle_driver = { |
| 179 | .name = "omap4_idle", | 164 | .name = "omap4_idle", |
| 180 | .owner = THIS_MODULE, | 165 | .owner = THIS_MODULE, |
| 181 | .en_core_tk_irqen = 1, | ||
| 182 | .states = { | 166 | .states = { |
| 183 | { | 167 | { |
| 184 | /* C1 - CPU0 ON + CPU1 ON + MPU ON */ | 168 | /* C1 - CPU0 ON + CPU1 ON + MPU ON */ |
| 185 | .exit_latency = 2 + 2, | 169 | .exit_latency = 2 + 2, |
| 186 | .target_residency = 5, | 170 | .target_residency = 5, |
| 187 | .flags = CPUIDLE_FLAG_TIME_VALID, | 171 | .flags = CPUIDLE_FLAG_TIME_VALID, |
| 188 | .enter = omap4_enter_idle_simple, | 172 | .enter = omap_enter_idle_simple, |
| 189 | .name = "C1", | 173 | .name = "C1", |
| 190 | .desc = "MPUSS ON" | 174 | .desc = "CPUx ON, MPUSS ON" |
| 191 | }, | 175 | }, |
| 192 | { | 176 | { |
| 193 | /* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */ | 177 | /* C2 - CPU0 OFF + CPU1 OFF + MPU CSWR */ |
| 194 | .exit_latency = 328 + 440, | 178 | .exit_latency = 328 + 440, |
| 195 | .target_residency = 960, | 179 | .target_residency = 960, |
| 196 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED, | 180 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED | |
| 197 | .enter = omap4_enter_idle_coupled, | 181 | CPUIDLE_FLAG_TIMER_STOP, |
| 182 | .enter = omap_enter_idle_coupled, | ||
| 198 | .name = "C2", | 183 | .name = "C2", |
| 199 | .desc = "MPUSS CSWR", | 184 | .desc = "CPUx OFF, MPUSS CSWR", |
| 200 | }, | 185 | }, |
| 201 | { | 186 | { |
| 202 | /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */ | 187 | /* C3 - CPU0 OFF + CPU1 OFF + MPU OSWR */ |
| 203 | .exit_latency = 460 + 518, | 188 | .exit_latency = 460 + 518, |
| 204 | .target_residency = 1100, | 189 | .target_residency = 1100, |
| 205 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED, | 190 | .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_COUPLED | |
| 206 | .enter = omap4_enter_idle_coupled, | 191 | CPUIDLE_FLAG_TIMER_STOP, |
| 192 | .enter = omap_enter_idle_coupled, | ||
| 207 | .name = "C3", | 193 | .name = "C3", |
| 208 | .desc = "MPUSS OSWR", | 194 | .desc = "CPUx OFF, MPUSS OSWR", |
| 209 | }, | 195 | }, |
| 210 | }, | 196 | }, |
| 211 | .state_count = ARRAY_SIZE(omap4_idle_data), | 197 | .state_count = ARRAY_SIZE(omap4_idle_data), |
| @@ -215,16 +201,13 @@ static struct cpuidle_driver omap4_idle_driver = { | |||
| 215 | /* Public functions */ | 201 | /* Public functions */ |
| 216 | 202 | ||
| 217 | /** | 203 | /** |
| 218 | * omap4_idle_init - Init routine for OMAP4 idle | 204 | * omap4_idle_init - Init routine for OMAP4+ idle |
| 219 | * | 205 | * |
| 220 | * Registers the OMAP4 specific cpuidle driver to the cpuidle | 206 | * Registers the OMAP4+ specific cpuidle driver to the cpuidle |
| 221 | * framework with the valid set of states. | 207 | * framework with the valid set of states. |
| 222 | */ | 208 | */ |
| 223 | int __init omap4_idle_init(void) | 209 | int __init omap4_idle_init(void) |
| 224 | { | 210 | { |
| 225 | struct cpuidle_device *dev; | ||
| 226 | unsigned int cpu_id = 0; | ||
| 227 | |||
| 228 | mpu_pd = pwrdm_lookup("mpu_pwrdm"); | 211 | mpu_pd = pwrdm_lookup("mpu_pwrdm"); |
| 229 | cpu_pd[0] = pwrdm_lookup("cpu0_pwrdm"); | 212 | cpu_pd[0] = pwrdm_lookup("cpu0_pwrdm"); |
| 230 | cpu_pd[1] = pwrdm_lookup("cpu1_pwrdm"); | 213 | cpu_pd[1] = pwrdm_lookup("cpu1_pwrdm"); |
| @@ -236,22 +219,5 @@ int __init omap4_idle_init(void) | |||
| 236 | if (!cpu_clkdm[0] || !cpu_clkdm[1]) | 219 | if (!cpu_clkdm[0] || !cpu_clkdm[1]) |
| 237 | return -ENODEV; | 220 | return -ENODEV; |
| 238 | 221 | ||
| 239 | /* Configure the broadcast timer on each cpu */ | 222 | return cpuidle_register(&omap4_idle_driver, cpu_online_mask); |
| 240 | on_each_cpu(omap_setup_broadcast_timer, NULL, 1); | ||
| 241 | |||
| 242 | for_each_cpu(cpu_id, cpu_online_mask) { | ||
| 243 | dev = &per_cpu(omap4_idle_dev, cpu_id); | ||
| 244 | dev->cpu = cpu_id; | ||
| 245 | #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED | ||
| 246 | dev->coupled_cpus = *cpu_online_mask; | ||
| 247 | #endif | ||
| 248 | cpuidle_register_driver(&omap4_idle_driver); | ||
| 249 | |||
| 250 | if (cpuidle_register_device(dev)) { | ||
| 251 | pr_err("%s: CPUidle register failed\n", __func__); | ||
| 252 | return -EIO; | ||
| 253 | } | ||
| 254 | } | ||
| 255 | |||
| 256 | return 0; | ||
| 257 | } | 223 | } |
diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c index 8bcb64bcdcdb..e80327b6c81f 100644 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c | |||
| @@ -139,20 +139,6 @@ static inline void cpu_clear_prev_logic_pwrst(unsigned int cpu_id) | |||
| 139 | } | 139 | } |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /** | ||
| 143 | * omap4_mpuss_read_prev_context_state: | ||
| 144 | * Function returns the MPUSS previous context state | ||
| 145 | */ | ||
| 146 | u32 omap4_mpuss_read_prev_context_state(void) | ||
| 147 | { | ||
| 148 | u32 reg; | ||
| 149 | |||
| 150 | reg = omap4_prminst_read_inst_reg(OMAP4430_PRM_PARTITION, | ||
| 151 | OMAP4430_PRM_MPU_INST, OMAP4_RM_MPU_MPU_CONTEXT_OFFSET); | ||
| 152 | reg &= OMAP4430_LOSTCONTEXT_DFF_MASK; | ||
| 153 | return reg; | ||
| 154 | } | ||
| 155 | |||
| 156 | /* | 142 | /* |
| 157 | * Store the CPU cluster state for L2X0 low power operations. | 143 | * Store the CPU cluster state for L2X0 low power operations. |
| 158 | */ | 144 | */ |
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c index dec553349ae2..e742118fcfd2 100644 --- a/arch/arm/mach-omap2/pm.c +++ b/arch/arm/mach-omap2/pm.c | |||
| @@ -264,6 +264,12 @@ static void __init omap4_init_voltages(void) | |||
| 264 | omap2_set_init_voltage("iva", "dpll_iva_m5x2_ck", "iva"); | 264 | omap2_set_init_voltage("iva", "dpll_iva_m5x2_ck", "iva"); |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | static inline void omap_init_cpufreq(void) | ||
| 268 | { | ||
| 269 | struct platform_device_info devinfo = { .name = "omap-cpufreq", }; | ||
| 270 | platform_device_register_full(&devinfo); | ||
| 271 | } | ||
| 272 | |||
| 267 | static int __init omap2_common_pm_init(void) | 273 | static int __init omap2_common_pm_init(void) |
| 268 | { | 274 | { |
| 269 | if (!of_have_populated_dt()) | 275 | if (!of_have_populated_dt()) |
| @@ -293,6 +299,9 @@ int __init omap2_common_pm_late_init(void) | |||
| 293 | 299 | ||
| 294 | /* Smartreflex device init */ | 300 | /* Smartreflex device init */ |
| 295 | omap_devinit_smartreflex(); | 301 | omap_devinit_smartreflex(); |
| 302 | |||
| 303 | /* cpufreq dummy device instantiation */ | ||
| 304 | omap_init_cpufreq(); | ||
| 296 | } | 305 | } |
| 297 | 306 | ||
| 298 | #ifdef CONFIG_SUSPEND | 307 | #ifdef CONFIG_SUSPEND |
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile index 12c500558387..648867a8caa8 100644 --- a/arch/arm/mach-pxa/Makefile +++ b/arch/arm/mach-pxa/Makefile | |||
| @@ -7,12 +7,6 @@ obj-y += clock.o devices.o generic.o irq.o \ | |||
| 7 | time.o reset.o | 7 | time.o reset.o |
| 8 | obj-$(CONFIG_PM) += pm.o sleep.o standby.o | 8 | obj-$(CONFIG_PM) += pm.o sleep.o standby.o |
| 9 | 9 | ||
| 10 | ifeq ($(CONFIG_CPU_FREQ),y) | ||
| 11 | obj-$(CONFIG_PXA25x) += cpufreq-pxa2xx.o | ||
| 12 | obj-$(CONFIG_PXA27x) += cpufreq-pxa2xx.o | ||
| 13 | obj-$(CONFIG_PXA3xx) += cpufreq-pxa3xx.o | ||
| 14 | endif | ||
| 15 | |||
| 16 | # Generic drivers that other drivers may depend upon | 10 | # Generic drivers that other drivers may depend upon |
| 17 | 11 | ||
| 18 | # SoC-specific code | 12 | # SoC-specific code |
diff --git a/arch/arm/mach-pxa/include/mach/generic.h b/arch/arm/mach-pxa/include/mach/generic.h new file mode 100644 index 000000000000..665542e0c9e2 --- /dev/null +++ b/arch/arm/mach-pxa/include/mach/generic.h | |||
| @@ -0,0 +1 @@ | |||
| #include "../../generic.h" | |||
diff --git a/arch/arm/mach-s3c24xx/cpufreq.c b/arch/arm/mach-s3c24xx/cpufreq.c index 5f181e733eee..3c0e78ede0da 100644 --- a/arch/arm/mach-s3c24xx/cpufreq.c +++ b/arch/arm/mach-s3c24xx/cpufreq.c | |||
| @@ -204,7 +204,6 @@ static int s3c_cpufreq_settarget(struct cpufreq_policy *policy, | |||
| 204 | freqs.old = cpu_cur.freq; | 204 | freqs.old = cpu_cur.freq; |
| 205 | freqs.new = cpu_new.freq; | 205 | freqs.new = cpu_new.freq; |
| 206 | 206 | ||
| 207 | freqs.freqs.cpu = 0; | ||
| 208 | freqs.freqs.old = cpu_cur.freq.armclk / 1000; | 207 | freqs.freqs.old = cpu_cur.freq.armclk / 1000; |
| 209 | freqs.freqs.new = cpu_new.freq.armclk / 1000; | 208 | freqs.freqs.new = cpu_new.freq.armclk / 1000; |
| 210 | 209 | ||
| @@ -218,9 +217,7 @@ static int s3c_cpufreq_settarget(struct cpufreq_policy *policy, | |||
| 218 | s3c_cpufreq_updateclk(clk_pclk, cpu_new.freq.pclk); | 217 | s3c_cpufreq_updateclk(clk_pclk, cpu_new.freq.pclk); |
| 219 | 218 | ||
| 220 | /* start the frequency change */ | 219 | /* start the frequency change */ |
| 221 | 220 | cpufreq_notify_transition(policy, &freqs.freqs, CPUFREQ_PRECHANGE); | |
| 222 | if (policy) | ||
| 223 | cpufreq_notify_transition(&freqs.freqs, CPUFREQ_PRECHANGE); | ||
| 224 | 221 | ||
| 225 | /* If hclk is staying the same, then we do not need to | 222 | /* If hclk is staying the same, then we do not need to |
| 226 | * re-write the IO or the refresh timings whilst we are changing | 223 | * re-write the IO or the refresh timings whilst we are changing |
| @@ -264,8 +261,7 @@ static int s3c_cpufreq_settarget(struct cpufreq_policy *policy, | |||
| 264 | local_irq_restore(flags); | 261 | local_irq_restore(flags); |
| 265 | 262 | ||
| 266 | /* notify everyone we've done this */ | 263 | /* notify everyone we've done this */ |
| 267 | if (policy) | 264 | cpufreq_notify_transition(policy, &freqs.freqs, CPUFREQ_POSTCHANGE); |
| 268 | cpufreq_notify_transition(&freqs.freqs, CPUFREQ_POSTCHANGE); | ||
| 269 | 265 | ||
| 270 | s3c_freq_dbg("%s: finished\n", __func__); | 266 | s3c_freq_dbg("%s: finished\n", __func__); |
| 271 | return 0; | 267 | return 0; |
diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c index ead5fab0dbb5..3c8ab07c2012 100644 --- a/arch/arm/mach-s3c64xx/cpuidle.c +++ b/arch/arm/mach-s3c64xx/cpuidle.c | |||
| @@ -40,12 +40,9 @@ static int s3c64xx_enter_idle(struct cpuidle_device *dev, | |||
| 40 | return index; | 40 | return index; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | static DEFINE_PER_CPU(struct cpuidle_device, s3c64xx_cpuidle_device); | ||
| 44 | |||
| 45 | static struct cpuidle_driver s3c64xx_cpuidle_driver = { | 43 | static struct cpuidle_driver s3c64xx_cpuidle_driver = { |
| 46 | .name = "s3c64xx_cpuidle", | 44 | .name = "s3c64xx_cpuidle", |
| 47 | .owner = THIS_MODULE, | 45 | .owner = THIS_MODULE, |
| 48 | .en_core_tk_irqen = 1, | ||
| 49 | .states = { | 46 | .states = { |
| 50 | { | 47 | { |
| 51 | .enter = s3c64xx_enter_idle, | 48 | .enter = s3c64xx_enter_idle, |
| @@ -61,16 +58,6 @@ static struct cpuidle_driver s3c64xx_cpuidle_driver = { | |||
| 61 | 58 | ||
| 62 | static int __init s3c64xx_init_cpuidle(void) | 59 | static int __init s3c64xx_init_cpuidle(void) |
| 63 | { | 60 | { |
| 64 | int ret; | 61 | return cpuidle_register(&s3c64xx_cpuidle_driver, NULL); |
| 65 | |||
| 66 | cpuidle_register_driver(&s3c64xx_cpuidle_driver); | ||
| 67 | |||
| 68 | ret = cpuidle_register_device(&s3c64xx_cpuidle_device); | ||
| 69 | if (ret) { | ||
| 70 | pr_err("Failed to register cpuidle device: %d\n", ret); | ||
| 71 | return ret; | ||
| 72 | } | ||
| 73 | |||
| 74 | return 0; | ||
| 75 | } | 62 | } |
| 76 | device_initcall(s3c64xx_init_cpuidle); | 63 | device_initcall(s3c64xx_init_cpuidle); |
diff --git a/arch/arm/mach-sa1100/Kconfig b/arch/arm/mach-sa1100/Kconfig index ca14dbdcfb22..04f9784ff0ed 100644 --- a/arch/arm/mach-sa1100/Kconfig +++ b/arch/arm/mach-sa1100/Kconfig | |||
| @@ -4,7 +4,7 @@ menu "SA11x0 Implementations" | |||
| 4 | 4 | ||
| 5 | config SA1100_ASSABET | 5 | config SA1100_ASSABET |
| 6 | bool "Assabet" | 6 | bool "Assabet" |
| 7 | select CPU_FREQ_SA1110 | 7 | select ARM_SA1110_CPUFREQ |
| 8 | help | 8 | help |
| 9 | Say Y here if you are using the Intel(R) StrongARM(R) SA-1110 | 9 | Say Y here if you are using the Intel(R) StrongARM(R) SA-1110 |
| 10 | Microprocessor Development Board (also known as the Assabet). | 10 | Microprocessor Development Board (also known as the Assabet). |
| @@ -20,7 +20,7 @@ config ASSABET_NEPONSET | |||
| 20 | 20 | ||
| 21 | config SA1100_CERF | 21 | config SA1100_CERF |
| 22 | bool "CerfBoard" | 22 | bool "CerfBoard" |
| 23 | select CPU_FREQ_SA1110 | 23 | select ARM_SA1110_CPUFREQ |
| 24 | help | 24 | help |
| 25 | The Intrinsyc CerfBoard is based on the StrongARM 1110 (Discontinued). | 25 | The Intrinsyc CerfBoard is based on the StrongARM 1110 (Discontinued). |
| 26 | More information is available at: | 26 | More information is available at: |
| @@ -47,7 +47,7 @@ endchoice | |||
| 47 | 47 | ||
| 48 | config SA1100_COLLIE | 48 | config SA1100_COLLIE |
| 49 | bool "Sharp Zaurus SL5500" | 49 | bool "Sharp Zaurus SL5500" |
| 50 | # FIXME: select CPU_FREQ_SA11x0 | 50 | # FIXME: select ARM_SA11x0_CPUFREQ |
| 51 | select SHARP_LOCOMO | 51 | select SHARP_LOCOMO |
| 52 | select SHARP_PARAM | 52 | select SHARP_PARAM |
| 53 | select SHARP_SCOOP | 53 | select SHARP_SCOOP |
| @@ -56,7 +56,7 @@ config SA1100_COLLIE | |||
| 56 | 56 | ||
| 57 | config SA1100_H3100 | 57 | config SA1100_H3100 |
| 58 | bool "Compaq iPAQ H3100" | 58 | bool "Compaq iPAQ H3100" |
| 59 | select CPU_FREQ_SA1110 | 59 | select ARM_SA1110_CPUFREQ |
| 60 | select HTC_EGPIO | 60 | select HTC_EGPIO |
| 61 | help | 61 | help |
| 62 | Say Y here if you intend to run this kernel on the Compaq iPAQ | 62 | Say Y here if you intend to run this kernel on the Compaq iPAQ |
| @@ -67,7 +67,7 @@ config SA1100_H3100 | |||
| 67 | 67 | ||
| 68 | config SA1100_H3600 | 68 | config SA1100_H3600 |
| 69 | bool "Compaq iPAQ H3600/H3700" | 69 | bool "Compaq iPAQ H3600/H3700" |
| 70 | select CPU_FREQ_SA1110 | 70 | select ARM_SA1110_CPUFREQ |
| 71 | select HTC_EGPIO | 71 | select HTC_EGPIO |
| 72 | help | 72 | help |
| 73 | Say Y here if you intend to run this kernel on the Compaq iPAQ | 73 | Say Y here if you intend to run this kernel on the Compaq iPAQ |
| @@ -78,7 +78,7 @@ config SA1100_H3600 | |||
| 78 | 78 | ||
| 79 | config SA1100_BADGE4 | 79 | config SA1100_BADGE4 |
| 80 | bool "HP Labs BadgePAD 4" | 80 | bool "HP Labs BadgePAD 4" |
| 81 | select CPU_FREQ_SA1100 | 81 | select ARM_SA1100_CPUFREQ |
| 82 | select SA1111 | 82 | select SA1111 |
| 83 | help | 83 | help |
| 84 | Say Y here if you want to build a kernel for the HP Laboratories | 84 | Say Y here if you want to build a kernel for the HP Laboratories |
| @@ -86,7 +86,7 @@ config SA1100_BADGE4 | |||
| 86 | 86 | ||
| 87 | config SA1100_JORNADA720 | 87 | config SA1100_JORNADA720 |
| 88 | bool "HP Jornada 720" | 88 | bool "HP Jornada 720" |
| 89 | # FIXME: select CPU_FREQ_SA11x0 | 89 | # FIXME: select ARM_SA11x0_CPUFREQ |
| 90 | select SA1111 | 90 | select SA1111 |
| 91 | help | 91 | help |
| 92 | Say Y here if you want to build a kernel for the HP Jornada 720 | 92 | Say Y here if you want to build a kernel for the HP Jornada 720 |
| @@ -105,14 +105,14 @@ config SA1100_JORNADA720_SSP | |||
| 105 | 105 | ||
| 106 | config SA1100_HACKKIT | 106 | config SA1100_HACKKIT |
| 107 | bool "HackKit Core CPU Board" | 107 | bool "HackKit Core CPU Board" |
| 108 | select CPU_FREQ_SA1100 | 108 | select ARM_SA1100_CPUFREQ |
| 109 | help | 109 | help |
| 110 | Say Y here to support the HackKit Core CPU Board | 110 | Say Y here to support the HackKit Core CPU Board |
| 111 | <http://hackkit.eletztrick.de>; | 111 | <http://hackkit.eletztrick.de>; |
| 112 | 112 | ||
| 113 | config SA1100_LART | 113 | config SA1100_LART |
| 114 | bool "LART" | 114 | bool "LART" |
| 115 | select CPU_FREQ_SA1100 | 115 | select ARM_SA1100_CPUFREQ |
| 116 | help | 116 | help |
| 117 | Say Y here if you are using the Linux Advanced Radio Terminal | 117 | Say Y here if you are using the Linux Advanced Radio Terminal |
| 118 | (also known as the LART). See <http://www.lartmaker.nl/> for | 118 | (also known as the LART). See <http://www.lartmaker.nl/> for |
| @@ -120,7 +120,7 @@ config SA1100_LART | |||
| 120 | 120 | ||
| 121 | config SA1100_NANOENGINE | 121 | config SA1100_NANOENGINE |
| 122 | bool "nanoEngine" | 122 | bool "nanoEngine" |
| 123 | select CPU_FREQ_SA1110 | 123 | select ARM_SA1110_CPUFREQ |
| 124 | select PCI | 124 | select PCI |
| 125 | select PCI_NANOENGINE | 125 | select PCI_NANOENGINE |
| 126 | help | 126 | help |
| @@ -130,7 +130,7 @@ config SA1100_NANOENGINE | |||
| 130 | 130 | ||
| 131 | config SA1100_PLEB | 131 | config SA1100_PLEB |
| 132 | bool "PLEB" | 132 | bool "PLEB" |
| 133 | select CPU_FREQ_SA1100 | 133 | select ARM_SA1100_CPUFREQ |
| 134 | help | 134 | help |
| 135 | Say Y here if you are using version 1 of the Portable Linux | 135 | Say Y here if you are using version 1 of the Portable Linux |
| 136 | Embedded Board (also known as PLEB). | 136 | Embedded Board (also known as PLEB). |
| @@ -139,7 +139,7 @@ config SA1100_PLEB | |||
| 139 | 139 | ||
| 140 | config SA1100_SHANNON | 140 | config SA1100_SHANNON |
| 141 | bool "Shannon" | 141 | bool "Shannon" |
| 142 | select CPU_FREQ_SA1100 | 142 | select ARM_SA1100_CPUFREQ |
| 143 | help | 143 | help |
| 144 | The Shannon (also known as a Tuxscreen, and also as a IS2630) was a | 144 | The Shannon (also known as a Tuxscreen, and also as a IS2630) was a |
| 145 | limited edition webphone produced by Philips. The Shannon is a SA1100 | 145 | limited edition webphone produced by Philips. The Shannon is a SA1100 |
| @@ -148,7 +148,7 @@ config SA1100_SHANNON | |||
| 148 | 148 | ||
| 149 | config SA1100_SIMPAD | 149 | config SA1100_SIMPAD |
| 150 | bool "Simpad" | 150 | bool "Simpad" |
| 151 | select CPU_FREQ_SA1110 | 151 | select ARM_SA1110_CPUFREQ |
| 152 | help | 152 | help |
| 153 | The SIEMENS webpad SIMpad is based on the StrongARM 1110. There | 153 | The SIEMENS webpad SIMpad is based on the StrongARM 1110. There |
| 154 | are two different versions CL4 and SL4. CL4 has 32MB RAM and 16MB | 154 | are two different versions CL4 and SL4. CL4 has 32MB RAM and 16MB |
diff --git a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile index 1aed9e70465d..2732eef48966 100644 --- a/arch/arm/mach-sa1100/Makefile +++ b/arch/arm/mach-sa1100/Makefile | |||
| @@ -8,9 +8,6 @@ obj-m := | |||
| 8 | obj-n := | 8 | obj-n := |
| 9 | obj- := | 9 | obj- := |
| 10 | 10 | ||
| 11 | obj-$(CONFIG_CPU_FREQ_SA1100) += cpu-sa1100.o | ||
| 12 | obj-$(CONFIG_CPU_FREQ_SA1110) += cpu-sa1110.o | ||
| 13 | |||
| 14 | # Specific board support | 11 | # Specific board support |
| 15 | obj-$(CONFIG_SA1100_ASSABET) += assabet.o | 12 | obj-$(CONFIG_SA1100_ASSABET) += assabet.o |
| 16 | obj-$(CONFIG_ASSABET_NEPONSET) += neponset.o | 13 | obj-$(CONFIG_ASSABET_NEPONSET) += neponset.o |
diff --git a/arch/arm/mach-sa1100/include/mach/generic.h b/arch/arm/mach-sa1100/include/mach/generic.h new file mode 100644 index 000000000000..665542e0c9e2 --- /dev/null +++ b/arch/arm/mach-sa1100/include/mach/generic.h | |||
| @@ -0,0 +1 @@ | |||
| #include "../../generic.h" | |||
diff --git a/arch/arm/mach-shmobile/cpuidle.c b/arch/arm/mach-shmobile/cpuidle.c index 9e050268cde4..0afeb5c7061c 100644 --- a/arch/arm/mach-shmobile/cpuidle.c +++ b/arch/arm/mach-shmobile/cpuidle.c | |||
| @@ -16,39 +16,22 @@ | |||
| 16 | #include <asm/cpuidle.h> | 16 | #include <asm/cpuidle.h> |
| 17 | #include <asm/io.h> | 17 | #include <asm/io.h> |
| 18 | 18 | ||
| 19 | int shmobile_enter_wfi(struct cpuidle_device *dev, struct cpuidle_driver *drv, | ||
| 20 | int index) | ||
| 21 | { | ||
| 22 | cpu_do_idle(); | ||
| 23 | return 0; | ||
| 24 | } | ||
| 25 | |||
| 26 | static struct cpuidle_device shmobile_cpuidle_dev; | ||
| 27 | static struct cpuidle_driver shmobile_cpuidle_default_driver = { | 19 | static struct cpuidle_driver shmobile_cpuidle_default_driver = { |
| 28 | .name = "shmobile_cpuidle", | 20 | .name = "shmobile_cpuidle", |
| 29 | .owner = THIS_MODULE, | 21 | .owner = THIS_MODULE, |
| 30 | .en_core_tk_irqen = 1, | ||
| 31 | .states[0] = ARM_CPUIDLE_WFI_STATE, | 22 | .states[0] = ARM_CPUIDLE_WFI_STATE, |
| 32 | .states[0].enter = shmobile_enter_wfi, | ||
| 33 | .safe_state_index = 0, /* C1 */ | 23 | .safe_state_index = 0, /* C1 */ |
| 34 | .state_count = 1, | 24 | .state_count = 1, |
| 35 | }; | 25 | }; |
| 36 | 26 | ||
| 37 | static struct cpuidle_driver *cpuidle_drv = &shmobile_cpuidle_default_driver; | 27 | static struct cpuidle_driver *cpuidle_drv = &shmobile_cpuidle_default_driver; |
| 38 | 28 | ||
| 39 | void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv) | 29 | void __init shmobile_cpuidle_set_driver(struct cpuidle_driver *drv) |
| 40 | { | 30 | { |
| 41 | cpuidle_drv = drv; | 31 | cpuidle_drv = drv; |
| 42 | } | 32 | } |
| 43 | 33 | ||
| 44 | int shmobile_cpuidle_init(void) | 34 | int __init shmobile_cpuidle_init(void) |
| 45 | { | 35 | { |
| 46 | struct cpuidle_device *dev = &shmobile_cpuidle_dev; | 36 | return cpuidle_register(cpuidle_drv, NULL); |
| 47 | |||
| 48 | cpuidle_register_driver(cpuidle_drv); | ||
| 49 | |||
| 50 | dev->state_count = cpuidle_drv->state_count; | ||
| 51 | cpuidle_register_device(dev); | ||
| 52 | |||
| 53 | return 0; | ||
| 54 | } | 37 | } |
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h index e48606d8a2be..362f9b2d2c02 100644 --- a/arch/arm/mach-shmobile/include/mach/common.h +++ b/arch/arm/mach-shmobile/include/mach/common.h | |||
| @@ -13,9 +13,6 @@ extern int shmobile_clk_init(void); | |||
| 13 | extern void shmobile_handle_irq_intc(struct pt_regs *); | 13 | extern void shmobile_handle_irq_intc(struct pt_regs *); |
| 14 | extern struct platform_suspend_ops shmobile_suspend_ops; | 14 | extern struct platform_suspend_ops shmobile_suspend_ops; |
| 15 | struct cpuidle_driver; | 15 | struct cpuidle_driver; |
| 16 | struct cpuidle_device; | ||
| 17 | extern int shmobile_enter_wfi(struct cpuidle_device *dev, | ||
| 18 | struct cpuidle_driver *drv, int index); | ||
| 19 | extern void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv); | 16 | extern void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv); |
| 20 | 17 | ||
| 21 | extern void sh7372_init_irq(void); | 18 | extern void sh7372_init_irq(void); |
diff --git a/arch/arm/mach-shmobile/pm-sh7372.c b/arch/arm/mach-shmobile/pm-sh7372.c index a0826a48dd08..dec9293bb90d 100644 --- a/arch/arm/mach-shmobile/pm-sh7372.c +++ b/arch/arm/mach-shmobile/pm-sh7372.c | |||
| @@ -410,11 +410,9 @@ static int sh7372_enter_a4s(struct cpuidle_device *dev, | |||
| 410 | static struct cpuidle_driver sh7372_cpuidle_driver = { | 410 | static struct cpuidle_driver sh7372_cpuidle_driver = { |
| 411 | .name = "sh7372_cpuidle", | 411 | .name = "sh7372_cpuidle", |
| 412 | .owner = THIS_MODULE, | 412 | .owner = THIS_MODULE, |
| 413 | .en_core_tk_irqen = 1, | ||
| 414 | .state_count = 5, | 413 | .state_count = 5, |
| 415 | .safe_state_index = 0, /* C1 */ | 414 | .safe_state_index = 0, /* C1 */ |
| 416 | .states[0] = ARM_CPUIDLE_WFI_STATE, | 415 | .states[0] = ARM_CPUIDLE_WFI_STATE, |
| 417 | .states[0].enter = shmobile_enter_wfi, | ||
| 418 | .states[1] = { | 416 | .states[1] = { |
| 419 | .name = "C2", | 417 | .name = "C2", |
| 420 | .desc = "Core Standby Mode", | 418 | .desc = "Core Standby Mode", |
| @@ -450,12 +448,12 @@ static struct cpuidle_driver sh7372_cpuidle_driver = { | |||
| 450 | }, | 448 | }, |
| 451 | }; | 449 | }; |
| 452 | 450 | ||
| 453 | static void sh7372_cpuidle_init(void) | 451 | static void __init sh7372_cpuidle_init(void) |
| 454 | { | 452 | { |
| 455 | shmobile_cpuidle_set_driver(&sh7372_cpuidle_driver); | 453 | shmobile_cpuidle_set_driver(&sh7372_cpuidle_driver); |
| 456 | } | 454 | } |
| 457 | #else | 455 | #else |
| 458 | static void sh7372_cpuidle_init(void) {} | 456 | static void __init sh7372_cpuidle_init(void) {} |
| 459 | #endif | 457 | #endif |
| 460 | 458 | ||
| 461 | #ifdef CONFIG_SUSPEND | 459 | #ifdef CONFIG_SUSPEND |
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile index f6b46ae2b7f8..09b578f9eb84 100644 --- a/arch/arm/mach-tegra/Makefile +++ b/arch/arm/mach-tegra/Makefile | |||
| @@ -24,7 +24,6 @@ obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += cpuidle-tegra30.o | |||
| 24 | endif | 24 | endif |
| 25 | obj-$(CONFIG_SMP) += platsmp.o headsmp.o | 25 | obj-$(CONFIG_SMP) += platsmp.o headsmp.o |
| 26 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o | 26 | obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o |
| 27 | obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o | ||
| 28 | obj-$(CONFIG_TEGRA_PCI) += pcie.o | 27 | obj-$(CONFIG_TEGRA_PCI) += pcie.o |
| 29 | 28 | ||
| 30 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-dt-tegra20.o | 29 | obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += board-dt-tegra20.o |
diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c index 0f4e8c483b34..1d1c6023f4a2 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra114.c +++ b/arch/arm/mach-tegra/cpuidle-tegra114.c | |||
| @@ -23,39 +23,13 @@ | |||
| 23 | static struct cpuidle_driver tegra_idle_driver = { | 23 | static struct cpuidle_driver tegra_idle_driver = { |
| 24 | .name = "tegra_idle", | 24 | .name = "tegra_idle", |
| 25 | .owner = THIS_MODULE, | 25 | .owner = THIS_MODULE, |
| 26 | .en_core_tk_irqen = 1, | ||
| 27 | .state_count = 1, | 26 | .state_count = 1, |
| 28 | .states = { | 27 | .states = { |
| 29 | [0] = ARM_CPUIDLE_WFI_STATE_PWR(600), | 28 | [0] = ARM_CPUIDLE_WFI_STATE_PWR(600), |
| 30 | }, | 29 | }, |
| 31 | }; | 30 | }; |
| 32 | 31 | ||
| 33 | static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device); | ||
| 34 | |||
| 35 | int __init tegra114_cpuidle_init(void) | 32 | int __init tegra114_cpuidle_init(void) |
| 36 | { | 33 | { |
| 37 | int ret; | 34 | return cpuidle_register(&tegra_idle_driver, NULL); |
| 38 | unsigned int cpu; | ||
| 39 | struct cpuidle_device *dev; | ||
| 40 | struct cpuidle_driver *drv = &tegra_idle_driver; | ||
| 41 | |||
| 42 | ret = cpuidle_register_driver(&tegra_idle_driver); | ||
| 43 | if (ret) { | ||
| 44 | pr_err("CPUidle driver registration failed\n"); | ||
| 45 | return ret; | ||
| 46 | } | ||
| 47 | |||
| 48 | for_each_possible_cpu(cpu) { | ||
| 49 | dev = &per_cpu(tegra_idle_device, cpu); | ||
| 50 | dev->cpu = cpu; | ||
| 51 | |||
| 52 | dev->state_count = drv->state_count; | ||
| 53 | ret = cpuidle_register_device(dev); | ||
| 54 | if (ret) { | ||
| 55 | pr_err("CPU%u: CPUidle device registration failed\n", | ||
| 56 | cpu); | ||
| 57 | return ret; | ||
| 58 | } | ||
| 59 | } | ||
| 60 | return 0; | ||
| 61 | } | 35 | } |
diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c index 825ced4f7a40..590ec25855dd 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c | |||
| @@ -43,32 +43,33 @@ static atomic_t abort_barrier; | |||
| 43 | static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev, | 43 | static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev, |
| 44 | struct cpuidle_driver *drv, | 44 | struct cpuidle_driver *drv, |
| 45 | int index); | 45 | int index); |
| 46 | #define TEGRA20_MAX_STATES 2 | ||
| 47 | #else | ||
| 48 | #define TEGRA20_MAX_STATES 1 | ||
| 46 | #endif | 49 | #endif |
| 47 | 50 | ||
| 48 | static struct cpuidle_state tegra_idle_states[] = { | ||
| 49 | [0] = ARM_CPUIDLE_WFI_STATE_PWR(600), | ||
| 50 | #ifdef CONFIG_PM_SLEEP | ||
| 51 | [1] = { | ||
| 52 | .enter = tegra20_idle_lp2_coupled, | ||
| 53 | .exit_latency = 5000, | ||
| 54 | .target_residency = 10000, | ||
| 55 | .power_usage = 0, | ||
| 56 | .flags = CPUIDLE_FLAG_TIME_VALID | | ||
| 57 | CPUIDLE_FLAG_COUPLED, | ||
| 58 | .name = "powered-down", | ||
| 59 | .desc = "CPU power gated", | ||
| 60 | }, | ||
| 61 | #endif | ||
| 62 | }; | ||
| 63 | |||
| 64 | static struct cpuidle_driver tegra_idle_driver = { | 51 | static struct cpuidle_driver tegra_idle_driver = { |
| 65 | .name = "tegra_idle", | 52 | .name = "tegra_idle", |
| 66 | .owner = THIS_MODULE, | 53 | .owner = THIS_MODULE, |
| 67 | .en_core_tk_irqen = 1, | 54 | .states = { |
| 55 | ARM_CPUIDLE_WFI_STATE_PWR(600), | ||
| 56 | #ifdef CONFIG_PM_SLEEP | ||
| 57 | { | ||
| 58 | .enter = tegra20_idle_lp2_coupled, | ||
| 59 | .exit_latency = 5000, | ||
| 60 | .target_residency = 10000, | ||
| 61 | .power_usage = 0, | ||
| 62 | .flags = CPUIDLE_FLAG_TIME_VALID | | ||
| 63 | CPUIDLE_FLAG_COUPLED, | ||
| 64 | .name = "powered-down", | ||
| 65 | .desc = "CPU power gated", | ||
| 66 | }, | ||
| 67 | #endif | ||
| 68 | }, | ||
| 69 | .state_count = TEGRA20_MAX_STATES, | ||
| 70 | .safe_state_index = 0, | ||
| 68 | }; | 71 | }; |
| 69 | 72 | ||
| 70 | static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device); | ||
| 71 | |||
| 72 | #ifdef CONFIG_PM_SLEEP | 73 | #ifdef CONFIG_PM_SLEEP |
| 73 | #ifdef CONFIG_SMP | 74 | #ifdef CONFIG_SMP |
| 74 | static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); | 75 | static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); |
| @@ -217,39 +218,8 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev, | |||
| 217 | 218 | ||
| 218 | int __init tegra20_cpuidle_init(void) | 219 | int __init tegra20_cpuidle_init(void) |
| 219 | { | 220 | { |
| 220 | int ret; | ||
| 221 | unsigned int cpu; | ||
| 222 | struct cpuidle_device *dev; | ||
| 223 | struct cpuidle_driver *drv = &tegra_idle_driver; | ||
| 224 | |||
| 225 | #ifdef CONFIG_PM_SLEEP | 221 | #ifdef CONFIG_PM_SLEEP |
| 226 | tegra_tear_down_cpu = tegra20_tear_down_cpu; | 222 | tegra_tear_down_cpu = tegra20_tear_down_cpu; |
| 227 | #endif | 223 | #endif |
| 228 | 224 | return cpuidle_register(&tegra_idle_driver, cpu_possible_mask); | |
| 229 | drv->state_count = ARRAY_SIZE(tegra_idle_states); | ||
| 230 | memcpy(drv->states, tegra_idle_states, | ||
| 231 | drv->state_count * sizeof(drv->states[0])); | ||
| 232 | |||
| 233 | ret = cpuidle_register_driver(&tegra_idle_driver); | ||
| 234 | if (ret) { | ||
| 235 | pr_err("CPUidle driver registration failed\n"); | ||
| 236 | return ret; | ||
| 237 | } | ||
| 238 | |||
| 239 | for_each_possible_cpu(cpu) { | ||
| 240 | dev = &per_cpu(tegra_idle_device, cpu); | ||
| 241 | dev->cpu = cpu; | ||
| 242 | #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED | ||
| 243 | dev->coupled_cpus = *cpu_possible_mask; | ||
| 244 | #endif | ||
| 245 | |||
| 246 | dev->state_count = drv->state_count; | ||
| 247 | ret = cpuidle_register_device(dev); | ||
| 248 | if (ret) { | ||
| 249 | pr_err("CPU%u: CPUidle device registration failed\n", | ||
| 250 | cpu); | ||
| 251 | return ret; | ||
| 252 | } | ||
| 253 | } | ||
| 254 | return 0; | ||
| 255 | } | 225 | } |
diff --git a/arch/arm/mach-tegra/cpuidle-tegra30.c b/arch/arm/mach-tegra/cpuidle-tegra30.c index 8b50cf4ddd6f..36dc2befa9d8 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra30.c +++ b/arch/arm/mach-tegra/cpuidle-tegra30.c | |||
| @@ -43,7 +43,6 @@ static int tegra30_idle_lp2(struct cpuidle_device *dev, | |||
| 43 | static struct cpuidle_driver tegra_idle_driver = { | 43 | static struct cpuidle_driver tegra_idle_driver = { |
| 44 | .name = "tegra_idle", | 44 | .name = "tegra_idle", |
| 45 | .owner = THIS_MODULE, | 45 | .owner = THIS_MODULE, |
| 46 | .en_core_tk_irqen = 1, | ||
| 47 | #ifdef CONFIG_PM_SLEEP | 46 | #ifdef CONFIG_PM_SLEEP |
| 48 | .state_count = 2, | 47 | .state_count = 2, |
| 49 | #else | 48 | #else |
| @@ -65,8 +64,6 @@ static struct cpuidle_driver tegra_idle_driver = { | |||
| 65 | }, | 64 | }, |
| 66 | }; | 65 | }; |
| 67 | 66 | ||
| 68 | static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device); | ||
| 69 | |||
| 70 | #ifdef CONFIG_PM_SLEEP | 67 | #ifdef CONFIG_PM_SLEEP |
| 71 | static bool tegra30_cpu_cluster_power_down(struct cpuidle_device *dev, | 68 | static bool tegra30_cpu_cluster_power_down(struct cpuidle_device *dev, |
| 72 | struct cpuidle_driver *drv, | 69 | struct cpuidle_driver *drv, |
| @@ -157,32 +154,8 @@ static int tegra30_idle_lp2(struct cpuidle_device *dev, | |||
| 157 | 154 | ||
| 158 | int __init tegra30_cpuidle_init(void) | 155 | int __init tegra30_cpuidle_init(void) |
| 159 | { | 156 | { |
| 160 | int ret; | ||
| 161 | unsigned int cpu; | ||
| 162 | struct cpuidle_device *dev; | ||
| 163 | struct cpuidle_driver *drv = &tegra_idle_driver; | ||
| 164 | |||
| 165 | #ifdef CONFIG_PM_SLEEP | 157 | #ifdef CONFIG_PM_SLEEP |
| 166 | tegra_tear_down_cpu = tegra30_tear_down_cpu; | 158 | tegra_tear_down_cpu = tegra30_tear_down_cpu; |
| 167 | #endif | 159 | #endif |
| 168 | 160 | return cpuidle_register(&tegra_idle_driver, NULL); | |
| 169 | ret = cpuidle_register_driver(&tegra_idle_driver); | ||
| 170 | if (ret) { | ||
| 171 | pr_err("CPUidle driver registration failed\n"); | ||
| 172 | return ret; | ||
| 173 | } | ||
| 174 | |||
| 175 | for_each_possible_cpu(cpu) { | ||
| 176 | dev = &per_cpu(tegra_idle_device, cpu); | ||
| 177 | dev->cpu = cpu; | ||
| 178 | |||
| 179 | dev->state_count = drv->state_count; | ||
| 180 | ret = cpuidle_register_device(dev); | ||
| 181 | if (ret) { | ||
| 182 | pr_err("CPU%u: CPUidle device registration failed\n", | ||
| 183 | cpu); | ||
| 184 | return ret; | ||
| 185 | } | ||
| 186 | } | ||
| 187 | return 0; | ||
| 188 | } | 161 | } |
diff --git a/arch/arm/mach-ux500/cpuidle.c b/arch/arm/mach-ux500/cpuidle.c index ce9149302cc3..488e07472d98 100644 --- a/arch/arm/mach-ux500/cpuidle.c +++ b/arch/arm/mach-ux500/cpuidle.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | 11 | ||
| 12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
| 13 | #include <linux/cpuidle.h> | 13 | #include <linux/cpuidle.h> |
| 14 | #include <linux/clockchips.h> | ||
| 15 | #include <linux/spinlock.h> | 14 | #include <linux/spinlock.h> |
| 16 | #include <linux/atomic.h> | 15 | #include <linux/atomic.h> |
| 17 | #include <linux/smp.h> | 16 | #include <linux/smp.h> |
| @@ -22,7 +21,6 @@ | |||
| 22 | 21 | ||
| 23 | static atomic_t master = ATOMIC_INIT(0); | 22 | static atomic_t master = ATOMIC_INIT(0); |
| 24 | static DEFINE_SPINLOCK(master_lock); | 23 | static DEFINE_SPINLOCK(master_lock); |
| 25 | static DEFINE_PER_CPU(struct cpuidle_device, ux500_cpuidle_device); | ||
| 26 | 24 | ||
| 27 | static inline int ux500_enter_idle(struct cpuidle_device *dev, | 25 | static inline int ux500_enter_idle(struct cpuidle_device *dev, |
| 28 | struct cpuidle_driver *drv, int index) | 26 | struct cpuidle_driver *drv, int index) |
| @@ -30,8 +28,6 @@ static inline int ux500_enter_idle(struct cpuidle_device *dev, | |||
| 30 | int this_cpu = smp_processor_id(); | 28 | int this_cpu = smp_processor_id(); |
| 31 | bool recouple = false; | 29 | bool recouple = false; |
| 32 | 30 | ||
| 33 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &this_cpu); | ||
| 34 | |||
| 35 | if (atomic_inc_return(&master) == num_online_cpus()) { | 31 | if (atomic_inc_return(&master) == num_online_cpus()) { |
| 36 | 32 | ||
| 37 | /* With this lock, we prevent the other cpu to exit and enter | 33 | /* With this lock, we prevent the other cpu to exit and enter |
| @@ -91,22 +87,20 @@ out: | |||
| 91 | spin_unlock(&master_lock); | 87 | spin_unlock(&master_lock); |
| 92 | } | 88 | } |
| 93 | 89 | ||
| 94 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &this_cpu); | ||
| 95 | |||
| 96 | return index; | 90 | return index; |
| 97 | } | 91 | } |
| 98 | 92 | ||
| 99 | static struct cpuidle_driver ux500_idle_driver = { | 93 | static struct cpuidle_driver ux500_idle_driver = { |
| 100 | .name = "ux500_idle", | 94 | .name = "ux500_idle", |
| 101 | .owner = THIS_MODULE, | 95 | .owner = THIS_MODULE, |
| 102 | .en_core_tk_irqen = 1, | ||
| 103 | .states = { | 96 | .states = { |
| 104 | ARM_CPUIDLE_WFI_STATE, | 97 | ARM_CPUIDLE_WFI_STATE, |
| 105 | { | 98 | { |
| 106 | .enter = ux500_enter_idle, | 99 | .enter = ux500_enter_idle, |
| 107 | .exit_latency = 70, | 100 | .exit_latency = 70, |
| 108 | .target_residency = 260, | 101 | .target_residency = 260, |
| 109 | .flags = CPUIDLE_FLAG_TIME_VALID, | 102 | .flags = CPUIDLE_FLAG_TIME_VALID | |
| 103 | CPUIDLE_FLAG_TIMER_STOP, | ||
| 110 | .name = "ApIdle", | 104 | .name = "ApIdle", |
| 111 | .desc = "ARM Retention", | 105 | .desc = "ARM Retention", |
| 112 | }, | 106 | }, |
| @@ -115,59 +109,13 @@ static struct cpuidle_driver ux500_idle_driver = { | |||
| 115 | .state_count = 2, | 109 | .state_count = 2, |
| 116 | }; | 110 | }; |
| 117 | 111 | ||
| 118 | /* | ||
| 119 | * For each cpu, setup the broadcast timer because we will | ||
| 120 | * need to migrate the timers for the states >= ApIdle. | ||
| 121 | */ | ||
| 122 | static void ux500_setup_broadcast_timer(void *arg) | ||
| 123 | { | ||
| 124 | int cpu = smp_processor_id(); | ||
| 125 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ON, &cpu); | ||
| 126 | } | ||
| 127 | |||
| 128 | int __init ux500_idle_init(void) | 112 | int __init ux500_idle_init(void) |
| 129 | { | 113 | { |
| 130 | int ret, cpu; | ||
| 131 | struct cpuidle_device *device; | ||
| 132 | |||
| 133 | /* Configure wake up reasons */ | 114 | /* Configure wake up reasons */ |
| 134 | prcmu_enable_wakeups(PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) | | 115 | prcmu_enable_wakeups(PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) | |
| 135 | PRCMU_WAKEUP(ABB)); | 116 | PRCMU_WAKEUP(ABB)); |
| 136 | 117 | ||
| 137 | /* | 118 | return cpuidle_register(&ux500_idle_driver, NULL); |
| 138 | * Configure the timer broadcast for each cpu, that must | ||
| 139 | * be done from the cpu context, so we use a smp cross | ||
| 140 | * call with 'on_each_cpu'. | ||
| 141 | */ | ||
| 142 | on_each_cpu(ux500_setup_broadcast_timer, NULL, 1); | ||
| 143 | |||
| 144 | ret = cpuidle_register_driver(&ux500_idle_driver); | ||
| 145 | if (ret) { | ||
| 146 | printk(KERN_ERR "failed to register ux500 idle driver\n"); | ||
| 147 | return ret; | ||
| 148 | } | ||
| 149 | |||
| 150 | for_each_online_cpu(cpu) { | ||
| 151 | device = &per_cpu(ux500_cpuidle_device, cpu); | ||
| 152 | device->cpu = cpu; | ||
| 153 | ret = cpuidle_register_device(device); | ||
| 154 | if (ret) { | ||
| 155 | printk(KERN_ERR "Failed to register cpuidle " | ||
| 156 | "device for cpu%d\n", cpu); | ||
| 157 | goto out_unregister; | ||
| 158 | } | ||
| 159 | } | ||
| 160 | out: | ||
| 161 | return ret; | ||
| 162 | |||
| 163 | out_unregister: | ||
| 164 | for_each_online_cpu(cpu) { | ||
| 165 | device = &per_cpu(ux500_cpuidle_device, cpu); | ||
| 166 | cpuidle_unregister_device(device); | ||
| 167 | } | ||
| 168 | |||
| 169 | cpuidle_unregister_driver(&ux500_idle_driver); | ||
| 170 | goto out; | ||
| 171 | } | 119 | } |
| 172 | 120 | ||
| 173 | device_initcall(ux500_idle_init); | 121 | device_initcall(ux500_idle_init); |
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig index c1a868d398bd..22c40308360b 100644 --- a/arch/avr32/Kconfig +++ b/arch/avr32/Kconfig | |||
| @@ -250,20 +250,7 @@ config ARCH_SUSPEND_POSSIBLE | |||
| 250 | def_bool y | 250 | def_bool y |
| 251 | 251 | ||
| 252 | menu "CPU Frequency scaling" | 252 | menu "CPU Frequency scaling" |
| 253 | |||
| 254 | source "drivers/cpufreq/Kconfig" | 253 | source "drivers/cpufreq/Kconfig" |
| 255 | |||
| 256 | config CPU_FREQ_AT32AP | ||
| 257 | bool "CPU frequency driver for AT32AP" | ||
| 258 | depends on CPU_FREQ && PLATFORM_AT32AP | ||
| 259 | default n | ||
| 260 | help | ||
| 261 | This enables the CPU frequency driver for AT32AP processors. | ||
| 262 | |||
| 263 | For details, take a look in <file:Documentation/cpu-freq>. | ||
| 264 | |||
| 265 | If in doubt, say N. | ||
| 266 | |||
| 267 | endmenu | 254 | endmenu |
| 268 | 255 | ||
| 269 | endmenu | 256 | endmenu |
diff --git a/arch/avr32/configs/atngw100_defconfig b/arch/avr32/configs/atngw100_defconfig index f4025db184ff..d5aff36ade92 100644 --- a/arch/avr32/configs/atngw100_defconfig +++ b/arch/avr32/configs/atngw100_defconfig | |||
| @@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y | |||
| 26 | # CONFIG_CPU_FREQ_STAT is not set | 26 | # CONFIG_CPU_FREQ_STAT is not set |
| 27 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 27 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 28 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 28 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 29 | CONFIG_CPU_FREQ_AT32AP=y | 29 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 30 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y | 30 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y |
| 31 | CONFIG_NET=y | 31 | CONFIG_NET=y |
| 32 | CONFIG_PACKET=y | 32 | CONFIG_PACKET=y |
diff --git a/arch/avr32/configs/atngw100_evklcd100_defconfig b/arch/avr32/configs/atngw100_evklcd100_defconfig index c76a49b9e9d0..4abcf435d599 100644 --- a/arch/avr32/configs/atngw100_evklcd100_defconfig +++ b/arch/avr32/configs/atngw100_evklcd100_defconfig | |||
| @@ -28,7 +28,7 @@ CONFIG_CPU_FREQ=y | |||
| 28 | # CONFIG_CPU_FREQ_STAT is not set | 28 | # CONFIG_CPU_FREQ_STAT is not set |
| 29 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 29 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 30 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 30 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 31 | CONFIG_CPU_FREQ_AT32AP=y | 31 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 32 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y | 32 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y |
| 33 | CONFIG_NET=y | 33 | CONFIG_NET=y |
| 34 | CONFIG_PACKET=y | 34 | CONFIG_PACKET=y |
diff --git a/arch/avr32/configs/atngw100_evklcd101_defconfig b/arch/avr32/configs/atngw100_evklcd101_defconfig index 2d8ab089a64e..18f3fa0470ff 100644 --- a/arch/avr32/configs/atngw100_evklcd101_defconfig +++ b/arch/avr32/configs/atngw100_evklcd101_defconfig | |||
| @@ -27,7 +27,7 @@ CONFIG_CPU_FREQ=y | |||
| 27 | # CONFIG_CPU_FREQ_STAT is not set | 27 | # CONFIG_CPU_FREQ_STAT is not set |
| 28 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 28 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 29 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 29 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 30 | CONFIG_CPU_FREQ_AT32AP=y | 30 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 31 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y | 31 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y |
| 32 | CONFIG_NET=y | 32 | CONFIG_NET=y |
| 33 | CONFIG_PACKET=y | 33 | CONFIG_PACKET=y |
diff --git a/arch/avr32/configs/atngw100_mrmt_defconfig b/arch/avr32/configs/atngw100_mrmt_defconfig index b189e0cab04b..06e389cfcd12 100644 --- a/arch/avr32/configs/atngw100_mrmt_defconfig +++ b/arch/avr32/configs/atngw100_mrmt_defconfig | |||
| @@ -23,7 +23,7 @@ CONFIG_CPU_FREQ=y | |||
| 23 | CONFIG_CPU_FREQ_GOV_POWERSAVE=y | 23 | CONFIG_CPU_FREQ_GOV_POWERSAVE=y |
| 24 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 24 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 25 | CONFIG_CPU_FREQ_GOV_ONDEMAND=y | 25 | CONFIG_CPU_FREQ_GOV_ONDEMAND=y |
| 26 | CONFIG_CPU_FREQ_AT32AP=y | 26 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 27 | CONFIG_NET=y | 27 | CONFIG_NET=y |
| 28 | CONFIG_PACKET=y | 28 | CONFIG_PACKET=y |
| 29 | CONFIG_UNIX=y | 29 | CONFIG_UNIX=y |
diff --git a/arch/avr32/configs/atngw100mkii_defconfig b/arch/avr32/configs/atngw100mkii_defconfig index 2e4de42a53c4..2518a1368d7c 100644 --- a/arch/avr32/configs/atngw100mkii_defconfig +++ b/arch/avr32/configs/atngw100mkii_defconfig | |||
| @@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y | |||
| 26 | # CONFIG_CPU_FREQ_STAT is not set | 26 | # CONFIG_CPU_FREQ_STAT is not set |
| 27 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 27 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 28 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 28 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 29 | CONFIG_CPU_FREQ_AT32AP=y | 29 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 30 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y | 30 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y |
| 31 | CONFIG_NET=y | 31 | CONFIG_NET=y |
| 32 | CONFIG_PACKET=y | 32 | CONFIG_PACKET=y |
diff --git a/arch/avr32/configs/atngw100mkii_evklcd100_defconfig b/arch/avr32/configs/atngw100mkii_evklcd100_defconfig index fad3cd22dfd3..245ef6bd0fa6 100644 --- a/arch/avr32/configs/atngw100mkii_evklcd100_defconfig +++ b/arch/avr32/configs/atngw100mkii_evklcd100_defconfig | |||
| @@ -29,7 +29,7 @@ CONFIG_CPU_FREQ=y | |||
| 29 | # CONFIG_CPU_FREQ_STAT is not set | 29 | # CONFIG_CPU_FREQ_STAT is not set |
| 30 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 30 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 31 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 31 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 32 | CONFIG_CPU_FREQ_AT32AP=y | 32 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 33 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y | 33 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y |
| 34 | CONFIG_NET=y | 34 | CONFIG_NET=y |
| 35 | CONFIG_PACKET=y | 35 | CONFIG_PACKET=y |
diff --git a/arch/avr32/configs/atngw100mkii_evklcd101_defconfig b/arch/avr32/configs/atngw100mkii_evklcd101_defconfig index 29986230aaa5..fa6cbac6e418 100644 --- a/arch/avr32/configs/atngw100mkii_evklcd101_defconfig +++ b/arch/avr32/configs/atngw100mkii_evklcd101_defconfig | |||
| @@ -28,7 +28,7 @@ CONFIG_CPU_FREQ=y | |||
| 28 | # CONFIG_CPU_FREQ_STAT is not set | 28 | # CONFIG_CPU_FREQ_STAT is not set |
| 29 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 29 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 30 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 30 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 31 | CONFIG_CPU_FREQ_AT32AP=y | 31 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 32 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y | 32 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y |
| 33 | CONFIG_NET=y | 33 | CONFIG_NET=y |
| 34 | CONFIG_PACKET=y | 34 | CONFIG_PACKET=y |
diff --git a/arch/avr32/configs/atstk1002_defconfig b/arch/avr32/configs/atstk1002_defconfig index a582465e1cef..bbd5131021a5 100644 --- a/arch/avr32/configs/atstk1002_defconfig +++ b/arch/avr32/configs/atstk1002_defconfig | |||
| @@ -25,7 +25,7 @@ CONFIG_CPU_FREQ=y | |||
| 25 | # CONFIG_CPU_FREQ_STAT is not set | 25 | # CONFIG_CPU_FREQ_STAT is not set |
| 26 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 26 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 27 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 27 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 28 | CONFIG_CPU_FREQ_AT32AP=y | 28 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 29 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y | 29 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y |
| 30 | CONFIG_NET=y | 30 | CONFIG_NET=y |
| 31 | CONFIG_PACKET=y | 31 | CONFIG_PACKET=y |
diff --git a/arch/avr32/configs/atstk1003_defconfig b/arch/avr32/configs/atstk1003_defconfig index 57a79df2ce5d..c1cd726f9012 100644 --- a/arch/avr32/configs/atstk1003_defconfig +++ b/arch/avr32/configs/atstk1003_defconfig | |||
| @@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y | |||
| 26 | # CONFIG_CPU_FREQ_STAT is not set | 26 | # CONFIG_CPU_FREQ_STAT is not set |
| 27 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 27 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 28 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 28 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 29 | CONFIG_CPU_FREQ_AT32AP=y | 29 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 30 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y | 30 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y |
| 31 | CONFIG_NET=y | 31 | CONFIG_NET=y |
| 32 | CONFIG_PACKET=y | 32 | CONFIG_PACKET=y |
diff --git a/arch/avr32/configs/atstk1004_defconfig b/arch/avr32/configs/atstk1004_defconfig index 1a49bd8c6340..754ae56b2767 100644 --- a/arch/avr32/configs/atstk1004_defconfig +++ b/arch/avr32/configs/atstk1004_defconfig | |||
| @@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y | |||
| 26 | # CONFIG_CPU_FREQ_STAT is not set | 26 | # CONFIG_CPU_FREQ_STAT is not set |
| 27 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 27 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 28 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 28 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 29 | CONFIG_CPU_FREQ_AT32AP=y | 29 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 30 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y | 30 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y |
| 31 | CONFIG_NET=y | 31 | CONFIG_NET=y |
| 32 | CONFIG_PACKET=y | 32 | CONFIG_PACKET=y |
diff --git a/arch/avr32/configs/atstk1006_defconfig b/arch/avr32/configs/atstk1006_defconfig index 206a1b67f763..58589d8cc0ac 100644 --- a/arch/avr32/configs/atstk1006_defconfig +++ b/arch/avr32/configs/atstk1006_defconfig | |||
| @@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y | |||
| 26 | # CONFIG_CPU_FREQ_STAT is not set | 26 | # CONFIG_CPU_FREQ_STAT is not set |
| 27 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 27 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 28 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 28 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 29 | CONFIG_CPU_FREQ_AT32AP=y | 29 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 30 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y | 30 | CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y |
| 31 | CONFIG_NET=y | 31 | CONFIG_NET=y |
| 32 | CONFIG_PACKET=y | 32 | CONFIG_PACKET=y |
diff --git a/arch/avr32/configs/favr-32_defconfig b/arch/avr32/configs/favr-32_defconfig index 0421498d666b..57788a42ff83 100644 --- a/arch/avr32/configs/favr-32_defconfig +++ b/arch/avr32/configs/favr-32_defconfig | |||
| @@ -27,7 +27,7 @@ CONFIG_CPU_FREQ=y | |||
| 27 | # CONFIG_CPU_FREQ_STAT is not set | 27 | # CONFIG_CPU_FREQ_STAT is not set |
| 28 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 28 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 29 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 29 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 30 | CONFIG_CPU_FREQ_AT32AP=y | 30 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 31 | CONFIG_NET=y | 31 | CONFIG_NET=y |
| 32 | CONFIG_PACKET=y | 32 | CONFIG_PACKET=y |
| 33 | CONFIG_UNIX=y | 33 | CONFIG_UNIX=y |
diff --git a/arch/avr32/configs/hammerhead_defconfig b/arch/avr32/configs/hammerhead_defconfig index 82f24eb251bd..ba7c31e269cb 100644 --- a/arch/avr32/configs/hammerhead_defconfig +++ b/arch/avr32/configs/hammerhead_defconfig | |||
| @@ -31,7 +31,7 @@ CONFIG_CPU_FREQ=y | |||
| 31 | # CONFIG_CPU_FREQ_STAT is not set | 31 | # CONFIG_CPU_FREQ_STAT is not set |
| 32 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 32 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 33 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 33 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 34 | CONFIG_CPU_FREQ_AT32AP=y | 34 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 35 | CONFIG_NET=y | 35 | CONFIG_NET=y |
| 36 | CONFIG_PACKET=y | 36 | CONFIG_PACKET=y |
| 37 | CONFIG_UNIX=y | 37 | CONFIG_UNIX=y |
diff --git a/arch/avr32/configs/mimc200_defconfig b/arch/avr32/configs/mimc200_defconfig index 1bee51f22154..0a8bfdc420e0 100644 --- a/arch/avr32/configs/mimc200_defconfig +++ b/arch/avr32/configs/mimc200_defconfig | |||
| @@ -24,7 +24,7 @@ CONFIG_CPU_FREQ=y | |||
| 24 | # CONFIG_CPU_FREQ_STAT is not set | 24 | # CONFIG_CPU_FREQ_STAT is not set |
| 25 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y | 25 | CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y |
| 26 | CONFIG_CPU_FREQ_GOV_USERSPACE=y | 26 | CONFIG_CPU_FREQ_GOV_USERSPACE=y |
| 27 | CONFIG_CPU_FREQ_AT32AP=y | 27 | CONFIG_AVR32_AT32AP_CPUFREQ=y |
| 28 | CONFIG_NET=y | 28 | CONFIG_NET=y |
| 29 | CONFIG_PACKET=y | 29 | CONFIG_PACKET=y |
| 30 | CONFIG_UNIX=y | 30 | CONFIG_UNIX=y |
diff --git a/arch/avr32/mach-at32ap/Makefile b/arch/avr32/mach-at32ap/Makefile index 514c9a9b009a..fc09ec4bc725 100644 --- a/arch/avr32/mach-at32ap/Makefile +++ b/arch/avr32/mach-at32ap/Makefile | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | obj-y += pdc.o clock.o intc.o extint.o pio.o hsmc.o | 1 | obj-y += pdc.o clock.o intc.o extint.o pio.o hsmc.o |
| 2 | obj-y += hmatrix.o | 2 | obj-y += hmatrix.o |
| 3 | obj-$(CONFIG_CPU_AT32AP700X) += at32ap700x.o pm-at32ap700x.o | 3 | obj-$(CONFIG_CPU_AT32AP700X) += at32ap700x.o pm-at32ap700x.o |
| 4 | obj-$(CONFIG_CPU_FREQ_AT32AP) += cpufreq.o | ||
| 5 | obj-$(CONFIG_PM) += pm.o | 4 | obj-$(CONFIG_PM) += pm.o |
| 6 | 5 | ||
| 7 | ifeq ($(CONFIG_PM_DEBUG),y) | 6 | ifeq ($(CONFIG_PM_DEBUG),y) |
diff --git a/arch/blackfin/mach-common/Makefile b/arch/blackfin/mach-common/Makefile index 75f0ba29ebb9..675466d490d4 100644 --- a/arch/blackfin/mach-common/Makefile +++ b/arch/blackfin/mach-common/Makefile | |||
| @@ -10,7 +10,6 @@ obj-$(CONFIG_PM) += pm.o | |||
| 10 | ifneq ($(CONFIG_BF60x),y) | 10 | ifneq ($(CONFIG_BF60x),y) |
| 11 | obj-$(CONFIG_PM) += dpmc_modes.o | 11 | obj-$(CONFIG_PM) += dpmc_modes.o |
| 12 | endif | 12 | endif |
| 13 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o | ||
| 14 | obj-$(CONFIG_CPU_VOLTAGE) += dpmc.o | 13 | obj-$(CONFIG_CPU_VOLTAGE) += dpmc.o |
| 15 | obj-$(CONFIG_SMP) += smp.o | 14 | obj-$(CONFIG_SMP) += smp.o |
| 16 | obj-$(CONFIG_BFIN_KERNEL_CLOCK) += clocks-init.o | 15 | obj-$(CONFIG_BFIN_KERNEL_CLOCK) += clocks-init.o |
diff --git a/arch/cris/arch-v32/mach-a3/Makefile b/arch/cris/arch-v32/mach-a3/Makefile index d366e0891988..18a227196a41 100644 --- a/arch/cris/arch-v32/mach-a3/Makefile +++ b/arch/cris/arch-v32/mach-a3/Makefile | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | obj-y := dma.o pinmux.o io.o arbiter.o | 5 | obj-y := dma.o pinmux.o io.o arbiter.o |
| 6 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o | ||
| 7 | 6 | ||
| 8 | clean: | 7 | clean: |
| 9 | 8 | ||
diff --git a/arch/cris/arch-v32/mach-fs/Makefile b/arch/cris/arch-v32/mach-fs/Makefile index d366e0891988..18a227196a41 100644 --- a/arch/cris/arch-v32/mach-fs/Makefile +++ b/arch/cris/arch-v32/mach-fs/Makefile | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | obj-y := dma.o pinmux.o io.o arbiter.o | 5 | obj-y := dma.o pinmux.o io.o arbiter.o |
| 6 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o | ||
| 7 | 6 | ||
| 8 | clean: | 7 | clean: |
| 9 | 8 | ||
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index e7e55a00f94f..e725ea01569e 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig | |||
| @@ -591,9 +591,9 @@ source "kernel/power/Kconfig" | |||
| 591 | source "drivers/acpi/Kconfig" | 591 | source "drivers/acpi/Kconfig" |
| 592 | 592 | ||
| 593 | if PM | 593 | if PM |
| 594 | 594 | menu "CPU Frequency scaling" | |
| 595 | source "arch/ia64/kernel/cpufreq/Kconfig" | 595 | source "drivers/cpufreq/Kconfig" |
| 596 | 596 | endmenu | |
| 597 | endif | 597 | endif |
| 598 | 598 | ||
| 599 | endmenu | 599 | endmenu |
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile index d959c84904be..20678a9ed11a 100644 --- a/arch/ia64/kernel/Makefile +++ b/arch/ia64/kernel/Makefile | |||
| @@ -23,7 +23,6 @@ obj-$(CONFIG_SMP) += smp.o smpboot.o | |||
| 23 | obj-$(CONFIG_NUMA) += numa.o | 23 | obj-$(CONFIG_NUMA) += numa.o |
| 24 | obj-$(CONFIG_PERFMON) += perfmon_default_smpl.o | 24 | obj-$(CONFIG_PERFMON) += perfmon_default_smpl.o |
| 25 | obj-$(CONFIG_IA64_CYCLONE) += cyclone.o | 25 | obj-$(CONFIG_IA64_CYCLONE) += cyclone.o |
| 26 | obj-$(CONFIG_CPU_FREQ) += cpufreq/ | ||
| 27 | obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o | 26 | obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o |
| 28 | obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o | 27 | obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o |
| 29 | obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o | 28 | obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o |
diff --git a/arch/ia64/kernel/cpufreq/Kconfig b/arch/ia64/kernel/cpufreq/Kconfig deleted file mode 100644 index 2d9d5279b981..000000000000 --- a/arch/ia64/kernel/cpufreq/Kconfig +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | |||
| 2 | # | ||
| 3 | # CPU Frequency scaling | ||
| 4 | # | ||
| 5 | |||
| 6 | menu "CPU Frequency scaling" | ||
| 7 | |||
| 8 | source "drivers/cpufreq/Kconfig" | ||
| 9 | |||
| 10 | if CPU_FREQ | ||
| 11 | |||
| 12 | comment "CPUFreq processor drivers" | ||
| 13 | |||
| 14 | config IA64_ACPI_CPUFREQ | ||
| 15 | tristate "ACPI Processor P-States driver" | ||
| 16 | select CPU_FREQ_TABLE | ||
| 17 | depends on ACPI_PROCESSOR | ||
| 18 | help | ||
| 19 | This driver adds a CPUFreq driver which utilizes the ACPI | ||
| 20 | Processor Performance States. | ||
| 21 | |||
| 22 | For details, take a look at <file:Documentation/cpu-freq/>. | ||
| 23 | |||
| 24 | If in doubt, say N. | ||
| 25 | |||
| 26 | endif # CPU_FREQ | ||
| 27 | |||
| 28 | endmenu | ||
| 29 | |||
diff --git a/arch/ia64/kernel/cpufreq/Makefile b/arch/ia64/kernel/cpufreq/Makefile deleted file mode 100644 index 4838f2a57c7a..000000000000 --- a/arch/ia64/kernel/cpufreq/Makefile +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | obj-$(CONFIG_IA64_ACPI_CPUFREQ) += acpi-cpufreq.o | ||
| 2 | |||
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 3a7b3954ce1b..007a917a980d 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
| @@ -2541,7 +2541,14 @@ source "kernel/power/Kconfig" | |||
| 2541 | 2541 | ||
| 2542 | endmenu | 2542 | endmenu |
| 2543 | 2543 | ||
| 2544 | source "arch/mips/kernel/cpufreq/Kconfig" | 2544 | config MIPS_EXTERNAL_TIMER |
| 2545 | bool | ||
| 2546 | |||
| 2547 | if CPU_SUPPORTS_CPUFREQ && MIPS_EXTERNAL_TIMER | ||
| 2548 | menu "CPU Power Management" | ||
| 2549 | source "drivers/cpufreq/Kconfig" | ||
| 2550 | endmenu | ||
| 2551 | endif | ||
| 2545 | 2552 | ||
| 2546 | source "net/Kconfig" | 2553 | source "net/Kconfig" |
| 2547 | 2554 | ||
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile index de75fb50562b..520a908d45d6 100644 --- a/arch/mips/kernel/Makefile +++ b/arch/mips/kernel/Makefile | |||
| @@ -92,8 +92,6 @@ CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/n | |||
| 92 | 92 | ||
| 93 | obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o | 93 | obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o |
| 94 | 94 | ||
| 95 | obj-$(CONFIG_MIPS_CPUFREQ) += cpufreq/ | ||
| 96 | |||
| 97 | obj-$(CONFIG_PERF_EVENTS) += perf_event.o | 95 | obj-$(CONFIG_PERF_EVENTS) += perf_event.o |
| 98 | obj-$(CONFIG_HW_PERF_EVENTS) += perf_event_mipsxx.o | 96 | obj-$(CONFIG_HW_PERF_EVENTS) += perf_event_mipsxx.o |
| 99 | 97 | ||
diff --git a/arch/mips/kernel/cpufreq/Kconfig b/arch/mips/kernel/cpufreq/Kconfig deleted file mode 100644 index 58c601eee6fd..000000000000 --- a/arch/mips/kernel/cpufreq/Kconfig +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 1 | # | ||
| 2 | # CPU Frequency scaling | ||
| 3 | # | ||
| 4 | |||
| 5 | config MIPS_EXTERNAL_TIMER | ||
| 6 | bool | ||
| 7 | |||
| 8 | config MIPS_CPUFREQ | ||
| 9 | bool | ||
| 10 | default y | ||
| 11 | depends on CPU_SUPPORTS_CPUFREQ && MIPS_EXTERNAL_TIMER | ||
| 12 | |||
| 13 | if MIPS_CPUFREQ | ||
| 14 | |||
| 15 | menu "CPU Frequency scaling" | ||
| 16 | |||
| 17 | source "drivers/cpufreq/Kconfig" | ||
| 18 | |||
| 19 | if CPU_FREQ | ||
| 20 | |||
| 21 | comment "CPUFreq processor drivers" | ||
| 22 | |||
| 23 | config LOONGSON2_CPUFREQ | ||
| 24 | tristate "Loongson2 CPUFreq Driver" | ||
| 25 | select CPU_FREQ_TABLE | ||
| 26 | depends on MIPS_CPUFREQ | ||
| 27 | help | ||
| 28 | This option adds a CPUFreq driver for loongson processors which | ||
| 29 | support software configurable cpu frequency. | ||
| 30 | |||
| 31 | Loongson2F and it's successors support this feature. | ||
| 32 | |||
| 33 | For details, take a look at <file:Documentation/cpu-freq/>. | ||
| 34 | |||
| 35 | If in doubt, say N. | ||
| 36 | |||
| 37 | endif # CPU_FREQ | ||
| 38 | |||
| 39 | endmenu | ||
| 40 | |||
| 41 | endif # MIPS_CPUFREQ | ||
diff --git a/arch/mips/kernel/cpufreq/Makefile b/arch/mips/kernel/cpufreq/Makefile deleted file mode 100644 index 05a5715ee38c..000000000000 --- a/arch/mips/kernel/cpufreq/Makefile +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Makefile for the Linux/MIPS cpufreq. | ||
| 3 | # | ||
| 4 | |||
| 5 | obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o | ||
diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig index 53aaefeb3386..9978f594cac0 100644 --- a/arch/powerpc/platforms/cell/Kconfig +++ b/arch/powerpc/platforms/cell/Kconfig | |||
| @@ -113,34 +113,10 @@ config CBE_THERM | |||
| 113 | default m | 113 | default m |
| 114 | depends on CBE_RAS && SPU_BASE | 114 | depends on CBE_RAS && SPU_BASE |
| 115 | 115 | ||
| 116 | config CBE_CPUFREQ | ||
| 117 | tristate "CBE frequency scaling" | ||
| 118 | depends on CBE_RAS && CPU_FREQ | ||
| 119 | default m | ||
| 120 | help | ||
| 121 | This adds the cpufreq driver for Cell BE processors. | ||
| 122 | For details, take a look at <file:Documentation/cpu-freq/>. | ||
| 123 | If you don't have such processor, say N | ||
| 124 | |||
| 125 | config CBE_CPUFREQ_PMI_ENABLE | ||
| 126 | bool "CBE frequency scaling using PMI interface" | ||
| 127 | depends on CBE_CPUFREQ | ||
| 128 | default n | ||
| 129 | help | ||
| 130 | Select this, if you want to use the PMI interface | ||
| 131 | to switch frequencies. Using PMI, the | ||
| 132 | processor will not only be able to run at lower speed, | ||
| 133 | but also at lower core voltage. | ||
| 134 | |||
| 135 | config CBE_CPUFREQ_PMI | ||
| 136 | tristate | ||
| 137 | depends on CBE_CPUFREQ_PMI_ENABLE | ||
| 138 | default CBE_CPUFREQ | ||
| 139 | |||
| 140 | config PPC_PMI | 116 | config PPC_PMI |
| 141 | tristate | 117 | tristate |
| 142 | default y | 118 | default y |
| 143 | depends on CBE_CPUFREQ_PMI || PPC_IBM_CELL_POWERBUTTON | 119 | depends on CPU_FREQ_CBE_PMI || PPC_IBM_CELL_POWERBUTTON |
| 144 | help | 120 | help |
| 145 | PMI (Platform Management Interrupt) is a way to | 121 | PMI (Platform Management Interrupt) is a way to |
| 146 | communicate with the BMC (Baseboard Management Controller). | 122 | communicate with the BMC (Baseboard Management Controller). |
diff --git a/arch/powerpc/platforms/cell/Makefile b/arch/powerpc/platforms/cell/Makefile index a4a89350bcfc..fe053e7c73ee 100644 --- a/arch/powerpc/platforms/cell/Makefile +++ b/arch/powerpc/platforms/cell/Makefile | |||
| @@ -5,9 +5,6 @@ obj-$(CONFIG_PPC_CELL_NATIVE) += iommu.o setup.o spider-pic.o \ | |||
| 5 | obj-$(CONFIG_CBE_RAS) += ras.o | 5 | obj-$(CONFIG_CBE_RAS) += ras.o |
| 6 | 6 | ||
| 7 | obj-$(CONFIG_CBE_THERM) += cbe_thermal.o | 7 | obj-$(CONFIG_CBE_THERM) += cbe_thermal.o |
| 8 | obj-$(CONFIG_CBE_CPUFREQ_PMI) += cbe_cpufreq_pmi.o | ||
| 9 | obj-$(CONFIG_CBE_CPUFREQ) += cbe-cpufreq.o | ||
| 10 | cbe-cpufreq-y += cbe_cpufreq_pervasive.o cbe_cpufreq.o | ||
| 11 | obj-$(CONFIG_CBE_CPUFREQ_SPU_GOVERNOR) += cpufreq_spudemand.o | 8 | obj-$(CONFIG_CBE_CPUFREQ_SPU_GOVERNOR) += cpufreq_spudemand.o |
| 12 | 9 | ||
| 13 | obj-$(CONFIG_PPC_IBM_CELL_POWERBUTTON) += cbe_powerbutton.o | 10 | obj-$(CONFIG_PPC_IBM_CELL_POWERBUTTON) += cbe_powerbutton.o |
diff --git a/arch/powerpc/platforms/pasemi/cpufreq.c b/arch/powerpc/platforms/pasemi/cpufreq.c index 890f30e70f98..be1e7958909e 100644 --- a/arch/powerpc/platforms/pasemi/cpufreq.c +++ b/arch/powerpc/platforms/pasemi/cpufreq.c | |||
| @@ -273,10 +273,9 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy, | |||
| 273 | 273 | ||
| 274 | freqs.old = policy->cur; | 274 | freqs.old = policy->cur; |
| 275 | freqs.new = pas_freqs[pas_astate_new].frequency; | 275 | freqs.new = pas_freqs[pas_astate_new].frequency; |
| 276 | freqs.cpu = policy->cpu; | ||
| 277 | 276 | ||
| 278 | mutex_lock(&pas_switch_mutex); | 277 | mutex_lock(&pas_switch_mutex); |
| 279 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 278 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 280 | 279 | ||
| 281 | pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", | 280 | pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", |
| 282 | policy->cpu, | 281 | policy->cpu, |
| @@ -288,7 +287,7 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy, | |||
| 288 | for_each_online_cpu(i) | 287 | for_each_online_cpu(i) |
| 289 | set_astate(i, pas_astate_new); | 288 | set_astate(i, pas_astate_new); |
| 290 | 289 | ||
| 291 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 290 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 292 | mutex_unlock(&pas_switch_mutex); | 291 | mutex_unlock(&pas_switch_mutex); |
| 293 | 292 | ||
| 294 | ppc_proc_freq = freqs.new * 1000ul; | 293 | ppc_proc_freq = freqs.new * 1000ul; |
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/arch/powerpc/platforms/powermac/cpufreq_32.c index 311b804353b1..3104fad82480 100644 --- a/arch/powerpc/platforms/powermac/cpufreq_32.c +++ b/arch/powerpc/platforms/powermac/cpufreq_32.c | |||
| @@ -335,7 +335,8 @@ static int pmu_set_cpu_speed(int low_speed) | |||
| 335 | return 0; | 335 | return 0; |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | static int do_set_cpu_speed(int speed_mode, int notify) | 338 | static int do_set_cpu_speed(struct cpufreq_policy *policy, int speed_mode, |
| 339 | int notify) | ||
| 339 | { | 340 | { |
| 340 | struct cpufreq_freqs freqs; | 341 | struct cpufreq_freqs freqs; |
| 341 | unsigned long l3cr; | 342 | unsigned long l3cr; |
| @@ -343,13 +344,12 @@ static int do_set_cpu_speed(int speed_mode, int notify) | |||
| 343 | 344 | ||
| 344 | freqs.old = cur_freq; | 345 | freqs.old = cur_freq; |
| 345 | freqs.new = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq; | 346 | freqs.new = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq; |
| 346 | freqs.cpu = smp_processor_id(); | ||
| 347 | 347 | ||
| 348 | if (freqs.old == freqs.new) | 348 | if (freqs.old == freqs.new) |
| 349 | return 0; | 349 | return 0; |
| 350 | 350 | ||
| 351 | if (notify) | 351 | if (notify) |
| 352 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 352 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 353 | if (speed_mode == CPUFREQ_LOW && | 353 | if (speed_mode == CPUFREQ_LOW && |
| 354 | cpu_has_feature(CPU_FTR_L3CR)) { | 354 | cpu_has_feature(CPU_FTR_L3CR)) { |
| 355 | l3cr = _get_L3CR(); | 355 | l3cr = _get_L3CR(); |
| @@ -366,7 +366,7 @@ static int do_set_cpu_speed(int speed_mode, int notify) | |||
| 366 | _set_L3CR(prev_l3cr); | 366 | _set_L3CR(prev_l3cr); |
| 367 | } | 367 | } |
| 368 | if (notify) | 368 | if (notify) |
| 369 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 369 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 370 | cur_freq = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq; | 370 | cur_freq = (speed_mode == CPUFREQ_HIGH) ? hi_freq : low_freq; |
| 371 | 371 | ||
| 372 | return 0; | 372 | return 0; |
| @@ -393,7 +393,7 @@ static int pmac_cpufreq_target( struct cpufreq_policy *policy, | |||
| 393 | target_freq, relation, &newstate)) | 393 | target_freq, relation, &newstate)) |
| 394 | return -EINVAL; | 394 | return -EINVAL; |
| 395 | 395 | ||
| 396 | rc = do_set_cpu_speed(newstate, 1); | 396 | rc = do_set_cpu_speed(policy, newstate, 1); |
| 397 | 397 | ||
| 398 | ppc_proc_freq = cur_freq * 1000ul; | 398 | ppc_proc_freq = cur_freq * 1000ul; |
| 399 | return rc; | 399 | return rc; |
| @@ -442,7 +442,7 @@ static int pmac_cpufreq_suspend(struct cpufreq_policy *policy) | |||
| 442 | no_schedule = 1; | 442 | no_schedule = 1; |
| 443 | sleep_freq = cur_freq; | 443 | sleep_freq = cur_freq; |
| 444 | if (cur_freq == low_freq && !is_pmu_based) | 444 | if (cur_freq == low_freq && !is_pmu_based) |
| 445 | do_set_cpu_speed(CPUFREQ_HIGH, 0); | 445 | do_set_cpu_speed(policy, CPUFREQ_HIGH, 0); |
| 446 | return 0; | 446 | return 0; |
| 447 | } | 447 | } |
| 448 | 448 | ||
| @@ -458,7 +458,7 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy) | |||
| 458 | * is that we force a switch to whatever it was, which is | 458 | * is that we force a switch to whatever it was, which is |
| 459 | * probably high speed due to our suspend() routine | 459 | * probably high speed due to our suspend() routine |
| 460 | */ | 460 | */ |
| 461 | do_set_cpu_speed(sleep_freq == low_freq ? | 461 | do_set_cpu_speed(policy, sleep_freq == low_freq ? |
| 462 | CPUFREQ_LOW : CPUFREQ_HIGH, 0); | 462 | CPUFREQ_LOW : CPUFREQ_HIGH, 0); |
| 463 | 463 | ||
| 464 | ppc_proc_freq = cur_freq * 1000ul; | 464 | ppc_proc_freq = cur_freq * 1000ul; |
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/arch/powerpc/platforms/powermac/cpufreq_64.c index 9650c6029c82..7ba423431cfe 100644 --- a/arch/powerpc/platforms/powermac/cpufreq_64.c +++ b/arch/powerpc/platforms/powermac/cpufreq_64.c | |||
| @@ -339,11 +339,10 @@ static int g5_cpufreq_target(struct cpufreq_policy *policy, | |||
| 339 | 339 | ||
| 340 | freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency; | 340 | freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency; |
| 341 | freqs.new = g5_cpu_freqs[newstate].frequency; | 341 | freqs.new = g5_cpu_freqs[newstate].frequency; |
| 342 | freqs.cpu = 0; | ||
| 343 | 342 | ||
| 344 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 343 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 345 | rc = g5_switch_freq(newstate); | 344 | rc = g5_switch_freq(newstate); |
| 346 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 345 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 347 | 346 | ||
| 348 | mutex_unlock(&g5_switch_mutex); | 347 | mutex_unlock(&g5_switch_mutex); |
| 349 | 348 | ||
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c b/arch/powerpc/platforms/pseries/processor_idle.c index 4d806b419606..4644efa06941 100644 --- a/arch/powerpc/platforms/pseries/processor_idle.c +++ b/arch/powerpc/platforms/pseries/processor_idle.c | |||
| @@ -23,8 +23,8 @@ | |||
| 23 | #include "pseries.h" | 23 | #include "pseries.h" |
| 24 | 24 | ||
| 25 | struct cpuidle_driver pseries_idle_driver = { | 25 | struct cpuidle_driver pseries_idle_driver = { |
| 26 | .name = "pseries_idle", | 26 | .name = "pseries_idle", |
| 27 | .owner = THIS_MODULE, | 27 | .owner = THIS_MODULE, |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | #define MAX_IDLE_STATE_COUNT 2 | 30 | #define MAX_IDLE_STATE_COUNT 2 |
| @@ -33,10 +33,8 @@ static int max_idle_state = MAX_IDLE_STATE_COUNT - 1; | |||
| 33 | static struct cpuidle_device __percpu *pseries_cpuidle_devices; | 33 | static struct cpuidle_device __percpu *pseries_cpuidle_devices; |
| 34 | static struct cpuidle_state *cpuidle_state_table; | 34 | static struct cpuidle_state *cpuidle_state_table; |
| 35 | 35 | ||
| 36 | static inline void idle_loop_prolog(unsigned long *in_purr, ktime_t *kt_before) | 36 | static inline void idle_loop_prolog(unsigned long *in_purr) |
| 37 | { | 37 | { |
| 38 | |||
| 39 | *kt_before = ktime_get(); | ||
| 40 | *in_purr = mfspr(SPRN_PURR); | 38 | *in_purr = mfspr(SPRN_PURR); |
| 41 | /* | 39 | /* |
| 42 | * Indicate to the HV that we are idle. Now would be | 40 | * Indicate to the HV that we are idle. Now would be |
| @@ -45,12 +43,10 @@ static inline void idle_loop_prolog(unsigned long *in_purr, ktime_t *kt_before) | |||
| 45 | get_lppaca()->idle = 1; | 43 | get_lppaca()->idle = 1; |
| 46 | } | 44 | } |
| 47 | 45 | ||
| 48 | static inline s64 idle_loop_epilog(unsigned long in_purr, ktime_t kt_before) | 46 | static inline void idle_loop_epilog(unsigned long in_purr) |
| 49 | { | 47 | { |
| 50 | get_lppaca()->wait_state_cycles += mfspr(SPRN_PURR) - in_purr; | 48 | get_lppaca()->wait_state_cycles += mfspr(SPRN_PURR) - in_purr; |
| 51 | get_lppaca()->idle = 0; | 49 | get_lppaca()->idle = 0; |
| 52 | |||
| 53 | return ktime_to_us(ktime_sub(ktime_get(), kt_before)); | ||
| 54 | } | 50 | } |
| 55 | 51 | ||
| 56 | static int snooze_loop(struct cpuidle_device *dev, | 52 | static int snooze_loop(struct cpuidle_device *dev, |
| @@ -58,10 +54,9 @@ static int snooze_loop(struct cpuidle_device *dev, | |||
| 58 | int index) | 54 | int index) |
| 59 | { | 55 | { |
| 60 | unsigned long in_purr; | 56 | unsigned long in_purr; |
| 61 | ktime_t kt_before; | ||
| 62 | int cpu = dev->cpu; | 57 | int cpu = dev->cpu; |
| 63 | 58 | ||
| 64 | idle_loop_prolog(&in_purr, &kt_before); | 59 | idle_loop_prolog(&in_purr); |
| 65 | local_irq_enable(); | 60 | local_irq_enable(); |
| 66 | set_thread_flag(TIF_POLLING_NRFLAG); | 61 | set_thread_flag(TIF_POLLING_NRFLAG); |
| 67 | 62 | ||
| @@ -75,8 +70,8 @@ static int snooze_loop(struct cpuidle_device *dev, | |||
| 75 | clear_thread_flag(TIF_POLLING_NRFLAG); | 70 | clear_thread_flag(TIF_POLLING_NRFLAG); |
| 76 | smp_mb(); | 71 | smp_mb(); |
| 77 | 72 | ||
| 78 | dev->last_residency = | 73 | idle_loop_epilog(in_purr); |
| 79 | (int)idle_loop_epilog(in_purr, kt_before); | 74 | |
| 80 | return index; | 75 | return index; |
| 81 | } | 76 | } |
| 82 | 77 | ||
| @@ -102,9 +97,8 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, | |||
| 102 | int index) | 97 | int index) |
| 103 | { | 98 | { |
| 104 | unsigned long in_purr; | 99 | unsigned long in_purr; |
| 105 | ktime_t kt_before; | ||
| 106 | 100 | ||
| 107 | idle_loop_prolog(&in_purr, &kt_before); | 101 | idle_loop_prolog(&in_purr); |
| 108 | get_lppaca()->donate_dedicated_cpu = 1; | 102 | get_lppaca()->donate_dedicated_cpu = 1; |
| 109 | 103 | ||
| 110 | ppc64_runlatch_off(); | 104 | ppc64_runlatch_off(); |
| @@ -112,8 +106,9 @@ static int dedicated_cede_loop(struct cpuidle_device *dev, | |||
| 112 | check_and_cede_processor(); | 106 | check_and_cede_processor(); |
| 113 | 107 | ||
| 114 | get_lppaca()->donate_dedicated_cpu = 0; | 108 | get_lppaca()->donate_dedicated_cpu = 0; |
| 115 | dev->last_residency = | 109 | |
| 116 | (int)idle_loop_epilog(in_purr, kt_before); | 110 | idle_loop_epilog(in_purr); |
| 111 | |||
| 117 | return index; | 112 | return index; |
| 118 | } | 113 | } |
| 119 | 114 | ||
| @@ -122,9 +117,8 @@ static int shared_cede_loop(struct cpuidle_device *dev, | |||
| 122 | int index) | 117 | int index) |
| 123 | { | 118 | { |
| 124 | unsigned long in_purr; | 119 | unsigned long in_purr; |
| 125 | ktime_t kt_before; | ||
| 126 | 120 | ||
| 127 | idle_loop_prolog(&in_purr, &kt_before); | 121 | idle_loop_prolog(&in_purr); |
| 128 | 122 | ||
| 129 | /* | 123 | /* |
| 130 | * Yield the processor to the hypervisor. We return if | 124 | * Yield the processor to the hypervisor. We return if |
| @@ -135,8 +129,8 @@ static int shared_cede_loop(struct cpuidle_device *dev, | |||
| 135 | */ | 129 | */ |
| 136 | check_and_cede_processor(); | 130 | check_and_cede_processor(); |
| 137 | 131 | ||
| 138 | dev->last_residency = | 132 | idle_loop_epilog(in_purr); |
| 139 | (int)idle_loop_epilog(in_purr, kt_before); | 133 | |
| 140 | return index; | 134 | return index; |
| 141 | } | 135 | } |
| 142 | 136 | ||
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 1ea597c6497a..78d8ace57272 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig | |||
| @@ -622,25 +622,7 @@ config SH_CLK_CPG_LEGACY | |||
| 622 | endmenu | 622 | endmenu |
| 623 | 623 | ||
| 624 | menu "CPU Frequency scaling" | 624 | menu "CPU Frequency scaling" |
| 625 | |||
| 626 | source "drivers/cpufreq/Kconfig" | 625 | source "drivers/cpufreq/Kconfig" |
| 627 | |||
| 628 | config SH_CPU_FREQ | ||
| 629 | tristate "SuperH CPU Frequency driver" | ||
| 630 | depends on CPU_FREQ | ||
| 631 | select CPU_FREQ_TABLE | ||
| 632 | help | ||
| 633 | This adds the cpufreq driver for SuperH. Any CPU that supports | ||
| 634 | clock rate rounding through the clock framework can use this | ||
| 635 | driver. While it will make the kernel slightly larger, this is | ||
| 636 | harmless for CPUs that don't support rate rounding. The driver | ||
| 637 | will also generate a notice in the boot log before disabling | ||
| 638 | itself if the CPU in question is not capable of rate rounding. | ||
| 639 | |||
| 640 | For details, take a look at <file:Documentation/cpu-freq>. | ||
| 641 | |||
| 642 | If unsure, say N. | ||
| 643 | |||
| 644 | endmenu | 626 | endmenu |
| 645 | 627 | ||
| 646 | source "arch/sh/drivers/Kconfig" | 628 | source "arch/sh/drivers/Kconfig" |
diff --git a/arch/sh/include/asm/suspend.h b/arch/sh/include/asm/suspend.h index e14567a7e9a1..70ae0b2888ab 100644 --- a/arch/sh/include/asm/suspend.h +++ b/arch/sh/include/asm/suspend.h | |||
| @@ -14,9 +14,9 @@ struct swsusp_arch_regs { | |||
| 14 | void sh_mobile_call_standby(unsigned long mode); | 14 | void sh_mobile_call_standby(unsigned long mode); |
| 15 | 15 | ||
| 16 | #ifdef CONFIG_CPU_IDLE | 16 | #ifdef CONFIG_CPU_IDLE |
| 17 | void sh_mobile_setup_cpuidle(void); | 17 | int sh_mobile_setup_cpuidle(void); |
| 18 | #else | 18 | #else |
| 19 | static inline void sh_mobile_setup_cpuidle(void) {} | 19 | static inline int sh_mobile_setup_cpuidle(void) { return 0; } |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | /* notifier chains for pre/post sleep hooks */ | 22 | /* notifier chains for pre/post sleep hooks */ |
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile index f259b37874e9..261c8bfd75ce 100644 --- a/arch/sh/kernel/Makefile +++ b/arch/sh/kernel/Makefile | |||
| @@ -31,7 +31,6 @@ obj-$(CONFIG_VSYSCALL) += vsyscall/ | |||
| 31 | obj-$(CONFIG_SMP) += smp.o | 31 | obj-$(CONFIG_SMP) += smp.o |
| 32 | obj-$(CONFIG_SH_STANDARD_BIOS) += sh_bios.o | 32 | obj-$(CONFIG_SH_STANDARD_BIOS) += sh_bios.o |
| 33 | obj-$(CONFIG_KGDB) += kgdb.o | 33 | obj-$(CONFIG_KGDB) += kgdb.o |
| 34 | obj-$(CONFIG_SH_CPU_FREQ) += cpufreq.o | ||
| 35 | obj-$(CONFIG_MODULES) += sh_ksyms_$(BITS).o module.o | 34 | obj-$(CONFIG_MODULES) += sh_ksyms_$(BITS).o module.o |
| 36 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o | 35 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o |
| 37 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o | 36 | obj-$(CONFIG_CRASH_DUMP) += crash_dump.o |
diff --git a/arch/sh/kernel/cpu/shmobile/cpuidle.c b/arch/sh/kernel/cpu/shmobile/cpuidle.c index 1ddc876d3b26..d30622592116 100644 --- a/arch/sh/kernel/cpu/shmobile/cpuidle.c +++ b/arch/sh/kernel/cpu/shmobile/cpuidle.c | |||
| @@ -51,70 +51,53 @@ static int cpuidle_sleep_enter(struct cpuidle_device *dev, | |||
| 51 | return k; | 51 | return k; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | static struct cpuidle_device cpuidle_dev; | ||
| 55 | static struct cpuidle_driver cpuidle_driver = { | 54 | static struct cpuidle_driver cpuidle_driver = { |
| 56 | .name = "sh_idle", | 55 | .name = "sh_idle", |
| 57 | .owner = THIS_MODULE, | 56 | .owner = THIS_MODULE, |
| 58 | .en_core_tk_irqen = 1, | 57 | .states = { |
| 58 | { | ||
| 59 | .exit_latency = 1, | ||
| 60 | .target_residency = 1 * 2, | ||
| 61 | .power_usage = 3, | ||
| 62 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
| 63 | .enter = cpuidle_sleep_enter, | ||
| 64 | .name = "C1", | ||
| 65 | .desc = "SuperH Sleep Mode", | ||
| 66 | }, | ||
| 67 | { | ||
| 68 | .exit_latency = 100, | ||
| 69 | .target_residency = 1 * 2, | ||
| 70 | .power_usage = 1, | ||
| 71 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
| 72 | .enter = cpuidle_sleep_enter, | ||
| 73 | .name = "C2", | ||
| 74 | .desc = "SuperH Sleep Mode [SF]", | ||
| 75 | .disabled = true, | ||
| 76 | }, | ||
| 77 | { | ||
| 78 | .exit_latency = 2300, | ||
| 79 | .target_residency = 1 * 2, | ||
| 80 | .power_usage = 1, | ||
| 81 | .flags = CPUIDLE_FLAG_TIME_VALID, | ||
| 82 | .enter = cpuidle_sleep_enter, | ||
| 83 | .name = "C3", | ||
| 84 | .desc = "SuperH Mobile Standby Mode [SF]", | ||
| 85 | .disabled = true, | ||
| 86 | }, | ||
| 87 | }, | ||
| 88 | .safe_state_index = 0, | ||
| 89 | .state_count = 3, | ||
| 59 | }; | 90 | }; |
| 60 | 91 | ||
| 61 | void sh_mobile_setup_cpuidle(void) | 92 | int __init sh_mobile_setup_cpuidle(void) |
| 62 | { | 93 | { |
| 63 | struct cpuidle_device *dev = &cpuidle_dev; | 94 | int ret; |
| 64 | struct cpuidle_driver *drv = &cpuidle_driver; | ||
| 65 | struct cpuidle_state *state; | ||
| 66 | int i; | ||
| 67 | 95 | ||
| 96 | if (sh_mobile_sleep_supported & SUSP_SH_SF) | ||
| 97 | cpuidle_driver.states[1].disabled = false; | ||
| 68 | 98 | ||
| 69 | for (i = 0; i < CPUIDLE_STATE_MAX; i++) { | 99 | if (sh_mobile_sleep_supported & SUSP_SH_STANDBY) |
| 70 | drv->states[i].name[0] = '\0'; | 100 | cpuidle_driver.states[2].disabled = false; |
| 71 | drv->states[i].desc[0] = '\0'; | ||
| 72 | } | ||
| 73 | 101 | ||
| 74 | i = CPUIDLE_DRIVER_STATE_START; | 102 | return cpuidle_register(&cpuidle_driver); |
| 75 | |||
| 76 | state = &drv->states[i++]; | ||
| 77 | snprintf(state->name, CPUIDLE_NAME_LEN, "C1"); | ||
| 78 | strncpy(state->desc, "SuperH Sleep Mode", CPUIDLE_DESC_LEN); | ||
| 79 | state->exit_latency = 1; | ||
| 80 | state->target_residency = 1 * 2; | ||
| 81 | state->power_usage = 3; | ||
| 82 | state->flags = 0; | ||
| 83 | state->flags |= CPUIDLE_FLAG_TIME_VALID; | ||
| 84 | state->enter = cpuidle_sleep_enter; | ||
| 85 | |||
| 86 | drv->safe_state_index = i-1; | ||
| 87 | |||
| 88 | if (sh_mobile_sleep_supported & SUSP_SH_SF) { | ||
| 89 | state = &drv->states[i++]; | ||
| 90 | snprintf(state->name, CPUIDLE_NAME_LEN, "C2"); | ||
| 91 | strncpy(state->desc, "SuperH Sleep Mode [SF]", | ||
| 92 | CPUIDLE_DESC_LEN); | ||
| 93 | state->exit_latency = 100; | ||
| 94 | state->target_residency = 1 * 2; | ||
| 95 | state->power_usage = 1; | ||
| 96 | state->flags = 0; | ||
| 97 | state->flags |= CPUIDLE_FLAG_TIME_VALID; | ||
| 98 | state->enter = cpuidle_sleep_enter; | ||
| 99 | } | ||
| 100 | |||
| 101 | if (sh_mobile_sleep_supported & SUSP_SH_STANDBY) { | ||
| 102 | state = &drv->states[i++]; | ||
| 103 | snprintf(state->name, CPUIDLE_NAME_LEN, "C3"); | ||
| 104 | strncpy(state->desc, "SuperH Mobile Standby Mode [SF]", | ||
| 105 | CPUIDLE_DESC_LEN); | ||
| 106 | state->exit_latency = 2300; | ||
| 107 | state->target_residency = 1 * 2; | ||
| 108 | state->power_usage = 1; | ||
| 109 | state->flags = 0; | ||
| 110 | state->flags |= CPUIDLE_FLAG_TIME_VALID; | ||
| 111 | state->enter = cpuidle_sleep_enter; | ||
| 112 | } | ||
| 113 | |||
| 114 | drv->state_count = i; | ||
| 115 | dev->state_count = i; | ||
| 116 | |||
| 117 | cpuidle_register_driver(&cpuidle_driver); | ||
| 118 | |||
| 119 | cpuidle_register_device(dev); | ||
| 120 | } | 103 | } |
diff --git a/arch/sh/kernel/cpu/shmobile/pm.c b/arch/sh/kernel/cpu/shmobile/pm.c index 08d27fac8d08..ac37b7234f85 100644 --- a/arch/sh/kernel/cpu/shmobile/pm.c +++ b/arch/sh/kernel/cpu/shmobile/pm.c | |||
| @@ -150,8 +150,7 @@ static const struct platform_suspend_ops sh_pm_ops = { | |||
| 150 | static int __init sh_pm_init(void) | 150 | static int __init sh_pm_init(void) |
| 151 | { | 151 | { |
| 152 | suspend_set_ops(&sh_pm_ops); | 152 | suspend_set_ops(&sh_pm_ops); |
| 153 | sh_mobile_setup_cpuidle(); | 153 | return sh_mobile_setup_cpuidle(); |
| 154 | return 0; | ||
| 155 | } | 154 | } |
| 156 | 155 | ||
| 157 | late_initcall(sh_pm_init); | 156 | late_initcall(sh_pm_init); |
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 66dc562950ae..e5641157464f 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
| @@ -254,29 +254,6 @@ config HOTPLUG_CPU | |||
| 254 | 254 | ||
| 255 | if SPARC64 | 255 | if SPARC64 |
| 256 | source "drivers/cpufreq/Kconfig" | 256 | source "drivers/cpufreq/Kconfig" |
| 257 | |||
| 258 | config US3_FREQ | ||
| 259 | tristate "UltraSPARC-III CPU Frequency driver" | ||
| 260 | depends on CPU_FREQ | ||
| 261 | select CPU_FREQ_TABLE | ||
| 262 | help | ||
| 263 | This adds the CPUFreq driver for UltraSPARC-III processors. | ||
| 264 | |||
| 265 | For details, take a look at <file:Documentation/cpu-freq>. | ||
| 266 | |||
| 267 | If in doubt, say N. | ||
| 268 | |||
| 269 | config US2E_FREQ | ||
| 270 | tristate "UltraSPARC-IIe CPU Frequency driver" | ||
| 271 | depends on CPU_FREQ | ||
| 272 | select CPU_FREQ_TABLE | ||
| 273 | help | ||
| 274 | This adds the CPUFreq driver for UltraSPARC-IIe processors. | ||
| 275 | |||
| 276 | For details, take a look at <file:Documentation/cpu-freq>. | ||
| 277 | |||
| 278 | If in doubt, say N. | ||
| 279 | |||
| 280 | endif | 257 | endif |
| 281 | 258 | ||
| 282 | config US3_MC | 259 | config US3_MC |
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile index 6cf591b7e1c6..5276fd4e9d03 100644 --- a/arch/sparc/kernel/Makefile +++ b/arch/sparc/kernel/Makefile | |||
| @@ -102,9 +102,6 @@ obj-$(CONFIG_PCI_MSI) += pci_msi.o | |||
| 102 | 102 | ||
| 103 | obj-$(CONFIG_COMPAT) += sys32.o sys_sparc32.o signal32.o | 103 | obj-$(CONFIG_COMPAT) += sys32.o sys_sparc32.o signal32.o |
| 104 | 104 | ||
| 105 | # sparc64 cpufreq | ||
| 106 | obj-$(CONFIG_US3_FREQ) += us3_cpufreq.o | ||
| 107 | obj-$(CONFIG_US2E_FREQ) += us2e_cpufreq.o | ||
| 108 | obj-$(CONFIG_US3_MC) += chmc.o | 105 | obj-$(CONFIG_US3_MC) += chmc.o |
| 109 | 106 | ||
| 110 | obj-$(CONFIG_KPROBES) += kprobes.o | 107 | obj-$(CONFIG_KPROBES) += kprobes.o |
diff --git a/arch/unicore32/kernel/Makefile b/arch/unicore32/kernel/Makefile index fa497e0efe5a..607a72f2ae35 100644 --- a/arch/unicore32/kernel/Makefile +++ b/arch/unicore32/kernel/Makefile | |||
| @@ -9,7 +9,6 @@ obj-y += setup.o signal.o sys.o stacktrace.o traps.o | |||
| 9 | obj-$(CONFIG_MODULES) += ksyms.o module.o | 9 | obj-$(CONFIG_MODULES) += ksyms.o module.o |
| 10 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o | 10 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o |
| 11 | 11 | ||
| 12 | obj-$(CONFIG_CPU_FREQ) += cpu-ucv2.o | ||
| 13 | obj-$(CONFIG_UNICORE_FPU_F64) += fpu-ucf64.o | 12 | obj-$(CONFIG_UNICORE_FPU_F64) += fpu-ucf64.o |
| 14 | 13 | ||
| 15 | # obj-y for architecture PKUnity v3 | 14 | # obj-y for architecture PKUnity v3 |
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 398f7cb1353d..8010ebc5705f 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h | |||
| @@ -185,6 +185,7 @@ | |||
| 185 | #define X86_FEATURE_PTS (7*32+ 6) /* Intel Package Thermal Status */ | 185 | #define X86_FEATURE_PTS (7*32+ 6) /* Intel Package Thermal Status */ |
| 186 | #define X86_FEATURE_DTHERM (7*32+ 7) /* Digital Thermal Sensor */ | 186 | #define X86_FEATURE_DTHERM (7*32+ 7) /* Digital Thermal Sensor */ |
| 187 | #define X86_FEATURE_HW_PSTATE (7*32+ 8) /* AMD HW-PState */ | 187 | #define X86_FEATURE_HW_PSTATE (7*32+ 8) /* AMD HW-PState */ |
| 188 | #define X86_FEATURE_PROC_FEEDBACK (7*32+ 9) /* AMD ProcFeedbackInterface */ | ||
| 188 | 189 | ||
| 189 | /* Virtualization flags: Linux defined, word 8 */ | 190 | /* Virtualization flags: Linux defined, word 8 */ |
| 190 | #define X86_FEATURE_TPR_SHADOW (8*32+ 0) /* Intel TPR Shadow */ | 191 | #define X86_FEATURE_TPR_SHADOW (8*32+ 0) /* Intel TPR Shadow */ |
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c index 66b5faffe14a..53a4e2744846 100644 --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c | |||
| @@ -373,7 +373,6 @@ static int apm_cpu_idle(struct cpuidle_device *dev, | |||
| 373 | static struct cpuidle_driver apm_idle_driver = { | 373 | static struct cpuidle_driver apm_idle_driver = { |
| 374 | .name = "apm_idle", | 374 | .name = "apm_idle", |
| 375 | .owner = THIS_MODULE, | 375 | .owner = THIS_MODULE, |
| 376 | .en_core_tk_irqen = 1, | ||
| 377 | .states = { | 376 | .states = { |
| 378 | { /* entry 0 is for polling */ }, | 377 | { /* entry 0 is for polling */ }, |
| 379 | { /* entry 1 is for APM idle */ | 378 | { /* entry 1 is for APM idle */ |
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index ee8e9abc859f..d92b5dad15dd 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c | |||
| @@ -39,8 +39,9 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c) | |||
| 39 | { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 }, | 39 | { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 }, |
| 40 | { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 }, | 40 | { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 }, |
| 41 | { X86_FEATURE_XSAVEOPT, CR_EAX, 0, 0x0000000d, 1 }, | 41 | { X86_FEATURE_XSAVEOPT, CR_EAX, 0, 0x0000000d, 1 }, |
| 42 | { X86_FEATURE_CPB, CR_EDX, 9, 0x80000007, 0 }, | ||
| 43 | { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 }, | 42 | { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 }, |
| 43 | { X86_FEATURE_CPB, CR_EDX, 9, 0x80000007, 0 }, | ||
| 44 | { X86_FEATURE_PROC_FEEDBACK, CR_EDX,11, 0x80000007, 0 }, | ||
| 44 | { X86_FEATURE_NPT, CR_EDX, 0, 0x8000000a, 0 }, | 45 | { X86_FEATURE_NPT, CR_EDX, 0, 0x8000000a, 0 }, |
| 45 | { X86_FEATURE_LBRV, CR_EDX, 1, 0x8000000a, 0 }, | 46 | { X86_FEATURE_LBRV, CR_EDX, 1, 0x8000000a, 0 }, |
| 46 | { X86_FEATURE_SVML, CR_EDX, 2, 0x8000000a, 0 }, | 47 | { X86_FEATURE_SVML, CR_EDX, 2, 0x8000000a, 0 }, |
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 4bf68c8d4797..100bd724f648 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
| @@ -298,14 +298,6 @@ config ACPI_DEBUG | |||
| 298 | Documentation/kernel-parameters.txt to control the type and | 298 | Documentation/kernel-parameters.txt to control the type and |
| 299 | amount of debug output. | 299 | amount of debug output. |
| 300 | 300 | ||
| 301 | config ACPI_DEBUG_FUNC_TRACE | ||
| 302 | bool "Additionally enable ACPI function tracing" | ||
| 303 | default n | ||
| 304 | depends on ACPI_DEBUG | ||
| 305 | help | ||
| 306 | ACPI Debug Statements slow down ACPI processing. Function trace | ||
| 307 | is about half of the penalty and is rarely useful. | ||
| 308 | |||
| 309 | config ACPI_PCI_SLOT | 301 | config ACPI_PCI_SLOT |
| 310 | bool "PCI slot detection driver" | 302 | bool "PCI slot detection driver" |
| 311 | depends on SYSFS | 303 | depends on SYSFS |
| @@ -334,7 +326,7 @@ config X86_PM_TIMER | |||
| 334 | 326 | ||
| 335 | config ACPI_CONTAINER | 327 | config ACPI_CONTAINER |
| 336 | bool "Container and Module Devices" | 328 | bool "Container and Module Devices" |
| 337 | default (ACPI_HOTPLUG_MEMORY || ACPI_HOTPLUG_CPU || ACPI_HOTPLUG_IO) | 329 | default (ACPI_HOTPLUG_MEMORY || ACPI_HOTPLUG_CPU) |
| 338 | help | 330 | help |
| 339 | This driver supports ACPI Container and Module devices (IDs | 331 | This driver supports ACPI Container and Module devices (IDs |
| 340 | ACPI0004, PNP0A05, and PNP0A06). | 332 | ACPI0004, PNP0A05, and PNP0A06). |
| @@ -345,9 +337,8 @@ config ACPI_CONTAINER | |||
| 345 | the module will be called container. | 337 | the module will be called container. |
| 346 | 338 | ||
| 347 | config ACPI_HOTPLUG_MEMORY | 339 | config ACPI_HOTPLUG_MEMORY |
| 348 | tristate "Memory Hotplug" | 340 | bool "Memory Hotplug" |
| 349 | depends on MEMORY_HOTPLUG | 341 | depends on MEMORY_HOTPLUG |
| 350 | default n | ||
| 351 | help | 342 | help |
| 352 | This driver supports ACPI memory hotplug. The driver | 343 | This driver supports ACPI memory hotplug. The driver |
| 353 | fields notifications on ACPI memory devices (PNP0C80), | 344 | fields notifications on ACPI memory devices (PNP0C80), |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 474fcfeba66c..ecb743bf05a5 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
| @@ -39,6 +39,7 @@ acpi-y += ec.o | |||
| 39 | acpi-$(CONFIG_ACPI_DOCK) += dock.o | 39 | acpi-$(CONFIG_ACPI_DOCK) += dock.o |
| 40 | acpi-y += pci_root.o pci_link.o pci_irq.o | 40 | acpi-y += pci_root.o pci_link.o pci_irq.o |
| 41 | acpi-y += csrt.o | 41 | acpi-y += csrt.o |
| 42 | acpi-$(CONFIG_X86_INTEL_LPSS) += acpi_lpss.o | ||
| 42 | acpi-y += acpi_platform.o | 43 | acpi-y += acpi_platform.o |
| 43 | acpi-y += power.o | 44 | acpi-y += power.o |
| 44 | acpi-y += event.o | 45 | acpi-y += event.o |
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c new file mode 100644 index 000000000000..b1c95422ce74 --- /dev/null +++ b/drivers/acpi/acpi_lpss.c | |||
| @@ -0,0 +1,292 @@ | |||
| 1 | /* | ||
| 2 | * ACPI support for Intel Lynxpoint LPSS. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013, Intel Corporation | ||
| 5 | * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> | ||
| 6 | * Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 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 | #include <linux/acpi.h> | ||
| 14 | #include <linux/clk.h> | ||
| 15 | #include <linux/clkdev.h> | ||
| 16 | #include <linux/clk-provider.h> | ||
| 17 | #include <linux/err.h> | ||
| 18 | #include <linux/io.h> | ||
| 19 | #include <linux/platform_device.h> | ||
| 20 | #include <linux/platform_data/clk-lpss.h> | ||
| 21 | #include <linux/pm_runtime.h> | ||
| 22 | |||
| 23 | #include "internal.h" | ||
| 24 | |||
| 25 | ACPI_MODULE_NAME("acpi_lpss"); | ||
| 26 | |||
| 27 | #define LPSS_CLK_SIZE 0x04 | ||
| 28 | #define LPSS_LTR_SIZE 0x18 | ||
| 29 | |||
| 30 | /* Offsets relative to LPSS_PRIVATE_OFFSET */ | ||
| 31 | #define LPSS_GENERAL 0x08 | ||
| 32 | #define LPSS_GENERAL_LTR_MODE_SW BIT(2) | ||
| 33 | #define LPSS_SW_LTR 0x10 | ||
| 34 | #define LPSS_AUTO_LTR 0x14 | ||
| 35 | |||
| 36 | struct lpss_device_desc { | ||
| 37 | bool clk_required; | ||
| 38 | const char *clk_parent; | ||
| 39 | bool ltr_required; | ||
| 40 | unsigned int prv_offset; | ||
| 41 | }; | ||
| 42 | |||
| 43 | struct lpss_private_data { | ||
| 44 | void __iomem *mmio_base; | ||
| 45 | resource_size_t mmio_size; | ||
| 46 | struct clk *clk; | ||
| 47 | const struct lpss_device_desc *dev_desc; | ||
| 48 | }; | ||
| 49 | |||
| 50 | static struct lpss_device_desc lpt_dev_desc = { | ||
| 51 | .clk_required = true, | ||
| 52 | .clk_parent = "lpss_clk", | ||
| 53 | .prv_offset = 0x800, | ||
| 54 | .ltr_required = true, | ||
| 55 | }; | ||
| 56 | |||
| 57 | static struct lpss_device_desc lpt_sdio_dev_desc = { | ||
| 58 | .prv_offset = 0x1000, | ||
| 59 | .ltr_required = true, | ||
| 60 | }; | ||
| 61 | |||
| 62 | static const struct acpi_device_id acpi_lpss_device_ids[] = { | ||
| 63 | /* Lynxpoint LPSS devices */ | ||
| 64 | { "INT33C0", (unsigned long)&lpt_dev_desc }, | ||
| 65 | { "INT33C1", (unsigned long)&lpt_dev_desc }, | ||
| 66 | { "INT33C2", (unsigned long)&lpt_dev_desc }, | ||
| 67 | { "INT33C3", (unsigned long)&lpt_dev_desc }, | ||
| 68 | { "INT33C4", (unsigned long)&lpt_dev_desc }, | ||
| 69 | { "INT33C5", (unsigned long)&lpt_dev_desc }, | ||
| 70 | { "INT33C6", (unsigned long)&lpt_sdio_dev_desc }, | ||
| 71 | { "INT33C7", }, | ||
| 72 | |||
| 73 | { } | ||
| 74 | }; | ||
| 75 | |||
| 76 | static int is_memory(struct acpi_resource *res, void *not_used) | ||
| 77 | { | ||
| 78 | struct resource r; | ||
| 79 | return !acpi_dev_resource_memory(res, &r); | ||
| 80 | } | ||
| 81 | |||
| 82 | /* LPSS main clock device. */ | ||
| 83 | static struct platform_device *lpss_clk_dev; | ||
| 84 | |||
| 85 | static inline void lpt_register_clock_device(void) | ||
| 86 | { | ||
| 87 | lpss_clk_dev = platform_device_register_simple("clk-lpt", -1, NULL, 0); | ||
| 88 | } | ||
| 89 | |||
| 90 | static int register_device_clock(struct acpi_device *adev, | ||
| 91 | struct lpss_private_data *pdata) | ||
| 92 | { | ||
| 93 | const struct lpss_device_desc *dev_desc = pdata->dev_desc; | ||
| 94 | |||
| 95 | if (!lpss_clk_dev) | ||
| 96 | lpt_register_clock_device(); | ||
| 97 | |||
| 98 | if (!dev_desc->clk_parent || !pdata->mmio_base | ||
| 99 | || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE) | ||
| 100 | return -ENODATA; | ||
| 101 | |||
| 102 | pdata->clk = clk_register_gate(NULL, dev_name(&adev->dev), | ||
| 103 | dev_desc->clk_parent, 0, | ||
| 104 | pdata->mmio_base + dev_desc->prv_offset, | ||
| 105 | 0, 0, NULL); | ||
| 106 | if (IS_ERR(pdata->clk)) | ||
| 107 | return PTR_ERR(pdata->clk); | ||
| 108 | |||
| 109 | clk_register_clkdev(pdata->clk, NULL, dev_name(&adev->dev)); | ||
| 110 | return 0; | ||
| 111 | } | ||
| 112 | |||
| 113 | static int acpi_lpss_create_device(struct acpi_device *adev, | ||
| 114 | const struct acpi_device_id *id) | ||
| 115 | { | ||
| 116 | struct lpss_device_desc *dev_desc; | ||
| 117 | struct lpss_private_data *pdata; | ||
| 118 | struct resource_list_entry *rentry; | ||
| 119 | struct list_head resource_list; | ||
| 120 | int ret; | ||
| 121 | |||
| 122 | dev_desc = (struct lpss_device_desc *)id->driver_data; | ||
| 123 | if (!dev_desc) | ||
| 124 | return acpi_create_platform_device(adev, id); | ||
| 125 | |||
| 126 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | ||
| 127 | if (!pdata) | ||
| 128 | return -ENOMEM; | ||
| 129 | |||
| 130 | INIT_LIST_HEAD(&resource_list); | ||
| 131 | ret = acpi_dev_get_resources(adev, &resource_list, is_memory, NULL); | ||
| 132 | if (ret < 0) | ||
| 133 | goto err_out; | ||
| 134 | |||
| 135 | list_for_each_entry(rentry, &resource_list, node) | ||
| 136 | if (resource_type(&rentry->res) == IORESOURCE_MEM) { | ||
| 137 | pdata->mmio_size = resource_size(&rentry->res); | ||
| 138 | pdata->mmio_base = ioremap(rentry->res.start, | ||
| 139 | pdata->mmio_size); | ||
| 140 | pdata->dev_desc = dev_desc; | ||
| 141 | break; | ||
| 142 | } | ||
| 143 | |||
| 144 | acpi_dev_free_resource_list(&resource_list); | ||
| 145 | |||
| 146 | if (dev_desc->clk_required) { | ||
| 147 | ret = register_device_clock(adev, pdata); | ||
| 148 | if (ret) { | ||
| 149 | /* | ||
| 150 | * Skip the device, but don't terminate the namespace | ||
| 151 | * scan. | ||
| 152 | */ | ||
| 153 | kfree(pdata); | ||
| 154 | return 0; | ||
| 155 | } | ||
| 156 | } | ||
| 157 | |||
| 158 | adev->driver_data = pdata; | ||
| 159 | ret = acpi_create_platform_device(adev, id); | ||
| 160 | if (ret > 0) | ||
| 161 | return ret; | ||
| 162 | |||
| 163 | adev->driver_data = NULL; | ||
| 164 | |||
| 165 | err_out: | ||
| 166 | kfree(pdata); | ||
| 167 | return ret; | ||
| 168 | } | ||
| 169 | |||
| 170 | static int lpss_reg_read(struct device *dev, unsigned int reg, u32 *val) | ||
| 171 | { | ||
| 172 | struct acpi_device *adev; | ||
| 173 | struct lpss_private_data *pdata; | ||
| 174 | unsigned long flags; | ||
| 175 | int ret; | ||
| 176 | |||
| 177 | ret = acpi_bus_get_device(ACPI_HANDLE(dev), &adev); | ||
| 178 | if (WARN_ON(ret)) | ||
| 179 | return ret; | ||
| 180 | |||
| 181 | spin_lock_irqsave(&dev->power.lock, flags); | ||
| 182 | if (pm_runtime_suspended(dev)) { | ||
| 183 | ret = -EAGAIN; | ||
| 184 | goto out; | ||
| 185 | } | ||
| 186 | pdata = acpi_driver_data(adev); | ||
| 187 | if (WARN_ON(!pdata || !pdata->mmio_base)) { | ||
| 188 | ret = -ENODEV; | ||
| 189 | goto out; | ||
| 190 | } | ||
| 191 | *val = readl(pdata->mmio_base + pdata->dev_desc->prv_offset + reg); | ||
| 192 | |||
| 193 | out: | ||
| 194 | spin_unlock_irqrestore(&dev->power.lock, flags); | ||
| 195 | return ret; | ||
| 196 | } | ||
| 197 | |||
| 198 | static ssize_t lpss_ltr_show(struct device *dev, struct device_attribute *attr, | ||
| 199 | char *buf) | ||
| 200 | { | ||
| 201 | u32 ltr_value = 0; | ||
| 202 | unsigned int reg; | ||
| 203 | int ret; | ||
| 204 | |||
| 205 | reg = strcmp(attr->attr.name, "auto_ltr") ? LPSS_SW_LTR : LPSS_AUTO_LTR; | ||
| 206 | ret = lpss_reg_read(dev, reg, <r_value); | ||
| 207 | if (ret) | ||
| 208 | return ret; | ||
| 209 | |||
| 210 | return snprintf(buf, PAGE_SIZE, "%08x\n", ltr_value); | ||
| 211 | } | ||
| 212 | |||
| 213 | static ssize_t lpss_ltr_mode_show(struct device *dev, | ||
| 214 | struct device_attribute *attr, char *buf) | ||
| 215 | { | ||
| 216 | u32 ltr_mode = 0; | ||
| 217 | char *outstr; | ||
| 218 | int ret; | ||
| 219 | |||
| 220 | ret = lpss_reg_read(dev, LPSS_GENERAL, <r_mode); | ||
| 221 | if (ret) | ||
| 222 | return ret; | ||
| 223 | |||
| 224 | outstr = (ltr_mode & LPSS_GENERAL_LTR_MODE_SW) ? "sw" : "auto"; | ||
| 225 | return sprintf(buf, "%s\n", outstr); | ||
| 226 | } | ||
| 227 | |||
| 228 | static DEVICE_ATTR(auto_ltr, S_IRUSR, lpss_ltr_show, NULL); | ||
| 229 | static DEVICE_ATTR(sw_ltr, S_IRUSR, lpss_ltr_show, NULL); | ||
| 230 | static DEVICE_ATTR(ltr_mode, S_IRUSR, lpss_ltr_mode_show, NULL); | ||
| 231 | |||
| 232 | static struct attribute *lpss_attrs[] = { | ||
| 233 | &dev_attr_auto_ltr.attr, | ||
| 234 | &dev_attr_sw_ltr.attr, | ||
| 235 | &dev_attr_ltr_mode.attr, | ||
| 236 | NULL, | ||
| 237 | }; | ||
| 238 | |||
| 239 | static struct attribute_group lpss_attr_group = { | ||
| 240 | .attrs = lpss_attrs, | ||
| 241 | .name = "lpss_ltr", | ||
| 242 | }; | ||
| 243 | |||
| 244 | static int acpi_lpss_platform_notify(struct notifier_block *nb, | ||
| 245 | unsigned long action, void *data) | ||
| 246 | { | ||
| 247 | struct platform_device *pdev = to_platform_device(data); | ||
| 248 | struct lpss_private_data *pdata; | ||
| 249 | struct acpi_device *adev; | ||
| 250 | const struct acpi_device_id *id; | ||
| 251 | int ret = 0; | ||
| 252 | |||
| 253 | id = acpi_match_device(acpi_lpss_device_ids, &pdev->dev); | ||
| 254 | if (!id || !id->driver_data) | ||
| 255 | return 0; | ||
| 256 | |||
| 257 | if (acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev)) | ||
| 258 | return 0; | ||
| 259 | |||
| 260 | pdata = acpi_driver_data(adev); | ||
| 261 | if (!pdata || !pdata->mmio_base || !pdata->dev_desc->ltr_required) | ||
| 262 | return 0; | ||
| 263 | |||
| 264 | if (pdata->mmio_size < pdata->dev_desc->prv_offset + LPSS_LTR_SIZE) { | ||
| 265 | dev_err(&pdev->dev, "MMIO size insufficient to access LTR\n"); | ||
| 266 | return 0; | ||
| 267 | } | ||
| 268 | |||
| 269 | if (action == BUS_NOTIFY_ADD_DEVICE) | ||
| 270 | ret = sysfs_create_group(&pdev->dev.kobj, &lpss_attr_group); | ||
| 271 | else if (action == BUS_NOTIFY_DEL_DEVICE) | ||
| 272 | sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group); | ||
| 273 | |||
| 274 | return ret; | ||
| 275 | } | ||
| 276 | |||
| 277 | static struct notifier_block acpi_lpss_nb = { | ||
| 278 | .notifier_call = acpi_lpss_platform_notify, | ||
| 279 | }; | ||
| 280 | |||
| 281 | static struct acpi_scan_handler lpss_handler = { | ||
| 282 | .ids = acpi_lpss_device_ids, | ||
| 283 | .attach = acpi_lpss_create_device, | ||
| 284 | }; | ||
| 285 | |||
| 286 | void __init acpi_lpss_init(void) | ||
| 287 | { | ||
| 288 | if (!lpt_clk_init()) { | ||
| 289 | bus_register_notifier(&platform_bus_type, &acpi_lpss_nb); | ||
| 290 | acpi_scan_add_handler(&lpss_handler); | ||
| 291 | } | ||
| 292 | } | ||
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index da1f82b445e0..5e6301e94920 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2004 Intel Corporation <naveen.b.s@intel.com> | 2 | * Copyright (C) 2004, 2013 Intel Corporation |
| 3 | * Author: Naveen B S <naveen.b.s@intel.com> | ||
| 4 | * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 3 | * | 5 | * |
| 4 | * All rights reserved. | 6 | * All rights reserved. |
| 5 | * | 7 | * |
| @@ -25,14 +27,10 @@ | |||
| 25 | * ranges. | 27 | * ranges. |
| 26 | */ | 28 | */ |
| 27 | 29 | ||
| 28 | #include <linux/kernel.h> | ||
| 29 | #include <linux/module.h> | ||
| 30 | #include <linux/init.h> | ||
| 31 | #include <linux/types.h> | ||
| 32 | #include <linux/memory_hotplug.h> | ||
| 33 | #include <linux/slab.h> | ||
| 34 | #include <linux/acpi.h> | 30 | #include <linux/acpi.h> |
| 35 | #include <acpi/acpi_drivers.h> | 31 | #include <linux/memory_hotplug.h> |
| 32 | |||
| 33 | #include "internal.h" | ||
| 36 | 34 | ||
| 37 | #define ACPI_MEMORY_DEVICE_CLASS "memory" | 35 | #define ACPI_MEMORY_DEVICE_CLASS "memory" |
| 38 | #define ACPI_MEMORY_DEVICE_HID "PNP0C80" | 36 | #define ACPI_MEMORY_DEVICE_HID "PNP0C80" |
| @@ -44,32 +42,28 @@ | |||
| 44 | #define PREFIX "ACPI:memory_hp:" | 42 | #define PREFIX "ACPI:memory_hp:" |
| 45 | 43 | ||
| 46 | ACPI_MODULE_NAME("acpi_memhotplug"); | 44 | ACPI_MODULE_NAME("acpi_memhotplug"); |
| 47 | MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>"); | ||
| 48 | MODULE_DESCRIPTION("Hotplug Mem Driver"); | ||
| 49 | MODULE_LICENSE("GPL"); | ||
| 50 | 45 | ||
| 51 | /* Memory Device States */ | 46 | /* Memory Device States */ |
| 52 | #define MEMORY_INVALID_STATE 0 | 47 | #define MEMORY_INVALID_STATE 0 |
| 53 | #define MEMORY_POWER_ON_STATE 1 | 48 | #define MEMORY_POWER_ON_STATE 1 |
| 54 | #define MEMORY_POWER_OFF_STATE 2 | 49 | #define MEMORY_POWER_OFF_STATE 2 |
| 55 | 50 | ||
| 56 | static int acpi_memory_device_add(struct acpi_device *device); | 51 | static int acpi_memory_device_add(struct acpi_device *device, |
| 57 | static int acpi_memory_device_remove(struct acpi_device *device); | 52 | const struct acpi_device_id *not_used); |
| 53 | static void acpi_memory_device_remove(struct acpi_device *device); | ||
| 58 | 54 | ||
| 59 | static const struct acpi_device_id memory_device_ids[] = { | 55 | static const struct acpi_device_id memory_device_ids[] = { |
| 60 | {ACPI_MEMORY_DEVICE_HID, 0}, | 56 | {ACPI_MEMORY_DEVICE_HID, 0}, |
| 61 | {"", 0}, | 57 | {"", 0}, |
| 62 | }; | 58 | }; |
| 63 | MODULE_DEVICE_TABLE(acpi, memory_device_ids); | ||
| 64 | 59 | ||
| 65 | static struct acpi_driver acpi_memory_device_driver = { | 60 | static struct acpi_scan_handler memory_device_handler = { |
| 66 | .name = "acpi_memhotplug", | ||
| 67 | .class = ACPI_MEMORY_DEVICE_CLASS, | ||
| 68 | .ids = memory_device_ids, | 61 | .ids = memory_device_ids, |
| 69 | .ops = { | 62 | .attach = acpi_memory_device_add, |
| 70 | .add = acpi_memory_device_add, | 63 | .detach = acpi_memory_device_remove, |
| 71 | .remove = acpi_memory_device_remove, | 64 | .hotplug = { |
| 72 | }, | 65 | .enabled = true, |
| 66 | }, | ||
| 73 | }; | 67 | }; |
| 74 | 68 | ||
| 75 | struct acpi_memory_info { | 69 | struct acpi_memory_info { |
| @@ -79,7 +73,6 @@ struct acpi_memory_info { | |||
| 79 | unsigned short caching; /* memory cache attribute */ | 73 | unsigned short caching; /* memory cache attribute */ |
| 80 | unsigned short write_protect; /* memory read/write attribute */ | 74 | unsigned short write_protect; /* memory read/write attribute */ |
| 81 | unsigned int enabled:1; | 75 | unsigned int enabled:1; |
| 82 | unsigned int failed:1; | ||
| 83 | }; | 76 | }; |
| 84 | 77 | ||
| 85 | struct acpi_memory_device { | 78 | struct acpi_memory_device { |
| @@ -153,48 +146,6 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) | |||
| 153 | return 0; | 146 | return 0; |
| 154 | } | 147 | } |
| 155 | 148 | ||
| 156 | static int acpi_memory_get_device(acpi_handle handle, | ||
| 157 | struct acpi_memory_device **mem_device) | ||
| 158 | { | ||
| 159 | struct acpi_device *device = NULL; | ||
| 160 | int result = 0; | ||
| 161 | |||
| 162 | acpi_scan_lock_acquire(); | ||
| 163 | |||
| 164 | acpi_bus_get_device(handle, &device); | ||
| 165 | if (device) | ||
| 166 | goto end; | ||
| 167 | |||
| 168 | /* | ||
| 169 | * Now add the notified device. This creates the acpi_device | ||
| 170 | * and invokes .add function | ||
| 171 | */ | ||
| 172 | result = acpi_bus_scan(handle); | ||
| 173 | if (result) { | ||
| 174 | acpi_handle_warn(handle, "ACPI namespace scan failed\n"); | ||
| 175 | result = -EINVAL; | ||
| 176 | goto out; | ||
| 177 | } | ||
| 178 | result = acpi_bus_get_device(handle, &device); | ||
| 179 | if (result) { | ||
| 180 | acpi_handle_warn(handle, "Missing device object\n"); | ||
| 181 | result = -EINVAL; | ||
| 182 | goto out; | ||
| 183 | } | ||
| 184 | |||
| 185 | end: | ||
| 186 | *mem_device = acpi_driver_data(device); | ||
| 187 | if (!(*mem_device)) { | ||
| 188 | dev_err(&device->dev, "driver data not found\n"); | ||
| 189 | result = -ENODEV; | ||
| 190 | goto out; | ||
| 191 | } | ||
| 192 | |||
| 193 | out: | ||
| 194 | acpi_scan_lock_release(); | ||
| 195 | return result; | ||
| 196 | } | ||
| 197 | |||
| 198 | static int acpi_memory_check_device(struct acpi_memory_device *mem_device) | 149 | static int acpi_memory_check_device(struct acpi_memory_device *mem_device) |
| 199 | { | 150 | { |
| 200 | unsigned long long current_status; | 151 | unsigned long long current_status; |
| @@ -249,13 +200,11 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) | |||
| 249 | * returns -EEXIST. If add_memory() returns the other error, it | 200 | * returns -EEXIST. If add_memory() returns the other error, it |
| 250 | * means that this memory block is not used by the kernel. | 201 | * means that this memory block is not used by the kernel. |
| 251 | */ | 202 | */ |
| 252 | if (result && result != -EEXIST) { | 203 | if (result && result != -EEXIST) |
| 253 | info->failed = 1; | ||
| 254 | continue; | 204 | continue; |
| 255 | } | ||
| 256 | 205 | ||
| 257 | if (!result) | 206 | info->enabled = 1; |
| 258 | info->enabled = 1; | 207 | |
| 259 | /* | 208 | /* |
| 260 | * Add num_enable even if add_memory() returns -EEXIST, so the | 209 | * Add num_enable even if add_memory() returns -EEXIST, so the |
| 261 | * device is bound to this driver. | 210 | * device is bound to this driver. |
| @@ -286,16 +235,8 @@ static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device) | |||
| 286 | nid = acpi_get_node(mem_device->device->handle); | 235 | nid = acpi_get_node(mem_device->device->handle); |
| 287 | 236 | ||
| 288 | list_for_each_entry_safe(info, n, &mem_device->res_list, list) { | 237 | list_for_each_entry_safe(info, n, &mem_device->res_list, list) { |
| 289 | if (info->failed) | ||
| 290 | /* The kernel does not use this memory block */ | ||
| 291 | continue; | ||
| 292 | |||
| 293 | if (!info->enabled) | 238 | if (!info->enabled) |
| 294 | /* | 239 | continue; |
| 295 | * The kernel uses this memory block, but it may be not | ||
| 296 | * managed by us. | ||
| 297 | */ | ||
| 298 | return -EBUSY; | ||
| 299 | 240 | ||
| 300 | if (nid < 0) | 241 | if (nid < 0) |
| 301 | nid = memory_add_physaddr_to_nid(info->start_addr); | 242 | nid = memory_add_physaddr_to_nid(info->start_addr); |
| @@ -310,95 +251,21 @@ static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device) | |||
| 310 | return result; | 251 | return result; |
| 311 | } | 252 | } |
| 312 | 253 | ||
| 313 | static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) | ||
| 314 | { | ||
| 315 | struct acpi_memory_device *mem_device; | ||
| 316 | struct acpi_device *device; | ||
| 317 | struct acpi_eject_event *ej_event = NULL; | ||
| 318 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ | ||
| 319 | acpi_status status; | ||
| 320 | |||
| 321 | switch (event) { | ||
| 322 | case ACPI_NOTIFY_BUS_CHECK: | ||
| 323 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 324 | "\nReceived BUS CHECK notification for device\n")); | ||
| 325 | /* Fall Through */ | ||
| 326 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
| 327 | if (event == ACPI_NOTIFY_DEVICE_CHECK) | ||
| 328 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 329 | "\nReceived DEVICE CHECK notification for device\n")); | ||
| 330 | if (acpi_memory_get_device(handle, &mem_device)) { | ||
| 331 | acpi_handle_err(handle, "Cannot find driver data\n"); | ||
| 332 | break; | ||
| 333 | } | ||
| 334 | |||
| 335 | ost_code = ACPI_OST_SC_SUCCESS; | ||
| 336 | break; | ||
| 337 | |||
| 338 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
| 339 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 340 | "\nReceived EJECT REQUEST notification for device\n")); | ||
| 341 | |||
| 342 | status = AE_ERROR; | ||
| 343 | acpi_scan_lock_acquire(); | ||
| 344 | |||
| 345 | if (acpi_bus_get_device(handle, &device)) { | ||
| 346 | acpi_handle_err(handle, "Device doesn't exist\n"); | ||
| 347 | goto unlock; | ||
| 348 | } | ||
| 349 | mem_device = acpi_driver_data(device); | ||
| 350 | if (!mem_device) { | ||
| 351 | acpi_handle_err(handle, "Driver Data is NULL\n"); | ||
| 352 | goto unlock; | ||
| 353 | } | ||
| 354 | |||
| 355 | ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); | ||
| 356 | if (!ej_event) { | ||
| 357 | pr_err(PREFIX "No memory, dropping EJECT\n"); | ||
| 358 | goto unlock; | ||
| 359 | } | ||
| 360 | |||
| 361 | get_device(&device->dev); | ||
| 362 | ej_event->device = device; | ||
| 363 | ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; | ||
| 364 | /* The eject is carried out asynchronously. */ | ||
| 365 | status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, | ||
| 366 | ej_event); | ||
| 367 | if (ACPI_FAILURE(status)) { | ||
| 368 | put_device(&device->dev); | ||
| 369 | kfree(ej_event); | ||
| 370 | } | ||
| 371 | |||
| 372 | unlock: | ||
| 373 | acpi_scan_lock_release(); | ||
| 374 | if (ACPI_SUCCESS(status)) | ||
| 375 | return; | ||
| 376 | default: | ||
| 377 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 378 | "Unsupported event [0x%x]\n", event)); | ||
| 379 | |||
| 380 | /* non-hotplug event; possibly handled by other handler */ | ||
| 381 | return; | ||
| 382 | } | ||
| 383 | |||
| 384 | /* Inform firmware that the hotplug operation has completed */ | ||
| 385 | (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL); | ||
| 386 | } | ||
| 387 | |||
| 388 | static void acpi_memory_device_free(struct acpi_memory_device *mem_device) | 254 | static void acpi_memory_device_free(struct acpi_memory_device *mem_device) |
| 389 | { | 255 | { |
| 390 | if (!mem_device) | 256 | if (!mem_device) |
| 391 | return; | 257 | return; |
| 392 | 258 | ||
| 393 | acpi_memory_free_device_resources(mem_device); | 259 | acpi_memory_free_device_resources(mem_device); |
| 260 | mem_device->device->driver_data = NULL; | ||
| 394 | kfree(mem_device); | 261 | kfree(mem_device); |
| 395 | } | 262 | } |
| 396 | 263 | ||
| 397 | static int acpi_memory_device_add(struct acpi_device *device) | 264 | static int acpi_memory_device_add(struct acpi_device *device, |
| 265 | const struct acpi_device_id *not_used) | ||
| 398 | { | 266 | { |
| 267 | struct acpi_memory_device *mem_device; | ||
| 399 | int result; | 268 | int result; |
| 400 | struct acpi_memory_device *mem_device = NULL; | ||
| 401 | |||
| 402 | 269 | ||
| 403 | if (!device) | 270 | if (!device) |
| 404 | return -EINVAL; | 271 | return -EINVAL; |
| @@ -423,147 +290,36 @@ static int acpi_memory_device_add(struct acpi_device *device) | |||
| 423 | /* Set the device state */ | 290 | /* Set the device state */ |
| 424 | mem_device->state = MEMORY_POWER_ON_STATE; | 291 | mem_device->state = MEMORY_POWER_ON_STATE; |
| 425 | 292 | ||
| 426 | pr_debug("%s\n", acpi_device_name(device)); | 293 | result = acpi_memory_check_device(mem_device); |
| 294 | if (result) { | ||
| 295 | acpi_memory_device_free(mem_device); | ||
| 296 | return 0; | ||
| 297 | } | ||
| 427 | 298 | ||
| 428 | if (!acpi_memory_check_device(mem_device)) { | 299 | result = acpi_memory_enable_device(mem_device); |
| 429 | /* call add_memory func */ | 300 | if (result) { |
| 430 | result = acpi_memory_enable_device(mem_device); | 301 | dev_err(&device->dev, "acpi_memory_enable_device() error\n"); |
| 431 | if (result) { | 302 | acpi_memory_device_free(mem_device); |
| 432 | dev_err(&device->dev, | 303 | return -ENODEV; |
| 433 | "Error in acpi_memory_enable_device\n"); | ||
| 434 | acpi_memory_device_free(mem_device); | ||
| 435 | } | ||
| 436 | } | 304 | } |
| 437 | return result; | 305 | |
| 306 | dev_dbg(&device->dev, "Memory device configured by ACPI\n"); | ||
| 307 | return 1; | ||
| 438 | } | 308 | } |
| 439 | 309 | ||
| 440 | static int acpi_memory_device_remove(struct acpi_device *device) | 310 | static void acpi_memory_device_remove(struct acpi_device *device) |
| 441 | { | 311 | { |
| 442 | struct acpi_memory_device *mem_device = NULL; | 312 | struct acpi_memory_device *mem_device; |
| 443 | int result; | ||
| 444 | 313 | ||
| 445 | if (!device || !acpi_driver_data(device)) | 314 | if (!device || !acpi_driver_data(device)) |
| 446 | return -EINVAL; | 315 | return; |
| 447 | 316 | ||
| 448 | mem_device = acpi_driver_data(device); | 317 | mem_device = acpi_driver_data(device); |
| 449 | 318 | acpi_memory_remove_memory(mem_device); | |
| 450 | result = acpi_memory_remove_memory(mem_device); | ||
| 451 | if (result) | ||
| 452 | return result; | ||
| 453 | |||
| 454 | acpi_memory_device_free(mem_device); | 319 | acpi_memory_device_free(mem_device); |
| 455 | |||
| 456 | return 0; | ||
| 457 | } | ||
| 458 | |||
| 459 | /* | ||
| 460 | * Helper function to check for memory device | ||
| 461 | */ | ||
| 462 | static acpi_status is_memory_device(acpi_handle handle) | ||
| 463 | { | ||
| 464 | char *hardware_id; | ||
| 465 | acpi_status status; | ||
| 466 | struct acpi_device_info *info; | ||
| 467 | |||
| 468 | status = acpi_get_object_info(handle, &info); | ||
| 469 | if (ACPI_FAILURE(status)) | ||
| 470 | return status; | ||
| 471 | |||
| 472 | if (!(info->valid & ACPI_VALID_HID)) { | ||
| 473 | kfree(info); | ||
| 474 | return AE_ERROR; | ||
| 475 | } | ||
| 476 | |||
| 477 | hardware_id = info->hardware_id.string; | ||
| 478 | if ((hardware_id == NULL) || | ||
| 479 | (strcmp(hardware_id, ACPI_MEMORY_DEVICE_HID))) | ||
| 480 | status = AE_ERROR; | ||
| 481 | |||
| 482 | kfree(info); | ||
| 483 | return status; | ||
| 484 | } | ||
| 485 | |||
| 486 | static acpi_status | ||
| 487 | acpi_memory_register_notify_handler(acpi_handle handle, | ||
| 488 | u32 level, void *ctxt, void **retv) | ||
| 489 | { | ||
| 490 | acpi_status status; | ||
| 491 | |||
| 492 | |||
| 493 | status = is_memory_device(handle); | ||
| 494 | if (ACPI_FAILURE(status)) | ||
| 495 | return AE_OK; /* continue */ | ||
| 496 | |||
| 497 | status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
| 498 | acpi_memory_device_notify, NULL); | ||
| 499 | /* continue */ | ||
| 500 | return AE_OK; | ||
| 501 | } | ||
| 502 | |||
| 503 | static acpi_status | ||
| 504 | acpi_memory_deregister_notify_handler(acpi_handle handle, | ||
| 505 | u32 level, void *ctxt, void **retv) | ||
| 506 | { | ||
| 507 | acpi_status status; | ||
| 508 | |||
| 509 | |||
| 510 | status = is_memory_device(handle); | ||
| 511 | if (ACPI_FAILURE(status)) | ||
| 512 | return AE_OK; /* continue */ | ||
| 513 | |||
| 514 | status = acpi_remove_notify_handler(handle, | ||
| 515 | ACPI_SYSTEM_NOTIFY, | ||
| 516 | acpi_memory_device_notify); | ||
| 517 | |||
| 518 | return AE_OK; /* continue */ | ||
| 519 | } | ||
| 520 | |||
| 521 | static int __init acpi_memory_device_init(void) | ||
| 522 | { | ||
| 523 | int result; | ||
| 524 | acpi_status status; | ||
| 525 | |||
| 526 | |||
| 527 | result = acpi_bus_register_driver(&acpi_memory_device_driver); | ||
| 528 | |||
| 529 | if (result < 0) | ||
| 530 | return -ENODEV; | ||
| 531 | |||
| 532 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
| 533 | ACPI_UINT32_MAX, | ||
| 534 | acpi_memory_register_notify_handler, NULL, | ||
| 535 | NULL, NULL); | ||
| 536 | |||
| 537 | if (ACPI_FAILURE(status)) { | ||
| 538 | ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed")); | ||
| 539 | acpi_bus_unregister_driver(&acpi_memory_device_driver); | ||
| 540 | return -ENODEV; | ||
| 541 | } | ||
| 542 | |||
| 543 | return 0; | ||
| 544 | } | 320 | } |
| 545 | 321 | ||
| 546 | static void __exit acpi_memory_device_exit(void) | 322 | void __init acpi_memory_hotplug_init(void) |
| 547 | { | 323 | { |
| 548 | acpi_status status; | 324 | acpi_scan_add_handler_with_hotplug(&memory_device_handler, "memory"); |
| 549 | |||
| 550 | |||
| 551 | /* | ||
| 552 | * Adding this to un-install notification handlers for all the device | ||
| 553 | * handles. | ||
| 554 | */ | ||
| 555 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
| 556 | ACPI_UINT32_MAX, | ||
| 557 | acpi_memory_deregister_notify_handler, NULL, | ||
| 558 | NULL, NULL); | ||
| 559 | |||
| 560 | if (ACPI_FAILURE(status)) | ||
| 561 | ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed")); | ||
| 562 | |||
| 563 | acpi_bus_unregister_driver(&acpi_memory_device_driver); | ||
| 564 | |||
| 565 | return; | ||
| 566 | } | 325 | } |
| 567 | |||
| 568 | module_init(acpi_memory_device_init); | ||
| 569 | module_exit(acpi_memory_device_exit); | ||
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index 31de1043eea0..27bb6a91de5f 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c | |||
| @@ -236,7 +236,7 @@ static int create_power_saving_task(void) | |||
| 236 | ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread, | 236 | ps_tsks[ps_tsk_num] = kthread_run(power_saving_thread, |
| 237 | (void *)(unsigned long)ps_tsk_num, | 237 | (void *)(unsigned long)ps_tsk_num, |
| 238 | "acpi_pad/%d", ps_tsk_num); | 238 | "acpi_pad/%d", ps_tsk_num); |
| 239 | rc = IS_ERR(ps_tsks[ps_tsk_num]) ? PTR_ERR(ps_tsks[ps_tsk_num]) : 0; | 239 | rc = PTR_RET(ps_tsks[ps_tsk_num]); |
| 240 | if (!rc) | 240 | if (!rc) |
| 241 | ps_tsk_num++; | 241 | ps_tsk_num++; |
| 242 | else | 242 | else |
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 26fce4b8a632..fafec5ddf17f 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c | |||
| @@ -22,9 +22,6 @@ | |||
| 22 | 22 | ||
| 23 | ACPI_MODULE_NAME("platform"); | 23 | ACPI_MODULE_NAME("platform"); |
| 24 | 24 | ||
| 25 | /* Flags for acpi_create_platform_device */ | ||
| 26 | #define ACPI_PLATFORM_CLK BIT(0) | ||
| 27 | |||
| 28 | /* | 25 | /* |
| 29 | * The following ACPI IDs are known to be suitable for representing as | 26 | * The following ACPI IDs are known to be suitable for representing as |
| 30 | * platform devices. | 27 | * platform devices. |
| @@ -33,33 +30,9 @@ static const struct acpi_device_id acpi_platform_device_ids[] = { | |||
| 33 | 30 | ||
| 34 | { "PNP0D40" }, | 31 | { "PNP0D40" }, |
| 35 | 32 | ||
| 36 | /* Haswell LPSS devices */ | ||
| 37 | { "INT33C0", ACPI_PLATFORM_CLK }, | ||
| 38 | { "INT33C1", ACPI_PLATFORM_CLK }, | ||
| 39 | { "INT33C2", ACPI_PLATFORM_CLK }, | ||
| 40 | { "INT33C3", ACPI_PLATFORM_CLK }, | ||
| 41 | { "INT33C4", ACPI_PLATFORM_CLK }, | ||
| 42 | { "INT33C5", ACPI_PLATFORM_CLK }, | ||
| 43 | { "INT33C6", ACPI_PLATFORM_CLK }, | ||
| 44 | { "INT33C7", ACPI_PLATFORM_CLK }, | ||
| 45 | |||
| 46 | { } | 33 | { } |
| 47 | }; | 34 | }; |
| 48 | 35 | ||
| 49 | static int acpi_create_platform_clks(struct acpi_device *adev) | ||
| 50 | { | ||
| 51 | static struct platform_device *pdev; | ||
| 52 | |||
| 53 | /* Create Lynxpoint LPSS clocks */ | ||
| 54 | if (!pdev && !strncmp(acpi_device_hid(adev), "INT33C", 6)) { | ||
| 55 | pdev = platform_device_register_simple("clk-lpt", -1, NULL, 0); | ||
| 56 | if (IS_ERR(pdev)) | ||
| 57 | return PTR_ERR(pdev); | ||
| 58 | } | ||
| 59 | |||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | |||
| 63 | /** | 36 | /** |
| 64 | * acpi_create_platform_device - Create platform device for ACPI device node | 37 | * acpi_create_platform_device - Create platform device for ACPI device node |
| 65 | * @adev: ACPI device node to create a platform device for. | 38 | * @adev: ACPI device node to create a platform device for. |
| @@ -71,10 +44,9 @@ static int acpi_create_platform_clks(struct acpi_device *adev) | |||
| 71 | * | 44 | * |
| 72 | * Name of the platform device will be the same as @adev's. | 45 | * Name of the platform device will be the same as @adev's. |
| 73 | */ | 46 | */ |
| 74 | static int acpi_create_platform_device(struct acpi_device *adev, | 47 | int acpi_create_platform_device(struct acpi_device *adev, |
| 75 | const struct acpi_device_id *id) | 48 | const struct acpi_device_id *id) |
| 76 | { | 49 | { |
| 77 | unsigned long flags = id->driver_data; | ||
| 78 | struct platform_device *pdev = NULL; | 50 | struct platform_device *pdev = NULL; |
| 79 | struct acpi_device *acpi_parent; | 51 | struct acpi_device *acpi_parent; |
| 80 | struct platform_device_info pdevinfo; | 52 | struct platform_device_info pdevinfo; |
| @@ -83,14 +55,6 @@ static int acpi_create_platform_device(struct acpi_device *adev, | |||
| 83 | struct resource *resources; | 55 | struct resource *resources; |
| 84 | int count; | 56 | int count; |
| 85 | 57 | ||
| 86 | if (flags & ACPI_PLATFORM_CLK) { | ||
| 87 | int ret = acpi_create_platform_clks(adev); | ||
| 88 | if (ret) { | ||
| 89 | dev_err(&adev->dev, "failed to create clocks\n"); | ||
| 90 | return ret; | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | /* If the ACPI node already has a physical device attached, skip it. */ | 58 | /* If the ACPI node already has a physical device attached, skip it. */ |
| 95 | if (adev->physical_node_count) | 59 | if (adev->physical_node_count) |
| 96 | return 0; | 60 | return 0; |
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index a1b9bf5085a2..7ddf29eca9f5 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile | |||
| @@ -83,6 +83,7 @@ acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o | |||
| 83 | acpi-y += \ | 83 | acpi-y += \ |
| 84 | nsaccess.o \ | 84 | nsaccess.o \ |
| 85 | nsalloc.o \ | 85 | nsalloc.o \ |
| 86 | nsconvert.o \ | ||
| 86 | nsdump.o \ | 87 | nsdump.o \ |
| 87 | nseval.o \ | 88 | nseval.o \ |
| 88 | nsinit.o \ | 89 | nsinit.o \ |
| @@ -160,6 +161,7 @@ acpi-y += \ | |||
| 160 | utobject.o \ | 161 | utobject.o \ |
| 161 | utosi.o \ | 162 | utosi.o \ |
| 162 | utownerid.o \ | 163 | utownerid.o \ |
| 164 | utpredef.o \ | ||
| 163 | utresrc.o \ | 165 | utresrc.o \ |
| 164 | utstate.o \ | 166 | utstate.o \ |
| 165 | utstring.o \ | 167 | utstring.o \ |
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index ecb49927b817..07160928ca25 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h | |||
| @@ -224,6 +224,7 @@ ACPI_EXTERN u8 acpi_gbl_global_lock_pending; | |||
| 224 | */ | 224 | */ |
| 225 | ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */ | 225 | ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */ |
| 226 | ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ | 226 | ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ |
| 227 | ACPI_EXTERN acpi_spinlock acpi_gbl_reference_count_lock; | ||
| 227 | 228 | ||
| 228 | /* Mutex for _OSI support */ | 229 | /* Mutex for _OSI support */ |
| 229 | 230 | ||
| @@ -413,10 +414,12 @@ ACPI_EXTERN u8 acpi_gbl_db_output_flags; | |||
| 413 | 414 | ||
| 414 | #ifdef ACPI_DISASSEMBLER | 415 | #ifdef ACPI_DISASSEMBLER |
| 415 | 416 | ||
| 416 | u8 ACPI_INIT_GLOBAL(acpi_gbl_ignore_noop_operator, FALSE); | 417 | ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_ignore_noop_operator, FALSE); |
| 417 | 418 | ||
| 418 | ACPI_EXTERN u8 acpi_gbl_db_opt_disasm; | 419 | ACPI_EXTERN u8 acpi_gbl_db_opt_disasm; |
| 419 | ACPI_EXTERN u8 acpi_gbl_db_opt_verbose; | 420 | ACPI_EXTERN u8 acpi_gbl_db_opt_verbose; |
| 421 | ACPI_EXTERN u8 acpi_gbl_num_external_methods; | ||
| 422 | ACPI_EXTERN u32 acpi_gbl_resolved_external_methods; | ||
| 420 | ACPI_EXTERN struct acpi_external_list *acpi_gbl_external_list; | 423 | ACPI_EXTERN struct acpi_external_list *acpi_gbl_external_list; |
| 421 | ACPI_EXTERN struct acpi_external_file *acpi_gbl_external_file_list; | 424 | ACPI_EXTERN struct acpi_external_file *acpi_gbl_external_file_list; |
| 422 | #endif | 425 | #endif |
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index 805f419086ab..d5bfbd331bfd 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h | |||
| @@ -294,6 +294,8 @@ acpi_status(*acpi_internal_method) (struct acpi_walk_state * walk_state); | |||
| 294 | #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ | 294 | #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ |
| 295 | #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF | 295 | #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF |
| 296 | 296 | ||
| 297 | #pragma pack(1) | ||
| 298 | |||
| 297 | /* | 299 | /* |
| 298 | * Information structure for ACPI predefined names. | 300 | * Information structure for ACPI predefined names. |
| 299 | * Each entry in the table contains the following items: | 301 | * Each entry in the table contains the following items: |
| @@ -304,7 +306,7 @@ acpi_status(*acpi_internal_method) (struct acpi_walk_state * walk_state); | |||
| 304 | */ | 306 | */ |
| 305 | struct acpi_name_info { | 307 | struct acpi_name_info { |
| 306 | char name[ACPI_NAME_SIZE]; | 308 | char name[ACPI_NAME_SIZE]; |
| 307 | u8 param_count; | 309 | u16 argument_list; |
| 308 | u8 expected_btypes; | 310 | u8 expected_btypes; |
| 309 | }; | 311 | }; |
| 310 | 312 | ||
| @@ -327,7 +329,7 @@ struct acpi_package_info { | |||
| 327 | u8 count1; | 329 | u8 count1; |
| 328 | u8 object_type2; | 330 | u8 object_type2; |
| 329 | u8 count2; | 331 | u8 count2; |
| 330 | u8 reserved; | 332 | u16 reserved; |
| 331 | }; | 333 | }; |
| 332 | 334 | ||
| 333 | /* Used for ACPI_PTYPE2_FIXED */ | 335 | /* Used for ACPI_PTYPE2_FIXED */ |
| @@ -336,6 +338,7 @@ struct acpi_package_info2 { | |||
| 336 | u8 type; | 338 | u8 type; |
| 337 | u8 count; | 339 | u8 count; |
| 338 | u8 object_type[4]; | 340 | u8 object_type[4]; |
| 341 | u8 reserved; | ||
| 339 | }; | 342 | }; |
| 340 | 343 | ||
| 341 | /* Used for ACPI_PTYPE1_OPTION */ | 344 | /* Used for ACPI_PTYPE1_OPTION */ |
| @@ -345,7 +348,7 @@ struct acpi_package_info3 { | |||
| 345 | u8 count; | 348 | u8 count; |
| 346 | u8 object_type[2]; | 349 | u8 object_type[2]; |
| 347 | u8 tail_object_type; | 350 | u8 tail_object_type; |
| 348 | u8 reserved; | 351 | u16 reserved; |
| 349 | }; | 352 | }; |
| 350 | 353 | ||
| 351 | union acpi_predefined_info { | 354 | union acpi_predefined_info { |
| @@ -355,6 +358,10 @@ union acpi_predefined_info { | |||
| 355 | struct acpi_package_info3 ret_info3; | 358 | struct acpi_package_info3 ret_info3; |
| 356 | }; | 359 | }; |
| 357 | 360 | ||
| 361 | /* Reset to default packing */ | ||
| 362 | |||
| 363 | #pragma pack() | ||
| 364 | |||
| 358 | /* Data block used during object validation */ | 365 | /* Data block used during object validation */ |
| 359 | 366 | ||
| 360 | struct acpi_predefined_data { | 367 | struct acpi_predefined_data { |
| @@ -363,6 +370,7 @@ struct acpi_predefined_data { | |||
| 363 | union acpi_operand_object *parent_package; | 370 | union acpi_operand_object *parent_package; |
| 364 | struct acpi_namespace_node *node; | 371 | struct acpi_namespace_node *node; |
| 365 | u32 flags; | 372 | u32 flags; |
| 373 | u32 return_btype; | ||
| 366 | u8 node_flags; | 374 | u8 node_flags; |
| 367 | }; | 375 | }; |
| 368 | 376 | ||
| @@ -371,6 +379,20 @@ struct acpi_predefined_data { | |||
| 371 | #define ACPI_OBJECT_REPAIRED 1 | 379 | #define ACPI_OBJECT_REPAIRED 1 |
| 372 | #define ACPI_OBJECT_WRAPPED 2 | 380 | #define ACPI_OBJECT_WRAPPED 2 |
| 373 | 381 | ||
| 382 | /* Return object auto-repair info */ | ||
| 383 | |||
| 384 | typedef acpi_status(*acpi_object_converter) (union acpi_operand_object | ||
| 385 | *original_object, | ||
| 386 | union acpi_operand_object | ||
| 387 | **converted_object); | ||
| 388 | |||
| 389 | struct acpi_simple_repair_info { | ||
| 390 | char name[ACPI_NAME_SIZE]; | ||
| 391 | u32 unexpected_btypes; | ||
| 392 | u32 package_index; | ||
| 393 | acpi_object_converter object_converter; | ||
| 394 | }; | ||
| 395 | |||
| 374 | /* | 396 | /* |
| 375 | * Bitmapped return value types | 397 | * Bitmapped return value types |
| 376 | * Note: the actual data types must be contiguous, a loop in nspredef.c | 398 | * Note: the actual data types must be contiguous, a loop in nspredef.c |
| @@ -1037,6 +1059,7 @@ struct acpi_external_list { | |||
| 1037 | u16 length; | 1059 | u16 length; |
| 1038 | u8 type; | 1060 | u8 type; |
| 1039 | u8 flags; | 1061 | u8 flags; |
| 1062 | u8 resolved; | ||
| 1040 | }; | 1063 | }; |
| 1041 | 1064 | ||
| 1042 | /* Values for Flags field above */ | 1065 | /* Values for Flags field above */ |
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index ed7943b9044f..53666bd9193d 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h | |||
| @@ -322,10 +322,12 @@ | |||
| 322 | * where a pointer to an object of type union acpi_operand_object can also | 322 | * where a pointer to an object of type union acpi_operand_object can also |
| 323 | * appear. This macro is used to distinguish them. | 323 | * appear. This macro is used to distinguish them. |
| 324 | * | 324 | * |
| 325 | * The "Descriptor" field is the first field in both structures. | 325 | * The "DescriptorType" field is the second field in both structures. |
| 326 | */ | 326 | */ |
| 327 | #define ACPI_GET_DESCRIPTOR_PTR(d) (((union acpi_descriptor *)(void *)(d))->common.common_pointer) | ||
| 328 | #define ACPI_SET_DESCRIPTOR_PTR(d, p) (((union acpi_descriptor *)(void *)(d))->common.common_pointer = (p)) | ||
| 327 | #define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type) | 329 | #define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type) |
| 328 | #define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t) | 330 | #define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = (t)) |
| 329 | 331 | ||
| 330 | /* | 332 | /* |
| 331 | * Macros for the master AML opcode table | 333 | * Macros for the master AML opcode table |
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h index 02cd5482ff8b..d2e491876bc0 100644 --- a/drivers/acpi/acpica/acnamesp.h +++ b/drivers/acpi/acpica/acnamesp.h | |||
| @@ -167,6 +167,29 @@ void acpi_ns_delete_children(struct acpi_namespace_node *parent); | |||
| 167 | int acpi_ns_compare_names(char *name1, char *name2); | 167 | int acpi_ns_compare_names(char *name1, char *name2); |
| 168 | 168 | ||
| 169 | /* | 169 | /* |
| 170 | * nsconvert - Dynamic object conversion routines | ||
| 171 | */ | ||
| 172 | acpi_status | ||
| 173 | acpi_ns_convert_to_integer(union acpi_operand_object *original_object, | ||
| 174 | union acpi_operand_object **return_object); | ||
| 175 | |||
| 176 | acpi_status | ||
| 177 | acpi_ns_convert_to_string(union acpi_operand_object *original_object, | ||
| 178 | union acpi_operand_object **return_object); | ||
| 179 | |||
| 180 | acpi_status | ||
| 181 | acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, | ||
| 182 | union acpi_operand_object **return_object); | ||
| 183 | |||
| 184 | acpi_status | ||
| 185 | acpi_ns_convert_to_unicode(union acpi_operand_object *original_object, | ||
| 186 | union acpi_operand_object **return_object); | ||
| 187 | |||
| 188 | acpi_status | ||
| 189 | acpi_ns_convert_to_resource(union acpi_operand_object *original_object, | ||
| 190 | union acpi_operand_object **return_object); | ||
| 191 | |||
| 192 | /* | ||
| 170 | * nsdump - Namespace dump/print utilities | 193 | * nsdump - Namespace dump/print utilities |
| 171 | */ | 194 | */ |
| 172 | #ifdef ACPI_FUTURE_USAGE | 195 | #ifdef ACPI_FUTURE_USAGE |
| @@ -208,10 +231,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
| 208 | acpi_status return_status, | 231 | acpi_status return_status, |
| 209 | union acpi_operand_object **return_object); | 232 | union acpi_operand_object **return_object); |
| 210 | 233 | ||
| 211 | const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct | ||
| 212 | acpi_namespace_node | ||
| 213 | *node); | ||
| 214 | |||
| 215 | void | 234 | void |
| 216 | acpi_ns_check_parameter_count(char *pathname, | 235 | acpi_ns_check_parameter_count(char *pathname, |
| 217 | struct acpi_namespace_node *node, | 236 | struct acpi_namespace_node *node, |
| @@ -289,7 +308,7 @@ acpi_ns_get_attached_data(struct acpi_namespace_node *node, | |||
| 289 | * predefined methods/objects | 308 | * predefined methods/objects |
| 290 | */ | 309 | */ |
| 291 | acpi_status | 310 | acpi_status |
| 292 | acpi_ns_repair_object(struct acpi_predefined_data *data, | 311 | acpi_ns_simple_repair(struct acpi_predefined_data *data, |
| 293 | u32 expected_btypes, | 312 | u32 expected_btypes, |
| 294 | u32 package_index, | 313 | u32 package_index, |
| 295 | union acpi_operand_object **return_object_ptr); | 314 | union acpi_operand_object **return_object_ptr); |
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h index 752cc40cdc1e..b22b70944fd6 100644 --- a/drivers/acpi/acpica/acpredef.h +++ b/drivers/acpi/acpica/acpredef.h | |||
| @@ -56,7 +56,7 @@ | |||
| 56 | * object type | 56 | * object type |
| 57 | * count | 57 | * count |
| 58 | * | 58 | * |
| 59 | * ACPI_PTYPE1_VAR: Variable-length length: | 59 | * ACPI_PTYPE1_VAR: Variable-length length. Zero-length package is allowed: |
| 60 | * object type (Int/Buf/Ref) | 60 | * object type (Int/Buf/Ref) |
| 61 | * | 61 | * |
| 62 | * ACPI_PTYPE1_OPTION: Package has some required and some optional elements | 62 | * ACPI_PTYPE1_OPTION: Package has some required and some optional elements |
| @@ -66,14 +66,16 @@ | |||
| 66 | * 2) PTYPE2 packages contain a Variable-length number of sub-packages. Each | 66 | * 2) PTYPE2 packages contain a Variable-length number of sub-packages. Each |
| 67 | * of the different types describe the contents of each of the sub-packages. | 67 | * of the different types describe the contents of each of the sub-packages. |
| 68 | * | 68 | * |
| 69 | * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types: | 69 | * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types. Zero-length |
| 70 | * parent package is allowed: | ||
| 70 | * object type | 71 | * object type |
| 71 | * count | 72 | * count |
| 72 | * object type | 73 | * object type |
| 73 | * count | 74 | * count |
| 74 | * (Used for _ALR,_MLS,_PSS,_TRT,_TSS) | 75 | * (Used for _ALR,_MLS,_PSS,_TRT,_TSS) |
| 75 | * | 76 | * |
| 76 | * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element: | 77 | * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element. |
| 78 | * Zero-length parent package is allowed: | ||
| 77 | * object type | 79 | * object type |
| 78 | * (Used for _CSD,_PSD,_TSD) | 80 | * (Used for _CSD,_PSD,_TSD) |
| 79 | * | 81 | * |
| @@ -84,17 +86,19 @@ | |||
| 84 | * count | 86 | * count |
| 85 | * (Used for _CST) | 87 | * (Used for _CST) |
| 86 | * | 88 | * |
| 87 | * ACPI_PTYPE2_FIXED: Each subpackage is of Fixed-length | 89 | * ACPI_PTYPE2_FIXED: Each subpackage is of Fixed-length. Zero-length |
| 90 | * parent package is allowed. | ||
| 88 | * (Used for _PRT) | 91 | * (Used for _PRT) |
| 89 | * | 92 | * |
| 90 | * ACPI_PTYPE2_MIN: Each subpackage has a Variable-length but minimum length | 93 | * ACPI_PTYPE2_MIN: Each subpackage has a Variable-length but minimum length. |
| 94 | * Zero-length parent package is allowed: | ||
| 91 | * (Used for _HPX) | 95 | * (Used for _HPX) |
| 92 | * | 96 | * |
| 93 | * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length | 97 | * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length |
| 94 | * (Used for _ART, _FPS) | 98 | * (Used for _ART, _FPS) |
| 95 | * | 99 | * |
| 96 | * ACPI_PTYPE2_FIX_VAR: Each subpackage consists of some fixed-length elements | 100 | * ACPI_PTYPE2_FIX_VAR: Each subpackage consists of some fixed-length elements |
| 97 | * followed by an optional element | 101 | * followed by an optional element. Zero-length parent package is allowed. |
| 98 | * object type | 102 | * object type |
| 99 | * count | 103 | * count |
| 100 | * object type | 104 | * object type |
| @@ -116,8 +120,47 @@ enum acpi_return_package_types { | |||
| 116 | ACPI_PTYPE2_FIX_VAR = 10 | 120 | ACPI_PTYPE2_FIX_VAR = 10 |
| 117 | }; | 121 | }; |
| 118 | 122 | ||
| 123 | /* Support macros for users of the predefined info table */ | ||
| 124 | |||
| 125 | #define METHOD_PREDEF_ARGS_MAX 4 | ||
| 126 | #define METHOD_ARG_BIT_WIDTH 3 | ||
| 127 | #define METHOD_ARG_MASK 0x0007 | ||
| 128 | #define ARG_COUNT_IS_MINIMUM 0x8000 | ||
| 129 | #define METHOD_MAX_ARG_TYPE ACPI_TYPE_PACKAGE | ||
| 130 | |||
| 131 | #define METHOD_GET_COUNT(arg_list) (arg_list & METHOD_ARG_MASK) | ||
| 132 | #define METHOD_GET_NEXT_ARG(arg_list) (arg_list >> METHOD_ARG_BIT_WIDTH) | ||
| 133 | |||
| 134 | /* Macros used to build the predefined info table */ | ||
| 135 | |||
| 136 | #define METHOD_0ARGS 0 | ||
| 137 | #define METHOD_1ARGS(a1) (1 | (a1 << 3)) | ||
| 138 | #define METHOD_2ARGS(a1,a2) (2 | (a1 << 3) | (a2 << 6)) | ||
| 139 | #define METHOD_3ARGS(a1,a2,a3) (3 | (a1 << 3) | (a2 << 6) | (a3 << 9)) | ||
| 140 | #define METHOD_4ARGS(a1,a2,a3,a4) (4 | (a1 << 3) | (a2 << 6) | (a3 << 9) | (a4 << 12)) | ||
| 141 | |||
| 142 | #define METHOD_RETURNS(type) (type) | ||
| 143 | #define METHOD_NO_RETURN_VALUE 0 | ||
| 144 | |||
| 145 | #define PACKAGE_INFO(a,b,c,d,e,f) {{{(a),(b),(c),(d)}, ((((u16)(f)) << 8) | (e)), 0}} | ||
| 146 | |||
| 147 | /* Support macros for the resource descriptor info table */ | ||
| 148 | |||
| 149 | #define WIDTH_1 0x0001 | ||
| 150 | #define WIDTH_2 0x0002 | ||
| 151 | #define WIDTH_3 0x0004 | ||
| 152 | #define WIDTH_8 0x0008 | ||
| 153 | #define WIDTH_16 0x0010 | ||
| 154 | #define WIDTH_32 0x0020 | ||
| 155 | #define WIDTH_64 0x0040 | ||
| 156 | #define VARIABLE_DATA 0x0080 | ||
| 157 | #define NUM_RESOURCE_WIDTHS 8 | ||
| 158 | |||
| 159 | #define WIDTH_ADDRESS WIDTH_16 | WIDTH_32 | WIDTH_64 | ||
| 160 | |||
| 119 | #ifdef ACPI_CREATE_PREDEFINED_TABLE | 161 | #ifdef ACPI_CREATE_PREDEFINED_TABLE |
| 120 | /* | 162 | /****************************************************************************** |
| 163 | * | ||
| 121 | * Predefined method/object information table. | 164 | * Predefined method/object information table. |
| 122 | * | 165 | * |
| 123 | * These are the names that can actually be evaluated via acpi_evaluate_object. | 166 | * These are the names that can actually be evaluated via acpi_evaluate_object. |
| @@ -125,23 +168,24 @@ enum acpi_return_package_types { | |||
| 125 | * | 168 | * |
| 126 | * 1) Predefined/Reserved names that are never evaluated via | 169 | * 1) Predefined/Reserved names that are never evaluated via |
| 127 | * acpi_evaluate_object: | 170 | * acpi_evaluate_object: |
| 128 | * _Lxx and _Exx GPE methods | 171 | * _Lxx and _Exx GPE methods |
| 129 | * _Qxx EC methods | 172 | * _Qxx EC methods |
| 130 | * _T_x compiler temporary variables | 173 | * _T_x compiler temporary variables |
| 174 | * _Wxx wake events | ||
| 131 | * | 175 | * |
| 132 | * 2) Predefined names that never actually exist within the AML code: | 176 | * 2) Predefined names that never actually exist within the AML code: |
| 133 | * Predefined resource descriptor field names | 177 | * Predefined resource descriptor field names |
| 134 | * | 178 | * |
| 135 | * 3) Predefined names that are implemented within ACPICA: | 179 | * 3) Predefined names that are implemented within ACPICA: |
| 136 | * _OSI | 180 | * _OSI |
| 137 | * | ||
| 138 | * 4) Some predefined names that are not documented within the ACPI spec. | ||
| 139 | * _WDG, _WED | ||
| 140 | * | 181 | * |
| 141 | * The main entries in the table each contain the following items: | 182 | * The main entries in the table each contain the following items: |
| 142 | * | 183 | * |
| 143 | * name - The ACPI reserved name | 184 | * name - The ACPI reserved name |
| 144 | * param_count - Number of arguments to the method | 185 | * argument_list - Contains (in 16 bits), the number of required |
| 186 | * arguments to the method (3 bits), and a 3-bit type | ||
| 187 | * field for each argument (up to 4 arguments). The | ||
| 188 | * METHOD_?ARGS macros generate the correct packed data. | ||
| 145 | * expected_btypes - Allowed type(s) for the return value. | 189 | * expected_btypes - Allowed type(s) for the return value. |
| 146 | * 0 means that no return value is expected. | 190 | * 0 means that no return value is expected. |
| 147 | * | 191 | * |
| @@ -151,256 +195,511 @@ enum acpi_return_package_types { | |||
| 151 | * overall size of the stored data. | 195 | * overall size of the stored data. |
| 152 | * | 196 | * |
| 153 | * Note: The additional braces are intended to promote portability. | 197 | * Note: The additional braces are intended to promote portability. |
| 154 | */ | 198 | * |
| 155 | static const union acpi_predefined_info predefined_names[] = { | 199 | * Note2: Table is used by the kernel-resident subsystem, the iASL compiler, |
| 156 | {{"_AC0", 0, ACPI_RTYPE_INTEGER}}, | 200 | * and the acpi_help utility. |
| 157 | {{"_AC1", 0, ACPI_RTYPE_INTEGER}}, | 201 | * |
| 158 | {{"_AC2", 0, ACPI_RTYPE_INTEGER}}, | 202 | * TBD: _PRT - currently ignore reversed entries. Attempt to fix in nsrepair. |
| 159 | {{"_AC3", 0, ACPI_RTYPE_INTEGER}}, | 203 | * Possibly fixing package elements like _BIF, etc. |
| 160 | {{"_AC4", 0, ACPI_RTYPE_INTEGER}}, | 204 | * |
| 161 | {{"_AC5", 0, ACPI_RTYPE_INTEGER}}, | 205 | *****************************************************************************/ |
| 162 | {{"_AC6", 0, ACPI_RTYPE_INTEGER}}, | 206 | |
| 163 | {{"_AC7", 0, ACPI_RTYPE_INTEGER}}, | 207 | const union acpi_predefined_info acpi_gbl_predefined_methods[] = { |
| 164 | {{"_AC8", 0, ACPI_RTYPE_INTEGER}}, | 208 | {{"_AC0", METHOD_0ARGS, |
| 165 | {{"_AC9", 0, ACPI_RTYPE_INTEGER}}, | 209 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 166 | {{"_ADR", 0, ACPI_RTYPE_INTEGER}}, | 210 | |
| 167 | {{"_AEI", 0, ACPI_RTYPE_BUFFER}}, | 211 | {{"_AC1", METHOD_0ARGS, |
| 168 | {{"_AL0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 212 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 169 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 213 | |
| 170 | 214 | {{"_AC2", METHOD_0ARGS, | |
| 171 | {{"_AL1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 215 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 172 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 216 | |
| 173 | 217 | {{"_AC3", METHOD_0ARGS, | |
| 174 | {{"_AL2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 218 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 175 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 219 | |
| 176 | 220 | {{"_AC4", METHOD_0ARGS, | |
| 177 | {{"_AL3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 221 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 178 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 222 | |
| 179 | 223 | {{"_AC5", METHOD_0ARGS, | |
| 180 | {{"_AL4", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 224 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 181 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 225 | |
| 182 | 226 | {{"_AC6", METHOD_0ARGS, | |
| 183 | {{"_AL5", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 227 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 184 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 228 | |
| 185 | 229 | {{"_AC7", METHOD_0ARGS, | |
| 186 | {{"_AL6", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 230 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 187 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 231 | |
| 188 | 232 | {{"_AC8", METHOD_0ARGS, | |
| 189 | {{"_AL7", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 233 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 190 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 234 | |
| 191 | 235 | {{"_AC9", METHOD_0ARGS, | |
| 192 | {{"_AL8", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 236 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 193 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 237 | |
| 194 | 238 | {{"_ADR", METHOD_0ARGS, | |
| 195 | {{"_AL9", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 239 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 196 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 240 | |
| 197 | 241 | {{"_AEI", METHOD_0ARGS, | |
| 198 | {{"_ALC", 0, ACPI_RTYPE_INTEGER}}, | 242 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, |
| 199 | {{"_ALI", 0, ACPI_RTYPE_INTEGER}}, | 243 | |
| 200 | {{"_ALP", 0, ACPI_RTYPE_INTEGER}}, | 244 | {{"_AL0", METHOD_0ARGS, |
| 201 | {{"_ALR", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2 (Ints) */ | 245 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ |
| 202 | {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, | 246 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 203 | 247 | ||
| 204 | {{"_ALT", 0, ACPI_RTYPE_INTEGER}}, | 248 | {{"_AL1", METHOD_0ARGS, |
| 205 | {{"_ART", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (2 Ref/11 Int) */ | 249 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ |
| 206 | {{{ACPI_PTYPE2_REV_FIXED, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, | 250 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 207 | 11, 0}}, | 251 | |
| 208 | 252 | {{"_AL2", METHOD_0ARGS, | |
| 209 | {{"_BBN", 0, ACPI_RTYPE_INTEGER}}, | 253 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ |
| 210 | {{"_BCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ | 254 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 211 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, | 255 | |
| 212 | 256 | {{"_AL3", METHOD_0ARGS, | |
| 213 | {{"_BCM", 1, 0}}, | 257 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ |
| 214 | {{"_BCT", 1, ACPI_RTYPE_INTEGER}}, | 258 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 215 | {{"_BDN", 0, ACPI_RTYPE_INTEGER}}, | 259 | |
| 216 | {{"_BFS", 1, 0}}, | 260 | {{"_AL4", METHOD_0ARGS, |
| 217 | {{"_BIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (9 Int),(4 Str) */ | 261 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ |
| 218 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 9, ACPI_RTYPE_STRING}, 4, 0}}, | 262 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 219 | 263 | ||
| 220 | {{"_BIX", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int),(4 Str) */ | 264 | {{"_AL5", METHOD_0ARGS, |
| 221 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING}, 4, | 265 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ |
| 222 | 0}}, | 266 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 223 | 267 | ||
| 224 | {{"_BLT", 3, 0}}, | 268 | {{"_AL6", METHOD_0ARGS, |
| 225 | {{"_BMA", 1, ACPI_RTYPE_INTEGER}}, | 269 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ |
| 226 | {{"_BMC", 1, 0}}, | 270 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 227 | {{"_BMD", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (5 Int) */ | 271 | |
| 228 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, | 272 | {{"_AL7", METHOD_0ARGS, |
| 229 | 273 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | |
| 230 | {{"_BMS", 1, ACPI_RTYPE_INTEGER}}, | 274 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 231 | {{"_BQC", 0, ACPI_RTYPE_INTEGER}}, | 275 | |
| 232 | {{"_BST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ | 276 | {{"_AL8", METHOD_0ARGS, |
| 233 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, | 277 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ |
| 234 | 278 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | |
| 235 | {{"_BTM", 1, ACPI_RTYPE_INTEGER}}, | 279 | |
| 236 | {{"_BTP", 1, 0}}, | 280 | {{"_AL9", METHOD_0ARGS, |
| 237 | {{"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* See PCI firmware spec 3.0 */ | 281 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ |
| 238 | {{"_CDM", 0, ACPI_RTYPE_INTEGER}}, | 282 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 239 | {{"_CID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Strs) */ | 283 | |
| 240 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0, 0}, 0, | 284 | {{"_ALC", METHOD_0ARGS, |
| 241 | 0}}, | 285 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 242 | 286 | ||
| 243 | {{"_CLS", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int) */ | 287 | {{"_ALI", METHOD_0ARGS, |
| 244 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, 0}, 0, 0}}, | 288 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 245 | 289 | ||
| 246 | {{"_CPC", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Bufs) */ | 290 | {{"_ALP", METHOD_0ARGS, |
| 247 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER, 0, 0}, 0, | 291 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 248 | 0}}, | 292 | |
| 249 | 293 | {{"_ALR", METHOD_0ARGS, | |
| 250 | {{"_CRS", 0, ACPI_RTYPE_BUFFER}}, | 294 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each 2 (Ints) */ |
| 251 | {{"_CRT", 0, ACPI_RTYPE_INTEGER}}, | 295 | PACKAGE_INFO(ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2, 0, 0, 0), |
| 252 | {{"_CSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n-1 Int) */ | 296 | |
| 253 | {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, | 297 | {{"_ALT", METHOD_0ARGS, |
| 254 | 298 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | |
| 255 | {{"_CST", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */ | 299 | |
| 256 | {{{ACPI_PTYPE2_PKG_COUNT, ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER}, 3, | 300 | {{"_ART", METHOD_0ARGS, |
| 257 | 0}}, | 301 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int(rev), n Pkg (2 Ref/11 Int) */ |
| 258 | 302 | PACKAGE_INFO(ACPI_PTYPE2_REV_FIXED, ACPI_RTYPE_REFERENCE, 2, | |
| 259 | {{"_CWS", 1, ACPI_RTYPE_INTEGER}}, | 303 | ACPI_RTYPE_INTEGER, 11, 0), |
| 260 | {{"_DCK", 1, ACPI_RTYPE_INTEGER}}, | 304 | |
| 261 | {{"_DCS", 0, ACPI_RTYPE_INTEGER}}, | 305 | {{"_BBN", METHOD_0ARGS, |
| 262 | {{"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}}, | 306 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 263 | {{"_DDN", 0, ACPI_RTYPE_STRING}}, | 307 | |
| 264 | {{"_DEP", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 308 | {{"_BCL", METHOD_0ARGS, |
| 265 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}}, | 309 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints) */ |
| 266 | 310 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0), | |
| 267 | {{"_DGS", 0, ACPI_RTYPE_INTEGER}}, | 311 | |
| 268 | {{"_DIS", 0, 0}}, | 312 | {{"_BCM", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 269 | 313 | METHOD_NO_RETURN_VALUE}}, | |
| 270 | {{"_DLM", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (1 Ref, 0/1 Optional Buf/Ref) */ | 314 | |
| 271 | {{{ACPI_PTYPE2_FIX_VAR, ACPI_RTYPE_REFERENCE, 1, | 315 | {{"_BCT", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 272 | ACPI_RTYPE_REFERENCE | ACPI_RTYPE_BUFFER}, 0, 0}}, | 316 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 273 | 317 | ||
| 274 | {{"_DMA", 0, ACPI_RTYPE_BUFFER}}, | 318 | {{"_BDN", METHOD_0ARGS, |
| 275 | {{"_DOD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ | 319 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 276 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, | 320 | |
| 277 | 321 | {{"_BFS", METHOD_1ARGS(ACPI_TYPE_INTEGER), | |
| 278 | {{"_DOS", 1, 0}}, | 322 | METHOD_NO_RETURN_VALUE}}, |
| 279 | {{"_DSM", 4, ACPI_RTYPE_ALL}}, /* Must return a type, but it can be of any type */ | 323 | |
| 280 | {{"_DSS", 1, 0}}, | 324 | {{"_BIF", METHOD_0ARGS, |
| 281 | {{"_DSW", 3, 0}}, | 325 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (9 Int),(4 Str) */ |
| 282 | {{"_DTI", 1, 0}}, | 326 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 9, |
| 283 | {{"_EC_", 0, ACPI_RTYPE_INTEGER}}, | 327 | ACPI_RTYPE_STRING, 4, 0), |
| 284 | {{"_EDL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs)*/ | 328 | |
| 285 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 329 | {{"_BIX", METHOD_0ARGS, |
| 286 | 330 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (16 Int),(4 Str) */ | |
| 287 | {{"_EJ0", 1, 0}}, | 331 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, |
| 288 | {{"_EJ1", 1, 0}}, | 332 | ACPI_RTYPE_STRING, 4, 0), |
| 289 | {{"_EJ2", 1, 0}}, | 333 | |
| 290 | {{"_EJ3", 1, 0}}, | 334 | {{"_BLT", |
| 291 | {{"_EJ4", 1, 0}}, | 335 | METHOD_3ARGS(ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER), |
| 292 | {{"_EJD", 0, ACPI_RTYPE_STRING}}, | 336 | METHOD_NO_RETURN_VALUE}}, |
| 293 | {{"_EVT", 1, 0}}, | 337 | |
| 294 | {{"_FDE", 0, ACPI_RTYPE_BUFFER}}, | 338 | {{"_BMA", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 295 | {{"_FDI", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int) */ | 339 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 296 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16,0}, 0,0}}, | 340 | |
| 297 | 341 | {{"_BMC", METHOD_1ARGS(ACPI_TYPE_INTEGER), | |
| 298 | {{"_FDM", 1, 0}}, | 342 | METHOD_NO_RETURN_VALUE}}, |
| 299 | {{"_FIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ | 343 | |
| 300 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0}, 0, 0}}, | 344 | {{"_BMD", METHOD_0ARGS, |
| 301 | 345 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (5 Int) */ | |
| 302 | {{"_FIX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ | 346 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5, 0, 0, 0), |
| 303 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, | 347 | |
| 304 | 348 | {{"_BMS", METHOD_1ARGS(ACPI_TYPE_INTEGER), | |
| 305 | {{"_FPS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(rev), n Pkg (5 Int) */ | 349 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 306 | {{{ACPI_PTYPE2_REV_FIXED, ACPI_RTYPE_INTEGER, 5, 0}, 0, 0}}, | 350 | |
| 307 | 351 | {{"_BQC", METHOD_0ARGS, | |
| 308 | {{"_FSL", 1, 0}}, | 352 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 309 | {{"_FST", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int) */ | 353 | |
| 310 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, 0}, 0, 0}}, | 354 | {{"_BST", METHOD_0ARGS, |
| 311 | 355 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */ | |
| 312 | {{"_GAI", 0, ACPI_RTYPE_INTEGER}}, | 356 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0), |
| 313 | {{"_GCP", 0, ACPI_RTYPE_INTEGER}}, | 357 | |
| 314 | {{"_GHL", 0, ACPI_RTYPE_INTEGER}}, | 358 | {{"_BTM", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 315 | {{"_GLK", 0, ACPI_RTYPE_INTEGER}}, | 359 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 316 | {{"_GPD", 0, ACPI_RTYPE_INTEGER}}, | 360 | |
| 317 | {{"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */ | 361 | {{"_BTP", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 318 | {{"_GRT", 0, ACPI_RTYPE_BUFFER}}, | 362 | METHOD_NO_RETURN_VALUE}}, |
| 319 | {{"_GSB", 0, ACPI_RTYPE_INTEGER}}, | 363 | |
| 320 | {{"_GTF", 0, ACPI_RTYPE_BUFFER}}, | 364 | {{"_CBA", METHOD_0ARGS, |
| 321 | {{"_GTM", 0, ACPI_RTYPE_BUFFER}}, | 365 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* See PCI firmware spec 3.0 */ |
| 322 | {{"_GTS", 1, 0}}, | 366 | |
| 323 | {{"_GWS", 1, ACPI_RTYPE_INTEGER}}, | 367 | {{"_CDM", METHOD_0ARGS, |
| 324 | {{"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, | 368 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 325 | {{"_HOT", 0, ACPI_RTYPE_INTEGER}}, | 369 | |
| 326 | {{"_HPP", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ | 370 | {{"_CID", METHOD_0ARGS, |
| 327 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, | 371 | METHOD_RETURNS(ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints/Strs) */ |
| 372 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0, | ||
| 373 | 0, 0, 0), | ||
| 374 | |||
| 375 | {{"_CLS", METHOD_0ARGS, | ||
| 376 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (3 Int) */ | ||
| 377 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, 0, 0, 0), | ||
| 378 | |||
| 379 | {{"_CPC", METHOD_0ARGS, | ||
| 380 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints/Bufs) */ | ||
| 381 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER, 0, | ||
| 382 | 0, 0, 0), | ||
| 383 | |||
| 384 | {{"_CRS", METHOD_0ARGS, | ||
| 385 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, | ||
| 386 | |||
| 387 | {{"_CRT", METHOD_0ARGS, | ||
| 388 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 389 | |||
| 390 | {{"_CSD", METHOD_0ARGS, | ||
| 391 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int(n), n-1 Int) */ | ||
| 392 | PACKAGE_INFO(ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0, 0, 0, 0), | ||
| 393 | |||
| 394 | {{"_CST", METHOD_0ARGS, | ||
| 395 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */ | ||
| 396 | PACKAGE_INFO(ACPI_PTYPE2_PKG_COUNT, ACPI_RTYPE_BUFFER, 1, | ||
| 397 | ACPI_RTYPE_INTEGER, 3, 0), | ||
| 398 | |||
| 399 | {{"_CWS", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 400 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 401 | |||
| 402 | {{"_DCK", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 403 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 404 | |||
| 405 | {{"_DCS", METHOD_0ARGS, | ||
| 406 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 407 | |||
| 408 | {{"_DDC", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 409 | METHOD_RETURNS(ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER)}}, | ||
| 410 | |||
| 411 | {{"_DDN", METHOD_0ARGS, | ||
| 412 | METHOD_RETURNS(ACPI_RTYPE_STRING)}}, | ||
| 413 | |||
| 414 | {{"_DEP", METHOD_0ARGS, | ||
| 415 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | ||
| 416 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | ||
| 417 | |||
| 418 | {{"_DGS", METHOD_0ARGS, | ||
| 419 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 420 | |||
| 421 | {{"_DIS", METHOD_0ARGS, | ||
| 422 | METHOD_NO_RETURN_VALUE}}, | ||
| 423 | |||
| 424 | {{"_DLM", METHOD_0ARGS, | ||
| 425 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (1 Ref, 0/1 Optional Buf/Ref) */ | ||
| 426 | PACKAGE_INFO(ACPI_PTYPE2_FIX_VAR, ACPI_RTYPE_REFERENCE, 1, | ||
| 427 | ACPI_RTYPE_REFERENCE | ACPI_RTYPE_BUFFER, 0, 0), | ||
| 428 | |||
| 429 | {{"_DMA", METHOD_0ARGS, | ||
| 430 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, | ||
| 431 | |||
| 432 | {{"_DOD", METHOD_0ARGS, | ||
| 433 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints) */ | ||
| 434 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0), | ||
| 435 | |||
| 436 | {{"_DOS", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 437 | METHOD_NO_RETURN_VALUE}}, | ||
| 438 | |||
| 439 | {{"_DSM", | ||
| 440 | METHOD_4ARGS(ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, | ||
| 441 | ACPI_TYPE_PACKAGE), | ||
| 442 | METHOD_RETURNS(ACPI_RTYPE_ALL)}}, /* Must return a value, but it can be of any type */ | ||
| 443 | |||
| 444 | {{"_DSS", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 445 | METHOD_NO_RETURN_VALUE}}, | ||
| 446 | |||
| 447 | {{"_DSW", | ||
| 448 | METHOD_3ARGS(ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER), | ||
| 449 | METHOD_NO_RETURN_VALUE}}, | ||
| 450 | |||
| 451 | {{"_DTI", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 452 | METHOD_NO_RETURN_VALUE}}, | ||
| 453 | |||
| 454 | {{"_EC_", METHOD_0ARGS, | ||
| 455 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 456 | |||
| 457 | {{"_EDL", METHOD_0ARGS, | ||
| 458 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | ||
| 459 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | ||
| 460 | |||
| 461 | {{"_EJ0", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 462 | METHOD_NO_RETURN_VALUE}}, | ||
| 463 | |||
| 464 | {{"_EJ1", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 465 | METHOD_NO_RETURN_VALUE}}, | ||
| 466 | |||
| 467 | {{"_EJ2", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 468 | METHOD_NO_RETURN_VALUE}}, | ||
| 469 | |||
| 470 | {{"_EJ3", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 471 | METHOD_NO_RETURN_VALUE}}, | ||
| 472 | |||
| 473 | {{"_EJ4", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 474 | METHOD_NO_RETURN_VALUE}}, | ||
| 475 | |||
| 476 | {{"_EJD", METHOD_0ARGS, | ||
| 477 | METHOD_RETURNS(ACPI_RTYPE_STRING)}}, | ||
| 478 | |||
| 479 | {{"_ERR", | ||
| 480 | METHOD_3ARGS(ACPI_TYPE_INTEGER, ACPI_TYPE_STRING, ACPI_TYPE_INTEGER), | ||
| 481 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* Internal use only, used by ACPICA test suites */ | ||
| 482 | |||
| 483 | {{"_EVT", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 484 | METHOD_NO_RETURN_VALUE}}, | ||
| 485 | |||
| 486 | {{"_FDE", METHOD_0ARGS, | ||
| 487 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, | ||
| 488 | |||
| 489 | {{"_FDI", METHOD_0ARGS, | ||
| 490 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (16 Int) */ | ||
| 491 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, 0, 0, 0), | ||
| 492 | |||
| 493 | {{"_FDM", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 494 | METHOD_NO_RETURN_VALUE}}, | ||
| 495 | |||
| 496 | {{"_FIF", METHOD_0ARGS, | ||
| 497 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */ | ||
| 498 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0), | ||
| 499 | |||
| 500 | {{"_FIX", METHOD_0ARGS, | ||
| 501 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints) */ | ||
| 502 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0), | ||
| 503 | |||
| 504 | {{"_FPS", METHOD_0ARGS, | ||
| 505 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int(rev), n Pkg (5 Int) */ | ||
| 506 | PACKAGE_INFO(ACPI_PTYPE2_REV_FIXED, ACPI_RTYPE_INTEGER, 5, 0, 0, 0), | ||
| 507 | |||
| 508 | {{"_FSL", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 509 | METHOD_NO_RETURN_VALUE}}, | ||
| 510 | |||
| 511 | {{"_FST", METHOD_0ARGS, | ||
| 512 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (3 Int) */ | ||
| 513 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, 0, 0, 0), | ||
| 514 | |||
| 515 | {{"_GAI", METHOD_0ARGS, | ||
| 516 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 517 | |||
| 518 | {{"_GCP", METHOD_0ARGS, | ||
| 519 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 520 | |||
| 521 | {{"_GHL", METHOD_0ARGS, | ||
| 522 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 523 | |||
| 524 | {{"_GLK", METHOD_0ARGS, | ||
| 525 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 526 | |||
| 527 | {{"_GPD", METHOD_0ARGS, | ||
| 528 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 529 | |||
| 530 | {{"_GPE", METHOD_0ARGS, | ||
| 531 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* _GPE method, not _GPE scope */ | ||
| 532 | |||
| 533 | {{"_GRT", METHOD_0ARGS, | ||
| 534 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, | ||
| 535 | |||
| 536 | {{"_GSB", METHOD_0ARGS, | ||
| 537 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 538 | |||
| 539 | {{"_GTF", METHOD_0ARGS, | ||
| 540 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, | ||
| 541 | |||
| 542 | {{"_GTM", METHOD_0ARGS, | ||
| 543 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, | ||
| 544 | |||
| 545 | {{"_GTS", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 546 | METHOD_NO_RETURN_VALUE}}, | ||
| 547 | |||
| 548 | {{"_GWS", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 549 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 550 | |||
| 551 | {{"_HID", METHOD_0ARGS, | ||
| 552 | METHOD_RETURNS(ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING)}}, | ||
| 553 | |||
| 554 | {{"_HOT", METHOD_0ARGS, | ||
| 555 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 556 | |||
| 557 | {{"_HPP", METHOD_0ARGS, | ||
| 558 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */ | ||
| 559 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0), | ||
| 328 | 560 | ||
| 329 | /* | 561 | /* |
| 330 | * For _HPX, a single package is returned, containing a Variable-length number | 562 | * For _HPX, a single package is returned, containing a variable-length number |
| 331 | * of sub-packages. Each sub-package contains a PCI record setting. | 563 | * of sub-packages. Each sub-package contains a PCI record setting. |
| 332 | * There are several different type of record settings, of different | 564 | * There are several different type of record settings, of different |
| 333 | * lengths, but all elements of all settings are Integers. | 565 | * lengths, but all elements of all settings are Integers. |
| 334 | */ | 566 | */ |
| 335 | {{"_HPX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (var Ints) */ | 567 | {{"_HPX", METHOD_0ARGS, |
| 336 | {{{ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, | 568 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (var Ints) */ |
| 337 | 569 | PACKAGE_INFO(ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5, 0, 0, 0), | |
| 338 | {{"_HRV", 0, ACPI_RTYPE_INTEGER}}, | 570 | |
| 339 | {{"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ | 571 | {{"_HRV", METHOD_0ARGS, |
| 340 | {{"_INI", 0, 0}}, | 572 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 341 | {{"_IRC", 0, 0}}, | 573 | |
| 342 | {{"_LCK", 1, 0}}, | 574 | {{"_IFT", METHOD_0ARGS, |
| 343 | {{"_LID", 0, ACPI_RTYPE_INTEGER}}, | 575 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* See IPMI spec */ |
| 344 | {{"_MAT", 0, ACPI_RTYPE_BUFFER}}, | 576 | |
| 345 | {{"_MBM", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (8 Int) */ | 577 | {{"_INI", METHOD_0ARGS, |
| 346 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 8, 0}, 0, 0}}, | 578 | METHOD_NO_RETURN_VALUE}}, |
| 347 | 579 | ||
| 348 | {{"_MLS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (1 Str/1 Buf) */ | 580 | {{"_IRC", METHOD_0ARGS, |
| 349 | {{{ACPI_PTYPE2, ACPI_RTYPE_STRING, 1, ACPI_RTYPE_BUFFER}, 1, 0}}, | 581 | METHOD_NO_RETURN_VALUE}}, |
| 350 | 582 | ||
| 351 | {{"_MSG", 1, 0}}, | 583 | {{"_LCK", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 352 | {{"_MSM", 4, ACPI_RTYPE_INTEGER}}, | 584 | METHOD_NO_RETURN_VALUE}}, |
| 353 | {{"_NTT", 0, ACPI_RTYPE_INTEGER}}, | 585 | |
| 354 | {{"_OFF", 0, 0}}, | 586 | {{"_LID", METHOD_0ARGS, |
| 355 | {{"_ON_", 0, 0}}, | 587 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 356 | {{"_OS_", 0, ACPI_RTYPE_STRING}}, | 588 | |
| 357 | {{"_OSC", 4, ACPI_RTYPE_BUFFER}}, | 589 | {{"_MAT", METHOD_0ARGS, |
| 358 | {{"_OST", 3, 0}}, | 590 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, |
| 359 | {{"_PAI", 1, ACPI_RTYPE_INTEGER}}, | 591 | |
| 360 | {{"_PCL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 592 | {{"_MBM", METHOD_0ARGS, |
| 361 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 593 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (8 Int) */ |
| 362 | 594 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 8, 0, 0, 0), | |
| 363 | {{"_PCT", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */ | 595 | |
| 364 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}}, | 596 | {{"_MLS", METHOD_0ARGS, |
| 365 | 597 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (1 Str/1 Buf) */ | |
| 366 | {{"_PDC", 1, 0}}, | 598 | PACKAGE_INFO(ACPI_PTYPE2, ACPI_RTYPE_STRING, 1, ACPI_RTYPE_BUFFER, 1, |
| 367 | {{"_PDL", 0, ACPI_RTYPE_INTEGER}}, | 599 | 0), |
| 368 | {{"_PIC", 1, 0}}, | 600 | |
| 369 | {{"_PIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int),(3 Str) */ | 601 | {{"_MSG", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 370 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, ACPI_RTYPE_STRING}, 3, 0}}, | 602 | METHOD_NO_RETURN_VALUE}}, |
| 371 | 603 | ||
| 372 | {{"_PLD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Bufs) */ | 604 | {{"_MSM", |
| 373 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0,0}, 0,0}}, | 605 | METHOD_4ARGS(ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, |
| 374 | 606 | ACPI_TYPE_INTEGER), | |
| 375 | {{"_PMC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (11 Int),(3 Str) */ | 607 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 376 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 11, ACPI_RTYPE_STRING}, 3, | 608 | |
| 377 | 0}}, | 609 | {{"_NTT", METHOD_0ARGS, |
| 378 | 610 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | |
| 379 | {{"_PMD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 611 | |
| 380 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}}, | 612 | {{"_OFF", METHOD_0ARGS, |
| 381 | 613 | METHOD_NO_RETURN_VALUE}}, | |
| 382 | {{"_PMM", 0, ACPI_RTYPE_INTEGER}}, | 614 | |
| 383 | {{"_PPC", 0, ACPI_RTYPE_INTEGER}}, | 615 | {{"_ON_", METHOD_0ARGS, |
| 384 | {{"_PPE", 0, ACPI_RTYPE_INTEGER}}, /* See dig64 spec */ | 616 | METHOD_NO_RETURN_VALUE}}, |
| 385 | {{"_PR0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 617 | |
| 386 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 618 | {{"_OS_", METHOD_0ARGS, |
| 387 | 619 | METHOD_RETURNS(ACPI_RTYPE_STRING)}}, | |
| 388 | {{"_PR1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 620 | |
| 389 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 621 | {{"_OSC", |
| 390 | 622 | METHOD_4ARGS(ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, | |
| 391 | {{"_PR2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 623 | ACPI_TYPE_BUFFER), |
| 392 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 624 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, |
| 393 | 625 | ||
| 394 | {{"_PR3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 626 | {{"_OST", |
| 395 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}}, | 627 | METHOD_3ARGS(ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_BUFFER), |
| 396 | 628 | METHOD_NO_RETURN_VALUE}}, | |
| 397 | {{"_PRE", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 629 | |
| 398 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}}, | 630 | {{"_PAI", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 399 | 631 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | |
| 400 | {{"_PRL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 632 | |
| 401 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0}, 0, 0}}, | 633 | {{"_PCL", METHOD_0ARGS, |
| 402 | 634 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | |
| 403 | {{"_PRS", 0, ACPI_RTYPE_BUFFER}}, | 635 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 636 | |||
| 637 | {{"_PCT", METHOD_0ARGS, | ||
| 638 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (2 Buf) */ | ||
| 639 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2, 0, 0, 0), | ||
| 640 | |||
| 641 | {{"_PDC", METHOD_1ARGS(ACPI_TYPE_BUFFER), | ||
| 642 | METHOD_NO_RETURN_VALUE}}, | ||
| 643 | |||
| 644 | {{"_PDL", METHOD_0ARGS, | ||
| 645 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 646 | |||
| 647 | {{"_PIC", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 648 | METHOD_NO_RETURN_VALUE}}, | ||
| 649 | |||
| 650 | {{"_PIF", METHOD_0ARGS, | ||
| 651 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (3 Int),(3 Str) */ | ||
| 652 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, | ||
| 653 | ACPI_RTYPE_STRING, 3, 0), | ||
| 654 | |||
| 655 | {{"_PLD", METHOD_0ARGS, | ||
| 656 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Bufs) */ | ||
| 657 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0, 0, 0, 0), | ||
| 658 | |||
| 659 | {{"_PMC", METHOD_0ARGS, | ||
| 660 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (11 Int),(3 Str) */ | ||
| 661 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 11, | ||
| 662 | ACPI_RTYPE_STRING, 3, 0), | ||
| 663 | |||
| 664 | {{"_PMD", METHOD_0ARGS, | ||
| 665 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | ||
| 666 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | ||
| 667 | |||
| 668 | {{"_PMM", METHOD_0ARGS, | ||
| 669 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 670 | |||
| 671 | {{"_PPC", METHOD_0ARGS, | ||
| 672 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 673 | |||
| 674 | {{"_PPE", METHOD_0ARGS, | ||
| 675 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* See dig64 spec */ | ||
| 676 | |||
| 677 | {{"_PR0", METHOD_0ARGS, | ||
| 678 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | ||
| 679 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | ||
| 680 | |||
| 681 | {{"_PR1", METHOD_0ARGS, | ||
| 682 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | ||
| 683 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | ||
| 684 | |||
| 685 | {{"_PR2", METHOD_0ARGS, | ||
| 686 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | ||
| 687 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | ||
| 688 | |||
| 689 | {{"_PR3", METHOD_0ARGS, | ||
| 690 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | ||
| 691 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | ||
| 692 | |||
| 693 | {{"_PRE", METHOD_0ARGS, | ||
| 694 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | ||
| 695 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | ||
| 696 | |||
| 697 | {{"_PRL", METHOD_0ARGS, | ||
| 698 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | ||
| 699 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | ||
| 700 | |||
| 701 | {{"_PRS", METHOD_0ARGS, | ||
| 702 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, | ||
| 404 | 703 | ||
| 405 | /* | 704 | /* |
| 406 | * For _PRT, many BIOSs reverse the 3rd and 4th Package elements (Source | 705 | * For _PRT, many BIOSs reverse the 3rd and 4th Package elements (Source |
| @@ -410,47 +709,89 @@ static const union acpi_predefined_info predefined_names[] = { | |||
| 410 | * warning, add the ACPI_RTYPE_REFERENCE type to the 4th element (index 3) | 709 | * warning, add the ACPI_RTYPE_REFERENCE type to the 4th element (index 3) |
| 411 | * in the statement below. | 710 | * in the statement below. |
| 412 | */ | 711 | */ |
| 413 | {{"_PRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (4): Int,Int,Int/Ref,Int */ | 712 | {{"_PRT", METHOD_0ARGS, |
| 414 | {{{ACPI_PTYPE2_FIXED, 4, ACPI_RTYPE_INTEGER,ACPI_RTYPE_INTEGER}, | 713 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (4): Int,Int,Int/Ref,Int */ |
| 415 | ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE, | 714 | PACKAGE_INFO(ACPI_PTYPE2_FIXED, 4, ACPI_RTYPE_INTEGER, |
| 416 | ACPI_RTYPE_INTEGER}}, | 715 | ACPI_RTYPE_INTEGER, |
| 417 | 716 | ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE, | |
| 418 | {{"_PRW", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each: Pkg/Int,Int,[Variable-length Refs] (Pkg is Ref/Int) */ | 717 | ACPI_RTYPE_INTEGER), |
| 419 | {{{ACPI_PTYPE1_OPTION, 2, ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE, | 718 | |
| 420 | ACPI_RTYPE_INTEGER}, ACPI_RTYPE_REFERENCE,0}}, | 719 | {{"_PRW", METHOD_0ARGS, |
| 421 | 720 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each: Pkg/Int,Int,[Variable-length Refs] (Pkg is Ref/Int) */ | |
| 422 | {{"_PS0", 0, 0}}, | 721 | PACKAGE_INFO(ACPI_PTYPE1_OPTION, 2, |
| 423 | {{"_PS1", 0, 0}}, | 722 | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE, |
| 424 | {{"_PS2", 0, 0}}, | 723 | ACPI_RTYPE_INTEGER, ACPI_RTYPE_REFERENCE, 0), |
| 425 | {{"_PS3", 0, 0}}, | 724 | |
| 426 | {{"_PSC", 0, ACPI_RTYPE_INTEGER}}, | 725 | {{"_PS0", METHOD_0ARGS, |
| 427 | {{"_PSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (5 Int) with count */ | 726 | METHOD_NO_RETURN_VALUE}}, |
| 428 | {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER,0,0}, 0,0}}, | 727 | |
| 429 | 728 | {{"_PS1", METHOD_0ARGS, | |
| 430 | {{"_PSE", 1, 0}}, | 729 | METHOD_NO_RETURN_VALUE}}, |
| 431 | {{"_PSL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 730 | |
| 432 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 731 | {{"_PS2", METHOD_0ARGS, |
| 433 | 732 | METHOD_NO_RETURN_VALUE}}, | |
| 434 | {{"_PSR", 0, ACPI_RTYPE_INTEGER}}, | 733 | |
| 435 | {{"_PSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (6 Int) */ | 734 | {{"_PS3", METHOD_0ARGS, |
| 436 | {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6,0}, 0,0}}, | 735 | METHOD_NO_RETURN_VALUE}}, |
| 437 | 736 | ||
| 438 | {{"_PSV", 0, ACPI_RTYPE_INTEGER}}, | 737 | {{"_PSC", METHOD_0ARGS, |
| 439 | {{"_PSW", 1, 0}}, | 738 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 440 | {{"_PTC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */ | 739 | |
| 441 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2,0}, 0,0}}, | 740 | {{"_PSD", METHOD_0ARGS, |
| 442 | 741 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (5 Int) with count */ | |
| 443 | {{"_PTP", 2, ACPI_RTYPE_INTEGER}}, | 742 | PACKAGE_INFO(ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0, 0, 0, 0), |
| 444 | {{"_PTS", 1, 0}}, | 743 | |
| 445 | {{"_PUR", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Int) */ | 744 | {{"_PSE", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 446 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2, 0}, 0, 0}}, | 745 | METHOD_NO_RETURN_VALUE}}, |
| 447 | 746 | ||
| 448 | {{"_PXM", 0, ACPI_RTYPE_INTEGER}}, | 747 | {{"_PSL", METHOD_0ARGS, |
| 449 | {{"_REG", 2, 0}}, | 748 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ |
| 450 | {{"_REV", 0, ACPI_RTYPE_INTEGER}}, | 749 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), |
| 451 | {{"_RMV", 0, ACPI_RTYPE_INTEGER}}, | 750 | |
| 452 | {{"_ROM", 2, ACPI_RTYPE_BUFFER}}, | 751 | {{"_PSR", METHOD_0ARGS, |
| 453 | {{"_RTV", 0, ACPI_RTYPE_INTEGER}}, | 752 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 753 | |||
| 754 | {{"_PSS", METHOD_0ARGS, | ||
| 755 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each (6 Int) */ | ||
| 756 | PACKAGE_INFO(ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6, 0, 0, 0), | ||
| 757 | |||
| 758 | {{"_PSV", METHOD_0ARGS, | ||
| 759 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 760 | |||
| 761 | {{"_PSW", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 762 | METHOD_NO_RETURN_VALUE}}, | ||
| 763 | |||
| 764 | {{"_PTC", METHOD_0ARGS, | ||
| 765 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (2 Buf) */ | ||
| 766 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2, 0, 0, 0), | ||
| 767 | |||
| 768 | {{"_PTP", METHOD_2ARGS(ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER), | ||
| 769 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 770 | |||
| 771 | {{"_PTS", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 772 | METHOD_NO_RETURN_VALUE}}, | ||
| 773 | |||
| 774 | {{"_PUR", METHOD_0ARGS, | ||
| 775 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (2 Int) */ | ||
| 776 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2, 0, 0, 0), | ||
| 777 | |||
| 778 | {{"_PXM", METHOD_0ARGS, | ||
| 779 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 780 | |||
| 781 | {{"_REG", METHOD_2ARGS(ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER), | ||
| 782 | METHOD_NO_RETURN_VALUE}}, | ||
| 783 | |||
| 784 | {{"_REV", METHOD_0ARGS, | ||
| 785 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 786 | |||
| 787 | {{"_RMV", METHOD_0ARGS, | ||
| 788 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 789 | |||
| 790 | {{"_ROM", METHOD_2ARGS(ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER), | ||
| 791 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, | ||
| 792 | |||
| 793 | {{"_RTV", METHOD_0ARGS, | ||
| 794 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 454 | 795 | ||
| 455 | /* | 796 | /* |
| 456 | * For _S0_ through _S5_, the ACPI spec defines a return Package | 797 | * For _S0_ through _S5_, the ACPI spec defines a return Package |
| @@ -458,111 +799,285 @@ static const union acpi_predefined_info predefined_names[] = { | |||
| 458 | * Allow this by making the objects "Variable-length length", but all elements | 799 | * Allow this by making the objects "Variable-length length", but all elements |
| 459 | * must be Integers. | 800 | * must be Integers. |
| 460 | */ | 801 | */ |
| 461 | {{"_S0_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ | 802 | {{"_S0_", METHOD_0ARGS, |
| 462 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, | 803 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */ |
| 463 | 804 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0), | |
| 464 | {{"_S1_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ | 805 | |
| 465 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, | 806 | {{"_S1_", METHOD_0ARGS, |
| 466 | 807 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */ | |
| 467 | {{"_S2_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ | 808 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0), |
| 468 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, | 809 | |
| 469 | 810 | {{"_S2_", METHOD_0ARGS, | |
| 470 | {{"_S3_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ | 811 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */ |
| 471 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, | 812 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0), |
| 472 | 813 | ||
| 473 | {{"_S4_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ | 814 | {{"_S3_", METHOD_0ARGS, |
| 474 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, | 815 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */ |
| 475 | 816 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0), | |
| 476 | {{"_S5_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ | 817 | |
| 477 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, | 818 | {{"_S4_", METHOD_0ARGS, |
| 478 | 819 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */ | |
| 479 | {{"_S1D", 0, ACPI_RTYPE_INTEGER}}, | 820 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0), |
| 480 | {{"_S2D", 0, ACPI_RTYPE_INTEGER}}, | 821 | |
| 481 | {{"_S3D", 0, ACPI_RTYPE_INTEGER}}, | 822 | {{"_S5_", METHOD_0ARGS, |
| 482 | {{"_S4D", 0, ACPI_RTYPE_INTEGER}}, | 823 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Int) */ |
| 483 | {{"_S0W", 0, ACPI_RTYPE_INTEGER}}, | 824 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0), |
| 484 | {{"_S1W", 0, ACPI_RTYPE_INTEGER}}, | 825 | |
| 485 | {{"_S2W", 0, ACPI_RTYPE_INTEGER}}, | 826 | {{"_S1D", METHOD_0ARGS, |
| 486 | {{"_S3W", 0, ACPI_RTYPE_INTEGER}}, | 827 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 487 | {{"_S4W", 0, ACPI_RTYPE_INTEGER}}, | 828 | |
| 488 | {{"_SBS", 0, ACPI_RTYPE_INTEGER}}, | 829 | {{"_S2D", METHOD_0ARGS, |
| 489 | {{"_SCP", 0x13, 0}}, /* Acpi 1.0 allowed 1 arg. Acpi 3.0 expanded to 3 args. Allow both. */ | 830 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 490 | /* Note: the 3-arg definition may be removed for ACPI 4.0 */ | 831 | |
| 491 | {{"_SDD", 1, 0}}, | 832 | {{"_S3D", METHOD_0ARGS, |
| 492 | {{"_SEG", 0, ACPI_RTYPE_INTEGER}}, | 833 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 493 | {{"_SHL", 1, ACPI_RTYPE_INTEGER}}, | 834 | |
| 494 | {{"_SLI", 0, ACPI_RTYPE_BUFFER}}, | 835 | {{"_S4D", METHOD_0ARGS, |
| 495 | {{"_SPD", 1, ACPI_RTYPE_INTEGER}}, | 836 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 496 | {{"_SRS", 1, 0}}, | 837 | |
| 497 | {{"_SRT", 1, ACPI_RTYPE_INTEGER}}, | 838 | {{"_S0W", METHOD_0ARGS, |
| 498 | {{"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ | 839 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 499 | {{"_SST", 1, 0}}, | 840 | |
| 500 | {{"_STA", 0, ACPI_RTYPE_INTEGER}}, | 841 | {{"_S1W", METHOD_0ARGS, |
| 501 | {{"_STM", 3, 0}}, | 842 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 502 | {{"_STP", 2, ACPI_RTYPE_INTEGER}}, | 843 | |
| 503 | {{"_STR", 0, ACPI_RTYPE_BUFFER}}, | 844 | {{"_S2W", METHOD_0ARGS, |
| 504 | {{"_STV", 2, ACPI_RTYPE_INTEGER}}, | 845 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 505 | {{"_SUB", 0, ACPI_RTYPE_STRING}}, | 846 | |
| 506 | {{"_SUN", 0, ACPI_RTYPE_INTEGER}}, | 847 | {{"_S3W", METHOD_0ARGS, |
| 507 | {{"_SWS", 0, ACPI_RTYPE_INTEGER}}, | 848 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 508 | {{"_TC1", 0, ACPI_RTYPE_INTEGER}}, | 849 | |
| 509 | {{"_TC2", 0, ACPI_RTYPE_INTEGER}}, | 850 | {{"_S4W", METHOD_0ARGS, |
| 510 | {{"_TDL", 0, ACPI_RTYPE_INTEGER}}, | 851 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 511 | {{"_TIP", 1, ACPI_RTYPE_INTEGER}}, | 852 | |
| 512 | {{"_TIV", 1, ACPI_RTYPE_INTEGER}}, | 853 | {{"_SBS", METHOD_0ARGS, |
| 513 | {{"_TMP", 0, ACPI_RTYPE_INTEGER}}, | 854 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 514 | {{"_TPC", 0, ACPI_RTYPE_INTEGER}}, | 855 | |
| 515 | {{"_TPT", 1, 0}}, | 856 | {{"_SCP", METHOD_1ARGS(ACPI_TYPE_INTEGER) | ARG_COUNT_IS_MINIMUM, |
| 516 | {{"_TRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2 Ref/6 Int */ | 857 | METHOD_NO_RETURN_VALUE}}, /* Acpi 1.0 allowed 1 integer arg. Acpi 3.0 expanded to 3 args. Allow both. */ |
| 517 | {{{ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 6, 0}}, | 858 | |
| 518 | 859 | {{"_SDD", METHOD_1ARGS(ACPI_TYPE_BUFFER), | |
| 519 | {{"_TSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5 Int with count */ | 860 | METHOD_NO_RETURN_VALUE}}, |
| 520 | {{{ACPI_PTYPE2_COUNT,ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, | 861 | |
| 521 | 862 | {{"_SEG", METHOD_0ARGS, | |
| 522 | {{"_TSP", 0, ACPI_RTYPE_INTEGER}}, | 863 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 523 | {{"_TSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5 Int */ | 864 | |
| 524 | {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, | 865 | {{"_SHL", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 525 | 866 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | |
| 526 | {{"_TST", 0, ACPI_RTYPE_INTEGER}}, | 867 | |
| 527 | {{"_TTS", 1, 0}}, | 868 | {{"_SLI", METHOD_0ARGS, |
| 528 | {{"_TZD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ | 869 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, |
| 529 | {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, | 870 | |
| 530 | 871 | {{"_SPD", METHOD_1ARGS(ACPI_TYPE_INTEGER), | |
| 531 | {{"_TZM", 0, ACPI_RTYPE_REFERENCE}}, | 872 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 532 | {{"_TZP", 0, ACPI_RTYPE_INTEGER}}, | 873 | |
| 533 | {{"_UID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, | 874 | {{"_SRS", METHOD_1ARGS(ACPI_TYPE_BUFFER), |
| 534 | {{"_UPC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ | 875 | METHOD_NO_RETURN_VALUE}}, |
| 535 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, | 876 | |
| 536 | 877 | {{"_SRT", METHOD_1ARGS(ACPI_TYPE_BUFFER), | |
| 537 | {{"_UPD", 0, ACPI_RTYPE_INTEGER}}, | 878 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, |
| 538 | {{"_UPP", 0, ACPI_RTYPE_INTEGER}}, | 879 | |
| 539 | {{"_VPO", 0, ACPI_RTYPE_INTEGER}}, | 880 | {{"_SRV", METHOD_0ARGS, |
| 881 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, /* See IPMI spec */ | ||
| 882 | |||
| 883 | {{"_SST", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 884 | METHOD_NO_RETURN_VALUE}}, | ||
| 885 | |||
| 886 | {{"_STA", METHOD_0ARGS, | ||
| 887 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 888 | |||
| 889 | {{"_STM", | ||
| 890 | METHOD_3ARGS(ACPI_TYPE_BUFFER, ACPI_TYPE_BUFFER, ACPI_TYPE_BUFFER), | ||
| 891 | METHOD_NO_RETURN_VALUE}}, | ||
| 892 | |||
| 893 | {{"_STP", METHOD_2ARGS(ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER), | ||
| 894 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 895 | |||
| 896 | {{"_STR", METHOD_0ARGS, | ||
| 897 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, | ||
| 898 | |||
| 899 | {{"_STV", METHOD_2ARGS(ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER), | ||
| 900 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 901 | |||
| 902 | {{"_SUB", METHOD_0ARGS, | ||
| 903 | METHOD_RETURNS(ACPI_RTYPE_STRING)}}, | ||
| 904 | |||
| 905 | {{"_SUN", METHOD_0ARGS, | ||
| 906 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 907 | |||
| 908 | {{"_SWS", METHOD_0ARGS, | ||
| 909 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 910 | |||
| 911 | {{"_TC1", METHOD_0ARGS, | ||
| 912 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 913 | |||
| 914 | {{"_TC2", METHOD_0ARGS, | ||
| 915 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 916 | |||
| 917 | {{"_TDL", METHOD_0ARGS, | ||
| 918 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 919 | |||
| 920 | {{"_TIP", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 921 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 922 | |||
| 923 | {{"_TIV", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 924 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 925 | |||
| 926 | {{"_TMP", METHOD_0ARGS, | ||
| 927 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 928 | |||
| 929 | {{"_TPC", METHOD_0ARGS, | ||
| 930 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 931 | |||
| 932 | {{"_TPT", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 933 | METHOD_NO_RETURN_VALUE}}, | ||
| 934 | |||
| 935 | {{"_TRT", METHOD_0ARGS, | ||
| 936 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each 2 Ref/6 Int */ | ||
| 937 | PACKAGE_INFO(ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER, | ||
| 938 | 6, 0), | ||
| 939 | |||
| 940 | {{"_TSD", METHOD_0ARGS, | ||
| 941 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each 5 Int with count */ | ||
| 942 | PACKAGE_INFO(ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 5, 0, 0, 0), | ||
| 943 | |||
| 944 | {{"_TSP", METHOD_0ARGS, | ||
| 945 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 946 | |||
| 947 | {{"_TSS", METHOD_0ARGS, | ||
| 948 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each 5 Int */ | ||
| 949 | PACKAGE_INFO(ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5, 0, 0, 0), | ||
| 950 | |||
| 951 | {{"_TST", METHOD_0ARGS, | ||
| 952 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 953 | |||
| 954 | {{"_TTS", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 955 | METHOD_NO_RETURN_VALUE}}, | ||
| 956 | |||
| 957 | {{"_TZD", METHOD_0ARGS, | ||
| 958 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */ | ||
| 959 | PACKAGE_INFO(ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0), | ||
| 960 | |||
| 961 | {{"_TZM", METHOD_0ARGS, | ||
| 962 | METHOD_RETURNS(ACPI_RTYPE_REFERENCE)}}, | ||
| 963 | |||
| 964 | {{"_TZP", METHOD_0ARGS, | ||
| 965 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 966 | |||
| 967 | {{"_UID", METHOD_0ARGS, | ||
| 968 | METHOD_RETURNS(ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING)}}, | ||
| 969 | |||
| 970 | {{"_UPC", METHOD_0ARGS, | ||
| 971 | METHOD_RETURNS(ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */ | ||
| 972 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0), | ||
| 973 | |||
| 974 | {{"_UPD", METHOD_0ARGS, | ||
| 975 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 976 | |||
| 977 | {{"_UPP", METHOD_0ARGS, | ||
| 978 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 979 | |||
| 980 | {{"_VPO", METHOD_0ARGS, | ||
| 981 | METHOD_RETURNS(ACPI_RTYPE_INTEGER)}}, | ||
| 540 | 982 | ||
| 541 | /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */ | 983 | /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */ |
| 542 | 984 | ||
| 543 | {{"_WAK", 1, | 985 | {{"_WAK", METHOD_1ARGS(ACPI_TYPE_INTEGER), |
| 544 | ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}}, | 986 | METHOD_RETURNS(ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | |
| 545 | {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2,0}, 0,0}}, /* Fixed-length (2 Int), but is optional */ | 987 | ACPI_RTYPE_PACKAGE)}}, |
| 988 | PACKAGE_INFO(ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2, 0, 0, 0), /* Fixed-length (2 Int), but is optional */ | ||
| 546 | 989 | ||
| 547 | /* _WDG/_WED are MS extensions defined by "Windows Instrumentation" */ | 990 | /* _WDG/_WED are MS extensions defined by "Windows Instrumentation" */ |
| 548 | 991 | ||
| 549 | {{"_WDG", 0, ACPI_RTYPE_BUFFER}}, | 992 | {{"_WDG", METHOD_0ARGS, |
| 550 | {{"_WED", 1, | 993 | METHOD_RETURNS(ACPI_RTYPE_BUFFER)}}, |
| 551 | ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER}}, | 994 | |
| 995 | {{"_WED", METHOD_1ARGS(ACPI_TYPE_INTEGER), | ||
| 996 | METHOD_RETURNS(ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | | ||
| 997 | ACPI_RTYPE_BUFFER)}}, | ||
| 552 | 998 | ||
| 553 | {{{0, 0, 0, 0}, 0, 0}} /* Table terminator */ | 999 | PACKAGE_INFO(0, 0, 0, 0, 0, 0) /* Table terminator */ |
| 554 | }; | 1000 | }; |
| 1001 | #else | ||
| 1002 | extern const union acpi_predefined_info acpi_gbl_predefined_methods[]; | ||
| 1003 | #endif | ||
| 555 | 1004 | ||
| 556 | #if 0 | 1005 | #if (defined ACPI_CREATE_RESOURCE_TABLE && defined ACPI_APPLICATION) |
| 1006 | /****************************************************************************** | ||
| 1007 | * | ||
| 1008 | * Predefined names for use in Resource Descriptors. These names do not | ||
| 1009 | * appear in the global Predefined Name table (since these names never | ||
| 1010 | * appear in actual AML byte code, only in the original ASL) | ||
| 1011 | * | ||
| 1012 | * Note: Used by iASL compiler and acpi_help utility only. | ||
| 1013 | * | ||
| 1014 | *****************************************************************************/ | ||
| 557 | 1015 | ||
| 558 | /* This is an internally implemented control method, no need to check */ | 1016 | const union acpi_predefined_info acpi_gbl_resource_names[] = { |
| 559 | { { | 1017 | {{"_ADR", WIDTH_16 | WIDTH_64, 0}}, |
| 560 | "_OSI", 1, ACPI_RTYPE_INTEGER}}, | 1018 | {{"_ALN", WIDTH_8 | WIDTH_16 | WIDTH_32, 0}}, |
| 1019 | {{"_ASI", WIDTH_8, 0}}, | ||
| 1020 | {{"_ASZ", WIDTH_8, 0}}, | ||
| 1021 | {{"_ATT", WIDTH_64, 0}}, | ||
| 1022 | {{"_BAS", WIDTH_16 | WIDTH_32, 0}}, | ||
| 1023 | {{"_BM_", WIDTH_1, 0}}, | ||
| 1024 | {{"_DBT", WIDTH_16, 0}}, /* Acpi 5.0 */ | ||
| 1025 | {{"_DEC", WIDTH_1, 0}}, | ||
| 1026 | {{"_DMA", WIDTH_8, 0}}, | ||
| 1027 | {{"_DPL", WIDTH_1, 0}}, /* Acpi 5.0 */ | ||
| 1028 | {{"_DRS", WIDTH_16, 0}}, /* Acpi 5.0 */ | ||
| 1029 | {{"_END", WIDTH_1, 0}}, /* Acpi 5.0 */ | ||
| 1030 | {{"_FLC", WIDTH_2, 0}}, /* Acpi 5.0 */ | ||
| 1031 | {{"_GRA", WIDTH_ADDRESS, 0}}, | ||
| 1032 | {{"_HE_", WIDTH_1, 0}}, | ||
| 1033 | {{"_INT", WIDTH_16 | WIDTH_32, 0}}, | ||
| 1034 | {{"_IOR", WIDTH_2, 0}}, /* Acpi 5.0 */ | ||
| 1035 | {{"_LEN", WIDTH_8 | WIDTH_ADDRESS, 0}}, | ||
| 1036 | {{"_LIN", WIDTH_8, 0}}, /* Acpi 5.0 */ | ||
| 1037 | {{"_LL_", WIDTH_1, 0}}, | ||
| 1038 | {{"_MAF", WIDTH_1, 0}}, | ||
| 1039 | {{"_MAX", WIDTH_ADDRESS, 0}}, | ||
| 1040 | {{"_MEM", WIDTH_2, 0}}, | ||
| 1041 | {{"_MIF", WIDTH_1, 0}}, | ||
| 1042 | {{"_MIN", WIDTH_ADDRESS, 0}}, | ||
| 1043 | {{"_MOD", WIDTH_1, 0}}, /* Acpi 5.0 */ | ||
| 1044 | {{"_MTP", WIDTH_2, 0}}, | ||
| 1045 | {{"_PAR", WIDTH_8, 0}}, /* Acpi 5.0 */ | ||
| 1046 | {{"_PHA", WIDTH_1, 0}}, /* Acpi 5.0 */ | ||
| 1047 | {{"_PIN", WIDTH_16, 0}}, /* Acpi 5.0 */ | ||
| 1048 | {{"_PPI", WIDTH_8, 0}}, /* Acpi 5.0 */ | ||
| 1049 | {{"_POL", WIDTH_1 | WIDTH_2, 0}}, /* Acpi 5.0 */ | ||
| 1050 | {{"_RBO", WIDTH_8, 0}}, | ||
| 1051 | {{"_RBW", WIDTH_8, 0}}, | ||
| 1052 | {{"_RNG", WIDTH_1, 0}}, | ||
| 1053 | {{"_RT_", WIDTH_8, 0}}, /* Acpi 3.0 */ | ||
| 1054 | {{"_RW_", WIDTH_1, 0}}, | ||
| 1055 | {{"_RXL", WIDTH_16, 0}}, /* Acpi 5.0 */ | ||
| 1056 | {{"_SHR", WIDTH_2, 0}}, | ||
| 1057 | {{"_SIZ", WIDTH_2, 0}}, | ||
| 1058 | {{"_SLV", WIDTH_1, 0}}, /* Acpi 5.0 */ | ||
| 1059 | {{"_SPE", WIDTH_32, 0}}, /* Acpi 5.0 */ | ||
| 1060 | {{"_STB", WIDTH_2, 0}}, /* Acpi 5.0 */ | ||
| 1061 | {{"_TRA", WIDTH_ADDRESS, 0}}, | ||
| 1062 | {{"_TRS", WIDTH_1, 0}}, | ||
| 1063 | {{"_TSF", WIDTH_8, 0}}, /* Acpi 3.0 */ | ||
| 1064 | {{"_TTP", WIDTH_1, 0}}, | ||
| 1065 | {{"_TXL", WIDTH_16, 0}}, /* Acpi 5.0 */ | ||
| 1066 | {{"_TYP", WIDTH_2 | WIDTH_16, 0}}, | ||
| 1067 | {{"_VEN", VARIABLE_DATA, 0}}, /* Acpi 5.0 */ | ||
| 1068 | PACKAGE_INFO(0, 0, 0, 0, 0, 0) /* Table terminator */ | ||
| 1069 | }; | ||
| 561 | 1070 | ||
| 562 | /* TBD: */ | 1071 | static const union acpi_predefined_info acpi_gbl_scope_names[] = { |
| 563 | _PRT - currently ignore reversed entries. attempt to fix here? | 1072 | {{"_GPE", 0, 0}}, |
| 564 | think about possibly fixing package elements like _BIF, etc. | 1073 | {{"_PR_", 0, 0}}, |
| 1074 | {{"_SB_", 0, 0}}, | ||
| 1075 | {{"_SI_", 0, 0}}, | ||
| 1076 | {{"_TZ_", 0, 0}}, | ||
| 1077 | PACKAGE_INFO(0, 0, 0, 0, 0, 0) /* Table terminator */ | ||
| 1078 | }; | ||
| 1079 | #else | ||
| 1080 | extern const union acpi_predefined_info acpi_gbl_resource_names[]; | ||
| 565 | #endif | 1081 | #endif |
| 566 | 1082 | ||
| 567 | #endif | 1083 | #endif |
| 568 | #endif | ||
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 0082fa0a6139..202f4f12d3e2 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h | |||
| @@ -113,9 +113,10 @@ struct acpi_pkg_info { | |||
| 113 | u32 num_packages; | 113 | u32 num_packages; |
| 114 | }; | 114 | }; |
| 115 | 115 | ||
| 116 | /* Object reference counts */ | ||
| 117 | |||
| 116 | #define REF_INCREMENT (u16) 0 | 118 | #define REF_INCREMENT (u16) 0 |
| 117 | #define REF_DECREMENT (u16) 1 | 119 | #define REF_DECREMENT (u16) 1 |
| 118 | #define REF_FORCE_DELETE (u16) 2 | ||
| 119 | 120 | ||
| 120 | /* acpi_ut_dump_buffer */ | 121 | /* acpi_ut_dump_buffer */ |
| 121 | 122 | ||
| @@ -421,7 +422,7 @@ acpi_ut_get_object_size(union acpi_operand_object *obj, acpi_size * obj_length); | |||
| 421 | */ | 422 | */ |
| 422 | acpi_status acpi_ut_initialize_interfaces(void); | 423 | acpi_status acpi_ut_initialize_interfaces(void); |
| 423 | 424 | ||
| 424 | void acpi_ut_interface_terminate(void); | 425 | acpi_status acpi_ut_interface_terminate(void); |
| 425 | 426 | ||
| 426 | acpi_status acpi_ut_install_interface(acpi_string interface_name); | 427 | acpi_status acpi_ut_install_interface(acpi_string interface_name); |
| 427 | 428 | ||
| @@ -432,6 +433,26 @@ struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name); | |||
| 432 | acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state); | 433 | acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state); |
| 433 | 434 | ||
| 434 | /* | 435 | /* |
| 436 | * utpredef - support for predefined names | ||
| 437 | */ | ||
| 438 | const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union | ||
| 439 | acpi_predefined_info | ||
| 440 | *this_name); | ||
| 441 | |||
| 442 | const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name); | ||
| 443 | |||
| 444 | const union acpi_predefined_info *acpi_ut_match_resource_name(char *name); | ||
| 445 | |||
| 446 | void | ||
| 447 | acpi_ut_display_predefined_method(char *buffer, | ||
| 448 | const union acpi_predefined_info *this_name, | ||
| 449 | u8 multi_line); | ||
| 450 | |||
| 451 | void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes); | ||
| 452 | |||
| 453 | u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types); | ||
| 454 | |||
| 455 | /* | ||
| 435 | * utstate - Generic state creation/cache routines | 456 | * utstate - Generic state creation/cache routines |
| 436 | */ | 457 | */ |
| 437 | void | 458 | void |
| @@ -483,7 +504,8 @@ acpi_ut_short_divide(u64 in_dividend, | |||
| 483 | /* | 504 | /* |
| 484 | * utmisc | 505 | * utmisc |
| 485 | */ | 506 | */ |
| 486 | const char *acpi_ut_validate_exception(acpi_status status); | 507 | const struct acpi_exception_info *acpi_ut_validate_exception(acpi_status |
| 508 | status); | ||
| 487 | 509 | ||
| 488 | u8 acpi_ut_is_pci_root_bridge(char *id); | 510 | u8 acpi_ut_is_pci_root_bridge(char *id); |
| 489 | 511 | ||
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c index 4d8c992a51d8..99778997c35a 100644 --- a/drivers/acpi/acpica/dsutils.c +++ b/drivers/acpi/acpica/dsutils.c | |||
| @@ -178,7 +178,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
| 178 | 178 | ||
| 179 | if (!op) { | 179 | if (!op) { |
| 180 | ACPI_ERROR((AE_INFO, "Null Op")); | 180 | ACPI_ERROR((AE_INFO, "Null Op")); |
| 181 | return_VALUE(TRUE); | 181 | return_UINT8(TRUE); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | /* | 184 | /* |
| @@ -210,7 +210,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
| 210 | "At Method level, result of [%s] not used\n", | 210 | "At Method level, result of [%s] not used\n", |
| 211 | acpi_ps_get_opcode_name(op->common. | 211 | acpi_ps_get_opcode_name(op->common. |
| 212 | aml_opcode))); | 212 | aml_opcode))); |
| 213 | return_VALUE(FALSE); | 213 | return_UINT8(FALSE); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | /* Get info on the parent. The root_op is AML_SCOPE */ | 216 | /* Get info on the parent. The root_op is AML_SCOPE */ |
| @@ -219,7 +219,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
| 219 | acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode); | 219 | acpi_ps_get_opcode_info(op->common.parent->common.aml_opcode); |
| 220 | if (parent_info->class == AML_CLASS_UNKNOWN) { | 220 | if (parent_info->class == AML_CLASS_UNKNOWN) { |
| 221 | ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op)); | 221 | ACPI_ERROR((AE_INFO, "Unknown parent opcode Op=%p", op)); |
| 222 | return_VALUE(FALSE); | 222 | return_UINT8(FALSE); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | /* | 225 | /* |
| @@ -307,7 +307,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
| 307 | acpi_ps_get_opcode_name(op->common.parent->common. | 307 | acpi_ps_get_opcode_name(op->common.parent->common. |
| 308 | aml_opcode), op)); | 308 | aml_opcode), op)); |
| 309 | 309 | ||
| 310 | return_VALUE(TRUE); | 310 | return_UINT8(TRUE); |
| 311 | 311 | ||
| 312 | result_not_used: | 312 | result_not_used: |
| 313 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, | 313 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, |
| @@ -316,7 +316,7 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
| 316 | acpi_ps_get_opcode_name(op->common.parent->common. | 316 | acpi_ps_get_opcode_name(op->common.parent->common. |
| 317 | aml_opcode), op)); | 317 | aml_opcode), op)); |
| 318 | 318 | ||
| 319 | return_VALUE(FALSE); | 319 | return_UINT8(FALSE); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | /******************************************************************************* | 322 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c index 44f8325c2bae..e2199a947470 100644 --- a/drivers/acpi/acpica/dswexec.c +++ b/drivers/acpi/acpica/dswexec.c | |||
| @@ -693,7 +693,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) | |||
| 693 | default: | 693 | default: |
| 694 | 694 | ||
| 695 | ACPI_ERROR((AE_INFO, | 695 | ACPI_ERROR((AE_INFO, |
| 696 | "Unimplemented opcode, class=0x%X type=0x%X Opcode=-0x%X Op=%p", | 696 | "Unimplemented opcode, class=0x%X type=0x%X Opcode=0x%X Op=%p", |
| 697 | op_class, op_type, op->common.aml_opcode, | 697 | op_class, op_type, op->common.aml_opcode, |
| 698 | op)); | 698 | op)); |
| 699 | 699 | ||
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c index b8ea0b26cde3..83cd45f4a870 100644 --- a/drivers/acpi/acpica/evevent.c +++ b/drivers/acpi/acpica/evevent.c | |||
| @@ -257,6 +257,8 @@ u32 acpi_ev_fixed_event_detect(void) | |||
| 257 | * | 257 | * |
| 258 | * DESCRIPTION: Clears the status bit for the requested event, calls the | 258 | * DESCRIPTION: Clears the status bit for the requested event, calls the |
| 259 | * handler that previously registered for the event. | 259 | * handler that previously registered for the event. |
| 260 | * NOTE: If there is no handler for the event, the event is | ||
| 261 | * disabled to prevent further interrupts. | ||
| 260 | * | 262 | * |
| 261 | ******************************************************************************/ | 263 | ******************************************************************************/ |
| 262 | 264 | ||
| @@ -271,17 +273,17 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event) | |||
| 271 | status_register_id, ACPI_CLEAR_STATUS); | 273 | status_register_id, ACPI_CLEAR_STATUS); |
| 272 | 274 | ||
| 273 | /* | 275 | /* |
| 274 | * Make sure we've got a handler. If not, report an error. The event is | 276 | * Make sure that a handler exists. If not, report an error |
| 275 | * disabled to prevent further interrupts. | 277 | * and disable the event to prevent further interrupts. |
| 276 | */ | 278 | */ |
| 277 | if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { | 279 | if (!acpi_gbl_fixed_event_handlers[event].handler) { |
| 278 | (void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. | 280 | (void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. |
| 279 | enable_register_id, | 281 | enable_register_id, |
| 280 | ACPI_DISABLE_EVENT); | 282 | ACPI_DISABLE_EVENT); |
| 281 | 283 | ||
| 282 | ACPI_ERROR((AE_INFO, | 284 | ACPI_ERROR((AE_INFO, |
| 283 | "No installed handler for fixed event [0x%08X]", | 285 | "No installed handler for fixed event - %s (%u), disabling", |
| 284 | event)); | 286 | acpi_ut_get_event_name(event), event)); |
| 285 | 287 | ||
| 286 | return (ACPI_INTERRUPT_NOT_HANDLED); | 288 | return (ACPI_INTERRUPT_NOT_HANDLED); |
| 287 | } | 289 | } |
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c index b9adb9a7ed85..a493b528f8f9 100644 --- a/drivers/acpi/acpica/evgpe.c +++ b/drivers/acpi/acpica/evgpe.c | |||
| @@ -707,7 +707,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, | |||
| 707 | if (ACPI_FAILURE(status)) { | 707 | if (ACPI_FAILURE(status)) { |
| 708 | ACPI_EXCEPTION((AE_INFO, status, | 708 | ACPI_EXCEPTION((AE_INFO, status, |
| 709 | "Unable to clear GPE%02X", gpe_number)); | 709 | "Unable to clear GPE%02X", gpe_number)); |
| 710 | return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); | 710 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); |
| 711 | } | 711 | } |
| 712 | } | 712 | } |
| 713 | 713 | ||
| @@ -724,7 +724,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, | |||
| 724 | if (ACPI_FAILURE(status)) { | 724 | if (ACPI_FAILURE(status)) { |
| 725 | ACPI_EXCEPTION((AE_INFO, status, | 725 | ACPI_EXCEPTION((AE_INFO, status, |
| 726 | "Unable to disable GPE%02X", gpe_number)); | 726 | "Unable to disable GPE%02X", gpe_number)); |
| 727 | return_VALUE(ACPI_INTERRUPT_NOT_HANDLED); | 727 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); |
| 728 | } | 728 | } |
| 729 | 729 | ||
| 730 | /* | 730 | /* |
| @@ -784,7 +784,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, | |||
| 784 | break; | 784 | break; |
| 785 | } | 785 | } |
| 786 | 786 | ||
| 787 | return_VALUE(ACPI_INTERRUPT_HANDLED); | 787 | return_UINT32(ACPI_INTERRUPT_HANDLED); |
| 788 | } | 788 | } |
| 789 | 789 | ||
| 790 | #endif /* !ACPI_REDUCED_HARDWARE */ | 790 | #endif /* !ACPI_REDUCED_HARDWARE */ |
diff --git a/drivers/acpi/acpica/evsci.c b/drivers/acpi/acpica/evsci.c index f4b43bede015..b905acf7aacd 100644 --- a/drivers/acpi/acpica/evsci.c +++ b/drivers/acpi/acpica/evsci.c | |||
| @@ -89,7 +89,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context) | |||
| 89 | */ | 89 | */ |
| 90 | interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); | 90 | interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); |
| 91 | 91 | ||
| 92 | return_VALUE(interrupt_handled); | 92 | return_UINT32(interrupt_handled); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | /******************************************************************************* | 95 | /******************************************************************************* |
| @@ -120,7 +120,7 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context) | |||
| 120 | 120 | ||
| 121 | interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); | 121 | interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); |
| 122 | 122 | ||
| 123 | return_VALUE(interrupt_handled); | 123 | return_UINT32(interrupt_handled); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | /****************************************************************************** | 126 | /****************************************************************************** |
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c index ddffd6847914..ca5fba99c33b 100644 --- a/drivers/acpi/acpica/evxface.c +++ b/drivers/acpi/acpica/evxface.c | |||
| @@ -467,9 +467,9 @@ acpi_install_fixed_event_handler(u32 event, | |||
| 467 | return_ACPI_STATUS(status); | 467 | return_ACPI_STATUS(status); |
| 468 | } | 468 | } |
| 469 | 469 | ||
| 470 | /* Don't allow two handlers. */ | 470 | /* Do not allow multiple handlers */ |
| 471 | 471 | ||
| 472 | if (NULL != acpi_gbl_fixed_event_handlers[event].handler) { | 472 | if (acpi_gbl_fixed_event_handlers[event].handler) { |
| 473 | status = AE_ALREADY_EXISTS; | 473 | status = AE_ALREADY_EXISTS; |
| 474 | goto cleanup; | 474 | goto cleanup; |
| 475 | } | 475 | } |
| @@ -483,8 +483,9 @@ acpi_install_fixed_event_handler(u32 event, | |||
| 483 | if (ACPI_SUCCESS(status)) | 483 | if (ACPI_SUCCESS(status)) |
| 484 | status = acpi_enable_event(event, 0); | 484 | status = acpi_enable_event(event, 0); |
| 485 | if (ACPI_FAILURE(status)) { | 485 | if (ACPI_FAILURE(status)) { |
| 486 | ACPI_WARNING((AE_INFO, "Could not enable fixed event 0x%X", | 486 | ACPI_WARNING((AE_INFO, |
| 487 | event)); | 487 | "Could not enable fixed event - %s (%u)", |
| 488 | acpi_ut_get_event_name(event), event)); | ||
| 488 | 489 | ||
| 489 | /* Remove the handler */ | 490 | /* Remove the handler */ |
| 490 | 491 | ||
| @@ -492,7 +493,8 @@ acpi_install_fixed_event_handler(u32 event, | |||
| 492 | acpi_gbl_fixed_event_handlers[event].context = NULL; | 493 | acpi_gbl_fixed_event_handlers[event].context = NULL; |
| 493 | } else { | 494 | } else { |
| 494 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 495 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 495 | "Enabled fixed event %X, Handler=%p\n", event, | 496 | "Enabled fixed event %s (%X), Handler=%p\n", |
| 497 | acpi_ut_get_event_name(event), event, | ||
| 496 | handler)); | 498 | handler)); |
| 497 | } | 499 | } |
| 498 | 500 | ||
| @@ -544,11 +546,12 @@ acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler) | |||
| 544 | 546 | ||
| 545 | if (ACPI_FAILURE(status)) { | 547 | if (ACPI_FAILURE(status)) { |
| 546 | ACPI_WARNING((AE_INFO, | 548 | ACPI_WARNING((AE_INFO, |
| 547 | "Could not write to fixed event enable register 0x%X", | 549 | "Could not disable fixed event - %s (%u)", |
| 548 | event)); | 550 | acpi_ut_get_event_name(event), event)); |
| 549 | } else { | 551 | } else { |
| 550 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n", | 552 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 551 | event)); | 553 | "Disabled fixed event - %s (%X)\n", |
| 554 | acpi_ut_get_event_name(event), event)); | ||
| 552 | } | 555 | } |
| 553 | 556 | ||
| 554 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | 557 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c index d6e4e42316db..7039606a0ba8 100644 --- a/drivers/acpi/acpica/evxfevnt.c +++ b/drivers/acpi/acpica/evxfevnt.c | |||
| @@ -74,6 +74,12 @@ acpi_status acpi_enable(void) | |||
| 74 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); | 74 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | /* If the Hardware Reduced flag is set, machine is always in acpi mode */ | ||
| 78 | |||
| 79 | if (acpi_gbl_reduced_hardware) { | ||
| 80 | return_ACPI_STATUS(AE_OK); | ||
| 81 | } | ||
| 82 | |||
| 77 | /* Check current mode */ | 83 | /* Check current mode */ |
| 78 | 84 | ||
| 79 | if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) { | 85 | if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) { |
| @@ -126,6 +132,12 @@ acpi_status acpi_disable(void) | |||
| 126 | 132 | ||
| 127 | ACPI_FUNCTION_TRACE(acpi_disable); | 133 | ACPI_FUNCTION_TRACE(acpi_disable); |
| 128 | 134 | ||
| 135 | /* If the Hardware Reduced flag is set, machine is always in acpi mode */ | ||
| 136 | |||
| 137 | if (acpi_gbl_reduced_hardware) { | ||
| 138 | return_ACPI_STATUS(AE_OK); | ||
| 139 | } | ||
| 140 | |||
| 129 | if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) { | 141 | if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) { |
| 130 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, | 142 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
| 131 | "System is already in legacy (non-ACPI) mode\n")); | 143 | "System is already in legacy (non-ACPI) mode\n")); |
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c index e491e46f17df..b0838a4ea53e 100644 --- a/drivers/acpi/acpica/exoparg2.c +++ b/drivers/acpi/acpica/exoparg2.c | |||
| @@ -257,7 +257,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
| 257 | union acpi_operand_object *return_desc = NULL; | 257 | union acpi_operand_object *return_desc = NULL; |
| 258 | u64 index; | 258 | u64 index; |
| 259 | acpi_status status = AE_OK; | 259 | acpi_status status = AE_OK; |
| 260 | acpi_size length; | 260 | acpi_size length = 0; |
| 261 | 261 | ||
| 262 | ACPI_FUNCTION_TRACE_STR(ex_opcode_2A_1T_1R, | 262 | ACPI_FUNCTION_TRACE_STR(ex_opcode_2A_1T_1R, |
| 263 | acpi_ps_get_opcode_name(walk_state->opcode)); | 263 | acpi_ps_get_opcode_name(walk_state->opcode)); |
| @@ -320,7 +320,6 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
| 320 | * NOTE: A length of zero is ok, and will create a zero-length, null | 320 | * NOTE: A length of zero is ok, and will create a zero-length, null |
| 321 | * terminated string. | 321 | * terminated string. |
| 322 | */ | 322 | */ |
| 323 | length = 0; | ||
| 324 | while ((length < operand[0]->buffer.length) && | 323 | while ((length < operand[0]->buffer.length) && |
| 325 | (length < operand[1]->integer.value) && | 324 | (length < operand[1]->integer.value) && |
| 326 | (operand[0]->buffer.pointer[length])) { | 325 | (operand[0]->buffer.pointer[length])) { |
| @@ -376,6 +375,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
| 376 | case ACPI_TYPE_STRING: | 375 | case ACPI_TYPE_STRING: |
| 377 | 376 | ||
| 378 | if (index >= operand[0]->string.length) { | 377 | if (index >= operand[0]->string.length) { |
| 378 | length = operand[0]->string.length; | ||
| 379 | status = AE_AML_STRING_LIMIT; | 379 | status = AE_AML_STRING_LIMIT; |
| 380 | } | 380 | } |
| 381 | 381 | ||
| @@ -386,6 +386,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
| 386 | case ACPI_TYPE_BUFFER: | 386 | case ACPI_TYPE_BUFFER: |
| 387 | 387 | ||
| 388 | if (index >= operand[0]->buffer.length) { | 388 | if (index >= operand[0]->buffer.length) { |
| 389 | length = operand[0]->buffer.length; | ||
| 389 | status = AE_AML_BUFFER_LIMIT; | 390 | status = AE_AML_BUFFER_LIMIT; |
| 390 | } | 391 | } |
| 391 | 392 | ||
| @@ -396,6 +397,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
| 396 | case ACPI_TYPE_PACKAGE: | 397 | case ACPI_TYPE_PACKAGE: |
| 397 | 398 | ||
| 398 | if (index >= operand[0]->package.count) { | 399 | if (index >= operand[0]->package.count) { |
| 400 | length = operand[0]->package.count; | ||
| 399 | status = AE_AML_PACKAGE_LIMIT; | 401 | status = AE_AML_PACKAGE_LIMIT; |
| 400 | } | 402 | } |
| 401 | 403 | ||
| @@ -414,8 +416,9 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
| 414 | 416 | ||
| 415 | if (ACPI_FAILURE(status)) { | 417 | if (ACPI_FAILURE(status)) { |
| 416 | ACPI_EXCEPTION((AE_INFO, status, | 418 | ACPI_EXCEPTION((AE_INFO, status, |
| 417 | "Index (0x%8.8X%8.8X) is beyond end of object", | 419 | "Index (0x%X%8.8X) is beyond end of object (length 0x%X)", |
| 418 | ACPI_FORMAT_UINT64(index))); | 420 | ACPI_FORMAT_UINT64(index), |
| 421 | (u32)length)); | ||
| 419 | goto cleanup; | 422 | goto cleanup; |
| 420 | } | 423 | } |
| 421 | 424 | ||
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c index d6eab81f54fb..6b728aef2dca 100644 --- a/drivers/acpi/acpica/exprep.c +++ b/drivers/acpi/acpica/exprep.c | |||
| @@ -276,7 +276,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, | |||
| 276 | /* Invalid field access type */ | 276 | /* Invalid field access type */ |
| 277 | 277 | ||
| 278 | ACPI_ERROR((AE_INFO, "Unknown field access type 0x%X", access)); | 278 | ACPI_ERROR((AE_INFO, "Unknown field access type 0x%X", access)); |
| 279 | return_VALUE(0); | 279 | return_UINT32(0); |
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) { | 282 | if (obj_desc->common.type == ACPI_TYPE_BUFFER_FIELD) { |
| @@ -289,7 +289,7 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, | |||
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | *return_byte_alignment = byte_alignment; | 291 | *return_byte_alignment = byte_alignment; |
| 292 | return_VALUE(bit_length); | 292 | return_UINT32(bit_length); |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | /******************************************************************************* | 295 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c index b205cbb4b50c..99dc7b287d55 100644 --- a/drivers/acpi/acpica/exutils.c +++ b/drivers/acpi/acpica/exutils.c | |||
| @@ -340,7 +340,7 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base) | |||
| 340 | /* u64 is unsigned, so we don't worry about a '-' prefix */ | 340 | /* u64 is unsigned, so we don't worry about a '-' prefix */ |
| 341 | 341 | ||
| 342 | if (value == 0) { | 342 | if (value == 0) { |
| 343 | return_VALUE(1); | 343 | return_UINT32(1); |
| 344 | } | 344 | } |
| 345 | 345 | ||
| 346 | current_value = value; | 346 | current_value = value; |
| @@ -354,7 +354,7 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base) | |||
| 354 | num_digits++; | 354 | num_digits++; |
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | return_VALUE(num_digits); | 357 | return_UINT32(num_digits); |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | /******************************************************************************* | 360 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c index deb3f61e2bd1..579c3a53ac87 100644 --- a/drivers/acpi/acpica/hwacpi.c +++ b/drivers/acpi/acpica/hwacpi.c | |||
| @@ -66,6 +66,12 @@ acpi_status acpi_hw_set_mode(u32 mode) | |||
| 66 | 66 | ||
| 67 | ACPI_FUNCTION_TRACE(hw_set_mode); | 67 | ACPI_FUNCTION_TRACE(hw_set_mode); |
| 68 | 68 | ||
| 69 | /* If the Hardware Reduced flag is set, machine is always in acpi mode */ | ||
| 70 | |||
| 71 | if (acpi_gbl_reduced_hardware) { | ||
| 72 | return_ACPI_STATUS(AE_OK); | ||
| 73 | } | ||
| 74 | |||
| 69 | /* | 75 | /* |
| 70 | * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, | 76 | * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, |
| 71 | * system does not support mode transition. | 77 | * system does not support mode transition. |
| @@ -146,23 +152,29 @@ u32 acpi_hw_get_mode(void) | |||
| 146 | 152 | ||
| 147 | ACPI_FUNCTION_TRACE(hw_get_mode); | 153 | ACPI_FUNCTION_TRACE(hw_get_mode); |
| 148 | 154 | ||
| 155 | /* If the Hardware Reduced flag is set, machine is always in acpi mode */ | ||
| 156 | |||
| 157 | if (acpi_gbl_reduced_hardware) { | ||
| 158 | return_UINT32(ACPI_SYS_MODE_ACPI); | ||
| 159 | } | ||
| 160 | |||
| 149 | /* | 161 | /* |
| 150 | * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, | 162 | * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, |
| 151 | * system does not support mode transition. | 163 | * system does not support mode transition. |
| 152 | */ | 164 | */ |
| 153 | if (!acpi_gbl_FADT.smi_command) { | 165 | if (!acpi_gbl_FADT.smi_command) { |
| 154 | return_VALUE(ACPI_SYS_MODE_ACPI); | 166 | return_UINT32(ACPI_SYS_MODE_ACPI); |
| 155 | } | 167 | } |
| 156 | 168 | ||
| 157 | status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value); | 169 | status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value); |
| 158 | if (ACPI_FAILURE(status)) { | 170 | if (ACPI_FAILURE(status)) { |
| 159 | return_VALUE(ACPI_SYS_MODE_LEGACY); | 171 | return_UINT32(ACPI_SYS_MODE_LEGACY); |
| 160 | } | 172 | } |
| 161 | 173 | ||
| 162 | if (value) { | 174 | if (value) { |
| 163 | return_VALUE(ACPI_SYS_MODE_ACPI); | 175 | return_UINT32(ACPI_SYS_MODE_ACPI); |
| 164 | } else { | 176 | } else { |
| 165 | return_VALUE(ACPI_SYS_MODE_LEGACY); | 177 | return_UINT32(ACPI_SYS_MODE_LEGACY); |
| 166 | } | 178 | } |
| 167 | } | 179 | } |
| 168 | 180 | ||
diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c new file mode 100644 index 000000000000..8f79a9d2d50e --- /dev/null +++ b/drivers/acpi/acpica/nsconvert.c | |||
| @@ -0,0 +1,443 @@ | |||
| 1 | /****************************************************************************** | ||
| 2 | * | ||
| 3 | * Module Name: nsconvert - Object conversions for objects returned by | ||
| 4 | * predefined methods | ||
| 5 | * | ||
| 6 | *****************************************************************************/ | ||
| 7 | |||
| 8 | /* | ||
| 9 | * Copyright (C) 2000 - 2013, Intel Corp. | ||
| 10 | * All rights reserved. | ||
| 11 | * | ||
| 12 | * Redistribution and use in source and binary forms, with or without | ||
| 13 | * modification, are permitted provided that the following conditions | ||
| 14 | * are met: | ||
| 15 | * 1. Redistributions of source code must retain the above copyright | ||
| 16 | * notice, this list of conditions, and the following disclaimer, | ||
| 17 | * without modification. | ||
| 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
| 19 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
| 20 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
| 21 | * including a substantially similar Disclaimer requirement for further | ||
| 22 | * binary redistribution. | ||
| 23 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
| 24 | * of any contributors may be used to endorse or promote products derived | ||
| 25 | * from this software without specific prior written permission. | ||
| 26 | * | ||
| 27 | * Alternatively, this software may be distributed under the terms of the | ||
| 28 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
| 29 | * Software Foundation. | ||
| 30 | * | ||
| 31 | * NO WARRANTY | ||
| 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
| 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
| 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 42 | * POSSIBILITY OF SUCH DAMAGES. | ||
| 43 | */ | ||
| 44 | |||
| 45 | #include <acpi/acpi.h> | ||
| 46 | #include "accommon.h" | ||
| 47 | #include "acnamesp.h" | ||
| 48 | #include "acinterp.h" | ||
| 49 | #include "acpredef.h" | ||
| 50 | #include "amlresrc.h" | ||
| 51 | |||
| 52 | #define _COMPONENT ACPI_NAMESPACE | ||
| 53 | ACPI_MODULE_NAME("nsconvert") | ||
| 54 | |||
| 55 | /******************************************************************************* | ||
| 56 | * | ||
| 57 | * FUNCTION: acpi_ns_convert_to_integer | ||
| 58 | * | ||
| 59 | * PARAMETERS: original_object - Object to be converted | ||
| 60 | * return_object - Where the new converted object is returned | ||
| 61 | * | ||
| 62 | * RETURN: Status. AE_OK if conversion was successful. | ||
| 63 | * | ||
| 64 | * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer. | ||
| 65 | * | ||
| 66 | ******************************************************************************/ | ||
| 67 | acpi_status | ||
| 68 | acpi_ns_convert_to_integer(union acpi_operand_object *original_object, | ||
| 69 | union acpi_operand_object **return_object) | ||
| 70 | { | ||
| 71 | union acpi_operand_object *new_object; | ||
| 72 | acpi_status status; | ||
| 73 | u64 value = 0; | ||
| 74 | u32 i; | ||
| 75 | |||
| 76 | switch (original_object->common.type) { | ||
| 77 | case ACPI_TYPE_STRING: | ||
| 78 | |||
| 79 | /* String-to-Integer conversion */ | ||
| 80 | |||
| 81 | status = acpi_ut_strtoul64(original_object->string.pointer, | ||
| 82 | ACPI_ANY_BASE, &value); | ||
| 83 | if (ACPI_FAILURE(status)) { | ||
| 84 | return (status); | ||
| 85 | } | ||
| 86 | break; | ||
| 87 | |||
| 88 | case ACPI_TYPE_BUFFER: | ||
| 89 | |||
| 90 | /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */ | ||
| 91 | |||
| 92 | if (original_object->buffer.length > 8) { | ||
| 93 | return (AE_AML_OPERAND_TYPE); | ||
| 94 | } | ||
| 95 | |||
| 96 | /* Extract each buffer byte to create the integer */ | ||
| 97 | |||
| 98 | for (i = 0; i < original_object->buffer.length; i++) { | ||
| 99 | value |= | ||
| 100 | ((u64)original_object->buffer. | ||
| 101 | pointer[i] << (i * 8)); | ||
| 102 | } | ||
| 103 | break; | ||
| 104 | |||
| 105 | default: | ||
| 106 | return (AE_AML_OPERAND_TYPE); | ||
| 107 | } | ||
| 108 | |||
| 109 | new_object = acpi_ut_create_integer_object(value); | ||
| 110 | if (!new_object) { | ||
| 111 | return (AE_NO_MEMORY); | ||
| 112 | } | ||
| 113 | |||
| 114 | *return_object = new_object; | ||
| 115 | return (AE_OK); | ||
| 116 | } | ||
| 117 | |||
| 118 | /******************************************************************************* | ||
| 119 | * | ||
| 120 | * FUNCTION: acpi_ns_convert_to_string | ||
| 121 | * | ||
| 122 | * PARAMETERS: original_object - Object to be converted | ||
| 123 | * return_object - Where the new converted object is returned | ||
| 124 | * | ||
| 125 | * RETURN: Status. AE_OK if conversion was successful. | ||
| 126 | * | ||
| 127 | * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String. | ||
| 128 | * | ||
| 129 | ******************************************************************************/ | ||
| 130 | |||
| 131 | acpi_status | ||
| 132 | acpi_ns_convert_to_string(union acpi_operand_object *original_object, | ||
| 133 | union acpi_operand_object **return_object) | ||
| 134 | { | ||
| 135 | union acpi_operand_object *new_object; | ||
| 136 | acpi_size length; | ||
| 137 | acpi_status status; | ||
| 138 | |||
| 139 | switch (original_object->common.type) { | ||
| 140 | case ACPI_TYPE_INTEGER: | ||
| 141 | /* | ||
| 142 | * Integer-to-String conversion. Commonly, convert | ||
| 143 | * an integer of value 0 to a NULL string. The last element of | ||
| 144 | * _BIF and _BIX packages occasionally need this fix. | ||
| 145 | */ | ||
| 146 | if (original_object->integer.value == 0) { | ||
| 147 | |||
| 148 | /* Allocate a new NULL string object */ | ||
| 149 | |||
| 150 | new_object = acpi_ut_create_string_object(0); | ||
| 151 | if (!new_object) { | ||
| 152 | return (AE_NO_MEMORY); | ||
| 153 | } | ||
| 154 | } else { | ||
| 155 | status = | ||
| 156 | acpi_ex_convert_to_string(original_object, | ||
| 157 | &new_object, | ||
| 158 | ACPI_IMPLICIT_CONVERT_HEX); | ||
| 159 | if (ACPI_FAILURE(status)) { | ||
| 160 | return (status); | ||
| 161 | } | ||
| 162 | } | ||
| 163 | break; | ||
| 164 | |||
| 165 | case ACPI_TYPE_BUFFER: | ||
| 166 | /* | ||
| 167 | * Buffer-to-String conversion. Use a to_string | ||
| 168 | * conversion, no transform performed on the buffer data. The best | ||
| 169 | * example of this is the _BIF method, where the string data from | ||
| 170 | * the battery is often (incorrectly) returned as buffer object(s). | ||
| 171 | */ | ||
| 172 | length = 0; | ||
| 173 | while ((length < original_object->buffer.length) && | ||
| 174 | (original_object->buffer.pointer[length])) { | ||
| 175 | length++; | ||
| 176 | } | ||
| 177 | |||
| 178 | /* Allocate a new string object */ | ||
| 179 | |||
| 180 | new_object = acpi_ut_create_string_object(length); | ||
| 181 | if (!new_object) { | ||
| 182 | return (AE_NO_MEMORY); | ||
| 183 | } | ||
| 184 | |||
| 185 | /* | ||
| 186 | * Copy the raw buffer data with no transform. String is already NULL | ||
| 187 | * terminated at Length+1. | ||
| 188 | */ | ||
| 189 | ACPI_MEMCPY(new_object->string.pointer, | ||
| 190 | original_object->buffer.pointer, length); | ||
| 191 | break; | ||
| 192 | |||
| 193 | default: | ||
| 194 | return (AE_AML_OPERAND_TYPE); | ||
| 195 | } | ||
| 196 | |||
| 197 | *return_object = new_object; | ||
| 198 | return (AE_OK); | ||
| 199 | } | ||
| 200 | |||
| 201 | /******************************************************************************* | ||
| 202 | * | ||
| 203 | * FUNCTION: acpi_ns_convert_to_buffer | ||
| 204 | * | ||
| 205 | * PARAMETERS: original_object - Object to be converted | ||
| 206 | * return_object - Where the new converted object is returned | ||
| 207 | * | ||
| 208 | * RETURN: Status. AE_OK if conversion was successful. | ||
| 209 | * | ||
| 210 | * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer. | ||
| 211 | * | ||
| 212 | ******************************************************************************/ | ||
| 213 | |||
| 214 | acpi_status | ||
| 215 | acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, | ||
| 216 | union acpi_operand_object **return_object) | ||
| 217 | { | ||
| 218 | union acpi_operand_object *new_object; | ||
| 219 | acpi_status status; | ||
| 220 | union acpi_operand_object **elements; | ||
| 221 | u32 *dword_buffer; | ||
| 222 | u32 count; | ||
| 223 | u32 i; | ||
| 224 | |||
| 225 | switch (original_object->common.type) { | ||
| 226 | case ACPI_TYPE_INTEGER: | ||
| 227 | /* | ||
| 228 | * Integer-to-Buffer conversion. | ||
| 229 | * Convert the Integer to a packed-byte buffer. _MAT and other | ||
| 230 | * objects need this sometimes, if a read has been performed on a | ||
| 231 | * Field object that is less than or equal to the global integer | ||
| 232 | * size (32 or 64 bits). | ||
| 233 | */ | ||
| 234 | status = | ||
| 235 | acpi_ex_convert_to_buffer(original_object, &new_object); | ||
| 236 | if (ACPI_FAILURE(status)) { | ||
| 237 | return (status); | ||
| 238 | } | ||
| 239 | break; | ||
| 240 | |||
| 241 | case ACPI_TYPE_STRING: | ||
| 242 | |||
| 243 | /* String-to-Buffer conversion. Simple data copy */ | ||
| 244 | |||
| 245 | new_object = | ||
| 246 | acpi_ut_create_buffer_object(original_object->string. | ||
| 247 | length); | ||
| 248 | if (!new_object) { | ||
| 249 | return (AE_NO_MEMORY); | ||
| 250 | } | ||
| 251 | |||
| 252 | ACPI_MEMCPY(new_object->buffer.pointer, | ||
| 253 | original_object->string.pointer, | ||
| 254 | original_object->string.length); | ||
| 255 | break; | ||
| 256 | |||
| 257 | case ACPI_TYPE_PACKAGE: | ||
| 258 | /* | ||
| 259 | * This case is often seen for predefined names that must return a | ||
| 260 | * Buffer object with multiple DWORD integers within. For example, | ||
| 261 | * _FDE and _GTM. The Package can be converted to a Buffer. | ||
| 262 | */ | ||
| 263 | |||
| 264 | /* All elements of the Package must be integers */ | ||
| 265 | |||
| 266 | elements = original_object->package.elements; | ||
| 267 | count = original_object->package.count; | ||
| 268 | |||
| 269 | for (i = 0; i < count; i++) { | ||
| 270 | if ((!*elements) || | ||
| 271 | ((*elements)->common.type != ACPI_TYPE_INTEGER)) { | ||
| 272 | return (AE_AML_OPERAND_TYPE); | ||
| 273 | } | ||
| 274 | elements++; | ||
| 275 | } | ||
| 276 | |||
| 277 | /* Create the new buffer object to replace the Package */ | ||
| 278 | |||
| 279 | new_object = acpi_ut_create_buffer_object(ACPI_MUL_4(count)); | ||
| 280 | if (!new_object) { | ||
| 281 | return (AE_NO_MEMORY); | ||
| 282 | } | ||
| 283 | |||
| 284 | /* Copy the package elements (integers) to the buffer as DWORDs */ | ||
| 285 | |||
| 286 | elements = original_object->package.elements; | ||
| 287 | dword_buffer = ACPI_CAST_PTR(u32, new_object->buffer.pointer); | ||
| 288 | |||
| 289 | for (i = 0; i < count; i++) { | ||
| 290 | *dword_buffer = (u32)(*elements)->integer.value; | ||
| 291 | dword_buffer++; | ||
| 292 | elements++; | ||
| 293 | } | ||
| 294 | break; | ||
| 295 | |||
| 296 | default: | ||
| 297 | return (AE_AML_OPERAND_TYPE); | ||
| 298 | } | ||
| 299 | |||
| 300 | *return_object = new_object; | ||
| 301 | return (AE_OK); | ||
| 302 | } | ||
| 303 | |||
| 304 | /******************************************************************************* | ||
| 305 | * | ||
| 306 | * FUNCTION: acpi_ns_convert_to_unicode | ||
| 307 | * | ||
| 308 | * PARAMETERS: original_object - ASCII String Object to be converted | ||
| 309 | * return_object - Where the new converted object is returned | ||
| 310 | * | ||
| 311 | * RETURN: Status. AE_OK if conversion was successful. | ||
| 312 | * | ||
| 313 | * DESCRIPTION: Attempt to convert a String object to a Unicode string Buffer. | ||
| 314 | * | ||
| 315 | ******************************************************************************/ | ||
| 316 | |||
| 317 | acpi_status | ||
| 318 | acpi_ns_convert_to_unicode(union acpi_operand_object *original_object, | ||
| 319 | union acpi_operand_object **return_object) | ||
| 320 | { | ||
| 321 | union acpi_operand_object *new_object; | ||
| 322 | char *ascii_string; | ||
| 323 | u16 *unicode_buffer; | ||
| 324 | u32 unicode_length; | ||
| 325 | u32 i; | ||
| 326 | |||
| 327 | if (!original_object) { | ||
| 328 | return (AE_OK); | ||
| 329 | } | ||
| 330 | |||
| 331 | /* If a Buffer was returned, it must be at least two bytes long */ | ||
| 332 | |||
| 333 | if (original_object->common.type == ACPI_TYPE_BUFFER) { | ||
| 334 | if (original_object->buffer.length < 2) { | ||
| 335 | return (AE_AML_OPERAND_VALUE); | ||
| 336 | } | ||
| 337 | |||
| 338 | *return_object = NULL; | ||
| 339 | return (AE_OK); | ||
| 340 | } | ||
| 341 | |||
| 342 | /* | ||
| 343 | * The original object is an ASCII string. Convert this string to | ||
| 344 | * a unicode buffer. | ||
| 345 | */ | ||
| 346 | ascii_string = original_object->string.pointer; | ||
| 347 | unicode_length = (original_object->string.length * 2) + 2; | ||
| 348 | |||
| 349 | /* Create a new buffer object for the Unicode data */ | ||
| 350 | |||
| 351 | new_object = acpi_ut_create_buffer_object(unicode_length); | ||
| 352 | if (!new_object) { | ||
| 353 | return (AE_NO_MEMORY); | ||
| 354 | } | ||
| 355 | |||
| 356 | unicode_buffer = ACPI_CAST_PTR(u16, new_object->buffer.pointer); | ||
| 357 | |||
| 358 | /* Convert ASCII to Unicode */ | ||
| 359 | |||
| 360 | for (i = 0; i < original_object->string.length; i++) { | ||
| 361 | unicode_buffer[i] = (u16)ascii_string[i]; | ||
| 362 | } | ||
| 363 | |||
| 364 | *return_object = new_object; | ||
| 365 | return (AE_OK); | ||
| 366 | } | ||
| 367 | |||
| 368 | /******************************************************************************* | ||
| 369 | * | ||
| 370 | * FUNCTION: acpi_ns_convert_to_resource | ||
| 371 | * | ||
| 372 | * PARAMETERS: original_object - Object to be converted | ||
| 373 | * return_object - Where the new converted object is returned | ||
| 374 | * | ||
| 375 | * RETURN: Status. AE_OK if conversion was successful | ||
| 376 | * | ||
| 377 | * DESCRIPTION: Attempt to convert a Integer object to a resource_template | ||
| 378 | * Buffer. | ||
| 379 | * | ||
| 380 | ******************************************************************************/ | ||
| 381 | |||
| 382 | acpi_status | ||
| 383 | acpi_ns_convert_to_resource(union acpi_operand_object *original_object, | ||
| 384 | union acpi_operand_object **return_object) | ||
| 385 | { | ||
| 386 | union acpi_operand_object *new_object; | ||
| 387 | u8 *buffer; | ||
| 388 | |||
| 389 | /* | ||
| 390 | * We can fix the following cases for an expected resource template: | ||
| 391 | * 1. No return value (interpreter slack mode is disabled) | ||
| 392 | * 2. A "Return (Zero)" statement | ||
| 393 | * 3. A "Return empty buffer" statement | ||
| 394 | * | ||
| 395 | * We will return a buffer containing a single end_tag | ||
| 396 | * resource descriptor. | ||
| 397 | */ | ||
| 398 | if (original_object) { | ||
| 399 | switch (original_object->common.type) { | ||
| 400 | case ACPI_TYPE_INTEGER: | ||
| 401 | |||
| 402 | /* We can only repair an Integer==0 */ | ||
| 403 | |||
| 404 | if (original_object->integer.value) { | ||
| 405 | return (AE_AML_OPERAND_TYPE); | ||
| 406 | } | ||
| 407 | break; | ||
| 408 | |||
| 409 | case ACPI_TYPE_BUFFER: | ||
| 410 | |||
| 411 | if (original_object->buffer.length) { | ||
| 412 | |||
| 413 | /* Additional checks can be added in the future */ | ||
| 414 | |||
| 415 | *return_object = NULL; | ||
| 416 | return (AE_OK); | ||
| 417 | } | ||
| 418 | break; | ||
| 419 | |||
| 420 | case ACPI_TYPE_STRING: | ||
| 421 | default: | ||
| 422 | |||
| 423 | return (AE_AML_OPERAND_TYPE); | ||
| 424 | } | ||
| 425 | } | ||
| 426 | |||
| 427 | /* Create the new buffer object for the resource descriptor */ | ||
| 428 | |||
| 429 | new_object = acpi_ut_create_buffer_object(2); | ||
| 430 | if (!new_object) { | ||
| 431 | return (AE_NO_MEMORY); | ||
| 432 | } | ||
| 433 | |||
| 434 | buffer = ACPI_CAST_PTR(u8, new_object->buffer.pointer); | ||
| 435 | |||
| 436 | /* Initialize the Buffer with a single end_tag descriptor */ | ||
| 437 | |||
| 438 | buffer[0] = (ACPI_RESOURCE_NAME_END_TAG | ASL_RDESC_END_TAG_SIZE); | ||
| 439 | buffer[1] = 0x00; | ||
| 440 | |||
| 441 | *return_object = new_object; | ||
| 442 | return (AE_OK); | ||
| 443 | } | ||
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c index 1538f3eb2a8f..b61db69d5675 100644 --- a/drivers/acpi/acpica/nseval.c +++ b/drivers/acpi/acpica/nseval.c | |||
| @@ -98,17 +98,21 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) | |||
| 98 | info->return_object = NULL; | 98 | info->return_object = NULL; |
| 99 | info->param_count = 0; | 99 | info->param_count = 0; |
| 100 | 100 | ||
| 101 | /* | 101 | if (!info->resolved_node) { |
| 102 | * Get the actual namespace node for the target object. Handles these cases: | 102 | /* |
| 103 | * | 103 | * Get the actual namespace node for the target object if we need to. |
| 104 | * 1) Null node, Pathname (absolute path) | 104 | * Handles these cases: |
| 105 | * 2) Node, Pathname (path relative to Node) | 105 | * |
| 106 | * 3) Node, Null Pathname | 106 | * 1) Null node, Pathname (absolute path) |
| 107 | */ | 107 | * 2) Node, Pathname (path relative to Node) |
| 108 | status = acpi_ns_get_node(info->prefix_node, info->pathname, | 108 | * 3) Node, Null Pathname |
| 109 | ACPI_NS_NO_UPSEARCH, &info->resolved_node); | 109 | */ |
| 110 | if (ACPI_FAILURE(status)) { | 110 | status = acpi_ns_get_node(info->prefix_node, info->pathname, |
| 111 | return_ACPI_STATUS(status); | 111 | ACPI_NS_NO_UPSEARCH, |
| 112 | &info->resolved_node); | ||
| 113 | if (ACPI_FAILURE(status)) { | ||
| 114 | return_ACPI_STATUS(status); | ||
| 115 | } | ||
| 112 | } | 116 | } |
| 113 | 117 | ||
| 114 | /* | 118 | /* |
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c index 224c30053401..8a52916148cb 100644 --- a/drivers/acpi/acpica/nspredef.c +++ b/drivers/acpi/acpica/nspredef.c | |||
| @@ -76,19 +76,7 @@ static acpi_status | |||
| 76 | acpi_ns_check_reference(struct acpi_predefined_data *data, | 76 | acpi_ns_check_reference(struct acpi_predefined_data *data, |
| 77 | union acpi_operand_object *return_object); | 77 | union acpi_operand_object *return_object); |
| 78 | 78 | ||
| 79 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes); | 79 | static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); |
| 80 | |||
| 81 | /* | ||
| 82 | * Names for the types that can be returned by the predefined objects. | ||
| 83 | * Used for warning messages. Must be in the same order as the ACPI_RTYPEs | ||
| 84 | */ | ||
| 85 | static const char *acpi_rtype_names[] = { | ||
| 86 | "/Integer", | ||
| 87 | "/String", | ||
| 88 | "/Buffer", | ||
| 89 | "/Package", | ||
| 90 | "/Reference", | ||
| 91 | }; | ||
| 92 | 80 | ||
| 93 | /******************************************************************************* | 81 | /******************************************************************************* |
| 94 | * | 82 | * |
| @@ -112,7 +100,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
| 112 | acpi_status return_status, | 100 | acpi_status return_status, |
| 113 | union acpi_operand_object **return_object_ptr) | 101 | union acpi_operand_object **return_object_ptr) |
| 114 | { | 102 | { |
| 115 | union acpi_operand_object *return_object = *return_object_ptr; | ||
| 116 | acpi_status status = AE_OK; | 103 | acpi_status status = AE_OK; |
| 117 | const union acpi_predefined_info *predefined; | 104 | const union acpi_predefined_info *predefined; |
| 118 | char *pathname; | 105 | char *pathname; |
| @@ -120,7 +107,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
| 120 | 107 | ||
| 121 | /* Match the name for this method/object against the predefined list */ | 108 | /* Match the name for this method/object against the predefined list */ |
| 122 | 109 | ||
| 123 | predefined = acpi_ns_check_for_predefined_name(node); | 110 | predefined = acpi_ut_match_predefined_method(node->name.ascii); |
| 124 | 111 | ||
| 125 | /* Get the full pathname to the object, for use in warning messages */ | 112 | /* Get the full pathname to the object, for use in warning messages */ |
| 126 | 113 | ||
| @@ -152,25 +139,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
| 152 | } | 139 | } |
| 153 | 140 | ||
| 154 | /* | 141 | /* |
| 155 | * If there is no return value, check if we require a return value for | ||
| 156 | * this predefined name. Either one return value is expected, or none, | ||
| 157 | * for both methods and other objects. | ||
| 158 | * | ||
| 159 | * Exit now if there is no return object. Warning if one was expected. | ||
| 160 | */ | ||
| 161 | if (!return_object) { | ||
| 162 | if ((predefined->info.expected_btypes) && | ||
| 163 | (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) { | ||
| 164 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | ||
| 165 | ACPI_WARN_ALWAYS, | ||
| 166 | "Missing expected return value")); | ||
| 167 | |||
| 168 | status = AE_AML_NO_RETURN_VALUE; | ||
| 169 | } | ||
| 170 | goto cleanup; | ||
| 171 | } | ||
| 172 | |||
| 173 | /* | ||
| 174 | * Return value validation and possible repair. | 142 | * Return value validation and possible repair. |
| 175 | * | 143 | * |
| 176 | * 1) Don't perform return value validation/repair if this feature | 144 | * 1) Don't perform return value validation/repair if this feature |
| @@ -310,8 +278,10 @@ acpi_ns_check_parameter_count(char *pathname, | |||
| 310 | * Validate the user-supplied parameter count. | 278 | * Validate the user-supplied parameter count. |
| 311 | * Allow two different legal argument counts (_SCP, etc.) | 279 | * Allow two different legal argument counts (_SCP, etc.) |
| 312 | */ | 280 | */ |
| 313 | required_params_current = predefined->info.param_count & 0x0F; | 281 | required_params_current = |
| 314 | required_params_old = predefined->info.param_count >> 4; | 282 | predefined->info.argument_list & METHOD_ARG_MASK; |
| 283 | required_params_old = | ||
| 284 | predefined->info.argument_list >> METHOD_ARG_BIT_WIDTH; | ||
| 315 | 285 | ||
| 316 | if (user_param_count != ACPI_UINT32_MAX) { | 286 | if (user_param_count != ACPI_UINT32_MAX) { |
| 317 | if ((user_param_count != required_params_current) && | 287 | if ((user_param_count != required_params_current) && |
| @@ -340,52 +310,6 @@ acpi_ns_check_parameter_count(char *pathname, | |||
| 340 | 310 | ||
| 341 | /******************************************************************************* | 311 | /******************************************************************************* |
| 342 | * | 312 | * |
| 343 | * FUNCTION: acpi_ns_check_for_predefined_name | ||
| 344 | * | ||
| 345 | * PARAMETERS: node - Namespace node for the method/object | ||
| 346 | * | ||
| 347 | * RETURN: Pointer to entry in predefined table. NULL indicates not found. | ||
| 348 | * | ||
| 349 | * DESCRIPTION: Check an object name against the predefined object list. | ||
| 350 | * | ||
| 351 | ******************************************************************************/ | ||
| 352 | |||
| 353 | const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct | ||
| 354 | acpi_namespace_node | ||
| 355 | *node) | ||
| 356 | { | ||
| 357 | const union acpi_predefined_info *this_name; | ||
| 358 | |||
| 359 | /* Quick check for a predefined name, first character must be underscore */ | ||
| 360 | |||
| 361 | if (node->name.ascii[0] != '_') { | ||
| 362 | return (NULL); | ||
| 363 | } | ||
| 364 | |||
| 365 | /* Search info table for a predefined method/object name */ | ||
| 366 | |||
| 367 | this_name = predefined_names; | ||
| 368 | while (this_name->info.name[0]) { | ||
| 369 | if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) { | ||
| 370 | return (this_name); | ||
| 371 | } | ||
| 372 | |||
| 373 | /* | ||
| 374 | * Skip next entry in the table if this name returns a Package | ||
| 375 | * (next entry contains the package info) | ||
| 376 | */ | ||
| 377 | if (this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) { | ||
| 378 | this_name++; | ||
| 379 | } | ||
| 380 | |||
| 381 | this_name++; | ||
| 382 | } | ||
| 383 | |||
| 384 | return (NULL); /* Not found */ | ||
| 385 | } | ||
| 386 | |||
| 387 | /******************************************************************************* | ||
| 388 | * | ||
| 389 | * FUNCTION: acpi_ns_check_object_type | 313 | * FUNCTION: acpi_ns_check_object_type |
| 390 | * | 314 | * |
| 391 | * PARAMETERS: data - Pointer to validation data structure | 315 | * PARAMETERS: data - Pointer to validation data structure |
| @@ -410,28 +334,12 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
| 410 | { | 334 | { |
| 411 | union acpi_operand_object *return_object = *return_object_ptr; | 335 | union acpi_operand_object *return_object = *return_object_ptr; |
| 412 | acpi_status status = AE_OK; | 336 | acpi_status status = AE_OK; |
| 413 | u32 return_btype; | ||
| 414 | char type_buffer[48]; /* Room for 5 types */ | 337 | char type_buffer[48]; /* Room for 5 types */ |
| 415 | 338 | ||
| 416 | /* | ||
| 417 | * If we get a NULL return_object here, it is a NULL package element. | ||
| 418 | * Since all extraneous NULL package elements were removed earlier by a | ||
| 419 | * call to acpi_ns_remove_null_elements, this is an unexpected NULL element. | ||
| 420 | * We will attempt to repair it. | ||
| 421 | */ | ||
| 422 | if (!return_object) { | ||
| 423 | status = acpi_ns_repair_null_element(data, expected_btypes, | ||
| 424 | package_index, | ||
| 425 | return_object_ptr); | ||
| 426 | if (ACPI_SUCCESS(status)) { | ||
| 427 | return (AE_OK); /* Repair was successful */ | ||
| 428 | } | ||
| 429 | goto type_error_exit; | ||
| 430 | } | ||
| 431 | |||
| 432 | /* A Namespace node should not get here, but make sure */ | 339 | /* A Namespace node should not get here, but make sure */ |
| 433 | 340 | ||
| 434 | if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { | 341 | if (return_object && |
| 342 | ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { | ||
| 435 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 343 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
| 436 | "Invalid return type - Found a Namespace node [%4.4s] type %s", | 344 | "Invalid return type - Found a Namespace node [%4.4s] type %s", |
| 437 | return_object->node.name.ascii, | 345 | return_object->node.name.ascii, |
| @@ -448,59 +356,31 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
| 448 | * from all of the predefined names (including elements of returned | 356 | * from all of the predefined names (including elements of returned |
| 449 | * packages) | 357 | * packages) |
| 450 | */ | 358 | */ |
| 451 | switch (return_object->common.type) { | 359 | data->return_btype = acpi_ns_get_bitmapped_type(return_object); |
| 452 | case ACPI_TYPE_INTEGER: | 360 | if (data->return_btype == ACPI_RTYPE_ANY) { |
| 453 | return_btype = ACPI_RTYPE_INTEGER; | ||
| 454 | break; | ||
| 455 | |||
| 456 | case ACPI_TYPE_BUFFER: | ||
| 457 | return_btype = ACPI_RTYPE_BUFFER; | ||
| 458 | break; | ||
| 459 | |||
| 460 | case ACPI_TYPE_STRING: | ||
| 461 | return_btype = ACPI_RTYPE_STRING; | ||
| 462 | break; | ||
| 463 | 361 | ||
| 464 | case ACPI_TYPE_PACKAGE: | ||
| 465 | return_btype = ACPI_RTYPE_PACKAGE; | ||
| 466 | break; | ||
| 467 | |||
| 468 | case ACPI_TYPE_LOCAL_REFERENCE: | ||
| 469 | return_btype = ACPI_RTYPE_REFERENCE; | ||
| 470 | break; | ||
| 471 | |||
| 472 | default: | ||
| 473 | /* Not one of the supported objects, must be incorrect */ | 362 | /* Not one of the supported objects, must be incorrect */ |
| 474 | |||
| 475 | goto type_error_exit; | 363 | goto type_error_exit; |
| 476 | } | 364 | } |
| 477 | 365 | ||
| 478 | /* Is the object one of the expected types? */ | 366 | /* For reference objects, check that the reference type is correct */ |
| 479 | |||
| 480 | if (return_btype & expected_btypes) { | ||
| 481 | |||
| 482 | /* For reference objects, check that the reference type is correct */ | ||
| 483 | |||
| 484 | if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { | ||
| 485 | status = acpi_ns_check_reference(data, return_object); | ||
| 486 | } | ||
| 487 | 367 | ||
| 368 | if ((data->return_btype & expected_btypes) == ACPI_RTYPE_REFERENCE) { | ||
| 369 | status = acpi_ns_check_reference(data, return_object); | ||
| 488 | return (status); | 370 | return (status); |
| 489 | } | 371 | } |
| 490 | 372 | ||
| 491 | /* Type mismatch -- attempt repair of the returned object */ | 373 | /* Attempt simple repair of the returned object if necessary */ |
| 492 | 374 | ||
| 493 | status = acpi_ns_repair_object(data, expected_btypes, | 375 | status = acpi_ns_simple_repair(data, expected_btypes, |
| 494 | package_index, return_object_ptr); | 376 | package_index, return_object_ptr); |
| 495 | if (ACPI_SUCCESS(status)) { | 377 | return (status); |
| 496 | return (AE_OK); /* Repair was successful */ | ||
| 497 | } | ||
| 498 | 378 | ||
| 499 | type_error_exit: | 379 | type_error_exit: |
| 500 | 380 | ||
| 501 | /* Create a string with all expected types for this predefined object */ | 381 | /* Create a string with all expected types for this predefined object */ |
| 502 | 382 | ||
| 503 | acpi_ns_get_expected_types(type_buffer, expected_btypes); | 383 | acpi_ut_get_expected_return_types(type_buffer, expected_btypes); |
| 504 | 384 | ||
| 505 | if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { | 385 | if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { |
| 506 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 386 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
| @@ -558,36 +438,55 @@ acpi_ns_check_reference(struct acpi_predefined_data *data, | |||
| 558 | 438 | ||
| 559 | /******************************************************************************* | 439 | /******************************************************************************* |
| 560 | * | 440 | * |
| 561 | * FUNCTION: acpi_ns_get_expected_types | 441 | * FUNCTION: acpi_ns_get_bitmapped_type |
| 562 | * | 442 | * |
| 563 | * PARAMETERS: buffer - Pointer to where the string is returned | 443 | * PARAMETERS: return_object - Object returned from method/obj evaluation |
| 564 | * expected_btypes - Bitmap of expected return type(s) | ||
| 565 | * | 444 | * |
| 566 | * RETURN: Buffer is populated with type names. | 445 | * RETURN: Object return type. ACPI_RTYPE_ANY indicates that the object |
| 446 | * type is not supported. ACPI_RTYPE_NONE indicates that no | ||
| 447 | * object was returned (return_object is NULL). | ||
| 567 | * | 448 | * |
| 568 | * DESCRIPTION: Translate the expected types bitmap into a string of ascii | 449 | * DESCRIPTION: Convert object type into a bitmapped object return type. |
| 569 | * names of expected types, for use in warning messages. | ||
| 570 | * | 450 | * |
| 571 | ******************************************************************************/ | 451 | ******************************************************************************/ |
| 572 | 452 | ||
| 573 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes) | 453 | static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object) |
| 574 | { | 454 | { |
| 575 | u32 this_rtype; | 455 | u32 return_btype; |
| 576 | u32 i; | ||
| 577 | u32 j; | ||
| 578 | 456 | ||
| 579 | j = 1; | 457 | if (!return_object) { |
| 580 | buffer[0] = 0; | 458 | return (ACPI_RTYPE_NONE); |
| 581 | this_rtype = ACPI_RTYPE_INTEGER; | 459 | } |
| 582 | 460 | ||
| 583 | for (i = 0; i < ACPI_NUM_RTYPES; i++) { | 461 | /* Map acpi_object_type to internal bitmapped type */ |
| 584 | 462 | ||
| 585 | /* If one of the expected types, concatenate the name of this type */ | 463 | switch (return_object->common.type) { |
| 464 | case ACPI_TYPE_INTEGER: | ||
| 465 | return_btype = ACPI_RTYPE_INTEGER; | ||
| 466 | break; | ||
| 586 | 467 | ||
| 587 | if (expected_btypes & this_rtype) { | 468 | case ACPI_TYPE_BUFFER: |
| 588 | ACPI_STRCAT(buffer, &acpi_rtype_names[i][j]); | 469 | return_btype = ACPI_RTYPE_BUFFER; |
| 589 | j = 0; /* Use name separator from now on */ | 470 | break; |
| 590 | } | 471 | |
| 591 | this_rtype <<= 1; /* Next Rtype */ | 472 | case ACPI_TYPE_STRING: |
| 473 | return_btype = ACPI_RTYPE_STRING; | ||
| 474 | break; | ||
| 475 | |||
| 476 | case ACPI_TYPE_PACKAGE: | ||
| 477 | return_btype = ACPI_RTYPE_PACKAGE; | ||
| 478 | break; | ||
| 479 | |||
| 480 | case ACPI_TYPE_LOCAL_REFERENCE: | ||
| 481 | return_btype = ACPI_RTYPE_REFERENCE; | ||
| 482 | break; | ||
| 483 | |||
| 484 | default: | ||
| 485 | /* Not one of the supported objects, must be incorrect */ | ||
| 486 | |||
| 487 | return_btype = ACPI_RTYPE_ANY; | ||
| 488 | break; | ||
| 592 | } | 489 | } |
| 490 | |||
| 491 | return (return_btype); | ||
| 593 | } | 492 | } |
diff --git a/drivers/acpi/acpica/nsprepkg.c b/drivers/acpi/acpica/nsprepkg.c index a40155467d2e..77cdd539de16 100644 --- a/drivers/acpi/acpica/nsprepkg.c +++ b/drivers/acpi/acpica/nsprepkg.c | |||
| @@ -112,9 +112,15 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
| 112 | elements = return_object->package.elements; | 112 | elements = return_object->package.elements; |
| 113 | count = return_object->package.count; | 113 | count = return_object->package.count; |
| 114 | 114 | ||
| 115 | /* The package must have at least one element, else invalid */ | 115 | /* |
| 116 | 116 | * Most packages must have at least one element. The only exception | |
| 117 | * is the variable-length package (ACPI_PTYPE1_VAR). | ||
| 118 | */ | ||
| 117 | if (!count) { | 119 | if (!count) { |
| 120 | if (package->ret_info.type == ACPI_PTYPE1_VAR) { | ||
| 121 | return (AE_OK); | ||
| 122 | } | ||
| 123 | |||
| 118 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 124 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, |
| 119 | "Return Package has no elements (empty)")); | 125 | "Return Package has no elements (empty)")); |
| 120 | 126 | ||
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c index 9e833353c06a..18f02e4ece01 100644 --- a/drivers/acpi/acpica/nsrepair.c +++ b/drivers/acpi/acpica/nsrepair.c | |||
| @@ -46,6 +46,7 @@ | |||
| 46 | #include "acnamesp.h" | 46 | #include "acnamesp.h" |
| 47 | #include "acinterp.h" | 47 | #include "acinterp.h" |
| 48 | #include "acpredef.h" | 48 | #include "acpredef.h" |
| 49 | #include "amlresrc.h" | ||
| 49 | 50 | ||
| 50 | #define _COMPONENT ACPI_NAMESPACE | 51 | #define _COMPONENT ACPI_NAMESPACE |
| 51 | ACPI_MODULE_NAME("nsrepair") | 52 | ACPI_MODULE_NAME("nsrepair") |
| @@ -71,6 +72,11 @@ ACPI_MODULE_NAME("nsrepair") | |||
| 71 | * Buffer -> String | 72 | * Buffer -> String |
| 72 | * Buffer -> Package of Integers | 73 | * Buffer -> Package of Integers |
| 73 | * Package -> Package of one Package | 74 | * Package -> Package of one Package |
| 75 | * | ||
| 76 | * Additional conversions that are available: | ||
| 77 | * Convert a null return or zero return value to an end_tag descriptor | ||
| 78 | * Convert an ASCII string to a Unicode buffer | ||
| 79 | * | ||
| 74 | * An incorrect standalone object is wrapped with required outer package | 80 | * An incorrect standalone object is wrapped with required outer package |
| 75 | * | 81 | * |
| 76 | * Additional possible repairs: | 82 | * Additional possible repairs: |
| @@ -78,21 +84,51 @@ ACPI_MODULE_NAME("nsrepair") | |||
| 78 | * | 84 | * |
| 79 | ******************************************************************************/ | 85 | ******************************************************************************/ |
| 80 | /* Local prototypes */ | 86 | /* Local prototypes */ |
| 81 | static acpi_status | 87 | static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct |
| 82 | acpi_ns_convert_to_integer(union acpi_operand_object *original_object, | 88 | acpi_namespace_node |
| 83 | union acpi_operand_object **return_object); | 89 | *node, |
| 84 | 90 | u32 | |
| 85 | static acpi_status | 91 | return_btype, |
| 86 | acpi_ns_convert_to_string(union acpi_operand_object *original_object, | 92 | u32 |
| 87 | union acpi_operand_object **return_object); | 93 | package_index); |
| 88 | 94 | ||
| 89 | static acpi_status | 95 | /* |
| 90 | acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, | 96 | * Special but simple repairs for some names. |
| 91 | union acpi_operand_object **return_object); | 97 | * |
| 98 | * 2nd argument: Unexpected types that can be repaired | ||
| 99 | */ | ||
| 100 | static const struct acpi_simple_repair_info acpi_object_repair_info[] = { | ||
| 101 | /* Resource descriptor conversions */ | ||
| 102 | |||
| 103 | {"_CRS", | ||
| 104 | ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | | ||
| 105 | ACPI_RTYPE_NONE, | ||
| 106 | ACPI_NOT_PACKAGE_ELEMENT, | ||
| 107 | acpi_ns_convert_to_resource}, | ||
| 108 | {"_DMA", | ||
| 109 | ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | | ||
| 110 | ACPI_RTYPE_NONE, | ||
| 111 | ACPI_NOT_PACKAGE_ELEMENT, | ||
| 112 | acpi_ns_convert_to_resource}, | ||
| 113 | {"_PRS", | ||
| 114 | ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER | | ||
| 115 | ACPI_RTYPE_NONE, | ||
| 116 | ACPI_NOT_PACKAGE_ELEMENT, | ||
| 117 | acpi_ns_convert_to_resource}, | ||
| 118 | |||
| 119 | /* Unicode conversions */ | ||
| 120 | |||
| 121 | {"_MLS", ACPI_RTYPE_STRING, 1, | ||
| 122 | acpi_ns_convert_to_unicode}, | ||
| 123 | {"_STR", ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER, | ||
| 124 | ACPI_NOT_PACKAGE_ELEMENT, | ||
| 125 | acpi_ns_convert_to_unicode}, | ||
| 126 | {{0, 0, 0, 0}, 0, 0, NULL} /* Table terminator */ | ||
| 127 | }; | ||
| 92 | 128 | ||
| 93 | /******************************************************************************* | 129 | /******************************************************************************* |
| 94 | * | 130 | * |
| 95 | * FUNCTION: acpi_ns_repair_object | 131 | * FUNCTION: acpi_ns_simple_repair |
| 96 | * | 132 | * |
| 97 | * PARAMETERS: data - Pointer to validation data structure | 133 | * PARAMETERS: data - Pointer to validation data structure |
| 98 | * expected_btypes - Object types expected | 134 | * expected_btypes - Object types expected |
| @@ -110,16 +146,54 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, | |||
| 110 | ******************************************************************************/ | 146 | ******************************************************************************/ |
| 111 | 147 | ||
| 112 | acpi_status | 148 | acpi_status |
| 113 | acpi_ns_repair_object(struct acpi_predefined_data *data, | 149 | acpi_ns_simple_repair(struct acpi_predefined_data *data, |
| 114 | u32 expected_btypes, | 150 | u32 expected_btypes, |
| 115 | u32 package_index, | 151 | u32 package_index, |
| 116 | union acpi_operand_object **return_object_ptr) | 152 | union acpi_operand_object **return_object_ptr) |
| 117 | { | 153 | { |
| 118 | union acpi_operand_object *return_object = *return_object_ptr; | 154 | union acpi_operand_object *return_object = *return_object_ptr; |
| 119 | union acpi_operand_object *new_object; | 155 | union acpi_operand_object *new_object = NULL; |
| 120 | acpi_status status; | 156 | acpi_status status; |
| 157 | const struct acpi_simple_repair_info *predefined; | ||
| 158 | |||
| 159 | ACPI_FUNCTION_NAME(ns_simple_repair); | ||
| 160 | |||
| 161 | /* | ||
| 162 | * Special repairs for certain names that are in the repair table. | ||
| 163 | * Check if this name is in the list of repairable names. | ||
| 164 | */ | ||
| 165 | predefined = acpi_ns_match_simple_repair(data->node, | ||
| 166 | data->return_btype, | ||
| 167 | package_index); | ||
| 168 | if (predefined) { | ||
| 169 | if (!return_object) { | ||
| 170 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, | ||
| 171 | ACPI_WARN_ALWAYS, | ||
| 172 | "Missing expected return value")); | ||
| 173 | } | ||
| 174 | |||
| 175 | status = | ||
| 176 | predefined->object_converter(return_object, &new_object); | ||
| 177 | if (ACPI_FAILURE(status)) { | ||
| 178 | |||
| 179 | /* A fatal error occurred during a conversion */ | ||
| 180 | |||
| 181 | ACPI_EXCEPTION((AE_INFO, status, | ||
| 182 | "During return object analysis")); | ||
| 183 | return (status); | ||
| 184 | } | ||
| 185 | if (new_object) { | ||
| 186 | goto object_repaired; | ||
| 187 | } | ||
| 188 | } | ||
| 121 | 189 | ||
| 122 | ACPI_FUNCTION_NAME(ns_repair_object); | 190 | /* |
| 191 | * Do not perform simple object repair unless the return type is not | ||
| 192 | * expected. | ||
| 193 | */ | ||
| 194 | if (data->return_btype & expected_btypes) { | ||
| 195 | return (AE_OK); | ||
| 196 | } | ||
| 123 | 197 | ||
| 124 | /* | 198 | /* |
| 125 | * At this point, we know that the type of the returned object was not | 199 | * At this point, we know that the type of the returned object was not |
| @@ -127,6 +201,24 @@ acpi_ns_repair_object(struct acpi_predefined_data *data, | |||
| 127 | * repair the object by converting it to one of the expected object | 201 | * repair the object by converting it to one of the expected object |
| 128 | * types for this predefined name. | 202 | * types for this predefined name. |
| 129 | */ | 203 | */ |
| 204 | |||
| 205 | /* | ||
| 206 | * If there is no return value, check if we require a return value for | ||
| 207 | * this predefined name. Either one return value is expected, or none, | ||
| 208 | * for both methods and other objects. | ||
| 209 | * | ||
| 210 | * Exit now if there is no return object. Warning if one was expected. | ||
| 211 | */ | ||
| 212 | if (!return_object) { | ||
| 213 | if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) { | ||
| 214 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, | ||
| 215 | ACPI_WARN_ALWAYS, | ||
| 216 | "Missing expected return value")); | ||
| 217 | |||
| 218 | return (AE_AML_NO_RETURN_VALUE); | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 130 | if (expected_btypes & ACPI_RTYPE_INTEGER) { | 222 | if (expected_btypes & ACPI_RTYPE_INTEGER) { |
| 131 | status = acpi_ns_convert_to_integer(return_object, &new_object); | 223 | status = acpi_ns_convert_to_integer(return_object, &new_object); |
| 132 | if (ACPI_SUCCESS(status)) { | 224 | if (ACPI_SUCCESS(status)) { |
| @@ -216,254 +308,51 @@ acpi_ns_repair_object(struct acpi_predefined_data *data, | |||
| 216 | return (AE_OK); | 308 | return (AE_OK); |
| 217 | } | 309 | } |
| 218 | 310 | ||
| 219 | /******************************************************************************* | 311 | /****************************************************************************** |
| 220 | * | ||
| 221 | * FUNCTION: acpi_ns_convert_to_integer | ||
| 222 | * | ||
| 223 | * PARAMETERS: original_object - Object to be converted | ||
| 224 | * return_object - Where the new converted object is returned | ||
| 225 | * | ||
| 226 | * RETURN: Status. AE_OK if conversion was successful. | ||
| 227 | * | ||
| 228 | * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer. | ||
| 229 | * | ||
| 230 | ******************************************************************************/ | ||
| 231 | |||
| 232 | static acpi_status | ||
| 233 | acpi_ns_convert_to_integer(union acpi_operand_object *original_object, | ||
| 234 | union acpi_operand_object **return_object) | ||
| 235 | { | ||
| 236 | union acpi_operand_object *new_object; | ||
| 237 | acpi_status status; | ||
| 238 | u64 value = 0; | ||
| 239 | u32 i; | ||
| 240 | |||
| 241 | switch (original_object->common.type) { | ||
| 242 | case ACPI_TYPE_STRING: | ||
| 243 | |||
| 244 | /* String-to-Integer conversion */ | ||
| 245 | |||
| 246 | status = acpi_ut_strtoul64(original_object->string.pointer, | ||
| 247 | ACPI_ANY_BASE, &value); | ||
| 248 | if (ACPI_FAILURE(status)) { | ||
| 249 | return (status); | ||
| 250 | } | ||
| 251 | break; | ||
| 252 | |||
| 253 | case ACPI_TYPE_BUFFER: | ||
| 254 | |||
| 255 | /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */ | ||
| 256 | |||
| 257 | if (original_object->buffer.length > 8) { | ||
| 258 | return (AE_AML_OPERAND_TYPE); | ||
| 259 | } | ||
| 260 | |||
| 261 | /* Extract each buffer byte to create the integer */ | ||
| 262 | |||
| 263 | for (i = 0; i < original_object->buffer.length; i++) { | ||
| 264 | value |= | ||
| 265 | ((u64) original_object->buffer. | ||
| 266 | pointer[i] << (i * 8)); | ||
| 267 | } | ||
| 268 | break; | ||
| 269 | |||
| 270 | default: | ||
| 271 | return (AE_AML_OPERAND_TYPE); | ||
| 272 | } | ||
| 273 | |||
| 274 | new_object = acpi_ut_create_integer_object(value); | ||
| 275 | if (!new_object) { | ||
| 276 | return (AE_NO_MEMORY); | ||
| 277 | } | ||
| 278 | |||
| 279 | *return_object = new_object; | ||
| 280 | return (AE_OK); | ||
| 281 | } | ||
| 282 | |||
| 283 | /******************************************************************************* | ||
| 284 | * | ||
| 285 | * FUNCTION: acpi_ns_convert_to_string | ||
| 286 | * | ||
| 287 | * PARAMETERS: original_object - Object to be converted | ||
| 288 | * return_object - Where the new converted object is returned | ||
| 289 | * | ||
| 290 | * RETURN: Status. AE_OK if conversion was successful. | ||
| 291 | * | ||
| 292 | * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String. | ||
| 293 | * | ||
| 294 | ******************************************************************************/ | ||
| 295 | |||
| 296 | static acpi_status | ||
| 297 | acpi_ns_convert_to_string(union acpi_operand_object *original_object, | ||
| 298 | union acpi_operand_object **return_object) | ||
| 299 | { | ||
| 300 | union acpi_operand_object *new_object; | ||
| 301 | acpi_size length; | ||
| 302 | acpi_status status; | ||
| 303 | |||
| 304 | switch (original_object->common.type) { | ||
| 305 | case ACPI_TYPE_INTEGER: | ||
| 306 | /* | ||
| 307 | * Integer-to-String conversion. Commonly, convert | ||
| 308 | * an integer of value 0 to a NULL string. The last element of | ||
| 309 | * _BIF and _BIX packages occasionally need this fix. | ||
| 310 | */ | ||
| 311 | if (original_object->integer.value == 0) { | ||
| 312 | |||
| 313 | /* Allocate a new NULL string object */ | ||
| 314 | |||
| 315 | new_object = acpi_ut_create_string_object(0); | ||
| 316 | if (!new_object) { | ||
| 317 | return (AE_NO_MEMORY); | ||
| 318 | } | ||
| 319 | } else { | ||
| 320 | status = | ||
| 321 | acpi_ex_convert_to_string(original_object, | ||
| 322 | &new_object, | ||
| 323 | ACPI_IMPLICIT_CONVERT_HEX); | ||
| 324 | if (ACPI_FAILURE(status)) { | ||
| 325 | return (status); | ||
| 326 | } | ||
| 327 | } | ||
| 328 | break; | ||
| 329 | |||
| 330 | case ACPI_TYPE_BUFFER: | ||
| 331 | /* | ||
| 332 | * Buffer-to-String conversion. Use a to_string | ||
| 333 | * conversion, no transform performed on the buffer data. The best | ||
| 334 | * example of this is the _BIF method, where the string data from | ||
| 335 | * the battery is often (incorrectly) returned as buffer object(s). | ||
| 336 | */ | ||
| 337 | length = 0; | ||
| 338 | while ((length < original_object->buffer.length) && | ||
| 339 | (original_object->buffer.pointer[length])) { | ||
| 340 | length++; | ||
| 341 | } | ||
| 342 | |||
| 343 | /* Allocate a new string object */ | ||
| 344 | |||
| 345 | new_object = acpi_ut_create_string_object(length); | ||
| 346 | if (!new_object) { | ||
| 347 | return (AE_NO_MEMORY); | ||
| 348 | } | ||
| 349 | |||
| 350 | /* | ||
| 351 | * Copy the raw buffer data with no transform. String is already NULL | ||
| 352 | * terminated at Length+1. | ||
| 353 | */ | ||
| 354 | ACPI_MEMCPY(new_object->string.pointer, | ||
| 355 | original_object->buffer.pointer, length); | ||
| 356 | break; | ||
| 357 | |||
| 358 | default: | ||
| 359 | return (AE_AML_OPERAND_TYPE); | ||
| 360 | } | ||
| 361 | |||
| 362 | *return_object = new_object; | ||
| 363 | return (AE_OK); | ||
| 364 | } | ||
| 365 | |||
| 366 | /******************************************************************************* | ||
| 367 | * | 312 | * |
| 368 | * FUNCTION: acpi_ns_convert_to_buffer | 313 | * FUNCTION: acpi_ns_match_simple_repair |
| 369 | * | 314 | * |
| 370 | * PARAMETERS: original_object - Object to be converted | 315 | * PARAMETERS: node - Namespace node for the method/object |
| 371 | * return_object - Where the new converted object is returned | 316 | * return_btype - Object type that was returned |
| 317 | * package_index - Index of object within parent package (if | ||
| 318 | * applicable - ACPI_NOT_PACKAGE_ELEMENT | ||
| 319 | * otherwise) | ||
| 372 | * | 320 | * |
| 373 | * RETURN: Status. AE_OK if conversion was successful. | 321 | * RETURN: Pointer to entry in repair table. NULL indicates not found. |
| 374 | * | 322 | * |
| 375 | * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer. | 323 | * DESCRIPTION: Check an object name against the repairable object list. |
| 376 | * | 324 | * |
| 377 | ******************************************************************************/ | 325 | *****************************************************************************/ |
| 378 | 326 | ||
| 379 | static acpi_status | 327 | static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct |
| 380 | acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, | 328 | acpi_namespace_node |
| 381 | union acpi_operand_object **return_object) | 329 | *node, |
| 330 | u32 | ||
| 331 | return_btype, | ||
| 332 | u32 | ||
| 333 | package_index) | ||
| 382 | { | 334 | { |
| 383 | union acpi_operand_object *new_object; | 335 | const struct acpi_simple_repair_info *this_name; |
| 384 | acpi_status status; | ||
| 385 | union acpi_operand_object **elements; | ||
| 386 | u32 *dword_buffer; | ||
| 387 | u32 count; | ||
| 388 | u32 i; | ||
| 389 | 336 | ||
| 390 | switch (original_object->common.type) { | 337 | /* Search info table for a repairable predefined method/object name */ |
| 391 | case ACPI_TYPE_INTEGER: | ||
| 392 | /* | ||
| 393 | * Integer-to-Buffer conversion. | ||
| 394 | * Convert the Integer to a packed-byte buffer. _MAT and other | ||
| 395 | * objects need this sometimes, if a read has been performed on a | ||
| 396 | * Field object that is less than or equal to the global integer | ||
| 397 | * size (32 or 64 bits). | ||
| 398 | */ | ||
| 399 | status = | ||
| 400 | acpi_ex_convert_to_buffer(original_object, &new_object); | ||
| 401 | if (ACPI_FAILURE(status)) { | ||
| 402 | return (status); | ||
| 403 | } | ||
| 404 | break; | ||
| 405 | 338 | ||
| 406 | case ACPI_TYPE_STRING: | 339 | this_name = acpi_object_repair_info; |
| 340 | while (this_name->object_converter) { | ||
| 341 | if (ACPI_COMPARE_NAME(node->name.ascii, this_name->name)) { | ||
| 407 | 342 | ||
| 408 | /* String-to-Buffer conversion. Simple data copy */ | 343 | /* Check if we can actually repair this name/type combination */ |
| 409 | |||
| 410 | new_object = | ||
| 411 | acpi_ut_create_buffer_object(original_object->string. | ||
| 412 | length); | ||
| 413 | if (!new_object) { | ||
| 414 | return (AE_NO_MEMORY); | ||
| 415 | } | ||
| 416 | 344 | ||
| 417 | ACPI_MEMCPY(new_object->buffer.pointer, | 345 | if ((return_btype & this_name->unexpected_btypes) && |
| 418 | original_object->string.pointer, | 346 | (package_index == this_name->package_index)) { |
| 419 | original_object->string.length); | 347 | return (this_name); |
| 420 | break; | ||
| 421 | |||
| 422 | case ACPI_TYPE_PACKAGE: | ||
| 423 | /* | ||
| 424 | * This case is often seen for predefined names that must return a | ||
| 425 | * Buffer object with multiple DWORD integers within. For example, | ||
| 426 | * _FDE and _GTM. The Package can be converted to a Buffer. | ||
| 427 | */ | ||
| 428 | |||
| 429 | /* All elements of the Package must be integers */ | ||
| 430 | |||
| 431 | elements = original_object->package.elements; | ||
| 432 | count = original_object->package.count; | ||
| 433 | |||
| 434 | for (i = 0; i < count; i++) { | ||
| 435 | if ((!*elements) || | ||
| 436 | ((*elements)->common.type != ACPI_TYPE_INTEGER)) { | ||
| 437 | return (AE_AML_OPERAND_TYPE); | ||
| 438 | } | 348 | } |
| 439 | elements++; | ||
| 440 | } | ||
| 441 | |||
| 442 | /* Create the new buffer object to replace the Package */ | ||
| 443 | 349 | ||
| 444 | new_object = acpi_ut_create_buffer_object(ACPI_MUL_4(count)); | 350 | return (NULL); |
| 445 | if (!new_object) { | ||
| 446 | return (AE_NO_MEMORY); | ||
| 447 | } | 351 | } |
| 448 | 352 | this_name++; | |
| 449 | /* Copy the package elements (integers) to the buffer as DWORDs */ | ||
| 450 | |||
| 451 | elements = original_object->package.elements; | ||
| 452 | dword_buffer = ACPI_CAST_PTR(u32, new_object->buffer.pointer); | ||
| 453 | |||
| 454 | for (i = 0; i < count; i++) { | ||
| 455 | *dword_buffer = (u32) (*elements)->integer.value; | ||
| 456 | dword_buffer++; | ||
| 457 | elements++; | ||
| 458 | } | ||
| 459 | break; | ||
| 460 | |||
| 461 | default: | ||
| 462 | return (AE_AML_OPERAND_TYPE); | ||
| 463 | } | 353 | } |
| 464 | 354 | ||
| 465 | *return_object = new_object; | 355 | return (NULL); /* Name was not found in the repair table */ |
| 466 | return (AE_OK); | ||
| 467 | } | 356 | } |
| 468 | 357 | ||
| 469 | /******************************************************************************* | 358 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c index ba4d98287c6a..149e9b9c2c1b 100644 --- a/drivers/acpi/acpica/nsrepair2.c +++ b/drivers/acpi/acpica/nsrepair2.c | |||
| @@ -66,9 +66,9 @@ typedef struct acpi_repair_info { | |||
| 66 | 66 | ||
| 67 | /* Local prototypes */ | 67 | /* Local prototypes */ |
| 68 | 68 | ||
| 69 | static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct | 69 | static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct |
| 70 | acpi_namespace_node | 70 | acpi_namespace_node |
| 71 | *node); | 71 | *node); |
| 72 | 72 | ||
| 73 | static acpi_status | 73 | static acpi_status |
| 74 | acpi_ns_repair_ALR(struct acpi_predefined_data *data, | 74 | acpi_ns_repair_ALR(struct acpi_predefined_data *data, |
| @@ -175,7 +175,7 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data, | |||
| 175 | 175 | ||
| 176 | /* Check if this name is in the list of repairable names */ | 176 | /* Check if this name is in the list of repairable names */ |
| 177 | 177 | ||
| 178 | predefined = acpi_ns_match_repairable_name(node); | 178 | predefined = acpi_ns_match_complex_repair(node); |
| 179 | if (!predefined) { | 179 | if (!predefined) { |
| 180 | return (validate_status); | 180 | return (validate_status); |
| 181 | } | 181 | } |
| @@ -186,7 +186,7 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data, | |||
| 186 | 186 | ||
| 187 | /****************************************************************************** | 187 | /****************************************************************************** |
| 188 | * | 188 | * |
| 189 | * FUNCTION: acpi_ns_match_repairable_name | 189 | * FUNCTION: acpi_ns_match_complex_repair |
| 190 | * | 190 | * |
| 191 | * PARAMETERS: node - Namespace node for the method/object | 191 | * PARAMETERS: node - Namespace node for the method/object |
| 192 | * | 192 | * |
| @@ -196,9 +196,9 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data, | |||
| 196 | * | 196 | * |
| 197 | *****************************************************************************/ | 197 | *****************************************************************************/ |
| 198 | 198 | ||
| 199 | static const struct acpi_repair_info *acpi_ns_match_repairable_name(struct | 199 | static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct |
| 200 | acpi_namespace_node | 200 | acpi_namespace_node |
| 201 | *node) | 201 | *node) |
| 202 | { | 202 | { |
| 203 | const struct acpi_repair_info *this_name; | 203 | const struct acpi_repair_info *this_name; |
| 204 | 204 | ||
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c index 686420df684f..2808586fad30 100644 --- a/drivers/acpi/acpica/nsutils.c +++ b/drivers/acpi/acpica/nsutils.c | |||
| @@ -112,10 +112,10 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node) | |||
| 112 | 112 | ||
| 113 | if (!node) { | 113 | if (!node) { |
| 114 | ACPI_WARNING((AE_INFO, "Null Node parameter")); | 114 | ACPI_WARNING((AE_INFO, "Null Node parameter")); |
| 115 | return_VALUE(ACPI_TYPE_ANY); | 115 | return_UINT8(ACPI_TYPE_ANY); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | return_VALUE(node->type); | 118 | return_UINT8(node->type); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | /******************************************************************************* | 121 | /******************************************************************************* |
| @@ -140,10 +140,10 @@ u32 acpi_ns_local(acpi_object_type type) | |||
| 140 | /* Type code out of range */ | 140 | /* Type code out of range */ |
| 141 | 141 | ||
| 142 | ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type)); | 142 | ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type)); |
| 143 | return_VALUE(ACPI_NS_NORMAL); | 143 | return_UINT32(ACPI_NS_NORMAL); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | return_VALUE(acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); | 146 | return_UINT32(acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | /******************************************************************************* | 149 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c index f51308cdbc65..9f25a3d4e992 100644 --- a/drivers/acpi/acpica/psargs.c +++ b/drivers/acpi/acpica/psargs.c | |||
| @@ -108,7 +108,7 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) | |||
| 108 | /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */ | 108 | /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */ |
| 109 | 109 | ||
| 110 | package_length |= (aml[0] & byte_zero_mask); | 110 | package_length |= (aml[0] & byte_zero_mask); |
| 111 | return_VALUE(package_length); | 111 | return_UINT32(package_length); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | /******************************************************************************* | 114 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c index 7816d4eef04e..72077fa1eea5 100644 --- a/drivers/acpi/acpica/rscalc.c +++ b/drivers/acpi/acpica/rscalc.c | |||
| @@ -202,6 +202,12 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) | |||
| 202 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); | 202 | return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | /* Sanity check the length. It must not be zero, or we loop forever */ | ||
| 206 | |||
| 207 | if (!resource->length) { | ||
| 208 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | ||
| 209 | } | ||
| 210 | |||
| 205 | /* Get the base size of the (external stream) resource descriptor */ | 211 | /* Get the base size of the (external stream) resource descriptor */ |
| 206 | 212 | ||
| 207 | total_size = acpi_gbl_aml_resource_sizes[resource->type]; | 213 | total_size = acpi_gbl_aml_resource_sizes[resource->type]; |
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c index cab51445189d..b5fc0db2e87b 100644 --- a/drivers/acpi/acpica/rsdump.c +++ b/drivers/acpi/acpica/rsdump.c | |||
| @@ -385,6 +385,14 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list) | |||
| 385 | return; | 385 | return; |
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | /* Sanity check the length. It must not be zero, or we loop forever */ | ||
| 389 | |||
| 390 | if (!resource_list->length) { | ||
| 391 | acpi_os_printf | ||
| 392 | ("Invalid zero length descriptor in resource list\n"); | ||
| 393 | return; | ||
| 394 | } | ||
| 395 | |||
| 388 | /* Dump the resource descriptor */ | 396 | /* Dump the resource descriptor */ |
| 389 | 397 | ||
| 390 | if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { | 398 | if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { |
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c index ee2e206fc6c8..6053aa182093 100644 --- a/drivers/acpi/acpica/rslist.c +++ b/drivers/acpi/acpica/rslist.c | |||
| @@ -178,6 +178,14 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource, | |||
| 178 | return_ACPI_STATUS(AE_BAD_DATA); | 178 | return_ACPI_STATUS(AE_BAD_DATA); |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | /* Sanity check the length. It must not be zero, or we loop forever */ | ||
| 182 | |||
| 183 | if (!resource->length) { | ||
| 184 | ACPI_ERROR((AE_INFO, | ||
| 185 | "Invalid zero length descriptor in resource list\n")); | ||
| 186 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | ||
| 187 | } | ||
| 188 | |||
| 181 | /* Perform the conversion */ | 189 | /* Perform the conversion */ |
| 182 | 190 | ||
| 183 | if (resource->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { | 191 | if (resource->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { |
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c index 15d6eaef0e28..c0e5d2d3ce67 100644 --- a/drivers/acpi/acpica/rsxface.c +++ b/drivers/acpi/acpica/rsxface.c | |||
| @@ -563,13 +563,19 @@ acpi_walk_resource_buffer(struct acpi_buffer * buffer, | |||
| 563 | 563 | ||
| 564 | while (resource < resource_end) { | 564 | while (resource < resource_end) { |
| 565 | 565 | ||
| 566 | /* Sanity check the resource */ | 566 | /* Sanity check the resource type */ |
| 567 | 567 | ||
| 568 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { | 568 | if (resource->type > ACPI_RESOURCE_TYPE_MAX) { |
| 569 | status = AE_AML_INVALID_RESOURCE_TYPE; | 569 | status = AE_AML_INVALID_RESOURCE_TYPE; |
| 570 | break; | 570 | break; |
| 571 | } | 571 | } |
| 572 | 572 | ||
| 573 | /* Sanity check the length. It must not be zero, or we loop forever */ | ||
| 574 | |||
| 575 | if (!resource->length) { | ||
| 576 | return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH); | ||
| 577 | } | ||
| 578 | |||
| 573 | /* Invoke the user function, abort on any error returned */ | 579 | /* Invoke the user function, abort on any error returned */ |
| 574 | 580 | ||
| 575 | status = user_function(resource, context); | 581 | status = user_function(resource, context); |
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c index 74181bf181ec..33b00d22300a 100644 --- a/drivers/acpi/acpica/tbfadt.c +++ b/drivers/acpi/acpica/tbfadt.c | |||
| @@ -559,8 +559,12 @@ static void acpi_tb_validate_fadt(void) | |||
| 559 | /* | 559 | /* |
| 560 | * For each extended field, check for length mismatch between the | 560 | * For each extended field, check for length mismatch between the |
| 561 | * legacy length field and the corresponding 64-bit X length field. | 561 | * legacy length field and the corresponding 64-bit X length field. |
| 562 | * Note: If the legacy length field is > 0xFF bits, ignore this | ||
| 563 | * check. (GPE registers can be larger than the 64-bit GAS structure | ||
| 564 | * can accomodate, 0xFF bits). | ||
| 562 | */ | 565 | */ |
| 563 | if (address64->address && | 566 | if (address64->address && |
| 567 | (ACPI_MUL_8(length) <= ACPI_UINT8_MAX) && | ||
| 564 | (address64->bit_width != ACPI_MUL_8(length))) { | 568 | (address64->bit_width != ACPI_MUL_8(length))) { |
| 565 | ACPI_BIOS_WARNING((AE_INFO, | 569 | ACPI_BIOS_WARNING((AE_INFO, |
| 566 | "32/64X length mismatch in FADT/%s: %u/%u", | 570 | "32/64X length mismatch in FADT/%s: %u/%u", |
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c index b35a5e6d653a..ad11162482ff 100644 --- a/drivers/acpi/acpica/tbxface.c +++ b/drivers/acpi/acpica/tbxface.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /****************************************************************************** | 1 | /****************************************************************************** |
| 2 | * | 2 | * |
| 3 | * Module Name: tbxface - ACPI table oriented external interfaces | 3 | * Module Name: tbxface - ACPI table-oriented external interfaces |
| 4 | * | 4 | * |
| 5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
| 6 | 6 | ||
| @@ -80,7 +80,7 @@ acpi_status acpi_allocate_root_table(u32 initial_table_count) | |||
| 80 | * array is dynamically allocated. | 80 | * array is dynamically allocated. |
| 81 | * initial_table_count - Size of initial_table_array, in number of | 81 | * initial_table_count - Size of initial_table_array, in number of |
| 82 | * struct acpi_table_desc structures | 82 | * struct acpi_table_desc structures |
| 83 | * allow_realloc - Flag to tell Table Manager if resize of | 83 | * allow_resize - Flag to tell Table Manager if resize of |
| 84 | * pre-allocated array is allowed. Ignored | 84 | * pre-allocated array is allowed. Ignored |
| 85 | * if initial_table_array is NULL. | 85 | * if initial_table_array is NULL. |
| 86 | * | 86 | * |
| @@ -107,8 +107,8 @@ acpi_initialize_tables(struct acpi_table_desc * initial_table_array, | |||
| 107 | ACPI_FUNCTION_TRACE(acpi_initialize_tables); | 107 | ACPI_FUNCTION_TRACE(acpi_initialize_tables); |
| 108 | 108 | ||
| 109 | /* | 109 | /* |
| 110 | * Set up the Root Table Array | 110 | * Setup the Root Table Array and allocate the table array |
| 111 | * Allocate the table array if requested | 111 | * if requested |
| 112 | */ | 112 | */ |
| 113 | if (!initial_table_array) { | 113 | if (!initial_table_array) { |
| 114 | status = acpi_allocate_root_table(initial_table_count); | 114 | status = acpi_allocate_root_table(initial_table_count); |
| @@ -305,9 +305,10 @@ ACPI_EXPORT_SYMBOL(acpi_unload_table_id) | |||
| 305 | * instance - Which instance (for SSDTs) | 305 | * instance - Which instance (for SSDTs) |
| 306 | * out_table - Where the pointer to the table is returned | 306 | * out_table - Where the pointer to the table is returned |
| 307 | * | 307 | * |
| 308 | * RETURN: Status and pointer to table | 308 | * RETURN: Status and pointer to the requested table |
| 309 | * | 309 | * |
| 310 | * DESCRIPTION: Finds and verifies an ACPI table. | 310 | * DESCRIPTION: Finds and verifies an ACPI table. Table must be in the |
| 311 | * RSDT/XSDT. | ||
| 311 | * | 312 | * |
| 312 | ******************************************************************************/ | 313 | ******************************************************************************/ |
| 313 | acpi_status | 314 | acpi_status |
| @@ -375,9 +376,10 @@ ACPI_EXPORT_SYMBOL(acpi_get_table) | |||
| 375 | * PARAMETERS: table_index - Table index | 376 | * PARAMETERS: table_index - Table index |
| 376 | * table - Where the pointer to the table is returned | 377 | * table - Where the pointer to the table is returned |
| 377 | * | 378 | * |
| 378 | * RETURN: Status and pointer to the table | 379 | * RETURN: Status and pointer to the requested table |
| 379 | * | 380 | * |
| 380 | * DESCRIPTION: Obtain a table by an index into the global table list. | 381 | * DESCRIPTION: Obtain a table by an index into the global table list. Used |
| 382 | * internally also. | ||
| 381 | * | 383 | * |
| 382 | ******************************************************************************/ | 384 | ******************************************************************************/ |
| 383 | acpi_status | 385 | acpi_status |
| @@ -432,7 +434,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_table_by_index) | |||
| 432 | * | 434 | * |
| 433 | * RETURN: Status | 435 | * RETURN: Status |
| 434 | * | 436 | * |
| 435 | * DESCRIPTION: Install table event handler | 437 | * DESCRIPTION: Install a global table event handler. |
| 436 | * | 438 | * |
| 437 | ******************************************************************************/ | 439 | ******************************************************************************/ |
| 438 | acpi_status | 440 | acpi_status |
| @@ -479,7 +481,7 @@ ACPI_EXPORT_SYMBOL(acpi_install_table_handler) | |||
| 479 | * | 481 | * |
| 480 | * RETURN: Status | 482 | * RETURN: Status |
| 481 | * | 483 | * |
| 482 | * DESCRIPTION: Remove table event handler | 484 | * DESCRIPTION: Remove a table event handler |
| 483 | * | 485 | * |
| 484 | ******************************************************************************/ | 486 | ******************************************************************************/ |
| 485 | acpi_status acpi_remove_table_handler(acpi_table_handler handler) | 487 | acpi_status acpi_remove_table_handler(acpi_table_handler handler) |
diff --git a/drivers/acpi/acpica/utaddress.c b/drivers/acpi/acpica/utaddress.c index 698b9d385516..e0a2e2779c2e 100644 --- a/drivers/acpi/acpica/utaddress.c +++ b/drivers/acpi/acpica/utaddress.c | |||
| @@ -214,7 +214,7 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id, | |||
| 214 | 214 | ||
| 215 | if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) && | 215 | if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) && |
| 216 | (space_id != ACPI_ADR_SPACE_SYSTEM_IO)) { | 216 | (space_id != ACPI_ADR_SPACE_SYSTEM_IO)) { |
| 217 | return_VALUE(0); | 217 | return_UINT32(0); |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | range_info = acpi_gbl_address_range_list[space_id]; | 220 | range_info = acpi_gbl_address_range_list[space_id]; |
| @@ -256,7 +256,7 @@ acpi_ut_check_address_range(acpi_adr_space_type space_id, | |||
| 256 | range_info = range_info->next; | 256 | range_info = range_info->next; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | return_VALUE(overlap_count); | 259 | return_UINT32(overlap_count); |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | /******************************************************************************* | 262 | /******************************************************************************* |
diff --git a/drivers/acpi/acpica/utcache.c b/drivers/acpi/acpica/utcache.c index e0e8579deaac..a877a9647fd9 100644 --- a/drivers/acpi/acpica/utcache.c +++ b/drivers/acpi/acpica/utcache.c | |||
| @@ -85,7 +85,6 @@ acpi_os_create_cache(char *cache_name, | |||
| 85 | /* Populate the cache object and return it */ | 85 | /* Populate the cache object and return it */ |
| 86 | 86 | ||
| 87 | ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list)); | 87 | ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list)); |
| 88 | cache->link_offset = 8; | ||
| 89 | cache->list_name = cache_name; | 88 | cache->list_name = cache_name; |
| 90 | cache->object_size = object_size; | 89 | cache->object_size = object_size; |
| 91 | cache->max_depth = max_depth; | 90 | cache->max_depth = max_depth; |
| @@ -108,7 +107,7 @@ acpi_os_create_cache(char *cache_name, | |||
| 108 | 107 | ||
| 109 | acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache) | 108 | acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache) |
| 110 | { | 109 | { |
| 111 | char *next; | 110 | void *next; |
| 112 | acpi_status status; | 111 | acpi_status status; |
| 113 | 112 | ||
| 114 | ACPI_FUNCTION_ENTRY(); | 113 | ACPI_FUNCTION_ENTRY(); |
| @@ -128,10 +127,7 @@ acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache) | |||
| 128 | 127 | ||
| 129 | /* Delete and unlink one cached state object */ | 128 | /* Delete and unlink one cached state object */ |
| 130 | 129 | ||
| 131 | next = *(ACPI_CAST_INDIRECT_PTR(char, | 130 | next = ACPI_GET_DESCRIPTOR_PTR(cache->list_head); |
| 132 | &(((char *)cache-> | ||
| 133 | list_head)[cache-> | ||
| 134 | link_offset]))); | ||
| 135 | ACPI_FREE(cache->list_head); | 131 | ACPI_FREE(cache->list_head); |
| 136 | 132 | ||
| 137 | cache->list_head = next; | 133 | cache->list_head = next; |
| @@ -221,10 +217,7 @@ acpi_os_release_object(struct acpi_memory_list * cache, void *object) | |||
| 221 | 217 | ||
| 222 | /* Put the object at the head of the cache list */ | 218 | /* Put the object at the head of the cache list */ |
| 223 | 219 | ||
| 224 | *(ACPI_CAST_INDIRECT_PTR(char, | 220 | ACPI_SET_DESCRIPTOR_PTR(object, cache->list_head); |
| 225 | &(((char *)object)[cache-> | ||
| 226 | link_offset]))) = | ||
| 227 | cache->list_head; | ||
| 228 | cache->list_head = object; | 221 | cache->list_head = object; |
| 229 | cache->current_depth++; | 222 | cache->current_depth++; |
| 230 | 223 | ||
| @@ -272,10 +265,7 @@ void *acpi_os_acquire_object(struct acpi_memory_list *cache) | |||
| 272 | /* There is an object available, use it */ | 265 | /* There is an object available, use it */ |
| 273 | 266 | ||
| 274 | object = cache->list_head; | 267 | object = cache->list_head; |
| 275 | cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char, | 268 | cache->list_head = ACPI_GET_DESCRIPTOR_PTR(object); |
| 276 | &(((char *) | ||
| 277 | object)[cache-> | ||
| 278 | link_offset]))); | ||
| 279 | 269 | ||
| 280 | cache->current_depth--; | 270 | cache->current_depth--; |
| 281 | 271 | ||
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c index 2541de420249..29b930250b6f 100644 --- a/drivers/acpi/acpica/utdelete.c +++ b/drivers/acpi/acpica/utdelete.c | |||
| @@ -359,19 +359,20 @@ void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list) | |||
| 359 | * FUNCTION: acpi_ut_update_ref_count | 359 | * FUNCTION: acpi_ut_update_ref_count |
| 360 | * | 360 | * |
| 361 | * PARAMETERS: object - Object whose ref count is to be updated | 361 | * PARAMETERS: object - Object whose ref count is to be updated |
| 362 | * action - What to do | 362 | * action - What to do (REF_INCREMENT or REF_DECREMENT) |
| 363 | * | 363 | * |
| 364 | * RETURN: New ref count | 364 | * RETURN: None. Sets new reference count within the object |
| 365 | * | 365 | * |
| 366 | * DESCRIPTION: Modify the ref count and return it. | 366 | * DESCRIPTION: Modify the reference count for an internal acpi object |
| 367 | * | 367 | * |
| 368 | ******************************************************************************/ | 368 | ******************************************************************************/ |
| 369 | 369 | ||
| 370 | static void | 370 | static void |
| 371 | acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) | 371 | acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) |
| 372 | { | 372 | { |
| 373 | u16 count; | 373 | u16 original_count; |
| 374 | u16 new_count; | 374 | u16 new_count = 0; |
| 375 | acpi_cpu_flags lock_flags; | ||
| 375 | 376 | ||
| 376 | ACPI_FUNCTION_NAME(ut_update_ref_count); | 377 | ACPI_FUNCTION_NAME(ut_update_ref_count); |
| 377 | 378 | ||
| @@ -379,76 +380,79 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) | |||
| 379 | return; | 380 | return; |
| 380 | } | 381 | } |
| 381 | 382 | ||
| 382 | count = object->common.reference_count; | ||
| 383 | new_count = count; | ||
| 384 | |||
| 385 | /* | 383 | /* |
| 386 | * Perform the reference count action (increment, decrement, force delete) | 384 | * Always get the reference count lock. Note: Interpreter and/or |
| 385 | * Namespace is not always locked when this function is called. | ||
| 387 | */ | 386 | */ |
| 387 | lock_flags = acpi_os_acquire_lock(acpi_gbl_reference_count_lock); | ||
| 388 | original_count = object->common.reference_count; | ||
| 389 | |||
| 390 | /* Perform the reference count action (increment, decrement) */ | ||
| 391 | |||
| 388 | switch (action) { | 392 | switch (action) { |
| 389 | case REF_INCREMENT: | 393 | case REF_INCREMENT: |
| 390 | 394 | ||
| 391 | new_count++; | 395 | new_count = original_count + 1; |
| 392 | object->common.reference_count = new_count; | 396 | object->common.reference_count = new_count; |
| 397 | acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags); | ||
| 398 | |||
| 399 | /* The current reference count should never be zero here */ | ||
| 400 | |||
| 401 | if (!original_count) { | ||
| 402 | ACPI_WARNING((AE_INFO, | ||
| 403 | "Obj %p, Reference Count was zero before increment\n", | ||
| 404 | object)); | ||
| 405 | } | ||
| 393 | 406 | ||
| 394 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, | 407 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 395 | "Obj %p Refs=%X, [Incremented]\n", | 408 | "Obj %p Type %.2X Refs %.2X [Incremented]\n", |
| 396 | object, new_count)); | 409 | object, object->common.type, new_count)); |
| 397 | break; | 410 | break; |
| 398 | 411 | ||
| 399 | case REF_DECREMENT: | 412 | case REF_DECREMENT: |
| 400 | 413 | ||
| 401 | if (count < 1) { | 414 | /* The current reference count must be non-zero */ |
| 402 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, | ||
| 403 | "Obj %p Refs=%X, can't decrement! (Set to 0)\n", | ||
| 404 | object, new_count)); | ||
| 405 | |||
| 406 | new_count = 0; | ||
| 407 | } else { | ||
| 408 | new_count--; | ||
| 409 | 415 | ||
| 410 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, | 416 | if (original_count) { |
| 411 | "Obj %p Refs=%X, [Decremented]\n", | 417 | new_count = original_count - 1; |
| 412 | object, new_count)); | 418 | object->common.reference_count = new_count; |
| 413 | } | 419 | } |
| 414 | 420 | ||
| 415 | if (object->common.type == ACPI_TYPE_METHOD) { | 421 | acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags); |
| 416 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, | ||
| 417 | "Method Obj %p Refs=%X, [Decremented]\n", | ||
| 418 | object, new_count)); | ||
| 419 | } | ||
| 420 | 422 | ||
| 421 | object->common.reference_count = new_count; | 423 | if (!original_count) { |
| 422 | if (new_count == 0) { | 424 | ACPI_WARNING((AE_INFO, |
| 423 | acpi_ut_delete_internal_obj(object); | 425 | "Obj %p, Reference Count is already zero, cannot decrement\n", |
| 426 | object)); | ||
| 424 | } | 427 | } |
| 425 | break; | ||
| 426 | |||
| 427 | case REF_FORCE_DELETE: | ||
| 428 | 428 | ||
| 429 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, | 429 | ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, |
| 430 | "Obj %p Refs=%X, Force delete! (Set to 0)\n", | 430 | "Obj %p Type %.2X Refs %.2X [Decremented]\n", |
| 431 | object, count)); | 431 | object, object->common.type, new_count)); |
| 432 | 432 | ||
| 433 | new_count = 0; | 433 | /* Actually delete the object on a reference count of zero */ |
| 434 | object->common.reference_count = new_count; | 434 | |
| 435 | acpi_ut_delete_internal_obj(object); | 435 | if (new_count == 0) { |
| 436 | acpi_ut_delete_internal_obj(object); | ||
| 437 | } | ||
| 436 | break; | 438 | break; |
| 437 | 439 | ||
| 438 | default: | 440 | default: |
| 439 | 441 | ||
| 440 | ACPI_ERROR((AE_INFO, "Unknown action (0x%X)", action)); | 442 | acpi_os_release_lock(acpi_gbl_reference_count_lock, lock_flags); |
| 441 | break; | 443 | ACPI_ERROR((AE_INFO, "Unknown Reference Count action (0x%X)", |
| 444 | action)); | ||
| 445 | return; | ||
| 442 | } | 446 | } |
| 443 | 447 | ||
| 444 | /* | 448 | /* |
| 445 | * Sanity check the reference count, for debug purposes only. | 449 | * Sanity check the reference count, for debug purposes only. |
| 446 | * (A deleted object will have a huge reference count) | 450 | * (A deleted object will have a huge reference count) |
| 447 | */ | 451 | */ |
| 448 | if (count > ACPI_MAX_REFERENCE_COUNT) { | 452 | if (new_count > ACPI_MAX_REFERENCE_COUNT) { |
| 449 | ACPI_WARNING((AE_INFO, | 453 | ACPI_WARNING((AE_INFO, |
| 450 | "Large Reference Count (0x%X) in object %p", | 454 | "Large Reference Count (0x%X) in object %p, Type=0x%.2X", |
| 451 | count, object)); | 455 | new_count, object, object->common.type)); |
| 452 | } | 456 | } |
| 453 | } | 457 | } |
| 454 | 458 | ||
| @@ -458,8 +462,7 @@ acpi_ut_update_ref_count(union acpi_operand_object *object, u32 action) | |||
| 458 | * | 462 | * |
| 459 | * PARAMETERS: object - Increment ref count for this object | 463 | * PARAMETERS: object - Increment ref count for this object |
| 460 | * and all sub-objects | 464 | * and all sub-objects |
| 461 | * action - Either REF_INCREMENT or REF_DECREMENT or | 465 | * action - Either REF_INCREMENT or REF_DECREMENT |
| 462 | * REF_FORCE_DELETE | ||
| 463 | * | 466 | * |
| 464 | * RETURN: Status | 467 | * RETURN: Status |
| 465 | * | 468 | * |
| @@ -714,7 +717,6 @@ void acpi_ut_remove_reference(union acpi_operand_object *object) | |||
| 714 | /* | 717 | /* |
| 715 | * Allow a NULL pointer to be passed in, just ignore it. This saves | 718 | * Allow a NULL pointer to be passed in, just ignore it. This saves |
| 716 | * each caller from having to check. Also, ignore NS nodes. | 719 | * each caller from having to check. Also, ignore NS nodes. |
| 717 | * | ||
| 718 | */ | 720 | */ |
| 719 | if (!object || | 721 | if (!object || |
| 720 | (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) { | 722 | (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) { |
diff --git a/drivers/acpi/acpica/utexcep.c b/drivers/acpi/acpica/utexcep.c index a0ab7c02e87c..b543a144941a 100644 --- a/drivers/acpi/acpica/utexcep.c +++ b/drivers/acpi/acpica/utexcep.c | |||
| @@ -64,7 +64,7 @@ ACPI_MODULE_NAME("utexcep") | |||
| 64 | ******************************************************************************/ | 64 | ******************************************************************************/ |
| 65 | const char *acpi_format_exception(acpi_status status) | 65 | const char *acpi_format_exception(acpi_status status) |
| 66 | { | 66 | { |
| 67 | const char *exception = NULL; | 67 | const struct acpi_exception_info *exception; |
| 68 | 68 | ||
| 69 | ACPI_FUNCTION_ENTRY(); | 69 | ACPI_FUNCTION_ENTRY(); |
| 70 | 70 | ||
| @@ -76,10 +76,10 @@ const char *acpi_format_exception(acpi_status status) | |||
| 76 | ACPI_ERROR((AE_INFO, | 76 | ACPI_ERROR((AE_INFO, |
| 77 | "Unknown exception code: 0x%8.8X", status)); | 77 | "Unknown exception code: 0x%8.8X", status)); |
| 78 | 78 | ||
| 79 | exception = "UNKNOWN_STATUS_CODE"; | 79 | return ("UNKNOWN_STATUS_CODE"); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | return (ACPI_CAST_PTR(const char, exception)); | 82 | return (exception->name); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | ACPI_EXPORT_SYMBOL(acpi_format_exception) | 85 | ACPI_EXPORT_SYMBOL(acpi_format_exception) |
| @@ -97,10 +97,10 @@ ACPI_EXPORT_SYMBOL(acpi_format_exception) | |||
| 97 | * an ASCII string. | 97 | * an ASCII string. |
| 98 | * | 98 | * |
| 99 | ******************************************************************************/ | 99 | ******************************************************************************/ |
| 100 | const char *acpi_ut_validate_exception(acpi_status status) | 100 | const struct acpi_exception_info *acpi_ut_validate_exception(acpi_status status) |
| 101 | { | 101 | { |
| 102 | u32 sub_status; | 102 | u32 sub_status; |
| 103 | const char *exception = NULL; | 103 | const struct acpi_exception_info *exception = NULL; |
| 104 | 104 | ||
| 105 | ACPI_FUNCTION_ENTRY(); | 105 | ACPI_FUNCTION_ENTRY(); |
| 106 | 106 | ||
| @@ -113,35 +113,35 @@ const char *acpi_ut_validate_exception(acpi_status status) | |||
| 113 | case AE_CODE_ENVIRONMENTAL: | 113 | case AE_CODE_ENVIRONMENTAL: |
| 114 | 114 | ||
| 115 | if (sub_status <= AE_CODE_ENV_MAX) { | 115 | if (sub_status <= AE_CODE_ENV_MAX) { |
| 116 | exception = acpi_gbl_exception_names_env[sub_status]; | 116 | exception = &acpi_gbl_exception_names_env[sub_status]; |
| 117 | } | 117 | } |
| 118 | break; | 118 | break; |
| 119 | 119 | ||
| 120 | case AE_CODE_PROGRAMMER: | 120 | case AE_CODE_PROGRAMMER: |
| 121 | 121 | ||
| 122 | if (sub_status <= AE_CODE_PGM_MAX) { | 122 | if (sub_status <= AE_CODE_PGM_MAX) { |
| 123 | exception = acpi_gbl_exception_names_pgm[sub_status]; | 123 | exception = &acpi_gbl_exception_names_pgm[sub_status]; |
| 124 | } | 124 | } |
| 125 | break; | 125 | break; |
| 126 | 126 | ||
| 127 | case AE_CODE_ACPI_TABLES: | 127 | case AE_CODE_ACPI_TABLES: |
| 128 | 128 | ||
| 129 | if (sub_status <= AE_CODE_TBL_MAX) { | 129 | if (sub_status <= AE_CODE_TBL_MAX) { |
| 130 | exception = acpi_gbl_exception_names_tbl[sub_status]; | 130 | exception = &acpi_gbl_exception_names_tbl[sub_status]; |
| 131 | } | 131 | } |
| 132 | break; | 132 | break; |
| 133 | 133 | ||
| 134 | case AE_CODE_AML: | 134 | case AE_CODE_AML: |
| 135 | 135 | ||
| 136 | if (sub_status <= AE_CODE_AML_MAX) { | 136 | if (sub_status <= AE_CODE_AML_MAX) { |
| 137 | exception = acpi_gbl_exception_names_aml[sub_status]; | 137 | exception = &acpi_gbl_exception_names_aml[sub_status]; |
| 138 | } | 138 | } |
| 139 | break; | 139 | break; |
| 140 | 140 | ||
| 141 | case AE_CODE_CONTROL: | 141 | case AE_CODE_CONTROL: |
| 142 | 142 | ||
| 143 | if (sub_status <= AE_CODE_CTRL_MAX) { | 143 | if (sub_status <= AE_CODE_CTRL_MAX) { |
| 144 | exception = acpi_gbl_exception_names_ctrl[sub_status]; | 144 | exception = &acpi_gbl_exception_names_ctrl[sub_status]; |
| 145 | } | 145 | } |
| 146 | break; | 146 | break; |
| 147 | 147 | ||
| @@ -149,5 +149,9 @@ const char *acpi_ut_validate_exception(acpi_status status) | |||
| 149 | break; | 149 | break; |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | return (ACPI_CAST_PTR(const char, exception)); | 152 | if (!exception || !exception->name) { |
| 153 | return (NULL); | ||
| 154 | } | ||
| 155 | |||
| 156 | return (exception); | ||
| 153 | } | 157 | } |
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c index ffecf4b4f0dd..f736448a8606 100644 --- a/drivers/acpi/acpica/utglobal.c +++ b/drivers/acpi/acpica/utglobal.c | |||
| @@ -359,6 +359,8 @@ acpi_status acpi_ut_init_globals(void) | |||
| 359 | 359 | ||
| 360 | #ifdef ACPI_DISASSEMBLER | 360 | #ifdef ACPI_DISASSEMBLER |
| 361 | acpi_gbl_external_list = NULL; | 361 | acpi_gbl_external_list = NULL; |
| 362 | acpi_gbl_num_external_methods = 0; | ||
| 363 | acpi_gbl_resolved_external_methods = 0; | ||
| 362 | #endif | 364 | #endif |
| 363 | 365 | ||
| 364 | #ifdef ACPI_DEBUG_OUTPUT | 366 | #ifdef ACPI_DEBUG_OUTPUT |
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c index 22feb99b8e35..08c323245584 100644 --- a/drivers/acpi/acpica/utmutex.c +++ b/drivers/acpi/acpica/utmutex.c | |||
| @@ -81,7 +81,7 @@ acpi_status acpi_ut_mutex_initialize(void) | |||
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | /* Create the spinlocks for use at interrupt level */ | 84 | /* Create the spinlocks for use at interrupt level or for speed */ |
| 85 | 85 | ||
| 86 | status = acpi_os_create_lock (&acpi_gbl_gpe_lock); | 86 | status = acpi_os_create_lock (&acpi_gbl_gpe_lock); |
| 87 | if (ACPI_FAILURE (status)) { | 87 | if (ACPI_FAILURE (status)) { |
| @@ -93,7 +93,13 @@ acpi_status acpi_ut_mutex_initialize(void) | |||
| 93 | return_ACPI_STATUS (status); | 93 | return_ACPI_STATUS (status); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | status = acpi_os_create_lock(&acpi_gbl_reference_count_lock); | ||
| 97 | if (ACPI_FAILURE(status)) { | ||
| 98 | return_ACPI_STATUS(status); | ||
| 99 | } | ||
| 100 | |||
| 96 | /* Mutex for _OSI support */ | 101 | /* Mutex for _OSI support */ |
| 102 | |||
| 97 | status = acpi_os_create_mutex(&acpi_gbl_osi_mutex); | 103 | status = acpi_os_create_mutex(&acpi_gbl_osi_mutex); |
| 98 | if (ACPI_FAILURE(status)) { | 104 | if (ACPI_FAILURE(status)) { |
| 99 | return_ACPI_STATUS(status); | 105 | return_ACPI_STATUS(status); |
| @@ -136,6 +142,7 @@ void acpi_ut_mutex_terminate(void) | |||
| 136 | 142 | ||
| 137 | acpi_os_delete_lock(acpi_gbl_gpe_lock); | 143 | acpi_os_delete_lock(acpi_gbl_gpe_lock); |
| 138 | acpi_os_delete_lock(acpi_gbl_hardware_lock); | 144 | acpi_os_delete_lock(acpi_gbl_hardware_lock); |
| 145 | acpi_os_delete_lock(acpi_gbl_reference_count_lock); | ||
| 139 | 146 | ||
| 140 | /* Delete the reader/writer lock */ | 147 | /* Delete the reader/writer lock */ |
| 141 | 148 | ||
diff --git a/drivers/acpi/acpica/utosi.c b/drivers/acpi/acpica/utosi.c index 36a7d361d7cb..b15acebb96a1 100644 --- a/drivers/acpi/acpica/utosi.c +++ b/drivers/acpi/acpica/utosi.c | |||
| @@ -108,9 +108,14 @@ static struct acpi_interface_info acpi_default_supported_interfaces[] = { | |||
| 108 | 108 | ||
| 109 | acpi_status acpi_ut_initialize_interfaces(void) | 109 | acpi_status acpi_ut_initialize_interfaces(void) |
| 110 | { | 110 | { |
| 111 | acpi_status status; | ||
| 111 | u32 i; | 112 | u32 i; |
| 112 | 113 | ||
| 113 | (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); | 114 | status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); |
| 115 | if (ACPI_FAILURE(status)) { | ||
| 116 | return (status); | ||
| 117 | } | ||
| 118 | |||
| 114 | acpi_gbl_supported_interfaces = acpi_default_supported_interfaces; | 119 | acpi_gbl_supported_interfaces = acpi_default_supported_interfaces; |
| 115 | 120 | ||
| 116 | /* Link the static list of supported interfaces */ | 121 | /* Link the static list of supported interfaces */ |
| @@ -132,20 +137,24 @@ acpi_status acpi_ut_initialize_interfaces(void) | |||
| 132 | * | 137 | * |
| 133 | * PARAMETERS: None | 138 | * PARAMETERS: None |
| 134 | * | 139 | * |
| 135 | * RETURN: None | 140 | * RETURN: Status |
| 136 | * | 141 | * |
| 137 | * DESCRIPTION: Delete all interfaces in the global list. Sets | 142 | * DESCRIPTION: Delete all interfaces in the global list. Sets |
| 138 | * acpi_gbl_supported_interfaces to NULL. | 143 | * acpi_gbl_supported_interfaces to NULL. |
| 139 | * | 144 | * |
| 140 | ******************************************************************************/ | 145 | ******************************************************************************/ |
| 141 | 146 | ||
| 142 | void acpi_ut_interface_terminate(void) | 147 | acpi_status acpi_ut_interface_terminate(void) |
| 143 | { | 148 | { |
| 149 | acpi_status status; | ||
| 144 | struct acpi_interface_info *next_interface; | 150 | struct acpi_interface_info *next_interface; |
| 145 | 151 | ||
| 146 | (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); | 152 | status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); |
| 147 | next_interface = acpi_gbl_supported_interfaces; | 153 | if (ACPI_FAILURE(status)) { |
| 154 | return (status); | ||
| 155 | } | ||
| 148 | 156 | ||
| 157 | next_interface = acpi_gbl_supported_interfaces; | ||
| 149 | while (next_interface) { | 158 | while (next_interface) { |
| 150 | acpi_gbl_supported_interfaces = next_interface->next; | 159 | acpi_gbl_supported_interfaces = next_interface->next; |
| 151 | 160 | ||
| @@ -160,6 +169,7 @@ void acpi_ut_interface_terminate(void) | |||
| 160 | } | 169 | } |
| 161 | 170 | ||
| 162 | acpi_os_release_mutex(acpi_gbl_osi_mutex); | 171 | acpi_os_release_mutex(acpi_gbl_osi_mutex); |
| 172 | return (AE_OK); | ||
| 163 | } | 173 | } |
| 164 | 174 | ||
| 165 | /******************************************************************************* | 175 | /******************************************************************************* |
| @@ -315,6 +325,7 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state * walk_state) | |||
| 315 | union acpi_operand_object *return_desc; | 325 | union acpi_operand_object *return_desc; |
| 316 | struct acpi_interface_info *interface_info; | 326 | struct acpi_interface_info *interface_info; |
| 317 | acpi_interface_handler interface_handler; | 327 | acpi_interface_handler interface_handler; |
| 328 | acpi_status status; | ||
| 318 | u32 return_value; | 329 | u32 return_value; |
| 319 | 330 | ||
| 320 | ACPI_FUNCTION_TRACE(ut_osi_implementation); | 331 | ACPI_FUNCTION_TRACE(ut_osi_implementation); |
| @@ -336,7 +347,10 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state * walk_state) | |||
| 336 | /* Default return value is 0, NOT SUPPORTED */ | 347 | /* Default return value is 0, NOT SUPPORTED */ |
| 337 | 348 | ||
| 338 | return_value = 0; | 349 | return_value = 0; |
| 339 | (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); | 350 | status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); |
| 351 | if (ACPI_FAILURE(status)) { | ||
| 352 | return (status); | ||
| 353 | } | ||
| 340 | 354 | ||
| 341 | /* Lookup the interface in the global _OSI list */ | 355 | /* Lookup the interface in the global _OSI list */ |
| 342 | 356 | ||
diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c new file mode 100644 index 000000000000..29459479148f --- /dev/null +++ b/drivers/acpi/acpica/utpredef.c | |||
| @@ -0,0 +1,399 @@ | |||
| 1 | /****************************************************************************** | ||
| 2 | * | ||
| 3 | * Module Name: utpredef - support functions for predefined names | ||
| 4 | * | ||
| 5 | *****************************************************************************/ | ||
| 6 | |||
| 7 | /* | ||
| 8 | * Copyright (C) 2000 - 2013, Intel Corp. | ||
| 9 | * All rights reserved. | ||
| 10 | * | ||
| 11 | * Redistribution and use in source and binary forms, with or without | ||
| 12 | * modification, are permitted provided that the following conditions | ||
| 13 | * are met: | ||
| 14 | * 1. Redistributions of source code must retain the above copyright | ||
| 15 | * notice, this list of conditions, and the following disclaimer, | ||
| 16 | * without modification. | ||
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
| 20 | * including a substantially similar Disclaimer requirement for further | ||
| 21 | * binary redistribution. | ||
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
| 23 | * of any contributors may be used to endorse or promote products derived | ||
| 24 | * from this software without specific prior written permission. | ||
| 25 | * | ||
| 26 | * Alternatively, this software may be distributed under the terms of the | ||
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
| 28 | * Software Foundation. | ||
| 29 | * | ||
| 30 | * NO WARRANTY | ||
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 41 | * POSSIBILITY OF SUCH DAMAGES. | ||
| 42 | */ | ||
| 43 | |||
| 44 | #include <acpi/acpi.h> | ||
| 45 | #include "accommon.h" | ||
| 46 | #include "acpredef.h" | ||
| 47 | |||
| 48 | #define _COMPONENT ACPI_UTILITIES | ||
| 49 | ACPI_MODULE_NAME("utpredef") | ||
| 50 | |||
| 51 | /* | ||
| 52 | * Names for the types that can be returned by the predefined objects. | ||
| 53 | * Used for warning messages. Must be in the same order as the ACPI_RTYPEs | ||
| 54 | */ | ||
| 55 | static const char *ut_rtype_names[] = { | ||
| 56 | "/Integer", | ||
| 57 | "/String", | ||
| 58 | "/Buffer", | ||
| 59 | "/Package", | ||
| 60 | "/Reference", | ||
| 61 | }; | ||
| 62 | |||
| 63 | /******************************************************************************* | ||
| 64 | * | ||
| 65 | * FUNCTION: acpi_ut_get_next_predefined_method | ||
| 66 | * | ||
| 67 | * PARAMETERS: this_name - Entry in the predefined method/name table | ||
| 68 | * | ||
| 69 | * RETURN: Pointer to next entry in predefined table. | ||
| 70 | * | ||
| 71 | * DESCRIPTION: Get the next entry in the predefine method table. Handles the | ||
| 72 | * cases where a package info entry follows a method name that | ||
| 73 | * returns a package. | ||
| 74 | * | ||
| 75 | ******************************************************************************/ | ||
| 76 | |||
| 77 | const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union | ||
| 78 | acpi_predefined_info | ||
| 79 | *this_name) | ||
| 80 | { | ||
| 81 | |||
| 82 | /* | ||
| 83 | * Skip next entry in the table if this name returns a Package | ||
| 84 | * (next entry contains the package info) | ||
| 85 | */ | ||
| 86 | if ((this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) && | ||
| 87 | (this_name->info.expected_btypes != ACPI_RTYPE_ALL)) { | ||
| 88 | this_name++; | ||
| 89 | } | ||
| 90 | |||
| 91 | this_name++; | ||
| 92 | return (this_name); | ||
| 93 | } | ||
| 94 | |||
| 95 | /******************************************************************************* | ||
| 96 | * | ||
| 97 | * FUNCTION: acpi_ut_match_predefined_method | ||
| 98 | * | ||
| 99 | * PARAMETERS: name - Name to find | ||
| 100 | * | ||
| 101 | * RETURN: Pointer to entry in predefined table. NULL indicates not found. | ||
| 102 | * | ||
| 103 | * DESCRIPTION: Check an object name against the predefined object list. | ||
| 104 | * | ||
| 105 | ******************************************************************************/ | ||
| 106 | |||
| 107 | const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name) | ||
| 108 | { | ||
| 109 | const union acpi_predefined_info *this_name; | ||
| 110 | |||
| 111 | /* Quick check for a predefined name, first character must be underscore */ | ||
| 112 | |||
| 113 | if (name[0] != '_') { | ||
| 114 | return (NULL); | ||
| 115 | } | ||
| 116 | |||
| 117 | /* Search info table for a predefined method/object name */ | ||
| 118 | |||
| 119 | this_name = acpi_gbl_predefined_methods; | ||
| 120 | while (this_name->info.name[0]) { | ||
| 121 | if (ACPI_COMPARE_NAME(name, this_name->info.name)) { | ||
| 122 | return (this_name); | ||
| 123 | } | ||
| 124 | |||
| 125 | this_name = acpi_ut_get_next_predefined_method(this_name); | ||
| 126 | } | ||
| 127 | |||
| 128 | return (NULL); /* Not found */ | ||
| 129 | } | ||
| 130 | |||
| 131 | /******************************************************************************* | ||
| 132 | * | ||
| 133 | * FUNCTION: acpi_ut_get_expected_return_types | ||
| 134 | * | ||
| 135 | * PARAMETERS: buffer - Where the formatted string is returned | ||
| 136 | * expected_Btypes - Bitfield of expected data types | ||
| 137 | * | ||
| 138 | * RETURN: Formatted string in Buffer. | ||
| 139 | * | ||
| 140 | * DESCRIPTION: Format the expected object types into a printable string. | ||
| 141 | * | ||
| 142 | ******************************************************************************/ | ||
| 143 | |||
| 144 | void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes) | ||
| 145 | { | ||
| 146 | u32 this_rtype; | ||
| 147 | u32 i; | ||
| 148 | u32 j; | ||
| 149 | |||
| 150 | j = 1; | ||
| 151 | buffer[0] = 0; | ||
| 152 | this_rtype = ACPI_RTYPE_INTEGER; | ||
| 153 | |||
| 154 | for (i = 0; i < ACPI_NUM_RTYPES; i++) { | ||
| 155 | |||
| 156 | /* If one of the expected types, concatenate the name of this type */ | ||
| 157 | |||
| 158 | if (expected_btypes & this_rtype) { | ||
| 159 | ACPI_STRCAT(buffer, &ut_rtype_names[i][j]); | ||
| 160 | j = 0; /* Use name separator from now on */ | ||
| 161 | } | ||
| 162 | |||
| 163 | this_rtype <<= 1; /* Next Rtype */ | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | /******************************************************************************* | ||
| 168 | * | ||
| 169 | * The remaining functions are used by iASL and acpi_help only | ||
| 170 | * | ||
| 171 | ******************************************************************************/ | ||
| 172 | |||
| 173 | #if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP) | ||
| 174 | #include <stdio.h> | ||
| 175 | #include <string.h> | ||
| 176 | |||
| 177 | /* Local prototypes */ | ||
| 178 | |||
| 179 | static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types); | ||
| 180 | |||
| 181 | /* Types that can be returned externally by a predefined name */ | ||
| 182 | |||
| 183 | static const char *ut_external_type_names[] = /* Indexed by ACPI_TYPE_* */ | ||
| 184 | { | ||
| 185 | ", UNSUPPORTED-TYPE", | ||
| 186 | ", Integer", | ||
| 187 | ", String", | ||
| 188 | ", Buffer", | ||
| 189 | ", Package" | ||
| 190 | }; | ||
| 191 | |||
| 192 | /* Bit widths for resource descriptor predefined names */ | ||
| 193 | |||
| 194 | static const char *ut_resource_type_names[] = { | ||
| 195 | "/1", | ||
| 196 | "/2", | ||
| 197 | "/3", | ||
| 198 | "/8", | ||
| 199 | "/16", | ||
| 200 | "/32", | ||
| 201 | "/64", | ||
| 202 | "/variable", | ||
| 203 | }; | ||
| 204 | |||
| 205 | /******************************************************************************* | ||
| 206 | * | ||
| 207 | * FUNCTION: acpi_ut_match_resource_name | ||
| 208 | * | ||
| 209 | * PARAMETERS: name - Name to find | ||
| 210 | * | ||
| 211 | * RETURN: Pointer to entry in the resource table. NULL indicates not | ||
| 212 | * found. | ||
| 213 | * | ||
| 214 | * DESCRIPTION: Check an object name against the predefined resource | ||
| 215 | * descriptor object list. | ||
| 216 | * | ||
| 217 | ******************************************************************************/ | ||
| 218 | |||
| 219 | const union acpi_predefined_info *acpi_ut_match_resource_name(char *name) | ||
| 220 | { | ||
| 221 | const union acpi_predefined_info *this_name; | ||
| 222 | |||
| 223 | /* Quick check for a predefined name, first character must be underscore */ | ||
| 224 | |||
| 225 | if (name[0] != '_') { | ||
| 226 | return (NULL); | ||
| 227 | } | ||
| 228 | |||
| 229 | /* Search info table for a predefined method/object name */ | ||
| 230 | |||
| 231 | this_name = acpi_gbl_resource_names; | ||
| 232 | while (this_name->info.name[0]) { | ||
| 233 | if (ACPI_COMPARE_NAME(name, this_name->info.name)) { | ||
| 234 | return (this_name); | ||
| 235 | } | ||
| 236 | |||
| 237 | this_name++; | ||
| 238 | } | ||
| 239 | |||
| 240 | return (NULL); /* Not found */ | ||
| 241 | } | ||
| 242 | |||
| 243 | /******************************************************************************* | ||
| 244 | * | ||
| 245 | * FUNCTION: acpi_ut_display_predefined_method | ||
| 246 | * | ||
| 247 | * PARAMETERS: buffer - Scratch buffer for this function | ||
| 248 | * this_name - Entry in the predefined method/name table | ||
| 249 | * multi_line - TRUE if output should be on >1 line | ||
| 250 | * | ||
| 251 | * RETURN: None | ||
| 252 | * | ||
| 253 | * DESCRIPTION: Display information about a predefined method. Number and | ||
| 254 | * type of the input arguments, and expected type(s) for the | ||
| 255 | * return value, if any. | ||
| 256 | * | ||
| 257 | ******************************************************************************/ | ||
| 258 | |||
| 259 | void | ||
| 260 | acpi_ut_display_predefined_method(char *buffer, | ||
| 261 | const union acpi_predefined_info *this_name, | ||
| 262 | u8 multi_line) | ||
| 263 | { | ||
| 264 | u32 arg_count; | ||
| 265 | |||
| 266 | /* | ||
| 267 | * Get the argument count and the string buffer | ||
| 268 | * containing all argument types | ||
| 269 | */ | ||
| 270 | arg_count = acpi_ut_get_argument_types(buffer, | ||
| 271 | this_name->info.argument_list); | ||
| 272 | |||
| 273 | if (multi_line) { | ||
| 274 | printf(" "); | ||
| 275 | } | ||
| 276 | |||
| 277 | printf("%4.4s Requires %s%u argument%s", | ||
| 278 | this_name->info.name, | ||
| 279 | (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ? | ||
| 280 | "(at least) " : "", arg_count, arg_count != 1 ? "s" : ""); | ||
| 281 | |||
| 282 | /* Display the types for any arguments */ | ||
| 283 | |||
| 284 | if (arg_count > 0) { | ||
| 285 | printf(" (%s)", buffer); | ||
| 286 | } | ||
| 287 | |||
| 288 | if (multi_line) { | ||
| 289 | printf("\n "); | ||
| 290 | } | ||
| 291 | |||
| 292 | /* Get the return value type(s) allowed */ | ||
| 293 | |||
| 294 | if (this_name->info.expected_btypes) { | ||
| 295 | acpi_ut_get_expected_return_types(buffer, | ||
| 296 | this_name->info. | ||
| 297 | expected_btypes); | ||
| 298 | printf(" Return value types: %s\n", buffer); | ||
| 299 | } else { | ||
| 300 | printf(" No return value\n"); | ||
| 301 | } | ||
| 302 | } | ||
| 303 | |||
| 304 | /******************************************************************************* | ||
| 305 | * | ||
| 306 | * FUNCTION: acpi_ut_get_argument_types | ||
| 307 | * | ||
| 308 | * PARAMETERS: buffer - Where to return the formatted types | ||
| 309 | * argument_types - Types field for this method | ||
| 310 | * | ||
| 311 | * RETURN: count - the number of arguments required for this method | ||
| 312 | * | ||
| 313 | * DESCRIPTION: Format the required data types for this method (Integer, | ||
| 314 | * String, Buffer, or Package) and return the required argument | ||
| 315 | * count. | ||
| 316 | * | ||
| 317 | ******************************************************************************/ | ||
| 318 | |||
| 319 | static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types) | ||
| 320 | { | ||
| 321 | u16 this_argument_type; | ||
| 322 | u16 sub_index; | ||
| 323 | u16 arg_count; | ||
| 324 | u32 i; | ||
| 325 | |||
| 326 | *buffer = 0; | ||
| 327 | sub_index = 2; | ||
| 328 | |||
| 329 | /* First field in the types list is the count of args to follow */ | ||
| 330 | |||
| 331 | arg_count = (argument_types & METHOD_ARG_MASK); | ||
| 332 | argument_types >>= METHOD_ARG_BIT_WIDTH; | ||
| 333 | |||
| 334 | if (arg_count > METHOD_PREDEF_ARGS_MAX) { | ||
| 335 | printf("**** Invalid argument count (%u) " | ||
| 336 | "in predefined info structure\n", arg_count); | ||
| 337 | return (arg_count); | ||
| 338 | } | ||
| 339 | |||
| 340 | /* Get each argument from the list, convert to ascii, store to buffer */ | ||
| 341 | |||
| 342 | for (i = 0; i < arg_count; i++) { | ||
| 343 | this_argument_type = (argument_types & METHOD_ARG_MASK); | ||
| 344 | if (!this_argument_type | ||
| 345 | || (this_argument_type > METHOD_MAX_ARG_TYPE)) { | ||
| 346 | printf("**** Invalid argument type (%u) " | ||
| 347 | "in predefined info structure\n", | ||
| 348 | this_argument_type); | ||
| 349 | return (arg_count); | ||
| 350 | } | ||
| 351 | |||
| 352 | strcat(buffer, | ||
| 353 | ut_external_type_names[this_argument_type] + sub_index); | ||
| 354 | |||
| 355 | /* Shift to next argument type field */ | ||
| 356 | |||
| 357 | argument_types >>= METHOD_ARG_BIT_WIDTH; | ||
| 358 | sub_index = 0; | ||
| 359 | } | ||
| 360 | |||
| 361 | return (arg_count); | ||
| 362 | } | ||
| 363 | |||
| 364 | /******************************************************************************* | ||
| 365 | * | ||
| 366 | * FUNCTION: acpi_ut_get_resource_bit_width | ||
| 367 | * | ||
| 368 | * PARAMETERS: buffer - Where the formatted string is returned | ||
| 369 | * types - Bitfield of expected data types | ||
| 370 | * | ||
| 371 | * RETURN: Count of return types. Formatted string in Buffer. | ||
| 372 | * | ||
| 373 | * DESCRIPTION: Format the resource bit widths into a printable string. | ||
| 374 | * | ||
| 375 | ******************************************************************************/ | ||
| 376 | |||
| 377 | u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types) | ||
| 378 | { | ||
| 379 | u32 i; | ||
| 380 | u16 sub_index; | ||
| 381 | u32 found; | ||
| 382 | |||
| 383 | *buffer = 0; | ||
| 384 | sub_index = 1; | ||
| 385 | found = 0; | ||
| 386 | |||
| 387 | for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) { | ||
| 388 | if (types & 1) { | ||
| 389 | strcat(buffer, &(ut_resource_type_names[i][sub_index])); | ||
| 390 | sub_index = 0; | ||
| 391 | found++; | ||
| 392 | } | ||
| 393 | |||
| 394 | types >>= 1; | ||
| 395 | } | ||
| 396 | |||
| 397 | return (found); | ||
| 398 | } | ||
| 399 | #endif | ||
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c index 48efb446258c..6505774f223e 100644 --- a/drivers/acpi/acpica/utxface.c +++ b/drivers/acpi/acpica/utxface.c | |||
| @@ -287,7 +287,10 @@ acpi_status acpi_install_interface(acpi_string interface_name) | |||
| 287 | return (AE_BAD_PARAMETER); | 287 | return (AE_BAD_PARAMETER); |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); | 290 | status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); |
| 291 | if (ACPI_FAILURE(status)) { | ||
| 292 | return (status); | ||
| 293 | } | ||
| 291 | 294 | ||
| 292 | /* Check if the interface name is already in the global list */ | 295 | /* Check if the interface name is already in the global list */ |
| 293 | 296 | ||
| @@ -336,7 +339,10 @@ acpi_status acpi_remove_interface(acpi_string interface_name) | |||
| 336 | return (AE_BAD_PARAMETER); | 339 | return (AE_BAD_PARAMETER); |
| 337 | } | 340 | } |
| 338 | 341 | ||
| 339 | (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); | 342 | status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); |
| 343 | if (ACPI_FAILURE(status)) { | ||
| 344 | return (status); | ||
| 345 | } | ||
| 340 | 346 | ||
| 341 | status = acpi_ut_remove_interface(interface_name); | 347 | status = acpi_ut_remove_interface(interface_name); |
| 342 | 348 | ||
| @@ -362,9 +368,12 @@ ACPI_EXPORT_SYMBOL(acpi_remove_interface) | |||
| 362 | ****************************************************************************/ | 368 | ****************************************************************************/ |
| 363 | acpi_status acpi_install_interface_handler(acpi_interface_handler handler) | 369 | acpi_status acpi_install_interface_handler(acpi_interface_handler handler) |
| 364 | { | 370 | { |
| 365 | acpi_status status = AE_OK; | 371 | acpi_status status; |
| 366 | 372 | ||
| 367 | (void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); | 373 | status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER); |
| 374 | if (ACPI_FAILURE(status)) { | ||
| 375 | return (status); | ||
| 376 | } | ||
| 368 | 377 | ||
| 369 | if (handler && acpi_gbl_interface_handler) { | 378 | if (handler && acpi_gbl_interface_handler) { |
| 370 | status = AE_ALREADY_EXISTS; | 379 | status = AE_ALREADY_EXISTS; |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index c5cd5b5513e6..0cc384b72943 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
| @@ -146,7 +146,7 @@ struct acpi_battery { | |||
| 146 | 146 | ||
| 147 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat) | 147 | #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat) |
| 148 | 148 | ||
| 149 | inline int acpi_battery_present(struct acpi_battery *battery) | 149 | static inline int acpi_battery_present(struct acpi_battery *battery) |
| 150 | { | 150 | { |
| 151 | return battery->device->status.battery_present; | 151 | return battery->device->status.battery_present; |
| 152 | } | 152 | } |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 01708a165368..292de3cab9cc 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
| @@ -288,13 +288,12 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context) | |||
| 288 | } | 288 | } |
| 289 | out_success: | 289 | out_success: |
| 290 | context->ret.length = out_obj->buffer.length; | 290 | context->ret.length = out_obj->buffer.length; |
| 291 | context->ret.pointer = kmalloc(context->ret.length, GFP_KERNEL); | 291 | context->ret.pointer = kmemdup(out_obj->buffer.pointer, |
| 292 | context->ret.length, GFP_KERNEL); | ||
| 292 | if (!context->ret.pointer) { | 293 | if (!context->ret.pointer) { |
| 293 | status = AE_NO_MEMORY; | 294 | status = AE_NO_MEMORY; |
| 294 | goto out_kfree; | 295 | goto out_kfree; |
| 295 | } | 296 | } |
| 296 | memcpy(context->ret.pointer, out_obj->buffer.pointer, | ||
| 297 | context->ret.length); | ||
| 298 | status = AE_OK; | 297 | status = AE_OK; |
| 299 | 298 | ||
| 300 | out_kfree: | 299 | out_kfree: |
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 86c7d5445c38..92a659aa6396 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
| 34 | #include <acpi/acpi_bus.h> | 34 | #include <acpi/acpi_bus.h> |
| 35 | #include <acpi/acpi_drivers.h> | 35 | #include <acpi/acpi_drivers.h> |
| 36 | #include <acpi/button.h> | ||
| 36 | 37 | ||
| 37 | #define PREFIX "ACPI: " | 38 | #define PREFIX "ACPI: " |
| 38 | 39 | ||
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 5523ba7d764d..e23151667655 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * acpi_container.c - ACPI Generic Container Driver | 2 | * container.c - ACPI Generic Container Driver |
| 3 | * ($Revision: ) | ||
| 4 | * | 3 | * |
| 5 | * Copyright (C) 2004 Anil S Keshavamurthy (anil.s.keshavamurthy@intel.com) | 4 | * Copyright (C) 2004 Anil S Keshavamurthy (anil.s.keshavamurthy@intel.com) |
| 6 | * Copyright (C) 2004 Keiichiro Tokunaga (tokunaga.keiich@jp.fujitsu.com) | 5 | * Copyright (C) 2004 Keiichiro Tokunaga (tokunaga.keiich@jp.fujitsu.com) |
| 7 | * Copyright (C) 2004 Motoyuki Ito (motoyuki@soft.fujitsu.com) | 6 | * Copyright (C) 2004 Motoyuki Ito (motoyuki@soft.fujitsu.com) |
| 8 | * Copyright (C) 2004 Intel Corp. | ||
| 9 | * Copyright (C) 2004 FUJITSU LIMITED | 7 | * Copyright (C) 2004 FUJITSU LIMITED |
| 8 | * Copyright (C) 2004, 2013 Intel Corp. | ||
| 9 | * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 10 | * | 10 | * |
| 11 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 11 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 12 | * | 12 | * |
| @@ -26,14 +26,11 @@ | |||
| 26 | * | 26 | * |
| 27 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 27 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 28 | */ | 28 | */ |
| 29 | #include <linux/kernel.h> | ||
| 30 | #include <linux/module.h> | ||
| 31 | #include <linux/init.h> | ||
| 32 | #include <linux/slab.h> | ||
| 33 | #include <linux/types.h> | ||
| 34 | #include <linux/acpi.h> | 29 | #include <linux/acpi.h> |
| 35 | #include <acpi/acpi_bus.h> | 30 | |
| 36 | #include <acpi/acpi_drivers.h> | 31 | #include "internal.h" |
| 32 | |||
| 33 | #include "internal.h" | ||
| 37 | 34 | ||
| 38 | #define PREFIX "ACPI: " | 35 | #define PREFIX "ACPI: " |
| 39 | 36 | ||
| @@ -50,141 +47,20 @@ static const struct acpi_device_id container_device_ids[] = { | |||
| 50 | static int container_device_attach(struct acpi_device *device, | 47 | static int container_device_attach(struct acpi_device *device, |
| 51 | const struct acpi_device_id *not_used) | 48 | const struct acpi_device_id *not_used) |
| 52 | { | 49 | { |
| 53 | /* | 50 | /* This is necessary for container hotplug to work. */ |
| 54 | * FIXME: This is necessary, so that acpi_eject_store() doesn't return | ||
| 55 | * -ENODEV for containers. | ||
| 56 | */ | ||
| 57 | return 1; | 51 | return 1; |
| 58 | } | 52 | } |
| 59 | 53 | ||
| 60 | static struct acpi_scan_handler container_device_handler = { | 54 | static struct acpi_scan_handler container_handler = { |
| 61 | .ids = container_device_ids, | 55 | .ids = container_device_ids, |
| 62 | .attach = container_device_attach, | 56 | .attach = container_device_attach, |
| 57 | .hotplug = { | ||
| 58 | .enabled = true, | ||
| 59 | .mode = AHM_CONTAINER, | ||
| 60 | }, | ||
| 63 | }; | 61 | }; |
| 64 | 62 | ||
| 65 | static int is_device_present(acpi_handle handle) | ||
| 66 | { | ||
| 67 | acpi_handle temp; | ||
| 68 | acpi_status status; | ||
| 69 | unsigned long long sta; | ||
| 70 | |||
| 71 | |||
| 72 | status = acpi_get_handle(handle, "_STA", &temp); | ||
| 73 | if (ACPI_FAILURE(status)) | ||
| 74 | return 1; /* _STA not found, assume device present */ | ||
| 75 | |||
| 76 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | ||
| 77 | if (ACPI_FAILURE(status)) | ||
| 78 | return 0; /* Firmware error */ | ||
| 79 | |||
| 80 | return ((sta & ACPI_STA_DEVICE_PRESENT) == ACPI_STA_DEVICE_PRESENT); | ||
| 81 | } | ||
| 82 | |||
| 83 | static void container_notify_cb(acpi_handle handle, u32 type, void *context) | ||
| 84 | { | ||
| 85 | struct acpi_device *device = NULL; | ||
| 86 | int result; | ||
| 87 | int present; | ||
| 88 | acpi_status status; | ||
| 89 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ | ||
| 90 | |||
| 91 | acpi_scan_lock_acquire(); | ||
| 92 | |||
| 93 | switch (type) { | ||
| 94 | case ACPI_NOTIFY_BUS_CHECK: | ||
| 95 | /* Fall through */ | ||
| 96 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
| 97 | pr_debug("Container driver received %s event\n", | ||
| 98 | (type == ACPI_NOTIFY_BUS_CHECK) ? | ||
| 99 | "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); | ||
| 100 | |||
| 101 | present = is_device_present(handle); | ||
| 102 | status = acpi_bus_get_device(handle, &device); | ||
| 103 | if (!present) { | ||
| 104 | if (ACPI_SUCCESS(status)) { | ||
| 105 | /* device exist and this is a remove request */ | ||
| 106 | device->flags.eject_pending = 1; | ||
| 107 | kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); | ||
| 108 | goto out; | ||
| 109 | } | ||
| 110 | break; | ||
| 111 | } | ||
| 112 | |||
| 113 | if (!ACPI_FAILURE(status) || device) | ||
| 114 | break; | ||
| 115 | |||
| 116 | result = acpi_bus_scan(handle); | ||
| 117 | if (result) { | ||
| 118 | acpi_handle_warn(handle, "Failed to add container\n"); | ||
| 119 | break; | ||
| 120 | } | ||
| 121 | result = acpi_bus_get_device(handle, &device); | ||
| 122 | if (result) { | ||
| 123 | acpi_handle_warn(handle, "Missing device object\n"); | ||
| 124 | break; | ||
| 125 | } | ||
| 126 | |||
| 127 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); | ||
| 128 | ost_code = ACPI_OST_SC_SUCCESS; | ||
| 129 | break; | ||
| 130 | |||
| 131 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
| 132 | if (!acpi_bus_get_device(handle, &device) && device) { | ||
| 133 | device->flags.eject_pending = 1; | ||
| 134 | kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); | ||
| 135 | goto out; | ||
| 136 | } | ||
| 137 | break; | ||
| 138 | |||
| 139 | default: | ||
| 140 | /* non-hotplug event; possibly handled by other handler */ | ||
| 141 | goto out; | ||
| 142 | } | ||
| 143 | |||
| 144 | /* Inform firmware that the hotplug operation has completed */ | ||
| 145 | (void) acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL); | ||
| 146 | |||
| 147 | out: | ||
| 148 | acpi_scan_lock_release(); | ||
| 149 | } | ||
| 150 | |||
| 151 | static bool is_container(acpi_handle handle) | ||
| 152 | { | ||
| 153 | struct acpi_device_info *info; | ||
| 154 | bool ret = false; | ||
| 155 | |||
| 156 | if (ACPI_FAILURE(acpi_get_object_info(handle, &info))) | ||
| 157 | return false; | ||
| 158 | |||
| 159 | if (info->valid & ACPI_VALID_HID) { | ||
| 160 | const struct acpi_device_id *id; | ||
| 161 | |||
| 162 | for (id = container_device_ids; id->id[0]; id++) { | ||
| 163 | ret = !strcmp((char *)id->id, info->hardware_id.string); | ||
| 164 | if (ret) | ||
| 165 | break; | ||
| 166 | } | ||
| 167 | } | ||
| 168 | kfree(info); | ||
| 169 | return ret; | ||
| 170 | } | ||
| 171 | |||
| 172 | static acpi_status acpi_container_register_notify_handler(acpi_handle handle, | ||
| 173 | u32 lvl, void *ctxt, | ||
| 174 | void **retv) | ||
| 175 | { | ||
| 176 | if (is_container(handle)) | ||
| 177 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
| 178 | container_notify_cb, NULL); | ||
| 179 | |||
| 180 | return AE_OK; | ||
| 181 | } | ||
| 182 | |||
| 183 | void __init acpi_container_init(void) | 63 | void __init acpi_container_init(void) |
| 184 | { | 64 | { |
| 185 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, | 65 | acpi_scan_add_handler_with_hotplug(&container_handler, "container"); |
| 186 | acpi_container_register_notify_handler, NULL, | ||
| 187 | NULL, NULL); | ||
| 188 | |||
| 189 | acpi_scan_add_handler(&container_device_handler); | ||
| 190 | } | 66 | } |
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index dd314ef9bff1..96de787e6104 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
| @@ -145,27 +145,36 @@ int acpi_device_get_power(struct acpi_device *device, int *state) | |||
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | /* | 147 | /* |
| 148 | * Get the device's power state either directly (via _PSC) or | 148 | * Get the device's power state from power resources settings and _PSC, |
| 149 | * indirectly (via power resources). | 149 | * if available. |
| 150 | */ | 150 | */ |
| 151 | if (device->power.flags.power_resources) { | ||
| 152 | int error = acpi_power_get_inferred_state(device, &result); | ||
| 153 | if (error) | ||
| 154 | return error; | ||
| 155 | } | ||
| 151 | if (device->power.flags.explicit_get) { | 156 | if (device->power.flags.explicit_get) { |
| 157 | acpi_handle handle = device->handle; | ||
| 152 | unsigned long long psc; | 158 | unsigned long long psc; |
| 153 | acpi_status status = acpi_evaluate_integer(device->handle, | 159 | acpi_status status; |
| 154 | "_PSC", NULL, &psc); | 160 | |
| 161 | status = acpi_evaluate_integer(handle, "_PSC", NULL, &psc); | ||
| 155 | if (ACPI_FAILURE(status)) | 162 | if (ACPI_FAILURE(status)) |
| 156 | return -ENODEV; | 163 | return -ENODEV; |
| 157 | 164 | ||
| 158 | result = psc; | 165 | /* |
| 159 | } | 166 | * The power resources settings may indicate a power state |
| 160 | /* The test below covers ACPI_STATE_UNKNOWN too. */ | 167 | * shallower than the actual power state of the device. |
| 161 | if (result <= ACPI_STATE_D2) { | 168 | * |
| 162 | ; /* Do nothing. */ | 169 | * Moreover, on systems predating ACPI 4.0, if the device |
| 163 | } else if (device->power.flags.power_resources) { | 170 | * doesn't depend on any power resources and _PSC returns 3, |
| 164 | int error = acpi_power_get_inferred_state(device, &result); | 171 | * that means "power off". We need to maintain compatibility |
| 165 | if (error) | 172 | * with those systems. |
| 166 | return error; | 173 | */ |
| 167 | } else if (result == ACPI_STATE_D3_HOT) { | 174 | if (psc > result && psc < ACPI_STATE_D3_COLD) |
| 168 | result = ACPI_STATE_D3; | 175 | result = psc; |
| 176 | else if (result == ACPI_STATE_UNKNOWN) | ||
| 177 | result = psc > ACPI_STATE_D2 ? ACPI_STATE_D3_COLD : psc; | ||
| 169 | } | 178 | } |
| 170 | 179 | ||
| 171 | /* | 180 | /* |
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index f815da82c765..8d1c0105e113 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
| @@ -174,9 +174,13 @@ static int acpi_fan_add(struct acpi_device *device) | |||
| 174 | 174 | ||
| 175 | static int acpi_fan_remove(struct acpi_device *device) | 175 | static int acpi_fan_remove(struct acpi_device *device) |
| 176 | { | 176 | { |
| 177 | struct thermal_cooling_device *cdev = acpi_driver_data(device); | 177 | struct thermal_cooling_device *cdev; |
| 178 | |||
| 179 | if (!device) | ||
| 180 | return -EINVAL; | ||
| 178 | 181 | ||
| 179 | if (!device || !cdev) | 182 | cdev = acpi_driver_data(device); |
| 183 | if (!cdev) | ||
| 180 | return -EINVAL; | 184 | return -EINVAL; |
| 181 | 185 | ||
| 182 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | 186 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); |
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 3c94a732b4b3..6f1afd9118c8 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h | |||
| @@ -41,6 +41,17 @@ void acpi_container_init(void); | |||
| 41 | #else | 41 | #else |
| 42 | static inline void acpi_container_init(void) {} | 42 | static inline void acpi_container_init(void) {} |
| 43 | #endif | 43 | #endif |
| 44 | #ifdef CONFIG_ACPI_HOTPLUG_MEMORY | ||
| 45 | void acpi_memory_hotplug_init(void); | ||
| 46 | #else | ||
| 47 | static inline void acpi_memory_hotplug_init(void) {} | ||
| 48 | #endif | ||
| 49 | |||
| 50 | void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, | ||
| 51 | const char *name); | ||
| 52 | int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler, | ||
| 53 | const char *hotplug_profile_name); | ||
| 54 | void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val); | ||
| 44 | 55 | ||
| 45 | #ifdef CONFIG_DEBUG_FS | 56 | #ifdef CONFIG_DEBUG_FS |
| 46 | extern struct dentry *acpi_debugfs_dir; | 57 | extern struct dentry *acpi_debugfs_dir; |
| @@ -48,6 +59,11 @@ int acpi_debugfs_init(void); | |||
| 48 | #else | 59 | #else |
| 49 | static inline void acpi_debugfs_init(void) { return; } | 60 | static inline void acpi_debugfs_init(void) { return; } |
| 50 | #endif | 61 | #endif |
| 62 | #ifdef CONFIG_X86_INTEL_LPSS | ||
| 63 | void acpi_lpss_init(void); | ||
| 64 | #else | ||
| 65 | static inline void acpi_lpss_init(void) {} | ||
| 66 | #endif | ||
| 51 | 67 | ||
| 52 | /* -------------------------------------------------------------------------- | 68 | /* -------------------------------------------------------------------------- |
| 53 | Device Node Initialization / Removal | 69 | Device Node Initialization / Removal |
| @@ -60,7 +76,7 @@ int acpi_device_add(struct acpi_device *device, | |||
| 60 | void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | 76 | void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, |
| 61 | int type, unsigned long long sta); | 77 | int type, unsigned long long sta); |
| 62 | void acpi_device_add_finalize(struct acpi_device *device); | 78 | void acpi_device_add_finalize(struct acpi_device *device); |
| 63 | void acpi_free_ids(struct acpi_device *device); | 79 | void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); |
| 64 | 80 | ||
| 65 | /* -------------------------------------------------------------------------- | 81 | /* -------------------------------------------------------------------------- |
| 66 | Power Resource | 82 | Power Resource |
| @@ -131,4 +147,7 @@ static inline void suspend_nvs_restore(void) {} | |||
| 131 | -------------------------------------------------------------------------- */ | 147 | -------------------------------------------------------------------------- */ |
| 132 | struct platform_device; | 148 | struct platform_device; |
| 133 | 149 | ||
| 150 | int acpi_create_platform_device(struct acpi_device *adev, | ||
| 151 | const struct acpi_device_id *id); | ||
| 152 | |||
| 134 | #endif /* _ACPI_INTERNAL_H_ */ | 153 | #endif /* _ACPI_INTERNAL_H_ */ |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 586e7e993d3d..e72186340fec 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
| @@ -641,7 +641,7 @@ void __init acpi_initrd_override(void *data, size_t size) | |||
| 641 | * Both memblock_reserve and e820_add_region (via arch_reserve_mem_area) | 641 | * Both memblock_reserve and e820_add_region (via arch_reserve_mem_area) |
| 642 | * works fine. | 642 | * works fine. |
| 643 | */ | 643 | */ |
| 644 | memblock_reserve(acpi_tables_addr, acpi_tables_addr + all_tables_size); | 644 | memblock_reserve(acpi_tables_addr, all_tables_size); |
| 645 | arch_reserve_mem_area(acpi_tables_addr, all_tables_size); | 645 | arch_reserve_mem_area(acpi_tables_addr, all_tables_size); |
| 646 | 646 | ||
| 647 | p = early_ioremap(acpi_tables_addr, all_tables_size); | 647 | p = early_ioremap(acpi_tables_addr, all_tables_size); |
| @@ -1555,7 +1555,7 @@ int acpi_check_resource_conflict(const struct resource *res) | |||
| 1555 | else | 1555 | else |
| 1556 | space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY; | 1556 | space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY; |
| 1557 | 1557 | ||
| 1558 | length = res->end - res->start + 1; | 1558 | length = resource_size(res); |
| 1559 | if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) | 1559 | if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) |
| 1560 | warn = 1; | 1560 | warn = 1; |
| 1561 | clash = acpi_check_address_range(space_id, res->start, length, warn); | 1561 | clash = acpi_check_address_range(space_id, res->start, length, warn); |
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index ab764ed34a50..2652a614deeb 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c | |||
| @@ -354,6 +354,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) | |||
| 354 | 354 | ||
| 355 | } | 355 | } |
| 356 | resource->end.type = ACPI_RESOURCE_TYPE_END_TAG; | 356 | resource->end.type = ACPI_RESOURCE_TYPE_END_TAG; |
| 357 | resource->end.length = sizeof(struct acpi_resource); | ||
| 357 | 358 | ||
| 358 | /* Attempt to set the resource */ | 359 | /* Attempt to set the resource */ |
| 359 | status = acpi_set_current_resources(link->device->handle, &buffer); | 360 | status = acpi_set_current_resources(link->device->handle, &buffer); |
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index ac8688b89705..1dd6f6c85874 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
| @@ -169,8 +169,8 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root, | |||
| 169 | *control &= OSC_PCI_CONTROL_MASKS; | 169 | *control &= OSC_PCI_CONTROL_MASKS; |
| 170 | capbuf[OSC_CONTROL_TYPE] = *control | root->osc_control_set; | 170 | capbuf[OSC_CONTROL_TYPE] = *control | root->osc_control_set; |
| 171 | } else { | 171 | } else { |
| 172 | /* Run _OSC query for all possible controls. */ | 172 | /* Run _OSC query only with existing controls. */ |
| 173 | capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS; | 173 | capbuf[OSC_CONTROL_TYPE] = root->osc_control_set; |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | status = acpi_pci_run_osc(root->device->handle, capbuf, &result); | 176 | status = acpi_pci_run_osc(root->device->handle, capbuf, &result); |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 34f5ef11d427..f962047c6c85 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
| @@ -459,57 +459,79 @@ static struct attribute_group attr_groups[] = { | |||
| 459 | }, | 459 | }, |
| 460 | }; | 460 | }; |
| 461 | 461 | ||
| 462 | static void acpi_power_hide_list(struct acpi_device *adev, int state) | 462 | static struct attribute_group wakeup_attr_group = { |
| 463 | .name = "power_resources_wakeup", | ||
| 464 | .attrs = attrs, | ||
| 465 | }; | ||
| 466 | |||
| 467 | static void acpi_power_hide_list(struct acpi_device *adev, | ||
| 468 | struct list_head *resources, | ||
| 469 | struct attribute_group *attr_group) | ||
| 463 | { | 470 | { |
| 464 | struct acpi_device_power_state *ps = &adev->power.states[state]; | ||
| 465 | struct acpi_power_resource_entry *entry; | 471 | struct acpi_power_resource_entry *entry; |
| 466 | 472 | ||
| 467 | if (list_empty(&ps->resources)) | 473 | if (list_empty(resources)) |
| 468 | return; | 474 | return; |
| 469 | 475 | ||
| 470 | list_for_each_entry_reverse(entry, &ps->resources, node) { | 476 | list_for_each_entry_reverse(entry, resources, node) { |
| 471 | struct acpi_device *res_dev = &entry->resource->device; | 477 | struct acpi_device *res_dev = &entry->resource->device; |
| 472 | 478 | ||
| 473 | sysfs_remove_link_from_group(&adev->dev.kobj, | 479 | sysfs_remove_link_from_group(&adev->dev.kobj, |
| 474 | attr_groups[state].name, | 480 | attr_group->name, |
| 475 | dev_name(&res_dev->dev)); | 481 | dev_name(&res_dev->dev)); |
| 476 | } | 482 | } |
| 477 | sysfs_remove_group(&adev->dev.kobj, &attr_groups[state]); | 483 | sysfs_remove_group(&adev->dev.kobj, attr_group); |
| 478 | } | 484 | } |
| 479 | 485 | ||
| 480 | static void acpi_power_expose_list(struct acpi_device *adev, int state) | 486 | static void acpi_power_expose_list(struct acpi_device *adev, |
| 487 | struct list_head *resources, | ||
| 488 | struct attribute_group *attr_group) | ||
| 481 | { | 489 | { |
| 482 | struct acpi_device_power_state *ps = &adev->power.states[state]; | ||
| 483 | struct acpi_power_resource_entry *entry; | 490 | struct acpi_power_resource_entry *entry; |
| 484 | int ret; | 491 | int ret; |
| 485 | 492 | ||
| 486 | if (list_empty(&ps->resources)) | 493 | if (list_empty(resources)) |
| 487 | return; | 494 | return; |
| 488 | 495 | ||
| 489 | ret = sysfs_create_group(&adev->dev.kobj, &attr_groups[state]); | 496 | ret = sysfs_create_group(&adev->dev.kobj, attr_group); |
| 490 | if (ret) | 497 | if (ret) |
| 491 | return; | 498 | return; |
| 492 | 499 | ||
| 493 | list_for_each_entry(entry, &ps->resources, node) { | 500 | list_for_each_entry(entry, resources, node) { |
| 494 | struct acpi_device *res_dev = &entry->resource->device; | 501 | struct acpi_device *res_dev = &entry->resource->device; |
| 495 | 502 | ||
| 496 | ret = sysfs_add_link_to_group(&adev->dev.kobj, | 503 | ret = sysfs_add_link_to_group(&adev->dev.kobj, |
| 497 | attr_groups[state].name, | 504 | attr_group->name, |
| 498 | &res_dev->dev.kobj, | 505 | &res_dev->dev.kobj, |
| 499 | dev_name(&res_dev->dev)); | 506 | dev_name(&res_dev->dev)); |
| 500 | if (ret) { | 507 | if (ret) { |
| 501 | acpi_power_hide_list(adev, state); | 508 | acpi_power_hide_list(adev, resources, attr_group); |
| 502 | break; | 509 | break; |
| 503 | } | 510 | } |
| 504 | } | 511 | } |
| 505 | } | 512 | } |
| 506 | 513 | ||
| 514 | static void acpi_power_expose_hide(struct acpi_device *adev, | ||
| 515 | struct list_head *resources, | ||
| 516 | struct attribute_group *attr_group, | ||
| 517 | bool expose) | ||
| 518 | { | ||
| 519 | if (expose) | ||
| 520 | acpi_power_expose_list(adev, resources, attr_group); | ||
| 521 | else | ||
| 522 | acpi_power_hide_list(adev, resources, attr_group); | ||
| 523 | } | ||
| 524 | |||
| 507 | void acpi_power_add_remove_device(struct acpi_device *adev, bool add) | 525 | void acpi_power_add_remove_device(struct acpi_device *adev, bool add) |
| 508 | { | 526 | { |
| 509 | struct acpi_device_power_state *ps; | 527 | struct acpi_device_power_state *ps; |
| 510 | struct acpi_power_resource_entry *entry; | 528 | struct acpi_power_resource_entry *entry; |
| 511 | int state; | 529 | int state; |
| 512 | 530 | ||
| 531 | if (adev->wakeup.flags.valid) | ||
| 532 | acpi_power_expose_hide(adev, &adev->wakeup.resources, | ||
| 533 | &wakeup_attr_group, add); | ||
| 534 | |||
| 513 | if (!adev->power.flags.power_resources) | 535 | if (!adev->power.flags.power_resources) |
| 514 | return; | 536 | return; |
| 515 | 537 | ||
| @@ -523,12 +545,10 @@ void acpi_power_add_remove_device(struct acpi_device *adev, bool add) | |||
| 523 | acpi_power_remove_dependent(resource, adev); | 545 | acpi_power_remove_dependent(resource, adev); |
| 524 | } | 546 | } |
| 525 | 547 | ||
| 526 | for (state = ACPI_STATE_D0; state <= ACPI_STATE_D3_HOT; state++) { | 548 | for (state = ACPI_STATE_D0; state <= ACPI_STATE_D3_HOT; state++) |
| 527 | if (add) | 549 | acpi_power_expose_hide(adev, |
| 528 | acpi_power_expose_list(adev, state); | 550 | &adev->power.states[state].resources, |
| 529 | else | 551 | &attr_groups[state], add); |
| 530 | acpi_power_hide_list(adev, state); | ||
| 531 | } | ||
| 532 | } | 552 | } |
| 533 | 553 | ||
| 534 | int acpi_power_wakeup_list_init(struct list_head *list, int *system_level_p) | 554 | int acpi_power_wakeup_list_init(struct list_head *list, int *system_level_p) |
| @@ -824,7 +844,7 @@ static void acpi_release_power_resource(struct device *dev) | |||
| 824 | list_del(&resource->list_node); | 844 | list_del(&resource->list_node); |
| 825 | mutex_unlock(&power_resource_list_lock); | 845 | mutex_unlock(&power_resource_list_lock); |
| 826 | 846 | ||
| 827 | acpi_free_ids(device); | 847 | acpi_free_pnp_ids(&device->pnp); |
| 828 | kfree(resource); | 848 | kfree(resource); |
| 829 | } | 849 | } |
| 830 | 850 | ||
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index ee255c60bdac..f0df2c9434d2 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
| @@ -918,7 +918,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, | |||
| 918 | struct cpuidle_driver acpi_idle_driver = { | 918 | struct cpuidle_driver acpi_idle_driver = { |
| 919 | .name = "acpi_idle", | 919 | .name = "acpi_idle", |
| 920 | .owner = THIS_MODULE, | 920 | .owner = THIS_MODULE, |
| 921 | .en_core_tk_irqen = 1, | ||
| 922 | }; | 921 | }; |
| 923 | 922 | ||
| 924 | /** | 923 | /** |
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index 641b5450a0db..e8e652710e65 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c | |||
| @@ -218,9 +218,13 @@ processor_get_max_state(struct thermal_cooling_device *cdev, | |||
| 218 | unsigned long *state) | 218 | unsigned long *state) |
| 219 | { | 219 | { |
| 220 | struct acpi_device *device = cdev->devdata; | 220 | struct acpi_device *device = cdev->devdata; |
| 221 | struct acpi_processor *pr = acpi_driver_data(device); | 221 | struct acpi_processor *pr; |
| 222 | 222 | ||
| 223 | if (!device || !pr) | 223 | if (!device) |
| 224 | return -EINVAL; | ||
| 225 | |||
| 226 | pr = acpi_driver_data(device); | ||
| 227 | if (!pr) | ||
| 224 | return -EINVAL; | 228 | return -EINVAL; |
| 225 | 229 | ||
| 226 | *state = acpi_processor_max_state(pr); | 230 | *state = acpi_processor_max_state(pr); |
| @@ -232,9 +236,13 @@ processor_get_cur_state(struct thermal_cooling_device *cdev, | |||
| 232 | unsigned long *cur_state) | 236 | unsigned long *cur_state) |
| 233 | { | 237 | { |
| 234 | struct acpi_device *device = cdev->devdata; | 238 | struct acpi_device *device = cdev->devdata; |
| 235 | struct acpi_processor *pr = acpi_driver_data(device); | 239 | struct acpi_processor *pr; |
| 236 | 240 | ||
| 237 | if (!device || !pr) | 241 | if (!device) |
| 242 | return -EINVAL; | ||
| 243 | |||
| 244 | pr = acpi_driver_data(device); | ||
| 245 | if (!pr) | ||
| 238 | return -EINVAL; | 246 | return -EINVAL; |
| 239 | 247 | ||
| 240 | *cur_state = cpufreq_get_cur_state(pr->id); | 248 | *cur_state = cpufreq_get_cur_state(pr->id); |
| @@ -248,11 +256,15 @@ processor_set_cur_state(struct thermal_cooling_device *cdev, | |||
| 248 | unsigned long state) | 256 | unsigned long state) |
| 249 | { | 257 | { |
| 250 | struct acpi_device *device = cdev->devdata; | 258 | struct acpi_device *device = cdev->devdata; |
| 251 | struct acpi_processor *pr = acpi_driver_data(device); | 259 | struct acpi_processor *pr; |
| 252 | int result = 0; | 260 | int result = 0; |
| 253 | int max_pstate; | 261 | int max_pstate; |
| 254 | 262 | ||
| 255 | if (!device || !pr) | 263 | if (!device) |
| 264 | return -EINVAL; | ||
| 265 | |||
| 266 | pr = acpi_driver_data(device); | ||
| 267 | if (!pr) | ||
| 256 | return -EINVAL; | 268 | return -EINVAL; |
| 257 | 269 | ||
| 258 | max_pstate = cpufreq_get_max_state(pr->id); | 270 | max_pstate = cpufreq_get_max_state(pr->id); |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 1d02b7b5ade0..e7dd2c1fee79 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
| @@ -211,9 +211,10 @@ err_ret: | |||
| 211 | */ | 211 | */ |
| 212 | void acpi_processor_throttling_init(void) | 212 | void acpi_processor_throttling_init(void) |
| 213 | { | 213 | { |
| 214 | if (acpi_processor_update_tsd_coord()) | 214 | if (acpi_processor_update_tsd_coord()) { |
| 215 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 215 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 216 | "Assume no T-state coordination\n")); | 216 | "Assume no T-state coordination\n")); |
| 217 | } | ||
| 217 | 218 | ||
| 218 | return; | 219 | return; |
| 219 | } | 220 | } |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index f54d1985e594..fe158fd4f1df 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
| @@ -63,6 +63,19 @@ int acpi_scan_add_handler(struct acpi_scan_handler *handler) | |||
| 63 | return 0; | 63 | return 0; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler, | ||
| 67 | const char *hotplug_profile_name) | ||
| 68 | { | ||
| 69 | int error; | ||
| 70 | |||
| 71 | error = acpi_scan_add_handler(handler); | ||
| 72 | if (error) | ||
| 73 | return error; | ||
| 74 | |||
| 75 | acpi_sysfs_add_hotplug_profile(&handler->hotplug, hotplug_profile_name); | ||
| 76 | return 0; | ||
| 77 | } | ||
| 78 | |||
| 66 | /* | 79 | /* |
| 67 | * Creates hid/cid(s) string needed for modalias and uevent | 80 | * Creates hid/cid(s) string needed for modalias and uevent |
| 68 | * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get: | 81 | * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get: |
| @@ -107,32 +120,20 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha | |||
| 107 | } | 120 | } |
| 108 | static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); | 121 | static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); |
| 109 | 122 | ||
| 110 | /** | 123 | static int acpi_scan_hot_remove(struct acpi_device *device) |
| 111 | * acpi_bus_hot_remove_device: hot-remove a device and its children | ||
| 112 | * @context: struct acpi_eject_event pointer (freed in this func) | ||
| 113 | * | ||
| 114 | * Hot-remove a device and its children. This function frees up the | ||
| 115 | * memory space passed by arg context, so that the caller may call | ||
| 116 | * this function asynchronously through acpi_os_hotplug_execute(). | ||
| 117 | */ | ||
| 118 | void acpi_bus_hot_remove_device(void *context) | ||
| 119 | { | 124 | { |
| 120 | struct acpi_eject_event *ej_event = context; | ||
| 121 | struct acpi_device *device = ej_event->device; | ||
| 122 | acpi_handle handle = device->handle; | 125 | acpi_handle handle = device->handle; |
| 123 | acpi_handle temp; | 126 | acpi_handle not_used; |
| 124 | struct acpi_object_list arg_list; | 127 | struct acpi_object_list arg_list; |
| 125 | union acpi_object arg; | 128 | union acpi_object arg; |
| 126 | acpi_status status = AE_OK; | 129 | acpi_status status; |
| 127 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ | 130 | unsigned long long sta; |
| 128 | |||
| 129 | mutex_lock(&acpi_scan_lock); | ||
| 130 | 131 | ||
| 131 | /* If there is no handle, the device node has been unregistered. */ | 132 | /* If there is no handle, the device node has been unregistered. */ |
| 132 | if (!device->handle) { | 133 | if (!handle) { |
| 133 | dev_dbg(&device->dev, "ACPI handle missing\n"); | 134 | dev_dbg(&device->dev, "ACPI handle missing\n"); |
| 134 | put_device(&device->dev); | 135 | put_device(&device->dev); |
| 135 | goto out; | 136 | return -EINVAL; |
| 136 | } | 137 | } |
| 137 | 138 | ||
| 138 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 139 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| @@ -143,7 +144,7 @@ void acpi_bus_hot_remove_device(void *context) | |||
| 143 | put_device(&device->dev); | 144 | put_device(&device->dev); |
| 144 | device = NULL; | 145 | device = NULL; |
| 145 | 146 | ||
| 146 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_LCK", &temp))) { | 147 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_LCK", ¬_used))) { |
| 147 | arg_list.count = 1; | 148 | arg_list.count = 1; |
| 148 | arg_list.pointer = &arg; | 149 | arg_list.pointer = &arg; |
| 149 | arg.type = ACPI_TYPE_INTEGER; | 150 | arg.type = ACPI_TYPE_INTEGER; |
| @@ -161,18 +162,205 @@ void acpi_bus_hot_remove_device(void *context) | |||
| 161 | */ | 162 | */ |
| 162 | status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); | 163 | status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); |
| 163 | if (ACPI_FAILURE(status)) { | 164 | if (ACPI_FAILURE(status)) { |
| 164 | if (status != AE_NOT_FOUND) | 165 | if (status == AE_NOT_FOUND) { |
| 165 | acpi_handle_warn(handle, "Eject failed\n"); | 166 | return -ENODEV; |
| 167 | } else { | ||
| 168 | acpi_handle_warn(handle, "Eject failed (0x%x)\n", | ||
| 169 | status); | ||
| 170 | return -EIO; | ||
| 171 | } | ||
| 172 | } | ||
| 166 | 173 | ||
| 167 | /* Tell the firmware the hot-remove operation has failed. */ | 174 | /* |
| 168 | acpi_evaluate_hotplug_ost(handle, ej_event->event, | 175 | * Verify if eject was indeed successful. If not, log an error |
| 169 | ost_code, NULL); | 176 | * message. No need to call _OST since _EJ0 call was made OK. |
| 177 | */ | ||
| 178 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | ||
| 179 | if (ACPI_FAILURE(status)) { | ||
| 180 | acpi_handle_warn(handle, | ||
| 181 | "Status check after eject failed (0x%x)\n", status); | ||
| 182 | } else if (sta & ACPI_STA_DEVICE_ENABLED) { | ||
| 183 | acpi_handle_warn(handle, | ||
| 184 | "Eject incomplete - status 0x%llx\n", sta); | ||
| 185 | } | ||
| 186 | |||
| 187 | return 0; | ||
| 188 | } | ||
| 189 | |||
| 190 | static void acpi_bus_device_eject(void *context) | ||
| 191 | { | ||
| 192 | acpi_handle handle = context; | ||
| 193 | struct acpi_device *device = NULL; | ||
| 194 | struct acpi_scan_handler *handler; | ||
| 195 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; | ||
| 196 | |||
| 197 | mutex_lock(&acpi_scan_lock); | ||
| 198 | |||
| 199 | acpi_bus_get_device(handle, &device); | ||
| 200 | if (!device) | ||
| 201 | goto err_out; | ||
| 202 | |||
| 203 | handler = device->handler; | ||
| 204 | if (!handler || !handler->hotplug.enabled) { | ||
| 205 | ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; | ||
| 206 | goto err_out; | ||
| 207 | } | ||
| 208 | acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, | ||
| 209 | ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); | ||
| 210 | if (handler->hotplug.mode == AHM_CONTAINER) { | ||
| 211 | device->flags.eject_pending = true; | ||
| 212 | kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); | ||
| 213 | } else { | ||
| 214 | int error; | ||
| 215 | |||
| 216 | get_device(&device->dev); | ||
| 217 | error = acpi_scan_hot_remove(device); | ||
| 218 | if (error) | ||
| 219 | goto err_out; | ||
| 170 | } | 220 | } |
| 171 | 221 | ||
| 172 | out: | 222 | out: |
| 173 | mutex_unlock(&acpi_scan_lock); | 223 | mutex_unlock(&acpi_scan_lock); |
| 174 | kfree(context); | ||
| 175 | return; | 224 | return; |
| 225 | |||
| 226 | err_out: | ||
| 227 | acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, ost_code, | ||
| 228 | NULL); | ||
| 229 | goto out; | ||
| 230 | } | ||
| 231 | |||
| 232 | static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source) | ||
| 233 | { | ||
| 234 | struct acpi_device *device = NULL; | ||
| 235 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; | ||
| 236 | int error; | ||
| 237 | |||
| 238 | mutex_lock(&acpi_scan_lock); | ||
| 239 | |||
| 240 | acpi_bus_get_device(handle, &device); | ||
| 241 | if (device) { | ||
| 242 | dev_warn(&device->dev, "Attempt to re-insert\n"); | ||
| 243 | goto out; | ||
| 244 | } | ||
| 245 | acpi_evaluate_hotplug_ost(handle, ost_source, | ||
| 246 | ACPI_OST_SC_INSERT_IN_PROGRESS, NULL); | ||
| 247 | error = acpi_bus_scan(handle); | ||
| 248 | if (error) { | ||
| 249 | acpi_handle_warn(handle, "Namespace scan failure\n"); | ||
| 250 | goto out; | ||
| 251 | } | ||
| 252 | error = acpi_bus_get_device(handle, &device); | ||
| 253 | if (error) { | ||
| 254 | acpi_handle_warn(handle, "Missing device node object\n"); | ||
| 255 | goto out; | ||
| 256 | } | ||
| 257 | ost_code = ACPI_OST_SC_SUCCESS; | ||
| 258 | if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER) | ||
| 259 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); | ||
| 260 | |||
| 261 | out: | ||
| 262 | acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL); | ||
| 263 | mutex_unlock(&acpi_scan_lock); | ||
| 264 | } | ||
| 265 | |||
| 266 | static void acpi_scan_bus_check(void *context) | ||
| 267 | { | ||
| 268 | acpi_scan_bus_device_check((acpi_handle)context, | ||
| 269 | ACPI_NOTIFY_BUS_CHECK); | ||
| 270 | } | ||
| 271 | |||
| 272 | static void acpi_scan_device_check(void *context) | ||
| 273 | { | ||
| 274 | acpi_scan_bus_device_check((acpi_handle)context, | ||
| 275 | ACPI_NOTIFY_DEVICE_CHECK); | ||
| 276 | } | ||
| 277 | |||
| 278 | static void acpi_hotplug_unsupported(acpi_handle handle, u32 type) | ||
| 279 | { | ||
| 280 | u32 ost_status; | ||
| 281 | |||
| 282 | switch (type) { | ||
| 283 | case ACPI_NOTIFY_BUS_CHECK: | ||
| 284 | acpi_handle_debug(handle, | ||
| 285 | "ACPI_NOTIFY_BUS_CHECK event: unsupported\n"); | ||
| 286 | ost_status = ACPI_OST_SC_INSERT_NOT_SUPPORTED; | ||
| 287 | break; | ||
| 288 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
| 289 | acpi_handle_debug(handle, | ||
| 290 | "ACPI_NOTIFY_DEVICE_CHECK event: unsupported\n"); | ||
| 291 | ost_status = ACPI_OST_SC_INSERT_NOT_SUPPORTED; | ||
| 292 | break; | ||
| 293 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
| 294 | acpi_handle_debug(handle, | ||
| 295 | "ACPI_NOTIFY_EJECT_REQUEST event: unsupported\n"); | ||
| 296 | ost_status = ACPI_OST_SC_EJECT_NOT_SUPPORTED; | ||
| 297 | break; | ||
| 298 | default: | ||
| 299 | /* non-hotplug event; possibly handled by other handler */ | ||
| 300 | return; | ||
| 301 | } | ||
| 302 | |||
| 303 | acpi_evaluate_hotplug_ost(handle, type, ost_status, NULL); | ||
| 304 | } | ||
| 305 | |||
| 306 | static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) | ||
| 307 | { | ||
| 308 | acpi_osd_exec_callback callback; | ||
| 309 | struct acpi_scan_handler *handler = data; | ||
| 310 | acpi_status status; | ||
| 311 | |||
| 312 | if (!handler->hotplug.enabled) | ||
| 313 | return acpi_hotplug_unsupported(handle, type); | ||
| 314 | |||
| 315 | switch (type) { | ||
| 316 | case ACPI_NOTIFY_BUS_CHECK: | ||
| 317 | acpi_handle_debug(handle, "ACPI_NOTIFY_BUS_CHECK event\n"); | ||
| 318 | callback = acpi_scan_bus_check; | ||
| 319 | break; | ||
| 320 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
| 321 | acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK event\n"); | ||
| 322 | callback = acpi_scan_device_check; | ||
| 323 | break; | ||
| 324 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
| 325 | acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n"); | ||
| 326 | callback = acpi_bus_device_eject; | ||
| 327 | break; | ||
| 328 | default: | ||
| 329 | /* non-hotplug event; possibly handled by other handler */ | ||
| 330 | return; | ||
| 331 | } | ||
| 332 | status = acpi_os_hotplug_execute(callback, handle); | ||
| 333 | if (ACPI_FAILURE(status)) | ||
| 334 | acpi_evaluate_hotplug_ost(handle, type, | ||
| 335 | ACPI_OST_SC_NON_SPECIFIC_FAILURE, | ||
| 336 | NULL); | ||
| 337 | } | ||
| 338 | |||
| 339 | /** | ||
| 340 | * acpi_bus_hot_remove_device: hot-remove a device and its children | ||
| 341 | * @context: struct acpi_eject_event pointer (freed in this func) | ||
| 342 | * | ||
| 343 | * Hot-remove a device and its children. This function frees up the | ||
| 344 | * memory space passed by arg context, so that the caller may call | ||
| 345 | * this function asynchronously through acpi_os_hotplug_execute(). | ||
| 346 | */ | ||
| 347 | void acpi_bus_hot_remove_device(void *context) | ||
| 348 | { | ||
| 349 | struct acpi_eject_event *ej_event = context; | ||
| 350 | struct acpi_device *device = ej_event->device; | ||
| 351 | acpi_handle handle = device->handle; | ||
| 352 | int error; | ||
| 353 | |||
| 354 | mutex_lock(&acpi_scan_lock); | ||
| 355 | |||
| 356 | error = acpi_scan_hot_remove(device); | ||
| 357 | if (error && handle) | ||
| 358 | acpi_evaluate_hotplug_ost(handle, ej_event->event, | ||
| 359 | ACPI_OST_SC_NON_SPECIFIC_FAILURE, | ||
| 360 | NULL); | ||
| 361 | |||
| 362 | mutex_unlock(&acpi_scan_lock); | ||
| 363 | kfree(context); | ||
| 176 | } | 364 | } |
| 177 | EXPORT_SYMBOL(acpi_bus_hot_remove_device); | 365 | EXPORT_SYMBOL(acpi_bus_hot_remove_device); |
| 178 | 366 | ||
| @@ -206,51 +394,61 @@ static ssize_t | |||
| 206 | acpi_eject_store(struct device *d, struct device_attribute *attr, | 394 | acpi_eject_store(struct device *d, struct device_attribute *attr, |
| 207 | const char *buf, size_t count) | 395 | const char *buf, size_t count) |
| 208 | { | 396 | { |
| 209 | int ret = count; | ||
| 210 | acpi_status status; | ||
| 211 | acpi_object_type type = 0; | ||
| 212 | struct acpi_device *acpi_device = to_acpi_device(d); | 397 | struct acpi_device *acpi_device = to_acpi_device(d); |
| 213 | struct acpi_eject_event *ej_event; | 398 | struct acpi_eject_event *ej_event; |
| 399 | acpi_object_type not_used; | ||
| 400 | acpi_status status; | ||
| 401 | u32 ost_source; | ||
| 402 | int ret; | ||
| 214 | 403 | ||
| 215 | if ((!count) || (buf[0] != '1')) { | 404 | if (!count || buf[0] != '1') |
| 216 | return -EINVAL; | 405 | return -EINVAL; |
| 217 | } | ||
| 218 | if (!acpi_device->driver && !acpi_device->handler) { | ||
| 219 | ret = -ENODEV; | ||
| 220 | goto err; | ||
| 221 | } | ||
| 222 | status = acpi_get_type(acpi_device->handle, &type); | ||
| 223 | if (ACPI_FAILURE(status) || (!acpi_device->flags.ejectable)) { | ||
| 224 | ret = -ENODEV; | ||
| 225 | goto err; | ||
| 226 | } | ||
| 227 | 406 | ||
| 228 | ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); | 407 | if ((!acpi_device->handler || !acpi_device->handler->hotplug.enabled) |
| 229 | if (!ej_event) { | 408 | && !acpi_device->driver) |
| 230 | ret = -ENOMEM; | 409 | return -ENODEV; |
| 231 | goto err; | 410 | |
| 232 | } | 411 | status = acpi_get_type(acpi_device->handle, ¬_used); |
| 412 | if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable) | ||
| 413 | return -ENODEV; | ||
| 414 | |||
| 415 | mutex_lock(&acpi_scan_lock); | ||
| 233 | 416 | ||
| 234 | get_device(&acpi_device->dev); | ||
| 235 | ej_event->device = acpi_device; | ||
| 236 | if (acpi_device->flags.eject_pending) { | 417 | if (acpi_device->flags.eject_pending) { |
| 237 | /* event originated from ACPI eject notification */ | 418 | /* ACPI eject notification event. */ |
| 238 | ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; | 419 | ost_source = ACPI_NOTIFY_EJECT_REQUEST; |
| 239 | acpi_device->flags.eject_pending = 0; | 420 | acpi_device->flags.eject_pending = 0; |
| 240 | } else { | 421 | } else { |
| 241 | /* event originated from user */ | 422 | /* Eject initiated by user space. */ |
| 242 | ej_event->event = ACPI_OST_EC_OSPM_EJECT; | 423 | ost_source = ACPI_OST_EC_OSPM_EJECT; |
| 243 | (void) acpi_evaluate_hotplug_ost(acpi_device->handle, | ||
| 244 | ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); | ||
| 245 | } | 424 | } |
| 246 | 425 | ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); | |
| 426 | if (!ej_event) { | ||
| 427 | ret = -ENOMEM; | ||
| 428 | goto err_out; | ||
| 429 | } | ||
| 430 | acpi_evaluate_hotplug_ost(acpi_device->handle, ost_source, | ||
| 431 | ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); | ||
| 432 | ej_event->device = acpi_device; | ||
| 433 | ej_event->event = ost_source; | ||
| 434 | get_device(&acpi_device->dev); | ||
| 247 | status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, ej_event); | 435 | status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, ej_event); |
| 248 | if (ACPI_FAILURE(status)) { | 436 | if (ACPI_FAILURE(status)) { |
| 249 | put_device(&acpi_device->dev); | 437 | put_device(&acpi_device->dev); |
| 250 | kfree(ej_event); | 438 | kfree(ej_event); |
| 439 | ret = status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN; | ||
| 440 | goto err_out; | ||
| 251 | } | 441 | } |
| 252 | err: | 442 | ret = count; |
| 443 | |||
| 444 | out: | ||
| 445 | mutex_unlock(&acpi_scan_lock); | ||
| 253 | return ret; | 446 | return ret; |
| 447 | |||
| 448 | err_out: | ||
| 449 | acpi_evaluate_hotplug_ost(acpi_device->handle, ost_source, | ||
| 450 | ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL); | ||
| 451 | goto out; | ||
| 254 | } | 452 | } |
| 255 | 453 | ||
| 256 | static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store); | 454 | static DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store); |
| @@ -376,7 +574,7 @@ static int acpi_device_setup_files(struct acpi_device *dev) | |||
| 376 | goto end; | 574 | goto end; |
| 377 | } | 575 | } |
| 378 | 576 | ||
| 379 | if (dev->flags.bus_address) | 577 | if (dev->pnp.type.bus_address) |
| 380 | result = device_create_file(&dev->dev, &dev_attr_adr); | 578 | result = device_create_file(&dev->dev, &dev_attr_adr); |
| 381 | if (dev->pnp.unique_id) | 579 | if (dev->pnp.unique_id) |
| 382 | result = device_create_file(&dev->dev, &dev_attr_uid); | 580 | result = device_create_file(&dev->dev, &dev_attr_uid); |
| @@ -449,7 +647,7 @@ static void acpi_device_remove_files(struct acpi_device *dev) | |||
| 449 | 647 | ||
| 450 | if (dev->pnp.unique_id) | 648 | if (dev->pnp.unique_id) |
| 451 | device_remove_file(&dev->dev, &dev_attr_uid); | 649 | device_remove_file(&dev->dev, &dev_attr_uid); |
| 452 | if (dev->flags.bus_address) | 650 | if (dev->pnp.type.bus_address) |
| 453 | device_remove_file(&dev->dev, &dev_attr_adr); | 651 | device_remove_file(&dev->dev, &dev_attr_adr); |
| 454 | device_remove_file(&dev->dev, &dev_attr_modalias); | 652 | device_remove_file(&dev->dev, &dev_attr_modalias); |
| 455 | device_remove_file(&dev->dev, &dev_attr_hid); | 653 | device_remove_file(&dev->dev, &dev_attr_hid); |
| @@ -512,17 +710,6 @@ int acpi_match_device_ids(struct acpi_device *device, | |||
| 512 | } | 710 | } |
| 513 | EXPORT_SYMBOL(acpi_match_device_ids); | 711 | EXPORT_SYMBOL(acpi_match_device_ids); |
| 514 | 712 | ||
| 515 | void acpi_free_ids(struct acpi_device *device) | ||
| 516 | { | ||
| 517 | struct acpi_hardware_id *id, *tmp; | ||
| 518 | |||
| 519 | list_for_each_entry_safe(id, tmp, &device->pnp.ids, list) { | ||
| 520 | kfree(id->id); | ||
| 521 | kfree(id); | ||
| 522 | } | ||
| 523 | kfree(device->pnp.unique_id); | ||
| 524 | } | ||
| 525 | |||
| 526 | static void acpi_free_power_resources_lists(struct acpi_device *device) | 713 | static void acpi_free_power_resources_lists(struct acpi_device *device) |
| 527 | { | 714 | { |
| 528 | int i; | 715 | int i; |
| @@ -543,7 +730,7 @@ static void acpi_device_release(struct device *dev) | |||
| 543 | { | 730 | { |
| 544 | struct acpi_device *acpi_dev = to_acpi_device(dev); | 731 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
| 545 | 732 | ||
| 546 | acpi_free_ids(acpi_dev); | 733 | acpi_free_pnp_ids(&acpi_dev->pnp); |
| 547 | acpi_free_power_resources_lists(acpi_dev); | 734 | acpi_free_power_resources_lists(acpi_dev); |
| 548 | kfree(acpi_dev); | 735 | kfree(acpi_dev); |
| 549 | } | 736 | } |
| @@ -1256,19 +1443,17 @@ static void acpi_device_get_busid(struct acpi_device *device) | |||
| 1256 | } | 1443 | } |
| 1257 | 1444 | ||
| 1258 | /* | 1445 | /* |
| 1259 | * acpi_bay_match - see if a device is an ejectable driver bay | 1446 | * acpi_bay_match - see if an acpi object is an ejectable driver bay |
| 1260 | * | 1447 | * |
| 1261 | * If an acpi object is ejectable and has one of the ACPI ATA methods defined, | 1448 | * If an acpi object is ejectable and has one of the ACPI ATA methods defined, |
| 1262 | * then we can safely call it an ejectable drive bay | 1449 | * then we can safely call it an ejectable drive bay |
| 1263 | */ | 1450 | */ |
| 1264 | static int acpi_bay_match(struct acpi_device *device){ | 1451 | static int acpi_bay_match(acpi_handle handle) |
| 1452 | { | ||
| 1265 | acpi_status status; | 1453 | acpi_status status; |
| 1266 | acpi_handle handle; | ||
| 1267 | acpi_handle tmp; | 1454 | acpi_handle tmp; |
| 1268 | acpi_handle phandle; | 1455 | acpi_handle phandle; |
| 1269 | 1456 | ||
| 1270 | handle = device->handle; | ||
| 1271 | |||
| 1272 | status = acpi_get_handle(handle, "_EJ0", &tmp); | 1457 | status = acpi_get_handle(handle, "_EJ0", &tmp); |
| 1273 | if (ACPI_FAILURE(status)) | 1458 | if (ACPI_FAILURE(status)) |
| 1274 | return -ENODEV; | 1459 | return -ENODEV; |
| @@ -1292,12 +1477,12 @@ static int acpi_bay_match(struct acpi_device *device){ | |||
| 1292 | } | 1477 | } |
| 1293 | 1478 | ||
| 1294 | /* | 1479 | /* |
| 1295 | * acpi_dock_match - see if a device has a _DCK method | 1480 | * acpi_dock_match - see if an acpi object has a _DCK method |
| 1296 | */ | 1481 | */ |
| 1297 | static int acpi_dock_match(struct acpi_device *device) | 1482 | static int acpi_dock_match(acpi_handle handle) |
| 1298 | { | 1483 | { |
| 1299 | acpi_handle tmp; | 1484 | acpi_handle tmp; |
| 1300 | return acpi_get_handle(device->handle, "_DCK", &tmp); | 1485 | return acpi_get_handle(handle, "_DCK", &tmp); |
| 1301 | } | 1486 | } |
| 1302 | 1487 | ||
| 1303 | const char *acpi_device_hid(struct acpi_device *device) | 1488 | const char *acpi_device_hid(struct acpi_device *device) |
| @@ -1312,7 +1497,7 @@ const char *acpi_device_hid(struct acpi_device *device) | |||
| 1312 | } | 1497 | } |
| 1313 | EXPORT_SYMBOL(acpi_device_hid); | 1498 | EXPORT_SYMBOL(acpi_device_hid); |
| 1314 | 1499 | ||
| 1315 | static void acpi_add_id(struct acpi_device *device, const char *dev_id) | 1500 | static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id) |
| 1316 | { | 1501 | { |
| 1317 | struct acpi_hardware_id *id; | 1502 | struct acpi_hardware_id *id; |
| 1318 | 1503 | ||
| @@ -1326,7 +1511,8 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id) | |||
| 1326 | return; | 1511 | return; |
| 1327 | } | 1512 | } |
| 1328 | 1513 | ||
| 1329 | list_add_tail(&id->list, &device->pnp.ids); | 1514 | list_add_tail(&id->list, &pnp->ids); |
| 1515 | pnp->type.hardware_id = 1; | ||
| 1330 | } | 1516 | } |
| 1331 | 1517 | ||
| 1332 | /* | 1518 | /* |
| @@ -1334,7 +1520,7 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id) | |||
| 1334 | * lacks the SMBUS01 HID and the methods do not have the necessary "_" | 1520 | * lacks the SMBUS01 HID and the methods do not have the necessary "_" |
| 1335 | * prefix. Work around this. | 1521 | * prefix. Work around this. |
| 1336 | */ | 1522 | */ |
| 1337 | static int acpi_ibm_smbus_match(struct acpi_device *device) | 1523 | static int acpi_ibm_smbus_match(acpi_handle handle) |
| 1338 | { | 1524 | { |
| 1339 | acpi_handle h_dummy; | 1525 | acpi_handle h_dummy; |
| 1340 | struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; | 1526 | struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; |
| @@ -1344,7 +1530,7 @@ static int acpi_ibm_smbus_match(struct acpi_device *device) | |||
| 1344 | return -ENODEV; | 1530 | return -ENODEV; |
| 1345 | 1531 | ||
| 1346 | /* Look for SMBS object */ | 1532 | /* Look for SMBS object */ |
| 1347 | result = acpi_get_name(device->handle, ACPI_SINGLE_NAME, &path); | 1533 | result = acpi_get_name(handle, ACPI_SINGLE_NAME, &path); |
| 1348 | if (result) | 1534 | if (result) |
| 1349 | return result; | 1535 | return result; |
| 1350 | 1536 | ||
| @@ -1355,48 +1541,50 @@ static int acpi_ibm_smbus_match(struct acpi_device *device) | |||
| 1355 | 1541 | ||
| 1356 | /* Does it have the necessary (but misnamed) methods? */ | 1542 | /* Does it have the necessary (but misnamed) methods? */ |
| 1357 | result = -ENODEV; | 1543 | result = -ENODEV; |
| 1358 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "SBI", &h_dummy)) && | 1544 | if (ACPI_SUCCESS(acpi_get_handle(handle, "SBI", &h_dummy)) && |
| 1359 | ACPI_SUCCESS(acpi_get_handle(device->handle, "SBR", &h_dummy)) && | 1545 | ACPI_SUCCESS(acpi_get_handle(handle, "SBR", &h_dummy)) && |
| 1360 | ACPI_SUCCESS(acpi_get_handle(device->handle, "SBW", &h_dummy))) | 1546 | ACPI_SUCCESS(acpi_get_handle(handle, "SBW", &h_dummy))) |
| 1361 | result = 0; | 1547 | result = 0; |
| 1362 | out: | 1548 | out: |
| 1363 | kfree(path.pointer); | 1549 | kfree(path.pointer); |
| 1364 | return result; | 1550 | return result; |
| 1365 | } | 1551 | } |
| 1366 | 1552 | ||
| 1367 | static void acpi_device_set_id(struct acpi_device *device) | 1553 | static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, |
| 1554 | int device_type) | ||
| 1368 | { | 1555 | { |
| 1369 | acpi_status status; | 1556 | acpi_status status; |
| 1370 | struct acpi_device_info *info; | 1557 | struct acpi_device_info *info; |
| 1371 | struct acpi_pnp_device_id_list *cid_list; | 1558 | struct acpi_pnp_device_id_list *cid_list; |
| 1372 | int i; | 1559 | int i; |
| 1373 | 1560 | ||
| 1374 | switch (device->device_type) { | 1561 | switch (device_type) { |
| 1375 | case ACPI_BUS_TYPE_DEVICE: | 1562 | case ACPI_BUS_TYPE_DEVICE: |
| 1376 | if (ACPI_IS_ROOT_DEVICE(device)) { | 1563 | if (handle == ACPI_ROOT_OBJECT) { |
| 1377 | acpi_add_id(device, ACPI_SYSTEM_HID); | 1564 | acpi_add_id(pnp, ACPI_SYSTEM_HID); |
| 1378 | break; | 1565 | break; |
| 1379 | } | 1566 | } |
| 1380 | 1567 | ||
| 1381 | status = acpi_get_object_info(device->handle, &info); | 1568 | status = acpi_get_object_info(handle, &info); |
| 1382 | if (ACPI_FAILURE(status)) { | 1569 | if (ACPI_FAILURE(status)) { |
| 1383 | printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__); | 1570 | pr_err(PREFIX "%s: Error reading device info\n", |
| 1571 | __func__); | ||
| 1384 | return; | 1572 | return; |
| 1385 | } | 1573 | } |
| 1386 | 1574 | ||
| 1387 | if (info->valid & ACPI_VALID_HID) | 1575 | if (info->valid & ACPI_VALID_HID) |
| 1388 | acpi_add_id(device, info->hardware_id.string); | 1576 | acpi_add_id(pnp, info->hardware_id.string); |
| 1389 | if (info->valid & ACPI_VALID_CID) { | 1577 | if (info->valid & ACPI_VALID_CID) { |
| 1390 | cid_list = &info->compatible_id_list; | 1578 | cid_list = &info->compatible_id_list; |
| 1391 | for (i = 0; i < cid_list->count; i++) | 1579 | for (i = 0; i < cid_list->count; i++) |
| 1392 | acpi_add_id(device, cid_list->ids[i].string); | 1580 | acpi_add_id(pnp, cid_list->ids[i].string); |
| 1393 | } | 1581 | } |
| 1394 | if (info->valid & ACPI_VALID_ADR) { | 1582 | if (info->valid & ACPI_VALID_ADR) { |
| 1395 | device->pnp.bus_address = info->address; | 1583 | pnp->bus_address = info->address; |
| 1396 | device->flags.bus_address = 1; | 1584 | pnp->type.bus_address = 1; |
| 1397 | } | 1585 | } |
| 1398 | if (info->valid & ACPI_VALID_UID) | 1586 | if (info->valid & ACPI_VALID_UID) |
| 1399 | device->pnp.unique_id = kstrdup(info->unique_id.string, | 1587 | pnp->unique_id = kstrdup(info->unique_id.string, |
| 1400 | GFP_KERNEL); | 1588 | GFP_KERNEL); |
| 1401 | 1589 | ||
| 1402 | kfree(info); | 1590 | kfree(info); |
| @@ -1405,40 +1593,50 @@ static void acpi_device_set_id(struct acpi_device *device) | |||
| 1405 | * Some devices don't reliably have _HIDs & _CIDs, so add | 1593 | * Some devices don't reliably have _HIDs & _CIDs, so add |
| 1406 | * synthetic HIDs to make sure drivers can find them. | 1594 | * synthetic HIDs to make sure drivers can find them. |
| 1407 | */ | 1595 | */ |
| 1408 | if (acpi_is_video_device(device)) | 1596 | if (acpi_is_video_device(handle)) |
| 1409 | acpi_add_id(device, ACPI_VIDEO_HID); | 1597 | acpi_add_id(pnp, ACPI_VIDEO_HID); |
| 1410 | else if (ACPI_SUCCESS(acpi_bay_match(device))) | 1598 | else if (ACPI_SUCCESS(acpi_bay_match(handle))) |
| 1411 | acpi_add_id(device, ACPI_BAY_HID); | 1599 | acpi_add_id(pnp, ACPI_BAY_HID); |
| 1412 | else if (ACPI_SUCCESS(acpi_dock_match(device))) | 1600 | else if (ACPI_SUCCESS(acpi_dock_match(handle))) |
| 1413 | acpi_add_id(device, ACPI_DOCK_HID); | 1601 | acpi_add_id(pnp, ACPI_DOCK_HID); |
| 1414 | else if (!acpi_ibm_smbus_match(device)) | 1602 | else if (!acpi_ibm_smbus_match(handle)) |
| 1415 | acpi_add_id(device, ACPI_SMBUS_IBM_HID); | 1603 | acpi_add_id(pnp, ACPI_SMBUS_IBM_HID); |
| 1416 | else if (list_empty(&device->pnp.ids) && | 1604 | else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) { |
| 1417 | ACPI_IS_ROOT_DEVICE(device->parent)) { | 1605 | acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ |
| 1418 | acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ | 1606 | strcpy(pnp->device_name, ACPI_BUS_DEVICE_NAME); |
| 1419 | strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); | 1607 | strcpy(pnp->device_class, ACPI_BUS_CLASS); |
| 1420 | strcpy(device->pnp.device_class, ACPI_BUS_CLASS); | ||
| 1421 | } | 1608 | } |
| 1422 | 1609 | ||
| 1423 | break; | 1610 | break; |
| 1424 | case ACPI_BUS_TYPE_POWER: | 1611 | case ACPI_BUS_TYPE_POWER: |
| 1425 | acpi_add_id(device, ACPI_POWER_HID); | 1612 | acpi_add_id(pnp, ACPI_POWER_HID); |
| 1426 | break; | 1613 | break; |
| 1427 | case ACPI_BUS_TYPE_PROCESSOR: | 1614 | case ACPI_BUS_TYPE_PROCESSOR: |
| 1428 | acpi_add_id(device, ACPI_PROCESSOR_OBJECT_HID); | 1615 | acpi_add_id(pnp, ACPI_PROCESSOR_OBJECT_HID); |
| 1429 | break; | 1616 | break; |
| 1430 | case ACPI_BUS_TYPE_THERMAL: | 1617 | case ACPI_BUS_TYPE_THERMAL: |
| 1431 | acpi_add_id(device, ACPI_THERMAL_HID); | 1618 | acpi_add_id(pnp, ACPI_THERMAL_HID); |
| 1432 | break; | 1619 | break; |
| 1433 | case ACPI_BUS_TYPE_POWER_BUTTON: | 1620 | case ACPI_BUS_TYPE_POWER_BUTTON: |
| 1434 | acpi_add_id(device, ACPI_BUTTON_HID_POWERF); | 1621 | acpi_add_id(pnp, ACPI_BUTTON_HID_POWERF); |
| 1435 | break; | 1622 | break; |
| 1436 | case ACPI_BUS_TYPE_SLEEP_BUTTON: | 1623 | case ACPI_BUS_TYPE_SLEEP_BUTTON: |
| 1437 | acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF); | 1624 | acpi_add_id(pnp, ACPI_BUTTON_HID_SLEEPF); |
| 1438 | break; | 1625 | break; |
| 1439 | } | 1626 | } |
| 1440 | } | 1627 | } |
| 1441 | 1628 | ||
| 1629 | void acpi_free_pnp_ids(struct acpi_device_pnp *pnp) | ||
| 1630 | { | ||
| 1631 | struct acpi_hardware_id *id, *tmp; | ||
| 1632 | |||
| 1633 | list_for_each_entry_safe(id, tmp, &pnp->ids, list) { | ||
| 1634 | kfree(id->id); | ||
| 1635 | kfree(id); | ||
| 1636 | } | ||
| 1637 | kfree(pnp->unique_id); | ||
| 1638 | } | ||
| 1639 | |||
| 1442 | void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | 1640 | void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, |
| 1443 | int type, unsigned long long sta) | 1641 | int type, unsigned long long sta) |
| 1444 | { | 1642 | { |
| @@ -1448,7 +1646,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | |||
| 1448 | device->parent = acpi_bus_get_parent(handle); | 1646 | device->parent = acpi_bus_get_parent(handle); |
| 1449 | STRUCT_TO_INT(device->status) = sta; | 1647 | STRUCT_TO_INT(device->status) = sta; |
| 1450 | acpi_device_get_busid(device); | 1648 | acpi_device_get_busid(device); |
| 1451 | acpi_device_set_id(device); | 1649 | acpi_set_pnp_ids(handle, &device->pnp, type); |
| 1452 | acpi_bus_get_flags(device); | 1650 | acpi_bus_get_flags(device); |
| 1453 | device->flags.match_driver = false; | 1651 | device->flags.match_driver = false; |
| 1454 | device_initialize(&device->dev); | 1652 | device_initialize(&device->dev); |
| @@ -1536,6 +1734,75 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, | |||
| 1536 | return 0; | 1734 | return 0; |
| 1537 | } | 1735 | } |
| 1538 | 1736 | ||
| 1737 | static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler, | ||
| 1738 | char *idstr, | ||
| 1739 | const struct acpi_device_id **matchid) | ||
| 1740 | { | ||
| 1741 | const struct acpi_device_id *devid; | ||
| 1742 | |||
| 1743 | for (devid = handler->ids; devid->id[0]; devid++) | ||
| 1744 | if (!strcmp((char *)devid->id, idstr)) { | ||
| 1745 | if (matchid) | ||
| 1746 | *matchid = devid; | ||
| 1747 | |||
| 1748 | return true; | ||
| 1749 | } | ||
| 1750 | |||
| 1751 | return false; | ||
| 1752 | } | ||
| 1753 | |||
| 1754 | static struct acpi_scan_handler *acpi_scan_match_handler(char *idstr, | ||
| 1755 | const struct acpi_device_id **matchid) | ||
| 1756 | { | ||
| 1757 | struct acpi_scan_handler *handler; | ||
| 1758 | |||
| 1759 | list_for_each_entry(handler, &acpi_scan_handlers_list, list_node) | ||
| 1760 | if (acpi_scan_handler_matching(handler, idstr, matchid)) | ||
| 1761 | return handler; | ||
| 1762 | |||
| 1763 | return NULL; | ||
| 1764 | } | ||
| 1765 | |||
| 1766 | void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val) | ||
| 1767 | { | ||
| 1768 | if (!!hotplug->enabled == !!val) | ||
| 1769 | return; | ||
| 1770 | |||
| 1771 | mutex_lock(&acpi_scan_lock); | ||
| 1772 | |||
| 1773 | hotplug->enabled = val; | ||
| 1774 | |||
| 1775 | mutex_unlock(&acpi_scan_lock); | ||
| 1776 | } | ||
| 1777 | |||
| 1778 | static void acpi_scan_init_hotplug(acpi_handle handle, int type) | ||
| 1779 | { | ||
| 1780 | struct acpi_device_pnp pnp = {}; | ||
| 1781 | struct acpi_hardware_id *hwid; | ||
| 1782 | struct acpi_scan_handler *handler; | ||
| 1783 | |||
| 1784 | INIT_LIST_HEAD(&pnp.ids); | ||
| 1785 | acpi_set_pnp_ids(handle, &pnp, type); | ||
| 1786 | |||
| 1787 | if (!pnp.type.hardware_id) | ||
| 1788 | return; | ||
| 1789 | |||
| 1790 | /* | ||
| 1791 | * This relies on the fact that acpi_install_notify_handler() will not | ||
| 1792 | * install the same notify handler routine twice for the same handle. | ||
| 1793 | */ | ||
| 1794 | list_for_each_entry(hwid, &pnp.ids, list) { | ||
| 1795 | handler = acpi_scan_match_handler(hwid->id, NULL); | ||
| 1796 | if (handler) { | ||
| 1797 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
| 1798 | acpi_hotplug_notify_cb, handler); | ||
| 1799 | break; | ||
| 1800 | } | ||
| 1801 | } | ||
| 1802 | |||
| 1803 | acpi_free_pnp_ids(&pnp); | ||
| 1804 | } | ||
| 1805 | |||
| 1539 | static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | 1806 | static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, |
| 1540 | void *not_used, void **return_value) | 1807 | void *not_used, void **return_value) |
| 1541 | { | 1808 | { |
| @@ -1558,6 +1825,8 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | |||
| 1558 | return AE_OK; | 1825 | return AE_OK; |
| 1559 | } | 1826 | } |
| 1560 | 1827 | ||
| 1828 | acpi_scan_init_hotplug(handle, type); | ||
| 1829 | |||
| 1561 | if (!(sta & ACPI_STA_DEVICE_PRESENT) && | 1830 | if (!(sta & ACPI_STA_DEVICE_PRESENT) && |
| 1562 | !(sta & ACPI_STA_DEVICE_FUNCTIONING)) { | 1831 | !(sta & ACPI_STA_DEVICE_FUNCTIONING)) { |
| 1563 | struct acpi_device_wakeup wakeup; | 1832 | struct acpi_device_wakeup wakeup; |
| @@ -1583,42 +1852,26 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | |||
| 1583 | return AE_OK; | 1852 | return AE_OK; |
| 1584 | } | 1853 | } |
| 1585 | 1854 | ||
| 1586 | static int acpi_scan_do_attach_handler(struct acpi_device *device, char *id) | 1855 | static int acpi_scan_attach_handler(struct acpi_device *device) |
| 1587 | { | 1856 | { |
| 1588 | struct acpi_scan_handler *handler; | 1857 | struct acpi_hardware_id *hwid; |
| 1858 | int ret = 0; | ||
| 1589 | 1859 | ||
| 1590 | list_for_each_entry(handler, &acpi_scan_handlers_list, list_node) { | 1860 | list_for_each_entry(hwid, &device->pnp.ids, list) { |
| 1591 | const struct acpi_device_id *devid; | 1861 | const struct acpi_device_id *devid; |
| 1862 | struct acpi_scan_handler *handler; | ||
| 1592 | 1863 | ||
| 1593 | for (devid = handler->ids; devid->id[0]; devid++) { | 1864 | handler = acpi_scan_match_handler(hwid->id, &devid); |
| 1594 | int ret; | 1865 | if (handler) { |
| 1595 | |||
| 1596 | if (strcmp((char *)devid->id, id)) | ||
| 1597 | continue; | ||
| 1598 | |||
| 1599 | ret = handler->attach(device, devid); | 1866 | ret = handler->attach(device, devid); |
| 1600 | if (ret > 0) { | 1867 | if (ret > 0) { |
| 1601 | device->handler = handler; | 1868 | device->handler = handler; |
| 1602 | return ret; | 1869 | break; |
| 1603 | } else if (ret < 0) { | 1870 | } else if (ret < 0) { |
| 1604 | return ret; | 1871 | break; |
| 1605 | } | 1872 | } |
| 1606 | } | 1873 | } |
| 1607 | } | 1874 | } |
| 1608 | return 0; | ||
| 1609 | } | ||
| 1610 | |||
| 1611 | static int acpi_scan_attach_handler(struct acpi_device *device) | ||
| 1612 | { | ||
| 1613 | struct acpi_hardware_id *hwid; | ||
| 1614 | int ret = 0; | ||
| 1615 | |||
| 1616 | list_for_each_entry(hwid, &device->pnp.ids, list) { | ||
| 1617 | ret = acpi_scan_do_attach_handler(device, hwid->id); | ||
| 1618 | if (ret) | ||
| 1619 | break; | ||
| 1620 | |||
| 1621 | } | ||
| 1622 | return ret; | 1875 | return ret; |
| 1623 | } | 1876 | } |
| 1624 | 1877 | ||
| @@ -1788,8 +2041,10 @@ int __init acpi_scan_init(void) | |||
| 1788 | acpi_pci_root_init(); | 2041 | acpi_pci_root_init(); |
| 1789 | acpi_pci_link_init(); | 2042 | acpi_pci_link_init(); |
| 1790 | acpi_platform_init(); | 2043 | acpi_platform_init(); |
| 2044 | acpi_lpss_init(); | ||
| 1791 | acpi_csrt_init(); | 2045 | acpi_csrt_init(); |
| 1792 | acpi_container_init(); | 2046 | acpi_container_init(); |
| 2047 | acpi_memory_hotplug_init(); | ||
| 1793 | 2048 | ||
| 1794 | mutex_lock(&acpi_scan_lock); | 2049 | mutex_lock(&acpi_scan_lock); |
| 1795 | /* | 2050 | /* |
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 41c0504470db..fcae5fa2e1b3 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | #include <linux/moduleparam.h> | 7 | #include <linux/moduleparam.h> |
| 8 | #include <acpi/acpi_drivers.h> | 8 | #include <acpi/acpi_drivers.h> |
| 9 | 9 | ||
| 10 | #include "internal.h" | ||
| 11 | |||
| 10 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 12 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
| 11 | ACPI_MODULE_NAME("sysfs"); | 13 | ACPI_MODULE_NAME("sysfs"); |
| 12 | 14 | ||
| @@ -249,6 +251,7 @@ module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444); | |||
| 249 | static LIST_HEAD(acpi_table_attr_list); | 251 | static LIST_HEAD(acpi_table_attr_list); |
| 250 | static struct kobject *tables_kobj; | 252 | static struct kobject *tables_kobj; |
| 251 | static struct kobject *dynamic_tables_kobj; | 253 | static struct kobject *dynamic_tables_kobj; |
| 254 | static struct kobject *hotplug_kobj; | ||
| 252 | 255 | ||
| 253 | struct acpi_table_attr { | 256 | struct acpi_table_attr { |
| 254 | struct bin_attribute attr; | 257 | struct bin_attribute attr; |
| @@ -716,6 +719,67 @@ acpi_show_profile(struct device *dev, struct device_attribute *attr, | |||
| 716 | static const struct device_attribute pm_profile_attr = | 719 | static const struct device_attribute pm_profile_attr = |
| 717 | __ATTR(pm_profile, S_IRUGO, acpi_show_profile, NULL); | 720 | __ATTR(pm_profile, S_IRUGO, acpi_show_profile, NULL); |
| 718 | 721 | ||
| 722 | static ssize_t hotplug_enabled_show(struct kobject *kobj, | ||
| 723 | struct kobj_attribute *attr, char *buf) | ||
| 724 | { | ||
| 725 | struct acpi_hotplug_profile *hotplug = to_acpi_hotplug_profile(kobj); | ||
| 726 | |||
| 727 | return sprintf(buf, "%d\n", hotplug->enabled); | ||
| 728 | } | ||
| 729 | |||
| 730 | static ssize_t hotplug_enabled_store(struct kobject *kobj, | ||
| 731 | struct kobj_attribute *attr, | ||
| 732 | const char *buf, size_t size) | ||
| 733 | { | ||
| 734 | struct acpi_hotplug_profile *hotplug = to_acpi_hotplug_profile(kobj); | ||
| 735 | unsigned int val; | ||
| 736 | |||
| 737 | if (kstrtouint(buf, 10, &val) || val > 1) | ||
| 738 | return -EINVAL; | ||
| 739 | |||
| 740 | acpi_scan_hotplug_enabled(hotplug, val); | ||
| 741 | return size; | ||
| 742 | } | ||
| 743 | |||
| 744 | static struct kobj_attribute hotplug_enabled_attr = | ||
| 745 | __ATTR(enabled, S_IRUGO | S_IWUSR, hotplug_enabled_show, | ||
| 746 | hotplug_enabled_store); | ||
| 747 | |||
| 748 | static struct attribute *hotplug_profile_attrs[] = { | ||
| 749 | &hotplug_enabled_attr.attr, | ||
| 750 | NULL | ||
| 751 | }; | ||
| 752 | |||
| 753 | static struct kobj_type acpi_hotplug_profile_ktype = { | ||
| 754 | .sysfs_ops = &kobj_sysfs_ops, | ||
| 755 | .default_attrs = hotplug_profile_attrs, | ||
| 756 | }; | ||
| 757 | |||
| 758 | void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, | ||
| 759 | const char *name) | ||
| 760 | { | ||
| 761 | int error; | ||
| 762 | |||
| 763 | if (!hotplug_kobj) | ||
| 764 | goto err_out; | ||
| 765 | |||
| 766 | kobject_init(&hotplug->kobj, &acpi_hotplug_profile_ktype); | ||
| 767 | error = kobject_set_name(&hotplug->kobj, "%s", name); | ||
| 768 | if (error) | ||
| 769 | goto err_out; | ||
| 770 | |||
| 771 | hotplug->kobj.parent = hotplug_kobj; | ||
| 772 | error = kobject_add(&hotplug->kobj, hotplug_kobj, NULL); | ||
| 773 | if (error) | ||
| 774 | goto err_out; | ||
| 775 | |||
| 776 | kobject_uevent(&hotplug->kobj, KOBJ_ADD); | ||
| 777 | return; | ||
| 778 | |||
| 779 | err_out: | ||
| 780 | pr_err(PREFIX "Unable to add hotplug profile '%s'\n", name); | ||
| 781 | } | ||
| 782 | |||
| 719 | int __init acpi_sysfs_init(void) | 783 | int __init acpi_sysfs_init(void) |
| 720 | { | 784 | { |
| 721 | int result; | 785 | int result; |
| @@ -723,6 +787,8 @@ int __init acpi_sysfs_init(void) | |||
| 723 | result = acpi_tables_sysfs_init(); | 787 | result = acpi_tables_sysfs_init(); |
| 724 | if (result) | 788 | if (result) |
| 725 | return result; | 789 | return result; |
| 790 | |||
| 791 | hotplug_kobj = kobject_create_and_add("hotplug", acpi_kobj); | ||
| 726 | result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr); | 792 | result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr); |
| 727 | return result; | 793 | return result; |
| 728 | } | 794 | } |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 8470771e5eae..a33821ca3895 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
| @@ -723,9 +723,19 @@ static int thermal_get_trend(struct thermal_zone_device *thermal, | |||
| 723 | return -EINVAL; | 723 | return -EINVAL; |
| 724 | 724 | ||
| 725 | if (type == THERMAL_TRIP_ACTIVE) { | 725 | if (type == THERMAL_TRIP_ACTIVE) { |
| 726 | /* aggressive active cooling */ | 726 | unsigned long trip_temp; |
| 727 | *trend = THERMAL_TREND_RAISING; | 727 | unsigned long temp = KELVIN_TO_MILLICELSIUS(tz->temperature, |
| 728 | return 0; | 728 | tz->kelvin_offset); |
| 729 | if (thermal_get_trip_temp(thermal, trip, &trip_temp)) | ||
| 730 | return -EINVAL; | ||
| 731 | |||
| 732 | if (temp > trip_temp) { | ||
| 733 | *trend = THERMAL_TREND_RAISING; | ||
| 734 | return 0; | ||
| 735 | } else { | ||
| 736 | /* Fall back on default trend */ | ||
| 737 | return -EINVAL; | ||
| 738 | } | ||
| 729 | } | 739 | } |
| 730 | 740 | ||
| 731 | /* | 741 | /* |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 313f959413dc..c3932d0876e0 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
| @@ -167,7 +167,8 @@ struct acpi_video_device_flags { | |||
| 167 | u8 dvi:1; | 167 | u8 dvi:1; |
| 168 | u8 bios:1; | 168 | u8 bios:1; |
| 169 | u8 unknown:1; | 169 | u8 unknown:1; |
| 170 | u8 reserved:2; | 170 | u8 notify:1; |
| 171 | u8 reserved:1; | ||
| 171 | }; | 172 | }; |
| 172 | 173 | ||
| 173 | struct acpi_video_device_cap { | 174 | struct acpi_video_device_cap { |
| @@ -222,7 +223,7 @@ static int acpi_video_device_lcd_set_level(struct acpi_video_device *device, | |||
| 222 | int level); | 223 | int level); |
| 223 | static int acpi_video_device_lcd_get_level_current( | 224 | static int acpi_video_device_lcd_get_level_current( |
| 224 | struct acpi_video_device *device, | 225 | struct acpi_video_device *device, |
| 225 | unsigned long long *level, int init); | 226 | unsigned long long *level, bool raw); |
| 226 | static int acpi_video_get_next_level(struct acpi_video_device *device, | 227 | static int acpi_video_get_next_level(struct acpi_video_device *device, |
| 227 | u32 level_current, u32 event); | 228 | u32 level_current, u32 event); |
| 228 | static int acpi_video_switch_brightness(struct acpi_video_device *device, | 229 | static int acpi_video_switch_brightness(struct acpi_video_device *device, |
| @@ -236,7 +237,7 @@ static int acpi_video_get_brightness(struct backlight_device *bd) | |||
| 236 | struct acpi_video_device *vd = | 237 | struct acpi_video_device *vd = |
| 237 | (struct acpi_video_device *)bl_get_data(bd); | 238 | (struct acpi_video_device *)bl_get_data(bd); |
| 238 | 239 | ||
| 239 | if (acpi_video_device_lcd_get_level_current(vd, &cur_level, 0)) | 240 | if (acpi_video_device_lcd_get_level_current(vd, &cur_level, false)) |
| 240 | return -EINVAL; | 241 | return -EINVAL; |
| 241 | for (i = 2; i < vd->brightness->count; i++) { | 242 | for (i = 2; i < vd->brightness->count; i++) { |
| 242 | if (vd->brightness->levels[i] == cur_level) | 243 | if (vd->brightness->levels[i] == cur_level) |
| @@ -281,7 +282,7 @@ static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsig | |||
| 281 | unsigned long long level; | 282 | unsigned long long level; |
| 282 | int offset; | 283 | int offset; |
| 283 | 284 | ||
| 284 | if (acpi_video_device_lcd_get_level_current(video, &level, 0)) | 285 | if (acpi_video_device_lcd_get_level_current(video, &level, false)) |
| 285 | return -EINVAL; | 286 | return -EINVAL; |
| 286 | for (offset = 2; offset < video->brightness->count; offset++) | 287 | for (offset = 2; offset < video->brightness->count; offset++) |
| 287 | if (level == video->brightness->levels[offset]) { | 288 | if (level == video->brightness->levels[offset]) { |
| @@ -447,12 +448,45 @@ static struct dmi_system_id video_dmi_table[] __initdata = { | |||
| 447 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"), | 448 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"), |
| 448 | }, | 449 | }, |
| 449 | }, | 450 | }, |
| 451 | { | ||
| 452 | .callback = video_ignore_initial_backlight, | ||
| 453 | .ident = "HP Pavilion dm4", | ||
| 454 | .matches = { | ||
| 455 | DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), | ||
| 456 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dm4 Notebook PC"), | ||
| 457 | }, | ||
| 458 | }, | ||
| 450 | {} | 459 | {} |
| 451 | }; | 460 | }; |
| 452 | 461 | ||
| 462 | static unsigned long long | ||
| 463 | acpi_video_bqc_value_to_level(struct acpi_video_device *device, | ||
| 464 | unsigned long long bqc_value) | ||
| 465 | { | ||
| 466 | unsigned long long level; | ||
| 467 | |||
| 468 | if (device->brightness->flags._BQC_use_index) { | ||
| 469 | /* | ||
| 470 | * _BQC returns an index that doesn't account for | ||
| 471 | * the first 2 items with special meaning, so we need | ||
| 472 | * to compensate for that by offsetting ourselves | ||
| 473 | */ | ||
| 474 | if (device->brightness->flags._BCL_reversed) | ||
| 475 | bqc_value = device->brightness->count - 3 - bqc_value; | ||
| 476 | |||
| 477 | level = device->brightness->levels[bqc_value + 2]; | ||
| 478 | } else { | ||
| 479 | level = bqc_value; | ||
| 480 | } | ||
| 481 | |||
| 482 | level += bqc_offset_aml_bug_workaround; | ||
| 483 | |||
| 484 | return level; | ||
| 485 | } | ||
| 486 | |||
| 453 | static int | 487 | static int |
| 454 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, | 488 | acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, |
| 455 | unsigned long long *level, int init) | 489 | unsigned long long *level, bool raw) |
| 456 | { | 490 | { |
| 457 | acpi_status status = AE_OK; | 491 | acpi_status status = AE_OK; |
| 458 | int i; | 492 | int i; |
| @@ -463,29 +497,30 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device, | |||
| 463 | status = acpi_evaluate_integer(device->dev->handle, buf, | 497 | status = acpi_evaluate_integer(device->dev->handle, buf, |
| 464 | NULL, level); | 498 | NULL, level); |
| 465 | if (ACPI_SUCCESS(status)) { | 499 | if (ACPI_SUCCESS(status)) { |
| 466 | if (device->brightness->flags._BQC_use_index) { | 500 | if (raw) { |
| 467 | if (device->brightness->flags._BCL_reversed) | 501 | /* |
| 468 | *level = device->brightness->count | 502 | * Caller has indicated he wants the raw |
| 469 | - 3 - (*level); | 503 | * value returned by _BQC, so don't furtherly |
| 470 | *level = device->brightness->levels[*level + 2]; | 504 | * mess with the value. |
| 471 | 505 | */ | |
| 506 | return 0; | ||
| 472 | } | 507 | } |
| 473 | *level += bqc_offset_aml_bug_workaround; | 508 | |
| 509 | *level = acpi_video_bqc_value_to_level(device, *level); | ||
| 510 | |||
| 474 | for (i = 2; i < device->brightness->count; i++) | 511 | for (i = 2; i < device->brightness->count; i++) |
| 475 | if (device->brightness->levels[i] == *level) { | 512 | if (device->brightness->levels[i] == *level) { |
| 476 | device->brightness->curr = *level; | 513 | device->brightness->curr = *level; |
| 477 | return 0; | 514 | return 0; |
| 478 | } | 515 | } |
| 479 | if (!init) { | 516 | /* |
| 480 | /* | 517 | * BQC returned an invalid level. |
| 481 | * BQC returned an invalid level. | 518 | * Stop using it. |
| 482 | * Stop using it. | 519 | */ |
| 483 | */ | 520 | ACPI_WARNING((AE_INFO, |
| 484 | ACPI_WARNING((AE_INFO, | 521 | "%s returned an invalid level", |
| 485 | "%s returned an invalid level", | 522 | buf)); |
| 486 | buf)); | 523 | device->cap._BQC = device->cap._BCQ = 0; |
| 487 | device->cap._BQC = device->cap._BCQ = 0; | ||
| 488 | } | ||
| 489 | } else { | 524 | } else { |
| 490 | /* Fixme: | 525 | /* Fixme: |
| 491 | * should we return an error or ignore this failure? | 526 | * should we return an error or ignore this failure? |
| @@ -598,6 +633,56 @@ acpi_video_cmp_level(const void *a, const void *b) | |||
| 598 | } | 633 | } |
| 599 | 634 | ||
| 600 | /* | 635 | /* |
| 636 | * Decides if _BQC/_BCQ for this system is usable | ||
| 637 | * | ||
| 638 | * We do this by changing the level first and then read out the current | ||
| 639 | * brightness level, if the value does not match, find out if it is using | ||
| 640 | * index. If not, clear the _BQC/_BCQ capability. | ||
| 641 | */ | ||
| 642 | static int acpi_video_bqc_quirk(struct acpi_video_device *device, | ||
| 643 | int max_level, int current_level) | ||
| 644 | { | ||
| 645 | struct acpi_video_device_brightness *br = device->brightness; | ||
| 646 | int result; | ||
| 647 | unsigned long long level; | ||
| 648 | int test_level; | ||
| 649 | |||
| 650 | /* don't mess with existing known broken systems */ | ||
| 651 | if (bqc_offset_aml_bug_workaround) | ||
| 652 | return 0; | ||
| 653 | |||
| 654 | /* | ||
| 655 | * Some systems always report current brightness level as maximum | ||
| 656 | * through _BQC, we need to test another value for them. | ||
| 657 | */ | ||
| 658 | test_level = current_level == max_level ? br->levels[2] : max_level; | ||
| 659 | |||
| 660 | result = acpi_video_device_lcd_set_level(device, test_level); | ||
| 661 | if (result) | ||
| 662 | return result; | ||
| 663 | |||
| 664 | result = acpi_video_device_lcd_get_level_current(device, &level, true); | ||
| 665 | if (result) | ||
| 666 | return result; | ||
| 667 | |||
| 668 | if (level != test_level) { | ||
| 669 | /* buggy _BQC found, need to find out if it uses index */ | ||
| 670 | if (level < br->count) { | ||
| 671 | if (br->flags._BCL_reversed) | ||
| 672 | level = br->count - 3 - level; | ||
| 673 | if (br->levels[level + 2] == test_level) | ||
| 674 | br->flags._BQC_use_index = 1; | ||
| 675 | } | ||
| 676 | |||
| 677 | if (!br->flags._BQC_use_index) | ||
| 678 | device->cap._BQC = device->cap._BCQ = 0; | ||
| 679 | } | ||
| 680 | |||
| 681 | return 0; | ||
| 682 | } | ||
| 683 | |||
| 684 | |||
| 685 | /* | ||
| 601 | * Arg: | 686 | * Arg: |
| 602 | * device : video output device (LCD, CRT, ..) | 687 | * device : video output device (LCD, CRT, ..) |
| 603 | * | 688 | * |
| @@ -703,42 +788,36 @@ acpi_video_init_brightness(struct acpi_video_device *device) | |||
| 703 | if (!device->cap._BQC) | 788 | if (!device->cap._BQC) |
| 704 | goto set_level; | 789 | goto set_level; |
| 705 | 790 | ||
| 706 | result = acpi_video_device_lcd_get_level_current(device, &level_old, 1); | 791 | result = acpi_video_device_lcd_get_level_current(device, |
| 707 | if (result) | 792 | &level_old, true); |
| 708 | goto out_free_levels; | ||
| 709 | |||
| 710 | /* | ||
| 711 | * Set the level to maximum and check if _BQC uses indexed value | ||
| 712 | */ | ||
| 713 | result = acpi_video_device_lcd_set_level(device, max_level); | ||
| 714 | if (result) | 793 | if (result) |
| 715 | goto out_free_levels; | 794 | goto out_free_levels; |
| 716 | 795 | ||
| 717 | result = acpi_video_device_lcd_get_level_current(device, &level, 0); | 796 | result = acpi_video_bqc_quirk(device, max_level, level_old); |
| 718 | if (result) | 797 | if (result) |
| 719 | goto out_free_levels; | 798 | goto out_free_levels; |
| 799 | /* | ||
| 800 | * cap._BQC may get cleared due to _BQC is found to be broken | ||
| 801 | * in acpi_video_bqc_quirk, so check again here. | ||
| 802 | */ | ||
| 803 | if (!device->cap._BQC) | ||
| 804 | goto set_level; | ||
| 720 | 805 | ||
| 721 | br->flags._BQC_use_index = (level == max_level ? 0 : 1); | 806 | if (use_bios_initial_backlight) { |
| 722 | 807 | level = acpi_video_bqc_value_to_level(device, level_old); | |
| 723 | if (!br->flags._BQC_use_index) { | ||
| 724 | /* | 808 | /* |
| 725 | * Set the backlight to the initial state. | 809 | * On some buggy laptops, _BQC returns an uninitialized |
| 726 | * On some buggy laptops, _BQC returns an uninitialized value | 810 | * value when invoked for the first time, i.e. |
| 727 | * when invoked for the first time, i.e. level_old is invalid. | 811 | * level_old is invalid (no matter whether it's a level |
| 728 | * set the backlight to max_level in this case | 812 | * or an index). Set the backlight to max_level in this case. |
| 729 | */ | 813 | */ |
| 730 | if (use_bios_initial_backlight) { | 814 | for (i = 2; i < br->count; i++) |
| 731 | for (i = 2; i < br->count; i++) | 815 | if (level_old == br->levels[i]) |
| 732 | if (level_old == br->levels[i]) | 816 | break; |
| 733 | level = level_old; | 817 | if (i == br->count) |
| 734 | } | 818 | level = max_level; |
| 735 | goto set_level; | ||
| 736 | } | 819 | } |
| 737 | 820 | ||
| 738 | if (br->flags._BCL_reversed) | ||
| 739 | level_old = (br->count - 1) - level_old; | ||
| 740 | level = br->levels[level_old]; | ||
| 741 | |||
| 742 | set_level: | 821 | set_level: |
| 743 | result = acpi_video_device_lcd_set_level(device, level); | 822 | result = acpi_video_device_lcd_set_level(device, level); |
| 744 | if (result) | 823 | if (result) |
| @@ -996,53 +1075,51 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
| 996 | struct acpi_video_device *data; | 1075 | struct acpi_video_device *data; |
| 997 | struct acpi_video_device_attrib* attribute; | 1076 | struct acpi_video_device_attrib* attribute; |
| 998 | 1077 | ||
| 999 | if (!device || !video) | ||
| 1000 | return -EINVAL; | ||
| 1001 | |||
| 1002 | status = | 1078 | status = |
| 1003 | acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); | 1079 | acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); |
| 1004 | if (ACPI_SUCCESS(status)) { | 1080 | /* Some device omits _ADR, we skip them instead of fail */ |
| 1005 | 1081 | if (ACPI_FAILURE(status)) | |
| 1006 | data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL); | 1082 | return 0; |
| 1007 | if (!data) | ||
| 1008 | return -ENOMEM; | ||
| 1009 | |||
| 1010 | strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME); | ||
| 1011 | strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); | ||
| 1012 | device->driver_data = data; | ||
| 1013 | |||
| 1014 | data->device_id = device_id; | ||
| 1015 | data->video = video; | ||
| 1016 | data->dev = device; | ||
| 1017 | 1083 | ||
| 1018 | attribute = acpi_video_get_device_attr(video, device_id); | 1084 | data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL); |
| 1085 | if (!data) | ||
| 1086 | return -ENOMEM; | ||
| 1019 | 1087 | ||
| 1020 | if((attribute != NULL) && attribute->device_id_scheme) { | 1088 | strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME); |
| 1021 | switch (attribute->display_type) { | 1089 | strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); |
| 1022 | case ACPI_VIDEO_DISPLAY_CRT: | 1090 | device->driver_data = data; |
| 1023 | data->flags.crt = 1; | 1091 | |
| 1024 | break; | 1092 | data->device_id = device_id; |
| 1025 | case ACPI_VIDEO_DISPLAY_TV: | 1093 | data->video = video; |
| 1026 | data->flags.tvout = 1; | 1094 | data->dev = device; |
| 1027 | break; | 1095 | |
| 1028 | case ACPI_VIDEO_DISPLAY_DVI: | 1096 | attribute = acpi_video_get_device_attr(video, device_id); |
| 1029 | data->flags.dvi = 1; | 1097 | |
| 1030 | break; | 1098 | if((attribute != NULL) && attribute->device_id_scheme) { |
| 1031 | case ACPI_VIDEO_DISPLAY_LCD: | 1099 | switch (attribute->display_type) { |
| 1032 | data->flags.lcd = 1; | 1100 | case ACPI_VIDEO_DISPLAY_CRT: |
| 1033 | break; | 1101 | data->flags.crt = 1; |
| 1034 | default: | 1102 | break; |
| 1035 | data->flags.unknown = 1; | 1103 | case ACPI_VIDEO_DISPLAY_TV: |
| 1036 | break; | 1104 | data->flags.tvout = 1; |
| 1037 | } | 1105 | break; |
| 1038 | if(attribute->bios_can_detect) | 1106 | case ACPI_VIDEO_DISPLAY_DVI: |
| 1039 | data->flags.bios = 1; | 1107 | data->flags.dvi = 1; |
| 1040 | } else { | 1108 | break; |
| 1041 | /* Check for legacy IDs */ | 1109 | case ACPI_VIDEO_DISPLAY_LCD: |
| 1042 | device_type = acpi_video_get_device_type(video, | 1110 | data->flags.lcd = 1; |
| 1043 | device_id); | 1111 | break; |
| 1044 | /* Ignore bits 16 and 18-20 */ | 1112 | default: |
| 1045 | switch (device_type & 0xffe2ffff) { | 1113 | data->flags.unknown = 1; |
| 1114 | break; | ||
| 1115 | } | ||
| 1116 | if(attribute->bios_can_detect) | ||
| 1117 | data->flags.bios = 1; | ||
| 1118 | } else { | ||
| 1119 | /* Check for legacy IDs */ | ||
| 1120 | device_type = acpi_video_get_device_type(video, device_id); | ||
| 1121 | /* Ignore bits 16 and 18-20 */ | ||
| 1122 | switch (device_type & 0xffe2ffff) { | ||
| 1046 | case ACPI_VIDEO_DISPLAY_LEGACY_MONITOR: | 1123 | case ACPI_VIDEO_DISPLAY_LEGACY_MONITOR: |
| 1047 | data->flags.crt = 1; | 1124 | data->flags.crt = 1; |
| 1048 | break; | 1125 | break; |
| @@ -1054,34 +1131,24 @@ acpi_video_bus_get_one_device(struct acpi_device *device, | |||
| 1054 | break; | 1131 | break; |
| 1055 | default: | 1132 | default: |
| 1056 | data->flags.unknown = 1; | 1133 | data->flags.unknown = 1; |
| 1057 | } | ||
| 1058 | } | 1134 | } |
| 1135 | } | ||
| 1059 | 1136 | ||
| 1060 | acpi_video_device_bind(video, data); | 1137 | acpi_video_device_bind(video, data); |
| 1061 | acpi_video_device_find_cap(data); | 1138 | acpi_video_device_find_cap(data); |
| 1062 | |||
| 1063 | status = acpi_install_notify_handler(device->handle, | ||
| 1064 | ACPI_DEVICE_NOTIFY, | ||
| 1065 | acpi_video_device_notify, | ||
| 1066 | data); | ||
| 1067 | if (ACPI_FAILURE(status)) { | ||
| 1068 | printk(KERN_ERR PREFIX | ||
| 1069 | "Error installing notify handler\n"); | ||
| 1070 | if(data->brightness) | ||
| 1071 | kfree(data->brightness->levels); | ||
| 1072 | kfree(data->brightness); | ||
| 1073 | kfree(data); | ||
| 1074 | return -ENODEV; | ||
| 1075 | } | ||
| 1076 | 1139 | ||
| 1077 | mutex_lock(&video->device_list_lock); | 1140 | status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, |
| 1078 | list_add_tail(&data->entry, &video->video_device_list); | 1141 | acpi_video_device_notify, data); |
| 1079 | mutex_unlock(&video->device_list_lock); | 1142 | if (ACPI_FAILURE(status)) |
| 1143 | dev_err(&device->dev, "Error installing notify handler\n"); | ||
| 1144 | else | ||
| 1145 | data->flags.notify = 1; | ||
| 1080 | 1146 | ||
| 1081 | return 0; | 1147 | mutex_lock(&video->device_list_lock); |
| 1082 | } | 1148 | list_add_tail(&data->entry, &video->video_device_list); |
| 1149 | mutex_unlock(&video->device_list_lock); | ||
| 1083 | 1150 | ||
| 1084 | return -ENOENT; | 1151 | return status; |
| 1085 | } | 1152 | } |
| 1086 | 1153 | ||
| 1087 | /* | 1154 | /* |
| @@ -1268,7 +1335,8 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event) | |||
| 1268 | goto out; | 1335 | goto out; |
| 1269 | 1336 | ||
| 1270 | result = acpi_video_device_lcd_get_level_current(device, | 1337 | result = acpi_video_device_lcd_get_level_current(device, |
| 1271 | &level_current, 0); | 1338 | &level_current, |
| 1339 | false); | ||
| 1272 | if (result) | 1340 | if (result) |
| 1273 | goto out; | 1341 | goto out; |
| 1274 | 1342 | ||
| @@ -1373,9 +1441,8 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video, | |||
| 1373 | 1441 | ||
| 1374 | status = acpi_video_bus_get_one_device(dev, video); | 1442 | status = acpi_video_bus_get_one_device(dev, video); |
| 1375 | if (status) { | 1443 | if (status) { |
| 1376 | printk(KERN_WARNING PREFIX | 1444 | dev_err(&dev->dev, "Can't attach device\n"); |
| 1377 | "Can't attach device\n"); | 1445 | break; |
| 1378 | continue; | ||
| 1379 | } | 1446 | } |
| 1380 | } | 1447 | } |
| 1381 | return status; | 1448 | return status; |
| @@ -1388,13 +1455,14 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) | |||
| 1388 | if (!device || !device->video) | 1455 | if (!device || !device->video) |
| 1389 | return -ENOENT; | 1456 | return -ENOENT; |
| 1390 | 1457 | ||
| 1391 | status = acpi_remove_notify_handler(device->dev->handle, | 1458 | if (device->flags.notify) { |
| 1392 | ACPI_DEVICE_NOTIFY, | 1459 | status = acpi_remove_notify_handler(device->dev->handle, |
| 1393 | acpi_video_device_notify); | 1460 | ACPI_DEVICE_NOTIFY, acpi_video_device_notify); |
| 1394 | if (ACPI_FAILURE(status)) { | 1461 | if (ACPI_FAILURE(status)) |
| 1395 | printk(KERN_WARNING PREFIX | 1462 | dev_err(&device->dev->dev, |
| 1396 | "Can't remove video notify handler\n"); | 1463 | "Can't remove video notify handler\n"); |
| 1397 | } | 1464 | } |
| 1465 | |||
| 1398 | if (device->backlight) { | 1466 | if (device->backlight) { |
| 1399 | backlight_device_unregister(device->backlight); | 1467 | backlight_device_unregister(device->backlight); |
| 1400 | device->backlight = NULL; | 1468 | device->backlight = NULL; |
| @@ -1676,7 +1744,7 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
| 1676 | 1744 | ||
| 1677 | error = acpi_video_bus_get_devices(video, device); | 1745 | error = acpi_video_bus_get_devices(video, device); |
| 1678 | if (error) | 1746 | if (error) |
| 1679 | goto err_free_video; | 1747 | goto err_put_video; |
| 1680 | 1748 | ||
| 1681 | video->input = input = input_allocate_device(); | 1749 | video->input = input = input_allocate_device(); |
| 1682 | if (!input) { | 1750 | if (!input) { |
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index 4ac2593234e7..66f67626f02e 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c | |||
| @@ -67,40 +67,37 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, | |||
| 67 | return 0; | 67 | return 0; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | /* Returns true if the device is a video device which can be handled by | 70 | /* Returns true if the ACPI object is a video device which can be |
| 71 | * video.ko. | 71 | * handled by video.ko. |
| 72 | * The device will get a Linux specific CID added in scan.c to | 72 | * The device will get a Linux specific CID added in scan.c to |
| 73 | * identify the device as an ACPI graphics device | 73 | * identify the device as an ACPI graphics device |
| 74 | * Be aware that the graphics device may not be physically present | 74 | * Be aware that the graphics device may not be physically present |
| 75 | * Use acpi_video_get_capabilities() to detect general ACPI video | 75 | * Use acpi_video_get_capabilities() to detect general ACPI video |
| 76 | * capabilities of present cards | 76 | * capabilities of present cards |
| 77 | */ | 77 | */ |
| 78 | long acpi_is_video_device(struct acpi_device *device) | 78 | long acpi_is_video_device(acpi_handle handle) |
| 79 | { | 79 | { |
| 80 | acpi_handle h_dummy; | 80 | acpi_handle h_dummy; |
| 81 | long video_caps = 0; | 81 | long video_caps = 0; |
| 82 | 82 | ||
| 83 | if (!device) | ||
| 84 | return 0; | ||
| 85 | |||
| 86 | /* Is this device able to support video switching ? */ | 83 | /* Is this device able to support video switching ? */ |
| 87 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) || | 84 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_DOD", &h_dummy)) || |
| 88 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy))) | 85 | ACPI_SUCCESS(acpi_get_handle(handle, "_DOS", &h_dummy))) |
| 89 | video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING; | 86 | video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING; |
| 90 | 87 | ||
| 91 | /* Is this device able to retrieve a video ROM ? */ | 88 | /* Is this device able to retrieve a video ROM ? */ |
| 92 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy))) | 89 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_ROM", &h_dummy))) |
| 93 | video_caps |= ACPI_VIDEO_ROM_AVAILABLE; | 90 | video_caps |= ACPI_VIDEO_ROM_AVAILABLE; |
| 94 | 91 | ||
| 95 | /* Is this device able to configure which video head to be POSTed ? */ | 92 | /* Is this device able to configure which video head to be POSTed ? */ |
| 96 | if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) && | 93 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_VPO", &h_dummy)) && |
| 97 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) && | 94 | ACPI_SUCCESS(acpi_get_handle(handle, "_GPD", &h_dummy)) && |
| 98 | ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy))) | 95 | ACPI_SUCCESS(acpi_get_handle(handle, "_SPD", &h_dummy))) |
| 99 | video_caps |= ACPI_VIDEO_DEVICE_POSTING; | 96 | video_caps |= ACPI_VIDEO_DEVICE_POSTING; |
| 100 | 97 | ||
| 101 | /* Only check for backlight functionality if one of the above hit. */ | 98 | /* Only check for backlight functionality if one of the above hit. */ |
| 102 | if (video_caps) | 99 | if (video_caps) |
| 103 | acpi_walk_namespace(ACPI_TYPE_DEVICE, device->handle, | 100 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, |
| 104 | ACPI_UINT32_MAX, acpi_backlight_cap_match, NULL, | 101 | ACPI_UINT32_MAX, acpi_backlight_cap_match, NULL, |
| 105 | &video_caps, NULL); | 102 | &video_caps, NULL); |
| 106 | 103 | ||
| @@ -127,7 +124,7 @@ find_video(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
| 127 | if (!dev) | 124 | if (!dev) |
| 128 | return AE_OK; | 125 | return AE_OK; |
| 129 | pci_dev_put(dev); | 126 | pci_dev_put(dev); |
| 130 | *cap |= acpi_is_video_device(acpi_dev); | 127 | *cap |= acpi_is_video_device(handle); |
| 131 | } | 128 | } |
| 132 | return AE_OK; | 129 | return AE_OK; |
| 133 | } | 130 | } |
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 9a6b05a35603..7072404c8b6d 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c | |||
| @@ -920,7 +920,7 @@ static int pm_genpd_prepare(struct device *dev) | |||
| 920 | pm_wakeup_event(dev, 0); | 920 | pm_wakeup_event(dev, 0); |
| 921 | 921 | ||
| 922 | if (pm_wakeup_pending()) { | 922 | if (pm_wakeup_pending()) { |
| 923 | pm_runtime_put_sync(dev); | 923 | pm_runtime_put(dev); |
| 924 | return -EBUSY; | 924 | return -EBUSY; |
| 925 | } | 925 | } |
| 926 | 926 | ||
| @@ -961,7 +961,7 @@ static int pm_genpd_prepare(struct device *dev) | |||
| 961 | pm_runtime_enable(dev); | 961 | pm_runtime_enable(dev); |
| 962 | } | 962 | } |
| 963 | 963 | ||
| 964 | pm_runtime_put_sync(dev); | 964 | pm_runtime_put(dev); |
| 965 | return ret; | 965 | return ret; |
| 966 | } | 966 | } |
| 967 | 967 | ||
| @@ -1327,7 +1327,7 @@ static void pm_genpd_complete(struct device *dev) | |||
| 1327 | pm_generic_complete(dev); | 1327 | pm_generic_complete(dev); |
| 1328 | pm_runtime_set_active(dev); | 1328 | pm_runtime_set_active(dev); |
| 1329 | pm_runtime_enable(dev); | 1329 | pm_runtime_enable(dev); |
| 1330 | pm_runtime_idle(dev); | 1330 | pm_request_idle(dev); |
| 1331 | } | 1331 | } |
| 1332 | } | 1332 | } |
| 1333 | 1333 | ||
diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c index d03d290f31c2..bfd898b8988e 100644 --- a/drivers/base/power/generic_ops.c +++ b/drivers/base/power/generic_ops.c | |||
| @@ -324,6 +324,6 @@ void pm_generic_complete(struct device *dev) | |||
| 324 | * Let runtime PM try to suspend devices that haven't been in use before | 324 | * Let runtime PM try to suspend devices that haven't been in use before |
| 325 | * going into the system-wide sleep state we're resuming from. | 325 | * going into the system-wide sleep state we're resuming from. |
| 326 | */ | 326 | */ |
| 327 | pm_runtime_idle(dev); | 327 | pm_request_idle(dev); |
| 328 | } | 328 | } |
| 329 | #endif /* CONFIG_PM_SLEEP */ | 329 | #endif /* CONFIG_PM_SLEEP */ |
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 15beb500a4e4..5a9b6569dd74 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
| @@ -756,7 +756,7 @@ static void device_complete(struct device *dev, pm_message_t state) | |||
| 756 | 756 | ||
| 757 | device_unlock(dev); | 757 | device_unlock(dev); |
| 758 | 758 | ||
| 759 | pm_runtime_put_sync(dev); | 759 | pm_runtime_put(dev); |
| 760 | } | 760 | } |
| 761 | 761 | ||
| 762 | /** | 762 | /** |
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 32ee0fc7ea54..f0077cb8e249 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c | |||
| @@ -55,6 +55,7 @@ | |||
| 55 | * @rate: Frequency in hertz | 55 | * @rate: Frequency in hertz |
| 56 | * @u_volt: Nominal voltage in microvolts corresponding to this OPP | 56 | * @u_volt: Nominal voltage in microvolts corresponding to this OPP |
| 57 | * @dev_opp: points back to the device_opp struct this opp belongs to | 57 | * @dev_opp: points back to the device_opp struct this opp belongs to |
| 58 | * @head: RCU callback head used for deferred freeing | ||
| 58 | * | 59 | * |
| 59 | * This structure stores the OPP information for a given device. | 60 | * This structure stores the OPP information for a given device. |
| 60 | */ | 61 | */ |
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 1244930e3d7a..ef13ad08afb2 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c | |||
| @@ -1400,5 +1400,5 @@ void pm_runtime_remove(struct device *dev) | |||
| 1400 | if (dev->power.runtime_status == RPM_ACTIVE) | 1400 | if (dev->power.runtime_status == RPM_ACTIVE) |
| 1401 | pm_runtime_set_suspended(dev); | 1401 | pm_runtime_set_suspended(dev); |
| 1402 | if (dev->power.irq_safe && dev->parent) | 1402 | if (dev->power.irq_safe && dev->parent) |
| 1403 | pm_runtime_put_sync(dev->parent); | 1403 | pm_runtime_put(dev->parent); |
| 1404 | } | 1404 | } |
diff --git a/drivers/clk/x86/Makefile b/drivers/clk/x86/Makefile index f9ba4fab0ddc..04781389d0fb 100644 --- a/drivers/clk/x86/Makefile +++ b/drivers/clk/x86/Makefile | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | clk-x86-lpss-objs := clk-lpss.o clk-lpt.o | 1 | clk-x86-lpss-objs := clk-lpt.o |
| 2 | obj-$(CONFIG_X86_INTEL_LPSS) += clk-x86-lpss.o | 2 | obj-$(CONFIG_X86_INTEL_LPSS) += clk-x86-lpss.o |
diff --git a/drivers/clk/x86/clk-lpss.c b/drivers/clk/x86/clk-lpss.c deleted file mode 100644 index b5e229f3c3d9..000000000000 --- a/drivers/clk/x86/clk-lpss.c +++ /dev/null | |||
| @@ -1,99 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Intel Low Power Subsystem clocks. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013, Intel Corporation | ||
| 5 | * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> | ||
| 6 | * Heikki Krogerus <heikki.krogerus@linux.intel.com> | ||
| 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 | #include <linux/acpi.h> | ||
| 14 | #include <linux/clk.h> | ||
| 15 | #include <linux/clk-provider.h> | ||
| 16 | #include <linux/err.h> | ||
| 17 | #include <linux/io.h> | ||
| 18 | #include <linux/module.h> | ||
| 19 | |||
| 20 | static int clk_lpss_is_mmio_resource(struct acpi_resource *res, void *data) | ||
| 21 | { | ||
| 22 | struct resource r; | ||
| 23 | return !acpi_dev_resource_memory(res, &r); | ||
| 24 | } | ||
| 25 | |||
| 26 | static acpi_status clk_lpss_find_mmio(acpi_handle handle, u32 level, | ||
| 27 | void *data, void **retval) | ||
| 28 | { | ||
| 29 | struct resource_list_entry *rentry; | ||
| 30 | struct list_head resource_list; | ||
| 31 | struct acpi_device *adev; | ||
| 32 | const char *uid = data; | ||
| 33 | int ret; | ||
| 34 | |||
| 35 | if (acpi_bus_get_device(handle, &adev)) | ||
| 36 | return AE_OK; | ||
| 37 | |||
| 38 | if (uid) { | ||
| 39 | if (!adev->pnp.unique_id) | ||
| 40 | return AE_OK; | ||
| 41 | if (strcmp(uid, adev->pnp.unique_id)) | ||
| 42 | return AE_OK; | ||
| 43 | } | ||
| 44 | |||
| 45 | INIT_LIST_HEAD(&resource_list); | ||
| 46 | ret = acpi_dev_get_resources(adev, &resource_list, | ||
| 47 | clk_lpss_is_mmio_resource, NULL); | ||
| 48 | if (ret < 0) | ||
| 49 | return AE_NO_MEMORY; | ||
| 50 | |||
| 51 | list_for_each_entry(rentry, &resource_list, node) | ||
| 52 | if (resource_type(&rentry->res) == IORESOURCE_MEM) { | ||
| 53 | *(struct resource *)retval = rentry->res; | ||
| 54 | break; | ||
| 55 | } | ||
| 56 | |||
| 57 | acpi_dev_free_resource_list(&resource_list); | ||
| 58 | return AE_OK; | ||
| 59 | } | ||
| 60 | |||
| 61 | /** | ||
| 62 | * clk_register_lpss_gate - register LPSS clock gate | ||
| 63 | * @name: name of this clock gate | ||
| 64 | * @parent_name: parent clock name | ||
| 65 | * @hid: ACPI _HID of the device | ||
| 66 | * @uid: ACPI _UID of the device (optional) | ||
| 67 | * @offset: LPSS PRV_CLOCK_PARAMS offset | ||
| 68 | * | ||
| 69 | * Creates and registers LPSS clock gate. | ||
| 70 | */ | ||
| 71 | struct clk *clk_register_lpss_gate(const char *name, const char *parent_name, | ||
| 72 | const char *hid, const char *uid, | ||
| 73 | unsigned offset) | ||
| 74 | { | ||
| 75 | struct resource res = { }; | ||
| 76 | void __iomem *mmio_base; | ||
| 77 | acpi_status status; | ||
| 78 | struct clk *clk; | ||
| 79 | |||
| 80 | /* | ||
| 81 | * First try to look the device and its mmio resource from the | ||
| 82 | * ACPI namespace. | ||
| 83 | */ | ||
| 84 | status = acpi_get_devices(hid, clk_lpss_find_mmio, (void *)uid, | ||
| 85 | (void **)&res); | ||
| 86 | if (ACPI_FAILURE(status) || !res.start) | ||
| 87 | return ERR_PTR(-ENODEV); | ||
| 88 | |||
| 89 | mmio_base = ioremap(res.start, resource_size(&res)); | ||
| 90 | if (!mmio_base) | ||
| 91 | return ERR_PTR(-ENOMEM); | ||
| 92 | |||
| 93 | clk = clk_register_gate(NULL, name, parent_name, 0, mmio_base + offset, | ||
| 94 | 0, 0, NULL); | ||
| 95 | if (IS_ERR(clk)) | ||
| 96 | iounmap(mmio_base); | ||
| 97 | |||
| 98 | return clk; | ||
| 99 | } | ||
diff --git a/drivers/clk/x86/clk-lpss.h b/drivers/clk/x86/clk-lpss.h deleted file mode 100644 index e9460f442297..000000000000 --- a/drivers/clk/x86/clk-lpss.h +++ /dev/null | |||
| @@ -1,36 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Intel Low Power Subsystem clock. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013, Intel Corporation | ||
| 5 | * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> | ||
| 6 | * Heikki Krogerus <heikki.krogerus@linux.intel.com> | ||
| 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 __CLK_LPSS_H | ||
| 14 | #define __CLK_LPSS_H | ||
| 15 | |||
| 16 | #include <linux/err.h> | ||
| 17 | #include <linux/errno.h> | ||
| 18 | #include <linux/clk.h> | ||
| 19 | |||
| 20 | #ifdef CONFIG_ACPI | ||
| 21 | extern struct clk *clk_register_lpss_gate(const char *name, | ||
| 22 | const char *parent_name, | ||
| 23 | const char *hid, const char *uid, | ||
| 24 | unsigned offset); | ||
| 25 | #else | ||
| 26 | static inline struct clk *clk_register_lpss_gate(const char *name, | ||
| 27 | const char *parent_name, | ||
| 28 | const char *hid, | ||
| 29 | const char *uid, | ||
| 30 | unsigned offset) | ||
| 31 | { | ||
| 32 | return ERR_PTR(-ENODEV); | ||
| 33 | } | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #endif /* __CLK_LPSS_H */ | ||
diff --git a/drivers/clk/x86/clk-lpt.c b/drivers/clk/x86/clk-lpt.c index 81298aeef7e3..5cf4f4686406 100644 --- a/drivers/clk/x86/clk-lpt.c +++ b/drivers/clk/x86/clk-lpt.c | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #include <linux/acpi.h> | ||
| 14 | #include <linux/clk.h> | 13 | #include <linux/clk.h> |
| 15 | #include <linux/clkdev.h> | 14 | #include <linux/clkdev.h> |
| 16 | #include <linux/clk-provider.h> | 15 | #include <linux/clk-provider.h> |
| @@ -18,8 +17,6 @@ | |||
| 18 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| 19 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
| 20 | 19 | ||
| 21 | #include "clk-lpss.h" | ||
| 22 | |||
| 23 | #define PRV_CLOCK_PARAMS 0x800 | 20 | #define PRV_CLOCK_PARAMS 0x800 |
| 24 | 21 | ||
| 25 | static int lpt_clk_probe(struct platform_device *pdev) | 22 | static int lpt_clk_probe(struct platform_device *pdev) |
| @@ -34,40 +31,6 @@ static int lpt_clk_probe(struct platform_device *pdev) | |||
| 34 | 31 | ||
| 35 | /* Shared DMA clock */ | 32 | /* Shared DMA clock */ |
| 36 | clk_register_clkdev(clk, "hclk", "INTL9C60.0.auto"); | 33 | clk_register_clkdev(clk, "hclk", "INTL9C60.0.auto"); |
| 37 | |||
| 38 | /* SPI clocks */ | ||
| 39 | clk = clk_register_lpss_gate("spi0_clk", "lpss_clk", "INT33C0", NULL, | ||
| 40 | PRV_CLOCK_PARAMS); | ||
| 41 | if (!IS_ERR(clk)) | ||
| 42 | clk_register_clkdev(clk, NULL, "INT33C0:00"); | ||
| 43 | |||
| 44 | clk = clk_register_lpss_gate("spi1_clk", "lpss_clk", "INT33C1", NULL, | ||
| 45 | PRV_CLOCK_PARAMS); | ||
| 46 | if (!IS_ERR(clk)) | ||
| 47 | clk_register_clkdev(clk, NULL, "INT33C1:00"); | ||
| 48 | |||
| 49 | /* I2C clocks */ | ||
| 50 | clk = clk_register_lpss_gate("i2c0_clk", "lpss_clk", "INT33C2", NULL, | ||
| 51 | PRV_CLOCK_PARAMS); | ||
| 52 | if (!IS_ERR(clk)) | ||
| 53 | clk_register_clkdev(clk, NULL, "INT33C2:00"); | ||
| 54 | |||
| 55 | clk = clk_register_lpss_gate("i2c1_clk", "lpss_clk", "INT33C3", NULL, | ||
| 56 | PRV_CLOCK_PARAMS); | ||
| 57 | if (!IS_ERR(clk)) | ||
| 58 | clk_register_clkdev(clk, NULL, "INT33C3:00"); | ||
| 59 | |||
| 60 | /* UART clocks */ | ||
| 61 | clk = clk_register_lpss_gate("uart0_clk", "lpss_clk", "INT33C4", NULL, | ||
| 62 | PRV_CLOCK_PARAMS); | ||
| 63 | if (!IS_ERR(clk)) | ||
| 64 | clk_register_clkdev(clk, NULL, "INT33C4:00"); | ||
| 65 | |||
| 66 | clk = clk_register_lpss_gate("uart1_clk", "lpss_clk", "INT33C5", NULL, | ||
| 67 | PRV_CLOCK_PARAMS); | ||
| 68 | if (!IS_ERR(clk)) | ||
| 69 | clk_register_clkdev(clk, NULL, "INT33C5:00"); | ||
| 70 | |||
| 71 | return 0; | 34 | return 0; |
| 72 | } | 35 | } |
| 73 | 36 | ||
| @@ -79,8 +42,7 @@ static struct platform_driver lpt_clk_driver = { | |||
| 79 | .probe = lpt_clk_probe, | 42 | .probe = lpt_clk_probe, |
| 80 | }; | 43 | }; |
| 81 | 44 | ||
| 82 | static int __init lpt_clk_init(void) | 45 | int __init lpt_clk_init(void) |
| 83 | { | 46 | { |
| 84 | return platform_driver_register(&lpt_clk_driver); | 47 | return platform_driver_register(&lpt_clk_driver); |
| 85 | } | 48 | } |
| 86 | arch_initcall(lpt_clk_init); | ||
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index cbcb21e32771..a1488f58f6ca 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig | |||
| @@ -205,10 +205,99 @@ depends on ARM | |||
| 205 | source "drivers/cpufreq/Kconfig.arm" | 205 | source "drivers/cpufreq/Kconfig.arm" |
| 206 | endmenu | 206 | endmenu |
| 207 | 207 | ||
| 208 | menu "AVR32 CPU frequency scaling drivers" | ||
| 209 | depends on AVR32 | ||
| 210 | |||
| 211 | config AVR32_AT32AP_CPUFREQ | ||
| 212 | bool "CPU frequency driver for AT32AP" | ||
| 213 | depends on PLATFORM_AT32AP | ||
| 214 | default n | ||
| 215 | help | ||
| 216 | This enables the CPU frequency driver for AT32AP processors. | ||
| 217 | If in doubt, say N. | ||
| 218 | |||
| 219 | endmenu | ||
| 220 | |||
| 221 | menu "CPUFreq processor drivers" | ||
| 222 | depends on IA64 | ||
| 223 | |||
| 224 | config IA64_ACPI_CPUFREQ | ||
| 225 | tristate "ACPI Processor P-States driver" | ||
| 226 | select CPU_FREQ_TABLE | ||
| 227 | depends on ACPI_PROCESSOR | ||
| 228 | help | ||
| 229 | This driver adds a CPUFreq driver which utilizes the ACPI | ||
| 230 | Processor Performance States. | ||
| 231 | |||
| 232 | For details, take a look at <file:Documentation/cpu-freq/>. | ||
| 233 | |||
| 234 | If in doubt, say N. | ||
| 235 | |||
| 236 | endmenu | ||
| 237 | |||
| 238 | menu "MIPS CPUFreq processor drivers" | ||
| 239 | depends on MIPS | ||
| 240 | |||
| 241 | config LOONGSON2_CPUFREQ | ||
| 242 | tristate "Loongson2 CPUFreq Driver" | ||
| 243 | select CPU_FREQ_TABLE | ||
| 244 | help | ||
| 245 | This option adds a CPUFreq driver for loongson processors which | ||
| 246 | support software configurable cpu frequency. | ||
| 247 | |||
| 248 | Loongson2F and it's successors support this feature. | ||
| 249 | |||
| 250 | For details, take a look at <file:Documentation/cpu-freq/>. | ||
| 251 | |||
| 252 | If in doubt, say N. | ||
| 253 | |||
| 254 | endmenu | ||
| 255 | |||
| 208 | menu "PowerPC CPU frequency scaling drivers" | 256 | menu "PowerPC CPU frequency scaling drivers" |
| 209 | depends on PPC32 || PPC64 | 257 | depends on PPC32 || PPC64 |
| 210 | source "drivers/cpufreq/Kconfig.powerpc" | 258 | source "drivers/cpufreq/Kconfig.powerpc" |
| 211 | endmenu | 259 | endmenu |
| 212 | 260 | ||
| 261 | menu "SPARC CPU frequency scaling drivers" | ||
| 262 | depends on SPARC64 | ||
| 263 | config SPARC_US3_CPUFREQ | ||
| 264 | tristate "UltraSPARC-III CPU Frequency driver" | ||
| 265 | select CPU_FREQ_TABLE | ||
| 266 | help | ||
| 267 | This adds the CPUFreq driver for UltraSPARC-III processors. | ||
| 268 | |||
| 269 | For details, take a look at <file:Documentation/cpu-freq>. | ||
| 270 | |||
| 271 | If in doubt, say N. | ||
| 272 | |||
| 273 | config SPARC_US2E_CPUFREQ | ||
| 274 | tristate "UltraSPARC-IIe CPU Frequency driver" | ||
| 275 | select CPU_FREQ_TABLE | ||
| 276 | help | ||
| 277 | This adds the CPUFreq driver for UltraSPARC-IIe processors. | ||
| 278 | |||
| 279 | For details, take a look at <file:Documentation/cpu-freq>. | ||
| 280 | |||
| 281 | If in doubt, say N. | ||
| 282 | endmenu | ||
| 283 | |||
| 284 | menu "SH CPU Frequency scaling" | ||
| 285 | depends on SUPERH | ||
| 286 | config SH_CPU_FREQ | ||
| 287 | tristate "SuperH CPU Frequency driver" | ||
| 288 | select CPU_FREQ_TABLE | ||
| 289 | help | ||
| 290 | This adds the cpufreq driver for SuperH. Any CPU that supports | ||
| 291 | clock rate rounding through the clock framework can use this | ||
| 292 | driver. While it will make the kernel slightly larger, this is | ||
| 293 | harmless for CPUs that don't support rate rounding. The driver | ||
| 294 | will also generate a notice in the boot log before disabling | ||
| 295 | itself if the CPU in question is not capable of rate rounding. | ||
| 296 | |||
| 297 | For details, take a look at <file:Documentation/cpu-freq>. | ||
| 298 | |||
| 299 | If unsure, say N. | ||
| 300 | endmenu | ||
| 301 | |||
| 213 | endif | 302 | endif |
| 214 | endmenu | 303 | endmenu |
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index 030ddf6dd3f1..f3af18b9acc5 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm | |||
| @@ -2,6 +2,93 @@ | |||
| 2 | # ARM CPU Frequency scaling drivers | 2 | # ARM CPU Frequency scaling drivers |
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | config ARM_BIG_LITTLE_CPUFREQ | ||
| 6 | tristate | ||
| 7 | depends on ARM_CPU_TOPOLOGY | ||
| 8 | |||
| 9 | config ARM_DT_BL_CPUFREQ | ||
| 10 | tristate "Generic ARM big LITTLE CPUfreq driver probed via DT" | ||
| 11 | select ARM_BIG_LITTLE_CPUFREQ | ||
| 12 | depends on OF && HAVE_CLK | ||
| 13 | help | ||
| 14 | This enables the Generic CPUfreq driver for ARM big.LITTLE platform. | ||
| 15 | This gets frequency tables from DT. | ||
| 16 | |||
| 17 | config ARM_EXYNOS_CPUFREQ | ||
| 18 | bool "SAMSUNG EXYNOS SoCs" | ||
| 19 | depends on ARCH_EXYNOS | ||
| 20 | default y | ||
| 21 | help | ||
| 22 | This adds the CPUFreq driver common part for Samsung | ||
| 23 | EXYNOS SoCs. | ||
| 24 | |||
| 25 | If in doubt, say N. | ||
| 26 | |||
| 27 | config ARM_EXYNOS4210_CPUFREQ | ||
| 28 | def_bool CPU_EXYNOS4210 | ||
| 29 | help | ||
| 30 | This adds the CPUFreq driver for Samsung EXYNOS4210 | ||
| 31 | SoC (S5PV310 or S5PC210). | ||
| 32 | |||
| 33 | config ARM_EXYNOS4X12_CPUFREQ | ||
| 34 | def_bool (SOC_EXYNOS4212 || SOC_EXYNOS4412) | ||
| 35 | help | ||
| 36 | This adds the CPUFreq driver for Samsung EXYNOS4X12 | ||
| 37 | SoC (EXYNOS4212 or EXYNOS4412). | ||
| 38 | |||
| 39 | config ARM_EXYNOS5250_CPUFREQ | ||
| 40 | def_bool SOC_EXYNOS5250 | ||
| 41 | help | ||
| 42 | This adds the CPUFreq driver for Samsung EXYNOS5250 | ||
| 43 | SoC. | ||
| 44 | |||
| 45 | config ARM_EXYNOS5440_CPUFREQ | ||
| 46 | def_bool SOC_EXYNOS5440 | ||
| 47 | depends on HAVE_CLK && PM_OPP && OF | ||
| 48 | help | ||
| 49 | This adds the CPUFreq driver for Samsung EXYNOS5440 | ||
| 50 | SoC. The nature of exynos5440 clock controller is | ||
| 51 | different than previous exynos controllers so not using | ||
| 52 | the common exynos framework. | ||
| 53 | |||
| 54 | config ARM_HIGHBANK_CPUFREQ | ||
| 55 | tristate "Calxeda Highbank-based" | ||
| 56 | depends on ARCH_HIGHBANK | ||
| 57 | select CPU_FREQ_TABLE | ||
| 58 | select GENERIC_CPUFREQ_CPU0 | ||
| 59 | select PM_OPP | ||
| 60 | select REGULATOR | ||
| 61 | |||
| 62 | default m | ||
| 63 | help | ||
| 64 | This adds the CPUFreq driver for Calxeda Highbank SoC | ||
| 65 | based boards. | ||
| 66 | |||
| 67 | If in doubt, say N. | ||
| 68 | |||
| 69 | config ARM_IMX6Q_CPUFREQ | ||
| 70 | tristate "Freescale i.MX6Q cpufreq support" | ||
| 71 | depends on SOC_IMX6Q | ||
| 72 | depends on REGULATOR_ANATOP | ||
| 73 | help | ||
| 74 | This adds cpufreq driver support for Freescale i.MX6Q SOC. | ||
| 75 | |||
| 76 | If in doubt, say N. | ||
| 77 | |||
| 78 | config ARM_INTEGRATOR | ||
| 79 | tristate "CPUfreq driver for ARM Integrator CPUs" | ||
| 80 | depends on ARCH_INTEGRATOR | ||
| 81 | default y | ||
| 82 | help | ||
| 83 | This enables the CPUfreq driver for ARM Integrator CPUs. | ||
| 84 | If in doubt, say Y. | ||
| 85 | |||
| 86 | config ARM_KIRKWOOD_CPUFREQ | ||
| 87 | def_bool ARCH_KIRKWOOD && OF | ||
| 88 | help | ||
| 89 | This adds the CPUFreq driver for Marvell Kirkwood | ||
| 90 | SoCs. | ||
| 91 | |||
| 5 | config ARM_OMAP2PLUS_CPUFREQ | 92 | config ARM_OMAP2PLUS_CPUFREQ |
| 6 | bool "TI OMAP2+" | 93 | bool "TI OMAP2+" |
| 7 | depends on ARCH_OMAP2PLUS | 94 | depends on ARCH_OMAP2PLUS |
| @@ -42,6 +129,7 @@ config ARM_S3C64XX_CPUFREQ | |||
| 42 | config ARM_S5PV210_CPUFREQ | 129 | config ARM_S5PV210_CPUFREQ |
| 43 | bool "Samsung S5PV210 and S5PC110" | 130 | bool "Samsung S5PV210 and S5PC110" |
| 44 | depends on CPU_S5PV210 | 131 | depends on CPU_S5PV210 |
| 132 | select CPU_FREQ_TABLE | ||
| 45 | default y | 133 | default y |
| 46 | help | 134 | help |
| 47 | This adds the CPUFreq driver for Samsung S5PV210 and | 135 | This adds the CPUFreq driver for Samsung S5PV210 and |
| @@ -49,48 +137,11 @@ config ARM_S5PV210_CPUFREQ | |||
| 49 | 137 | ||
| 50 | If in doubt, say N. | 138 | If in doubt, say N. |
| 51 | 139 | ||
| 52 | config ARM_EXYNOS_CPUFREQ | 140 | config ARM_SA1100_CPUFREQ |
| 53 | bool "SAMSUNG EXYNOS SoCs" | 141 | bool |
| 54 | depends on ARCH_EXYNOS | ||
| 55 | default y | ||
| 56 | help | ||
| 57 | This adds the CPUFreq driver common part for Samsung | ||
| 58 | EXYNOS SoCs. | ||
| 59 | |||
| 60 | If in doubt, say N. | ||
| 61 | 142 | ||
| 62 | config ARM_EXYNOS4210_CPUFREQ | 143 | config ARM_SA1110_CPUFREQ |
| 63 | def_bool CPU_EXYNOS4210 | 144 | bool |
| 64 | help | ||
| 65 | This adds the CPUFreq driver for Samsung EXYNOS4210 | ||
| 66 | SoC (S5PV310 or S5PC210). | ||
| 67 | |||
| 68 | config ARM_EXYNOS4X12_CPUFREQ | ||
| 69 | def_bool (SOC_EXYNOS4212 || SOC_EXYNOS4412) | ||
| 70 | help | ||
| 71 | This adds the CPUFreq driver for Samsung EXYNOS4X12 | ||
| 72 | SoC (EXYNOS4212 or EXYNOS4412). | ||
| 73 | |||
| 74 | config ARM_EXYNOS5250_CPUFREQ | ||
| 75 | def_bool SOC_EXYNOS5250 | ||
| 76 | help | ||
| 77 | This adds the CPUFreq driver for Samsung EXYNOS5250 | ||
| 78 | SoC. | ||
| 79 | |||
| 80 | config ARM_KIRKWOOD_CPUFREQ | ||
| 81 | def_bool ARCH_KIRKWOOD && OF | ||
| 82 | help | ||
| 83 | This adds the CPUFreq driver for Marvell Kirkwood | ||
| 84 | SoCs. | ||
| 85 | |||
| 86 | config ARM_IMX6Q_CPUFREQ | ||
| 87 | tristate "Freescale i.MX6Q cpufreq support" | ||
| 88 | depends on SOC_IMX6Q | ||
| 89 | depends on REGULATOR_ANATOP | ||
| 90 | help | ||
| 91 | This adds cpufreq driver support for Freescale i.MX6Q SOC. | ||
| 92 | |||
| 93 | If in doubt, say N. | ||
| 94 | 145 | ||
| 95 | config ARM_SPEAR_CPUFREQ | 146 | config ARM_SPEAR_CPUFREQ |
| 96 | bool "SPEAr CPUFreq support" | 147 | bool "SPEAr CPUFreq support" |
| @@ -98,18 +149,3 @@ config ARM_SPEAR_CPUFREQ | |||
| 98 | default y | 149 | default y |
| 99 | help | 150 | help |
| 100 | This adds the CPUFreq driver support for SPEAr SOCs. | 151 | This adds the CPUFreq driver support for SPEAr SOCs. |
| 101 | |||
| 102 | config ARM_HIGHBANK_CPUFREQ | ||
| 103 | tristate "Calxeda Highbank-based" | ||
| 104 | depends on ARCH_HIGHBANK | ||
| 105 | select CPU_FREQ_TABLE | ||
| 106 | select GENERIC_CPUFREQ_CPU0 | ||
| 107 | select PM_OPP | ||
| 108 | select REGULATOR | ||
| 109 | |||
| 110 | default m | ||
| 111 | help | ||
| 112 | This adds the CPUFreq driver for Calxeda Highbank SoC | ||
| 113 | based boards. | ||
| 114 | |||
| 115 | If in doubt, say N. | ||
diff --git a/drivers/cpufreq/Kconfig.powerpc b/drivers/cpufreq/Kconfig.powerpc index e76992f79683..9c926ca0d718 100644 --- a/drivers/cpufreq/Kconfig.powerpc +++ b/drivers/cpufreq/Kconfig.powerpc | |||
| @@ -1,3 +1,21 @@ | |||
| 1 | config CPU_FREQ_CBE | ||
| 2 | tristate "CBE frequency scaling" | ||
| 3 | depends on CBE_RAS && PPC_CELL | ||
| 4 | default m | ||
| 5 | help | ||
| 6 | This adds the cpufreq driver for Cell BE processors. | ||
| 7 | For details, take a look at <file:Documentation/cpu-freq/>. | ||
| 8 | If you don't have such processor, say N | ||
| 9 | |||
| 10 | config CPU_FREQ_CBE_PMI | ||
| 11 | bool "CBE frequency scaling using PMI interface" | ||
| 12 | depends on CPU_FREQ_CBE | ||
| 13 | default n | ||
| 14 | help | ||
| 15 | Select this, if you want to use the PMI interface to switch | ||
| 16 | frequencies. Using PMI, the processor will not only be able to run at | ||
| 17 | lower speed, but also at lower core voltage. | ||
| 18 | |||
| 1 | config CPU_FREQ_MAPLE | 19 | config CPU_FREQ_MAPLE |
| 2 | bool "Support for Maple 970FX Evaluation Board" | 20 | bool "Support for Maple 970FX Evaluation Board" |
| 3 | depends on PPC_MAPLE | 21 | depends on PPC_MAPLE |
diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index d7dc0ed6adb0..2b8a8c374548 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 | |||
| @@ -129,6 +129,23 @@ config X86_POWERNOW_K8 | |||
| 129 | 129 | ||
| 130 | For details, take a look at <file:Documentation/cpu-freq/>. | 130 | For details, take a look at <file:Documentation/cpu-freq/>. |
| 131 | 131 | ||
| 132 | config X86_AMD_FREQ_SENSITIVITY | ||
| 133 | tristate "AMD frequency sensitivity feedback powersave bias" | ||
| 134 | depends on CPU_FREQ_GOV_ONDEMAND && X86_ACPI_CPUFREQ && CPU_SUP_AMD | ||
| 135 | help | ||
| 136 | This adds AMD-specific powersave bias function to the ondemand | ||
| 137 | governor, which allows it to make more power-conscious frequency | ||
| 138 | change decisions based on feedback from hardware (availble on AMD | ||
| 139 | Family 16h and above). | ||
| 140 | |||
| 141 | Hardware feedback tells software how "sensitive" to frequency changes | ||
| 142 | the CPUs' workloads are. CPU-bound workloads will be more sensitive | ||
| 143 | -- they will perform better as frequency increases. Memory/IO-bound | ||
| 144 | workloads will be less sensitive -- they will not necessarily perform | ||
| 145 | better as frequency increases. | ||
| 146 | |||
| 147 | If in doubt, say N. | ||
| 148 | |||
| 132 | config X86_GX_SUSPMOD | 149 | config X86_GX_SUSPMOD |
| 133 | tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation" | 150 | tristate "Cyrix MediaGX/NatSemi Geode Suspend Modulation" |
| 134 | depends on X86_32 && PCI | 151 | depends on X86_32 && PCI |
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 863fd1865d45..315b9231feb1 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
| @@ -41,23 +41,54 @@ obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o | |||
| 41 | obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o | 41 | obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o |
| 42 | obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o | 42 | obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o |
| 43 | obj-$(CONFIG_X86_INTEL_PSTATE) += intel_pstate.o | 43 | obj-$(CONFIG_X86_INTEL_PSTATE) += intel_pstate.o |
| 44 | obj-$(CONFIG_X86_AMD_FREQ_SENSITIVITY) += amd_freq_sensitivity.o | ||
| 44 | 45 | ||
| 45 | ################################################################################## | 46 | ################################################################################## |
| 46 | # ARM SoC drivers | 47 | # ARM SoC drivers |
| 48 | obj-$(CONFIG_ARM_BIG_LITTLE_CPUFREQ) += arm_big_little.o | ||
| 49 | # big LITTLE per platform glues. Keep DT_BL_CPUFREQ as the last entry in all big | ||
| 50 | # LITTLE drivers, so that it is probed last. | ||
| 51 | obj-$(CONFIG_ARM_DT_BL_CPUFREQ) += arm_big_little_dt.o | ||
| 52 | |||
| 53 | obj-$(CONFIG_ARCH_DAVINCI_DA850) += davinci-cpufreq.o | ||
| 47 | obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o | 54 | obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o |
| 48 | obj-$(CONFIG_ARM_S3C2416_CPUFREQ) += s3c2416-cpufreq.o | ||
| 49 | obj-$(CONFIG_ARM_S3C64XX_CPUFREQ) += s3c64xx-cpufreq.o | ||
| 50 | obj-$(CONFIG_ARM_S5PV210_CPUFREQ) += s5pv210-cpufreq.o | ||
| 51 | obj-$(CONFIG_ARM_EXYNOS_CPUFREQ) += exynos-cpufreq.o | 55 | obj-$(CONFIG_ARM_EXYNOS_CPUFREQ) += exynos-cpufreq.o |
| 52 | obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o | 56 | obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o |
| 53 | obj-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ) += exynos4x12-cpufreq.o | 57 | obj-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ) += exynos4x12-cpufreq.o |
| 54 | obj-$(CONFIG_ARM_EXYNOS5250_CPUFREQ) += exynos5250-cpufreq.o | 58 | obj-$(CONFIG_ARM_EXYNOS5250_CPUFREQ) += exynos5250-cpufreq.o |
| 59 | obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o | ||
| 60 | obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o | ||
| 61 | obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o | ||
| 62 | obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o | ||
| 55 | obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o | 63 | obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o |
| 56 | obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o | 64 | obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o |
| 65 | obj-$(CONFIG_PXA25x) += pxa2xx-cpufreq.o | ||
| 66 | obj-$(CONFIG_PXA27x) += pxa2xx-cpufreq.o | ||
| 67 | obj-$(CONFIG_PXA3xx) += pxa3xx-cpufreq.o | ||
| 68 | obj-$(CONFIG_ARM_S3C2416_CPUFREQ) += s3c2416-cpufreq.o | ||
| 69 | obj-$(CONFIG_ARM_S3C64XX_CPUFREQ) += s3c64xx-cpufreq.o | ||
| 70 | obj-$(CONFIG_ARM_S5PV210_CPUFREQ) += s5pv210-cpufreq.o | ||
| 71 | obj-$(CONFIG_ARM_SA1100_CPUFREQ) += sa1100-cpufreq.o | ||
| 72 | obj-$(CONFIG_ARM_SA1110_CPUFREQ) += sa1110-cpufreq.o | ||
| 57 | obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o | 73 | obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o |
| 58 | obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o | 74 | obj-$(CONFIG_ARCH_TEGRA) += tegra-cpufreq.o |
| 59 | obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o | ||
| 60 | 75 | ||
| 61 | ################################################################################## | 76 | ################################################################################## |
| 62 | # PowerPC platform drivers | 77 | # PowerPC platform drivers |
| 78 | obj-$(CONFIG_CPU_FREQ_CBE) += ppc-cbe-cpufreq.o | ||
| 79 | ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o | ||
| 80 | obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o | ||
| 63 | obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o | 81 | obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o |
| 82 | |||
| 83 | ################################################################################## | ||
| 84 | # Other platform drivers | ||
| 85 | obj-$(CONFIG_AVR32_AT32AP_CPUFREQ) += at32ap-cpufreq.o | ||
| 86 | obj-$(CONFIG_BLACKFIN) += blackfin-cpufreq.o | ||
| 87 | obj-$(CONFIG_CRIS_MACH_ARTPEC3) += cris-artpec3-cpufreq.o | ||
| 88 | obj-$(CONFIG_ETRAXFS) += cris-etraxfs-cpufreq.o | ||
| 89 | obj-$(CONFIG_IA64_ACPI_CPUFREQ) += ia64-acpi-cpufreq.o | ||
| 90 | obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o | ||
| 91 | obj-$(CONFIG_SH_CPU_FREQ) += sh-cpufreq.o | ||
| 92 | obj-$(CONFIG_SPARC_US2E_CPUFREQ) += sparc-us2e-cpufreq.o | ||
| 93 | obj-$(CONFIG_SPARC_US3_CPUFREQ) += sparc-us3-cpufreq.o | ||
| 94 | obj-$(CONFIG_UNICORE32) += unicore2-cpufreq.o | ||
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 57a8774f0b4e..11b8b4b54ceb 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
| @@ -423,7 +423,6 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
| 423 | struct drv_cmd cmd; | 423 | struct drv_cmd cmd; |
| 424 | unsigned int next_state = 0; /* Index into freq_table */ | 424 | unsigned int next_state = 0; /* Index into freq_table */ |
| 425 | unsigned int next_perf_state = 0; /* Index into perf table */ | 425 | unsigned int next_perf_state = 0; /* Index into perf table */ |
| 426 | unsigned int i; | ||
| 427 | int result = 0; | 426 | int result = 0; |
| 428 | 427 | ||
| 429 | pr_debug("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu); | 428 | pr_debug("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu); |
| @@ -486,10 +485,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
| 486 | 485 | ||
| 487 | freqs.old = perf->states[perf->state].core_frequency * 1000; | 486 | freqs.old = perf->states[perf->state].core_frequency * 1000; |
| 488 | freqs.new = data->freq_table[next_state].frequency; | 487 | freqs.new = data->freq_table[next_state].frequency; |
| 489 | for_each_cpu(i, policy->cpus) { | 488 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 490 | freqs.cpu = i; | ||
| 491 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 492 | } | ||
| 493 | 489 | ||
| 494 | drv_write(&cmd); | 490 | drv_write(&cmd); |
| 495 | 491 | ||
| @@ -502,10 +498,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
| 502 | } | 498 | } |
| 503 | } | 499 | } |
| 504 | 500 | ||
| 505 | for_each_cpu(i, policy->cpus) { | 501 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 506 | freqs.cpu = i; | ||
| 507 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 508 | } | ||
| 509 | perf->state = next_perf_state; | 502 | perf->state = next_perf_state; |
| 510 | 503 | ||
| 511 | out: | 504 | out: |
diff --git a/drivers/cpufreq/amd_freq_sensitivity.c b/drivers/cpufreq/amd_freq_sensitivity.c new file mode 100644 index 000000000000..f6b79ab0070b --- /dev/null +++ b/drivers/cpufreq/amd_freq_sensitivity.c | |||
| @@ -0,0 +1,148 @@ | |||
| 1 | /* | ||
| 2 | * amd_freq_sensitivity.c: AMD frequency sensitivity feedback powersave bias | ||
| 3 | * for the ondemand governor. | ||
| 4 | * | ||
| 5 | * Copyright (C) 2013 Advanced Micro Devices, Inc. | ||
| 6 | * | ||
| 7 | * Author: Jacob Shin <jacob.shin@amd.com> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License version 2 as | ||
| 11 | * published by the Free Software Foundation. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/kernel.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/types.h> | ||
| 17 | #include <linux/percpu-defs.h> | ||
| 18 | #include <linux/init.h> | ||
| 19 | #include <linux/mod_devicetable.h> | ||
| 20 | |||
| 21 | #include <asm/msr.h> | ||
| 22 | #include <asm/cpufeature.h> | ||
| 23 | |||
| 24 | #include "cpufreq_governor.h" | ||
| 25 | |||
| 26 | #define MSR_AMD64_FREQ_SENSITIVITY_ACTUAL 0xc0010080 | ||
| 27 | #define MSR_AMD64_FREQ_SENSITIVITY_REFERENCE 0xc0010081 | ||
| 28 | #define CLASS_CODE_SHIFT 56 | ||
| 29 | #define POWERSAVE_BIAS_MAX 1000 | ||
| 30 | #define POWERSAVE_BIAS_DEF 400 | ||
| 31 | |||
| 32 | struct cpu_data_t { | ||
| 33 | u64 actual; | ||
| 34 | u64 reference; | ||
| 35 | unsigned int freq_prev; | ||
| 36 | }; | ||
| 37 | |||
| 38 | static DEFINE_PER_CPU(struct cpu_data_t, cpu_data); | ||
| 39 | |||
| 40 | static unsigned int amd_powersave_bias_target(struct cpufreq_policy *policy, | ||
| 41 | unsigned int freq_next, | ||
| 42 | unsigned int relation) | ||
| 43 | { | ||
| 44 | int sensitivity; | ||
| 45 | long d_actual, d_reference; | ||
| 46 | struct msr actual, reference; | ||
| 47 | struct cpu_data_t *data = &per_cpu(cpu_data, policy->cpu); | ||
| 48 | struct dbs_data *od_data = policy->governor_data; | ||
| 49 | struct od_dbs_tuners *od_tuners = od_data->tuners; | ||
| 50 | struct od_cpu_dbs_info_s *od_info = | ||
| 51 | od_data->cdata->get_cpu_dbs_info_s(policy->cpu); | ||
| 52 | |||
| 53 | if (!od_info->freq_table) | ||
| 54 | return freq_next; | ||
| 55 | |||
| 56 | rdmsr_on_cpu(policy->cpu, MSR_AMD64_FREQ_SENSITIVITY_ACTUAL, | ||
| 57 | &actual.l, &actual.h); | ||
| 58 | rdmsr_on_cpu(policy->cpu, MSR_AMD64_FREQ_SENSITIVITY_REFERENCE, | ||
| 59 | &reference.l, &reference.h); | ||
| 60 | actual.h &= 0x00ffffff; | ||
| 61 | reference.h &= 0x00ffffff; | ||
| 62 | |||
| 63 | /* counter wrapped around, so stay on current frequency */ | ||
| 64 | if (actual.q < data->actual || reference.q < data->reference) { | ||
| 65 | freq_next = policy->cur; | ||
| 66 | goto out; | ||
| 67 | } | ||
| 68 | |||
| 69 | d_actual = actual.q - data->actual; | ||
| 70 | d_reference = reference.q - data->reference; | ||
| 71 | |||
| 72 | /* divide by 0, so stay on current frequency as well */ | ||
| 73 | if (d_reference == 0) { | ||
| 74 | freq_next = policy->cur; | ||
| 75 | goto out; | ||
| 76 | } | ||
| 77 | |||
| 78 | sensitivity = POWERSAVE_BIAS_MAX - | ||
| 79 | (POWERSAVE_BIAS_MAX * (d_reference - d_actual) / d_reference); | ||
| 80 | |||
| 81 | clamp(sensitivity, 0, POWERSAVE_BIAS_MAX); | ||
| 82 | |||
| 83 | /* this workload is not CPU bound, so choose a lower freq */ | ||
| 84 | if (sensitivity < od_tuners->powersave_bias) { | ||
| 85 | if (data->freq_prev == policy->cur) | ||
| 86 | freq_next = policy->cur; | ||
| 87 | |||
| 88 | if (freq_next > policy->cur) | ||
| 89 | freq_next = policy->cur; | ||
| 90 | else if (freq_next < policy->cur) | ||
| 91 | freq_next = policy->min; | ||
| 92 | else { | ||
| 93 | unsigned int index; | ||
| 94 | |||
| 95 | cpufreq_frequency_table_target(policy, | ||
| 96 | od_info->freq_table, policy->cur - 1, | ||
| 97 | CPUFREQ_RELATION_H, &index); | ||
| 98 | freq_next = od_info->freq_table[index].frequency; | ||
| 99 | } | ||
| 100 | |||
| 101 | data->freq_prev = freq_next; | ||
| 102 | } else | ||
| 103 | data->freq_prev = 0; | ||
| 104 | |||
| 105 | out: | ||
| 106 | data->actual = actual.q; | ||
| 107 | data->reference = reference.q; | ||
| 108 | return freq_next; | ||
| 109 | } | ||
| 110 | |||
| 111 | static int __init amd_freq_sensitivity_init(void) | ||
| 112 | { | ||
| 113 | u64 val; | ||
| 114 | |||
| 115 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) | ||
| 116 | return -ENODEV; | ||
| 117 | |||
| 118 | if (!static_cpu_has(X86_FEATURE_PROC_FEEDBACK)) | ||
| 119 | return -ENODEV; | ||
| 120 | |||
| 121 | if (rdmsrl_safe(MSR_AMD64_FREQ_SENSITIVITY_ACTUAL, &val)) | ||
| 122 | return -ENODEV; | ||
| 123 | |||
| 124 | if (!(val >> CLASS_CODE_SHIFT)) | ||
| 125 | return -ENODEV; | ||
| 126 | |||
| 127 | od_register_powersave_bias_handler(amd_powersave_bias_target, | ||
| 128 | POWERSAVE_BIAS_DEF); | ||
| 129 | return 0; | ||
| 130 | } | ||
| 131 | late_initcall(amd_freq_sensitivity_init); | ||
| 132 | |||
| 133 | static void __exit amd_freq_sensitivity_exit(void) | ||
| 134 | { | ||
| 135 | od_unregister_powersave_bias_handler(); | ||
| 136 | } | ||
| 137 | module_exit(amd_freq_sensitivity_exit); | ||
| 138 | |||
| 139 | static const struct x86_cpu_id amd_freq_sensitivity_ids[] = { | ||
| 140 | X86_FEATURE_MATCH(X86_FEATURE_PROC_FEEDBACK), | ||
| 141 | {} | ||
| 142 | }; | ||
| 143 | MODULE_DEVICE_TABLE(x86cpu, amd_freq_sensitivity_ids); | ||
| 144 | |||
| 145 | MODULE_AUTHOR("Jacob Shin <jacob.shin@amd.com>"); | ||
| 146 | MODULE_DESCRIPTION("AMD frequency sensitivity feedback powersave bias for " | ||
| 147 | "the ondemand governor."); | ||
| 148 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c new file mode 100644 index 000000000000..dbdf677d2f36 --- /dev/null +++ b/drivers/cpufreq/arm_big_little.c | |||
| @@ -0,0 +1,278 @@ | |||
| 1 | /* | ||
| 2 | * ARM big.LITTLE Platforms CPUFreq support | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013 ARM Ltd. | ||
| 5 | * Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com> | ||
| 6 | * | ||
| 7 | * Copyright (C) 2013 Linaro. | ||
| 8 | * Viresh Kumar <viresh.kumar@linaro.org> | ||
| 9 | * | ||
| 10 | * This program is free software; you can redistribute it and/or modify | ||
| 11 | * it under the terms of the GNU General Public License version 2 as | ||
| 12 | * published by the Free Software Foundation. | ||
| 13 | * | ||
| 14 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
| 15 | * kind, whether express or implied; without even the implied warranty | ||
| 16 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 21 | |||
| 22 | #include <linux/clk.h> | ||
| 23 | #include <linux/cpu.h> | ||
| 24 | #include <linux/cpufreq.h> | ||
| 25 | #include <linux/cpumask.h> | ||
| 26 | #include <linux/export.h> | ||
| 27 | #include <linux/of_platform.h> | ||
| 28 | #include <linux/opp.h> | ||
| 29 | #include <linux/slab.h> | ||
| 30 | #include <linux/topology.h> | ||
| 31 | #include <linux/types.h> | ||
| 32 | |||
| 33 | #include "arm_big_little.h" | ||
| 34 | |||
| 35 | /* Currently we support only two clusters */ | ||
| 36 | #define MAX_CLUSTERS 2 | ||
| 37 | |||
| 38 | static struct cpufreq_arm_bL_ops *arm_bL_ops; | ||
| 39 | static struct clk *clk[MAX_CLUSTERS]; | ||
| 40 | static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS]; | ||
| 41 | static atomic_t cluster_usage[MAX_CLUSTERS] = {ATOMIC_INIT(0), ATOMIC_INIT(0)}; | ||
| 42 | |||
| 43 | static int cpu_to_cluster(int cpu) | ||
| 44 | { | ||
| 45 | return topology_physical_package_id(cpu); | ||
| 46 | } | ||
| 47 | |||
| 48 | static unsigned int bL_cpufreq_get(unsigned int cpu) | ||
| 49 | { | ||
| 50 | u32 cur_cluster = cpu_to_cluster(cpu); | ||
| 51 | |||
| 52 | return clk_get_rate(clk[cur_cluster]) / 1000; | ||
| 53 | } | ||
| 54 | |||
| 55 | /* Validate policy frequency range */ | ||
| 56 | static int bL_cpufreq_verify_policy(struct cpufreq_policy *policy) | ||
| 57 | { | ||
| 58 | u32 cur_cluster = cpu_to_cluster(policy->cpu); | ||
| 59 | |||
| 60 | return cpufreq_frequency_table_verify(policy, freq_table[cur_cluster]); | ||
| 61 | } | ||
| 62 | |||
| 63 | /* Set clock frequency */ | ||
| 64 | static int bL_cpufreq_set_target(struct cpufreq_policy *policy, | ||
| 65 | unsigned int target_freq, unsigned int relation) | ||
| 66 | { | ||
| 67 | struct cpufreq_freqs freqs; | ||
| 68 | u32 cpu = policy->cpu, freq_tab_idx, cur_cluster; | ||
| 69 | int ret = 0; | ||
| 70 | |||
| 71 | cur_cluster = cpu_to_cluster(policy->cpu); | ||
| 72 | |||
| 73 | freqs.old = bL_cpufreq_get(policy->cpu); | ||
| 74 | |||
| 75 | /* Determine valid target frequency using freq_table */ | ||
| 76 | cpufreq_frequency_table_target(policy, freq_table[cur_cluster], | ||
| 77 | target_freq, relation, &freq_tab_idx); | ||
| 78 | freqs.new = freq_table[cur_cluster][freq_tab_idx].frequency; | ||
| 79 | |||
| 80 | pr_debug("%s: cpu: %d, cluster: %d, oldfreq: %d, target freq: %d, new freq: %d\n", | ||
| 81 | __func__, cpu, cur_cluster, freqs.old, target_freq, | ||
| 82 | freqs.new); | ||
| 83 | |||
| 84 | if (freqs.old == freqs.new) | ||
| 85 | return 0; | ||
| 86 | |||
| 87 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
| 88 | |||
| 89 | ret = clk_set_rate(clk[cur_cluster], freqs.new * 1000); | ||
| 90 | if (ret) { | ||
| 91 | pr_err("clk_set_rate failed: %d\n", ret); | ||
| 92 | return ret; | ||
| 93 | } | ||
| 94 | |||
| 95 | policy->cur = freqs.new; | ||
| 96 | |||
| 97 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
| 98 | |||
| 99 | return ret; | ||
| 100 | } | ||
| 101 | |||
| 102 | static void put_cluster_clk_and_freq_table(struct device *cpu_dev) | ||
| 103 | { | ||
| 104 | u32 cluster = cpu_to_cluster(cpu_dev->id); | ||
| 105 | |||
| 106 | if (!atomic_dec_return(&cluster_usage[cluster])) { | ||
| 107 | clk_put(clk[cluster]); | ||
| 108 | opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]); | ||
| 109 | dev_dbg(cpu_dev, "%s: cluster: %d\n", __func__, cluster); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | static int get_cluster_clk_and_freq_table(struct device *cpu_dev) | ||
| 114 | { | ||
| 115 | u32 cluster = cpu_to_cluster(cpu_dev->id); | ||
| 116 | char name[14] = "cpu-cluster."; | ||
| 117 | int ret; | ||
| 118 | |||
| 119 | if (atomic_inc_return(&cluster_usage[cluster]) != 1) | ||
| 120 | return 0; | ||
| 121 | |||
| 122 | ret = arm_bL_ops->init_opp_table(cpu_dev); | ||
| 123 | if (ret) { | ||
| 124 | dev_err(cpu_dev, "%s: init_opp_table failed, cpu: %d, err: %d\n", | ||
| 125 | __func__, cpu_dev->id, ret); | ||
| 126 | goto atomic_dec; | ||
| 127 | } | ||
| 128 | |||
| 129 | ret = opp_init_cpufreq_table(cpu_dev, &freq_table[cluster]); | ||
| 130 | if (ret) { | ||
| 131 | dev_err(cpu_dev, "%s: failed to init cpufreq table, cpu: %d, err: %d\n", | ||
| 132 | __func__, cpu_dev->id, ret); | ||
| 133 | goto atomic_dec; | ||
| 134 | } | ||
| 135 | |||
| 136 | name[12] = cluster + '0'; | ||
| 137 | clk[cluster] = clk_get_sys(name, NULL); | ||
| 138 | if (!IS_ERR(clk[cluster])) { | ||
| 139 | dev_dbg(cpu_dev, "%s: clk: %p & freq table: %p, cluster: %d\n", | ||
| 140 | __func__, clk[cluster], freq_table[cluster], | ||
| 141 | cluster); | ||
| 142 | return 0; | ||
| 143 | } | ||
| 144 | |||
| 145 | dev_err(cpu_dev, "%s: Failed to get clk for cpu: %d, cluster: %d\n", | ||
| 146 | __func__, cpu_dev->id, cluster); | ||
| 147 | ret = PTR_ERR(clk[cluster]); | ||
| 148 | opp_free_cpufreq_table(cpu_dev, &freq_table[cluster]); | ||
| 149 | |||
| 150 | atomic_dec: | ||
| 151 | atomic_dec(&cluster_usage[cluster]); | ||
| 152 | dev_err(cpu_dev, "%s: Failed to get data for cluster: %d\n", __func__, | ||
| 153 | cluster); | ||
| 154 | return ret; | ||
| 155 | } | ||
| 156 | |||
| 157 | /* Per-CPU initialization */ | ||
| 158 | static int bL_cpufreq_init(struct cpufreq_policy *policy) | ||
| 159 | { | ||
| 160 | u32 cur_cluster = cpu_to_cluster(policy->cpu); | ||
| 161 | struct device *cpu_dev; | ||
| 162 | int ret; | ||
| 163 | |||
| 164 | cpu_dev = get_cpu_device(policy->cpu); | ||
| 165 | if (!cpu_dev) { | ||
| 166 | pr_err("%s: failed to get cpu%d device\n", __func__, | ||
| 167 | policy->cpu); | ||
| 168 | return -ENODEV; | ||
| 169 | } | ||
| 170 | |||
| 171 | ret = get_cluster_clk_and_freq_table(cpu_dev); | ||
| 172 | if (ret) | ||
| 173 | return ret; | ||
| 174 | |||
| 175 | ret = cpufreq_frequency_table_cpuinfo(policy, freq_table[cur_cluster]); | ||
| 176 | if (ret) { | ||
| 177 | dev_err(cpu_dev, "CPU %d, cluster: %d invalid freq table\n", | ||
| 178 | policy->cpu, cur_cluster); | ||
| 179 | put_cluster_clk_and_freq_table(cpu_dev); | ||
| 180 | return ret; | ||
| 181 | } | ||
| 182 | |||
| 183 | cpufreq_frequency_table_get_attr(freq_table[cur_cluster], policy->cpu); | ||
| 184 | |||
| 185 | if (arm_bL_ops->get_transition_latency) | ||
| 186 | policy->cpuinfo.transition_latency = | ||
| 187 | arm_bL_ops->get_transition_latency(cpu_dev); | ||
| 188 | else | ||
| 189 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | ||
| 190 | |||
| 191 | policy->cur = bL_cpufreq_get(policy->cpu); | ||
| 192 | |||
| 193 | cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu)); | ||
| 194 | |||
| 195 | dev_info(cpu_dev, "CPU %d initialized\n", policy->cpu); | ||
| 196 | return 0; | ||
| 197 | } | ||
| 198 | |||
| 199 | static int bL_cpufreq_exit(struct cpufreq_policy *policy) | ||
| 200 | { | ||
| 201 | struct device *cpu_dev; | ||
| 202 | |||
| 203 | cpu_dev = get_cpu_device(policy->cpu); | ||
| 204 | if (!cpu_dev) { | ||
| 205 | pr_err("%s: failed to get cpu%d device\n", __func__, | ||
| 206 | policy->cpu); | ||
| 207 | return -ENODEV; | ||
| 208 | } | ||
| 209 | |||
| 210 | put_cluster_clk_and_freq_table(cpu_dev); | ||
| 211 | dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu); | ||
| 212 | |||
| 213 | return 0; | ||
| 214 | } | ||
| 215 | |||
| 216 | /* Export freq_table to sysfs */ | ||
| 217 | static struct freq_attr *bL_cpufreq_attr[] = { | ||
| 218 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 219 | NULL, | ||
| 220 | }; | ||
| 221 | |||
| 222 | static struct cpufreq_driver bL_cpufreq_driver = { | ||
| 223 | .name = "arm-big-little", | ||
| 224 | .flags = CPUFREQ_STICKY, | ||
| 225 | .verify = bL_cpufreq_verify_policy, | ||
| 226 | .target = bL_cpufreq_set_target, | ||
| 227 | .get = bL_cpufreq_get, | ||
| 228 | .init = bL_cpufreq_init, | ||
| 229 | .exit = bL_cpufreq_exit, | ||
| 230 | .have_governor_per_policy = true, | ||
| 231 | .attr = bL_cpufreq_attr, | ||
| 232 | }; | ||
| 233 | |||
| 234 | int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops) | ||
| 235 | { | ||
| 236 | int ret; | ||
| 237 | |||
| 238 | if (arm_bL_ops) { | ||
| 239 | pr_debug("%s: Already registered: %s, exiting\n", __func__, | ||
| 240 | arm_bL_ops->name); | ||
| 241 | return -EBUSY; | ||
| 242 | } | ||
| 243 | |||
| 244 | if (!ops || !strlen(ops->name) || !ops->init_opp_table) { | ||
| 245 | pr_err("%s: Invalid arm_bL_ops, exiting\n", __func__); | ||
| 246 | return -ENODEV; | ||
| 247 | } | ||
| 248 | |||
| 249 | arm_bL_ops = ops; | ||
| 250 | |||
| 251 | ret = cpufreq_register_driver(&bL_cpufreq_driver); | ||
| 252 | if (ret) { | ||
| 253 | pr_info("%s: Failed registering platform driver: %s, err: %d\n", | ||
| 254 | __func__, ops->name, ret); | ||
| 255 | arm_bL_ops = NULL; | ||
| 256 | } else { | ||
| 257 | pr_info("%s: Registered platform driver: %s\n", __func__, | ||
| 258 | ops->name); | ||
| 259 | } | ||
| 260 | |||
| 261 | return ret; | ||
| 262 | } | ||
| 263 | EXPORT_SYMBOL_GPL(bL_cpufreq_register); | ||
| 264 | |||
| 265 | void bL_cpufreq_unregister(struct cpufreq_arm_bL_ops *ops) | ||
| 266 | { | ||
| 267 | if (arm_bL_ops != ops) { | ||
| 268 | pr_err("%s: Registered with: %s, can't unregister, exiting\n", | ||
| 269 | __func__, arm_bL_ops->name); | ||
| 270 | return; | ||
| 271 | } | ||
| 272 | |||
| 273 | cpufreq_unregister_driver(&bL_cpufreq_driver); | ||
| 274 | pr_info("%s: Un-registered platform driver: %s\n", __func__, | ||
| 275 | arm_bL_ops->name); | ||
| 276 | arm_bL_ops = NULL; | ||
| 277 | } | ||
| 278 | EXPORT_SYMBOL_GPL(bL_cpufreq_unregister); | ||
diff --git a/drivers/cpufreq/arm_big_little.h b/drivers/cpufreq/arm_big_little.h new file mode 100644 index 000000000000..70f18fc12d4a --- /dev/null +++ b/drivers/cpufreq/arm_big_little.h | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | /* | ||
| 2 | * ARM big.LITTLE platform's CPUFreq header file | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013 ARM Ltd. | ||
| 5 | * Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com> | ||
| 6 | * | ||
| 7 | * Copyright (C) 2013 Linaro. | ||
| 8 | * Viresh Kumar <viresh.kumar@linaro.org> | ||
| 9 | * | ||
| 10 | * This program is free software; you can redistribute it and/or modify | ||
| 11 | * it under the terms of the GNU General Public License version 2 as | ||
| 12 | * published by the Free Software Foundation. | ||
| 13 | * | ||
| 14 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
| 15 | * kind, whether express or implied; without even the implied warranty | ||
| 16 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | */ | ||
| 19 | #ifndef CPUFREQ_ARM_BIG_LITTLE_H | ||
| 20 | #define CPUFREQ_ARM_BIG_LITTLE_H | ||
| 21 | |||
| 22 | #include <linux/cpufreq.h> | ||
| 23 | #include <linux/device.h> | ||
| 24 | #include <linux/types.h> | ||
| 25 | |||
| 26 | struct cpufreq_arm_bL_ops { | ||
| 27 | char name[CPUFREQ_NAME_LEN]; | ||
| 28 | int (*get_transition_latency)(struct device *cpu_dev); | ||
| 29 | |||
| 30 | /* | ||
| 31 | * This must set opp table for cpu_dev in a similar way as done by | ||
| 32 | * of_init_opp_table(). | ||
| 33 | */ | ||
| 34 | int (*init_opp_table)(struct device *cpu_dev); | ||
| 35 | }; | ||
| 36 | |||
| 37 | int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops); | ||
| 38 | void bL_cpufreq_unregister(struct cpufreq_arm_bL_ops *ops); | ||
| 39 | |||
| 40 | #endif /* CPUFREQ_ARM_BIG_LITTLE_H */ | ||
diff --git a/drivers/cpufreq/arm_big_little_dt.c b/drivers/cpufreq/arm_big_little_dt.c new file mode 100644 index 000000000000..44be3115375c --- /dev/null +++ b/drivers/cpufreq/arm_big_little_dt.c | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | /* | ||
| 2 | * Generic big.LITTLE CPUFreq Interface driver | ||
| 3 | * | ||
| 4 | * It provides necessary ops to arm_big_little cpufreq driver and gets | ||
| 5 | * Frequency information from Device Tree. Freq table in DT must be in KHz. | ||
| 6 | * | ||
| 7 | * Copyright (C) 2013 Linaro. | ||
| 8 | * Viresh Kumar <viresh.kumar@linaro.org> | ||
| 9 | * | ||
| 10 | * This program is free software; you can redistribute it and/or modify | ||
| 11 | * it under the terms of the GNU General Public License version 2 as | ||
| 12 | * published by the Free Software Foundation. | ||
| 13 | * | ||
| 14 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
| 15 | * kind, whether express or implied; without even the implied warranty | ||
| 16 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * GNU General Public License for more details. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 21 | |||
| 22 | #include <linux/cpufreq.h> | ||
| 23 | #include <linux/device.h> | ||
| 24 | #include <linux/export.h> | ||
| 25 | #include <linux/module.h> | ||
| 26 | #include <linux/of.h> | ||
| 27 | #include <linux/opp.h> | ||
| 28 | #include <linux/slab.h> | ||
| 29 | #include <linux/types.h> | ||
| 30 | #include "arm_big_little.h" | ||
| 31 | |||
| 32 | static int dt_init_opp_table(struct device *cpu_dev) | ||
| 33 | { | ||
| 34 | struct device_node *np, *parent; | ||
| 35 | int count = 0, ret; | ||
| 36 | |||
| 37 | parent = of_find_node_by_path("/cpus"); | ||
| 38 | if (!parent) { | ||
| 39 | pr_err("failed to find OF /cpus\n"); | ||
| 40 | return -ENOENT; | ||
| 41 | } | ||
| 42 | |||
| 43 | for_each_child_of_node(parent, np) { | ||
| 44 | if (count++ != cpu_dev->id) | ||
| 45 | continue; | ||
| 46 | if (!of_get_property(np, "operating-points", NULL)) { | ||
| 47 | ret = -ENODATA; | ||
| 48 | } else { | ||
| 49 | cpu_dev->of_node = np; | ||
| 50 | ret = of_init_opp_table(cpu_dev); | ||
| 51 | } | ||
| 52 | of_node_put(np); | ||
| 53 | of_node_put(parent); | ||
| 54 | |||
| 55 | return ret; | ||
| 56 | } | ||
| 57 | |||
| 58 | return -ENODEV; | ||
| 59 | } | ||
| 60 | |||
| 61 | static int dt_get_transition_latency(struct device *cpu_dev) | ||
| 62 | { | ||
| 63 | struct device_node *np, *parent; | ||
| 64 | u32 transition_latency = CPUFREQ_ETERNAL; | ||
| 65 | int count = 0; | ||
| 66 | |||
| 67 | parent = of_find_node_by_path("/cpus"); | ||
| 68 | if (!parent) { | ||
| 69 | pr_err("failed to find OF /cpus\n"); | ||
| 70 | return -ENOENT; | ||
| 71 | } | ||
| 72 | |||
| 73 | for_each_child_of_node(parent, np) { | ||
| 74 | if (count++ != cpu_dev->id) | ||
| 75 | continue; | ||
| 76 | |||
| 77 | of_property_read_u32(np, "clock-latency", &transition_latency); | ||
| 78 | of_node_put(np); | ||
| 79 | of_node_put(parent); | ||
| 80 | |||
| 81 | return 0; | ||
| 82 | } | ||
| 83 | |||
| 84 | return -ENODEV; | ||
| 85 | } | ||
| 86 | |||
| 87 | static struct cpufreq_arm_bL_ops dt_bL_ops = { | ||
| 88 | .name = "dt-bl", | ||
| 89 | .get_transition_latency = dt_get_transition_latency, | ||
| 90 | .init_opp_table = dt_init_opp_table, | ||
| 91 | }; | ||
| 92 | |||
| 93 | static int generic_bL_init(void) | ||
| 94 | { | ||
| 95 | return bL_cpufreq_register(&dt_bL_ops); | ||
| 96 | } | ||
| 97 | module_init(generic_bL_init); | ||
| 98 | |||
| 99 | static void generic_bL_exit(void) | ||
| 100 | { | ||
| 101 | return bL_cpufreq_unregister(&dt_bL_ops); | ||
| 102 | } | ||
| 103 | module_exit(generic_bL_exit); | ||
| 104 | |||
| 105 | MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>"); | ||
| 106 | MODULE_DESCRIPTION("Generic ARM big LITTLE cpufreq driver via DT"); | ||
| 107 | MODULE_LICENSE("GPL"); | ||
diff --git a/arch/avr32/mach-at32ap/cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c index 18b765629a0c..654488723cb5 100644 --- a/arch/avr32/mach-at32ap/cpufreq.c +++ b/drivers/cpufreq/at32ap-cpufreq.c | |||
| @@ -61,7 +61,6 @@ static int at32_set_target(struct cpufreq_policy *policy, | |||
| 61 | 61 | ||
| 62 | freqs.old = at32_get_speed(0); | 62 | freqs.old = at32_get_speed(0); |
| 63 | freqs.new = (freq + 500) / 1000; | 63 | freqs.new = (freq + 500) / 1000; |
| 64 | freqs.cpu = 0; | ||
| 65 | freqs.flags = 0; | 64 | freqs.flags = 0; |
| 66 | 65 | ||
| 67 | if (!ref_freq) { | 66 | if (!ref_freq) { |
| @@ -69,7 +68,7 @@ static int at32_set_target(struct cpufreq_policy *policy, | |||
| 69 | loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy; | 68 | loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy; |
| 70 | } | 69 | } |
| 71 | 70 | ||
| 72 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 71 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 73 | if (freqs.old < freqs.new) | 72 | if (freqs.old < freqs.new) |
| 74 | boot_cpu_data.loops_per_jiffy = cpufreq_scale( | 73 | boot_cpu_data.loops_per_jiffy = cpufreq_scale( |
| 75 | loops_per_jiffy_ref, ref_freq, freqs.new); | 74 | loops_per_jiffy_ref, ref_freq, freqs.new); |
| @@ -77,7 +76,7 @@ static int at32_set_target(struct cpufreq_policy *policy, | |||
| 77 | if (freqs.new < freqs.old) | 76 | if (freqs.new < freqs.old) |
| 78 | boot_cpu_data.loops_per_jiffy = cpufreq_scale( | 77 | boot_cpu_data.loops_per_jiffy = cpufreq_scale( |
| 79 | loops_per_jiffy_ref, ref_freq, freqs.new); | 78 | loops_per_jiffy_ref, ref_freq, freqs.new); |
| 80 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 79 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 81 | 80 | ||
| 82 | pr_debug("cpufreq: set frequency %lu Hz\n", freq); | 81 | pr_debug("cpufreq: set frequency %lu Hz\n", freq); |
| 83 | 82 | ||
diff --git a/arch/blackfin/mach-common/cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c index d88bd31319e6..995511e80bef 100644 --- a/arch/blackfin/mach-common/cpufreq.c +++ b/drivers/cpufreq/blackfin-cpufreq.c | |||
| @@ -127,13 +127,13 @@ unsigned long cpu_set_cclk(int cpu, unsigned long new) | |||
| 127 | } | 127 | } |
| 128 | #endif | 128 | #endif |
| 129 | 129 | ||
| 130 | static int bfin_target(struct cpufreq_policy *poli, | 130 | static int bfin_target(struct cpufreq_policy *policy, |
| 131 | unsigned int target_freq, unsigned int relation) | 131 | unsigned int target_freq, unsigned int relation) |
| 132 | { | 132 | { |
| 133 | #ifndef CONFIG_BF60x | 133 | #ifndef CONFIG_BF60x |
| 134 | unsigned int plldiv; | 134 | unsigned int plldiv; |
| 135 | #endif | 135 | #endif |
| 136 | unsigned int index, cpu; | 136 | unsigned int index; |
| 137 | unsigned long cclk_hz; | 137 | unsigned long cclk_hz; |
| 138 | struct cpufreq_freqs freqs; | 138 | struct cpufreq_freqs freqs; |
| 139 | static unsigned long lpj_ref; | 139 | static unsigned long lpj_ref; |
| @@ -144,59 +144,48 @@ static int bfin_target(struct cpufreq_policy *poli, | |||
| 144 | cycles_t cycles; | 144 | cycles_t cycles; |
| 145 | #endif | 145 | #endif |
| 146 | 146 | ||
| 147 | for_each_online_cpu(cpu) { | 147 | if (cpufreq_frequency_table_target(policy, bfin_freq_table, target_freq, |
| 148 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | 148 | relation, &index)) |
| 149 | return -EINVAL; | ||
| 149 | 150 | ||
| 150 | if (!policy) | 151 | cclk_hz = bfin_freq_table[index].frequency; |
| 151 | continue; | ||
| 152 | 152 | ||
| 153 | if (cpufreq_frequency_table_target(policy, bfin_freq_table, | 153 | freqs.old = bfin_getfreq_khz(0); |
| 154 | target_freq, relation, &index)) | 154 | freqs.new = cclk_hz; |
| 155 | return -EINVAL; | ||
| 156 | 155 | ||
| 157 | cclk_hz = bfin_freq_table[index].frequency; | 156 | pr_debug("cpufreq: changing cclk to %lu; target = %u, oldfreq = %u\n", |
| 157 | cclk_hz, target_freq, freqs.old); | ||
| 158 | 158 | ||
| 159 | freqs.old = bfin_getfreq_khz(0); | 159 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 160 | freqs.new = cclk_hz; | ||
| 161 | freqs.cpu = cpu; | ||
| 162 | |||
| 163 | pr_debug("cpufreq: changing cclk to %lu; target = %u, oldfreq = %u\n", | ||
| 164 | cclk_hz, target_freq, freqs.old); | ||
| 165 | |||
| 166 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 167 | if (cpu == CPUFREQ_CPU) { | ||
| 168 | #ifndef CONFIG_BF60x | 160 | #ifndef CONFIG_BF60x |
| 169 | plldiv = (bfin_read_PLL_DIV() & SSEL) | | 161 | plldiv = (bfin_read_PLL_DIV() & SSEL) | dpm_state_table[index].csel; |
| 170 | dpm_state_table[index].csel; | 162 | bfin_write_PLL_DIV(plldiv); |
| 171 | bfin_write_PLL_DIV(plldiv); | ||
| 172 | #else | 163 | #else |
| 173 | ret = cpu_set_cclk(cpu, freqs.new * 1000); | 164 | ret = cpu_set_cclk(policy->cpu, freqs.new * 1000); |
| 174 | if (ret != 0) { | 165 | if (ret != 0) { |
| 175 | WARN_ONCE(ret, "cpufreq set freq failed %d\n", ret); | 166 | WARN_ONCE(ret, "cpufreq set freq failed %d\n", ret); |
| 176 | break; | 167 | return ret; |
| 177 | } | 168 | } |
| 178 | #endif | 169 | #endif |
| 179 | on_each_cpu(bfin_adjust_core_timer, &index, 1); | 170 | on_each_cpu(bfin_adjust_core_timer, &index, 1); |
| 180 | #if defined(CONFIG_CYCLES_CLOCKSOURCE) | 171 | #if defined(CONFIG_CYCLES_CLOCKSOURCE) |
| 181 | cycles = get_cycles(); | 172 | cycles = get_cycles(); |
| 182 | SSYNC(); | 173 | SSYNC(); |
| 183 | cycles += 10; /* ~10 cycles we lose after get_cycles() */ | 174 | cycles += 10; /* ~10 cycles we lose after get_cycles() */ |
| 184 | __bfin_cycles_off += | 175 | __bfin_cycles_off += (cycles << __bfin_cycles_mod) - (cycles << index); |
| 185 | (cycles << __bfin_cycles_mod) - (cycles << index); | 176 | __bfin_cycles_mod = index; |
| 186 | __bfin_cycles_mod = index; | ||
| 187 | #endif | 177 | #endif |
| 188 | if (!lpj_ref_freq) { | 178 | if (!lpj_ref_freq) { |
| 189 | lpj_ref = loops_per_jiffy; | 179 | lpj_ref = loops_per_jiffy; |
| 190 | lpj_ref_freq = freqs.old; | 180 | lpj_ref_freq = freqs.old; |
| 191 | } | ||
| 192 | if (freqs.new != freqs.old) { | ||
| 193 | loops_per_jiffy = cpufreq_scale(lpj_ref, | ||
| 194 | lpj_ref_freq, freqs.new); | ||
| 195 | } | ||
| 196 | } | ||
| 197 | /* TODO: just test case for cycles clock source, remove later */ | ||
| 198 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 199 | } | 181 | } |
| 182 | if (freqs.new != freqs.old) { | ||
| 183 | loops_per_jiffy = cpufreq_scale(lpj_ref, | ||
| 184 | lpj_ref_freq, freqs.new); | ||
| 185 | } | ||
| 186 | |||
| 187 | /* TODO: just test case for cycles clock source, remove later */ | ||
| 188 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
| 200 | 189 | ||
| 201 | pr_debug("cpufreq: done\n"); | 190 | pr_debug("cpufreq: done\n"); |
| 202 | return ret; | 191 | return ret; |
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index 37d23a0f8c56..3ab8294eab04 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c | |||
| @@ -44,8 +44,9 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
| 44 | { | 44 | { |
| 45 | struct cpufreq_freqs freqs; | 45 | struct cpufreq_freqs freqs; |
| 46 | struct opp *opp; | 46 | struct opp *opp; |
| 47 | unsigned long freq_Hz, volt = 0, volt_old = 0, tol = 0; | 47 | unsigned long volt = 0, volt_old = 0, tol = 0; |
| 48 | unsigned int index, cpu; | 48 | long freq_Hz; |
| 49 | unsigned int index; | ||
| 49 | int ret; | 50 | int ret; |
| 50 | 51 | ||
| 51 | ret = cpufreq_frequency_table_target(policy, freq_table, target_freq, | 52 | ret = cpufreq_frequency_table_target(policy, freq_table, target_freq, |
| @@ -65,10 +66,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
| 65 | if (freqs.old == freqs.new) | 66 | if (freqs.old == freqs.new) |
| 66 | return 0; | 67 | return 0; |
| 67 | 68 | ||
| 68 | for_each_online_cpu(cpu) { | 69 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 69 | freqs.cpu = cpu; | ||
| 70 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 71 | } | ||
| 72 | 70 | ||
| 73 | if (cpu_reg) { | 71 | if (cpu_reg) { |
| 74 | rcu_read_lock(); | 72 | rcu_read_lock(); |
| @@ -76,7 +74,9 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
| 76 | if (IS_ERR(opp)) { | 74 | if (IS_ERR(opp)) { |
| 77 | rcu_read_unlock(); | 75 | rcu_read_unlock(); |
| 78 | pr_err("failed to find OPP for %ld\n", freq_Hz); | 76 | pr_err("failed to find OPP for %ld\n", freq_Hz); |
| 79 | return PTR_ERR(opp); | 77 | freqs.new = freqs.old; |
| 78 | ret = PTR_ERR(opp); | ||
| 79 | goto post_notify; | ||
| 80 | } | 80 | } |
| 81 | volt = opp_get_voltage(opp); | 81 | volt = opp_get_voltage(opp); |
| 82 | rcu_read_unlock(); | 82 | rcu_read_unlock(); |
| @@ -94,7 +94,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
| 94 | if (ret) { | 94 | if (ret) { |
| 95 | pr_err("failed to scale voltage up: %d\n", ret); | 95 | pr_err("failed to scale voltage up: %d\n", ret); |
| 96 | freqs.new = freqs.old; | 96 | freqs.new = freqs.old; |
| 97 | return ret; | 97 | goto post_notify; |
| 98 | } | 98 | } |
| 99 | } | 99 | } |
| 100 | 100 | ||
| @@ -103,7 +103,8 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
| 103 | pr_err("failed to set clock rate: %d\n", ret); | 103 | pr_err("failed to set clock rate: %d\n", ret); |
| 104 | if (cpu_reg) | 104 | if (cpu_reg) |
| 105 | regulator_set_voltage_tol(cpu_reg, volt_old, tol); | 105 | regulator_set_voltage_tol(cpu_reg, volt_old, tol); |
| 106 | return ret; | 106 | freqs.new = freqs.old; |
| 107 | goto post_notify; | ||
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | /* scaling down? scale voltage after frequency */ | 110 | /* scaling down? scale voltage after frequency */ |
| @@ -113,25 +114,19 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
| 113 | pr_err("failed to scale voltage down: %d\n", ret); | 114 | pr_err("failed to scale voltage down: %d\n", ret); |
| 114 | clk_set_rate(cpu_clk, freqs.old * 1000); | 115 | clk_set_rate(cpu_clk, freqs.old * 1000); |
| 115 | freqs.new = freqs.old; | 116 | freqs.new = freqs.old; |
| 116 | return ret; | ||
| 117 | } | 117 | } |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | for_each_online_cpu(cpu) { | 120 | post_notify: |
| 121 | freqs.cpu = cpu; | 121 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 122 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 123 | } | ||
| 124 | 122 | ||
| 125 | return 0; | 123 | return ret; |
| 126 | } | 124 | } |
| 127 | 125 | ||
| 128 | static int cpu0_cpufreq_init(struct cpufreq_policy *policy) | 126 | static int cpu0_cpufreq_init(struct cpufreq_policy *policy) |
| 129 | { | 127 | { |
| 130 | int ret; | 128 | int ret; |
| 131 | 129 | ||
| 132 | if (policy->cpu != 0) | ||
| 133 | return -EINVAL; | ||
| 134 | |||
| 135 | ret = cpufreq_frequency_table_cpuinfo(policy, freq_table); | 130 | ret = cpufreq_frequency_table_cpuinfo(policy, freq_table); |
| 136 | if (ret) { | 131 | if (ret) { |
| 137 | pr_err("invalid frequency table: %d\n", ret); | 132 | pr_err("invalid frequency table: %d\n", ret); |
| @@ -262,6 +257,7 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) | |||
| 262 | } | 257 | } |
| 263 | 258 | ||
| 264 | of_node_put(np); | 259 | of_node_put(np); |
| 260 | of_node_put(parent); | ||
| 265 | return 0; | 261 | return 0; |
| 266 | 262 | ||
| 267 | out_free_table: | 263 | out_free_table: |
diff --git a/drivers/cpufreq/cpufreq-nforce2.c b/drivers/cpufreq/cpufreq-nforce2.c index 13d311ee08b3..af1542d41440 100644 --- a/drivers/cpufreq/cpufreq-nforce2.c +++ b/drivers/cpufreq/cpufreq-nforce2.c | |||
| @@ -263,7 +263,6 @@ static int nforce2_target(struct cpufreq_policy *policy, | |||
| 263 | 263 | ||
| 264 | freqs.old = nforce2_get(policy->cpu); | 264 | freqs.old = nforce2_get(policy->cpu); |
| 265 | freqs.new = target_fsb * fid * 100; | 265 | freqs.new = target_fsb * fid * 100; |
| 266 | freqs.cpu = 0; /* Only one CPU on nForce2 platforms */ | ||
| 267 | 266 | ||
| 268 | if (freqs.old == freqs.new) | 267 | if (freqs.old == freqs.new) |
| 269 | return 0; | 268 | return 0; |
| @@ -271,7 +270,7 @@ static int nforce2_target(struct cpufreq_policy *policy, | |||
| 271 | pr_debug("Old CPU frequency %d kHz, new %d kHz\n", | 270 | pr_debug("Old CPU frequency %d kHz, new %d kHz\n", |
| 272 | freqs.old, freqs.new); | 271 | freqs.old, freqs.new); |
| 273 | 272 | ||
| 274 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 273 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 275 | 274 | ||
| 276 | /* Disable IRQs */ | 275 | /* Disable IRQs */ |
| 277 | /* local_irq_save(flags); */ | 276 | /* local_irq_save(flags); */ |
| @@ -286,7 +285,7 @@ static int nforce2_target(struct cpufreq_policy *policy, | |||
| 286 | /* Enable IRQs */ | 285 | /* Enable IRQs */ |
| 287 | /* local_irq_restore(flags); */ | 286 | /* local_irq_restore(flags); */ |
| 288 | 287 | ||
| 289 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 288 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 290 | 289 | ||
| 291 | return 0; | 290 | return 0; |
| 292 | } | 291 | } |
| @@ -360,12 +359,10 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy) | |||
| 360 | min_fsb = NFORCE2_MIN_FSB; | 359 | min_fsb = NFORCE2_MIN_FSB; |
| 361 | 360 | ||
| 362 | /* cpuinfo and default policy values */ | 361 | /* cpuinfo and default policy values */ |
| 363 | policy->cpuinfo.min_freq = min_fsb * fid * 100; | 362 | policy->min = policy->cpuinfo.min_freq = min_fsb * fid * 100; |
| 364 | policy->cpuinfo.max_freq = max_fsb * fid * 100; | 363 | policy->max = policy->cpuinfo.max_freq = max_fsb * fid * 100; |
| 365 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 364 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
| 366 | policy->cur = nforce2_get(policy->cpu); | 365 | policy->cur = nforce2_get(policy->cpu); |
| 367 | policy->min = policy->cpuinfo.min_freq; | ||
| 368 | policy->max = policy->cpuinfo.max_freq; | ||
| 369 | 366 | ||
| 370 | return 0; | 367 | return 0; |
| 371 | } | 368 | } |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b02824d092e7..1b8a48eaf90f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
| @@ -45,7 +45,7 @@ static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); | |||
| 45 | /* This one keeps track of the previously set governor of a removed CPU */ | 45 | /* This one keeps track of the previously set governor of a removed CPU */ |
| 46 | static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); | 46 | static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); |
| 47 | #endif | 47 | #endif |
| 48 | static DEFINE_SPINLOCK(cpufreq_driver_lock); | 48 | static DEFINE_RWLOCK(cpufreq_driver_lock); |
| 49 | 49 | ||
| 50 | /* | 50 | /* |
| 51 | * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure | 51 | * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure |
| @@ -128,6 +128,11 @@ void disable_cpufreq(void) | |||
| 128 | static LIST_HEAD(cpufreq_governor_list); | 128 | static LIST_HEAD(cpufreq_governor_list); |
| 129 | static DEFINE_MUTEX(cpufreq_governor_mutex); | 129 | static DEFINE_MUTEX(cpufreq_governor_mutex); |
| 130 | 130 | ||
| 131 | bool have_governor_per_policy(void) | ||
| 132 | { | ||
| 133 | return cpufreq_driver->have_governor_per_policy; | ||
| 134 | } | ||
| 135 | |||
| 131 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | 136 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) |
| 132 | { | 137 | { |
| 133 | struct cpufreq_policy *data; | 138 | struct cpufreq_policy *data; |
| @@ -137,7 +142,7 @@ static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | |||
| 137 | goto err_out; | 142 | goto err_out; |
| 138 | 143 | ||
| 139 | /* get the cpufreq driver */ | 144 | /* get the cpufreq driver */ |
| 140 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 145 | read_lock_irqsave(&cpufreq_driver_lock, flags); |
| 141 | 146 | ||
| 142 | if (!cpufreq_driver) | 147 | if (!cpufreq_driver) |
| 143 | goto err_out_unlock; | 148 | goto err_out_unlock; |
| @@ -155,13 +160,13 @@ static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | |||
| 155 | if (!sysfs && !kobject_get(&data->kobj)) | 160 | if (!sysfs && !kobject_get(&data->kobj)) |
| 156 | goto err_out_put_module; | 161 | goto err_out_put_module; |
| 157 | 162 | ||
| 158 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 163 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 159 | return data; | 164 | return data; |
| 160 | 165 | ||
| 161 | err_out_put_module: | 166 | err_out_put_module: |
| 162 | module_put(cpufreq_driver->owner); | 167 | module_put(cpufreq_driver->owner); |
| 163 | err_out_unlock: | 168 | err_out_unlock: |
| 164 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 169 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 165 | err_out: | 170 | err_out: |
| 166 | return NULL; | 171 | return NULL; |
| 167 | } | 172 | } |
| @@ -244,19 +249,9 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) | |||
| 244 | #endif | 249 | #endif |
| 245 | 250 | ||
| 246 | 251 | ||
| 247 | /** | 252 | void __cpufreq_notify_transition(struct cpufreq_policy *policy, |
| 248 | * cpufreq_notify_transition - call notifier chain and adjust_jiffies | 253 | struct cpufreq_freqs *freqs, unsigned int state) |
| 249 | * on frequency transition. | ||
| 250 | * | ||
| 251 | * This function calls the transition notifiers and the "adjust_jiffies" | ||
| 252 | * function. It is called twice on all CPU frequency changes that have | ||
| 253 | * external effects. | ||
| 254 | */ | ||
| 255 | void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) | ||
| 256 | { | 254 | { |
| 257 | struct cpufreq_policy *policy; | ||
| 258 | unsigned long flags; | ||
| 259 | |||
| 260 | BUG_ON(irqs_disabled()); | 255 | BUG_ON(irqs_disabled()); |
| 261 | 256 | ||
| 262 | if (cpufreq_disabled()) | 257 | if (cpufreq_disabled()) |
| @@ -266,10 +261,6 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) | |||
| 266 | pr_debug("notification %u of frequency transition to %u kHz\n", | 261 | pr_debug("notification %u of frequency transition to %u kHz\n", |
| 267 | state, freqs->new); | 262 | state, freqs->new); |
| 268 | 263 | ||
| 269 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | ||
| 270 | policy = per_cpu(cpufreq_cpu_data, freqs->cpu); | ||
| 271 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
| 272 | |||
| 273 | switch (state) { | 264 | switch (state) { |
| 274 | 265 | ||
| 275 | case CPUFREQ_PRECHANGE: | 266 | case CPUFREQ_PRECHANGE: |
| @@ -303,6 +294,20 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) | |||
| 303 | break; | 294 | break; |
| 304 | } | 295 | } |
| 305 | } | 296 | } |
| 297 | /** | ||
| 298 | * cpufreq_notify_transition - call notifier chain and adjust_jiffies | ||
| 299 | * on frequency transition. | ||
| 300 | * | ||
| 301 | * This function calls the transition notifiers and the "adjust_jiffies" | ||
| 302 | * function. It is called twice on all CPU frequency changes that have | ||
| 303 | * external effects. | ||
| 304 | */ | ||
| 305 | void cpufreq_notify_transition(struct cpufreq_policy *policy, | ||
| 306 | struct cpufreq_freqs *freqs, unsigned int state) | ||
| 307 | { | ||
| 308 | for_each_cpu(freqs->cpu, policy->cpus) | ||
| 309 | __cpufreq_notify_transition(policy, freqs, state); | ||
| 310 | } | ||
| 306 | EXPORT_SYMBOL_GPL(cpufreq_notify_transition); | 311 | EXPORT_SYMBOL_GPL(cpufreq_notify_transition); |
| 307 | 312 | ||
| 308 | 313 | ||
| @@ -765,12 +770,12 @@ static int cpufreq_add_dev_interface(unsigned int cpu, | |||
| 765 | goto err_out_kobj_put; | 770 | goto err_out_kobj_put; |
| 766 | } | 771 | } |
| 767 | 772 | ||
| 768 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 773 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
| 769 | for_each_cpu(j, policy->cpus) { | 774 | for_each_cpu(j, policy->cpus) { |
| 770 | per_cpu(cpufreq_cpu_data, j) = policy; | 775 | per_cpu(cpufreq_cpu_data, j) = policy; |
| 771 | per_cpu(cpufreq_policy_cpu, j) = policy->cpu; | 776 | per_cpu(cpufreq_policy_cpu, j) = policy->cpu; |
| 772 | } | 777 | } |
| 773 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 778 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 774 | 779 | ||
| 775 | ret = cpufreq_add_dev_symlink(cpu, policy); | 780 | ret = cpufreq_add_dev_symlink(cpu, policy); |
| 776 | if (ret) | 781 | if (ret) |
| @@ -803,27 +808,30 @@ static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling, | |||
| 803 | struct device *dev) | 808 | struct device *dev) |
| 804 | { | 809 | { |
| 805 | struct cpufreq_policy *policy; | 810 | struct cpufreq_policy *policy; |
| 806 | int ret = 0; | 811 | int ret = 0, has_target = !!cpufreq_driver->target; |
| 807 | unsigned long flags; | 812 | unsigned long flags; |
| 808 | 813 | ||
| 809 | policy = cpufreq_cpu_get(sibling); | 814 | policy = cpufreq_cpu_get(sibling); |
| 810 | WARN_ON(!policy); | 815 | WARN_ON(!policy); |
| 811 | 816 | ||
| 812 | __cpufreq_governor(policy, CPUFREQ_GOV_STOP); | 817 | if (has_target) |
| 818 | __cpufreq_governor(policy, CPUFREQ_GOV_STOP); | ||
| 813 | 819 | ||
| 814 | lock_policy_rwsem_write(sibling); | 820 | lock_policy_rwsem_write(sibling); |
| 815 | 821 | ||
| 816 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 822 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
| 817 | 823 | ||
| 818 | cpumask_set_cpu(cpu, policy->cpus); | 824 | cpumask_set_cpu(cpu, policy->cpus); |
| 819 | per_cpu(cpufreq_policy_cpu, cpu) = policy->cpu; | 825 | per_cpu(cpufreq_policy_cpu, cpu) = policy->cpu; |
| 820 | per_cpu(cpufreq_cpu_data, cpu) = policy; | 826 | per_cpu(cpufreq_cpu_data, cpu) = policy; |
| 821 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 827 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 822 | 828 | ||
| 823 | unlock_policy_rwsem_write(sibling); | 829 | unlock_policy_rwsem_write(sibling); |
| 824 | 830 | ||
| 825 | __cpufreq_governor(policy, CPUFREQ_GOV_START); | 831 | if (has_target) { |
| 826 | __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | 832 | __cpufreq_governor(policy, CPUFREQ_GOV_START); |
| 833 | __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); | ||
| 834 | } | ||
| 827 | 835 | ||
| 828 | ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); | 836 | ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); |
| 829 | if (ret) { | 837 | if (ret) { |
| @@ -871,15 +879,15 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | |||
| 871 | 879 | ||
| 872 | #ifdef CONFIG_HOTPLUG_CPU | 880 | #ifdef CONFIG_HOTPLUG_CPU |
| 873 | /* Check if this cpu was hot-unplugged earlier and has siblings */ | 881 | /* Check if this cpu was hot-unplugged earlier and has siblings */ |
| 874 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 882 | read_lock_irqsave(&cpufreq_driver_lock, flags); |
| 875 | for_each_online_cpu(sibling) { | 883 | for_each_online_cpu(sibling) { |
| 876 | struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling); | 884 | struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling); |
| 877 | if (cp && cpumask_test_cpu(cpu, cp->related_cpus)) { | 885 | if (cp && cpumask_test_cpu(cpu, cp->related_cpus)) { |
| 878 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 886 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 879 | return cpufreq_add_policy_cpu(cpu, sibling, dev); | 887 | return cpufreq_add_policy_cpu(cpu, sibling, dev); |
| 880 | } | 888 | } |
| 881 | } | 889 | } |
| 882 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 890 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 883 | #endif | 891 | #endif |
| 884 | #endif | 892 | #endif |
| 885 | 893 | ||
| @@ -952,10 +960,10 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | |||
| 952 | return 0; | 960 | return 0; |
| 953 | 961 | ||
| 954 | err_out_unregister: | 962 | err_out_unregister: |
| 955 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 963 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
| 956 | for_each_cpu(j, policy->cpus) | 964 | for_each_cpu(j, policy->cpus) |
| 957 | per_cpu(cpufreq_cpu_data, j) = NULL; | 965 | per_cpu(cpufreq_cpu_data, j) = NULL; |
| 958 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 966 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 959 | 967 | ||
| 960 | kobject_put(&policy->kobj); | 968 | kobject_put(&policy->kobj); |
| 961 | wait_for_completion(&policy->kobj_unregister); | 969 | wait_for_completion(&policy->kobj_unregister); |
| @@ -1008,12 +1016,12 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif | |||
| 1008 | 1016 | ||
| 1009 | pr_debug("%s: unregistering CPU %u\n", __func__, cpu); | 1017 | pr_debug("%s: unregistering CPU %u\n", __func__, cpu); |
| 1010 | 1018 | ||
| 1011 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 1019 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
| 1012 | 1020 | ||
| 1013 | data = per_cpu(cpufreq_cpu_data, cpu); | 1021 | data = per_cpu(cpufreq_cpu_data, cpu); |
| 1014 | per_cpu(cpufreq_cpu_data, cpu) = NULL; | 1022 | per_cpu(cpufreq_cpu_data, cpu) = NULL; |
| 1015 | 1023 | ||
| 1016 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1024 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 1017 | 1025 | ||
| 1018 | if (!data) { | 1026 | if (!data) { |
| 1019 | pr_debug("%s: No cpu_data found\n", __func__); | 1027 | pr_debug("%s: No cpu_data found\n", __func__); |
| @@ -1031,7 +1039,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif | |||
| 1031 | 1039 | ||
| 1032 | WARN_ON(lock_policy_rwsem_write(cpu)); | 1040 | WARN_ON(lock_policy_rwsem_write(cpu)); |
| 1033 | cpus = cpumask_weight(data->cpus); | 1041 | cpus = cpumask_weight(data->cpus); |
| 1034 | cpumask_clear_cpu(cpu, data->cpus); | 1042 | |
| 1043 | if (cpus > 1) | ||
| 1044 | cpumask_clear_cpu(cpu, data->cpus); | ||
| 1035 | unlock_policy_rwsem_write(cpu); | 1045 | unlock_policy_rwsem_write(cpu); |
| 1036 | 1046 | ||
| 1037 | if (cpu != data->cpu) { | 1047 | if (cpu != data->cpu) { |
| @@ -1047,9 +1057,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif | |||
| 1047 | WARN_ON(lock_policy_rwsem_write(cpu)); | 1057 | WARN_ON(lock_policy_rwsem_write(cpu)); |
| 1048 | cpumask_set_cpu(cpu, data->cpus); | 1058 | cpumask_set_cpu(cpu, data->cpus); |
| 1049 | 1059 | ||
| 1050 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 1060 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
| 1051 | per_cpu(cpufreq_cpu_data, cpu) = data; | 1061 | per_cpu(cpufreq_cpu_data, cpu) = data; |
| 1052 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1062 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 1053 | 1063 | ||
| 1054 | unlock_policy_rwsem_write(cpu); | 1064 | unlock_policy_rwsem_write(cpu); |
| 1055 | 1065 | ||
| @@ -1070,6 +1080,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif | |||
| 1070 | 1080 | ||
| 1071 | /* If cpu is last user of policy, free policy */ | 1081 | /* If cpu is last user of policy, free policy */ |
| 1072 | if (cpus == 1) { | 1082 | if (cpus == 1) { |
| 1083 | if (cpufreq_driver->target) | ||
| 1084 | __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); | ||
| 1085 | |||
| 1073 | lock_policy_rwsem_read(cpu); | 1086 | lock_policy_rwsem_read(cpu); |
| 1074 | kobj = &data->kobj; | 1087 | kobj = &data->kobj; |
| 1075 | cmp = &data->kobj_unregister; | 1088 | cmp = &data->kobj_unregister; |
| @@ -1134,16 +1147,23 @@ static void handle_update(struct work_struct *work) | |||
| 1134 | static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, | 1147 | static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, |
| 1135 | unsigned int new_freq) | 1148 | unsigned int new_freq) |
| 1136 | { | 1149 | { |
| 1150 | struct cpufreq_policy *policy; | ||
| 1137 | struct cpufreq_freqs freqs; | 1151 | struct cpufreq_freqs freqs; |
| 1152 | unsigned long flags; | ||
| 1153 | |||
| 1138 | 1154 | ||
| 1139 | pr_debug("Warning: CPU frequency out of sync: cpufreq and timing " | 1155 | pr_debug("Warning: CPU frequency out of sync: cpufreq and timing " |
| 1140 | "core thinks of %u, is %u kHz.\n", old_freq, new_freq); | 1156 | "core thinks of %u, is %u kHz.\n", old_freq, new_freq); |
| 1141 | 1157 | ||
| 1142 | freqs.cpu = cpu; | ||
| 1143 | freqs.old = old_freq; | 1158 | freqs.old = old_freq; |
| 1144 | freqs.new = new_freq; | 1159 | freqs.new = new_freq; |
| 1145 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 1160 | |
| 1146 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 1161 | read_lock_irqsave(&cpufreq_driver_lock, flags); |
| 1162 | policy = per_cpu(cpufreq_cpu_data, cpu); | ||
| 1163 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); | ||
| 1164 | |||
| 1165 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
| 1166 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
| 1147 | } | 1167 | } |
| 1148 | 1168 | ||
| 1149 | 1169 | ||
| @@ -1544,10 +1564,12 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
| 1544 | policy->cpu, event); | 1564 | policy->cpu, event); |
| 1545 | ret = policy->governor->governor(policy, event); | 1565 | ret = policy->governor->governor(policy, event); |
| 1546 | 1566 | ||
| 1547 | if (event == CPUFREQ_GOV_START) | 1567 | if (!ret) { |
| 1548 | policy->governor->initialized++; | 1568 | if (event == CPUFREQ_GOV_POLICY_INIT) |
| 1549 | else if (event == CPUFREQ_GOV_STOP) | 1569 | policy->governor->initialized++; |
| 1550 | policy->governor->initialized--; | 1570 | else if (event == CPUFREQ_GOV_POLICY_EXIT) |
| 1571 | policy->governor->initialized--; | ||
| 1572 | } | ||
| 1551 | 1573 | ||
| 1552 | /* we keep one module reference alive for | 1574 | /* we keep one module reference alive for |
| 1553 | each CPU governed by this CPU */ | 1575 | each CPU governed by this CPU */ |
| @@ -1651,7 +1673,7 @@ EXPORT_SYMBOL(cpufreq_get_policy); | |||
| 1651 | static int __cpufreq_set_policy(struct cpufreq_policy *data, | 1673 | static int __cpufreq_set_policy(struct cpufreq_policy *data, |
| 1652 | struct cpufreq_policy *policy) | 1674 | struct cpufreq_policy *policy) |
| 1653 | { | 1675 | { |
| 1654 | int ret = 0; | 1676 | int ret = 0, failed = 1; |
| 1655 | 1677 | ||
| 1656 | pr_debug("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu, | 1678 | pr_debug("setting new policy for CPU %u: %u - %u kHz\n", policy->cpu, |
| 1657 | policy->min, policy->max); | 1679 | policy->min, policy->max); |
| @@ -1705,18 +1727,31 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, | |||
| 1705 | pr_debug("governor switch\n"); | 1727 | pr_debug("governor switch\n"); |
| 1706 | 1728 | ||
| 1707 | /* end old governor */ | 1729 | /* end old governor */ |
| 1708 | if (data->governor) | 1730 | if (data->governor) { |
| 1709 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 1731 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); |
| 1732 | __cpufreq_governor(data, | ||
| 1733 | CPUFREQ_GOV_POLICY_EXIT); | ||
| 1734 | } | ||
| 1710 | 1735 | ||
| 1711 | /* start new governor */ | 1736 | /* start new governor */ |
| 1712 | data->governor = policy->governor; | 1737 | data->governor = policy->governor; |
| 1713 | if (__cpufreq_governor(data, CPUFREQ_GOV_START)) { | 1738 | if (!__cpufreq_governor(data, CPUFREQ_GOV_POLICY_INIT)) { |
| 1739 | if (!__cpufreq_governor(data, CPUFREQ_GOV_START)) | ||
| 1740 | failed = 0; | ||
| 1741 | else | ||
| 1742 | __cpufreq_governor(data, | ||
| 1743 | CPUFREQ_GOV_POLICY_EXIT); | ||
| 1744 | } | ||
| 1745 | |||
| 1746 | if (failed) { | ||
| 1714 | /* new governor failed, so re-start old one */ | 1747 | /* new governor failed, so re-start old one */ |
| 1715 | pr_debug("starting governor %s failed\n", | 1748 | pr_debug("starting governor %s failed\n", |
| 1716 | data->governor->name); | 1749 | data->governor->name); |
| 1717 | if (old_gov) { | 1750 | if (old_gov) { |
| 1718 | data->governor = old_gov; | 1751 | data->governor = old_gov; |
| 1719 | __cpufreq_governor(data, | 1752 | __cpufreq_governor(data, |
| 1753 | CPUFREQ_GOV_POLICY_INIT); | ||
| 1754 | __cpufreq_governor(data, | ||
| 1720 | CPUFREQ_GOV_START); | 1755 | CPUFREQ_GOV_START); |
| 1721 | } | 1756 | } |
| 1722 | ret = -EINVAL; | 1757 | ret = -EINVAL; |
| @@ -1848,13 +1883,13 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
| 1848 | if (driver_data->setpolicy) | 1883 | if (driver_data->setpolicy) |
| 1849 | driver_data->flags |= CPUFREQ_CONST_LOOPS; | 1884 | driver_data->flags |= CPUFREQ_CONST_LOOPS; |
| 1850 | 1885 | ||
| 1851 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 1886 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
| 1852 | if (cpufreq_driver) { | 1887 | if (cpufreq_driver) { |
| 1853 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1888 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 1854 | return -EBUSY; | 1889 | return -EBUSY; |
| 1855 | } | 1890 | } |
| 1856 | cpufreq_driver = driver_data; | 1891 | cpufreq_driver = driver_data; |
| 1857 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1892 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 1858 | 1893 | ||
| 1859 | ret = subsys_interface_register(&cpufreq_interface); | 1894 | ret = subsys_interface_register(&cpufreq_interface); |
| 1860 | if (ret) | 1895 | if (ret) |
| @@ -1886,9 +1921,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
| 1886 | err_if_unreg: | 1921 | err_if_unreg: |
| 1887 | subsys_interface_unregister(&cpufreq_interface); | 1922 | subsys_interface_unregister(&cpufreq_interface); |
| 1888 | err_null_driver: | 1923 | err_null_driver: |
| 1889 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 1924 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
| 1890 | cpufreq_driver = NULL; | 1925 | cpufreq_driver = NULL; |
| 1891 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1926 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 1892 | return ret; | 1927 | return ret; |
| 1893 | } | 1928 | } |
| 1894 | EXPORT_SYMBOL_GPL(cpufreq_register_driver); | 1929 | EXPORT_SYMBOL_GPL(cpufreq_register_driver); |
| @@ -1914,9 +1949,9 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) | |||
| 1914 | subsys_interface_unregister(&cpufreq_interface); | 1949 | subsys_interface_unregister(&cpufreq_interface); |
| 1915 | unregister_hotcpu_notifier(&cpufreq_cpu_notifier); | 1950 | unregister_hotcpu_notifier(&cpufreq_cpu_notifier); |
| 1916 | 1951 | ||
| 1917 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 1952 | write_lock_irqsave(&cpufreq_driver_lock, flags); |
| 1918 | cpufreq_driver = NULL; | 1953 | cpufreq_driver = NULL; |
| 1919 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1954 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 1920 | 1955 | ||
| 1921 | return 0; | 1956 | return 0; |
| 1922 | } | 1957 | } |
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 4fd0006b1291..0ceb2eff5a7e 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/mutex.h> | 20 | #include <linux/mutex.h> |
| 21 | #include <linux/notifier.h> | 21 | #include <linux/notifier.h> |
| 22 | #include <linux/percpu-defs.h> | 22 | #include <linux/percpu-defs.h> |
| 23 | #include <linux/slab.h> | ||
| 23 | #include <linux/sysfs.h> | 24 | #include <linux/sysfs.h> |
| 24 | #include <linux/types.h> | 25 | #include <linux/types.h> |
| 25 | 26 | ||
| @@ -28,25 +29,29 @@ | |||
| 28 | /* Conservative governor macros */ | 29 | /* Conservative governor macros */ |
| 29 | #define DEF_FREQUENCY_UP_THRESHOLD (80) | 30 | #define DEF_FREQUENCY_UP_THRESHOLD (80) |
| 30 | #define DEF_FREQUENCY_DOWN_THRESHOLD (20) | 31 | #define DEF_FREQUENCY_DOWN_THRESHOLD (20) |
| 32 | #define DEF_FREQUENCY_STEP (5) | ||
| 31 | #define DEF_SAMPLING_DOWN_FACTOR (1) | 33 | #define DEF_SAMPLING_DOWN_FACTOR (1) |
| 32 | #define MAX_SAMPLING_DOWN_FACTOR (10) | 34 | #define MAX_SAMPLING_DOWN_FACTOR (10) |
| 33 | 35 | ||
| 34 | static struct dbs_data cs_dbs_data; | ||
| 35 | static DEFINE_PER_CPU(struct cs_cpu_dbs_info_s, cs_cpu_dbs_info); | 36 | static DEFINE_PER_CPU(struct cs_cpu_dbs_info_s, cs_cpu_dbs_info); |
| 36 | 37 | ||
| 37 | static struct cs_dbs_tuners cs_tuners = { | 38 | static inline unsigned int get_freq_target(struct cs_dbs_tuners *cs_tuners, |
| 38 | .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, | 39 | struct cpufreq_policy *policy) |
| 39 | .down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD, | 40 | { |
| 40 | .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, | 41 | unsigned int freq_target = (cs_tuners->freq_step * policy->max) / 100; |
| 41 | .ignore_nice = 0, | 42 | |
| 42 | .freq_step = 5, | 43 | /* max freq cannot be less than 100. But who knows... */ |
| 43 | }; | 44 | if (unlikely(freq_target == 0)) |
| 45 | freq_target = DEF_FREQUENCY_STEP; | ||
| 46 | |||
| 47 | return freq_target; | ||
| 48 | } | ||
| 44 | 49 | ||
| 45 | /* | 50 | /* |
| 46 | * Every sampling_rate, we check, if current idle time is less than 20% | 51 | * Every sampling_rate, we check, if current idle time is less than 20% |
| 47 | * (default), then we try to increase frequency Every sampling_rate * | 52 | * (default), then we try to increase frequency. Every sampling_rate * |
| 48 | * sampling_down_factor, we check, if current idle time is more than 80%, then | 53 | * sampling_down_factor, we check, if current idle time is more than 80% |
| 49 | * we try to decrease frequency | 54 | * (default), then we try to decrease frequency |
| 50 | * | 55 | * |
| 51 | * Any frequency increase takes it to the maximum frequency. Frequency reduction | 56 | * Any frequency increase takes it to the maximum frequency. Frequency reduction |
| 52 | * happens at minimum steps of 5% (default) of maximum frequency | 57 | * happens at minimum steps of 5% (default) of maximum frequency |
| @@ -55,30 +60,25 @@ static void cs_check_cpu(int cpu, unsigned int load) | |||
| 55 | { | 60 | { |
| 56 | struct cs_cpu_dbs_info_s *dbs_info = &per_cpu(cs_cpu_dbs_info, cpu); | 61 | struct cs_cpu_dbs_info_s *dbs_info = &per_cpu(cs_cpu_dbs_info, cpu); |
| 57 | struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy; | 62 | struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy; |
| 58 | unsigned int freq_target; | 63 | struct dbs_data *dbs_data = policy->governor_data; |
| 64 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | ||
| 59 | 65 | ||
| 60 | /* | 66 | /* |
| 61 | * break out if we 'cannot' reduce the speed as the user might | 67 | * break out if we 'cannot' reduce the speed as the user might |
| 62 | * want freq_step to be zero | 68 | * want freq_step to be zero |
| 63 | */ | 69 | */ |
| 64 | if (cs_tuners.freq_step == 0) | 70 | if (cs_tuners->freq_step == 0) |
| 65 | return; | 71 | return; |
| 66 | 72 | ||
| 67 | /* Check for frequency increase */ | 73 | /* Check for frequency increase */ |
| 68 | if (load > cs_tuners.up_threshold) { | 74 | if (load > cs_tuners->up_threshold) { |
| 69 | dbs_info->down_skip = 0; | 75 | dbs_info->down_skip = 0; |
| 70 | 76 | ||
| 71 | /* if we are already at full speed then break out early */ | 77 | /* if we are already at full speed then break out early */ |
| 72 | if (dbs_info->requested_freq == policy->max) | 78 | if (dbs_info->requested_freq == policy->max) |
| 73 | return; | 79 | return; |
| 74 | 80 | ||
| 75 | freq_target = (cs_tuners.freq_step * policy->max) / 100; | 81 | dbs_info->requested_freq += get_freq_target(cs_tuners, policy); |
| 76 | |||
| 77 | /* max freq cannot be less than 100. But who knows.... */ | ||
| 78 | if (unlikely(freq_target == 0)) | ||
| 79 | freq_target = 5; | ||
| 80 | |||
| 81 | dbs_info->requested_freq += freq_target; | ||
| 82 | if (dbs_info->requested_freq > policy->max) | 82 | if (dbs_info->requested_freq > policy->max) |
| 83 | dbs_info->requested_freq = policy->max; | 83 | dbs_info->requested_freq = policy->max; |
| 84 | 84 | ||
| @@ -87,45 +87,48 @@ static void cs_check_cpu(int cpu, unsigned int load) | |||
| 87 | return; | 87 | return; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | /* | 90 | /* if sampling_down_factor is active break out early */ |
| 91 | * The optimal frequency is the frequency that is the lowest that can | 91 | if (++dbs_info->down_skip < cs_tuners->sampling_down_factor) |
| 92 | * support the current CPU usage without triggering the up policy. To be | 92 | return; |
| 93 | * safe, we focus 10 points under the threshold. | 93 | dbs_info->down_skip = 0; |
| 94 | */ | ||
| 95 | if (load < (cs_tuners.down_threshold - 10)) { | ||
| 96 | freq_target = (cs_tuners.freq_step * policy->max) / 100; | ||
| 97 | |||
| 98 | dbs_info->requested_freq -= freq_target; | ||
| 99 | if (dbs_info->requested_freq < policy->min) | ||
| 100 | dbs_info->requested_freq = policy->min; | ||
| 101 | 94 | ||
| 95 | /* Check for frequency decrease */ | ||
| 96 | if (load < cs_tuners->down_threshold) { | ||
| 102 | /* | 97 | /* |
| 103 | * if we cannot reduce the frequency anymore, break out early | 98 | * if we cannot reduce the frequency anymore, break out early |
| 104 | */ | 99 | */ |
| 105 | if (policy->cur == policy->min) | 100 | if (policy->cur == policy->min) |
| 106 | return; | 101 | return; |
| 107 | 102 | ||
| 103 | dbs_info->requested_freq -= get_freq_target(cs_tuners, policy); | ||
| 104 | if (dbs_info->requested_freq < policy->min) | ||
| 105 | dbs_info->requested_freq = policy->min; | ||
| 106 | |||
| 108 | __cpufreq_driver_target(policy, dbs_info->requested_freq, | 107 | __cpufreq_driver_target(policy, dbs_info->requested_freq, |
| 109 | CPUFREQ_RELATION_H); | 108 | CPUFREQ_RELATION_L); |
| 110 | return; | 109 | return; |
| 111 | } | 110 | } |
| 112 | } | 111 | } |
| 113 | 112 | ||
| 114 | static void cs_dbs_timer(struct work_struct *work) | 113 | static void cs_dbs_timer(struct work_struct *work) |
| 115 | { | 114 | { |
| 116 | struct delayed_work *dw = to_delayed_work(work); | ||
| 117 | struct cs_cpu_dbs_info_s *dbs_info = container_of(work, | 115 | struct cs_cpu_dbs_info_s *dbs_info = container_of(work, |
| 118 | struct cs_cpu_dbs_info_s, cdbs.work.work); | 116 | struct cs_cpu_dbs_info_s, cdbs.work.work); |
| 119 | unsigned int cpu = dbs_info->cdbs.cur_policy->cpu; | 117 | unsigned int cpu = dbs_info->cdbs.cur_policy->cpu; |
| 120 | struct cs_cpu_dbs_info_s *core_dbs_info = &per_cpu(cs_cpu_dbs_info, | 118 | struct cs_cpu_dbs_info_s *core_dbs_info = &per_cpu(cs_cpu_dbs_info, |
| 121 | cpu); | 119 | cpu); |
| 122 | int delay = delay_for_sampling_rate(cs_tuners.sampling_rate); | 120 | struct dbs_data *dbs_data = dbs_info->cdbs.cur_policy->governor_data; |
| 121 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | ||
| 122 | int delay = delay_for_sampling_rate(cs_tuners->sampling_rate); | ||
| 123 | bool modify_all = true; | ||
| 123 | 124 | ||
| 124 | mutex_lock(&core_dbs_info->cdbs.timer_mutex); | 125 | mutex_lock(&core_dbs_info->cdbs.timer_mutex); |
| 125 | if (need_load_eval(&core_dbs_info->cdbs, cs_tuners.sampling_rate)) | 126 | if (!need_load_eval(&core_dbs_info->cdbs, cs_tuners->sampling_rate)) |
| 126 | dbs_check_cpu(&cs_dbs_data, cpu); | 127 | modify_all = false; |
| 128 | else | ||
| 129 | dbs_check_cpu(dbs_data, cpu); | ||
| 127 | 130 | ||
| 128 | schedule_delayed_work_on(smp_processor_id(), dw, delay); | 131 | gov_queue_work(dbs_data, dbs_info->cdbs.cur_policy, delay, modify_all); |
| 129 | mutex_unlock(&core_dbs_info->cdbs.timer_mutex); | 132 | mutex_unlock(&core_dbs_info->cdbs.timer_mutex); |
| 130 | } | 133 | } |
| 131 | 134 | ||
| @@ -154,16 +157,12 @@ static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val, | |||
| 154 | } | 157 | } |
| 155 | 158 | ||
| 156 | /************************** sysfs interface ************************/ | 159 | /************************** sysfs interface ************************/ |
| 157 | static ssize_t show_sampling_rate_min(struct kobject *kobj, | 160 | static struct common_dbs_data cs_dbs_cdata; |
| 158 | struct attribute *attr, char *buf) | ||
| 159 | { | ||
| 160 | return sprintf(buf, "%u\n", cs_dbs_data.min_sampling_rate); | ||
| 161 | } | ||
| 162 | 161 | ||
| 163 | static ssize_t store_sampling_down_factor(struct kobject *a, | 162 | static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data, |
| 164 | struct attribute *b, | 163 | const char *buf, size_t count) |
| 165 | const char *buf, size_t count) | ||
| 166 | { | 164 | { |
| 165 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | ||
| 167 | unsigned int input; | 166 | unsigned int input; |
| 168 | int ret; | 167 | int ret; |
| 169 | ret = sscanf(buf, "%u", &input); | 168 | ret = sscanf(buf, "%u", &input); |
| @@ -171,13 +170,14 @@ static ssize_t store_sampling_down_factor(struct kobject *a, | |||
| 171 | if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1) | 170 | if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1) |
| 172 | return -EINVAL; | 171 | return -EINVAL; |
| 173 | 172 | ||
| 174 | cs_tuners.sampling_down_factor = input; | 173 | cs_tuners->sampling_down_factor = input; |
| 175 | return count; | 174 | return count; |
| 176 | } | 175 | } |
| 177 | 176 | ||
| 178 | static ssize_t store_sampling_rate(struct kobject *a, struct attribute *b, | 177 | static ssize_t store_sampling_rate(struct dbs_data *dbs_data, const char *buf, |
| 179 | const char *buf, size_t count) | 178 | size_t count) |
| 180 | { | 179 | { |
| 180 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | ||
| 181 | unsigned int input; | 181 | unsigned int input; |
| 182 | int ret; | 182 | int ret; |
| 183 | ret = sscanf(buf, "%u", &input); | 183 | ret = sscanf(buf, "%u", &input); |
| @@ -185,43 +185,46 @@ static ssize_t store_sampling_rate(struct kobject *a, struct attribute *b, | |||
| 185 | if (ret != 1) | 185 | if (ret != 1) |
| 186 | return -EINVAL; | 186 | return -EINVAL; |
| 187 | 187 | ||
| 188 | cs_tuners.sampling_rate = max(input, cs_dbs_data.min_sampling_rate); | 188 | cs_tuners->sampling_rate = max(input, dbs_data->min_sampling_rate); |
| 189 | return count; | 189 | return count; |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | static ssize_t store_up_threshold(struct kobject *a, struct attribute *b, | 192 | static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf, |
| 193 | const char *buf, size_t count) | 193 | size_t count) |
| 194 | { | 194 | { |
| 195 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | ||
| 195 | unsigned int input; | 196 | unsigned int input; |
| 196 | int ret; | 197 | int ret; |
| 197 | ret = sscanf(buf, "%u", &input); | 198 | ret = sscanf(buf, "%u", &input); |
| 198 | 199 | ||
| 199 | if (ret != 1 || input > 100 || input <= cs_tuners.down_threshold) | 200 | if (ret != 1 || input > 100 || input <= cs_tuners->down_threshold) |
| 200 | return -EINVAL; | 201 | return -EINVAL; |
| 201 | 202 | ||
| 202 | cs_tuners.up_threshold = input; | 203 | cs_tuners->up_threshold = input; |
| 203 | return count; | 204 | return count; |
| 204 | } | 205 | } |
| 205 | 206 | ||
| 206 | static ssize_t store_down_threshold(struct kobject *a, struct attribute *b, | 207 | static ssize_t store_down_threshold(struct dbs_data *dbs_data, const char *buf, |
| 207 | const char *buf, size_t count) | 208 | size_t count) |
| 208 | { | 209 | { |
| 210 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | ||
| 209 | unsigned int input; | 211 | unsigned int input; |
| 210 | int ret; | 212 | int ret; |
| 211 | ret = sscanf(buf, "%u", &input); | 213 | ret = sscanf(buf, "%u", &input); |
| 212 | 214 | ||
| 213 | /* cannot be lower than 11 otherwise freq will not fall */ | 215 | /* cannot be lower than 11 otherwise freq will not fall */ |
| 214 | if (ret != 1 || input < 11 || input > 100 || | 216 | if (ret != 1 || input < 11 || input > 100 || |
| 215 | input >= cs_tuners.up_threshold) | 217 | input >= cs_tuners->up_threshold) |
| 216 | return -EINVAL; | 218 | return -EINVAL; |
| 217 | 219 | ||
| 218 | cs_tuners.down_threshold = input; | 220 | cs_tuners->down_threshold = input; |
| 219 | return count; | 221 | return count; |
| 220 | } | 222 | } |
| 221 | 223 | ||
| 222 | static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | 224 | static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf, |
| 223 | const char *buf, size_t count) | 225 | size_t count) |
| 224 | { | 226 | { |
| 227 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | ||
| 225 | unsigned int input, j; | 228 | unsigned int input, j; |
| 226 | int ret; | 229 | int ret; |
| 227 | 230 | ||
| @@ -232,27 +235,28 @@ static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | |||
| 232 | if (input > 1) | 235 | if (input > 1) |
| 233 | input = 1; | 236 | input = 1; |
| 234 | 237 | ||
| 235 | if (input == cs_tuners.ignore_nice) /* nothing to do */ | 238 | if (input == cs_tuners->ignore_nice) /* nothing to do */ |
| 236 | return count; | 239 | return count; |
| 237 | 240 | ||
| 238 | cs_tuners.ignore_nice = input; | 241 | cs_tuners->ignore_nice = input; |
| 239 | 242 | ||
| 240 | /* we need to re-evaluate prev_cpu_idle */ | 243 | /* we need to re-evaluate prev_cpu_idle */ |
| 241 | for_each_online_cpu(j) { | 244 | for_each_online_cpu(j) { |
| 242 | struct cs_cpu_dbs_info_s *dbs_info; | 245 | struct cs_cpu_dbs_info_s *dbs_info; |
| 243 | dbs_info = &per_cpu(cs_cpu_dbs_info, j); | 246 | dbs_info = &per_cpu(cs_cpu_dbs_info, j); |
| 244 | dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j, | 247 | dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j, |
| 245 | &dbs_info->cdbs.prev_cpu_wall); | 248 | &dbs_info->cdbs.prev_cpu_wall, 0); |
| 246 | if (cs_tuners.ignore_nice) | 249 | if (cs_tuners->ignore_nice) |
| 247 | dbs_info->cdbs.prev_cpu_nice = | 250 | dbs_info->cdbs.prev_cpu_nice = |
| 248 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; | 251 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
| 249 | } | 252 | } |
| 250 | return count; | 253 | return count; |
| 251 | } | 254 | } |
| 252 | 255 | ||
| 253 | static ssize_t store_freq_step(struct kobject *a, struct attribute *b, | 256 | static ssize_t store_freq_step(struct dbs_data *dbs_data, const char *buf, |
| 254 | const char *buf, size_t count) | 257 | size_t count) |
| 255 | { | 258 | { |
| 259 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | ||
| 256 | unsigned int input; | 260 | unsigned int input; |
| 257 | int ret; | 261 | int ret; |
| 258 | ret = sscanf(buf, "%u", &input); | 262 | ret = sscanf(buf, "%u", &input); |
| @@ -267,43 +271,88 @@ static ssize_t store_freq_step(struct kobject *a, struct attribute *b, | |||
| 267 | * no need to test here if freq_step is zero as the user might actually | 271 | * no need to test here if freq_step is zero as the user might actually |
| 268 | * want this, they would be crazy though :) | 272 | * want this, they would be crazy though :) |
| 269 | */ | 273 | */ |
| 270 | cs_tuners.freq_step = input; | 274 | cs_tuners->freq_step = input; |
| 271 | return count; | 275 | return count; |
| 272 | } | 276 | } |
| 273 | 277 | ||
| 274 | show_one(cs, sampling_rate, sampling_rate); | 278 | show_store_one(cs, sampling_rate); |
| 275 | show_one(cs, sampling_down_factor, sampling_down_factor); | 279 | show_store_one(cs, sampling_down_factor); |
| 276 | show_one(cs, up_threshold, up_threshold); | 280 | show_store_one(cs, up_threshold); |
| 277 | show_one(cs, down_threshold, down_threshold); | 281 | show_store_one(cs, down_threshold); |
| 278 | show_one(cs, ignore_nice_load, ignore_nice); | 282 | show_store_one(cs, ignore_nice); |
| 279 | show_one(cs, freq_step, freq_step); | 283 | show_store_one(cs, freq_step); |
| 280 | 284 | declare_show_sampling_rate_min(cs); | |
| 281 | define_one_global_rw(sampling_rate); | 285 | |
| 282 | define_one_global_rw(sampling_down_factor); | 286 | gov_sys_pol_attr_rw(sampling_rate); |
| 283 | define_one_global_rw(up_threshold); | 287 | gov_sys_pol_attr_rw(sampling_down_factor); |
| 284 | define_one_global_rw(down_threshold); | 288 | gov_sys_pol_attr_rw(up_threshold); |
| 285 | define_one_global_rw(ignore_nice_load); | 289 | gov_sys_pol_attr_rw(down_threshold); |
| 286 | define_one_global_rw(freq_step); | 290 | gov_sys_pol_attr_rw(ignore_nice); |
| 287 | define_one_global_ro(sampling_rate_min); | 291 | gov_sys_pol_attr_rw(freq_step); |
| 288 | 292 | gov_sys_pol_attr_ro(sampling_rate_min); | |
| 289 | static struct attribute *dbs_attributes[] = { | 293 | |
| 290 | &sampling_rate_min.attr, | 294 | static struct attribute *dbs_attributes_gov_sys[] = { |
| 291 | &sampling_rate.attr, | 295 | &sampling_rate_min_gov_sys.attr, |
| 292 | &sampling_down_factor.attr, | 296 | &sampling_rate_gov_sys.attr, |
| 293 | &up_threshold.attr, | 297 | &sampling_down_factor_gov_sys.attr, |
| 294 | &down_threshold.attr, | 298 | &up_threshold_gov_sys.attr, |
| 295 | &ignore_nice_load.attr, | 299 | &down_threshold_gov_sys.attr, |
| 296 | &freq_step.attr, | 300 | &ignore_nice_gov_sys.attr, |
| 301 | &freq_step_gov_sys.attr, | ||
| 297 | NULL | 302 | NULL |
| 298 | }; | 303 | }; |
| 299 | 304 | ||
| 300 | static struct attribute_group cs_attr_group = { | 305 | static struct attribute_group cs_attr_group_gov_sys = { |
| 301 | .attrs = dbs_attributes, | 306 | .attrs = dbs_attributes_gov_sys, |
| 307 | .name = "conservative", | ||
| 308 | }; | ||
| 309 | |||
| 310 | static struct attribute *dbs_attributes_gov_pol[] = { | ||
| 311 | &sampling_rate_min_gov_pol.attr, | ||
| 312 | &sampling_rate_gov_pol.attr, | ||
| 313 | &sampling_down_factor_gov_pol.attr, | ||
| 314 | &up_threshold_gov_pol.attr, | ||
| 315 | &down_threshold_gov_pol.attr, | ||
| 316 | &ignore_nice_gov_pol.attr, | ||
| 317 | &freq_step_gov_pol.attr, | ||
| 318 | NULL | ||
| 319 | }; | ||
| 320 | |||
| 321 | static struct attribute_group cs_attr_group_gov_pol = { | ||
| 322 | .attrs = dbs_attributes_gov_pol, | ||
| 302 | .name = "conservative", | 323 | .name = "conservative", |
| 303 | }; | 324 | }; |
| 304 | 325 | ||
| 305 | /************************** sysfs end ************************/ | 326 | /************************** sysfs end ************************/ |
| 306 | 327 | ||
| 328 | static int cs_init(struct dbs_data *dbs_data) | ||
| 329 | { | ||
| 330 | struct cs_dbs_tuners *tuners; | ||
| 331 | |||
| 332 | tuners = kzalloc(sizeof(struct cs_dbs_tuners), GFP_KERNEL); | ||
| 333 | if (!tuners) { | ||
| 334 | pr_err("%s: kzalloc failed\n", __func__); | ||
| 335 | return -ENOMEM; | ||
| 336 | } | ||
| 337 | |||
| 338 | tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD; | ||
| 339 | tuners->down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD; | ||
| 340 | tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; | ||
| 341 | tuners->ignore_nice = 0; | ||
| 342 | tuners->freq_step = DEF_FREQUENCY_STEP; | ||
| 343 | |||
| 344 | dbs_data->tuners = tuners; | ||
| 345 | dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * | ||
| 346 | jiffies_to_usecs(10); | ||
| 347 | mutex_init(&dbs_data->mutex); | ||
| 348 | return 0; | ||
| 349 | } | ||
| 350 | |||
| 351 | static void cs_exit(struct dbs_data *dbs_data) | ||
| 352 | { | ||
| 353 | kfree(dbs_data->tuners); | ||
| 354 | } | ||
| 355 | |||
| 307 | define_get_cpu_dbs_routines(cs_cpu_dbs_info); | 356 | define_get_cpu_dbs_routines(cs_cpu_dbs_info); |
| 308 | 357 | ||
| 309 | static struct notifier_block cs_cpufreq_notifier_block = { | 358 | static struct notifier_block cs_cpufreq_notifier_block = { |
| @@ -314,21 +363,23 @@ static struct cs_ops cs_ops = { | |||
| 314 | .notifier_block = &cs_cpufreq_notifier_block, | 363 | .notifier_block = &cs_cpufreq_notifier_block, |
| 315 | }; | 364 | }; |
| 316 | 365 | ||
| 317 | static struct dbs_data cs_dbs_data = { | 366 | static struct common_dbs_data cs_dbs_cdata = { |
| 318 | .governor = GOV_CONSERVATIVE, | 367 | .governor = GOV_CONSERVATIVE, |
| 319 | .attr_group = &cs_attr_group, | 368 | .attr_group_gov_sys = &cs_attr_group_gov_sys, |
| 320 | .tuners = &cs_tuners, | 369 | .attr_group_gov_pol = &cs_attr_group_gov_pol, |
| 321 | .get_cpu_cdbs = get_cpu_cdbs, | 370 | .get_cpu_cdbs = get_cpu_cdbs, |
| 322 | .get_cpu_dbs_info_s = get_cpu_dbs_info_s, | 371 | .get_cpu_dbs_info_s = get_cpu_dbs_info_s, |
| 323 | .gov_dbs_timer = cs_dbs_timer, | 372 | .gov_dbs_timer = cs_dbs_timer, |
| 324 | .gov_check_cpu = cs_check_cpu, | 373 | .gov_check_cpu = cs_check_cpu, |
| 325 | .gov_ops = &cs_ops, | 374 | .gov_ops = &cs_ops, |
| 375 | .init = cs_init, | ||
| 376 | .exit = cs_exit, | ||
| 326 | }; | 377 | }; |
| 327 | 378 | ||
| 328 | static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy, | 379 | static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy, |
| 329 | unsigned int event) | 380 | unsigned int event) |
| 330 | { | 381 | { |
| 331 | return cpufreq_governor_dbs(&cs_dbs_data, policy, event); | 382 | return cpufreq_governor_dbs(policy, &cs_dbs_cdata, event); |
| 332 | } | 383 | } |
| 333 | 384 | ||
| 334 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE | 385 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE |
| @@ -343,7 +394,6 @@ struct cpufreq_governor cpufreq_gov_conservative = { | |||
| 343 | 394 | ||
| 344 | static int __init cpufreq_gov_dbs_init(void) | 395 | static int __init cpufreq_gov_dbs_init(void) |
| 345 | { | 396 | { |
| 346 | mutex_init(&cs_dbs_data.mutex); | ||
| 347 | return cpufreq_register_governor(&cpufreq_gov_conservative); | 397 | return cpufreq_register_governor(&cpufreq_gov_conservative); |
| 348 | } | 398 | } |
| 349 | 399 | ||
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 5a76086ff09b..443442df113b 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c | |||
| @@ -22,12 +22,29 @@ | |||
| 22 | #include <linux/export.h> | 22 | #include <linux/export.h> |
| 23 | #include <linux/kernel_stat.h> | 23 | #include <linux/kernel_stat.h> |
| 24 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
| 25 | #include <linux/slab.h> | ||
| 25 | #include <linux/tick.h> | 26 | #include <linux/tick.h> |
| 26 | #include <linux/types.h> | 27 | #include <linux/types.h> |
| 27 | #include <linux/workqueue.h> | 28 | #include <linux/workqueue.h> |
| 28 | 29 | ||
| 29 | #include "cpufreq_governor.h" | 30 | #include "cpufreq_governor.h" |
| 30 | 31 | ||
| 32 | static struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) | ||
| 33 | { | ||
| 34 | if (have_governor_per_policy()) | ||
| 35 | return &policy->kobj; | ||
| 36 | else | ||
| 37 | return cpufreq_global_kobject; | ||
| 38 | } | ||
| 39 | |||
| 40 | static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) | ||
| 41 | { | ||
| 42 | if (have_governor_per_policy()) | ||
| 43 | return dbs_data->cdata->attr_group_gov_pol; | ||
| 44 | else | ||
| 45 | return dbs_data->cdata->attr_group_gov_sys; | ||
| 46 | } | ||
| 47 | |||
| 31 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) | 48 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) |
| 32 | { | 49 | { |
| 33 | u64 idle_time; | 50 | u64 idle_time; |
| @@ -50,13 +67,13 @@ static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) | |||
| 50 | return cputime_to_usecs(idle_time); | 67 | return cputime_to_usecs(idle_time); |
| 51 | } | 68 | } |
| 52 | 69 | ||
| 53 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall) | 70 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) |
| 54 | { | 71 | { |
| 55 | u64 idle_time = get_cpu_idle_time_us(cpu, NULL); | 72 | u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL); |
| 56 | 73 | ||
| 57 | if (idle_time == -1ULL) | 74 | if (idle_time == -1ULL) |
| 58 | return get_cpu_idle_time_jiffy(cpu, wall); | 75 | return get_cpu_idle_time_jiffy(cpu, wall); |
| 59 | else | 76 | else if (!io_busy) |
| 60 | idle_time += get_cpu_iowait_time_us(cpu, wall); | 77 | idle_time += get_cpu_iowait_time_us(cpu, wall); |
| 61 | 78 | ||
| 62 | return idle_time; | 79 | return idle_time; |
| @@ -65,7 +82,7 @@ EXPORT_SYMBOL_GPL(get_cpu_idle_time); | |||
| 65 | 82 | ||
| 66 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) | 83 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) |
| 67 | { | 84 | { |
| 68 | struct cpu_dbs_common_info *cdbs = dbs_data->get_cpu_cdbs(cpu); | 85 | struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); |
| 69 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | 86 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; |
| 70 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | 87 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; |
| 71 | struct cpufreq_policy *policy; | 88 | struct cpufreq_policy *policy; |
| @@ -73,7 +90,7 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) | |||
| 73 | unsigned int ignore_nice; | 90 | unsigned int ignore_nice; |
| 74 | unsigned int j; | 91 | unsigned int j; |
| 75 | 92 | ||
| 76 | if (dbs_data->governor == GOV_ONDEMAND) | 93 | if (dbs_data->cdata->governor == GOV_ONDEMAND) |
| 77 | ignore_nice = od_tuners->ignore_nice; | 94 | ignore_nice = od_tuners->ignore_nice; |
| 78 | else | 95 | else |
| 79 | ignore_nice = cs_tuners->ignore_nice; | 96 | ignore_nice = cs_tuners->ignore_nice; |
| @@ -83,13 +100,22 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) | |||
| 83 | /* Get Absolute Load (in terms of freq for ondemand gov) */ | 100 | /* Get Absolute Load (in terms of freq for ondemand gov) */ |
| 84 | for_each_cpu(j, policy->cpus) { | 101 | for_each_cpu(j, policy->cpus) { |
| 85 | struct cpu_dbs_common_info *j_cdbs; | 102 | struct cpu_dbs_common_info *j_cdbs; |
| 86 | u64 cur_wall_time, cur_idle_time, cur_iowait_time; | 103 | u64 cur_wall_time, cur_idle_time; |
| 87 | unsigned int idle_time, wall_time, iowait_time; | 104 | unsigned int idle_time, wall_time; |
| 88 | unsigned int load; | 105 | unsigned int load; |
| 106 | int io_busy = 0; | ||
| 89 | 107 | ||
| 90 | j_cdbs = dbs_data->get_cpu_cdbs(j); | 108 | j_cdbs = dbs_data->cdata->get_cpu_cdbs(j); |
| 91 | 109 | ||
| 92 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); | 110 | /* |
| 111 | * For the purpose of ondemand, waiting for disk IO is | ||
| 112 | * an indication that you're performance critical, and | ||
| 113 | * not that the system is actually idle. So do not add | ||
| 114 | * the iowait time to the cpu idle time. | ||
| 115 | */ | ||
| 116 | if (dbs_data->cdata->governor == GOV_ONDEMAND) | ||
| 117 | io_busy = od_tuners->io_is_busy; | ||
| 118 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time, io_busy); | ||
| 93 | 119 | ||
| 94 | wall_time = (unsigned int) | 120 | wall_time = (unsigned int) |
| 95 | (cur_wall_time - j_cdbs->prev_cpu_wall); | 121 | (cur_wall_time - j_cdbs->prev_cpu_wall); |
| @@ -117,35 +143,12 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) | |||
| 117 | idle_time += jiffies_to_usecs(cur_nice_jiffies); | 143 | idle_time += jiffies_to_usecs(cur_nice_jiffies); |
| 118 | } | 144 | } |
| 119 | 145 | ||
| 120 | if (dbs_data->governor == GOV_ONDEMAND) { | ||
| 121 | struct od_cpu_dbs_info_s *od_j_dbs_info = | ||
| 122 | dbs_data->get_cpu_dbs_info_s(cpu); | ||
| 123 | |||
| 124 | cur_iowait_time = get_cpu_iowait_time_us(j, | ||
| 125 | &cur_wall_time); | ||
| 126 | if (cur_iowait_time == -1ULL) | ||
| 127 | cur_iowait_time = 0; | ||
| 128 | |||
| 129 | iowait_time = (unsigned int) (cur_iowait_time - | ||
| 130 | od_j_dbs_info->prev_cpu_iowait); | ||
| 131 | od_j_dbs_info->prev_cpu_iowait = cur_iowait_time; | ||
| 132 | |||
| 133 | /* | ||
| 134 | * For the purpose of ondemand, waiting for disk IO is | ||
| 135 | * an indication that you're performance critical, and | ||
| 136 | * not that the system is actually idle. So subtract the | ||
| 137 | * iowait time from the cpu idle time. | ||
| 138 | */ | ||
| 139 | if (od_tuners->io_is_busy && idle_time >= iowait_time) | ||
| 140 | idle_time -= iowait_time; | ||
| 141 | } | ||
| 142 | |||
| 143 | if (unlikely(!wall_time || wall_time < idle_time)) | 146 | if (unlikely(!wall_time || wall_time < idle_time)) |
| 144 | continue; | 147 | continue; |
| 145 | 148 | ||
| 146 | load = 100 * (wall_time - idle_time) / wall_time; | 149 | load = 100 * (wall_time - idle_time) / wall_time; |
| 147 | 150 | ||
| 148 | if (dbs_data->governor == GOV_ONDEMAND) { | 151 | if (dbs_data->cdata->governor == GOV_ONDEMAND) { |
| 149 | int freq_avg = __cpufreq_driver_getavg(policy, j); | 152 | int freq_avg = __cpufreq_driver_getavg(policy, j); |
| 150 | if (freq_avg <= 0) | 153 | if (freq_avg <= 0) |
| 151 | freq_avg = policy->cur; | 154 | freq_avg = policy->cur; |
| @@ -157,24 +160,42 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) | |||
| 157 | max_load = load; | 160 | max_load = load; |
| 158 | } | 161 | } |
| 159 | 162 | ||
| 160 | dbs_data->gov_check_cpu(cpu, max_load); | 163 | dbs_data->cdata->gov_check_cpu(cpu, max_load); |
| 161 | } | 164 | } |
| 162 | EXPORT_SYMBOL_GPL(dbs_check_cpu); | 165 | EXPORT_SYMBOL_GPL(dbs_check_cpu); |
| 163 | 166 | ||
| 164 | static inline void dbs_timer_init(struct dbs_data *dbs_data, int cpu, | 167 | static inline void __gov_queue_work(int cpu, struct dbs_data *dbs_data, |
| 165 | unsigned int sampling_rate) | 168 | unsigned int delay) |
| 166 | { | 169 | { |
| 167 | int delay = delay_for_sampling_rate(sampling_rate); | 170 | struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); |
| 168 | struct cpu_dbs_common_info *cdbs = dbs_data->get_cpu_cdbs(cpu); | ||
| 169 | 171 | ||
| 170 | schedule_delayed_work_on(cpu, &cdbs->work, delay); | 172 | mod_delayed_work_on(cpu, system_wq, &cdbs->work, delay); |
| 171 | } | 173 | } |
| 172 | 174 | ||
| 173 | static inline void dbs_timer_exit(struct dbs_data *dbs_data, int cpu) | 175 | void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy, |
| 176 | unsigned int delay, bool all_cpus) | ||
| 174 | { | 177 | { |
| 175 | struct cpu_dbs_common_info *cdbs = dbs_data->get_cpu_cdbs(cpu); | 178 | int i; |
| 176 | 179 | ||
| 177 | cancel_delayed_work_sync(&cdbs->work); | 180 | if (!all_cpus) { |
| 181 | __gov_queue_work(smp_processor_id(), dbs_data, delay); | ||
| 182 | } else { | ||
| 183 | for_each_cpu(i, policy->cpus) | ||
| 184 | __gov_queue_work(i, dbs_data, delay); | ||
| 185 | } | ||
| 186 | } | ||
| 187 | EXPORT_SYMBOL_GPL(gov_queue_work); | ||
| 188 | |||
| 189 | static inline void gov_cancel_work(struct dbs_data *dbs_data, | ||
| 190 | struct cpufreq_policy *policy) | ||
| 191 | { | ||
| 192 | struct cpu_dbs_common_info *cdbs; | ||
| 193 | int i; | ||
| 194 | |||
| 195 | for_each_cpu(i, policy->cpus) { | ||
| 196 | cdbs = dbs_data->cdata->get_cpu_cdbs(i); | ||
| 197 | cancel_delayed_work_sync(&cdbs->work); | ||
| 198 | } | ||
| 178 | } | 199 | } |
| 179 | 200 | ||
| 180 | /* Will return if we need to evaluate cpu load again or not */ | 201 | /* Will return if we need to evaluate cpu load again or not */ |
| @@ -196,31 +217,130 @@ bool need_load_eval(struct cpu_dbs_common_info *cdbs, | |||
| 196 | } | 217 | } |
| 197 | EXPORT_SYMBOL_GPL(need_load_eval); | 218 | EXPORT_SYMBOL_GPL(need_load_eval); |
| 198 | 219 | ||
| 199 | int cpufreq_governor_dbs(struct dbs_data *dbs_data, | 220 | static void set_sampling_rate(struct dbs_data *dbs_data, |
| 200 | struct cpufreq_policy *policy, unsigned int event) | 221 | unsigned int sampling_rate) |
| 201 | { | 222 | { |
| 223 | if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { | ||
| 224 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | ||
| 225 | cs_tuners->sampling_rate = sampling_rate; | ||
| 226 | } else { | ||
| 227 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | ||
| 228 | od_tuners->sampling_rate = sampling_rate; | ||
| 229 | } | ||
| 230 | } | ||
| 231 | |||
| 232 | int cpufreq_governor_dbs(struct cpufreq_policy *policy, | ||
| 233 | struct common_dbs_data *cdata, unsigned int event) | ||
| 234 | { | ||
| 235 | struct dbs_data *dbs_data; | ||
| 202 | struct od_cpu_dbs_info_s *od_dbs_info = NULL; | 236 | struct od_cpu_dbs_info_s *od_dbs_info = NULL; |
| 203 | struct cs_cpu_dbs_info_s *cs_dbs_info = NULL; | 237 | struct cs_cpu_dbs_info_s *cs_dbs_info = NULL; |
| 204 | struct cs_ops *cs_ops = NULL; | ||
| 205 | struct od_ops *od_ops = NULL; | 238 | struct od_ops *od_ops = NULL; |
| 206 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | 239 | struct od_dbs_tuners *od_tuners = NULL; |
| 207 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | 240 | struct cs_dbs_tuners *cs_tuners = NULL; |
| 208 | struct cpu_dbs_common_info *cpu_cdbs; | 241 | struct cpu_dbs_common_info *cpu_cdbs; |
| 209 | unsigned int *sampling_rate, latency, ignore_nice, j, cpu = policy->cpu; | 242 | unsigned int sampling_rate, latency, ignore_nice, j, cpu = policy->cpu; |
| 243 | int io_busy = 0; | ||
| 210 | int rc; | 244 | int rc; |
| 211 | 245 | ||
| 212 | cpu_cdbs = dbs_data->get_cpu_cdbs(cpu); | 246 | if (have_governor_per_policy()) |
| 247 | dbs_data = policy->governor_data; | ||
| 248 | else | ||
| 249 | dbs_data = cdata->gdbs_data; | ||
| 250 | |||
| 251 | WARN_ON(!dbs_data && (event != CPUFREQ_GOV_POLICY_INIT)); | ||
| 252 | |||
| 253 | switch (event) { | ||
| 254 | case CPUFREQ_GOV_POLICY_INIT: | ||
| 255 | if (have_governor_per_policy()) { | ||
| 256 | WARN_ON(dbs_data); | ||
| 257 | } else if (dbs_data) { | ||
| 258 | policy->governor_data = dbs_data; | ||
| 259 | return 0; | ||
| 260 | } | ||
| 261 | |||
| 262 | dbs_data = kzalloc(sizeof(*dbs_data), GFP_KERNEL); | ||
| 263 | if (!dbs_data) { | ||
| 264 | pr_err("%s: POLICY_INIT: kzalloc failed\n", __func__); | ||
| 265 | return -ENOMEM; | ||
| 266 | } | ||
| 267 | |||
| 268 | dbs_data->cdata = cdata; | ||
| 269 | rc = cdata->init(dbs_data); | ||
| 270 | if (rc) { | ||
| 271 | pr_err("%s: POLICY_INIT: init() failed\n", __func__); | ||
| 272 | kfree(dbs_data); | ||
| 273 | return rc; | ||
| 274 | } | ||
| 275 | |||
| 276 | rc = sysfs_create_group(get_governor_parent_kobj(policy), | ||
| 277 | get_sysfs_attr(dbs_data)); | ||
| 278 | if (rc) { | ||
| 279 | cdata->exit(dbs_data); | ||
| 280 | kfree(dbs_data); | ||
| 281 | return rc; | ||
| 282 | } | ||
| 283 | |||
| 284 | policy->governor_data = dbs_data; | ||
| 213 | 285 | ||
| 214 | if (dbs_data->governor == GOV_CONSERVATIVE) { | 286 | /* policy latency is in nS. Convert it to uS first */ |
| 215 | cs_dbs_info = dbs_data->get_cpu_dbs_info_s(cpu); | 287 | latency = policy->cpuinfo.transition_latency / 1000; |
| 216 | sampling_rate = &cs_tuners->sampling_rate; | 288 | if (latency == 0) |
| 289 | latency = 1; | ||
| 290 | |||
| 291 | /* Bring kernel and HW constraints together */ | ||
| 292 | dbs_data->min_sampling_rate = max(dbs_data->min_sampling_rate, | ||
| 293 | MIN_LATENCY_MULTIPLIER * latency); | ||
| 294 | set_sampling_rate(dbs_data, max(dbs_data->min_sampling_rate, | ||
| 295 | latency * LATENCY_MULTIPLIER)); | ||
| 296 | |||
| 297 | if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { | ||
| 298 | struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; | ||
| 299 | |||
| 300 | cpufreq_register_notifier(cs_ops->notifier_block, | ||
| 301 | CPUFREQ_TRANSITION_NOTIFIER); | ||
| 302 | } | ||
| 303 | |||
| 304 | if (!have_governor_per_policy()) | ||
| 305 | cdata->gdbs_data = dbs_data; | ||
| 306 | |||
| 307 | return 0; | ||
| 308 | case CPUFREQ_GOV_POLICY_EXIT: | ||
| 309 | if ((policy->governor->initialized == 1) || | ||
| 310 | have_governor_per_policy()) { | ||
| 311 | sysfs_remove_group(get_governor_parent_kobj(policy), | ||
| 312 | get_sysfs_attr(dbs_data)); | ||
| 313 | |||
| 314 | if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { | ||
| 315 | struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; | ||
| 316 | |||
| 317 | cpufreq_unregister_notifier(cs_ops->notifier_block, | ||
| 318 | CPUFREQ_TRANSITION_NOTIFIER); | ||
| 319 | } | ||
| 320 | |||
| 321 | cdata->exit(dbs_data); | ||
| 322 | kfree(dbs_data); | ||
| 323 | cdata->gdbs_data = NULL; | ||
| 324 | } | ||
| 325 | |||
| 326 | policy->governor_data = NULL; | ||
| 327 | return 0; | ||
| 328 | } | ||
| 329 | |||
| 330 | cpu_cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); | ||
| 331 | |||
| 332 | if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { | ||
| 333 | cs_tuners = dbs_data->tuners; | ||
| 334 | cs_dbs_info = dbs_data->cdata->get_cpu_dbs_info_s(cpu); | ||
| 335 | sampling_rate = cs_tuners->sampling_rate; | ||
| 217 | ignore_nice = cs_tuners->ignore_nice; | 336 | ignore_nice = cs_tuners->ignore_nice; |
| 218 | cs_ops = dbs_data->gov_ops; | ||
| 219 | } else { | 337 | } else { |
| 220 | od_dbs_info = dbs_data->get_cpu_dbs_info_s(cpu); | 338 | od_tuners = dbs_data->tuners; |
| 221 | sampling_rate = &od_tuners->sampling_rate; | 339 | od_dbs_info = dbs_data->cdata->get_cpu_dbs_info_s(cpu); |
| 340 | sampling_rate = od_tuners->sampling_rate; | ||
| 222 | ignore_nice = od_tuners->ignore_nice; | 341 | ignore_nice = od_tuners->ignore_nice; |
| 223 | od_ops = dbs_data->gov_ops; | 342 | od_ops = dbs_data->cdata->gov_ops; |
| 343 | io_busy = od_tuners->io_is_busy; | ||
| 224 | } | 344 | } |
| 225 | 345 | ||
| 226 | switch (event) { | 346 | switch (event) { |
| @@ -232,96 +352,53 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data, | |||
| 232 | 352 | ||
| 233 | for_each_cpu(j, policy->cpus) { | 353 | for_each_cpu(j, policy->cpus) { |
| 234 | struct cpu_dbs_common_info *j_cdbs = | 354 | struct cpu_dbs_common_info *j_cdbs = |
| 235 | dbs_data->get_cpu_cdbs(j); | 355 | dbs_data->cdata->get_cpu_cdbs(j); |
| 236 | 356 | ||
| 237 | j_cdbs->cpu = j; | 357 | j_cdbs->cpu = j; |
| 238 | j_cdbs->cur_policy = policy; | 358 | j_cdbs->cur_policy = policy; |
| 239 | j_cdbs->prev_cpu_idle = get_cpu_idle_time(j, | 359 | j_cdbs->prev_cpu_idle = get_cpu_idle_time(j, |
| 240 | &j_cdbs->prev_cpu_wall); | 360 | &j_cdbs->prev_cpu_wall, io_busy); |
| 241 | if (ignore_nice) | 361 | if (ignore_nice) |
| 242 | j_cdbs->prev_cpu_nice = | 362 | j_cdbs->prev_cpu_nice = |
| 243 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; | 363 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
| 244 | 364 | ||
| 245 | mutex_init(&j_cdbs->timer_mutex); | 365 | mutex_init(&j_cdbs->timer_mutex); |
| 246 | INIT_DEFERRABLE_WORK(&j_cdbs->work, | 366 | INIT_DEFERRABLE_WORK(&j_cdbs->work, |
| 247 | dbs_data->gov_dbs_timer); | 367 | dbs_data->cdata->gov_dbs_timer); |
| 248 | } | ||
| 249 | |||
| 250 | if (!policy->governor->initialized) { | ||
| 251 | rc = sysfs_create_group(cpufreq_global_kobject, | ||
| 252 | dbs_data->attr_group); | ||
| 253 | if (rc) { | ||
| 254 | mutex_unlock(&dbs_data->mutex); | ||
| 255 | return rc; | ||
| 256 | } | ||
| 257 | } | 368 | } |
| 258 | 369 | ||
| 259 | /* | 370 | /* |
| 260 | * conservative does not implement micro like ondemand | 371 | * conservative does not implement micro like ondemand |
| 261 | * governor, thus we are bound to jiffes/HZ | 372 | * governor, thus we are bound to jiffes/HZ |
| 262 | */ | 373 | */ |
| 263 | if (dbs_data->governor == GOV_CONSERVATIVE) { | 374 | if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { |
| 264 | cs_dbs_info->down_skip = 0; | 375 | cs_dbs_info->down_skip = 0; |
| 265 | cs_dbs_info->enable = 1; | 376 | cs_dbs_info->enable = 1; |
| 266 | cs_dbs_info->requested_freq = policy->cur; | 377 | cs_dbs_info->requested_freq = policy->cur; |
| 267 | |||
| 268 | if (!policy->governor->initialized) { | ||
| 269 | cpufreq_register_notifier(cs_ops->notifier_block, | ||
| 270 | CPUFREQ_TRANSITION_NOTIFIER); | ||
| 271 | |||
| 272 | dbs_data->min_sampling_rate = | ||
| 273 | MIN_SAMPLING_RATE_RATIO * | ||
| 274 | jiffies_to_usecs(10); | ||
| 275 | } | ||
| 276 | } else { | 378 | } else { |
| 277 | od_dbs_info->rate_mult = 1; | 379 | od_dbs_info->rate_mult = 1; |
| 278 | od_dbs_info->sample_type = OD_NORMAL_SAMPLE; | 380 | od_dbs_info->sample_type = OD_NORMAL_SAMPLE; |
| 279 | od_ops->powersave_bias_init_cpu(cpu); | 381 | od_ops->powersave_bias_init_cpu(cpu); |
| 280 | |||
| 281 | if (!policy->governor->initialized) | ||
| 282 | od_tuners->io_is_busy = od_ops->io_busy(); | ||
| 283 | } | 382 | } |
| 284 | 383 | ||
| 285 | if (policy->governor->initialized) | ||
| 286 | goto unlock; | ||
| 287 | |||
| 288 | /* policy latency is in nS. Convert it to uS first */ | ||
| 289 | latency = policy->cpuinfo.transition_latency / 1000; | ||
| 290 | if (latency == 0) | ||
| 291 | latency = 1; | ||
| 292 | |||
| 293 | /* Bring kernel and HW constraints together */ | ||
| 294 | dbs_data->min_sampling_rate = max(dbs_data->min_sampling_rate, | ||
| 295 | MIN_LATENCY_MULTIPLIER * latency); | ||
| 296 | *sampling_rate = max(dbs_data->min_sampling_rate, latency * | ||
| 297 | LATENCY_MULTIPLIER); | ||
| 298 | unlock: | ||
| 299 | mutex_unlock(&dbs_data->mutex); | 384 | mutex_unlock(&dbs_data->mutex); |
| 300 | 385 | ||
| 301 | /* Initiate timer time stamp */ | 386 | /* Initiate timer time stamp */ |
| 302 | cpu_cdbs->time_stamp = ktime_get(); | 387 | cpu_cdbs->time_stamp = ktime_get(); |
| 303 | 388 | ||
| 304 | for_each_cpu(j, policy->cpus) | 389 | gov_queue_work(dbs_data, policy, |
| 305 | dbs_timer_init(dbs_data, j, *sampling_rate); | 390 | delay_for_sampling_rate(sampling_rate), true); |
| 306 | break; | 391 | break; |
| 307 | 392 | ||
| 308 | case CPUFREQ_GOV_STOP: | 393 | case CPUFREQ_GOV_STOP: |
| 309 | if (dbs_data->governor == GOV_CONSERVATIVE) | 394 | if (dbs_data->cdata->governor == GOV_CONSERVATIVE) |
| 310 | cs_dbs_info->enable = 0; | 395 | cs_dbs_info->enable = 0; |
| 311 | 396 | ||
| 312 | for_each_cpu(j, policy->cpus) | 397 | gov_cancel_work(dbs_data, policy); |
| 313 | dbs_timer_exit(dbs_data, j); | ||
| 314 | 398 | ||
| 315 | mutex_lock(&dbs_data->mutex); | 399 | mutex_lock(&dbs_data->mutex); |
| 316 | mutex_destroy(&cpu_cdbs->timer_mutex); | 400 | mutex_destroy(&cpu_cdbs->timer_mutex); |
| 317 | 401 | ||
| 318 | if (policy->governor->initialized == 1) { | ||
| 319 | sysfs_remove_group(cpufreq_global_kobject, | ||
| 320 | dbs_data->attr_group); | ||
| 321 | if (dbs_data->governor == GOV_CONSERVATIVE) | ||
| 322 | cpufreq_unregister_notifier(cs_ops->notifier_block, | ||
| 323 | CPUFREQ_TRANSITION_NOTIFIER); | ||
| 324 | } | ||
| 325 | mutex_unlock(&dbs_data->mutex); | 402 | mutex_unlock(&dbs_data->mutex); |
| 326 | 403 | ||
| 327 | break; | 404 | break; |
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index cc4bd2f6838a..8ac33538d0bd 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h | |||
| @@ -34,20 +34,81 @@ | |||
| 34 | */ | 34 | */ |
| 35 | #define MIN_SAMPLING_RATE_RATIO (2) | 35 | #define MIN_SAMPLING_RATE_RATIO (2) |
| 36 | #define LATENCY_MULTIPLIER (1000) | 36 | #define LATENCY_MULTIPLIER (1000) |
| 37 | #define MIN_LATENCY_MULTIPLIER (100) | 37 | #define MIN_LATENCY_MULTIPLIER (20) |
| 38 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) | 38 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) |
| 39 | 39 | ||
| 40 | /* Ondemand Sampling types */ | 40 | /* Ondemand Sampling types */ |
| 41 | enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE}; | 41 | enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE}; |
| 42 | 42 | ||
| 43 | /* Macro creating sysfs show routines */ | 43 | /* |
| 44 | #define show_one(_gov, file_name, object) \ | 44 | * Macro for creating governors sysfs routines |
| 45 | static ssize_t show_##file_name \ | 45 | * |
| 46 | * - gov_sys: One governor instance per whole system | ||
| 47 | * - gov_pol: One governor instance per policy | ||
| 48 | */ | ||
| 49 | |||
| 50 | /* Create attributes */ | ||
| 51 | #define gov_sys_attr_ro(_name) \ | ||
| 52 | static struct global_attr _name##_gov_sys = \ | ||
| 53 | __ATTR(_name, 0444, show_##_name##_gov_sys, NULL) | ||
| 54 | |||
| 55 | #define gov_sys_attr_rw(_name) \ | ||
| 56 | static struct global_attr _name##_gov_sys = \ | ||
| 57 | __ATTR(_name, 0644, show_##_name##_gov_sys, store_##_name##_gov_sys) | ||
| 58 | |||
| 59 | #define gov_pol_attr_ro(_name) \ | ||
| 60 | static struct freq_attr _name##_gov_pol = \ | ||
| 61 | __ATTR(_name, 0444, show_##_name##_gov_pol, NULL) | ||
| 62 | |||
| 63 | #define gov_pol_attr_rw(_name) \ | ||
| 64 | static struct freq_attr _name##_gov_pol = \ | ||
| 65 | __ATTR(_name, 0644, show_##_name##_gov_pol, store_##_name##_gov_pol) | ||
| 66 | |||
| 67 | #define gov_sys_pol_attr_rw(_name) \ | ||
| 68 | gov_sys_attr_rw(_name); \ | ||
| 69 | gov_pol_attr_rw(_name) | ||
| 70 | |||
| 71 | #define gov_sys_pol_attr_ro(_name) \ | ||
| 72 | gov_sys_attr_ro(_name); \ | ||
| 73 | gov_pol_attr_ro(_name) | ||
| 74 | |||
| 75 | /* Create show/store routines */ | ||
| 76 | #define show_one(_gov, file_name) \ | ||
| 77 | static ssize_t show_##file_name##_gov_sys \ | ||
| 46 | (struct kobject *kobj, struct attribute *attr, char *buf) \ | 78 | (struct kobject *kobj, struct attribute *attr, char *buf) \ |
| 47 | { \ | 79 | { \ |
| 48 | return sprintf(buf, "%u\n", _gov##_tuners.object); \ | 80 | struct _gov##_dbs_tuners *tuners = _gov##_dbs_cdata.gdbs_data->tuners; \ |
| 81 | return sprintf(buf, "%u\n", tuners->file_name); \ | ||
| 82 | } \ | ||
| 83 | \ | ||
| 84 | static ssize_t show_##file_name##_gov_pol \ | ||
| 85 | (struct cpufreq_policy *policy, char *buf) \ | ||
| 86 | { \ | ||
| 87 | struct dbs_data *dbs_data = policy->governor_data; \ | ||
| 88 | struct _gov##_dbs_tuners *tuners = dbs_data->tuners; \ | ||
| 89 | return sprintf(buf, "%u\n", tuners->file_name); \ | ||
| 90 | } | ||
| 91 | |||
| 92 | #define store_one(_gov, file_name) \ | ||
| 93 | static ssize_t store_##file_name##_gov_sys \ | ||
| 94 | (struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \ | ||
| 95 | { \ | ||
| 96 | struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \ | ||
| 97 | return store_##file_name(dbs_data, buf, count); \ | ||
| 98 | } \ | ||
| 99 | \ | ||
| 100 | static ssize_t store_##file_name##_gov_pol \ | ||
| 101 | (struct cpufreq_policy *policy, const char *buf, size_t count) \ | ||
| 102 | { \ | ||
| 103 | struct dbs_data *dbs_data = policy->governor_data; \ | ||
| 104 | return store_##file_name(dbs_data, buf, count); \ | ||
| 49 | } | 105 | } |
| 50 | 106 | ||
| 107 | #define show_store_one(_gov, file_name) \ | ||
| 108 | show_one(_gov, file_name); \ | ||
| 109 | store_one(_gov, file_name) | ||
| 110 | |||
| 111 | /* create helper routines */ | ||
| 51 | #define define_get_cpu_dbs_routines(_dbs_info) \ | 112 | #define define_get_cpu_dbs_routines(_dbs_info) \ |
| 52 | static struct cpu_dbs_common_info *get_cpu_cdbs(int cpu) \ | 113 | static struct cpu_dbs_common_info *get_cpu_cdbs(int cpu) \ |
| 53 | { \ | 114 | { \ |
| @@ -87,7 +148,6 @@ struct cpu_dbs_common_info { | |||
| 87 | 148 | ||
| 88 | struct od_cpu_dbs_info_s { | 149 | struct od_cpu_dbs_info_s { |
| 89 | struct cpu_dbs_common_info cdbs; | 150 | struct cpu_dbs_common_info cdbs; |
| 90 | u64 prev_cpu_iowait; | ||
| 91 | struct cpufreq_frequency_table *freq_table; | 151 | struct cpufreq_frequency_table *freq_table; |
| 92 | unsigned int freq_lo; | 152 | unsigned int freq_lo; |
| 93 | unsigned int freq_lo_jiffies; | 153 | unsigned int freq_lo_jiffies; |
| @@ -103,7 +163,7 @@ struct cs_cpu_dbs_info_s { | |||
| 103 | unsigned int enable:1; | 163 | unsigned int enable:1; |
| 104 | }; | 164 | }; |
| 105 | 165 | ||
| 106 | /* Governers sysfs tunables */ | 166 | /* Per policy Governers sysfs tunables */ |
| 107 | struct od_dbs_tuners { | 167 | struct od_dbs_tuners { |
| 108 | unsigned int ignore_nice; | 168 | unsigned int ignore_nice; |
| 109 | unsigned int sampling_rate; | 169 | unsigned int sampling_rate; |
| @@ -123,31 +183,42 @@ struct cs_dbs_tuners { | |||
| 123 | unsigned int freq_step; | 183 | unsigned int freq_step; |
| 124 | }; | 184 | }; |
| 125 | 185 | ||
| 126 | /* Per Governer data */ | 186 | /* Common Governer data across policies */ |
| 127 | struct dbs_data { | 187 | struct dbs_data; |
| 188 | struct common_dbs_data { | ||
| 128 | /* Common across governors */ | 189 | /* Common across governors */ |
| 129 | #define GOV_ONDEMAND 0 | 190 | #define GOV_ONDEMAND 0 |
| 130 | #define GOV_CONSERVATIVE 1 | 191 | #define GOV_CONSERVATIVE 1 |
| 131 | int governor; | 192 | int governor; |
| 132 | unsigned int min_sampling_rate; | 193 | struct attribute_group *attr_group_gov_sys; /* one governor - system */ |
| 133 | struct attribute_group *attr_group; | 194 | struct attribute_group *attr_group_gov_pol; /* one governor - policy */ |
| 134 | void *tuners; | ||
| 135 | 195 | ||
| 136 | /* dbs_mutex protects dbs_enable in governor start/stop */ | 196 | /* Common data for platforms that don't set have_governor_per_policy */ |
| 137 | struct mutex mutex; | 197 | struct dbs_data *gdbs_data; |
| 138 | 198 | ||
| 139 | struct cpu_dbs_common_info *(*get_cpu_cdbs)(int cpu); | 199 | struct cpu_dbs_common_info *(*get_cpu_cdbs)(int cpu); |
| 140 | void *(*get_cpu_dbs_info_s)(int cpu); | 200 | void *(*get_cpu_dbs_info_s)(int cpu); |
| 141 | void (*gov_dbs_timer)(struct work_struct *work); | 201 | void (*gov_dbs_timer)(struct work_struct *work); |
| 142 | void (*gov_check_cpu)(int cpu, unsigned int load); | 202 | void (*gov_check_cpu)(int cpu, unsigned int load); |
| 203 | int (*init)(struct dbs_data *dbs_data); | ||
| 204 | void (*exit)(struct dbs_data *dbs_data); | ||
| 143 | 205 | ||
| 144 | /* Governor specific ops, see below */ | 206 | /* Governor specific ops, see below */ |
| 145 | void *gov_ops; | 207 | void *gov_ops; |
| 146 | }; | 208 | }; |
| 147 | 209 | ||
| 210 | /* Governer Per policy data */ | ||
| 211 | struct dbs_data { | ||
| 212 | struct common_dbs_data *cdata; | ||
| 213 | unsigned int min_sampling_rate; | ||
| 214 | void *tuners; | ||
| 215 | |||
| 216 | /* dbs_mutex protects dbs_enable in governor start/stop */ | ||
| 217 | struct mutex mutex; | ||
| 218 | }; | ||
| 219 | |||
| 148 | /* Governor specific ops, will be passed to dbs_data->gov_ops */ | 220 | /* Governor specific ops, will be passed to dbs_data->gov_ops */ |
| 149 | struct od_ops { | 221 | struct od_ops { |
| 150 | int (*io_busy)(void); | ||
| 151 | void (*powersave_bias_init_cpu)(int cpu); | 222 | void (*powersave_bias_init_cpu)(int cpu); |
| 152 | unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy, | 223 | unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy, |
| 153 | unsigned int freq_next, unsigned int relation); | 224 | unsigned int freq_next, unsigned int relation); |
| @@ -169,10 +240,31 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate) | |||
| 169 | return delay; | 240 | return delay; |
| 170 | } | 241 | } |
| 171 | 242 | ||
| 172 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall); | 243 | #define declare_show_sampling_rate_min(_gov) \ |
| 244 | static ssize_t show_sampling_rate_min_gov_sys \ | ||
| 245 | (struct kobject *kobj, struct attribute *attr, char *buf) \ | ||
| 246 | { \ | ||
| 247 | struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \ | ||
| 248 | return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \ | ||
| 249 | } \ | ||
| 250 | \ | ||
| 251 | static ssize_t show_sampling_rate_min_gov_pol \ | ||
| 252 | (struct cpufreq_policy *policy, char *buf) \ | ||
| 253 | { \ | ||
| 254 | struct dbs_data *dbs_data = policy->governor_data; \ | ||
| 255 | return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \ | ||
| 256 | } | ||
| 257 | |||
| 258 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); | ||
| 173 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); | 259 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); |
| 174 | bool need_load_eval(struct cpu_dbs_common_info *cdbs, | 260 | bool need_load_eval(struct cpu_dbs_common_info *cdbs, |
| 175 | unsigned int sampling_rate); | 261 | unsigned int sampling_rate); |
| 176 | int cpufreq_governor_dbs(struct dbs_data *dbs_data, | 262 | int cpufreq_governor_dbs(struct cpufreq_policy *policy, |
| 177 | struct cpufreq_policy *policy, unsigned int event); | 263 | struct common_dbs_data *cdata, unsigned int event); |
| 264 | void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy, | ||
| 265 | unsigned int delay, bool all_cpus); | ||
| 266 | void od_register_powersave_bias_handler(unsigned int (*f) | ||
| 267 | (struct cpufreq_policy *, unsigned int, unsigned int), | ||
| 268 | unsigned int powersave_bias); | ||
| 269 | void od_unregister_powersave_bias_handler(void); | ||
| 178 | #endif /* _CPUFREQ_GOVERNOR_H */ | 270 | #endif /* _CPUFREQ_GOVERNOR_H */ |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index f3eb26cd848f..b0ffef96bf77 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
| @@ -20,9 +20,11 @@ | |||
| 20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
| 21 | #include <linux/mutex.h> | 21 | #include <linux/mutex.h> |
| 22 | #include <linux/percpu-defs.h> | 22 | #include <linux/percpu-defs.h> |
| 23 | #include <linux/slab.h> | ||
| 23 | #include <linux/sysfs.h> | 24 | #include <linux/sysfs.h> |
| 24 | #include <linux/tick.h> | 25 | #include <linux/tick.h> |
| 25 | #include <linux/types.h> | 26 | #include <linux/types.h> |
| 27 | #include <linux/cpu.h> | ||
| 26 | 28 | ||
| 27 | #include "cpufreq_governor.h" | 29 | #include "cpufreq_governor.h" |
| 28 | 30 | ||
| @@ -37,22 +39,14 @@ | |||
| 37 | #define MIN_FREQUENCY_UP_THRESHOLD (11) | 39 | #define MIN_FREQUENCY_UP_THRESHOLD (11) |
| 38 | #define MAX_FREQUENCY_UP_THRESHOLD (100) | 40 | #define MAX_FREQUENCY_UP_THRESHOLD (100) |
| 39 | 41 | ||
| 40 | static struct dbs_data od_dbs_data; | ||
| 41 | static DEFINE_PER_CPU(struct od_cpu_dbs_info_s, od_cpu_dbs_info); | 42 | static DEFINE_PER_CPU(struct od_cpu_dbs_info_s, od_cpu_dbs_info); |
| 42 | 43 | ||
| 44 | static struct od_ops od_ops; | ||
| 45 | |||
| 43 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND | 46 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND |
| 44 | static struct cpufreq_governor cpufreq_gov_ondemand; | 47 | static struct cpufreq_governor cpufreq_gov_ondemand; |
| 45 | #endif | 48 | #endif |
| 46 | 49 | ||
| 47 | static struct od_dbs_tuners od_tuners = { | ||
| 48 | .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, | ||
| 49 | .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, | ||
| 50 | .adj_up_threshold = DEF_FREQUENCY_UP_THRESHOLD - | ||
| 51 | DEF_FREQUENCY_DOWN_DIFFERENTIAL, | ||
| 52 | .ignore_nice = 0, | ||
| 53 | .powersave_bias = 0, | ||
| 54 | }; | ||
| 55 | |||
| 56 | static void ondemand_powersave_bias_init_cpu(int cpu) | 50 | static void ondemand_powersave_bias_init_cpu(int cpu) |
| 57 | { | 51 | { |
| 58 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); | 52 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); |
| @@ -89,7 +83,7 @@ static int should_io_be_busy(void) | |||
| 89 | * Returns the freq_hi to be used right now and will set freq_hi_jiffies, | 83 | * Returns the freq_hi to be used right now and will set freq_hi_jiffies, |
| 90 | * freq_lo, and freq_lo_jiffies in percpu area for averaging freqs. | 84 | * freq_lo, and freq_lo_jiffies in percpu area for averaging freqs. |
| 91 | */ | 85 | */ |
| 92 | static unsigned int powersave_bias_target(struct cpufreq_policy *policy, | 86 | static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy, |
| 93 | unsigned int freq_next, unsigned int relation) | 87 | unsigned int freq_next, unsigned int relation) |
| 94 | { | 88 | { |
| 95 | unsigned int freq_req, freq_reduc, freq_avg; | 89 | unsigned int freq_req, freq_reduc, freq_avg; |
| @@ -98,6 +92,8 @@ static unsigned int powersave_bias_target(struct cpufreq_policy *policy, | |||
| 98 | unsigned int jiffies_total, jiffies_hi, jiffies_lo; | 92 | unsigned int jiffies_total, jiffies_hi, jiffies_lo; |
| 99 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, | 93 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, |
| 100 | policy->cpu); | 94 | policy->cpu); |
| 95 | struct dbs_data *dbs_data = policy->governor_data; | ||
| 96 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | ||
| 101 | 97 | ||
| 102 | if (!dbs_info->freq_table) { | 98 | if (!dbs_info->freq_table) { |
| 103 | dbs_info->freq_lo = 0; | 99 | dbs_info->freq_lo = 0; |
| @@ -108,7 +104,7 @@ static unsigned int powersave_bias_target(struct cpufreq_policy *policy, | |||
| 108 | cpufreq_frequency_table_target(policy, dbs_info->freq_table, freq_next, | 104 | cpufreq_frequency_table_target(policy, dbs_info->freq_table, freq_next, |
| 109 | relation, &index); | 105 | relation, &index); |
| 110 | freq_req = dbs_info->freq_table[index].frequency; | 106 | freq_req = dbs_info->freq_table[index].frequency; |
| 111 | freq_reduc = freq_req * od_tuners.powersave_bias / 1000; | 107 | freq_reduc = freq_req * od_tuners->powersave_bias / 1000; |
| 112 | freq_avg = freq_req - freq_reduc; | 108 | freq_avg = freq_req - freq_reduc; |
| 113 | 109 | ||
| 114 | /* Find freq bounds for freq_avg in freq_table */ | 110 | /* Find freq bounds for freq_avg in freq_table */ |
| @@ -127,7 +123,7 @@ static unsigned int powersave_bias_target(struct cpufreq_policy *policy, | |||
| 127 | dbs_info->freq_lo_jiffies = 0; | 123 | dbs_info->freq_lo_jiffies = 0; |
| 128 | return freq_lo; | 124 | return freq_lo; |
| 129 | } | 125 | } |
| 130 | jiffies_total = usecs_to_jiffies(od_tuners.sampling_rate); | 126 | jiffies_total = usecs_to_jiffies(od_tuners->sampling_rate); |
| 131 | jiffies_hi = (freq_avg - freq_lo) * jiffies_total; | 127 | jiffies_hi = (freq_avg - freq_lo) * jiffies_total; |
| 132 | jiffies_hi += ((freq_hi - freq_lo) / 2); | 128 | jiffies_hi += ((freq_hi - freq_lo) / 2); |
| 133 | jiffies_hi /= (freq_hi - freq_lo); | 129 | jiffies_hi /= (freq_hi - freq_lo); |
| @@ -148,12 +144,16 @@ static void ondemand_powersave_bias_init(void) | |||
| 148 | 144 | ||
| 149 | static void dbs_freq_increase(struct cpufreq_policy *p, unsigned int freq) | 145 | static void dbs_freq_increase(struct cpufreq_policy *p, unsigned int freq) |
| 150 | { | 146 | { |
| 151 | if (od_tuners.powersave_bias) | 147 | struct dbs_data *dbs_data = p->governor_data; |
| 152 | freq = powersave_bias_target(p, freq, CPUFREQ_RELATION_H); | 148 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; |
| 149 | |||
| 150 | if (od_tuners->powersave_bias) | ||
| 151 | freq = od_ops.powersave_bias_target(p, freq, | ||
| 152 | CPUFREQ_RELATION_H); | ||
| 153 | else if (p->cur == p->max) | 153 | else if (p->cur == p->max) |
| 154 | return; | 154 | return; |
| 155 | 155 | ||
| 156 | __cpufreq_driver_target(p, freq, od_tuners.powersave_bias ? | 156 | __cpufreq_driver_target(p, freq, od_tuners->powersave_bias ? |
| 157 | CPUFREQ_RELATION_L : CPUFREQ_RELATION_H); | 157 | CPUFREQ_RELATION_L : CPUFREQ_RELATION_H); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| @@ -170,15 +170,17 @@ static void od_check_cpu(int cpu, unsigned int load_freq) | |||
| 170 | { | 170 | { |
| 171 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); | 171 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); |
| 172 | struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy; | 172 | struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy; |
| 173 | struct dbs_data *dbs_data = policy->governor_data; | ||
| 174 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | ||
| 173 | 175 | ||
| 174 | dbs_info->freq_lo = 0; | 176 | dbs_info->freq_lo = 0; |
| 175 | 177 | ||
| 176 | /* Check for frequency increase */ | 178 | /* Check for frequency increase */ |
| 177 | if (load_freq > od_tuners.up_threshold * policy->cur) { | 179 | if (load_freq > od_tuners->up_threshold * policy->cur) { |
| 178 | /* If switching to max speed, apply sampling_down_factor */ | 180 | /* If switching to max speed, apply sampling_down_factor */ |
| 179 | if (policy->cur < policy->max) | 181 | if (policy->cur < policy->max) |
| 180 | dbs_info->rate_mult = | 182 | dbs_info->rate_mult = |
| 181 | od_tuners.sampling_down_factor; | 183 | od_tuners->sampling_down_factor; |
| 182 | dbs_freq_increase(policy, policy->max); | 184 | dbs_freq_increase(policy, policy->max); |
| 183 | return; | 185 | return; |
| 184 | } | 186 | } |
| @@ -193,9 +195,10 @@ static void od_check_cpu(int cpu, unsigned int load_freq) | |||
| 193 | * support the current CPU usage without triggering the up policy. To be | 195 | * support the current CPU usage without triggering the up policy. To be |
| 194 | * safe, we focus 10 points under the threshold. | 196 | * safe, we focus 10 points under the threshold. |
| 195 | */ | 197 | */ |
| 196 | if (load_freq < od_tuners.adj_up_threshold * policy->cur) { | 198 | if (load_freq < od_tuners->adj_up_threshold |
| 199 | * policy->cur) { | ||
| 197 | unsigned int freq_next; | 200 | unsigned int freq_next; |
| 198 | freq_next = load_freq / od_tuners.adj_up_threshold; | 201 | freq_next = load_freq / od_tuners->adj_up_threshold; |
| 199 | 202 | ||
| 200 | /* No longer fully busy, reset rate_mult */ | 203 | /* No longer fully busy, reset rate_mult */ |
| 201 | dbs_info->rate_mult = 1; | 204 | dbs_info->rate_mult = 1; |
| @@ -203,65 +206,62 @@ static void od_check_cpu(int cpu, unsigned int load_freq) | |||
| 203 | if (freq_next < policy->min) | 206 | if (freq_next < policy->min) |
| 204 | freq_next = policy->min; | 207 | freq_next = policy->min; |
| 205 | 208 | ||
| 206 | if (!od_tuners.powersave_bias) { | 209 | if (!od_tuners->powersave_bias) { |
| 207 | __cpufreq_driver_target(policy, freq_next, | 210 | __cpufreq_driver_target(policy, freq_next, |
| 208 | CPUFREQ_RELATION_L); | 211 | CPUFREQ_RELATION_L); |
| 209 | } else { | 212 | return; |
| 210 | int freq = powersave_bias_target(policy, freq_next, | ||
| 211 | CPUFREQ_RELATION_L); | ||
| 212 | __cpufreq_driver_target(policy, freq, | ||
| 213 | CPUFREQ_RELATION_L); | ||
| 214 | } | 213 | } |
| 214 | |||
| 215 | freq_next = od_ops.powersave_bias_target(policy, freq_next, | ||
| 216 | CPUFREQ_RELATION_L); | ||
| 217 | __cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_L); | ||
| 215 | } | 218 | } |
| 216 | } | 219 | } |
| 217 | 220 | ||
| 218 | static void od_dbs_timer(struct work_struct *work) | 221 | static void od_dbs_timer(struct work_struct *work) |
| 219 | { | 222 | { |
| 220 | struct delayed_work *dw = to_delayed_work(work); | ||
| 221 | struct od_cpu_dbs_info_s *dbs_info = | 223 | struct od_cpu_dbs_info_s *dbs_info = |
| 222 | container_of(work, struct od_cpu_dbs_info_s, cdbs.work.work); | 224 | container_of(work, struct od_cpu_dbs_info_s, cdbs.work.work); |
| 223 | unsigned int cpu = dbs_info->cdbs.cur_policy->cpu; | 225 | unsigned int cpu = dbs_info->cdbs.cur_policy->cpu; |
| 224 | struct od_cpu_dbs_info_s *core_dbs_info = &per_cpu(od_cpu_dbs_info, | 226 | struct od_cpu_dbs_info_s *core_dbs_info = &per_cpu(od_cpu_dbs_info, |
| 225 | cpu); | 227 | cpu); |
| 226 | int delay, sample_type = core_dbs_info->sample_type; | 228 | struct dbs_data *dbs_data = dbs_info->cdbs.cur_policy->governor_data; |
| 227 | bool eval_load; | 229 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; |
| 230 | int delay = 0, sample_type = core_dbs_info->sample_type; | ||
| 231 | bool modify_all = true; | ||
| 228 | 232 | ||
| 229 | mutex_lock(&core_dbs_info->cdbs.timer_mutex); | 233 | mutex_lock(&core_dbs_info->cdbs.timer_mutex); |
| 230 | eval_load = need_load_eval(&core_dbs_info->cdbs, | 234 | if (!need_load_eval(&core_dbs_info->cdbs, od_tuners->sampling_rate)) { |
| 231 | od_tuners.sampling_rate); | 235 | modify_all = false; |
| 236 | goto max_delay; | ||
| 237 | } | ||
| 232 | 238 | ||
| 233 | /* Common NORMAL_SAMPLE setup */ | 239 | /* Common NORMAL_SAMPLE setup */ |
| 234 | core_dbs_info->sample_type = OD_NORMAL_SAMPLE; | 240 | core_dbs_info->sample_type = OD_NORMAL_SAMPLE; |
| 235 | if (sample_type == OD_SUB_SAMPLE) { | 241 | if (sample_type == OD_SUB_SAMPLE) { |
| 236 | delay = core_dbs_info->freq_lo_jiffies; | 242 | delay = core_dbs_info->freq_lo_jiffies; |
| 237 | if (eval_load) | 243 | __cpufreq_driver_target(core_dbs_info->cdbs.cur_policy, |
| 238 | __cpufreq_driver_target(core_dbs_info->cdbs.cur_policy, | 244 | core_dbs_info->freq_lo, CPUFREQ_RELATION_H); |
| 239 | core_dbs_info->freq_lo, | ||
| 240 | CPUFREQ_RELATION_H); | ||
| 241 | } else { | 245 | } else { |
| 242 | if (eval_load) | 246 | dbs_check_cpu(dbs_data, cpu); |
| 243 | dbs_check_cpu(&od_dbs_data, cpu); | ||
| 244 | if (core_dbs_info->freq_lo) { | 247 | if (core_dbs_info->freq_lo) { |
| 245 | /* Setup timer for SUB_SAMPLE */ | 248 | /* Setup timer for SUB_SAMPLE */ |
| 246 | core_dbs_info->sample_type = OD_SUB_SAMPLE; | 249 | core_dbs_info->sample_type = OD_SUB_SAMPLE; |
| 247 | delay = core_dbs_info->freq_hi_jiffies; | 250 | delay = core_dbs_info->freq_hi_jiffies; |
| 248 | } else { | ||
| 249 | delay = delay_for_sampling_rate(od_tuners.sampling_rate | ||
| 250 | * core_dbs_info->rate_mult); | ||
| 251 | } | 251 | } |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | schedule_delayed_work_on(smp_processor_id(), dw, delay); | 254 | max_delay: |
| 255 | if (!delay) | ||
| 256 | delay = delay_for_sampling_rate(od_tuners->sampling_rate | ||
| 257 | * core_dbs_info->rate_mult); | ||
| 258 | |||
| 259 | gov_queue_work(dbs_data, dbs_info->cdbs.cur_policy, delay, modify_all); | ||
| 255 | mutex_unlock(&core_dbs_info->cdbs.timer_mutex); | 260 | mutex_unlock(&core_dbs_info->cdbs.timer_mutex); |
| 256 | } | 261 | } |
| 257 | 262 | ||
| 258 | /************************** sysfs interface ************************/ | 263 | /************************** sysfs interface ************************/ |
| 259 | 264 | static struct common_dbs_data od_dbs_cdata; | |
| 260 | static ssize_t show_sampling_rate_min(struct kobject *kobj, | ||
| 261 | struct attribute *attr, char *buf) | ||
| 262 | { | ||
| 263 | return sprintf(buf, "%u\n", od_dbs_data.min_sampling_rate); | ||
| 264 | } | ||
| 265 | 265 | ||
| 266 | /** | 266 | /** |
| 267 | * update_sampling_rate - update sampling rate effective immediately if needed. | 267 | * update_sampling_rate - update sampling rate effective immediately if needed. |
| @@ -276,12 +276,14 @@ static ssize_t show_sampling_rate_min(struct kobject *kobj, | |||
| 276 | * reducing the sampling rate, we need to make the new value effective | 276 | * reducing the sampling rate, we need to make the new value effective |
| 277 | * immediately. | 277 | * immediately. |
| 278 | */ | 278 | */ |
| 279 | static void update_sampling_rate(unsigned int new_rate) | 279 | static void update_sampling_rate(struct dbs_data *dbs_data, |
| 280 | unsigned int new_rate) | ||
| 280 | { | 281 | { |
| 282 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | ||
| 281 | int cpu; | 283 | int cpu; |
| 282 | 284 | ||
| 283 | od_tuners.sampling_rate = new_rate = max(new_rate, | 285 | od_tuners->sampling_rate = new_rate = max(new_rate, |
| 284 | od_dbs_data.min_sampling_rate); | 286 | dbs_data->min_sampling_rate); |
| 285 | 287 | ||
| 286 | for_each_online_cpu(cpu) { | 288 | for_each_online_cpu(cpu) { |
| 287 | struct cpufreq_policy *policy; | 289 | struct cpufreq_policy *policy; |
| @@ -314,42 +316,54 @@ static void update_sampling_rate(unsigned int new_rate) | |||
| 314 | cancel_delayed_work_sync(&dbs_info->cdbs.work); | 316 | cancel_delayed_work_sync(&dbs_info->cdbs.work); |
| 315 | mutex_lock(&dbs_info->cdbs.timer_mutex); | 317 | mutex_lock(&dbs_info->cdbs.timer_mutex); |
| 316 | 318 | ||
| 317 | schedule_delayed_work_on(cpu, &dbs_info->cdbs.work, | 319 | gov_queue_work(dbs_data, dbs_info->cdbs.cur_policy, |
| 318 | usecs_to_jiffies(new_rate)); | 320 | usecs_to_jiffies(new_rate), true); |
| 319 | 321 | ||
| 320 | } | 322 | } |
| 321 | mutex_unlock(&dbs_info->cdbs.timer_mutex); | 323 | mutex_unlock(&dbs_info->cdbs.timer_mutex); |
| 322 | } | 324 | } |
| 323 | } | 325 | } |
| 324 | 326 | ||
| 325 | static ssize_t store_sampling_rate(struct kobject *a, struct attribute *b, | 327 | static ssize_t store_sampling_rate(struct dbs_data *dbs_data, const char *buf, |
| 326 | const char *buf, size_t count) | 328 | size_t count) |
| 327 | { | 329 | { |
| 328 | unsigned int input; | 330 | unsigned int input; |
| 329 | int ret; | 331 | int ret; |
| 330 | ret = sscanf(buf, "%u", &input); | 332 | ret = sscanf(buf, "%u", &input); |
| 331 | if (ret != 1) | 333 | if (ret != 1) |
| 332 | return -EINVAL; | 334 | return -EINVAL; |
| 333 | update_sampling_rate(input); | 335 | |
| 336 | update_sampling_rate(dbs_data, input); | ||
| 334 | return count; | 337 | return count; |
| 335 | } | 338 | } |
| 336 | 339 | ||
| 337 | static ssize_t store_io_is_busy(struct kobject *a, struct attribute *b, | 340 | static ssize_t store_io_is_busy(struct dbs_data *dbs_data, const char *buf, |
| 338 | const char *buf, size_t count) | 341 | size_t count) |
| 339 | { | 342 | { |
| 343 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | ||
| 340 | unsigned int input; | 344 | unsigned int input; |
| 341 | int ret; | 345 | int ret; |
| 346 | unsigned int j; | ||
| 342 | 347 | ||
| 343 | ret = sscanf(buf, "%u", &input); | 348 | ret = sscanf(buf, "%u", &input); |
| 344 | if (ret != 1) | 349 | if (ret != 1) |
| 345 | return -EINVAL; | 350 | return -EINVAL; |
| 346 | od_tuners.io_is_busy = !!input; | 351 | od_tuners->io_is_busy = !!input; |
| 352 | |||
| 353 | /* we need to re-evaluate prev_cpu_idle */ | ||
| 354 | for_each_online_cpu(j) { | ||
| 355 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, | ||
| 356 | j); | ||
| 357 | dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j, | ||
| 358 | &dbs_info->cdbs.prev_cpu_wall, od_tuners->io_is_busy); | ||
| 359 | } | ||
| 347 | return count; | 360 | return count; |
| 348 | } | 361 | } |
| 349 | 362 | ||
| 350 | static ssize_t store_up_threshold(struct kobject *a, struct attribute *b, | 363 | static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf, |
| 351 | const char *buf, size_t count) | 364 | size_t count) |
| 352 | { | 365 | { |
| 366 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | ||
| 353 | unsigned int input; | 367 | unsigned int input; |
| 354 | int ret; | 368 | int ret; |
| 355 | ret = sscanf(buf, "%u", &input); | 369 | ret = sscanf(buf, "%u", &input); |
| @@ -359,23 +373,24 @@ static ssize_t store_up_threshold(struct kobject *a, struct attribute *b, | |||
| 359 | return -EINVAL; | 373 | return -EINVAL; |
| 360 | } | 374 | } |
| 361 | /* Calculate the new adj_up_threshold */ | 375 | /* Calculate the new adj_up_threshold */ |
| 362 | od_tuners.adj_up_threshold += input; | 376 | od_tuners->adj_up_threshold += input; |
| 363 | od_tuners.adj_up_threshold -= od_tuners.up_threshold; | 377 | od_tuners->adj_up_threshold -= od_tuners->up_threshold; |
| 364 | 378 | ||
| 365 | od_tuners.up_threshold = input; | 379 | od_tuners->up_threshold = input; |
| 366 | return count; | 380 | return count; |
| 367 | } | 381 | } |
| 368 | 382 | ||
| 369 | static ssize_t store_sampling_down_factor(struct kobject *a, | 383 | static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data, |
| 370 | struct attribute *b, const char *buf, size_t count) | 384 | const char *buf, size_t count) |
| 371 | { | 385 | { |
| 386 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | ||
| 372 | unsigned int input, j; | 387 | unsigned int input, j; |
| 373 | int ret; | 388 | int ret; |
| 374 | ret = sscanf(buf, "%u", &input); | 389 | ret = sscanf(buf, "%u", &input); |
| 375 | 390 | ||
| 376 | if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1) | 391 | if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1) |
| 377 | return -EINVAL; | 392 | return -EINVAL; |
| 378 | od_tuners.sampling_down_factor = input; | 393 | od_tuners->sampling_down_factor = input; |
| 379 | 394 | ||
| 380 | /* Reset down sampling multiplier in case it was active */ | 395 | /* Reset down sampling multiplier in case it was active */ |
| 381 | for_each_online_cpu(j) { | 396 | for_each_online_cpu(j) { |
| @@ -386,9 +401,10 @@ static ssize_t store_sampling_down_factor(struct kobject *a, | |||
| 386 | return count; | 401 | return count; |
| 387 | } | 402 | } |
| 388 | 403 | ||
| 389 | static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | 404 | static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf, |
| 390 | const char *buf, size_t count) | 405 | size_t count) |
| 391 | { | 406 | { |
| 407 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | ||
| 392 | unsigned int input; | 408 | unsigned int input; |
| 393 | int ret; | 409 | int ret; |
| 394 | 410 | ||
| @@ -401,18 +417,18 @@ static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | |||
| 401 | if (input > 1) | 417 | if (input > 1) |
| 402 | input = 1; | 418 | input = 1; |
| 403 | 419 | ||
| 404 | if (input == od_tuners.ignore_nice) { /* nothing to do */ | 420 | if (input == od_tuners->ignore_nice) { /* nothing to do */ |
| 405 | return count; | 421 | return count; |
| 406 | } | 422 | } |
| 407 | od_tuners.ignore_nice = input; | 423 | od_tuners->ignore_nice = input; |
| 408 | 424 | ||
| 409 | /* we need to re-evaluate prev_cpu_idle */ | 425 | /* we need to re-evaluate prev_cpu_idle */ |
| 410 | for_each_online_cpu(j) { | 426 | for_each_online_cpu(j) { |
| 411 | struct od_cpu_dbs_info_s *dbs_info; | 427 | struct od_cpu_dbs_info_s *dbs_info; |
| 412 | dbs_info = &per_cpu(od_cpu_dbs_info, j); | 428 | dbs_info = &per_cpu(od_cpu_dbs_info, j); |
| 413 | dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j, | 429 | dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j, |
| 414 | &dbs_info->cdbs.prev_cpu_wall); | 430 | &dbs_info->cdbs.prev_cpu_wall, od_tuners->io_is_busy); |
| 415 | if (od_tuners.ignore_nice) | 431 | if (od_tuners->ignore_nice) |
| 416 | dbs_info->cdbs.prev_cpu_nice = | 432 | dbs_info->cdbs.prev_cpu_nice = |
| 417 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; | 433 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
| 418 | 434 | ||
| @@ -420,9 +436,10 @@ static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | |||
| 420 | return count; | 436 | return count; |
| 421 | } | 437 | } |
| 422 | 438 | ||
| 423 | static ssize_t store_powersave_bias(struct kobject *a, struct attribute *b, | 439 | static ssize_t store_powersave_bias(struct dbs_data *dbs_data, const char *buf, |
| 424 | const char *buf, size_t count) | 440 | size_t count) |
| 425 | { | 441 | { |
| 442 | struct od_dbs_tuners *od_tuners = dbs_data->tuners; | ||
| 426 | unsigned int input; | 443 | unsigned int input; |
| 427 | int ret; | 444 | int ret; |
| 428 | ret = sscanf(buf, "%u", &input); | 445 | ret = sscanf(buf, "%u", &input); |
| @@ -433,68 +450,179 @@ static ssize_t store_powersave_bias(struct kobject *a, struct attribute *b, | |||
| 433 | if (input > 1000) | 450 | if (input > 1000) |
| 434 | input = 1000; | 451 | input = 1000; |
| 435 | 452 | ||
| 436 | od_tuners.powersave_bias = input; | 453 | od_tuners->powersave_bias = input; |
| 437 | ondemand_powersave_bias_init(); | 454 | ondemand_powersave_bias_init(); |
| 438 | return count; | 455 | return count; |
| 439 | } | 456 | } |
| 440 | 457 | ||
| 441 | show_one(od, sampling_rate, sampling_rate); | 458 | show_store_one(od, sampling_rate); |
| 442 | show_one(od, io_is_busy, io_is_busy); | 459 | show_store_one(od, io_is_busy); |
| 443 | show_one(od, up_threshold, up_threshold); | 460 | show_store_one(od, up_threshold); |
| 444 | show_one(od, sampling_down_factor, sampling_down_factor); | 461 | show_store_one(od, sampling_down_factor); |
| 445 | show_one(od, ignore_nice_load, ignore_nice); | 462 | show_store_one(od, ignore_nice); |
| 446 | show_one(od, powersave_bias, powersave_bias); | 463 | show_store_one(od, powersave_bias); |
| 447 | 464 | declare_show_sampling_rate_min(od); | |
| 448 | define_one_global_rw(sampling_rate); | 465 | |
| 449 | define_one_global_rw(io_is_busy); | 466 | gov_sys_pol_attr_rw(sampling_rate); |
| 450 | define_one_global_rw(up_threshold); | 467 | gov_sys_pol_attr_rw(io_is_busy); |
| 451 | define_one_global_rw(sampling_down_factor); | 468 | gov_sys_pol_attr_rw(up_threshold); |
| 452 | define_one_global_rw(ignore_nice_load); | 469 | gov_sys_pol_attr_rw(sampling_down_factor); |
| 453 | define_one_global_rw(powersave_bias); | 470 | gov_sys_pol_attr_rw(ignore_nice); |
| 454 | define_one_global_ro(sampling_rate_min); | 471 | gov_sys_pol_attr_rw(powersave_bias); |
| 455 | 472 | gov_sys_pol_attr_ro(sampling_rate_min); | |
| 456 | static struct attribute *dbs_attributes[] = { | 473 | |
| 457 | &sampling_rate_min.attr, | 474 | static struct attribute *dbs_attributes_gov_sys[] = { |
| 458 | &sampling_rate.attr, | 475 | &sampling_rate_min_gov_sys.attr, |
| 459 | &up_threshold.attr, | 476 | &sampling_rate_gov_sys.attr, |
| 460 | &sampling_down_factor.attr, | 477 | &up_threshold_gov_sys.attr, |
| 461 | &ignore_nice_load.attr, | 478 | &sampling_down_factor_gov_sys.attr, |
| 462 | &powersave_bias.attr, | 479 | &ignore_nice_gov_sys.attr, |
| 463 | &io_is_busy.attr, | 480 | &powersave_bias_gov_sys.attr, |
| 481 | &io_is_busy_gov_sys.attr, | ||
| 482 | NULL | ||
| 483 | }; | ||
| 484 | |||
| 485 | static struct attribute_group od_attr_group_gov_sys = { | ||
| 486 | .attrs = dbs_attributes_gov_sys, | ||
| 487 | .name = "ondemand", | ||
| 488 | }; | ||
| 489 | |||
| 490 | static struct attribute *dbs_attributes_gov_pol[] = { | ||
| 491 | &sampling_rate_min_gov_pol.attr, | ||
| 492 | &sampling_rate_gov_pol.attr, | ||
| 493 | &up_threshold_gov_pol.attr, | ||
| 494 | &sampling_down_factor_gov_pol.attr, | ||
| 495 | &ignore_nice_gov_pol.attr, | ||
| 496 | &powersave_bias_gov_pol.attr, | ||
| 497 | &io_is_busy_gov_pol.attr, | ||
| 464 | NULL | 498 | NULL |
| 465 | }; | 499 | }; |
| 466 | 500 | ||
| 467 | static struct attribute_group od_attr_group = { | 501 | static struct attribute_group od_attr_group_gov_pol = { |
| 468 | .attrs = dbs_attributes, | 502 | .attrs = dbs_attributes_gov_pol, |
| 469 | .name = "ondemand", | 503 | .name = "ondemand", |
| 470 | }; | 504 | }; |
| 471 | 505 | ||
| 472 | /************************** sysfs end ************************/ | 506 | /************************** sysfs end ************************/ |
| 473 | 507 | ||
| 508 | static int od_init(struct dbs_data *dbs_data) | ||
| 509 | { | ||
| 510 | struct od_dbs_tuners *tuners; | ||
| 511 | u64 idle_time; | ||
| 512 | int cpu; | ||
| 513 | |||
| 514 | tuners = kzalloc(sizeof(struct od_dbs_tuners), GFP_KERNEL); | ||
| 515 | if (!tuners) { | ||
| 516 | pr_err("%s: kzalloc failed\n", __func__); | ||
| 517 | return -ENOMEM; | ||
| 518 | } | ||
| 519 | |||
| 520 | cpu = get_cpu(); | ||
| 521 | idle_time = get_cpu_idle_time_us(cpu, NULL); | ||
| 522 | put_cpu(); | ||
| 523 | if (idle_time != -1ULL) { | ||
| 524 | /* Idle micro accounting is supported. Use finer thresholds */ | ||
| 525 | tuners->up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; | ||
| 526 | tuners->adj_up_threshold = MICRO_FREQUENCY_UP_THRESHOLD - | ||
| 527 | MICRO_FREQUENCY_DOWN_DIFFERENTIAL; | ||
| 528 | /* | ||
| 529 | * In nohz/micro accounting case we set the minimum frequency | ||
| 530 | * not depending on HZ, but fixed (very low). The deferred | ||
| 531 | * timer might skip some samples if idle/sleeping as needed. | ||
| 532 | */ | ||
| 533 | dbs_data->min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE; | ||
| 534 | } else { | ||
| 535 | tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD; | ||
| 536 | tuners->adj_up_threshold = DEF_FREQUENCY_UP_THRESHOLD - | ||
| 537 | DEF_FREQUENCY_DOWN_DIFFERENTIAL; | ||
| 538 | |||
| 539 | /* For correct statistics, we need 10 ticks for each measure */ | ||
| 540 | dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * | ||
| 541 | jiffies_to_usecs(10); | ||
| 542 | } | ||
| 543 | |||
| 544 | tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; | ||
| 545 | tuners->ignore_nice = 0; | ||
| 546 | tuners->powersave_bias = 0; | ||
| 547 | tuners->io_is_busy = should_io_be_busy(); | ||
| 548 | |||
| 549 | dbs_data->tuners = tuners; | ||
| 550 | pr_info("%s: tuners %p\n", __func__, tuners); | ||
| 551 | mutex_init(&dbs_data->mutex); | ||
| 552 | return 0; | ||
| 553 | } | ||
| 554 | |||
| 555 | static void od_exit(struct dbs_data *dbs_data) | ||
| 556 | { | ||
| 557 | kfree(dbs_data->tuners); | ||
| 558 | } | ||
| 559 | |||
| 474 | define_get_cpu_dbs_routines(od_cpu_dbs_info); | 560 | define_get_cpu_dbs_routines(od_cpu_dbs_info); |
| 475 | 561 | ||
| 476 | static struct od_ops od_ops = { | 562 | static struct od_ops od_ops = { |
| 477 | .io_busy = should_io_be_busy, | ||
| 478 | .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu, | 563 | .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu, |
| 479 | .powersave_bias_target = powersave_bias_target, | 564 | .powersave_bias_target = generic_powersave_bias_target, |
| 480 | .freq_increase = dbs_freq_increase, | 565 | .freq_increase = dbs_freq_increase, |
| 481 | }; | 566 | }; |
| 482 | 567 | ||
| 483 | static struct dbs_data od_dbs_data = { | 568 | static struct common_dbs_data od_dbs_cdata = { |
| 484 | .governor = GOV_ONDEMAND, | 569 | .governor = GOV_ONDEMAND, |
| 485 | .attr_group = &od_attr_group, | 570 | .attr_group_gov_sys = &od_attr_group_gov_sys, |
| 486 | .tuners = &od_tuners, | 571 | .attr_group_gov_pol = &od_attr_group_gov_pol, |
| 487 | .get_cpu_cdbs = get_cpu_cdbs, | 572 | .get_cpu_cdbs = get_cpu_cdbs, |
| 488 | .get_cpu_dbs_info_s = get_cpu_dbs_info_s, | 573 | .get_cpu_dbs_info_s = get_cpu_dbs_info_s, |
| 489 | .gov_dbs_timer = od_dbs_timer, | 574 | .gov_dbs_timer = od_dbs_timer, |
| 490 | .gov_check_cpu = od_check_cpu, | 575 | .gov_check_cpu = od_check_cpu, |
| 491 | .gov_ops = &od_ops, | 576 | .gov_ops = &od_ops, |
| 577 | .init = od_init, | ||
| 578 | .exit = od_exit, | ||
| 492 | }; | 579 | }; |
| 493 | 580 | ||
| 581 | static void od_set_powersave_bias(unsigned int powersave_bias) | ||
| 582 | { | ||
| 583 | struct cpufreq_policy *policy; | ||
| 584 | struct dbs_data *dbs_data; | ||
| 585 | struct od_dbs_tuners *od_tuners; | ||
| 586 | unsigned int cpu; | ||
| 587 | cpumask_t done; | ||
| 588 | |||
| 589 | cpumask_clear(&done); | ||
| 590 | |||
| 591 | get_online_cpus(); | ||
| 592 | for_each_online_cpu(cpu) { | ||
| 593 | if (cpumask_test_cpu(cpu, &done)) | ||
| 594 | continue; | ||
| 595 | |||
| 596 | policy = per_cpu(od_cpu_dbs_info, cpu).cdbs.cur_policy; | ||
| 597 | dbs_data = policy->governor_data; | ||
| 598 | od_tuners = dbs_data->tuners; | ||
| 599 | od_tuners->powersave_bias = powersave_bias; | ||
| 600 | |||
| 601 | cpumask_or(&done, &done, policy->cpus); | ||
| 602 | } | ||
| 603 | put_online_cpus(); | ||
| 604 | } | ||
| 605 | |||
| 606 | void od_register_powersave_bias_handler(unsigned int (*f) | ||
| 607 | (struct cpufreq_policy *, unsigned int, unsigned int), | ||
| 608 | unsigned int powersave_bias) | ||
| 609 | { | ||
| 610 | od_ops.powersave_bias_target = f; | ||
| 611 | od_set_powersave_bias(powersave_bias); | ||
| 612 | } | ||
| 613 | EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler); | ||
| 614 | |||
| 615 | void od_unregister_powersave_bias_handler(void) | ||
| 616 | { | ||
| 617 | od_ops.powersave_bias_target = generic_powersave_bias_target; | ||
| 618 | od_set_powersave_bias(0); | ||
| 619 | } | ||
| 620 | EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler); | ||
| 621 | |||
| 494 | static int od_cpufreq_governor_dbs(struct cpufreq_policy *policy, | 622 | static int od_cpufreq_governor_dbs(struct cpufreq_policy *policy, |
| 495 | unsigned int event) | 623 | unsigned int event) |
| 496 | { | 624 | { |
| 497 | return cpufreq_governor_dbs(&od_dbs_data, policy, event); | 625 | return cpufreq_governor_dbs(policy, &od_dbs_cdata, event); |
| 498 | } | 626 | } |
| 499 | 627 | ||
| 500 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND | 628 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND |
| @@ -509,29 +637,6 @@ struct cpufreq_governor cpufreq_gov_ondemand = { | |||
| 509 | 637 | ||
| 510 | static int __init cpufreq_gov_dbs_init(void) | 638 | static int __init cpufreq_gov_dbs_init(void) |
| 511 | { | 639 | { |
| 512 | u64 idle_time; | ||
| 513 | int cpu = get_cpu(); | ||
| 514 | |||
| 515 | mutex_init(&od_dbs_data.mutex); | ||
| 516 | idle_time = get_cpu_idle_time_us(cpu, NULL); | ||
| 517 | put_cpu(); | ||
| 518 | if (idle_time != -1ULL) { | ||
| 519 | /* Idle micro accounting is supported. Use finer thresholds */ | ||
| 520 | od_tuners.up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; | ||
| 521 | od_tuners.adj_up_threshold = MICRO_FREQUENCY_UP_THRESHOLD - | ||
| 522 | MICRO_FREQUENCY_DOWN_DIFFERENTIAL; | ||
| 523 | /* | ||
| 524 | * In nohz/micro accounting case we set the minimum frequency | ||
| 525 | * not depending on HZ, but fixed (very low). The deferred | ||
| 526 | * timer might skip some samples if idle/sleeping as needed. | ||
| 527 | */ | ||
| 528 | od_dbs_data.min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE; | ||
| 529 | } else { | ||
| 530 | /* For correct statistics, we need 10 ticks for each measure */ | ||
| 531 | od_dbs_data.min_sampling_rate = MIN_SAMPLING_RATE_RATIO * | ||
| 532 | jiffies_to_usecs(10); | ||
| 533 | } | ||
| 534 | |||
| 535 | return cpufreq_register_governor(&cpufreq_gov_ondemand); | 640 | return cpufreq_register_governor(&cpufreq_gov_ondemand); |
| 536 | } | 641 | } |
| 537 | 642 | ||
diff --git a/arch/cris/arch-v32/mach-a3/cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c index ee391ecb5bc9..ee142c490575 100644 --- a/arch/cris/arch-v32/mach-a3/cpufreq.c +++ b/drivers/cpufreq/cris-artpec3-cpufreq.c | |||
| @@ -27,23 +27,17 @@ static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu) | |||
| 27 | return clk_ctrl.pll ? 200000 : 6000; | 27 | return clk_ctrl.pll ? 200000 : 6000; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static void cris_freq_set_cpu_state(unsigned int state) | 30 | static void cris_freq_set_cpu_state(struct cpufreq_policy *policy, |
| 31 | unsigned int state) | ||
| 31 | { | 32 | { |
| 32 | int i = 0; | ||
| 33 | struct cpufreq_freqs freqs; | 33 | struct cpufreq_freqs freqs; |
| 34 | reg_clkgen_rw_clk_ctrl clk_ctrl; | 34 | reg_clkgen_rw_clk_ctrl clk_ctrl; |
| 35 | clk_ctrl = REG_RD(clkgen, regi_clkgen, rw_clk_ctrl); | 35 | clk_ctrl = REG_RD(clkgen, regi_clkgen, rw_clk_ctrl); |
| 36 | 36 | ||
| 37 | #ifdef CONFIG_SMP | 37 | freqs.old = cris_freq_get_cpu_frequency(policy->cpu); |
| 38 | for_each_present_cpu(i) | 38 | freqs.new = cris_freq_table[state].frequency; |
| 39 | #endif | ||
| 40 | { | ||
| 41 | freqs.old = cris_freq_get_cpu_frequency(i); | ||
| 42 | freqs.new = cris_freq_table[state].frequency; | ||
| 43 | freqs.cpu = i; | ||
| 44 | } | ||
| 45 | 39 | ||
| 46 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 40 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 47 | 41 | ||
| 48 | local_irq_disable(); | 42 | local_irq_disable(); |
| 49 | 43 | ||
| @@ -57,7 +51,7 @@ static void cris_freq_set_cpu_state(unsigned int state) | |||
| 57 | 51 | ||
| 58 | local_irq_enable(); | 52 | local_irq_enable(); |
| 59 | 53 | ||
| 60 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 54 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 61 | }; | 55 | }; |
| 62 | 56 | ||
| 63 | static int cris_freq_verify(struct cpufreq_policy *policy) | 57 | static int cris_freq_verify(struct cpufreq_policy *policy) |
| @@ -75,7 +69,7 @@ static int cris_freq_target(struct cpufreq_policy *policy, | |||
| 75 | target_freq, relation, &newstate)) | 69 | target_freq, relation, &newstate)) |
| 76 | return -EINVAL; | 70 | return -EINVAL; |
| 77 | 71 | ||
| 78 | cris_freq_set_cpu_state(newstate); | 72 | cris_freq_set_cpu_state(policy, newstate); |
| 79 | 73 | ||
| 80 | return 0; | 74 | return 0; |
| 81 | } | 75 | } |
diff --git a/arch/cris/arch-v32/mach-fs/cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c index d92cf70d1cbe..12952235d5db 100644 --- a/arch/cris/arch-v32/mach-fs/cpufreq.c +++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c | |||
| @@ -27,20 +27,17 @@ static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu) | |||
| 27 | return clk_ctrl.pll ? 200000 : 6000; | 27 | return clk_ctrl.pll ? 200000 : 6000; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static void cris_freq_set_cpu_state(unsigned int state) | 30 | static void cris_freq_set_cpu_state(struct cpufreq_policy *policy, |
| 31 | unsigned int state) | ||
| 31 | { | 32 | { |
| 32 | int i; | ||
| 33 | struct cpufreq_freqs freqs; | 33 | struct cpufreq_freqs freqs; |
| 34 | reg_config_rw_clk_ctrl clk_ctrl; | 34 | reg_config_rw_clk_ctrl clk_ctrl; |
| 35 | clk_ctrl = REG_RD(config, regi_config, rw_clk_ctrl); | 35 | clk_ctrl = REG_RD(config, regi_config, rw_clk_ctrl); |
| 36 | 36 | ||
| 37 | for_each_possible_cpu(i) { | 37 | freqs.old = cris_freq_get_cpu_frequency(policy->cpu); |
| 38 | freqs.old = cris_freq_get_cpu_frequency(i); | 38 | freqs.new = cris_freq_table[state].frequency; |
| 39 | freqs.new = cris_freq_table[state].frequency; | ||
| 40 | freqs.cpu = i; | ||
| 41 | } | ||
| 42 | 39 | ||
| 43 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 40 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 44 | 41 | ||
| 45 | local_irq_disable(); | 42 | local_irq_disable(); |
| 46 | 43 | ||
| @@ -54,7 +51,7 @@ static void cris_freq_set_cpu_state(unsigned int state) | |||
| 54 | 51 | ||
| 55 | local_irq_enable(); | 52 | local_irq_enable(); |
| 56 | 53 | ||
| 57 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 54 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 58 | }; | 55 | }; |
| 59 | 56 | ||
| 60 | static int cris_freq_verify(struct cpufreq_policy *policy) | 57 | static int cris_freq_verify(struct cpufreq_policy *policy) |
| @@ -71,7 +68,7 @@ static int cris_freq_target(struct cpufreq_policy *policy, | |||
| 71 | (policy, cris_freq_table, target_freq, relation, &newstate)) | 68 | (policy, cris_freq_table, target_freq, relation, &newstate)) |
| 72 | return -EINVAL; | 69 | return -EINVAL; |
| 73 | 70 | ||
| 74 | cris_freq_set_cpu_state(newstate); | 71 | cris_freq_set_cpu_state(policy, newstate); |
| 75 | 72 | ||
| 76 | return 0; | 73 | return 0; |
| 77 | } | 74 | } |
diff --git a/arch/arm/mach-davinci/cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c index 4729eaab0f40..c33c76c360fa 100644 --- a/arch/arm/mach-davinci/cpufreq.c +++ b/drivers/cpufreq/davinci-cpufreq.c | |||
| @@ -30,8 +30,6 @@ | |||
| 30 | #include <mach/cpufreq.h> | 30 | #include <mach/cpufreq.h> |
| 31 | #include <mach/common.h> | 31 | #include <mach/common.h> |
| 32 | 32 | ||
| 33 | #include "clock.h" | ||
| 34 | |||
| 35 | struct davinci_cpufreq { | 33 | struct davinci_cpufreq { |
| 36 | struct device *dev; | 34 | struct device *dev; |
| 37 | struct clk *armclk; | 35 | struct clk *armclk; |
| @@ -79,18 +77,8 @@ static int davinci_target(struct cpufreq_policy *policy, | |||
| 79 | struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data; | 77 | struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data; |
| 80 | struct clk *armclk = cpufreq.armclk; | 78 | struct clk *armclk = cpufreq.armclk; |
| 81 | 79 | ||
| 82 | /* | ||
| 83 | * Ensure desired rate is within allowed range. Some govenors | ||
| 84 | * (ondemand) will just pass target_freq=0 to get the minimum. | ||
| 85 | */ | ||
| 86 | if (target_freq < policy->cpuinfo.min_freq) | ||
| 87 | target_freq = policy->cpuinfo.min_freq; | ||
| 88 | if (target_freq > policy->cpuinfo.max_freq) | ||
| 89 | target_freq = policy->cpuinfo.max_freq; | ||
| 90 | |||
| 91 | freqs.old = davinci_getspeed(0); | 80 | freqs.old = davinci_getspeed(0); |
| 92 | freqs.new = clk_round_rate(armclk, target_freq * 1000) / 1000; | 81 | freqs.new = clk_round_rate(armclk, target_freq * 1000) / 1000; |
| 93 | freqs.cpu = 0; | ||
| 94 | 82 | ||
| 95 | if (freqs.old == freqs.new) | 83 | if (freqs.old == freqs.new) |
| 96 | return ret; | 84 | return ret; |
| @@ -102,7 +90,7 @@ static int davinci_target(struct cpufreq_policy *policy, | |||
| 102 | if (ret) | 90 | if (ret) |
| 103 | return -EINVAL; | 91 | return -EINVAL; |
| 104 | 92 | ||
| 105 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 93 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 106 | 94 | ||
| 107 | /* if moving to higher frequency, up the voltage beforehand */ | 95 | /* if moving to higher frequency, up the voltage beforehand */ |
| 108 | if (pdata->set_voltage && freqs.new > freqs.old) { | 96 | if (pdata->set_voltage && freqs.new > freqs.old) { |
| @@ -126,7 +114,7 @@ static int davinci_target(struct cpufreq_policy *policy, | |||
| 126 | pdata->set_voltage(idx); | 114 | pdata->set_voltage(idx); |
| 127 | 115 | ||
| 128 | out: | 116 | out: |
| 129 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 117 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 130 | 118 | ||
| 131 | return ret; | 119 | return ret; |
| 132 | } | 120 | } |
| @@ -147,21 +135,16 @@ static int davinci_cpu_init(struct cpufreq_policy *policy) | |||
| 147 | return result; | 135 | return result; |
| 148 | } | 136 | } |
| 149 | 137 | ||
| 150 | policy->cur = policy->min = policy->max = davinci_getspeed(0); | 138 | policy->cur = davinci_getspeed(0); |
| 151 | 139 | ||
| 152 | if (freq_table) { | 140 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); |
| 153 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); | 141 | if (result) { |
| 154 | if (!result) | 142 | pr_err("%s: cpufreq_frequency_table_cpuinfo() failed", |
| 155 | cpufreq_frequency_table_get_attr(freq_table, | 143 | __func__); |
| 156 | policy->cpu); | 144 | return result; |
| 157 | } else { | ||
| 158 | policy->cpuinfo.min_freq = policy->min; | ||
| 159 | policy->cpuinfo.max_freq = policy->max; | ||
| 160 | } | 145 | } |
| 161 | 146 | ||
| 162 | policy->min = policy->cpuinfo.min_freq; | 147 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); |
| 163 | policy->max = policy->cpuinfo.max_freq; | ||
| 164 | policy->cur = davinci_getspeed(0); | ||
| 165 | 148 | ||
| 166 | /* | 149 | /* |
| 167 | * Time measurement across the target() function yields ~1500-1800us | 150 | * Time measurement across the target() function yields ~1500-1800us |
diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c index 72f0c3efa76e..6ec6539ae041 100644 --- a/drivers/cpufreq/dbx500-cpufreq.c +++ b/drivers/cpufreq/dbx500-cpufreq.c | |||
| @@ -37,12 +37,6 @@ static int dbx500_cpufreq_target(struct cpufreq_policy *policy, | |||
| 37 | unsigned int idx; | 37 | unsigned int idx; |
| 38 | int ret; | 38 | int ret; |
| 39 | 39 | ||
| 40 | /* scale the target frequency to one of the extremes supported */ | ||
| 41 | if (target_freq < policy->cpuinfo.min_freq) | ||
| 42 | target_freq = policy->cpuinfo.min_freq; | ||
| 43 | if (target_freq > policy->cpuinfo.max_freq) | ||
| 44 | target_freq = policy->cpuinfo.max_freq; | ||
| 45 | |||
| 46 | /* Lookup the next frequency */ | 40 | /* Lookup the next frequency */ |
| 47 | if (cpufreq_frequency_table_target(policy, freq_table, target_freq, | 41 | if (cpufreq_frequency_table_target(policy, freq_table, target_freq, |
| 48 | relation, &idx)) | 42 | relation, &idx)) |
| @@ -55,8 +49,7 @@ static int dbx500_cpufreq_target(struct cpufreq_policy *policy, | |||
| 55 | return 0; | 49 | return 0; |
| 56 | 50 | ||
| 57 | /* pre-change notification */ | 51 | /* pre-change notification */ |
| 58 | for_each_cpu(freqs.cpu, policy->cpus) | 52 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 59 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 60 | 53 | ||
| 61 | /* update armss clk frequency */ | 54 | /* update armss clk frequency */ |
| 62 | ret = clk_set_rate(armss_clk, freqs.new * 1000); | 55 | ret = clk_set_rate(armss_clk, freqs.new * 1000); |
| @@ -68,8 +61,7 @@ static int dbx500_cpufreq_target(struct cpufreq_policy *policy, | |||
| 68 | } | 61 | } |
| 69 | 62 | ||
| 70 | /* post change notification */ | 63 | /* post change notification */ |
| 71 | for_each_cpu(freqs.cpu, policy->cpus) | 64 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 72 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 73 | 65 | ||
| 74 | return 0; | 66 | return 0; |
| 75 | } | 67 | } |
| @@ -79,15 +71,15 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu) | |||
| 79 | int i = 0; | 71 | int i = 0; |
| 80 | unsigned long freq = clk_get_rate(armss_clk) / 1000; | 72 | unsigned long freq = clk_get_rate(armss_clk) / 1000; |
| 81 | 73 | ||
| 82 | while (freq_table[i].frequency != CPUFREQ_TABLE_END) { | 74 | /* The value is rounded to closest frequency in the defined table. */ |
| 83 | if (freq <= freq_table[i].frequency) | 75 | while (freq_table[i + 1].frequency != CPUFREQ_TABLE_END) { |
| 76 | if (freq < freq_table[i].frequency + | ||
| 77 | (freq_table[i + 1].frequency - freq_table[i].frequency) / 2) | ||
| 84 | return freq_table[i].frequency; | 78 | return freq_table[i].frequency; |
| 85 | i++; | 79 | i++; |
| 86 | } | 80 | } |
| 87 | 81 | ||
| 88 | /* We could not find a corresponding frequency. */ | 82 | return freq_table[i].frequency; |
| 89 | pr_err("dbx500-cpufreq: Failed to find cpufreq speed\n"); | ||
| 90 | return 0; | ||
| 91 | } | 83 | } |
| 92 | 84 | ||
| 93 | static int __cpuinit dbx500_cpufreq_init(struct cpufreq_policy *policy) | 85 | static int __cpuinit dbx500_cpufreq_init(struct cpufreq_policy *policy) |
diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c index 3fffbe6025cd..37380fb92621 100644 --- a/drivers/cpufreq/e_powersaver.c +++ b/drivers/cpufreq/e_powersaver.c | |||
| @@ -104,7 +104,7 @@ static unsigned int eps_get(unsigned int cpu) | |||
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | static int eps_set_state(struct eps_cpu_data *centaur, | 106 | static int eps_set_state(struct eps_cpu_data *centaur, |
| 107 | unsigned int cpu, | 107 | struct cpufreq_policy *policy, |
| 108 | u32 dest_state) | 108 | u32 dest_state) |
| 109 | { | 109 | { |
| 110 | struct cpufreq_freqs freqs; | 110 | struct cpufreq_freqs freqs; |
| @@ -112,10 +112,9 @@ static int eps_set_state(struct eps_cpu_data *centaur, | |||
| 112 | int err = 0; | 112 | int err = 0; |
| 113 | int i; | 113 | int i; |
| 114 | 114 | ||
| 115 | freqs.old = eps_get(cpu); | 115 | freqs.old = eps_get(policy->cpu); |
| 116 | freqs.new = centaur->fsb * ((dest_state >> 8) & 0xff); | 116 | freqs.new = centaur->fsb * ((dest_state >> 8) & 0xff); |
| 117 | freqs.cpu = cpu; | 117 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 118 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 119 | 118 | ||
| 120 | /* Wait while CPU is busy */ | 119 | /* Wait while CPU is busy */ |
| 121 | rdmsr(MSR_IA32_PERF_STATUS, lo, hi); | 120 | rdmsr(MSR_IA32_PERF_STATUS, lo, hi); |
| @@ -162,7 +161,7 @@ postchange: | |||
| 162 | current_multiplier); | 161 | current_multiplier); |
| 163 | } | 162 | } |
| 164 | #endif | 163 | #endif |
| 165 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 164 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 166 | return err; | 165 | return err; |
| 167 | } | 166 | } |
| 168 | 167 | ||
| @@ -190,7 +189,7 @@ static int eps_target(struct cpufreq_policy *policy, | |||
| 190 | 189 | ||
| 191 | /* Make frequency transition */ | 190 | /* Make frequency transition */ |
| 192 | dest_state = centaur->freq_table[newstate].index & 0xffff; | 191 | dest_state = centaur->freq_table[newstate].index & 0xffff; |
| 193 | ret = eps_set_state(centaur, cpu, dest_state); | 192 | ret = eps_set_state(centaur, policy, dest_state); |
| 194 | if (ret) | 193 | if (ret) |
| 195 | printk(KERN_ERR "eps: Timeout!\n"); | 194 | printk(KERN_ERR "eps: Timeout!\n"); |
| 196 | return ret; | 195 | return ret; |
diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c index 960671fd3d7e..658d860344b0 100644 --- a/drivers/cpufreq/elanfreq.c +++ b/drivers/cpufreq/elanfreq.c | |||
| @@ -117,15 +117,15 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu) | |||
| 117 | * There is no return value. | 117 | * There is no return value. |
| 118 | */ | 118 | */ |
| 119 | 119 | ||
| 120 | static void elanfreq_set_cpu_state(unsigned int state) | 120 | static void elanfreq_set_cpu_state(struct cpufreq_policy *policy, |
| 121 | unsigned int state) | ||
| 121 | { | 122 | { |
| 122 | struct cpufreq_freqs freqs; | 123 | struct cpufreq_freqs freqs; |
| 123 | 124 | ||
| 124 | freqs.old = elanfreq_get_cpu_frequency(0); | 125 | freqs.old = elanfreq_get_cpu_frequency(0); |
| 125 | freqs.new = elan_multiplier[state].clock; | 126 | freqs.new = elan_multiplier[state].clock; |
| 126 | freqs.cpu = 0; /* elanfreq.c is UP only driver */ | ||
| 127 | 127 | ||
| 128 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 128 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 129 | 129 | ||
| 130 | printk(KERN_INFO "elanfreq: attempting to set frequency to %i kHz\n", | 130 | printk(KERN_INFO "elanfreq: attempting to set frequency to %i kHz\n", |
| 131 | elan_multiplier[state].clock); | 131 | elan_multiplier[state].clock); |
| @@ -161,7 +161,7 @@ static void elanfreq_set_cpu_state(unsigned int state) | |||
| 161 | udelay(10000); | 161 | udelay(10000); |
| 162 | local_irq_enable(); | 162 | local_irq_enable(); |
| 163 | 163 | ||
| 164 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 164 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 165 | }; | 165 | }; |
| 166 | 166 | ||
| 167 | 167 | ||
| @@ -188,7 +188,7 @@ static int elanfreq_target(struct cpufreq_policy *policy, | |||
| 188 | target_freq, relation, &newstate)) | 188 | target_freq, relation, &newstate)) |
| 189 | return -EINVAL; | 189 | return -EINVAL; |
| 190 | 190 | ||
| 191 | elanfreq_set_cpu_state(newstate); | 191 | elanfreq_set_cpu_state(policy, newstate); |
| 192 | 192 | ||
| 193 | return 0; | 193 | return 0; |
| 194 | } | 194 | } |
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c index 78057a357ddb..475b4f607f0d 100644 --- a/drivers/cpufreq/exynos-cpufreq.c +++ b/drivers/cpufreq/exynos-cpufreq.c | |||
| @@ -70,7 +70,6 @@ static int exynos_cpufreq_scale(unsigned int target_freq) | |||
| 70 | 70 | ||
| 71 | freqs.old = policy->cur; | 71 | freqs.old = policy->cur; |
| 72 | freqs.new = target_freq; | 72 | freqs.new = target_freq; |
| 73 | freqs.cpu = policy->cpu; | ||
| 74 | 73 | ||
| 75 | if (freqs.new == freqs.old) | 74 | if (freqs.new == freqs.old) |
| 76 | goto out; | 75 | goto out; |
| @@ -105,8 +104,7 @@ static int exynos_cpufreq_scale(unsigned int target_freq) | |||
| 105 | } | 104 | } |
| 106 | arm_volt = volt_table[index]; | 105 | arm_volt = volt_table[index]; |
| 107 | 106 | ||
| 108 | for_each_cpu(freqs.cpu, policy->cpus) | 107 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 109 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 110 | 108 | ||
| 111 | /* When the new frequency is higher than current frequency */ | 109 | /* When the new frequency is higher than current frequency */ |
| 112 | if ((freqs.new > freqs.old) && !safe_arm_volt) { | 110 | if ((freqs.new > freqs.old) && !safe_arm_volt) { |
| @@ -131,8 +129,7 @@ static int exynos_cpufreq_scale(unsigned int target_freq) | |||
| 131 | 129 | ||
| 132 | exynos_info->set_freq(old_index, index); | 130 | exynos_info->set_freq(old_index, index); |
| 133 | 131 | ||
| 134 | for_each_cpu(freqs.cpu, policy->cpus) | 132 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 135 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 136 | 133 | ||
| 137 | /* When the new frequency is lower than current frequency */ | 134 | /* When the new frequency is lower than current frequency */ |
| 138 | if ((freqs.new < freqs.old) || | 135 | if ((freqs.new < freqs.old) || |
| @@ -297,7 +294,7 @@ static int __init exynos_cpufreq_init(void) | |||
| 297 | else if (soc_is_exynos5250()) | 294 | else if (soc_is_exynos5250()) |
| 298 | ret = exynos5250_cpufreq_init(exynos_info); | 295 | ret = exynos5250_cpufreq_init(exynos_info); |
| 299 | else | 296 | else |
| 300 | pr_err("%s: CPU type not found\n", __func__); | 297 | return 0; |
| 301 | 298 | ||
| 302 | if (ret) | 299 | if (ret) |
| 303 | goto err_vdd_arm; | 300 | goto err_vdd_arm; |
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c new file mode 100644 index 000000000000..0c74018eda47 --- /dev/null +++ b/drivers/cpufreq/exynos5440-cpufreq.c | |||
| @@ -0,0 +1,481 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | ||
| 3 | * http://www.samsung.com | ||
| 4 | * | ||
| 5 | * Amit Daniel Kachhap <amit.daniel@samsung.com> | ||
| 6 | * | ||
| 7 | * EXYNOS5440 - CPU frequency scaling support | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License version 2 as | ||
| 11 | * published by the Free Software Foundation. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/clk.h> | ||
| 15 | #include <linux/cpu.h> | ||
| 16 | #include <linux/cpufreq.h> | ||
| 17 | #include <linux/err.h> | ||
| 18 | #include <linux/interrupt.h> | ||
| 19 | #include <linux/io.h> | ||
| 20 | #include <linux/module.h> | ||
| 21 | #include <linux/of_address.h> | ||
| 22 | #include <linux/of_irq.h> | ||
| 23 | #include <linux/opp.h> | ||
| 24 | #include <linux/platform_device.h> | ||
| 25 | #include <linux/slab.h> | ||
| 26 | |||
| 27 | /* Register definitions */ | ||
| 28 | #define XMU_DVFS_CTRL 0x0060 | ||
| 29 | #define XMU_PMU_P0_7 0x0064 | ||
| 30 | #define XMU_C0_3_PSTATE 0x0090 | ||
| 31 | #define XMU_P_LIMIT 0x00a0 | ||
| 32 | #define XMU_P_STATUS 0x00a4 | ||
| 33 | #define XMU_PMUEVTEN 0x00d0 | ||
| 34 | #define XMU_PMUIRQEN 0x00d4 | ||
| 35 | #define XMU_PMUIRQ 0x00d8 | ||
| 36 | |||
| 37 | /* PMU mask and shift definations */ | ||
| 38 | #define P_VALUE_MASK 0x7 | ||
| 39 | |||
| 40 | #define XMU_DVFS_CTRL_EN_SHIFT 0 | ||
| 41 | |||
| 42 | #define P0_7_CPUCLKDEV_SHIFT 21 | ||
| 43 | #define P0_7_CPUCLKDEV_MASK 0x7 | ||
| 44 | #define P0_7_ATBCLKDEV_SHIFT 18 | ||
| 45 | #define P0_7_ATBCLKDEV_MASK 0x7 | ||
| 46 | #define P0_7_CSCLKDEV_SHIFT 15 | ||
| 47 | #define P0_7_CSCLKDEV_MASK 0x7 | ||
| 48 | #define P0_7_CPUEMA_SHIFT 28 | ||
| 49 | #define P0_7_CPUEMA_MASK 0xf | ||
| 50 | #define P0_7_L2EMA_SHIFT 24 | ||
| 51 | #define P0_7_L2EMA_MASK 0xf | ||
| 52 | #define P0_7_VDD_SHIFT 8 | ||
| 53 | #define P0_7_VDD_MASK 0x7f | ||
| 54 | #define P0_7_FREQ_SHIFT 0 | ||
| 55 | #define P0_7_FREQ_MASK 0xff | ||
| 56 | |||
| 57 | #define C0_3_PSTATE_VALID_SHIFT 8 | ||
| 58 | #define C0_3_PSTATE_CURR_SHIFT 4 | ||
| 59 | #define C0_3_PSTATE_NEW_SHIFT 0 | ||
| 60 | |||
| 61 | #define PSTATE_CHANGED_EVTEN_SHIFT 0 | ||
| 62 | |||
| 63 | #define PSTATE_CHANGED_IRQEN_SHIFT 0 | ||
| 64 | |||
| 65 | #define PSTATE_CHANGED_SHIFT 0 | ||
| 66 | |||
| 67 | /* some constant values for clock divider calculation */ | ||
| 68 | #define CPU_DIV_FREQ_MAX 500 | ||
| 69 | #define CPU_DBG_FREQ_MAX 375 | ||
| 70 | #define CPU_ATB_FREQ_MAX 500 | ||
| 71 | |||
| 72 | #define PMIC_LOW_VOLT 0x30 | ||
| 73 | #define PMIC_HIGH_VOLT 0x28 | ||
| 74 | |||
| 75 | #define CPUEMA_HIGH 0x2 | ||
| 76 | #define CPUEMA_MID 0x4 | ||
| 77 | #define CPUEMA_LOW 0x7 | ||
| 78 | |||
| 79 | #define L2EMA_HIGH 0x1 | ||
| 80 | #define L2EMA_MID 0x3 | ||
| 81 | #define L2EMA_LOW 0x4 | ||
| 82 | |||
| 83 | #define DIV_TAB_MAX 2 | ||
| 84 | /* frequency unit is 20MHZ */ | ||
| 85 | #define FREQ_UNIT 20 | ||
| 86 | #define MAX_VOLTAGE 1550000 /* In microvolt */ | ||
| 87 | #define VOLTAGE_STEP 12500 /* In microvolt */ | ||
| 88 | |||
| 89 | #define CPUFREQ_NAME "exynos5440_dvfs" | ||
| 90 | #define DEF_TRANS_LATENCY 100000 | ||
| 91 | |||
| 92 | enum cpufreq_level_index { | ||
| 93 | L0, L1, L2, L3, L4, | ||
| 94 | L5, L6, L7, L8, L9, | ||
| 95 | }; | ||
| 96 | #define CPUFREQ_LEVEL_END (L7 + 1) | ||
| 97 | |||
| 98 | struct exynos_dvfs_data { | ||
| 99 | void __iomem *base; | ||
| 100 | struct resource *mem; | ||
| 101 | int irq; | ||
| 102 | struct clk *cpu_clk; | ||
| 103 | unsigned int cur_frequency; | ||
| 104 | unsigned int latency; | ||
| 105 | struct cpufreq_frequency_table *freq_table; | ||
| 106 | unsigned int freq_count; | ||
| 107 | struct device *dev; | ||
| 108 | bool dvfs_enabled; | ||
| 109 | struct work_struct irq_work; | ||
| 110 | }; | ||
| 111 | |||
| 112 | static struct exynos_dvfs_data *dvfs_info; | ||
| 113 | static DEFINE_MUTEX(cpufreq_lock); | ||
| 114 | static struct cpufreq_freqs freqs; | ||
| 115 | |||
| 116 | static int init_div_table(void) | ||
| 117 | { | ||
| 118 | struct cpufreq_frequency_table *freq_tbl = dvfs_info->freq_table; | ||
| 119 | unsigned int tmp, clk_div, ema_div, freq, volt_id; | ||
| 120 | int i = 0; | ||
| 121 | struct opp *opp; | ||
| 122 | |||
| 123 | rcu_read_lock(); | ||
| 124 | for (i = 0; freq_tbl[i].frequency != CPUFREQ_TABLE_END; i++) { | ||
| 125 | |||
| 126 | opp = opp_find_freq_exact(dvfs_info->dev, | ||
| 127 | freq_tbl[i].frequency * 1000, true); | ||
| 128 | if (IS_ERR(opp)) { | ||
| 129 | rcu_read_unlock(); | ||
| 130 | dev_err(dvfs_info->dev, | ||
| 131 | "failed to find valid OPP for %u KHZ\n", | ||
| 132 | freq_tbl[i].frequency); | ||
| 133 | return PTR_ERR(opp); | ||
| 134 | } | ||
| 135 | |||
| 136 | freq = freq_tbl[i].frequency / 1000; /* In MHZ */ | ||
| 137 | clk_div = ((freq / CPU_DIV_FREQ_MAX) & P0_7_CPUCLKDEV_MASK) | ||
| 138 | << P0_7_CPUCLKDEV_SHIFT; | ||
| 139 | clk_div |= ((freq / CPU_ATB_FREQ_MAX) & P0_7_ATBCLKDEV_MASK) | ||
| 140 | << P0_7_ATBCLKDEV_SHIFT; | ||
| 141 | clk_div |= ((freq / CPU_DBG_FREQ_MAX) & P0_7_CSCLKDEV_MASK) | ||
| 142 | << P0_7_CSCLKDEV_SHIFT; | ||
| 143 | |||
| 144 | /* Calculate EMA */ | ||
| 145 | volt_id = opp_get_voltage(opp); | ||
| 146 | volt_id = (MAX_VOLTAGE - volt_id) / VOLTAGE_STEP; | ||
| 147 | if (volt_id < PMIC_HIGH_VOLT) { | ||
| 148 | ema_div = (CPUEMA_HIGH << P0_7_CPUEMA_SHIFT) | | ||
| 149 | (L2EMA_HIGH << P0_7_L2EMA_SHIFT); | ||
| 150 | } else if (volt_id > PMIC_LOW_VOLT) { | ||
| 151 | ema_div = (CPUEMA_LOW << P0_7_CPUEMA_SHIFT) | | ||
| 152 | (L2EMA_LOW << P0_7_L2EMA_SHIFT); | ||
| 153 | } else { | ||
| 154 | ema_div = (CPUEMA_MID << P0_7_CPUEMA_SHIFT) | | ||
| 155 | (L2EMA_MID << P0_7_L2EMA_SHIFT); | ||
| 156 | } | ||
| 157 | |||
| 158 | tmp = (clk_div | ema_div | (volt_id << P0_7_VDD_SHIFT) | ||
| 159 | | ((freq / FREQ_UNIT) << P0_7_FREQ_SHIFT)); | ||
| 160 | |||
| 161 | __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * i); | ||
| 162 | } | ||
| 163 | |||
| 164 | rcu_read_unlock(); | ||
| 165 | return 0; | ||
| 166 | } | ||
| 167 | |||
| 168 | static void exynos_enable_dvfs(void) | ||
| 169 | { | ||
| 170 | unsigned int tmp, i, cpu; | ||
| 171 | struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table; | ||
| 172 | /* Disable DVFS */ | ||
| 173 | __raw_writel(0, dvfs_info->base + XMU_DVFS_CTRL); | ||
| 174 | |||
| 175 | /* Enable PSTATE Change Event */ | ||
| 176 | tmp = __raw_readl(dvfs_info->base + XMU_PMUEVTEN); | ||
| 177 | tmp |= (1 << PSTATE_CHANGED_EVTEN_SHIFT); | ||
| 178 | __raw_writel(tmp, dvfs_info->base + XMU_PMUEVTEN); | ||
| 179 | |||
| 180 | /* Enable PSTATE Change IRQ */ | ||
| 181 | tmp = __raw_readl(dvfs_info->base + XMU_PMUIRQEN); | ||
| 182 | tmp |= (1 << PSTATE_CHANGED_IRQEN_SHIFT); | ||
| 183 | __raw_writel(tmp, dvfs_info->base + XMU_PMUIRQEN); | ||
| 184 | |||
| 185 | /* Set initial performance index */ | ||
| 186 | for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) | ||
| 187 | if (freq_table[i].frequency == dvfs_info->cur_frequency) | ||
| 188 | break; | ||
| 189 | |||
| 190 | if (freq_table[i].frequency == CPUFREQ_TABLE_END) { | ||
| 191 | dev_crit(dvfs_info->dev, "Boot up frequency not supported\n"); | ||
| 192 | /* Assign the highest frequency */ | ||
| 193 | i = 0; | ||
| 194 | dvfs_info->cur_frequency = freq_table[i].frequency; | ||
| 195 | } | ||
| 196 | |||
| 197 | dev_info(dvfs_info->dev, "Setting dvfs initial frequency = %uKHZ", | ||
| 198 | dvfs_info->cur_frequency); | ||
| 199 | |||
| 200 | for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++) { | ||
| 201 | tmp = __raw_readl(dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4); | ||
| 202 | tmp &= ~(P_VALUE_MASK << C0_3_PSTATE_NEW_SHIFT); | ||
| 203 | tmp |= (i << C0_3_PSTATE_NEW_SHIFT); | ||
| 204 | __raw_writel(tmp, dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4); | ||
| 205 | } | ||
| 206 | |||
| 207 | /* Enable DVFS */ | ||
| 208 | __raw_writel(1 << XMU_DVFS_CTRL_EN_SHIFT, | ||
| 209 | dvfs_info->base + XMU_DVFS_CTRL); | ||
| 210 | } | ||
| 211 | |||
| 212 | static int exynos_verify_speed(struct cpufreq_policy *policy) | ||
| 213 | { | ||
| 214 | return cpufreq_frequency_table_verify(policy, | ||
| 215 | dvfs_info->freq_table); | ||
| 216 | } | ||
| 217 | |||
| 218 | static unsigned int exynos_getspeed(unsigned int cpu) | ||
| 219 | { | ||
| 220 | return dvfs_info->cur_frequency; | ||
| 221 | } | ||
| 222 | |||
| 223 | static int exynos_target(struct cpufreq_policy *policy, | ||
| 224 | unsigned int target_freq, | ||
| 225 | unsigned int relation) | ||
| 226 | { | ||
| 227 | unsigned int index, tmp; | ||
| 228 | int ret = 0, i; | ||
| 229 | struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table; | ||
| 230 | |||
| 231 | mutex_lock(&cpufreq_lock); | ||
| 232 | |||
| 233 | ret = cpufreq_frequency_table_target(policy, freq_table, | ||
| 234 | target_freq, relation, &index); | ||
| 235 | if (ret) | ||
| 236 | goto out; | ||
| 237 | |||
| 238 | freqs.old = dvfs_info->cur_frequency; | ||
| 239 | freqs.new = freq_table[index].frequency; | ||
| 240 | |||
| 241 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
| 242 | |||
| 243 | /* Set the target frequency in all C0_3_PSTATE register */ | ||
| 244 | for_each_cpu(i, policy->cpus) { | ||
| 245 | tmp = __raw_readl(dvfs_info->base + XMU_C0_3_PSTATE + i * 4); | ||
| 246 | tmp &= ~(P_VALUE_MASK << C0_3_PSTATE_NEW_SHIFT); | ||
| 247 | tmp |= (index << C0_3_PSTATE_NEW_SHIFT); | ||
| 248 | |||
| 249 | __raw_writel(tmp, dvfs_info->base + XMU_C0_3_PSTATE + i * 4); | ||
| 250 | } | ||
| 251 | out: | ||
| 252 | mutex_unlock(&cpufreq_lock); | ||
| 253 | return ret; | ||
| 254 | } | ||
| 255 | |||
| 256 | static void exynos_cpufreq_work(struct work_struct *work) | ||
| 257 | { | ||
| 258 | unsigned int cur_pstate, index; | ||
| 259 | struct cpufreq_policy *policy = cpufreq_cpu_get(0); /* boot CPU */ | ||
| 260 | struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table; | ||
| 261 | |||
| 262 | /* Ensure we can access cpufreq structures */ | ||
| 263 | if (unlikely(dvfs_info->dvfs_enabled == false)) | ||
| 264 | goto skip_work; | ||
| 265 | |||
| 266 | mutex_lock(&cpufreq_lock); | ||
| 267 | freqs.old = dvfs_info->cur_frequency; | ||
| 268 | |||
| 269 | cur_pstate = __raw_readl(dvfs_info->base + XMU_P_STATUS); | ||
| 270 | if (cur_pstate >> C0_3_PSTATE_VALID_SHIFT & 0x1) | ||
| 271 | index = (cur_pstate >> C0_3_PSTATE_CURR_SHIFT) & P_VALUE_MASK; | ||
| 272 | else | ||
| 273 | index = (cur_pstate >> C0_3_PSTATE_NEW_SHIFT) & P_VALUE_MASK; | ||
| 274 | |||
| 275 | if (likely(index < dvfs_info->freq_count)) { | ||
| 276 | freqs.new = freq_table[index].frequency; | ||
| 277 | dvfs_info->cur_frequency = freqs.new; | ||
| 278 | } else { | ||
| 279 | dev_crit(dvfs_info->dev, "New frequency out of range\n"); | ||
| 280 | freqs.new = dvfs_info->cur_frequency; | ||
| 281 | } | ||
| 282 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
| 283 | |||
| 284 | cpufreq_cpu_put(policy); | ||
| 285 | mutex_unlock(&cpufreq_lock); | ||
| 286 | skip_work: | ||
| 287 | enable_irq(dvfs_info->irq); | ||
| 288 | } | ||
| 289 | |||
| 290 | static irqreturn_t exynos_cpufreq_irq(int irq, void *id) | ||
| 291 | { | ||
| 292 | unsigned int tmp; | ||
| 293 | |||
| 294 | tmp = __raw_readl(dvfs_info->base + XMU_PMUIRQ); | ||
| 295 | if (tmp >> PSTATE_CHANGED_SHIFT & 0x1) { | ||
| 296 | __raw_writel(tmp, dvfs_info->base + XMU_PMUIRQ); | ||
| 297 | disable_irq_nosync(irq); | ||
| 298 | schedule_work(&dvfs_info->irq_work); | ||
| 299 | } | ||
| 300 | return IRQ_HANDLED; | ||
| 301 | } | ||
| 302 | |||
| 303 | static void exynos_sort_descend_freq_table(void) | ||
| 304 | { | ||
| 305 | struct cpufreq_frequency_table *freq_tbl = dvfs_info->freq_table; | ||
| 306 | int i = 0, index; | ||
| 307 | unsigned int tmp_freq; | ||
| 308 | /* | ||
| 309 | * Exynos5440 clock controller state logic expects the cpufreq table to | ||
| 310 | * be in descending order. But the OPP library constructs the table in | ||
| 311 | * ascending order. So to make the table descending we just need to | ||
| 312 | * swap the i element with the N - i element. | ||
| 313 | */ | ||
| 314 | for (i = 0; i < dvfs_info->freq_count / 2; i++) { | ||
| 315 | index = dvfs_info->freq_count - i - 1; | ||
| 316 | tmp_freq = freq_tbl[i].frequency; | ||
| 317 | freq_tbl[i].frequency = freq_tbl[index].frequency; | ||
| 318 | freq_tbl[index].frequency = tmp_freq; | ||
| 319 | } | ||
| 320 | } | ||
| 321 | |||
| 322 | static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy) | ||
| 323 | { | ||
| 324 | int ret; | ||
| 325 | |||
| 326 | ret = cpufreq_frequency_table_cpuinfo(policy, dvfs_info->freq_table); | ||
| 327 | if (ret) { | ||
| 328 | dev_err(dvfs_info->dev, "Invalid frequency table: %d\n", ret); | ||
| 329 | return ret; | ||
| 330 | } | ||
| 331 | |||
| 332 | policy->cur = dvfs_info->cur_frequency; | ||
| 333 | policy->cpuinfo.transition_latency = dvfs_info->latency; | ||
| 334 | cpumask_setall(policy->cpus); | ||
| 335 | |||
| 336 | cpufreq_frequency_table_get_attr(dvfs_info->freq_table, policy->cpu); | ||
| 337 | |||
| 338 | return 0; | ||
| 339 | } | ||
| 340 | |||
| 341 | static struct cpufreq_driver exynos_driver = { | ||
| 342 | .flags = CPUFREQ_STICKY, | ||
| 343 | .verify = exynos_verify_speed, | ||
| 344 | .target = exynos_target, | ||
| 345 | .get = exynos_getspeed, | ||
| 346 | .init = exynos_cpufreq_cpu_init, | ||
| 347 | .name = CPUFREQ_NAME, | ||
| 348 | }; | ||
| 349 | |||
| 350 | static const struct of_device_id exynos_cpufreq_match[] = { | ||
| 351 | { | ||
| 352 | .compatible = "samsung,exynos5440-cpufreq", | ||
| 353 | }, | ||
| 354 | {}, | ||
| 355 | }; | ||
| 356 | MODULE_DEVICE_TABLE(of, exynos_cpufreq_match); | ||
| 357 | |||
| 358 | static int exynos_cpufreq_probe(struct platform_device *pdev) | ||
| 359 | { | ||
| 360 | int ret = -EINVAL; | ||
| 361 | struct device_node *np; | ||
| 362 | struct resource res; | ||
| 363 | |||
| 364 | np = pdev->dev.of_node; | ||
| 365 | if (!np) | ||
| 366 | return -ENODEV; | ||
| 367 | |||
| 368 | dvfs_info = devm_kzalloc(&pdev->dev, sizeof(*dvfs_info), GFP_KERNEL); | ||
| 369 | if (!dvfs_info) { | ||
| 370 | ret = -ENOMEM; | ||
| 371 | goto err_put_node; | ||
| 372 | } | ||
| 373 | |||
| 374 | dvfs_info->dev = &pdev->dev; | ||
| 375 | |||
| 376 | ret = of_address_to_resource(np, 0, &res); | ||
| 377 | if (ret) | ||
| 378 | goto err_put_node; | ||
| 379 | |||
| 380 | dvfs_info->base = devm_ioremap_resource(dvfs_info->dev, &res); | ||
| 381 | if (IS_ERR(dvfs_info->base)) { | ||
| 382 | ret = PTR_ERR(dvfs_info->base); | ||
| 383 | goto err_put_node; | ||
| 384 | } | ||
| 385 | |||
| 386 | dvfs_info->irq = irq_of_parse_and_map(np, 0); | ||
| 387 | if (!dvfs_info->irq) { | ||
| 388 | dev_err(dvfs_info->dev, "No cpufreq irq found\n"); | ||
| 389 | ret = -ENODEV; | ||
| 390 | goto err_put_node; | ||
| 391 | } | ||
| 392 | |||
| 393 | ret = of_init_opp_table(dvfs_info->dev); | ||
| 394 | if (ret) { | ||
| 395 | dev_err(dvfs_info->dev, "failed to init OPP table: %d\n", ret); | ||
| 396 | goto err_put_node; | ||
| 397 | } | ||
| 398 | |||
| 399 | ret = opp_init_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table); | ||
| 400 | if (ret) { | ||
| 401 | dev_err(dvfs_info->dev, | ||
| 402 | "failed to init cpufreq table: %d\n", ret); | ||
| 403 | goto err_put_node; | ||
| 404 | } | ||
| 405 | dvfs_info->freq_count = opp_get_opp_count(dvfs_info->dev); | ||
| 406 | exynos_sort_descend_freq_table(); | ||
| 407 | |||
| 408 | if (of_property_read_u32(np, "clock-latency", &dvfs_info->latency)) | ||
| 409 | dvfs_info->latency = DEF_TRANS_LATENCY; | ||
| 410 | |||
| 411 | dvfs_info->cpu_clk = devm_clk_get(dvfs_info->dev, "armclk"); | ||
| 412 | if (IS_ERR(dvfs_info->cpu_clk)) { | ||
| 413 | dev_err(dvfs_info->dev, "Failed to get cpu clock\n"); | ||
| 414 | ret = PTR_ERR(dvfs_info->cpu_clk); | ||
| 415 | goto err_free_table; | ||
| 416 | } | ||
| 417 | |||
| 418 | dvfs_info->cur_frequency = clk_get_rate(dvfs_info->cpu_clk); | ||
| 419 | if (!dvfs_info->cur_frequency) { | ||
| 420 | dev_err(dvfs_info->dev, "Failed to get clock rate\n"); | ||
| 421 | ret = -EINVAL; | ||
| 422 | goto err_free_table; | ||
| 423 | } | ||
| 424 | dvfs_info->cur_frequency /= 1000; | ||
| 425 | |||
| 426 | INIT_WORK(&dvfs_info->irq_work, exynos_cpufreq_work); | ||
| 427 | ret = devm_request_irq(dvfs_info->dev, dvfs_info->irq, | ||
| 428 | exynos_cpufreq_irq, IRQF_TRIGGER_NONE, | ||
| 429 | CPUFREQ_NAME, dvfs_info); | ||
| 430 | if (ret) { | ||
| 431 | dev_err(dvfs_info->dev, "Failed to register IRQ\n"); | ||
| 432 | goto err_free_table; | ||
| 433 | } | ||
| 434 | |||
| 435 | ret = init_div_table(); | ||
| 436 | if (ret) { | ||
| 437 | dev_err(dvfs_info->dev, "Failed to initialise div table\n"); | ||
| 438 | goto err_free_table; | ||
| 439 | } | ||
| 440 | |||
| 441 | exynos_enable_dvfs(); | ||
| 442 | ret = cpufreq_register_driver(&exynos_driver); | ||
| 443 | if (ret) { | ||
| 444 | dev_err(dvfs_info->dev, | ||
| 445 | "%s: failed to register cpufreq driver\n", __func__); | ||
| 446 | goto err_free_table; | ||
| 447 | } | ||
| 448 | |||
| 449 | of_node_put(np); | ||
| 450 | dvfs_info->dvfs_enabled = true; | ||
| 451 | return 0; | ||
| 452 | |||
| 453 | err_free_table: | ||
| 454 | opp_free_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table); | ||
| 455 | err_put_node: | ||
| 456 | of_node_put(np); | ||
| 457 | dev_err(dvfs_info->dev, "%s: failed initialization\n", __func__); | ||
| 458 | return ret; | ||
| 459 | } | ||
| 460 | |||
| 461 | static int exynos_cpufreq_remove(struct platform_device *pdev) | ||
| 462 | { | ||
| 463 | cpufreq_unregister_driver(&exynos_driver); | ||
| 464 | opp_free_cpufreq_table(dvfs_info->dev, &dvfs_info->freq_table); | ||
| 465 | return 0; | ||
| 466 | } | ||
| 467 | |||
| 468 | static struct platform_driver exynos_cpufreq_platdrv = { | ||
| 469 | .driver = { | ||
| 470 | .name = "exynos5440-cpufreq", | ||
| 471 | .owner = THIS_MODULE, | ||
| 472 | .of_match_table = exynos_cpufreq_match, | ||
| 473 | }, | ||
| 474 | .probe = exynos_cpufreq_probe, | ||
| 475 | .remove = exynos_cpufreq_remove, | ||
| 476 | }; | ||
| 477 | module_platform_driver(exynos_cpufreq_platdrv); | ||
| 478 | |||
| 479 | MODULE_AUTHOR("Amit Daniel Kachhap <amit.daniel@samsung.com>"); | ||
| 480 | MODULE_DESCRIPTION("Exynos5440 cpufreq driver"); | ||
| 481 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/cpufreq/gx-suspmod.c b/drivers/cpufreq/gx-suspmod.c index 456bee058fe6..3dfc99b9ca86 100644 --- a/drivers/cpufreq/gx-suspmod.c +++ b/drivers/cpufreq/gx-suspmod.c | |||
| @@ -251,14 +251,13 @@ static unsigned int gx_validate_speed(unsigned int khz, u8 *on_duration, | |||
| 251 | * set cpu speed in khz. | 251 | * set cpu speed in khz. |
| 252 | **/ | 252 | **/ |
| 253 | 253 | ||
| 254 | static void gx_set_cpuspeed(unsigned int khz) | 254 | static void gx_set_cpuspeed(struct cpufreq_policy *policy, unsigned int khz) |
| 255 | { | 255 | { |
| 256 | u8 suscfg, pmer1; | 256 | u8 suscfg, pmer1; |
| 257 | unsigned int new_khz; | 257 | unsigned int new_khz; |
| 258 | unsigned long flags; | 258 | unsigned long flags; |
| 259 | struct cpufreq_freqs freqs; | 259 | struct cpufreq_freqs freqs; |
| 260 | 260 | ||
| 261 | freqs.cpu = 0; | ||
| 262 | freqs.old = gx_get_cpuspeed(0); | 261 | freqs.old = gx_get_cpuspeed(0); |
| 263 | 262 | ||
| 264 | new_khz = gx_validate_speed(khz, &gx_params->on_duration, | 263 | new_khz = gx_validate_speed(khz, &gx_params->on_duration, |
| @@ -266,11 +265,9 @@ static void gx_set_cpuspeed(unsigned int khz) | |||
| 266 | 265 | ||
| 267 | freqs.new = new_khz; | 266 | freqs.new = new_khz; |
| 268 | 267 | ||
| 269 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 268 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 270 | local_irq_save(flags); | 269 | local_irq_save(flags); |
| 271 | 270 | ||
| 272 | |||
| 273 | |||
| 274 | if (new_khz != stock_freq) { | 271 | if (new_khz != stock_freq) { |
| 275 | /* if new khz == 100% of CPU speed, it is special case */ | 272 | /* if new khz == 100% of CPU speed, it is special case */ |
| 276 | switch (gx_params->cs55x0->device) { | 273 | switch (gx_params->cs55x0->device) { |
| @@ -317,7 +314,7 @@ static void gx_set_cpuspeed(unsigned int khz) | |||
| 317 | 314 | ||
| 318 | gx_params->pci_suscfg = suscfg; | 315 | gx_params->pci_suscfg = suscfg; |
| 319 | 316 | ||
| 320 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 317 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 321 | 318 | ||
| 322 | pr_debug("suspend modulation w/ duration of ON:%d us, OFF:%d us\n", | 319 | pr_debug("suspend modulation w/ duration of ON:%d us, OFF:%d us\n", |
| 323 | gx_params->on_duration * 32, gx_params->off_duration * 32); | 320 | gx_params->on_duration * 32, gx_params->off_duration * 32); |
| @@ -397,7 +394,7 @@ static int cpufreq_gx_target(struct cpufreq_policy *policy, | |||
| 397 | tmp_freq = gx_validate_speed(tmp_freq, &tmp1, &tmp2); | 394 | tmp_freq = gx_validate_speed(tmp_freq, &tmp1, &tmp2); |
| 398 | } | 395 | } |
| 399 | 396 | ||
| 400 | gx_set_cpuspeed(tmp_freq); | 397 | gx_set_cpuspeed(policy, tmp_freq); |
| 401 | 398 | ||
| 402 | return 0; | 399 | return 0; |
| 403 | } | 400 | } |
diff --git a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c index f09b174244d5..c0075dbaa633 100644 --- a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/ia64-acpi-cpufreq.c | |||
| @@ -1,5 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * arch/ia64/kernel/cpufreq/acpi-cpufreq.c | ||
| 3 | * This file provides the ACPI based P-state support. This | 2 | * This file provides the ACPI based P-state support. This |
| 4 | * module works with generic cpufreq infrastructure. Most of | 3 | * module works with generic cpufreq infrastructure. Most of |
| 5 | * the code is based on i386 version | 4 | * the code is based on i386 version |
| @@ -137,7 +136,7 @@ migrate_end: | |||
| 137 | static int | 136 | static int |
| 138 | processor_set_freq ( | 137 | processor_set_freq ( |
| 139 | struct cpufreq_acpi_io *data, | 138 | struct cpufreq_acpi_io *data, |
| 140 | unsigned int cpu, | 139 | struct cpufreq_policy *policy, |
| 141 | int state) | 140 | int state) |
| 142 | { | 141 | { |
| 143 | int ret = 0; | 142 | int ret = 0; |
| @@ -149,8 +148,8 @@ processor_set_freq ( | |||
| 149 | pr_debug("processor_set_freq\n"); | 148 | pr_debug("processor_set_freq\n"); |
| 150 | 149 | ||
| 151 | saved_mask = current->cpus_allowed; | 150 | saved_mask = current->cpus_allowed; |
| 152 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); | 151 | set_cpus_allowed_ptr(current, cpumask_of(policy->cpu)); |
| 153 | if (smp_processor_id() != cpu) { | 152 | if (smp_processor_id() != policy->cpu) { |
| 154 | retval = -EAGAIN; | 153 | retval = -EAGAIN; |
| 155 | goto migrate_end; | 154 | goto migrate_end; |
| 156 | } | 155 | } |
| @@ -170,12 +169,11 @@ processor_set_freq ( | |||
| 170 | data->acpi_data.state, state); | 169 | data->acpi_data.state, state); |
| 171 | 170 | ||
| 172 | /* cpufreq frequency struct */ | 171 | /* cpufreq frequency struct */ |
| 173 | cpufreq_freqs.cpu = cpu; | ||
| 174 | cpufreq_freqs.old = data->freq_table[data->acpi_data.state].frequency; | 172 | cpufreq_freqs.old = data->freq_table[data->acpi_data.state].frequency; |
| 175 | cpufreq_freqs.new = data->freq_table[state].frequency; | 173 | cpufreq_freqs.new = data->freq_table[state].frequency; |
| 176 | 174 | ||
| 177 | /* notify cpufreq */ | 175 | /* notify cpufreq */ |
| 178 | cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE); | 176 | cpufreq_notify_transition(policy, &cpufreq_freqs, CPUFREQ_PRECHANGE); |
| 179 | 177 | ||
| 180 | /* | 178 | /* |
| 181 | * First we write the target state's 'control' value to the | 179 | * First we write the target state's 'control' value to the |
| @@ -189,17 +187,20 @@ processor_set_freq ( | |||
| 189 | ret = processor_set_pstate(value); | 187 | ret = processor_set_pstate(value); |
| 190 | if (ret) { | 188 | if (ret) { |
| 191 | unsigned int tmp = cpufreq_freqs.new; | 189 | unsigned int tmp = cpufreq_freqs.new; |
| 192 | cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE); | 190 | cpufreq_notify_transition(policy, &cpufreq_freqs, |
| 191 | CPUFREQ_POSTCHANGE); | ||
| 193 | cpufreq_freqs.new = cpufreq_freqs.old; | 192 | cpufreq_freqs.new = cpufreq_freqs.old; |
| 194 | cpufreq_freqs.old = tmp; | 193 | cpufreq_freqs.old = tmp; |
| 195 | cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_PRECHANGE); | 194 | cpufreq_notify_transition(policy, &cpufreq_freqs, |
| 196 | cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE); | 195 | CPUFREQ_PRECHANGE); |
| 196 | cpufreq_notify_transition(policy, &cpufreq_freqs, | ||
| 197 | CPUFREQ_POSTCHANGE); | ||
| 197 | printk(KERN_WARNING "Transition failed with error %d\n", ret); | 198 | printk(KERN_WARNING "Transition failed with error %d\n", ret); |
| 198 | retval = -ENODEV; | 199 | retval = -ENODEV; |
| 199 | goto migrate_end; | 200 | goto migrate_end; |
| 200 | } | 201 | } |
| 201 | 202 | ||
| 202 | cpufreq_notify_transition(&cpufreq_freqs, CPUFREQ_POSTCHANGE); | 203 | cpufreq_notify_transition(policy, &cpufreq_freqs, CPUFREQ_POSTCHANGE); |
| 203 | 204 | ||
| 204 | data->acpi_data.state = state; | 205 | data->acpi_data.state = state; |
| 205 | 206 | ||
| @@ -240,7 +241,7 @@ acpi_cpufreq_target ( | |||
| 240 | if (result) | 241 | if (result) |
| 241 | return (result); | 242 | return (result); |
| 242 | 243 | ||
| 243 | result = processor_set_freq(data, policy->cpu, next_state); | 244 | result = processor_set_freq(data, policy, next_state); |
| 244 | 245 | ||
| 245 | return (result); | 246 | return (result); |
| 246 | } | 247 | } |
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 54e336de373b..b78bc35973ba 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c | |||
| @@ -50,7 +50,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, | |||
| 50 | struct cpufreq_freqs freqs; | 50 | struct cpufreq_freqs freqs; |
| 51 | struct opp *opp; | 51 | struct opp *opp; |
| 52 | unsigned long freq_hz, volt, volt_old; | 52 | unsigned long freq_hz, volt, volt_old; |
| 53 | unsigned int index, cpu; | 53 | unsigned int index; |
| 54 | int ret; | 54 | int ret; |
| 55 | 55 | ||
| 56 | ret = cpufreq_frequency_table_target(policy, freq_table, target_freq, | 56 | ret = cpufreq_frequency_table_target(policy, freq_table, target_freq, |
| @@ -68,10 +68,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, | |||
| 68 | if (freqs.old == freqs.new) | 68 | if (freqs.old == freqs.new) |
| 69 | return 0; | 69 | return 0; |
| 70 | 70 | ||
| 71 | for_each_online_cpu(cpu) { | 71 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 72 | freqs.cpu = cpu; | ||
| 73 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 74 | } | ||
| 75 | 72 | ||
| 76 | rcu_read_lock(); | 73 | rcu_read_lock(); |
| 77 | opp = opp_find_freq_ceil(cpu_dev, &freq_hz); | 74 | opp = opp_find_freq_ceil(cpu_dev, &freq_hz); |
| @@ -166,10 +163,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, | |||
| 166 | } | 163 | } |
| 167 | } | 164 | } |
| 168 | 165 | ||
| 169 | for_each_online_cpu(cpu) { | 166 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 170 | freqs.cpu = cpu; | ||
| 171 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 172 | } | ||
| 173 | 167 | ||
| 174 | return 0; | 168 | return 0; |
| 175 | } | 169 | } |
diff --git a/arch/arm/mach-integrator/cpu.c b/drivers/cpufreq/integrator-cpufreq.c index 590c192cdf4d..f7c99df0880b 100644 --- a/arch/arm/mach-integrator/cpu.c +++ b/drivers/cpufreq/integrator-cpufreq.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/arch/arm/mach-integrator/cpu.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 2001-2002 Deep Blue Solutions Ltd. | 2 | * Copyright (C) 2001-2002 Deep Blue Solutions Ltd. |
| 5 | * | 3 | * |
| 6 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
| @@ -123,14 +121,12 @@ static int integrator_set_target(struct cpufreq_policy *policy, | |||
| 123 | vco = icst_hz_to_vco(&cclk_params, target_freq * 1000); | 121 | vco = icst_hz_to_vco(&cclk_params, target_freq * 1000); |
| 124 | freqs.new = icst_hz(&cclk_params, vco) / 1000; | 122 | freqs.new = icst_hz(&cclk_params, vco) / 1000; |
| 125 | 123 | ||
| 126 | freqs.cpu = policy->cpu; | ||
| 127 | |||
| 128 | if (freqs.old == freqs.new) { | 124 | if (freqs.old == freqs.new) { |
| 129 | set_cpus_allowed(current, cpus_allowed); | 125 | set_cpus_allowed(current, cpus_allowed); |
| 130 | return 0; | 126 | return 0; |
| 131 | } | 127 | } |
| 132 | 128 | ||
| 133 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 129 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 134 | 130 | ||
| 135 | cm_osc = __raw_readl(CM_OSC); | 131 | cm_osc = __raw_readl(CM_OSC); |
| 136 | 132 | ||
| @@ -151,7 +147,7 @@ static int integrator_set_target(struct cpufreq_policy *policy, | |||
| 151 | */ | 147 | */ |
| 152 | set_cpus_allowed(current, cpus_allowed); | 148 | set_cpus_allowed(current, cpus_allowed); |
| 153 | 149 | ||
| 154 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 150 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 155 | 151 | ||
| 156 | return 0; | 152 | return 0; |
| 157 | } | 153 | } |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 6133ef5cf671..cc3a8e6c92be 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * cpufreq_snb.c: Native P state management for Intel processors | 2 | * intel_pstate.c: Native P state management for Intel processors |
| 3 | * | 3 | * |
| 4 | * (C) Copyright 2012 Intel Corporation | 4 | * (C) Copyright 2012 Intel Corporation |
| 5 | * Author: Dirk Brandewie <dirk.j.brandewie@intel.com> | 5 | * Author: Dirk Brandewie <dirk.j.brandewie@intel.com> |
| @@ -657,30 +657,27 @@ static unsigned int intel_pstate_get(unsigned int cpu_num) | |||
| 657 | static int intel_pstate_set_policy(struct cpufreq_policy *policy) | 657 | static int intel_pstate_set_policy(struct cpufreq_policy *policy) |
| 658 | { | 658 | { |
| 659 | struct cpudata *cpu; | 659 | struct cpudata *cpu; |
| 660 | int min, max; | ||
| 661 | 660 | ||
| 662 | cpu = all_cpu_data[policy->cpu]; | 661 | cpu = all_cpu_data[policy->cpu]; |
| 663 | 662 | ||
| 664 | if (!policy->cpuinfo.max_freq) | 663 | if (!policy->cpuinfo.max_freq) |
| 665 | return -ENODEV; | 664 | return -ENODEV; |
| 666 | 665 | ||
| 667 | intel_pstate_get_min_max(cpu, &min, &max); | ||
| 668 | |||
| 669 | limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; | ||
| 670 | limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); | ||
| 671 | limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); | ||
| 672 | |||
| 673 | limits.max_perf_pct = policy->max * 100 / policy->cpuinfo.max_freq; | ||
| 674 | limits.max_perf_pct = clamp_t(int, limits.max_perf_pct, 0 , 100); | ||
| 675 | limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); | ||
| 676 | |||
| 677 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { | 666 | if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { |
| 678 | limits.min_perf_pct = 100; | 667 | limits.min_perf_pct = 100; |
| 679 | limits.min_perf = int_tofp(1); | 668 | limits.min_perf = int_tofp(1); |
| 680 | limits.max_perf_pct = 100; | 669 | limits.max_perf_pct = 100; |
| 681 | limits.max_perf = int_tofp(1); | 670 | limits.max_perf = int_tofp(1); |
| 682 | limits.no_turbo = 0; | 671 | limits.no_turbo = 0; |
| 672 | return 0; | ||
| 683 | } | 673 | } |
| 674 | limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; | ||
| 675 | limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); | ||
| 676 | limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); | ||
| 677 | |||
| 678 | limits.max_perf_pct = policy->max * 100 / policy->cpuinfo.max_freq; | ||
| 679 | limits.max_perf_pct = clamp_t(int, limits.max_perf_pct, 0 , 100); | ||
| 680 | limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); | ||
| 684 | 681 | ||
| 685 | return 0; | 682 | return 0; |
| 686 | } | 683 | } |
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c index 0e83e3c24f5b..d36ea8dc96eb 100644 --- a/drivers/cpufreq/kirkwood-cpufreq.c +++ b/drivers/cpufreq/kirkwood-cpufreq.c | |||
| @@ -55,7 +55,8 @@ static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu) | |||
| 55 | return kirkwood_freq_table[0].frequency; | 55 | return kirkwood_freq_table[0].frequency; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | static void kirkwood_cpufreq_set_cpu_state(unsigned int index) | 58 | static void kirkwood_cpufreq_set_cpu_state(struct cpufreq_policy *policy, |
| 59 | unsigned int index) | ||
| 59 | { | 60 | { |
| 60 | struct cpufreq_freqs freqs; | 61 | struct cpufreq_freqs freqs; |
| 61 | unsigned int state = kirkwood_freq_table[index].index; | 62 | unsigned int state = kirkwood_freq_table[index].index; |
| @@ -63,9 +64,8 @@ static void kirkwood_cpufreq_set_cpu_state(unsigned int index) | |||
| 63 | 64 | ||
| 64 | freqs.old = kirkwood_cpufreq_get_cpu_frequency(0); | 65 | freqs.old = kirkwood_cpufreq_get_cpu_frequency(0); |
| 65 | freqs.new = kirkwood_freq_table[index].frequency; | 66 | freqs.new = kirkwood_freq_table[index].frequency; |
| 66 | freqs.cpu = 0; /* Kirkwood is UP */ | ||
| 67 | 67 | ||
| 68 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 68 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 69 | 69 | ||
| 70 | dev_dbg(priv.dev, "Attempting to set frequency to %i KHz\n", | 70 | dev_dbg(priv.dev, "Attempting to set frequency to %i KHz\n", |
| 71 | kirkwood_freq_table[index].frequency); | 71 | kirkwood_freq_table[index].frequency); |
| @@ -99,7 +99,7 @@ static void kirkwood_cpufreq_set_cpu_state(unsigned int index) | |||
| 99 | 99 | ||
| 100 | local_irq_enable(); | 100 | local_irq_enable(); |
| 101 | } | 101 | } |
| 102 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 102 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 103 | }; | 103 | }; |
| 104 | 104 | ||
| 105 | static int kirkwood_cpufreq_verify(struct cpufreq_policy *policy) | 105 | static int kirkwood_cpufreq_verify(struct cpufreq_policy *policy) |
| @@ -117,7 +117,7 @@ static int kirkwood_cpufreq_target(struct cpufreq_policy *policy, | |||
| 117 | target_freq, relation, &index)) | 117 | target_freq, relation, &index)) |
| 118 | return -EINVAL; | 118 | return -EINVAL; |
| 119 | 119 | ||
| 120 | kirkwood_cpufreq_set_cpu_state(index); | 120 | kirkwood_cpufreq_set_cpu_state(policy, index); |
| 121 | 121 | ||
| 122 | return 0; | 122 | return 0; |
| 123 | } | 123 | } |
| @@ -175,11 +175,9 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev) | |||
| 175 | dev_err(&pdev->dev, "Cannot get memory resource\n"); | 175 | dev_err(&pdev->dev, "Cannot get memory resource\n"); |
| 176 | return -ENODEV; | 176 | return -ENODEV; |
| 177 | } | 177 | } |
| 178 | priv.base = devm_request_and_ioremap(&pdev->dev, res); | 178 | priv.base = devm_ioremap_resource(&pdev->dev, res); |
| 179 | if (!priv.base) { | 179 | if (IS_ERR(priv.base)) |
| 180 | dev_err(&pdev->dev, "Cannot ioremap\n"); | 180 | return PTR_ERR(priv.base); |
| 181 | return -EADDRNOTAVAIL; | ||
| 182 | } | ||
| 183 | 181 | ||
| 184 | np = of_find_node_by_path("/cpus/cpu@0"); | 182 | np = of_find_node_by_path("/cpus/cpu@0"); |
| 185 | if (!np) | 183 | if (!np) |
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index 1180d536d1eb..b448638e34de 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c | |||
| @@ -242,7 +242,8 @@ static void do_powersaver(int cx_address, unsigned int mults_index, | |||
| 242 | * Sets a new clock ratio. | 242 | * Sets a new clock ratio. |
| 243 | */ | 243 | */ |
| 244 | 244 | ||
| 245 | static void longhaul_setstate(unsigned int table_index) | 245 | static void longhaul_setstate(struct cpufreq_policy *policy, |
| 246 | unsigned int table_index) | ||
| 246 | { | 247 | { |
| 247 | unsigned int mults_index; | 248 | unsigned int mults_index; |
| 248 | int speed, mult; | 249 | int speed, mult; |
| @@ -267,9 +268,8 @@ static void longhaul_setstate(unsigned int table_index) | |||
| 267 | 268 | ||
| 268 | freqs.old = calc_speed(longhaul_get_cpu_mult()); | 269 | freqs.old = calc_speed(longhaul_get_cpu_mult()); |
| 269 | freqs.new = speed; | 270 | freqs.new = speed; |
| 270 | freqs.cpu = 0; /* longhaul.c is UP only driver */ | ||
| 271 | 271 | ||
| 272 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 272 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 273 | 273 | ||
| 274 | pr_debug("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n", | 274 | pr_debug("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n", |
| 275 | fsb, mult/10, mult%10, print_speed(speed/1000)); | 275 | fsb, mult/10, mult%10, print_speed(speed/1000)); |
| @@ -386,7 +386,7 @@ retry_loop: | |||
| 386 | } | 386 | } |
| 387 | } | 387 | } |
| 388 | /* Report true CPU frequency */ | 388 | /* Report true CPU frequency */ |
| 389 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 389 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 390 | 390 | ||
| 391 | if (!bm_timeout) | 391 | if (!bm_timeout) |
| 392 | printk(KERN_INFO PFX "Warning: Timeout while waiting for " | 392 | printk(KERN_INFO PFX "Warning: Timeout while waiting for " |
| @@ -648,7 +648,7 @@ static int longhaul_target(struct cpufreq_policy *policy, | |||
| 648 | return 0; | 648 | return 0; |
| 649 | 649 | ||
| 650 | if (!can_scale_voltage) | 650 | if (!can_scale_voltage) |
| 651 | longhaul_setstate(table_index); | 651 | longhaul_setstate(policy, table_index); |
| 652 | else { | 652 | else { |
| 653 | /* On test system voltage transitions exceeding single | 653 | /* On test system voltage transitions exceeding single |
| 654 | * step up or down were turning motherboard off. Both | 654 | * step up or down were turning motherboard off. Both |
| @@ -663,7 +663,7 @@ static int longhaul_target(struct cpufreq_policy *policy, | |||
| 663 | while (i != table_index) { | 663 | while (i != table_index) { |
| 664 | vid = (longhaul_table[i].index >> 8) & 0x1f; | 664 | vid = (longhaul_table[i].index >> 8) & 0x1f; |
| 665 | if (vid != current_vid) { | 665 | if (vid != current_vid) { |
| 666 | longhaul_setstate(i); | 666 | longhaul_setstate(policy, i); |
| 667 | current_vid = vid; | 667 | current_vid = vid; |
| 668 | msleep(200); | 668 | msleep(200); |
| 669 | } | 669 | } |
| @@ -672,7 +672,7 @@ static int longhaul_target(struct cpufreq_policy *policy, | |||
| 672 | else | 672 | else |
| 673 | i--; | 673 | i--; |
| 674 | } | 674 | } |
| 675 | longhaul_setstate(table_index); | 675 | longhaul_setstate(policy, table_index); |
| 676 | } | 676 | } |
| 677 | longhaul_index = table_index; | 677 | longhaul_index = table_index; |
| 678 | return 0; | 678 | return 0; |
| @@ -998,15 +998,17 @@ static int __init longhaul_init(void) | |||
| 998 | 998 | ||
| 999 | static void __exit longhaul_exit(void) | 999 | static void __exit longhaul_exit(void) |
| 1000 | { | 1000 | { |
| 1001 | struct cpufreq_policy *policy = cpufreq_cpu_get(0); | ||
| 1001 | int i; | 1002 | int i; |
| 1002 | 1003 | ||
| 1003 | for (i = 0; i < numscales; i++) { | 1004 | for (i = 0; i < numscales; i++) { |
| 1004 | if (mults[i] == maxmult) { | 1005 | if (mults[i] == maxmult) { |
| 1005 | longhaul_setstate(i); | 1006 | longhaul_setstate(policy, i); |
| 1006 | break; | 1007 | break; |
| 1007 | } | 1008 | } |
| 1008 | } | 1009 | } |
| 1009 | 1010 | ||
| 1011 | cpufreq_cpu_put(policy); | ||
| 1010 | cpufreq_unregister_driver(&longhaul_driver); | 1012 | cpufreq_unregister_driver(&longhaul_driver); |
| 1011 | kfree(longhaul_table); | 1013 | kfree(longhaul_table); |
| 1012 | } | 1014 | } |
diff --git a/arch/mips/kernel/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c index 3237c5235f9c..84889573b566 100644 --- a/arch/mips/kernel/cpufreq/loongson2_cpufreq.c +++ b/drivers/cpufreq/loongson2_cpufreq.c | |||
| @@ -61,9 +61,6 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy, | |||
| 61 | struct cpufreq_freqs freqs; | 61 | struct cpufreq_freqs freqs; |
| 62 | unsigned int freq; | 62 | unsigned int freq; |
| 63 | 63 | ||
| 64 | if (!cpu_online(cpu)) | ||
| 65 | return -ENODEV; | ||
| 66 | |||
| 67 | cpus_allowed = current->cpus_allowed; | 64 | cpus_allowed = current->cpus_allowed; |
| 68 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); | 65 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); |
| 69 | 66 | ||
| @@ -80,7 +77,6 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy, | |||
| 80 | 77 | ||
| 81 | pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000); | 78 | pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000); |
| 82 | 79 | ||
| 83 | freqs.cpu = cpu; | ||
| 84 | freqs.old = loongson2_cpufreq_get(cpu); | 80 | freqs.old = loongson2_cpufreq_get(cpu); |
| 85 | freqs.new = freq; | 81 | freqs.new = freq; |
| 86 | freqs.flags = 0; | 82 | freqs.flags = 0; |
| @@ -89,7 +85,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy, | |||
| 89 | return 0; | 85 | return 0; |
| 90 | 86 | ||
| 91 | /* notifiers */ | 87 | /* notifiers */ |
| 92 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 88 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 93 | 89 | ||
| 94 | set_cpus_allowed_ptr(current, &cpus_allowed); | 90 | set_cpus_allowed_ptr(current, &cpus_allowed); |
| 95 | 91 | ||
| @@ -97,7 +93,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy, | |||
| 97 | clk_set_rate(cpuclk, freq); | 93 | clk_set_rate(cpuclk, freq); |
| 98 | 94 | ||
| 99 | /* notifiers */ | 95 | /* notifiers */ |
| 100 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 96 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 101 | 97 | ||
| 102 | pr_debug("cpufreq: set frequency %u kHz\n", freq); | 98 | pr_debug("cpufreq: set frequency %u kHz\n", freq); |
| 103 | 99 | ||
| @@ -110,9 +106,6 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 110 | unsigned long rate; | 106 | unsigned long rate; |
| 111 | int ret; | 107 | int ret; |
| 112 | 108 | ||
| 113 | if (!cpu_online(policy->cpu)) | ||
| 114 | return -ENODEV; | ||
| 115 | |||
| 116 | cpuclk = clk_get(NULL, "cpu_clk"); | 109 | cpuclk = clk_get(NULL, "cpu_clk"); |
| 117 | if (IS_ERR(cpuclk)) { | 110 | if (IS_ERR(cpuclk)) { |
| 118 | printk(KERN_ERR "cpufreq: couldn't get CPU clk\n"); | 111 | printk(KERN_ERR "cpufreq: couldn't get CPU clk\n"); |
diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c index d4c4989823dc..cdd62915efaf 100644 --- a/drivers/cpufreq/maple-cpufreq.c +++ b/drivers/cpufreq/maple-cpufreq.c | |||
| @@ -158,11 +158,10 @@ static int maple_cpufreq_target(struct cpufreq_policy *policy, | |||
| 158 | 158 | ||
| 159 | freqs.old = maple_cpu_freqs[maple_pmode_cur].frequency; | 159 | freqs.old = maple_cpu_freqs[maple_pmode_cur].frequency; |
| 160 | freqs.new = maple_cpu_freqs[newstate].frequency; | 160 | freqs.new = maple_cpu_freqs[newstate].frequency; |
| 161 | freqs.cpu = 0; | ||
| 162 | 161 | ||
| 163 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 162 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 164 | rc = maple_scom_switch_freq(newstate); | 163 | rc = maple_scom_switch_freq(newstate); |
| 165 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 164 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 166 | 165 | ||
| 167 | mutex_unlock(&maple_switch_mutex); | 166 | mutex_unlock(&maple_switch_mutex); |
| 168 | 167 | ||
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index 9128c07bafba..0279d18a57f9 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/opp.h> | 25 | #include <linux/opp.h> |
| 26 | #include <linux/cpu.h> | 26 | #include <linux/cpu.h> |
| 27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
| 28 | #include <linux/platform_device.h> | ||
| 28 | #include <linux/regulator/consumer.h> | 29 | #include <linux/regulator/consumer.h> |
| 29 | 30 | ||
| 30 | #include <asm/smp_plat.h> | 31 | #include <asm/smp_plat.h> |
| @@ -88,16 +89,12 @@ static int omap_target(struct cpufreq_policy *policy, | |||
| 88 | } | 89 | } |
| 89 | 90 | ||
| 90 | freqs.old = omap_getspeed(policy->cpu); | 91 | freqs.old = omap_getspeed(policy->cpu); |
| 91 | freqs.cpu = policy->cpu; | ||
| 92 | 92 | ||
| 93 | if (freqs.old == freqs.new && policy->cur == freqs.new) | 93 | if (freqs.old == freqs.new && policy->cur == freqs.new) |
| 94 | return ret; | 94 | return ret; |
| 95 | 95 | ||
| 96 | /* notifiers */ | 96 | /* notifiers */ |
| 97 | for_each_cpu(i, policy->cpus) { | 97 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 98 | freqs.cpu = i; | ||
| 99 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 100 | } | ||
| 101 | 98 | ||
| 102 | freq = freqs.new * 1000; | 99 | freq = freqs.new * 1000; |
| 103 | ret = clk_round_rate(mpu_clk, freq); | 100 | ret = clk_round_rate(mpu_clk, freq); |
| @@ -157,10 +154,7 @@ static int omap_target(struct cpufreq_policy *policy, | |||
| 157 | 154 | ||
| 158 | done: | 155 | done: |
| 159 | /* notifiers */ | 156 | /* notifiers */ |
| 160 | for_each_cpu(i, policy->cpus) { | 157 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 161 | freqs.cpu = i; | ||
| 162 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 163 | } | ||
| 164 | 158 | ||
| 165 | return ret; | 159 | return ret; |
| 166 | } | 160 | } |
| @@ -184,7 +178,7 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | |||
| 184 | goto fail_ck; | 178 | goto fail_ck; |
| 185 | } | 179 | } |
| 186 | 180 | ||
| 187 | policy->cur = policy->min = policy->max = omap_getspeed(policy->cpu); | 181 | policy->cur = omap_getspeed(policy->cpu); |
| 188 | 182 | ||
| 189 | if (!freq_table) | 183 | if (!freq_table) |
| 190 | result = opp_init_cpufreq_table(mpu_dev, &freq_table); | 184 | result = opp_init_cpufreq_table(mpu_dev, &freq_table); |
| @@ -203,8 +197,6 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy) | |||
| 203 | 197 | ||
| 204 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | 198 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); |
| 205 | 199 | ||
| 206 | policy->min = policy->cpuinfo.min_freq; | ||
| 207 | policy->max = policy->cpuinfo.max_freq; | ||
| 208 | policy->cur = omap_getspeed(policy->cpu); | 200 | policy->cur = omap_getspeed(policy->cpu); |
| 209 | 201 | ||
| 210 | /* | 202 | /* |
| @@ -252,7 +244,7 @@ static struct cpufreq_driver omap_driver = { | |||
| 252 | .attr = omap_cpufreq_attr, | 244 | .attr = omap_cpufreq_attr, |
| 253 | }; | 245 | }; |
| 254 | 246 | ||
| 255 | static int __init omap_cpufreq_init(void) | 247 | static int omap_cpufreq_probe(struct platform_device *pdev) |
| 256 | { | 248 | { |
| 257 | mpu_dev = get_cpu_device(0); | 249 | mpu_dev = get_cpu_device(0); |
| 258 | if (!mpu_dev) { | 250 | if (!mpu_dev) { |
| @@ -280,12 +272,20 @@ static int __init omap_cpufreq_init(void) | |||
| 280 | return cpufreq_register_driver(&omap_driver); | 272 | return cpufreq_register_driver(&omap_driver); |
| 281 | } | 273 | } |
| 282 | 274 | ||
| 283 | static void __exit omap_cpufreq_exit(void) | 275 | static int omap_cpufreq_remove(struct platform_device *pdev) |
| 284 | { | 276 | { |
| 285 | cpufreq_unregister_driver(&omap_driver); | 277 | return cpufreq_unregister_driver(&omap_driver); |
| 286 | } | 278 | } |
| 287 | 279 | ||
| 280 | static struct platform_driver omap_cpufreq_platdrv = { | ||
| 281 | .driver = { | ||
| 282 | .name = "omap-cpufreq", | ||
| 283 | .owner = THIS_MODULE, | ||
| 284 | }, | ||
| 285 | .probe = omap_cpufreq_probe, | ||
| 286 | .remove = omap_cpufreq_remove, | ||
| 287 | }; | ||
| 288 | module_platform_driver(omap_cpufreq_platdrv); | ||
| 289 | |||
| 288 | MODULE_DESCRIPTION("cpufreq driver for OMAP SoCs"); | 290 | MODULE_DESCRIPTION("cpufreq driver for OMAP SoCs"); |
| 289 | MODULE_LICENSE("GPL"); | 291 | MODULE_LICENSE("GPL"); |
| 290 | module_init(omap_cpufreq_init); | ||
| 291 | module_exit(omap_cpufreq_exit); | ||
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c index 827629c9aad7..421ef37d0bb3 100644 --- a/drivers/cpufreq/p4-clockmod.c +++ b/drivers/cpufreq/p4-clockmod.c | |||
| @@ -58,8 +58,7 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate) | |||
| 58 | { | 58 | { |
| 59 | u32 l, h; | 59 | u32 l, h; |
| 60 | 60 | ||
| 61 | if (!cpu_online(cpu) || | 61 | if ((newstate > DC_DISABLE) || (newstate == DC_RESV)) |
| 62 | (newstate > DC_DISABLE) || (newstate == DC_RESV)) | ||
| 63 | return -EINVAL; | 62 | return -EINVAL; |
| 64 | 63 | ||
| 65 | rdmsr_on_cpu(cpu, MSR_IA32_THERM_STATUS, &l, &h); | 64 | rdmsr_on_cpu(cpu, MSR_IA32_THERM_STATUS, &l, &h); |
| @@ -125,10 +124,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, | |||
| 125 | return 0; | 124 | return 0; |
| 126 | 125 | ||
| 127 | /* notifiers */ | 126 | /* notifiers */ |
| 128 | for_each_cpu(i, policy->cpus) { | 127 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 129 | freqs.cpu = i; | ||
| 130 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 131 | } | ||
| 132 | 128 | ||
| 133 | /* run on each logical CPU, | 129 | /* run on each logical CPU, |
| 134 | * see section 13.15.3 of IA32 Intel Architecture Software | 130 | * see section 13.15.3 of IA32 Intel Architecture Software |
| @@ -138,10 +134,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, | |||
| 138 | cpufreq_p4_setdc(i, p4clockmod_table[newstate].index); | 134 | cpufreq_p4_setdc(i, p4clockmod_table[newstate].index); |
| 139 | 135 | ||
| 140 | /* notifiers */ | 136 | /* notifiers */ |
| 141 | for_each_cpu(i, policy->cpus) { | 137 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 142 | freqs.cpu = i; | ||
| 143 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 144 | } | ||
| 145 | 138 | ||
| 146 | return 0; | 139 | return 0; |
| 147 | } | 140 | } |
diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c index 503996a94a6a..0de00081a81e 100644 --- a/drivers/cpufreq/pcc-cpufreq.c +++ b/drivers/cpufreq/pcc-cpufreq.c | |||
| @@ -215,8 +215,7 @@ static int pcc_cpufreq_target(struct cpufreq_policy *policy, | |||
| 215 | (pcch_virt_addr + pcc_cpu_data->input_offset)); | 215 | (pcch_virt_addr + pcc_cpu_data->input_offset)); |
| 216 | 216 | ||
| 217 | freqs.new = target_freq; | 217 | freqs.new = target_freq; |
| 218 | freqs.cpu = cpu; | 218 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 219 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 220 | 219 | ||
| 221 | input_buffer = 0x1 | (((target_freq * 100) | 220 | input_buffer = 0x1 | (((target_freq * 100) |
| 222 | / (ioread32(&pcch_hdr->nominal) * 1000)) << 8); | 221 | / (ioread32(&pcch_hdr->nominal) * 1000)) << 8); |
| @@ -237,7 +236,7 @@ static int pcc_cpufreq_target(struct cpufreq_policy *policy, | |||
| 237 | } | 236 | } |
| 238 | iowrite16(0, &pcch_hdr->status); | 237 | iowrite16(0, &pcch_hdr->status); |
| 239 | 238 | ||
| 240 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 239 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 241 | pr_debug("target: was SUCCESSFUL for cpu %d\n", cpu); | 240 | pr_debug("target: was SUCCESSFUL for cpu %d\n", cpu); |
| 242 | spin_unlock(&pcc_lock); | 241 | spin_unlock(&pcc_lock); |
| 243 | 242 | ||
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c index af23e0b9ec92..ea0222a45b7b 100644 --- a/drivers/cpufreq/powernow-k6.c +++ b/drivers/cpufreq/powernow-k6.c | |||
| @@ -68,7 +68,8 @@ static int powernow_k6_get_cpu_multiplier(void) | |||
| 68 | * | 68 | * |
| 69 | * Tries to change the PowerNow! multiplier | 69 | * Tries to change the PowerNow! multiplier |
| 70 | */ | 70 | */ |
| 71 | static void powernow_k6_set_state(unsigned int best_i) | 71 | static void powernow_k6_set_state(struct cpufreq_policy *policy, |
| 72 | unsigned int best_i) | ||
| 72 | { | 73 | { |
| 73 | unsigned long outvalue = 0, invalue = 0; | 74 | unsigned long outvalue = 0, invalue = 0; |
| 74 | unsigned long msrval; | 75 | unsigned long msrval; |
| @@ -81,9 +82,8 @@ static void powernow_k6_set_state(unsigned int best_i) | |||
| 81 | 82 | ||
| 82 | freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); | 83 | freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); |
| 83 | freqs.new = busfreq * clock_ratio[best_i].index; | 84 | freqs.new = busfreq * clock_ratio[best_i].index; |
| 84 | freqs.cpu = 0; /* powernow-k6.c is UP only driver */ | ||
| 85 | 85 | ||
| 86 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 86 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 87 | 87 | ||
| 88 | /* we now need to transform best_i to the BVC format, see AMD#23446 */ | 88 | /* we now need to transform best_i to the BVC format, see AMD#23446 */ |
| 89 | 89 | ||
| @@ -98,7 +98,7 @@ static void powernow_k6_set_state(unsigned int best_i) | |||
| 98 | msrval = POWERNOW_IOPORT + 0x0; | 98 | msrval = POWERNOW_IOPORT + 0x0; |
| 99 | wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ | 99 | wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ |
| 100 | 100 | ||
| 101 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 101 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 102 | 102 | ||
| 103 | return; | 103 | return; |
| 104 | } | 104 | } |
| @@ -136,7 +136,7 @@ static int powernow_k6_target(struct cpufreq_policy *policy, | |||
| 136 | target_freq, relation, &newstate)) | 136 | target_freq, relation, &newstate)) |
| 137 | return -EINVAL; | 137 | return -EINVAL; |
| 138 | 138 | ||
| 139 | powernow_k6_set_state(newstate); | 139 | powernow_k6_set_state(policy, newstate); |
| 140 | 140 | ||
| 141 | return 0; | 141 | return 0; |
| 142 | } | 142 | } |
| @@ -182,7 +182,7 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy) | |||
| 182 | unsigned int i; | 182 | unsigned int i; |
| 183 | for (i = 0; i < 8; i++) { | 183 | for (i = 0; i < 8; i++) { |
| 184 | if (i == max_multiplier) | 184 | if (i == max_multiplier) |
| 185 | powernow_k6_set_state(i); | 185 | powernow_k6_set_state(policy, i); |
| 186 | } | 186 | } |
| 187 | cpufreq_frequency_table_put_attr(policy->cpu); | 187 | cpufreq_frequency_table_put_attr(policy->cpu); |
| 188 | return 0; | 188 | return 0; |
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c index 334cc2f1e9f1..53888dacbe58 100644 --- a/drivers/cpufreq/powernow-k7.c +++ b/drivers/cpufreq/powernow-k7.c | |||
| @@ -248,7 +248,7 @@ static void change_VID(int vid) | |||
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | 250 | ||
| 251 | static void change_speed(unsigned int index) | 251 | static void change_speed(struct cpufreq_policy *policy, unsigned int index) |
| 252 | { | 252 | { |
| 253 | u8 fid, vid; | 253 | u8 fid, vid; |
| 254 | struct cpufreq_freqs freqs; | 254 | struct cpufreq_freqs freqs; |
| @@ -263,15 +263,13 @@ static void change_speed(unsigned int index) | |||
| 263 | fid = powernow_table[index].index & 0xFF; | 263 | fid = powernow_table[index].index & 0xFF; |
| 264 | vid = (powernow_table[index].index & 0xFF00) >> 8; | 264 | vid = (powernow_table[index].index & 0xFF00) >> 8; |
| 265 | 265 | ||
| 266 | freqs.cpu = 0; | ||
| 267 | |||
| 268 | rdmsrl(MSR_K7_FID_VID_STATUS, fidvidstatus.val); | 266 | rdmsrl(MSR_K7_FID_VID_STATUS, fidvidstatus.val); |
| 269 | cfid = fidvidstatus.bits.CFID; | 267 | cfid = fidvidstatus.bits.CFID; |
| 270 | freqs.old = fsb * fid_codes[cfid] / 10; | 268 | freqs.old = fsb * fid_codes[cfid] / 10; |
| 271 | 269 | ||
| 272 | freqs.new = powernow_table[index].frequency; | 270 | freqs.new = powernow_table[index].frequency; |
| 273 | 271 | ||
| 274 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 272 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 275 | 273 | ||
| 276 | /* Now do the magic poking into the MSRs. */ | 274 | /* Now do the magic poking into the MSRs. */ |
| 277 | 275 | ||
| @@ -292,7 +290,7 @@ static void change_speed(unsigned int index) | |||
| 292 | if (have_a0 == 1) | 290 | if (have_a0 == 1) |
| 293 | local_irq_enable(); | 291 | local_irq_enable(); |
| 294 | 292 | ||
| 295 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 293 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 296 | } | 294 | } |
| 297 | 295 | ||
| 298 | 296 | ||
| @@ -546,7 +544,7 @@ static int powernow_target(struct cpufreq_policy *policy, | |||
| 546 | relation, &newstate)) | 544 | relation, &newstate)) |
| 547 | return -EINVAL; | 545 | return -EINVAL; |
| 548 | 546 | ||
| 549 | change_speed(newstate); | 547 | change_speed(policy, newstate); |
| 550 | 548 | ||
| 551 | return 0; | 549 | return 0; |
| 552 | } | 550 | } |
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c index d13a13678b5f..b828efe4b2f8 100644 --- a/drivers/cpufreq/powernow-k8.c +++ b/drivers/cpufreq/powernow-k8.c | |||
| @@ -928,9 +928,10 @@ static int get_transition_latency(struct powernow_k8_data *data) | |||
| 928 | static int transition_frequency_fidvid(struct powernow_k8_data *data, | 928 | static int transition_frequency_fidvid(struct powernow_k8_data *data, |
| 929 | unsigned int index) | 929 | unsigned int index) |
| 930 | { | 930 | { |
| 931 | struct cpufreq_policy *policy; | ||
| 931 | u32 fid = 0; | 932 | u32 fid = 0; |
| 932 | u32 vid = 0; | 933 | u32 vid = 0; |
| 933 | int res, i; | 934 | int res; |
| 934 | struct cpufreq_freqs freqs; | 935 | struct cpufreq_freqs freqs; |
| 935 | 936 | ||
| 936 | pr_debug("cpu %d transition to index %u\n", smp_processor_id(), index); | 937 | pr_debug("cpu %d transition to index %u\n", smp_processor_id(), index); |
| @@ -959,10 +960,10 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, | |||
| 959 | freqs.old = find_khz_freq_from_fid(data->currfid); | 960 | freqs.old = find_khz_freq_from_fid(data->currfid); |
| 960 | freqs.new = find_khz_freq_from_fid(fid); | 961 | freqs.new = find_khz_freq_from_fid(fid); |
| 961 | 962 | ||
| 962 | for_each_cpu(i, data->available_cores) { | 963 | policy = cpufreq_cpu_get(smp_processor_id()); |
| 963 | freqs.cpu = i; | 964 | cpufreq_cpu_put(policy); |
| 964 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 965 | |
| 965 | } | 966 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 966 | 967 | ||
| 967 | res = transition_fid_vid(data, fid, vid); | 968 | res = transition_fid_vid(data, fid, vid); |
| 968 | if (res) | 969 | if (res) |
| @@ -970,10 +971,7 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, | |||
| 970 | 971 | ||
| 971 | freqs.new = find_khz_freq_from_fid(data->currfid); | 972 | freqs.new = find_khz_freq_from_fid(data->currfid); |
| 972 | 973 | ||
| 973 | for_each_cpu(i, data->available_cores) { | 974 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 974 | freqs.cpu = i; | ||
| 975 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 976 | } | ||
| 977 | return res; | 975 | return res; |
| 978 | } | 976 | } |
| 979 | 977 | ||
| @@ -1104,9 +1102,6 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
| 1104 | struct init_on_cpu init_on_cpu; | 1102 | struct init_on_cpu init_on_cpu; |
| 1105 | int rc; | 1103 | int rc; |
| 1106 | 1104 | ||
| 1107 | if (!cpu_online(pol->cpu)) | ||
| 1108 | return -ENODEV; | ||
| 1109 | |||
| 1110 | smp_call_function_single(pol->cpu, check_supported_cpu, &rc, 1); | 1105 | smp_call_function_single(pol->cpu, check_supported_cpu, &rc, 1); |
| 1111 | if (rc) | 1106 | if (rc) |
| 1112 | return -ENODEV; | 1107 | return -ENODEV; |
diff --git a/arch/powerpc/platforms/cell/cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c index d4c39e32f147..e577a1dbbfcd 100644 --- a/arch/powerpc/platforms/cell/cbe_cpufreq.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq.c | |||
| @@ -27,7 +27,8 @@ | |||
| 27 | #include <asm/machdep.h> | 27 | #include <asm/machdep.h> |
| 28 | #include <asm/prom.h> | 28 | #include <asm/prom.h> |
| 29 | #include <asm/cell-regs.h> | 29 | #include <asm/cell-regs.h> |
| 30 | #include "cbe_cpufreq.h" | 30 | |
| 31 | #include "ppc_cbe_cpufreq.h" | ||
| 31 | 32 | ||
| 32 | static DEFINE_MUTEX(cbe_switch_mutex); | 33 | static DEFINE_MUTEX(cbe_switch_mutex); |
| 33 | 34 | ||
| @@ -156,10 +157,9 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy, | |||
| 156 | 157 | ||
| 157 | freqs.old = policy->cur; | 158 | freqs.old = policy->cur; |
| 158 | freqs.new = cbe_freqs[cbe_pmode_new].frequency; | 159 | freqs.new = cbe_freqs[cbe_pmode_new].frequency; |
| 159 | freqs.cpu = policy->cpu; | ||
| 160 | 160 | ||
| 161 | mutex_lock(&cbe_switch_mutex); | 161 | mutex_lock(&cbe_switch_mutex); |
| 162 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 162 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 163 | 163 | ||
| 164 | pr_debug("setting frequency for cpu %d to %d kHz, " \ | 164 | pr_debug("setting frequency for cpu %d to %d kHz, " \ |
| 165 | "1/%d of max frequency\n", | 165 | "1/%d of max frequency\n", |
| @@ -169,7 +169,7 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy, | |||
| 169 | 169 | ||
| 170 | rc = set_pmode(policy->cpu, cbe_pmode_new); | 170 | rc = set_pmode(policy->cpu, cbe_pmode_new); |
| 171 | 171 | ||
| 172 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 172 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 173 | mutex_unlock(&cbe_switch_mutex); | 173 | mutex_unlock(&cbe_switch_mutex); |
| 174 | 174 | ||
| 175 | return rc; | 175 | return rc; |
diff --git a/arch/powerpc/platforms/cell/cbe_cpufreq.h b/drivers/cpufreq/ppc_cbe_cpufreq.h index c1d86bfa92ff..b4c00a5a6a59 100644 --- a/arch/powerpc/platforms/cell/cbe_cpufreq.h +++ b/drivers/cpufreq/ppc_cbe_cpufreq.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * cbe_cpufreq.h | 2 | * ppc_cbe_cpufreq.h |
| 3 | * | 3 | * |
| 4 | * This file contains the definitions used by the cbe_cpufreq driver. | 4 | * This file contains the definitions used by the cbe_cpufreq driver. |
| 5 | * | 5 | * |
| @@ -17,7 +17,7 @@ int cbe_cpufreq_get_pmode(int cpu); | |||
| 17 | 17 | ||
| 18 | int cbe_cpufreq_set_pmode_pmi(int cpu, unsigned int pmode); | 18 | int cbe_cpufreq_set_pmode_pmi(int cpu, unsigned int pmode); |
| 19 | 19 | ||
| 20 | #if defined(CONFIG_CBE_CPUFREQ_PMI) || defined(CONFIG_CBE_CPUFREQ_PMI_MODULE) | 20 | #if defined(CONFIG_CPU_FREQ_CBE_PMI) || defined(CONFIG_CPU_FREQ_CBE_PMI_MODULE) |
| 21 | extern bool cbe_cpufreq_has_pmi; | 21 | extern bool cbe_cpufreq_has_pmi; |
| 22 | #else | 22 | #else |
| 23 | #define cbe_cpufreq_has_pmi (0) | 23 | #define cbe_cpufreq_has_pmi (0) |
diff --git a/arch/powerpc/platforms/cell/cbe_cpufreq_pervasive.c b/drivers/cpufreq/ppc_cbe_cpufreq_pervasive.c index 20472e487b6f..84d2f2cf5ba7 100644 --- a/arch/powerpc/platforms/cell/cbe_cpufreq_pervasive.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq_pervasive.c | |||
| @@ -30,7 +30,7 @@ | |||
| 30 | #include <asm/hw_irq.h> | 30 | #include <asm/hw_irq.h> |
| 31 | #include <asm/cell-regs.h> | 31 | #include <asm/cell-regs.h> |
| 32 | 32 | ||
| 33 | #include "cbe_cpufreq.h" | 33 | #include "ppc_cbe_cpufreq.h" |
| 34 | 34 | ||
| 35 | /* to write to MIC register */ | 35 | /* to write to MIC register */ |
| 36 | static u64 MIC_Slow_Fast_Timer_table[] = { | 36 | static u64 MIC_Slow_Fast_Timer_table[] = { |
diff --git a/arch/powerpc/platforms/cell/cbe_cpufreq_pmi.c b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c index 60a07a4f9326..d29e8da396a0 100644 --- a/arch/powerpc/platforms/cell/cbe_cpufreq_pmi.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq_pmi.c | |||
| @@ -35,7 +35,7 @@ | |||
| 35 | #include <asm/time.h> | 35 | #include <asm/time.h> |
| 36 | #endif | 36 | #endif |
| 37 | 37 | ||
| 38 | #include "cbe_cpufreq.h" | 38 | #include "ppc_cbe_cpufreq.h" |
| 39 | 39 | ||
| 40 | static u8 pmi_slow_mode_limit[MAX_CBE]; | 40 | static u8 pmi_slow_mode_limit[MAX_CBE]; |
| 41 | 41 | ||
diff --git a/arch/arm/mach-pxa/cpufreq-pxa2xx.c b/drivers/cpufreq/pxa2xx-cpufreq.c index 6a7aeab42f6c..9e5bc8e388a0 100644 --- a/arch/arm/mach-pxa/cpufreq-pxa2xx.c +++ b/drivers/cpufreq/pxa2xx-cpufreq.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/arch/arm/mach-pxa/cpufreq-pxa2xx.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 2002,2003 Intrinsyc Software | 2 | * Copyright (C) 2002,2003 Intrinsyc Software |
| 5 | * | 3 | * |
| 6 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
| @@ -223,10 +221,11 @@ static void find_freq_tables(struct cpufreq_frequency_table **freq_table, | |||
| 223 | *pxa_freqs = pxa255_turbo_freqs; | 221 | *pxa_freqs = pxa255_turbo_freqs; |
| 224 | *freq_table = pxa255_turbo_freq_table; | 222 | *freq_table = pxa255_turbo_freq_table; |
| 225 | } | 223 | } |
| 226 | } | 224 | } else if (cpu_is_pxa27x()) { |
| 227 | if (cpu_is_pxa27x()) { | ||
| 228 | *pxa_freqs = pxa27x_freqs; | 225 | *pxa_freqs = pxa27x_freqs; |
| 229 | *freq_table = pxa27x_freq_table; | 226 | *freq_table = pxa27x_freq_table; |
| 227 | } else { | ||
| 228 | BUG(); | ||
| 230 | } | 229 | } |
| 231 | } | 230 | } |
| 232 | 231 | ||
| @@ -311,7 +310,6 @@ static int pxa_set_target(struct cpufreq_policy *policy, | |||
| 311 | new_freq_mem = pxa_freq_settings[idx].membus; | 310 | new_freq_mem = pxa_freq_settings[idx].membus; |
| 312 | freqs.old = policy->cur; | 311 | freqs.old = policy->cur; |
| 313 | freqs.new = new_freq_cpu; | 312 | freqs.new = new_freq_cpu; |
| 314 | freqs.cpu = policy->cpu; | ||
| 315 | 313 | ||
| 316 | if (freq_debug) | 314 | if (freq_debug) |
| 317 | pr_debug("Changing CPU frequency to %d Mhz, (SDRAM %d Mhz)\n", | 315 | pr_debug("Changing CPU frequency to %d Mhz, (SDRAM %d Mhz)\n", |
| @@ -327,7 +325,7 @@ static int pxa_set_target(struct cpufreq_policy *policy, | |||
| 327 | * you should add a notify client with any platform specific | 325 | * you should add a notify client with any platform specific |
| 328 | * Vcc changing capability | 326 | * Vcc changing capability |
| 329 | */ | 327 | */ |
| 330 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 328 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 331 | 329 | ||
| 332 | /* Calculate the next MDREFR. If we're slowing down the SDRAM clock | 330 | /* Calculate the next MDREFR. If we're slowing down the SDRAM clock |
| 333 | * we need to preset the smaller DRI before the change. If we're | 331 | * we need to preset the smaller DRI before the change. If we're |
| @@ -382,7 +380,7 @@ static int pxa_set_target(struct cpufreq_policy *policy, | |||
| 382 | * you should add a notify client with any platform specific | 380 | * you should add a notify client with any platform specific |
| 383 | * SDRAM refresh timer adjustments | 381 | * SDRAM refresh timer adjustments |
| 384 | */ | 382 | */ |
| 385 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 383 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 386 | 384 | ||
| 387 | /* | 385 | /* |
| 388 | * Even if voltage setting fails, we don't report it, as the frequency | 386 | * Even if voltage setting fails, we don't report it, as the frequency |
diff --git a/arch/arm/mach-pxa/cpufreq-pxa3xx.c b/drivers/cpufreq/pxa3xx-cpufreq.c index b85b4ab7aac6..15d60f857ad5 100644 --- a/arch/arm/mach-pxa/cpufreq-pxa3xx.c +++ b/drivers/cpufreq/pxa3xx-cpufreq.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/arch/arm/mach-pxa/cpufreq-pxa3xx.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008 Marvell International Ltd. | 2 | * Copyright (C) 2008 Marvell International Ltd. |
| 5 | * | 3 | * |
| 6 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
| @@ -17,10 +15,9 @@ | |||
| 17 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
| 18 | #include <linux/io.h> | 16 | #include <linux/io.h> |
| 19 | 17 | ||
| 18 | #include <mach/generic.h> | ||
| 20 | #include <mach/pxa3xx-regs.h> | 19 | #include <mach/pxa3xx-regs.h> |
| 21 | 20 | ||
| 22 | #include "generic.h" | ||
| 23 | |||
| 24 | #define HSS_104M (0) | 21 | #define HSS_104M (0) |
| 25 | #define HSS_156M (1) | 22 | #define HSS_156M (1) |
| 26 | #define HSS_208M (2) | 23 | #define HSS_208M (2) |
| @@ -184,7 +181,6 @@ static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, | |||
| 184 | 181 | ||
| 185 | freqs.old = policy->cur; | 182 | freqs.old = policy->cur; |
| 186 | freqs.new = next->cpufreq_mhz * 1000; | 183 | freqs.new = next->cpufreq_mhz * 1000; |
| 187 | freqs.cpu = policy->cpu; | ||
| 188 | 184 | ||
| 189 | pr_debug("CPU frequency from %d MHz to %d MHz%s\n", | 185 | pr_debug("CPU frequency from %d MHz to %d MHz%s\n", |
| 190 | freqs.old / 1000, freqs.new / 1000, | 186 | freqs.old / 1000, freqs.new / 1000, |
| @@ -193,14 +189,14 @@ static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, | |||
| 193 | if (freqs.old == target_freq) | 189 | if (freqs.old == target_freq) |
| 194 | return 0; | 190 | return 0; |
| 195 | 191 | ||
| 196 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 192 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 197 | 193 | ||
| 198 | local_irq_save(flags); | 194 | local_irq_save(flags); |
| 199 | __update_core_freq(next); | 195 | __update_core_freq(next); |
| 200 | __update_bus_freq(next); | 196 | __update_bus_freq(next); |
| 201 | local_irq_restore(flags); | 197 | local_irq_restore(flags); |
| 202 | 198 | ||
| 203 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 199 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 204 | 200 | ||
| 205 | return 0; | 201 | return 0; |
| 206 | } | 202 | } |
diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c index bcc053bc02c4..4f1881eee3f1 100644 --- a/drivers/cpufreq/s3c2416-cpufreq.c +++ b/drivers/cpufreq/s3c2416-cpufreq.c | |||
| @@ -256,7 +256,6 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy, | |||
| 256 | goto out; | 256 | goto out; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | freqs.cpu = 0; | ||
| 260 | freqs.flags = 0; | 259 | freqs.flags = 0; |
| 261 | freqs.old = s3c_freq->is_dvs ? FREQ_DVS | 260 | freqs.old = s3c_freq->is_dvs ? FREQ_DVS |
| 262 | : clk_get_rate(s3c_freq->armclk) / 1000; | 261 | : clk_get_rate(s3c_freq->armclk) / 1000; |
| @@ -274,7 +273,7 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy, | |||
| 274 | if (!to_dvs && freqs.old == freqs.new) | 273 | if (!to_dvs && freqs.old == freqs.new) |
| 275 | goto out; | 274 | goto out; |
| 276 | 275 | ||
| 277 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 276 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 278 | 277 | ||
| 279 | if (to_dvs) { | 278 | if (to_dvs) { |
| 280 | pr_debug("cpufreq: enter dvs\n"); | 279 | pr_debug("cpufreq: enter dvs\n"); |
| @@ -287,7 +286,7 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy, | |||
| 287 | ret = s3c2416_cpufreq_set_armdiv(s3c_freq, freqs.new); | 286 | ret = s3c2416_cpufreq_set_armdiv(s3c_freq, freqs.new); |
| 288 | } | 287 | } |
| 289 | 288 | ||
| 290 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 289 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 291 | 290 | ||
| 292 | out: | 291 | out: |
| 293 | mutex_unlock(&cpufreq_lock); | 292 | mutex_unlock(&cpufreq_lock); |
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c index 6f9490b3c356..27cacb524796 100644 --- a/drivers/cpufreq/s3c64xx-cpufreq.c +++ b/drivers/cpufreq/s3c64xx-cpufreq.c | |||
| @@ -84,7 +84,6 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, | |||
| 84 | if (ret != 0) | 84 | if (ret != 0) |
| 85 | return ret; | 85 | return ret; |
| 86 | 86 | ||
| 87 | freqs.cpu = 0; | ||
| 88 | freqs.old = clk_get_rate(armclk) / 1000; | 87 | freqs.old = clk_get_rate(armclk) / 1000; |
| 89 | freqs.new = s3c64xx_freq_table[i].frequency; | 88 | freqs.new = s3c64xx_freq_table[i].frequency; |
| 90 | freqs.flags = 0; | 89 | freqs.flags = 0; |
| @@ -95,7 +94,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, | |||
| 95 | 94 | ||
| 96 | pr_debug("Transition %d-%dkHz\n", freqs.old, freqs.new); | 95 | pr_debug("Transition %d-%dkHz\n", freqs.old, freqs.new); |
| 97 | 96 | ||
| 98 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 97 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 99 | 98 | ||
| 100 | #ifdef CONFIG_REGULATOR | 99 | #ifdef CONFIG_REGULATOR |
| 101 | if (vddarm && freqs.new > freqs.old) { | 100 | if (vddarm && freqs.new > freqs.old) { |
| @@ -117,7 +116,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, | |||
| 117 | goto err; | 116 | goto err; |
| 118 | } | 117 | } |
| 119 | 118 | ||
| 120 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 119 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 121 | 120 | ||
| 122 | #ifdef CONFIG_REGULATOR | 121 | #ifdef CONFIG_REGULATOR |
| 123 | if (vddarm && freqs.new < freqs.old) { | 122 | if (vddarm && freqs.new < freqs.old) { |
| @@ -141,7 +140,7 @@ err_clk: | |||
| 141 | if (clk_set_rate(armclk, freqs.old * 1000) < 0) | 140 | if (clk_set_rate(armclk, freqs.old * 1000) < 0) |
| 142 | pr_err("Failed to restore original clock rate\n"); | 141 | pr_err("Failed to restore original clock rate\n"); |
| 143 | err: | 142 | err: |
| 144 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 143 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 145 | 144 | ||
| 146 | return ret; | 145 | return ret; |
| 147 | } | 146 | } |
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c index a484aaea9809..5c7757073793 100644 --- a/drivers/cpufreq/s5pv210-cpufreq.c +++ b/drivers/cpufreq/s5pv210-cpufreq.c | |||
| @@ -229,7 +229,6 @@ static int s5pv210_target(struct cpufreq_policy *policy, | |||
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | freqs.new = s5pv210_freq_table[index].frequency; | 231 | freqs.new = s5pv210_freq_table[index].frequency; |
| 232 | freqs.cpu = 0; | ||
| 233 | 232 | ||
| 234 | if (freqs.new == freqs.old) | 233 | if (freqs.new == freqs.old) |
| 235 | goto exit; | 234 | goto exit; |
| @@ -256,7 +255,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, | |||
| 256 | goto exit; | 255 | goto exit; |
| 257 | } | 256 | } |
| 258 | 257 | ||
| 259 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 258 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 260 | 259 | ||
| 261 | /* Check if there need to change PLL */ | 260 | /* Check if there need to change PLL */ |
| 262 | if ((index == L0) || (priv_index == L0)) | 261 | if ((index == L0) || (priv_index == L0)) |
| @@ -468,7 +467,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, | |||
| 468 | } | 467 | } |
| 469 | } | 468 | } |
| 470 | 469 | ||
| 471 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 470 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 472 | 471 | ||
| 473 | if (freqs.new < freqs.old) { | 472 | if (freqs.new < freqs.old) { |
| 474 | regulator_set_voltage(int_regulator, | 473 | regulator_set_voltage(int_regulator, |
diff --git a/arch/arm/mach-sa1100/cpu-sa1100.c b/drivers/cpufreq/sa1100-cpufreq.c index e8f4d1e19233..cff18e87ca58 100644 --- a/arch/arm/mach-sa1100/cpu-sa1100.c +++ b/drivers/cpufreq/sa1100-cpufreq.c | |||
| @@ -91,10 +91,9 @@ | |||
| 91 | 91 | ||
| 92 | #include <asm/cputype.h> | 92 | #include <asm/cputype.h> |
| 93 | 93 | ||
| 94 | #include <mach/generic.h> | ||
| 94 | #include <mach/hardware.h> | 95 | #include <mach/hardware.h> |
| 95 | 96 | ||
| 96 | #include "generic.h" | ||
| 97 | |||
| 98 | struct sa1100_dram_regs { | 97 | struct sa1100_dram_regs { |
| 99 | int speed; | 98 | int speed; |
| 100 | u32 mdcnfg; | 99 | u32 mdcnfg; |
| @@ -201,9 +200,8 @@ static int sa1100_target(struct cpufreq_policy *policy, | |||
| 201 | 200 | ||
| 202 | freqs.old = cur; | 201 | freqs.old = cur; |
| 203 | freqs.new = sa11x0_ppcr_to_freq(new_ppcr); | 202 | freqs.new = sa11x0_ppcr_to_freq(new_ppcr); |
| 204 | freqs.cpu = 0; | ||
| 205 | 203 | ||
| 206 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 204 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 207 | 205 | ||
| 208 | if (freqs.new > cur) | 206 | if (freqs.new > cur) |
| 209 | sa1100_update_dram_timings(cur, freqs.new); | 207 | sa1100_update_dram_timings(cur, freqs.new); |
| @@ -213,7 +211,7 @@ static int sa1100_target(struct cpufreq_policy *policy, | |||
| 213 | if (freqs.new < cur) | 211 | if (freqs.new < cur) |
| 214 | sa1100_update_dram_timings(cur, freqs.new); | 212 | sa1100_update_dram_timings(cur, freqs.new); |
| 215 | 213 | ||
| 216 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 214 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 217 | 215 | ||
| 218 | return 0; | 216 | return 0; |
| 219 | } | 217 | } |
diff --git a/arch/arm/mach-sa1100/cpu-sa1110.c b/drivers/cpufreq/sa1110-cpufreq.c index 48c45b0c92bb..39c90b6f4286 100644 --- a/arch/arm/mach-sa1100/cpu-sa1110.c +++ b/drivers/cpufreq/sa1110-cpufreq.c | |||
| @@ -27,10 +27,9 @@ | |||
| 27 | #include <asm/cputype.h> | 27 | #include <asm/cputype.h> |
| 28 | #include <asm/mach-types.h> | 28 | #include <asm/mach-types.h> |
| 29 | 29 | ||
| 30 | #include <mach/generic.h> | ||
| 30 | #include <mach/hardware.h> | 31 | #include <mach/hardware.h> |
| 31 | 32 | ||
| 32 | #include "generic.h" | ||
| 33 | |||
| 34 | #undef DEBUG | 33 | #undef DEBUG |
| 35 | 34 | ||
| 36 | struct sdram_params { | 35 | struct sdram_params { |
| @@ -258,7 +257,6 @@ static int sa1110_target(struct cpufreq_policy *policy, | |||
| 258 | 257 | ||
| 259 | freqs.old = sa11x0_getspeed(0); | 258 | freqs.old = sa11x0_getspeed(0); |
| 260 | freqs.new = sa11x0_ppcr_to_freq(ppcr); | 259 | freqs.new = sa11x0_ppcr_to_freq(ppcr); |
| 261 | freqs.cpu = 0; | ||
| 262 | 260 | ||
| 263 | sdram_calculate_timing(&sd, freqs.new, sdram); | 261 | sdram_calculate_timing(&sd, freqs.new, sdram); |
| 264 | 262 | ||
| @@ -279,7 +277,7 @@ static int sa1110_target(struct cpufreq_policy *policy, | |||
| 279 | sd.mdcas[2] = 0xaaaaaaaa; | 277 | sd.mdcas[2] = 0xaaaaaaaa; |
| 280 | #endif | 278 | #endif |
| 281 | 279 | ||
| 282 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 280 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 283 | 281 | ||
| 284 | /* | 282 | /* |
| 285 | * The clock could be going away for some time. Set the SDRAMs | 283 | * The clock could be going away for some time. Set the SDRAMs |
| @@ -327,7 +325,7 @@ static int sa1110_target(struct cpufreq_policy *policy, | |||
| 327 | */ | 325 | */ |
| 328 | sdram_update_refresh(freqs.new, sdram); | 326 | sdram_update_refresh(freqs.new, sdram); |
| 329 | 327 | ||
| 330 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 328 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 331 | 329 | ||
| 332 | return 0; | 330 | return 0; |
| 333 | } | 331 | } |
diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c index e42e073cd9b8..f740b134d27b 100644 --- a/drivers/cpufreq/sc520_freq.c +++ b/drivers/cpufreq/sc520_freq.c | |||
| @@ -53,7 +53,8 @@ static unsigned int sc520_freq_get_cpu_frequency(unsigned int cpu) | |||
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | static void sc520_freq_set_cpu_state(unsigned int state) | 56 | static void sc520_freq_set_cpu_state(struct cpufreq_policy *policy, |
| 57 | unsigned int state) | ||
| 57 | { | 58 | { |
| 58 | 59 | ||
| 59 | struct cpufreq_freqs freqs; | 60 | struct cpufreq_freqs freqs; |
| @@ -61,9 +62,8 @@ static void sc520_freq_set_cpu_state(unsigned int state) | |||
| 61 | 62 | ||
| 62 | freqs.old = sc520_freq_get_cpu_frequency(0); | 63 | freqs.old = sc520_freq_get_cpu_frequency(0); |
| 63 | freqs.new = sc520_freq_table[state].frequency; | 64 | freqs.new = sc520_freq_table[state].frequency; |
| 64 | freqs.cpu = 0; /* AMD Elan is UP */ | ||
| 65 | 65 | ||
| 66 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 66 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 67 | 67 | ||
| 68 | pr_debug("attempting to set frequency to %i kHz\n", | 68 | pr_debug("attempting to set frequency to %i kHz\n", |
| 69 | sc520_freq_table[state].frequency); | 69 | sc520_freq_table[state].frequency); |
| @@ -75,7 +75,7 @@ static void sc520_freq_set_cpu_state(unsigned int state) | |||
| 75 | 75 | ||
| 76 | local_irq_enable(); | 76 | local_irq_enable(); |
| 77 | 77 | ||
| 78 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 78 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | static int sc520_freq_verify(struct cpufreq_policy *policy) | 81 | static int sc520_freq_verify(struct cpufreq_policy *policy) |
| @@ -93,7 +93,7 @@ static int sc520_freq_target(struct cpufreq_policy *policy, | |||
| 93 | target_freq, relation, &newstate)) | 93 | target_freq, relation, &newstate)) |
| 94 | return -EINVAL; | 94 | return -EINVAL; |
| 95 | 95 | ||
| 96 | sc520_freq_set_cpu_state(newstate); | 96 | sc520_freq_set_cpu_state(policy, newstate); |
| 97 | 97 | ||
| 98 | return 0; | 98 | return 0; |
| 99 | } | 99 | } |
diff --git a/arch/sh/kernel/cpufreq.c b/drivers/cpufreq/sh-cpufreq.c index e68b45b6f3f9..73adb64651e8 100644 --- a/arch/sh/kernel/cpufreq.c +++ b/drivers/cpufreq/sh-cpufreq.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * arch/sh/kernel/cpufreq.c | ||
| 3 | * | ||
| 4 | * cpufreq driver for the SuperH processors. | 2 | * cpufreq driver for the SuperH processors. |
| 5 | * | 3 | * |
| 6 | * Copyright (C) 2002 - 2012 Paul Mundt | 4 | * Copyright (C) 2002 - 2012 Paul Mundt |
| @@ -51,9 +49,6 @@ static int sh_cpufreq_target(struct cpufreq_policy *policy, | |||
| 51 | struct device *dev; | 49 | struct device *dev; |
| 52 | long freq; | 50 | long freq; |
| 53 | 51 | ||
| 54 | if (!cpu_online(cpu)) | ||
| 55 | return -ENODEV; | ||
| 56 | |||
| 57 | cpus_allowed = current->cpus_allowed; | 52 | cpus_allowed = current->cpus_allowed; |
| 58 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); | 53 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); |
| 59 | 54 | ||
| @@ -69,15 +64,14 @@ static int sh_cpufreq_target(struct cpufreq_policy *policy, | |||
| 69 | 64 | ||
| 70 | dev_dbg(dev, "requested frequency %u Hz\n", target_freq * 1000); | 65 | dev_dbg(dev, "requested frequency %u Hz\n", target_freq * 1000); |
| 71 | 66 | ||
| 72 | freqs.cpu = cpu; | ||
| 73 | freqs.old = sh_cpufreq_get(cpu); | 67 | freqs.old = sh_cpufreq_get(cpu); |
| 74 | freqs.new = (freq + 500) / 1000; | 68 | freqs.new = (freq + 500) / 1000; |
| 75 | freqs.flags = 0; | 69 | freqs.flags = 0; |
| 76 | 70 | ||
| 77 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 71 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 78 | set_cpus_allowed_ptr(current, &cpus_allowed); | 72 | set_cpus_allowed_ptr(current, &cpus_allowed); |
| 79 | clk_set_rate(cpuclk, freq); | 73 | clk_set_rate(cpuclk, freq); |
| 80 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 74 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 81 | 75 | ||
| 82 | dev_dbg(dev, "set frequency %lu Hz\n", freq); | 76 | dev_dbg(dev, "set frequency %lu Hz\n", freq); |
| 83 | 77 | ||
| @@ -112,9 +106,6 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 112 | struct cpufreq_frequency_table *freq_table; | 106 | struct cpufreq_frequency_table *freq_table; |
| 113 | struct device *dev; | 107 | struct device *dev; |
| 114 | 108 | ||
| 115 | if (!cpu_online(cpu)) | ||
| 116 | return -ENODEV; | ||
| 117 | |||
| 118 | dev = get_cpu_device(cpu); | 109 | dev = get_cpu_device(cpu); |
| 119 | 110 | ||
| 120 | cpuclk = clk_get(dev, "cpu_clk"); | 111 | cpuclk = clk_get(dev, "cpu_clk"); |
| @@ -123,7 +114,7 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 123 | return PTR_ERR(cpuclk); | 114 | return PTR_ERR(cpuclk); |
| 124 | } | 115 | } |
| 125 | 116 | ||
| 126 | policy->cur = policy->min = policy->max = sh_cpufreq_get(cpu); | 117 | policy->cur = sh_cpufreq_get(cpu); |
| 127 | 118 | ||
| 128 | freq_table = cpuclk->nr_freqs ? cpuclk->freq_table : NULL; | 119 | freq_table = cpuclk->nr_freqs ? cpuclk->freq_table : NULL; |
| 129 | if (freq_table) { | 120 | if (freq_table) { |
| @@ -136,15 +127,12 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 136 | dev_notice(dev, "no frequency table found, falling back " | 127 | dev_notice(dev, "no frequency table found, falling back " |
| 137 | "to rate rounding.\n"); | 128 | "to rate rounding.\n"); |
| 138 | 129 | ||
| 139 | policy->cpuinfo.min_freq = | 130 | policy->min = policy->cpuinfo.min_freq = |
| 140 | (clk_round_rate(cpuclk, 1) + 500) / 1000; | 131 | (clk_round_rate(cpuclk, 1) + 500) / 1000; |
| 141 | policy->cpuinfo.max_freq = | 132 | policy->max = policy->cpuinfo.max_freq = |
| 142 | (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; | 133 | (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; |
| 143 | } | 134 | } |
| 144 | 135 | ||
| 145 | policy->min = policy->cpuinfo.min_freq; | ||
| 146 | policy->max = policy->cpuinfo.max_freq; | ||
| 147 | |||
| 148 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 136 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
| 149 | 137 | ||
| 150 | dev_info(dev, "CPU Frequencies - Minimum %u.%03u MHz, " | 138 | dev_info(dev, "CPU Frequencies - Minimum %u.%03u MHz, " |
diff --git a/arch/sparc/kernel/us2e_cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c index 489fc15f3194..306ae462bba6 100644 --- a/arch/sparc/kernel/us2e_cpufreq.c +++ b/drivers/cpufreq/sparc-us2e-cpufreq.c | |||
| @@ -234,9 +234,6 @@ static unsigned int us2e_freq_get(unsigned int cpu) | |||
| 234 | cpumask_t cpus_allowed; | 234 | cpumask_t cpus_allowed; |
| 235 | unsigned long clock_tick, estar; | 235 | unsigned long clock_tick, estar; |
| 236 | 236 | ||
| 237 | if (!cpu_online(cpu)) | ||
| 238 | return 0; | ||
| 239 | |||
| 240 | cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); | 237 | cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); |
| 241 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); | 238 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); |
| 242 | 239 | ||
| @@ -248,16 +245,15 @@ static unsigned int us2e_freq_get(unsigned int cpu) | |||
| 248 | return clock_tick / estar_to_divisor(estar); | 245 | return clock_tick / estar_to_divisor(estar); |
| 249 | } | 246 | } |
| 250 | 247 | ||
| 251 | static void us2e_set_cpu_divider_index(unsigned int cpu, unsigned int index) | 248 | static void us2e_set_cpu_divider_index(struct cpufreq_policy *policy, |
| 249 | unsigned int index) | ||
| 252 | { | 250 | { |
| 251 | unsigned int cpu = policy->cpu; | ||
| 253 | unsigned long new_bits, new_freq; | 252 | unsigned long new_bits, new_freq; |
| 254 | unsigned long clock_tick, divisor, old_divisor, estar; | 253 | unsigned long clock_tick, divisor, old_divisor, estar; |
| 255 | cpumask_t cpus_allowed; | 254 | cpumask_t cpus_allowed; |
| 256 | struct cpufreq_freqs freqs; | 255 | struct cpufreq_freqs freqs; |
| 257 | 256 | ||
| 258 | if (!cpu_online(cpu)) | ||
| 259 | return; | ||
| 260 | |||
| 261 | cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); | 257 | cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); |
| 262 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); | 258 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); |
| 263 | 259 | ||
| @@ -272,14 +268,13 @@ static void us2e_set_cpu_divider_index(unsigned int cpu, unsigned int index) | |||
| 272 | 268 | ||
| 273 | freqs.old = clock_tick / old_divisor; | 269 | freqs.old = clock_tick / old_divisor; |
| 274 | freqs.new = new_freq; | 270 | freqs.new = new_freq; |
| 275 | freqs.cpu = cpu; | 271 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 276 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 277 | 272 | ||
| 278 | if (old_divisor != divisor) | 273 | if (old_divisor != divisor) |
| 279 | us2e_transition(estar, new_bits, clock_tick * 1000, | 274 | us2e_transition(estar, new_bits, clock_tick * 1000, |
| 280 | old_divisor, divisor); | 275 | old_divisor, divisor); |
| 281 | 276 | ||
| 282 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 277 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 283 | 278 | ||
| 284 | set_cpus_allowed_ptr(current, &cpus_allowed); | 279 | set_cpus_allowed_ptr(current, &cpus_allowed); |
| 285 | } | 280 | } |
| @@ -295,7 +290,7 @@ static int us2e_freq_target(struct cpufreq_policy *policy, | |||
| 295 | target_freq, relation, &new_index)) | 290 | target_freq, relation, &new_index)) |
| 296 | return -EINVAL; | 291 | return -EINVAL; |
| 297 | 292 | ||
| 298 | us2e_set_cpu_divider_index(policy->cpu, new_index); | 293 | us2e_set_cpu_divider_index(policy, new_index); |
| 299 | 294 | ||
| 300 | return 0; | 295 | return 0; |
| 301 | } | 296 | } |
| @@ -335,7 +330,7 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy) | |||
| 335 | static int us2e_freq_cpu_exit(struct cpufreq_policy *policy) | 330 | static int us2e_freq_cpu_exit(struct cpufreq_policy *policy) |
| 336 | { | 331 | { |
| 337 | if (cpufreq_us2e_driver) | 332 | if (cpufreq_us2e_driver) |
| 338 | us2e_set_cpu_divider_index(policy->cpu, 0); | 333 | us2e_set_cpu_divider_index(policy, 0); |
| 339 | 334 | ||
| 340 | return 0; | 335 | return 0; |
| 341 | } | 336 | } |
diff --git a/arch/sparc/kernel/us3_cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c index eb1624b931d9..c71ee142347a 100644 --- a/arch/sparc/kernel/us3_cpufreq.c +++ b/drivers/cpufreq/sparc-us3-cpufreq.c | |||
| @@ -82,9 +82,6 @@ static unsigned int us3_freq_get(unsigned int cpu) | |||
| 82 | unsigned long reg; | 82 | unsigned long reg; |
| 83 | unsigned int ret; | 83 | unsigned int ret; |
| 84 | 84 | ||
| 85 | if (!cpu_online(cpu)) | ||
| 86 | return 0; | ||
| 87 | |||
| 88 | cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); | 85 | cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); |
| 89 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); | 86 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); |
| 90 | 87 | ||
| @@ -96,15 +93,14 @@ static unsigned int us3_freq_get(unsigned int cpu) | |||
| 96 | return ret; | 93 | return ret; |
| 97 | } | 94 | } |
| 98 | 95 | ||
| 99 | static void us3_set_cpu_divider_index(unsigned int cpu, unsigned int index) | 96 | static void us3_set_cpu_divider_index(struct cpufreq_policy *policy, |
| 97 | unsigned int index) | ||
| 100 | { | 98 | { |
| 99 | unsigned int cpu = policy->cpu; | ||
| 101 | unsigned long new_bits, new_freq, reg; | 100 | unsigned long new_bits, new_freq, reg; |
| 102 | cpumask_t cpus_allowed; | 101 | cpumask_t cpus_allowed; |
| 103 | struct cpufreq_freqs freqs; | 102 | struct cpufreq_freqs freqs; |
| 104 | 103 | ||
| 105 | if (!cpu_online(cpu)) | ||
| 106 | return; | ||
| 107 | |||
| 108 | cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); | 104 | cpumask_copy(&cpus_allowed, tsk_cpus_allowed(current)); |
| 109 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); | 105 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); |
| 110 | 106 | ||
| @@ -131,14 +127,13 @@ static void us3_set_cpu_divider_index(unsigned int cpu, unsigned int index) | |||
| 131 | 127 | ||
| 132 | freqs.old = get_current_freq(cpu, reg); | 128 | freqs.old = get_current_freq(cpu, reg); |
| 133 | freqs.new = new_freq; | 129 | freqs.new = new_freq; |
| 134 | freqs.cpu = cpu; | 130 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 135 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 136 | 131 | ||
| 137 | reg &= ~SAFARI_CFG_DIV_MASK; | 132 | reg &= ~SAFARI_CFG_DIV_MASK; |
| 138 | reg |= new_bits; | 133 | reg |= new_bits; |
| 139 | write_safari_cfg(reg); | 134 | write_safari_cfg(reg); |
| 140 | 135 | ||
| 141 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 136 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 142 | 137 | ||
| 143 | set_cpus_allowed_ptr(current, &cpus_allowed); | 138 | set_cpus_allowed_ptr(current, &cpus_allowed); |
| 144 | } | 139 | } |
| @@ -156,7 +151,7 @@ static int us3_freq_target(struct cpufreq_policy *policy, | |||
| 156 | &new_index)) | 151 | &new_index)) |
| 157 | return -EINVAL; | 152 | return -EINVAL; |
| 158 | 153 | ||
| 159 | us3_set_cpu_divider_index(policy->cpu, new_index); | 154 | us3_set_cpu_divider_index(policy, new_index); |
| 160 | 155 | ||
| 161 | return 0; | 156 | return 0; |
| 162 | } | 157 | } |
| @@ -192,7 +187,7 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy) | |||
| 192 | static int us3_freq_cpu_exit(struct cpufreq_policy *policy) | 187 | static int us3_freq_cpu_exit(struct cpufreq_policy *policy) |
| 193 | { | 188 | { |
| 194 | if (cpufreq_us3_driver) | 189 | if (cpufreq_us3_driver) |
| 195 | us3_set_cpu_divider_index(policy->cpu, 0); | 190 | us3_set_cpu_divider_index(policy, 0); |
| 196 | 191 | ||
| 197 | return 0; | 192 | return 0; |
| 198 | } | 193 | } |
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c index 7e4d77327957..156829f4576d 100644 --- a/drivers/cpufreq/spear-cpufreq.c +++ b/drivers/cpufreq/spear-cpufreq.c | |||
| @@ -121,7 +121,6 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy, | |||
| 121 | target_freq, relation, &index)) | 121 | target_freq, relation, &index)) |
| 122 | return -EINVAL; | 122 | return -EINVAL; |
| 123 | 123 | ||
| 124 | freqs.cpu = policy->cpu; | ||
| 125 | freqs.old = spear_cpufreq_get(0); | 124 | freqs.old = spear_cpufreq_get(0); |
| 126 | 125 | ||
| 127 | newfreq = spear_cpufreq.freq_tbl[index].frequency * 1000; | 126 | newfreq = spear_cpufreq.freq_tbl[index].frequency * 1000; |
| @@ -158,8 +157,7 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy, | |||
| 158 | freqs.new = newfreq / 1000; | 157 | freqs.new = newfreq / 1000; |
| 159 | freqs.new /= mult; | 158 | freqs.new /= mult; |
| 160 | 159 | ||
| 161 | for_each_cpu(freqs.cpu, policy->cpus) | 160 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 162 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 163 | 161 | ||
| 164 | if (mult == 2) | 162 | if (mult == 2) |
| 165 | ret = spear1340_set_cpu_rate(srcclk, newfreq); | 163 | ret = spear1340_set_cpu_rate(srcclk, newfreq); |
| @@ -172,8 +170,7 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy, | |||
| 172 | freqs.new = clk_get_rate(spear_cpufreq.clk) / 1000; | 170 | freqs.new = clk_get_rate(spear_cpufreq.clk) / 1000; |
| 173 | } | 171 | } |
| 174 | 172 | ||
| 175 | for_each_cpu(freqs.cpu, policy->cpus) | 173 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 176 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 177 | return ret; | 174 | return ret; |
| 178 | } | 175 | } |
| 179 | 176 | ||
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c index 3a953d519f46..618e6f417b1c 100644 --- a/drivers/cpufreq/speedstep-centrino.c +++ b/drivers/cpufreq/speedstep-centrino.c | |||
| @@ -457,7 +457,7 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
| 457 | unsigned int msr, oldmsr = 0, h = 0, cpu = policy->cpu; | 457 | unsigned int msr, oldmsr = 0, h = 0, cpu = policy->cpu; |
| 458 | struct cpufreq_freqs freqs; | 458 | struct cpufreq_freqs freqs; |
| 459 | int retval = 0; | 459 | int retval = 0; |
| 460 | unsigned int j, k, first_cpu, tmp; | 460 | unsigned int j, first_cpu, tmp; |
| 461 | cpumask_var_t covered_cpus; | 461 | cpumask_var_t covered_cpus; |
| 462 | 462 | ||
| 463 | if (unlikely(!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL))) | 463 | if (unlikely(!zalloc_cpumask_var(&covered_cpus, GFP_KERNEL))) |
| @@ -481,10 +481,6 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
| 481 | for_each_cpu(j, policy->cpus) { | 481 | for_each_cpu(j, policy->cpus) { |
| 482 | int good_cpu; | 482 | int good_cpu; |
| 483 | 483 | ||
| 484 | /* cpufreq holds the hotplug lock, so we are safe here */ | ||
| 485 | if (!cpu_online(j)) | ||
| 486 | continue; | ||
| 487 | |||
| 488 | /* | 484 | /* |
| 489 | * Support for SMP systems. | 485 | * Support for SMP systems. |
| 490 | * Make sure we are running on CPU that wants to change freq | 486 | * Make sure we are running on CPU that wants to change freq |
| @@ -522,13 +518,8 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
| 522 | pr_debug("target=%dkHz old=%d new=%d msr=%04x\n", | 518 | pr_debug("target=%dkHz old=%d new=%d msr=%04x\n", |
| 523 | target_freq, freqs.old, freqs.new, msr); | 519 | target_freq, freqs.old, freqs.new, msr); |
| 524 | 520 | ||
| 525 | for_each_cpu(k, policy->cpus) { | 521 | cpufreq_notify_transition(policy, &freqs, |
| 526 | if (!cpu_online(k)) | ||
| 527 | continue; | ||
| 528 | freqs.cpu = k; | ||
| 529 | cpufreq_notify_transition(&freqs, | ||
| 530 | CPUFREQ_PRECHANGE); | 522 | CPUFREQ_PRECHANGE); |
| 531 | } | ||
| 532 | 523 | ||
| 533 | first_cpu = 0; | 524 | first_cpu = 0; |
| 534 | /* all but 16 LSB are reserved, treat them with care */ | 525 | /* all but 16 LSB are reserved, treat them with care */ |
| @@ -544,12 +535,7 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
| 544 | cpumask_set_cpu(j, covered_cpus); | 535 | cpumask_set_cpu(j, covered_cpus); |
| 545 | } | 536 | } |
| 546 | 537 | ||
| 547 | for_each_cpu(k, policy->cpus) { | 538 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 548 | if (!cpu_online(k)) | ||
| 549 | continue; | ||
| 550 | freqs.cpu = k; | ||
| 551 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 552 | } | ||
| 553 | 539 | ||
| 554 | if (unlikely(retval)) { | 540 | if (unlikely(retval)) { |
| 555 | /* | 541 | /* |
| @@ -565,12 +551,8 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
| 565 | tmp = freqs.new; | 551 | tmp = freqs.new; |
| 566 | freqs.new = freqs.old; | 552 | freqs.new = freqs.old; |
| 567 | freqs.old = tmp; | 553 | freqs.old = tmp; |
| 568 | for_each_cpu(j, policy->cpus) { | 554 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 569 | if (!cpu_online(j)) | 555 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 570 | continue; | ||
| 571 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 572 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 573 | } | ||
| 574 | } | 556 | } |
| 575 | retval = 0; | 557 | retval = 0; |
| 576 | 558 | ||
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c index e29b59aa68a8..e2e5aa971452 100644 --- a/drivers/cpufreq/speedstep-ich.c +++ b/drivers/cpufreq/speedstep-ich.c | |||
| @@ -263,7 +263,6 @@ static int speedstep_target(struct cpufreq_policy *policy, | |||
| 263 | { | 263 | { |
| 264 | unsigned int newstate = 0, policy_cpu; | 264 | unsigned int newstate = 0, policy_cpu; |
| 265 | struct cpufreq_freqs freqs; | 265 | struct cpufreq_freqs freqs; |
| 266 | int i; | ||
| 267 | 266 | ||
| 268 | if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], | 267 | if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], |
| 269 | target_freq, relation, &newstate)) | 268 | target_freq, relation, &newstate)) |
| @@ -272,7 +271,6 @@ static int speedstep_target(struct cpufreq_policy *policy, | |||
| 272 | policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask); | 271 | policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask); |
| 273 | freqs.old = speedstep_get(policy_cpu); | 272 | freqs.old = speedstep_get(policy_cpu); |
| 274 | freqs.new = speedstep_freqs[newstate].frequency; | 273 | freqs.new = speedstep_freqs[newstate].frequency; |
| 275 | freqs.cpu = policy->cpu; | ||
| 276 | 274 | ||
| 277 | pr_debug("transiting from %u to %u kHz\n", freqs.old, freqs.new); | 275 | pr_debug("transiting from %u to %u kHz\n", freqs.old, freqs.new); |
| 278 | 276 | ||
| @@ -280,18 +278,12 @@ static int speedstep_target(struct cpufreq_policy *policy, | |||
| 280 | if (freqs.old == freqs.new) | 278 | if (freqs.old == freqs.new) |
| 281 | return 0; | 279 | return 0; |
| 282 | 280 | ||
| 283 | for_each_cpu(i, policy->cpus) { | 281 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 284 | freqs.cpu = i; | ||
| 285 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 286 | } | ||
| 287 | 282 | ||
| 288 | smp_call_function_single(policy_cpu, _speedstep_set_state, &newstate, | 283 | smp_call_function_single(policy_cpu, _speedstep_set_state, &newstate, |
| 289 | true); | 284 | true); |
| 290 | 285 | ||
| 291 | for_each_cpu(i, policy->cpus) { | 286 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 292 | freqs.cpu = i; | ||
| 293 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 294 | } | ||
| 295 | 287 | ||
| 296 | return 0; | 288 | return 0; |
| 297 | } | 289 | } |
diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c index 6a457fcaaad5..f5a6b70ee6c0 100644 --- a/drivers/cpufreq/speedstep-smi.c +++ b/drivers/cpufreq/speedstep-smi.c | |||
| @@ -252,14 +252,13 @@ static int speedstep_target(struct cpufreq_policy *policy, | |||
| 252 | 252 | ||
| 253 | freqs.old = speedstep_freqs[speedstep_get_state()].frequency; | 253 | freqs.old = speedstep_freqs[speedstep_get_state()].frequency; |
| 254 | freqs.new = speedstep_freqs[newstate].frequency; | 254 | freqs.new = speedstep_freqs[newstate].frequency; |
| 255 | freqs.cpu = 0; /* speedstep.c is UP only driver */ | ||
| 256 | 255 | ||
| 257 | if (freqs.old == freqs.new) | 256 | if (freqs.old == freqs.new) |
| 258 | return 0; | 257 | return 0; |
| 259 | 258 | ||
| 260 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 259 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 261 | speedstep_set_state(newstate); | 260 | speedstep_set_state(newstate); |
| 262 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 261 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 263 | 262 | ||
| 264 | return 0; | 263 | return 0; |
| 265 | } | 264 | } |
diff --git a/arch/arm/mach-tegra/cpu-tegra.c b/drivers/cpufreq/tegra-cpufreq.c index e3d6e15ff188..c74c0e130ef4 100644 --- a/arch/arm/mach-tegra/cpu-tegra.c +++ b/drivers/cpufreq/tegra-cpufreq.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * arch/arm/mach-tegra/cpu-tegra.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 2010 Google, Inc. | 2 | * Copyright (C) 2010 Google, Inc. |
| 5 | * | 3 | * |
| 6 | * Author: | 4 | * Author: |
| @@ -106,7 +104,8 @@ out: | |||
| 106 | return ret; | 104 | return ret; |
| 107 | } | 105 | } |
| 108 | 106 | ||
| 109 | static int tegra_update_cpu_speed(unsigned long rate) | 107 | static int tegra_update_cpu_speed(struct cpufreq_policy *policy, |
| 108 | unsigned long rate) | ||
| 110 | { | 109 | { |
| 111 | int ret = 0; | 110 | int ret = 0; |
| 112 | struct cpufreq_freqs freqs; | 111 | struct cpufreq_freqs freqs; |
| @@ -128,8 +127,7 @@ static int tegra_update_cpu_speed(unsigned long rate) | |||
| 128 | else | 127 | else |
| 129 | clk_set_rate(emc_clk, 100000000); /* emc 50Mhz */ | 128 | clk_set_rate(emc_clk, 100000000); /* emc 50Mhz */ |
| 130 | 129 | ||
| 131 | for_each_online_cpu(freqs.cpu) | 130 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 132 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
| 133 | 131 | ||
| 134 | #ifdef CONFIG_CPU_FREQ_DEBUG | 132 | #ifdef CONFIG_CPU_FREQ_DEBUG |
| 135 | printk(KERN_DEBUG "cpufreq-tegra: transition: %u --> %u\n", | 133 | printk(KERN_DEBUG "cpufreq-tegra: transition: %u --> %u\n", |
| @@ -143,8 +141,7 @@ static int tegra_update_cpu_speed(unsigned long rate) | |||
| 143 | return ret; | 141 | return ret; |
| 144 | } | 142 | } |
| 145 | 143 | ||
| 146 | for_each_online_cpu(freqs.cpu) | 144 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 147 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
| 148 | 145 | ||
| 149 | return 0; | 146 | return 0; |
| 150 | } | 147 | } |
| @@ -181,7 +178,7 @@ static int tegra_target(struct cpufreq_policy *policy, | |||
| 181 | 178 | ||
| 182 | target_cpu_speed[policy->cpu] = freq; | 179 | target_cpu_speed[policy->cpu] = freq; |
| 183 | 180 | ||
| 184 | ret = tegra_update_cpu_speed(tegra_cpu_highest_speed()); | 181 | ret = tegra_update_cpu_speed(policy, tegra_cpu_highest_speed()); |
| 185 | 182 | ||
| 186 | out: | 183 | out: |
| 187 | mutex_unlock(&tegra_cpu_lock); | 184 | mutex_unlock(&tegra_cpu_lock); |
| @@ -193,10 +190,12 @@ static int tegra_pm_notify(struct notifier_block *nb, unsigned long event, | |||
| 193 | { | 190 | { |
| 194 | mutex_lock(&tegra_cpu_lock); | 191 | mutex_lock(&tegra_cpu_lock); |
| 195 | if (event == PM_SUSPEND_PREPARE) { | 192 | if (event == PM_SUSPEND_PREPARE) { |
| 193 | struct cpufreq_policy *policy = cpufreq_cpu_get(0); | ||
| 196 | is_suspended = true; | 194 | is_suspended = true; |
| 197 | pr_info("Tegra cpufreq suspend: setting frequency to %d kHz\n", | 195 | pr_info("Tegra cpufreq suspend: setting frequency to %d kHz\n", |
| 198 | freq_table[0].frequency); | 196 | freq_table[0].frequency); |
| 199 | tegra_update_cpu_speed(freq_table[0].frequency); | 197 | tegra_update_cpu_speed(policy, freq_table[0].frequency); |
| 198 | cpufreq_cpu_put(policy); | ||
| 200 | } else if (event == PM_POST_SUSPEND) { | 199 | } else if (event == PM_POST_SUSPEND) { |
| 201 | is_suspended = false; | 200 | is_suspended = false; |
| 202 | } | 201 | } |
diff --git a/arch/unicore32/kernel/cpu-ucv2.c b/drivers/cpufreq/unicore2-cpufreq.c index 4a99f62584c7..12fc904d7dab 100644 --- a/arch/unicore32/kernel/cpu-ucv2.c +++ b/drivers/cpufreq/unicore2-cpufreq.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/arch/unicore32/kernel/cpu-ucv2.c: clock scaling for the UniCore-II | 2 | * clock scaling for the UniCore-II |
| 3 | * | 3 | * |
| 4 | * Code specific to PKUnity SoC and UniCore ISA | 4 | * Code specific to PKUnity SoC and UniCore ISA |
| 5 | * | 5 | * |
| @@ -52,15 +52,14 @@ static int ucv2_target(struct cpufreq_policy *policy, | |||
| 52 | struct cpufreq_freqs freqs; | 52 | struct cpufreq_freqs freqs; |
| 53 | struct clk *mclk = clk_get(NULL, "MAIN_CLK"); | 53 | struct clk *mclk = clk_get(NULL, "MAIN_CLK"); |
| 54 | 54 | ||
| 55 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 55 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
| 56 | 56 | ||
| 57 | if (!clk_set_rate(mclk, target_freq * 1000)) { | 57 | if (!clk_set_rate(mclk, target_freq * 1000)) { |
| 58 | freqs.old = cur; | 58 | freqs.old = cur; |
| 59 | freqs.new = target_freq; | 59 | freqs.new = target_freq; |
| 60 | freqs.cpu = 0; | ||
| 61 | } | 60 | } |
| 62 | 61 | ||
| 63 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 62 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 64 | 63 | ||
| 65 | return 0; | 64 | return 0; |
| 66 | } | 65 | } |
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index 071e2c3eec4f..c4cc27e5c8a5 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig | |||
| @@ -39,10 +39,4 @@ config CPU_IDLE_CALXEDA | |||
| 39 | help | 39 | help |
| 40 | Select this to enable cpuidle on Calxeda processors. | 40 | Select this to enable cpuidle on Calxeda processors. |
| 41 | 41 | ||
| 42 | config CPU_IDLE_KIRKWOOD | ||
| 43 | bool "CPU Idle Driver for Kirkwood processors" | ||
| 44 | depends on ARCH_KIRKWOOD | ||
| 45 | help | ||
| 46 | Select this to enable cpuidle on Kirkwood processors. | ||
| 47 | |||
| 48 | endif | 42 | endif |
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile index 24c6e7d945ed..0d8bd55e776f 100644 --- a/drivers/cpuidle/Makefile +++ b/drivers/cpuidle/Makefile | |||
| @@ -6,4 +6,4 @@ obj-y += cpuidle.o driver.o governor.o sysfs.o governors/ | |||
| 6 | obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o | 6 | obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o |
| 7 | 7 | ||
| 8 | obj-$(CONFIG_CPU_IDLE_CALXEDA) += cpuidle-calxeda.o | 8 | obj-$(CONFIG_CPU_IDLE_CALXEDA) += cpuidle-calxeda.o |
| 9 | obj-$(CONFIG_CPU_IDLE_KIRKWOOD) += cpuidle-kirkwood.o | 9 | obj-$(CONFIG_ARCH_KIRKWOOD) += cpuidle-kirkwood.o |
diff --git a/drivers/cpuidle/cpuidle-calxeda.c b/drivers/cpuidle/cpuidle-calxeda.c index e1aab38c5a8d..223379169cb0 100644 --- a/drivers/cpuidle/cpuidle-calxeda.c +++ b/drivers/cpuidle/cpuidle-calxeda.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright 2012 Calxeda, Inc. | 2 | * Copyright 2012 Calxeda, Inc. |
| 3 | * | 3 | * |
| 4 | * Based on arch/arm/plat-mxc/cpuidle.c: | 4 | * Based on arch/arm/plat-mxc/cpuidle.c: #v3.7 |
| 5 | * Copyright 2012 Freescale Semiconductor, Inc. | 5 | * Copyright 2012 Freescale Semiconductor, Inc. |
| 6 | * Copyright 2012 Linaro Ltd. | 6 | * Copyright 2012 Linaro Ltd. |
| 7 | * | 7 | * |
| @@ -16,6 +16,8 @@ | |||
| 16 | * | 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with | 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * | ||
| 20 | * Maintainer: Rob Herring <rob.herring@calxeda.com> | ||
| 19 | */ | 21 | */ |
| 20 | 22 | ||
| 21 | #include <linux/cpuidle.h> | 23 | #include <linux/cpuidle.h> |
| @@ -35,8 +37,6 @@ | |||
| 35 | extern void highbank_set_cpu_jump(int cpu, void *jump_addr); | 37 | extern void highbank_set_cpu_jump(int cpu, void *jump_addr); |
| 36 | extern void *scu_base_addr; | 38 | extern void *scu_base_addr; |
| 37 | 39 | ||
| 38 | static struct cpuidle_device __percpu *calxeda_idle_cpuidle_devices; | ||
| 39 | |||
| 40 | static inline unsigned int get_auxcr(void) | 40 | static inline unsigned int get_auxcr(void) |
| 41 | { | 41 | { |
| 42 | unsigned int val; | 42 | unsigned int val; |
| @@ -85,22 +85,8 @@ static int calxeda_pwrdown_idle(struct cpuidle_device *dev, | |||
| 85 | return index; | 85 | return index; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | static void calxeda_idle_cpuidle_devices_uninit(void) | ||
| 89 | { | ||
| 90 | int i; | ||
| 91 | struct cpuidle_device *dev; | ||
| 92 | |||
| 93 | for_each_possible_cpu(i) { | ||
| 94 | dev = per_cpu_ptr(calxeda_idle_cpuidle_devices, i); | ||
| 95 | cpuidle_unregister_device(dev); | ||
| 96 | } | ||
| 97 | |||
| 98 | free_percpu(calxeda_idle_cpuidle_devices); | ||
| 99 | } | ||
| 100 | |||
| 101 | static struct cpuidle_driver calxeda_idle_driver = { | 88 | static struct cpuidle_driver calxeda_idle_driver = { |
| 102 | .name = "calxeda_idle", | 89 | .name = "calxeda_idle", |
| 103 | .en_core_tk_irqen = 1, | ||
| 104 | .states = { | 90 | .states = { |
| 105 | ARM_CPUIDLE_WFI_STATE, | 91 | ARM_CPUIDLE_WFI_STATE, |
| 106 | { | 92 | { |
| @@ -118,44 +104,9 @@ static struct cpuidle_driver calxeda_idle_driver = { | |||
| 118 | 104 | ||
| 119 | static int __init calxeda_cpuidle_init(void) | 105 | static int __init calxeda_cpuidle_init(void) |
| 120 | { | 106 | { |
| 121 | int cpu_id; | ||
| 122 | int ret; | ||
| 123 | struct cpuidle_device *dev; | ||
| 124 | struct cpuidle_driver *drv = &calxeda_idle_driver; | ||
| 125 | |||
| 126 | if (!of_machine_is_compatible("calxeda,highbank")) | 107 | if (!of_machine_is_compatible("calxeda,highbank")) |
| 127 | return -ENODEV; | 108 | return -ENODEV; |
| 128 | 109 | ||
| 129 | ret = cpuidle_register_driver(drv); | 110 | return cpuidle_register(&calxeda_idle_driver, NULL); |
| 130 | if (ret) | ||
| 131 | return ret; | ||
| 132 | |||
| 133 | calxeda_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device); | ||
| 134 | if (calxeda_idle_cpuidle_devices == NULL) { | ||
| 135 | ret = -ENOMEM; | ||
| 136 | goto unregister_drv; | ||
| 137 | } | ||
| 138 | |||
| 139 | /* initialize state data for each cpuidle_device */ | ||
| 140 | for_each_possible_cpu(cpu_id) { | ||
| 141 | dev = per_cpu_ptr(calxeda_idle_cpuidle_devices, cpu_id); | ||
| 142 | dev->cpu = cpu_id; | ||
| 143 | dev->state_count = drv->state_count; | ||
| 144 | |||
| 145 | ret = cpuidle_register_device(dev); | ||
| 146 | if (ret) { | ||
| 147 | pr_err("Failed to register cpu %u, error: %d\n", | ||
| 148 | cpu_id, ret); | ||
| 149 | goto uninit; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | return 0; | ||
| 154 | |||
| 155 | uninit: | ||
| 156 | calxeda_idle_cpuidle_devices_uninit(); | ||
| 157 | unregister_drv: | ||
| 158 | cpuidle_unregister_driver(drv); | ||
| 159 | return ret; | ||
| 160 | } | 111 | } |
| 161 | module_init(calxeda_cpuidle_init); | 112 | module_init(calxeda_cpuidle_init); |
diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c index 670aa1e55cd6..521b0a7fdd89 100644 --- a/drivers/cpuidle/cpuidle-kirkwood.c +++ b/drivers/cpuidle/cpuidle-kirkwood.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * arch/arm/mach-kirkwood/cpuidle.c | ||
| 3 | * | ||
| 4 | * CPU idle Marvell Kirkwood SoCs | 2 | * CPU idle Marvell Kirkwood SoCs |
| 5 | * | 3 | * |
| 6 | * This file is licensed under the terms of the GNU General Public | 4 | * This file is licensed under the terms of the GNU General Public |
| @@ -11,6 +9,9 @@ | |||
| 11 | * to implement two idle states - | 9 | * to implement two idle states - |
| 12 | * #1 wait-for-interrupt | 10 | * #1 wait-for-interrupt |
| 13 | * #2 wait-for-interrupt and DDR self refresh | 11 | * #2 wait-for-interrupt and DDR self refresh |
| 12 | * | ||
| 13 | * Maintainer: Jason Cooper <jason@lakedaemon.net> | ||
| 14 | * Maintainer: Andrew Lunn <andrew@lunn.ch> | ||
| 14 | */ | 15 | */ |
| 15 | 16 | ||
| 16 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
| @@ -41,7 +42,6 @@ static int kirkwood_enter_idle(struct cpuidle_device *dev, | |||
| 41 | static struct cpuidle_driver kirkwood_idle_driver = { | 42 | static struct cpuidle_driver kirkwood_idle_driver = { |
| 42 | .name = "kirkwood_idle", | 43 | .name = "kirkwood_idle", |
| 43 | .owner = THIS_MODULE, | 44 | .owner = THIS_MODULE, |
| 44 | .en_core_tk_irqen = 1, | ||
| 45 | .states[0] = ARM_CPUIDLE_WFI_STATE, | 45 | .states[0] = ARM_CPUIDLE_WFI_STATE, |
| 46 | .states[1] = { | 46 | .states[1] = { |
| 47 | .enter = kirkwood_enter_idle, | 47 | .enter = kirkwood_enter_idle, |
| @@ -53,9 +53,6 @@ static struct cpuidle_driver kirkwood_idle_driver = { | |||
| 53 | }, | 53 | }, |
| 54 | .state_count = KIRKWOOD_MAX_STATES, | 54 | .state_count = KIRKWOOD_MAX_STATES, |
| 55 | }; | 55 | }; |
| 56 | static struct cpuidle_device *device; | ||
| 57 | |||
| 58 | static DEFINE_PER_CPU(struct cpuidle_device, kirkwood_cpuidle_device); | ||
| 59 | 56 | ||
| 60 | /* Initialize CPU idle by registering the idle states */ | 57 | /* Initialize CPU idle by registering the idle states */ |
| 61 | static int kirkwood_cpuidle_probe(struct platform_device *pdev) | 58 | static int kirkwood_cpuidle_probe(struct platform_device *pdev) |
| @@ -66,26 +63,16 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev) | |||
| 66 | if (res == NULL) | 63 | if (res == NULL) |
| 67 | return -EINVAL; | 64 | return -EINVAL; |
| 68 | 65 | ||
| 69 | ddr_operation_base = devm_request_and_ioremap(&pdev->dev, res); | 66 | ddr_operation_base = devm_ioremap_resource(&pdev->dev, res); |
| 70 | if (!ddr_operation_base) | 67 | if (IS_ERR(ddr_operation_base)) |
| 71 | return -EADDRNOTAVAIL; | 68 | return PTR_ERR(ddr_operation_base); |
| 72 | 69 | ||
| 73 | device = &per_cpu(kirkwood_cpuidle_device, smp_processor_id()); | 70 | return cpuidle_register(&kirkwood_idle_driver, NULL); |
| 74 | device->state_count = KIRKWOOD_MAX_STATES; | ||
| 75 | |||
| 76 | cpuidle_register_driver(&kirkwood_idle_driver); | ||
| 77 | if (cpuidle_register_device(device)) { | ||
| 78 | pr_err("kirkwood_init_cpuidle: Failed registering\n"); | ||
| 79 | return -EIO; | ||
| 80 | } | ||
| 81 | return 0; | ||
| 82 | } | 71 | } |
| 83 | 72 | ||
| 84 | int kirkwood_cpuidle_remove(struct platform_device *pdev) | 73 | int kirkwood_cpuidle_remove(struct platform_device *pdev) |
| 85 | { | 74 | { |
| 86 | cpuidle_unregister_device(device); | 75 | cpuidle_unregister(&kirkwood_idle_driver); |
| 87 | cpuidle_unregister_driver(&kirkwood_idle_driver); | ||
| 88 | |||
| 89 | return 0; | 76 | return 0; |
| 90 | } | 77 | } |
| 91 | 78 | ||
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index eba69290e074..c3a93fece819 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | * This code is licenced under the GPL. | 8 | * This code is licenced under the GPL. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #include <linux/clockchips.h> | ||
| 11 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
| 12 | #include <linux/mutex.h> | 13 | #include <linux/mutex.h> |
| 13 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
| @@ -23,6 +24,7 @@ | |||
| 23 | #include "cpuidle.h" | 24 | #include "cpuidle.h" |
| 24 | 25 | ||
| 25 | DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); | 26 | DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices); |
| 27 | DEFINE_PER_CPU(struct cpuidle_device, cpuidle_dev); | ||
| 26 | 28 | ||
| 27 | DEFINE_MUTEX(cpuidle_lock); | 29 | DEFINE_MUTEX(cpuidle_lock); |
| 28 | LIST_HEAD(cpuidle_detected_devices); | 30 | LIST_HEAD(cpuidle_detected_devices); |
| @@ -42,24 +44,6 @@ void disable_cpuidle(void) | |||
| 42 | 44 | ||
| 43 | static int __cpuidle_register_device(struct cpuidle_device *dev); | 45 | static int __cpuidle_register_device(struct cpuidle_device *dev); |
| 44 | 46 | ||
| 45 | static inline int cpuidle_enter(struct cpuidle_device *dev, | ||
| 46 | struct cpuidle_driver *drv, int index) | ||
| 47 | { | ||
| 48 | struct cpuidle_state *target_state = &drv->states[index]; | ||
| 49 | return target_state->enter(dev, drv, index); | ||
| 50 | } | ||
| 51 | |||
| 52 | static inline int cpuidle_enter_tk(struct cpuidle_device *dev, | ||
| 53 | struct cpuidle_driver *drv, int index) | ||
| 54 | { | ||
| 55 | return cpuidle_wrap_enter(dev, drv, index, cpuidle_enter); | ||
| 56 | } | ||
| 57 | |||
| 58 | typedef int (*cpuidle_enter_t)(struct cpuidle_device *dev, | ||
| 59 | struct cpuidle_driver *drv, int index); | ||
| 60 | |||
| 61 | static cpuidle_enter_t cpuidle_enter_ops; | ||
| 62 | |||
| 63 | /** | 47 | /** |
| 64 | * cpuidle_play_dead - cpu off-lining | 48 | * cpuidle_play_dead - cpu off-lining |
| 65 | * | 49 | * |
| @@ -89,11 +73,27 @@ int cpuidle_play_dead(void) | |||
| 89 | * @next_state: index into drv->states of the state to enter | 73 | * @next_state: index into drv->states of the state to enter |
| 90 | */ | 74 | */ |
| 91 | int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, | 75 | int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, |
| 92 | int next_state) | 76 | int index) |
| 93 | { | 77 | { |
| 94 | int entered_state; | 78 | int entered_state; |
| 95 | 79 | ||
| 96 | entered_state = cpuidle_enter_ops(dev, drv, next_state); | 80 | struct cpuidle_state *target_state = &drv->states[index]; |
| 81 | ktime_t time_start, time_end; | ||
| 82 | s64 diff; | ||
| 83 | |||
| 84 | time_start = ktime_get(); | ||
| 85 | |||
| 86 | entered_state = target_state->enter(dev, drv, index); | ||
| 87 | |||
| 88 | time_end = ktime_get(); | ||
| 89 | |||
| 90 | local_irq_enable(); | ||
| 91 | |||
| 92 | diff = ktime_to_us(ktime_sub(time_end, time_start)); | ||
| 93 | if (diff > INT_MAX) | ||
| 94 | diff = INT_MAX; | ||
| 95 | |||
| 96 | dev->last_residency = (int) diff; | ||
| 97 | 97 | ||
| 98 | if (entered_state >= 0) { | 98 | if (entered_state >= 0) { |
| 99 | /* Update cpuidle counters */ | 99 | /* Update cpuidle counters */ |
| @@ -146,12 +146,20 @@ int cpuidle_idle_call(void) | |||
| 146 | 146 | ||
| 147 | trace_cpu_idle_rcuidle(next_state, dev->cpu); | 147 | trace_cpu_idle_rcuidle(next_state, dev->cpu); |
| 148 | 148 | ||
| 149 | if (drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP) | ||
| 150 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, | ||
| 151 | &dev->cpu); | ||
| 152 | |||
| 149 | if (cpuidle_state_is_coupled(dev, drv, next_state)) | 153 | if (cpuidle_state_is_coupled(dev, drv, next_state)) |
| 150 | entered_state = cpuidle_enter_state_coupled(dev, drv, | 154 | entered_state = cpuidle_enter_state_coupled(dev, drv, |
| 151 | next_state); | 155 | next_state); |
| 152 | else | 156 | else |
| 153 | entered_state = cpuidle_enter_state(dev, drv, next_state); | 157 | entered_state = cpuidle_enter_state(dev, drv, next_state); |
| 154 | 158 | ||
| 159 | if (drv->states[next_state].flags & CPUIDLE_FLAG_TIMER_STOP) | ||
| 160 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, | ||
| 161 | &dev->cpu); | ||
| 162 | |||
| 155 | trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); | 163 | trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); |
| 156 | 164 | ||
| 157 | /* give the governor an opportunity to reflect on the outcome */ | 165 | /* give the governor an opportunity to reflect on the outcome */ |
| @@ -222,37 +230,6 @@ void cpuidle_resume(void) | |||
| 222 | mutex_unlock(&cpuidle_lock); | 230 | mutex_unlock(&cpuidle_lock); |
| 223 | } | 231 | } |
| 224 | 232 | ||
| 225 | /** | ||
| 226 | * cpuidle_wrap_enter - performs timekeeping and irqen around enter function | ||
| 227 | * @dev: pointer to a valid cpuidle_device object | ||
| 228 | * @drv: pointer to a valid cpuidle_driver object | ||
| 229 | * @index: index of the target cpuidle state. | ||
| 230 | */ | ||
| 231 | int cpuidle_wrap_enter(struct cpuidle_device *dev, | ||
| 232 | struct cpuidle_driver *drv, int index, | ||
| 233 | int (*enter)(struct cpuidle_device *dev, | ||
| 234 | struct cpuidle_driver *drv, int index)) | ||
| 235 | { | ||
| 236 | ktime_t time_start, time_end; | ||
| 237 | s64 diff; | ||
| 238 | |||
| 239 | time_start = ktime_get(); | ||
| 240 | |||
| 241 | index = enter(dev, drv, index); | ||
| 242 | |||
| 243 | time_end = ktime_get(); | ||
| 244 | |||
| 245 | local_irq_enable(); | ||
| 246 | |||
| 247 | diff = ktime_to_us(ktime_sub(time_end, time_start)); | ||
| 248 | if (diff > INT_MAX) | ||
| 249 | diff = INT_MAX; | ||
| 250 | |||
| 251 | dev->last_residency = (int) diff; | ||
| 252 | |||
| 253 | return index; | ||
| 254 | } | ||
| 255 | |||
| 256 | #ifdef CONFIG_ARCH_HAS_CPU_RELAX | 233 | #ifdef CONFIG_ARCH_HAS_CPU_RELAX |
| 257 | static int poll_idle(struct cpuidle_device *dev, | 234 | static int poll_idle(struct cpuidle_device *dev, |
| 258 | struct cpuidle_driver *drv, int index) | 235 | struct cpuidle_driver *drv, int index) |
| @@ -324,9 +301,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev) | |||
| 324 | return ret; | 301 | return ret; |
| 325 | } | 302 | } |
| 326 | 303 | ||
| 327 | cpuidle_enter_ops = drv->en_core_tk_irqen ? | ||
| 328 | cpuidle_enter_tk : cpuidle_enter; | ||
| 329 | |||
| 330 | poll_idle_init(drv); | 304 | poll_idle_init(drv); |
| 331 | 305 | ||
| 332 | ret = cpuidle_add_device_sysfs(dev); | 306 | ret = cpuidle_add_device_sysfs(dev); |
| @@ -480,6 +454,77 @@ void cpuidle_unregister_device(struct cpuidle_device *dev) | |||
| 480 | 454 | ||
| 481 | EXPORT_SYMBOL_GPL(cpuidle_unregister_device); | 455 | EXPORT_SYMBOL_GPL(cpuidle_unregister_device); |
| 482 | 456 | ||
| 457 | /** | ||
| 458 | * cpuidle_unregister: unregister a driver and the devices. This function | ||
| 459 | * can be used only if the driver has been previously registered through | ||
| 460 | * the cpuidle_register function. | ||
| 461 | * | ||
| 462 | * @drv: a valid pointer to a struct cpuidle_driver | ||
| 463 | */ | ||
| 464 | void cpuidle_unregister(struct cpuidle_driver *drv) | ||
| 465 | { | ||
| 466 | int cpu; | ||
| 467 | struct cpuidle_device *device; | ||
| 468 | |||
| 469 | for_each_possible_cpu(cpu) { | ||
| 470 | device = &per_cpu(cpuidle_dev, cpu); | ||
| 471 | cpuidle_unregister_device(device); | ||
| 472 | } | ||
| 473 | |||
| 474 | cpuidle_unregister_driver(drv); | ||
| 475 | } | ||
| 476 | EXPORT_SYMBOL_GPL(cpuidle_unregister); | ||
| 477 | |||
| 478 | /** | ||
| 479 | * cpuidle_register: registers the driver and the cpu devices with the | ||
| 480 | * coupled_cpus passed as parameter. This function is used for all common | ||
| 481 | * initialization pattern there are in the arch specific drivers. The | ||
| 482 | * devices is globally defined in this file. | ||
| 483 | * | ||
| 484 | * @drv : a valid pointer to a struct cpuidle_driver | ||
| 485 | * @coupled_cpus: a cpumask for the coupled states | ||
| 486 | * | ||
| 487 | * Returns 0 on success, < 0 otherwise | ||
| 488 | */ | ||
| 489 | int cpuidle_register(struct cpuidle_driver *drv, | ||
| 490 | const struct cpumask *const coupled_cpus) | ||
| 491 | { | ||
| 492 | int ret, cpu; | ||
| 493 | struct cpuidle_device *device; | ||
| 494 | |||
| 495 | ret = cpuidle_register_driver(drv); | ||
| 496 | if (ret) { | ||
| 497 | pr_err("failed to register cpuidle driver\n"); | ||
| 498 | return ret; | ||
| 499 | } | ||
| 500 | |||
| 501 | for_each_possible_cpu(cpu) { | ||
| 502 | device = &per_cpu(cpuidle_dev, cpu); | ||
| 503 | device->cpu = cpu; | ||
| 504 | |||
| 505 | #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED | ||
| 506 | /* | ||
| 507 | * On multiplatform for ARM, the coupled idle states could | ||
| 508 | * enabled in the kernel even if the cpuidle driver does not | ||
| 509 | * use it. Note, coupled_cpus is a struct copy. | ||
| 510 | */ | ||
| 511 | if (coupled_cpus) | ||
| 512 | device->coupled_cpus = *coupled_cpus; | ||
| 513 | #endif | ||
| 514 | ret = cpuidle_register_device(device); | ||
| 515 | if (!ret) | ||
| 516 | continue; | ||
| 517 | |||
| 518 | pr_err("Failed to register cpuidle device for cpu%d\n", cpu); | ||
| 519 | |||
| 520 | cpuidle_unregister(drv); | ||
| 521 | break; | ||
| 522 | } | ||
| 523 | |||
| 524 | return ret; | ||
| 525 | } | ||
| 526 | EXPORT_SYMBOL_GPL(cpuidle_register); | ||
| 527 | |||
| 483 | #ifdef CONFIG_SMP | 528 | #ifdef CONFIG_SMP |
| 484 | 529 | ||
| 485 | static void smp_callback(void *v) | 530 | static void smp_callback(void *v) |
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 422c7b69ba7c..8dfaaae94444 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c | |||
| @@ -11,6 +11,8 @@ | |||
| 11 | #include <linux/mutex.h> | 11 | #include <linux/mutex.h> |
| 12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
| 13 | #include <linux/cpuidle.h> | 13 | #include <linux/cpuidle.h> |
| 14 | #include <linux/cpumask.h> | ||
| 15 | #include <linux/clockchips.h> | ||
| 14 | 16 | ||
| 15 | #include "cpuidle.h" | 17 | #include "cpuidle.h" |
| 16 | 18 | ||
| @@ -19,9 +21,28 @@ DEFINE_SPINLOCK(cpuidle_driver_lock); | |||
| 19 | static void __cpuidle_set_cpu_driver(struct cpuidle_driver *drv, int cpu); | 21 | static void __cpuidle_set_cpu_driver(struct cpuidle_driver *drv, int cpu); |
| 20 | static struct cpuidle_driver * __cpuidle_get_cpu_driver(int cpu); | 22 | static struct cpuidle_driver * __cpuidle_get_cpu_driver(int cpu); |
| 21 | 23 | ||
| 22 | static void __cpuidle_driver_init(struct cpuidle_driver *drv) | 24 | static void cpuidle_setup_broadcast_timer(void *arg) |
| 23 | { | 25 | { |
| 26 | int cpu = smp_processor_id(); | ||
| 27 | clockevents_notify((long)(arg), &cpu); | ||
| 28 | } | ||
| 29 | |||
| 30 | static void __cpuidle_driver_init(struct cpuidle_driver *drv, int cpu) | ||
| 31 | { | ||
| 32 | int i; | ||
| 33 | |||
| 24 | drv->refcnt = 0; | 34 | drv->refcnt = 0; |
| 35 | |||
| 36 | for (i = drv->state_count - 1; i >= 0 ; i--) { | ||
| 37 | |||
| 38 | if (!(drv->states[i].flags & CPUIDLE_FLAG_TIMER_STOP)) | ||
| 39 | continue; | ||
| 40 | |||
| 41 | drv->bctimer = 1; | ||
| 42 | on_each_cpu_mask(get_cpu_mask(cpu), cpuidle_setup_broadcast_timer, | ||
| 43 | (void *)CLOCK_EVT_NOTIFY_BROADCAST_ON, 1); | ||
| 44 | break; | ||
| 45 | } | ||
| 25 | } | 46 | } |
| 26 | 47 | ||
| 27 | static int __cpuidle_register_driver(struct cpuidle_driver *drv, int cpu) | 48 | static int __cpuidle_register_driver(struct cpuidle_driver *drv, int cpu) |
| @@ -35,7 +56,7 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv, int cpu) | |||
| 35 | if (__cpuidle_get_cpu_driver(cpu)) | 56 | if (__cpuidle_get_cpu_driver(cpu)) |
| 36 | return -EBUSY; | 57 | return -EBUSY; |
| 37 | 58 | ||
| 38 | __cpuidle_driver_init(drv); | 59 | __cpuidle_driver_init(drv, cpu); |
| 39 | 60 | ||
| 40 | __cpuidle_set_cpu_driver(drv, cpu); | 61 | __cpuidle_set_cpu_driver(drv, cpu); |
| 41 | 62 | ||
| @@ -49,6 +70,12 @@ static void __cpuidle_unregister_driver(struct cpuidle_driver *drv, int cpu) | |||
| 49 | 70 | ||
| 50 | if (!WARN_ON(drv->refcnt > 0)) | 71 | if (!WARN_ON(drv->refcnt > 0)) |
| 51 | __cpuidle_set_cpu_driver(NULL, cpu); | 72 | __cpuidle_set_cpu_driver(NULL, cpu); |
| 73 | |||
| 74 | if (drv->bctimer) { | ||
| 75 | drv->bctimer = 0; | ||
| 76 | on_each_cpu_mask(get_cpu_mask(cpu), cpuidle_setup_broadcast_timer, | ||
| 77 | (void *)CLOCK_EVT_NOTIFY_BROADCAST_OFF, 1); | ||
| 78 | } | ||
| 52 | } | 79 | } |
| 53 | 80 | ||
| 54 | #ifdef CONFIG_CPU_IDLE_MULTIPLE_DRIVERS | 81 | #ifdef CONFIG_CPU_IDLE_MULTIPLE_DRIVERS |
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c index 4d338740f2cb..a8117e614009 100644 --- a/drivers/gpu/drm/i915/intel_opregion.c +++ b/drivers/gpu/drm/i915/intel_opregion.c | |||
| @@ -350,11 +350,11 @@ static void intel_didl_outputs(struct drm_device *dev) | |||
| 350 | if (!handle || acpi_bus_get_device(handle, &acpi_dev)) | 350 | if (!handle || acpi_bus_get_device(handle, &acpi_dev)) |
| 351 | return; | 351 | return; |
| 352 | 352 | ||
| 353 | if (acpi_is_video_device(acpi_dev)) | 353 | if (acpi_is_video_device(handle)) |
| 354 | acpi_video_bus = acpi_dev; | 354 | acpi_video_bus = acpi_dev; |
| 355 | else { | 355 | else { |
| 356 | list_for_each_entry(acpi_cdev, &acpi_dev->children, node) { | 356 | list_for_each_entry(acpi_cdev, &acpi_dev->children, node) { |
| 357 | if (acpi_is_video_device(acpi_cdev)) { | 357 | if (acpi_is_video_device(acpi_cdev->handle)) { |
| 358 | acpi_video_bus = acpi_cdev; | 358 | acpi_video_bus = acpi_cdev; |
| 359 | break; | 359 | break; |
| 360 | } | 360 | } |
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 1a38dd7dfe4e..0e8fab1913df 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c | |||
| @@ -71,7 +71,6 @@ | |||
| 71 | static struct cpuidle_driver intel_idle_driver = { | 71 | static struct cpuidle_driver intel_idle_driver = { |
| 72 | .name = "intel_idle", | 72 | .name = "intel_idle", |
| 73 | .owner = THIS_MODULE, | 73 | .owner = THIS_MODULE, |
| 74 | .en_core_tk_irqen = 1, | ||
| 75 | }; | 74 | }; |
| 76 | /* intel_idle.max_cstate=0 disables driver */ | 75 | /* intel_idle.max_cstate=0 disables driver */ |
| 77 | static int max_cstate = CPUIDLE_STATE_MAX - 1; | 76 | static int max_cstate = CPUIDLE_STATE_MAX - 1; |
| @@ -339,7 +338,6 @@ static int intel_idle(struct cpuidle_device *dev, | |||
| 339 | if (!(lapic_timer_reliable_states & (1 << (cstate)))) | 338 | if (!(lapic_timer_reliable_states & (1 << (cstate)))) |
| 340 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu); | 339 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu); |
| 341 | 340 | ||
| 342 | stop_critical_timings(); | ||
| 343 | if (!need_resched()) { | 341 | if (!need_resched()) { |
| 344 | 342 | ||
| 345 | __monitor((void *)¤t_thread_info()->flags, 0, 0); | 343 | __monitor((void *)¤t_thread_info()->flags, 0, 0); |
| @@ -348,8 +346,6 @@ static int intel_idle(struct cpuidle_device *dev, | |||
| 348 | __mwait(eax, ecx); | 346 | __mwait(eax, ecx); |
| 349 | } | 347 | } |
| 350 | 348 | ||
| 351 | start_critical_timings(); | ||
| 352 | |||
| 353 | if (!(lapic_timer_reliable_states & (1 << (cstate)))) | 349 | if (!(lapic_timer_reliable_states & (1 << (cstate)))) |
| 354 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu); | 350 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu); |
| 355 | 351 | ||
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index 14d4dced1def..d544e3aaf761 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c | |||
| @@ -4121,7 +4121,7 @@ static int sony_pic_enable(struct acpi_device *device, | |||
| 4121 | resource->res3.data.irq.sharable = ACPI_SHARED; | 4121 | resource->res3.data.irq.sharable = ACPI_SHARED; |
| 4122 | 4122 | ||
| 4123 | resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG; | 4123 | resource->res4.type = ACPI_RESOURCE_TYPE_END_TAG; |
| 4124 | 4124 | resource->res4.length = sizeof(struct acpi_resource); | |
| 4125 | } | 4125 | } |
| 4126 | /* setup Type 2/3 resources */ | 4126 | /* setup Type 2/3 resources */ |
| 4127 | else { | 4127 | else { |
| @@ -4140,6 +4140,7 @@ static int sony_pic_enable(struct acpi_device *device, | |||
| 4140 | resource->res2.data.irq.sharable = ACPI_SHARED; | 4140 | resource->res2.data.irq.sharable = ACPI_SHARED; |
| 4141 | 4141 | ||
| 4142 | resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG; | 4142 | resource->res3.type = ACPI_RESOURCE_TYPE_END_TAG; |
| 4143 | resource->res3.length = sizeof(struct acpi_resource); | ||
| 4143 | } | 4144 | } |
| 4144 | 4145 | ||
| 4145 | /* Attempt to set the resource */ | 4146 | /* Attempt to set the resource */ |
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 918d5f044865..cf88f9b62445 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c | |||
| @@ -379,10 +379,6 @@ static int __init isapnp_read_tag(unsigned char *type, unsigned short *size) | |||
| 379 | *type = (tag >> 3) & 0x0f; | 379 | *type = (tag >> 3) & 0x0f; |
| 380 | *size = tag & 0x07; | 380 | *size = tag & 0x07; |
| 381 | } | 381 | } |
| 382 | #if 0 | ||
| 383 | printk(KERN_DEBUG "tag = 0x%x, type = 0x%x, size = %i\n", tag, *type, | ||
| 384 | *size); | ||
| 385 | #endif | ||
| 386 | if (*type == 0xff && *size == 0xffff) /* probably invalid data */ | 382 | if (*type == 0xff && *size == 0xffff) /* probably invalid data */ |
| 387 | return -1; | 383 | return -1; |
| 388 | return 0; | 384 | return 0; |
| @@ -813,13 +809,6 @@ static int __init isapnp_build_device_list(void) | |||
| 813 | if (!card) | 809 | if (!card) |
| 814 | continue; | 810 | continue; |
| 815 | 811 | ||
| 816 | #if 0 | ||
| 817 | dev_info(&card->dev, | ||
| 818 | "vendor: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", | ||
| 819 | header[0], header[1], header[2], header[3], header[4], | ||
| 820 | header[5], header[6], header[7], header[8]); | ||
| 821 | dev_info(&card->dev, "checksum = %#x\n", checksum); | ||
| 822 | #endif | ||
| 823 | INIT_LIST_HEAD(&card->devices); | 812 | INIT_LIST_HEAD(&card->devices); |
| 824 | card->serial = | 813 | card->serial = |
| 825 | (header[7] << 24) | (header[6] << 16) | (header[5] << 8) | | 814 | (header[7] << 24) | (header[6] << 16) | (header[5] << 8) | |
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index b8f4ea7b27fc..9847ab163829 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
| @@ -634,6 +634,7 @@ int pnpacpi_build_resource_template(struct pnp_dev *dev, | |||
| 634 | } | 634 | } |
| 635 | /* resource will pointer the end resource now */ | 635 | /* resource will pointer the end resource now */ |
| 636 | resource->type = ACPI_RESOURCE_TYPE_END_TAG; | 636 | resource->type = ACPI_RESOURCE_TYPE_END_TAG; |
| 637 | resource->length = sizeof(struct acpi_resource); | ||
| 637 | 638 | ||
| 638 | return 0; | 639 | return 0; |
| 639 | } | 640 | } |
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c index 63ddb0173456..1c03ee822e50 100644 --- a/drivers/pnp/pnpbios/proc.c +++ b/drivers/pnp/pnpbios/proc.c | |||
| @@ -185,10 +185,9 @@ static int pnp_devices_proc_show(struct seq_file *m, void *v) | |||
| 185 | 185 | ||
| 186 | if (pnp_bios_get_dev_node(&nodenum, PNPMODE_DYNAMIC, node)) | 186 | if (pnp_bios_get_dev_node(&nodenum, PNPMODE_DYNAMIC, node)) |
| 187 | break; | 187 | break; |
| 188 | seq_printf(m, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n", | 188 | seq_printf(m, "%02x\t%08x\t%3phC\t%04x\n", |
| 189 | node->handle, node->eisa_id, | 189 | node->handle, node->eisa_id, |
| 190 | node->type_code[0], node->type_code[1], | 190 | node->type_code, node->flags); |
| 191 | node->type_code[2], node->flags); | ||
| 192 | if (nodenum <= thisnodenum) { | 191 | if (nodenum <= thisnodenum) { |
| 193 | printk(KERN_ERR | 192 | printk(KERN_ERR |
| 194 | "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", | 193 | "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", |
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h index 9bf59d0e8aaa..cf051e05a8fe 100644 --- a/include/acpi/acexcep.h +++ b/include/acpi/acexcep.h | |||
| @@ -44,17 +44,50 @@ | |||
| 44 | #ifndef __ACEXCEP_H__ | 44 | #ifndef __ACEXCEP_H__ |
| 45 | #define __ACEXCEP_H__ | 45 | #define __ACEXCEP_H__ |
| 46 | 46 | ||
| 47 | /* This module contains all possible exception codes for acpi_status */ | ||
| 48 | |||
| 47 | /* | 49 | /* |
| 48 | * Exceptions returned by external ACPI interfaces | 50 | * Exception code classes |
| 49 | */ | 51 | */ |
| 50 | #define AE_CODE_ENVIRONMENTAL 0x0000 | 52 | #define AE_CODE_ENVIRONMENTAL 0x0000 /* General ACPICA environment */ |
| 51 | #define AE_CODE_PROGRAMMER 0x1000 | 53 | #define AE_CODE_PROGRAMMER 0x1000 /* External ACPICA interface caller */ |
| 52 | #define AE_CODE_ACPI_TABLES 0x2000 | 54 | #define AE_CODE_ACPI_TABLES 0x2000 /* ACPI tables */ |
| 53 | #define AE_CODE_AML 0x3000 | 55 | #define AE_CODE_AML 0x3000 /* From executing AML code */ |
| 54 | #define AE_CODE_CONTROL 0x4000 | 56 | #define AE_CODE_CONTROL 0x4000 /* Internal control codes */ |
| 57 | |||
| 55 | #define AE_CODE_MAX 0x4000 | 58 | #define AE_CODE_MAX 0x4000 |
| 56 | #define AE_CODE_MASK 0xF000 | 59 | #define AE_CODE_MASK 0xF000 |
| 57 | 60 | ||
| 61 | /* | ||
| 62 | * Macros to insert the exception code classes | ||
| 63 | */ | ||
| 64 | #define EXCEP_ENV(code) ((acpi_status) (code | AE_CODE_ENVIRONMENTAL)) | ||
| 65 | #define EXCEP_PGM(code) ((acpi_status) (code | AE_CODE_PROGRAMMER)) | ||
| 66 | #define EXCEP_TBL(code) ((acpi_status) (code | AE_CODE_ACPI_TABLES)) | ||
| 67 | #define EXCEP_AML(code) ((acpi_status) (code | AE_CODE_AML)) | ||
| 68 | #define EXCEP_CTL(code) ((acpi_status) (code | AE_CODE_CONTROL)) | ||
| 69 | |||
| 70 | /* | ||
| 71 | * Exception info table. The "Description" field is used only by the | ||
| 72 | * ACPICA help application (acpihelp). | ||
| 73 | */ | ||
| 74 | struct acpi_exception_info { | ||
| 75 | char *name; | ||
| 76 | |||
| 77 | #ifdef ACPI_HELP_APP | ||
| 78 | char *description; | ||
| 79 | #endif | ||
| 80 | }; | ||
| 81 | |||
| 82 | #ifdef ACPI_HELP_APP | ||
| 83 | #define EXCEP_TXT(name,description) {name, description} | ||
| 84 | #else | ||
| 85 | #define EXCEP_TXT(name,description) {name} | ||
| 86 | #endif | ||
| 87 | |||
| 88 | /* | ||
| 89 | * Success is always zero, failure is non-zero | ||
| 90 | */ | ||
| 58 | #define ACPI_SUCCESS(a) (!(a)) | 91 | #define ACPI_SUCCESS(a) (!(a)) |
| 59 | #define ACPI_FAILURE(a) (a) | 92 | #define ACPI_FAILURE(a) (a) |
| 60 | 93 | ||
| @@ -64,60 +97,60 @@ | |||
| 64 | /* | 97 | /* |
| 65 | * Environmental exceptions | 98 | * Environmental exceptions |
| 66 | */ | 99 | */ |
| 67 | #define AE_ERROR (acpi_status) (0x0001 | AE_CODE_ENVIRONMENTAL) | 100 | #define AE_ERROR EXCEP_ENV (0x0001) |
| 68 | #define AE_NO_ACPI_TABLES (acpi_status) (0x0002 | AE_CODE_ENVIRONMENTAL) | 101 | #define AE_NO_ACPI_TABLES EXCEP_ENV (0x0002) |
| 69 | #define AE_NO_NAMESPACE (acpi_status) (0x0003 | AE_CODE_ENVIRONMENTAL) | 102 | #define AE_NO_NAMESPACE EXCEP_ENV (0x0003) |
| 70 | #define AE_NO_MEMORY (acpi_status) (0x0004 | AE_CODE_ENVIRONMENTAL) | 103 | #define AE_NO_MEMORY EXCEP_ENV (0x0004) |
| 71 | #define AE_NOT_FOUND (acpi_status) (0x0005 | AE_CODE_ENVIRONMENTAL) | 104 | #define AE_NOT_FOUND EXCEP_ENV (0x0005) |
| 72 | #define AE_NOT_EXIST (acpi_status) (0x0006 | AE_CODE_ENVIRONMENTAL) | 105 | #define AE_NOT_EXIST EXCEP_ENV (0x0006) |
| 73 | #define AE_ALREADY_EXISTS (acpi_status) (0x0007 | AE_CODE_ENVIRONMENTAL) | 106 | #define AE_ALREADY_EXISTS EXCEP_ENV (0x0007) |
| 74 | #define AE_TYPE (acpi_status) (0x0008 | AE_CODE_ENVIRONMENTAL) | 107 | #define AE_TYPE EXCEP_ENV (0x0008) |
| 75 | #define AE_NULL_OBJECT (acpi_status) (0x0009 | AE_CODE_ENVIRONMENTAL) | 108 | #define AE_NULL_OBJECT EXCEP_ENV (0x0009) |
| 76 | #define AE_NULL_ENTRY (acpi_status) (0x000A | AE_CODE_ENVIRONMENTAL) | 109 | #define AE_NULL_ENTRY EXCEP_ENV (0x000A) |
| 77 | #define AE_BUFFER_OVERFLOW (acpi_status) (0x000B | AE_CODE_ENVIRONMENTAL) | 110 | #define AE_BUFFER_OVERFLOW EXCEP_ENV (0x000B) |
| 78 | #define AE_STACK_OVERFLOW (acpi_status) (0x000C | AE_CODE_ENVIRONMENTAL) | 111 | #define AE_STACK_OVERFLOW EXCEP_ENV (0x000C) |
| 79 | #define AE_STACK_UNDERFLOW (acpi_status) (0x000D | AE_CODE_ENVIRONMENTAL) | 112 | #define AE_STACK_UNDERFLOW EXCEP_ENV (0x000D) |
| 80 | #define AE_NOT_IMPLEMENTED (acpi_status) (0x000E | AE_CODE_ENVIRONMENTAL) | 113 | #define AE_NOT_IMPLEMENTED EXCEP_ENV (0x000E) |
| 81 | #define AE_SUPPORT (acpi_status) (0x000F | AE_CODE_ENVIRONMENTAL) | 114 | #define AE_SUPPORT EXCEP_ENV (0x000F) |
| 82 | #define AE_LIMIT (acpi_status) (0x0010 | AE_CODE_ENVIRONMENTAL) | 115 | #define AE_LIMIT EXCEP_ENV (0x0010) |
| 83 | #define AE_TIME (acpi_status) (0x0011 | AE_CODE_ENVIRONMENTAL) | 116 | #define AE_TIME EXCEP_ENV (0x0011) |
| 84 | #define AE_ACQUIRE_DEADLOCK (acpi_status) (0x0012 | AE_CODE_ENVIRONMENTAL) | 117 | #define AE_ACQUIRE_DEADLOCK EXCEP_ENV (0x0012) |
| 85 | #define AE_RELEASE_DEADLOCK (acpi_status) (0x0013 | AE_CODE_ENVIRONMENTAL) | 118 | #define AE_RELEASE_DEADLOCK EXCEP_ENV (0x0013) |
| 86 | #define AE_NOT_ACQUIRED (acpi_status) (0x0014 | AE_CODE_ENVIRONMENTAL) | 119 | #define AE_NOT_ACQUIRED EXCEP_ENV (0x0014) |
| 87 | #define AE_ALREADY_ACQUIRED (acpi_status) (0x0015 | AE_CODE_ENVIRONMENTAL) | 120 | #define AE_ALREADY_ACQUIRED EXCEP_ENV (0x0015) |
| 88 | #define AE_NO_HARDWARE_RESPONSE (acpi_status) (0x0016 | AE_CODE_ENVIRONMENTAL) | 121 | #define AE_NO_HARDWARE_RESPONSE EXCEP_ENV (0x0016) |
| 89 | #define AE_NO_GLOBAL_LOCK (acpi_status) (0x0017 | AE_CODE_ENVIRONMENTAL) | 122 | #define AE_NO_GLOBAL_LOCK EXCEP_ENV (0x0017) |
| 90 | #define AE_ABORT_METHOD (acpi_status) (0x0018 | AE_CODE_ENVIRONMENTAL) | 123 | #define AE_ABORT_METHOD EXCEP_ENV (0x0018) |
| 91 | #define AE_SAME_HANDLER (acpi_status) (0x0019 | AE_CODE_ENVIRONMENTAL) | 124 | #define AE_SAME_HANDLER EXCEP_ENV (0x0019) |
| 92 | #define AE_NO_HANDLER (acpi_status) (0x001A | AE_CODE_ENVIRONMENTAL) | 125 | #define AE_NO_HANDLER EXCEP_ENV (0x001A) |
| 93 | #define AE_OWNER_ID_LIMIT (acpi_status) (0x001B | AE_CODE_ENVIRONMENTAL) | 126 | #define AE_OWNER_ID_LIMIT EXCEP_ENV (0x001B) |
| 94 | #define AE_NOT_CONFIGURED (acpi_status) (0x001C | AE_CODE_ENVIRONMENTAL) | 127 | #define AE_NOT_CONFIGURED EXCEP_ENV (0x001C) |
| 95 | 128 | ||
| 96 | #define AE_CODE_ENV_MAX 0x001C | 129 | #define AE_CODE_ENV_MAX 0x001C |
| 97 | 130 | ||
| 98 | /* | 131 | /* |
| 99 | * Programmer exceptions | 132 | * Programmer exceptions |
| 100 | */ | 133 | */ |
| 101 | #define AE_BAD_PARAMETER (acpi_status) (0x0001 | AE_CODE_PROGRAMMER) | 134 | #define AE_BAD_PARAMETER EXCEP_PGM (0x0001) |
| 102 | #define AE_BAD_CHARACTER (acpi_status) (0x0002 | AE_CODE_PROGRAMMER) | 135 | #define AE_BAD_CHARACTER EXCEP_PGM (0x0002) |
| 103 | #define AE_BAD_PATHNAME (acpi_status) (0x0003 | AE_CODE_PROGRAMMER) | 136 | #define AE_BAD_PATHNAME EXCEP_PGM (0x0003) |
| 104 | #define AE_BAD_DATA (acpi_status) (0x0004 | AE_CODE_PROGRAMMER) | 137 | #define AE_BAD_DATA EXCEP_PGM (0x0004) |
| 105 | #define AE_BAD_HEX_CONSTANT (acpi_status) (0x0005 | AE_CODE_PROGRAMMER) | 138 | #define AE_BAD_HEX_CONSTANT EXCEP_PGM (0x0005) |
| 106 | #define AE_BAD_OCTAL_CONSTANT (acpi_status) (0x0006 | AE_CODE_PROGRAMMER) | 139 | #define AE_BAD_OCTAL_CONSTANT EXCEP_PGM (0x0006) |
| 107 | #define AE_BAD_DECIMAL_CONSTANT (acpi_status) (0x0007 | AE_CODE_PROGRAMMER) | 140 | #define AE_BAD_DECIMAL_CONSTANT EXCEP_PGM (0x0007) |
| 108 | #define AE_MISSING_ARGUMENTS (acpi_status) (0x0008 | AE_CODE_PROGRAMMER) | 141 | #define AE_MISSING_ARGUMENTS EXCEP_PGM (0x0008) |
| 109 | #define AE_BAD_ADDRESS (acpi_status) (0x0009 | AE_CODE_PROGRAMMER) | 142 | #define AE_BAD_ADDRESS EXCEP_PGM (0x0009) |
| 110 | 143 | ||
| 111 | #define AE_CODE_PGM_MAX 0x0009 | 144 | #define AE_CODE_PGM_MAX 0x0009 |
| 112 | 145 | ||
| 113 | /* | 146 | /* |
| 114 | * Acpi table exceptions | 147 | * Acpi table exceptions |
| 115 | */ | 148 | */ |
| 116 | #define AE_BAD_SIGNATURE (acpi_status) (0x0001 | AE_CODE_ACPI_TABLES) | 149 | #define AE_BAD_SIGNATURE EXCEP_TBL (0x0001) |
| 117 | #define AE_BAD_HEADER (acpi_status) (0x0002 | AE_CODE_ACPI_TABLES) | 150 | #define AE_BAD_HEADER EXCEP_TBL (0x0002) |
| 118 | #define AE_BAD_CHECKSUM (acpi_status) (0x0003 | AE_CODE_ACPI_TABLES) | 151 | #define AE_BAD_CHECKSUM EXCEP_TBL (0x0003) |
| 119 | #define AE_BAD_VALUE (acpi_status) (0x0004 | AE_CODE_ACPI_TABLES) | 152 | #define AE_BAD_VALUE EXCEP_TBL (0x0004) |
| 120 | #define AE_INVALID_TABLE_LENGTH (acpi_status) (0x0005 | AE_CODE_ACPI_TABLES) | 153 | #define AE_INVALID_TABLE_LENGTH EXCEP_TBL (0x0005) |
| 121 | 154 | ||
| 122 | #define AE_CODE_TBL_MAX 0x0005 | 155 | #define AE_CODE_TBL_MAX 0x0005 |
| 123 | 156 | ||
| @@ -125,58 +158,58 @@ | |||
| 125 | * AML exceptions. These are caused by problems with | 158 | * AML exceptions. These are caused by problems with |
| 126 | * the actual AML byte stream | 159 | * the actual AML byte stream |
| 127 | */ | 160 | */ |
| 128 | #define AE_AML_BAD_OPCODE (acpi_status) (0x0001 | AE_CODE_AML) | 161 | #define AE_AML_BAD_OPCODE EXCEP_AML (0x0001) |
| 129 | #define AE_AML_NO_OPERAND (acpi_status) (0x0002 | AE_CODE_AML) | 162 | #define AE_AML_NO_OPERAND EXCEP_AML (0x0002) |
| 130 | #define AE_AML_OPERAND_TYPE (acpi_status) (0x0003 | AE_CODE_AML) | 163 | #define AE_AML_OPERAND_TYPE EXCEP_AML (0x0003) |
| 131 | #define AE_AML_OPERAND_VALUE (acpi_status) (0x0004 | AE_CODE_AML) | 164 | #define AE_AML_OPERAND_VALUE EXCEP_AML (0x0004) |
| 132 | #define AE_AML_UNINITIALIZED_LOCAL (acpi_status) (0x0005 | AE_CODE_AML) | 165 | #define AE_AML_UNINITIALIZED_LOCAL EXCEP_AML (0x0005) |
| 133 | #define AE_AML_UNINITIALIZED_ARG (acpi_status) (0x0006 | AE_CODE_AML) | 166 | #define AE_AML_UNINITIALIZED_ARG EXCEP_AML (0x0006) |
| 134 | #define AE_AML_UNINITIALIZED_ELEMENT (acpi_status) (0x0007 | AE_CODE_AML) | 167 | #define AE_AML_UNINITIALIZED_ELEMENT EXCEP_AML (0x0007) |
| 135 | #define AE_AML_NUMERIC_OVERFLOW (acpi_status) (0x0008 | AE_CODE_AML) | 168 | #define AE_AML_NUMERIC_OVERFLOW EXCEP_AML (0x0008) |
| 136 | #define AE_AML_REGION_LIMIT (acpi_status) (0x0009 | AE_CODE_AML) | 169 | #define AE_AML_REGION_LIMIT EXCEP_AML (0x0009) |
| 137 | #define AE_AML_BUFFER_LIMIT (acpi_status) (0x000A | AE_CODE_AML) | 170 | #define AE_AML_BUFFER_LIMIT EXCEP_AML (0x000A) |
| 138 | #define AE_AML_PACKAGE_LIMIT (acpi_status) (0x000B | AE_CODE_AML) | 171 | #define AE_AML_PACKAGE_LIMIT EXCEP_AML (0x000B) |
| 139 | #define AE_AML_DIVIDE_BY_ZERO (acpi_status) (0x000C | AE_CODE_AML) | 172 | #define AE_AML_DIVIDE_BY_ZERO EXCEP_AML (0x000C) |
| 140 | #define AE_AML_BAD_NAME (acpi_status) (0x000D | AE_CODE_AML) | 173 | #define AE_AML_BAD_NAME EXCEP_AML (0x000D) |
| 141 | #define AE_AML_NAME_NOT_FOUND (acpi_status) (0x000E | AE_CODE_AML) | 174 | #define AE_AML_NAME_NOT_FOUND EXCEP_AML (0x000E) |
| 142 | #define AE_AML_INTERNAL (acpi_status) (0x000F | AE_CODE_AML) | 175 | #define AE_AML_INTERNAL EXCEP_AML (0x000F) |
| 143 | #define AE_AML_INVALID_SPACE_ID (acpi_status) (0x0010 | AE_CODE_AML) | 176 | #define AE_AML_INVALID_SPACE_ID EXCEP_AML (0x0010) |
| 144 | #define AE_AML_STRING_LIMIT (acpi_status) (0x0011 | AE_CODE_AML) | 177 | #define AE_AML_STRING_LIMIT EXCEP_AML (0x0011) |
| 145 | #define AE_AML_NO_RETURN_VALUE (acpi_status) (0x0012 | AE_CODE_AML) | 178 | #define AE_AML_NO_RETURN_VALUE EXCEP_AML (0x0012) |
| 146 | #define AE_AML_METHOD_LIMIT (acpi_status) (0x0013 | AE_CODE_AML) | 179 | #define AE_AML_METHOD_LIMIT EXCEP_AML (0x0013) |
| 147 | #define AE_AML_NOT_OWNER (acpi_status) (0x0014 | AE_CODE_AML) | 180 | #define AE_AML_NOT_OWNER EXCEP_AML (0x0014) |
| 148 | #define AE_AML_MUTEX_ORDER (acpi_status) (0x0015 | AE_CODE_AML) | 181 | #define AE_AML_MUTEX_ORDER EXCEP_AML (0x0015) |
| 149 | #define AE_AML_MUTEX_NOT_ACQUIRED (acpi_status) (0x0016 | AE_CODE_AML) | 182 | #define AE_AML_MUTEX_NOT_ACQUIRED EXCEP_AML (0x0016) |
| 150 | #define AE_AML_INVALID_RESOURCE_TYPE (acpi_status) (0x0017 | AE_CODE_AML) | 183 | #define AE_AML_INVALID_RESOURCE_TYPE EXCEP_AML (0x0017) |
| 151 | #define AE_AML_INVALID_INDEX (acpi_status) (0x0018 | AE_CODE_AML) | 184 | #define AE_AML_INVALID_INDEX EXCEP_AML (0x0018) |
| 152 | #define AE_AML_REGISTER_LIMIT (acpi_status) (0x0019 | AE_CODE_AML) | 185 | #define AE_AML_REGISTER_LIMIT EXCEP_AML (0x0019) |
| 153 | #define AE_AML_NO_WHILE (acpi_status) (0x001A | AE_CODE_AML) | 186 | #define AE_AML_NO_WHILE EXCEP_AML (0x001A) |
| 154 | #define AE_AML_ALIGNMENT (acpi_status) (0x001B | AE_CODE_AML) | 187 | #define AE_AML_ALIGNMENT EXCEP_AML (0x001B) |
| 155 | #define AE_AML_NO_RESOURCE_END_TAG (acpi_status) (0x001C | AE_CODE_AML) | 188 | #define AE_AML_NO_RESOURCE_END_TAG EXCEP_AML (0x001C) |
| 156 | #define AE_AML_BAD_RESOURCE_VALUE (acpi_status) (0x001D | AE_CODE_AML) | 189 | #define AE_AML_BAD_RESOURCE_VALUE EXCEP_AML (0x001D) |
| 157 | #define AE_AML_CIRCULAR_REFERENCE (acpi_status) (0x001E | AE_CODE_AML) | 190 | #define AE_AML_CIRCULAR_REFERENCE EXCEP_AML (0x001E) |
| 158 | #define AE_AML_BAD_RESOURCE_LENGTH (acpi_status) (0x001F | AE_CODE_AML) | 191 | #define AE_AML_BAD_RESOURCE_LENGTH EXCEP_AML (0x001F) |
| 159 | #define AE_AML_ILLEGAL_ADDRESS (acpi_status) (0x0020 | AE_CODE_AML) | 192 | #define AE_AML_ILLEGAL_ADDRESS EXCEP_AML (0x0020) |
| 160 | #define AE_AML_INFINITE_LOOP (acpi_status) (0x0021 | AE_CODE_AML) | 193 | #define AE_AML_INFINITE_LOOP EXCEP_AML (0x0021) |
| 161 | 194 | ||
| 162 | #define AE_CODE_AML_MAX 0x0021 | 195 | #define AE_CODE_AML_MAX 0x0021 |
| 163 | 196 | ||
| 164 | /* | 197 | /* |
| 165 | * Internal exceptions used for control | 198 | * Internal exceptions used for control |
| 166 | */ | 199 | */ |
| 167 | #define AE_CTRL_RETURN_VALUE (acpi_status) (0x0001 | AE_CODE_CONTROL) | 200 | #define AE_CTRL_RETURN_VALUE EXCEP_CTL (0x0001) |
| 168 | #define AE_CTRL_PENDING (acpi_status) (0x0002 | AE_CODE_CONTROL) | 201 | #define AE_CTRL_PENDING EXCEP_CTL (0x0002) |
| 169 | #define AE_CTRL_TERMINATE (acpi_status) (0x0003 | AE_CODE_CONTROL) | 202 | #define AE_CTRL_TERMINATE EXCEP_CTL (0x0003) |
| 170 | #define AE_CTRL_TRUE (acpi_status) (0x0004 | AE_CODE_CONTROL) | 203 | #define AE_CTRL_TRUE EXCEP_CTL (0x0004) |
| 171 | #define AE_CTRL_FALSE (acpi_status) (0x0005 | AE_CODE_CONTROL) | 204 | #define AE_CTRL_FALSE EXCEP_CTL (0x0005) |
| 172 | #define AE_CTRL_DEPTH (acpi_status) (0x0006 | AE_CODE_CONTROL) | 205 | #define AE_CTRL_DEPTH EXCEP_CTL (0x0006) |
| 173 | #define AE_CTRL_END (acpi_status) (0x0007 | AE_CODE_CONTROL) | 206 | #define AE_CTRL_END EXCEP_CTL (0x0007) |
| 174 | #define AE_CTRL_TRANSFER (acpi_status) (0x0008 | AE_CODE_CONTROL) | 207 | #define AE_CTRL_TRANSFER EXCEP_CTL (0x0008) |
| 175 | #define AE_CTRL_BREAK (acpi_status) (0x0009 | AE_CODE_CONTROL) | 208 | #define AE_CTRL_BREAK EXCEP_CTL (0x0009) |
| 176 | #define AE_CTRL_CONTINUE (acpi_status) (0x000A | AE_CODE_CONTROL) | 209 | #define AE_CTRL_CONTINUE EXCEP_CTL (0x000A) |
| 177 | #define AE_CTRL_SKIP (acpi_status) (0x000B | AE_CODE_CONTROL) | 210 | #define AE_CTRL_SKIP EXCEP_CTL (0x000B) |
| 178 | #define AE_CTRL_PARSE_CONTINUE (acpi_status) (0x000C | AE_CODE_CONTROL) | 211 | #define AE_CTRL_PARSE_CONTINUE EXCEP_CTL (0x000C) |
| 179 | #define AE_CTRL_PARSE_PENDING (acpi_status) (0x000D | AE_CODE_CONTROL) | 212 | #define AE_CTRL_PARSE_PENDING EXCEP_CTL (0x000D) |
| 180 | 213 | ||
| 181 | #define AE_CODE_CTRL_MAX 0x000D | 214 | #define AE_CODE_CTRL_MAX 0x000D |
| 182 | 215 | ||
| @@ -188,112 +221,156 @@ | |||
| 188 | * String versions of the exception codes above | 221 | * String versions of the exception codes above |
| 189 | * These strings must match the corresponding defines exactly | 222 | * These strings must match the corresponding defines exactly |
| 190 | */ | 223 | */ |
| 191 | char const *acpi_gbl_exception_names_env[] = { | 224 | static const struct acpi_exception_info acpi_gbl_exception_names_env[] = { |
| 192 | "AE_OK", | 225 | EXCEP_TXT("AE_OK", "No error"), |
| 193 | "AE_ERROR", | 226 | EXCEP_TXT("AE_ERROR", "Unspecified error"), |
| 194 | "AE_NO_ACPI_TABLES", | 227 | EXCEP_TXT("AE_NO_ACPI_TABLES", "ACPI tables could not be found"), |
| 195 | "AE_NO_NAMESPACE", | 228 | EXCEP_TXT("AE_NO_NAMESPACE", "A namespace has not been loaded"), |
| 196 | "AE_NO_MEMORY", | 229 | EXCEP_TXT("AE_NO_MEMORY", "Insufficient dynamic memory"), |
| 197 | "AE_NOT_FOUND", | 230 | EXCEP_TXT("AE_NOT_FOUND", "The name was not found in the namespace"), |
| 198 | "AE_NOT_EXIST", | 231 | EXCEP_TXT("AE_NOT_EXIST", "A required entity does not exist"), |
| 199 | "AE_ALREADY_EXISTS", | 232 | EXCEP_TXT("AE_ALREADY_EXISTS", "An entity already exists"), |
| 200 | "AE_TYPE", | 233 | EXCEP_TXT("AE_TYPE", "The object type is incorrect"), |
| 201 | "AE_NULL_OBJECT", | 234 | EXCEP_TXT("AE_NULL_OBJECT", "A required object was missing"), |
| 202 | "AE_NULL_ENTRY", | 235 | EXCEP_TXT("AE_NULL_ENTRY", "The requested object does not exist"), |
| 203 | "AE_BUFFER_OVERFLOW", | 236 | EXCEP_TXT("AE_BUFFER_OVERFLOW", "The buffer provided is too small"), |
| 204 | "AE_STACK_OVERFLOW", | 237 | EXCEP_TXT("AE_STACK_OVERFLOW", "An internal stack overflowed"), |
| 205 | "AE_STACK_UNDERFLOW", | 238 | EXCEP_TXT("AE_STACK_UNDERFLOW", "An internal stack underflowed"), |
| 206 | "AE_NOT_IMPLEMENTED", | 239 | EXCEP_TXT("AE_NOT_IMPLEMENTED", "The feature is not implemented"), |
| 207 | "AE_SUPPORT", | 240 | EXCEP_TXT("AE_SUPPORT", "The feature is not supported"), |
| 208 | "AE_LIMIT", | 241 | EXCEP_TXT("AE_LIMIT", "A predefined limit was exceeded"), |
| 209 | "AE_TIME", | 242 | EXCEP_TXT("AE_TIME", "A time limit or timeout expired"), |
| 210 | "AE_ACQUIRE_DEADLOCK", | 243 | EXCEP_TXT("AE_ACQUIRE_DEADLOCK", |
| 211 | "AE_RELEASE_DEADLOCK", | 244 | "Internal error, attempt was made to acquire a mutex in improper order"), |
| 212 | "AE_NOT_ACQUIRED", | 245 | EXCEP_TXT("AE_RELEASE_DEADLOCK", |
| 213 | "AE_ALREADY_ACQUIRED", | 246 | "Internal error, attempt was made to release a mutex in improper order"), |
| 214 | "AE_NO_HARDWARE_RESPONSE", | 247 | EXCEP_TXT("AE_NOT_ACQUIRED", |
| 215 | "AE_NO_GLOBAL_LOCK", | 248 | "An attempt to release a mutex or Global Lock without a previous acquire"), |
| 216 | "AE_ABORT_METHOD", | 249 | EXCEP_TXT("AE_ALREADY_ACQUIRED", |
| 217 | "AE_SAME_HANDLER", | 250 | "Internal error, attempt was made to acquire a mutex twice"), |
| 218 | "AE_NO_HANDLER", | 251 | EXCEP_TXT("AE_NO_HARDWARE_RESPONSE", |
| 219 | "AE_OWNER_ID_LIMIT", | 252 | "Hardware did not respond after an I/O operation"), |
| 220 | "AE_NOT_CONFIGURED" | 253 | EXCEP_TXT("AE_NO_GLOBAL_LOCK", "There is no FACS Global Lock"), |
| 254 | EXCEP_TXT("AE_ABORT_METHOD", "A control method was aborted"), | ||
| 255 | EXCEP_TXT("AE_SAME_HANDLER", | ||
| 256 | "Attempt was made to install the same handler that is already installed"), | ||
| 257 | EXCEP_TXT("AE_NO_HANDLER", | ||
| 258 | "A handler for the operation is not installed"), | ||
| 259 | EXCEP_TXT("AE_OWNER_ID_LIMIT", | ||
| 260 | "There are no more Owner IDs available for ACPI tables or control methods"), | ||
| 261 | EXCEP_TXT("AE_NOT_CONFIGURED", | ||
| 262 | "The interface is not part of the current subsystem configuration") | ||
| 221 | }; | 263 | }; |
| 222 | 264 | ||
| 223 | char const *acpi_gbl_exception_names_pgm[] = { | 265 | static const struct acpi_exception_info acpi_gbl_exception_names_pgm[] = { |
| 224 | NULL, | 266 | EXCEP_TXT(NULL, NULL), |
| 225 | "AE_BAD_PARAMETER", | 267 | EXCEP_TXT("AE_BAD_PARAMETER", "A parameter is out of range or invalid"), |
| 226 | "AE_BAD_CHARACTER", | 268 | EXCEP_TXT("AE_BAD_CHARACTER", |
| 227 | "AE_BAD_PATHNAME", | 269 | "An invalid character was found in a name"), |
| 228 | "AE_BAD_DATA", | 270 | EXCEP_TXT("AE_BAD_PATHNAME", |
| 229 | "AE_BAD_HEX_CONSTANT", | 271 | "An invalid character was found in a pathname"), |
| 230 | "AE_BAD_OCTAL_CONSTANT", | 272 | EXCEP_TXT("AE_BAD_DATA", |
| 231 | "AE_BAD_DECIMAL_CONSTANT", | 273 | "A package or buffer contained incorrect data"), |
| 232 | "AE_MISSING_ARGUMENTS", | 274 | EXCEP_TXT("AE_BAD_HEX_CONSTANT", "Invalid character in a Hex constant"), |
| 233 | "AE_BAD_ADDRESS" | 275 | EXCEP_TXT("AE_BAD_OCTAL_CONSTANT", |
| 276 | "Invalid character in an Octal constant"), | ||
| 277 | EXCEP_TXT("AE_BAD_DECIMAL_CONSTANT", | ||
| 278 | "Invalid character in a Decimal constant"), | ||
| 279 | EXCEP_TXT("AE_MISSING_ARGUMENTS", | ||
| 280 | "Too few arguments were passed to a control method"), | ||
| 281 | EXCEP_TXT("AE_BAD_ADDRESS", "An illegal null I/O address") | ||
| 234 | }; | 282 | }; |
| 235 | 283 | ||
| 236 | char const *acpi_gbl_exception_names_tbl[] = { | 284 | static const struct acpi_exception_info acpi_gbl_exception_names_tbl[] = { |
| 237 | NULL, | 285 | EXCEP_TXT(NULL, NULL), |
| 238 | "AE_BAD_SIGNATURE", | 286 | EXCEP_TXT("AE_BAD_SIGNATURE", "An ACPI table has an invalid signature"), |
| 239 | "AE_BAD_HEADER", | 287 | EXCEP_TXT("AE_BAD_HEADER", "Invalid field in an ACPI table header"), |
| 240 | "AE_BAD_CHECKSUM", | 288 | EXCEP_TXT("AE_BAD_CHECKSUM", "An ACPI table checksum is not correct"), |
| 241 | "AE_BAD_VALUE", | 289 | EXCEP_TXT("AE_BAD_VALUE", "An invalid value was found in a table"), |
| 242 | "AE_INVALID_TABLE_LENGTH" | 290 | EXCEP_TXT("AE_INVALID_TABLE_LENGTH", |
| 291 | "The FADT or FACS has improper length") | ||
| 243 | }; | 292 | }; |
| 244 | 293 | ||
| 245 | char const *acpi_gbl_exception_names_aml[] = { | 294 | static const struct acpi_exception_info acpi_gbl_exception_names_aml[] = { |
| 246 | NULL, | 295 | EXCEP_TXT(NULL, NULL), |
| 247 | "AE_AML_BAD_OPCODE", | 296 | EXCEP_TXT("AE_AML_BAD_OPCODE", "Invalid AML opcode encountered"), |
| 248 | "AE_AML_NO_OPERAND", | 297 | EXCEP_TXT("AE_AML_NO_OPERAND", "A required operand is missing"), |
| 249 | "AE_AML_OPERAND_TYPE", | 298 | EXCEP_TXT("AE_AML_OPERAND_TYPE", |
| 250 | "AE_AML_OPERAND_VALUE", | 299 | "An operand of an incorrect type was encountered"), |
| 251 | "AE_AML_UNINITIALIZED_LOCAL", | 300 | EXCEP_TXT("AE_AML_OPERAND_VALUE", |
| 252 | "AE_AML_UNINITIALIZED_ARG", | 301 | "The operand had an inappropriate or invalid value"), |
| 253 | "AE_AML_UNINITIALIZED_ELEMENT", | 302 | EXCEP_TXT("AE_AML_UNINITIALIZED_LOCAL", |
| 254 | "AE_AML_NUMERIC_OVERFLOW", | 303 | "Method tried to use an uninitialized local variable"), |
| 255 | "AE_AML_REGION_LIMIT", | 304 | EXCEP_TXT("AE_AML_UNINITIALIZED_ARG", |
| 256 | "AE_AML_BUFFER_LIMIT", | 305 | "Method tried to use an uninitialized argument"), |
| 257 | "AE_AML_PACKAGE_LIMIT", | 306 | EXCEP_TXT("AE_AML_UNINITIALIZED_ELEMENT", |
| 258 | "AE_AML_DIVIDE_BY_ZERO", | 307 | "Method tried to use an empty package element"), |
| 259 | "AE_AML_BAD_NAME", | 308 | EXCEP_TXT("AE_AML_NUMERIC_OVERFLOW", |
| 260 | "AE_AML_NAME_NOT_FOUND", | 309 | "Overflow during BCD conversion or other"), |
| 261 | "AE_AML_INTERNAL", | 310 | EXCEP_TXT("AE_AML_REGION_LIMIT", |
| 262 | "AE_AML_INVALID_SPACE_ID", | 311 | "Tried to access beyond the end of an Operation Region"), |
| 263 | "AE_AML_STRING_LIMIT", | 312 | EXCEP_TXT("AE_AML_BUFFER_LIMIT", |
| 264 | "AE_AML_NO_RETURN_VALUE", | 313 | "Tried to access beyond the end of a buffer"), |
| 265 | "AE_AML_METHOD_LIMIT", | 314 | EXCEP_TXT("AE_AML_PACKAGE_LIMIT", |
| 266 | "AE_AML_NOT_OWNER", | 315 | "Tried to access beyond the end of a package"), |
| 267 | "AE_AML_MUTEX_ORDER", | 316 | EXCEP_TXT("AE_AML_DIVIDE_BY_ZERO", |
| 268 | "AE_AML_MUTEX_NOT_ACQUIRED", | 317 | "During execution of AML Divide operator"), |
| 269 | "AE_AML_INVALID_RESOURCE_TYPE", | 318 | EXCEP_TXT("AE_AML_BAD_NAME", |
| 270 | "AE_AML_INVALID_INDEX", | 319 | "An ACPI name contains invalid character(s)"), |
| 271 | "AE_AML_REGISTER_LIMIT", | 320 | EXCEP_TXT("AE_AML_NAME_NOT_FOUND", |
| 272 | "AE_AML_NO_WHILE", | 321 | "Could not resolve a named reference"), |
| 273 | "AE_AML_ALIGNMENT", | 322 | EXCEP_TXT("AE_AML_INTERNAL", "An internal error within the interprete"), |
| 274 | "AE_AML_NO_RESOURCE_END_TAG", | 323 | EXCEP_TXT("AE_AML_INVALID_SPACE_ID", |
| 275 | "AE_AML_BAD_RESOURCE_VALUE", | 324 | "An Operation Region SpaceID is invalid"), |
| 276 | "AE_AML_CIRCULAR_REFERENCE", | 325 | EXCEP_TXT("AE_AML_STRING_LIMIT", |
| 277 | "AE_AML_BAD_RESOURCE_LENGTH", | 326 | "String is longer than 200 characters"), |
| 278 | "AE_AML_ILLEGAL_ADDRESS", | 327 | EXCEP_TXT("AE_AML_NO_RETURN_VALUE", |
| 279 | "AE_AML_INFINITE_LOOP" | 328 | "A method did not return a required value"), |
| 329 | EXCEP_TXT("AE_AML_METHOD_LIMIT", | ||
| 330 | "A control method reached the maximum reentrancy limit of 255"), | ||
| 331 | EXCEP_TXT("AE_AML_NOT_OWNER", | ||
| 332 | "A thread tried to release a mutex that it does not own"), | ||
| 333 | EXCEP_TXT("AE_AML_MUTEX_ORDER", "Mutex SyncLevel release mismatch"), | ||
| 334 | EXCEP_TXT("AE_AML_MUTEX_NOT_ACQUIRED", | ||
| 335 | "Attempt to release a mutex that was not previously acquired"), | ||
| 336 | EXCEP_TXT("AE_AML_INVALID_RESOURCE_TYPE", | ||
| 337 | "Invalid resource type in resource list"), | ||
| 338 | EXCEP_TXT("AE_AML_INVALID_INDEX", | ||
| 339 | "Invalid Argx or Localx (x too large)"), | ||
| 340 | EXCEP_TXT("AE_AML_REGISTER_LIMIT", | ||
| 341 | "Bank value or Index value beyond range of register"), | ||
| 342 | EXCEP_TXT("AE_AML_NO_WHILE", "Break or Continue without a While"), | ||
| 343 | EXCEP_TXT("AE_AML_ALIGNMENT", | ||
| 344 | "Non-aligned memory transfer on platform that does not support this"), | ||
| 345 | EXCEP_TXT("AE_AML_NO_RESOURCE_END_TAG", | ||
| 346 | "No End Tag in a resource list"), | ||
| 347 | EXCEP_TXT("AE_AML_BAD_RESOURCE_VALUE", | ||
| 348 | "Invalid value of a resource element"), | ||
| 349 | EXCEP_TXT("AE_AML_CIRCULAR_REFERENCE", | ||
| 350 | "Two references refer to each other"), | ||
| 351 | EXCEP_TXT("AE_AML_BAD_RESOURCE_LENGTH", | ||
| 352 | "The length of a Resource Descriptor in the AML is incorrect"), | ||
| 353 | EXCEP_TXT("AE_AML_ILLEGAL_ADDRESS", | ||
| 354 | "A memory, I/O, or PCI configuration address is invalid"), | ||
| 355 | EXCEP_TXT("AE_AML_INFINITE_LOOP", | ||
| 356 | "An apparent infinite AML While loop, method was aborted") | ||
| 280 | }; | 357 | }; |
| 281 | 358 | ||
| 282 | char const *acpi_gbl_exception_names_ctrl[] = { | 359 | static const struct acpi_exception_info acpi_gbl_exception_names_ctrl[] = { |
| 283 | NULL, | 360 | EXCEP_TXT(NULL, NULL), |
| 284 | "AE_CTRL_RETURN_VALUE", | 361 | EXCEP_TXT("AE_CTRL_RETURN_VALUE", "A Method returned a value"), |
| 285 | "AE_CTRL_PENDING", | 362 | EXCEP_TXT("AE_CTRL_PENDING", "Method is calling another method"), |
| 286 | "AE_CTRL_TERMINATE", | 363 | EXCEP_TXT("AE_CTRL_TERMINATE", "Terminate the executing method"), |
| 287 | "AE_CTRL_TRUE", | 364 | EXCEP_TXT("AE_CTRL_TRUE", "An If or While predicate result"), |
| 288 | "AE_CTRL_FALSE", | 365 | EXCEP_TXT("AE_CTRL_FALSE", "An If or While predicate result"), |
| 289 | "AE_CTRL_DEPTH", | 366 | EXCEP_TXT("AE_CTRL_DEPTH", "Maximum search depth has been reached"), |
| 290 | "AE_CTRL_END", | 367 | EXCEP_TXT("AE_CTRL_END", "An If or While predicate is false"), |
| 291 | "AE_CTRL_TRANSFER", | 368 | EXCEP_TXT("AE_CTRL_TRANSFER", "Transfer control to called method"), |
| 292 | "AE_CTRL_BREAK", | 369 | EXCEP_TXT("AE_CTRL_BREAK", "A Break has been executed"), |
| 293 | "AE_CTRL_CONTINUE", | 370 | EXCEP_TXT("AE_CTRL_CONTINUE", "A Continue has been executed"), |
| 294 | "AE_CTRL_SKIP", | 371 | EXCEP_TXT("AE_CTRL_SKIP", "Not currently used"), |
| 295 | "AE_CTRL_PARSE_CONTINUE", | 372 | EXCEP_TXT("AE_CTRL_PARSE_CONTINUE", "Used to skip over bad opcodes"), |
| 296 | "AE_CTRL_PARSE_PENDING" | 373 | EXCEP_TXT("AE_CTRL_PARSE_PENDING", "Used to implement AML While loops") |
| 297 | }; | 374 | }; |
| 298 | 375 | ||
| 299 | #endif /* EXCEPTION_TABLE */ | 376 | #endif /* EXCEPTION_TABLE */ |
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h index 9885276178e0..4f52ea795c7a 100644 --- a/include/acpi/acoutput.h +++ b/include/acpi/acoutput.h | |||
| @@ -324,9 +324,9 @@ | |||
| 324 | 324 | ||
| 325 | /* Helper macro */ | 325 | /* Helper macro */ |
| 326 | 326 | ||
| 327 | #define ACPI_TRACE_ENTRY(name, function, cast, param) \ | 327 | #define ACPI_TRACE_ENTRY(name, function, type, param) \ |
| 328 | ACPI_FUNCTION_NAME (name) \ | 328 | ACPI_FUNCTION_NAME (name) \ |
| 329 | function (ACPI_DEBUG_PARAMETERS, cast (param)) | 329 | function (ACPI_DEBUG_PARAMETERS, (type) (param)) |
| 330 | 330 | ||
| 331 | /* The actual entry trace macros */ | 331 | /* The actual entry trace macros */ |
| 332 | 332 | ||
| @@ -335,13 +335,13 @@ | |||
| 335 | acpi_ut_trace (ACPI_DEBUG_PARAMETERS) | 335 | acpi_ut_trace (ACPI_DEBUG_PARAMETERS) |
| 336 | 336 | ||
| 337 | #define ACPI_FUNCTION_TRACE_PTR(name, pointer) \ | 337 | #define ACPI_FUNCTION_TRACE_PTR(name, pointer) \ |
| 338 | ACPI_TRACE_ENTRY (name, acpi_ut_trace_ptr, (void *), pointer) | 338 | ACPI_TRACE_ENTRY (name, acpi_ut_trace_ptr, void *, pointer) |
| 339 | 339 | ||
| 340 | #define ACPI_FUNCTION_TRACE_U32(name, value) \ | 340 | #define ACPI_FUNCTION_TRACE_U32(name, value) \ |
| 341 | ACPI_TRACE_ENTRY (name, acpi_ut_trace_u32, (u32), value) | 341 | ACPI_TRACE_ENTRY (name, acpi_ut_trace_u32, u32, value) |
| 342 | 342 | ||
| 343 | #define ACPI_FUNCTION_TRACE_STR(name, string) \ | 343 | #define ACPI_FUNCTION_TRACE_STR(name, string) \ |
| 344 | ACPI_TRACE_ENTRY (name, acpi_ut_trace_str, (char *), string) | 344 | ACPI_TRACE_ENTRY (name, acpi_ut_trace_str, char *, string) |
| 345 | 345 | ||
| 346 | #define ACPI_FUNCTION_ENTRY() \ | 346 | #define ACPI_FUNCTION_ENTRY() \ |
| 347 | acpi_ut_track_stack_ptr() | 347 | acpi_ut_track_stack_ptr() |
| @@ -355,16 +355,37 @@ | |||
| 355 | * | 355 | * |
| 356 | * One of the FUNCTION_TRACE macros above must be used in conjunction | 356 | * One of the FUNCTION_TRACE macros above must be used in conjunction |
| 357 | * with these macros so that "_AcpiFunctionName" is defined. | 357 | * with these macros so that "_AcpiFunctionName" is defined. |
| 358 | * | ||
| 359 | * There are two versions of most of the return macros. The default version is | ||
| 360 | * safer, since it avoids side-effects by guaranteeing that the argument will | ||
| 361 | * not be evaluated twice. | ||
| 362 | * | ||
| 363 | * A less-safe version of the macros is provided for optional use if the | ||
| 364 | * compiler uses excessive CPU stack (for example, this may happen in the | ||
| 365 | * debug case if code optimzation is disabled.) | ||
| 358 | */ | 366 | */ |
| 359 | 367 | ||
| 360 | /* Exit trace helper macro */ | 368 | /* Exit trace helper macro */ |
| 361 | 369 | ||
| 362 | #define ACPI_TRACE_EXIT(function, cast, param) \ | 370 | #ifndef ACPI_SIMPLE_RETURN_MACROS |
| 371 | |||
| 372 | #define ACPI_TRACE_EXIT(function, type, param) \ | ||
| 373 | ACPI_DO_WHILE0 ({ \ | ||
| 374 | register type _param = (type) (param); \ | ||
| 375 | function (ACPI_DEBUG_PARAMETERS, _param); \ | ||
| 376 | return (_param); \ | ||
| 377 | }) | ||
| 378 | |||
| 379 | #else /* Use original less-safe macros */ | ||
| 380 | |||
| 381 | #define ACPI_TRACE_EXIT(function, type, param) \ | ||
| 363 | ACPI_DO_WHILE0 ({ \ | 382 | ACPI_DO_WHILE0 ({ \ |
| 364 | function (ACPI_DEBUG_PARAMETERS, cast (param)); \ | 383 | function (ACPI_DEBUG_PARAMETERS, (type) (param)); \ |
| 365 | return ((param)); \ | 384 | return (param); \ |
| 366 | }) | 385 | }) |
| 367 | 386 | ||
| 387 | #endif /* ACPI_SIMPLE_RETURN_MACROS */ | ||
| 388 | |||
| 368 | /* The actual exit macros */ | 389 | /* The actual exit macros */ |
| 369 | 390 | ||
| 370 | #define return_VOID \ | 391 | #define return_VOID \ |
| @@ -374,13 +395,19 @@ | |||
| 374 | }) | 395 | }) |
| 375 | 396 | ||
| 376 | #define return_ACPI_STATUS(status) \ | 397 | #define return_ACPI_STATUS(status) \ |
| 377 | ACPI_TRACE_EXIT (acpi_ut_status_exit, (acpi_status), status) | 398 | ACPI_TRACE_EXIT (acpi_ut_status_exit, acpi_status, status) |
| 378 | 399 | ||
| 379 | #define return_PTR(pointer) \ | 400 | #define return_PTR(pointer) \ |
| 380 | ACPI_TRACE_EXIT (acpi_ut_ptr_exit, (u8 *), pointer) | 401 | ACPI_TRACE_EXIT (acpi_ut_ptr_exit, void *, pointer) |
| 381 | 402 | ||
| 382 | #define return_VALUE(value) \ | 403 | #define return_VALUE(value) \ |
| 383 | ACPI_TRACE_EXIT (acpi_ut_value_exit, (u64), value) | 404 | ACPI_TRACE_EXIT (acpi_ut_value_exit, u64, value) |
| 405 | |||
| 406 | #define return_UINT32(value) \ | ||
| 407 | ACPI_TRACE_EXIT (acpi_ut_value_exit, u32, value) | ||
| 408 | |||
| 409 | #define return_UINT8(value) \ | ||
| 410 | ACPI_TRACE_EXIT (acpi_ut_value_exit, u8, value) | ||
| 384 | 411 | ||
| 385 | /* Conditional execution */ | 412 | /* Conditional execution */ |
| 386 | 413 | ||
| @@ -428,8 +455,10 @@ | |||
| 428 | 455 | ||
| 429 | #define return_VOID return | 456 | #define return_VOID return |
| 430 | #define return_ACPI_STATUS(s) return(s) | 457 | #define return_ACPI_STATUS(s) return(s) |
| 431 | #define return_VALUE(s) return(s) | ||
| 432 | #define return_PTR(s) return(s) | 458 | #define return_PTR(s) return(s) |
| 459 | #define return_VALUE(s) return(s) | ||
| 460 | #define return_UINT8(s) return(s) | ||
| 461 | #define return_UINT32(s) return(s) | ||
| 433 | 462 | ||
| 434 | #endif /* ACPI_DEBUG_OUTPUT */ | 463 | #endif /* ACPI_DEBUG_OUTPUT */ |
| 435 | 464 | ||
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 22ba56e834e2..98db31d9f9b4 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
| @@ -88,11 +88,30 @@ struct acpi_device; | |||
| 88 | * ----------------- | 88 | * ----------------- |
| 89 | */ | 89 | */ |
| 90 | 90 | ||
| 91 | enum acpi_hotplug_mode { | ||
| 92 | AHM_GENERIC = 0, | ||
| 93 | AHM_CONTAINER, | ||
| 94 | AHM_COUNT | ||
| 95 | }; | ||
| 96 | |||
| 97 | struct acpi_hotplug_profile { | ||
| 98 | struct kobject kobj; | ||
| 99 | bool enabled:1; | ||
| 100 | enum acpi_hotplug_mode mode; | ||
| 101 | }; | ||
| 102 | |||
| 103 | static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile( | ||
| 104 | struct kobject *kobj) | ||
| 105 | { | ||
| 106 | return container_of(kobj, struct acpi_hotplug_profile, kobj); | ||
| 107 | } | ||
| 108 | |||
| 91 | struct acpi_scan_handler { | 109 | struct acpi_scan_handler { |
| 92 | const struct acpi_device_id *ids; | 110 | const struct acpi_device_id *ids; |
| 93 | struct list_head list_node; | 111 | struct list_head list_node; |
| 94 | int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id); | 112 | int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id); |
| 95 | void (*detach)(struct acpi_device *dev); | 113 | void (*detach)(struct acpi_device *dev); |
| 114 | struct acpi_hotplug_profile hotplug; | ||
| 96 | }; | 115 | }; |
| 97 | 116 | ||
| 98 | /* | 117 | /* |
| @@ -142,7 +161,6 @@ struct acpi_device_status { | |||
| 142 | 161 | ||
| 143 | struct acpi_device_flags { | 162 | struct acpi_device_flags { |
| 144 | u32 dynamic_status:1; | 163 | u32 dynamic_status:1; |
| 145 | u32 bus_address:1; | ||
| 146 | u32 removable:1; | 164 | u32 removable:1; |
| 147 | u32 ejectable:1; | 165 | u32 ejectable:1; |
| 148 | u32 suprise_removal_ok:1; | 166 | u32 suprise_removal_ok:1; |
| @@ -150,7 +168,7 @@ struct acpi_device_flags { | |||
| 150 | u32 performance_manageable:1; | 168 | u32 performance_manageable:1; |
| 151 | u32 eject_pending:1; | 169 | u32 eject_pending:1; |
| 152 | u32 match_driver:1; | 170 | u32 match_driver:1; |
| 153 | u32 reserved:23; | 171 | u32 reserved:24; |
| 154 | }; | 172 | }; |
| 155 | 173 | ||
| 156 | /* File System */ | 174 | /* File System */ |
| @@ -173,10 +191,17 @@ struct acpi_hardware_id { | |||
| 173 | char *id; | 191 | char *id; |
| 174 | }; | 192 | }; |
| 175 | 193 | ||
| 194 | struct acpi_pnp_type { | ||
| 195 | u32 hardware_id:1; | ||
| 196 | u32 bus_address:1; | ||
| 197 | u32 reserved:30; | ||
| 198 | }; | ||
| 199 | |||
| 176 | struct acpi_device_pnp { | 200 | struct acpi_device_pnp { |
| 177 | acpi_bus_id bus_id; /* Object name */ | 201 | acpi_bus_id bus_id; /* Object name */ |
| 202 | struct acpi_pnp_type type; /* ID type */ | ||
| 178 | acpi_bus_address bus_address; /* _ADR */ | 203 | acpi_bus_address bus_address; /* _ADR */ |
| 179 | char *unique_id; /* _UID */ | 204 | char *unique_id; /* _UID */ |
| 180 | struct list_head ids; /* _HID and _CIDs */ | 205 | struct list_head ids; /* _HID and _CIDs */ |
| 181 | acpi_device_name device_name; /* Driver-determined */ | 206 | acpi_device_name device_name; /* Driver-determined */ |
| 182 | acpi_device_class device_class; /* " */ | 207 | acpi_device_class device_class; /* " */ |
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h index 627749af0ba7..e6168a24b9f0 100644 --- a/include/acpi/acpi_drivers.h +++ b/include/acpi/acpi_drivers.h | |||
| @@ -95,7 +95,6 @@ int acpi_pci_link_free_irq(acpi_handle handle); | |||
| 95 | struct pci_bus; | 95 | struct pci_bus; |
| 96 | 96 | ||
| 97 | struct pci_dev *acpi_get_pci_dev(acpi_handle); | 97 | struct pci_dev *acpi_get_pci_dev(acpi_handle); |
| 98 | int acpi_pci_bind_root(struct acpi_device *device); | ||
| 99 | 98 | ||
| 100 | /* Arch-defined function to add a bus to the system */ | 99 | /* Arch-defined function to add a bus to the system */ |
| 101 | 100 | ||
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 03322dddd88e..454881e6450a 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h | |||
| @@ -46,7 +46,7 @@ | |||
| 46 | 46 | ||
| 47 | /* Current ACPICA subsystem version in YYYYMMDD format */ | 47 | /* Current ACPICA subsystem version in YYYYMMDD format */ |
| 48 | 48 | ||
| 49 | #define ACPI_CA_VERSION 0x20130117 | 49 | #define ACPI_CA_VERSION 0x20130328 |
| 50 | 50 | ||
| 51 | #include <acpi/acconfig.h> | 51 | #include <acpi/acconfig.h> |
| 52 | #include <acpi/actypes.h> | 52 | #include <acpi/actypes.h> |
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index 77dc7a4099a3..ffaac0e7e0c6 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h | |||
| @@ -72,11 +72,13 @@ | |||
| 72 | #define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Structure */ | 72 | #define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Structure */ |
| 73 | #define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ | 73 | #define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */ |
| 74 | #define ACPI_SIG_MCHI "MCHI" /* Management Controller Host Interface table */ | 74 | #define ACPI_SIG_MCHI "MCHI" /* Management Controller Host Interface table */ |
| 75 | #define ACPI_SIG_MTMR "MTMR" /* MID Timer table */ | ||
| 75 | #define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description Table */ | 76 | #define ACPI_SIG_SLIC "SLIC" /* Software Licensing Description Table */ |
| 76 | #define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ | 77 | #define ACPI_SIG_SPCR "SPCR" /* Serial Port Console Redirection table */ |
| 77 | #define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ | 78 | #define ACPI_SIG_SPMI "SPMI" /* Server Platform Management Interface table */ |
| 78 | #define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ | 79 | #define ACPI_SIG_TCPA "TCPA" /* Trusted Computing Platform Alliance table */ |
| 79 | #define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */ | 80 | #define ACPI_SIG_UEFI "UEFI" /* Uefi Boot Optimization Table */ |
| 81 | #define ACPI_SIG_VRTC "VRTC" /* Virtual Real Time Clock Table */ | ||
| 80 | #define ACPI_SIG_WAET "WAET" /* Windows ACPI Emulated devices Table */ | 82 | #define ACPI_SIG_WAET "WAET" /* Windows ACPI Emulated devices Table */ |
| 81 | #define ACPI_SIG_WDAT "WDAT" /* Watchdog Action Table */ | 83 | #define ACPI_SIG_WDAT "WDAT" /* Watchdog Action Table */ |
| 82 | #define ACPI_SIG_WDDT "WDDT" /* Watchdog Timer Description Table */ | 84 | #define ACPI_SIG_WDDT "WDDT" /* Watchdog Timer Description Table */ |
| @@ -852,6 +854,29 @@ struct acpi_table_mchi { | |||
| 852 | 854 | ||
| 853 | /******************************************************************************* | 855 | /******************************************************************************* |
| 854 | * | 856 | * |
| 857 | * MTMR - MID Timer Table | ||
| 858 | * Version 1 | ||
| 859 | * | ||
| 860 | * Conforms to "Simple Firmware Interface Specification", | ||
| 861 | * Draft 0.8.2, Oct 19, 2010 | ||
| 862 | * NOTE: The ACPI MTMR is equivalent to the SFI MTMR table. | ||
| 863 | * | ||
| 864 | ******************************************************************************/ | ||
| 865 | |||
| 866 | struct acpi_table_mtmr { | ||
| 867 | struct acpi_table_header header; /* Common ACPI table header */ | ||
| 868 | }; | ||
| 869 | |||
| 870 | /* MTMR entry */ | ||
| 871 | |||
| 872 | struct acpi_mtmr_entry { | ||
| 873 | struct acpi_generic_address physical_address; | ||
| 874 | u32 frequency; | ||
| 875 | u32 irq; | ||
| 876 | }; | ||
| 877 | |||
| 878 | /******************************************************************************* | ||
| 879 | * | ||
| 855 | * SLIC - Software Licensing Description Table | 880 | * SLIC - Software Licensing Description Table |
| 856 | * Version 1 | 881 | * Version 1 |
| 857 | * | 882 | * |
| @@ -1025,6 +1050,28 @@ struct acpi_table_uefi { | |||
| 1025 | 1050 | ||
| 1026 | /******************************************************************************* | 1051 | /******************************************************************************* |
| 1027 | * | 1052 | * |
| 1053 | * VRTC - Virtual Real Time Clock Table | ||
| 1054 | * Version 1 | ||
| 1055 | * | ||
| 1056 | * Conforms to "Simple Firmware Interface Specification", | ||
| 1057 | * Draft 0.8.2, Oct 19, 2010 | ||
| 1058 | * NOTE: The ACPI VRTC is equivalent to The SFI MRTC table. | ||
| 1059 | * | ||
| 1060 | ******************************************************************************/ | ||
| 1061 | |||
| 1062 | struct acpi_table_vrtc { | ||
| 1063 | struct acpi_table_header header; /* Common ACPI table header */ | ||
| 1064 | }; | ||
| 1065 | |||
| 1066 | /* VRTC entry */ | ||
| 1067 | |||
| 1068 | struct acpi_vrtc_entry { | ||
| 1069 | struct acpi_generic_address physical_address; | ||
| 1070 | u32 irq; | ||
| 1071 | }; | ||
| 1072 | |||
| 1073 | /******************************************************************************* | ||
| 1074 | * | ||
| 1028 | * WAET - Windows ACPI Emulated devices Table | 1075 | * WAET - Windows ACPI Emulated devices Table |
| 1029 | * Version 1 | 1076 | * Version 1 |
| 1030 | * | 1077 | * |
diff --git a/include/acpi/actbl3.h b/include/acpi/actbl3.h index 332b17e3bec8..e2c0931a3d67 100644 --- a/include/acpi/actbl3.h +++ b/include/acpi/actbl3.h | |||
| @@ -174,7 +174,7 @@ struct acpi_fpdt_header { | |||
| 174 | 174 | ||
| 175 | enum acpi_fpdt_type { | 175 | enum acpi_fpdt_type { |
| 176 | ACPI_FPDT_TYPE_BOOT = 0, | 176 | ACPI_FPDT_TYPE_BOOT = 0, |
| 177 | ACPI_FPDT_TYPE_S3PERF = 1, | 177 | ACPI_FPDT_TYPE_S3PERF = 1 |
| 178 | }; | 178 | }; |
| 179 | 179 | ||
| 180 | /* | 180 | /* |
| @@ -223,7 +223,7 @@ struct acpi_s3pt_header { | |||
| 223 | 223 | ||
| 224 | enum acpi_s3pt_type { | 224 | enum acpi_s3pt_type { |
| 225 | ACPI_S3PT_TYPE_RESUME = 0, | 225 | ACPI_S3PT_TYPE_RESUME = 0, |
| 226 | ACPI_S3PT_TYPE_SUSPEND = 1, | 226 | ACPI_S3PT_TYPE_SUSPEND = 1 |
| 227 | }; | 227 | }; |
| 228 | 228 | ||
| 229 | struct acpi_s3pt_resume { | 229 | struct acpi_s3pt_resume { |
| @@ -505,26 +505,59 @@ struct acpi_rasf_shared_memory { | |||
| 505 | u32 signature; | 505 | u32 signature; |
| 506 | u16 command; | 506 | u16 command; |
| 507 | u16 status; | 507 | u16 status; |
| 508 | u64 requested_address; | 508 | u16 version; |
| 509 | u64 requested_length; | 509 | u8 capabilities[16]; |
| 510 | u64 actual_address; | 510 | u8 set_capabilities[16]; |
| 511 | u64 actual_length; | 511 | u16 num_parameter_blocks; |
| 512 | u32 set_capabilities_status; | ||
| 513 | }; | ||
| 514 | |||
| 515 | /* RASF Parameter Block Structure Header */ | ||
| 516 | |||
| 517 | struct acpi_rasf_parameter_block { | ||
| 518 | u16 type; | ||
| 519 | u16 version; | ||
| 520 | u16 length; | ||
| 521 | }; | ||
| 522 | |||
| 523 | /* RASF Parameter Block Structure for PATROL_SCRUB */ | ||
| 524 | |||
| 525 | struct acpi_rasf_patrol_scrub_parameter { | ||
| 526 | struct acpi_rasf_parameter_block header; | ||
| 527 | u16 patrol_scrub_command; | ||
| 528 | u64 requested_address_range[2]; | ||
| 529 | u64 actual_address_range[2]; | ||
| 512 | u16 flags; | 530 | u16 flags; |
| 513 | u8 speed; | 531 | u8 requested_speed; |
| 514 | }; | 532 | }; |
| 515 | 533 | ||
| 516 | /* Masks for Flags and Speed fields above */ | 534 | /* Masks for Flags and Speed fields above */ |
| 517 | 535 | ||
| 518 | #define ACPI_RASF_SCRUBBER_RUNNING 1 | 536 | #define ACPI_RASF_SCRUBBER_RUNNING 1 |
| 519 | #define ACPI_RASF_SPEED (7<<1) | 537 | #define ACPI_RASF_SPEED (7<<1) |
| 538 | #define ACPI_RASF_SPEED_SLOW (0<<1) | ||
| 539 | #define ACPI_RASF_SPEED_MEDIUM (4<<1) | ||
| 540 | #define ACPI_RASF_SPEED_FAST (7<<1) | ||
| 520 | 541 | ||
| 521 | /* Channel Commands */ | 542 | /* Channel Commands */ |
| 522 | 543 | ||
| 523 | enum acpi_rasf_commands { | 544 | enum acpi_rasf_commands { |
| 524 | ACPI_RASF_GET_RAS_CAPABILITIES = 1, | 545 | ACPI_RASF_EXECUTE_RASF_COMMAND = 1 |
| 525 | ACPI_RASF_GET_PATROL_PARAMETERS = 2, | 546 | }; |
| 526 | ACPI_RASF_START_PATROL_SCRUBBER = 3, | 547 | |
| 527 | ACPI_RASF_STOP_PATROL_SCRUBBER = 4 | 548 | /* Platform RAS Capabilities */ |
| 549 | |||
| 550 | enum acpi_rasf_capabiliities { | ||
| 551 | ACPI_HW_PATROL_SCRUB_SUPPORTED = 0, | ||
| 552 | ACPI_SW_PATROL_SCRUB_EXPOSED = 1 | ||
| 553 | }; | ||
| 554 | |||
| 555 | /* Patrol Scrub Commands */ | ||
| 556 | |||
| 557 | enum acpi_rasf_patrol_scrub_commands { | ||
| 558 | ACPI_RASF_GET_PATROL_PARAMETERS = 1, | ||
| 559 | ACPI_RASF_START_PATROL_SCRUBBER = 2, | ||
| 560 | ACPI_RASF_STOP_PATROL_SCRUBBER = 3 | ||
| 528 | }; | 561 | }; |
| 529 | 562 | ||
| 530 | /* Channel Command flags */ | 563 | /* Channel Command flags */ |
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index 845e75f1ffd8..a64adcc29ae5 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h | |||
| @@ -650,13 +650,14 @@ typedef u32 acpi_event_type; | |||
| 650 | * The encoding of acpi_event_status is illustrated below. | 650 | * The encoding of acpi_event_status is illustrated below. |
| 651 | * Note that a set bit (1) indicates the property is TRUE | 651 | * Note that a set bit (1) indicates the property is TRUE |
| 652 | * (e.g. if bit 0 is set then the event is enabled). | 652 | * (e.g. if bit 0 is set then the event is enabled). |
| 653 | * +-------------+-+-+-+ | 653 | * +-------------+-+-+-+-+ |
| 654 | * | Bits 31:3 |2|1|0| | 654 | * | Bits 31:4 |3|2|1|0| |
| 655 | * +-------------+-+-+-+ | 655 | * +-------------+-+-+-+-+ |
| 656 | * | | | | | 656 | * | | | | | |
| 657 | * | | | +- Enabled? | 657 | * | | | | +- Enabled? |
| 658 | * | | +--- Enabled for wake? | 658 | * | | | +--- Enabled for wake? |
| 659 | * | +----- Set? | 659 | * | | +----- Set? |
| 660 | * | +------- Has a handler? | ||
| 660 | * +----------- <Reserved> | 661 | * +----------- <Reserved> |
| 661 | */ | 662 | */ |
| 662 | typedef u32 acpi_event_status; | 663 | typedef u32 acpi_event_status; |
| @@ -1128,7 +1129,6 @@ struct acpi_memory_list { | |||
| 1128 | u16 object_size; | 1129 | u16 object_size; |
| 1129 | u16 max_depth; | 1130 | u16 max_depth; |
| 1130 | u16 current_depth; | 1131 | u16 current_depth; |
| 1131 | u16 link_offset; | ||
| 1132 | 1132 | ||
| 1133 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS | 1133 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
| 1134 | 1134 | ||
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 03053aca5b32..17b5b5967641 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
| @@ -195,7 +195,7 @@ extern bool wmi_has_guid(const char *guid); | |||
| 195 | #if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE) | 195 | #if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE) |
| 196 | 196 | ||
| 197 | extern long acpi_video_get_capabilities(acpi_handle graphics_dev_handle); | 197 | extern long acpi_video_get_capabilities(acpi_handle graphics_dev_handle); |
| 198 | extern long acpi_is_video_device(struct acpi_device *device); | 198 | extern long acpi_is_video_device(acpi_handle handle); |
| 199 | extern void acpi_video_dmi_promote_vendor(void); | 199 | extern void acpi_video_dmi_promote_vendor(void); |
| 200 | extern void acpi_video_dmi_demote_vendor(void); | 200 | extern void acpi_video_dmi_demote_vendor(void); |
| 201 | extern int acpi_video_backlight_support(void); | 201 | extern int acpi_video_backlight_support(void); |
| @@ -208,7 +208,7 @@ static inline long acpi_video_get_capabilities(acpi_handle graphics_dev_handle) | |||
| 208 | return 0; | 208 | return 0; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | static inline long acpi_is_video_device(struct acpi_device *device) | 211 | static inline long acpi_is_video_device(acpi_handle handle) |
| 212 | { | 212 | { |
| 213 | return 0; | 213 | return 0; |
| 214 | } | 214 | } |
diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h index 464e229e7d84..963d71431388 100644 --- a/include/linux/clockchips.h +++ b/include/linux/clockchips.h | |||
| @@ -8,6 +8,20 @@ | |||
| 8 | #ifndef _LINUX_CLOCKCHIPS_H | 8 | #ifndef _LINUX_CLOCKCHIPS_H |
| 9 | #define _LINUX_CLOCKCHIPS_H | 9 | #define _LINUX_CLOCKCHIPS_H |
| 10 | 10 | ||
| 11 | /* Clock event notification values */ | ||
| 12 | enum clock_event_nofitiers { | ||
| 13 | CLOCK_EVT_NOTIFY_ADD, | ||
| 14 | CLOCK_EVT_NOTIFY_BROADCAST_ON, | ||
| 15 | CLOCK_EVT_NOTIFY_BROADCAST_OFF, | ||
| 16 | CLOCK_EVT_NOTIFY_BROADCAST_FORCE, | ||
| 17 | CLOCK_EVT_NOTIFY_BROADCAST_ENTER, | ||
| 18 | CLOCK_EVT_NOTIFY_BROADCAST_EXIT, | ||
| 19 | CLOCK_EVT_NOTIFY_SUSPEND, | ||
| 20 | CLOCK_EVT_NOTIFY_RESUME, | ||
| 21 | CLOCK_EVT_NOTIFY_CPU_DYING, | ||
| 22 | CLOCK_EVT_NOTIFY_CPU_DEAD, | ||
| 23 | }; | ||
| 24 | |||
| 11 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD | 25 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BUILD |
| 12 | 26 | ||
| 13 | #include <linux/clocksource.h> | 27 | #include <linux/clocksource.h> |
| @@ -26,20 +40,6 @@ enum clock_event_mode { | |||
| 26 | CLOCK_EVT_MODE_RESUME, | 40 | CLOCK_EVT_MODE_RESUME, |
| 27 | }; | 41 | }; |
| 28 | 42 | ||
| 29 | /* Clock event notification values */ | ||
| 30 | enum clock_event_nofitiers { | ||
| 31 | CLOCK_EVT_NOTIFY_ADD, | ||
| 32 | CLOCK_EVT_NOTIFY_BROADCAST_ON, | ||
| 33 | CLOCK_EVT_NOTIFY_BROADCAST_OFF, | ||
| 34 | CLOCK_EVT_NOTIFY_BROADCAST_FORCE, | ||
| 35 | CLOCK_EVT_NOTIFY_BROADCAST_ENTER, | ||
| 36 | CLOCK_EVT_NOTIFY_BROADCAST_EXIT, | ||
| 37 | CLOCK_EVT_NOTIFY_SUSPEND, | ||
| 38 | CLOCK_EVT_NOTIFY_RESUME, | ||
| 39 | CLOCK_EVT_NOTIFY_CPU_DYING, | ||
| 40 | CLOCK_EVT_NOTIFY_CPU_DEAD, | ||
| 41 | }; | ||
| 42 | |||
| 43 | /* | 43 | /* |
| 44 | * Clock event features | 44 | * Clock event features |
| 45 | */ | 45 | */ |
| @@ -184,7 +184,7 @@ static inline int tick_check_broadcast_expired(void) { return 0; } | |||
| 184 | #ifdef CONFIG_GENERIC_CLOCKEVENTS | 184 | #ifdef CONFIG_GENERIC_CLOCKEVENTS |
| 185 | extern void clockevents_notify(unsigned long reason, void *arg); | 185 | extern void clockevents_notify(unsigned long reason, void *arg); |
| 186 | #else | 186 | #else |
| 187 | # define clockevents_notify(reason, arg) do { } while (0) | 187 | static inline void clockevents_notify(unsigned long reason, void *arg) {} |
| 188 | #endif | 188 | #endif |
| 189 | 189 | ||
| 190 | #else /* CONFIG_GENERIC_CLOCKEVENTS_BUILD */ | 190 | #else /* CONFIG_GENERIC_CLOCKEVENTS_BUILD */ |
| @@ -192,7 +192,7 @@ extern void clockevents_notify(unsigned long reason, void *arg); | |||
| 192 | static inline void clockevents_suspend(void) {} | 192 | static inline void clockevents_suspend(void) {} |
| 193 | static inline void clockevents_resume(void) {} | 193 | static inline void clockevents_resume(void) {} |
| 194 | 194 | ||
| 195 | #define clockevents_notify(reason, arg) do { } while (0) | 195 | static inline void clockevents_notify(unsigned long reason, void *arg) {} |
| 196 | static inline int tick_check_broadcast_expired(void) { return 0; } | 196 | static inline int tick_check_broadcast_expired(void) { return 0; } |
| 197 | 197 | ||
| 198 | #endif | 198 | #endif |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index a22944ca0526..037d36ae63e5 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
| @@ -106,6 +106,7 @@ struct cpufreq_policy { | |||
| 106 | * governors are used */ | 106 | * governors are used */ |
| 107 | unsigned int policy; /* see above */ | 107 | unsigned int policy; /* see above */ |
| 108 | struct cpufreq_governor *governor; /* see below */ | 108 | struct cpufreq_governor *governor; /* see below */ |
| 109 | void *governor_data; | ||
| 109 | 110 | ||
| 110 | struct work_struct update; /* if update_policy() needs to be | 111 | struct work_struct update; /* if update_policy() needs to be |
| 111 | * called, but you're in IRQ context */ | 112 | * called, but you're in IRQ context */ |
| @@ -178,9 +179,11 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu | |||
| 178 | * CPUFREQ GOVERNORS * | 179 | * CPUFREQ GOVERNORS * |
| 179 | *********************************************************************/ | 180 | *********************************************************************/ |
| 180 | 181 | ||
| 181 | #define CPUFREQ_GOV_START 1 | 182 | #define CPUFREQ_GOV_START 1 |
| 182 | #define CPUFREQ_GOV_STOP 2 | 183 | #define CPUFREQ_GOV_STOP 2 |
| 183 | #define CPUFREQ_GOV_LIMITS 3 | 184 | #define CPUFREQ_GOV_LIMITS 3 |
| 185 | #define CPUFREQ_GOV_POLICY_INIT 4 | ||
| 186 | #define CPUFREQ_GOV_POLICY_EXIT 5 | ||
| 184 | 187 | ||
| 185 | struct cpufreq_governor { | 188 | struct cpufreq_governor { |
| 186 | char name[CPUFREQ_NAME_LEN]; | 189 | char name[CPUFREQ_NAME_LEN]; |
| @@ -229,6 +232,13 @@ struct cpufreq_driver { | |||
| 229 | struct module *owner; | 232 | struct module *owner; |
| 230 | char name[CPUFREQ_NAME_LEN]; | 233 | char name[CPUFREQ_NAME_LEN]; |
| 231 | u8 flags; | 234 | u8 flags; |
| 235 | /* | ||
| 236 | * This should be set by platforms having multiple clock-domains, i.e. | ||
| 237 | * supporting multiple policies. With this sysfs directories of governor | ||
| 238 | * would be created in cpu/cpu<num>/cpufreq/ directory and so they can | ||
| 239 | * use the same governor with different tunables for different clusters. | ||
| 240 | */ | ||
| 241 | bool have_governor_per_policy; | ||
| 232 | 242 | ||
| 233 | /* needed by all drivers */ | 243 | /* needed by all drivers */ |
| 234 | int (*init) (struct cpufreq_policy *policy); | 244 | int (*init) (struct cpufreq_policy *policy); |
| @@ -268,8 +278,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data); | |||
| 268 | int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); | 278 | int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); |
| 269 | 279 | ||
| 270 | 280 | ||
| 271 | void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state); | 281 | void cpufreq_notify_transition(struct cpufreq_policy *policy, |
| 272 | 282 | struct cpufreq_freqs *freqs, unsigned int state); | |
| 273 | 283 | ||
| 274 | static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) | 284 | static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) |
| 275 | { | 285 | { |
| @@ -329,6 +339,7 @@ const char *cpufreq_get_current_driver(void); | |||
| 329 | *********************************************************************/ | 339 | *********************************************************************/ |
| 330 | int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); | 340 | int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); |
| 331 | int cpufreq_update_policy(unsigned int cpu); | 341 | int cpufreq_update_policy(unsigned int cpu); |
| 342 | bool have_governor_per_policy(void); | ||
| 332 | 343 | ||
| 333 | #ifdef CONFIG_CPU_FREQ | 344 | #ifdef CONFIG_CPU_FREQ |
| 334 | /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */ | 345 | /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */ |
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 480c14dc1ddd..3c86faa59798 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h | |||
| @@ -57,6 +57,7 @@ struct cpuidle_state { | |||
| 57 | /* Idle State Flags */ | 57 | /* Idle State Flags */ |
| 58 | #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */ | 58 | #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */ |
| 59 | #define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */ | 59 | #define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */ |
| 60 | #define CPUIDLE_FLAG_TIMER_STOP (0x04) /* timer is stopped on this state */ | ||
| 60 | 61 | ||
| 61 | #define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000) | 62 | #define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000) |
| 62 | 63 | ||
| @@ -104,8 +105,8 @@ struct cpuidle_driver { | |||
| 104 | struct module *owner; | 105 | struct module *owner; |
| 105 | int refcnt; | 106 | int refcnt; |
| 106 | 107 | ||
| 107 | /* set to 1 to use the core cpuidle time keeping (for all states). */ | 108 | /* used by the cpuidle framework to setup the broadcast timer */ |
| 108 | unsigned int en_core_tk_irqen:1; | 109 | unsigned int bctimer:1; |
| 109 | /* states array must be ordered in decreasing power consumption */ | 110 | /* states array must be ordered in decreasing power consumption */ |
| 110 | struct cpuidle_state states[CPUIDLE_STATE_MAX]; | 111 | struct cpuidle_state states[CPUIDLE_STATE_MAX]; |
| 111 | int state_count; | 112 | int state_count; |
| @@ -122,17 +123,15 @@ extern void cpuidle_driver_unref(void); | |||
| 122 | extern void cpuidle_unregister_driver(struct cpuidle_driver *drv); | 123 | extern void cpuidle_unregister_driver(struct cpuidle_driver *drv); |
| 123 | extern int cpuidle_register_device(struct cpuidle_device *dev); | 124 | extern int cpuidle_register_device(struct cpuidle_device *dev); |
| 124 | extern void cpuidle_unregister_device(struct cpuidle_device *dev); | 125 | extern void cpuidle_unregister_device(struct cpuidle_device *dev); |
| 125 | 126 | extern int cpuidle_register(struct cpuidle_driver *drv, | |
| 127 | const struct cpumask *const coupled_cpus); | ||
| 128 | extern void cpuidle_unregister(struct cpuidle_driver *drv); | ||
| 126 | extern void cpuidle_pause_and_lock(void); | 129 | extern void cpuidle_pause_and_lock(void); |
| 127 | extern void cpuidle_resume_and_unlock(void); | 130 | extern void cpuidle_resume_and_unlock(void); |
| 128 | extern void cpuidle_pause(void); | 131 | extern void cpuidle_pause(void); |
| 129 | extern void cpuidle_resume(void); | 132 | extern void cpuidle_resume(void); |
| 130 | extern int cpuidle_enable_device(struct cpuidle_device *dev); | 133 | extern int cpuidle_enable_device(struct cpuidle_device *dev); |
| 131 | extern void cpuidle_disable_device(struct cpuidle_device *dev); | 134 | extern void cpuidle_disable_device(struct cpuidle_device *dev); |
| 132 | extern int cpuidle_wrap_enter(struct cpuidle_device *dev, | ||
| 133 | struct cpuidle_driver *drv, int index, | ||
| 134 | int (*enter)(struct cpuidle_device *dev, | ||
| 135 | struct cpuidle_driver *drv, int index)); | ||
| 136 | extern int cpuidle_play_dead(void); | 135 | extern int cpuidle_play_dead(void); |
| 137 | 136 | ||
| 138 | extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev); | 137 | extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev); |
| @@ -151,7 +150,10 @@ static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { } | |||
| 151 | static inline int cpuidle_register_device(struct cpuidle_device *dev) | 150 | static inline int cpuidle_register_device(struct cpuidle_device *dev) |
| 152 | {return -ENODEV; } | 151 | {return -ENODEV; } |
| 153 | static inline void cpuidle_unregister_device(struct cpuidle_device *dev) { } | 152 | static inline void cpuidle_unregister_device(struct cpuidle_device *dev) { } |
| 154 | 153 | static inline int cpuidle_register(struct cpuidle_driver *drv, | |
| 154 | const struct cpumask *const coupled_cpus) | ||
| 155 | {return -ENODEV; } | ||
| 156 | static inline void cpuidle_unregister(struct cpuidle_driver *drv) { } | ||
| 155 | static inline void cpuidle_pause_and_lock(void) { } | 157 | static inline void cpuidle_pause_and_lock(void) { } |
| 156 | static inline void cpuidle_resume_and_unlock(void) { } | 158 | static inline void cpuidle_resume_and_unlock(void) { } |
| 157 | static inline void cpuidle_pause(void) { } | 159 | static inline void cpuidle_pause(void) { } |
| @@ -159,11 +161,6 @@ static inline void cpuidle_resume(void) { } | |||
| 159 | static inline int cpuidle_enable_device(struct cpuidle_device *dev) | 161 | static inline int cpuidle_enable_device(struct cpuidle_device *dev) |
| 160 | {return -ENODEV; } | 162 | {return -ENODEV; } |
| 161 | static inline void cpuidle_disable_device(struct cpuidle_device *dev) { } | 163 | static inline void cpuidle_disable_device(struct cpuidle_device *dev) { } |
| 162 | static inline int cpuidle_wrap_enter(struct cpuidle_device *dev, | ||
| 163 | struct cpuidle_driver *drv, int index, | ||
| 164 | int (*enter)(struct cpuidle_device *dev, | ||
| 165 | struct cpuidle_driver *drv, int index)) | ||
| 166 | { return -ENODEV; } | ||
| 167 | static inline int cpuidle_play_dead(void) {return -ENODEV; } | 164 | static inline int cpuidle_play_dead(void) {return -ENODEV; } |
| 168 | #endif | 165 | #endif |
| 169 | 166 | ||
diff --git a/include/linux/platform_data/clk-lpss.h b/include/linux/platform_data/clk-lpss.h new file mode 100644 index 000000000000..528e73ce46d2 --- /dev/null +++ b/include/linux/platform_data/clk-lpss.h | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | /* | ||
| 2 | * Intel Low Power Subsystem clocks. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013, Intel Corporation | ||
| 5 | * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> | ||
| 6 | * Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| 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 __CLK_LPSS_H | ||
| 14 | #define __CLK_LPSS_H | ||
| 15 | |||
| 16 | extern int lpt_clk_init(void); | ||
| 17 | |||
| 18 | #endif /* __CLK_LPSS_H */ | ||
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index d4feda084a3a..bef86d121eb2 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
| @@ -76,8 +76,20 @@ EXPORT_SYMBOL_GPL(suspend_set_ops); | |||
| 76 | 76 | ||
| 77 | bool valid_state(suspend_state_t state) | 77 | bool valid_state(suspend_state_t state) |
| 78 | { | 78 | { |
| 79 | if (state == PM_SUSPEND_FREEZE) | 79 | if (state == PM_SUSPEND_FREEZE) { |
| 80 | return true; | 80 | #ifdef CONFIG_PM_DEBUG |
| 81 | if (pm_test_level != TEST_NONE && | ||
| 82 | pm_test_level != TEST_FREEZER && | ||
| 83 | pm_test_level != TEST_DEVICES && | ||
| 84 | pm_test_level != TEST_PLATFORM) { | ||
| 85 | printk(KERN_WARNING "Unsupported pm_test mode for " | ||
| 86 | "freeze state, please choose " | ||
| 87 | "none/freezer/devices/platform.\n"); | ||
| 88 | return false; | ||
| 89 | } | ||
| 90 | #endif | ||
| 91 | return true; | ||
| 92 | } | ||
| 81 | /* | 93 | /* |
| 82 | * PM_SUSPEND_STANDBY and PM_SUSPEND_MEMORY states need lowlevel | 94 | * PM_SUSPEND_STANDBY and PM_SUSPEND_MEMORY states need lowlevel |
| 83 | * support and need to be valid to the lowlevel | 95 | * support and need to be valid to the lowlevel |
| @@ -184,6 +196,9 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) | |||
| 184 | goto Platform_wake; | 196 | goto Platform_wake; |
| 185 | } | 197 | } |
| 186 | 198 | ||
| 199 | if (suspend_test(TEST_PLATFORM)) | ||
| 200 | goto Platform_wake; | ||
| 201 | |||
| 187 | /* | 202 | /* |
| 188 | * PM_SUSPEND_FREEZE equals | 203 | * PM_SUSPEND_FREEZE equals |
| 189 | * frozen processes + suspended devices + idle processors. | 204 | * frozen processes + suspended devices + idle processors. |
| @@ -195,9 +210,6 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) | |||
| 195 | goto Platform_wake; | 210 | goto Platform_wake; |
| 196 | } | 211 | } |
| 197 | 212 | ||
| 198 | if (suspend_test(TEST_PLATFORM)) | ||
| 199 | goto Platform_wake; | ||
| 200 | |||
| 201 | error = disable_nonboot_cpus(); | 213 | error = disable_nonboot_cpus(); |
| 202 | if (error || suspend_test(TEST_CPUS)) | 214 | if (error || suspend_test(TEST_CPUS)) |
| 203 | goto Enable_cpus; | 215 | goto Enable_cpus; |
