aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-20 14:26:56 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-20 14:26:56 -0500
commit8793422fd9ac5037f5047f80473007301df3689f (patch)
treef5aa3b3a564f053e1b5604c45db80193abc734a4
parentb3cdda2b4f541439ca4205793040aa2e1c852e3b (diff)
parent10baf04e95fbf7eb6089410220a547211dd2ffa7 (diff)
Merge tag 'pm+acpi-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI and power management updates from Rafael Wysocki: - Rework of the ACPI namespace scanning code from Rafael J. Wysocki with contributions from Bjorn Helgaas, Jiang Liu, Mika Westerberg, Toshi Kani, and Yinghai Lu. - ACPI power resources handling and ACPI device PM update from Rafael J Wysocki. - ACPICA update to version 20130117 from Bob Moore and Lv Zheng with contributions from Aaron Lu, Chao Guan, Jesper Juhl, and Tim Gardner. - Support for Intel Lynxpoint LPSS from Mika Westerberg. - cpuidle update from Len Brown including Intel Haswell support, C1 state for intel_idle, removal of global pm_idle. - cpuidle fixes and cleanups from Daniel Lezcano. - cpufreq fixes and cleanups from Viresh Kumar and Fabio Baltieri with contributions from Stratos Karafotis and Rickard Andersson. - Intel P-states driver for Sandy Bridge processors from Dirk Brandewie. - cpufreq driver for Marvell Kirkwood SoCs from Andrew Lunn. - cpufreq fixes related to ordering issues between acpi-cpufreq and powernow-k8 from Borislav Petkov and Matthew Garrett. - cpufreq support for Calxeda Highbank processors from Mark Langsdorf and Rob Herring. - cpufreq driver for the Freescale i.MX6Q SoC and cpufreq-cpu0 update from Shawn Guo. - cpufreq Exynos fixes and cleanups from Jonghwan Choi, Sachin Kamat, and Inderpal Singh. - Support for "lightweight suspend" from Zhang Rui. - Removal of the deprecated power trace API from Paul Gortmaker. - Assorted updates from Andreas Fleig, Colin Ian King, Davidlohr Bueso, Joseph Salisbury, Kees Cook, Li Fei, Nishanth Menon, ShuoX Liu, Srinivas Pandruvada, Tejun Heo, Thomas Renninger, and Yasuaki Ishimatsu. * tag 'pm+acpi-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (267 commits) PM idle: remove global declaration of pm_idle unicore32 idle: delete stray pm_idle comment openrisc idle: delete pm_idle mn10300 idle: delete pm_idle microblaze idle: delete pm_idle m32r idle: delete pm_idle, and other dead idle code ia64 idle: delete pm_idle cris idle: delete idle and pm_idle ARM64 idle: delete pm_idle ARM idle: delete pm_idle blackfin idle: delete pm_idle sparc idle: rename pm_idle to sparc_idle sh idle: rename global pm_idle to static sh_idle x86 idle: rename global pm_idle to static x86_idle APM idle: register apm_cpu_idle via cpuidle cpufreq / intel_pstate: Add kernel command line option disable intel_pstate. cpufreq / intel_pstate: Change to disallow module build tools/power turbostat: display SMI count by default intel_idle: export both C1 and C1E ACPI / hotplug: Fix concurrency issues and memory leaks ...
-rw-r--r--Documentation/ABI/testing/sysfs-devices-power_resources_D013
-rw-r--r--Documentation/ABI/testing/sysfs-devices-power_resources_D114
-rw-r--r--Documentation/ABI/testing/sysfs-devices-power_resources_D214
-rw-r--r--Documentation/ABI/testing/sysfs-devices-power_resources_D3hot14
-rw-r--r--Documentation/ABI/testing/sysfs-devices-power_state20
-rw-r--r--Documentation/ABI/testing/sysfs-devices-real_power_state23
-rw-r--r--Documentation/ABI/testing/sysfs-devices-resource_in_use12
-rw-r--r--Documentation/acpi/enumeration.txt4
-rw-r--r--Documentation/acpi/scan_handlers.txt77
-rw-r--r--Documentation/cpu-freq/cpu-drivers.txt6
-rw-r--r--Documentation/cpu-freq/user-guide.txt8
-rw-r--r--Documentation/devicetree/bindings/arm/kirkwood.txt27
-rw-r--r--Documentation/kernel-parameters.txt16
-rw-r--r--Documentation/power/freezing-of-tasks.txt5
-rw-r--r--Documentation/power/runtime_pm.txt4
-rw-r--r--Documentation/trace/events-power.txt27
-rw-r--r--arch/arm/boot/dts/highbank.dts10
-rw-r--r--arch/arm/kernel/process.c13
-rw-r--r--arch/arm/kernel/smp_twd.c53
-rw-r--r--arch/arm/mach-davinci/cpuidle.c84
-rw-r--r--arch/arm/mach-exynos/include/mach/cpufreq.h19
-rw-r--r--arch/arm/mach-highbank/Kconfig4
-rw-r--r--arch/arm/mach-omap2/pm34xx.c2
-rw-r--r--arch/arm/mach-tegra/cpu-tegra.c3
-rw-r--r--arch/arm64/kernel/process.c13
-rw-r--r--arch/blackfin/kernel/process.c7
-rw-r--r--arch/cris/kernel/process.c11
-rw-r--r--arch/ia64/hp/common/aml_nfw.c2
-rw-r--r--arch/ia64/include/asm/acpi.h4
-rw-r--r--arch/ia64/kernel/process.c3
-rw-r--r--arch/ia64/kernel/setup.c1
-rw-r--r--arch/m32r/kernel/process.c51
-rw-r--r--arch/microblaze/kernel/process.c3
-rw-r--r--arch/mn10300/kernel/process.c7
-rw-r--r--arch/openrisc/kernel/idle.c5
-rw-r--r--arch/sh/kernel/idle.c12
-rw-r--r--arch/sparc/include/asm/processor_32.h1
-rw-r--r--arch/sparc/kernel/apc.c3
-rw-r--r--arch/sparc/kernel/leon_pmc.c5
-rw-r--r--arch/sparc/kernel/pmc.c3
-rw-r--r--arch/sparc/kernel/process_32.c7
-rw-r--r--arch/unicore32/kernel/process.c5
-rw-r--r--arch/x86/Kconfig11
-rw-r--r--arch/x86/include/asm/acpi.h4
-rw-r--r--arch/x86/include/asm/mwait.h3
-rw-r--r--arch/x86/include/asm/processor.h18
-rw-r--r--arch/x86/include/uapi/asm/msr-index.h3
-rw-r--r--arch/x86/kernel/apm_32.c57
-rw-r--r--arch/x86/kernel/cpu/bugs.c27
-rw-r--r--arch/x86/kernel/cpu/proc.c2
-rw-r--r--arch/x86/kernel/process.c122
-rw-r--r--arch/x86/kernel/smpboot.c2
-rw-r--r--arch/x86/platform/olpc/olpc-xo15-sci.c2
-rw-r--r--arch/x86/xen/setup.c5
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/acpi/Kconfig2
-rw-r--r--drivers/acpi/Makefile3
-rw-r--r--drivers/acpi/ac.c4
-rw-r--r--drivers/acpi/acpi_memhotplug.c82
-rw-r--r--drivers/acpi/acpi_pad.c3
-rw-r--r--drivers/acpi/acpi_platform.c72
-rw-r--r--drivers/acpi/acpica/Makefile8
-rw-r--r--drivers/acpi/acpica/accommon.h3
-rw-r--r--drivers/acpi/acpica/acdebug.h19
-rw-r--r--drivers/acpi/acpica/acdispat.h2
-rw-r--r--drivers/acpi/acpica/acevents.h23
-rw-r--r--drivers/acpi/acpica/acglobal.h43
-rw-r--r--drivers/acpi/acpica/achware.h2
-rw-r--r--drivers/acpi/acpica/acinterp.h4
-rw-r--r--drivers/acpi/acpica/aclocal.h47
-rw-r--r--drivers/acpi/acpica/acmacros.h173
-rw-r--r--drivers/acpi/acpica/acnamesp.h16
-rw-r--r--drivers/acpi/acpica/acobject.h4
-rw-r--r--drivers/acpi/acpica/acopcode.h2
-rw-r--r--drivers/acpi/acpica/acparser.h27
-rw-r--r--drivers/acpi/acpica/acpredef.h31
-rw-r--r--drivers/acpi/acpica/acresrc.h8
-rw-r--r--drivers/acpi/acpica/acstruct.h2
-rw-r--r--drivers/acpi/acpica/actables.h2
-rw-r--r--drivers/acpi/acpica/acutils.h59
-rw-r--r--drivers/acpi/acpica/amlcode.h2
-rw-r--r--drivers/acpi/acpica/amlresrc.h8
-rw-r--r--drivers/acpi/acpica/dsargs.c2
-rw-r--r--drivers/acpi/acpica/dscontrol.c2
-rw-r--r--drivers/acpi/acpica/dsfield.c2
-rw-r--r--drivers/acpi/acpica/dsinit.c2
-rw-r--r--drivers/acpi/acpica/dsmethod.c8
-rw-r--r--drivers/acpi/acpica/dsmthdat.c2
-rw-r--r--drivers/acpi/acpica/dsobject.c20
-rw-r--r--drivers/acpi/acpica/dsopcode.c16
-rw-r--r--drivers/acpi/acpica/dsutils.c12
-rw-r--r--drivers/acpi/acpica/dswexec.c6
-rw-r--r--drivers/acpi/acpica/dswload.c7
-rw-r--r--drivers/acpi/acpica/dswload2.c4
-rw-r--r--drivers/acpi/acpica/dswscope.c2
-rw-r--r--drivers/acpi/acpica/dswstate.c2
-rw-r--r--drivers/acpi/acpica/evevent.c2
-rw-r--r--drivers/acpi/acpica/evglock.c2
-rw-r--r--drivers/acpi/acpica/evgpe.c14
-rw-r--r--drivers/acpi/acpica/evgpeblk.c24
-rw-r--r--drivers/acpi/acpica/evgpeinit.c5
-rw-r--r--drivers/acpi/acpica/evgpeutil.c2
-rw-r--r--drivers/acpi/acpica/evhandler.c529
-rw-r--r--drivers/acpi/acpica/evmisc.c2
-rw-r--r--drivers/acpi/acpica/evregion.c584
-rw-r--r--drivers/acpi/acpica/evrgnini.c2
-rw-r--r--drivers/acpi/acpica/evsci.c6
-rw-r--r--drivers/acpi/acpica/evxface.c36
-rw-r--r--drivers/acpi/acpica/evxfevnt.c7
-rw-r--r--drivers/acpi/acpica/evxfgpe.c11
-rw-r--r--drivers/acpi/acpica/evxfregn.c2
-rw-r--r--drivers/acpi/acpica/exconfig.c22
-rw-r--r--drivers/acpi/acpica/exconvrt.c4
-rw-r--r--drivers/acpi/acpica/excreate.c2
-rw-r--r--drivers/acpi/acpica/exdebug.c2
-rw-r--r--drivers/acpi/acpica/exdump.c21
-rw-r--r--drivers/acpi/acpica/exfield.c2
-rw-r--r--drivers/acpi/acpica/exfldio.c3
-rw-r--r--drivers/acpi/acpica/exmisc.c2
-rw-r--r--drivers/acpi/acpica/exmutex.c5
-rw-r--r--drivers/acpi/acpica/exnames.c2
-rw-r--r--drivers/acpi/acpica/exoparg1.c10
-rw-r--r--drivers/acpi/acpica/exoparg2.c2
-rw-r--r--drivers/acpi/acpica/exoparg3.c2
-rw-r--r--drivers/acpi/acpica/exoparg6.c2
-rw-r--r--drivers/acpi/acpica/exprep.c6
-rw-r--r--drivers/acpi/acpica/exregion.c25
-rw-r--r--drivers/acpi/acpica/exresnte.c2
-rw-r--r--drivers/acpi/acpica/exresolv.c2
-rw-r--r--drivers/acpi/acpica/exresop.c2
-rw-r--r--drivers/acpi/acpica/exstore.c31
-rw-r--r--drivers/acpi/acpica/exstoren.c4
-rw-r--r--drivers/acpi/acpica/exstorob.c2
-rw-r--r--drivers/acpi/acpica/exsystem.c2
-rw-r--r--drivers/acpi/acpica/exutils.c24
-rw-r--r--drivers/acpi/acpica/hwacpi.c13
-rw-r--r--drivers/acpi/acpica/hwesleep.c3
-rw-r--r--drivers/acpi/acpica/hwgpe.c10
-rw-r--r--drivers/acpi/acpica/hwpci.c2
-rw-r--r--drivers/acpi/acpica/hwregs.c8
-rw-r--r--drivers/acpi/acpica/hwsleep.c8
-rw-r--r--drivers/acpi/acpica/hwtimer.c9
-rw-r--r--drivers/acpi/acpica/hwvalid.c20
-rw-r--r--drivers/acpi/acpica/hwxface.c137
-rw-r--r--drivers/acpi/acpica/hwxfsleep.c13
-rw-r--r--drivers/acpi/acpica/nsaccess.c2
-rw-r--r--drivers/acpi/acpica/nsalloc.c2
-rw-r--r--drivers/acpi/acpica/nsdump.c14
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c3
-rw-r--r--drivers/acpi/acpica/nseval.c2
-rw-r--r--drivers/acpi/acpica/nsinit.c29
-rw-r--r--drivers/acpi/acpica/nsload.c2
-rw-r--r--drivers/acpi/acpica/nsnames.c5
-rw-r--r--drivers/acpi/acpica/nsobject.c2
-rw-r--r--drivers/acpi/acpica/nsparse.c2
-rw-r--r--drivers/acpi/acpica/nspredef.c586
-rw-r--r--drivers/acpi/acpica/nsprepkg.c621
-rw-r--r--drivers/acpi/acpica/nsrepair.c2
-rw-r--r--drivers/acpi/acpica/nsrepair2.c5
-rw-r--r--drivers/acpi/acpica/nssearch.c7
-rw-r--r--drivers/acpi/acpica/nsutils.c88
-rw-r--r--drivers/acpi/acpica/nswalk.c6
-rw-r--r--drivers/acpi/acpica/nsxfeval.c19
-rw-r--r--drivers/acpi/acpica/nsxfname.c20
-rw-r--r--drivers/acpi/acpica/nsxfobj.c2
-rw-r--r--drivers/acpi/acpica/psargs.c9
-rw-r--r--drivers/acpi/acpica/psloop.c623
-rw-r--r--drivers/acpi/acpica/psobject.c647
-rw-r--r--drivers/acpi/acpica/psopcode.c174
-rw-r--r--drivers/acpi/acpica/psopinfo.c223
-rw-r--r--drivers/acpi/acpica/psparse.c2
-rw-r--r--drivers/acpi/acpica/psscope.c2
-rw-r--r--drivers/acpi/acpica/pstree.c2
-rw-r--r--drivers/acpi/acpica/psutils.c10
-rw-r--r--drivers/acpi/acpica/pswalk.c2
-rw-r--r--drivers/acpi/acpica/psxface.c2
-rw-r--r--drivers/acpi/acpica/rsaddr.c2
-rw-r--r--drivers/acpi/acpica/rscalc.c8
-rw-r--r--drivers/acpi/acpica/rscreate.c9
-rw-r--r--drivers/acpi/acpica/rsdump.c424
-rw-r--r--drivers/acpi/acpica/rsdumpinfo.c454
-rw-r--r--drivers/acpi/acpica/rsinfo.c2
-rw-r--r--drivers/acpi/acpica/rsio.c2
-rw-r--r--drivers/acpi/acpica/rsirq.c40
-rw-r--r--drivers/acpi/acpica/rslist.c9
-rw-r--r--drivers/acpi/acpica/rsmemory.c8
-rw-r--r--drivers/acpi/acpica/rsmisc.c76
-rw-r--r--drivers/acpi/acpica/rsserial.c10
-rw-r--r--drivers/acpi/acpica/rsutils.c14
-rw-r--r--drivers/acpi/acpica/rsxface.c107
-rw-r--r--drivers/acpi/acpica/tbfadt.c7
-rw-r--r--drivers/acpi/acpica/tbfind.c2
-rw-r--r--drivers/acpi/acpica/tbinstal.c2
-rw-r--r--drivers/acpi/acpica/tbutils.c4
-rw-r--r--drivers/acpi/acpica/tbxface.c7
-rw-r--r--drivers/acpi/acpica/tbxfload.c4
-rw-r--r--drivers/acpi/acpica/tbxfroot.c2
-rw-r--r--drivers/acpi/acpica/utaddress.c6
-rw-r--r--drivers/acpi/acpica/utalloc.c2
-rw-r--r--drivers/acpi/acpica/utcache.c2
-rw-r--r--drivers/acpi/acpica/utcopy.c6
-rw-r--r--drivers/acpi/acpica/utdebug.c120
-rw-r--r--drivers/acpi/acpica/utdecode.c2
-rw-r--r--drivers/acpi/acpica/utdelete.c70
-rw-r--r--drivers/acpi/acpica/uteval.c4
-rw-r--r--drivers/acpi/acpica/utexcep.c2
-rw-r--r--drivers/acpi/acpica/utglobal.c11
-rw-r--r--drivers/acpi/acpica/utids.c2
-rw-r--r--drivers/acpi/acpica/utinit.c2
-rw-r--r--drivers/acpi/acpica/utlock.c16
-rw-r--r--drivers/acpi/acpica/utmath.c2
-rw-r--r--drivers/acpi/acpica/utmisc.c830
-rw-r--r--drivers/acpi/acpica/utmutex.c2
-rw-r--r--drivers/acpi/acpica/utobject.c4
-rw-r--r--drivers/acpi/acpica/utosi.c2
-rw-r--r--drivers/acpi/acpica/utownerid.c218
-rw-r--r--drivers/acpi/acpica/utresrc.c83
-rw-r--r--drivers/acpi/acpica/utstate.c42
-rw-r--r--drivers/acpi/acpica/utstring.c574
-rw-r--r--drivers/acpi/acpica/uttrack.c18
-rw-r--r--drivers/acpi/acpica/utxface.c6
-rw-r--r--drivers/acpi/acpica/utxferror.c6
-rw-r--r--drivers/acpi/acpica/utxfinit.c2
-rw-r--r--drivers/acpi/acpica/utxfmutex.c2
-rw-r--r--drivers/acpi/battery.c2
-rw-r--r--drivers/acpi/bus.c270
-rw-r--r--drivers/acpi/button.c4
-rw-r--r--drivers/acpi/container.c211
-rw-r--r--drivers/acpi/csrt.c159
-rw-r--r--drivers/acpi/custom_method.c2
-rw-r--r--drivers/acpi/device_pm.c359
-rw-r--r--drivers/acpi/dock.c44
-rw-r--r--drivers/acpi/ec.c2
-rw-r--r--drivers/acpi/fan.c4
-rw-r--r--drivers/acpi/glue.c85
-rw-r--r--drivers/acpi/hed.c2
-rw-r--r--drivers/acpi/internal.h31
-rw-r--r--drivers/acpi/numa.c8
-rw-r--r--drivers/acpi/osl.c2
-rw-r--r--drivers/acpi/pci_bind.c122
-rw-r--r--drivers/acpi/pci_link.c47
-rw-r--r--drivers/acpi/pci_root.c101
-rw-r--r--drivers/acpi/pci_slot.c7
-rw-r--r--drivers/acpi/power.c730
-rw-r--r--drivers/acpi/proc.c9
-rw-r--r--drivers/acpi/processor_driver.c62
-rw-r--r--drivers/acpi/processor_idle.c48
-rw-r--r--drivers/acpi/sbs.c6
-rw-r--r--drivers/acpi/sbshc.c4
-rw-r--r--drivers/acpi/scan.c976
-rw-r--r--drivers/acpi/sleep.c97
-rw-r--r--drivers/acpi/sleep.h2
-rw-r--r--drivers/acpi/sysfs.c2
-rw-r--r--drivers/acpi/tables.c6
-rw-r--r--drivers/acpi/thermal.c10
-rw-r--r--drivers/acpi/video.c8
-rw-r--r--drivers/ata/libata-acpi.c18
-rw-r--r--drivers/base/power/domain.c3
-rw-r--r--drivers/base/power/opp.c19
-rw-r--r--drivers/base/power/wakeup.c6
-rw-r--r--drivers/char/hpet.c2
-rw-r--r--drivers/char/sonypi.c2
-rw-r--r--drivers/clk/Makefile1
-rw-r--r--drivers/clk/clk-highbank.c2
-rw-r--r--drivers/clk/mvebu/clk-gating-ctrl.c1
-rw-r--r--drivers/clk/x86/Makefile2
-rw-r--r--drivers/clk/x86/clk-lpss.c99
-rw-r--r--drivers/clk/x86/clk-lpss.h36
-rw-r--r--drivers/clk/x86/clk-lpt.c86
-rw-r--r--drivers/cpufreq/Kconfig2
-rw-r--r--drivers/cpufreq/Kconfig.arm30
-rw-r--r--drivers/cpufreq/Kconfig.x8613
-rw-r--r--drivers/cpufreq/Makefile11
-rw-r--r--drivers/cpufreq/acpi-cpufreq.c8
-rw-r--r--drivers/cpufreq/cpufreq-cpu0.c42
-rw-r--r--drivers/cpufreq/cpufreq.c460
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c19
-rw-r--r--drivers/cpufreq/cpufreq_governor.c131
-rw-r--r--drivers/cpufreq/cpufreq_governor.h6
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c70
-rw-r--r--drivers/cpufreq/cpufreq_stats.c49
-rw-r--r--drivers/cpufreq/cpufreq_userspace.c2
-rw-r--r--drivers/cpufreq/db8500-cpufreq.c4
-rw-r--r--drivers/cpufreq/exynos-cpufreq.c188
-rw-r--r--drivers/cpufreq/exynos4210-cpufreq.c152
-rw-r--r--drivers/cpufreq/exynos4x12-cpufreq.c388
-rw-r--r--drivers/cpufreq/exynos5250-cpufreq.c178
-rw-r--r--drivers/cpufreq/freq_table.c15
-rw-r--r--drivers/cpufreq/highbank-cpufreq.c120
-rw-r--r--drivers/cpufreq/imx6q-cpufreq.c336
-rw-r--r--drivers/cpufreq/intel_pstate.c823
-rw-r--r--drivers/cpufreq/kirkwood-cpufreq.c259
-rw-r--r--drivers/cpufreq/maple-cpufreq.c2
-rw-r--r--drivers/cpufreq/omap-cpufreq.c4
-rw-r--r--drivers/cpufreq/powernow-k8.c46
-rw-r--r--drivers/cpufreq/spear-cpufreq.c12
-rw-r--r--drivers/cpuidle/cpuidle.c2
-rw-r--r--drivers/hwmon/acpi_power_meter.c2
-rw-r--r--drivers/hwmon/asus_atk0110.c4
-rw-r--r--drivers/i2c/busses/i2c-scmi.c2
-rw-r--r--drivers/idle/intel_idle.c278
-rw-r--r--drivers/input/misc/atlas_btns.c2
-rw-r--r--drivers/mailbox/Kconfig19
-rw-r--r--drivers/mailbox/Makefile1
-rw-r--r--drivers/mailbox/pl320-ipc.c199
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c56
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c15
-rw-r--r--drivers/pci/pci-acpi.c56
-rw-r--r--drivers/pci/pci.c26
-rw-r--r--drivers/pci/pci.h5
-rw-r--r--drivers/pci/probe.c1
-rw-r--r--drivers/platform/x86/asus-laptop.c2
-rw-r--r--drivers/platform/x86/classmate-laptop.c10
-rw-r--r--drivers/platform/x86/eeepc-laptop.c2
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c4
-rw-r--r--drivers/platform/x86/fujitsu-tablet.c2
-rw-r--r--drivers/platform/x86/hp_accel.c2
-rw-r--r--drivers/platform/x86/ideapad-laptop.c2
-rw-r--r--drivers/platform/x86/intel_menlow.c2
-rw-r--r--drivers/platform/x86/panasonic-laptop.c4
-rw-r--r--drivers/platform/x86/sony-laptop.c4
-rw-r--r--drivers/platform/x86/topstar-laptop.c2
-rw-r--r--drivers/platform/x86/toshiba_acpi.c4
-rw-r--r--drivers/platform/x86/toshiba_bluetooth.c4
-rw-r--r--drivers/platform/x86/wmi.c4
-rw-r--r--drivers/platform/x86/xo15-ebook.c2
-rw-r--r--drivers/pnp/pnpacpi/core.c10
-rw-r--r--drivers/pnp/pnpbios/Kconfig4
-rw-r--r--drivers/staging/quickstart/quickstart.c2
-rw-r--r--drivers/video/backlight/apple_bl.c2
-rw-r--r--drivers/xen/xen-acpi-pad.c3
-rw-r--r--fs/sysfs/group.c42
-rw-r--r--fs/sysfs/symlink.c45
-rw-r--r--fs/sysfs/sysfs.h2
-rw-r--r--include/acpi/acbuffer.h2
-rw-r--r--include/acpi/acconfig.h27
-rw-r--r--include/acpi/acexcep.h2
-rw-r--r--include/acpi/acnames.h2
-rw-r--r--include/acpi/acoutput.h159
-rw-r--r--include/acpi/acpi.h2
-rw-r--r--include/acpi/acpi_bus.h100
-rw-r--r--include/acpi/acpiosxf.h13
-rw-r--r--include/acpi/acpixf.h68
-rw-r--r--include/acpi/acrestyp.h17
-rw-r--r--include/acpi/actbl.h9
-rw-r--r--include/acpi/actbl1.h8
-rw-r--r--include/acpi/actbl2.h25
-rw-r--r--include/acpi/actbl3.h34
-rw-r--r--include/acpi/actypes.h38
-rw-r--r--include/acpi/container.h12
-rw-r--r--include/acpi/platform/acenv.h319
-rw-r--r--include/acpi/platform/acgcc.h6
-rw-r--r--include/acpi/platform/aclinux.h3
-rw-r--r--include/linux/acpi.h25
-rw-r--r--include/linux/cpufreq.h34
-rw-r--r--include/linux/cpuidle.h22
-rw-r--r--include/linux/freezer.h5
-rw-r--r--include/linux/mailbox.h17
-rw-r--r--include/linux/pm.h1
-rw-r--r--include/linux/pm_runtime.h7
-rw-r--r--include/linux/suspend.h6
-rw-r--r--include/linux/sysfs.h16
-rw-r--r--include/trace/events/power.h92
-rw-r--r--kernel/power/autosleep.c2
-rw-r--r--kernel/power/main.c29
-rw-r--r--kernel/power/process.c4
-rw-r--r--kernel/power/qos.c9
-rw-r--r--kernel/power/suspend.c69
-rw-r--r--kernel/trace/Kconfig15
-rw-r--r--kernel/trace/power-traces.c3
-rw-r--r--tools/power/acpi/Makefile2
-rw-r--r--tools/power/x86/turbostat/turbostat.836
-rw-r--r--tools/power/x86/turbostat/turbostat.c48
374 files changed, 10713 insertions, 8060 deletions
diff --git a/Documentation/ABI/testing/sysfs-devices-power_resources_D0 b/Documentation/ABI/testing/sysfs-devices-power_resources_D0
new file mode 100644
index 000000000000..73b77a6be196
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-power_resources_D0
@@ -0,0 +1,13 @@
1What: /sys/devices/.../power_resources_D0/
2Date: January 2013
3Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
4Description:
5 The /sys/devices/.../power_resources_D0/ directory is only
6 present for device objects representing ACPI device nodes that
7 use ACPI power resources for power management.
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 in ACPI power state D0. The names
12 of the links are the same as the names of the directories they
13 point to.
diff --git a/Documentation/ABI/testing/sysfs-devices-power_resources_D1 b/Documentation/ABI/testing/sysfs-devices-power_resources_D1
new file mode 100644
index 000000000000..30c20703fb8c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-power_resources_D1
@@ -0,0 +1,14 @@
1What: /sys/devices/.../power_resources_D1/
2Date: January 2013
3Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
4Description:
5 The /sys/devices/.../power_resources_D1/ directory is only
6 present for device objects representing ACPI device nodes that
7 use ACPI power resources for power management and support ACPI
8 power state D1.
9
10 If present, it contains symbolic links to device directories
11 representing ACPI power resources that need to be turned on for
12 the given device node to be in ACPI power state D1. The names
13 of the links are the same as the names of the directories they
14 point to.
diff --git a/Documentation/ABI/testing/sysfs-devices-power_resources_D2 b/Documentation/ABI/testing/sysfs-devices-power_resources_D2
new file mode 100644
index 000000000000..fd9d84b421e1
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-power_resources_D2
@@ -0,0 +1,14 @@
1What: /sys/devices/.../power_resources_D2/
2Date: January 2013
3Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
4Description:
5 The /sys/devices/.../power_resources_D2/ directory is only
6 present for device objects representing ACPI device nodes that
7 use ACPI power resources for power management and support ACPI
8 power state D2.
9
10 If present, it contains symbolic links to device directories
11 representing ACPI power resources that need to be turned on for
12 the given device node to be in ACPI power state D2. The names
13 of the links are the same as the names of the directories they
14 point to.
diff --git a/Documentation/ABI/testing/sysfs-devices-power_resources_D3hot b/Documentation/ABI/testing/sysfs-devices-power_resources_D3hot
new file mode 100644
index 000000000000..3df32c20addf
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-power_resources_D3hot
@@ -0,0 +1,14 @@
1What: /sys/devices/.../power_resources_D3hot/
2Date: January 2013
3Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
4Description:
5 The /sys/devices/.../power_resources_D3hot/ directory is only
6 present for device objects representing ACPI device nodes that
7 use ACPI power resources for power management and support ACPI
8 power state D3hot.
9
10 If present, it contains symbolic links to device directories
11 representing ACPI power resources that need to be turned on for
12 the given device node to be in ACPI power state D3hot. The
13 names of the links are the same as the names of the directories
14 they point to.
diff --git a/Documentation/ABI/testing/sysfs-devices-power_state b/Documentation/ABI/testing/sysfs-devices-power_state
new file mode 100644
index 000000000000..7ad9546748f0
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-power_state
@@ -0,0 +1,20 @@
1What: /sys/devices/.../power_state
2Date: January 2013
3Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
4Description:
5 The /sys/devices/.../power_state attribute is only present for
6 device objects representing ACPI device nodes that provide power
7 management methods.
8
9 If present, it contains a string representing the current ACPI
10 power state of the given device node. Its possible values,
11 "D0", "D1", "D2", "D3hot", and "D3cold", reflect the power state
12 names defined by the ACPI specification (ACPI 4 and above).
13
14 If the device node uses shared ACPI power resources, this state
15 determines a list of power resources required not to be turned
16 off. However, some power resources needed by the device node in
17 higher-power (lower-number) states may also be ON because of
18 some other devices using them at the moment.
19
20 This attribute is read-only.
diff --git a/Documentation/ABI/testing/sysfs-devices-real_power_state b/Documentation/ABI/testing/sysfs-devices-real_power_state
new file mode 100644
index 000000000000..8b3527c82a7d
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-real_power_state
@@ -0,0 +1,23 @@
1What: /sys/devices/.../real_power_state
2Date: January 2013
3Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
4Description:
5 The /sys/devices/.../real_power_state attribute is only present
6 for device objects representing ACPI device nodes that provide
7 power management methods and use ACPI power resources for power
8 management.
9
10 If present, it contains a string representing the real ACPI
11 power state of the given device node as returned by the _PSC
12 control method or inferred from the configuration of power
13 resources. Its possible values, "D0", "D1", "D2", "D3hot", and
14 "D3cold", reflect the power state names defined by the ACPI
15 specification (ACPI 4 and above).
16
17 In some situations the value of this attribute may be different
18 from the value of the /sys/devices/.../power_state attribute for
19 the same device object. If that happens, some shared power
20 resources used by the device node are only ON because of some
21 other devices using them at the moment.
22
23 This attribute is read-only.
diff --git a/Documentation/ABI/testing/sysfs-devices-resource_in_use b/Documentation/ABI/testing/sysfs-devices-resource_in_use
new file mode 100644
index 000000000000..b4a3bc5922a3
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-resource_in_use
@@ -0,0 +1,12 @@
1What: /sys/devices/.../resource_in_use
2Date: January 2013
3Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
4Description:
5 The /sys/devices/.../resource_in_use attribute is only present
6 for device objects representing ACPI power resources.
7
8 If present, it contains a number (0 or 1) representing the
9 current status of the given power resource (0 means that the
10 resource is not in use and therefore it has been turned off).
11
12 This attribute is read-only.
diff --git a/Documentation/acpi/enumeration.txt b/Documentation/acpi/enumeration.txt
index 54469bc81b1c..94a656131885 100644
--- a/Documentation/acpi/enumeration.txt
+++ b/Documentation/acpi/enumeration.txt
@@ -63,8 +63,8 @@ from ACPI tables.
63Currently the kernel is not able to automatically determine from which ACPI 63Currently the kernel is not able to automatically determine from which ACPI
64device it should make the corresponding platform device so we need to add 64device it should make the corresponding platform device so we need to add
65the ACPI device explicitly to acpi_platform_device_ids list defined in 65the ACPI device explicitly to acpi_platform_device_ids list defined in
66drivers/acpi/scan.c. This limitation is only for the platform devices, SPI 66drivers/acpi/acpi_platform.c. This limitation is only for the platform
67and I2C devices are created automatically as described below. 67devices, SPI and I2C devices are created automatically as described below.
68 68
69SPI serial bus support 69SPI serial bus support
70~~~~~~~~~~~~~~~~~~~~~~ 70~~~~~~~~~~~~~~~~~~~~~~
diff --git a/Documentation/acpi/scan_handlers.txt b/Documentation/acpi/scan_handlers.txt
new file mode 100644
index 000000000000..3246ccf15992
--- /dev/null
+++ b/Documentation/acpi/scan_handlers.txt
@@ -0,0 +1,77 @@
1ACPI Scan Handlers
2
3Copyright (C) 2012, Intel Corporation
4Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
5
6During system initialization and ACPI-based device hot-add, the ACPI namespace
7is scanned in search of device objects that generally represent various pieces
8of hardware. This causes a struct acpi_device object to be created and
9registered with the driver core for every device object in the ACPI namespace
10and the hierarchy of those struct acpi_device objects reflects the namespace
11layout (i.e. parent device objects in the namespace are represented by parent
12struct acpi_device objects and analogously for their children). Those struct
13acpi_device objects are referred to as "device nodes" in what follows, but they
14should not be confused with struct device_node objects used by the Device Trees
15parsing code (although their role is analogous to the role of those objects).
16
17During ACPI-based device hot-remove device nodes representing pieces of hardware
18being removed are unregistered and deleted.
19
20The core ACPI namespace scanning code in drivers/acpi/scan.c carries out basic
21initialization of device nodes, such as retrieving common configuration
22information from the device objects represented by them and populating them with
23appropriate data, but some of them require additional handling after they have
24been registered. For example, if the given device node represents a PCI host
25bridge, its registration should cause the PCI bus under that bridge to be
26enumerated and PCI devices on that bus to be registered with the driver core.
27Similarly, if the device node represents a PCI interrupt link, it is necessary
28to configure that link so that the kernel can use it.
29
30Those additional configuration tasks usually depend on the type of the hardware
31component represented by the given device node which can be determined on the
32basis of the device node's hardware ID (HID). They are performed by objects
33called ACPI scan handlers represented by the following structure:
34
35struct acpi_scan_handler {
36 const struct acpi_device_id *ids;
37 struct list_head list_node;
38 int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
39 void (*detach)(struct acpi_device *dev);
40};
41
42where ids is the list of IDs of device nodes the given handler is supposed to
43take care of, list_node is the hook to the global list of ACPI scan handlers
44maintained by the ACPI core and the .attach() and .detach() callbacks are
45executed, respectively, after registration of new device nodes and before
46unregistration of device nodes the handler attached to previously.
47
48The namespace scanning function, acpi_bus_scan(), first registers all of the
49device nodes in the given namespace scope with the driver core. Then, it tries
50to match a scan handler against each of them using the ids arrays of the
51available scan handlers. If a matching scan handler is found, its .attach()
52callback is executed for the given device node. If that callback returns 1,
53that means that the handler has claimed the device node and is now responsible
54for carrying out any additional configuration tasks related to it. It also will
55be responsible for preparing the device node for unregistration in that case.
56The device node's handler field is then populated with the address of the scan
57handler that has claimed it.
58
59If the .attach() callback returns 0, it means that the device node is not
60interesting to the given scan handler and may be matched against the next scan
61handler in the list. If it returns a (negative) error code, that means that
62the namespace scan should be terminated due to a serious error. The error code
63returned should then reflect the type of the error.
64
65The namespace trimming function, acpi_bus_trim(), first executes .detach()
66callbacks from the scan handlers of all device nodes in the given namespace
67scope (if they have scan handlers). Next, it unregisters all of the device
68nodes in that scope.
69
70ACPI scan handlers can be added to the list maintained by the ACPI core with the
71help of the acpi_scan_add_handler() function taking a pointer to the new scan
72handler as an argument. The order in which scan handlers are added to the list
73is the order in which they are matched against device nodes during namespace
74scans.
75
76All scan handles must be added to the list before acpi_bus_scan() is run for the
77first time and they cannot be removed from it.
diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt
index c436096351f8..72f70b16d299 100644
--- a/Documentation/cpu-freq/cpu-drivers.txt
+++ b/Documentation/cpu-freq/cpu-drivers.txt
@@ -111,6 +111,12 @@ policy->governor must contain the "default policy" for
111For setting some of these values, the frequency table helpers might be 111For setting some of these values, the frequency table helpers might be
112helpful. See the section 2 for more information on them. 112helpful. See the section 2 for more information on them.
113 113
114SMP 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()
116routine must initialize policy->cpus with mask of all possible cpus (Online +
117Offline) that share the clock. Then the core would copy this mask onto
118policy->related_cpus and will reset policy->cpus to carry only online cpus.
119
114 120
1151.3 verify 1211.3 verify
116------------ 122------------
diff --git a/Documentation/cpu-freq/user-guide.txt b/Documentation/cpu-freq/user-guide.txt
index 04f6b32993e6..ff2f28332cc4 100644
--- a/Documentation/cpu-freq/user-guide.txt
+++ b/Documentation/cpu-freq/user-guide.txt
@@ -190,11 +190,11 @@ scaling_max_freq show the current "policy limits" (in
190 first set scaling_max_freq, then 190 first set scaling_max_freq, then
191 scaling_min_freq. 191 scaling_min_freq.
192 192
193affected_cpus : List of CPUs that require software coordination 193affected_cpus : List of Online CPUs that require software
194 of frequency. 194 coordination of frequency.
195 195
196related_cpus : List of CPUs that need some sort of frequency 196related_cpus : List of Online + Offline CPUs that need software
197 coordination, whether software or hardware. 197 coordination of frequency.
198 198
199scaling_driver : Hardware driver for cpufreq. 199scaling_driver : Hardware driver for cpufreq.
200 200
diff --git a/Documentation/devicetree/bindings/arm/kirkwood.txt b/Documentation/devicetree/bindings/arm/kirkwood.txt
new file mode 100644
index 000000000000..98cce9a653eb
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/kirkwood.txt
@@ -0,0 +1,27 @@
1Marvell Kirkwood Platforms Device Tree Bindings
2-----------------------------------------------
3
4Boards with a SoC of the Marvell Kirkwood
5shall have the following property:
6
7Required root node property:
8
9compatible: must contain "marvell,kirkwood";
10
11In order to support the kirkwood cpufreq driver, there must be a node
12cpus/cpu@0 with three clocks, "cpu_clk", "ddrclk" and "powersave",
13where the "powersave" clock is a gating clock used to switch the CPU
14between the "cpu_clk" and the "ddrclk".
15
16Example:
17
18 cpus {
19 #address-cells = <1>;
20 #size-cells = <0>;
21
22 cpu@0 {
23 device_type = "cpu";
24 compatible = "marvell,sheeva-88SV131";
25 clocks = <&core_clk 1>, <&core_clk 3>, <&gate_clk 11>;
26 clock-names = "cpu_clk", "ddrclk", "powersave";
27 };
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 6c723811c0a0..4c5b3f993bbb 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1039,16 +1039,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1039 Claim all unknown PCI IDE storage controllers. 1039 Claim all unknown PCI IDE storage controllers.
1040 1040
1041 idle= [X86] 1041 idle= [X86]
1042 Format: idle=poll, idle=mwait, idle=halt, idle=nomwait 1042 Format: idle=poll, idle=halt, idle=nomwait
1043 Poll forces a polling idle loop that can slightly 1043 Poll forces a polling idle loop that can slightly
1044 improve the performance of waking up a idle CPU, but 1044 improve the performance of waking up a idle CPU, but
1045 will use a lot of power and make the system run hot. 1045 will use a lot of power and make the system run hot.
1046 Not recommended. 1046 Not recommended.
1047 idle=mwait: On systems which support MONITOR/MWAIT but
1048 the kernel chose to not use it because it doesn't save
1049 as much power as a normal idle loop, use the
1050 MONITOR/MWAIT idle loop anyways. Performance should be
1051 the same as idle=poll.
1052 idle=halt: Halt is forced to be used for CPU idle. 1047 idle=halt: Halt is forced to be used for CPU idle.
1053 In such case C2/C3 won't be used again. 1048 In such case C2/C3 won't be used again.
1054 idle=nomwait: Disable mwait for CPU C-states 1049 idle=nomwait: Disable mwait for CPU C-states
@@ -1131,6 +1126,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1131 0 disables intel_idle and fall back on acpi_idle. 1126 0 disables intel_idle and fall back on acpi_idle.
1132 1 to 6 specify maximum depth of C-state. 1127 1 to 6 specify maximum depth of C-state.
1133 1128
1129 intel_pstate= [X86]
1130 disable
1131 Do not enable intel_pstate as the default
1132 scaling driver for the supported processors
1133
1134 intremap= [X86-64, Intel-IOMMU] 1134 intremap= [X86-64, Intel-IOMMU]
1135 on enable Interrupt Remapping (default) 1135 on enable Interrupt Remapping (default)
1136 off disable Interrupt Remapping 1136 off disable Interrupt Remapping
@@ -1886,10 +1886,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1886 wfi(ARM) instruction doesn't work correctly and not to 1886 wfi(ARM) instruction doesn't work correctly and not to
1887 use it. This is also useful when using JTAG debugger. 1887 use it. This is also useful when using JTAG debugger.
1888 1888
1889 no-hlt [BUGS=X86-32] Tells the kernel that the hlt
1890 instruction doesn't work correctly and not to
1891 use it.
1892
1893 no_file_caps Tells the kernel not to honor file capabilities. The 1889 no_file_caps Tells the kernel not to honor file capabilities. The
1894 only way then for a file to be executed with privilege 1890 only way then for a file to be executed with privilege
1895 is to be setuid root or executed by root. 1891 is to be setuid root or executed by root.
diff --git a/Documentation/power/freezing-of-tasks.txt b/Documentation/power/freezing-of-tasks.txt
index 6ec291ea1c78..85894d83b352 100644
--- a/Documentation/power/freezing-of-tasks.txt
+++ b/Documentation/power/freezing-of-tasks.txt
@@ -223,3 +223,8 @@ since they ask the freezer to skip freezing this task, since it is anyway
223only after the entire suspend/hibernation sequence is complete. 223only after the entire suspend/hibernation sequence is complete.
224So, to summarize, use [un]lock_system_sleep() instead of directly using 224So, to summarize, use [un]lock_system_sleep() instead of directly using
225mutex_[un]lock(&pm_mutex). That would prevent freezing failures. 225mutex_[un]lock(&pm_mutex). That would prevent freezing failures.
226
227V. Miscellaneous
228/sys/power/pm_freeze_timeout controls how long it will cost at most to freeze
229all user space processes or all freezable kernel threads, in unit of millisecond.
230The default value is 20000, with range of unsigned integer.
diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt
index 03591a750f99..6c9f5d9aa115 100644
--- a/Documentation/power/runtime_pm.txt
+++ b/Documentation/power/runtime_pm.txt
@@ -426,6 +426,10 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
426 'power.runtime_error' is set or 'power.disable_depth' is greater than 426 'power.runtime_error' is set or 'power.disable_depth' is greater than
427 zero) 427 zero)
428 428
429 bool pm_runtime_active(struct device *dev);
430 - return true if the device's runtime PM status is 'active' or its
431 'power.disable_depth' field is not equal to zero, or false otherwise
432
429 bool pm_runtime_suspended(struct device *dev); 433 bool pm_runtime_suspended(struct device *dev);
430 - return true if the device's runtime PM status is 'suspended' and its 434 - return true if the device's runtime PM status is 'suspended' and its
431 'power.disable_depth' field is equal to zero, or false otherwise 435 'power.disable_depth' field is equal to zero, or false otherwise
diff --git a/Documentation/trace/events-power.txt b/Documentation/trace/events-power.txt
index cf794af22855..e1498ff8cf94 100644
--- a/Documentation/trace/events-power.txt
+++ b/Documentation/trace/events-power.txt
@@ -17,7 +17,7 @@ Cf. include/trace/events/power.h for the events definitions.
171. Power state switch events 171. Power state switch events
18============================ 18============================
19 19
201.1 New trace API 201.1 Trace API
21----------------- 21-----------------
22 22
23A 'cpu' event class gathers the CPU-related events: cpuidle and 23A 'cpu' event class gathers the CPU-related events: cpuidle and
@@ -41,31 +41,6 @@ The event which has 'state=4294967295' in the trace is very important to the use
41space tools which are using it to detect the end of the current state, and so to 41space tools which are using it to detect the end of the current state, and so to
42correctly draw the states diagrams and to calculate accurate statistics etc. 42correctly draw the states diagrams and to calculate accurate statistics etc.
43 43
441.2 DEPRECATED trace API
45------------------------
46
47A new Kconfig option CONFIG_EVENT_POWER_TRACING_DEPRECATED with the default value of
48'y' has been created. This allows the legacy trace power API to be used conjointly
49with the new trace API.
50The Kconfig option, the old trace API (in include/trace/events/power.h) and the
51old trace points will disappear in a future release (namely 2.6.41).
52
53power_start "type=%lu state=%lu cpu_id=%lu"
54power_frequency "type=%lu state=%lu cpu_id=%lu"
55power_end "cpu_id=%lu"
56
57The 'type' parameter takes one of those macros:
58 . POWER_NONE = 0,
59 . POWER_CSTATE = 1, /* C-State */
60 . POWER_PSTATE = 2, /* Frequency change or DVFS */
61
62The 'state' parameter is set depending on the type:
63 . Target C-state for type=POWER_CSTATE,
64 . Target frequency for type=POWER_PSTATE,
65
66power_end is used to indicate the exit of a state, corresponding to the latest
67power_start event.
68
692. Clocks events 442. Clocks events
70================ 45================
71The clock events are used for clock enable/disable and for 46The clock events are used for clock enable/disable and for
diff --git a/arch/arm/boot/dts/highbank.dts b/arch/arm/boot/dts/highbank.dts
index 5927a8df5625..6aad34ad9517 100644
--- a/arch/arm/boot/dts/highbank.dts
+++ b/arch/arm/boot/dts/highbank.dts
@@ -37,6 +37,16 @@
37 next-level-cache = <&L2>; 37 next-level-cache = <&L2>;
38 clocks = <&a9pll>; 38 clocks = <&a9pll>;
39 clock-names = "cpu"; 39 clock-names = "cpu";
40 operating-points = <
41 /* kHz ignored */
42 1300000 1000000
43 1200000 1000000
44 1100000 1000000
45 800000 1000000
46 400000 1000000
47 200000 1000000
48 >;
49 clock-latency = <100000>;
40 }; 50 };
41 51
42 cpu@901 { 52 cpu@901 {
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index c6dec5fc20aa..047d3e40e470 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -172,14 +172,9 @@ static void default_idle(void)
172 local_irq_enable(); 172 local_irq_enable();
173} 173}
174 174
175void (*pm_idle)(void) = default_idle;
176EXPORT_SYMBOL(pm_idle);
177
178/* 175/*
179 * The idle thread, has rather strange semantics for calling pm_idle, 176 * The idle thread.
180 * but this is what x86 does and we need to do the same, so that 177 * We always respect 'hlt_counter' to prevent low power idle.
181 * things like cpuidle get called in the same way. The only difference
182 * is that we always respect 'hlt_counter' to prevent low power idle.
183 */ 178 */
184void cpu_idle(void) 179void cpu_idle(void)
185{ 180{
@@ -210,10 +205,10 @@ void cpu_idle(void)
210 } else if (!need_resched()) { 205 } else if (!need_resched()) {
211 stop_critical_timings(); 206 stop_critical_timings();
212 if (cpuidle_idle_call()) 207 if (cpuidle_idle_call())
213 pm_idle(); 208 default_idle();
214 start_critical_timings(); 209 start_critical_timings();
215 /* 210 /*
216 * pm_idle functions must always 211 * default_idle functions must always
217 * return with IRQs enabled. 212 * return with IRQs enabled.
218 */ 213 */
219 WARN_ON(irqs_disabled()); 214 WARN_ON(irqs_disabled());
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index 49f335d301ba..ae0c7bb39ae8 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -31,7 +31,6 @@ static void __iomem *twd_base;
31 31
32static struct clk *twd_clk; 32static struct clk *twd_clk;
33static unsigned long twd_timer_rate; 33static unsigned long twd_timer_rate;
34static bool common_setup_called;
35static DEFINE_PER_CPU(bool, percpu_setup_called); 34static DEFINE_PER_CPU(bool, percpu_setup_called);
36 35
37static struct clock_event_device __percpu **twd_evt; 36static struct clock_event_device __percpu **twd_evt;
@@ -239,25 +238,28 @@ static irqreturn_t twd_handler(int irq, void *dev_id)
239 return IRQ_NONE; 238 return IRQ_NONE;
240} 239}
241 240
242static struct clk *twd_get_clock(void) 241static void twd_get_clock(struct device_node *np)
243{ 242{
244 struct clk *clk;
245 int err; 243 int err;
246 244
247 clk = clk_get_sys("smp_twd", NULL); 245 if (np)
248 if (IS_ERR(clk)) { 246 twd_clk = of_clk_get(np, 0);
249 pr_err("smp_twd: clock not found: %d\n", (int)PTR_ERR(clk)); 247 else
250 return clk; 248 twd_clk = clk_get_sys("smp_twd", NULL);
249
250 if (IS_ERR(twd_clk)) {
251 pr_err("smp_twd: clock not found %d\n", (int) PTR_ERR(twd_clk));
252 return;
251 } 253 }
252 254
253 err = clk_prepare_enable(clk); 255 err = clk_prepare_enable(twd_clk);
254 if (err) { 256 if (err) {
255 pr_err("smp_twd: clock failed to prepare+enable: %d\n", err); 257 pr_err("smp_twd: clock failed to prepare+enable: %d\n", err);
256 clk_put(clk); 258 clk_put(twd_clk);
257 return ERR_PTR(err); 259 return;
258 } 260 }
259 261
260 return clk; 262 twd_timer_rate = clk_get_rate(twd_clk);
261} 263}
262 264
263/* 265/*
@@ -280,26 +282,7 @@ static int __cpuinit twd_timer_setup(struct clock_event_device *clk)
280 } 282 }
281 per_cpu(percpu_setup_called, cpu) = true; 283 per_cpu(percpu_setup_called, cpu) = true;
282 284
283 /* 285 twd_calibrate_rate();
284 * This stuff only need to be done once for the entire TWD cluster
285 * during the runtime of the system.
286 */
287 if (!common_setup_called) {
288 twd_clk = twd_get_clock();
289
290 /*
291 * We use IS_ERR_OR_NULL() here, because if the clock stubs
292 * are active we will get a valid clk reference which is
293 * however NULL and will return the rate 0. In that case we
294 * need to calibrate the rate instead.
295 */
296 if (!IS_ERR_OR_NULL(twd_clk))
297 twd_timer_rate = clk_get_rate(twd_clk);
298 else
299 twd_calibrate_rate();
300
301 common_setup_called = true;
302 }
303 286
304 /* 287 /*
305 * The following is done once per CPU the first time .setup() is 288 * The following is done once per CPU the first time .setup() is
@@ -330,7 +313,7 @@ static struct local_timer_ops twd_lt_ops __cpuinitdata = {
330 .stop = twd_timer_stop, 313 .stop = twd_timer_stop,
331}; 314};
332 315
333static int __init twd_local_timer_common_register(void) 316static int __init twd_local_timer_common_register(struct device_node *np)
334{ 317{
335 int err; 318 int err;
336 319
@@ -350,6 +333,8 @@ static int __init twd_local_timer_common_register(void)
350 if (err) 333 if (err)
351 goto out_irq; 334 goto out_irq;
352 335
336 twd_get_clock(np);
337
353 return 0; 338 return 0;
354 339
355out_irq: 340out_irq:
@@ -373,7 +358,7 @@ int __init twd_local_timer_register(struct twd_local_timer *tlt)
373 if (!twd_base) 358 if (!twd_base)
374 return -ENOMEM; 359 return -ENOMEM;
375 360
376 return twd_local_timer_common_register(); 361 return twd_local_timer_common_register(NULL);
377} 362}
378 363
379#ifdef CONFIG_OF 364#ifdef CONFIG_OF
@@ -405,7 +390,7 @@ void __init twd_local_timer_of_register(void)
405 goto out; 390 goto out;
406 } 391 }
407 392
408 err = twd_local_timer_common_register(); 393 err = twd_local_timer_common_register(np);
409 394
410out: 395out:
411 WARN(err, "twd_local_timer_of_register failed (%d)\n", err); 396 WARN(err, "twd_local_timer_of_register failed (%d)\n", err);
diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
index 9107691adbdb..5ac9e9384b15 100644
--- a/arch/arm/mach-davinci/cpuidle.c
+++ b/arch/arm/mach-davinci/cpuidle.c
@@ -25,35 +25,44 @@
25 25
26#define DAVINCI_CPUIDLE_MAX_STATES 2 26#define DAVINCI_CPUIDLE_MAX_STATES 2
27 27
28struct davinci_ops { 28static DEFINE_PER_CPU(struct cpuidle_device, davinci_cpuidle_device);
29 void (*enter) (u32 flags); 29static void __iomem *ddr2_reg_base;
30 void (*exit) (u32 flags); 30static bool ddr2_pdown;
31 u32 flags; 31
32}; 32static void davinci_save_ddr_power(int enter, bool pdown)
33{
34 u32 val;
35
36 val = __raw_readl(ddr2_reg_base + DDR2_SDRCR_OFFSET);
37
38 if (enter) {
39 if (pdown)
40 val |= DDR2_SRPD_BIT;
41 else
42 val &= ~DDR2_SRPD_BIT;
43 val |= DDR2_LPMODEN_BIT;
44 } else {
45 val &= ~(DDR2_SRPD_BIT | DDR2_LPMODEN_BIT);
46 }
47
48 __raw_writel(val, ddr2_reg_base + DDR2_SDRCR_OFFSET);
49}
33 50
34/* Actual code that puts the SoC in different idle states */ 51/* Actual code that puts the SoC in different idle states */
35static int davinci_enter_idle(struct cpuidle_device *dev, 52static int davinci_enter_idle(struct cpuidle_device *dev,
36 struct cpuidle_driver *drv, 53 struct cpuidle_driver *drv,
37 int index) 54 int index)
38{ 55{
39 struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 56 davinci_save_ddr_power(1, ddr2_pdown);
40 struct davinci_ops *ops = cpuidle_get_statedata(state_usage);
41
42 if (ops && ops->enter)
43 ops->enter(ops->flags);
44 57
45 index = cpuidle_wrap_enter(dev, drv, index, 58 index = cpuidle_wrap_enter(dev, drv, index,
46 arm_cpuidle_simple_enter); 59 arm_cpuidle_simple_enter);
47 60
48 if (ops && ops->exit) 61 davinci_save_ddr_power(0, ddr2_pdown);
49 ops->exit(ops->flags);
50 62
51 return index; 63 return index;
52} 64}
53 65
54/* fields in davinci_ops.flags */
55#define DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN BIT(0)
56
57static struct cpuidle_driver davinci_idle_driver = { 66static struct cpuidle_driver davinci_idle_driver = {
58 .name = "cpuidle-davinci", 67 .name = "cpuidle-davinci",
59 .owner = THIS_MODULE, 68 .owner = THIS_MODULE,
@@ -70,45 +79,6 @@ static struct cpuidle_driver davinci_idle_driver = {
70 .state_count = DAVINCI_CPUIDLE_MAX_STATES, 79 .state_count = DAVINCI_CPUIDLE_MAX_STATES,
71}; 80};
72 81
73static DEFINE_PER_CPU(struct cpuidle_device, davinci_cpuidle_device);
74static void __iomem *ddr2_reg_base;
75
76static void davinci_save_ddr_power(int enter, bool pdown)
77{
78 u32 val;
79
80 val = __raw_readl(ddr2_reg_base + DDR2_SDRCR_OFFSET);
81
82 if (enter) {
83 if (pdown)
84 val |= DDR2_SRPD_BIT;
85 else
86 val &= ~DDR2_SRPD_BIT;
87 val |= DDR2_LPMODEN_BIT;
88 } else {
89 val &= ~(DDR2_SRPD_BIT | DDR2_LPMODEN_BIT);
90 }
91
92 __raw_writel(val, ddr2_reg_base + DDR2_SDRCR_OFFSET);
93}
94
95static void davinci_c2state_enter(u32 flags)
96{
97 davinci_save_ddr_power(1, !!(flags & DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN));
98}
99
100static void davinci_c2state_exit(u32 flags)
101{
102 davinci_save_ddr_power(0, !!(flags & DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN));
103}
104
105static struct davinci_ops davinci_states[DAVINCI_CPUIDLE_MAX_STATES] = {
106 [1] = {
107 .enter = davinci_c2state_enter,
108 .exit = davinci_c2state_exit,
109 },
110};
111
112static int __init davinci_cpuidle_probe(struct platform_device *pdev) 82static int __init davinci_cpuidle_probe(struct platform_device *pdev)
113{ 83{
114 int ret; 84 int ret;
@@ -124,11 +94,7 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev)
124 94
125 ddr2_reg_base = pdata->ddr2_ctlr_base; 95 ddr2_reg_base = pdata->ddr2_ctlr_base;
126 96
127 if (pdata->ddr2_pdown) 97 ddr2_pdown = pdata->ddr2_pdown;
128 davinci_states[1].flags |= DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN;
129 cpuidle_set_statedata(&device->states_usage[1], &davinci_states[1]);
130
131 device->state_count = DAVINCI_CPUIDLE_MAX_STATES;
132 98
133 ret = cpuidle_register_driver(&davinci_idle_driver); 99 ret = cpuidle_register_driver(&davinci_idle_driver);
134 if (ret) { 100 if (ret) {
diff --git a/arch/arm/mach-exynos/include/mach/cpufreq.h b/arch/arm/mach-exynos/include/mach/cpufreq.h
index 7517c3f417af..b5d39dd03b2a 100644
--- a/arch/arm/mach-exynos/include/mach/cpufreq.h
+++ b/arch/arm/mach-exynos/include/mach/cpufreq.h
@@ -18,12 +18,25 @@ enum cpufreq_level_index {
18 L20, 18 L20,
19}; 19};
20 20
21#define APLL_FREQ(f, a0, a1, a2, a3, a4, a5, a6, a7, b0, b1, b2, m, p, s) \
22 { \
23 .freq = (f) * 1000, \
24 .clk_div_cpu0 = ((a0) | (a1) << 4 | (a2) << 8 | (a3) << 12 | \
25 (a4) << 16 | (a5) << 20 | (a6) << 24 | (a7) << 28), \
26 .clk_div_cpu1 = (b0 << 0 | b1 << 4 | b2 << 8), \
27 .mps = ((m) << 16 | (p) << 8 | (s)), \
28 }
29
30struct apll_freq {
31 unsigned int freq;
32 u32 clk_div_cpu0;
33 u32 clk_div_cpu1;
34 u32 mps;
35};
36
21struct exynos_dvfs_info { 37struct exynos_dvfs_info {
22 unsigned long mpll_freq_khz; 38 unsigned long mpll_freq_khz;
23 unsigned int pll_safe_idx; 39 unsigned int pll_safe_idx;
24 unsigned int pm_lock_idx;
25 unsigned int max_support_idx;
26 unsigned int min_support_idx;
27 struct clk *cpu_clk; 40 struct clk *cpu_clk;
28 unsigned int *volt_table; 41 unsigned int *volt_table;
29 struct cpufreq_frequency_table *freq_table; 42 struct cpufreq_frequency_table *freq_table;
diff --git a/arch/arm/mach-highbank/Kconfig b/arch/arm/mach-highbank/Kconfig
index 551c97e87a78..44b12f9c1584 100644
--- a/arch/arm/mach-highbank/Kconfig
+++ b/arch/arm/mach-highbank/Kconfig
@@ -1,5 +1,7 @@
1config ARCH_HIGHBANK 1config ARCH_HIGHBANK
2 bool "Calxeda ECX-1000/2000 (Highbank/Midway)" if ARCH_MULTI_V7 2 bool "Calxeda ECX-1000/2000 (Highbank/Midway)" if ARCH_MULTI_V7
3 select ARCH_HAS_CPUFREQ
4 select ARCH_HAS_OPP
3 select ARCH_WANT_OPTIONAL_GPIOLIB 5 select ARCH_WANT_OPTIONAL_GPIOLIB
4 select ARM_AMBA 6 select ARM_AMBA
5 select ARM_GIC 7 select ARM_GIC
@@ -11,5 +13,7 @@ config ARCH_HIGHBANK
11 select GENERIC_CLOCKEVENTS 13 select GENERIC_CLOCKEVENTS
12 select HAVE_ARM_SCU 14 select HAVE_ARM_SCU
13 select HAVE_SMP 15 select HAVE_SMP
16 select MAILBOX
17 select PL320_MBOX
14 select SPARSE_IRQ 18 select SPARSE_IRQ
15 select USE_OF 19 select USE_OF
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 7be3622cfc85..2d93d8b23835 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -351,12 +351,10 @@ static void omap3_pm_idle(void)
351 if (omap_irq_pending()) 351 if (omap_irq_pending())
352 goto out; 352 goto out;
353 353
354 trace_power_start(POWER_CSTATE, 1, smp_processor_id());
355 trace_cpu_idle(1, smp_processor_id()); 354 trace_cpu_idle(1, smp_processor_id());
356 355
357 omap_sram_idle(); 356 omap_sram_idle();
358 357
359 trace_power_end(smp_processor_id());
360 trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id()); 358 trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
361 359
362out: 360out:
diff --git a/arch/arm/mach-tegra/cpu-tegra.c b/arch/arm/mach-tegra/cpu-tegra.c
index a74d3c7d2e26..a36a03d3c9a0 100644
--- a/arch/arm/mach-tegra/cpu-tegra.c
+++ b/arch/arm/mach-tegra/cpu-tegra.c
@@ -243,8 +243,7 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)
243 /* FIXME: what's the actual transition time? */ 243 /* FIXME: what's the actual transition time? */
244 policy->cpuinfo.transition_latency = 300 * 1000; 244 policy->cpuinfo.transition_latency = 300 * 1000;
245 245
246 policy->shared_type = CPUFREQ_SHARED_TYPE_ALL; 246 cpumask_copy(policy->cpus, cpu_possible_mask);
247 cpumask_copy(policy->related_cpus, cpu_possible_mask);
248 247
249 if (policy->cpu == 0) 248 if (policy->cpu == 0)
250 register_pm_notifier(&tegra_cpu_pm_notifier); 249 register_pm_notifier(&tegra_cpu_pm_notifier);
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index cb0956bc96ed..c7002d40a9b0 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -97,14 +97,9 @@ static void default_idle(void)
97 local_irq_enable(); 97 local_irq_enable();
98} 98}
99 99
100void (*pm_idle)(void) = default_idle;
101EXPORT_SYMBOL_GPL(pm_idle);
102
103/* 100/*
104 * The idle thread, has rather strange semantics for calling pm_idle, 101 * The idle thread.
105 * but this is what x86 does and we need to do the same, so that 102 * We always respect 'hlt_counter' to prevent low power idle.
106 * things like cpuidle get called in the same way. The only difference
107 * is that we always respect 'hlt_counter' to prevent low power idle.
108 */ 103 */
109void cpu_idle(void) 104void cpu_idle(void)
110{ 105{
@@ -122,10 +117,10 @@ void cpu_idle(void)
122 local_irq_disable(); 117 local_irq_disable();
123 if (!need_resched()) { 118 if (!need_resched()) {
124 stop_critical_timings(); 119 stop_critical_timings();
125 pm_idle(); 120 default_idle();
126 start_critical_timings(); 121 start_critical_timings();
127 /* 122 /*
128 * pm_idle functions should always return 123 * default_idle functions should always return
129 * with IRQs enabled. 124 * with IRQs enabled.
130 */ 125 */
131 WARN_ON(irqs_disabled()); 126 WARN_ON(irqs_disabled());
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c
index 3e16ad9b0a99..8061426b7df5 100644
--- a/arch/blackfin/kernel/process.c
+++ b/arch/blackfin/kernel/process.c
@@ -39,12 +39,6 @@ int nr_l1stack_tasks;
39void *l1_stack_base; 39void *l1_stack_base;
40unsigned long l1_stack_len; 40unsigned long l1_stack_len;
41 41
42/*
43 * Powermanagement idle function, if any..
44 */
45void (*pm_idle)(void) = NULL;
46EXPORT_SYMBOL(pm_idle);
47
48void (*pm_power_off)(void) = NULL; 42void (*pm_power_off)(void) = NULL;
49EXPORT_SYMBOL(pm_power_off); 43EXPORT_SYMBOL(pm_power_off);
50 44
@@ -81,7 +75,6 @@ void cpu_idle(void)
81{ 75{
82 /* endless idle loop with no priority at all */ 76 /* endless idle loop with no priority at all */
83 while (1) { 77 while (1) {
84 void (*idle)(void) = pm_idle;
85 78
86#ifdef CONFIG_HOTPLUG_CPU 79#ifdef CONFIG_HOTPLUG_CPU
87 if (cpu_is_offline(smp_processor_id())) 80 if (cpu_is_offline(smp_processor_id()))
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
index 7f65be6f7f17..104ff4dd9b98 100644
--- a/arch/cris/kernel/process.c
+++ b/arch/cris/kernel/process.c
@@ -54,11 +54,6 @@ void enable_hlt(void)
54 54
55EXPORT_SYMBOL(enable_hlt); 55EXPORT_SYMBOL(enable_hlt);
56 56
57/*
58 * The following aren't currently used.
59 */
60void (*pm_idle)(void);
61
62extern void default_idle(void); 57extern void default_idle(void);
63 58
64void (*pm_power_off)(void); 59void (*pm_power_off)(void);
@@ -77,16 +72,12 @@ void cpu_idle (void)
77 while (1) { 72 while (1) {
78 rcu_idle_enter(); 73 rcu_idle_enter();
79 while (!need_resched()) { 74 while (!need_resched()) {
80 void (*idle)(void);
81 /* 75 /*
82 * Mark this as an RCU critical section so that 76 * Mark this as an RCU critical section so that
83 * synchronize_kernel() in the unload path waits 77 * synchronize_kernel() in the unload path waits
84 * for our completion. 78 * for our completion.
85 */ 79 */
86 idle = pm_idle; 80 default_idle();
87 if (!idle)
88 idle = default_idle;
89 idle();
90 } 81 }
91 rcu_idle_exit(); 82 rcu_idle_exit();
92 schedule_preempt_disabled(); 83 schedule_preempt_disabled();
diff --git a/arch/ia64/hp/common/aml_nfw.c b/arch/ia64/hp/common/aml_nfw.c
index 6192f7188654..916ffe770bcf 100644
--- a/arch/ia64/hp/common/aml_nfw.c
+++ b/arch/ia64/hp/common/aml_nfw.c
@@ -191,7 +191,7 @@ static int aml_nfw_add(struct acpi_device *device)
191 return aml_nfw_add_global_handler(); 191 return aml_nfw_add_global_handler();
192} 192}
193 193
194static int aml_nfw_remove(struct acpi_device *device, int type) 194static int aml_nfw_remove(struct acpi_device *device)
195{ 195{
196 return aml_nfw_remove_global_handler(); 196 return aml_nfw_remove_global_handler();
197} 197}
diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
index 359e68a03ca3..faa1bf0da815 100644
--- a/arch/ia64/include/asm/acpi.h
+++ b/arch/ia64/include/asm/acpi.h
@@ -52,10 +52,6 @@
52 52
53/* Asm macros */ 53/* Asm macros */
54 54
55#define ACPI_ASM_MACROS
56#define BREAKPOINT3
57#define ACPI_DISABLE_IRQS() local_irq_disable()
58#define ACPI_ENABLE_IRQS() local_irq_enable()
59#define ACPI_FLUSH_CPU_CACHE() 55#define ACPI_FLUSH_CPU_CACHE()
60 56
61static inline int 57static inline int
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 31360cbbd5f8..e34f565f595a 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -57,8 +57,6 @@ void (*ia64_mark_idle)(int);
57 57
58unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE; 58unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;
59EXPORT_SYMBOL(boot_option_idle_override); 59EXPORT_SYMBOL(boot_option_idle_override);
60void (*pm_idle) (void);
61EXPORT_SYMBOL(pm_idle);
62void (*pm_power_off) (void); 60void (*pm_power_off) (void);
63EXPORT_SYMBOL(pm_power_off); 61EXPORT_SYMBOL(pm_power_off);
64 62
@@ -301,7 +299,6 @@ cpu_idle (void)
301 if (mark_idle) 299 if (mark_idle)
302 (*mark_idle)(1); 300 (*mark_idle)(1);
303 301
304 idle = pm_idle;
305 if (!idle) 302 if (!idle)
306 idle = default_idle; 303 idle = default_idle;
307 (*idle)(); 304 (*idle)();
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index aaefd9b94f2f..2029cc0d2fc6 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -1051,7 +1051,6 @@ cpu_init (void)
1051 max_num_phys_stacked = num_phys_stacked; 1051 max_num_phys_stacked = num_phys_stacked;
1052 } 1052 }
1053 platform_cpu_init(); 1053 platform_cpu_init();
1054 pm_idle = default_idle;
1055} 1054}
1056 1055
1057void __init 1056void __init
diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c
index 765d0f57c787..bde899e155d3 100644
--- a/arch/m32r/kernel/process.c
+++ b/arch/m32r/kernel/process.c
@@ -44,36 +44,10 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
44 return tsk->thread.lr; 44 return tsk->thread.lr;
45} 45}
46 46
47/*
48 * Powermanagement idle function, if any..
49 */
50static void (*pm_idle)(void) = NULL;
51
52void (*pm_power_off)(void) = NULL; 47void (*pm_power_off)(void) = NULL;
53EXPORT_SYMBOL(pm_power_off); 48EXPORT_SYMBOL(pm_power_off);
54 49
55/* 50/*
56 * We use this is we don't have any better
57 * idle routine..
58 */
59static void default_idle(void)
60{
61 /* M32R_FIXME: Please use "cpu_sleep" mode. */
62 cpu_relax();
63}
64
65/*
66 * On SMP it's slightly faster (but much more power-consuming!)
67 * to poll the ->work.need_resched flag instead of waiting for the
68 * cross-CPU IPI to arrive. Use this option with caution.
69 */
70static void poll_idle (void)
71{
72 /* M32R_FIXME */
73 cpu_relax();
74}
75
76/*
77 * The idle thread. There's no useful work to be 51 * The idle thread. There's no useful work to be
78 * done, so just try to conserve power and have a 52 * done, so just try to conserve power and have a
79 * low exit latency (ie sit in a loop waiting for 53 * low exit latency (ie sit in a loop waiting for
@@ -84,14 +58,8 @@ void cpu_idle (void)
84 /* endless idle loop with no priority at all */ 58 /* endless idle loop with no priority at all */
85 while (1) { 59 while (1) {
86 rcu_idle_enter(); 60 rcu_idle_enter();
87 while (!need_resched()) { 61 while (!need_resched())
88 void (*idle)(void) = pm_idle; 62 cpu_relax();
89
90 if (!idle)
91 idle = default_idle;
92
93 idle();
94 }
95 rcu_idle_exit(); 63 rcu_idle_exit();
96 schedule_preempt_disabled(); 64 schedule_preempt_disabled();
97 } 65 }
@@ -120,21 +88,6 @@ void machine_power_off(void)
120 /* M32R_FIXME */ 88 /* M32R_FIXME */
121} 89}
122 90
123static int __init idle_setup (char *str)
124{
125 if (!strncmp(str, "poll", 4)) {
126 printk("using poll in idle threads.\n");
127 pm_idle = poll_idle;
128 } else if (!strncmp(str, "sleep", 4)) {
129 printk("using sleep in idle threads.\n");
130 pm_idle = default_idle;
131 }
132
133 return 1;
134}
135
136__setup("idle=", idle_setup);
137
138void show_regs(struct pt_regs * regs) 91void show_regs(struct pt_regs * regs)
139{ 92{
140 printk("\n"); 93 printk("\n");
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
index a5b74f729e5b..6ff2dcff3410 100644
--- a/arch/microblaze/kernel/process.c
+++ b/arch/microblaze/kernel/process.c
@@ -41,7 +41,6 @@ void show_regs(struct pt_regs *regs)
41 regs->msr, regs->ear, regs->esr, regs->fsr); 41 regs->msr, regs->ear, regs->esr, regs->fsr);
42} 42}
43 43
44void (*pm_idle)(void);
45void (*pm_power_off)(void) = NULL; 44void (*pm_power_off)(void) = NULL;
46EXPORT_SYMBOL(pm_power_off); 45EXPORT_SYMBOL(pm_power_off);
47 46
@@ -98,8 +97,6 @@ void cpu_idle(void)
98 97
99 /* endless idle loop with no priority at all */ 98 /* endless idle loop with no priority at all */
100 while (1) { 99 while (1) {
101 void (*idle)(void) = pm_idle;
102
103 if (!idle) 100 if (!idle)
104 idle = default_idle; 101 idle = default_idle;
105 102
diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c
index eb09f5a552ff..84f4e97e3074 100644
--- a/arch/mn10300/kernel/process.c
+++ b/arch/mn10300/kernel/process.c
@@ -37,12 +37,6 @@
37#include "internal.h" 37#include "internal.h"
38 38
39/* 39/*
40 * power management idle function, if any..
41 */
42void (*pm_idle)(void);
43EXPORT_SYMBOL(pm_idle);
44
45/*
46 * return saved PC of a blocked thread. 40 * return saved PC of a blocked thread.
47 */ 41 */
48unsigned long thread_saved_pc(struct task_struct *tsk) 42unsigned long thread_saved_pc(struct task_struct *tsk)
@@ -113,7 +107,6 @@ void cpu_idle(void)
113 void (*idle)(void); 107 void (*idle)(void);
114 108
115 smp_rmb(); 109 smp_rmb();
116 idle = pm_idle;
117 if (!idle) { 110 if (!idle) {
118#if defined(CONFIG_SMP) && !defined(CONFIG_HOTPLUG_CPU) 111#if defined(CONFIG_SMP) && !defined(CONFIG_HOTPLUG_CPU)
119 idle = poll_idle; 112 idle = poll_idle;
diff --git a/arch/openrisc/kernel/idle.c b/arch/openrisc/kernel/idle.c
index 7d618feb1b72..5e8a3b6d6bc6 100644
--- a/arch/openrisc/kernel/idle.c
+++ b/arch/openrisc/kernel/idle.c
@@ -39,11 +39,6 @@
39 39
40void (*powersave) (void) = NULL; 40void (*powersave) (void) = NULL;
41 41
42static inline void pm_idle(void)
43{
44 barrier();
45}
46
47void cpu_idle(void) 42void cpu_idle(void)
48{ 43{
49 set_thread_flag(TIF_POLLING_NRFLAG); 44 set_thread_flag(TIF_POLLING_NRFLAG);
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c
index 0c910163caa3..3d5a1b387cc0 100644
--- a/arch/sh/kernel/idle.c
+++ b/arch/sh/kernel/idle.c
@@ -22,7 +22,7 @@
22#include <asm/smp.h> 22#include <asm/smp.h>
23#include <asm/bl_bit.h> 23#include <asm/bl_bit.h>
24 24
25void (*pm_idle)(void); 25static void (*sh_idle)(void);
26 26
27static int hlt_counter; 27static int hlt_counter;
28 28
@@ -103,9 +103,9 @@ void cpu_idle(void)
103 /* Don't trace irqs off for idle */ 103 /* Don't trace irqs off for idle */
104 stop_critical_timings(); 104 stop_critical_timings();
105 if (cpuidle_idle_call()) 105 if (cpuidle_idle_call())
106 pm_idle(); 106 sh_idle();
107 /* 107 /*
108 * Sanity check to ensure that pm_idle() returns 108 * Sanity check to ensure that sh_idle() returns
109 * with IRQs enabled 109 * with IRQs enabled
110 */ 110 */
111 WARN_ON(irqs_disabled()); 111 WARN_ON(irqs_disabled());
@@ -123,13 +123,13 @@ void __init select_idle_routine(void)
123 /* 123 /*
124 * If a platform has set its own idle routine, leave it alone. 124 * If a platform has set its own idle routine, leave it alone.
125 */ 125 */
126 if (pm_idle) 126 if (sh_idle)
127 return; 127 return;
128 128
129 if (hlt_works()) 129 if (hlt_works())
130 pm_idle = default_idle; 130 sh_idle = default_idle;
131 else 131 else
132 pm_idle = poll_idle; 132 sh_idle = poll_idle;
133} 133}
134 134
135void stop_this_cpu(void *unused) 135void stop_this_cpu(void *unused)
diff --git a/arch/sparc/include/asm/processor_32.h b/arch/sparc/include/asm/processor_32.h
index c1e01914fd98..2c7baa4c4505 100644
--- a/arch/sparc/include/asm/processor_32.h
+++ b/arch/sparc/include/asm/processor_32.h
@@ -118,6 +118,7 @@ extern unsigned long get_wchan(struct task_struct *);
118extern struct task_struct *last_task_used_math; 118extern struct task_struct *last_task_used_math;
119 119
120#define cpu_relax() barrier() 120#define cpu_relax() barrier()
121extern void (*sparc_idle)(void);
121 122
122#endif 123#endif
123 124
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c
index 348fa1aeabce..eefda32b595e 100644
--- a/arch/sparc/kernel/apc.c
+++ b/arch/sparc/kernel/apc.c
@@ -20,6 +20,7 @@
20#include <asm/uaccess.h> 20#include <asm/uaccess.h>
21#include <asm/auxio.h> 21#include <asm/auxio.h>
22#include <asm/apc.h> 22#include <asm/apc.h>
23#include <asm/processor.h>
23 24
24/* Debugging 25/* Debugging
25 * 26 *
@@ -158,7 +159,7 @@ static int apc_probe(struct platform_device *op)
158 159
159 /* Assign power management IDLE handler */ 160 /* Assign power management IDLE handler */
160 if (!apc_no_idle) 161 if (!apc_no_idle)
161 pm_idle = apc_swift_idle; 162 sparc_idle = apc_swift_idle;
162 163
163 printk(KERN_INFO "%s: power management initialized%s\n", 164 printk(KERN_INFO "%s: power management initialized%s\n",
164 APC_DEVNAME, apc_no_idle ? " (CPU idle disabled)" : ""); 165 APC_DEVNAME, apc_no_idle ? " (CPU idle disabled)" : "");
diff --git a/arch/sparc/kernel/leon_pmc.c b/arch/sparc/kernel/leon_pmc.c
index 4e174321097d..708bca435219 100644
--- a/arch/sparc/kernel/leon_pmc.c
+++ b/arch/sparc/kernel/leon_pmc.c
@@ -9,6 +9,7 @@
9#include <asm/leon_amba.h> 9#include <asm/leon_amba.h>
10#include <asm/cpu_type.h> 10#include <asm/cpu_type.h>
11#include <asm/leon.h> 11#include <asm/leon.h>
12#include <asm/processor.h>
12 13
13/* List of Systems that need fixup instructions around power-down instruction */ 14/* List of Systems that need fixup instructions around power-down instruction */
14unsigned int pmc_leon_fixup_ids[] = { 15unsigned int pmc_leon_fixup_ids[] = {
@@ -69,9 +70,9 @@ static int __init leon_pmc_install(void)
69 if (sparc_cpu_model == sparc_leon) { 70 if (sparc_cpu_model == sparc_leon) {
70 /* Assign power management IDLE handler */ 71 /* Assign power management IDLE handler */
71 if (pmc_leon_need_fixup()) 72 if (pmc_leon_need_fixup())
72 pm_idle = pmc_leon_idle_fixup; 73 sparc_idle = pmc_leon_idle_fixup;
73 else 74 else
74 pm_idle = pmc_leon_idle; 75 sparc_idle = pmc_leon_idle;
75 76
76 printk(KERN_INFO "leon: power management initialized\n"); 77 printk(KERN_INFO "leon: power management initialized\n");
77 } 78 }
diff --git a/arch/sparc/kernel/pmc.c b/arch/sparc/kernel/pmc.c
index dcbb62f63068..8b7297faca79 100644
--- a/arch/sparc/kernel/pmc.c
+++ b/arch/sparc/kernel/pmc.c
@@ -17,6 +17,7 @@
17#include <asm/oplib.h> 17#include <asm/oplib.h>
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include <asm/auxio.h> 19#include <asm/auxio.h>
20#include <asm/processor.h>
20 21
21/* Debug 22/* Debug
22 * 23 *
@@ -63,7 +64,7 @@ static int pmc_probe(struct platform_device *op)
63 64
64#ifndef PMC_NO_IDLE 65#ifndef PMC_NO_IDLE
65 /* Assign power management IDLE handler */ 66 /* Assign power management IDLE handler */
66 pm_idle = pmc_swift_idle; 67 sparc_idle = pmc_swift_idle;
67#endif 68#endif
68 69
69 printk(KERN_INFO "%s: power management initialized\n", PMC_DEVNAME); 70 printk(KERN_INFO "%s: power management initialized\n", PMC_DEVNAME);
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index be8e862badaf..62eede13831a 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -43,8 +43,7 @@
43 * Power management idle function 43 * Power management idle function
44 * Set in pm platform drivers (apc.c and pmc.c) 44 * Set in pm platform drivers (apc.c and pmc.c)
45 */ 45 */
46void (*pm_idle)(void); 46void (*sparc_idle)(void);
47EXPORT_SYMBOL(pm_idle);
48 47
49/* 48/*
50 * Power-off handler instantiation for pm.h compliance 49 * Power-off handler instantiation for pm.h compliance
@@ -75,8 +74,8 @@ void cpu_idle(void)
75 /* endless idle loop with no priority at all */ 74 /* endless idle loop with no priority at all */
76 for (;;) { 75 for (;;) {
77 while (!need_resched()) { 76 while (!need_resched()) {
78 if (pm_idle) 77 if (sparc_idle)
79 (*pm_idle)(); 78 (*sparc_idle)();
80 else 79 else
81 cpu_relax(); 80 cpu_relax();
82 } 81 }
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index 62bad9fed03e..872d7e22d847 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -45,11 +45,6 @@ static const char * const processor_modes[] = {
45 "UK18", "UK19", "UK1A", "EXTN", "UK1C", "UK1D", "UK1E", "SUSR" 45 "UK18", "UK19", "UK1A", "EXTN", "UK1C", "UK1D", "UK1E", "SUSR"
46}; 46};
47 47
48/*
49 * The idle thread, has rather strange semantics for calling pm_idle,
50 * but this is what x86 does and we need to do the same, so that
51 * things like cpuidle get called in the same way.
52 */
53void cpu_idle(void) 48void cpu_idle(void)
54{ 49{
55 /* endless idle loop with no priority at all */ 50 /* endless idle loop with no priority at all */
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 260857a53b87..f7a27fdb5098 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -469,6 +469,16 @@ config X86_MDFLD
469 469
470endif 470endif
471 471
472config X86_INTEL_LPSS
473 bool "Intel Low Power Subsystem Support"
474 depends on ACPI
475 select COMMON_CLK
476 ---help---
477 Select to build support for Intel Low Power Subsystem such as
478 found on Intel Lynxpoint PCH. Selecting this option enables
479 things like clock tree (common clock framework) which are needed
480 by the LPSS peripheral drivers.
481
472config X86_RDC321X 482config X86_RDC321X
473 bool "RDC R-321x SoC" 483 bool "RDC R-321x SoC"
474 depends on X86_32 484 depends on X86_32
@@ -1927,6 +1937,7 @@ config APM_DO_ENABLE
1927 this feature. 1937 this feature.
1928 1938
1929config APM_CPU_IDLE 1939config APM_CPU_IDLE
1940 depends on CPU_IDLE
1930 bool "Make CPU Idle calls when idle" 1941 bool "Make CPU Idle calls when idle"
1931 ---help--- 1942 ---help---
1932 Enable calls to APM CPU Idle/CPU Busy inside the kernel's idle loop. 1943 Enable calls to APM CPU Idle/CPU Busy inside the kernel's idle loop.
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index 0c44630d1789..b31bf97775fc 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -49,10 +49,6 @@
49 49
50/* Asm macros */ 50/* Asm macros */
51 51
52#define ACPI_ASM_MACROS
53#define BREAKPOINT3
54#define ACPI_DISABLE_IRQS() local_irq_disable()
55#define ACPI_ENABLE_IRQS() local_irq_enable()
56#define ACPI_FLUSH_CPU_CACHE() wbinvd() 52#define ACPI_FLUSH_CPU_CACHE() wbinvd()
57 53
58int __acpi_acquire_global_lock(unsigned int *lock); 54int __acpi_acquire_global_lock(unsigned int *lock);
diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
index bcdff997668c..2f366d0ac6b4 100644
--- a/arch/x86/include/asm/mwait.h
+++ b/arch/x86/include/asm/mwait.h
@@ -4,7 +4,8 @@
4#define MWAIT_SUBSTATE_MASK 0xf 4#define MWAIT_SUBSTATE_MASK 0xf
5#define MWAIT_CSTATE_MASK 0xf 5#define MWAIT_CSTATE_MASK 0xf
6#define MWAIT_SUBSTATE_SIZE 4 6#define MWAIT_SUBSTATE_SIZE 4
7#define MWAIT_MAX_NUM_CSTATES 8 7#define MWAIT_HINT2CSTATE(hint) (((hint) >> MWAIT_SUBSTATE_SIZE) & MWAIT_CSTATE_MASK)
8#define MWAIT_HINT2SUBSTATE(hint) ((hint) & MWAIT_CSTATE_MASK)
8 9
9#define CPUID_MWAIT_LEAF 5 10#define CPUID_MWAIT_LEAF 5
10#define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1 11#define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index cf500543f6ff..d172588efae5 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -89,7 +89,6 @@ struct cpuinfo_x86 {
89 char wp_works_ok; /* It doesn't on 386's */ 89 char wp_works_ok; /* It doesn't on 386's */
90 90
91 /* Problems on some 486Dx4's and old 386's: */ 91 /* Problems on some 486Dx4's and old 386's: */
92 char hlt_works_ok;
93 char hard_math; 92 char hard_math;
94 char rfu; 93 char rfu;
95 char fdiv_bug; 94 char fdiv_bug;
@@ -165,15 +164,6 @@ DECLARE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
165 164
166extern const struct seq_operations cpuinfo_op; 165extern const struct seq_operations cpuinfo_op;
167 166
168static inline int hlt_works(int cpu)
169{
170#ifdef CONFIG_X86_32
171 return cpu_data(cpu).hlt_works_ok;
172#else
173 return 1;
174#endif
175}
176
177#define cache_line_size() (boot_cpu_data.x86_cache_alignment) 167#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
178 168
179extern void cpu_detect(struct cpuinfo_x86 *c); 169extern void cpu_detect(struct cpuinfo_x86 *c);
@@ -725,7 +715,7 @@ extern unsigned long boot_option_idle_override;
725extern bool amd_e400_c1e_detected; 715extern bool amd_e400_c1e_detected;
726 716
727enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_NOMWAIT, 717enum idle_boot_override {IDLE_NO_OVERRIDE=0, IDLE_HALT, IDLE_NOMWAIT,
728 IDLE_POLL, IDLE_FORCE_MWAIT}; 718 IDLE_POLL};
729 719
730extern void enable_sep_cpu(void); 720extern void enable_sep_cpu(void);
731extern int sysenter_setup(void); 721extern int sysenter_setup(void);
@@ -998,7 +988,11 @@ extern unsigned long arch_align_stack(unsigned long sp);
998extern void free_init_pages(char *what, unsigned long begin, unsigned long end); 988extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
999 989
1000void default_idle(void); 990void default_idle(void);
1001bool set_pm_idle_to_default(void); 991#ifdef CONFIG_XEN
992bool xen_set_default_idle(void);
993#else
994#define xen_set_default_idle 0
995#endif
1002 996
1003void stop_this_cpu(void *dummy); 997void stop_this_cpu(void *dummy);
1004 998
diff --git a/arch/x86/include/uapi/asm/msr-index.h b/arch/x86/include/uapi/asm/msr-index.h
index 075a40255591..f26d2771846f 100644
--- a/arch/x86/include/uapi/asm/msr-index.h
+++ b/arch/x86/include/uapi/asm/msr-index.h
@@ -103,6 +103,8 @@
103#define DEBUGCTLMSR_BTS_OFF_USR (1UL << 10) 103#define DEBUGCTLMSR_BTS_OFF_USR (1UL << 10)
104#define DEBUGCTLMSR_FREEZE_LBRS_ON_PMI (1UL << 11) 104#define DEBUGCTLMSR_FREEZE_LBRS_ON_PMI (1UL << 11)
105 105
106#define MSR_IA32_POWER_CTL 0x000001fc
107
106#define MSR_IA32_MC0_CTL 0x00000400 108#define MSR_IA32_MC0_CTL 0x00000400
107#define MSR_IA32_MC0_STATUS 0x00000401 109#define MSR_IA32_MC0_STATUS 0x00000401
108#define MSR_IA32_MC0_ADDR 0x00000402 110#define MSR_IA32_MC0_ADDR 0x00000402
@@ -274,6 +276,7 @@
274#define MSR_IA32_PLATFORM_ID 0x00000017 276#define MSR_IA32_PLATFORM_ID 0x00000017
275#define MSR_IA32_EBL_CR_POWERON 0x0000002a 277#define MSR_IA32_EBL_CR_POWERON 0x0000002a
276#define MSR_EBC_FREQUENCY_ID 0x0000002c 278#define MSR_EBC_FREQUENCY_ID 0x0000002c
279#define MSR_SMI_COUNT 0x00000034
277#define MSR_IA32_FEATURE_CONTROL 0x0000003a 280#define MSR_IA32_FEATURE_CONTROL 0x0000003a
278#define MSR_IA32_TSC_ADJUST 0x0000003b 281#define MSR_IA32_TSC_ADJUST 0x0000003b
279 282
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 8d7012b7f402..66b5faffe14a 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -232,6 +232,7 @@
232#include <linux/acpi.h> 232#include <linux/acpi.h>
233#include <linux/syscore_ops.h> 233#include <linux/syscore_ops.h>
234#include <linux/i8253.h> 234#include <linux/i8253.h>
235#include <linux/cpuidle.h>
235 236
236#include <asm/uaccess.h> 237#include <asm/uaccess.h>
237#include <asm/desc.h> 238#include <asm/desc.h>
@@ -360,13 +361,35 @@ struct apm_user {
360 * idle percentage above which bios idle calls are done 361 * idle percentage above which bios idle calls are done
361 */ 362 */
362#ifdef CONFIG_APM_CPU_IDLE 363#ifdef CONFIG_APM_CPU_IDLE
363#warning deprecated CONFIG_APM_CPU_IDLE will be deleted in 2012
364#define DEFAULT_IDLE_THRESHOLD 95 364#define DEFAULT_IDLE_THRESHOLD 95
365#else 365#else
366#define DEFAULT_IDLE_THRESHOLD 100 366#define DEFAULT_IDLE_THRESHOLD 100
367#endif 367#endif
368#define DEFAULT_IDLE_PERIOD (100 / 3) 368#define DEFAULT_IDLE_PERIOD (100 / 3)
369 369
370static int apm_cpu_idle(struct cpuidle_device *dev,
371 struct cpuidle_driver *drv, int index);
372
373static struct cpuidle_driver apm_idle_driver = {
374 .name = "apm_idle",
375 .owner = THIS_MODULE,
376 .en_core_tk_irqen = 1,
377 .states = {
378 { /* entry 0 is for polling */ },
379 { /* entry 1 is for APM idle */
380 .name = "APM",
381 .desc = "APM idle",
382 .flags = CPUIDLE_FLAG_TIME_VALID,
383 .exit_latency = 250, /* WAG */
384 .target_residency = 500, /* WAG */
385 .enter = &apm_cpu_idle
386 },
387 },
388 .state_count = 2,
389};
390
391static struct cpuidle_device apm_cpuidle_device;
392
370/* 393/*
371 * Local variables 394 * Local variables
372 */ 395 */
@@ -377,7 +400,6 @@ static struct {
377static int clock_slowed; 400static int clock_slowed;
378static int idle_threshold __read_mostly = DEFAULT_IDLE_THRESHOLD; 401static int idle_threshold __read_mostly = DEFAULT_IDLE_THRESHOLD;
379static int idle_period __read_mostly = DEFAULT_IDLE_PERIOD; 402static int idle_period __read_mostly = DEFAULT_IDLE_PERIOD;
380static int set_pm_idle;
381static int suspends_pending; 403static int suspends_pending;
382static int standbys_pending; 404static int standbys_pending;
383static int ignore_sys_suspend; 405static int ignore_sys_suspend;
@@ -884,8 +906,6 @@ static void apm_do_busy(void)
884#define IDLE_CALC_LIMIT (HZ * 100) 906#define IDLE_CALC_LIMIT (HZ * 100)
885#define IDLE_LEAKY_MAX 16 907#define IDLE_LEAKY_MAX 16
886 908
887static void (*original_pm_idle)(void) __read_mostly;
888
889/** 909/**
890 * apm_cpu_idle - cpu idling for APM capable Linux 910 * apm_cpu_idle - cpu idling for APM capable Linux
891 * 911 *
@@ -894,7 +914,8 @@ static void (*original_pm_idle)(void) __read_mostly;
894 * Furthermore it calls the system default idle routine. 914 * Furthermore it calls the system default idle routine.
895 */ 915 */
896 916
897static void apm_cpu_idle(void) 917static int apm_cpu_idle(struct cpuidle_device *dev,
918 struct cpuidle_driver *drv, int index)
898{ 919{
899 static int use_apm_idle; /* = 0 */ 920 static int use_apm_idle; /* = 0 */
900 static unsigned int last_jiffies; /* = 0 */ 921 static unsigned int last_jiffies; /* = 0 */
@@ -905,7 +926,6 @@ static void apm_cpu_idle(void)
905 unsigned int jiffies_since_last_check = jiffies - last_jiffies; 926 unsigned int jiffies_since_last_check = jiffies - last_jiffies;
906 unsigned int bucket; 927 unsigned int bucket;
907 928
908 WARN_ONCE(1, "deprecated apm_cpu_idle will be deleted in 2012");
909recalc: 929recalc:
910 task_cputime(current, NULL, &stime); 930 task_cputime(current, NULL, &stime);
911 if (jiffies_since_last_check > IDLE_CALC_LIMIT) { 931 if (jiffies_since_last_check > IDLE_CALC_LIMIT) {
@@ -951,10 +971,7 @@ recalc:
951 break; 971 break;
952 } 972 }
953 } 973 }
954 if (original_pm_idle) 974 default_idle();
955 original_pm_idle();
956 else
957 default_idle();
958 local_irq_disable(); 975 local_irq_disable();
959 jiffies_since_last_check = jiffies - last_jiffies; 976 jiffies_since_last_check = jiffies - last_jiffies;
960 if (jiffies_since_last_check > idle_period) 977 if (jiffies_since_last_check > idle_period)
@@ -964,7 +981,7 @@ recalc:
964 if (apm_idle_done) 981 if (apm_idle_done)
965 apm_do_busy(); 982 apm_do_busy();
966 983
967 local_irq_enable(); 984 return index;
968} 985}
969 986
970/** 987/**
@@ -2382,9 +2399,9 @@ static int __init apm_init(void)
2382 if (HZ != 100) 2399 if (HZ != 100)
2383 idle_period = (idle_period * HZ) / 100; 2400 idle_period = (idle_period * HZ) / 100;
2384 if (idle_threshold < 100) { 2401 if (idle_threshold < 100) {
2385 original_pm_idle = pm_idle; 2402 if (!cpuidle_register_driver(&apm_idle_driver))
2386 pm_idle = apm_cpu_idle; 2403 if (cpuidle_register_device(&apm_cpuidle_device))
2387 set_pm_idle = 1; 2404 cpuidle_unregister_driver(&apm_idle_driver);
2388 } 2405 }
2389 2406
2390 return 0; 2407 return 0;
@@ -2394,15 +2411,9 @@ static void __exit apm_exit(void)
2394{ 2411{
2395 int error; 2412 int error;
2396 2413
2397 if (set_pm_idle) { 2414 cpuidle_unregister_device(&apm_cpuidle_device);
2398 pm_idle = original_pm_idle; 2415 cpuidle_unregister_driver(&apm_idle_driver);
2399 /* 2416
2400 * We are about to unload the current idle thread pm callback
2401 * (pm_idle), Wait for all processors to update cached/local
2402 * copies of pm_idle before proceeding.
2403 */
2404 kick_all_cpus_sync();
2405 }
2406 if (((apm_info.bios.flags & APM_BIOS_DISENGAGED) == 0) 2417 if (((apm_info.bios.flags & APM_BIOS_DISENGAGED) == 0)
2407 && (apm_info.connection_version > 0x0100)) { 2418 && (apm_info.connection_version > 0x0100)) {
2408 error = apm_engage_power_management(APM_DEVICE_ALL, 0); 2419 error = apm_engage_power_management(APM_DEVICE_ALL, 0);
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 92dfec986a48..af6455e3fcc9 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -17,15 +17,6 @@
17#include <asm/paravirt.h> 17#include <asm/paravirt.h>
18#include <asm/alternative.h> 18#include <asm/alternative.h>
19 19
20static int __init no_halt(char *s)
21{
22 WARN_ONCE(1, "\"no-hlt\" is deprecated, please use \"idle=poll\"\n");
23 boot_cpu_data.hlt_works_ok = 0;
24 return 1;
25}
26
27__setup("no-hlt", no_halt);
28
29static int __init no_387(char *s) 20static int __init no_387(char *s)
30{ 21{
31 boot_cpu_data.hard_math = 0; 22 boot_cpu_data.hard_math = 0;
@@ -89,23 +80,6 @@ static void __init check_fpu(void)
89 pr_warn("Hmm, FPU with FDIV bug\n"); 80 pr_warn("Hmm, FPU with FDIV bug\n");
90} 81}
91 82
92static void __init check_hlt(void)
93{
94 if (boot_cpu_data.x86 >= 5 || paravirt_enabled())
95 return;
96
97 pr_info("Checking 'hlt' instruction... ");
98 if (!boot_cpu_data.hlt_works_ok) {
99 pr_cont("disabled\n");
100 return;
101 }
102 halt();
103 halt();
104 halt();
105 halt();
106 pr_cont("OK\n");
107}
108
109/* 83/*
110 * Check whether we are able to run this kernel safely on SMP. 84 * Check whether we are able to run this kernel safely on SMP.
111 * 85 *
@@ -129,7 +103,6 @@ void __init check_bugs(void)
129 print_cpu_info(&boot_cpu_data); 103 print_cpu_info(&boot_cpu_data);
130#endif 104#endif
131 check_config(); 105 check_config();
132 check_hlt();
133 init_utsname()->machine[1] = 106 init_utsname()->machine[1] =
134 '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86); 107 '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
135 alternative_instructions(); 108 alternative_instructions();
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index 3286a92e662a..e280253f6f94 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -28,7 +28,6 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)
28{ 28{
29 seq_printf(m, 29 seq_printf(m,
30 "fdiv_bug\t: %s\n" 30 "fdiv_bug\t: %s\n"
31 "hlt_bug\t\t: %s\n"
32 "f00f_bug\t: %s\n" 31 "f00f_bug\t: %s\n"
33 "coma_bug\t: %s\n" 32 "coma_bug\t: %s\n"
34 "fpu\t\t: %s\n" 33 "fpu\t\t: %s\n"
@@ -36,7 +35,6 @@ static void show_cpuinfo_misc(struct seq_file *m, struct cpuinfo_x86 *c)
36 "cpuid level\t: %d\n" 35 "cpuid level\t: %d\n"
37 "wp\t\t: %s\n", 36 "wp\t\t: %s\n",
38 c->fdiv_bug ? "yes" : "no", 37 c->fdiv_bug ? "yes" : "no",
39 c->hlt_works_ok ? "no" : "yes",
40 c->f00f_bug ? "yes" : "no", 38 c->f00f_bug ? "yes" : "no",
41 c->coma_bug ? "yes" : "no", 39 c->coma_bug ? "yes" : "no",
42 c->hard_math ? "yes" : "no", 40 c->hard_math ? "yes" : "no",
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 2ed787f15bf0..14ae10031ff0 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -268,13 +268,7 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,
268unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE; 268unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;
269EXPORT_SYMBOL(boot_option_idle_override); 269EXPORT_SYMBOL(boot_option_idle_override);
270 270
271/* 271static void (*x86_idle)(void);
272 * Powermanagement idle function, if any..
273 */
274void (*pm_idle)(void);
275#ifdef CONFIG_APM_MODULE
276EXPORT_SYMBOL(pm_idle);
277#endif
278 272
279#ifndef CONFIG_SMP 273#ifndef CONFIG_SMP
280static inline void play_dead(void) 274static inline void play_dead(void)
@@ -351,7 +345,7 @@ void cpu_idle(void)
351 rcu_idle_enter(); 345 rcu_idle_enter();
352 346
353 if (cpuidle_idle_call()) 347 if (cpuidle_idle_call())
354 pm_idle(); 348 x86_idle();
355 349
356 rcu_idle_exit(); 350 rcu_idle_exit();
357 start_critical_timings(); 351 start_critical_timings();
@@ -375,7 +369,6 @@ void cpu_idle(void)
375 */ 369 */
376void default_idle(void) 370void default_idle(void)
377{ 371{
378 trace_power_start_rcuidle(POWER_CSTATE, 1, smp_processor_id());
379 trace_cpu_idle_rcuidle(1, smp_processor_id()); 372 trace_cpu_idle_rcuidle(1, smp_processor_id());
380 current_thread_info()->status &= ~TS_POLLING; 373 current_thread_info()->status &= ~TS_POLLING;
381 /* 374 /*
@@ -389,21 +382,22 @@ void default_idle(void)
389 else 382 else
390 local_irq_enable(); 383 local_irq_enable();
391 current_thread_info()->status |= TS_POLLING; 384 current_thread_info()->status |= TS_POLLING;
392 trace_power_end_rcuidle(smp_processor_id());
393 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); 385 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
394} 386}
395#ifdef CONFIG_APM_MODULE 387#ifdef CONFIG_APM_MODULE
396EXPORT_SYMBOL(default_idle); 388EXPORT_SYMBOL(default_idle);
397#endif 389#endif
398 390
399bool set_pm_idle_to_default(void) 391#ifdef CONFIG_XEN
392bool xen_set_default_idle(void)
400{ 393{
401 bool ret = !!pm_idle; 394 bool ret = !!x86_idle;
402 395
403 pm_idle = default_idle; 396 x86_idle = default_idle;
404 397
405 return ret; 398 return ret;
406} 399}
400#endif
407void stop_this_cpu(void *dummy) 401void stop_this_cpu(void *dummy)
408{ 402{
409 local_irq_disable(); 403 local_irq_disable();
@@ -413,31 +407,8 @@ void stop_this_cpu(void *dummy)
413 set_cpu_online(smp_processor_id(), false); 407 set_cpu_online(smp_processor_id(), false);
414 disable_local_APIC(); 408 disable_local_APIC();
415 409
416 for (;;) { 410 for (;;)
417 if (hlt_works(smp_processor_id())) 411 halt();
418 halt();
419 }
420}
421
422/* Default MONITOR/MWAIT with no hints, used for default C1 state */
423static void mwait_idle(void)
424{
425 if (!need_resched()) {
426 trace_power_start_rcuidle(POWER_CSTATE, 1, smp_processor_id());
427 trace_cpu_idle_rcuidle(1, smp_processor_id());
428 if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR))
429 clflush((void *)&current_thread_info()->flags);
430
431 __monitor((void *)&current_thread_info()->flags, 0, 0);
432 smp_mb();
433 if (!need_resched())
434 __sti_mwait(0, 0);
435 else
436 local_irq_enable();
437 trace_power_end_rcuidle(smp_processor_id());
438 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
439 } else
440 local_irq_enable();
441} 412}
442 413
443/* 414/*
@@ -447,62 +418,13 @@ static void mwait_idle(void)
447 */ 418 */
448static void poll_idle(void) 419static void poll_idle(void)
449{ 420{
450 trace_power_start_rcuidle(POWER_CSTATE, 0, smp_processor_id());
451 trace_cpu_idle_rcuidle(0, smp_processor_id()); 421 trace_cpu_idle_rcuidle(0, smp_processor_id());
452 local_irq_enable(); 422 local_irq_enable();
453 while (!need_resched()) 423 while (!need_resched())
454 cpu_relax(); 424 cpu_relax();
455 trace_power_end_rcuidle(smp_processor_id());
456 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); 425 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
457} 426}
458 427
459/*
460 * mwait selection logic:
461 *
462 * It depends on the CPU. For AMD CPUs that support MWAIT this is
463 * wrong. Family 0x10 and 0x11 CPUs will enter C1 on HLT. Powersavings
464 * then depend on a clock divisor and current Pstate of the core. If
465 * all cores of a processor are in halt state (C1) the processor can
466 * enter the C1E (C1 enhanced) state. If mwait is used this will never
467 * happen.
468 *
469 * idle=mwait overrides this decision and forces the usage of mwait.
470 */
471
472#define MWAIT_INFO 0x05
473#define MWAIT_ECX_EXTENDED_INFO 0x01
474#define MWAIT_EDX_C1 0xf0
475
476int mwait_usable(const struct cpuinfo_x86 *c)
477{
478 u32 eax, ebx, ecx, edx;
479
480 /* Use mwait if idle=mwait boot option is given */
481 if (boot_option_idle_override == IDLE_FORCE_MWAIT)
482 return 1;
483
484 /*
485 * Any idle= boot option other than idle=mwait means that we must not
486 * use mwait. Eg: idle=halt or idle=poll or idle=nomwait
487 */
488 if (boot_option_idle_override != IDLE_NO_OVERRIDE)
489 return 0;
490
491 if (c->cpuid_level < MWAIT_INFO)
492 return 0;
493
494 cpuid(MWAIT_INFO, &eax, &ebx, &ecx, &edx);
495 /* Check, whether EDX has extended info about MWAIT */
496 if (!(ecx & MWAIT_ECX_EXTENDED_INFO))
497 return 1;
498
499 /*
500 * edx enumeratios MONITOR/MWAIT extensions. Check, whether
501 * C1 supports MWAIT
502 */
503 return (edx & MWAIT_EDX_C1);
504}
505
506bool amd_e400_c1e_detected; 428bool amd_e400_c1e_detected;
507EXPORT_SYMBOL(amd_e400_c1e_detected); 429EXPORT_SYMBOL(amd_e400_c1e_detected);
508 430
@@ -567,31 +489,24 @@ static void amd_e400_idle(void)
567void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) 489void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
568{ 490{
569#ifdef CONFIG_SMP 491#ifdef CONFIG_SMP
570 if (pm_idle == poll_idle && smp_num_siblings > 1) { 492 if (x86_idle == poll_idle && smp_num_siblings > 1)
571 pr_warn_once("WARNING: polling idle and HT enabled, performance may degrade\n"); 493 pr_warn_once("WARNING: polling idle and HT enabled, performance may degrade\n");
572 }
573#endif 494#endif
574 if (pm_idle) 495 if (x86_idle)
575 return; 496 return;
576 497
577 if (cpu_has(c, X86_FEATURE_MWAIT) && mwait_usable(c)) { 498 if (cpu_has_amd_erratum(amd_erratum_400)) {
578 /*
579 * One CPU supports mwait => All CPUs supports mwait
580 */
581 pr_info("using mwait in idle threads\n");
582 pm_idle = mwait_idle;
583 } else if (cpu_has_amd_erratum(amd_erratum_400)) {
584 /* E400: APIC timer interrupt does not wake up CPU from C1e */ 499 /* E400: APIC timer interrupt does not wake up CPU from C1e */
585 pr_info("using AMD E400 aware idle routine\n"); 500 pr_info("using AMD E400 aware idle routine\n");
586 pm_idle = amd_e400_idle; 501 x86_idle = amd_e400_idle;
587 } else 502 } else
588 pm_idle = default_idle; 503 x86_idle = default_idle;
589} 504}
590 505
591void __init init_amd_e400_c1e_mask(void) 506void __init init_amd_e400_c1e_mask(void)
592{ 507{
593 /* If we're using amd_e400_idle, we need to allocate amd_e400_c1e_mask. */ 508 /* If we're using amd_e400_idle, we need to allocate amd_e400_c1e_mask. */
594 if (pm_idle == amd_e400_idle) 509 if (x86_idle == amd_e400_idle)
595 zalloc_cpumask_var(&amd_e400_c1e_mask, GFP_KERNEL); 510 zalloc_cpumask_var(&amd_e400_c1e_mask, GFP_KERNEL);
596} 511}
597 512
@@ -602,11 +517,8 @@ static int __init idle_setup(char *str)
602 517
603 if (!strcmp(str, "poll")) { 518 if (!strcmp(str, "poll")) {
604 pr_info("using polling idle threads\n"); 519 pr_info("using polling idle threads\n");
605 pm_idle = poll_idle; 520 x86_idle = poll_idle;
606 boot_option_idle_override = IDLE_POLL; 521 boot_option_idle_override = IDLE_POLL;
607 } else if (!strcmp(str, "mwait")) {
608 boot_option_idle_override = IDLE_FORCE_MWAIT;
609 WARN_ONCE(1, "\"idle=mwait\" will be removed in 2012\n");
610 } else if (!strcmp(str, "halt")) { 522 } else if (!strcmp(str, "halt")) {
611 /* 523 /*
612 * When the boot option of idle=halt is added, halt is 524 * When the boot option of idle=halt is added, halt is
@@ -615,7 +527,7 @@ static int __init idle_setup(char *str)
615 * To continue to load the CPU idle driver, don't touch 527 * To continue to load the CPU idle driver, don't touch
616 * the boot_option_idle_override. 528 * the boot_option_idle_override.
617 */ 529 */
618 pm_idle = default_idle; 530 x86_idle = default_idle;
619 boot_option_idle_override = IDLE_HALT; 531 boot_option_idle_override = IDLE_HALT;
620 } else if (!strcmp(str, "nomwait")) { 532 } else if (!strcmp(str, "nomwait")) {
621 /* 533 /*
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index ed0fe385289d..a6ceaedc396a 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1369,7 +1369,7 @@ static inline void mwait_play_dead(void)
1369 void *mwait_ptr; 1369 void *mwait_ptr;
1370 struct cpuinfo_x86 *c = __this_cpu_ptr(&cpu_info); 1370 struct cpuinfo_x86 *c = __this_cpu_ptr(&cpu_info);
1371 1371
1372 if (!(this_cpu_has(X86_FEATURE_MWAIT) && mwait_usable(c))) 1372 if (!this_cpu_has(X86_FEATURE_MWAIT))
1373 return; 1373 return;
1374 if (!this_cpu_has(X86_FEATURE_CLFLSH)) 1374 if (!this_cpu_has(X86_FEATURE_CLFLSH))
1375 return; 1375 return;
diff --git a/arch/x86/platform/olpc/olpc-xo15-sci.c b/arch/x86/platform/olpc/olpc-xo15-sci.c
index 2fdca25905ae..fef7d0ba7e3a 100644
--- a/arch/x86/platform/olpc/olpc-xo15-sci.c
+++ b/arch/x86/platform/olpc/olpc-xo15-sci.c
@@ -195,7 +195,7 @@ err_sysfs:
195 return r; 195 return r;
196} 196}
197 197
198static int xo15_sci_remove(struct acpi_device *device, int type) 198static int xo15_sci_remove(struct acpi_device *device)
199{ 199{
200 acpi_disable_gpe(NULL, xo15_sci_gpe); 200 acpi_disable_gpe(NULL, xo15_sci_gpe);
201 acpi_remove_gpe_handler(NULL, xo15_sci_gpe, xo15_sci_gpe_handler); 201 acpi_remove_gpe_handler(NULL, xo15_sci_gpe, xo15_sci_gpe_handler);
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 8971a26d21ab..94eac5c85cdc 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -556,12 +556,9 @@ void __init xen_arch_setup(void)
556 COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE); 556 COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE);
557 557
558 /* Set up idle, making sure it calls safe_halt() pvop */ 558 /* Set up idle, making sure it calls safe_halt() pvop */
559#ifdef CONFIG_X86_32
560 boot_cpu_data.hlt_works_ok = 1;
561#endif
562 disable_cpuidle(); 559 disable_cpuidle();
563 disable_cpufreq(); 560 disable_cpufreq();
564 WARN_ON(set_pm_idle_to_default()); 561 WARN_ON(xen_set_default_idle());
565 fiddle_vdso(); 562 fiddle_vdso();
566#ifdef CONFIG_NUMA 563#ifdef CONFIG_NUMA
567 numa_off = 1; 564 numa_off = 1;
diff --git a/drivers/Kconfig b/drivers/Kconfig
index f5fb0722a63a..2b4e89ba15ad 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -134,6 +134,8 @@ source "drivers/hwspinlock/Kconfig"
134 134
135source "drivers/clocksource/Kconfig" 135source "drivers/clocksource/Kconfig"
136 136
137source "drivers/mailbox/Kconfig"
138
137source "drivers/iommu/Kconfig" 139source "drivers/iommu/Kconfig"
138 140
139source "drivers/remoteproc/Kconfig" 141source "drivers/remoteproc/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 7863b9fee50b..a8d32f1094b4 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -130,6 +130,7 @@ obj-y += platform/
130#common clk code 130#common clk code
131obj-y += clk/ 131obj-y += clk/
132 132
133obj-$(CONFIG_MAILBOX) += mailbox/
133obj-$(CONFIG_HWSPINLOCK) += hwspinlock/ 134obj-$(CONFIG_HWSPINLOCK) += hwspinlock/
134obj-$(CONFIG_NFC) += nfc/ 135obj-$(CONFIG_NFC) += nfc/
135obj-$(CONFIG_IOMMU_SUPPORT) += iommu/ 136obj-$(CONFIG_IOMMU_SUPPORT) += iommu/
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 38c5078da11d..78105b3a5262 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -337,7 +337,7 @@ config X86_PM_TIMER
337 systems require this timer. 337 systems require this timer.
338 338
339config ACPI_CONTAINER 339config ACPI_CONTAINER
340 tristate "Container and Module Devices (EXPERIMENTAL)" 340 bool "Container and Module Devices (EXPERIMENTAL)"
341 depends on EXPERIMENTAL 341 depends on EXPERIMENTAL
342 default (ACPI_HOTPLUG_MEMORY || ACPI_HOTPLUG_CPU || ACPI_HOTPLUG_IO) 342 default (ACPI_HOTPLUG_MEMORY || ACPI_HOTPLUG_CPU || ACPI_HOTPLUG_IO)
343 help 343 help
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 2a4502becd13..474fcfeba66c 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -37,7 +37,8 @@ acpi-y += resource.o
37acpi-y += processor_core.o 37acpi-y += processor_core.o
38acpi-y += ec.o 38acpi-y += ec.o
39acpi-$(CONFIG_ACPI_DOCK) += dock.o 39acpi-$(CONFIG_ACPI_DOCK) += dock.o
40acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o 40acpi-y += pci_root.o pci_link.o pci_irq.o
41acpi-y += csrt.o
41acpi-y += acpi_platform.o 42acpi-y += acpi_platform.o
42acpi-y += power.o 43acpi-y += power.o
43acpi-y += event.o 44acpi-y += event.o
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index d5fdd36190cc..6d5bf649196d 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -60,7 +60,7 @@ static int acpi_ac_open_fs(struct inode *inode, struct file *file);
60#endif 60#endif
61 61
62static int acpi_ac_add(struct acpi_device *device); 62static int acpi_ac_add(struct acpi_device *device);
63static int acpi_ac_remove(struct acpi_device *device, int type); 63static int acpi_ac_remove(struct acpi_device *device);
64static void acpi_ac_notify(struct acpi_device *device, u32 event); 64static void acpi_ac_notify(struct acpi_device *device, u32 event);
65 65
66static const struct acpi_device_id ac_device_ids[] = { 66static const struct acpi_device_id ac_device_ids[] = {
@@ -337,7 +337,7 @@ static int acpi_ac_resume(struct device *dev)
337} 337}
338#endif 338#endif
339 339
340static int acpi_ac_remove(struct acpi_device *device, int type) 340static int acpi_ac_remove(struct acpi_device *device)
341{ 341{
342 struct acpi_ac *ac = NULL; 342 struct acpi_ac *ac = NULL;
343 343
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index b679bf8478f7..034d3e72aa92 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL");
54#define MEMORY_POWER_OFF_STATE 2 54#define MEMORY_POWER_OFF_STATE 2
55 55
56static int acpi_memory_device_add(struct acpi_device *device); 56static int acpi_memory_device_add(struct acpi_device *device);
57static int acpi_memory_device_remove(struct acpi_device *device, int type); 57static int acpi_memory_device_remove(struct acpi_device *device);
58 58
59static const struct acpi_device_id memory_device_ids[] = { 59static const struct acpi_device_id memory_device_ids[] = {
60 {ACPI_MEMORY_DEVICE_HID, 0}, 60 {ACPI_MEMORY_DEVICE_HID, 0},
@@ -153,51 +153,46 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
153 return 0; 153 return 0;
154} 154}
155 155
156static int 156static int acpi_memory_get_device(acpi_handle handle,
157acpi_memory_get_device(acpi_handle handle, 157 struct acpi_memory_device **mem_device)
158 struct acpi_memory_device **mem_device)
159{ 158{
160 acpi_status status;
161 acpi_handle phandle;
162 struct acpi_device *device = NULL; 159 struct acpi_device *device = NULL;
163 struct acpi_device *pdevice = NULL; 160 int result = 0;
164 int result;
165 161
162 acpi_scan_lock_acquire();
166 163
167 if (!acpi_bus_get_device(handle, &device) && device) 164 acpi_bus_get_device(handle, &device);
165 if (device)
168 goto end; 166 goto end;
169 167
170 status = acpi_get_parent(handle, &phandle);
171 if (ACPI_FAILURE(status)) {
172 ACPI_EXCEPTION((AE_INFO, status, "Cannot find acpi parent"));
173 return -EINVAL;
174 }
175
176 /* Get the parent device */
177 result = acpi_bus_get_device(phandle, &pdevice);
178 if (result) {
179 acpi_handle_warn(phandle, "Cannot get acpi bus device\n");
180 return -EINVAL;
181 }
182
183 /* 168 /*
184 * Now add the notified device. This creates the acpi_device 169 * Now add the notified device. This creates the acpi_device
185 * and invokes .add function 170 * and invokes .add function
186 */ 171 */
187 result = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); 172 result = acpi_bus_scan(handle);
188 if (result) { 173 if (result) {
189 acpi_handle_warn(handle, "Cannot add acpi bus\n"); 174 acpi_handle_warn(handle, "ACPI namespace scan failed\n");
190 return -EINVAL; 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;
191 } 183 }
192 184
193 end: 185 end:
194 *mem_device = acpi_driver_data(device); 186 *mem_device = acpi_driver_data(device);
195 if (!(*mem_device)) { 187 if (!(*mem_device)) {
196 dev_err(&device->dev, "driver data not found\n"); 188 dev_err(&device->dev, "driver data not found\n");
197 return -ENODEV; 189 result = -ENODEV;
190 goto out;
198 } 191 }
199 192
200 return 0; 193 out:
194 acpi_scan_lock_release();
195 return result;
201} 196}
202 197
203static int acpi_memory_check_device(struct acpi_memory_device *mem_device) 198static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
@@ -317,6 +312,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
317 struct acpi_device *device; 312 struct acpi_device *device;
318 struct acpi_eject_event *ej_event = NULL; 313 struct acpi_eject_event *ej_event = NULL;
319 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ 314 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
315 acpi_status status;
320 316
321 switch (event) { 317 switch (event) {
322 case ACPI_NOTIFY_BUS_CHECK: 318 case ACPI_NOTIFY_BUS_CHECK:
@@ -339,29 +335,40 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
339 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 335 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
340 "\nReceived EJECT REQUEST notification for device\n")); 336 "\nReceived EJECT REQUEST notification for device\n"));
341 337
338 status = AE_ERROR;
339 acpi_scan_lock_acquire();
340
342 if (acpi_bus_get_device(handle, &device)) { 341 if (acpi_bus_get_device(handle, &device)) {
343 acpi_handle_err(handle, "Device doesn't exist\n"); 342 acpi_handle_err(handle, "Device doesn't exist\n");
344 break; 343 goto unlock;
345 } 344 }
346 mem_device = acpi_driver_data(device); 345 mem_device = acpi_driver_data(device);
347 if (!mem_device) { 346 if (!mem_device) {
348 acpi_handle_err(handle, "Driver Data is NULL\n"); 347 acpi_handle_err(handle, "Driver Data is NULL\n");
349 break; 348 goto unlock;
350 } 349 }
351 350
352 ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); 351 ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL);
353 if (!ej_event) { 352 if (!ej_event) {
354 pr_err(PREFIX "No memory, dropping EJECT\n"); 353 pr_err(PREFIX "No memory, dropping EJECT\n");
355 break; 354 goto unlock;
356 } 355 }
357 356
358 ej_event->handle = handle; 357 get_device(&device->dev);
358 ej_event->device = device;
359 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 359 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
360 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, 360 /* The eject is carried out asynchronously. */
361 (void *)ej_event); 361 status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
362 ej_event);
363 if (ACPI_FAILURE(status)) {
364 put_device(&device->dev);
365 kfree(ej_event);
366 }
362 367
363 /* eject is performed asynchronously */ 368 unlock:
364 return; 369 acpi_scan_lock_release();
370 if (ACPI_SUCCESS(status))
371 return;
365 default: 372 default:
366 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 373 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
367 "Unsupported event [0x%x]\n", event)); 374 "Unsupported event [0x%x]\n", event));
@@ -372,7 +379,6 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
372 379
373 /* Inform firmware that the hotplug operation has completed */ 380 /* Inform firmware that the hotplug operation has completed */
374 (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL); 381 (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL);
375 return;
376} 382}
377 383
378static void acpi_memory_device_free(struct acpi_memory_device *mem_device) 384static void acpi_memory_device_free(struct acpi_memory_device *mem_device)
@@ -427,7 +433,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
427 return result; 433 return result;
428} 434}
429 435
430static int acpi_memory_device_remove(struct acpi_device *device, int type) 436static int acpi_memory_device_remove(struct acpi_device *device)
431{ 437{
432 struct acpi_memory_device *mem_device = NULL; 438 struct acpi_memory_device *mem_device = NULL;
433 int result; 439 int result;
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 16fa979f7180..31de1043eea0 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -482,8 +482,7 @@ static int acpi_pad_add(struct acpi_device *device)
482 return 0; 482 return 0;
483} 483}
484 484
485static int acpi_pad_remove(struct acpi_device *device, 485static int acpi_pad_remove(struct acpi_device *device)
486 int type)
487{ 486{
488 mutex_lock(&isolated_cpus_lock); 487 mutex_lock(&isolated_cpus_lock);
489 acpi_pad_idle_cpus(0); 488 acpi_pad_idle_cpus(0);
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index db129b9f52cb..26fce4b8a632 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/acpi.h> 14#include <linux/acpi.h>
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/err.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17#include <linux/module.h> 18#include <linux/module.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
@@ -21,18 +22,59 @@
21 22
22ACPI_MODULE_NAME("platform"); 23ACPI_MODULE_NAME("platform");
23 24
25/* Flags for acpi_create_platform_device */
26#define ACPI_PLATFORM_CLK BIT(0)
27
28/*
29 * The following ACPI IDs are known to be suitable for representing as
30 * platform devices.
31 */
32static const struct acpi_device_id acpi_platform_device_ids[] = {
33
34 { "PNP0D40" },
35
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 { }
47};
48
49static 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
24/** 63/**
25 * acpi_create_platform_device - Create platform device for ACPI device node 64 * acpi_create_platform_device - Create platform device for ACPI device node
26 * @adev: ACPI device node to create a platform device for. 65 * @adev: ACPI device node to create a platform device for.
66 * @id: ACPI device ID used to match @adev.
27 * 67 *
28 * Check if the given @adev can be represented as a platform device and, if 68 * Check if the given @adev can be represented as a platform device and, if
29 * that's the case, create and register a platform device, populate its common 69 * that's the case, create and register a platform device, populate its common
30 * resources and returns a pointer to it. Otherwise, return %NULL. 70 * resources and returns a pointer to it. Otherwise, return %NULL.
31 * 71 *
32 * The platform device's name will be taken from the @adev's _HID and _UID. 72 * Name of the platform device will be the same as @adev's.
33 */ 73 */
34struct platform_device *acpi_create_platform_device(struct acpi_device *adev) 74static int acpi_create_platform_device(struct acpi_device *adev,
75 const struct acpi_device_id *id)
35{ 76{
77 unsigned long flags = id->driver_data;
36 struct platform_device *pdev = NULL; 78 struct platform_device *pdev = NULL;
37 struct acpi_device *acpi_parent; 79 struct acpi_device *acpi_parent;
38 struct platform_device_info pdevinfo; 80 struct platform_device_info pdevinfo;
@@ -41,20 +83,28 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
41 struct resource *resources; 83 struct resource *resources;
42 int count; 84 int count;
43 85
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
44 /* If the ACPI node already has a physical device attached, skip it. */ 94 /* If the ACPI node already has a physical device attached, skip it. */
45 if (adev->physical_node_count) 95 if (adev->physical_node_count)
46 return NULL; 96 return 0;
47 97
48 INIT_LIST_HEAD(&resource_list); 98 INIT_LIST_HEAD(&resource_list);
49 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); 99 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
50 if (count <= 0) 100 if (count <= 0)
51 return NULL; 101 return 0;
52 102
53 resources = kmalloc(count * sizeof(struct resource), GFP_KERNEL); 103 resources = kmalloc(count * sizeof(struct resource), GFP_KERNEL);
54 if (!resources) { 104 if (!resources) {
55 dev_err(&adev->dev, "No memory for resources\n"); 105 dev_err(&adev->dev, "No memory for resources\n");
56 acpi_dev_free_resource_list(&resource_list); 106 acpi_dev_free_resource_list(&resource_list);
57 return NULL; 107 return -ENOMEM;
58 } 108 }
59 count = 0; 109 count = 0;
60 list_for_each_entry(rentry, &resource_list, node) 110 list_for_each_entry(rentry, &resource_list, node)
@@ -100,5 +150,15 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
100 } 150 }
101 151
102 kfree(resources); 152 kfree(resources);
103 return pdev; 153 return 1;
154}
155
156static struct acpi_scan_handler platform_handler = {
157 .ids = acpi_platform_device_ids,
158 .attach = acpi_create_platform_device,
159};
160
161void __init acpi_platform_init(void)
162{
163 acpi_scan_add_handler(&platform_handler);
104} 164}
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index bc7a03ded064..a1b9bf5085a2 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -31,6 +31,7 @@ acpi-y += \
31 evgpeinit.o \ 31 evgpeinit.o \
32 evgpeutil.o \ 32 evgpeutil.o \
33 evglock.o \ 33 evglock.o \
34 evhandler.o \
34 evmisc.o \ 35 evmisc.o \
35 evregion.o \ 36 evregion.o \
36 evrgnini.o \ 37 evrgnini.o \
@@ -90,6 +91,7 @@ acpi-y += \
90 nsobject.o \ 91 nsobject.o \
91 nsparse.o \ 92 nsparse.o \
92 nspredef.o \ 93 nspredef.o \
94 nsprepkg.o \
93 nsrepair.o \ 95 nsrepair.o \
94 nsrepair2.o \ 96 nsrepair2.o \
95 nssearch.o \ 97 nssearch.o \
@@ -104,7 +106,9 @@ acpi-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
104acpi-y += \ 106acpi-y += \
105 psargs.o \ 107 psargs.o \
106 psloop.o \ 108 psloop.o \
109 psobject.o \
107 psopcode.o \ 110 psopcode.o \
111 psopinfo.o \
108 psparse.o \ 112 psparse.o \
109 psscope.o \ 113 psscope.o \
110 pstree.o \ 114 pstree.o \
@@ -126,7 +130,7 @@ acpi-y += \
126 rsutils.o \ 130 rsutils.o \
127 rsxface.o 131 rsxface.o
128 132
129acpi-$(ACPI_FUTURE_USAGE) += rsdump.o 133acpi-$(ACPI_FUTURE_USAGE) += rsdump.o rsdumpinfo.o
130 134
131acpi-y += \ 135acpi-y += \
132 tbfadt.o \ 136 tbfadt.o \
@@ -155,8 +159,10 @@ acpi-y += \
155 utmutex.o \ 159 utmutex.o \
156 utobject.o \ 160 utobject.o \
157 utosi.o \ 161 utosi.o \
162 utownerid.o \
158 utresrc.o \ 163 utresrc.o \
159 utstate.o \ 164 utstate.o \
165 utstring.o \
160 utxface.o \ 166 utxface.o \
161 utxfinit.o \ 167 utxfinit.o \
162 utxferror.o \ 168 utxferror.o \
diff --git a/drivers/acpi/acpica/accommon.h b/drivers/acpi/acpica/accommon.h
index 8a7d51bfb3b3..8a6c4a0d22db 100644
--- a/drivers/acpi/acpica/accommon.h
+++ b/drivers/acpi/acpica/accommon.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,7 @@
51 * 51 *
52 * Note: The order of these include files is important. 52 * Note: The order of these include files is important.
53 */ 53 */
54#include <acpi/acconfig.h> /* Global configuration constants */
54#include "acmacros.h" /* C macros */ 55#include "acmacros.h" /* C macros */
55#include "aclocal.h" /* Internal data types */ 56#include "aclocal.h" /* Internal data types */
56#include "acobject.h" /* ACPI internal object */ 57#include "acobject.h" /* ACPI internal object */
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index 432a318c9ed1..9feba08c29fe 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -115,6 +115,21 @@ ACPI_HW_DEPENDENT_RETURN_VOID(void
115 char *block_arg)) 115 char *block_arg))
116 116
117/* 117/*
118 * dbconvert - miscellaneous conversion routines
119 */
120 acpi_status acpi_db_hex_char_to_value(int hex_char, u8 *return_value);
121
122acpi_status acpi_db_convert_to_package(char *string, union acpi_object *object);
123
124acpi_status
125acpi_db_convert_to_object(acpi_object_type type,
126 char *string, union acpi_object *object);
127
128u8 *acpi_db_encode_pld_buffer(struct acpi_pld_info *pld_info);
129
130void acpi_db_dump_pld_buffer(union acpi_object *obj_desc);
131
132/*
118 * dbmethod - control method commands 133 * dbmethod - control method commands
119 */ 134 */
120void 135void
@@ -191,6 +206,8 @@ void
191acpi_db_create_execution_threads(char *num_threads_arg, 206acpi_db_create_execution_threads(char *num_threads_arg,
192 char *num_loops_arg, char *method_name_arg); 207 char *num_loops_arg, char *method_name_arg);
193 208
209void acpi_db_delete_objects(u32 count, union acpi_object *objects);
210
194#ifdef ACPI_DBG_TRACK_ALLOCATIONS 211#ifdef ACPI_DBG_TRACK_ALLOCATIONS
195u32 acpi_db_get_cache_info(struct acpi_memory_list *cache); 212u32 acpi_db_get_cache_info(struct acpi_memory_list *cache);
196#endif 213#endif
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
index ed33ebcdaebe..427db72a6302 100644
--- a/drivers/acpi/acpica/acdispat.h
+++ b/drivers/acpi/acpica/acdispat.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index e975c6720448..ab0e97710381 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -158,10 +158,23 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
158 void *context); 158 void *context);
159 159
160/* 160/*
161 * evregion - Address Space handling 161 * evhandler - Address space handling
162 */ 162 */
163u8
164acpi_ev_has_default_handler(struct acpi_namespace_node *node,
165 acpi_adr_space_type space_id);
166
163acpi_status acpi_ev_install_region_handlers(void); 167acpi_status acpi_ev_install_region_handlers(void);
164 168
169acpi_status
170acpi_ev_install_space_handler(struct acpi_namespace_node *node,
171 acpi_adr_space_type space_id,
172 acpi_adr_space_handler handler,
173 acpi_adr_space_setup setup, void *context);
174
175/*
176 * evregion - Operation region support
177 */
165acpi_status acpi_ev_initialize_op_regions(void); 178acpi_status acpi_ev_initialize_op_regions(void);
166 179
167acpi_status 180acpi_status
@@ -180,12 +193,6 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
180 u8 acpi_ns_is_locked); 193 u8 acpi_ns_is_locked);
181 194
182acpi_status 195acpi_status
183acpi_ev_install_space_handler(struct acpi_namespace_node *node,
184 acpi_adr_space_type space_id,
185 acpi_adr_space_handler handler,
186 acpi_adr_space_setup setup, void *context);
187
188acpi_status
189acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, 196acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
190 acpi_adr_space_type space_id); 197 acpi_adr_space_type space_id);
191 198
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 64472e4ec329..ecb49927b817 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -192,14 +192,6 @@ ACPI_EXTERN u8 acpi_gbl_integer_bit_width;
192ACPI_EXTERN u8 acpi_gbl_integer_byte_width; 192ACPI_EXTERN u8 acpi_gbl_integer_byte_width;
193ACPI_EXTERN u8 acpi_gbl_integer_nybble_width; 193ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
194 194
195/* Mutex for _OSI support */
196
197ACPI_EXTERN acpi_mutex acpi_gbl_osi_mutex;
198
199/* Reader/Writer lock is used for namespace walk and dynamic table unload */
200
201ACPI_EXTERN struct acpi_rw_lock acpi_gbl_namespace_rw_lock;
202
203/***************************************************************************** 195/*****************************************************************************
204 * 196 *
205 * Mutual exclusion within ACPICA subsystem 197 * Mutual exclusion within ACPICA subsystem
@@ -233,6 +225,14 @@ ACPI_EXTERN u8 acpi_gbl_global_lock_pending;
233ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */ 225ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock; /* For GPE data structs and registers */
234ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */ 226ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */
235 227
228/* Mutex for _OSI support */
229
230ACPI_EXTERN acpi_mutex acpi_gbl_osi_mutex;
231
232/* Reader/Writer lock is used for namespace walk and dynamic table unload */
233
234ACPI_EXTERN struct acpi_rw_lock acpi_gbl_namespace_rw_lock;
235
236/***************************************************************************** 236/*****************************************************************************
237 * 237 *
238 * Miscellaneous globals 238 * Miscellaneous globals
@@ -252,7 +252,7 @@ ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache;
252ACPI_EXTERN struct acpi_global_notify_handler acpi_gbl_global_notify[2]; 252ACPI_EXTERN struct acpi_global_notify_handler acpi_gbl_global_notify[2];
253ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler; 253ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
254ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler; 254ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
255ACPI_EXTERN acpi_tbl_handler acpi_gbl_table_handler; 255ACPI_EXTERN acpi_table_handler acpi_gbl_table_handler;
256ACPI_EXTERN void *acpi_gbl_table_handler_context; 256ACPI_EXTERN void *acpi_gbl_table_handler_context;
257ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk; 257ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
258ACPI_EXTERN acpi_interface_handler acpi_gbl_interface_handler; 258ACPI_EXTERN acpi_interface_handler acpi_gbl_interface_handler;
@@ -304,6 +304,7 @@ extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
304ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list; 304ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list;
305ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list; 305ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list;
306ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats; 306ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats;
307ACPI_EXTERN u8 acpi_gbl_disable_mem_tracking;
307#endif 308#endif
308 309
309/***************************************************************************** 310/*****************************************************************************
@@ -365,19 +366,18 @@ ACPI_EXTERN u8 acpi_gbl_sleep_type_b;
365 * 366 *
366 ****************************************************************************/ 367 ****************************************************************************/
367 368
368extern struct acpi_fixed_event_info
369 acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
370ACPI_EXTERN struct acpi_fixed_event_handler
371 acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
372ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
373ACPI_EXTERN struct acpi_gpe_block_info
374*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
375
376#if (!ACPI_REDUCED_HARDWARE) 369#if (!ACPI_REDUCED_HARDWARE)
377 370
378ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized; 371ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized;
372ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
373ACPI_EXTERN struct acpi_gpe_block_info
374 *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
379ACPI_EXTERN acpi_gbl_event_handler acpi_gbl_global_event_handler; 375ACPI_EXTERN acpi_gbl_event_handler acpi_gbl_global_event_handler;
380ACPI_EXTERN void *acpi_gbl_global_event_handler_context; 376ACPI_EXTERN void *acpi_gbl_global_event_handler_context;
377ACPI_EXTERN struct acpi_fixed_event_handler
378 acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
379extern struct acpi_fixed_event_info
380 acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
381 381
382#endif /* !ACPI_REDUCED_HARDWARE */ 382#endif /* !ACPI_REDUCED_HARDWARE */
383 383
@@ -405,7 +405,7 @@ ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer;
405 405
406/***************************************************************************** 406/*****************************************************************************
407 * 407 *
408 * Debugger globals 408 * Debugger and Disassembler globals
409 * 409 *
410 ****************************************************************************/ 410 ****************************************************************************/
411 411
@@ -413,8 +413,12 @@ ACPI_EXTERN u8 acpi_gbl_db_output_flags;
413 413
414#ifdef ACPI_DISASSEMBLER 414#ifdef ACPI_DISASSEMBLER
415 415
416u8 ACPI_INIT_GLOBAL(acpi_gbl_ignore_noop_operator, FALSE);
417
416ACPI_EXTERN u8 acpi_gbl_db_opt_disasm; 418ACPI_EXTERN u8 acpi_gbl_db_opt_disasm;
417ACPI_EXTERN u8 acpi_gbl_db_opt_verbose; 419ACPI_EXTERN u8 acpi_gbl_db_opt_verbose;
420ACPI_EXTERN struct acpi_external_list *acpi_gbl_external_list;
421ACPI_EXTERN struct acpi_external_file *acpi_gbl_external_file_list;
418#endif 422#endif
419 423
420#ifdef ACPI_DEBUGGER 424#ifdef ACPI_DEBUGGER
@@ -426,6 +430,7 @@ extern u8 acpi_gbl_db_terminate_threads;
426ACPI_EXTERN u8 acpi_gbl_db_opt_tables; 430ACPI_EXTERN u8 acpi_gbl_db_opt_tables;
427ACPI_EXTERN u8 acpi_gbl_db_opt_stats; 431ACPI_EXTERN u8 acpi_gbl_db_opt_stats;
428ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods; 432ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods;
433ACPI_EXTERN u8 acpi_gbl_db_opt_no_region_support;
429 434
430ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS]; 435ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS];
431ACPI_EXTERN acpi_object_type acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS]; 436ACPI_EXTERN acpi_object_type acpi_gbl_db_arg_types[ACPI_DEBUGGER_MAX_ARGS];
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index d902d31abc6c..6357e932bfd9 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
index eb308635da72..8af8c9bdeb35 100644
--- a/drivers/acpi/acpica/acinterp.h
+++ b/drivers/acpi/acpica/acinterp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -458,7 +458,7 @@ void acpi_ex_reacquire_interpreter(void);
458 458
459void acpi_ex_relinquish_interpreter(void); 459void acpi_ex_relinquish_interpreter(void);
460 460
461void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc); 461u8 acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc);
462 462
463void acpi_ex_acquire_global_lock(u32 rule); 463void acpi_ex_acquire_global_lock(u32 rule);
464 464
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index ff8bd0061e8b..805f419086ab 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -189,11 +189,10 @@ struct acpi_namespace_node {
189#define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */ 189#define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */
190#define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (install_method) */ 190#define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (install_method) */
191 191
192#define ANOBJ_IS_EXTERNAL 0x08 /* i_aSL only: This object created via External() */ 192#define ANOBJ_IS_EXTERNAL 0x08 /* iASL only: This object created via External() */
193#define ANOBJ_METHOD_NO_RETVAL 0x10 /* i_aSL only: Method has no return value */ 193#define ANOBJ_METHOD_NO_RETVAL 0x10 /* iASL only: Method has no return value */
194#define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* i_aSL only: Method has at least one return value */ 194#define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* iASL only: Method has at least one return value */
195#define ANOBJ_IS_BIT_OFFSET 0x40 /* i_aSL only: Reference is a bit offset */ 195#define ANOBJ_IS_REFERENCED 0x80 /* iASL only: Object was referenced */
196#define ANOBJ_IS_REFERENCED 0x80 /* i_aSL only: Object was referenced */
197 196
198/* Internal ACPI table management - master table list */ 197/* Internal ACPI table management - master table list */
199 198
@@ -411,11 +410,10 @@ struct acpi_gpe_notify_info {
411 struct acpi_gpe_notify_info *next; 410 struct acpi_gpe_notify_info *next;
412}; 411};
413 412
414struct acpi_gpe_notify_object { 413/*
415 struct acpi_namespace_node *node; 414 * GPE dispatch info. At any time, the GPE can have at most one type
416 struct acpi_gpe_notify_object *next; 415 * of dispatch - Method, Handler, or Implicit Notify.
417}; 416 */
418
419union acpi_gpe_dispatch_info { 417union acpi_gpe_dispatch_info {
420 struct acpi_namespace_node *method_node; /* Method node for this GPE level */ 418 struct acpi_namespace_node *method_node; /* Method node for this GPE level */
421 struct acpi_gpe_handler_info *handler; /* Installed GPE handler */ 419 struct acpi_gpe_handler_info *handler; /* Installed GPE handler */
@@ -679,6 +677,8 @@ struct acpi_opcode_info {
679 u8 type; /* Opcode type */ 677 u8 type; /* Opcode type */
680}; 678};
681 679
680/* Value associated with the parse object */
681
682union acpi_parse_value { 682union acpi_parse_value {
683 u64 integer; /* Integer constant (Up to 64 bits) */ 683 u64 integer; /* Integer constant (Up to 64 bits) */
684 u32 size; /* bytelist or field size */ 684 u32 size; /* bytelist or field size */
@@ -1025,6 +1025,31 @@ struct acpi_port_info {
1025 1025
1026/***************************************************************************** 1026/*****************************************************************************
1027 * 1027 *
1028 * Disassembler
1029 *
1030 ****************************************************************************/
1031
1032struct acpi_external_list {
1033 char *path;
1034 char *internal_path;
1035 struct acpi_external_list *next;
1036 u32 value;
1037 u16 length;
1038 u8 type;
1039 u8 flags;
1040};
1041
1042/* Values for Flags field above */
1043
1044#define ACPI_IPATH_ALLOCATED 0x01
1045
1046struct acpi_external_file {
1047 char *path;
1048 struct acpi_external_file *next;
1049};
1050
1051/*****************************************************************************
1052 *
1028 * Debugger 1053 * Debugger
1029 * 1054 *
1030 ****************************************************************************/ 1055 ****************************************************************************/
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 5efad99f2169..ed7943b9044f 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -49,14 +49,18 @@
49 * get into potential aligment issues -- see the STORE macros below. 49 * get into potential aligment issues -- see the STORE macros below.
50 * Use with care. 50 * Use with care.
51 */ 51 */
52#define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr) 52#define ACPI_CAST8(ptr) ACPI_CAST_PTR (u8, (ptr))
53#define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr) 53#define ACPI_CAST16(ptr) ACPI_CAST_PTR (u16, (ptr))
54#define ACPI_GET32(ptr) *ACPI_CAST_PTR (u32, ptr) 54#define ACPI_CAST32(ptr) ACPI_CAST_PTR (u32, (ptr))
55#define ACPI_GET64(ptr) *ACPI_CAST_PTR (u64, ptr) 55#define ACPI_CAST64(ptr) ACPI_CAST_PTR (u64, (ptr))
56#define ACPI_SET8(ptr) *ACPI_CAST_PTR (u8, ptr) 56#define ACPI_GET8(ptr) (*ACPI_CAST8 (ptr))
57#define ACPI_SET16(ptr) *ACPI_CAST_PTR (u16, ptr) 57#define ACPI_GET16(ptr) (*ACPI_CAST16 (ptr))
58#define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr) 58#define ACPI_GET32(ptr) (*ACPI_CAST32 (ptr))
59#define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr) 59#define ACPI_GET64(ptr) (*ACPI_CAST64 (ptr))
60#define ACPI_SET8(ptr, val) (*ACPI_CAST8 (ptr) = (u8) (val))
61#define ACPI_SET16(ptr, val) (*ACPI_CAST16 (ptr) = (u16) (val))
62#define ACPI_SET32(ptr, val) (*ACPI_CAST32 (ptr) = (u32) (val))
63#define ACPI_SET64(ptr, val) (*ACPI_CAST64 (ptr) = (u64) (val))
60 64
61/* 65/*
62 * printf() format helpers 66 * printf() format helpers
@@ -293,6 +297,26 @@
293#define ACPI_16BIT_MASK 0x0000FFFF 297#define ACPI_16BIT_MASK 0x0000FFFF
294#define ACPI_24BIT_MASK 0x00FFFFFF 298#define ACPI_24BIT_MASK 0x00FFFFFF
295 299
300/* Macros to extract flag bits from position zero */
301
302#define ACPI_GET_1BIT_FLAG(value) ((value) & ACPI_1BIT_MASK)
303#define ACPI_GET_2BIT_FLAG(value) ((value) & ACPI_2BIT_MASK)
304#define ACPI_GET_3BIT_FLAG(value) ((value) & ACPI_3BIT_MASK)
305#define ACPI_GET_4BIT_FLAG(value) ((value) & ACPI_4BIT_MASK)
306
307/* Macros to extract flag bits from position one and above */
308
309#define ACPI_EXTRACT_1BIT_FLAG(field, position) (ACPI_GET_1BIT_FLAG ((field) >> position))
310#define ACPI_EXTRACT_2BIT_FLAG(field, position) (ACPI_GET_2BIT_FLAG ((field) >> position))
311#define ACPI_EXTRACT_3BIT_FLAG(field, position) (ACPI_GET_3BIT_FLAG ((field) >> position))
312#define ACPI_EXTRACT_4BIT_FLAG(field, position) (ACPI_GET_4BIT_FLAG ((field) >> position))
313
314/* ACPI Pathname helpers */
315
316#define ACPI_IS_ROOT_PREFIX(c) ((c) == (u8) 0x5C) /* Backslash */
317#define ACPI_IS_PARENT_PREFIX(c) ((c) == (u8) 0x5E) /* Carat */
318#define ACPI_IS_PATH_SEPARATOR(c) ((c) == (u8) 0x2E) /* Period (dot) */
319
296/* 320/*
297 * An object of type struct acpi_namespace_node can appear in some contexts 321 * An object of type struct acpi_namespace_node can appear in some contexts
298 * 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
@@ -364,137 +388,6 @@
364 388
365#endif /* ACPI_NO_ERROR_MESSAGES */ 389#endif /* ACPI_NO_ERROR_MESSAGES */
366 390
367/*
368 * Debug macros that are conditionally compiled
369 */
370#ifdef ACPI_DEBUG_OUTPUT
371/*
372 * Function entry tracing
373 */
374#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
375 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
376#define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \
377 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS, (void *)b)
378#define ACPI_FUNCTION_TRACE_U32(a, b) ACPI_FUNCTION_NAME(a) \
379 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS, (u32)b)
380#define ACPI_FUNCTION_TRACE_STR(a, b) ACPI_FUNCTION_NAME(a) \
381 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS, (char *)b)
382
383#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr()
384
385/*
386 * Function exit tracing.
387 * WARNING: These macros include a return statement. This is usually considered
388 * bad form, but having a separate exit macro is very ugly and difficult to maintain.
389 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
390 * so that "_AcpiFunctionName" is defined.
391 *
392 * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining
393 * about these constructs.
394 */
395#ifdef ACPI_USE_DO_WHILE_0
396#define ACPI_DO_WHILE0(a) do a while(0)
397#else
398#define ACPI_DO_WHILE0(a) a
399#endif
400
401#define return_VOID ACPI_DO_WHILE0 ({ \
402 acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \
403 return;})
404/*
405 * There are two versions of most of the return macros. The default version is
406 * safer, since it avoids side-effects by guaranteeing that the argument will
407 * not be evaluated twice.
408 *
409 * A less-safe version of the macros is provided for optional use if the
410 * compiler uses excessive CPU stack (for example, this may happen in the
411 * debug case if code optimzation is disabled.)
412 */
413#ifndef ACPI_SIMPLE_RETURN_MACROS
414
415#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \
416 register acpi_status _s = (s); \
417 acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, _s); \
418 return (_s); })
419#define return_PTR(s) ACPI_DO_WHILE0 ({ \
420 register void *_s = (void *) (s); \
421 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \
422 return (_s); })
423#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
424 register u64 _s = (s); \
425 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \
426 return (_s); })
427#define return_UINT8(s) ACPI_DO_WHILE0 ({ \
428 register u8 _s = (u8) (s); \
429 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _s); \
430 return (_s); })
431#define return_UINT32(s) ACPI_DO_WHILE0 ({ \
432 register u32 _s = (u32) (s); \
433 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _s); \
434 return (_s); })
435#else /* Use original less-safe macros */
436
437#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \
438 acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, (s)); \
439 return((s)); })
440#define return_PTR(s) ACPI_DO_WHILE0 ({ \
441 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \
442 return((s)); })
443#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
444 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) (s)); \
445 return((s)); })
446#define return_UINT8(s) return_VALUE(s)
447#define return_UINT32(s) return_VALUE(s)
448
449#endif /* ACPI_SIMPLE_RETURN_MACROS */
450
451/* Conditional execution */
452
453#define ACPI_DEBUG_EXEC(a) a
454#define ACPI_DEBUG_ONLY_MEMBERS(a) a;
455#define _VERBOSE_STRUCTURES
456
457/* Various object display routines for debug */
458
459#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0)
460#define ACPI_DUMP_OPERANDS(a, b ,c) acpi_ex_dump_operands(a, b, c)
461#define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b)
462#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d)
463#define ACPI_DUMP_BUFFER(a, b) acpi_ut_debug_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
464
465#else
466/*
467 * This is the non-debug case -- make everything go away,
468 * leaving no executable debug code!
469 */
470#define ACPI_DEBUG_EXEC(a)
471#define ACPI_DEBUG_ONLY_MEMBERS(a)
472#define ACPI_FUNCTION_TRACE(a)
473#define ACPI_FUNCTION_TRACE_PTR(a, b)
474#define ACPI_FUNCTION_TRACE_U32(a, b)
475#define ACPI_FUNCTION_TRACE_STR(a, b)
476#define ACPI_FUNCTION_EXIT
477#define ACPI_FUNCTION_STATUS_EXIT(s)
478#define ACPI_FUNCTION_VALUE_EXIT(s)
479#define ACPI_FUNCTION_ENTRY()
480#define ACPI_DUMP_STACK_ENTRY(a)
481#define ACPI_DUMP_OPERANDS(a, b, c)
482#define ACPI_DUMP_ENTRY(a, b)
483#define ACPI_DUMP_TABLES(a, b)
484#define ACPI_DUMP_PATHNAME(a, b, c, d)
485#define ACPI_DUMP_BUFFER(a, b)
486#define ACPI_DEBUG_PRINT(pl)
487#define ACPI_DEBUG_PRINT_RAW(pl)
488
489#define return_VOID return
490#define return_ACPI_STATUS(s) return(s)
491#define return_VALUE(s) return(s)
492#define return_UINT8(s) return(s)
493#define return_UINT32(s) return(s)
494#define return_PTR(s) return(s)
495
496#endif /* ACPI_DEBUG_OUTPUT */
497
498#if (!ACPI_REDUCED_HARDWARE) 391#if (!ACPI_REDUCED_HARDWARE)
499#define ACPI_HW_OPTIONAL_FUNCTION(addr) addr 392#define ACPI_HW_OPTIONAL_FUNCTION(addr) addr
500#else 393#else
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index 9b19d4b86424..02cd5482ff8b 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -218,6 +218,18 @@ acpi_ns_check_parameter_count(char *pathname,
218 u32 user_param_count, 218 u32 user_param_count,
219 const union acpi_predefined_info *info); 219 const union acpi_predefined_info *info);
220 220
221acpi_status
222acpi_ns_check_object_type(struct acpi_predefined_data *data,
223 union acpi_operand_object **return_object_ptr,
224 u32 expected_btypes, u32 package_index);
225
226/*
227 * nsprepkg - Validation of predefined name packages
228 */
229acpi_status
230acpi_ns_check_package(struct acpi_predefined_data *data,
231 union acpi_operand_object **return_object_ptr);
232
221/* 233/*
222 * nsnames - Name and Scope manipulation 234 * nsnames - Name and Scope manipulation
223 */ 235 */
@@ -333,8 +345,6 @@ acpi_ns_install_node(struct acpi_walk_state *walk_state,
333/* 345/*
334 * nsutils - Utility functions 346 * nsutils - Utility functions
335 */ 347 */
336u8 acpi_ns_valid_root_prefix(char prefix);
337
338acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node); 348acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node);
339 349
340u32 acpi_ns_local(acpi_object_type type); 350u32 acpi_ns_local(acpi_object_type type);
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index 24eb9eac9514..cc7ab6dd724e 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -307,7 +307,7 @@ struct acpi_object_addr_handler {
307 struct acpi_namespace_node *node; /* Parent device */ 307 struct acpi_namespace_node *node; /* Parent device */
308 void *context; 308 void *context;
309 acpi_adr_space_setup setup; 309 acpi_adr_space_setup setup;
310 union acpi_operand_object *region_list; /* regions using this handler */ 310 union acpi_operand_object *region_list; /* Regions using this handler */
311 union acpi_operand_object *next; 311 union acpi_operand_object *next;
312}; 312};
313 313
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
index d786a5128b78..3fc9ca7e8aa3 100644
--- a/drivers/acpi/acpica/acopcode.h
+++ b/drivers/acpi/acpica/acopcode.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h
index eefcf47a61a0..aed319318835 100644
--- a/drivers/acpi/acpica/acparser.h
+++ b/drivers/acpi/acpica/acparser.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -105,7 +105,28 @@ union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope,
105union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op); 105union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op);
106 106
107/* 107/*
108 * psopcode - AML Opcode information 108 * psobject - support for parse object processing
109 */
110acpi_status
111acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
112 u8 *aml_op_start,
113 union acpi_parse_object *unnamed_op,
114 union acpi_parse_object **op);
115
116acpi_status
117acpi_ps_create_op(struct acpi_walk_state *walk_state,
118 u8 *aml_op_start, union acpi_parse_object **new_op);
119
120acpi_status
121acpi_ps_complete_op(struct acpi_walk_state *walk_state,
122 union acpi_parse_object **op, acpi_status status);
123
124acpi_status
125acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
126 union acpi_parse_object *op, acpi_status status);
127
128/*
129 * psopinfo - AML Opcode information
109 */ 130 */
110const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode); 131const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode);
111 132
@@ -211,8 +232,6 @@ void acpi_ps_free_op(union acpi_parse_object *op);
211 232
212u8 acpi_ps_is_leading_char(u32 c); 233u8 acpi_ps_is_leading_char(u32 c);
213 234
214u8 acpi_ps_is_prefix_char(u32 c);
215
216#ifdef ACPI_FUTURE_USAGE 235#ifdef ACPI_FUTURE_USAGE
217u32 acpi_ps_get_name(union acpi_parse_object *op); 236u32 acpi_ps_get_name(union acpi_parse_object *op);
218#endif /* ACPI_FUTURE_USAGE */ 237#endif /* ACPI_FUTURE_USAGE */
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index 9dfa1c83bd4e..752cc40cdc1e 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -1,12 +1,11 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Name: acpredef - Information table for ACPI predefined methods and objects 3 * Name: acpredef - Information table for ACPI predefined methods and objects
4 * $Revision: 1.1 $
5 * 4 *
6 *****************************************************************************/ 5 *****************************************************************************/
7 6
8/* 7/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 9 * All rights reserved.
11 * 10 *
12 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,13 +50,13 @@
51 * 50 *
52 * 1) PTYPE1 packages do not contain sub-packages. 51 * 1) PTYPE1 packages do not contain sub-packages.
53 * 52 *
54 * ACPI_PTYPE1_FIXED: Fixed length, 1 or 2 object types: 53 * ACPI_PTYPE1_FIXED: Fixed-length length, 1 or 2 object types:
55 * object type 54 * object type
56 * count 55 * count
57 * object type 56 * object type
58 * count 57 * count
59 * 58 *
60 * ACPI_PTYPE1_VAR: Variable length: 59 * ACPI_PTYPE1_VAR: Variable-length length:
61 * object type (Int/Buf/Ref) 60 * object type (Int/Buf/Ref)
62 * 61 *
63 * ACPI_PTYPE1_OPTION: Package has some required and some optional elements 62 * ACPI_PTYPE1_OPTION: Package has some required and some optional elements
@@ -85,10 +84,10 @@
85 * count 84 * count
86 * (Used for _CST) 85 * (Used for _CST)
87 * 86 *
88 * ACPI_PTYPE2_FIXED: Each subpackage is of fixed length 87 * ACPI_PTYPE2_FIXED: Each subpackage is of Fixed-length
89 * (Used for _PRT) 88 * (Used for _PRT)
90 * 89 *
91 * ACPI_PTYPE2_MIN: Each subpackage has a variable but minimum length 90 * ACPI_PTYPE2_MIN: Each subpackage has a Variable-length but minimum length
92 * (Used for _HPX) 91 * (Used for _HPX)
93 * 92 *
94 * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length 93 * ACPI_PTYPE2_REV_FIXED: Revision at start, each subpackage is Fixed-length
@@ -124,7 +123,8 @@ enum acpi_return_package_types {
124 * These are the names that can actually be evaluated via acpi_evaluate_object. 123 * These are the names that can actually be evaluated via acpi_evaluate_object.
125 * Not present in this table are the following: 124 * Not present in this table are the following:
126 * 125 *
127 * 1) Predefined/Reserved names that are never evaluated via acpi_evaluate_object: 126 * 1) Predefined/Reserved names that are never evaluated via
127 * acpi_evaluate_object:
128 * _Lxx and _Exx GPE methods 128 * _Lxx and _Exx GPE methods
129 * _Qxx EC methods 129 * _Qxx EC methods
130 * _T_x compiler temporary variables 130 * _T_x compiler temporary variables
@@ -149,6 +149,8 @@ enum acpi_return_package_types {
149 * information about the expected structure of the package. This information 149 * information about the expected structure of the package. This information
150 * is saved here (rather than in a separate table) in order to minimize the 150 * is saved here (rather than in a separate table) in order to minimize the
151 * overall size of the stored data. 151 * overall size of the stored data.
152 *
153 * Note: The additional braces are intended to promote portability.
152 */ 154 */
153static const union acpi_predefined_info predefined_names[] = { 155static const union acpi_predefined_info predefined_names[] = {
154 {{"_AC0", 0, ACPI_RTYPE_INTEGER}}, 156 {{"_AC0", 0, ACPI_RTYPE_INTEGER}},
@@ -212,9 +214,8 @@ static const union acpi_predefined_info predefined_names[] = {
212 {{"_BCT", 1, ACPI_RTYPE_INTEGER}}, 214 {{"_BCT", 1, ACPI_RTYPE_INTEGER}},
213 {{"_BDN", 0, ACPI_RTYPE_INTEGER}}, 215 {{"_BDN", 0, ACPI_RTYPE_INTEGER}},
214 {{"_BFS", 1, 0}}, 216 {{"_BFS", 1, 0}},
215 {{"_BIF", 0, ACPI_RTYPE_PACKAGE} }, /* Fixed-length (9 Int),(4 Str/Buf) */ 217 {{"_BIF", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (9 Int),(4 Str) */
216 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 9, 218 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 9, ACPI_RTYPE_STRING}, 4, 0}},
217 ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER}, 4, 0} },
218 219
219 {{"_BIX", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int),(4 Str) */ 220 {{"_BIX", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int),(4 Str) */
220 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING}, 4, 221 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, ACPI_RTYPE_STRING}, 4,
@@ -236,7 +237,8 @@ static const union acpi_predefined_info predefined_names[] = {
236 {{"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* See PCI firmware spec 3.0 */ 237 {{"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* See PCI firmware spec 3.0 */
237 {{"_CDM", 0, ACPI_RTYPE_INTEGER}}, 238 {{"_CDM", 0, ACPI_RTYPE_INTEGER}},
238 {{"_CID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Strs) */ 239 {{"_CID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints/Strs) */
239 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0,0}, 0,0}}, 240 {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0, 0}, 0,
241 0}},
240 242
241 {{"_CLS", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int) */ 243 {{"_CLS", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (3 Int) */
242 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, 0}, 0, 0}}, 244 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 3, 0}, 0, 0}},
@@ -251,7 +253,8 @@ static const union acpi_predefined_info predefined_names[] = {
251 {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, 253 {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0,0}, 0,0}},
252 254
253 {{"_CST", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */ 255 {{"_CST", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */
254 {{{ACPI_PTYPE2_PKG_COUNT,ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER}, 3,0}}, 256 {{{ACPI_PTYPE2_PKG_COUNT, ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER}, 3,
257 0}},
255 258
256 {{"_CWS", 1, ACPI_RTYPE_INTEGER}}, 259 {{"_CWS", 1, ACPI_RTYPE_INTEGER}},
257 {{"_DCK", 1, ACPI_RTYPE_INTEGER}}, 260 {{"_DCK", 1, ACPI_RTYPE_INTEGER}},
@@ -342,8 +345,8 @@ static const union acpi_predefined_info predefined_names[] = {
342 {{"_MBM", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (8 Int) */ 345 {{"_MBM", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (8 Int) */
343 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 8, 0}, 0, 0}}, 346 {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 8, 0}, 0, 0}},
344 347
345 {{"_MLS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (2 Str) */ 348 {{"_MLS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (1 Str/1 Buf) */
346 {{{ACPI_PTYPE2, ACPI_RTYPE_STRING, 2,0}, 0,0}}, 349 {{{ACPI_PTYPE2, ACPI_RTYPE_STRING, 1, ACPI_RTYPE_BUFFER}, 1, 0}},
347 350
348 {{"_MSG", 1, 0}}, 351 {{"_MSG", 1, 0}},
349 {{"_MSM", 4, ACPI_RTYPE_INTEGER}}, 352 {{"_MSM", 4, ACPI_RTYPE_INTEGER}},
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h
index 0347d0993497..f691d0e4d9fa 100644
--- a/drivers/acpi/acpica/acresrc.h
+++ b/drivers/acpi/acpica/acresrc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -347,18 +347,21 @@ extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
347extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[]; 347extern struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[];
348 348
349/* 349/*
350 * rsdump 350 * rsdumpinfo
351 */ 351 */
352extern struct acpi_rsdump_info acpi_rs_dump_irq[]; 352extern struct acpi_rsdump_info acpi_rs_dump_irq[];
353extern struct acpi_rsdump_info acpi_rs_dump_prt[];
353extern struct acpi_rsdump_info acpi_rs_dump_dma[]; 354extern struct acpi_rsdump_info acpi_rs_dump_dma[];
354extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[]; 355extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[];
355extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[]; 356extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[];
356extern struct acpi_rsdump_info acpi_rs_dump_io[]; 357extern struct acpi_rsdump_info acpi_rs_dump_io[];
358extern struct acpi_rsdump_info acpi_rs_dump_io_flags[];
357extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[]; 359extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[];
358extern struct acpi_rsdump_info acpi_rs_dump_vendor[]; 360extern struct acpi_rsdump_info acpi_rs_dump_vendor[];
359extern struct acpi_rsdump_info acpi_rs_dump_end_tag[]; 361extern struct acpi_rsdump_info acpi_rs_dump_end_tag[];
360extern struct acpi_rsdump_info acpi_rs_dump_memory24[]; 362extern struct acpi_rsdump_info acpi_rs_dump_memory24[];
361extern struct acpi_rsdump_info acpi_rs_dump_memory32[]; 363extern struct acpi_rsdump_info acpi_rs_dump_memory32[];
364extern struct acpi_rsdump_info acpi_rs_dump_memory_flags[];
362extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[]; 365extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[];
363extern struct acpi_rsdump_info acpi_rs_dump_address16[]; 366extern struct acpi_rsdump_info acpi_rs_dump_address16[];
364extern struct acpi_rsdump_info acpi_rs_dump_address32[]; 367extern struct acpi_rsdump_info acpi_rs_dump_address32[];
@@ -372,6 +375,7 @@ extern struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[];
372extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[]; 375extern struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[];
373extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[]; 376extern struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[];
374extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[]; 377extern struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[];
378extern struct acpi_rsdump_info acpi_rs_dump_general_flags[];
375#endif 379#endif
376 380
377#endif /* __ACRESRC_H__ */ 381#endif /* __ACRESRC_H__ */
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
index 937e66c65d1e..7896d85876ca 100644
--- a/drivers/acpi/acpica/acstruct.h
+++ b/drivers/acpi/acpica/acstruct.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 6712965ba8ae..7755e915a007 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index b0f5f92b674a..0082fa0a6139 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -483,39 +483,17 @@ acpi_ut_short_divide(u64 in_dividend,
483/* 483/*
484 * utmisc 484 * utmisc
485 */ 485 */
486void ut_convert_backslashes(char *pathname);
487
488const char *acpi_ut_validate_exception(acpi_status status); 486const char *acpi_ut_validate_exception(acpi_status status);
489 487
490u8 acpi_ut_is_pci_root_bridge(char *id); 488u8 acpi_ut_is_pci_root_bridge(char *id);
491 489
492u8 acpi_ut_is_aml_table(struct acpi_table_header *table); 490u8 acpi_ut_is_aml_table(struct acpi_table_header *table);
493 491
494acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id);
495
496void acpi_ut_release_owner_id(acpi_owner_id * owner_id);
497
498acpi_status 492acpi_status
499acpi_ut_walk_package_tree(union acpi_operand_object *source_object, 493acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
500 void *target_object, 494 void *target_object,
501 acpi_pkg_callback walk_callback, void *context); 495 acpi_pkg_callback walk_callback, void *context);
502 496
503void acpi_ut_strupr(char *src_string);
504
505void acpi_ut_strlwr(char *src_string);
506
507int acpi_ut_stricmp(char *string1, char *string2);
508
509void acpi_ut_print_string(char *string, u8 max_length);
510
511u8 acpi_ut_valid_acpi_name(u32 name);
512
513void acpi_ut_repair_name(char *name);
514
515u8 acpi_ut_valid_acpi_char(char character, u32 position);
516
517acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer);
518
519/* Values for Base above (16=Hex, 10=Decimal) */ 497/* Values for Base above (16=Hex, 10=Decimal) */
520 498
521#define ACPI_ANY_BASE 0 499#define ACPI_ANY_BASE 0
@@ -532,15 +510,25 @@ acpi_ut_display_init_pathname(u8 type,
532#endif 510#endif
533 511
534/* 512/*
513 * utownerid - Support for Table/Method Owner IDs
514 */
515acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id);
516
517void acpi_ut_release_owner_id(acpi_owner_id * owner_id);
518
519/*
535 * utresrc 520 * utresrc
536 */ 521 */
537acpi_status 522acpi_status
538acpi_ut_walk_aml_resources(u8 *aml, 523acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state,
524 u8 *aml,
539 acpi_size aml_length, 525 acpi_size aml_length,
540 acpi_walk_aml_callback user_function, 526 acpi_walk_aml_callback user_function,
541 void **context); 527 void **context);
542 528
543acpi_status acpi_ut_validate_resource(void *aml, u8 *return_index); 529acpi_status
530acpi_ut_validate_resource(struct acpi_walk_state *walk_state,
531 void *aml, u8 *return_index);
544 532
545u32 acpi_ut_get_descriptor_length(void *aml); 533u32 acpi_ut_get_descriptor_length(void *aml);
546 534
@@ -554,6 +542,27 @@ acpi_status
554acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag); 542acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag);
555 543
556/* 544/*
545 * utstring - String and character utilities
546 */
547void acpi_ut_strupr(char *src_string);
548
549void acpi_ut_strlwr(char *src_string);
550
551int acpi_ut_stricmp(char *string1, char *string2);
552
553acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer);
554
555void acpi_ut_print_string(char *string, u8 max_length);
556
557void ut_convert_backslashes(char *pathname);
558
559u8 acpi_ut_valid_acpi_name(u32 name);
560
561u8 acpi_ut_valid_acpi_char(char character, u32 position);
562
563void acpi_ut_repair_name(char *name);
564
565/*
557 * utmutex - mutex support 566 * utmutex - mutex support
558 */ 567 */
559acpi_status acpi_ut_mutex_initialize(void); 568acpi_status acpi_ut_mutex_initialize(void);
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index c26f8ff6c3b9..48a3e331b72d 100644
--- a/drivers/acpi/acpica/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2012, Intel Corp. 10 * Copyright (C) 2000 - 2013, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
index 968449685e06..87c26366d1df 100644
--- a/drivers/acpi/acpica/amlresrc.h
+++ b/drivers/acpi/acpica/amlresrc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -199,6 +199,12 @@ struct aml_resource_fixed_dma {
199struct aml_resource_large_header { 199struct aml_resource_large_header {
200AML_RESOURCE_LARGE_HEADER_COMMON}; 200AML_RESOURCE_LARGE_HEADER_COMMON};
201 201
202/* General Flags for address space resource descriptors */
203
204#define ACPI_RESOURCE_FLAG_DEC 2
205#define ACPI_RESOURCE_FLAG_MIF 4
206#define ACPI_RESOURCE_FLAG_MAF 8
207
202struct aml_resource_memory24 { 208struct aml_resource_memory24 {
203 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; 209 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
204 u16 minimum; 210 u16 minimum;
diff --git a/drivers/acpi/acpica/dsargs.c b/drivers/acpi/acpica/dsargs.c
index c8b5e2565b98..fb09b08d7080 100644
--- a/drivers/acpi/acpica/dsargs.c
+++ b/drivers/acpi/acpica/dsargs.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dscontrol.c b/drivers/acpi/acpica/dscontrol.c
index 57895db3231a..7ea0f162f11c 100644
--- a/drivers/acpi/acpica/dscontrol.c
+++ b/drivers/acpi/acpica/dscontrol.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index b5b904ee815f..feadeed1012d 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index 87eff701ecfa..bc8e63f7784b 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 52eb4e01622a..a9ffd44c18fe 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,7 @@
47#include "acinterp.h" 47#include "acinterp.h"
48#include "acnamesp.h" 48#include "acnamesp.h"
49#ifdef ACPI_DISASSEMBLER 49#ifdef ACPI_DISASSEMBLER
50#include <acpi/acdisasm.h> 50#include "acdisasm.h"
51#endif 51#endif
52 52
53#define _COMPONENT ACPI_DISPATCHER 53#define _COMPONENT ACPI_DISPATCHER
@@ -151,6 +151,7 @@ acpi_ds_create_method_mutex(union acpi_operand_object *method_desc)
151 151
152 status = acpi_os_create_mutex(&mutex_desc->mutex.os_mutex); 152 status = acpi_os_create_mutex(&mutex_desc->mutex.os_mutex);
153 if (ACPI_FAILURE(status)) { 153 if (ACPI_FAILURE(status)) {
154 acpi_ut_delete_object_desc(mutex_desc);
154 return_ACPI_STATUS(status); 155 return_ACPI_STATUS(status);
155 } 156 }
156 157
@@ -378,7 +379,8 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
378 */ 379 */
379 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); 380 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
380 if (!info) { 381 if (!info) {
381 return_ACPI_STATUS(AE_NO_MEMORY); 382 status = AE_NO_MEMORY;
383 goto cleanup;
382 } 384 }
383 385
384 info->parameters = &this_walk_state->operands[0]; 386 info->parameters = &this_walk_state->operands[0];
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index 9a83b7e0f3ba..3da80460ce38 100644
--- a/drivers/acpi/acpica/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index c9f15d3a3686..e20e9f84eee8 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -388,7 +388,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
388 union acpi_parse_object *parent; 388 union acpi_parse_object *parent;
389 union acpi_operand_object *obj_desc = NULL; 389 union acpi_operand_object *obj_desc = NULL;
390 acpi_status status = AE_OK; 390 acpi_status status = AE_OK;
391 unsigned i; 391 u32 i;
392 u16 index; 392 u16 index;
393 u16 reference_count; 393 u16 reference_count;
394 394
@@ -525,7 +525,7 @@ acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
525 } 525 }
526 526
527 ACPI_INFO((AE_INFO, 527 ACPI_INFO((AE_INFO,
528 "Actual Package length (%u) is larger than NumElements field (%u), truncated\n", 528 "Actual Package length (%u) is larger than NumElements field (%u), truncated",
529 i, element_count)); 529 i, element_count));
530 } else if (i < element_count) { 530 } else if (i < element_count) {
531 /* 531 /*
@@ -703,7 +703,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
703 /* Truncate value if we are executing from a 32-bit ACPI table */ 703 /* Truncate value if we are executing from a 32-bit ACPI table */
704 704
705#ifndef ACPI_NO_METHOD_EXECUTION 705#ifndef ACPI_NO_METHOD_EXECUTION
706 acpi_ex_truncate_for32bit_table(obj_desc); 706 (void)acpi_ex_truncate_for32bit_table(obj_desc);
707#endif 707#endif
708 break; 708 break;
709 709
@@ -725,8 +725,18 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
725 case AML_TYPE_LITERAL: 725 case AML_TYPE_LITERAL:
726 726
727 obj_desc->integer.value = op->common.value.integer; 727 obj_desc->integer.value = op->common.value.integer;
728
728#ifndef ACPI_NO_METHOD_EXECUTION 729#ifndef ACPI_NO_METHOD_EXECUTION
729 acpi_ex_truncate_for32bit_table(obj_desc); 730 if (acpi_ex_truncate_for32bit_table(obj_desc)) {
731
732 /* Warn if we found a 64-bit constant in a 32-bit table */
733
734 ACPI_WARNING((AE_INFO,
735 "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
736 ACPI_FORMAT_UINT64(op->common.
737 value.integer),
738 (u32)obj_desc->integer.value));
739 }
730#endif 740#endif
731 break; 741 break;
732 742
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index d09c6b4bab2c..ee6367b8eaf7 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -486,18 +486,18 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
486 ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op); 486 ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op);
487 487
488 /* 488 /*
489 * This is where we evaluate the signature_string and oem_iDString 489 * This is where we evaluate the Signature string, oem_id string,
490 * and oem_table_iDString of the data_table_region declaration 490 * and oem_table_id string of the Data Table Region declaration
491 */ 491 */
492 node = op->common.node; 492 node = op->common.node;
493 493
494 /* next_op points to signature_string op */ 494 /* next_op points to Signature string op */
495 495
496 next_op = op->common.value.arg; 496 next_op = op->common.value.arg;
497 497
498 /* 498 /*
499 * Evaluate/create the signature_string and oem_iDString 499 * Evaluate/create the Signature string, oem_id string,
500 * and oem_table_iDString operands 500 * and oem_table_id string operands
501 */ 501 */
502 status = acpi_ds_create_operands(walk_state, next_op); 502 status = acpi_ds_create_operands(walk_state, next_op);
503 if (ACPI_FAILURE(status)) { 503 if (ACPI_FAILURE(status)) {
@@ -505,8 +505,8 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
505 } 505 }
506 506
507 /* 507 /*
508 * Resolve the signature_string and oem_iDString 508 * Resolve the Signature string, oem_id string,
509 * and oem_table_iDString operands 509 * and oem_table_id string operands
510 */ 510 */
511 status = acpi_ex_resolve_operands(op->common.aml_opcode, 511 status = acpi_ex_resolve_operands(op->common.aml_opcode,
512 ACPI_WALK_OPERANDS, walk_state); 512 ACPI_WALK_OPERANDS, walk_state);
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index afeb99f49482..4d8c992a51d8 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -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_UINT8(TRUE); 181 return_VALUE(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_UINT8(FALSE); 213 return_VALUE(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_UINT8(FALSE); 222 return_VALUE(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_UINT8(TRUE); 310 return_VALUE(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_UINT8(FALSE); 319 return_VALUE(FALSE);
320} 320}
321 321
322/******************************************************************************* 322/*******************************************************************************
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c
index 58593931be96..44f8325c2bae 100644
--- a/drivers/acpi/acpica/dswexec.c
+++ b/drivers/acpi/acpica/dswexec.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -149,7 +149,7 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
149 149
150 /* Truncate the predicate to 32-bits if necessary */ 150 /* Truncate the predicate to 32-bits if necessary */
151 151
152 acpi_ex_truncate_for32bit_table(local_obj_desc); 152 (void)acpi_ex_truncate_for32bit_table(local_obj_desc);
153 153
154 /* 154 /*
155 * Save the result of the predicate evaluation on 155 * Save the result of the predicate evaluation on
@@ -706,7 +706,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
706 * ACPI 2.0 support for 64-bit integers: Truncate numeric 706 * ACPI 2.0 support for 64-bit integers: Truncate numeric
707 * result value if we are executing from a 32-bit ACPI table 707 * result value if we are executing from a 32-bit ACPI table
708 */ 708 */
709 acpi_ex_truncate_for32bit_table(walk_state->result_obj); 709 (void)acpi_ex_truncate_for32bit_table(walk_state->result_obj);
710 710
711 /* 711 /*
712 * Check if we just completed the evaluation of a 712 * Check if we just completed the evaluation of a
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 557510084c7a..6e17c0e24e63 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,7 @@
50#include "acnamesp.h" 50#include "acnamesp.h"
51 51
52#ifdef ACPI_ASL_COMPILER 52#ifdef ACPI_ASL_COMPILER
53#include <acpi/acdisasm.h> 53#include "acdisasm.h"
54#endif 54#endif
55 55
56#define _COMPONENT ACPI_DISPATCHER 56#define _COMPONENT ACPI_DISPATCHER
@@ -178,7 +178,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
178 * Target of Scope() not found. Generate an External for it, and 178 * Target of Scope() not found. Generate an External for it, and
179 * insert the name into the namespace. 179 * insert the name into the namespace.
180 */ 180 */
181 acpi_dm_add_to_external_list(path, ACPI_TYPE_DEVICE, 0); 181 acpi_dm_add_to_external_list(op, path, ACPI_TYPE_DEVICE,
182 0);
182 status = 183 status =
183 acpi_ns_lookup(walk_state->scope_info, path, 184 acpi_ns_lookup(walk_state->scope_info, path,
184 object_type, ACPI_IMODE_LOAD_PASS1, 185 object_type, ACPI_IMODE_LOAD_PASS1,
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c
index 379835748357..4407ff2377d5 100644
--- a/drivers/acpi/acpica/dswload2.c
+++ b/drivers/acpi/acpica/dswload2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -222,7 +222,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
222 */ 222 */
223 ACPI_WARNING((AE_INFO, 223 ACPI_WARNING((AE_INFO,
224 "Type override - [%4.4s] had invalid type (%s) " 224 "Type override - [%4.4s] had invalid type (%s) "
225 "for Scope operator, changed to type ANY\n", 225 "for Scope operator, changed to type ANY",
226 acpi_ut_get_node_name(node), 226 acpi_ut_get_node_name(node),
227 acpi_ut_get_type_name(node->type))); 227 acpi_ut_get_type_name(node->type)));
228 228
diff --git a/drivers/acpi/acpica/dswscope.c b/drivers/acpi/acpica/dswscope.c
index f6c4295470ae..d67891de1b54 100644
--- a/drivers/acpi/acpica/dswscope.c
+++ b/drivers/acpi/acpica/dswscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c
index 3e65a15a735f..ecb12e2137ff 100644
--- a/drivers/acpi/acpica/dswstate.c
+++ b/drivers/acpi/acpica/dswstate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index d4acfbbe5b29..b8ea0b26cde3 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evglock.c b/drivers/acpi/acpica/evglock.c
index af14a7137632..a621481c6cf2 100644
--- a/drivers/acpi/acpica/evglock.c
+++ b/drivers/acpi/acpica/evglock.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 36d120574423..b9adb9a7ed85 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -561,8 +561,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
561 status = AE_NO_MEMORY; 561 status = AE_NO_MEMORY;
562 } else { 562 } else {
563 /* 563 /*
564 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx 564 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the
565 * control method that corresponds to this GPE 565 * _Lxx/_Exx control method that corresponds to this GPE
566 */ 566 */
567 info->prefix_node = 567 info->prefix_node =
568 local_gpe_event_info->dispatch.method_node; 568 local_gpe_event_info->dispatch.method_node;
@@ -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_UINT32(ACPI_INTERRUPT_NOT_HANDLED); 710 return_VALUE(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_UINT32(ACPI_INTERRUPT_NOT_HANDLED); 727 return_VALUE(ACPI_INTERRUPT_NOT_HANDLED);
728 } 728 }
729 729
730 /* 730 /*
@@ -765,7 +765,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
765 gpe_event_info); 765 gpe_event_info);
766 if (ACPI_FAILURE(status)) { 766 if (ACPI_FAILURE(status)) {
767 ACPI_EXCEPTION((AE_INFO, status, 767 ACPI_EXCEPTION((AE_INFO, status,
768 "Unable to queue handler for GPE%2X - event disabled", 768 "Unable to queue handler for GPE%02X - event disabled",
769 gpe_number)); 769 gpe_number));
770 } 770 }
771 break; 771 break;
@@ -784,7 +784,7 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
784 break; 784 break;
785 } 785 }
786 786
787 return_UINT32(ACPI_INTERRUPT_HANDLED); 787 return_VALUE(ACPI_INTERRUPT_HANDLED);
788} 788}
789 789
790#endif /* !ACPI_REDUCED_HARDWARE */ 790#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 1571a61a7833..a2d688bbac02 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -405,13 +405,13 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
405 (*return_gpe_block) = gpe_block; 405 (*return_gpe_block) = gpe_block;
406 } 406 }
407 407
408 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 408 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
409 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", 409 " Initialized GPE %02X to %02X [%4.4s] %u regs on interrupt 0x%X\n",
410 (u32) gpe_block->block_base_number, 410 (u32)gpe_block->block_base_number,
411 (u32) (gpe_block->block_base_number + 411 (u32)(gpe_block->block_base_number +
412 (gpe_block->gpe_count - 1)), 412 (gpe_block->gpe_count - 1)),
413 gpe_device->name.ascii, gpe_block->register_count, 413 gpe_device->name.ascii, gpe_block->register_count,
414 interrupt_number)); 414 interrupt_number));
415 415
416 /* Update global count of currently available GPEs */ 416 /* Update global count of currently available GPEs */
417 417
@@ -496,9 +496,11 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
496 } 496 }
497 497
498 if (gpe_enabled_count) { 498 if (gpe_enabled_count) {
499 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 499 ACPI_INFO((AE_INFO,
500 "Enabled %u GPEs in this block\n", 500 "Enabled %u GPEs in block %02X to %02X",
501 gpe_enabled_count)); 501 gpe_enabled_count, (u32)gpe_block->block_base_number,
502 (u32)(gpe_block->block_base_number +
503 (gpe_block->gpe_count - 1))));
502 } 504 }
503 505
504 gpe_block->initialized = TRUE; 506 gpe_block->initialized = TRUE;
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c
index da0add858f81..72b8f6b3f4ca 100644
--- a/drivers/acpi/acpica/evgpeinit.c
+++ b/drivers/acpi/acpica/evgpeinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -86,6 +86,9 @@ acpi_status acpi_ev_gpe_initialize(void)
86 86
87 ACPI_FUNCTION_TRACE(ev_gpe_initialize); 87 ACPI_FUNCTION_TRACE(ev_gpe_initialize);
88 88
89 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
90 "Initializing General Purpose Events (GPEs):\n"));
91
89 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 92 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
90 if (ACPI_FAILURE(status)) { 93 if (ACPI_FAILURE(status)) {
91 return_ACPI_STATUS(status); 94 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c
index 228a0c3b1d49..b24dbb80fab8 100644
--- a/drivers/acpi/acpica/evgpeutil.c
+++ b/drivers/acpi/acpica/evgpeutil.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c
new file mode 100644
index 000000000000..d4f83112c2e2
--- /dev/null
+++ b/drivers/acpi/acpica/evhandler.c
@@ -0,0 +1,529 @@
1/******************************************************************************
2 *
3 * Module Name: evhandler - Support for Address Space handlers
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 "acevents.h"
47#include "acnamesp.h"
48#include "acinterp.h"
49
50#define _COMPONENT ACPI_EVENTS
51ACPI_MODULE_NAME("evhandler")
52
53/* Local prototypes */
54static acpi_status
55acpi_ev_install_handler(acpi_handle obj_handle,
56 u32 level, void *context, void **return_value);
57
58/* These are the address spaces that will get default handlers */
59
60u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
61 ACPI_ADR_SPACE_SYSTEM_MEMORY,
62 ACPI_ADR_SPACE_SYSTEM_IO,
63 ACPI_ADR_SPACE_PCI_CONFIG,
64 ACPI_ADR_SPACE_DATA_TABLE
65};
66
67/*******************************************************************************
68 *
69 * FUNCTION: acpi_ev_install_region_handlers
70 *
71 * PARAMETERS: None
72 *
73 * RETURN: Status
74 *
75 * DESCRIPTION: Installs the core subsystem default address space handlers.
76 *
77 ******************************************************************************/
78
79acpi_status acpi_ev_install_region_handlers(void)
80{
81 acpi_status status;
82 u32 i;
83
84 ACPI_FUNCTION_TRACE(ev_install_region_handlers);
85
86 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
87 if (ACPI_FAILURE(status)) {
88 return_ACPI_STATUS(status);
89 }
90
91 /*
92 * All address spaces (PCI Config, EC, SMBus) are scope dependent and
93 * registration must occur for a specific device.
94 *
95 * In the case of the system memory and IO address spaces there is
96 * currently no device associated with the address space. For these we
97 * use the root.
98 *
99 * We install the default PCI config space handler at the root so that
100 * this space is immediately available even though the we have not
101 * enumerated all the PCI Root Buses yet. This is to conform to the ACPI
102 * specification which states that the PCI config space must be always
103 * available -- even though we are nowhere near ready to find the PCI root
104 * buses at this point.
105 *
106 * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
107 * has already been installed (via acpi_install_address_space_handler).
108 * Similar for AE_SAME_HANDLER.
109 */
110 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
111 status = acpi_ev_install_space_handler(acpi_gbl_root_node,
112 acpi_gbl_default_address_spaces
113 [i],
114 ACPI_DEFAULT_HANDLER,
115 NULL, NULL);
116 switch (status) {
117 case AE_OK:
118 case AE_SAME_HANDLER:
119 case AE_ALREADY_EXISTS:
120
121 /* These exceptions are all OK */
122
123 status = AE_OK;
124 break;
125
126 default:
127
128 goto unlock_and_exit;
129 }
130 }
131
132 unlock_and_exit:
133 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
134 return_ACPI_STATUS(status);
135}
136
137/*******************************************************************************
138 *
139 * FUNCTION: acpi_ev_has_default_handler
140 *
141 * PARAMETERS: node - Namespace node for the device
142 * space_id - The address space ID
143 *
144 * RETURN: TRUE if default handler is installed, FALSE otherwise
145 *
146 * DESCRIPTION: Check if the default handler is installed for the requested
147 * space ID.
148 *
149 ******************************************************************************/
150
151u8
152acpi_ev_has_default_handler(struct acpi_namespace_node *node,
153 acpi_adr_space_type space_id)
154{
155 union acpi_operand_object *obj_desc;
156 union acpi_operand_object *handler_obj;
157
158 /* Must have an existing internal object */
159
160 obj_desc = acpi_ns_get_attached_object(node);
161 if (obj_desc) {
162 handler_obj = obj_desc->device.handler;
163
164 /* Walk the linked list of handlers for this object */
165
166 while (handler_obj) {
167 if (handler_obj->address_space.space_id == space_id) {
168 if (handler_obj->address_space.handler_flags &
169 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
170 return (TRUE);
171 }
172 }
173
174 handler_obj = handler_obj->address_space.next;
175 }
176 }
177
178 return (FALSE);
179}
180
181/*******************************************************************************
182 *
183 * FUNCTION: acpi_ev_install_handler
184 *
185 * PARAMETERS: walk_namespace callback
186 *
187 * DESCRIPTION: This routine installs an address handler into objects that are
188 * of type Region or Device.
189 *
190 * If the Object is a Device, and the device has a handler of
191 * the same type then the search is terminated in that branch.
192 *
193 * This is because the existing handler is closer in proximity
194 * to any more regions than the one we are trying to install.
195 *
196 ******************************************************************************/
197
198static acpi_status
199acpi_ev_install_handler(acpi_handle obj_handle,
200 u32 level, void *context, void **return_value)
201{
202 union acpi_operand_object *handler_obj;
203 union acpi_operand_object *next_handler_obj;
204 union acpi_operand_object *obj_desc;
205 struct acpi_namespace_node *node;
206 acpi_status status;
207
208 ACPI_FUNCTION_NAME(ev_install_handler);
209
210 handler_obj = (union acpi_operand_object *)context;
211
212 /* Parameter validation */
213
214 if (!handler_obj) {
215 return (AE_OK);
216 }
217
218 /* Convert and validate the device handle */
219
220 node = acpi_ns_validate_handle(obj_handle);
221 if (!node) {
222 return (AE_BAD_PARAMETER);
223 }
224
225 /*
226 * We only care about regions and objects that are allowed to have
227 * address space handlers
228 */
229 if ((node->type != ACPI_TYPE_DEVICE) &&
230 (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
231 return (AE_OK);
232 }
233
234 /* Check for an existing internal object */
235
236 obj_desc = acpi_ns_get_attached_object(node);
237 if (!obj_desc) {
238
239 /* No object, just exit */
240
241 return (AE_OK);
242 }
243
244 /* Devices are handled different than regions */
245
246 if (obj_desc->common.type == ACPI_TYPE_DEVICE) {
247
248 /* Check if this Device already has a handler for this address space */
249
250 next_handler_obj = obj_desc->device.handler;
251 while (next_handler_obj) {
252
253 /* Found a handler, is it for the same address space? */
254
255 if (next_handler_obj->address_space.space_id ==
256 handler_obj->address_space.space_id) {
257 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
258 "Found handler for region [%s] in device %p(%p) "
259 "handler %p\n",
260 acpi_ut_get_region_name
261 (handler_obj->address_space.
262 space_id), obj_desc,
263 next_handler_obj,
264 handler_obj));
265
266 /*
267 * Since the object we found it on was a device, then it
268 * means that someone has already installed a handler for
269 * the branch of the namespace from this device on. Just
270 * bail out telling the walk routine to not traverse this
271 * branch. This preserves the scoping rule for handlers.
272 */
273 return (AE_CTRL_DEPTH);
274 }
275
276 /* Walk the linked list of handlers attached to this device */
277
278 next_handler_obj = next_handler_obj->address_space.next;
279 }
280
281 /*
282 * As long as the device didn't have a handler for this space we
283 * don't care about it. We just ignore it and proceed.
284 */
285 return (AE_OK);
286 }
287
288 /* Object is a Region */
289
290 if (obj_desc->region.space_id != handler_obj->address_space.space_id) {
291
292 /* This region is for a different address space, just ignore it */
293
294 return (AE_OK);
295 }
296
297 /*
298 * Now we have a region and it is for the handler's address space type.
299 *
300 * First disconnect region for any previous handler (if any)
301 */
302 acpi_ev_detach_region(obj_desc, FALSE);
303
304 /* Connect the region to the new handler */
305
306 status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE);
307 return (status);
308}
309
310/*******************************************************************************
311 *
312 * FUNCTION: acpi_ev_install_space_handler
313 *
314 * PARAMETERS: node - Namespace node for the device
315 * space_id - The address space ID
316 * handler - Address of the handler
317 * setup - Address of the setup function
318 * context - Value passed to the handler on each access
319 *
320 * RETURN: Status
321 *
322 * DESCRIPTION: Install a handler for all op_regions of a given space_id.
323 * Assumes namespace is locked
324 *
325 ******************************************************************************/
326
327acpi_status
328acpi_ev_install_space_handler(struct acpi_namespace_node * node,
329 acpi_adr_space_type space_id,
330 acpi_adr_space_handler handler,
331 acpi_adr_space_setup setup, void *context)
332{
333 union acpi_operand_object *obj_desc;
334 union acpi_operand_object *handler_obj;
335 acpi_status status;
336 acpi_object_type type;
337 u8 flags = 0;
338
339 ACPI_FUNCTION_TRACE(ev_install_space_handler);
340
341 /*
342 * This registration is valid for only the types below and the root. This
343 * is where the default handlers get placed.
344 */
345 if ((node->type != ACPI_TYPE_DEVICE) &&
346 (node->type != ACPI_TYPE_PROCESSOR) &&
347 (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) {
348 status = AE_BAD_PARAMETER;
349 goto unlock_and_exit;
350 }
351
352 if (handler == ACPI_DEFAULT_HANDLER) {
353 flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED;
354
355 switch (space_id) {
356 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
357 handler = acpi_ex_system_memory_space_handler;
358 setup = acpi_ev_system_memory_region_setup;
359 break;
360
361 case ACPI_ADR_SPACE_SYSTEM_IO:
362 handler = acpi_ex_system_io_space_handler;
363 setup = acpi_ev_io_space_region_setup;
364 break;
365
366 case ACPI_ADR_SPACE_PCI_CONFIG:
367 handler = acpi_ex_pci_config_space_handler;
368 setup = acpi_ev_pci_config_region_setup;
369 break;
370
371 case ACPI_ADR_SPACE_CMOS:
372 handler = acpi_ex_cmos_space_handler;
373 setup = acpi_ev_cmos_region_setup;
374 break;
375
376 case ACPI_ADR_SPACE_PCI_BAR_TARGET:
377 handler = acpi_ex_pci_bar_space_handler;
378 setup = acpi_ev_pci_bar_region_setup;
379 break;
380
381 case ACPI_ADR_SPACE_DATA_TABLE:
382 handler = acpi_ex_data_table_space_handler;
383 setup = NULL;
384 break;
385
386 default:
387 status = AE_BAD_PARAMETER;
388 goto unlock_and_exit;
389 }
390 }
391
392 /* If the caller hasn't specified a setup routine, use the default */
393
394 if (!setup) {
395 setup = acpi_ev_default_region_setup;
396 }
397
398 /* Check for an existing internal object */
399
400 obj_desc = acpi_ns_get_attached_object(node);
401 if (obj_desc) {
402 /*
403 * The attached device object already exists. Make sure the handler
404 * is not already installed.
405 */
406 handler_obj = obj_desc->device.handler;
407
408 /* Walk the handler list for this device */
409
410 while (handler_obj) {
411
412 /* Same space_id indicates a handler already installed */
413
414 if (handler_obj->address_space.space_id == space_id) {
415 if (handler_obj->address_space.handler ==
416 handler) {
417 /*
418 * It is (relatively) OK to attempt to install the SAME
419 * handler twice. This can easily happen with the
420 * PCI_Config space.
421 */
422 status = AE_SAME_HANDLER;
423 goto unlock_and_exit;
424 } else {
425 /* A handler is already installed */
426
427 status = AE_ALREADY_EXISTS;
428 }
429 goto unlock_and_exit;
430 }
431
432 /* Walk the linked list of handlers */
433
434 handler_obj = handler_obj->address_space.next;
435 }
436 } else {
437 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
438 "Creating object on Device %p while installing handler\n",
439 node));
440
441 /* obj_desc does not exist, create one */
442
443 if (node->type == ACPI_TYPE_ANY) {
444 type = ACPI_TYPE_DEVICE;
445 } else {
446 type = node->type;
447 }
448
449 obj_desc = acpi_ut_create_internal_object(type);
450 if (!obj_desc) {
451 status = AE_NO_MEMORY;
452 goto unlock_and_exit;
453 }
454
455 /* Init new descriptor */
456
457 obj_desc->common.type = (u8)type;
458
459 /* Attach the new object to the Node */
460
461 status = acpi_ns_attach_object(node, obj_desc, type);
462
463 /* Remove local reference to the object */
464
465 acpi_ut_remove_reference(obj_desc);
466
467 if (ACPI_FAILURE(status)) {
468 goto unlock_and_exit;
469 }
470 }
471
472 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
473 "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
474 acpi_ut_get_region_name(space_id), space_id,
475 acpi_ut_get_node_name(node), node, obj_desc));
476
477 /*
478 * Install the handler
479 *
480 * At this point there is no existing handler. Just allocate the object
481 * for the handler and link it into the list.
482 */
483 handler_obj =
484 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
485 if (!handler_obj) {
486 status = AE_NO_MEMORY;
487 goto unlock_and_exit;
488 }
489
490 /* Init handler obj */
491
492 handler_obj->address_space.space_id = (u8)space_id;
493 handler_obj->address_space.handler_flags = flags;
494 handler_obj->address_space.region_list = NULL;
495 handler_obj->address_space.node = node;
496 handler_obj->address_space.handler = handler;
497 handler_obj->address_space.context = context;
498 handler_obj->address_space.setup = setup;
499
500 /* Install at head of Device.address_space list */
501
502 handler_obj->address_space.next = obj_desc->device.handler;
503
504 /*
505 * The Device object is the first reference on the handler_obj.
506 * Each region that uses the handler adds a reference.
507 */
508 obj_desc->device.handler = handler_obj;
509
510 /*
511 * Walk the namespace finding all of the regions this
512 * handler will manage.
513 *
514 * Start at the device and search the branch toward
515 * the leaf nodes until either the leaf is encountered or
516 * a device is detected that has an address handler of the
517 * same type.
518 *
519 * In either case, back up and search down the remainder
520 * of the branch
521 */
522 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
523 ACPI_NS_WALK_UNLOCK,
524 acpi_ev_install_handler, NULL,
525 handler_obj, NULL);
526
527 unlock_and_exit:
528 return_ACPI_STATUS(status);
529}
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index 51f537937c1f..c986b2336b81 100644
--- a/drivers/acpi/acpica/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 0cc6a16fedc7..6555e350fc1f 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -1,11 +1,11 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: evregion - ACPI address_space (op_region) handler dispatch 3 * Module Name: evregion - Operation Region support
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -50,10 +50,9 @@
50#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
51ACPI_MODULE_NAME("evregion") 51ACPI_MODULE_NAME("evregion")
52 52
53extern u8 acpi_gbl_default_address_spaces[];
54
53/* Local prototypes */ 55/* Local prototypes */
54static u8
55acpi_ev_has_default_handler(struct acpi_namespace_node *node,
56 acpi_adr_space_type space_id);
57 56
58static void acpi_ev_orphan_ec_reg_method(void); 57static void acpi_ev_orphan_ec_reg_method(void);
59 58
@@ -61,135 +60,6 @@ static acpi_status
61acpi_ev_reg_run(acpi_handle obj_handle, 60acpi_ev_reg_run(acpi_handle obj_handle,
62 u32 level, void *context, void **return_value); 61 u32 level, void *context, void **return_value);
63 62
64static acpi_status
65acpi_ev_install_handler(acpi_handle obj_handle,
66 u32 level, void *context, void **return_value);
67
68/* These are the address spaces that will get default handlers */
69
70#define ACPI_NUM_DEFAULT_SPACES 4
71
72static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
73 ACPI_ADR_SPACE_SYSTEM_MEMORY,
74 ACPI_ADR_SPACE_SYSTEM_IO,
75 ACPI_ADR_SPACE_PCI_CONFIG,
76 ACPI_ADR_SPACE_DATA_TABLE
77};
78
79/*******************************************************************************
80 *
81 * FUNCTION: acpi_ev_install_region_handlers
82 *
83 * PARAMETERS: None
84 *
85 * RETURN: Status
86 *
87 * DESCRIPTION: Installs the core subsystem default address space handlers.
88 *
89 ******************************************************************************/
90
91acpi_status acpi_ev_install_region_handlers(void)
92{
93 acpi_status status;
94 u32 i;
95
96 ACPI_FUNCTION_TRACE(ev_install_region_handlers);
97
98 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
99 if (ACPI_FAILURE(status)) {
100 return_ACPI_STATUS(status);
101 }
102
103 /*
104 * All address spaces (PCI Config, EC, SMBus) are scope dependent and
105 * registration must occur for a specific device.
106 *
107 * In the case of the system memory and IO address spaces there is
108 * currently no device associated with the address space. For these we
109 * use the root.
110 *
111 * We install the default PCI config space handler at the root so that
112 * this space is immediately available even though the we have not
113 * enumerated all the PCI Root Buses yet. This is to conform to the ACPI
114 * specification which states that the PCI config space must be always
115 * available -- even though we are nowhere near ready to find the PCI root
116 * buses at this point.
117 *
118 * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
119 * has already been installed (via acpi_install_address_space_handler).
120 * Similar for AE_SAME_HANDLER.
121 */
122 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
123 status = acpi_ev_install_space_handler(acpi_gbl_root_node,
124 acpi_gbl_default_address_spaces
125 [i],
126 ACPI_DEFAULT_HANDLER,
127 NULL, NULL);
128 switch (status) {
129 case AE_OK:
130 case AE_SAME_HANDLER:
131 case AE_ALREADY_EXISTS:
132
133 /* These exceptions are all OK */
134
135 status = AE_OK;
136 break;
137
138 default:
139
140 goto unlock_and_exit;
141 }
142 }
143
144 unlock_and_exit:
145 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
146 return_ACPI_STATUS(status);
147}
148
149/*******************************************************************************
150 *
151 * FUNCTION: acpi_ev_has_default_handler
152 *
153 * PARAMETERS: node - Namespace node for the device
154 * space_id - The address space ID
155 *
156 * RETURN: TRUE if default handler is installed, FALSE otherwise
157 *
158 * DESCRIPTION: Check if the default handler is installed for the requested
159 * space ID.
160 *
161 ******************************************************************************/
162
163static u8
164acpi_ev_has_default_handler(struct acpi_namespace_node *node,
165 acpi_adr_space_type space_id)
166{
167 union acpi_operand_object *obj_desc;
168 union acpi_operand_object *handler_obj;
169
170 /* Must have an existing internal object */
171
172 obj_desc = acpi_ns_get_attached_object(node);
173 if (obj_desc) {
174 handler_obj = obj_desc->device.handler;
175
176 /* Walk the linked list of handlers for this object */
177
178 while (handler_obj) {
179 if (handler_obj->address_space.space_id == space_id) {
180 if (handler_obj->address_space.handler_flags &
181 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) {
182 return (TRUE);
183 }
184 }
185
186 handler_obj = handler_obj->address_space.next;
187 }
188 }
189
190 return (FALSE);
191}
192
193/******************************************************************************* 63/*******************************************************************************
194 * 64 *
195 * FUNCTION: acpi_ev_initialize_op_regions 65 * FUNCTION: acpi_ev_initialize_op_regions
@@ -241,91 +111,6 @@ acpi_status acpi_ev_initialize_op_regions(void)
241 111
242/******************************************************************************* 112/*******************************************************************************
243 * 113 *
244 * FUNCTION: acpi_ev_execute_reg_method
245 *
246 * PARAMETERS: region_obj - Region object
247 * function - Passed to _REG: On (1) or Off (0)
248 *
249 * RETURN: Status
250 *
251 * DESCRIPTION: Execute _REG method for a region
252 *
253 ******************************************************************************/
254
255acpi_status
256acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
257{
258 struct acpi_evaluate_info *info;
259 union acpi_operand_object *args[3];
260 union acpi_operand_object *region_obj2;
261 acpi_status status;
262
263 ACPI_FUNCTION_TRACE(ev_execute_reg_method);
264
265 region_obj2 = acpi_ns_get_secondary_object(region_obj);
266 if (!region_obj2) {
267 return_ACPI_STATUS(AE_NOT_EXIST);
268 }
269
270 if (region_obj2->extra.method_REG == NULL) {
271 return_ACPI_STATUS(AE_OK);
272 }
273
274 /* Allocate and initialize the evaluation information block */
275
276 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
277 if (!info) {
278 return_ACPI_STATUS(AE_NO_MEMORY);
279 }
280
281 info->prefix_node = region_obj2->extra.method_REG;
282 info->pathname = NULL;
283 info->parameters = args;
284 info->flags = ACPI_IGNORE_RETURN_VALUE;
285
286 /*
287 * The _REG method has two arguments:
288 *
289 * arg0 - Integer:
290 * Operation region space ID Same value as region_obj->Region.space_id
291 *
292 * arg1 - Integer:
293 * connection status 1 for connecting the handler, 0 for disconnecting
294 * the handler (Passed as a parameter)
295 */
296 args[0] =
297 acpi_ut_create_integer_object((u64) region_obj->region.space_id);
298 if (!args[0]) {
299 status = AE_NO_MEMORY;
300 goto cleanup1;
301 }
302
303 args[1] = acpi_ut_create_integer_object((u64) function);
304 if (!args[1]) {
305 status = AE_NO_MEMORY;
306 goto cleanup2;
307 }
308
309 args[2] = NULL; /* Terminate list */
310
311 /* Execute the method, no return value */
312
313 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
314 (ACPI_TYPE_METHOD, info->prefix_node, NULL));
315
316 status = acpi_ns_evaluate(info);
317 acpi_ut_remove_reference(args[1]);
318
319 cleanup2:
320 acpi_ut_remove_reference(args[0]);
321
322 cleanup1:
323 ACPI_FREE(info);
324 return_ACPI_STATUS(status);
325}
326
327/*******************************************************************************
328 *
329 * FUNCTION: acpi_ev_address_space_dispatch 114 * FUNCTION: acpi_ev_address_space_dispatch
330 * 115 *
331 * PARAMETERS: region_obj - Internal region object 116 * PARAMETERS: region_obj - Internal region object
@@ -709,351 +494,86 @@ acpi_ev_attach_region(union acpi_operand_object *handler_obj,
709 494
710/******************************************************************************* 495/*******************************************************************************
711 * 496 *
712 * FUNCTION: acpi_ev_install_handler 497 * FUNCTION: acpi_ev_execute_reg_method
713 *
714 * PARAMETERS: walk_namespace callback
715 *
716 * DESCRIPTION: This routine installs an address handler into objects that are
717 * of type Region or Device.
718 *
719 * If the Object is a Device, and the device has a handler of
720 * the same type then the search is terminated in that branch.
721 *
722 * This is because the existing handler is closer in proximity
723 * to any more regions than the one we are trying to install.
724 *
725 ******************************************************************************/
726
727static acpi_status
728acpi_ev_install_handler(acpi_handle obj_handle,
729 u32 level, void *context, void **return_value)
730{
731 union acpi_operand_object *handler_obj;
732 union acpi_operand_object *next_handler_obj;
733 union acpi_operand_object *obj_desc;
734 struct acpi_namespace_node *node;
735 acpi_status status;
736
737 ACPI_FUNCTION_NAME(ev_install_handler);
738
739 handler_obj = (union acpi_operand_object *)context;
740
741 /* Parameter validation */
742
743 if (!handler_obj) {
744 return (AE_OK);
745 }
746
747 /* Convert and validate the device handle */
748
749 node = acpi_ns_validate_handle(obj_handle);
750 if (!node) {
751 return (AE_BAD_PARAMETER);
752 }
753
754 /*
755 * We only care about regions and objects that are allowed to have
756 * address space handlers
757 */
758 if ((node->type != ACPI_TYPE_DEVICE) &&
759 (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
760 return (AE_OK);
761 }
762
763 /* Check for an existing internal object */
764
765 obj_desc = acpi_ns_get_attached_object(node);
766 if (!obj_desc) {
767
768 /* No object, just exit */
769
770 return (AE_OK);
771 }
772
773 /* Devices are handled different than regions */
774
775 if (obj_desc->common.type == ACPI_TYPE_DEVICE) {
776
777 /* Check if this Device already has a handler for this address space */
778
779 next_handler_obj = obj_desc->device.handler;
780 while (next_handler_obj) {
781
782 /* Found a handler, is it for the same address space? */
783
784 if (next_handler_obj->address_space.space_id ==
785 handler_obj->address_space.space_id) {
786 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
787 "Found handler for region [%s] in device %p(%p) "
788 "handler %p\n",
789 acpi_ut_get_region_name
790 (handler_obj->address_space.
791 space_id), obj_desc,
792 next_handler_obj,
793 handler_obj));
794
795 /*
796 * Since the object we found it on was a device, then it
797 * means that someone has already installed a handler for
798 * the branch of the namespace from this device on. Just
799 * bail out telling the walk routine to not traverse this
800 * branch. This preserves the scoping rule for handlers.
801 */
802 return (AE_CTRL_DEPTH);
803 }
804
805 /* Walk the linked list of handlers attached to this device */
806
807 next_handler_obj = next_handler_obj->address_space.next;
808 }
809
810 /*
811 * As long as the device didn't have a handler for this space we
812 * don't care about it. We just ignore it and proceed.
813 */
814 return (AE_OK);
815 }
816
817 /* Object is a Region */
818
819 if (obj_desc->region.space_id != handler_obj->address_space.space_id) {
820
821 /* This region is for a different address space, just ignore it */
822
823 return (AE_OK);
824 }
825
826 /*
827 * Now we have a region and it is for the handler's address space type.
828 *
829 * First disconnect region for any previous handler (if any)
830 */
831 acpi_ev_detach_region(obj_desc, FALSE);
832
833 /* Connect the region to the new handler */
834
835 status = acpi_ev_attach_region(handler_obj, obj_desc, FALSE);
836 return (status);
837}
838
839/*******************************************************************************
840 *
841 * FUNCTION: acpi_ev_install_space_handler
842 * 498 *
843 * PARAMETERS: node - Namespace node for the device 499 * PARAMETERS: region_obj - Region object
844 * space_id - The address space ID 500 * function - Passed to _REG: On (1) or Off (0)
845 * handler - Address of the handler
846 * setup - Address of the setup function
847 * context - Value passed to the handler on each access
848 * 501 *
849 * RETURN: Status 502 * RETURN: Status
850 * 503 *
851 * DESCRIPTION: Install a handler for all op_regions of a given space_id. 504 * DESCRIPTION: Execute _REG method for a region
852 * Assumes namespace is locked
853 * 505 *
854 ******************************************************************************/ 506 ******************************************************************************/
855 507
856acpi_status 508acpi_status
857acpi_ev_install_space_handler(struct acpi_namespace_node * node, 509acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
858 acpi_adr_space_type space_id,
859 acpi_adr_space_handler handler,
860 acpi_adr_space_setup setup, void *context)
861{ 510{
862 union acpi_operand_object *obj_desc; 511 struct acpi_evaluate_info *info;
863 union acpi_operand_object *handler_obj; 512 union acpi_operand_object *args[3];
513 union acpi_operand_object *region_obj2;
864 acpi_status status; 514 acpi_status status;
865 acpi_object_type type;
866 u8 flags = 0;
867 515
868 ACPI_FUNCTION_TRACE(ev_install_space_handler); 516 ACPI_FUNCTION_TRACE(ev_execute_reg_method);
869
870 /*
871 * This registration is valid for only the types below and the root. This
872 * is where the default handlers get placed.
873 */
874 if ((node->type != ACPI_TYPE_DEVICE) &&
875 (node->type != ACPI_TYPE_PROCESSOR) &&
876 (node->type != ACPI_TYPE_THERMAL) && (node != acpi_gbl_root_node)) {
877 status = AE_BAD_PARAMETER;
878 goto unlock_and_exit;
879 }
880 517
881 if (handler == ACPI_DEFAULT_HANDLER) { 518 region_obj2 = acpi_ns_get_secondary_object(region_obj);
882 flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; 519 if (!region_obj2) {
883 520 return_ACPI_STATUS(AE_NOT_EXIST);
884 switch (space_id) {
885 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
886 handler = acpi_ex_system_memory_space_handler;
887 setup = acpi_ev_system_memory_region_setup;
888 break;
889
890 case ACPI_ADR_SPACE_SYSTEM_IO:
891 handler = acpi_ex_system_io_space_handler;
892 setup = acpi_ev_io_space_region_setup;
893 break;
894
895 case ACPI_ADR_SPACE_PCI_CONFIG:
896 handler = acpi_ex_pci_config_space_handler;
897 setup = acpi_ev_pci_config_region_setup;
898 break;
899
900 case ACPI_ADR_SPACE_CMOS:
901 handler = acpi_ex_cmos_space_handler;
902 setup = acpi_ev_cmos_region_setup;
903 break;
904
905 case ACPI_ADR_SPACE_PCI_BAR_TARGET:
906 handler = acpi_ex_pci_bar_space_handler;
907 setup = acpi_ev_pci_bar_region_setup;
908 break;
909
910 case ACPI_ADR_SPACE_DATA_TABLE:
911 handler = acpi_ex_data_table_space_handler;
912 setup = NULL;
913 break;
914
915 default:
916 status = AE_BAD_PARAMETER;
917 goto unlock_and_exit;
918 }
919 } 521 }
920 522
921 /* If the caller hasn't specified a setup routine, use the default */ 523 if (region_obj2->extra.method_REG == NULL) {
922 524 return_ACPI_STATUS(AE_OK);
923 if (!setup) {
924 setup = acpi_ev_default_region_setup;
925 } 525 }
926 526
927 /* Check for an existing internal object */ 527 /* Allocate and initialize the evaluation information block */
928
929 obj_desc = acpi_ns_get_attached_object(node);
930 if (obj_desc) {
931 /*
932 * The attached device object already exists. Make sure the handler
933 * is not already installed.
934 */
935 handler_obj = obj_desc->device.handler;
936
937 /* Walk the handler list for this device */
938
939 while (handler_obj) {
940
941 /* Same space_id indicates a handler already installed */
942
943 if (handler_obj->address_space.space_id == space_id) {
944 if (handler_obj->address_space.handler ==
945 handler) {
946 /*
947 * It is (relatively) OK to attempt to install the SAME
948 * handler twice. This can easily happen with the
949 * PCI_Config space.
950 */
951 status = AE_SAME_HANDLER;
952 goto unlock_and_exit;
953 } else {
954 /* A handler is already installed */
955
956 status = AE_ALREADY_EXISTS;
957 }
958 goto unlock_and_exit;
959 }
960
961 /* Walk the linked list of handlers */
962
963 handler_obj = handler_obj->address_space.next;
964 }
965 } else {
966 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
967 "Creating object on Device %p while installing handler\n",
968 node));
969
970 /* obj_desc does not exist, create one */
971
972 if (node->type == ACPI_TYPE_ANY) {
973 type = ACPI_TYPE_DEVICE;
974 } else {
975 type = node->type;
976 }
977
978 obj_desc = acpi_ut_create_internal_object(type);
979 if (!obj_desc) {
980 status = AE_NO_MEMORY;
981 goto unlock_and_exit;
982 }
983
984 /* Init new descriptor */
985
986 obj_desc->common.type = (u8) type;
987
988 /* Attach the new object to the Node */
989
990 status = acpi_ns_attach_object(node, obj_desc, type);
991
992 /* Remove local reference to the object */
993
994 acpi_ut_remove_reference(obj_desc);
995 528
996 if (ACPI_FAILURE(status)) { 529 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
997 goto unlock_and_exit; 530 if (!info) {
998 } 531 return_ACPI_STATUS(AE_NO_MEMORY);
999 } 532 }
1000 533
1001 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, 534 info->prefix_node = region_obj2->extra.method_REG;
1002 "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", 535 info->pathname = NULL;
1003 acpi_ut_get_region_name(space_id), space_id, 536 info->parameters = args;
1004 acpi_ut_get_node_name(node), node, obj_desc)); 537 info->flags = ACPI_IGNORE_RETURN_VALUE;
1005 538
1006 /* 539 /*
1007 * Install the handler 540 * The _REG method has two arguments:
541 *
542 * arg0 - Integer:
543 * Operation region space ID Same value as region_obj->Region.space_id
1008 * 544 *
1009 * At this point there is no existing handler. Just allocate the object 545 * arg1 - Integer:
1010 * for the handler and link it into the list. 546 * connection status 1 for connecting the handler, 0 for disconnecting
547 * the handler (Passed as a parameter)
1011 */ 548 */
1012 handler_obj = 549 args[0] =
1013 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); 550 acpi_ut_create_integer_object((u64)region_obj->region.space_id);
1014 if (!handler_obj) { 551 if (!args[0]) {
1015 status = AE_NO_MEMORY; 552 status = AE_NO_MEMORY;
1016 goto unlock_and_exit; 553 goto cleanup1;
1017 } 554 }
1018 555
1019 /* Init handler obj */ 556 args[1] = acpi_ut_create_integer_object((u64)function);
557 if (!args[1]) {
558 status = AE_NO_MEMORY;
559 goto cleanup2;
560 }
1020 561
1021 handler_obj->address_space.space_id = (u8) space_id; 562 args[2] = NULL; /* Terminate list */
1022 handler_obj->address_space.handler_flags = flags;
1023 handler_obj->address_space.region_list = NULL;
1024 handler_obj->address_space.node = node;
1025 handler_obj->address_space.handler = handler;
1026 handler_obj->address_space.context = context;
1027 handler_obj->address_space.setup = setup;
1028 563
1029 /* Install at head of Device.address_space list */ 564 /* Execute the method, no return value */
1030 565
1031 handler_obj->address_space.next = obj_desc->device.handler; 566 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
567 (ACPI_TYPE_METHOD, info->prefix_node, NULL));
1032 568
1033 /* 569 status = acpi_ns_evaluate(info);
1034 * The Device object is the first reference on the handler_obj. 570 acpi_ut_remove_reference(args[1]);
1035 * Each region that uses the handler adds a reference.
1036 */
1037 obj_desc->device.handler = handler_obj;
1038 571
1039 /* 572 cleanup2:
1040 * Walk the namespace finding all of the regions this 573 acpi_ut_remove_reference(args[0]);
1041 * handler will manage.
1042 *
1043 * Start at the device and search the branch toward
1044 * the leaf nodes until either the leaf is encountered or
1045 * a device is detected that has an address handler of the
1046 * same type.
1047 *
1048 * In either case, back up and search down the remainder
1049 * of the branch
1050 */
1051 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
1052 ACPI_NS_WALK_UNLOCK,
1053 acpi_ev_install_handler, NULL,
1054 handler_obj, NULL);
1055 574
1056 unlock_and_exit: 575 cleanup1:
576 ACPI_FREE(info);
1057 return_ACPI_STATUS(status); 577 return_ACPI_STATUS(status);
1058} 578}
1059 579
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 1474241bfc7e..3bb616794b3b 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evsci.c b/drivers/acpi/acpica/evsci.c
index f9661e2b46a9..f4b43bede015 100644
--- a/drivers/acpi/acpica/evsci.c
+++ b/drivers/acpi/acpica/evsci.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -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_UINT32(interrupt_handled); 92 return_VALUE(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_UINT32(interrupt_handled); 123 return_VALUE(interrupt_handled);
124} 124}
125 125
126/****************************************************************************** 126/******************************************************************************
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index ae668f32cf16..ddffd6847914 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -56,13 +56,13 @@ ACPI_MODULE_NAME("evxface")
56 * 56 *
57 * FUNCTION: acpi_install_notify_handler 57 * FUNCTION: acpi_install_notify_handler
58 * 58 *
59 * PARAMETERS: Device - The device for which notifies will be handled 59 * PARAMETERS: device - The device for which notifies will be handled
60 * handler_type - The type of handler: 60 * handler_type - The type of handler:
61 * ACPI_SYSTEM_NOTIFY: System Handler (00-7F) 61 * ACPI_SYSTEM_NOTIFY: System Handler (00-7F)
62 * ACPI_DEVICE_NOTIFY: Device Handler (80-FF) 62 * ACPI_DEVICE_NOTIFY: Device Handler (80-FF)
63 * ACPI_ALL_NOTIFY: Both System and Device 63 * ACPI_ALL_NOTIFY: Both System and Device
64 * Handler - Address of the handler 64 * handler - Address of the handler
65 * Context - Value passed to the handler on each GPE 65 * context - Value passed to the handler on each GPE
66 * 66 *
67 * RETURN: Status 67 * RETURN: Status
68 * 68 *
@@ -217,12 +217,12 @@ ACPI_EXPORT_SYMBOL(acpi_install_notify_handler)
217 * 217 *
218 * FUNCTION: acpi_remove_notify_handler 218 * FUNCTION: acpi_remove_notify_handler
219 * 219 *
220 * PARAMETERS: Device - The device for which the handler is installed 220 * PARAMETERS: device - The device for which the handler is installed
221 * handler_type - The type of handler: 221 * handler_type - The type of handler:
222 * ACPI_SYSTEM_NOTIFY: System Handler (00-7F) 222 * ACPI_SYSTEM_NOTIFY: System Handler (00-7F)
223 * ACPI_DEVICE_NOTIFY: Device Handler (80-FF) 223 * ACPI_DEVICE_NOTIFY: Device Handler (80-FF)
224 * ACPI_ALL_NOTIFY: Both System and Device 224 * ACPI_ALL_NOTIFY: Both System and Device
225 * Handler - Address of the handler 225 * handler - Address of the handler
226 * 226 *
227 * RETURN: Status 227 * RETURN: Status
228 * 228 *
@@ -249,7 +249,8 @@ acpi_remove_notify_handler(acpi_handle device,
249 (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { 249 (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
250 return_ACPI_STATUS(AE_BAD_PARAMETER); 250 return_ACPI_STATUS(AE_BAD_PARAMETER);
251 } 251 }
252 /* Make sure all deferred tasks are completed */ 252
253 /* Make sure all deferred notify tasks are completed */
253 254
254 acpi_os_wait_events_complete(); 255 acpi_os_wait_events_complete();
255 256
@@ -596,7 +597,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
596 return_ACPI_STATUS(status); 597 return_ACPI_STATUS(status);
597 } 598 }
598 599
599 /* Allocate memory for the handler object */ 600 /* Allocate and init handler object (before lock) */
600 601
601 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_handler_info)); 602 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_handler_info));
602 if (!handler) { 603 if (!handler) {
@@ -622,16 +623,15 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
622 goto free_and_exit; 623 goto free_and_exit;
623 } 624 }
624 625
625 /* Allocate and init handler object */
626
627 handler->address = address; 626 handler->address = address;
628 handler->context = context; 627 handler->context = context;
629 handler->method_node = gpe_event_info->dispatch.method_node; 628 handler->method_node = gpe_event_info->dispatch.method_node;
630 handler->original_flags = gpe_event_info->flags & 629 handler->original_flags = (u8)(gpe_event_info->flags &
631 (ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); 630 (ACPI_GPE_XRUPT_TYPE_MASK |
631 ACPI_GPE_DISPATCH_MASK));
632 632
633 /* 633 /*
634 * If the GPE is associated with a method, it might have been enabled 634 * If the GPE is associated with a method, it may have been enabled
635 * automatically during initialization, in which case it has to be 635 * automatically during initialization, in which case it has to be
636 * disabled now to avoid spurious execution of the handler. 636 * disabled now to avoid spurious execution of the handler.
637 */ 637 */
@@ -646,7 +646,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
646 646
647 gpe_event_info->dispatch.handler = handler; 647 gpe_event_info->dispatch.handler = handler;
648 648
649 /* Setup up dispatch flags to indicate handler (vs. method) */ 649 /* Setup up dispatch flags to indicate handler (vs. method/notify) */
650 650
651 gpe_event_info->flags &= 651 gpe_event_info->flags &=
652 ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); 652 ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
@@ -697,7 +697,7 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
697 return_ACPI_STATUS(AE_BAD_PARAMETER); 697 return_ACPI_STATUS(AE_BAD_PARAMETER);
698 } 698 }
699 699
700 /* Make sure all deferred tasks are completed */ 700 /* Make sure all deferred GPE tasks are completed */
701 701
702 acpi_os_wait_events_complete(); 702 acpi_os_wait_events_complete();
703 703
@@ -747,10 +747,10 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
747 * enabled, it should be enabled at this point to restore the 747 * enabled, it should be enabled at this point to restore the
748 * post-initialization configuration. 748 * post-initialization configuration.
749 */ 749 */
750 750 if ((handler->original_flags & ACPI_GPE_DISPATCH_METHOD) &&
751 if ((handler->original_flags & ACPI_GPE_DISPATCH_METHOD) 751 handler->originally_enabled) {
752 && handler->originally_enabled)
753 (void)acpi_ev_add_gpe_reference(gpe_event_info); 752 (void)acpi_ev_add_gpe_reference(gpe_event_info);
753 }
754 754
755 /* Now we can free the handler object */ 755 /* Now we can free the handler object */
756 756
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 35520c6eeefb..d6e4e42316db 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -61,7 +61,6 @@ ACPI_MODULE_NAME("evxfevnt")
61 * DESCRIPTION: Transfers the system into ACPI mode. 61 * DESCRIPTION: Transfers the system into ACPI mode.
62 * 62 *
63 ******************************************************************************/ 63 ******************************************************************************/
64
65acpi_status acpi_enable(void) 64acpi_status acpi_enable(void)
66{ 65{
67 acpi_status status; 66 acpi_status status;
@@ -210,8 +209,8 @@ ACPI_EXPORT_SYMBOL(acpi_enable_event)
210 * 209 *
211 * FUNCTION: acpi_disable_event 210 * FUNCTION: acpi_disable_event
212 * 211 *
213 * PARAMETERS: Event - The fixed eventto be enabled 212 * PARAMETERS: event - The fixed event to be disabled
214 * Flags - Reserved 213 * flags - Reserved
215 * 214 *
216 * RETURN: Status 215 * RETURN: Status
217 * 216 *
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c
index 3f30e753b652..aff4cc261211 100644
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,7 @@
51ACPI_MODULE_NAME("evxfgpe") 51ACPI_MODULE_NAME("evxfgpe")
52 52
53#if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 53#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
54/****************************************************************************** 54/*******************************************************************************
55 * 55 *
56 * FUNCTION: acpi_update_all_gpes 56 * FUNCTION: acpi_update_all_gpes
57 * 57 *
@@ -172,6 +172,7 @@ acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
172 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 172 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
173 return_ACPI_STATUS(status); 173 return_ACPI_STATUS(status);
174} 174}
175
175ACPI_EXPORT_SYMBOL(acpi_disable_gpe) 176ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
176 177
177 178
@@ -225,7 +226,7 @@ acpi_setup_gpe_for_wake(acpi_handle wake_device,
225 ACPI_CAST_PTR(struct acpi_namespace_node, wake_device); 226 ACPI_CAST_PTR(struct acpi_namespace_node, wake_device);
226 } 227 }
227 228
228 /* Validate WakeDevice is of type Device */ 229 /* Validate wake_device is of type Device */
229 230
230 if (device_node->type != ACPI_TYPE_DEVICE) { 231 if (device_node->type != ACPI_TYPE_DEVICE) {
231 return_ACPI_STATUS (AE_BAD_PARAMETER); 232 return_ACPI_STATUS (AE_BAD_PARAMETER);
@@ -432,8 +433,8 @@ ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
432 * 433 *
433 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1 434 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
434 * gpe_number - GPE level within the GPE block 435 * gpe_number - GPE level within the GPE block
435 * event_status - Where the current status of the event will 436 * event_status - Where the current status of the event
436 * be returned 437 * will be returned
437 * 438 *
438 * RETURN: Status 439 * RETURN: Status
439 * 440 *
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index 96b412d03950..96c9e5f355ae 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 16219bde48da..d93b70be60ad 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -48,6 +48,7 @@
48#include "actables.h" 48#include "actables.h"
49#include "acdispat.h" 49#include "acdispat.h"
50#include "acevents.h" 50#include "acevents.h"
51#include "amlcode.h"
51 52
52#define _COMPONENT ACPI_EXECUTER 53#define _COMPONENT ACPI_EXECUTER
53ACPI_MODULE_NAME("exconfig") 54ACPI_MODULE_NAME("exconfig")
@@ -120,8 +121,11 @@ acpi_ex_add_table(u32 table_index,
120 acpi_ns_exec_module_code_list(); 121 acpi_ns_exec_module_code_list();
121 acpi_ex_enter_interpreter(); 122 acpi_ex_enter_interpreter();
122 123
123 /* Update GPEs for any new _Lxx/_Exx methods. Ignore errors */ 124 /*
124 125 * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
126 * responsible for discovering any new wake GPEs by running _PRW methods
127 * that may have been loaded by this table.
128 */
125 status = acpi_tb_get_owner_id(table_index, &owner_id); 129 status = acpi_tb_get_owner_id(table_index, &owner_id);
126 if (ACPI_SUCCESS(status)) { 130 if (ACPI_SUCCESS(status)) {
127 acpi_ev_update_gpes(owner_id); 131 acpi_ev_update_gpes(owner_id);
@@ -158,12 +162,12 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
158 162
159 ACPI_FUNCTION_TRACE(ex_load_table_op); 163 ACPI_FUNCTION_TRACE(ex_load_table_op);
160 164
161 /* Validate lengths for the signature_string, OEMIDString, OEMtable_iD */ 165 /* Validate lengths for the Signature, oem_id, and oem_table_id strings */
162 166
163 if ((operand[0]->string.length > ACPI_NAME_SIZE) || 167 if ((operand[0]->string.length > ACPI_NAME_SIZE) ||
164 (operand[1]->string.length > ACPI_OEM_ID_SIZE) || 168 (operand[1]->string.length > ACPI_OEM_ID_SIZE) ||
165 (operand[2]->string.length > ACPI_OEM_TABLE_ID_SIZE)) { 169 (operand[2]->string.length > ACPI_OEM_TABLE_ID_SIZE)) {
166 return_ACPI_STATUS(AE_BAD_PARAMETER); 170 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
167 } 171 }
168 172
169 /* Find the ACPI table in the RSDT/XSDT */ 173 /* Find the ACPI table in the RSDT/XSDT */
@@ -210,8 +214,8 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
210 /* parameter_path (optional parameter) */ 214 /* parameter_path (optional parameter) */
211 215
212 if (operand[4]->string.length > 0) { 216 if (operand[4]->string.length > 0) {
213 if ((operand[4]->string.pointer[0] != '\\') && 217 if ((operand[4]->string.pointer[0] != AML_ROOT_PREFIX) &&
214 (operand[4]->string.pointer[0] != '^')) { 218 (operand[4]->string.pointer[0] != AML_PARENT_PREFIX)) {
215 /* 219 /*
216 * Path is not absolute, so it will be relative to the node 220 * Path is not absolute, so it will be relative to the node
217 * referenced by the root_path_string (or the NS root if omitted) 221 * referenced by the root_path_string (or the NS root if omitted)
@@ -301,7 +305,7 @@ acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
301 acpi_ev_address_space_dispatch(obj_desc, NULL, ACPI_READ, 305 acpi_ev_address_space_dispatch(obj_desc, NULL, ACPI_READ,
302 region_offset, 8, &value); 306 region_offset, 8, &value);
303 if (ACPI_FAILURE(status)) { 307 if (ACPI_FAILURE(status)) {
304 return status; 308 return (status);
305 } 309 }
306 310
307 *buffer = (u8)value; 311 *buffer = (u8)value;
@@ -309,7 +313,7 @@ acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
309 region_offset++; 313 region_offset++;
310 } 314 }
311 315
312 return AE_OK; 316 return (AE_OK);
313} 317}
314 318
315/******************************************************************************* 319/*******************************************************************************
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 4492a4e03022..d2b9613bbf01 100644
--- a/drivers/acpi/acpica/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -176,7 +176,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
176 176
177 /* Save the Result */ 177 /* Save the Result */
178 178
179 acpi_ex_truncate_for32bit_table(return_desc); 179 (void)acpi_ex_truncate_for32bit_table(return_desc);
180 *result_desc = return_desc; 180 *result_desc = return_desc;
181 return_ACPI_STATUS(AE_OK); 181 return_ACPI_STATUS(AE_OK);
182} 182}
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c
index 66554bc6f9a8..26a13f67977e 100644
--- a/drivers/acpi/acpica/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c
index d7c9f51608a7..7eb853cd279f 100644
--- a/drivers/acpi/acpica/exdebug.c
+++ b/drivers/acpi/acpica/exdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index 858b43a7dcf6..e5a3c249f7fa 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -464,9 +464,8 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
464 464
465 ACPI_FUNCTION_NAME(ex_dump_operand) 465 ACPI_FUNCTION_NAME(ex_dump_operand)
466 466
467 if (! 467 /* Check if debug output enabled */
468 ((ACPI_LV_EXEC & acpi_dbg_level) 468 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_EXEC, _COMPONENT)) {
469 && (_COMPONENT & acpi_dbg_layer))) {
470 return; 469 return;
471 } 470 }
472 471
@@ -811,9 +810,10 @@ void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags)
811 ACPI_FUNCTION_ENTRY(); 810 ACPI_FUNCTION_ENTRY();
812 811
813 if (!flags) { 812 if (!flags) {
814 if (! 813
815 ((ACPI_LV_OBJECTS & acpi_dbg_level) 814 /* Check if debug output enabled */
816 && (_COMPONENT & acpi_dbg_layer))) { 815
816 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_OBJECTS, _COMPONENT)) {
817 return; 817 return;
818 } 818 }
819 } 819 }
@@ -999,9 +999,10 @@ acpi_ex_dump_object_descriptor(union acpi_operand_object *obj_desc, u32 flags)
999 } 999 }
1000 1000
1001 if (!flags) { 1001 if (!flags) {
1002 if (! 1002
1003 ((ACPI_LV_OBJECTS & acpi_dbg_level) 1003 /* Check if debug output enabled */
1004 && (_COMPONENT & acpi_dbg_layer))) { 1004
1005 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_OBJECTS, _COMPONENT)) {
1005 return_VOID; 1006 return_VOID;
1006 } 1007 }
1007 } 1008 }
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index ebc55fbf3ff7..7d4bae71e8c6 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index aa2ccfb7cb61..ec7f5690031b 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -329,7 +329,6 @@ acpi_ex_access_region(union acpi_operand_object *obj_desc,
329static u8 329static u8
330acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value) 330acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)
331{ 331{
332 ACPI_FUNCTION_NAME(ex_register_overflow);
333 332
334 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) { 333 if (obj_desc->common_field.bit_length >= ACPI_INTEGER_BIT_SIZE) {
335 /* 334 /*
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c
index 84058705ed12..72a2a13b6d36 100644
--- a/drivers/acpi/acpica/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index d1f449d93dcf..7be0205ad067 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -377,7 +377,8 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
377 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); 377 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
378 } 378 }
379 379
380 /* Must have a valid thread. */ 380 /* Must have a valid thread ID */
381
381 if (!walk_state->thread) { 382 if (!walk_state->thread) {
382 ACPI_ERROR((AE_INFO, 383 ACPI_ERROR((AE_INFO,
383 "Cannot release Mutex [%4.4s], null thread info", 384 "Cannot release Mutex [%4.4s], null thread info",
diff --git a/drivers/acpi/acpica/exnames.c b/drivers/acpi/acpica/exnames.c
index 2ff578a16adc..14689dec4960 100644
--- a/drivers/acpi/acpica/exnames.c
+++ b/drivers/acpi/acpica/exnames.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index bbf01e9bf057..b60c877f5906 100644
--- a/drivers/acpi/acpica/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -948,13 +948,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
948 */ 948 */
949 return_desc = 949 return_desc =
950 acpi_ut_create_integer_object((u64) 950 acpi_ut_create_integer_object((u64)
951 temp_desc-> 951 temp_desc->buffer.pointer[operand[0]->reference.value]);
952 buffer.
953 pointer
954 [operand
955 [0]->
956 reference.
957 value]);
958 if (!return_desc) { 952 if (!return_desc) {
959 status = AE_NO_MEMORY; 953 status = AE_NO_MEMORY;
960 goto cleanup; 954 goto cleanup;
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index ee5634a074c4..e491e46f17df 100644
--- a/drivers/acpi/acpica/exoparg2.c
+++ b/drivers/acpi/acpica/exoparg2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index 2c89b4651f08..2d7491f3126e 100644
--- a/drivers/acpi/acpica/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c
index 3e08695c3b30..b76b97002dff 100644
--- a/drivers/acpi/acpica/exoparg6.c
+++ b/drivers/acpi/acpica/exoparg6.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index ba9db4de7c89..d6eab81f54fb 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -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_UINT32(0); 279 return_VALUE(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_UINT32(bit_length); 292 return_VALUE(bit_length);
293} 293}
294 294
295/******************************************************************************* 295/*******************************************************************************
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index 1db2c0bfde0b..182abaf045e1 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -142,9 +142,9 @@ acpi_ex_system_memory_space_handler(u32 function,
142 } 142 }
143 143
144 /* 144 /*
145 * Attempt to map from the requested address to the end of the region. 145 * October 2009: Attempt to map from the requested address to the
146 * However, we will never map more than one page, nor will we cross 146 * end of the region. However, we will never map more than one
147 * a page boundary. 147 * page, nor will we cross a page boundary.
148 */ 148 */
149 map_length = (acpi_size) 149 map_length = (acpi_size)
150 ((mem_info->address + mem_info->length) - address); 150 ((mem_info->address + mem_info->length) - address);
@@ -154,12 +154,15 @@ acpi_ex_system_memory_space_handler(u32 function,
154 * a page boundary, just map up to the page boundary, do not cross. 154 * a page boundary, just map up to the page boundary, do not cross.
155 * On some systems, crossing a page boundary while mapping regions 155 * On some systems, crossing a page boundary while mapping regions
156 * can cause warnings if the pages have different attributes 156 * can cause warnings if the pages have different attributes
157 * due to resource management 157 * due to resource management.
158 *
159 * This has the added benefit of constraining a single mapping to
160 * one page, which is similar to the original code that used a 4k
161 * maximum window.
158 */ 162 */
159 page_boundary_map_length = 163 page_boundary_map_length =
160 ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address; 164 ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address;
161 165 if (page_boundary_map_length == 0) {
162 if (!page_boundary_map_length) {
163 page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE; 166 page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE;
164 } 167 }
165 168
@@ -236,19 +239,19 @@ acpi_ex_system_memory_space_handler(u32 function,
236 239
237 switch (bit_width) { 240 switch (bit_width) {
238 case 8: 241 case 8:
239 ACPI_SET8(logical_addr_ptr) = (u8) * value; 242 ACPI_SET8(logical_addr_ptr, *value);
240 break; 243 break;
241 244
242 case 16: 245 case 16:
243 ACPI_SET16(logical_addr_ptr) = (u16) * value; 246 ACPI_SET16(logical_addr_ptr, *value);
244 break; 247 break;
245 248
246 case 32: 249 case 32:
247 ACPI_SET32(logical_addr_ptr) = (u32) * value; 250 ACPI_SET32(logical_addr_ptr, *value);
248 break; 251 break;
249 252
250 case 64: 253 case 64:
251 ACPI_SET64(logical_addr_ptr) = (u64) * value; 254 ACPI_SET64(logical_addr_ptr, *value);
252 break; 255 break;
253 256
254 default: 257 default:
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index 6239956786eb..8565b6bd12bb 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c
index cc176b245e22..e4f9dfbb2a13 100644
--- a/drivers/acpi/acpica/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c
index b9ebff2f6a09..9fb9f5e9a4da 100644
--- a/drivers/acpi/acpica/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index 90431f12f831..93c6049c2d75 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -487,14 +487,33 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
487 default: 487 default:
488 488
489 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 489 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
490 "Storing %s (%p) directly into node (%p) with no implicit conversion\n", 490 "Storing [%s] (%p) directly into node [%s] (%p)"
491 " with no implicit conversion\n",
491 acpi_ut_get_object_type_name(source_desc), 492 acpi_ut_get_object_type_name(source_desc),
492 source_desc, node)); 493 source_desc,
494 acpi_ut_get_object_type_name(target_desc),
495 node));
493 496
494 /* No conversions for all other types. Just attach the source object */ 497 /*
498 * No conversions for all other types. Directly store a copy of
499 * the source object. NOTE: This is a departure from the ACPI
500 * spec, which states "If conversion is impossible, abort the
501 * running control method".
502 *
503 * This code implements "If conversion is impossible, treat the
504 * Store operation as a CopyObject".
505 */
506 status =
507 acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc,
508 walk_state);
509 if (ACPI_FAILURE(status)) {
510 return_ACPI_STATUS(status);
511 }
495 512
496 status = acpi_ns_attach_object(node, source_desc, 513 status =
497 source_desc->common.type); 514 acpi_ns_attach_object(node, new_desc,
515 new_desc->common.type);
516 acpi_ut_remove_reference(new_desc);
498 break; 517 break;
499 } 518 }
500 519
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c
index 87153bbc4b43..1cefe777068e 100644
--- a/drivers/acpi/acpica/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -253,7 +253,7 @@ acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
253 253
254 /* Truncate value if we are executing from a 32-bit ACPI table */ 254 /* Truncate value if we are executing from a 32-bit ACPI table */
255 255
256 acpi_ex_truncate_for32bit_table(dest_desc); 256 (void)acpi_ex_truncate_for32bit_table(dest_desc);
257 break; 257 break;
258 258
259 case ACPI_TYPE_STRING: 259 case ACPI_TYPE_STRING:
diff --git a/drivers/acpi/acpica/exstorob.c b/drivers/acpi/acpica/exstorob.c
index b5f339cb1305..26e371073b1a 100644
--- a/drivers/acpi/acpica/exstorob.c
+++ b/drivers/acpi/acpica/exstorob.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exsystem.c b/drivers/acpi/acpica/exsystem.c
index c8a0ad5c1f55..6578dee2e51b 100644
--- a/drivers/acpi/acpica/exsystem.c
+++ b/drivers/acpi/acpica/exsystem.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c
index 264d22d8018c..b205cbb4b50c 100644
--- a/drivers/acpi/acpica/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -202,35 +202,39 @@ void acpi_ex_relinquish_interpreter(void)
202 * 202 *
203 * PARAMETERS: obj_desc - Object to be truncated 203 * PARAMETERS: obj_desc - Object to be truncated
204 * 204 *
205 * RETURN: none 205 * RETURN: TRUE if a truncation was performed, FALSE otherwise.
206 * 206 *
207 * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is 207 * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is
208 * 32-bit, as determined by the revision of the DSDT. 208 * 32-bit, as determined by the revision of the DSDT.
209 * 209 *
210 ******************************************************************************/ 210 ******************************************************************************/
211 211
212void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc) 212u8 acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
213{ 213{
214 214
215 ACPI_FUNCTION_ENTRY(); 215 ACPI_FUNCTION_ENTRY();
216 216
217 /* 217 /*
218 * Object must be a valid number and we must be executing 218 * Object must be a valid number and we must be executing
219 * a control method. NS node could be there for AML_INT_NAMEPATH_OP. 219 * a control method. Object could be NS node for AML_INT_NAMEPATH_OP.
220 */ 220 */
221 if ((!obj_desc) || 221 if ((!obj_desc) ||
222 (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) || 222 (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) ||
223 (obj_desc->common.type != ACPI_TYPE_INTEGER)) { 223 (obj_desc->common.type != ACPI_TYPE_INTEGER)) {
224 return; 224 return (FALSE);
225 } 225 }
226 226
227 if (acpi_gbl_integer_byte_width == 4) { 227 if ((acpi_gbl_integer_byte_width == 4) &&
228 (obj_desc->integer.value > (u64)ACPI_UINT32_MAX)) {
228 /* 229 /*
229 * We are running a method that exists in a 32-bit ACPI table. 230 * We are executing in a 32-bit ACPI table.
230 * Truncate the value to 32 bits by zeroing out the upper 32-bit field 231 * Truncate the value to 32 bits by zeroing out the upper 32-bit field
231 */ 232 */
232 obj_desc->integer.value &= (u64) ACPI_UINT32_MAX; 233 obj_desc->integer.value &= (u64)ACPI_UINT32_MAX;
234 return (TRUE);
233 } 235 }
236
237 return (FALSE);
234} 238}
235 239
236/******************************************************************************* 240/*******************************************************************************
@@ -336,7 +340,7 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base)
336 /* u64 is unsigned, so we don't worry about a '-' prefix */ 340 /* u64 is unsigned, so we don't worry about a '-' prefix */
337 341
338 if (value == 0) { 342 if (value == 0) {
339 return_UINT32(1); 343 return_VALUE(1);
340 } 344 }
341 345
342 current_value = value; 346 current_value = value;
@@ -350,7 +354,7 @@ static u32 acpi_ex_digits_needed(u64 value, u32 base)
350 num_digits++; 354 num_digits++;
351 } 355 }
352 356
353 return_UINT32(num_digits); 357 return_VALUE(num_digits);
354} 358}
355 359
356/******************************************************************************* 360/*******************************************************************************
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index 90a9aea1cee9..deb3f61e2bd1 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -108,8 +108,7 @@ acpi_status acpi_hw_set_mode(u32 mode)
108 * enable bits to default 108 * enable bits to default
109 */ 109 */
110 status = acpi_hw_write_port(acpi_gbl_FADT.smi_command, 110 status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
111 (u32) acpi_gbl_FADT.acpi_disable, 111 (u32)acpi_gbl_FADT.acpi_disable, 8);
112 8);
113 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 112 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
114 "Attempting to enable Legacy (non-ACPI) mode\n")); 113 "Attempting to enable Legacy (non-ACPI) mode\n"));
115 break; 114 break;
@@ -152,18 +151,18 @@ u32 acpi_hw_get_mode(void)
152 * system does not support mode transition. 151 * system does not support mode transition.
153 */ 152 */
154 if (!acpi_gbl_FADT.smi_command) { 153 if (!acpi_gbl_FADT.smi_command) {
155 return_UINT32(ACPI_SYS_MODE_ACPI); 154 return_VALUE(ACPI_SYS_MODE_ACPI);
156 } 155 }
157 156
158 status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value); 157 status = acpi_read_bit_register(ACPI_BITREG_SCI_ENABLE, &value);
159 if (ACPI_FAILURE(status)) { 158 if (ACPI_FAILURE(status)) {
160 return_UINT32(ACPI_SYS_MODE_LEGACY); 159 return_VALUE(ACPI_SYS_MODE_LEGACY);
161 } 160 }
162 161
163 if (value) { 162 if (value) {
164 return_UINT32(ACPI_SYS_MODE_ACPI); 163 return_VALUE(ACPI_SYS_MODE_ACPI);
165 } else { 164 } else {
166 return_UINT32(ACPI_SYS_MODE_LEGACY); 165 return_VALUE(ACPI_SYS_MODE_LEGACY);
167 } 166 }
168} 167}
169 168
diff --git a/drivers/acpi/acpica/hwesleep.c b/drivers/acpi/acpica/hwesleep.c
index 94996f9ae3ad..5e5f76230f5e 100644
--- a/drivers/acpi/acpica/hwesleep.c
+++ b/drivers/acpi/acpica/hwesleep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -200,7 +200,6 @@ acpi_status acpi_hw_extended_wake_prep(u8 sleep_state)
200 * FUNCTION: acpi_hw_extended_wake 200 * FUNCTION: acpi_hw_extended_wake
201 * 201 *
202 * PARAMETERS: sleep_state - Which sleep state we just exited 202 * PARAMETERS: sleep_state - Which sleep state we just exited
203 * flags - Reserved, set to zero
204 * 203 *
205 * RETURN: Status 204 * RETURN: Status
206 * 205 *
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 64560045052d..20d02e93c990 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -69,8 +69,10 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
69 69
70u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info) 70u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info)
71{ 71{
72 return (u32)1 << (gpe_event_info->gpe_number - 72
73 gpe_event_info->register_info->base_gpe_number); 73 return ((u32)1 <<
74 (gpe_event_info->gpe_number -
75 gpe_event_info->register_info->base_gpe_number));
74} 76}
75 77
76/****************************************************************************** 78/******************************************************************************
@@ -133,7 +135,7 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
133 break; 135 break;
134 136
135 default: 137 default:
136 ACPI_ERROR((AE_INFO, "Invalid GPE Action, %u\n", action)); 138 ACPI_ERROR((AE_INFO, "Invalid GPE Action, %u", action));
137 return (AE_BAD_PARAMETER); 139 return (AE_BAD_PARAMETER);
138 } 140 }
139 141
diff --git a/drivers/acpi/acpica/hwpci.c b/drivers/acpi/acpica/hwpci.c
index 65bc3453a29c..0889a629505f 100644
--- a/drivers/acpi/acpica/hwpci.c
+++ b/drivers/acpi/acpica/hwpci.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index f4e57503576b..083d6551f0e2 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,6 @@
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "acnamesp.h"
48#include "acevents.h" 47#include "acevents.h"
49 48
50#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
@@ -364,8 +363,7 @@ acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control)
364 * DESCRIPTION: Read from the specified ACPI register 363 * DESCRIPTION: Read from the specified ACPI register
365 * 364 *
366 ******************************************************************************/ 365 ******************************************************************************/
367acpi_status 366acpi_status acpi_hw_register_read(u32 register_id, u32 *return_value)
368acpi_hw_register_read(u32 register_id, u32 * return_value)
369{ 367{
370 u32 value = 0; 368 u32 value = 0;
371 acpi_status status; 369 acpi_status status;
@@ -485,7 +483,7 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value)
485 &acpi_gbl_xpm1b_status); 483 &acpi_gbl_xpm1b_status);
486 break; 484 break;
487 485
488 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access */ 486 case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */
489 487
490 status = acpi_hw_write_multiple(value, 488 status = acpi_hw_write_multiple(value,
491 &acpi_gbl_xpm1a_enable, 489 &acpi_gbl_xpm1a_enable,
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index 3fddde056a5e..e3828cc4361b 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -45,7 +45,6 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <linux/acpi.h> 46#include <linux/acpi.h>
47#include "accommon.h" 47#include "accommon.h"
48#include <linux/module.h>
49 48
50#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
51ACPI_MODULE_NAME("hwsleep") 50ACPI_MODULE_NAME("hwsleep")
@@ -178,7 +177,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
178 * to still read the right value. Ideally, this block would go 177 * to still read the right value. Ideally, this block would go
179 * away entirely. 178 * away entirely.
180 */ 179 */
181 acpi_os_stall(10000000); 180 acpi_os_stall(10 * ACPI_USEC_PER_SEC);
182 181
183 status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, 182 status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
184 sleep_enable_reg_info-> 183 sleep_enable_reg_info->
@@ -323,7 +322,8 @@ acpi_status acpi_hw_legacy_wake(u8 sleep_state)
323 * and use it to determine whether the system is rebooting or 322 * and use it to determine whether the system is rebooting or
324 * resuming. Clear WAK_STS for compatibility. 323 * resuming. Clear WAK_STS for compatibility.
325 */ 324 */
326 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); 325 (void)acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS,
326 ACPI_CLEAR_STATUS);
327 acpi_gbl_system_awake_and_running = TRUE; 327 acpi_gbl_system_awake_and_running = TRUE;
328 328
329 /* Enable power button */ 329 /* Enable power button */
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index bfdce22f3798..0c1a8bbd05d6 100644
--- a/drivers/acpi/acpica/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -176,10 +176,11 @@ acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed)
176 /* 176 /*
177 * Compute Duration (Requires a 64-bit multiply and divide): 177 * Compute Duration (Requires a 64-bit multiply and divide):
178 * 178 *
179 * time_elapsed = (delta_ticks * 1000000) / PM_TIMER_FREQUENCY; 179 * time_elapsed (microseconds) =
180 * (delta_ticks * ACPI_USEC_PER_SEC) / ACPI_PM_TIMER_FREQUENCY;
180 */ 181 */
181 status = acpi_ut_short_divide(((u64) delta_ticks) * 1000000, 182 status = acpi_ut_short_divide(((u64)delta_ticks) * ACPI_USEC_PER_SEC,
182 PM_TIMER_FREQUENCY, &quotient, NULL); 183 ACPI_PM_TIMER_FREQUENCY, &quotient, NULL);
183 184
184 *time_elapsed = (u32) quotient; 185 *time_elapsed = (u32) quotient;
185 return_ACPI_STATUS(status); 186 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
index b6aae58299dc..eab70d58852a 100644
--- a/drivers/acpi/acpica/hwvalid.c
+++ b/drivers/acpi/acpica/hwvalid.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -135,7 +135,7 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width)
135 if ((bit_width != 8) && (bit_width != 16) && (bit_width != 32)) { 135 if ((bit_width != 8) && (bit_width != 16) && (bit_width != 32)) {
136 ACPI_ERROR((AE_INFO, 136 ACPI_ERROR((AE_INFO,
137 "Bad BitWidth parameter: %8.8X", bit_width)); 137 "Bad BitWidth parameter: %8.8X", bit_width));
138 return AE_BAD_PARAMETER; 138 return (AE_BAD_PARAMETER);
139 } 139 }
140 140
141 port_info = acpi_protected_ports; 141 port_info = acpi_protected_ports;
@@ -234,11 +234,11 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width)
234 status = acpi_hw_validate_io_request(address, width); 234 status = acpi_hw_validate_io_request(address, width);
235 if (ACPI_SUCCESS(status)) { 235 if (ACPI_SUCCESS(status)) {
236 status = acpi_os_read_port(address, value, width); 236 status = acpi_os_read_port(address, value, width);
237 return status; 237 return (status);
238 } 238 }
239 239
240 if (status != AE_AML_ILLEGAL_ADDRESS) { 240 if (status != AE_AML_ILLEGAL_ADDRESS) {
241 return status; 241 return (status);
242 } 242 }
243 243
244 /* 244 /*
@@ -253,7 +253,7 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width)
253 if (acpi_hw_validate_io_request(address, 8) == AE_OK) { 253 if (acpi_hw_validate_io_request(address, 8) == AE_OK) {
254 status = acpi_os_read_port(address, &one_byte, 8); 254 status = acpi_os_read_port(address, &one_byte, 8);
255 if (ACPI_FAILURE(status)) { 255 if (ACPI_FAILURE(status)) {
256 return status; 256 return (status);
257 } 257 }
258 258
259 *value |= (one_byte << i); 259 *value |= (one_byte << i);
@@ -262,7 +262,7 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width)
262 address++; 262 address++;
263 } 263 }
264 264
265 return AE_OK; 265 return (AE_OK);
266} 266}
267 267
268/****************************************************************************** 268/******************************************************************************
@@ -297,11 +297,11 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width)
297 status = acpi_hw_validate_io_request(address, width); 297 status = acpi_hw_validate_io_request(address, width);
298 if (ACPI_SUCCESS(status)) { 298 if (ACPI_SUCCESS(status)) {
299 status = acpi_os_write_port(address, value, width); 299 status = acpi_os_write_port(address, value, width);
300 return status; 300 return (status);
301 } 301 }
302 302
303 if (status != AE_AML_ILLEGAL_ADDRESS) { 303 if (status != AE_AML_ILLEGAL_ADDRESS) {
304 return status; 304 return (status);
305 } 305 }
306 306
307 /* 307 /*
@@ -317,12 +317,12 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width)
317 status = 317 status =
318 acpi_os_write_port(address, (value >> i) & 0xFF, 8); 318 acpi_os_write_port(address, (value >> i) & 0xFF, 8);
319 if (ACPI_FAILURE(status)) { 319 if (ACPI_FAILURE(status)) {
320 return status; 320 return (status);
321 } 321 }
322 } 322 }
323 323
324 address++; 324 address++;
325 } 325 }
326 326
327 return AE_OK; 327 return (AE_OK);
328} 328}
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 05a154c3c9ac..04c2e16f2c0a 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -80,10 +80,10 @@ acpi_status acpi_reset(void)
80 80
81 if (reset_reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { 81 if (reset_reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
82 /* 82 /*
83 * For I/O space, write directly to the OSL. This 83 * For I/O space, write directly to the OSL. This bypasses the port
84 * bypasses the port validation mechanism, which may 84 * validation mechanism, which may block a valid write to the reset
85 * block a valid write to the reset register. Spec 85 * register.
86 * section 4.7.3.6 requires register width to be 8. 86 * Spec section 4.7.3.6 requires register width to be 8.
87 */ 87 */
88 status = 88 status =
89 acpi_os_write_port((acpi_io_address) reset_reg->address, 89 acpi_os_write_port((acpi_io_address) reset_reg->address,
@@ -333,7 +333,7 @@ ACPI_EXPORT_SYMBOL(acpi_read_bit_register)
333 * FUNCTION: acpi_write_bit_register 333 * FUNCTION: acpi_write_bit_register
334 * 334 *
335 * PARAMETERS: register_id - ID of ACPI Bit Register to access 335 * PARAMETERS: register_id - ID of ACPI Bit Register to access
336 * Value - Value to write to the register, in bit 336 * value - Value to write to the register, in bit
337 * position zero. The bit is automatically 337 * position zero. The bit is automatically
338 * shifted to the correct position. 338 * shifted to the correct position.
339 * 339 *
@@ -440,17 +440,41 @@ ACPI_EXPORT_SYMBOL(acpi_write_bit_register)
440 * *sleep_type_a - Where SLP_TYPa is returned 440 * *sleep_type_a - Where SLP_TYPa is returned
441 * *sleep_type_b - Where SLP_TYPb is returned 441 * *sleep_type_b - Where SLP_TYPb is returned
442 * 442 *
443 * RETURN: status - ACPI status 443 * RETURN: Status
444 *
445 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested
446 * sleep state via the appropriate \_Sx object.
447 *
448 * The sleep state package returned from the corresponding \_Sx_ object
449 * must contain at least one integer.
450 *
451 * March 2005:
452 * Added support for a package that contains two integers. This
453 * goes against the ACPI specification which defines this object as a
454 * package with one encoded DWORD integer. However, existing practice
455 * by many BIOS vendors is to return a package with 2 or more integer
456 * elements, at least one per sleep type (A/B).
444 * 457 *
445 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep 458 * January 2013:
446 * state. 459 * Therefore, we must be prepared to accept a package with either a
460 * single integer or multiple integers.
461 *
462 * The single integer DWORD format is as follows:
463 * BYTE 0 - Value for the PM1A SLP_TYP register
464 * BYTE 1 - Value for the PM1B SLP_TYP register
465 * BYTE 2-3 - Reserved
466 *
467 * The dual integer format is as follows:
468 * Integer 0 - Value for the PM1A SLP_TYP register
469 * Integer 1 - Value for the PM1A SLP_TYP register
447 * 470 *
448 ******************************************************************************/ 471 ******************************************************************************/
449acpi_status 472acpi_status
450acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) 473acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
451{ 474{
452 acpi_status status = AE_OK; 475 acpi_status status;
453 struct acpi_evaluate_info *info; 476 struct acpi_evaluate_info *info;
477 union acpi_operand_object **elements;
454 478
455 ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data); 479 ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data);
456 480
@@ -467,18 +491,14 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
467 return_ACPI_STATUS(AE_NO_MEMORY); 491 return_ACPI_STATUS(AE_NO_MEMORY);
468 } 492 }
469 493
494 /*
495 * Evaluate the \_Sx namespace object containing the register values
496 * for this state
497 */
470 info->pathname = 498 info->pathname =
471 ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]); 499 ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]);
472
473 /* Evaluate the namespace object containing the values for this state */
474
475 status = acpi_ns_evaluate(info); 500 status = acpi_ns_evaluate(info);
476 if (ACPI_FAILURE(status)) { 501 if (ACPI_FAILURE(status)) {
477 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
478 "%s while evaluating SleepState [%s]\n",
479 acpi_format_exception(status),
480 info->pathname));
481
482 goto cleanup; 502 goto cleanup;
483 } 503 }
484 504
@@ -487,64 +507,67 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
487 if (!info->return_object) { 507 if (!info->return_object) {
488 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", 508 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]",
489 info->pathname)); 509 info->pathname));
490 status = AE_NOT_EXIST; 510 status = AE_AML_NO_RETURN_VALUE;
511 goto cleanup;
491 } 512 }
492 513
493 /* It must be of type Package */ 514 /* Return object must be of type Package */
494 515
495 else if (info->return_object->common.type != ACPI_TYPE_PACKAGE) { 516 if (info->return_object->common.type != ACPI_TYPE_PACKAGE) {
496 ACPI_ERROR((AE_INFO, 517 ACPI_ERROR((AE_INFO,
497 "Sleep State return object is not a Package")); 518 "Sleep State return object is not a Package"));
498 status = AE_AML_OPERAND_TYPE; 519 status = AE_AML_OPERAND_TYPE;
520 goto cleanup1;
499 } 521 }
500 522
501 /* 523 /*
502 * The package must have at least two elements. NOTE (March 2005): This 524 * Any warnings about the package length or the object types have
503 * goes against the current ACPI spec which defines this object as a 525 * already been issued by the predefined name module -- there is no
504 * package with one encoded DWORD element. However, existing practice 526 * need to repeat them here.
505 * by BIOS vendors seems to be to have 2 or more elements, at least
506 * one per sleep type (A/B).
507 */ 527 */
508 else if (info->return_object->package.count < 2) { 528 elements = info->return_object->package.elements;
509 ACPI_ERROR((AE_INFO, 529 switch (info->return_object->package.count) {
510 "Sleep State return package does not have at least two elements")); 530 case 0:
511 status = AE_AML_NO_OPERAND; 531 status = AE_AML_PACKAGE_LIMIT;
512 } 532 break;
533
534 case 1:
535 if (elements[0]->common.type != ACPI_TYPE_INTEGER) {
536 status = AE_AML_OPERAND_TYPE;
537 break;
538 }
513 539
514 /* The first two elements must both be of type Integer */ 540 /* A valid _Sx_ package with one integer */
515 541
516 else if (((info->return_object->package.elements[0])->common.type 542 *sleep_type_a = (u8)elements[0]->integer.value;
517 != ACPI_TYPE_INTEGER) || 543 *sleep_type_b = (u8)(elements[0]->integer.value >> 8);
518 ((info->return_object->package.elements[1])->common.type 544 break;
519 != ACPI_TYPE_INTEGER)) {
520 ACPI_ERROR((AE_INFO,
521 "Sleep State return package elements are not both Integers "
522 "(%s, %s)",
523 acpi_ut_get_object_type_name(info->return_object->
524 package.elements[0]),
525 acpi_ut_get_object_type_name(info->return_object->
526 package.elements[1])));
527 status = AE_AML_OPERAND_TYPE;
528 } else {
529 /* Valid _Sx_ package size, type, and value */
530 545
531 *sleep_type_a = (u8) 546 case 2:
532 (info->return_object->package.elements[0])->integer.value; 547 default:
533 *sleep_type_b = (u8) 548 if ((elements[0]->common.type != ACPI_TYPE_INTEGER) ||
534 (info->return_object->package.elements[1])->integer.value; 549 (elements[1]->common.type != ACPI_TYPE_INTEGER)) {
535 } 550 status = AE_AML_OPERAND_TYPE;
551 break;
552 }
536 553
537 if (ACPI_FAILURE(status)) { 554 /* A valid _Sx_ package with two integers */
538 ACPI_EXCEPTION((AE_INFO, status, 555
539 "While evaluating SleepState [%s], bad Sleep object %p type %s", 556 *sleep_type_a = (u8)elements[0]->integer.value;
540 info->pathname, info->return_object, 557 *sleep_type_b = (u8)elements[1]->integer.value;
541 acpi_ut_get_object_type_name(info-> 558 break;
542 return_object)));
543 } 559 }
544 560
561 cleanup1:
545 acpi_ut_remove_reference(info->return_object); 562 acpi_ut_remove_reference(info->return_object);
546 563
547 cleanup: 564 cleanup:
565 if (ACPI_FAILURE(status)) {
566 ACPI_EXCEPTION((AE_INFO, status,
567 "While evaluating Sleep State [%s]",
568 info->pathname));
569 }
570
548 ACPI_FREE(info); 571 ACPI_FREE(info);
549 return_ACPI_STATUS(status); 572 return_ACPI_STATUS(status);
550} 573}
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
index ae443fe2ebf6..35eebdac0f9d 100644
--- a/drivers/acpi/acpica/hwxfsleep.c
+++ b/drivers/acpi/acpica/hwxfsleep.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -41,9 +41,9 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/export.h>
44#include <acpi/acpi.h> 45#include <acpi/acpi.h>
45#include "accommon.h" 46#include "accommon.h"
46#include <linux/module.h>
47 47
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwxfsleep") 49ACPI_MODULE_NAME("hwxfsleep")
@@ -207,7 +207,7 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
207 (u32)acpi_gbl_FADT.s4_bios_request, 8); 207 (u32)acpi_gbl_FADT.s4_bios_request, 8);
208 208
209 do { 209 do {
210 acpi_os_stall(1000); 210 acpi_os_stall(ACPI_USEC_PER_MSEC);
211 status = 211 status =
212 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value); 212 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
213 if (ACPI_FAILURE(status)) { 213 if (ACPI_FAILURE(status)) {
@@ -350,7 +350,7 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)
350 * 350 *
351 * RETURN: Status 351 * RETURN: Status
352 * 352 *
353 * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231) 353 * DESCRIPTION: Enter a system sleep state
354 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 354 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
355 * 355 *
356 ******************************************************************************/ 356 ******************************************************************************/
@@ -382,8 +382,9 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
382 * RETURN: Status 382 * RETURN: Status
383 * 383 *
384 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a 384 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
385 * sleep. 385 * sleep. Called with interrupts DISABLED.
386 * Called with interrupts DISABLED. 386 * We break wake/resume into 2 stages so that OSPM can handle
387 * various OS-specific tasks between the two steps.
387 * 388 *
388 ******************************************************************************/ 389 ******************************************************************************/
389acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) 390acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index d70eaf39dfdf..8769cf83b044 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index 15143c44f5e5..243737363fb8 100644
--- a/drivers/acpi/acpica/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index 924b3c71473a..ce6e97326205 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,7 @@
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h" 45#include "accommon.h"
46#include "acnamesp.h" 46#include "acnamesp.h"
47#include <acpi/acoutput.h>
47 48
48#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsdump") 50ACPI_MODULE_NAME("nsdump")
@@ -77,8 +78,9 @@ void acpi_ns_print_pathname(u32 num_segments, char *pathname)
77 78
78 ACPI_FUNCTION_NAME(ns_print_pathname); 79 ACPI_FUNCTION_NAME(ns_print_pathname);
79 80
80 if (!(acpi_dbg_level & ACPI_LV_NAMES) 81 /* Check if debug output enabled */
81 || !(acpi_dbg_layer & ACPI_NAMESPACE)) { 82
83 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_NAMES, ACPI_NAMESPACE)) {
82 return; 84 return;
83 } 85 }
84 86
@@ -127,7 +129,7 @@ acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component)
127 129
128 /* Do this only if the requested debug level and component are enabled */ 130 /* Do this only if the requested debug level and component are enabled */
129 131
130 if (!(acpi_dbg_level & level) || !(acpi_dbg_layer & component)) { 132 if (!ACPI_IS_DEBUG_ENABLED(level, component)) {
131 return_VOID; 133 return_VOID;
132 } 134 }
133 135
@@ -729,5 +731,5 @@ void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth)
729 ACPI_OWNER_ID_MAX, search_handle); 731 ACPI_OWNER_ID_MAX, search_handle);
730 return_VOID; 732 return_VOID;
731} 733}
732#endif /* _ACPI_ASL_COMPILER */ 734#endif
733#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */ 735#endif
diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index 944d4c8d9438..409ae80824d1 100644
--- a/drivers/acpi/acpica/nsdumpdv.c
+++ b/drivers/acpi/acpica/nsdumpdv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,6 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
46 45
47/* TBD: This entire module is apparently obsolete and should be removed */ 46/* TBD: This entire module is apparently obsolete and should be removed */
48 47
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index 69074be498e8..1538f3eb2a8f 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 4328e2adfeb9..2a431ec50a25 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,6 @@
46#include "acnamesp.h" 46#include "acnamesp.h"
47#include "acdispat.h" 47#include "acdispat.h"
48#include "acinterp.h" 48#include "acinterp.h"
49#include <linux/nmi.h>
50 49
51#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
52ACPI_MODULE_NAME("nsinit") 51ACPI_MODULE_NAME("nsinit")
@@ -87,7 +86,7 @@ acpi_status acpi_ns_initialize_objects(void)
87 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 86 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
88 "**** Starting initialization of namespace objects ****\n")); 87 "**** Starting initialization of namespace objects ****\n"));
89 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 88 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
90 "Completing Region/Field/Buffer/Package initialization:")); 89 "Completing Region/Field/Buffer/Package initialization:\n"));
91 90
92 /* Set all init info to zero */ 91 /* Set all init info to zero */
93 92
@@ -103,7 +102,7 @@ acpi_status acpi_ns_initialize_objects(void)
103 } 102 }
104 103
105 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 104 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
106 "\nInitialized %u/%u Regions %u/%u Fields %u/%u " 105 " Initialized %u/%u Regions %u/%u Fields %u/%u "
107 "Buffers %u/%u Packages (%u nodes)\n", 106 "Buffers %u/%u Packages (%u nodes)\n",
108 info.op_region_init, info.op_region_count, 107 info.op_region_init, info.op_region_count,
109 info.field_init, info.field_count, 108 info.field_init, info.field_count,
@@ -150,7 +149,7 @@ acpi_status acpi_ns_initialize_devices(void)
150 149
151 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 150 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
152 "Initializing Device/Processor/Thermal objects " 151 "Initializing Device/Processor/Thermal objects "
153 "by executing _INI methods:")); 152 "and executing _INI/_STA methods:\n"));
154 153
155 /* Tree analysis: find all subtrees that contain _INI methods */ 154 /* Tree analysis: find all subtrees that contain _INI methods */
156 155
@@ -208,7 +207,7 @@ acpi_status acpi_ns_initialize_devices(void)
208 } 207 }
209 208
210 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, 209 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
211 "\nExecuted %u _INI methods requiring %u _STA executions " 210 " Executed %u _INI methods requiring %u _STA executions "
212 "(examined %u objects)\n", 211 "(examined %u objects)\n",
213 info.num_INI, info.num_STA, info.device_count)); 212 info.num_INI, info.num_STA, info.device_count));
214 213
@@ -350,14 +349,6 @@ acpi_ns_init_one_object(acpi_handle obj_handle,
350 } 349 }
351 350
352 /* 351 /*
353 * Print a dot for each object unless we are going to print the entire
354 * pathname
355 */
356 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
357 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
358 }
359
360 /*
361 * We ignore errors from above, and always return OK, since we don't want 352 * We ignore errors from above, and always return OK, since we don't want
362 * to abort the walk on any single error. 353 * to abort the walk on any single error.
363 */ 354 */
@@ -572,20 +563,10 @@ acpi_ns_init_one_device(acpi_handle obj_handle,
572 info->parameters = NULL; 563 info->parameters = NULL;
573 info->flags = ACPI_IGNORE_RETURN_VALUE; 564 info->flags = ACPI_IGNORE_RETURN_VALUE;
574 565
575 /*
576 * Some hardware relies on this being executed as atomically
577 * as possible (without an NMI being received in the middle of
578 * this) - so disable NMIs and initialize the device:
579 */
580 status = acpi_ns_evaluate(info); 566 status = acpi_ns_evaluate(info);
581 567
582 if (ACPI_SUCCESS(status)) { 568 if (ACPI_SUCCESS(status)) {
583 walk_info->num_INI++; 569 walk_info->num_INI++;
584
585 if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) &&
586 (!(acpi_dbg_level & ACPI_LV_INFO))) {
587 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
588 }
589 } 570 }
590#ifdef ACPI_DEBUG_OUTPUT 571#ifdef ACPI_DEBUG_OUTPUT
591 else if (status != AE_NOT_FOUND) { 572 else if (status != AE_NOT_FOUND) {
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index 911f99127b99..0a7badc3179f 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index 55a175eadcc3..90a0380fb8a0 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -126,7 +126,8 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node,
126 * the node, In external format (name segments separated by path 126 * the node, In external format (name segments separated by path
127 * separators.) 127 * separators.)
128 * 128 *
129 * DESCRIPTION: Used for debug printing in acpi_ns_search_table(). 129 * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually
130 * for error and debug statements.
130 * 131 *
131 ******************************************************************************/ 132 ******************************************************************************/
132 133
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
index e69f7fa2579d..7a736f4d1fd8 100644
--- a/drivers/acpi/acpica/nsobject.c
+++ b/drivers/acpi/acpica/nsobject.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index 233f756d5cfa..35dde8151c0d 100644
--- a/drivers/acpi/acpica/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 2419f417ea33..224c30053401 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -1,12 +1,11 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Module Name: nspredef - Validation of ACPI predefined methods and objects 3 * Module Name: nspredef - Validation of ACPI predefined methods and objects
4 * $Revision: 1.1 $
5 * 4 *
6 *****************************************************************************/ 5 *****************************************************************************/
7 6
8/* 7/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 9 * All rights reserved.
11 * 10 *
12 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -74,27 +73,6 @@ ACPI_MODULE_NAME("nspredef")
74 ******************************************************************************/ 73 ******************************************************************************/
75/* Local prototypes */ 74/* Local prototypes */
76static acpi_status 75static acpi_status
77acpi_ns_check_package(struct acpi_predefined_data *data,
78 union acpi_operand_object **return_object_ptr);
79
80static acpi_status
81acpi_ns_check_package_list(struct acpi_predefined_data *data,
82 const union acpi_predefined_info *package,
83 union acpi_operand_object **elements, u32 count);
84
85static acpi_status
86acpi_ns_check_package_elements(struct acpi_predefined_data *data,
87 union acpi_operand_object **elements,
88 u8 type1,
89 u32 count1,
90 u8 type2, u32 count2, u32 start_index);
91
92static acpi_status
93acpi_ns_check_object_type(struct acpi_predefined_data *data,
94 union acpi_operand_object **return_object_ptr,
95 u32 expected_btypes, u32 package_index);
96
97static acpi_status
98acpi_ns_check_reference(struct acpi_predefined_data *data, 76acpi_ns_check_reference(struct acpi_predefined_data *data,
99 union acpi_operand_object *return_object); 77 union acpi_operand_object *return_object);
100 78
@@ -148,7 +126,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
148 126
149 pathname = acpi_ns_get_external_pathname(node); 127 pathname = acpi_ns_get_external_pathname(node);
150 if (!pathname) { 128 if (!pathname) {
151 return AE_OK; /* Could not get pathname, ignore */ 129 return (AE_OK); /* Could not get pathname, ignore */
152 } 130 }
153 131
154 /* 132 /*
@@ -408,564 +386,6 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
408 386
409/******************************************************************************* 387/*******************************************************************************
410 * 388 *
411 * FUNCTION: acpi_ns_check_package
412 *
413 * PARAMETERS: data - Pointer to validation data structure
414 * return_object_ptr - Pointer to the object returned from the
415 * evaluation of a method or object
416 *
417 * RETURN: Status
418 *
419 * DESCRIPTION: Check a returned package object for the correct count and
420 * correct type of all sub-objects.
421 *
422 ******************************************************************************/
423
424static acpi_status
425acpi_ns_check_package(struct acpi_predefined_data *data,
426 union acpi_operand_object **return_object_ptr)
427{
428 union acpi_operand_object *return_object = *return_object_ptr;
429 const union acpi_predefined_info *package;
430 union acpi_operand_object **elements;
431 acpi_status status = AE_OK;
432 u32 expected_count;
433 u32 count;
434 u32 i;
435
436 ACPI_FUNCTION_NAME(ns_check_package);
437
438 /* The package info for this name is in the next table entry */
439
440 package = data->predefined + 1;
441
442 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
443 "%s Validating return Package of Type %X, Count %X\n",
444 data->pathname, package->ret_info.type,
445 return_object->package.count));
446
447 /*
448 * For variable-length Packages, we can safely remove all embedded
449 * and trailing NULL package elements
450 */
451 acpi_ns_remove_null_elements(data, package->ret_info.type,
452 return_object);
453
454 /* Extract package count and elements array */
455
456 elements = return_object->package.elements;
457 count = return_object->package.count;
458
459 /* The package must have at least one element, else invalid */
460
461 if (!count) {
462 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
463 "Return Package has no elements (empty)"));
464
465 return (AE_AML_OPERAND_VALUE);
466 }
467
468 /*
469 * Decode the type of the expected package contents
470 *
471 * PTYPE1 packages contain no subpackages
472 * PTYPE2 packages contain sub-packages
473 */
474 switch (package->ret_info.type) {
475 case ACPI_PTYPE1_FIXED:
476
477 /*
478 * The package count is fixed and there are no sub-packages
479 *
480 * If package is too small, exit.
481 * If package is larger than expected, issue warning but continue
482 */
483 expected_count =
484 package->ret_info.count1 + package->ret_info.count2;
485 if (count < expected_count) {
486 goto package_too_small;
487 } else if (count > expected_count) {
488 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
489 "%s: Return Package is larger than needed - "
490 "found %u, expected %u\n",
491 data->pathname, count,
492 expected_count));
493 }
494
495 /* Validate all elements of the returned package */
496
497 status = acpi_ns_check_package_elements(data, elements,
498 package->ret_info.
499 object_type1,
500 package->ret_info.
501 count1,
502 package->ret_info.
503 object_type2,
504 package->ret_info.
505 count2, 0);
506 break;
507
508 case ACPI_PTYPE1_VAR:
509
510 /*
511 * The package count is variable, there are no sub-packages, and all
512 * elements must be of the same type
513 */
514 for (i = 0; i < count; i++) {
515 status = acpi_ns_check_object_type(data, elements,
516 package->ret_info.
517 object_type1, i);
518 if (ACPI_FAILURE(status)) {
519 return (status);
520 }
521 elements++;
522 }
523 break;
524
525 case ACPI_PTYPE1_OPTION:
526
527 /*
528 * The package count is variable, there are no sub-packages. There are
529 * a fixed number of required elements, and a variable number of
530 * optional elements.
531 *
532 * Check if package is at least as large as the minimum required
533 */
534 expected_count = package->ret_info3.count;
535 if (count < expected_count) {
536 goto package_too_small;
537 }
538
539 /* Variable number of sub-objects */
540
541 for (i = 0; i < count; i++) {
542 if (i < package->ret_info3.count) {
543
544 /* These are the required package elements (0, 1, or 2) */
545
546 status =
547 acpi_ns_check_object_type(data, elements,
548 package->
549 ret_info3.
550 object_type[i],
551 i);
552 if (ACPI_FAILURE(status)) {
553 return (status);
554 }
555 } else {
556 /* These are the optional package elements */
557
558 status =
559 acpi_ns_check_object_type(data, elements,
560 package->
561 ret_info3.
562 tail_object_type,
563 i);
564 if (ACPI_FAILURE(status)) {
565 return (status);
566 }
567 }
568 elements++;
569 }
570 break;
571
572 case ACPI_PTYPE2_REV_FIXED:
573
574 /* First element is the (Integer) revision */
575
576 status = acpi_ns_check_object_type(data, elements,
577 ACPI_RTYPE_INTEGER, 0);
578 if (ACPI_FAILURE(status)) {
579 return (status);
580 }
581
582 elements++;
583 count--;
584
585 /* Examine the sub-packages */
586
587 status =
588 acpi_ns_check_package_list(data, package, elements, count);
589 break;
590
591 case ACPI_PTYPE2_PKG_COUNT:
592
593 /* First element is the (Integer) count of sub-packages to follow */
594
595 status = acpi_ns_check_object_type(data, elements,
596 ACPI_RTYPE_INTEGER, 0);
597 if (ACPI_FAILURE(status)) {
598 return (status);
599 }
600
601 /*
602 * Count cannot be larger than the parent package length, but allow it
603 * to be smaller. The >= accounts for the Integer above.
604 */
605 expected_count = (u32) (*elements)->integer.value;
606 if (expected_count >= count) {
607 goto package_too_small;
608 }
609
610 count = expected_count;
611 elements++;
612
613 /* Examine the sub-packages */
614
615 status =
616 acpi_ns_check_package_list(data, package, elements, count);
617 break;
618
619 case ACPI_PTYPE2:
620 case ACPI_PTYPE2_FIXED:
621 case ACPI_PTYPE2_MIN:
622 case ACPI_PTYPE2_COUNT:
623 case ACPI_PTYPE2_FIX_VAR:
624
625 /*
626 * These types all return a single Package that consists of a
627 * variable number of sub-Packages.
628 *
629 * First, ensure that the first element is a sub-Package. If not,
630 * the BIOS may have incorrectly returned the object as a single
631 * package instead of a Package of Packages (a common error if
632 * there is only one entry). We may be able to repair this by
633 * wrapping the returned Package with a new outer Package.
634 */
635 if (*elements
636 && ((*elements)->common.type != ACPI_TYPE_PACKAGE)) {
637
638 /* Create the new outer package and populate it */
639
640 status =
641 acpi_ns_wrap_with_package(data, return_object,
642 return_object_ptr);
643 if (ACPI_FAILURE(status)) {
644 return (status);
645 }
646
647 /* Update locals to point to the new package (of 1 element) */
648
649 return_object = *return_object_ptr;
650 elements = return_object->package.elements;
651 count = 1;
652 }
653
654 /* Examine the sub-packages */
655
656 status =
657 acpi_ns_check_package_list(data, package, elements, count);
658 break;
659
660 default:
661
662 /* Should not get here if predefined info table is correct */
663
664 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
665 "Invalid internal return type in table entry: %X",
666 package->ret_info.type));
667
668 return (AE_AML_INTERNAL);
669 }
670
671 return (status);
672
673package_too_small:
674
675 /* Error exit for the case with an incorrect package count */
676
677 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
678 "Return Package is too small - found %u elements, expected %u",
679 count, expected_count));
680
681 return (AE_AML_OPERAND_VALUE);
682}
683
684/*******************************************************************************
685 *
686 * FUNCTION: acpi_ns_check_package_list
687 *
688 * PARAMETERS: data - Pointer to validation data structure
689 * package - Pointer to package-specific info for method
690 * elements - Element list of parent package. All elements
691 * of this list should be of type Package.
692 * count - Count of subpackages
693 *
694 * RETURN: Status
695 *
696 * DESCRIPTION: Examine a list of subpackages
697 *
698 ******************************************************************************/
699
700static acpi_status
701acpi_ns_check_package_list(struct acpi_predefined_data *data,
702 const union acpi_predefined_info *package,
703 union acpi_operand_object **elements, u32 count)
704{
705 union acpi_operand_object *sub_package;
706 union acpi_operand_object **sub_elements;
707 acpi_status status;
708 u32 expected_count;
709 u32 i;
710 u32 j;
711
712 /*
713 * Validate each sub-Package in the parent Package
714 *
715 * NOTE: assumes list of sub-packages contains no NULL elements.
716 * Any NULL elements should have been removed by earlier call
717 * to acpi_ns_remove_null_elements.
718 */
719 for (i = 0; i < count; i++) {
720 sub_package = *elements;
721 sub_elements = sub_package->package.elements;
722 data->parent_package = sub_package;
723
724 /* Each sub-object must be of type Package */
725
726 status = acpi_ns_check_object_type(data, &sub_package,
727 ACPI_RTYPE_PACKAGE, i);
728 if (ACPI_FAILURE(status)) {
729 return (status);
730 }
731
732 /* Examine the different types of expected sub-packages */
733
734 data->parent_package = sub_package;
735 switch (package->ret_info.type) {
736 case ACPI_PTYPE2:
737 case ACPI_PTYPE2_PKG_COUNT:
738 case ACPI_PTYPE2_REV_FIXED:
739
740 /* Each subpackage has a fixed number of elements */
741
742 expected_count =
743 package->ret_info.count1 + package->ret_info.count2;
744 if (sub_package->package.count < expected_count) {
745 goto package_too_small;
746 }
747
748 status =
749 acpi_ns_check_package_elements(data, sub_elements,
750 package->ret_info.
751 object_type1,
752 package->ret_info.
753 count1,
754 package->ret_info.
755 object_type2,
756 package->ret_info.
757 count2, 0);
758 if (ACPI_FAILURE(status)) {
759 return (status);
760 }
761 break;
762
763 case ACPI_PTYPE2_FIX_VAR:
764 /*
765 * Each subpackage has a fixed number of elements and an
766 * optional element
767 */
768 expected_count =
769 package->ret_info.count1 + package->ret_info.count2;
770 if (sub_package->package.count < expected_count) {
771 goto package_too_small;
772 }
773
774 status =
775 acpi_ns_check_package_elements(data, sub_elements,
776 package->ret_info.
777 object_type1,
778 package->ret_info.
779 count1,
780 package->ret_info.
781 object_type2,
782 sub_package->package.
783 count -
784 package->ret_info.
785 count1, 0);
786 if (ACPI_FAILURE(status)) {
787 return (status);
788 }
789 break;
790
791 case ACPI_PTYPE2_FIXED:
792
793 /* Each sub-package has a fixed length */
794
795 expected_count = package->ret_info2.count;
796 if (sub_package->package.count < expected_count) {
797 goto package_too_small;
798 }
799
800 /* Check the type of each sub-package element */
801
802 for (j = 0; j < expected_count; j++) {
803 status =
804 acpi_ns_check_object_type(data,
805 &sub_elements[j],
806 package->
807 ret_info2.
808 object_type[j],
809 j);
810 if (ACPI_FAILURE(status)) {
811 return (status);
812 }
813 }
814 break;
815
816 case ACPI_PTYPE2_MIN:
817
818 /* Each sub-package has a variable but minimum length */
819
820 expected_count = package->ret_info.count1;
821 if (sub_package->package.count < expected_count) {
822 goto package_too_small;
823 }
824
825 /* Check the type of each sub-package element */
826
827 status =
828 acpi_ns_check_package_elements(data, sub_elements,
829 package->ret_info.
830 object_type1,
831 sub_package->package.
832 count, 0, 0, 0);
833 if (ACPI_FAILURE(status)) {
834 return (status);
835 }
836 break;
837
838 case ACPI_PTYPE2_COUNT:
839
840 /*
841 * First element is the (Integer) count of elements, including
842 * the count field (the ACPI name is num_elements)
843 */
844 status = acpi_ns_check_object_type(data, sub_elements,
845 ACPI_RTYPE_INTEGER,
846 0);
847 if (ACPI_FAILURE(status)) {
848 return (status);
849 }
850
851 /*
852 * Make sure package is large enough for the Count and is
853 * is as large as the minimum size
854 */
855 expected_count = (u32)(*sub_elements)->integer.value;
856 if (sub_package->package.count < expected_count) {
857 goto package_too_small;
858 }
859 if (sub_package->package.count <
860 package->ret_info.count1) {
861 expected_count = package->ret_info.count1;
862 goto package_too_small;
863 }
864 if (expected_count == 0) {
865 /*
866 * Either the num_entries element was originally zero or it was
867 * a NULL element and repaired to an Integer of value zero.
868 * In either case, repair it by setting num_entries to be the
869 * actual size of the subpackage.
870 */
871 expected_count = sub_package->package.count;
872 (*sub_elements)->integer.value = expected_count;
873 }
874
875 /* Check the type of each sub-package element */
876
877 status =
878 acpi_ns_check_package_elements(data,
879 (sub_elements + 1),
880 package->ret_info.
881 object_type1,
882 (expected_count - 1),
883 0, 0, 1);
884 if (ACPI_FAILURE(status)) {
885 return (status);
886 }
887 break;
888
889 default: /* Should not get here, type was validated by caller */
890
891 return (AE_AML_INTERNAL);
892 }
893
894 elements++;
895 }
896
897 return (AE_OK);
898
899package_too_small:
900
901 /* The sub-package count was smaller than required */
902
903 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
904 "Return Sub-Package[%u] is too small - found %u elements, expected %u",
905 i, sub_package->package.count, expected_count));
906
907 return (AE_AML_OPERAND_VALUE);
908}
909
910/*******************************************************************************
911 *
912 * FUNCTION: acpi_ns_check_package_elements
913 *
914 * PARAMETERS: data - Pointer to validation data structure
915 * elements - Pointer to the package elements array
916 * type1 - Object type for first group
917 * count1 - Count for first group
918 * type2 - Object type for second group
919 * count2 - Count for second group
920 * start_index - Start of the first group of elements
921 *
922 * RETURN: Status
923 *
924 * DESCRIPTION: Check that all elements of a package are of the correct object
925 * type. Supports up to two groups of different object types.
926 *
927 ******************************************************************************/
928
929static acpi_status
930acpi_ns_check_package_elements(struct acpi_predefined_data *data,
931 union acpi_operand_object **elements,
932 u8 type1,
933 u32 count1,
934 u8 type2, u32 count2, u32 start_index)
935{
936 union acpi_operand_object **this_element = elements;
937 acpi_status status;
938 u32 i;
939
940 /*
941 * Up to two groups of package elements are supported by the data
942 * structure. All elements in each group must be of the same type.
943 * The second group can have a count of zero.
944 */
945 for (i = 0; i < count1; i++) {
946 status = acpi_ns_check_object_type(data, this_element,
947 type1, i + start_index);
948 if (ACPI_FAILURE(status)) {
949 return (status);
950 }
951 this_element++;
952 }
953
954 for (i = 0; i < count2; i++) {
955 status = acpi_ns_check_object_type(data, this_element,
956 type2,
957 (i + count1 + start_index));
958 if (ACPI_FAILURE(status)) {
959 return (status);
960 }
961 this_element++;
962 }
963
964 return (AE_OK);
965}
966
967/*******************************************************************************
968 *
969 * FUNCTION: acpi_ns_check_object_type 389 * FUNCTION: acpi_ns_check_object_type
970 * 390 *
971 * PARAMETERS: data - Pointer to validation data structure 391 * PARAMETERS: data - Pointer to validation data structure
@@ -983,7 +403,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data,
983 * 403 *
984 ******************************************************************************/ 404 ******************************************************************************/
985 405
986static acpi_status 406acpi_status
987acpi_ns_check_object_type(struct acpi_predefined_data *data, 407acpi_ns_check_object_type(struct acpi_predefined_data *data,
988 union acpi_operand_object **return_object_ptr, 408 union acpi_operand_object **return_object_ptr,
989 u32 expected_btypes, u32 package_index) 409 u32 expected_btypes, u32 package_index)
diff --git a/drivers/acpi/acpica/nsprepkg.c b/drivers/acpi/acpica/nsprepkg.c
new file mode 100644
index 000000000000..a40155467d2e
--- /dev/null
+++ b/drivers/acpi/acpica/nsprepkg.c
@@ -0,0 +1,621 @@
1/******************************************************************************
2 *
3 * Module Name: nsprepkg - Validation of package objects 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 "acnamesp.h"
47#include "acpredef.h"
48
49#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsprepkg")
51
52/* Local prototypes */
53static acpi_status
54acpi_ns_check_package_list(struct acpi_predefined_data *data,
55 const union acpi_predefined_info *package,
56 union acpi_operand_object **elements, u32 count);
57
58static acpi_status
59acpi_ns_check_package_elements(struct acpi_predefined_data *data,
60 union acpi_operand_object **elements,
61 u8 type1,
62 u32 count1,
63 u8 type2, u32 count2, u32 start_index);
64
65/*******************************************************************************
66 *
67 * FUNCTION: acpi_ns_check_package
68 *
69 * PARAMETERS: data - Pointer to validation data structure
70 * return_object_ptr - Pointer to the object returned from the
71 * evaluation of a method or object
72 *
73 * RETURN: Status
74 *
75 * DESCRIPTION: Check a returned package object for the correct count and
76 * correct type of all sub-objects.
77 *
78 ******************************************************************************/
79
80acpi_status
81acpi_ns_check_package(struct acpi_predefined_data *data,
82 union acpi_operand_object **return_object_ptr)
83{
84 union acpi_operand_object *return_object = *return_object_ptr;
85 const union acpi_predefined_info *package;
86 union acpi_operand_object **elements;
87 acpi_status status = AE_OK;
88 u32 expected_count;
89 u32 count;
90 u32 i;
91
92 ACPI_FUNCTION_NAME(ns_check_package);
93
94 /* The package info for this name is in the next table entry */
95
96 package = data->predefined + 1;
97
98 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
99 "%s Validating return Package of Type %X, Count %X\n",
100 data->pathname, package->ret_info.type,
101 return_object->package.count));
102
103 /*
104 * For variable-length Packages, we can safely remove all embedded
105 * and trailing NULL package elements
106 */
107 acpi_ns_remove_null_elements(data, package->ret_info.type,
108 return_object);
109
110 /* Extract package count and elements array */
111
112 elements = return_object->package.elements;
113 count = return_object->package.count;
114
115 /* The package must have at least one element, else invalid */
116
117 if (!count) {
118 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
119 "Return Package has no elements (empty)"));
120
121 return (AE_AML_OPERAND_VALUE);
122 }
123
124 /*
125 * Decode the type of the expected package contents
126 *
127 * PTYPE1 packages contain no subpackages
128 * PTYPE2 packages contain sub-packages
129 */
130 switch (package->ret_info.type) {
131 case ACPI_PTYPE1_FIXED:
132
133 /*
134 * The package count is fixed and there are no sub-packages
135 *
136 * If package is too small, exit.
137 * If package is larger than expected, issue warning but continue
138 */
139 expected_count =
140 package->ret_info.count1 + package->ret_info.count2;
141 if (count < expected_count) {
142 goto package_too_small;
143 } else if (count > expected_count) {
144 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
145 "%s: Return Package is larger than needed - "
146 "found %u, expected %u\n",
147 data->pathname, count,
148 expected_count));
149 }
150
151 /* Validate all elements of the returned package */
152
153 status = acpi_ns_check_package_elements(data, elements,
154 package->ret_info.
155 object_type1,
156 package->ret_info.
157 count1,
158 package->ret_info.
159 object_type2,
160 package->ret_info.
161 count2, 0);
162 break;
163
164 case ACPI_PTYPE1_VAR:
165
166 /*
167 * The package count is variable, there are no sub-packages, and all
168 * elements must be of the same type
169 */
170 for (i = 0; i < count; i++) {
171 status = acpi_ns_check_object_type(data, elements,
172 package->ret_info.
173 object_type1, i);
174 if (ACPI_FAILURE(status)) {
175 return (status);
176 }
177 elements++;
178 }
179 break;
180
181 case ACPI_PTYPE1_OPTION:
182
183 /*
184 * The package count is variable, there are no sub-packages. There are
185 * a fixed number of required elements, and a variable number of
186 * optional elements.
187 *
188 * Check if package is at least as large as the minimum required
189 */
190 expected_count = package->ret_info3.count;
191 if (count < expected_count) {
192 goto package_too_small;
193 }
194
195 /* Variable number of sub-objects */
196
197 for (i = 0; i < count; i++) {
198 if (i < package->ret_info3.count) {
199
200 /* These are the required package elements (0, 1, or 2) */
201
202 status =
203 acpi_ns_check_object_type(data, elements,
204 package->
205 ret_info3.
206 object_type[i],
207 i);
208 if (ACPI_FAILURE(status)) {
209 return (status);
210 }
211 } else {
212 /* These are the optional package elements */
213
214 status =
215 acpi_ns_check_object_type(data, elements,
216 package->
217 ret_info3.
218 tail_object_type,
219 i);
220 if (ACPI_FAILURE(status)) {
221 return (status);
222 }
223 }
224 elements++;
225 }
226 break;
227
228 case ACPI_PTYPE2_REV_FIXED:
229
230 /* First element is the (Integer) revision */
231
232 status = acpi_ns_check_object_type(data, elements,
233 ACPI_RTYPE_INTEGER, 0);
234 if (ACPI_FAILURE(status)) {
235 return (status);
236 }
237
238 elements++;
239 count--;
240
241 /* Examine the sub-packages */
242
243 status =
244 acpi_ns_check_package_list(data, package, elements, count);
245 break;
246
247 case ACPI_PTYPE2_PKG_COUNT:
248
249 /* First element is the (Integer) count of sub-packages to follow */
250
251 status = acpi_ns_check_object_type(data, elements,
252 ACPI_RTYPE_INTEGER, 0);
253 if (ACPI_FAILURE(status)) {
254 return (status);
255 }
256
257 /*
258 * Count cannot be larger than the parent package length, but allow it
259 * to be smaller. The >= accounts for the Integer above.
260 */
261 expected_count = (u32)(*elements)->integer.value;
262 if (expected_count >= count) {
263 goto package_too_small;
264 }
265
266 count = expected_count;
267 elements++;
268
269 /* Examine the sub-packages */
270
271 status =
272 acpi_ns_check_package_list(data, package, elements, count);
273 break;
274
275 case ACPI_PTYPE2:
276 case ACPI_PTYPE2_FIXED:
277 case ACPI_PTYPE2_MIN:
278 case ACPI_PTYPE2_COUNT:
279 case ACPI_PTYPE2_FIX_VAR:
280
281 /*
282 * These types all return a single Package that consists of a
283 * variable number of sub-Packages.
284 *
285 * First, ensure that the first element is a sub-Package. If not,
286 * the BIOS may have incorrectly returned the object as a single
287 * package instead of a Package of Packages (a common error if
288 * there is only one entry). We may be able to repair this by
289 * wrapping the returned Package with a new outer Package.
290 */
291 if (*elements
292 && ((*elements)->common.type != ACPI_TYPE_PACKAGE)) {
293
294 /* Create the new outer package and populate it */
295
296 status =
297 acpi_ns_wrap_with_package(data, return_object,
298 return_object_ptr);
299 if (ACPI_FAILURE(status)) {
300 return (status);
301 }
302
303 /* Update locals to point to the new package (of 1 element) */
304
305 return_object = *return_object_ptr;
306 elements = return_object->package.elements;
307 count = 1;
308 }
309
310 /* Examine the sub-packages */
311
312 status =
313 acpi_ns_check_package_list(data, package, elements, count);
314 break;
315
316 default:
317
318 /* Should not get here if predefined info table is correct */
319
320 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
321 "Invalid internal return type in table entry: %X",
322 package->ret_info.type));
323
324 return (AE_AML_INTERNAL);
325 }
326
327 return (status);
328
329 package_too_small:
330
331 /* Error exit for the case with an incorrect package count */
332
333 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
334 "Return Package is too small - found %u elements, expected %u",
335 count, expected_count));
336
337 return (AE_AML_OPERAND_VALUE);
338}
339
340/*******************************************************************************
341 *
342 * FUNCTION: acpi_ns_check_package_list
343 *
344 * PARAMETERS: data - Pointer to validation data structure
345 * package - Pointer to package-specific info for method
346 * elements - Element list of parent package. All elements
347 * of this list should be of type Package.
348 * count - Count of subpackages
349 *
350 * RETURN: Status
351 *
352 * DESCRIPTION: Examine a list of subpackages
353 *
354 ******************************************************************************/
355
356static acpi_status
357acpi_ns_check_package_list(struct acpi_predefined_data *data,
358 const union acpi_predefined_info *package,
359 union acpi_operand_object **elements, u32 count)
360{
361 union acpi_operand_object *sub_package;
362 union acpi_operand_object **sub_elements;
363 acpi_status status;
364 u32 expected_count;
365 u32 i;
366 u32 j;
367
368 /*
369 * Validate each sub-Package in the parent Package
370 *
371 * NOTE: assumes list of sub-packages contains no NULL elements.
372 * Any NULL elements should have been removed by earlier call
373 * to acpi_ns_remove_null_elements.
374 */
375 for (i = 0; i < count; i++) {
376 sub_package = *elements;
377 sub_elements = sub_package->package.elements;
378 data->parent_package = sub_package;
379
380 /* Each sub-object must be of type Package */
381
382 status = acpi_ns_check_object_type(data, &sub_package,
383 ACPI_RTYPE_PACKAGE, i);
384 if (ACPI_FAILURE(status)) {
385 return (status);
386 }
387
388 /* Examine the different types of expected sub-packages */
389
390 data->parent_package = sub_package;
391 switch (package->ret_info.type) {
392 case ACPI_PTYPE2:
393 case ACPI_PTYPE2_PKG_COUNT:
394 case ACPI_PTYPE2_REV_FIXED:
395
396 /* Each subpackage has a fixed number of elements */
397
398 expected_count =
399 package->ret_info.count1 + package->ret_info.count2;
400 if (sub_package->package.count < expected_count) {
401 goto package_too_small;
402 }
403
404 status =
405 acpi_ns_check_package_elements(data, sub_elements,
406 package->ret_info.
407 object_type1,
408 package->ret_info.
409 count1,
410 package->ret_info.
411 object_type2,
412 package->ret_info.
413 count2, 0);
414 if (ACPI_FAILURE(status)) {
415 return (status);
416 }
417 break;
418
419 case ACPI_PTYPE2_FIX_VAR:
420 /*
421 * Each subpackage has a fixed number of elements and an
422 * optional element
423 */
424 expected_count =
425 package->ret_info.count1 + package->ret_info.count2;
426 if (sub_package->package.count < expected_count) {
427 goto package_too_small;
428 }
429
430 status =
431 acpi_ns_check_package_elements(data, sub_elements,
432 package->ret_info.
433 object_type1,
434 package->ret_info.
435 count1,
436 package->ret_info.
437 object_type2,
438 sub_package->package.
439 count -
440 package->ret_info.
441 count1, 0);
442 if (ACPI_FAILURE(status)) {
443 return (status);
444 }
445 break;
446
447 case ACPI_PTYPE2_FIXED:
448
449 /* Each sub-package has a fixed length */
450
451 expected_count = package->ret_info2.count;
452 if (sub_package->package.count < expected_count) {
453 goto package_too_small;
454 }
455
456 /* Check the type of each sub-package element */
457
458 for (j = 0; j < expected_count; j++) {
459 status =
460 acpi_ns_check_object_type(data,
461 &sub_elements[j],
462 package->
463 ret_info2.
464 object_type[j],
465 j);
466 if (ACPI_FAILURE(status)) {
467 return (status);
468 }
469 }
470 break;
471
472 case ACPI_PTYPE2_MIN:
473
474 /* Each sub-package has a variable but minimum length */
475
476 expected_count = package->ret_info.count1;
477 if (sub_package->package.count < expected_count) {
478 goto package_too_small;
479 }
480
481 /* Check the type of each sub-package element */
482
483 status =
484 acpi_ns_check_package_elements(data, sub_elements,
485 package->ret_info.
486 object_type1,
487 sub_package->package.
488 count, 0, 0, 0);
489 if (ACPI_FAILURE(status)) {
490 return (status);
491 }
492 break;
493
494 case ACPI_PTYPE2_COUNT:
495
496 /*
497 * First element is the (Integer) count of elements, including
498 * the count field (the ACPI name is num_elements)
499 */
500 status = acpi_ns_check_object_type(data, sub_elements,
501 ACPI_RTYPE_INTEGER,
502 0);
503 if (ACPI_FAILURE(status)) {
504 return (status);
505 }
506
507 /*
508 * Make sure package is large enough for the Count and is
509 * is as large as the minimum size
510 */
511 expected_count = (u32)(*sub_elements)->integer.value;
512 if (sub_package->package.count < expected_count) {
513 goto package_too_small;
514 }
515 if (sub_package->package.count <
516 package->ret_info.count1) {
517 expected_count = package->ret_info.count1;
518 goto package_too_small;
519 }
520 if (expected_count == 0) {
521 /*
522 * Either the num_entries element was originally zero or it was
523 * a NULL element and repaired to an Integer of value zero.
524 * In either case, repair it by setting num_entries to be the
525 * actual size of the subpackage.
526 */
527 expected_count = sub_package->package.count;
528 (*sub_elements)->integer.value = expected_count;
529 }
530
531 /* Check the type of each sub-package element */
532
533 status =
534 acpi_ns_check_package_elements(data,
535 (sub_elements + 1),
536 package->ret_info.
537 object_type1,
538 (expected_count - 1),
539 0, 0, 1);
540 if (ACPI_FAILURE(status)) {
541 return (status);
542 }
543 break;
544
545 default: /* Should not get here, type was validated by caller */
546
547 return (AE_AML_INTERNAL);
548 }
549
550 elements++;
551 }
552
553 return (AE_OK);
554
555 package_too_small:
556
557 /* The sub-package count was smaller than required */
558
559 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
560 "Return Sub-Package[%u] is too small - found %u elements, expected %u",
561 i, sub_package->package.count, expected_count));
562
563 return (AE_AML_OPERAND_VALUE);
564}
565
566/*******************************************************************************
567 *
568 * FUNCTION: acpi_ns_check_package_elements
569 *
570 * PARAMETERS: data - Pointer to validation data structure
571 * elements - Pointer to the package elements array
572 * type1 - Object type for first group
573 * count1 - Count for first group
574 * type2 - Object type for second group
575 * count2 - Count for second group
576 * start_index - Start of the first group of elements
577 *
578 * RETURN: Status
579 *
580 * DESCRIPTION: Check that all elements of a package are of the correct object
581 * type. Supports up to two groups of different object types.
582 *
583 ******************************************************************************/
584
585static acpi_status
586acpi_ns_check_package_elements(struct acpi_predefined_data *data,
587 union acpi_operand_object **elements,
588 u8 type1,
589 u32 count1,
590 u8 type2, u32 count2, u32 start_index)
591{
592 union acpi_operand_object **this_element = elements;
593 acpi_status status;
594 u32 i;
595
596 /*
597 * Up to two groups of package elements are supported by the data
598 * structure. All elements in each group must be of the same type.
599 * The second group can have a count of zero.
600 */
601 for (i = 0; i < count1; i++) {
602 status = acpi_ns_check_object_type(data, this_element,
603 type1, i + start_index);
604 if (ACPI_FAILURE(status)) {
605 return (status);
606 }
607 this_element++;
608 }
609
610 for (i = 0; i < count2; i++) {
611 status = acpi_ns_check_object_type(data, this_element,
612 type2,
613 (i + count1 + start_index));
614 if (ACPI_FAILURE(status)) {
615 return (status);
616 }
617 this_element++;
618 }
619
620 return (AE_OK);
621}
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index 8c5f292860fc..9e833353c06a 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index 90189251cdf0..ba4d98287c6a 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,8 @@ ACPI_MODULE_NAME("nsrepair2")
55 */ 55 */
56typedef 56typedef
57acpi_status(*acpi_repair_function) (struct acpi_predefined_data *data, 57acpi_status(*acpi_repair_function) (struct acpi_predefined_data *data,
58 union acpi_operand_object **return_object_ptr); 58 union acpi_operand_object
59 **return_object_ptr);
59 60
60typedef struct acpi_repair_info { 61typedef struct acpi_repair_info {
61 char name[ACPI_NAME_SIZE]; 62 char name[ACPI_NAME_SIZE];
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index 1d2d8ffc1bc5..5d43efc53a61 100644
--- a/drivers/acpi/acpica/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -328,6 +328,11 @@ acpi_ns_search_and_enter(u32 target_name,
328 if ((status == AE_OK) && (flags & ACPI_NS_ERROR_IF_FOUND)) { 328 if ((status == AE_OK) && (flags & ACPI_NS_ERROR_IF_FOUND)) {
329 status = AE_ALREADY_EXISTS; 329 status = AE_ALREADY_EXISTS;
330 } 330 }
331#ifdef ACPI_ASL_COMPILER
332 if (*return_node && (*return_node)->type == ACPI_TYPE_ANY) {
333 (*return_node)->flags |= ANOBJ_IS_EXTERNAL;
334 }
335#endif
331 336
332 /* Either found it or there was an error: finished either way */ 337 /* Either found it or there was an error: finished either way */
333 338
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index b5b4cb72a8a8..686420df684f 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -46,14 +46,11 @@
46#include "accommon.h" 46#include "accommon.h"
47#include "acnamesp.h" 47#include "acnamesp.h"
48#include "amlcode.h" 48#include "amlcode.h"
49#include "actables.h"
50 49
51#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
52ACPI_MODULE_NAME("nsutils") 51ACPI_MODULE_NAME("nsutils")
53 52
54/* Local prototypes */ 53/* Local prototypes */
55static u8 acpi_ns_valid_path_separator(char sep);
56
57#ifdef ACPI_OBSOLETE_FUNCTIONS 54#ifdef ACPI_OBSOLETE_FUNCTIONS
58acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search); 55acpi_name acpi_ns_find_parent_name(struct acpi_namespace_node *node_to_search);
59#endif 56#endif
@@ -99,42 +96,6 @@ acpi_ns_print_node_pathname(struct acpi_namespace_node *node,
99 96
100/******************************************************************************* 97/*******************************************************************************
101 * 98 *
102 * FUNCTION: acpi_ns_valid_root_prefix
103 *
104 * PARAMETERS: prefix - Character to be checked
105 *
106 * RETURN: TRUE if a valid prefix
107 *
108 * DESCRIPTION: Check if a character is a valid ACPI Root prefix
109 *
110 ******************************************************************************/
111
112u8 acpi_ns_valid_root_prefix(char prefix)
113{
114
115 return ((u8) (prefix == '\\'));
116}
117
118/*******************************************************************************
119 *
120 * FUNCTION: acpi_ns_valid_path_separator
121 *
122 * PARAMETERS: sep - Character to be checked
123 *
124 * RETURN: TRUE if a valid path separator
125 *
126 * DESCRIPTION: Check if a character is a valid ACPI path separator
127 *
128 ******************************************************************************/
129
130static u8 acpi_ns_valid_path_separator(char sep)
131{
132
133 return ((u8) (sep == '.'));
134}
135
136/*******************************************************************************
137 *
138 * FUNCTION: acpi_ns_get_type 99 * FUNCTION: acpi_ns_get_type
139 * 100 *
140 * PARAMETERS: node - Parent Node to be examined 101 * PARAMETERS: node - Parent Node to be examined
@@ -151,10 +112,10 @@ acpi_object_type acpi_ns_get_type(struct acpi_namespace_node * node)
151 112
152 if (!node) { 113 if (!node) {
153 ACPI_WARNING((AE_INFO, "Null Node parameter")); 114 ACPI_WARNING((AE_INFO, "Null Node parameter"));
154 return_UINT32(ACPI_TYPE_ANY); 115 return_VALUE(ACPI_TYPE_ANY);
155 } 116 }
156 117
157 return_UINT32((acpi_object_type) node->type); 118 return_VALUE(node->type);
158} 119}
159 120
160/******************************************************************************* 121/*******************************************************************************
@@ -179,10 +140,10 @@ u32 acpi_ns_local(acpi_object_type type)
179 /* Type code out of range */ 140 /* Type code out of range */
180 141
181 ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type)); 142 ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
182 return_UINT32(ACPI_NS_NORMAL); 143 return_VALUE(ACPI_NS_NORMAL);
183 } 144 }
184 145
185 return_UINT32((u32) acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL); 146 return_VALUE(acpi_gbl_ns_properties[type] & ACPI_NS_LOCAL);
186} 147}
187 148
188/******************************************************************************* 149/*******************************************************************************
@@ -218,19 +179,19 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
218 * 179 *
219 * strlen() + 1 covers the first name_seg, which has no path separator 180 * strlen() + 1 covers the first name_seg, which has no path separator
220 */ 181 */
221 if (acpi_ns_valid_root_prefix(*next_external_char)) { 182 if (ACPI_IS_ROOT_PREFIX(*next_external_char)) {
222 info->fully_qualified = TRUE; 183 info->fully_qualified = TRUE;
223 next_external_char++; 184 next_external_char++;
224 185
225 /* Skip redundant root_prefix, like \\_SB.PCI0.SBRG.EC0 */ 186 /* Skip redundant root_prefix, like \\_SB.PCI0.SBRG.EC0 */
226 187
227 while (acpi_ns_valid_root_prefix(*next_external_char)) { 188 while (ACPI_IS_ROOT_PREFIX(*next_external_char)) {
228 next_external_char++; 189 next_external_char++;
229 } 190 }
230 } else { 191 } else {
231 /* Handle Carat prefixes */ 192 /* Handle Carat prefixes */
232 193
233 while (*next_external_char == '^') { 194 while (ACPI_IS_PARENT_PREFIX(*next_external_char)) {
234 info->num_carats++; 195 info->num_carats++;
235 next_external_char++; 196 next_external_char++;
236 } 197 }
@@ -244,7 +205,7 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
244 if (*next_external_char) { 205 if (*next_external_char) {
245 info->num_segments = 1; 206 info->num_segments = 1;
246 for (i = 0; next_external_char[i]; i++) { 207 for (i = 0; next_external_char[i]; i++) {
247 if (acpi_ns_valid_path_separator(next_external_char[i])) { 208 if (ACPI_IS_PATH_SEPARATOR(next_external_char[i])) {
248 info->num_segments++; 209 info->num_segments++;
249 } 210 }
250 } 211 }
@@ -282,7 +243,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
282 /* Setup the correct prefixes, counts, and pointers */ 243 /* Setup the correct prefixes, counts, and pointers */
283 244
284 if (info->fully_qualified) { 245 if (info->fully_qualified) {
285 internal_name[0] = '\\'; 246 internal_name[0] = AML_ROOT_PREFIX;
286 247
287 if (num_segments <= 1) { 248 if (num_segments <= 1) {
288 result = &internal_name[1]; 249 result = &internal_name[1];
@@ -302,7 +263,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
302 i = 0; 263 i = 0;
303 if (info->num_carats) { 264 if (info->num_carats) {
304 for (i = 0; i < info->num_carats; i++) { 265 for (i = 0; i < info->num_carats; i++) {
305 internal_name[i] = '^'; 266 internal_name[i] = AML_PARENT_PREFIX;
306 } 267 }
307 } 268 }
308 269
@@ -322,7 +283,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
322 283
323 for (; num_segments; num_segments--) { 284 for (; num_segments; num_segments--) {
324 for (i = 0; i < ACPI_NAME_SIZE; i++) { 285 for (i = 0; i < ACPI_NAME_SIZE; i++) {
325 if (acpi_ns_valid_path_separator(*external_name) || 286 if (ACPI_IS_PATH_SEPARATOR(*external_name) ||
326 (*external_name == 0)) { 287 (*external_name == 0)) {
327 288
328 /* Pad the segment with underscore(s) if segment is short */ 289 /* Pad the segment with underscore(s) if segment is short */
@@ -339,7 +300,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
339 300
340 /* Now we must have a path separator, or the pathname is bad */ 301 /* Now we must have a path separator, or the pathname is bad */
341 302
342 if (!acpi_ns_valid_path_separator(*external_name) && 303 if (!ACPI_IS_PATH_SEPARATOR(*external_name) &&
343 (*external_name != 0)) { 304 (*external_name != 0)) {
344 return_ACPI_STATUS(AE_BAD_PATHNAME); 305 return_ACPI_STATUS(AE_BAD_PATHNAME);
345 } 306 }
@@ -457,13 +418,13 @@ acpi_ns_externalize_name(u32 internal_name_length,
457 /* Check for a prefix (one '\' | one or more '^') */ 418 /* Check for a prefix (one '\' | one or more '^') */
458 419
459 switch (internal_name[0]) { 420 switch (internal_name[0]) {
460 case '\\': 421 case AML_ROOT_PREFIX:
461 prefix_length = 1; 422 prefix_length = 1;
462 break; 423 break;
463 424
464 case '^': 425 case AML_PARENT_PREFIX:
465 for (i = 0; i < internal_name_length; i++) { 426 for (i = 0; i < internal_name_length; i++) {
466 if (internal_name[i] == '^') { 427 if (ACPI_IS_PARENT_PREFIX(internal_name[i])) {
467 prefix_length = i + 1; 428 prefix_length = i + 1;
468 } else { 429 } else {
469 break; 430 break;
@@ -664,17 +625,17 @@ void acpi_ns_terminate(void)
664 625
665u32 acpi_ns_opens_scope(acpi_object_type type) 626u32 acpi_ns_opens_scope(acpi_object_type type)
666{ 627{
667 ACPI_FUNCTION_TRACE_STR(ns_opens_scope, acpi_ut_get_type_name(type)); 628 ACPI_FUNCTION_ENTRY();
668 629
669 if (!acpi_ut_valid_object_type(type)) { 630 if (type > ACPI_TYPE_LOCAL_MAX) {
670 631
671 /* type code out of range */ 632 /* type code out of range */
672 633
673 ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type)); 634 ACPI_WARNING((AE_INFO, "Invalid Object Type 0x%X", type));
674 return_UINT32(ACPI_NS_NORMAL); 635 return (ACPI_NS_NORMAL);
675 } 636 }
676 637
677 return_UINT32(((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE); 638 return (((u32)acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
678} 639}
679 640
680/******************************************************************************* 641/*******************************************************************************
@@ -710,6 +671,8 @@ acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
710 671
711 ACPI_FUNCTION_TRACE_PTR(ns_get_node, ACPI_CAST_PTR(char, pathname)); 672 ACPI_FUNCTION_TRACE_PTR(ns_get_node, ACPI_CAST_PTR(char, pathname));
712 673
674 /* Simplest case is a null pathname */
675
713 if (!pathname) { 676 if (!pathname) {
714 *return_node = prefix_node; 677 *return_node = prefix_node;
715 if (!prefix_node) { 678 if (!prefix_node) {
@@ -718,6 +681,13 @@ acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
718 return_ACPI_STATUS(AE_OK); 681 return_ACPI_STATUS(AE_OK);
719 } 682 }
720 683
684 /* Quick check for a reference to the root */
685
686 if (ACPI_IS_ROOT_PREFIX(pathname[0]) && (!pathname[1])) {
687 *return_node = acpi_gbl_root_node;
688 return_ACPI_STATUS(AE_OK);
689 }
690
721 /* Convert path to internal representation */ 691 /* Convert path to internal representation */
722 692
723 status = acpi_ns_internalize_name(pathname, &internal_path); 693 status = acpi_ns_internalize_name(pathname, &internal_path);
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index 0483877f26b8..e70911a9e441 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -76,12 +76,12 @@ struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node
76 76
77 /* It's really the parent's _scope_ that we want */ 77 /* It's really the parent's _scope_ that we want */
78 78
79 return parent_node->child; 79 return (parent_node->child);
80 } 80 }
81 81
82 /* Otherwise just return the next peer */ 82 /* Otherwise just return the next peer */
83 83
84 return child_node->peer; 84 return (child_node->peer);
85} 85}
86 86
87/******************************************************************************* 87/*******************************************************************************
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index d6a9f77972b6..fc69949151bb 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -236,7 +236,7 @@ acpi_evaluate_object(acpi_handle handle,
236 * 2) No handle, not fully qualified pathname (error) 236 * 2) No handle, not fully qualified pathname (error)
237 * 3) Valid handle 237 * 3) Valid handle
238 */ 238 */
239 if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) { 239 if ((pathname) && (ACPI_IS_ROOT_PREFIX(pathname[0]))) {
240 240
241 /* The path is fully qualified, just evaluate by name */ 241 /* The path is fully qualified, just evaluate by name */
242 242
@@ -492,7 +492,7 @@ acpi_walk_namespace(acpi_object_type type,
492 */ 492 */
493 status = acpi_ut_acquire_read_lock(&acpi_gbl_namespace_rw_lock); 493 status = acpi_ut_acquire_read_lock(&acpi_gbl_namespace_rw_lock);
494 if (ACPI_FAILURE(status)) { 494 if (ACPI_FAILURE(status)) {
495 return status; 495 return_ACPI_STATUS(status);
496 } 496 }
497 497
498 /* 498 /*
@@ -550,7 +550,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
550 550
551 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 551 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
552 if (ACPI_FAILURE(status)) { 552 if (ACPI_FAILURE(status)) {
553 return_ACPI_STATUS(status); 553 return (status);
554 } 554 }
555 555
556 node = acpi_ns_validate_handle(obj_handle); 556 node = acpi_ns_validate_handle(obj_handle);
@@ -602,17 +602,22 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
602 602
603 /* Walk the CID list */ 603 /* Walk the CID list */
604 604
605 found = 0; 605 found = FALSE;
606 for (i = 0; i < cid->count; i++) { 606 for (i = 0; i < cid->count; i++) {
607 if (ACPI_STRCMP(cid->ids[i].string, info->hid) 607 if (ACPI_STRCMP(cid->ids[i].string, info->hid)
608 == 0) { 608 == 0) {
609 found = 1; 609
610 /* Found a matching CID */
611
612 found = TRUE;
610 break; 613 break;
611 } 614 }
612 } 615 }
616
613 ACPI_FREE(cid); 617 ACPI_FREE(cid);
614 if (!found) 618 if (!found) {
615 return (AE_OK); 619 return (AE_OK);
620 }
616 } 621 }
617 } 622 }
618 623
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index 811c6f13f476..f3a4d95899f7 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -107,7 +107,7 @@ acpi_get_handle(acpi_handle parent,
107 * 107 *
108 * Error for <null Parent + relative path> 108 * Error for <null Parent + relative path>
109 */ 109 */
110 if (acpi_ns_valid_root_prefix(pathname[0])) { 110 if (ACPI_IS_ROOT_PREFIX(pathname[0])) {
111 111
112 /* Pathname is fully qualified (starts with '\') */ 112 /* Pathname is fully qualified (starts with '\') */
113 113
@@ -290,7 +290,7 @@ acpi_get_object_info(acpi_handle handle,
290 290
291 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 291 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
292 if (ACPI_FAILURE(status)) { 292 if (ACPI_FAILURE(status)) {
293 goto cleanup; 293 return (status);
294 } 294 }
295 295
296 node = acpi_ns_validate_handle(handle); 296 node = acpi_ns_validate_handle(handle);
@@ -539,14 +539,14 @@ acpi_status acpi_install_method(u8 *buffer)
539 /* Parameter validation */ 539 /* Parameter validation */
540 540
541 if (!buffer) { 541 if (!buffer) {
542 return AE_BAD_PARAMETER; 542 return (AE_BAD_PARAMETER);
543 } 543 }
544 544
545 /* Table must be a DSDT or SSDT */ 545 /* Table must be a DSDT or SSDT */
546 546
547 if (!ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT) && 547 if (!ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT) &&
548 !ACPI_COMPARE_NAME(table->signature, ACPI_SIG_SSDT)) { 548 !ACPI_COMPARE_NAME(table->signature, ACPI_SIG_SSDT)) {
549 return AE_BAD_HEADER; 549 return (AE_BAD_HEADER);
550 } 550 }
551 551
552 /* First AML opcode in the table must be a control method */ 552 /* First AML opcode in the table must be a control method */
@@ -554,7 +554,7 @@ acpi_status acpi_install_method(u8 *buffer)
554 parser_state.aml = buffer + sizeof(struct acpi_table_header); 554 parser_state.aml = buffer + sizeof(struct acpi_table_header);
555 opcode = acpi_ps_peek_opcode(&parser_state); 555 opcode = acpi_ps_peek_opcode(&parser_state);
556 if (opcode != AML_METHOD_OP) { 556 if (opcode != AML_METHOD_OP) {
557 return AE_BAD_PARAMETER; 557 return (AE_BAD_PARAMETER);
558 } 558 }
559 559
560 /* Extract method information from the raw AML */ 560 /* Extract method information from the raw AML */
@@ -572,13 +572,13 @@ acpi_status acpi_install_method(u8 *buffer)
572 */ 572 */
573 aml_buffer = ACPI_ALLOCATE(aml_length); 573 aml_buffer = ACPI_ALLOCATE(aml_length);
574 if (!aml_buffer) { 574 if (!aml_buffer) {
575 return AE_NO_MEMORY; 575 return (AE_NO_MEMORY);
576 } 576 }
577 577
578 method_obj = acpi_ut_create_internal_object(ACPI_TYPE_METHOD); 578 method_obj = acpi_ut_create_internal_object(ACPI_TYPE_METHOD);
579 if (!method_obj) { 579 if (!method_obj) {
580 ACPI_FREE(aml_buffer); 580 ACPI_FREE(aml_buffer);
581 return AE_NO_MEMORY; 581 return (AE_NO_MEMORY);
582 } 582 }
583 583
584 /* Lock namespace for acpi_ns_lookup, we may be creating a new node */ 584 /* Lock namespace for acpi_ns_lookup, we may be creating a new node */
@@ -644,12 +644,12 @@ acpi_status acpi_install_method(u8 *buffer)
644 /* Remove local reference to the method object */ 644 /* Remove local reference to the method object */
645 645
646 acpi_ut_remove_reference(method_obj); 646 acpi_ut_remove_reference(method_obj);
647 return status; 647 return (status);
648 648
649error_exit: 649error_exit:
650 650
651 ACPI_FREE(aml_buffer); 651 ACPI_FREE(aml_buffer);
652 ACPI_FREE(method_obj); 652 ACPI_FREE(method_obj);
653 return status; 653 return (status);
654} 654}
655ACPI_EXPORT_SYMBOL(acpi_install_method) 655ACPI_EXPORT_SYMBOL(acpi_install_method)
diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index 9d029dac6b64..c0853ef294e4 100644
--- a/drivers/acpi/acpica/nsxfobj.c
+++ b/drivers/acpi/acpica/nsxfobj.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2012, Intel Corp. 9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index cb79e2d4d743..f51308cdbc65 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -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_UINT32(package_length); 111 return_VALUE(package_length);
112} 112}
113 113
114/******************************************************************************* 114/*******************************************************************************
@@ -162,7 +162,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
162 162
163 /* Point past any namestring prefix characters (backslash or carat) */ 163 /* Point past any namestring prefix characters (backslash or carat) */
164 164
165 while (acpi_ps_is_prefix_char(*end)) { 165 while (ACPI_IS_ROOT_PREFIX(*end) || ACPI_IS_PARENT_PREFIX(*end)) {
166 end++; 166 end++;
167 } 167 }
168 168
@@ -798,7 +798,8 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
798 subop = acpi_ps_peek_opcode(parser_state); 798 subop = acpi_ps_peek_opcode(parser_state);
799 if (subop == 0 || 799 if (subop == 0 ||
800 acpi_ps_is_leading_char(subop) || 800 acpi_ps_is_leading_char(subop) ||
801 acpi_ps_is_prefix_char(subop)) { 801 ACPI_IS_ROOT_PREFIX(subop) ||
802 ACPI_IS_PARENT_PREFIX(subop)) {
802 803
803 /* null_name or name_string */ 804 /* null_name or name_string */
804 805
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index 5607805aab26..63c455447481 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -58,352 +58,17 @@
58#define _COMPONENT ACPI_PARSER 58#define _COMPONENT ACPI_PARSER
59ACPI_MODULE_NAME("psloop") 59ACPI_MODULE_NAME("psloop")
60 60
61static u32 acpi_gbl_depth = 0;
62
63/* Local prototypes */ 61/* Local prototypes */
64
65static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state);
66
67static acpi_status
68acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
69 u8 * aml_op_start,
70 union acpi_parse_object *unnamed_op,
71 union acpi_parse_object **op);
72
73static acpi_status
74acpi_ps_create_op(struct acpi_walk_state *walk_state,
75 u8 * aml_op_start, union acpi_parse_object **new_op);
76
77static acpi_status 62static acpi_status
78acpi_ps_get_arguments(struct acpi_walk_state *walk_state, 63acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
79 u8 * aml_op_start, union acpi_parse_object *op); 64 u8 * aml_op_start, union acpi_parse_object *op);
80 65
81static acpi_status
82acpi_ps_complete_op(struct acpi_walk_state *walk_state,
83 union acpi_parse_object **op, acpi_status status);
84
85static acpi_status
86acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
87 union acpi_parse_object *op, acpi_status status);
88
89static void 66static void
90acpi_ps_link_module_code(union acpi_parse_object *parent_op, 67acpi_ps_link_module_code(union acpi_parse_object *parent_op,
91 u8 *aml_start, u32 aml_length, acpi_owner_id owner_id); 68 u8 *aml_start, u32 aml_length, acpi_owner_id owner_id);
92 69
93/******************************************************************************* 70/*******************************************************************************
94 * 71 *
95 * FUNCTION: acpi_ps_get_aml_opcode
96 *
97 * PARAMETERS: walk_state - Current state
98 *
99 * RETURN: Status
100 *
101 * DESCRIPTION: Extract the next AML opcode from the input stream.
102 *
103 ******************************************************************************/
104
105static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
106{
107
108 ACPI_FUNCTION_TRACE_PTR(ps_get_aml_opcode, walk_state);
109
110 walk_state->aml_offset =
111 (u32) ACPI_PTR_DIFF(walk_state->parser_state.aml,
112 walk_state->parser_state.aml_start);
113 walk_state->opcode = acpi_ps_peek_opcode(&(walk_state->parser_state));
114
115 /*
116 * First cut to determine what we have found:
117 * 1) A valid AML opcode
118 * 2) A name string
119 * 3) An unknown/invalid opcode
120 */
121 walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
122
123 switch (walk_state->op_info->class) {
124 case AML_CLASS_ASCII:
125 case AML_CLASS_PREFIX:
126 /*
127 * Starts with a valid prefix or ASCII char, this is a name
128 * string. Convert the bare name string to a namepath.
129 */
130 walk_state->opcode = AML_INT_NAMEPATH_OP;
131 walk_state->arg_types = ARGP_NAMESTRING;
132 break;
133
134 case AML_CLASS_UNKNOWN:
135
136 /* The opcode is unrecognized. Complain and skip unknown opcodes */
137
138 if (walk_state->pass_number == 2) {
139 ACPI_ERROR((AE_INFO,
140 "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
141 walk_state->opcode,
142 (u32)(walk_state->aml_offset +
143 sizeof(struct acpi_table_header))));
144
145 ACPI_DUMP_BUFFER(walk_state->parser_state.aml - 16, 48);
146
147#ifdef ACPI_ASL_COMPILER
148 /*
149 * This is executed for the disassembler only. Output goes
150 * to the disassembled ASL output file.
151 */
152 acpi_os_printf
153 ("/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
154 walk_state->opcode,
155 (u32)(walk_state->aml_offset +
156 sizeof(struct acpi_table_header)));
157
158 /* Dump the context surrounding the invalid opcode */
159
160 acpi_ut_dump_buffer(((u8 *)walk_state->parser_state.
161 aml - 16), 48, DB_BYTE_DISPLAY,
162 walk_state->aml_offset +
163 sizeof(struct acpi_table_header) -
164 16);
165 acpi_os_printf(" */\n");
166#endif
167 }
168
169 /* Increment past one-byte or two-byte opcode */
170
171 walk_state->parser_state.aml++;
172 if (walk_state->opcode > 0xFF) { /* Can only happen if first byte is 0x5B */
173 walk_state->parser_state.aml++;
174 }
175
176 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
177
178 default:
179
180 /* Found opcode info, this is a normal opcode */
181
182 walk_state->parser_state.aml +=
183 acpi_ps_get_opcode_size(walk_state->opcode);
184 walk_state->arg_types = walk_state->op_info->parse_args;
185 break;
186 }
187
188 return_ACPI_STATUS(AE_OK);
189}
190
191/*******************************************************************************
192 *
193 * FUNCTION: acpi_ps_build_named_op
194 *
195 * PARAMETERS: walk_state - Current state
196 * aml_op_start - Begin of named Op in AML
197 * unnamed_op - Early Op (not a named Op)
198 * op - Returned Op
199 *
200 * RETURN: Status
201 *
202 * DESCRIPTION: Parse a named Op
203 *
204 ******************************************************************************/
205
206static acpi_status
207acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
208 u8 * aml_op_start,
209 union acpi_parse_object *unnamed_op,
210 union acpi_parse_object **op)
211{
212 acpi_status status = AE_OK;
213 union acpi_parse_object *arg = NULL;
214
215 ACPI_FUNCTION_TRACE_PTR(ps_build_named_op, walk_state);
216
217 unnamed_op->common.value.arg = NULL;
218 unnamed_op->common.arg_list_length = 0;
219 unnamed_op->common.aml_opcode = walk_state->opcode;
220
221 /*
222 * Get and append arguments until we find the node that contains
223 * the name (the type ARGP_NAME).
224 */
225 while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) &&
226 (GET_CURRENT_ARG_TYPE(walk_state->arg_types) != ARGP_NAME)) {
227 status =
228 acpi_ps_get_next_arg(walk_state,
229 &(walk_state->parser_state),
230 GET_CURRENT_ARG_TYPE(walk_state->
231 arg_types), &arg);
232 if (ACPI_FAILURE(status)) {
233 return_ACPI_STATUS(status);
234 }
235
236 acpi_ps_append_arg(unnamed_op, arg);
237 INCREMENT_ARG_LIST(walk_state->arg_types);
238 }
239
240 /*
241 * Make sure that we found a NAME and didn't run out of arguments
242 */
243 if (!GET_CURRENT_ARG_TYPE(walk_state->arg_types)) {
244 return_ACPI_STATUS(AE_AML_NO_OPERAND);
245 }
246
247 /* We know that this arg is a name, move to next arg */
248
249 INCREMENT_ARG_LIST(walk_state->arg_types);
250
251 /*
252 * Find the object. This will either insert the object into
253 * the namespace or simply look it up
254 */
255 walk_state->op = NULL;
256
257 status = walk_state->descending_callback(walk_state, op);
258 if (ACPI_FAILURE(status)) {
259 ACPI_EXCEPTION((AE_INFO, status, "During name lookup/catalog"));
260 return_ACPI_STATUS(status);
261 }
262
263 if (!*op) {
264 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
265 }
266
267 status = acpi_ps_next_parse_state(walk_state, *op, status);
268 if (ACPI_FAILURE(status)) {
269 if (status == AE_CTRL_PENDING) {
270 return_ACPI_STATUS(AE_CTRL_PARSE_PENDING);
271 }
272 return_ACPI_STATUS(status);
273 }
274
275 acpi_ps_append_arg(*op, unnamed_op->common.value.arg);
276 acpi_gbl_depth++;
277
278 if ((*op)->common.aml_opcode == AML_REGION_OP ||
279 (*op)->common.aml_opcode == AML_DATA_REGION_OP) {
280 /*
281 * Defer final parsing of an operation_region body, because we don't
282 * have enough info in the first pass to parse it correctly (i.e.,
283 * there may be method calls within the term_arg elements of the body.)
284 *
285 * However, we must continue parsing because the opregion is not a
286 * standalone package -- we don't know where the end is at this point.
287 *
288 * (Length is unknown until parse of the body complete)
289 */
290 (*op)->named.data = aml_op_start;
291 (*op)->named.length = 0;
292 }
293
294 return_ACPI_STATUS(AE_OK);
295}
296
297/*******************************************************************************
298 *
299 * FUNCTION: acpi_ps_create_op
300 *
301 * PARAMETERS: walk_state - Current state
302 * aml_op_start - Op start in AML
303 * new_op - Returned Op
304 *
305 * RETURN: Status
306 *
307 * DESCRIPTION: Get Op from AML
308 *
309 ******************************************************************************/
310
311static acpi_status
312acpi_ps_create_op(struct acpi_walk_state *walk_state,
313 u8 * aml_op_start, union acpi_parse_object **new_op)
314{
315 acpi_status status = AE_OK;
316 union acpi_parse_object *op;
317 union acpi_parse_object *named_op = NULL;
318 union acpi_parse_object *parent_scope;
319 u8 argument_count;
320 const struct acpi_opcode_info *op_info;
321
322 ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state);
323
324 status = acpi_ps_get_aml_opcode(walk_state);
325 if (status == AE_CTRL_PARSE_CONTINUE) {
326 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
327 }
328
329 /* Create Op structure and append to parent's argument list */
330
331 walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
332 op = acpi_ps_alloc_op(walk_state->opcode);
333 if (!op) {
334 return_ACPI_STATUS(AE_NO_MEMORY);
335 }
336
337 if (walk_state->op_info->flags & AML_NAMED) {
338 status =
339 acpi_ps_build_named_op(walk_state, aml_op_start, op,
340 &named_op);
341 acpi_ps_free_op(op);
342 if (ACPI_FAILURE(status)) {
343 return_ACPI_STATUS(status);
344 }
345
346 *new_op = named_op;
347 return_ACPI_STATUS(AE_OK);
348 }
349
350 /* Not a named opcode, just allocate Op and append to parent */
351
352 if (walk_state->op_info->flags & AML_CREATE) {
353 /*
354 * Backup to beginning of create_XXXfield declaration
355 * body_length is unknown until we parse the body
356 */
357 op->named.data = aml_op_start;
358 op->named.length = 0;
359 }
360
361 if (walk_state->opcode == AML_BANK_FIELD_OP) {
362 /*
363 * Backup to beginning of bank_field declaration
364 * body_length is unknown until we parse the body
365 */
366 op->named.data = aml_op_start;
367 op->named.length = 0;
368 }
369
370 parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state));
371 acpi_ps_append_arg(parent_scope, op);
372
373 if (parent_scope) {
374 op_info =
375 acpi_ps_get_opcode_info(parent_scope->common.aml_opcode);
376 if (op_info->flags & AML_HAS_TARGET) {
377 argument_count =
378 acpi_ps_get_argument_count(op_info->type);
379 if (parent_scope->common.arg_list_length >
380 argument_count) {
381 op->common.flags |= ACPI_PARSEOP_TARGET;
382 }
383 } else if (parent_scope->common.aml_opcode == AML_INCREMENT_OP) {
384 op->common.flags |= ACPI_PARSEOP_TARGET;
385 }
386 }
387
388 if (walk_state->descending_callback != NULL) {
389 /*
390 * Find the object. This will either insert the object into
391 * the namespace or simply look it up
392 */
393 walk_state->op = *new_op = op;
394
395 status = walk_state->descending_callback(walk_state, &op);
396 status = acpi_ps_next_parse_state(walk_state, op, status);
397 if (status == AE_CTRL_PENDING) {
398 status = AE_CTRL_PARSE_PENDING;
399 }
400 }
401
402 return_ACPI_STATUS(status);
403}
404
405/*******************************************************************************
406 *
407 * FUNCTION: acpi_ps_get_arguments 72 * FUNCTION: acpi_ps_get_arguments
408 * 73 *
409 * PARAMETERS: walk_state - Current state 74 * PARAMETERS: walk_state - Current state
@@ -711,288 +376,6 @@ acpi_ps_link_module_code(union acpi_parse_object *parent_op,
711 376
712/******************************************************************************* 377/*******************************************************************************
713 * 378 *
714 * FUNCTION: acpi_ps_complete_op
715 *
716 * PARAMETERS: walk_state - Current state
717 * op - Returned Op
718 * status - Parse status before complete Op
719 *
720 * RETURN: Status
721 *
722 * DESCRIPTION: Complete Op
723 *
724 ******************************************************************************/
725
726static acpi_status
727acpi_ps_complete_op(struct acpi_walk_state *walk_state,
728 union acpi_parse_object **op, acpi_status status)
729{
730 acpi_status status2;
731
732 ACPI_FUNCTION_TRACE_PTR(ps_complete_op, walk_state);
733
734 /*
735 * Finished one argument of the containing scope
736 */
737 walk_state->parser_state.scope->parse_scope.arg_count--;
738
739 /* Close this Op (will result in parse subtree deletion) */
740
741 status2 = acpi_ps_complete_this_op(walk_state, *op);
742 if (ACPI_FAILURE(status2)) {
743 return_ACPI_STATUS(status2);
744 }
745
746 *op = NULL;
747
748 switch (status) {
749 case AE_OK:
750 break;
751
752 case AE_CTRL_TRANSFER:
753
754 /* We are about to transfer to a called method */
755
756 walk_state->prev_op = NULL;
757 walk_state->prev_arg_types = walk_state->arg_types;
758 return_ACPI_STATUS(status);
759
760 case AE_CTRL_END:
761
762 acpi_ps_pop_scope(&(walk_state->parser_state), op,
763 &walk_state->arg_types,
764 &walk_state->arg_count);
765
766 if (*op) {
767 walk_state->op = *op;
768 walk_state->op_info =
769 acpi_ps_get_opcode_info((*op)->common.aml_opcode);
770 walk_state->opcode = (*op)->common.aml_opcode;
771
772 status = walk_state->ascending_callback(walk_state);
773 status =
774 acpi_ps_next_parse_state(walk_state, *op, status);
775
776 status2 = acpi_ps_complete_this_op(walk_state, *op);
777 if (ACPI_FAILURE(status2)) {
778 return_ACPI_STATUS(status2);
779 }
780 }
781
782 status = AE_OK;
783 break;
784
785 case AE_CTRL_BREAK:
786 case AE_CTRL_CONTINUE:
787
788 /* Pop off scopes until we find the While */
789
790 while (!(*op) || ((*op)->common.aml_opcode != AML_WHILE_OP)) {
791 acpi_ps_pop_scope(&(walk_state->parser_state), op,
792 &walk_state->arg_types,
793 &walk_state->arg_count);
794 }
795
796 /* Close this iteration of the While loop */
797
798 walk_state->op = *op;
799 walk_state->op_info =
800 acpi_ps_get_opcode_info((*op)->common.aml_opcode);
801 walk_state->opcode = (*op)->common.aml_opcode;
802
803 status = walk_state->ascending_callback(walk_state);
804 status = acpi_ps_next_parse_state(walk_state, *op, status);
805
806 status2 = acpi_ps_complete_this_op(walk_state, *op);
807 if (ACPI_FAILURE(status2)) {
808 return_ACPI_STATUS(status2);
809 }
810
811 status = AE_OK;
812 break;
813
814 case AE_CTRL_TERMINATE:
815
816 /* Clean up */
817 do {
818 if (*op) {
819 status2 =
820 acpi_ps_complete_this_op(walk_state, *op);
821 if (ACPI_FAILURE(status2)) {
822 return_ACPI_STATUS(status2);
823 }
824
825 acpi_ut_delete_generic_state
826 (acpi_ut_pop_generic_state
827 (&walk_state->control_state));
828 }
829
830 acpi_ps_pop_scope(&(walk_state->parser_state), op,
831 &walk_state->arg_types,
832 &walk_state->arg_count);
833
834 } while (*op);
835
836 return_ACPI_STATUS(AE_OK);
837
838 default: /* All other non-AE_OK status */
839
840 do {
841 if (*op) {
842 status2 =
843 acpi_ps_complete_this_op(walk_state, *op);
844 if (ACPI_FAILURE(status2)) {
845 return_ACPI_STATUS(status2);
846 }
847 }
848
849 acpi_ps_pop_scope(&(walk_state->parser_state), op,
850 &walk_state->arg_types,
851 &walk_state->arg_count);
852
853 } while (*op);
854
855#if 0
856 /*
857 * TBD: Cleanup parse ops on error
858 */
859 if (*op == NULL) {
860 acpi_ps_pop_scope(parser_state, op,
861 &walk_state->arg_types,
862 &walk_state->arg_count);
863 }
864#endif
865 walk_state->prev_op = NULL;
866 walk_state->prev_arg_types = walk_state->arg_types;
867 return_ACPI_STATUS(status);
868 }
869
870 /* This scope complete? */
871
872 if (acpi_ps_has_completed_scope(&(walk_state->parser_state))) {
873 acpi_ps_pop_scope(&(walk_state->parser_state), op,
874 &walk_state->arg_types,
875 &walk_state->arg_count);
876 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *op));
877 } else {
878 *op = NULL;
879 }
880
881 return_ACPI_STATUS(AE_OK);
882}
883
884/*******************************************************************************
885 *
886 * FUNCTION: acpi_ps_complete_final_op
887 *
888 * PARAMETERS: walk_state - Current state
889 * op - Current Op
890 * status - Current parse status before complete last
891 * Op
892 *
893 * RETURN: Status
894 *
895 * DESCRIPTION: Complete last Op.
896 *
897 ******************************************************************************/
898
899static acpi_status
900acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
901 union acpi_parse_object *op, acpi_status status)
902{
903 acpi_status status2;
904
905 ACPI_FUNCTION_TRACE_PTR(ps_complete_final_op, walk_state);
906
907 /*
908 * Complete the last Op (if not completed), and clear the scope stack.
909 * It is easily possible to end an AML "package" with an unbounded number
910 * of open scopes (such as when several ASL blocks are closed with
911 * sequential closing braces). We want to terminate each one cleanly.
912 */
913 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n",
914 op));
915 do {
916 if (op) {
917 if (walk_state->ascending_callback != NULL) {
918 walk_state->op = op;
919 walk_state->op_info =
920 acpi_ps_get_opcode_info(op->common.
921 aml_opcode);
922 walk_state->opcode = op->common.aml_opcode;
923
924 status =
925 walk_state->ascending_callback(walk_state);
926 status =
927 acpi_ps_next_parse_state(walk_state, op,
928 status);
929 if (status == AE_CTRL_PENDING) {
930 status =
931 acpi_ps_complete_op(walk_state, &op,
932 AE_OK);
933 if (ACPI_FAILURE(status)) {
934 return_ACPI_STATUS(status);
935 }
936 }
937
938 if (status == AE_CTRL_TERMINATE) {
939 status = AE_OK;
940
941 /* Clean up */
942 do {
943 if (op) {
944 status2 =
945 acpi_ps_complete_this_op
946 (walk_state, op);
947 if (ACPI_FAILURE
948 (status2)) {
949 return_ACPI_STATUS
950 (status2);
951 }
952 }
953
954 acpi_ps_pop_scope(&
955 (walk_state->
956 parser_state),
957 &op,
958 &walk_state->
959 arg_types,
960 &walk_state->
961 arg_count);
962
963 } while (op);
964
965 return_ACPI_STATUS(status);
966 }
967
968 else if (ACPI_FAILURE(status)) {
969
970 /* First error is most important */
971
972 (void)
973 acpi_ps_complete_this_op(walk_state,
974 op);
975 return_ACPI_STATUS(status);
976 }
977 }
978
979 status2 = acpi_ps_complete_this_op(walk_state, op);
980 if (ACPI_FAILURE(status2)) {
981 return_ACPI_STATUS(status2);
982 }
983 }
984
985 acpi_ps_pop_scope(&(walk_state->parser_state), &op,
986 &walk_state->arg_types,
987 &walk_state->arg_count);
988
989 } while (op);
990
991 return_ACPI_STATUS(status);
992}
993
994/*******************************************************************************
995 *
996 * FUNCTION: acpi_ps_parse_loop 379 * FUNCTION: acpi_ps_parse_loop
997 * 380 *
998 * PARAMETERS: walk_state - Current state 381 * PARAMETERS: walk_state - Current state
@@ -1177,10 +560,6 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
1177 walk_state->op_info = 560 walk_state->op_info =
1178 acpi_ps_get_opcode_info(op->common.aml_opcode); 561 acpi_ps_get_opcode_info(op->common.aml_opcode);
1179 if (walk_state->op_info->flags & AML_NAMED) { 562 if (walk_state->op_info->flags & AML_NAMED) {
1180 if (acpi_gbl_depth) {
1181 acpi_gbl_depth--;
1182 }
1183
1184 if (op->common.aml_opcode == AML_REGION_OP || 563 if (op->common.aml_opcode == AML_REGION_OP ||
1185 op->common.aml_opcode == AML_DATA_REGION_OP) { 564 op->common.aml_opcode == AML_DATA_REGION_OP) {
1186 /* 565 /*
diff --git a/drivers/acpi/acpica/psobject.c b/drivers/acpi/acpica/psobject.c
new file mode 100644
index 000000000000..12c4028002b1
--- /dev/null
+++ b/drivers/acpi/acpica/psobject.c
@@ -0,0 +1,647 @@
1/******************************************************************************
2 *
3 * Module Name: psobject - Support for parse objects
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 "acparser.h"
47#include "amlcode.h"
48
49#define _COMPONENT ACPI_PARSER
50ACPI_MODULE_NAME("psobject")
51
52/* Local prototypes */
53static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state);
54
55/*******************************************************************************
56 *
57 * FUNCTION: acpi_ps_get_aml_opcode
58 *
59 * PARAMETERS: walk_state - Current state
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Extract the next AML opcode from the input stream.
64 *
65 ******************************************************************************/
66
67static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
68{
69
70 ACPI_FUNCTION_TRACE_PTR(ps_get_aml_opcode, walk_state);
71
72 walk_state->aml_offset =
73 (u32)ACPI_PTR_DIFF(walk_state->parser_state.aml,
74 walk_state->parser_state.aml_start);
75 walk_state->opcode = acpi_ps_peek_opcode(&(walk_state->parser_state));
76
77 /*
78 * First cut to determine what we have found:
79 * 1) A valid AML opcode
80 * 2) A name string
81 * 3) An unknown/invalid opcode
82 */
83 walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
84
85 switch (walk_state->op_info->class) {
86 case AML_CLASS_ASCII:
87 case AML_CLASS_PREFIX:
88 /*
89 * Starts with a valid prefix or ASCII char, this is a name
90 * string. Convert the bare name string to a namepath.
91 */
92 walk_state->opcode = AML_INT_NAMEPATH_OP;
93 walk_state->arg_types = ARGP_NAMESTRING;
94 break;
95
96 case AML_CLASS_UNKNOWN:
97
98 /* The opcode is unrecognized. Complain and skip unknown opcodes */
99
100 if (walk_state->pass_number == 2) {
101 ACPI_ERROR((AE_INFO,
102 "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
103 walk_state->opcode,
104 (u32)(walk_state->aml_offset +
105 sizeof(struct acpi_table_header))));
106
107 ACPI_DUMP_BUFFER((walk_state->parser_state.aml - 16),
108 48);
109
110#ifdef ACPI_ASL_COMPILER
111 /*
112 * This is executed for the disassembler only. Output goes
113 * to the disassembled ASL output file.
114 */
115 acpi_os_printf
116 ("/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
117 walk_state->opcode,
118 (u32)(walk_state->aml_offset +
119 sizeof(struct acpi_table_header)));
120
121 /* Dump the context surrounding the invalid opcode */
122
123 acpi_ut_dump_buffer(((u8 *)walk_state->parser_state.
124 aml - 16), 48, DB_BYTE_DISPLAY,
125 (walk_state->aml_offset +
126 sizeof(struct acpi_table_header) -
127 16));
128 acpi_os_printf(" */\n");
129#endif
130 }
131
132 /* Increment past one-byte or two-byte opcode */
133
134 walk_state->parser_state.aml++;
135 if (walk_state->opcode > 0xFF) { /* Can only happen if first byte is 0x5B */
136 walk_state->parser_state.aml++;
137 }
138
139 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
140
141 default:
142
143 /* Found opcode info, this is a normal opcode */
144
145 walk_state->parser_state.aml +=
146 acpi_ps_get_opcode_size(walk_state->opcode);
147 walk_state->arg_types = walk_state->op_info->parse_args;
148 break;
149 }
150
151 return_ACPI_STATUS(AE_OK);
152}
153
154/*******************************************************************************
155 *
156 * FUNCTION: acpi_ps_build_named_op
157 *
158 * PARAMETERS: walk_state - Current state
159 * aml_op_start - Begin of named Op in AML
160 * unnamed_op - Early Op (not a named Op)
161 * op - Returned Op
162 *
163 * RETURN: Status
164 *
165 * DESCRIPTION: Parse a named Op
166 *
167 ******************************************************************************/
168
169acpi_status
170acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
171 u8 *aml_op_start,
172 union acpi_parse_object *unnamed_op,
173 union acpi_parse_object **op)
174{
175 acpi_status status = AE_OK;
176 union acpi_parse_object *arg = NULL;
177
178 ACPI_FUNCTION_TRACE_PTR(ps_build_named_op, walk_state);
179
180 unnamed_op->common.value.arg = NULL;
181 unnamed_op->common.arg_list_length = 0;
182 unnamed_op->common.aml_opcode = walk_state->opcode;
183
184 /*
185 * Get and append arguments until we find the node that contains
186 * the name (the type ARGP_NAME).
187 */
188 while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) &&
189 (GET_CURRENT_ARG_TYPE(walk_state->arg_types) != ARGP_NAME)) {
190 status =
191 acpi_ps_get_next_arg(walk_state,
192 &(walk_state->parser_state),
193 GET_CURRENT_ARG_TYPE(walk_state->
194 arg_types), &arg);
195 if (ACPI_FAILURE(status)) {
196 return_ACPI_STATUS(status);
197 }
198
199 acpi_ps_append_arg(unnamed_op, arg);
200 INCREMENT_ARG_LIST(walk_state->arg_types);
201 }
202
203 /*
204 * Make sure that we found a NAME and didn't run out of arguments
205 */
206 if (!GET_CURRENT_ARG_TYPE(walk_state->arg_types)) {
207 return_ACPI_STATUS(AE_AML_NO_OPERAND);
208 }
209
210 /* We know that this arg is a name, move to next arg */
211
212 INCREMENT_ARG_LIST(walk_state->arg_types);
213
214 /*
215 * Find the object. This will either insert the object into
216 * the namespace or simply look it up
217 */
218 walk_state->op = NULL;
219
220 status = walk_state->descending_callback(walk_state, op);
221 if (ACPI_FAILURE(status)) {
222 ACPI_EXCEPTION((AE_INFO, status, "During name lookup/catalog"));
223 return_ACPI_STATUS(status);
224 }
225
226 if (!*op) {
227 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
228 }
229
230 status = acpi_ps_next_parse_state(walk_state, *op, status);
231 if (ACPI_FAILURE(status)) {
232 if (status == AE_CTRL_PENDING) {
233 return_ACPI_STATUS(AE_CTRL_PARSE_PENDING);
234 }
235 return_ACPI_STATUS(status);
236 }
237
238 acpi_ps_append_arg(*op, unnamed_op->common.value.arg);
239
240 if ((*op)->common.aml_opcode == AML_REGION_OP ||
241 (*op)->common.aml_opcode == AML_DATA_REGION_OP) {
242 /*
243 * Defer final parsing of an operation_region body, because we don't
244 * have enough info in the first pass to parse it correctly (i.e.,
245 * there may be method calls within the term_arg elements of the body.)
246 *
247 * However, we must continue parsing because the opregion is not a
248 * standalone package -- we don't know where the end is at this point.
249 *
250 * (Length is unknown until parse of the body complete)
251 */
252 (*op)->named.data = aml_op_start;
253 (*op)->named.length = 0;
254 }
255
256 return_ACPI_STATUS(AE_OK);
257}
258
259/*******************************************************************************
260 *
261 * FUNCTION: acpi_ps_create_op
262 *
263 * PARAMETERS: walk_state - Current state
264 * aml_op_start - Op start in AML
265 * new_op - Returned Op
266 *
267 * RETURN: Status
268 *
269 * DESCRIPTION: Get Op from AML
270 *
271 ******************************************************************************/
272
273acpi_status
274acpi_ps_create_op(struct acpi_walk_state *walk_state,
275 u8 *aml_op_start, union acpi_parse_object **new_op)
276{
277 acpi_status status = AE_OK;
278 union acpi_parse_object *op;
279 union acpi_parse_object *named_op = NULL;
280 union acpi_parse_object *parent_scope;
281 u8 argument_count;
282 const struct acpi_opcode_info *op_info;
283
284 ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state);
285
286 status = acpi_ps_get_aml_opcode(walk_state);
287 if (status == AE_CTRL_PARSE_CONTINUE) {
288 return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
289 }
290
291 /* Create Op structure and append to parent's argument list */
292
293 walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
294 op = acpi_ps_alloc_op(walk_state->opcode);
295 if (!op) {
296 return_ACPI_STATUS(AE_NO_MEMORY);
297 }
298
299 if (walk_state->op_info->flags & AML_NAMED) {
300 status =
301 acpi_ps_build_named_op(walk_state, aml_op_start, op,
302 &named_op);
303 acpi_ps_free_op(op);
304 if (ACPI_FAILURE(status)) {
305 return_ACPI_STATUS(status);
306 }
307
308 *new_op = named_op;
309 return_ACPI_STATUS(AE_OK);
310 }
311
312 /* Not a named opcode, just allocate Op and append to parent */
313
314 if (walk_state->op_info->flags & AML_CREATE) {
315 /*
316 * Backup to beginning of create_XXXfield declaration
317 * body_length is unknown until we parse the body
318 */
319 op->named.data = aml_op_start;
320 op->named.length = 0;
321 }
322
323 if (walk_state->opcode == AML_BANK_FIELD_OP) {
324 /*
325 * Backup to beginning of bank_field declaration
326 * body_length is unknown until we parse the body
327 */
328 op->named.data = aml_op_start;
329 op->named.length = 0;
330 }
331
332 parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state));
333 acpi_ps_append_arg(parent_scope, op);
334
335 if (parent_scope) {
336 op_info =
337 acpi_ps_get_opcode_info(parent_scope->common.aml_opcode);
338 if (op_info->flags & AML_HAS_TARGET) {
339 argument_count =
340 acpi_ps_get_argument_count(op_info->type);
341 if (parent_scope->common.arg_list_length >
342 argument_count) {
343 op->common.flags |= ACPI_PARSEOP_TARGET;
344 }
345 } else if (parent_scope->common.aml_opcode == AML_INCREMENT_OP) {
346 op->common.flags |= ACPI_PARSEOP_TARGET;
347 }
348 }
349
350 if (walk_state->descending_callback != NULL) {
351 /*
352 * Find the object. This will either insert the object into
353 * the namespace or simply look it up
354 */
355 walk_state->op = *new_op = op;
356
357 status = walk_state->descending_callback(walk_state, &op);
358 status = acpi_ps_next_parse_state(walk_state, op, status);
359 if (status == AE_CTRL_PENDING) {
360 status = AE_CTRL_PARSE_PENDING;
361 }
362 }
363
364 return_ACPI_STATUS(status);
365}
366
367/*******************************************************************************
368 *
369 * FUNCTION: acpi_ps_complete_op
370 *
371 * PARAMETERS: walk_state - Current state
372 * op - Returned Op
373 * status - Parse status before complete Op
374 *
375 * RETURN: Status
376 *
377 * DESCRIPTION: Complete Op
378 *
379 ******************************************************************************/
380
381acpi_status
382acpi_ps_complete_op(struct acpi_walk_state *walk_state,
383 union acpi_parse_object **op, acpi_status status)
384{
385 acpi_status status2;
386
387 ACPI_FUNCTION_TRACE_PTR(ps_complete_op, walk_state);
388
389 /*
390 * Finished one argument of the containing scope
391 */
392 walk_state->parser_state.scope->parse_scope.arg_count--;
393
394 /* Close this Op (will result in parse subtree deletion) */
395
396 status2 = acpi_ps_complete_this_op(walk_state, *op);
397 if (ACPI_FAILURE(status2)) {
398 return_ACPI_STATUS(status2);
399 }
400
401 *op = NULL;
402
403 switch (status) {
404 case AE_OK:
405 break;
406
407 case AE_CTRL_TRANSFER:
408
409 /* We are about to transfer to a called method */
410
411 walk_state->prev_op = NULL;
412 walk_state->prev_arg_types = walk_state->arg_types;
413 return_ACPI_STATUS(status);
414
415 case AE_CTRL_END:
416
417 acpi_ps_pop_scope(&(walk_state->parser_state), op,
418 &walk_state->arg_types,
419 &walk_state->arg_count);
420
421 if (*op) {
422 walk_state->op = *op;
423 walk_state->op_info =
424 acpi_ps_get_opcode_info((*op)->common.aml_opcode);
425 walk_state->opcode = (*op)->common.aml_opcode;
426
427 status = walk_state->ascending_callback(walk_state);
428 status =
429 acpi_ps_next_parse_state(walk_state, *op, status);
430
431 status2 = acpi_ps_complete_this_op(walk_state, *op);
432 if (ACPI_FAILURE(status2)) {
433 return_ACPI_STATUS(status2);
434 }
435 }
436
437 status = AE_OK;
438 break;
439
440 case AE_CTRL_BREAK:
441 case AE_CTRL_CONTINUE:
442
443 /* Pop off scopes until we find the While */
444
445 while (!(*op) || ((*op)->common.aml_opcode != AML_WHILE_OP)) {
446 acpi_ps_pop_scope(&(walk_state->parser_state), op,
447 &walk_state->arg_types,
448 &walk_state->arg_count);
449 }
450
451 /* Close this iteration of the While loop */
452
453 walk_state->op = *op;
454 walk_state->op_info =
455 acpi_ps_get_opcode_info((*op)->common.aml_opcode);
456 walk_state->opcode = (*op)->common.aml_opcode;
457
458 status = walk_state->ascending_callback(walk_state);
459 status = acpi_ps_next_parse_state(walk_state, *op, status);
460
461 status2 = acpi_ps_complete_this_op(walk_state, *op);
462 if (ACPI_FAILURE(status2)) {
463 return_ACPI_STATUS(status2);
464 }
465
466 status = AE_OK;
467 break;
468
469 case AE_CTRL_TERMINATE:
470
471 /* Clean up */
472 do {
473 if (*op) {
474 status2 =
475 acpi_ps_complete_this_op(walk_state, *op);
476 if (ACPI_FAILURE(status2)) {
477 return_ACPI_STATUS(status2);
478 }
479
480 acpi_ut_delete_generic_state
481 (acpi_ut_pop_generic_state
482 (&walk_state->control_state));
483 }
484
485 acpi_ps_pop_scope(&(walk_state->parser_state), op,
486 &walk_state->arg_types,
487 &walk_state->arg_count);
488
489 } while (*op);
490
491 return_ACPI_STATUS(AE_OK);
492
493 default: /* All other non-AE_OK status */
494
495 do {
496 if (*op) {
497 status2 =
498 acpi_ps_complete_this_op(walk_state, *op);
499 if (ACPI_FAILURE(status2)) {
500 return_ACPI_STATUS(status2);
501 }
502 }
503
504 acpi_ps_pop_scope(&(walk_state->parser_state), op,
505 &walk_state->arg_types,
506 &walk_state->arg_count);
507
508 } while (*op);
509
510#if 0
511 /*
512 * TBD: Cleanup parse ops on error
513 */
514 if (*op == NULL) {
515 acpi_ps_pop_scope(parser_state, op,
516 &walk_state->arg_types,
517 &walk_state->arg_count);
518 }
519#endif
520 walk_state->prev_op = NULL;
521 walk_state->prev_arg_types = walk_state->arg_types;
522 return_ACPI_STATUS(status);
523 }
524
525 /* This scope complete? */
526
527 if (acpi_ps_has_completed_scope(&(walk_state->parser_state))) {
528 acpi_ps_pop_scope(&(walk_state->parser_state), op,
529 &walk_state->arg_types,
530 &walk_state->arg_count);
531 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *op));
532 } else {
533 *op = NULL;
534 }
535
536 return_ACPI_STATUS(AE_OK);
537}
538
539/*******************************************************************************
540 *
541 * FUNCTION: acpi_ps_complete_final_op
542 *
543 * PARAMETERS: walk_state - Current state
544 * op - Current Op
545 * status - Current parse status before complete last
546 * Op
547 *
548 * RETURN: Status
549 *
550 * DESCRIPTION: Complete last Op.
551 *
552 ******************************************************************************/
553
554acpi_status
555acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
556 union acpi_parse_object *op, acpi_status status)
557{
558 acpi_status status2;
559
560 ACPI_FUNCTION_TRACE_PTR(ps_complete_final_op, walk_state);
561
562 /*
563 * Complete the last Op (if not completed), and clear the scope stack.
564 * It is easily possible to end an AML "package" with an unbounded number
565 * of open scopes (such as when several ASL blocks are closed with
566 * sequential closing braces). We want to terminate each one cleanly.
567 */
568 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n",
569 op));
570 do {
571 if (op) {
572 if (walk_state->ascending_callback != NULL) {
573 walk_state->op = op;
574 walk_state->op_info =
575 acpi_ps_get_opcode_info(op->common.
576 aml_opcode);
577 walk_state->opcode = op->common.aml_opcode;
578
579 status =
580 walk_state->ascending_callback(walk_state);
581 status =
582 acpi_ps_next_parse_state(walk_state, op,
583 status);
584 if (status == AE_CTRL_PENDING) {
585 status =
586 acpi_ps_complete_op(walk_state, &op,
587 AE_OK);
588 if (ACPI_FAILURE(status)) {
589 return_ACPI_STATUS(status);
590 }
591 }
592
593 if (status == AE_CTRL_TERMINATE) {
594 status = AE_OK;
595
596 /* Clean up */
597 do {
598 if (op) {
599 status2 =
600 acpi_ps_complete_this_op
601 (walk_state, op);
602 if (ACPI_FAILURE
603 (status2)) {
604 return_ACPI_STATUS
605 (status2);
606 }
607 }
608
609 acpi_ps_pop_scope(&
610 (walk_state->
611 parser_state),
612 &op,
613 &walk_state->
614 arg_types,
615 &walk_state->
616 arg_count);
617
618 } while (op);
619
620 return_ACPI_STATUS(status);
621 }
622
623 else if (ACPI_FAILURE(status)) {
624
625 /* First error is most important */
626
627 (void)
628 acpi_ps_complete_this_op(walk_state,
629 op);
630 return_ACPI_STATUS(status);
631 }
632 }
633
634 status2 = acpi_ps_complete_this_op(walk_state, op);
635 if (ACPI_FAILURE(status2)) {
636 return_ACPI_STATUS(status2);
637 }
638 }
639
640 acpi_ps_pop_scope(&(walk_state->parser_state), &op,
641 &walk_state->arg_types,
642 &walk_state->arg_count);
643
644 } while (op);
645
646 return_ACPI_STATUS(status);
647}
diff --git a/drivers/acpi/acpica/psopcode.c b/drivers/acpi/acpica/psopcode.c
index 1793d934aa30..1b659e59710a 100644
--- a/drivers/acpi/acpica/psopcode.c
+++ b/drivers/acpi/acpica/psopcode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -43,16 +43,12 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h" 45#include "accommon.h"
46#include "acparser.h"
47#include "acopcode.h" 46#include "acopcode.h"
48#include "amlcode.h" 47#include "amlcode.h"
49 48
50#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
51ACPI_MODULE_NAME("psopcode") 50ACPI_MODULE_NAME("psopcode")
52 51
53static const u8 acpi_gbl_argument_count[] =
54 { 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 6 };
55
56/******************************************************************************* 52/*******************************************************************************
57 * 53 *
58 * NAME: acpi_gbl_aml_op_info 54 * NAME: acpi_gbl_aml_op_info
@@ -63,7 +59,6 @@ static const u8 acpi_gbl_argument_count[] =
63 * the operand type. 59 * the operand type.
64 * 60 *
65 ******************************************************************************/ 61 ******************************************************************************/
66
67/* 62/*
68 * Summary of opcode types/flags 63 * Summary of opcode types/flags
69 * 64 *
@@ -181,7 +176,6 @@ static const u8 acpi_gbl_argument_count[] =
181 AML_CREATE_QWORD_FIELD_OP 176 AML_CREATE_QWORD_FIELD_OP
182 177
183 ******************************************************************************/ 178 ******************************************************************************/
184
185/* 179/*
186 * Master Opcode information table. A summary of everything we know about each 180 * Master Opcode information table. A summary of everything we know about each
187 * opcode, all in one place. 181 * opcode, all in one place.
@@ -656,169 +650,3 @@ const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] = {
656 650
657/*! [End] no source code translation !*/ 651/*! [End] no source code translation !*/
658}; 652};
659
660/*
661 * This table is directly indexed by the opcodes, and returns an
662 * index into the table above
663 */
664static const u8 acpi_gbl_short_op_index[256] = {
665/* 0 1 2 3 4 5 6 7 */
666/* 8 9 A B C D E F */
667/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK,
668/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK,
669/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK,
670/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
671/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
672/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
673/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
674/* 0x38 */ 0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
675/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
676/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
677/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
678/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC,
679/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
680/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK,
681/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
682/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
683/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30,
684/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72,
685/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
686/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
687/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
688/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
689/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
690/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
691/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
692/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK,
693/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
694/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
695/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
696/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
697/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
698/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
699};
700
701/*
702 * This table is indexed by the second opcode of the extended opcode
703 * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info)
704 */
705static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = {
706/* 0 1 2 3 4 5 6 7 */
707/* 8 9 A B C D E F */
708/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK,
709/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
710/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK,
711/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
712/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
713/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
714/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
715/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
716/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
717/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
718/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
719/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
720/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
721/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
722/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
723/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
724/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
725/* 0x88 */ 0x7C,
726};
727
728/*******************************************************************************
729 *
730 * FUNCTION: acpi_ps_get_opcode_info
731 *
732 * PARAMETERS: opcode - The AML opcode
733 *
734 * RETURN: A pointer to the info about the opcode.
735 *
736 * DESCRIPTION: Find AML opcode description based on the opcode.
737 * NOTE: This procedure must ALWAYS return a valid pointer!
738 *
739 ******************************************************************************/
740
741const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
742{
743 ACPI_FUNCTION_NAME(ps_get_opcode_info);
744
745 /*
746 * Detect normal 8-bit opcode or extended 16-bit opcode
747 */
748 if (!(opcode & 0xFF00)) {
749
750 /* Simple (8-bit) opcode: 0-255, can't index beyond table */
751
752 return (&acpi_gbl_aml_op_info
753 [acpi_gbl_short_op_index[(u8) opcode]]);
754 }
755
756 if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
757 (((u8) opcode) <= MAX_EXTENDED_OPCODE)) {
758
759 /* Valid extended (16-bit) opcode */
760
761 return (&acpi_gbl_aml_op_info
762 [acpi_gbl_long_op_index[(u8) opcode]]);
763 }
764
765 /* Unknown AML opcode */
766
767 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
768 "Unknown AML opcode [%4.4X]\n", opcode));
769
770 return (&acpi_gbl_aml_op_info[_UNK]);
771}
772
773/*******************************************************************************
774 *
775 * FUNCTION: acpi_ps_get_opcode_name
776 *
777 * PARAMETERS: opcode - The AML opcode
778 *
779 * RETURN: A pointer to the name of the opcode (ASCII String)
780 * Note: Never returns NULL.
781 *
782 * DESCRIPTION: Translate an opcode into a human-readable string
783 *
784 ******************************************************************************/
785
786char *acpi_ps_get_opcode_name(u16 opcode)
787{
788#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
789
790 const struct acpi_opcode_info *op;
791
792 op = acpi_ps_get_opcode_info(opcode);
793
794 /* Always guaranteed to return a valid pointer */
795
796 return (op->name);
797
798#else
799 return ("OpcodeName unavailable");
800
801#endif
802}
803
804/*******************************************************************************
805 *
806 * FUNCTION: acpi_ps_get_argument_count
807 *
808 * PARAMETERS: op_type - Type associated with the AML opcode
809 *
810 * RETURN: Argument count
811 *
812 * DESCRIPTION: Obtain the number of expected arguments for an AML opcode
813 *
814 ******************************************************************************/
815
816u8 acpi_ps_get_argument_count(u32 op_type)
817{
818
819 if (op_type <= AML_TYPE_EXEC_6A_0T_1R) {
820 return (acpi_gbl_argument_count[op_type]);
821 }
822
823 return (0);
824}
diff --git a/drivers/acpi/acpica/psopinfo.c b/drivers/acpi/acpica/psopinfo.c
new file mode 100644
index 000000000000..9ba5301e5751
--- /dev/null
+++ b/drivers/acpi/acpica/psopinfo.c
@@ -0,0 +1,223 @@
1/******************************************************************************
2 *
3 * Module Name: psopinfo - AML opcode information functions and dispatch tables
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 "acparser.h"
47#include "acopcode.h"
48#include "amlcode.h"
49
50#define _COMPONENT ACPI_PARSER
51ACPI_MODULE_NAME("psopinfo")
52
53extern const u8 acpi_gbl_short_op_index[];
54extern const u8 acpi_gbl_long_op_index[];
55
56static const u8 acpi_gbl_argument_count[] =
57 { 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 6 };
58
59/*******************************************************************************
60 *
61 * FUNCTION: acpi_ps_get_opcode_info
62 *
63 * PARAMETERS: opcode - The AML opcode
64 *
65 * RETURN: A pointer to the info about the opcode.
66 *
67 * DESCRIPTION: Find AML opcode description based on the opcode.
68 * NOTE: This procedure must ALWAYS return a valid pointer!
69 *
70 ******************************************************************************/
71
72const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode)
73{
74 ACPI_FUNCTION_NAME(ps_get_opcode_info);
75
76 /*
77 * Detect normal 8-bit opcode or extended 16-bit opcode
78 */
79 if (!(opcode & 0xFF00)) {
80
81 /* Simple (8-bit) opcode: 0-255, can't index beyond table */
82
83 return (&acpi_gbl_aml_op_info
84 [acpi_gbl_short_op_index[(u8)opcode]]);
85 }
86
87 if (((opcode & 0xFF00) == AML_EXTENDED_OPCODE) &&
88 (((u8)opcode) <= MAX_EXTENDED_OPCODE)) {
89
90 /* Valid extended (16-bit) opcode */
91
92 return (&acpi_gbl_aml_op_info
93 [acpi_gbl_long_op_index[(u8)opcode]]);
94 }
95
96 /* Unknown AML opcode */
97
98 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
99 "Unknown AML opcode [%4.4X]\n", opcode));
100
101 return (&acpi_gbl_aml_op_info[_UNK]);
102}
103
104/*******************************************************************************
105 *
106 * FUNCTION: acpi_ps_get_opcode_name
107 *
108 * PARAMETERS: opcode - The AML opcode
109 *
110 * RETURN: A pointer to the name of the opcode (ASCII String)
111 * Note: Never returns NULL.
112 *
113 * DESCRIPTION: Translate an opcode into a human-readable string
114 *
115 ******************************************************************************/
116
117char *acpi_ps_get_opcode_name(u16 opcode)
118{
119#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
120
121 const struct acpi_opcode_info *op;
122
123 op = acpi_ps_get_opcode_info(opcode);
124
125 /* Always guaranteed to return a valid pointer */
126
127 return (op->name);
128
129#else
130 return ("OpcodeName unavailable");
131
132#endif
133}
134
135/*******************************************************************************
136 *
137 * FUNCTION: acpi_ps_get_argument_count
138 *
139 * PARAMETERS: op_type - Type associated with the AML opcode
140 *
141 * RETURN: Argument count
142 *
143 * DESCRIPTION: Obtain the number of expected arguments for an AML opcode
144 *
145 ******************************************************************************/
146
147u8 acpi_ps_get_argument_count(u32 op_type)
148{
149
150 if (op_type <= AML_TYPE_EXEC_6A_0T_1R) {
151 return (acpi_gbl_argument_count[op_type]);
152 }
153
154 return (0);
155}
156
157/*
158 * This table is directly indexed by the opcodes It returns
159 * an index into the opcode table (acpi_gbl_aml_op_info)
160 */
161const u8 acpi_gbl_short_op_index[256] = {
162/* 0 1 2 3 4 5 6 7 */
163/* 8 9 A B C D E F */
164/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK,
165/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK,
166/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK,
167/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
168/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
169/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX,
170/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D,
171/* 0x38 */ 0x7F, 0x80, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
172/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
173/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
174/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC,
175/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC,
176/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13,
177/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK,
178/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22,
179/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
180/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30,
181/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72,
182/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
183/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
184/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
185/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
186/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
187/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
188/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
189/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK,
190/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
191/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
192/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
193/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
194/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
195/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45,
196};
197
198/*
199 * This table is indexed by the second opcode of the extended opcode
200 * pair. It returns an index into the opcode table (acpi_gbl_aml_op_info)
201 */
202const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] = {
203/* 0 1 2 3 4 5 6 7 */
204/* 8 9 A B C D E F */
205/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK,
206/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
207/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK,
208/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B,
209/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
210/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK,
211/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK,
212/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
213/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
214/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
215/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
216/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
217/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
218/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
219/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
220/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
221/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
222/* 0x88 */ 0x7C,
223};
diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c
index 2494caf47755..abc4c48b2edd 100644
--- a/drivers/acpi/acpica/psparse.c
+++ b/drivers/acpi/acpica/psparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psscope.c b/drivers/acpi/acpica/psscope.c
index 608dc20dc173..6a4b6fb39f32 100644
--- a/drivers/acpi/acpica/psscope.c
+++ b/drivers/acpi/acpica/psscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pstree.c b/drivers/acpi/acpica/pstree.c
index fdb2e71f3046..c1934bf04f0a 100644
--- a/drivers/acpi/acpica/pstree.c
+++ b/drivers/acpi/acpica/pstree.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psutils.c b/drivers/acpi/acpica/psutils.c
index 4137dcb352d1..91fa73a6e55e 100644
--- a/drivers/acpi/acpica/psutils.c
+++ b/drivers/acpi/acpica/psutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -202,14 +202,6 @@ u8 acpi_ps_is_leading_char(u32 c)
202} 202}
203 203
204/* 204/*
205 * Is "c" a namestring prefix character?
206 */
207u8 acpi_ps_is_prefix_char(u32 c)
208{
209 return ((u8) (c == '\\' || c == '^'));
210}
211
212/*
213 * Get op's name (4-byte name segment) or 0 if unnamed 205 * Get op's name (4-byte name segment) or 0 if unnamed
214 */ 206 */
215#ifdef ACPI_FUTURE_USAGE 207#ifdef ACPI_FUTURE_USAGE
diff --git a/drivers/acpi/acpica/pswalk.c b/drivers/acpi/acpica/pswalk.c
index ab96cf47896d..abd65624754f 100644
--- a/drivers/acpi/acpica/pswalk.c
+++ b/drivers/acpi/acpica/pswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c
index 963e16225797..f68254268965 100644
--- a/drivers/acpi/acpica/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsaddr.c b/drivers/acpi/acpica/rsaddr.c
index 856ff075b6ab..f3a9276ac665 100644
--- a/drivers/acpi/acpica/rsaddr.c
+++ b/drivers/acpi/acpica/rsaddr.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 147feb6aa2a0..7816d4eef04e 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -84,7 +84,7 @@ static u8 acpi_rs_count_set_bits(u16 bit_field)
84 bit_field &= (u16) (bit_field - 1); 84 bit_field &= (u16) (bit_field - 1);
85 } 85 }
86 86
87 return bits_set; 87 return (bits_set);
88} 88}
89 89
90/******************************************************************************* 90/*******************************************************************************
@@ -407,7 +407,9 @@ acpi_rs_get_list_length(u8 * aml_buffer,
407 407
408 /* Validate the Resource Type and Resource Length */ 408 /* Validate the Resource Type and Resource Length */
409 409
410 status = acpi_ut_validate_resource(aml_buffer, &resource_index); 410 status =
411 acpi_ut_validate_resource(NULL, aml_buffer,
412 &resource_index);
411 if (ACPI_FAILURE(status)) { 413 if (ACPI_FAILURE(status)) {
412 /* 414 /*
413 * Exit on failure. Cannot continue because the descriptor length 415 * Exit on failure. Cannot continue because the descriptor length
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index 311cbc4f05fa..f8b55b426c9d 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -98,7 +98,7 @@ acpi_buffer_to_resource(u8 *aml_buffer,
98 98
99 /* Perform the AML-to-Resource conversion */ 99 /* Perform the AML-to-Resource conversion */
100 100
101 status = acpi_ut_walk_aml_resources(aml_buffer, aml_buffer_length, 101 status = acpi_ut_walk_aml_resources(NULL, aml_buffer, aml_buffer_length,
102 acpi_rs_convert_aml_to_resources, 102 acpi_rs_convert_aml_to_resources,
103 &current_resource_ptr); 103 &current_resource_ptr);
104 if (status == AE_AML_NO_RESOURCE_END_TAG) { 104 if (status == AE_AML_NO_RESOURCE_END_TAG) {
@@ -174,7 +174,7 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
174 /* Do the conversion */ 174 /* Do the conversion */
175 175
176 resource = output_buffer->pointer; 176 resource = output_buffer->pointer;
177 status = acpi_ut_walk_aml_resources(aml_start, aml_buffer_length, 177 status = acpi_ut_walk_aml_resources(NULL, aml_start, aml_buffer_length,
178 acpi_rs_convert_aml_to_resources, 178 acpi_rs_convert_aml_to_resources,
179 &resource); 179 &resource);
180 if (ACPI_FAILURE(status)) { 180 if (ACPI_FAILURE(status)) {
@@ -480,8 +480,7 @@ acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
480 status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed); 480 status = acpi_rs_get_aml_length(linked_list_buffer, &aml_size_needed);
481 481
482 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", 482 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
483 (u32) aml_size_needed, 483 (u32)aml_size_needed, acpi_format_exception(status)));
484 acpi_format_exception(status)));
485 if (ACPI_FAILURE(status)) { 484 if (ACPI_FAILURE(status)) {
486 return_ACPI_STATUS(status); 485 return_ACPI_STATUS(status);
487 } 486 }
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index 4d11b072388c..cab51445189d 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -77,419 +77,16 @@ static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
77static void 77static void
78acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table); 78acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table);
79 79
80#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f)
81#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f)
82#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info))
83
84/*******************************************************************************
85 *
86 * Resource Descriptor info tables
87 *
88 * Note: The first table entry must be a Title or Literal and must contain
89 * the table length (number of table entries)
90 *
91 ******************************************************************************/
92
93struct acpi_rsdump_info acpi_rs_dump_irq[7] = {
94 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL},
95 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.descriptor_length),
96 "Descriptor Length", NULL},
97 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering",
98 acpi_gbl_he_decode},
99 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity",
100 acpi_gbl_ll_decode},
101 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing",
102 acpi_gbl_shr_decode},
103 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count),
104 "Interrupt Count", NULL},
105 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]),
106 "Interrupt List", NULL}
107};
108
109struct acpi_rsdump_info acpi_rs_dump_dma[6] = {
110 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL},
111 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed",
112 acpi_gbl_typ_decode},
113 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering",
114 acpi_gbl_bm_decode},
115 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type",
116 acpi_gbl_siz_decode},
117 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count",
118 NULL},
119 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List",
120 NULL}
121};
122
123struct acpi_rsdump_info acpi_rs_dump_start_dpf[4] = {
124 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf),
125 "Start-Dependent-Functions", NULL},
126 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(start_dpf.descriptor_length),
127 "Descriptor Length", NULL},
128 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.compatibility_priority),
129 "Compatibility Priority", acpi_gbl_config_decode},
130 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.performance_robustness),
131 "Performance/Robustness", acpi_gbl_config_decode}
132};
133
134struct acpi_rsdump_info acpi_rs_dump_end_dpf[1] = {
135 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_dpf),
136 "End-Dependent-Functions", NULL}
137};
138
139struct acpi_rsdump_info acpi_rs_dump_io[6] = {
140 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io), "I/O", NULL},
141 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(io.io_decode), "Address Decoding",
142 acpi_gbl_io_decode},
143 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.minimum), "Address Minimum", NULL},
144 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.maximum), "Address Maximum", NULL},
145 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.alignment), "Alignment", NULL},
146 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.address_length), "Address Length",
147 NULL}
148};
149
150struct acpi_rsdump_info acpi_rs_dump_fixed_io[3] = {
151 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_io),
152 "Fixed I/O", NULL},
153 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_io.address), "Address", NULL},
154 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_io.address_length),
155 "Address Length", NULL}
156};
157
158struct acpi_rsdump_info acpi_rs_dump_vendor[3] = {
159 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_vendor),
160 "Vendor Specific", NULL},
161 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(vendor.byte_length), "Length", NULL},
162 {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET(vendor.byte_data[0]), "Vendor Data",
163 NULL}
164};
165
166struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = {
167 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "EndTag",
168 NULL}
169};
170
171struct acpi_rsdump_info acpi_rs_dump_memory24[6] = {
172 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24),
173 "24-Bit Memory Range", NULL},
174 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect),
175 "Write Protect", acpi_gbl_rw_decode},
176 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum",
177 NULL},
178 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum",
179 NULL},
180 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.alignment), "Alignment",
181 NULL},
182 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.address_length),
183 "Address Length", NULL}
184};
185
186struct acpi_rsdump_info acpi_rs_dump_memory32[6] = {
187 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32),
188 "32-Bit Memory Range", NULL},
189 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect),
190 "Write Protect", acpi_gbl_rw_decode},
191 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum",
192 NULL},
193 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum",
194 NULL},
195 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.alignment), "Alignment",
196 NULL},
197 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.address_length),
198 "Address Length", NULL}
199};
200
201struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = {
202 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32),
203 "32-Bit Fixed Memory Range", NULL},
204 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect),
205 "Write Protect", acpi_gbl_rw_decode},
206 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address",
207 NULL},
208 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length),
209 "Address Length", NULL}
210};
211
212struct acpi_rsdump_info acpi_rs_dump_address16[8] = {
213 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address16),
214 "16-Bit WORD Address Space", NULL},
215 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
216 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity",
217 NULL},
218 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum",
219 NULL},
220 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum",
221 NULL},
222 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset),
223 "Translation Offset", NULL},
224 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length),
225 "Address Length", NULL},
226 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL}
227};
228
229struct acpi_rsdump_info acpi_rs_dump_address32[8] = {
230 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address32),
231 "32-Bit DWORD Address Space", NULL},
232 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
233 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity",
234 NULL},
235 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum",
236 NULL},
237 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum",
238 NULL},
239 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset),
240 "Translation Offset", NULL},
241 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length),
242 "Address Length", NULL},
243 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL}
244};
245
246struct acpi_rsdump_info acpi_rs_dump_address64[8] = {
247 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address64),
248 "64-Bit QWORD Address Space", NULL},
249 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
250 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity",
251 NULL},
252 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum",
253 NULL},
254 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum",
255 NULL},
256 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset),
257 "Translation Offset", NULL},
258 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length),
259 "Address Length", NULL},
260 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL}
261};
262
263struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = {
264 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_address64),
265 "64-Bit Extended Address Space", NULL},
266 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
267 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity),
268 "Granularity", NULL},
269 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum),
270 "Address Minimum", NULL},
271 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum),
272 "Address Maximum", NULL},
273 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset),
274 "Translation Offset", NULL},
275 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length),
276 "Address Length", NULL},
277 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific),
278 "Type-Specific Attribute", NULL}
279};
280
281struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = {
282 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_irq),
283 "Extended IRQ", NULL},
284 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer),
285 "Type", acpi_gbl_consume_decode},
286 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering),
287 "Triggering", acpi_gbl_he_decode},
288 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity",
289 acpi_gbl_ll_decode},
290 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing",
291 acpi_gbl_shr_decode},
292 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL,
293 NULL},
294 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count),
295 "Interrupt Count", NULL},
296 {ACPI_RSD_DWORDLIST, ACPI_RSD_OFFSET(extended_irq.interrupts[0]),
297 "Interrupt List", NULL}
298};
299
300struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = {
301 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_generic_reg),
302 "Generic Register", NULL},
303 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.space_id), "Space ID",
304 NULL},
305 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_width), "Bit Width",
306 NULL},
307 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_offset), "Bit Offset",
308 NULL},
309 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.access_size),
310 "Access Size", NULL},
311 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL}
312};
313
314struct acpi_rsdump_info acpi_rs_dump_gpio[16] = {
315 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_gpio), "GPIO", NULL},
316 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.revision_id), "RevisionId", NULL},
317 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.connection_type),
318 "ConnectionType", acpi_gbl_ct_decode},
319 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.producer_consumer),
320 "ProducerConsumer", acpi_gbl_consume_decode},
321 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.pin_config), "PinConfig",
322 acpi_gbl_ppc_decode},
323 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.sharable), "Sharable",
324 acpi_gbl_shr_decode},
325 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.io_restriction),
326 "IoRestriction", acpi_gbl_ior_decode},
327 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.triggering), "Triggering",
328 acpi_gbl_he_decode},
329 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.polarity), "Polarity",
330 acpi_gbl_ll_decode},
331 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.drive_strength), "DriveStrength",
332 NULL},
333 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.debounce_timeout),
334 "DebounceTimeout", NULL},
335 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(gpio.resource_source),
336 "ResourceSource", NULL},
337 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.pin_table_length),
338 "PinTableLength", NULL},
339 {ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET(gpio.pin_table), "PinTable", NULL},
340 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.vendor_length), "VendorLength",
341 NULL},
342 {ACPI_RSD_SHORTLISTX, ACPI_RSD_OFFSET(gpio.vendor_data), "VendorData",
343 NULL},
344};
345
346struct acpi_rsdump_info acpi_rs_dump_fixed_dma[4] = {
347 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_dma),
348 "FixedDma", NULL},
349 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.request_lines),
350 "RequestLines", NULL},
351 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.channels), "Channels",
352 NULL},
353 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_dma.width), "TransferWidth",
354 acpi_gbl_dts_decode},
355};
356
357#define ACPI_RS_DUMP_COMMON_SERIAL_BUS \
358 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.revision_id), "RevisionId", NULL}, \
359 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type), "Type", acpi_gbl_sbt_decode}, \
360 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.producer_consumer), "ProducerConsumer", acpi_gbl_consume_decode}, \
361 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.slave_mode), "SlaveMode", acpi_gbl_sm_decode}, \
362 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type_revision_id), "TypeRevisionId", NULL}, \
363 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.type_data_length), "TypeDataLength", NULL}, \
364 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (common_serial_bus.resource_source), "ResourceSource", NULL}, \
365 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.vendor_length), "VendorLength", NULL}, \
366 {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (common_serial_bus.vendor_data), "VendorData", NULL},
367
368struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[10] = {
369 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_common_serial_bus),
370 "Common Serial Bus", NULL},
371 ACPI_RS_DUMP_COMMON_SERIAL_BUS
372};
373
374struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = {
375 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus),
376 "I2C Serial Bus", NULL},
377 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
378 ACPI_RSD_OFFSET(i2c_serial_bus.
379 access_mode),
380 "AccessMode", acpi_gbl_am_decode},
381 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(i2c_serial_bus.connection_speed),
382 "ConnectionSpeed", NULL},
383 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(i2c_serial_bus.slave_address),
384 "SlaveAddress", NULL},
385};
386
387struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = {
388 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_spi_serial_bus),
389 "Spi Serial Bus", NULL},
390 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
391 ACPI_RSD_OFFSET(spi_serial_bus.
392 wire_mode), "WireMode",
393 acpi_gbl_wm_decode},
394 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(spi_serial_bus.device_polarity),
395 "DevicePolarity", acpi_gbl_dp_decode},
396 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.data_bit_length),
397 "DataBitLength", NULL},
398 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_phase),
399 "ClockPhase", acpi_gbl_cph_decode},
400 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_polarity),
401 "ClockPolarity", acpi_gbl_cpo_decode},
402 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(spi_serial_bus.device_selection),
403 "DeviceSelection", NULL},
404 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(spi_serial_bus.connection_speed),
405 "ConnectionSpeed", NULL},
406};
407
408struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[19] = {
409 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_uart_serial_bus),
410 "Uart Serial Bus", NULL},
411 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_2BITFLAG,
412 ACPI_RSD_OFFSET(uart_serial_bus.
413 flow_control),
414 "FlowControl", acpi_gbl_fc_decode},
415 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.stop_bits),
416 "StopBits", acpi_gbl_sb_decode},
417 {ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.data_bits),
418 "DataBits", acpi_gbl_bpb_decode},
419 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.endian), "Endian",
420 acpi_gbl_ed_decode},
421 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.parity), "Parity",
422 acpi_gbl_pt_decode},
423 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.lines_enabled),
424 "LinesEnabled", NULL},
425 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.rx_fifo_size),
426 "RxFifoSize", NULL},
427 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.tx_fifo_size),
428 "TxFifoSize", NULL},
429 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(uart_serial_bus.default_baud_rate),
430 "ConnectionSpeed", NULL},
431};
432
433/*
434 * Tables used for common address descriptor flag fields
435 */
436static struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = {
437 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_general_flags), NULL,
438 NULL},
439 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer),
440 "Consumer/Producer", acpi_gbl_consume_decode},
441 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode",
442 acpi_gbl_dec_decode},
443 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed),
444 "Min Relocatability", acpi_gbl_min_decode},
445 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed),
446 "Max Relocatability", acpi_gbl_max_decode}
447};
448
449static struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
450 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags),
451 "Resource Type", (void *)"Memory Range"},
452 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
453 "Write Protect", acpi_gbl_rw_decode},
454 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
455 "Caching", acpi_gbl_mem_decode},
456 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type),
457 "Range Type", acpi_gbl_mtp_decode},
458 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation),
459 "Translation", acpi_gbl_ttp_decode}
460};
461
462static struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = {
463 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags),
464 "Resource Type", (void *)"I/O Range"},
465 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
466 "Range Type", acpi_gbl_rng_decode},
467 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
468 "Translation", acpi_gbl_ttp_decode},
469 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type),
470 "Translation Type", acpi_gbl_trs_decode}
471};
472
473/*
474 * Table used to dump _PRT contents
475 */
476static struct acpi_rsdump_info acpi_rs_dump_prt[5] = {
477 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_prt), NULL, NULL},
478 {ACPI_RSD_UINT64, ACPI_PRT_OFFSET(address), "Address", NULL},
479 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(pin), "Pin", NULL},
480 {ACPI_RSD_STRING, ACPI_PRT_OFFSET(source[0]), "Source", NULL},
481 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(source_index), "Source Index", NULL}
482};
483
484/******************************************************************************* 80/*******************************************************************************
485 * 81 *
486 * FUNCTION: acpi_rs_dump_descriptor 82 * FUNCTION: acpi_rs_dump_descriptor
487 * 83 *
488 * PARAMETERS: Resource 84 * PARAMETERS: resource - Buffer containing the resource
85 * table - Table entry to decode the resource
489 * 86 *
490 * RETURN: None 87 * RETURN: None
491 * 88 *
492 * DESCRIPTION: 89 * DESCRIPTION: Dump a resource descriptor based on a dump table entry.
493 * 90 *
494 ******************************************************************************/ 91 ******************************************************************************/
495 92
@@ -654,7 +251,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
654 /* 251 /*
655 * Optional resource_source for Address resources 252 * Optional resource_source for Address resources
656 */ 253 */
657 acpi_rs_dump_resource_source(ACPI_CAST_PTR(struct 254 acpi_rs_dump_resource_source(ACPI_CAST_PTR
255 (struct
658 acpi_resource_source, 256 acpi_resource_source,
659 target)); 257 target));
660 break; 258 break;
@@ -765,8 +363,9 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
765 363
766 ACPI_FUNCTION_ENTRY(); 364 ACPI_FUNCTION_ENTRY();
767 365
768 if (!(acpi_dbg_level & ACPI_LV_RESOURCES) 366 /* Check if debug output enabled */
769 || !(_COMPONENT & acpi_dbg_layer)) { 367
368 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
770 return; 369 return;
771 } 370 }
772 371
@@ -827,8 +426,9 @@ void acpi_rs_dump_irq_list(u8 * route_table)
827 426
828 ACPI_FUNCTION_ENTRY(); 427 ACPI_FUNCTION_ENTRY();
829 428
830 if (!(acpi_dbg_level & ACPI_LV_RESOURCES) 429 /* Check if debug output enabled */
831 || !(_COMPONENT & acpi_dbg_layer)) { 430
431 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
832 return; 432 return;
833 } 433 }
834 434
diff --git a/drivers/acpi/acpica/rsdumpinfo.c b/drivers/acpi/acpica/rsdumpinfo.c
new file mode 100644
index 000000000000..46192bd53653
--- /dev/null
+++ b/drivers/acpi/acpica/rsdumpinfo.c
@@ -0,0 +1,454 @@
1/*******************************************************************************
2 *
3 * Module Name: rsdumpinfo - Tables used to display resource descriptors.
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 "acresrc.h"
47
48#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsdumpinfo")
50
51#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
52#define ACPI_RSD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_resource_data,f)
53#define ACPI_PRT_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_pci_routing_table,f)
54#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_rsdump_info))
55/*******************************************************************************
56 *
57 * Resource Descriptor info tables
58 *
59 * Note: The first table entry must be a Title or Literal and must contain
60 * the table length (number of table entries)
61 *
62 ******************************************************************************/
63struct acpi_rsdump_info acpi_rs_dump_irq[7] = {
64 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_irq), "IRQ", NULL},
65 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.descriptor_length),
66 "Descriptor Length", NULL},
67 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.triggering), "Triggering",
68 acpi_gbl_he_decode},
69 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(irq.polarity), "Polarity",
70 acpi_gbl_ll_decode},
71 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(irq.sharable), "Sharing",
72 acpi_gbl_shr_decode},
73 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(irq.interrupt_count),
74 "Interrupt Count", NULL},
75 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(irq.interrupts[0]),
76 "Interrupt List", NULL}
77};
78
79struct acpi_rsdump_info acpi_rs_dump_dma[6] = {
80 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_dma), "DMA", NULL},
81 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.type), "Speed",
82 acpi_gbl_typ_decode},
83 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(dma.bus_master), "Mastering",
84 acpi_gbl_bm_decode},
85 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(dma.transfer), "Transfer Type",
86 acpi_gbl_siz_decode},
87 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(dma.channel_count), "Channel Count",
88 NULL},
89 {ACPI_RSD_SHORTLIST, ACPI_RSD_OFFSET(dma.channels[0]), "Channel List",
90 NULL}
91};
92
93struct acpi_rsdump_info acpi_rs_dump_start_dpf[4] = {
94 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_start_dpf),
95 "Start-Dependent-Functions", NULL},
96 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(start_dpf.descriptor_length),
97 "Descriptor Length", NULL},
98 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.compatibility_priority),
99 "Compatibility Priority", acpi_gbl_config_decode},
100 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(start_dpf.performance_robustness),
101 "Performance/Robustness", acpi_gbl_config_decode}
102};
103
104struct acpi_rsdump_info acpi_rs_dump_end_dpf[1] = {
105 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_dpf),
106 "End-Dependent-Functions", NULL}
107};
108
109struct acpi_rsdump_info acpi_rs_dump_io[6] = {
110 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io), "I/O", NULL},
111 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(io.io_decode), "Address Decoding",
112 acpi_gbl_io_decode},
113 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.minimum), "Address Minimum", NULL},
114 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(io.maximum), "Address Maximum", NULL},
115 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.alignment), "Alignment", NULL},
116 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(io.address_length), "Address Length",
117 NULL}
118};
119
120struct acpi_rsdump_info acpi_rs_dump_fixed_io[3] = {
121 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_io),
122 "Fixed I/O", NULL},
123 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_io.address), "Address", NULL},
124 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_io.address_length),
125 "Address Length", NULL}
126};
127
128struct acpi_rsdump_info acpi_rs_dump_vendor[3] = {
129 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_vendor),
130 "Vendor Specific", NULL},
131 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(vendor.byte_length), "Length", NULL},
132 {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET(vendor.byte_data[0]), "Vendor Data",
133 NULL}
134};
135
136struct acpi_rsdump_info acpi_rs_dump_end_tag[1] = {
137 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_end_tag), "EndTag",
138 NULL}
139};
140
141struct acpi_rsdump_info acpi_rs_dump_memory24[6] = {
142 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory24),
143 "24-Bit Memory Range", NULL},
144 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory24.write_protect),
145 "Write Protect", acpi_gbl_rw_decode},
146 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.minimum), "Address Minimum",
147 NULL},
148 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.maximum), "Address Maximum",
149 NULL},
150 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.alignment), "Alignment",
151 NULL},
152 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(memory24.address_length),
153 "Address Length", NULL}
154};
155
156struct acpi_rsdump_info acpi_rs_dump_memory32[6] = {
157 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory32),
158 "32-Bit Memory Range", NULL},
159 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(memory32.write_protect),
160 "Write Protect", acpi_gbl_rw_decode},
161 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.minimum), "Address Minimum",
162 NULL},
163 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.maximum), "Address Maximum",
164 NULL},
165 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.alignment), "Alignment",
166 NULL},
167 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(memory32.address_length),
168 "Address Length", NULL}
169};
170
171struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[4] = {
172 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_memory32),
173 "32-Bit Fixed Memory Range", NULL},
174 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(fixed_memory32.write_protect),
175 "Write Protect", acpi_gbl_rw_decode},
176 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address), "Address",
177 NULL},
178 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(fixed_memory32.address_length),
179 "Address Length", NULL}
180};
181
182struct acpi_rsdump_info acpi_rs_dump_address16[8] = {
183 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address16),
184 "16-Bit WORD Address Space", NULL},
185 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
186 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.granularity), "Granularity",
187 NULL},
188 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.minimum), "Address Minimum",
189 NULL},
190 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.maximum), "Address Maximum",
191 NULL},
192 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.translation_offset),
193 "Translation Offset", NULL},
194 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(address16.address_length),
195 "Address Length", NULL},
196 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address16.resource_source), NULL, NULL}
197};
198
199struct acpi_rsdump_info acpi_rs_dump_address32[8] = {
200 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address32),
201 "32-Bit DWORD Address Space", NULL},
202 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
203 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.granularity), "Granularity",
204 NULL},
205 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.minimum), "Address Minimum",
206 NULL},
207 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.maximum), "Address Maximum",
208 NULL},
209 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.translation_offset),
210 "Translation Offset", NULL},
211 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(address32.address_length),
212 "Address Length", NULL},
213 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address32.resource_source), NULL, NULL}
214};
215
216struct acpi_rsdump_info acpi_rs_dump_address64[8] = {
217 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_address64),
218 "64-Bit QWORD Address Space", NULL},
219 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
220 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.granularity), "Granularity",
221 NULL},
222 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.minimum), "Address Minimum",
223 NULL},
224 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.maximum), "Address Maximum",
225 NULL},
226 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.translation_offset),
227 "Translation Offset", NULL},
228 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(address64.address_length),
229 "Address Length", NULL},
230 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(address64.resource_source), NULL, NULL}
231};
232
233struct acpi_rsdump_info acpi_rs_dump_ext_address64[8] = {
234 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_address64),
235 "64-Bit Extended Address Space", NULL},
236 {ACPI_RSD_ADDRESS, 0, NULL, NULL},
237 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.granularity),
238 "Granularity", NULL},
239 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.minimum),
240 "Address Minimum", NULL},
241 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.maximum),
242 "Address Maximum", NULL},
243 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.translation_offset),
244 "Translation Offset", NULL},
245 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.address_length),
246 "Address Length", NULL},
247 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(ext_address64.type_specific),
248 "Type-Specific Attribute", NULL}
249};
250
251struct acpi_rsdump_info acpi_rs_dump_ext_irq[8] = {
252 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_ext_irq),
253 "Extended IRQ", NULL},
254 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.producer_consumer),
255 "Type", acpi_gbl_consume_decode},
256 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.triggering),
257 "Triggering", acpi_gbl_he_decode},
258 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(extended_irq.polarity), "Polarity",
259 acpi_gbl_ll_decode},
260 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(extended_irq.sharable), "Sharing",
261 acpi_gbl_shr_decode},
262 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(extended_irq.resource_source), NULL,
263 NULL},
264 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(extended_irq.interrupt_count),
265 "Interrupt Count", NULL},
266 {ACPI_RSD_DWORDLIST, ACPI_RSD_OFFSET(extended_irq.interrupts[0]),
267 "Interrupt List", NULL}
268};
269
270struct acpi_rsdump_info acpi_rs_dump_generic_reg[6] = {
271 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_generic_reg),
272 "Generic Register", NULL},
273 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.space_id), "Space ID",
274 NULL},
275 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_width), "Bit Width",
276 NULL},
277 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.bit_offset), "Bit Offset",
278 NULL},
279 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(generic_reg.access_size),
280 "Access Size", NULL},
281 {ACPI_RSD_UINT64, ACPI_RSD_OFFSET(generic_reg.address), "Address", NULL}
282};
283
284struct acpi_rsdump_info acpi_rs_dump_gpio[16] = {
285 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_gpio), "GPIO", NULL},
286 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.revision_id), "RevisionId", NULL},
287 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.connection_type),
288 "ConnectionType", acpi_gbl_ct_decode},
289 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.producer_consumer),
290 "ProducerConsumer", acpi_gbl_consume_decode},
291 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(gpio.pin_config), "PinConfig",
292 acpi_gbl_ppc_decode},
293 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.sharable), "Sharing",
294 acpi_gbl_shr_decode},
295 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.io_restriction),
296 "IoRestriction", acpi_gbl_ior_decode},
297 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(gpio.triggering), "Triggering",
298 acpi_gbl_he_decode},
299 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(gpio.polarity), "Polarity",
300 acpi_gbl_ll_decode},
301 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.drive_strength), "DriveStrength",
302 NULL},
303 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.debounce_timeout),
304 "DebounceTimeout", NULL},
305 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET(gpio.resource_source),
306 "ResourceSource", NULL},
307 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.pin_table_length),
308 "PinTableLength", NULL},
309 {ACPI_RSD_WORDLIST, ACPI_RSD_OFFSET(gpio.pin_table), "PinTable", NULL},
310 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(gpio.vendor_length), "VendorLength",
311 NULL},
312 {ACPI_RSD_SHORTLISTX, ACPI_RSD_OFFSET(gpio.vendor_data), "VendorData",
313 NULL},
314};
315
316struct acpi_rsdump_info acpi_rs_dump_fixed_dma[4] = {
317 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_fixed_dma),
318 "FixedDma", NULL},
319 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.request_lines),
320 "RequestLines", NULL},
321 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(fixed_dma.channels), "Channels",
322 NULL},
323 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(fixed_dma.width), "TransferWidth",
324 acpi_gbl_dts_decode},
325};
326
327#define ACPI_RS_DUMP_COMMON_SERIAL_BUS \
328 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.revision_id), "RevisionId", NULL}, \
329 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type), "Type", acpi_gbl_sbt_decode}, \
330 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.producer_consumer), "ProducerConsumer", acpi_gbl_consume_decode}, \
331 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (common_serial_bus.slave_mode), "SlaveMode", acpi_gbl_sm_decode}, \
332 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (common_serial_bus.type_revision_id), "TypeRevisionId", NULL}, \
333 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.type_data_length), "TypeDataLength", NULL}, \
334 {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (common_serial_bus.resource_source), "ResourceSource", NULL}, \
335 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (common_serial_bus.vendor_length), "VendorLength", NULL}, \
336 {ACPI_RSD_SHORTLISTX,ACPI_RSD_OFFSET (common_serial_bus.vendor_data), "VendorData", NULL},
337
338struct acpi_rsdump_info acpi_rs_dump_common_serial_bus[10] = {
339 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_common_serial_bus),
340 "Common Serial Bus", NULL},
341 ACPI_RS_DUMP_COMMON_SERIAL_BUS
342};
343
344struct acpi_rsdump_info acpi_rs_dump_i2c_serial_bus[13] = {
345 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_i2c_serial_bus),
346 "I2C Serial Bus", NULL},
347 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
348 ACPI_RSD_OFFSET(i2c_serial_bus.
349 access_mode),
350 "AccessMode", acpi_gbl_am_decode},
351 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(i2c_serial_bus.connection_speed),
352 "ConnectionSpeed", NULL},
353 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(i2c_serial_bus.slave_address),
354 "SlaveAddress", NULL},
355};
356
357struct acpi_rsdump_info acpi_rs_dump_spi_serial_bus[17] = {
358 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_spi_serial_bus),
359 "Spi Serial Bus", NULL},
360 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_1BITFLAG,
361 ACPI_RSD_OFFSET(spi_serial_bus.
362 wire_mode), "WireMode",
363 acpi_gbl_wm_decode},
364 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(spi_serial_bus.device_polarity),
365 "DevicePolarity", acpi_gbl_dp_decode},
366 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.data_bit_length),
367 "DataBitLength", NULL},
368 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_phase),
369 "ClockPhase", acpi_gbl_cph_decode},
370 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(spi_serial_bus.clock_polarity),
371 "ClockPolarity", acpi_gbl_cpo_decode},
372 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(spi_serial_bus.device_selection),
373 "DeviceSelection", NULL},
374 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(spi_serial_bus.connection_speed),
375 "ConnectionSpeed", NULL},
376};
377
378struct acpi_rsdump_info acpi_rs_dump_uart_serial_bus[19] = {
379 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_uart_serial_bus),
380 "Uart Serial Bus", NULL},
381 ACPI_RS_DUMP_COMMON_SERIAL_BUS {ACPI_RSD_2BITFLAG,
382 ACPI_RSD_OFFSET(uart_serial_bus.
383 flow_control),
384 "FlowControl", acpi_gbl_fc_decode},
385 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.stop_bits),
386 "StopBits", acpi_gbl_sb_decode},
387 {ACPI_RSD_3BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.data_bits),
388 "DataBits", acpi_gbl_bpb_decode},
389 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(uart_serial_bus.endian), "Endian",
390 acpi_gbl_ed_decode},
391 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.parity), "Parity",
392 acpi_gbl_pt_decode},
393 {ACPI_RSD_UINT8, ACPI_RSD_OFFSET(uart_serial_bus.lines_enabled),
394 "LinesEnabled", NULL},
395 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.rx_fifo_size),
396 "RxFifoSize", NULL},
397 {ACPI_RSD_UINT16, ACPI_RSD_OFFSET(uart_serial_bus.tx_fifo_size),
398 "TxFifoSize", NULL},
399 {ACPI_RSD_UINT32, ACPI_RSD_OFFSET(uart_serial_bus.default_baud_rate),
400 "ConnectionSpeed", NULL},
401};
402
403/*
404 * Tables used for common address descriptor flag fields
405 */
406struct acpi_rsdump_info acpi_rs_dump_general_flags[5] = {
407 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_general_flags), NULL,
408 NULL},
409 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.producer_consumer),
410 "Consumer/Producer", acpi_gbl_consume_decode},
411 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.decode), "Address Decode",
412 acpi_gbl_dec_decode},
413 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.min_address_fixed),
414 "Min Relocatability", acpi_gbl_min_decode},
415 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.max_address_fixed),
416 "Max Relocatability", acpi_gbl_max_decode}
417};
418
419struct acpi_rsdump_info acpi_rs_dump_memory_flags[5] = {
420 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_memory_flags),
421 "Resource Type", (void *)"Memory Range"},
422 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.write_protect),
423 "Write Protect", acpi_gbl_rw_decode},
424 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.caching),
425 "Caching", acpi_gbl_mem_decode},
426 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.mem.range_type),
427 "Range Type", acpi_gbl_mtp_decode},
428 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.mem.translation),
429 "Translation", acpi_gbl_ttp_decode}
430};
431
432struct acpi_rsdump_info acpi_rs_dump_io_flags[4] = {
433 {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_io_flags),
434 "Resource Type", (void *)"I/O Range"},
435 {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET(address.info.io.range_type),
436 "Range Type", acpi_gbl_rng_decode},
437 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation),
438 "Translation", acpi_gbl_ttp_decode},
439 {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET(address.info.io.translation_type),
440 "Translation Type", acpi_gbl_trs_decode}
441};
442
443/*
444 * Table used to dump _PRT contents
445 */
446struct acpi_rsdump_info acpi_rs_dump_prt[5] = {
447 {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE(acpi_rs_dump_prt), NULL, NULL},
448 {ACPI_RSD_UINT64, ACPI_PRT_OFFSET(address), "Address", NULL},
449 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(pin), "Pin", NULL},
450 {ACPI_RSD_STRING, ACPI_PRT_OFFSET(source[0]), "Source", NULL},
451 {ACPI_RSD_UINT32, ACPI_PRT_OFFSET(source_index), "Source Index", NULL}
452};
453
454#endif
diff --git a/drivers/acpi/acpica/rsinfo.c b/drivers/acpi/acpica/rsinfo.c
index a9fa5158200b..41fed78e0de6 100644
--- a/drivers/acpi/acpica/rsinfo.c
+++ b/drivers/acpi/acpica/rsinfo.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsio.c b/drivers/acpi/acpica/rsio.c
index f6a081057a22..ca183755a6f9 100644
--- a/drivers/acpi/acpica/rsio.c
+++ b/drivers/acpi/acpica/rsio.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsirq.c b/drivers/acpi/acpica/rsirq.c
index e23a9ec248cb..364decc1028a 100644
--- a/drivers/acpi/acpica/rsirq.c
+++ b/drivers/acpi/acpica/rsirq.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -53,7 +53,7 @@ ACPI_MODULE_NAME("rsirq")
53 * acpi_rs_get_irq 53 * acpi_rs_get_irq
54 * 54 *
55 ******************************************************************************/ 55 ******************************************************************************/
56struct acpi_rsconvert_info acpi_rs_get_irq[8] = { 56struct acpi_rsconvert_info acpi_rs_get_irq[9] = {
57 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ, 57 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
58 ACPI_RS_SIZE(struct acpi_resource_irq), 58 ACPI_RS_SIZE(struct acpi_resource_irq),
59 ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)}, 59 ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)},
@@ -80,7 +80,7 @@ struct acpi_rsconvert_info acpi_rs_get_irq[8] = {
80 80
81 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3}, 81 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
82 82
83 /* Get flags: Triggering[0], Polarity[3], Sharing[4] */ 83 /* Get flags: Triggering[0], Polarity[3], Sharing[4], Wake[5] */
84 84
85 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering), 85 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
86 AML_OFFSET(irq.flags), 86 AML_OFFSET(irq.flags),
@@ -92,7 +92,11 @@ struct acpi_rsconvert_info acpi_rs_get_irq[8] = {
92 92
93 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable), 93 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
94 AML_OFFSET(irq.flags), 94 AML_OFFSET(irq.flags),
95 4} 95 4},
96
97 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.wake_capable),
98 AML_OFFSET(irq.flags),
99 5}
96}; 100};
97 101
98/******************************************************************************* 102/*******************************************************************************
@@ -101,7 +105,7 @@ struct acpi_rsconvert_info acpi_rs_get_irq[8] = {
101 * 105 *
102 ******************************************************************************/ 106 ******************************************************************************/
103 107
104struct acpi_rsconvert_info acpi_rs_set_irq[13] = { 108struct acpi_rsconvert_info acpi_rs_set_irq[14] = {
105 /* Start with a default descriptor of length 3 */ 109 /* Start with a default descriptor of length 3 */
106 110
107 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ, 111 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
@@ -114,7 +118,7 @@ struct acpi_rsconvert_info acpi_rs_set_irq[13] = {
114 AML_OFFSET(irq.irq_mask), 118 AML_OFFSET(irq.irq_mask),
115 ACPI_RS_OFFSET(data.irq.interrupt_count)}, 119 ACPI_RS_OFFSET(data.irq.interrupt_count)},
116 120
117 /* Set the flags byte */ 121 /* Set flags: Triggering[0], Polarity[3], Sharing[4], Wake[5] */
118 122
119 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering), 123 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
120 AML_OFFSET(irq.flags), 124 AML_OFFSET(irq.flags),
@@ -128,6 +132,10 @@ struct acpi_rsconvert_info acpi_rs_set_irq[13] = {
128 AML_OFFSET(irq.flags), 132 AML_OFFSET(irq.flags),
129 4}, 133 4},
130 134
135 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.wake_capable),
136 AML_OFFSET(irq.flags),
137 5},
138
131 /* 139 /*
132 * All done if the output descriptor length is required to be 3 140 * All done if the output descriptor length is required to be 3
133 * (i.e., optimization to 2 bytes cannot be attempted) 141 * (i.e., optimization to 2 bytes cannot be attempted)
@@ -181,7 +189,7 @@ struct acpi_rsconvert_info acpi_rs_set_irq[13] = {
181 * 189 *
182 ******************************************************************************/ 190 ******************************************************************************/
183 191
184struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = { 192struct acpi_rsconvert_info acpi_rs_convert_ext_irq[10] = {
185 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ, 193 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
186 ACPI_RS_SIZE(struct acpi_resource_extended_irq), 194 ACPI_RS_SIZE(struct acpi_resource_extended_irq),
187 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)}, 195 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)},
@@ -190,8 +198,10 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = {
190 sizeof(struct aml_resource_extended_irq), 198 sizeof(struct aml_resource_extended_irq),
191 0}, 199 0},
192 200
193 /* Flag bits */ 201 /*
194 202 * Flags: Producer/Consumer[0], Triggering[1], Polarity[2],
203 * Sharing[3], Wake[4]
204 */
195 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer), 205 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer),
196 AML_OFFSET(extended_irq.flags), 206 AML_OFFSET(extended_irq.flags),
197 0}, 207 0},
@@ -208,19 +218,21 @@ struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = {
208 AML_OFFSET(extended_irq.flags), 218 AML_OFFSET(extended_irq.flags),
209 3}, 219 3},
210 220
221 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.wake_capable),
222 AML_OFFSET(extended_irq.flags),
223 4},
224
211 /* IRQ Table length (Byte4) */ 225 /* IRQ Table length (Byte4) */
212 226
213 {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count), 227 {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count),
214 AML_OFFSET(extended_irq.interrupt_count), 228 AML_OFFSET(extended_irq.interrupt_count),
215 sizeof(u32)} 229 sizeof(u32)},
216 ,
217 230
218 /* Copy every IRQ in the table, each is 32 bits */ 231 /* Copy every IRQ in the table, each is 32 bits */
219 232
220 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]), 233 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
221 AML_OFFSET(extended_irq.interrupts[0]), 234 AML_OFFSET(extended_irq.interrupts[0]),
222 0} 235 0},
223 ,
224 236
225 /* Optional resource_source (Index and String) */ 237 /* Optional resource_source (Index and String) */
226 238
@@ -285,7 +297,6 @@ struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[4] = {
285 * request_lines 297 * request_lines
286 * Channels 298 * Channels
287 */ 299 */
288
289 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_dma.request_lines), 300 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_dma.request_lines),
290 AML_OFFSET(fixed_dma.request_lines), 301 AML_OFFSET(fixed_dma.request_lines),
291 2}, 302 2},
@@ -293,5 +304,4 @@ struct acpi_rsconvert_info acpi_rs_convert_fixed_dma[4] = {
293 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_dma.width), 304 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_dma.width),
294 AML_OFFSET(fixed_dma.width), 305 AML_OFFSET(fixed_dma.width),
295 1}, 306 1},
296
297}; 307};
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c
index 8b64db9a3fd2..ee2e206fc6c8 100644
--- a/drivers/acpi/acpica/rslist.c
+++ b/drivers/acpi/acpica/rslist.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -217,9 +217,10 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
217 217
218 /* Perform final sanity check on the new AML resource descriptor */ 218 /* Perform final sanity check on the new AML resource descriptor */
219 219
220 status = 220 status = acpi_ut_validate_resource(NULL,
221 acpi_ut_validate_resource(ACPI_CAST_PTR 221 ACPI_CAST_PTR(union
222 (union aml_resource, aml), NULL); 222 aml_resource,
223 aml), NULL);
223 if (ACPI_FAILURE(status)) { 224 if (ACPI_FAILURE(status)) {
224 return_ACPI_STATUS(status); 225 return_ACPI_STATUS(status);
225 } 226 }
diff --git a/drivers/acpi/acpica/rsmemory.c b/drivers/acpi/acpica/rsmemory.c
index 4fd611ad02b4..ebc773a1b350 100644
--- a/drivers/acpi/acpica/rsmemory.c
+++ b/drivers/acpi/acpica/rsmemory.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -156,8 +156,7 @@ struct acpi_rsconvert_info acpi_rs_get_vendor_small[3] = {
156 156
157 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), 157 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
158 0, 158 0,
159 sizeof(u8)} 159 sizeof(u8)},
160 ,
161 160
162 /* Vendor data */ 161 /* Vendor data */
163 162
@@ -181,8 +180,7 @@ struct acpi_rsconvert_info acpi_rs_get_vendor_large[3] = {
181 180
182 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length), 181 {ACPI_RSC_COUNT16, ACPI_RS_OFFSET(data.vendor.byte_length),
183 0, 182 0,
184 sizeof(u8)} 183 sizeof(u8)},
185 ,
186 184
187 /* Vendor data */ 185 /* Vendor data */
188 186
diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index c6f291c2bc83..d5bf05a96096 100644
--- a/drivers/acpi/acpica/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -136,30 +136,30 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
136 /* 136 /*
137 * Mask and shift the flag bit 137 * Mask and shift the flag bit
138 */ 138 */
139 ACPI_SET8(destination) = (u8) 139 ACPI_SET8(destination,
140 ((ACPI_GET8(source) >> info->value) & 0x01); 140 ((ACPI_GET8(source) >> info->value) & 0x01));
141 break; 141 break;
142 142
143 case ACPI_RSC_2BITFLAG: 143 case ACPI_RSC_2BITFLAG:
144 /* 144 /*
145 * Mask and shift the flag bits 145 * Mask and shift the flag bits
146 */ 146 */
147 ACPI_SET8(destination) = (u8) 147 ACPI_SET8(destination,
148 ((ACPI_GET8(source) >> info->value) & 0x03); 148 ((ACPI_GET8(source) >> info->value) & 0x03));
149 break; 149 break;
150 150
151 case ACPI_RSC_3BITFLAG: 151 case ACPI_RSC_3BITFLAG:
152 /* 152 /*
153 * Mask and shift the flag bits 153 * Mask and shift the flag bits
154 */ 154 */
155 ACPI_SET8(destination) = (u8) 155 ACPI_SET8(destination,
156 ((ACPI_GET8(source) >> info->value) & 0x07); 156 ((ACPI_GET8(source) >> info->value) & 0x07));
157 break; 157 break;
158 158
159 case ACPI_RSC_COUNT: 159 case ACPI_RSC_COUNT:
160 160
161 item_count = ACPI_GET8(source); 161 item_count = ACPI_GET8(source);
162 ACPI_SET8(destination) = (u8) item_count; 162 ACPI_SET8(destination, item_count);
163 163
164 resource->length = resource->length + 164 resource->length = resource->length +
165 (info->value * (item_count - 1)); 165 (info->value * (item_count - 1));
@@ -168,7 +168,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
168 case ACPI_RSC_COUNT16: 168 case ACPI_RSC_COUNT16:
169 169
170 item_count = aml_resource_length; 170 item_count = aml_resource_length;
171 ACPI_SET16(destination) = item_count; 171 ACPI_SET16(destination, item_count);
172 172
173 resource->length = resource->length + 173 resource->length = resource->length +
174 (info->value * (item_count - 1)); 174 (info->value * (item_count - 1));
@@ -181,13 +181,13 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
181 181
182 resource->length = resource->length + item_count; 182 resource->length = resource->length + item_count;
183 item_count = item_count / 2; 183 item_count = item_count / 2;
184 ACPI_SET16(destination) = item_count; 184 ACPI_SET16(destination, item_count);
185 break; 185 break;
186 186
187 case ACPI_RSC_COUNT_GPIO_VEN: 187 case ACPI_RSC_COUNT_GPIO_VEN:
188 188
189 item_count = ACPI_GET8(source); 189 item_count = ACPI_GET8(source);
190 ACPI_SET8(destination) = (u8)item_count; 190 ACPI_SET8(destination, item_count);
191 191
192 resource->length = resource->length + 192 resource->length = resource->length +
193 (info->value * item_count); 193 (info->value * item_count);
@@ -216,7 +216,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
216 } 216 }
217 217
218 resource->length = resource->length + item_count; 218 resource->length = resource->length + item_count;
219 ACPI_SET16(destination) = item_count; 219 ACPI_SET16(destination, item_count);
220 break; 220 break;
221 221
222 case ACPI_RSC_COUNT_SERIAL_VEN: 222 case ACPI_RSC_COUNT_SERIAL_VEN:
@@ -224,7 +224,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
224 item_count = ACPI_GET16(source) - info->value; 224 item_count = ACPI_GET16(source) - info->value;
225 225
226 resource->length = resource->length + item_count; 226 resource->length = resource->length + item_count;
227 ACPI_SET16(destination) = item_count; 227 ACPI_SET16(destination, item_count);
228 break; 228 break;
229 229
230 case ACPI_RSC_COUNT_SERIAL_RES: 230 case ACPI_RSC_COUNT_SERIAL_RES:
@@ -234,7 +234,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
234 - ACPI_GET16(source) - info->value; 234 - ACPI_GET16(source) - info->value;
235 235
236 resource->length = resource->length + item_count; 236 resource->length = resource->length + item_count;
237 ACPI_SET16(destination) = item_count; 237 ACPI_SET16(destination, item_count);
238 break; 238 break;
239 239
240 case ACPI_RSC_LENGTH: 240 case ACPI_RSC_LENGTH:
@@ -385,7 +385,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
385 } 385 }
386 386
387 target = ACPI_ADD_PTR(char, resource, info->value); 387 target = ACPI_ADD_PTR(char, resource, info->value);
388 ACPI_SET8(target) = (u8) item_count; 388 ACPI_SET8(target, item_count);
389 break; 389 break;
390 390
391 case ACPI_RSC_BITMASK16: 391 case ACPI_RSC_BITMASK16:
@@ -401,7 +401,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
401 } 401 }
402 402
403 target = ACPI_ADD_PTR(char, resource, info->value); 403 target = ACPI_ADD_PTR(char, resource, info->value);
404 ACPI_SET8(target) = (u8) item_count; 404 ACPI_SET8(target, item_count);
405 break; 405 break;
406 406
407 case ACPI_RSC_EXIT_NE: 407 case ACPI_RSC_EXIT_NE:
@@ -514,37 +514,40 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
514 /* 514 /*
515 * Clear the flag byte 515 * Clear the flag byte
516 */ 516 */
517 ACPI_SET8(destination) = 0; 517 ACPI_SET8(destination, 0);
518 break; 518 break;
519 519
520 case ACPI_RSC_1BITFLAG: 520 case ACPI_RSC_1BITFLAG:
521 /* 521 /*
522 * Mask and shift the flag bit 522 * Mask and shift the flag bit
523 */ 523 */
524 ACPI_SET8(destination) |= (u8) 524 ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
525 ((ACPI_GET8(source) & 0x01) << info->value); 525 ((ACPI_GET8(source) & 0x01) << info->
526 value));
526 break; 527 break;
527 528
528 case ACPI_RSC_2BITFLAG: 529 case ACPI_RSC_2BITFLAG:
529 /* 530 /*
530 * Mask and shift the flag bits 531 * Mask and shift the flag bits
531 */ 532 */
532 ACPI_SET8(destination) |= (u8) 533 ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
533 ((ACPI_GET8(source) & 0x03) << info->value); 534 ((ACPI_GET8(source) & 0x03) << info->
535 value));
534 break; 536 break;
535 537
536 case ACPI_RSC_3BITFLAG: 538 case ACPI_RSC_3BITFLAG:
537 /* 539 /*
538 * Mask and shift the flag bits 540 * Mask and shift the flag bits
539 */ 541 */
540 ACPI_SET8(destination) |= (u8) 542 ACPI_SET_BIT(*ACPI_CAST8(destination), (u8)
541 ((ACPI_GET8(source) & 0x07) << info->value); 543 ((ACPI_GET8(source) & 0x07) << info->
544 value));
542 break; 545 break;
543 546
544 case ACPI_RSC_COUNT: 547 case ACPI_RSC_COUNT:
545 548
546 item_count = ACPI_GET8(source); 549 item_count = ACPI_GET8(source);
547 ACPI_SET8(destination) = (u8) item_count; 550 ACPI_SET8(destination, item_count);
548 551
549 aml_length = 552 aml_length =
550 (u16) (aml_length + 553 (u16) (aml_length +
@@ -561,18 +564,18 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
561 case ACPI_RSC_COUNT_GPIO_PIN: 564 case ACPI_RSC_COUNT_GPIO_PIN:
562 565
563 item_count = ACPI_GET16(source); 566 item_count = ACPI_GET16(source);
564 ACPI_SET16(destination) = (u16)aml_length; 567 ACPI_SET16(destination, aml_length);
565 568
566 aml_length = (u16)(aml_length + item_count * 2); 569 aml_length = (u16)(aml_length + item_count * 2);
567 target = ACPI_ADD_PTR(void, aml, info->value); 570 target = ACPI_ADD_PTR(void, aml, info->value);
568 ACPI_SET16(target) = (u16)aml_length; 571 ACPI_SET16(target, aml_length);
569 acpi_rs_set_resource_length(aml_length, aml); 572 acpi_rs_set_resource_length(aml_length, aml);
570 break; 573 break;
571 574
572 case ACPI_RSC_COUNT_GPIO_VEN: 575 case ACPI_RSC_COUNT_GPIO_VEN:
573 576
574 item_count = ACPI_GET16(source); 577 item_count = ACPI_GET16(source);
575 ACPI_SET16(destination) = (u16)item_count; 578 ACPI_SET16(destination, item_count);
576 579
577 aml_length = 580 aml_length =
578 (u16)(aml_length + (info->value * item_count)); 581 (u16)(aml_length + (info->value * item_count));
@@ -584,7 +587,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
584 /* Set resource source string length */ 587 /* Set resource source string length */
585 588
586 item_count = ACPI_GET16(source); 589 item_count = ACPI_GET16(source);
587 ACPI_SET16(destination) = (u16)aml_length; 590 ACPI_SET16(destination, aml_length);
588 591
589 /* Compute offset for the Vendor Data */ 592 /* Compute offset for the Vendor Data */
590 593
@@ -594,7 +597,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
594 /* Set vendor offset only if there is vendor data */ 597 /* Set vendor offset only if there is vendor data */
595 598
596 if (resource->data.gpio.vendor_length) { 599 if (resource->data.gpio.vendor_length) {
597 ACPI_SET16(target) = (u16)aml_length; 600 ACPI_SET16(target, aml_length);
598 } 601 }
599 602
600 acpi_rs_set_resource_length(aml_length, aml); 603 acpi_rs_set_resource_length(aml_length, aml);
@@ -603,7 +606,7 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
603 case ACPI_RSC_COUNT_SERIAL_VEN: 606 case ACPI_RSC_COUNT_SERIAL_VEN:
604 607
605 item_count = ACPI_GET16(source); 608 item_count = ACPI_GET16(source);
606 ACPI_SET16(destination) = item_count + info->value; 609 ACPI_SET16(destination, item_count + info->value);
607 aml_length = (u16)(aml_length + item_count); 610 aml_length = (u16)(aml_length + item_count);
608 acpi_rs_set_resource_length(aml_length, aml); 611 acpi_rs_set_resource_length(aml_length, aml);
609 break; 612 break;
@@ -686,7 +689,8 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
686 * Optional resource_source (Index and String) 689 * Optional resource_source (Index and String)
687 */ 690 */
688 aml_length = 691 aml_length =
689 acpi_rs_set_resource_source(aml, (acpi_rs_length) 692 acpi_rs_set_resource_source(aml,
693 (acpi_rs_length)
690 aml_length, source); 694 aml_length, source);
691 acpi_rs_set_resource_length(aml_length, aml); 695 acpi_rs_set_resource_length(aml_length, aml);
692 break; 696 break;
@@ -706,10 +710,12 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
706 /* 710 /*
707 * 8-bit encoded bitmask (DMA macro) 711 * 8-bit encoded bitmask (DMA macro)
708 */ 712 */
709 ACPI_SET8(destination) = (u8) 713 ACPI_SET8(destination,
710 acpi_rs_encode_bitmask(source, 714 acpi_rs_encode_bitmask(source,
711 *ACPI_ADD_PTR(u8, resource, 715 *ACPI_ADD_PTR(u8,
712 info->value)); 716 resource,
717 info->
718 value)));
713 break; 719 break;
714 720
715 case ACPI_RSC_BITMASK16: 721 case ACPI_RSC_BITMASK16:
diff --git a/drivers/acpi/acpica/rsserial.c b/drivers/acpi/acpica/rsserial.c
index 9aa5e689b444..fe49fc43e10f 100644
--- a/drivers/acpi/acpica/rsserial.c
+++ b/drivers/acpi/acpica/rsserial.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -53,7 +53,7 @@ ACPI_MODULE_NAME("rsserial")
53 * acpi_rs_convert_gpio 53 * acpi_rs_convert_gpio
54 * 54 *
55 ******************************************************************************/ 55 ******************************************************************************/
56struct acpi_rsconvert_info acpi_rs_convert_gpio[17] = { 56struct acpi_rsconvert_info acpi_rs_convert_gpio[18] = {
57 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO, 57 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO,
58 ACPI_RS_SIZE(struct acpi_resource_gpio), 58 ACPI_RS_SIZE(struct acpi_resource_gpio),
59 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_gpio)}, 59 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_gpio)},
@@ -75,10 +75,14 @@ struct acpi_rsconvert_info acpi_rs_convert_gpio[17] = {
75 AML_OFFSET(gpio.flags), 75 AML_OFFSET(gpio.flags),
76 0}, 76 0},
77 77
78 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.sharable), 78 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.sharable),
79 AML_OFFSET(gpio.int_flags), 79 AML_OFFSET(gpio.int_flags),
80 3}, 80 3},
81 81
82 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.gpio.wake_capable),
83 AML_OFFSET(gpio.int_flags),
84 4},
85
82 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.io_restriction), 86 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.gpio.io_restriction),
83 AML_OFFSET(gpio.int_flags), 87 AML_OFFSET(gpio.int_flags),
84 0}, 88 0},
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c
index 37d5241c0acf..a44953c6f75d 100644
--- a/drivers/acpi/acpica/rsutils.c
+++ b/drivers/acpi/acpica/rsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -108,7 +108,7 @@ u16 acpi_rs_encode_bitmask(u8 * list, u8 count)
108 mask |= (0x1 << list[i]); 108 mask |= (0x1 << list[i]);
109 } 109 }
110 110
111 return mask; 111 return (mask);
112} 112}
113 113
114/******************************************************************************* 114/*******************************************************************************
@@ -358,8 +358,10 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length,
358 * 358 *
359 * Zero the entire area of the buffer. 359 * Zero the entire area of the buffer.
360 */ 360 */
361 total_length = (u32) 361 total_length =
362 ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) + 1; 362 (u32)
363 ACPI_STRLEN(ACPI_CAST_PTR(char, &aml_resource_source[1])) +
364 1;
363 total_length = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(total_length); 365 total_length = (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(total_length);
364 366
365 ACPI_MEMSET(resource_source->string_ptr, 0, total_length); 367 ACPI_MEMSET(resource_source->string_ptr, 0, total_length);
@@ -675,7 +677,9 @@ acpi_rs_get_method_data(acpi_handle handle,
675 /* Execute the method, no parameters */ 677 /* Execute the method, no parameters */
676 678
677 status = 679 status =
678 acpi_ut_evaluate_object(handle, path, ACPI_BTYPE_BUFFER, &obj_desc); 680 acpi_ut_evaluate_object(ACPI_CAST_PTR
681 (struct acpi_namespace_node, handle), path,
682 ACPI_BTYPE_BUFFER, &obj_desc);
679 if (ACPI_FAILURE(status)) { 683 if (ACPI_FAILURE(status)) {
680 return_ACPI_STATUS(status); 684 return_ACPI_STATUS(status);
681 } 685 }
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index 5aad744b5b83..15d6eaef0e28 100644
--- a/drivers/acpi/acpica/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -423,7 +423,7 @@ ACPI_EXPORT_SYMBOL(acpi_resource_to_address64)
423 * 423 *
424 * RETURN: Status 424 * RETURN: Status
425 * 425 *
426 * DESCRIPTION: Walk a resource template for the specified evice to find a 426 * DESCRIPTION: Walk a resource template for the specified device to find a
427 * vendor-defined resource that matches the supplied UUID and 427 * vendor-defined resource that matches the supplied UUID and
428 * UUID subtype. Returns a struct acpi_resource of type Vendor. 428 * UUID subtype. Returns a struct acpi_resource of type Vendor.
429 * 429 *
@@ -522,57 +522,42 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
522 522
523/******************************************************************************* 523/*******************************************************************************
524 * 524 *
525 * FUNCTION: acpi_walk_resources 525 * FUNCTION: acpi_walk_resource_buffer
526 * 526 *
527 * PARAMETERS: device_handle - Handle to the device object for the 527 * PARAMETERS: buffer - Formatted buffer returned by one of the
528 * device we are querying 528 * various Get*Resource functions
529 * name - Method name of the resources we want.
530 * (METHOD_NAME__CRS, METHOD_NAME__PRS, or
531 * METHOD_NAME__AEI)
532 * user_function - Called for each resource 529 * user_function - Called for each resource
533 * context - Passed to user_function 530 * context - Passed to user_function
534 * 531 *
535 * RETURN: Status 532 * RETURN: Status
536 * 533 *
537 * DESCRIPTION: Retrieves the current or possible resource list for the 534 * DESCRIPTION: Walks the input resource template. The user_function is called
538 * specified device. The user_function is called once for 535 * once for each resource in the list.
539 * each resource in the list.
540 * 536 *
541 ******************************************************************************/ 537 ******************************************************************************/
538
542acpi_status 539acpi_status
543acpi_walk_resources(acpi_handle device_handle, 540acpi_walk_resource_buffer(struct acpi_buffer * buffer,
544 char *name, 541 acpi_walk_resource_callback user_function,
545 acpi_walk_resource_callback user_function, void *context) 542 void *context)
546{ 543{
547 acpi_status status; 544 acpi_status status = AE_OK;
548 struct acpi_buffer buffer;
549 struct acpi_resource *resource; 545 struct acpi_resource *resource;
550 struct acpi_resource *resource_end; 546 struct acpi_resource *resource_end;
551 547
552 ACPI_FUNCTION_TRACE(acpi_walk_resources); 548 ACPI_FUNCTION_TRACE(acpi_walk_resource_buffer);
553 549
554 /* Parameter validation */ 550 /* Parameter validation */
555 551
556 if (!device_handle || !user_function || !name || 552 if (!buffer || !buffer->pointer || !user_function) {
557 (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
558 !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) &&
559 !ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) {
560 return_ACPI_STATUS(AE_BAD_PARAMETER); 553 return_ACPI_STATUS(AE_BAD_PARAMETER);
561 } 554 }
562 555
563 /* Get the _CRS/_PRS/_AEI resource list */ 556 /* Buffer contains the resource list and length */
564
565 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
566 status = acpi_rs_get_method_data(device_handle, name, &buffer);
567 if (ACPI_FAILURE(status)) {
568 return_ACPI_STATUS(status);
569 }
570
571 /* Buffer now contains the resource list */
572 557
573 resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer); 558 resource = ACPI_CAST_PTR(struct acpi_resource, buffer->pointer);
574 resource_end = 559 resource_end =
575 ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length); 560 ACPI_ADD_PTR(struct acpi_resource, buffer->pointer, buffer->length);
576 561
577 /* Walk the resource list until the end_tag is found (or buffer end) */ 562 /* Walk the resource list until the end_tag is found (or buffer end) */
578 563
@@ -606,11 +591,63 @@ acpi_walk_resources(acpi_handle device_handle,
606 591
607 /* Get the next resource descriptor */ 592 /* Get the next resource descriptor */
608 593
609 resource = 594 resource = ACPI_NEXT_RESOURCE(resource);
610 ACPI_ADD_PTR(struct acpi_resource, resource,
611 resource->length);
612 } 595 }
613 596
597 return_ACPI_STATUS(status);
598}
599
600ACPI_EXPORT_SYMBOL(acpi_walk_resource_buffer)
601
602/*******************************************************************************
603 *
604 * FUNCTION: acpi_walk_resources
605 *
606 * PARAMETERS: device_handle - Handle to the device object for the
607 * device we are querying
608 * name - Method name of the resources we want.
609 * (METHOD_NAME__CRS, METHOD_NAME__PRS, or
610 * METHOD_NAME__AEI)
611 * user_function - Called for each resource
612 * context - Passed to user_function
613 *
614 * RETURN: Status
615 *
616 * DESCRIPTION: Retrieves the current or possible resource list for the
617 * specified device. The user_function is called once for
618 * each resource in the list.
619 *
620 ******************************************************************************/
621acpi_status
622acpi_walk_resources(acpi_handle device_handle,
623 char *name,
624 acpi_walk_resource_callback user_function, void *context)
625{
626 acpi_status status;
627 struct acpi_buffer buffer;
628
629 ACPI_FUNCTION_TRACE(acpi_walk_resources);
630
631 /* Parameter validation */
632
633 if (!device_handle || !user_function || !name ||
634 (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
635 !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS) &&
636 !ACPI_COMPARE_NAME(name, METHOD_NAME__AEI))) {
637 return_ACPI_STATUS(AE_BAD_PARAMETER);
638 }
639
640 /* Get the _CRS/_PRS/_AEI resource list */
641
642 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
643 status = acpi_rs_get_method_data(device_handle, name, &buffer);
644 if (ACPI_FAILURE(status)) {
645 return_ACPI_STATUS(status);
646 }
647
648 /* Walk the resource list and cleanup */
649
650 status = acpi_walk_resource_buffer(&buffer, user_function, context);
614 ACPI_FREE(buffer.pointer); 651 ACPI_FREE(buffer.pointer);
615 return_ACPI_STATUS(status); 652 return_ACPI_STATUS(status);
616} 653}
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 390651860bf0..74181bf181ec 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -172,6 +172,7 @@ static struct acpi_fadt_pm_info fadt_pm_info_table[] = {
172 * FUNCTION: acpi_tb_init_generic_address 172 * FUNCTION: acpi_tb_init_generic_address
173 * 173 *
174 * PARAMETERS: generic_address - GAS struct to be initialized 174 * PARAMETERS: generic_address - GAS struct to be initialized
175 * space_id - ACPI Space ID for this register
175 * byte_width - Width of this register 176 * byte_width - Width of this register
176 * address - Address of the register 177 * address - Address of the register
177 * 178 *
@@ -407,8 +408,8 @@ static void acpi_tb_convert_fadt(void)
407 * should be zero are indeed zero. This will workaround BIOSs that 408 * should be zero are indeed zero. This will workaround BIOSs that
408 * inadvertently place values in these fields. 409 * inadvertently place values in these fields.
409 * 410 *
410 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at 411 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
411 * offset 45, 55, 95, and the word located at offset 109, 110. 412 * at offset 45, 55, 95, and the word located at offset 109, 110.
412 * 413 *
413 * Note: The FADT revision value is unreliable. Only the length can be 414 * Note: The FADT revision value is unreliable. Only the length can be
414 * trusted. 415 * trusted.
diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 77d1db29a725..e4f4f02d49e7 100644
--- a/drivers/acpi/acpica/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index f540ae462925..e57cd38004e3 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 285e24b97382..ce3d5db39a9c 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -147,7 +147,7 @@ acpi_status acpi_tb_initialize_facs(void)
147 ACPI_CAST_INDIRECT_PTR(struct 147 ACPI_CAST_INDIRECT_PTR(struct
148 acpi_table_header, 148 acpi_table_header,
149 &acpi_gbl_FACS)); 149 &acpi_gbl_FACS));
150 return status; 150 return (status);
151} 151}
152#endif /* !ACPI_REDUCED_HARDWARE */ 152#endif /* !ACPI_REDUCED_HARDWARE */
153 153
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index f5632780421d..b35a5e6d653a 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,6 @@
44#include <linux/export.h> 44#include <linux/export.h>
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "acnamesp.h"
48#include "actables.h" 47#include "actables.h"
49 48
50#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
@@ -437,7 +436,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
437 * 436 *
438 ******************************************************************************/ 437 ******************************************************************************/
439acpi_status 438acpi_status
440acpi_install_table_handler(acpi_tbl_handler handler, void *context) 439acpi_install_table_handler(acpi_table_handler handler, void *context)
441{ 440{
442 acpi_status status; 441 acpi_status status;
443 442
@@ -483,7 +482,7 @@ ACPI_EXPORT_SYMBOL(acpi_install_table_handler)
483 * DESCRIPTION: Remove table event handler 482 * DESCRIPTION: Remove table event handler
484 * 483 *
485 ******************************************************************************/ 484 ******************************************************************************/
486acpi_status acpi_remove_table_handler(acpi_tbl_handler handler) 485acpi_status acpi_remove_table_handler(acpi_table_handler handler)
487{ 486{
488 acpi_status status; 487 acpi_status status;
489 488
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
index a5e1e4e47098..67e046ec8f0a 100644
--- a/drivers/acpi/acpica/tbxfload.c
+++ b/drivers/acpi/acpica/tbxfload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -192,7 +192,7 @@ static acpi_status acpi_tb_load_namespace(void)
192 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); 192 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
193 } 193 }
194 194
195 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); 195 ACPI_INFO((AE_INFO, "All ACPI Tables successfully acquired"));
196 196
197 unlock_and_exit: 197 unlock_and_exit:
198 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); 198 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index 28f330230f99..7c2ecfb7c2c3 100644
--- a/drivers/acpi/acpica/tbxfroot.c
+++ b/drivers/acpi/acpica/tbxfroot.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utaddress.c b/drivers/acpi/acpica/utaddress.c
index 64880306133d..698b9d385516 100644
--- a/drivers/acpi/acpica/utaddress.c
+++ b/drivers/acpi/acpica/utaddress.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -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_UINT32(0); 217 return_VALUE(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_UINT32(overlap_count); 259 return_VALUE(overlap_count);
260} 260}
261 261
262/******************************************************************************* 262/*******************************************************************************
diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c
index ed29d474095e..e0ffb580f4b0 100644
--- a/drivers/acpi/acpica/utalloc.c
+++ b/drivers/acpi/acpica/utalloc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utcache.c b/drivers/acpi/acpica/utcache.c
index e1d40ed26390..e0e8579deaac 100644
--- a/drivers/acpi/acpica/utcache.c
+++ b/drivers/acpi/acpica/utcache.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index 294692ae76e9..e4c9291fc0a3 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -785,7 +785,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
785 785
786 status = acpi_os_create_mutex(&dest_desc->mutex.os_mutex); 786 status = acpi_os_create_mutex(&dest_desc->mutex.os_mutex);
787 if (ACPI_FAILURE(status)) { 787 if (ACPI_FAILURE(status)) {
788 return status; 788 return (status);
789 } 789 }
790 break; 790 break;
791 791
@@ -795,7 +795,7 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
795 &dest_desc->event. 795 &dest_desc->event.
796 os_semaphore); 796 os_semaphore);
797 if (ACPI_FAILURE(status)) { 797 if (ACPI_FAILURE(status)) {
798 return status; 798 return (status);
799 } 799 }
800 break; 800 break;
801 801
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index 5d95166245ae..c57d9cc07ba9 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -166,11 +166,9 @@ acpi_debug_print(u32 requested_debug_level,
166 acpi_thread_id thread_id; 166 acpi_thread_id thread_id;
167 va_list args; 167 va_list args;
168 168
169 /* 169 /* Check if debug output enabled */
170 * Stay silent if the debug level or component ID is disabled 170
171 */ 171 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
172 if (!(requested_debug_level & acpi_dbg_level) ||
173 !(component_id & acpi_dbg_layer)) {
174 return; 172 return;
175 } 173 }
176 174
@@ -236,8 +234,9 @@ acpi_debug_print_raw(u32 requested_debug_level,
236{ 234{
237 va_list args; 235 va_list args;
238 236
239 if (!(requested_debug_level & acpi_dbg_level) || 237 /* Check if debug output enabled */
240 !(component_id & acpi_dbg_layer)) { 238
239 if (!ACPI_IS_DEBUG_ENABLED(requested_debug_level, component_id)) {
241 return; 240 return;
242 } 241 }
243 242
@@ -272,9 +271,13 @@ acpi_ut_trace(u32 line_number,
272 acpi_gbl_nesting_level++; 271 acpi_gbl_nesting_level++;
273 acpi_ut_track_stack_ptr(); 272 acpi_ut_track_stack_ptr();
274 273
275 acpi_debug_print(ACPI_LV_FUNCTIONS, 274 /* Check if enabled up-front for performance */
276 line_number, function_name, module_name, component_id, 275
277 "%s\n", acpi_gbl_fn_entry_str); 276 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
277 acpi_debug_print(ACPI_LV_FUNCTIONS,
278 line_number, function_name, module_name,
279 component_id, "%s\n", acpi_gbl_fn_entry_str);
280 }
278} 281}
279 282
280ACPI_EXPORT_SYMBOL(acpi_ut_trace) 283ACPI_EXPORT_SYMBOL(acpi_ut_trace)
@@ -304,9 +307,14 @@ acpi_ut_trace_ptr(u32 line_number,
304 acpi_gbl_nesting_level++; 307 acpi_gbl_nesting_level++;
305 acpi_ut_track_stack_ptr(); 308 acpi_ut_track_stack_ptr();
306 309
307 acpi_debug_print(ACPI_LV_FUNCTIONS, 310 /* Check if enabled up-front for performance */
308 line_number, function_name, module_name, component_id, 311
309 "%s %p\n", acpi_gbl_fn_entry_str, pointer); 312 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
313 acpi_debug_print(ACPI_LV_FUNCTIONS,
314 line_number, function_name, module_name,
315 component_id, "%s %p\n", acpi_gbl_fn_entry_str,
316 pointer);
317 }
310} 318}
311 319
312/******************************************************************************* 320/*******************************************************************************
@@ -335,9 +343,14 @@ acpi_ut_trace_str(u32 line_number,
335 acpi_gbl_nesting_level++; 343 acpi_gbl_nesting_level++;
336 acpi_ut_track_stack_ptr(); 344 acpi_ut_track_stack_ptr();
337 345
338 acpi_debug_print(ACPI_LV_FUNCTIONS, 346 /* Check if enabled up-front for performance */
339 line_number, function_name, module_name, component_id, 347
340 "%s %s\n", acpi_gbl_fn_entry_str, string); 348 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
349 acpi_debug_print(ACPI_LV_FUNCTIONS,
350 line_number, function_name, module_name,
351 component_id, "%s %s\n", acpi_gbl_fn_entry_str,
352 string);
353 }
341} 354}
342 355
343/******************************************************************************* 356/*******************************************************************************
@@ -366,9 +379,14 @@ acpi_ut_trace_u32(u32 line_number,
366 acpi_gbl_nesting_level++; 379 acpi_gbl_nesting_level++;
367 acpi_ut_track_stack_ptr(); 380 acpi_ut_track_stack_ptr();
368 381
369 acpi_debug_print(ACPI_LV_FUNCTIONS, 382 /* Check if enabled up-front for performance */
370 line_number, function_name, module_name, component_id, 383
371 "%s %08X\n", acpi_gbl_fn_entry_str, integer); 384 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
385 acpi_debug_print(ACPI_LV_FUNCTIONS,
386 line_number, function_name, module_name,
387 component_id, "%s %08X\n",
388 acpi_gbl_fn_entry_str, integer);
389 }
372} 390}
373 391
374/******************************************************************************* 392/*******************************************************************************
@@ -393,9 +411,13 @@ acpi_ut_exit(u32 line_number,
393 const char *module_name, u32 component_id) 411 const char *module_name, u32 component_id)
394{ 412{
395 413
396 acpi_debug_print(ACPI_LV_FUNCTIONS, 414 /* Check if enabled up-front for performance */
397 line_number, function_name, module_name, component_id, 415
398 "%s\n", acpi_gbl_fn_exit_str); 416 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
417 acpi_debug_print(ACPI_LV_FUNCTIONS,
418 line_number, function_name, module_name,
419 component_id, "%s\n", acpi_gbl_fn_exit_str);
420 }
399 421
400 acpi_gbl_nesting_level--; 422 acpi_gbl_nesting_level--;
401} 423}
@@ -425,17 +447,23 @@ acpi_ut_status_exit(u32 line_number,
425 u32 component_id, acpi_status status) 447 u32 component_id, acpi_status status)
426{ 448{
427 449
428 if (ACPI_SUCCESS(status)) { 450 /* Check if enabled up-front for performance */
429 acpi_debug_print(ACPI_LV_FUNCTIONS, 451
430 line_number, function_name, module_name, 452 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
431 component_id, "%s %s\n", acpi_gbl_fn_exit_str, 453 if (ACPI_SUCCESS(status)) {
432 acpi_format_exception(status)); 454 acpi_debug_print(ACPI_LV_FUNCTIONS,
433 } else { 455 line_number, function_name,
434 acpi_debug_print(ACPI_LV_FUNCTIONS, 456 module_name, component_id, "%s %s\n",
435 line_number, function_name, module_name, 457 acpi_gbl_fn_exit_str,
436 component_id, "%s ****Exception****: %s\n", 458 acpi_format_exception(status));
437 acpi_gbl_fn_exit_str, 459 } else {
438 acpi_format_exception(status)); 460 acpi_debug_print(ACPI_LV_FUNCTIONS,
461 line_number, function_name,
462 module_name, component_id,
463 "%s ****Exception****: %s\n",
464 acpi_gbl_fn_exit_str,
465 acpi_format_exception(status));
466 }
439 } 467 }
440 468
441 acpi_gbl_nesting_level--; 469 acpi_gbl_nesting_level--;
@@ -465,10 +493,15 @@ acpi_ut_value_exit(u32 line_number,
465 const char *module_name, u32 component_id, u64 value) 493 const char *module_name, u32 component_id, u64 value)
466{ 494{
467 495
468 acpi_debug_print(ACPI_LV_FUNCTIONS, 496 /* Check if enabled up-front for performance */
469 line_number, function_name, module_name, component_id, 497
470 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str, 498 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
471 ACPI_FORMAT_UINT64(value)); 499 acpi_debug_print(ACPI_LV_FUNCTIONS,
500 line_number, function_name, module_name,
501 component_id, "%s %8.8X%8.8X\n",
502 acpi_gbl_fn_exit_str,
503 ACPI_FORMAT_UINT64(value));
504 }
472 505
473 acpi_gbl_nesting_level--; 506 acpi_gbl_nesting_level--;
474} 507}
@@ -497,9 +530,14 @@ acpi_ut_ptr_exit(u32 line_number,
497 const char *module_name, u32 component_id, u8 *ptr) 530 const char *module_name, u32 component_id, u8 *ptr)
498{ 531{
499 532
500 acpi_debug_print(ACPI_LV_FUNCTIONS, 533 /* Check if enabled up-front for performance */
501 line_number, function_name, module_name, component_id, 534
502 "%s %p\n", acpi_gbl_fn_exit_str, ptr); 535 if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_FUNCTIONS, component_id)) {
536 acpi_debug_print(ACPI_LV_FUNCTIONS,
537 line_number, function_name, module_name,
538 component_id, "%s %p\n", acpi_gbl_fn_exit_str,
539 ptr);
540 }
503 541
504 acpi_gbl_nesting_level--; 542 acpi_gbl_nesting_level--;
505} 543}
diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c
index 60a158472d82..11e2e02e1618 100644
--- a/drivers/acpi/acpica/utdecode.c
+++ b/drivers/acpi/acpica/utdecode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
index 798105443d0f..2541de420249 100644
--- a/drivers/acpi/acpica/utdelete.c
+++ b/drivers/acpi/acpica/utdelete.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -340,7 +340,7 @@ void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
340{ 340{
341 union acpi_operand_object **internal_obj; 341 union acpi_operand_object **internal_obj;
342 342
343 ACPI_FUNCTION_TRACE(ut_delete_internal_object_list); 343 ACPI_FUNCTION_ENTRY();
344 344
345 /* Walk the null-terminated internal list */ 345 /* Walk the null-terminated internal list */
346 346
@@ -351,7 +351,7 @@ void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list)
351 /* Free the combined parameter pointer list and object array */ 351 /* Free the combined parameter pointer list and object array */
352 352
353 ACPI_FREE(obj_list); 353 ACPI_FREE(obj_list);
354 return_VOID; 354 return;
355} 355}
356 356
357/******************************************************************************* 357/*******************************************************************************
@@ -484,7 +484,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
484 union acpi_generic_state *state; 484 union acpi_generic_state *state;
485 u32 i; 485 u32 i;
486 486
487 ACPI_FUNCTION_TRACE_PTR(ut_update_object_reference, object); 487 ACPI_FUNCTION_NAME(ut_update_object_reference);
488 488
489 while (object) { 489 while (object) {
490 490
@@ -493,7 +493,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
493 if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) { 493 if (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED) {
494 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 494 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
495 "Object %p is NS handle\n", object)); 495 "Object %p is NS handle\n", object));
496 return_ACPI_STATUS(AE_OK); 496 return (AE_OK);
497 } 497 }
498 498
499 /* 499 /*
@@ -530,18 +530,42 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
530 */ 530 */
531 for (i = 0; i < object->package.count; i++) { 531 for (i = 0; i < object->package.count; i++) {
532 /* 532 /*
533 * Push each element onto the stack for later processing. 533 * Null package elements are legal and can be simply
534 * Note: There can be null elements within the package, 534 * ignored.
535 * these are simply ignored
536 */ 535 */
537 status = 536 next_object = object->package.elements[i];
538 acpi_ut_create_update_state_and_push 537 if (!next_object) {
539 (object->package.elements[i], action, 538 continue;
540 &state_list); 539 }
541 if (ACPI_FAILURE(status)) { 540
542 goto error_exit; 541 switch (next_object->common.type) {
542 case ACPI_TYPE_INTEGER:
543 case ACPI_TYPE_STRING:
544 case ACPI_TYPE_BUFFER:
545 /*
546 * For these very simple sub-objects, we can just
547 * update the reference count here and continue.
548 * Greatly increases performance of this operation.
549 */
550 acpi_ut_update_ref_count(next_object,
551 action);
552 break;
553
554 default:
555 /*
556 * For complex sub-objects, push them onto the stack
557 * for later processing (this eliminates recursion.)
558 */
559 status =
560 acpi_ut_create_update_state_and_push
561 (next_object, action, &state_list);
562 if (ACPI_FAILURE(status)) {
563 goto error_exit;
564 }
565 break;
543 } 566 }
544 } 567 }
568 next_object = NULL;
545 break; 569 break;
546 570
547 case ACPI_TYPE_BUFFER_FIELD: 571 case ACPI_TYPE_BUFFER_FIELD:
@@ -619,7 +643,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
619 } 643 }
620 } 644 }
621 645
622 return_ACPI_STATUS(AE_OK); 646 return (AE_OK);
623 647
624 error_exit: 648 error_exit:
625 649
@@ -633,7 +657,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
633 acpi_ut_delete_generic_state(state); 657 acpi_ut_delete_generic_state(state);
634 } 658 }
635 659
636 return_ACPI_STATUS(status); 660 return (status);
637} 661}
638 662
639/******************************************************************************* 663/*******************************************************************************
@@ -652,12 +676,12 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
652void acpi_ut_add_reference(union acpi_operand_object *object) 676void acpi_ut_add_reference(union acpi_operand_object *object)
653{ 677{
654 678
655 ACPI_FUNCTION_TRACE_PTR(ut_add_reference, object); 679 ACPI_FUNCTION_NAME(ut_add_reference);
656 680
657 /* Ensure that we have a valid object */ 681 /* Ensure that we have a valid object */
658 682
659 if (!acpi_ut_valid_internal_object(object)) { 683 if (!acpi_ut_valid_internal_object(object)) {
660 return_VOID; 684 return;
661 } 685 }
662 686
663 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 687 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
@@ -667,7 +691,7 @@ void acpi_ut_add_reference(union acpi_operand_object *object)
667 /* Increment the reference count */ 691 /* Increment the reference count */
668 692
669 (void)acpi_ut_update_object_reference(object, REF_INCREMENT); 693 (void)acpi_ut_update_object_reference(object, REF_INCREMENT);
670 return_VOID; 694 return;
671} 695}
672 696
673/******************************************************************************* 697/*******************************************************************************
@@ -685,7 +709,7 @@ void acpi_ut_add_reference(union acpi_operand_object *object)
685void acpi_ut_remove_reference(union acpi_operand_object *object) 709void acpi_ut_remove_reference(union acpi_operand_object *object)
686{ 710{
687 711
688 ACPI_FUNCTION_TRACE_PTR(ut_remove_reference, object); 712 ACPI_FUNCTION_NAME(ut_remove_reference);
689 713
690 /* 714 /*
691 * Allow a NULL pointer to be passed in, just ignore it. This saves 715 * Allow a NULL pointer to be passed in, just ignore it. This saves
@@ -694,13 +718,13 @@ void acpi_ut_remove_reference(union acpi_operand_object *object)
694 */ 718 */
695 if (!object || 719 if (!object ||
696 (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) { 720 (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_NAMED)) {
697 return_VOID; 721 return;
698 } 722 }
699 723
700 /* Ensure that we have a valid object */ 724 /* Ensure that we have a valid object */
701 725
702 if (!acpi_ut_valid_internal_object(object)) { 726 if (!acpi_ut_valid_internal_object(object)) {
703 return_VOID; 727 return;
704 } 728 }
705 729
706 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 730 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
@@ -713,5 +737,5 @@ void acpi_ut_remove_reference(union acpi_operand_object *object)
713 * of all subobjects!) 737 * of all subobjects!)
714 */ 738 */
715 (void)acpi_ut_update_object_reference(object, REF_DECREMENT); 739 (void)acpi_ut_update_object_reference(object, REF_DECREMENT);
716 return_VOID; 740 return;
717} 741}
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index a9c65fbea5f4..c3f3a7e7bdc7 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,7 @@ ACPI_MODULE_NAME("uteval")
68 ******************************************************************************/ 68 ******************************************************************************/
69 69
70acpi_status 70acpi_status
71acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, 71acpi_ut_evaluate_object(struct acpi_namespace_node * prefix_node,
72 char *path, 72 char *path,
73 u32 expected_return_btypes, 73 u32 expected_return_btypes,
74 union acpi_operand_object **return_desc) 74 union acpi_operand_object **return_desc)
diff --git a/drivers/acpi/acpica/utexcep.c b/drivers/acpi/acpica/utexcep.c
index 23b98945f6b7..a0ab7c02e87c 100644
--- a/drivers/acpi/acpica/utexcep.c
+++ b/drivers/acpi/acpica/utexcep.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index ed1893155f8b..ffecf4b4f0dd 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -293,11 +293,11 @@ acpi_status acpi_ut_init_globals(void)
293 293
294 /* GPE support */ 294 /* GPE support */
295 295
296 acpi_gbl_all_gpes_initialized = FALSE;
296 acpi_gbl_gpe_xrupt_list_head = NULL; 297 acpi_gbl_gpe_xrupt_list_head = NULL;
297 acpi_gbl_gpe_fadt_blocks[0] = NULL; 298 acpi_gbl_gpe_fadt_blocks[0] = NULL;
298 acpi_gbl_gpe_fadt_blocks[1] = NULL; 299 acpi_gbl_gpe_fadt_blocks[1] = NULL;
299 acpi_current_gpe_count = 0; 300 acpi_current_gpe_count = 0;
300 acpi_gbl_all_gpes_initialized = FALSE;
301 301
302 acpi_gbl_global_event_handler = NULL; 302 acpi_gbl_global_event_handler = NULL;
303 303
@@ -357,17 +357,24 @@ acpi_status acpi_ut_init_globals(void)
357 acpi_gbl_root_node_struct.peer = NULL; 357 acpi_gbl_root_node_struct.peer = NULL;
358 acpi_gbl_root_node_struct.object = NULL; 358 acpi_gbl_root_node_struct.object = NULL;
359 359
360#ifdef ACPI_DISASSEMBLER
361 acpi_gbl_external_list = NULL;
362#endif
363
360#ifdef ACPI_DEBUG_OUTPUT 364#ifdef ACPI_DEBUG_OUTPUT
361 acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX); 365 acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
362#endif 366#endif
363 367
364#ifdef ACPI_DBG_TRACK_ALLOCATIONS 368#ifdef ACPI_DBG_TRACK_ALLOCATIONS
365 acpi_gbl_display_final_mem_stats = FALSE; 369 acpi_gbl_display_final_mem_stats = FALSE;
370 acpi_gbl_disable_mem_tracking = FALSE;
366#endif 371#endif
367 372
368 return_ACPI_STATUS(AE_OK); 373 return_ACPI_STATUS(AE_OK);
369} 374}
370 375
376/* Public globals */
377
371ACPI_EXPORT_SYMBOL(acpi_gbl_FADT) 378ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
372ACPI_EXPORT_SYMBOL(acpi_dbg_level) 379ACPI_EXPORT_SYMBOL(acpi_dbg_level)
373ACPI_EXPORT_SYMBOL(acpi_dbg_layer) 380ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c
index 774c3aefbf5d..43a170a74a61 100644
--- a/drivers/acpi/acpica/utids.c
+++ b/drivers/acpi/acpica/utids.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index 246798e4c938..c5d1ac44c07d 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utlock.c b/drivers/acpi/acpica/utlock.c
index b1eb7f17e110..5c26ad420344 100644
--- a/drivers/acpi/acpica/utlock.c
+++ b/drivers/acpi/acpica/utlock.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -66,11 +66,11 @@ acpi_status acpi_ut_create_rw_lock(struct acpi_rw_lock *lock)
66 lock->num_readers = 0; 66 lock->num_readers = 0;
67 status = acpi_os_create_mutex(&lock->reader_mutex); 67 status = acpi_os_create_mutex(&lock->reader_mutex);
68 if (ACPI_FAILURE(status)) { 68 if (ACPI_FAILURE(status)) {
69 return status; 69 return (status);
70 } 70 }
71 71
72 status = acpi_os_create_mutex(&lock->writer_mutex); 72 status = acpi_os_create_mutex(&lock->writer_mutex);
73 return status; 73 return (status);
74} 74}
75 75
76void acpi_ut_delete_rw_lock(struct acpi_rw_lock *lock) 76void acpi_ut_delete_rw_lock(struct acpi_rw_lock *lock)
@@ -108,7 +108,7 @@ acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock)
108 108
109 status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER); 109 status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER);
110 if (ACPI_FAILURE(status)) { 110 if (ACPI_FAILURE(status)) {
111 return status; 111 return (status);
112 } 112 }
113 113
114 /* Acquire the write lock only for the first reader */ 114 /* Acquire the write lock only for the first reader */
@@ -121,7 +121,7 @@ acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock)
121 } 121 }
122 122
123 acpi_os_release_mutex(lock->reader_mutex); 123 acpi_os_release_mutex(lock->reader_mutex);
124 return status; 124 return (status);
125} 125}
126 126
127acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock) 127acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock)
@@ -130,7 +130,7 @@ acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock)
130 130
131 status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER); 131 status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER);
132 if (ACPI_FAILURE(status)) { 132 if (ACPI_FAILURE(status)) {
133 return status; 133 return (status);
134 } 134 }
135 135
136 /* Release the write lock only for the very last reader */ 136 /* Release the write lock only for the very last reader */
@@ -141,7 +141,7 @@ acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock)
141 } 141 }
142 142
143 acpi_os_release_mutex(lock->reader_mutex); 143 acpi_os_release_mutex(lock->reader_mutex);
144 return status; 144 return (status);
145} 145}
146 146
147/******************************************************************************* 147/*******************************************************************************
@@ -165,7 +165,7 @@ acpi_status acpi_ut_acquire_write_lock(struct acpi_rw_lock *lock)
165 acpi_status status; 165 acpi_status status;
166 166
167 status = acpi_os_acquire_mutex(lock->writer_mutex, ACPI_WAIT_FOREVER); 167 status = acpi_os_acquire_mutex(lock->writer_mutex, ACPI_WAIT_FOREVER);
168 return status; 168 return (status);
169} 169}
170 170
171void acpi_ut_release_write_lock(struct acpi_rw_lock *lock) 171void acpi_ut_release_write_lock(struct acpi_rw_lock *lock)
diff --git a/drivers/acpi/acpica/utmath.c b/drivers/acpi/acpica/utmath.c
index 49563674833a..909fe66e1934 100644
--- a/drivers/acpi/acpica/utmath.c
+++ b/drivers/acpi/acpica/utmath.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 9286a69eb9aa..785fdd07ae56 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -48,36 +48,6 @@
48#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utmisc") 49ACPI_MODULE_NAME("utmisc")
50 50
51#if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP
52/*******************************************************************************
53 *
54 * FUNCTION: ut_convert_backslashes
55 *
56 * PARAMETERS: pathname - File pathname string to be converted
57 *
58 * RETURN: Modifies the input Pathname
59 *
60 * DESCRIPTION: Convert all backslashes (0x5C) to forward slashes (0x2F) within
61 * the entire input file pathname string.
62 *
63 ******************************************************************************/
64void ut_convert_backslashes(char *pathname)
65{
66
67 if (!pathname) {
68 return;
69 }
70
71 while (*pathname) {
72 if (*pathname == '\\') {
73 *pathname = '/';
74 }
75
76 pathname++;
77 }
78}
79#endif
80
81/******************************************************************************* 51/*******************************************************************************
82 * 52 *
83 * FUNCTION: acpi_ut_is_pci_root_bridge 53 * FUNCTION: acpi_ut_is_pci_root_bridge
@@ -89,7 +59,6 @@ void ut_convert_backslashes(char *pathname)
89 * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. 59 * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
90 * 60 *
91 ******************************************************************************/ 61 ******************************************************************************/
92
93u8 acpi_ut_is_pci_root_bridge(char *id) 62u8 acpi_ut_is_pci_root_bridge(char *id)
94{ 63{
95 64
@@ -136,362 +105,6 @@ u8 acpi_ut_is_aml_table(struct acpi_table_header *table)
136 105
137/******************************************************************************* 106/*******************************************************************************
138 * 107 *
139 * FUNCTION: acpi_ut_allocate_owner_id
140 *
141 * PARAMETERS: owner_id - Where the new owner ID is returned
142 *
143 * RETURN: Status
144 *
145 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
146 * track objects created by the table or method, to be deleted
147 * when the method exits or the table is unloaded.
148 *
149 ******************************************************************************/
150
151acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
152{
153 u32 i;
154 u32 j;
155 u32 k;
156 acpi_status status;
157
158 ACPI_FUNCTION_TRACE(ut_allocate_owner_id);
159
160 /* Guard against multiple allocations of ID to the same location */
161
162 if (*owner_id) {
163 ACPI_ERROR((AE_INFO, "Owner ID [0x%2.2X] already exists",
164 *owner_id));
165 return_ACPI_STATUS(AE_ALREADY_EXISTS);
166 }
167
168 /* Mutex for the global ID mask */
169
170 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
171 if (ACPI_FAILURE(status)) {
172 return_ACPI_STATUS(status);
173 }
174
175 /*
176 * Find a free owner ID, cycle through all possible IDs on repeated
177 * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
178 * to be scanned twice.
179 */
180 for (i = 0, j = acpi_gbl_last_owner_id_index;
181 i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) {
182 if (j >= ACPI_NUM_OWNERID_MASKS) {
183 j = 0; /* Wraparound to start of mask array */
184 }
185
186 for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) {
187 if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) {
188
189 /* There are no free IDs in this mask */
190
191 break;
192 }
193
194 if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) {
195 /*
196 * Found a free ID. The actual ID is the bit index plus one,
197 * making zero an invalid Owner ID. Save this as the last ID
198 * allocated and update the global ID mask.
199 */
200 acpi_gbl_owner_id_mask[j] |= (1 << k);
201
202 acpi_gbl_last_owner_id_index = (u8)j;
203 acpi_gbl_next_owner_id_offset = (u8)(k + 1);
204
205 /*
206 * Construct encoded ID from the index and bit position
207 *
208 * Note: Last [j].k (bit 255) is never used and is marked
209 * permanently allocated (prevents +1 overflow)
210 */
211 *owner_id =
212 (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j));
213
214 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
215 "Allocated OwnerId: %2.2X\n",
216 (unsigned int)*owner_id));
217 goto exit;
218 }
219 }
220
221 acpi_gbl_next_owner_id_offset = 0;
222 }
223
224 /*
225 * All owner_ids have been allocated. This typically should
226 * not happen since the IDs are reused after deallocation. The IDs are
227 * allocated upon table load (one per table) and method execution, and
228 * they are released when a table is unloaded or a method completes
229 * execution.
230 *
231 * If this error happens, there may be very deep nesting of invoked control
232 * methods, or there may be a bug where the IDs are not released.
233 */
234 status = AE_OWNER_ID_LIMIT;
235 ACPI_ERROR((AE_INFO,
236 "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
237
238 exit:
239 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
240 return_ACPI_STATUS(status);
241}
242
243/*******************************************************************************
244 *
245 * FUNCTION: acpi_ut_release_owner_id
246 *
247 * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_ID
248 *
249 * RETURN: None. No error is returned because we are either exiting a
250 * control method or unloading a table. Either way, we would
251 * ignore any error anyway.
252 *
253 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255
254 *
255 ******************************************************************************/
256
257void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
258{
259 acpi_owner_id owner_id = *owner_id_ptr;
260 acpi_status status;
261 u32 index;
262 u32 bit;
263
264 ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id);
265
266 /* Always clear the input owner_id (zero is an invalid ID) */
267
268 *owner_id_ptr = 0;
269
270 /* Zero is not a valid owner_ID */
271
272 if (owner_id == 0) {
273 ACPI_ERROR((AE_INFO, "Invalid OwnerId: 0x%2.2X", owner_id));
274 return_VOID;
275 }
276
277 /* Mutex for the global ID mask */
278
279 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
280 if (ACPI_FAILURE(status)) {
281 return_VOID;
282 }
283
284 /* Normalize the ID to zero */
285
286 owner_id--;
287
288 /* Decode ID to index/offset pair */
289
290 index = ACPI_DIV_32(owner_id);
291 bit = 1 << ACPI_MOD_32(owner_id);
292
293 /* Free the owner ID only if it is valid */
294
295 if (acpi_gbl_owner_id_mask[index] & bit) {
296 acpi_gbl_owner_id_mask[index] ^= bit;
297 } else {
298 ACPI_ERROR((AE_INFO,
299 "Release of non-allocated OwnerId: 0x%2.2X",
300 owner_id + 1));
301 }
302
303 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
304 return_VOID;
305}
306
307/*******************************************************************************
308 *
309 * FUNCTION: acpi_ut_strupr (strupr)
310 *
311 * PARAMETERS: src_string - The source string to convert
312 *
313 * RETURN: None
314 *
315 * DESCRIPTION: Convert string to uppercase
316 *
317 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
318 *
319 ******************************************************************************/
320
321void acpi_ut_strupr(char *src_string)
322{
323 char *string;
324
325 ACPI_FUNCTION_ENTRY();
326
327 if (!src_string) {
328 return;
329 }
330
331 /* Walk entire string, uppercasing the letters */
332
333 for (string = src_string; *string; string++) {
334 *string = (char)ACPI_TOUPPER(*string);
335 }
336
337 return;
338}
339
340#ifdef ACPI_ASL_COMPILER
341/*******************************************************************************
342 *
343 * FUNCTION: acpi_ut_strlwr (strlwr)
344 *
345 * PARAMETERS: src_string - The source string to convert
346 *
347 * RETURN: None
348 *
349 * DESCRIPTION: Convert string to lowercase
350 *
351 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
352 *
353 ******************************************************************************/
354
355void acpi_ut_strlwr(char *src_string)
356{
357 char *string;
358
359 ACPI_FUNCTION_ENTRY();
360
361 if (!src_string) {
362 return;
363 }
364
365 /* Walk entire string, lowercasing the letters */
366
367 for (string = src_string; *string; string++) {
368 *string = (char)ACPI_TOLOWER(*string);
369 }
370
371 return;
372}
373
374/******************************************************************************
375 *
376 * FUNCTION: acpi_ut_stricmp
377 *
378 * PARAMETERS: string1 - first string to compare
379 * string2 - second string to compare
380 *
381 * RETURN: int that signifies string relationship. Zero means strings
382 * are equal.
383 *
384 * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare
385 * strings with no case sensitivity)
386 *
387 ******************************************************************************/
388
389int acpi_ut_stricmp(char *string1, char *string2)
390{
391 int c1;
392 int c2;
393
394 do {
395 c1 = tolower((int)*string1);
396 c2 = tolower((int)*string2);
397
398 string1++;
399 string2++;
400 }
401 while ((c1 == c2) && (c1));
402
403 return (c1 - c2);
404}
405#endif
406
407/*******************************************************************************
408 *
409 * FUNCTION: acpi_ut_print_string
410 *
411 * PARAMETERS: string - Null terminated ASCII string
412 * max_length - Maximum output length
413 *
414 * RETURN: None
415 *
416 * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
417 * sequences.
418 *
419 ******************************************************************************/
420
421void acpi_ut_print_string(char *string, u8 max_length)
422{
423 u32 i;
424
425 if (!string) {
426 acpi_os_printf("<\"NULL STRING PTR\">");
427 return;
428 }
429
430 acpi_os_printf("\"");
431 for (i = 0; string[i] && (i < max_length); i++) {
432
433 /* Escape sequences */
434
435 switch (string[i]) {
436 case 0x07:
437 acpi_os_printf("\\a"); /* BELL */
438 break;
439
440 case 0x08:
441 acpi_os_printf("\\b"); /* BACKSPACE */
442 break;
443
444 case 0x0C:
445 acpi_os_printf("\\f"); /* FORMFEED */
446 break;
447
448 case 0x0A:
449 acpi_os_printf("\\n"); /* LINEFEED */
450 break;
451
452 case 0x0D:
453 acpi_os_printf("\\r"); /* CARRIAGE RETURN */
454 break;
455
456 case 0x09:
457 acpi_os_printf("\\t"); /* HORIZONTAL TAB */
458 break;
459
460 case 0x0B:
461 acpi_os_printf("\\v"); /* VERTICAL TAB */
462 break;
463
464 case '\'': /* Single Quote */
465 case '\"': /* Double Quote */
466 case '\\': /* Backslash */
467 acpi_os_printf("\\%c", (int)string[i]);
468 break;
469
470 default:
471
472 /* Check for printable character or hex escape */
473
474 if (ACPI_IS_PRINT(string[i])) {
475 /* This is a normal character */
476
477 acpi_os_printf("%c", (int)string[i]);
478 } else {
479 /* All others will be Hex escapes */
480
481 acpi_os_printf("\\x%2.2X", (s32) string[i]);
482 }
483 break;
484 }
485 }
486 acpi_os_printf("\"");
487
488 if (i == max_length && string[i]) {
489 acpi_os_printf("...");
490 }
491}
492
493/*******************************************************************************
494 *
495 * FUNCTION: acpi_ut_dword_byte_swap 108 * FUNCTION: acpi_ut_dword_byte_swap
496 * 109 *
497 * PARAMETERS: value - Value to be converted 110 * PARAMETERS: value - Value to be converted
@@ -559,379 +172,6 @@ void acpi_ut_set_integer_width(u8 revision)
559 } 172 }
560} 173}
561 174
562#ifdef ACPI_DEBUG_OUTPUT
563/*******************************************************************************
564 *
565 * FUNCTION: acpi_ut_display_init_pathname
566 *
567 * PARAMETERS: type - Object type of the node
568 * obj_handle - Handle whose pathname will be displayed
569 * path - Additional path string to be appended.
570 * (NULL if no extra path)
571 *
572 * RETURN: acpi_status
573 *
574 * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
575 *
576 ******************************************************************************/
577
578void
579acpi_ut_display_init_pathname(u8 type,
580 struct acpi_namespace_node *obj_handle,
581 char *path)
582{
583 acpi_status status;
584 struct acpi_buffer buffer;
585
586 ACPI_FUNCTION_ENTRY();
587
588 /* Only print the path if the appropriate debug level is enabled */
589
590 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
591 return;
592 }
593
594 /* Get the full pathname to the node */
595
596 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
597 status = acpi_ns_handle_to_pathname(obj_handle, &buffer);
598 if (ACPI_FAILURE(status)) {
599 return;
600 }
601
602 /* Print what we're doing */
603
604 switch (type) {
605 case ACPI_TYPE_METHOD:
606 acpi_os_printf("Executing ");
607 break;
608
609 default:
610 acpi_os_printf("Initializing ");
611 break;
612 }
613
614 /* Print the object type and pathname */
615
616 acpi_os_printf("%-12s %s",
617 acpi_ut_get_type_name(type), (char *)buffer.pointer);
618
619 /* Extra path is used to append names like _STA, _INI, etc. */
620
621 if (path) {
622 acpi_os_printf(".%s", path);
623 }
624 acpi_os_printf("\n");
625
626 ACPI_FREE(buffer.pointer);
627}
628#endif
629
630/*******************************************************************************
631 *
632 * FUNCTION: acpi_ut_valid_acpi_char
633 *
634 * PARAMETERS: char - The character to be examined
635 * position - Byte position (0-3)
636 *
637 * RETURN: TRUE if the character is valid, FALSE otherwise
638 *
639 * DESCRIPTION: Check for a valid ACPI character. Must be one of:
640 * 1) Upper case alpha
641 * 2) numeric
642 * 3) underscore
643 *
644 * We allow a '!' as the last character because of the ASF! table
645 *
646 ******************************************************************************/
647
648u8 acpi_ut_valid_acpi_char(char character, u32 position)
649{
650
651 if (!((character >= 'A' && character <= 'Z') ||
652 (character >= '0' && character <= '9') || (character == '_'))) {
653
654 /* Allow a '!' in the last position */
655
656 if (character == '!' && position == 3) {
657 return (TRUE);
658 }
659
660 return (FALSE);
661 }
662
663 return (TRUE);
664}
665
666/*******************************************************************************
667 *
668 * FUNCTION: acpi_ut_valid_acpi_name
669 *
670 * PARAMETERS: name - The name to be examined
671 *
672 * RETURN: TRUE if the name is valid, FALSE otherwise
673 *
674 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
675 * 1) Upper case alpha
676 * 2) numeric
677 * 3) underscore
678 *
679 ******************************************************************************/
680
681u8 acpi_ut_valid_acpi_name(u32 name)
682{
683 u32 i;
684
685 ACPI_FUNCTION_ENTRY();
686
687 for (i = 0; i < ACPI_NAME_SIZE; i++) {
688 if (!acpi_ut_valid_acpi_char
689 ((ACPI_CAST_PTR(char, &name))[i], i)) {
690 return (FALSE);
691 }
692 }
693
694 return (TRUE);
695}
696
697/*******************************************************************************
698 *
699 * FUNCTION: acpi_ut_repair_name
700 *
701 * PARAMETERS: name - The ACPI name to be repaired
702 *
703 * RETURN: Repaired version of the name
704 *
705 * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
706 * return the new name. NOTE: the Name parameter must reside in
707 * read/write memory, cannot be a const.
708 *
709 * An ACPI Name must consist of valid ACPI characters. We will repair the name
710 * if necessary because we don't want to abort because of this, but we want
711 * all namespace names to be printable. A warning message is appropriate.
712 *
713 * This issue came up because there are in fact machines that exhibit
714 * this problem, and we want to be able to enable ACPI support for them,
715 * even though there are a few bad names.
716 *
717 ******************************************************************************/
718
719void acpi_ut_repair_name(char *name)
720{
721 u32 i;
722 u8 found_bad_char = FALSE;
723 u32 original_name;
724
725 ACPI_FUNCTION_NAME(ut_repair_name);
726
727 ACPI_MOVE_NAME(&original_name, name);
728
729 /* Check each character in the name */
730
731 for (i = 0; i < ACPI_NAME_SIZE; i++) {
732 if (acpi_ut_valid_acpi_char(name[i], i)) {
733 continue;
734 }
735
736 /*
737 * Replace a bad character with something printable, yet technically
738 * still invalid. This prevents any collisions with existing "good"
739 * names in the namespace.
740 */
741 name[i] = '*';
742 found_bad_char = TRUE;
743 }
744
745 if (found_bad_char) {
746
747 /* Report warning only if in strict mode or debug mode */
748
749 if (!acpi_gbl_enable_interpreter_slack) {
750 ACPI_WARNING((AE_INFO,
751 "Found bad character(s) in name, repaired: [%4.4s]\n",
752 name));
753 } else {
754 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
755 "Found bad character(s) in name, repaired: [%4.4s]\n",
756 name));
757 }
758 }
759}
760
761/*******************************************************************************
762 *
763 * FUNCTION: acpi_ut_strtoul64
764 *
765 * PARAMETERS: string - Null terminated string
766 * base - Radix of the string: 16 or ACPI_ANY_BASE;
767 * ACPI_ANY_BASE means 'in behalf of to_integer'
768 * ret_integer - Where the converted integer is returned
769 *
770 * RETURN: Status and Converted value
771 *
772 * DESCRIPTION: Convert a string into an unsigned value. Performs either a
773 * 32-bit or 64-bit conversion, depending on the current mode
774 * of the interpreter.
775 * NOTE: Does not support Octal strings, not needed.
776 *
777 ******************************************************************************/
778
779acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
780{
781 u32 this_digit = 0;
782 u64 return_value = 0;
783 u64 quotient;
784 u64 dividend;
785 u32 to_integer_op = (base == ACPI_ANY_BASE);
786 u32 mode32 = (acpi_gbl_integer_byte_width == 4);
787 u8 valid_digits = 0;
788 u8 sign_of0x = 0;
789 u8 term = 0;
790
791 ACPI_FUNCTION_TRACE_STR(ut_stroul64, string);
792
793 switch (base) {
794 case ACPI_ANY_BASE:
795 case 16:
796 break;
797
798 default:
799 /* Invalid Base */
800 return_ACPI_STATUS(AE_BAD_PARAMETER);
801 }
802
803 if (!string) {
804 goto error_exit;
805 }
806
807 /* Skip over any white space in the buffer */
808
809 while ((*string) && (ACPI_IS_SPACE(*string) || *string == '\t')) {
810 string++;
811 }
812
813 if (to_integer_op) {
814 /*
815 * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
816 * We need to determine if it is decimal or hexadecimal.
817 */
818 if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
819 sign_of0x = 1;
820 base = 16;
821
822 /* Skip over the leading '0x' */
823 string += 2;
824 } else {
825 base = 10;
826 }
827 }
828
829 /* Any string left? Check that '0x' is not followed by white space. */
830
831 if (!(*string) || ACPI_IS_SPACE(*string) || *string == '\t') {
832 if (to_integer_op) {
833 goto error_exit;
834 } else {
835 goto all_done;
836 }
837 }
838
839 /*
840 * Perform a 32-bit or 64-bit conversion, depending upon the current
841 * execution mode of the interpreter
842 */
843 dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
844
845 /* Main loop: convert the string to a 32- or 64-bit integer */
846
847 while (*string) {
848 if (ACPI_IS_DIGIT(*string)) {
849
850 /* Convert ASCII 0-9 to Decimal value */
851
852 this_digit = ((u8)*string) - '0';
853 } else if (base == 10) {
854
855 /* Digit is out of range; possible in to_integer case only */
856
857 term = 1;
858 } else {
859 this_digit = (u8)ACPI_TOUPPER(*string);
860 if (ACPI_IS_XDIGIT((char)this_digit)) {
861
862 /* Convert ASCII Hex char to value */
863
864 this_digit = this_digit - 'A' + 10;
865 } else {
866 term = 1;
867 }
868 }
869
870 if (term) {
871 if (to_integer_op) {
872 goto error_exit;
873 } else {
874 break;
875 }
876 } else if ((valid_digits == 0) && (this_digit == 0)
877 && !sign_of0x) {
878
879 /* Skip zeros */
880 string++;
881 continue;
882 }
883
884 valid_digits++;
885
886 if (sign_of0x
887 && ((valid_digits > 16)
888 || ((valid_digits > 8) && mode32))) {
889 /*
890 * This is to_integer operation case.
891 * No any restrictions for string-to-integer conversion,
892 * see ACPI spec.
893 */
894 goto error_exit;
895 }
896
897 /* Divide the digit into the correct position */
898
899 (void)acpi_ut_short_divide((dividend - (u64)this_digit),
900 base, &quotient, NULL);
901
902 if (return_value > quotient) {
903 if (to_integer_op) {
904 goto error_exit;
905 } else {
906 break;
907 }
908 }
909
910 return_value *= base;
911 return_value += this_digit;
912 string++;
913 }
914
915 /* All done, normal exit */
916
917 all_done:
918
919 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
920 ACPI_FORMAT_UINT64(return_value)));
921
922 *ret_integer = return_value;
923 return_ACPI_STATUS(AE_OK);
924
925 error_exit:
926 /* Base was set/validated above */
927
928 if (base == 10) {
929 return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
930 } else {
931 return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
932 }
933}
934
935/******************************************************************************* 175/*******************************************************************************
936 * 176 *
937 * FUNCTION: acpi_ut_create_update_state_and_push 177 * FUNCTION: acpi_ut_create_update_state_and_push
@@ -1097,3 +337,71 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
1097 337
1098 return_ACPI_STATUS(AE_AML_INTERNAL); 338 return_ACPI_STATUS(AE_AML_INTERNAL);
1099} 339}
340
341#ifdef ACPI_DEBUG_OUTPUT
342/*******************************************************************************
343 *
344 * FUNCTION: acpi_ut_display_init_pathname
345 *
346 * PARAMETERS: type - Object type of the node
347 * obj_handle - Handle whose pathname will be displayed
348 * path - Additional path string to be appended.
349 * (NULL if no extra path)
350 *
351 * RETURN: acpi_status
352 *
353 * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
354 *
355 ******************************************************************************/
356
357void
358acpi_ut_display_init_pathname(u8 type,
359 struct acpi_namespace_node *obj_handle,
360 char *path)
361{
362 acpi_status status;
363 struct acpi_buffer buffer;
364
365 ACPI_FUNCTION_ENTRY();
366
367 /* Only print the path if the appropriate debug level is enabled */
368
369 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
370 return;
371 }
372
373 /* Get the full pathname to the node */
374
375 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
376 status = acpi_ns_handle_to_pathname(obj_handle, &buffer);
377 if (ACPI_FAILURE(status)) {
378 return;
379 }
380
381 /* Print what we're doing */
382
383 switch (type) {
384 case ACPI_TYPE_METHOD:
385 acpi_os_printf("Executing ");
386 break;
387
388 default:
389 acpi_os_printf("Initializing ");
390 break;
391 }
392
393 /* Print the object type and pathname */
394
395 acpi_os_printf("%-12s %s",
396 acpi_ut_get_type_name(type), (char *)buffer.pointer);
397
398 /* Extra path is used to append names like _STA, _INI, etc. */
399
400 if (path) {
401 acpi_os_printf(".%s", path);
402 }
403 acpi_os_printf("\n");
404
405 ACPI_FREE(buffer.pointer);
406}
407#endif
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 5ccf57c0d87e..22feb99b8e35 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c
index 5c52ca78f6fa..1099f5c069f8 100644
--- a/drivers/acpi/acpica/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -419,7 +419,7 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object)
419{ 419{
420 ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object); 420 ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object);
421 421
422 /* Object must be a union acpi_operand_object */ 422 /* Object must be of type union acpi_operand_object */
423 423
424 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { 424 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
425 ACPI_ERROR((AE_INFO, 425 ACPI_ERROR((AE_INFO,
diff --git a/drivers/acpi/acpica/utosi.c b/drivers/acpi/acpica/utosi.c
index 676285d6116d..36a7d361d7cb 100644
--- a/drivers/acpi/acpica/utosi.c
+++ b/drivers/acpi/acpica/utosi.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utownerid.c b/drivers/acpi/acpica/utownerid.c
new file mode 100644
index 000000000000..835340b26d37
--- /dev/null
+++ b/drivers/acpi/acpica/utownerid.c
@@ -0,0 +1,218 @@
1/*******************************************************************************
2 *
3 * Module Name: utownerid - Support for Table/Method Owner IDs
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 "acnamesp.h"
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utownerid")
50
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_ut_allocate_owner_id
54 *
55 * PARAMETERS: owner_id - Where the new owner ID is returned
56 *
57 * RETURN: Status
58 *
59 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
60 * track objects created by the table or method, to be deleted
61 * when the method exits or the table is unloaded.
62 *
63 ******************************************************************************/
64acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
65{
66 u32 i;
67 u32 j;
68 u32 k;
69 acpi_status status;
70
71 ACPI_FUNCTION_TRACE(ut_allocate_owner_id);
72
73 /* Guard against multiple allocations of ID to the same location */
74
75 if (*owner_id) {
76 ACPI_ERROR((AE_INFO, "Owner ID [0x%2.2X] already exists",
77 *owner_id));
78 return_ACPI_STATUS(AE_ALREADY_EXISTS);
79 }
80
81 /* Mutex for the global ID mask */
82
83 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
84 if (ACPI_FAILURE(status)) {
85 return_ACPI_STATUS(status);
86 }
87
88 /*
89 * Find a free owner ID, cycle through all possible IDs on repeated
90 * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
91 * to be scanned twice.
92 */
93 for (i = 0, j = acpi_gbl_last_owner_id_index;
94 i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) {
95 if (j >= ACPI_NUM_OWNERID_MASKS) {
96 j = 0; /* Wraparound to start of mask array */
97 }
98
99 for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) {
100 if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) {
101
102 /* There are no free IDs in this mask */
103
104 break;
105 }
106
107 if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) {
108 /*
109 * Found a free ID. The actual ID is the bit index plus one,
110 * making zero an invalid Owner ID. Save this as the last ID
111 * allocated and update the global ID mask.
112 */
113 acpi_gbl_owner_id_mask[j] |= (1 << k);
114
115 acpi_gbl_last_owner_id_index = (u8)j;
116 acpi_gbl_next_owner_id_offset = (u8)(k + 1);
117
118 /*
119 * Construct encoded ID from the index and bit position
120 *
121 * Note: Last [j].k (bit 255) is never used and is marked
122 * permanently allocated (prevents +1 overflow)
123 */
124 *owner_id =
125 (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j));
126
127 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
128 "Allocated OwnerId: %2.2X\n",
129 (unsigned int)*owner_id));
130 goto exit;
131 }
132 }
133
134 acpi_gbl_next_owner_id_offset = 0;
135 }
136
137 /*
138 * All owner_ids have been allocated. This typically should
139 * not happen since the IDs are reused after deallocation. The IDs are
140 * allocated upon table load (one per table) and method execution, and
141 * they are released when a table is unloaded or a method completes
142 * execution.
143 *
144 * If this error happens, there may be very deep nesting of invoked control
145 * methods, or there may be a bug where the IDs are not released.
146 */
147 status = AE_OWNER_ID_LIMIT;
148 ACPI_ERROR((AE_INFO,
149 "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
150
151 exit:
152 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
153 return_ACPI_STATUS(status);
154}
155
156/*******************************************************************************
157 *
158 * FUNCTION: acpi_ut_release_owner_id
159 *
160 * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_ID
161 *
162 * RETURN: None. No error is returned because we are either exiting a
163 * control method or unloading a table. Either way, we would
164 * ignore any error anyway.
165 *
166 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255
167 *
168 ******************************************************************************/
169
170void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
171{
172 acpi_owner_id owner_id = *owner_id_ptr;
173 acpi_status status;
174 u32 index;
175 u32 bit;
176
177 ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id);
178
179 /* Always clear the input owner_id (zero is an invalid ID) */
180
181 *owner_id_ptr = 0;
182
183 /* Zero is not a valid owner_ID */
184
185 if (owner_id == 0) {
186 ACPI_ERROR((AE_INFO, "Invalid OwnerId: 0x%2.2X", owner_id));
187 return_VOID;
188 }
189
190 /* Mutex for the global ID mask */
191
192 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
193 if (ACPI_FAILURE(status)) {
194 return_VOID;
195 }
196
197 /* Normalize the ID to zero */
198
199 owner_id--;
200
201 /* Decode ID to index/offset pair */
202
203 index = ACPI_DIV_32(owner_id);
204 bit = 1 << ACPI_MOD_32(owner_id);
205
206 /* Free the owner ID only if it is valid */
207
208 if (acpi_gbl_owner_id_mask[index] & bit) {
209 acpi_gbl_owner_id_mask[index] ^= bit;
210 } else {
211 ACPI_ERROR((AE_INFO,
212 "Release of non-allocated OwnerId: 0x%2.2X",
213 owner_id + 1));
214 }
215
216 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
217 return_VOID;
218}
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index e38bef4980bc..cb7fa491decf 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -127,7 +127,9 @@ const char *acpi_gbl_rw_decode[] = {
127 127
128const char *acpi_gbl_shr_decode[] = { 128const char *acpi_gbl_shr_decode[] = {
129 "Exclusive", 129 "Exclusive",
130 "Shared" 130 "Shared",
131 "ExclusiveAndWake", /* ACPI 5.0 */
132 "SharedAndWake" /* ACPI 5.0 */
131}; 133};
132 134
133const char *acpi_gbl_siz_decode[] = { 135const char *acpi_gbl_siz_decode[] = {
@@ -383,26 +385,16 @@ static const u8 acpi_gbl_resource_types[] = {
383 ACPI_VARIABLE_LENGTH /* 0E *serial_bus */ 385 ACPI_VARIABLE_LENGTH /* 0E *serial_bus */
384}; 386};
385 387
386/*
387 * For the iASL compiler/disassembler, we don't want any error messages
388 * because the disassembler uses the resource validation code to determine
389 * if Buffer objects are actually Resource Templates.
390 */
391#ifdef ACPI_ASL_COMPILER
392#define ACPI_RESOURCE_ERROR(plist)
393#else
394#define ACPI_RESOURCE_ERROR(plist) ACPI_ERROR(plist)
395#endif
396
397/******************************************************************************* 388/*******************************************************************************
398 * 389 *
399 * FUNCTION: acpi_ut_walk_aml_resources 390 * FUNCTION: acpi_ut_walk_aml_resources
400 * 391 *
401 * PARAMETERS: aml - Pointer to the raw AML resource template 392 * PARAMETERS: walk_state - Current walk info
402 * aml_length - Length of the entire template 393 * PARAMETERS: aml - Pointer to the raw AML resource template
403 * user_function - Called once for each descriptor found. If 394 * aml_length - Length of the entire template
404 * NULL, a pointer to the end_tag is returned 395 * user_function - Called once for each descriptor found. If
405 * context - Passed to user_function 396 * NULL, a pointer to the end_tag is returned
397 * context - Passed to user_function
406 * 398 *
407 * RETURN: Status 399 * RETURN: Status
408 * 400 *
@@ -412,7 +404,8 @@ static const u8 acpi_gbl_resource_types[] = {
412 ******************************************************************************/ 404 ******************************************************************************/
413 405
414acpi_status 406acpi_status
415acpi_ut_walk_aml_resources(u8 * aml, 407acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state,
408 u8 *aml,
416 acpi_size aml_length, 409 acpi_size aml_length,
417 acpi_walk_aml_callback user_function, void **context) 410 acpi_walk_aml_callback user_function, void **context)
418{ 411{
@@ -441,7 +434,8 @@ acpi_ut_walk_aml_resources(u8 * aml,
441 434
442 /* Validate the Resource Type and Resource Length */ 435 /* Validate the Resource Type and Resource Length */
443 436
444 status = acpi_ut_validate_resource(aml, &resource_index); 437 status =
438 acpi_ut_validate_resource(walk_state, aml, &resource_index);
445 if (ACPI_FAILURE(status)) { 439 if (ACPI_FAILURE(status)) {
446 /* 440 /*
447 * Exit on failure. Cannot continue because the descriptor length 441 * Exit on failure. Cannot continue because the descriptor length
@@ -498,7 +492,8 @@ acpi_ut_walk_aml_resources(u8 * aml,
498 492
499 /* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */ 493 /* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */
500 494
501 (void)acpi_ut_validate_resource(end_tag, &resource_index); 495 (void)acpi_ut_validate_resource(walk_state, end_tag,
496 &resource_index);
502 status = 497 status =
503 user_function(end_tag, 2, offset, resource_index, context); 498 user_function(end_tag, 2, offset, resource_index, context);
504 if (ACPI_FAILURE(status)) { 499 if (ACPI_FAILURE(status)) {
@@ -513,9 +508,10 @@ acpi_ut_walk_aml_resources(u8 * aml,
513 * 508 *
514 * FUNCTION: acpi_ut_validate_resource 509 * FUNCTION: acpi_ut_validate_resource
515 * 510 *
516 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 511 * PARAMETERS: walk_state - Current walk info
517 * return_index - Where the resource index is returned. NULL 512 * aml - Pointer to the raw AML resource descriptor
518 * if the index is not required. 513 * return_index - Where the resource index is returned. NULL
514 * if the index is not required.
519 * 515 *
520 * RETURN: Status, and optionally the Index into the global resource tables 516 * RETURN: Status, and optionally the Index into the global resource tables
521 * 517 *
@@ -525,7 +521,9 @@ acpi_ut_walk_aml_resources(u8 * aml,
525 * 521 *
526 ******************************************************************************/ 522 ******************************************************************************/
527 523
528acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) 524acpi_status
525acpi_ut_validate_resource(struct acpi_walk_state *walk_state,
526 void *aml, u8 *return_index)
529{ 527{
530 union aml_resource *aml_resource; 528 union aml_resource *aml_resource;
531 u8 resource_type; 529 u8 resource_type;
@@ -627,10 +625,12 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
627 if ((aml_resource->common_serial_bus.type == 0) || 625 if ((aml_resource->common_serial_bus.type == 0) ||
628 (aml_resource->common_serial_bus.type > 626 (aml_resource->common_serial_bus.type >
629 AML_RESOURCE_MAX_SERIALBUSTYPE)) { 627 AML_RESOURCE_MAX_SERIALBUSTYPE)) {
630 ACPI_RESOURCE_ERROR((AE_INFO, 628 if (walk_state) {
631 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X", 629 ACPI_ERROR((AE_INFO,
632 aml_resource->common_serial_bus. 630 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
633 type)); 631 aml_resource->common_serial_bus.
632 type));
633 }
634 return (AE_AML_INVALID_RESOURCE_TYPE); 634 return (AE_AML_INVALID_RESOURCE_TYPE);
635 } 635 }
636 } 636 }
@@ -645,18 +645,22 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
645 645
646 invalid_resource: 646 invalid_resource:
647 647
648 ACPI_RESOURCE_ERROR((AE_INFO, 648 if (walk_state) {
649 "Invalid/unsupported resource descriptor: Type 0x%2.2X", 649 ACPI_ERROR((AE_INFO,
650 resource_type)); 650 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
651 resource_type));
652 }
651 return (AE_AML_INVALID_RESOURCE_TYPE); 653 return (AE_AML_INVALID_RESOURCE_TYPE);
652 654
653 bad_resource_length: 655 bad_resource_length:
654 656
655 ACPI_RESOURCE_ERROR((AE_INFO, 657 if (walk_state) {
656 "Invalid resource descriptor length: Type " 658 ACPI_ERROR((AE_INFO,
657 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X", 659 "Invalid resource descriptor length: Type "
658 resource_type, resource_length, 660 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
659 minimum_resource_length)); 661 resource_type, resource_length,
662 minimum_resource_length));
663 }
660 return (AE_AML_BAD_RESOURCE_LENGTH); 664 return (AE_AML_BAD_RESOURCE_LENGTH);
661} 665}
662 666
@@ -800,8 +804,7 @@ u32 acpi_ut_get_descriptor_length(void *aml)
800 ******************************************************************************/ 804 ******************************************************************************/
801 805
802acpi_status 806acpi_status
803acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc, 807acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag)
804 u8 ** end_tag)
805{ 808{
806 acpi_status status; 809 acpi_status status;
807 810
@@ -816,7 +819,7 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
816 819
817 /* Validate the template and get a pointer to the end_tag */ 820 /* Validate the template and get a pointer to the end_tag */
818 821
819 status = acpi_ut_walk_aml_resources(obj_desc->buffer.pointer, 822 status = acpi_ut_walk_aml_resources(NULL, obj_desc->buffer.pointer,
820 obj_desc->buffer.length, NULL, 823 obj_desc->buffer.length, NULL,
821 (void **)end_tag); 824 (void **)end_tag);
822 825
diff --git a/drivers/acpi/acpica/utstate.c b/drivers/acpi/acpica/utstate.c
index cee0473ba813..a6b729d4c1dc 100644
--- a/drivers/acpi/acpica/utstate.c
+++ b/drivers/acpi/acpica/utstate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -97,14 +97,13 @@ void
97acpi_ut_push_generic_state(union acpi_generic_state **list_head, 97acpi_ut_push_generic_state(union acpi_generic_state **list_head,
98 union acpi_generic_state *state) 98 union acpi_generic_state *state)
99{ 99{
100 ACPI_FUNCTION_TRACE(ut_push_generic_state); 100 ACPI_FUNCTION_ENTRY();
101 101
102 /* Push the state object onto the front of the list (stack) */ 102 /* Push the state object onto the front of the list (stack) */
103 103
104 state->common.next = *list_head; 104 state->common.next = *list_head;
105 *list_head = state; 105 *list_head = state;
106 106 return;
107 return_VOID;
108} 107}
109 108
110/******************************************************************************* 109/*******************************************************************************
@@ -124,7 +123,7 @@ union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
124{ 123{
125 union acpi_generic_state *state; 124 union acpi_generic_state *state;
126 125
127 ACPI_FUNCTION_TRACE(ut_pop_generic_state); 126 ACPI_FUNCTION_ENTRY();
128 127
129 /* Remove the state object at the head of the list (stack) */ 128 /* Remove the state object at the head of the list (stack) */
130 129
@@ -136,7 +135,7 @@ union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
136 *list_head = state->common.next; 135 *list_head = state->common.next;
137 } 136 }
138 137
139 return_PTR(state); 138 return (state);
140} 139}
141 140
142/******************************************************************************* 141/*******************************************************************************
@@ -186,13 +185,13 @@ struct acpi_thread_state *acpi_ut_create_thread_state(void)
186{ 185{
187 union acpi_generic_state *state; 186 union acpi_generic_state *state;
188 187
189 ACPI_FUNCTION_TRACE(ut_create_thread_state); 188 ACPI_FUNCTION_ENTRY();
190 189
191 /* Create the generic state object */ 190 /* Create the generic state object */
192 191
193 state = acpi_ut_create_generic_state(); 192 state = acpi_ut_create_generic_state();
194 if (!state) { 193 if (!state) {
195 return_PTR(NULL); 194 return (NULL);
196 } 195 }
197 196
198 /* Init fields specific to the update struct */ 197 /* Init fields specific to the update struct */
@@ -207,7 +206,7 @@ struct acpi_thread_state *acpi_ut_create_thread_state(void)
207 state->thread.thread_id = (acpi_thread_id) 1; 206 state->thread.thread_id = (acpi_thread_id) 1;
208 } 207 }
209 208
210 return_PTR((struct acpi_thread_state *)state); 209 return ((struct acpi_thread_state *)state);
211} 210}
212 211
213/******************************************************************************* 212/*******************************************************************************
@@ -230,13 +229,13 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
230{ 229{
231 union acpi_generic_state *state; 230 union acpi_generic_state *state;
232 231
233 ACPI_FUNCTION_TRACE_PTR(ut_create_update_state, object); 232 ACPI_FUNCTION_ENTRY();
234 233
235 /* Create the generic state object */ 234 /* Create the generic state object */
236 235
237 state = acpi_ut_create_generic_state(); 236 state = acpi_ut_create_generic_state();
238 if (!state) { 237 if (!state) {
239 return_PTR(NULL); 238 return (NULL);
240 } 239 }
241 240
242 /* Init fields specific to the update struct */ 241 /* Init fields specific to the update struct */
@@ -244,8 +243,7 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
244 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_UPDATE; 243 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_UPDATE;
245 state->update.object = object; 244 state->update.object = object;
246 state->update.value = action; 245 state->update.value = action;
247 246 return (state);
248 return_PTR(state);
249} 247}
250 248
251/******************************************************************************* 249/*******************************************************************************
@@ -267,13 +265,13 @@ union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
267{ 265{
268 union acpi_generic_state *state; 266 union acpi_generic_state *state;
269 267
270 ACPI_FUNCTION_TRACE_PTR(ut_create_pkg_state, internal_object); 268 ACPI_FUNCTION_ENTRY();
271 269
272 /* Create the generic state object */ 270 /* Create the generic state object */
273 271
274 state = acpi_ut_create_generic_state(); 272 state = acpi_ut_create_generic_state();
275 if (!state) { 273 if (!state) {
276 return_PTR(NULL); 274 return (NULL);
277 } 275 }
278 276
279 /* Init fields specific to the update struct */ 277 /* Init fields specific to the update struct */
@@ -283,8 +281,7 @@ union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
283 state->pkg.dest_object = external_object; 281 state->pkg.dest_object = external_object;
284 state->pkg.index = index; 282 state->pkg.index = index;
285 state->pkg.num_packages = 1; 283 state->pkg.num_packages = 1;
286 284 return (state);
287 return_PTR(state);
288} 285}
289 286
290/******************************************************************************* 287/*******************************************************************************
@@ -304,21 +301,20 @@ union acpi_generic_state *acpi_ut_create_control_state(void)
304{ 301{
305 union acpi_generic_state *state; 302 union acpi_generic_state *state;
306 303
307 ACPI_FUNCTION_TRACE(ut_create_control_state); 304 ACPI_FUNCTION_ENTRY();
308 305
309 /* Create the generic state object */ 306 /* Create the generic state object */
310 307
311 state = acpi_ut_create_generic_state(); 308 state = acpi_ut_create_generic_state();
312 if (!state) { 309 if (!state) {
313 return_PTR(NULL); 310 return (NULL);
314 } 311 }
315 312
316 /* Init fields specific to the control struct */ 313 /* Init fields specific to the control struct */
317 314
318 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_CONTROL; 315 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_CONTROL;
319 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING; 316 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
320 317 return (state);
321 return_PTR(state);
322} 318}
323 319
324/******************************************************************************* 320/*******************************************************************************
@@ -336,12 +332,12 @@ union acpi_generic_state *acpi_ut_create_control_state(void)
336 332
337void acpi_ut_delete_generic_state(union acpi_generic_state *state) 333void acpi_ut_delete_generic_state(union acpi_generic_state *state)
338{ 334{
339 ACPI_FUNCTION_TRACE(ut_delete_generic_state); 335 ACPI_FUNCTION_ENTRY();
340 336
341 /* Ignore null state */ 337 /* Ignore null state */
342 338
343 if (state) { 339 if (state) {
344 (void)acpi_os_release_object(acpi_gbl_state_cache, state); 340 (void)acpi_os_release_object(acpi_gbl_state_cache, state);
345 } 341 }
346 return_VOID; 342 return;
347} 343}
diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c
new file mode 100644
index 000000000000..b3e36a81aa4d
--- /dev/null
+++ b/drivers/acpi/acpica/utstring.c
@@ -0,0 +1,574 @@
1/*******************************************************************************
2 *
3 * Module Name: utstring - Common functions for strings and characters
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 "acnamesp.h"
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utstring")
50
51/*
52 * Non-ANSI C library functions - strlwr, strupr, stricmp, and a 64-bit
53 * version of strtoul.
54 */
55#ifdef ACPI_ASL_COMPILER
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_ut_strlwr (strlwr)
59 *
60 * PARAMETERS: src_string - The source string to convert
61 *
62 * RETURN: None
63 *
64 * DESCRIPTION: Convert string to lowercase
65 *
66 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
67 *
68 ******************************************************************************/
69void acpi_ut_strlwr(char *src_string)
70{
71 char *string;
72
73 ACPI_FUNCTION_ENTRY();
74
75 if (!src_string) {
76 return;
77 }
78
79 /* Walk entire string, lowercasing the letters */
80
81 for (string = src_string; *string; string++) {
82 *string = (char)ACPI_TOLOWER(*string);
83 }
84
85 return;
86}
87
88/******************************************************************************
89 *
90 * FUNCTION: acpi_ut_stricmp (stricmp)
91 *
92 * PARAMETERS: string1 - first string to compare
93 * string2 - second string to compare
94 *
95 * RETURN: int that signifies string relationship. Zero means strings
96 * are equal.
97 *
98 * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare
99 * strings with no case sensitivity)
100 *
101 ******************************************************************************/
102
103int acpi_ut_stricmp(char *string1, char *string2)
104{
105 int c1;
106 int c2;
107
108 do {
109 c1 = tolower((int)*string1);
110 c2 = tolower((int)*string2);
111
112 string1++;
113 string2++;
114 }
115 while ((c1 == c2) && (c1));
116
117 return (c1 - c2);
118}
119#endif
120
121/*******************************************************************************
122 *
123 * FUNCTION: acpi_ut_strupr (strupr)
124 *
125 * PARAMETERS: src_string - The source string to convert
126 *
127 * RETURN: None
128 *
129 * DESCRIPTION: Convert string to uppercase
130 *
131 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
132 *
133 ******************************************************************************/
134
135void acpi_ut_strupr(char *src_string)
136{
137 char *string;
138
139 ACPI_FUNCTION_ENTRY();
140
141 if (!src_string) {
142 return;
143 }
144
145 /* Walk entire string, uppercasing the letters */
146
147 for (string = src_string; *string; string++) {
148 *string = (char)ACPI_TOUPPER(*string);
149 }
150
151 return;
152}
153
154/*******************************************************************************
155 *
156 * FUNCTION: acpi_ut_strtoul64
157 *
158 * PARAMETERS: string - Null terminated string
159 * base - Radix of the string: 16 or ACPI_ANY_BASE;
160 * ACPI_ANY_BASE means 'in behalf of to_integer'
161 * ret_integer - Where the converted integer is returned
162 *
163 * RETURN: Status and Converted value
164 *
165 * DESCRIPTION: Convert a string into an unsigned value. Performs either a
166 * 32-bit or 64-bit conversion, depending on the current mode
167 * of the interpreter.
168 * NOTE: Does not support Octal strings, not needed.
169 *
170 ******************************************************************************/
171
172acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
173{
174 u32 this_digit = 0;
175 u64 return_value = 0;
176 u64 quotient;
177 u64 dividend;
178 u32 to_integer_op = (base == ACPI_ANY_BASE);
179 u32 mode32 = (acpi_gbl_integer_byte_width == 4);
180 u8 valid_digits = 0;
181 u8 sign_of0x = 0;
182 u8 term = 0;
183
184 ACPI_FUNCTION_TRACE_STR(ut_stroul64, string);
185
186 switch (base) {
187 case ACPI_ANY_BASE:
188 case 16:
189 break;
190
191 default:
192 /* Invalid Base */
193 return_ACPI_STATUS(AE_BAD_PARAMETER);
194 }
195
196 if (!string) {
197 goto error_exit;
198 }
199
200 /* Skip over any white space in the buffer */
201
202 while ((*string) && (ACPI_IS_SPACE(*string) || *string == '\t')) {
203 string++;
204 }
205
206 if (to_integer_op) {
207 /*
208 * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
209 * We need to determine if it is decimal or hexadecimal.
210 */
211 if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) {
212 sign_of0x = 1;
213 base = 16;
214
215 /* Skip over the leading '0x' */
216 string += 2;
217 } else {
218 base = 10;
219 }
220 }
221
222 /* Any string left? Check that '0x' is not followed by white space. */
223
224 if (!(*string) || ACPI_IS_SPACE(*string) || *string == '\t') {
225 if (to_integer_op) {
226 goto error_exit;
227 } else {
228 goto all_done;
229 }
230 }
231
232 /*
233 * Perform a 32-bit or 64-bit conversion, depending upon the current
234 * execution mode of the interpreter
235 */
236 dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
237
238 /* Main loop: convert the string to a 32- or 64-bit integer */
239
240 while (*string) {
241 if (ACPI_IS_DIGIT(*string)) {
242
243 /* Convert ASCII 0-9 to Decimal value */
244
245 this_digit = ((u8)*string) - '0';
246 } else if (base == 10) {
247
248 /* Digit is out of range; possible in to_integer case only */
249
250 term = 1;
251 } else {
252 this_digit = (u8)ACPI_TOUPPER(*string);
253 if (ACPI_IS_XDIGIT((char)this_digit)) {
254
255 /* Convert ASCII Hex char to value */
256
257 this_digit = this_digit - 'A' + 10;
258 } else {
259 term = 1;
260 }
261 }
262
263 if (term) {
264 if (to_integer_op) {
265 goto error_exit;
266 } else {
267 break;
268 }
269 } else if ((valid_digits == 0) && (this_digit == 0)
270 && !sign_of0x) {
271
272 /* Skip zeros */
273 string++;
274 continue;
275 }
276
277 valid_digits++;
278
279 if (sign_of0x
280 && ((valid_digits > 16)
281 || ((valid_digits > 8) && mode32))) {
282 /*
283 * This is to_integer operation case.
284 * No any restrictions for string-to-integer conversion,
285 * see ACPI spec.
286 */
287 goto error_exit;
288 }
289
290 /* Divide the digit into the correct position */
291
292 (void)acpi_ut_short_divide((dividend - (u64)this_digit),
293 base, &quotient, NULL);
294
295 if (return_value > quotient) {
296 if (to_integer_op) {
297 goto error_exit;
298 } else {
299 break;
300 }
301 }
302
303 return_value *= base;
304 return_value += this_digit;
305 string++;
306 }
307
308 /* All done, normal exit */
309
310 all_done:
311
312 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
313 ACPI_FORMAT_UINT64(return_value)));
314
315 *ret_integer = return_value;
316 return_ACPI_STATUS(AE_OK);
317
318 error_exit:
319 /* Base was set/validated above */
320
321 if (base == 10) {
322 return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
323 } else {
324 return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
325 }
326}
327
328/*******************************************************************************
329 *
330 * FUNCTION: acpi_ut_print_string
331 *
332 * PARAMETERS: string - Null terminated ASCII string
333 * max_length - Maximum output length
334 *
335 * RETURN: None
336 *
337 * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
338 * sequences.
339 *
340 ******************************************************************************/
341
342void acpi_ut_print_string(char *string, u8 max_length)
343{
344 u32 i;
345
346 if (!string) {
347 acpi_os_printf("<\"NULL STRING PTR\">");
348 return;
349 }
350
351 acpi_os_printf("\"");
352 for (i = 0; string[i] && (i < max_length); i++) {
353
354 /* Escape sequences */
355
356 switch (string[i]) {
357 case 0x07:
358 acpi_os_printf("\\a"); /* BELL */
359 break;
360
361 case 0x08:
362 acpi_os_printf("\\b"); /* BACKSPACE */
363 break;
364
365 case 0x0C:
366 acpi_os_printf("\\f"); /* FORMFEED */
367 break;
368
369 case 0x0A:
370 acpi_os_printf("\\n"); /* LINEFEED */
371 break;
372
373 case 0x0D:
374 acpi_os_printf("\\r"); /* CARRIAGE RETURN */
375 break;
376
377 case 0x09:
378 acpi_os_printf("\\t"); /* HORIZONTAL TAB */
379 break;
380
381 case 0x0B:
382 acpi_os_printf("\\v"); /* VERTICAL TAB */
383 break;
384
385 case '\'': /* Single Quote */
386 case '\"': /* Double Quote */
387 case '\\': /* Backslash */
388 acpi_os_printf("\\%c", (int)string[i]);
389 break;
390
391 default:
392
393 /* Check for printable character or hex escape */
394
395 if (ACPI_IS_PRINT(string[i])) {
396 /* This is a normal character */
397
398 acpi_os_printf("%c", (int)string[i]);
399 } else {
400 /* All others will be Hex escapes */
401
402 acpi_os_printf("\\x%2.2X", (s32) string[i]);
403 }
404 break;
405 }
406 }
407 acpi_os_printf("\"");
408
409 if (i == max_length && string[i]) {
410 acpi_os_printf("...");
411 }
412}
413
414/*******************************************************************************
415 *
416 * FUNCTION: acpi_ut_valid_acpi_char
417 *
418 * PARAMETERS: char - The character to be examined
419 * position - Byte position (0-3)
420 *
421 * RETURN: TRUE if the character is valid, FALSE otherwise
422 *
423 * DESCRIPTION: Check for a valid ACPI character. Must be one of:
424 * 1) Upper case alpha
425 * 2) numeric
426 * 3) underscore
427 *
428 * We allow a '!' as the last character because of the ASF! table
429 *
430 ******************************************************************************/
431
432u8 acpi_ut_valid_acpi_char(char character, u32 position)
433{
434
435 if (!((character >= 'A' && character <= 'Z') ||
436 (character >= '0' && character <= '9') || (character == '_'))) {
437
438 /* Allow a '!' in the last position */
439
440 if (character == '!' && position == 3) {
441 return (TRUE);
442 }
443
444 return (FALSE);
445 }
446
447 return (TRUE);
448}
449
450/*******************************************************************************
451 *
452 * FUNCTION: acpi_ut_valid_acpi_name
453 *
454 * PARAMETERS: name - The name to be examined
455 *
456 * RETURN: TRUE if the name is valid, FALSE otherwise
457 *
458 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
459 * 1) Upper case alpha
460 * 2) numeric
461 * 3) underscore
462 *
463 ******************************************************************************/
464
465u8 acpi_ut_valid_acpi_name(u32 name)
466{
467 u32 i;
468
469 ACPI_FUNCTION_ENTRY();
470
471 for (i = 0; i < ACPI_NAME_SIZE; i++) {
472 if (!acpi_ut_valid_acpi_char
473 ((ACPI_CAST_PTR(char, &name))[i], i)) {
474 return (FALSE);
475 }
476 }
477
478 return (TRUE);
479}
480
481/*******************************************************************************
482 *
483 * FUNCTION: acpi_ut_repair_name
484 *
485 * PARAMETERS: name - The ACPI name to be repaired
486 *
487 * RETURN: Repaired version of the name
488 *
489 * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
490 * return the new name. NOTE: the Name parameter must reside in
491 * read/write memory, cannot be a const.
492 *
493 * An ACPI Name must consist of valid ACPI characters. We will repair the name
494 * if necessary because we don't want to abort because of this, but we want
495 * all namespace names to be printable. A warning message is appropriate.
496 *
497 * This issue came up because there are in fact machines that exhibit
498 * this problem, and we want to be able to enable ACPI support for them,
499 * even though there are a few bad names.
500 *
501 ******************************************************************************/
502
503void acpi_ut_repair_name(char *name)
504{
505 u32 i;
506 u8 found_bad_char = FALSE;
507 u32 original_name;
508
509 ACPI_FUNCTION_NAME(ut_repair_name);
510
511 ACPI_MOVE_NAME(&original_name, name);
512
513 /* Check each character in the name */
514
515 for (i = 0; i < ACPI_NAME_SIZE; i++) {
516 if (acpi_ut_valid_acpi_char(name[i], i)) {
517 continue;
518 }
519
520 /*
521 * Replace a bad character with something printable, yet technically
522 * still invalid. This prevents any collisions with existing "good"
523 * names in the namespace.
524 */
525 name[i] = '*';
526 found_bad_char = TRUE;
527 }
528
529 if (found_bad_char) {
530
531 /* Report warning only if in strict mode or debug mode */
532
533 if (!acpi_gbl_enable_interpreter_slack) {
534 ACPI_WARNING((AE_INFO,
535 "Invalid character(s) in name (0x%.8X), repaired: [%4.4s]",
536 original_name, name));
537 } else {
538 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
539 "Invalid character(s) in name (0x%.8X), repaired: [%4.4s]",
540 original_name, name));
541 }
542 }
543}
544
545#if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP
546/*******************************************************************************
547 *
548 * FUNCTION: ut_convert_backslashes
549 *
550 * PARAMETERS: pathname - File pathname string to be converted
551 *
552 * RETURN: Modifies the input Pathname
553 *
554 * DESCRIPTION: Convert all backslashes (0x5C) to forward slashes (0x2F) within
555 * the entire input file pathname string.
556 *
557 ******************************************************************************/
558
559void ut_convert_backslashes(char *pathname)
560{
561
562 if (!pathname) {
563 return;
564 }
565
566 while (*pathname) {
567 if (*pathname == '\\') {
568 *pathname = '/';
569 }
570
571 pathname++;
572 }
573}
574#endif
diff --git a/drivers/acpi/acpica/uttrack.c b/drivers/acpi/acpica/uttrack.c
index a424a9e3fea4..62774c7b76a8 100644
--- a/drivers/acpi/acpica/uttrack.c
+++ b/drivers/acpi/acpica/uttrack.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -436,10 +436,10 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
436 struct acpi_memory_list *mem_list; 436 struct acpi_memory_list *mem_list;
437 acpi_status status; 437 acpi_status status;
438 438
439 ACPI_FUNCTION_TRACE(ut_remove_allocation); 439 ACPI_FUNCTION_NAME(ut_remove_allocation);
440 440
441 if (acpi_gbl_disable_mem_tracking) { 441 if (acpi_gbl_disable_mem_tracking) {
442 return_ACPI_STATUS(AE_OK); 442 return (AE_OK);
443 } 443 }
444 444
445 mem_list = acpi_gbl_global_list; 445 mem_list = acpi_gbl_global_list;
@@ -450,12 +450,12 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
450 ACPI_ERROR((module, line, 450 ACPI_ERROR((module, line,
451 "Empty allocation list, nothing to free!")); 451 "Empty allocation list, nothing to free!"));
452 452
453 return_ACPI_STATUS(AE_OK); 453 return (AE_OK);
454 } 454 }
455 455
456 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY); 456 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
457 if (ACPI_FAILURE(status)) { 457 if (ACPI_FAILURE(status)) {
458 return_ACPI_STATUS(status); 458 return (status);
459 } 459 }
460 460
461 /* Unlink */ 461 /* Unlink */
@@ -470,15 +470,15 @@ acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
470 (allocation->next)->previous = allocation->previous; 470 (allocation->next)->previous = allocation->previous;
471 } 471 }
472 472
473 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing %p, size 0%X\n",
474 &allocation->user_space, allocation->size));
475
473 /* Mark the segment as deleted */ 476 /* Mark the segment as deleted */
474 477
475 ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size); 478 ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size);
476 479
477 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
478 allocation->size));
479
480 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY); 480 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
481 return_ACPI_STATUS(status); 481 return (status);
482} 482}
483 483
484/******************************************************************************* 484/*******************************************************************************
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index 390db0ca5e2e..48efb446258c 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,11 +44,7 @@
44#include <linux/export.h> 44#include <linux/export.h>
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "acevents.h"
48#include "acnamesp.h"
49#include "acdebug.h" 47#include "acdebug.h"
50#include "actables.h"
51#include "acinterp.h"
52 48
53#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
54ACPI_MODULE_NAME("utxface") 50ACPI_MODULE_NAME("utxface")
diff --git a/drivers/acpi/acpica/utxferror.c b/drivers/acpi/acpica/utxferror.c
index d4d3826140d8..976b6c734fce 100644
--- a/drivers/acpi/acpica/utxferror.c
+++ b/drivers/acpi/acpica/utxferror.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -297,9 +297,9 @@ ACPI_EXPORT_SYMBOL(acpi_bios_warning)
297 * 297 *
298 * PARAMETERS: module_name - Caller's module name (for error output) 298 * PARAMETERS: module_name - Caller's module name (for error output)
299 * line_number - Caller's line number (for error output) 299 * line_number - Caller's line number (for error output)
300 * Pathname - Full pathname to the node 300 * pathname - Full pathname to the node
301 * node_flags - From Namespace node for the method/object 301 * node_flags - From Namespace node for the method/object
302 * Format - Printf format string + additional args 302 * format - Printf format string + additional args
303 * 303 *
304 * RETURN: None 304 * RETURN: None
305 * 305 *
diff --git a/drivers/acpi/acpica/utxfinit.c b/drivers/acpi/acpica/utxfinit.c
index 14f523627a5e..41ebaaf8bb1a 100644
--- a/drivers/acpi/acpica/utxfinit.c
+++ b/drivers/acpi/acpica/utxfinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utxfmutex.c b/drivers/acpi/acpica/utxfmutex.c
index 0a40a851b354..312299721ba1 100644
--- a/drivers/acpi/acpica/utxfmutex.c
+++ b/drivers/acpi/acpica/utxfmutex.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 7efaeaa53b88..c5cd5b5513e6 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -1111,7 +1111,7 @@ fail:
1111 return result; 1111 return result;
1112} 1112}
1113 1113
1114static int acpi_battery_remove(struct acpi_device *device, int type) 1114static int acpi_battery_remove(struct acpi_device *device)
1115{ 1115{
1116 struct acpi_battery *battery = NULL; 1116 struct acpi_battery *battery = NULL;
1117 1117
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 1f0d457ecbcf..01708a165368 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -178,276 +178,6 @@ int acpi_bus_get_private_data(acpi_handle handle, void **data)
178} 178}
179EXPORT_SYMBOL(acpi_bus_get_private_data); 179EXPORT_SYMBOL(acpi_bus_get_private_data);
180 180
181/* --------------------------------------------------------------------------
182 Power Management
183 -------------------------------------------------------------------------- */
184
185static const char *state_string(int state)
186{
187 switch (state) {
188 case ACPI_STATE_D0:
189 return "D0";
190 case ACPI_STATE_D1:
191 return "D1";
192 case ACPI_STATE_D2:
193 return "D2";
194 case ACPI_STATE_D3_HOT:
195 return "D3hot";
196 case ACPI_STATE_D3_COLD:
197 return "D3";
198 default:
199 return "(unknown)";
200 }
201}
202
203static int __acpi_bus_get_power(struct acpi_device *device, int *state)
204{
205 int result = ACPI_STATE_UNKNOWN;
206
207 if (!device || !state)
208 return -EINVAL;
209
210 if (!device->flags.power_manageable) {
211 /* TBD: Non-recursive algorithm for walking up hierarchy. */
212 *state = device->parent ?
213 device->parent->power.state : ACPI_STATE_D0;
214 goto out;
215 }
216
217 /*
218 * Get the device's power state either directly (via _PSC) or
219 * indirectly (via power resources).
220 */
221 if (device->power.flags.explicit_get) {
222 unsigned long long psc;
223 acpi_status status = acpi_evaluate_integer(device->handle,
224 "_PSC", NULL, &psc);
225 if (ACPI_FAILURE(status))
226 return -ENODEV;
227
228 result = psc;
229 }
230 /* The test below covers ACPI_STATE_UNKNOWN too. */
231 if (result <= ACPI_STATE_D2) {
232 ; /* Do nothing. */
233 } else if (device->power.flags.power_resources) {
234 int error = acpi_power_get_inferred_state(device, &result);
235 if (error)
236 return error;
237 } else if (result == ACPI_STATE_D3_HOT) {
238 result = ACPI_STATE_D3;
239 }
240
241 /*
242 * If we were unsure about the device parent's power state up to this
243 * point, the fact that the device is in D0 implies that the parent has
244 * to be in D0 too.
245 */
246 if (device->parent && device->parent->power.state == ACPI_STATE_UNKNOWN
247 && result == ACPI_STATE_D0)
248 device->parent->power.state = ACPI_STATE_D0;
249
250 *state = result;
251
252 out:
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is %s\n",
254 device->pnp.bus_id, state_string(*state)));
255
256 return 0;
257}
258
259
260/**
261 * acpi_device_set_power - Set power state of an ACPI device.
262 * @device: Device to set the power state of.
263 * @state: New power state to set.
264 *
265 * Callers must ensure that the device is power manageable before using this
266 * function.
267 */
268int acpi_device_set_power(struct acpi_device *device, int state)
269{
270 int result = 0;
271 acpi_status status = AE_OK;
272 char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' };
273
274 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
275 return -EINVAL;
276
277 /* Make sure this is a valid target state */
278
279 if (state == device->power.state) {
280 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at %s\n",
281 state_string(state)));
282 return 0;
283 }
284
285 if (!device->power.states[state].flags.valid) {
286 printk(KERN_WARNING PREFIX "Device does not support %s\n",
287 state_string(state));
288 return -ENODEV;
289 }
290 if (device->parent && (state < device->parent->power.state)) {
291 printk(KERN_WARNING PREFIX
292 "Cannot set device to a higher-powered"
293 " state than parent\n");
294 return -ENODEV;
295 }
296
297 /* For D3cold we should execute _PS3, not _PS4. */
298 if (state == ACPI_STATE_D3_COLD)
299 object_name[3] = '3';
300
301 /*
302 * Transition Power
303 * ----------------
304 * On transitions to a high-powered state we first apply power (via
305 * power resources) then evalute _PSx. Conversly for transitions to
306 * a lower-powered state.
307 */
308 if (state < device->power.state) {
309 if (device->power.state >= ACPI_STATE_D3_HOT &&
310 state != ACPI_STATE_D0) {
311 printk(KERN_WARNING PREFIX
312 "Cannot transition to non-D0 state from D3\n");
313 return -ENODEV;
314 }
315 if (device->power.flags.power_resources) {
316 result = acpi_power_transition(device, state);
317 if (result)
318 goto end;
319 }
320 if (device->power.states[state].flags.explicit_set) {
321 status = acpi_evaluate_object(device->handle,
322 object_name, NULL, NULL);
323 if (ACPI_FAILURE(status)) {
324 result = -ENODEV;
325 goto end;
326 }
327 }
328 } else {
329 if (device->power.states[state].flags.explicit_set) {
330 status = acpi_evaluate_object(device->handle,
331 object_name, NULL, NULL);
332 if (ACPI_FAILURE(status)) {
333 result = -ENODEV;
334 goto end;
335 }
336 }
337 if (device->power.flags.power_resources) {
338 result = acpi_power_transition(device, state);
339 if (result)
340 goto end;
341 }
342 }
343
344 end:
345 if (result)
346 printk(KERN_WARNING PREFIX
347 "Device [%s] failed to transition to %s\n",
348 device->pnp.bus_id, state_string(state));
349 else {
350 device->power.state = state;
351 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
352 "Device [%s] transitioned to %s\n",
353 device->pnp.bus_id, state_string(state)));
354 }
355
356 return result;
357}
358EXPORT_SYMBOL(acpi_device_set_power);
359
360
361int acpi_bus_set_power(acpi_handle handle, int state)
362{
363 struct acpi_device *device;
364 int result;
365
366 result = acpi_bus_get_device(handle, &device);
367 if (result)
368 return result;
369
370 if (!device->flags.power_manageable) {
371 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
372 "Device [%s] is not power manageable\n",
373 dev_name(&device->dev)));
374 return -ENODEV;
375 }
376
377 return acpi_device_set_power(device, state);
378}
379EXPORT_SYMBOL(acpi_bus_set_power);
380
381
382int acpi_bus_init_power(struct acpi_device *device)
383{
384 int state;
385 int result;
386
387 if (!device)
388 return -EINVAL;
389
390 device->power.state = ACPI_STATE_UNKNOWN;
391
392 result = __acpi_bus_get_power(device, &state);
393 if (result)
394 return result;
395
396 if (device->power.flags.power_resources)
397 result = acpi_power_on_resources(device, state);
398
399 if (!result)
400 device->power.state = state;
401
402 return result;
403}
404
405
406int acpi_bus_update_power(acpi_handle handle, int *state_p)
407{
408 struct acpi_device *device;
409 int state;
410 int result;
411
412 result = acpi_bus_get_device(handle, &device);
413 if (result)
414 return result;
415
416 result = __acpi_bus_get_power(device, &state);
417 if (result)
418 return result;
419
420 result = acpi_device_set_power(device, state);
421 if (!result && state_p)
422 *state_p = state;
423
424 return result;
425}
426EXPORT_SYMBOL_GPL(acpi_bus_update_power);
427
428
429bool acpi_bus_power_manageable(acpi_handle handle)
430{
431 struct acpi_device *device;
432 int result;
433
434 result = acpi_bus_get_device(handle, &device);
435 return result ? false : device->flags.power_manageable;
436}
437
438EXPORT_SYMBOL(acpi_bus_power_manageable);
439
440bool acpi_bus_can_wakeup(acpi_handle handle)
441{
442 struct acpi_device *device;
443 int result;
444
445 result = acpi_bus_get_device(handle, &device);
446 return result ? false : device->wakeup.flags.valid;
447}
448
449EXPORT_SYMBOL(acpi_bus_can_wakeup);
450
451static void acpi_print_osc_error(acpi_handle handle, 181static void acpi_print_osc_error(acpi_handle handle,
452 struct acpi_osc_context *context, char *error) 182 struct acpi_osc_context *context, char *error)
453{ 183{
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index f0d936b65e37..86c7d5445c38 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -75,7 +75,7 @@ static const struct acpi_device_id button_device_ids[] = {
75MODULE_DEVICE_TABLE(acpi, button_device_ids); 75MODULE_DEVICE_TABLE(acpi, button_device_ids);
76 76
77static int acpi_button_add(struct acpi_device *device); 77static int acpi_button_add(struct acpi_device *device);
78static int acpi_button_remove(struct acpi_device *device, int type); 78static int acpi_button_remove(struct acpi_device *device);
79static void acpi_button_notify(struct acpi_device *device, u32 event); 79static void acpi_button_notify(struct acpi_device *device, u32 event);
80 80
81#ifdef CONFIG_PM_SLEEP 81#ifdef CONFIG_PM_SLEEP
@@ -433,7 +433,7 @@ static int acpi_button_add(struct acpi_device *device)
433 return error; 433 return error;
434} 434}
435 435
436static int acpi_button_remove(struct acpi_device *device, int type) 436static int acpi_button_remove(struct acpi_device *device)
437{ 437{
438 struct acpi_button *button = acpi_driver_data(device); 438 struct acpi_button *button = acpi_driver_data(device);
439 439
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 811910b50b75..5523ba7d764d 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -34,46 +34,34 @@
34#include <linux/acpi.h> 34#include <linux/acpi.h>
35#include <acpi/acpi_bus.h> 35#include <acpi/acpi_bus.h>
36#include <acpi/acpi_drivers.h> 36#include <acpi/acpi_drivers.h>
37#include <acpi/container.h>
38 37
39#define PREFIX "ACPI: " 38#define PREFIX "ACPI: "
40 39
41#define ACPI_CONTAINER_DEVICE_NAME "ACPI container device"
42#define ACPI_CONTAINER_CLASS "container"
43
44#define INSTALL_NOTIFY_HANDLER 1
45#define UNINSTALL_NOTIFY_HANDLER 2
46
47#define _COMPONENT ACPI_CONTAINER_COMPONENT 40#define _COMPONENT ACPI_CONTAINER_COMPONENT
48ACPI_MODULE_NAME("container"); 41ACPI_MODULE_NAME("container");
49 42
50MODULE_AUTHOR("Anil S Keshavamurthy");
51MODULE_DESCRIPTION("ACPI container driver");
52MODULE_LICENSE("GPL");
53
54static int acpi_container_add(struct acpi_device *device);
55static int acpi_container_remove(struct acpi_device *device, int type);
56
57static const struct acpi_device_id container_device_ids[] = { 43static const struct acpi_device_id container_device_ids[] = {
58 {"ACPI0004", 0}, 44 {"ACPI0004", 0},
59 {"PNP0A05", 0}, 45 {"PNP0A05", 0},
60 {"PNP0A06", 0}, 46 {"PNP0A06", 0},
61 {"", 0}, 47 {"", 0},
62}; 48};
63MODULE_DEVICE_TABLE(acpi, container_device_ids);
64 49
65static struct acpi_driver acpi_container_driver = { 50static int container_device_attach(struct acpi_device *device,
66 .name = "container", 51 const struct acpi_device_id *not_used)
67 .class = ACPI_CONTAINER_CLASS, 52{
53 /*
54 * FIXME: This is necessary, so that acpi_eject_store() doesn't return
55 * -ENODEV for containers.
56 */
57 return 1;
58}
59
60static struct acpi_scan_handler container_device_handler = {
68 .ids = container_device_ids, 61 .ids = container_device_ids,
69 .ops = { 62 .attach = container_device_attach,
70 .add = acpi_container_add,
71 .remove = acpi_container_remove,
72 },
73}; 63};
74 64
75/*******************************************************************/
76
77static int is_device_present(acpi_handle handle) 65static int is_device_present(acpi_handle handle)
78{ 66{
79 acpi_handle temp; 67 acpi_handle temp;
@@ -92,73 +80,6 @@ static int is_device_present(acpi_handle handle)
92 return ((sta & ACPI_STA_DEVICE_PRESENT) == ACPI_STA_DEVICE_PRESENT); 80 return ((sta & ACPI_STA_DEVICE_PRESENT) == ACPI_STA_DEVICE_PRESENT);
93} 81}
94 82
95static bool is_container_device(const char *hid)
96{
97 const struct acpi_device_id *container_id;
98
99 for (container_id = container_device_ids;
100 container_id->id[0]; container_id++) {
101 if (!strcmp((char *)container_id->id, hid))
102 return true;
103 }
104
105 return false;
106}
107
108/*******************************************************************/
109static int acpi_container_add(struct acpi_device *device)
110{
111 struct acpi_container *container;
112
113 container = kzalloc(sizeof(struct acpi_container), GFP_KERNEL);
114 if (!container)
115 return -ENOMEM;
116
117 container->handle = device->handle;
118 strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME);
119 strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS);
120 device->driver_data = container;
121
122 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n",
123 acpi_device_name(device), acpi_device_bid(device)));
124
125 return 0;
126}
127
128static int acpi_container_remove(struct acpi_device *device, int type)
129{
130 acpi_status status = AE_OK;
131 struct acpi_container *pc = NULL;
132
133 pc = acpi_driver_data(device);
134 kfree(pc);
135 return status;
136}
137
138static int container_device_add(struct acpi_device **device, acpi_handle handle)
139{
140 acpi_handle phandle;
141 struct acpi_device *pdev;
142 int result;
143
144
145 if (acpi_get_parent(handle, &phandle)) {
146 return -ENODEV;
147 }
148
149 if (acpi_bus_get_device(phandle, &pdev)) {
150 return -ENODEV;
151 }
152
153 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) {
154 return -ENODEV;
155 }
156
157 result = acpi_bus_start(*device);
158
159 return result;
160}
161
162static void container_notify_cb(acpi_handle handle, u32 type, void *context) 83static void container_notify_cb(acpi_handle handle, u32 type, void *context)
163{ 84{
164 struct acpi_device *device = NULL; 85 struct acpi_device *device = NULL;
@@ -167,6 +88,8 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
167 acpi_status status; 88 acpi_status status;
168 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ 89 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
169 90
91 acpi_scan_lock_acquire();
92
170 switch (type) { 93 switch (type) {
171 case ACPI_NOTIFY_BUS_CHECK: 94 case ACPI_NOTIFY_BUS_CHECK:
172 /* Fall through */ 95 /* Fall through */
@@ -182,7 +105,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
182 /* device exist and this is a remove request */ 105 /* device exist and this is a remove request */
183 device->flags.eject_pending = 1; 106 device->flags.eject_pending = 1;
184 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); 107 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
185 return; 108 goto out;
186 } 109 }
187 break; 110 break;
188 } 111 }
@@ -190,11 +113,16 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
190 if (!ACPI_FAILURE(status) || device) 113 if (!ACPI_FAILURE(status) || device)
191 break; 114 break;
192 115
193 result = container_device_add(&device, handle); 116 result = acpi_bus_scan(handle);
194 if (result) { 117 if (result) {
195 acpi_handle_warn(handle, "Failed to add container\n"); 118 acpi_handle_warn(handle, "Failed to add container\n");
196 break; 119 break;
197 } 120 }
121 result = acpi_bus_get_device(handle, &device);
122 if (result) {
123 acpi_handle_warn(handle, "Missing device object\n");
124 break;
125 }
198 126
199 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); 127 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
200 ost_code = ACPI_OST_SC_SUCCESS; 128 ost_code = ACPI_OST_SC_SUCCESS;
@@ -204,98 +132,59 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
204 if (!acpi_bus_get_device(handle, &device) && device) { 132 if (!acpi_bus_get_device(handle, &device) && device) {
205 device->flags.eject_pending = 1; 133 device->flags.eject_pending = 1;
206 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); 134 kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
207 return; 135 goto out;
208 } 136 }
209 break; 137 break;
210 138
211 default: 139 default:
212 /* non-hotplug event; possibly handled by other handler */ 140 /* non-hotplug event; possibly handled by other handler */
213 return; 141 goto out;
214 } 142 }
215 143
216 /* Inform firmware that the hotplug operation has completed */ 144 /* Inform firmware that the hotplug operation has completed */
217 (void) acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL); 145 (void) acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
218 return; 146
147 out:
148 acpi_scan_lock_release();
219} 149}
220 150
221static acpi_status 151static bool is_container(acpi_handle handle)
222container_walk_namespace_cb(acpi_handle handle,
223 u32 lvl, void *context, void **rv)
224{ 152{
225 char *hid = NULL;
226 struct acpi_device_info *info; 153 struct acpi_device_info *info;
227 acpi_status status; 154 bool ret = false;
228 int *action = context;
229
230 status = acpi_get_object_info(handle, &info);
231 if (ACPI_FAILURE(status)) {
232 return AE_OK;
233 }
234 155
235 if (info->valid & ACPI_VALID_HID) 156 if (ACPI_FAILURE(acpi_get_object_info(handle, &info)))
236 hid = info->hardware_id.string; 157 return false;
237 158
238 if (hid == NULL) { 159 if (info->valid & ACPI_VALID_HID) {
239 goto end; 160 const struct acpi_device_id *id;
240 }
241
242 if (!is_container_device(hid))
243 goto end;
244 161
245 switch (*action) { 162 for (id = container_device_ids; id->id[0]; id++) {
246 case INSTALL_NOTIFY_HANDLER: 163 ret = !strcmp((char *)id->id, info->hardware_id.string);
247 acpi_install_notify_handler(handle, 164 if (ret)
248 ACPI_SYSTEM_NOTIFY, 165 break;
249 container_notify_cb, NULL); 166 }
250 break;
251 case UNINSTALL_NOTIFY_HANDLER:
252 acpi_remove_notify_handler(handle,
253 ACPI_SYSTEM_NOTIFY,
254 container_notify_cb);
255 break;
256 default:
257 break;
258 } 167 }
259
260 end:
261 kfree(info); 168 kfree(info);
262 169 return ret;
263 return AE_OK;
264} 170}
265 171
266static int __init acpi_container_init(void) 172static acpi_status acpi_container_register_notify_handler(acpi_handle handle,
173 u32 lvl, void *ctxt,
174 void **retv)
267{ 175{
268 int result = 0; 176 if (is_container(handle))
269 int action = INSTALL_NOTIFY_HANDLER; 177 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
270 178 container_notify_cb, NULL);
271 result = acpi_bus_register_driver(&acpi_container_driver);
272 if (result < 0) {
273 return (result);
274 }
275
276 /* register notify handler to every container device */
277 acpi_walk_namespace(ACPI_TYPE_DEVICE,
278 ACPI_ROOT_OBJECT,
279 ACPI_UINT32_MAX,
280 container_walk_namespace_cb, NULL, &action, NULL);
281 179
282 return (0); 180 return AE_OK;
283} 181}
284 182
285static void __exit acpi_container_exit(void) 183void __init acpi_container_init(void)
286{ 184{
287 int action = UNINSTALL_NOTIFY_HANDLER; 185 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
186 acpi_container_register_notify_handler, NULL,
187 NULL, NULL);
288 188
289 189 acpi_scan_add_handler(&container_device_handler);
290 acpi_walk_namespace(ACPI_TYPE_DEVICE,
291 ACPI_ROOT_OBJECT,
292 ACPI_UINT32_MAX,
293 container_walk_namespace_cb, NULL, &action, NULL);
294
295 acpi_bus_unregister_driver(&acpi_container_driver);
296
297 return;
298} 190}
299
300module_init(acpi_container_init);
301module_exit(acpi_container_exit);
diff --git a/drivers/acpi/csrt.c b/drivers/acpi/csrt.c
new file mode 100644
index 000000000000..5c15a91faf0b
--- /dev/null
+++ b/drivers/acpi/csrt.c
@@ -0,0 +1,159 @@
1/*
2 * Support for Core System Resources Table (CSRT)
3 *
4 * Copyright (C) 2013, Intel Corporation
5 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
6 * Andy Shevchenko <andriy.shevchenko@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#define pr_fmt(fmt) "ACPI: CSRT: " fmt
14
15#include <linux/acpi.h>
16#include <linux/device.h>
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20#include <linux/sizes.h>
21
22ACPI_MODULE_NAME("CSRT");
23
24static int __init acpi_csrt_parse_shared_info(struct platform_device *pdev,
25 const struct acpi_csrt_group *grp)
26{
27 const struct acpi_csrt_shared_info *si;
28 struct resource res[3];
29 size_t nres;
30 int ret;
31
32 memset(res, 0, sizeof(res));
33 nres = 0;
34
35 si = (const struct acpi_csrt_shared_info *)&grp[1];
36 /*
37 * The peripherals that are listed on CSRT typically support only
38 * 32-bit addresses so we only use the low part of MMIO base for
39 * now.
40 */
41 if (!si->mmio_base_high && si->mmio_base_low) {
42 /*
43 * There is no size of the memory resource in shared_info
44 * so we assume that it is 4k here.
45 */
46 res[nres].start = si->mmio_base_low;
47 res[nres].end = res[0].start + SZ_4K - 1;
48 res[nres++].flags = IORESOURCE_MEM;
49 }
50
51 if (si->gsi_interrupt) {
52 int irq = acpi_register_gsi(NULL, si->gsi_interrupt,
53 si->interrupt_mode,
54 si->interrupt_polarity);
55 res[nres].start = irq;
56 res[nres].end = irq;
57 res[nres++].flags = IORESOURCE_IRQ;
58 }
59
60 if (si->base_request_line || si->num_handshake_signals) {
61 /*
62 * We pass the driver a DMA resource describing the range
63 * of request lines the device supports.
64 */
65 res[nres].start = si->base_request_line;
66 res[nres].end = res[nres].start + si->num_handshake_signals - 1;
67 res[nres++].flags = IORESOURCE_DMA;
68 }
69
70 ret = platform_device_add_resources(pdev, res, nres);
71 if (ret) {
72 if (si->gsi_interrupt)
73 acpi_unregister_gsi(si->gsi_interrupt);
74 return ret;
75 }
76
77 return 0;
78}
79
80static int __init
81acpi_csrt_parse_resource_group(const struct acpi_csrt_group *grp)
82{
83 struct platform_device *pdev;
84 char vendor[5], name[16];
85 int ret, i;
86
87 vendor[0] = grp->vendor_id;
88 vendor[1] = grp->vendor_id >> 8;
89 vendor[2] = grp->vendor_id >> 16;
90 vendor[3] = grp->vendor_id >> 24;
91 vendor[4] = '\0';
92
93 if (grp->shared_info_length != sizeof(struct acpi_csrt_shared_info))
94 return -ENODEV;
95
96 snprintf(name, sizeof(name), "%s%04X", vendor, grp->device_id);
97 pdev = platform_device_alloc(name, PLATFORM_DEVID_AUTO);
98 if (!pdev)
99 return -ENOMEM;
100
101 /* Add resources based on the shared info */
102 ret = acpi_csrt_parse_shared_info(pdev, grp);
103 if (ret)
104 goto fail;
105
106 ret = platform_device_add(pdev);
107 if (ret)
108 goto fail;
109
110 for (i = 0; i < pdev->num_resources; i++)
111 dev_dbg(&pdev->dev, "%pR\n", &pdev->resource[i]);
112
113 return 0;
114
115fail:
116 platform_device_put(pdev);
117 return ret;
118}
119
120/*
121 * CSRT or Core System Resources Table is a proprietary ACPI table
122 * introduced by Microsoft. This table can contain devices that are not in
123 * the system DSDT table. In particular DMA controllers might be described
124 * here.
125 *
126 * We present these devices as normal platform devices that don't have ACPI
127 * IDs or handle. The platform device name will be something like
128 * <VENDOR><DEVID>.<n>.auto for example: INTL9C06.0.auto.
129 */
130void __init acpi_csrt_init(void)
131{
132 struct acpi_csrt_group *grp, *end;
133 struct acpi_table_csrt *csrt;
134 acpi_status status;
135 int ret;
136
137 status = acpi_get_table(ACPI_SIG_CSRT, 0,
138 (struct acpi_table_header **)&csrt);
139 if (ACPI_FAILURE(status)) {
140 if (status != AE_NOT_FOUND)
141 pr_warn("failed to get the CSRT table\n");
142 return;
143 }
144
145 pr_debug("parsing CSRT table for devices\n");
146
147 grp = (struct acpi_csrt_group *)(csrt + 1);
148 end = (struct acpi_csrt_group *)((void *)csrt + csrt->header.length);
149
150 while (grp < end) {
151 ret = acpi_csrt_parse_resource_group(grp);
152 if (ret) {
153 pr_warn("error in parsing resource group: %d\n", ret);
154 return;
155 }
156
157 grp = (struct acpi_csrt_group *)((void *)grp + grp->length);
158 }
159}
diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index 5d42c2414ae5..6adfc706a1de 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * debugfs.c - ACPI debugfs interface to userspace. 2 * custom_method.c - debugfs interface for customizing ACPI control method
3 */ 3 */
4 4
5#include <linux/init.h> 5#include <linux/init.h>
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index c6ff606c6d5b..dd314ef9bff1 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -30,6 +30,12 @@
30 30
31#include <acpi/acpi.h> 31#include <acpi/acpi.h>
32#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
33#include <acpi/acpi_drivers.h>
34
35#include "internal.h"
36
37#define _COMPONENT ACPI_POWER_COMPONENT
38ACPI_MODULE_NAME("device_pm");
33 39
34static DEFINE_MUTEX(acpi_pm_notifier_lock); 40static DEFINE_MUTEX(acpi_pm_notifier_lock);
35 41
@@ -94,6 +100,293 @@ acpi_status acpi_remove_pm_notifier(struct acpi_device *adev,
94} 100}
95 101
96/** 102/**
103 * acpi_power_state_string - String representation of ACPI device power state.
104 * @state: ACPI device power state to return the string representation of.
105 */
106const char *acpi_power_state_string(int state)
107{
108 switch (state) {
109 case ACPI_STATE_D0:
110 return "D0";
111 case ACPI_STATE_D1:
112 return "D1";
113 case ACPI_STATE_D2:
114 return "D2";
115 case ACPI_STATE_D3_HOT:
116 return "D3hot";
117 case ACPI_STATE_D3_COLD:
118 return "D3cold";
119 default:
120 return "(unknown)";
121 }
122}
123
124/**
125 * acpi_device_get_power - Get power state of an ACPI device.
126 * @device: Device to get the power state of.
127 * @state: Place to store the power state of the device.
128 *
129 * This function does not update the device's power.state field, but it may
130 * update its parent's power.state field (when the parent's power state is
131 * unknown and the device's power state turns out to be D0).
132 */
133int acpi_device_get_power(struct acpi_device *device, int *state)
134{
135 int result = ACPI_STATE_UNKNOWN;
136
137 if (!device || !state)
138 return -EINVAL;
139
140 if (!device->flags.power_manageable) {
141 /* TBD: Non-recursive algorithm for walking up hierarchy. */
142 *state = device->parent ?
143 device->parent->power.state : ACPI_STATE_D0;
144 goto out;
145 }
146
147 /*
148 * Get the device's power state either directly (via _PSC) or
149 * indirectly (via power resources).
150 */
151 if (device->power.flags.explicit_get) {
152 unsigned long long psc;
153 acpi_status status = acpi_evaluate_integer(device->handle,
154 "_PSC", NULL, &psc);
155 if (ACPI_FAILURE(status))
156 return -ENODEV;
157
158 result = psc;
159 }
160 /* The test below covers ACPI_STATE_UNKNOWN too. */
161 if (result <= ACPI_STATE_D2) {
162 ; /* Do nothing. */
163 } else if (device->power.flags.power_resources) {
164 int error = acpi_power_get_inferred_state(device, &result);
165 if (error)
166 return error;
167 } else if (result == ACPI_STATE_D3_HOT) {
168 result = ACPI_STATE_D3;
169 }
170
171 /*
172 * If we were unsure about the device parent's power state up to this
173 * point, the fact that the device is in D0 implies that the parent has
174 * to be in D0 too.
175 */
176 if (device->parent && device->parent->power.state == ACPI_STATE_UNKNOWN
177 && result == ACPI_STATE_D0)
178 device->parent->power.state = ACPI_STATE_D0;
179
180 *state = result;
181
182 out:
183 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is %s\n",
184 device->pnp.bus_id, acpi_power_state_string(*state)));
185
186 return 0;
187}
188
189static int acpi_dev_pm_explicit_set(struct acpi_device *adev, int state)
190{
191 if (adev->power.states[state].flags.explicit_set) {
192 char method[5] = { '_', 'P', 'S', '0' + state, '\0' };
193 acpi_status status;
194
195 status = acpi_evaluate_object(adev->handle, method, NULL, NULL);
196 if (ACPI_FAILURE(status))
197 return -ENODEV;
198 }
199 return 0;
200}
201
202/**
203 * acpi_device_set_power - Set power state of an ACPI device.
204 * @device: Device to set the power state of.
205 * @state: New power state to set.
206 *
207 * Callers must ensure that the device is power manageable before using this
208 * function.
209 */
210int acpi_device_set_power(struct acpi_device *device, int state)
211{
212 int result = 0;
213 bool cut_power = false;
214
215 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
216 return -EINVAL;
217
218 /* Make sure this is a valid target state */
219
220 if (state == device->power.state) {
221 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at %s\n",
222 acpi_power_state_string(state)));
223 return 0;
224 }
225
226 if (!device->power.states[state].flags.valid) {
227 printk(KERN_WARNING PREFIX "Device does not support %s\n",
228 acpi_power_state_string(state));
229 return -ENODEV;
230 }
231 if (device->parent && (state < device->parent->power.state)) {
232 printk(KERN_WARNING PREFIX
233 "Cannot set device to a higher-powered"
234 " state than parent\n");
235 return -ENODEV;
236 }
237
238 /* For D3cold we should first transition into D3hot. */
239 if (state == ACPI_STATE_D3_COLD
240 && device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible) {
241 state = ACPI_STATE_D3_HOT;
242 cut_power = true;
243 }
244
245 if (state < device->power.state && state != ACPI_STATE_D0
246 && device->power.state >= ACPI_STATE_D3_HOT) {
247 printk(KERN_WARNING PREFIX
248 "Cannot transition to non-D0 state from D3\n");
249 return -ENODEV;
250 }
251
252 /*
253 * Transition Power
254 * ----------------
255 * In accordance with the ACPI specification first apply power (via
256 * power resources) and then evalute _PSx.
257 */
258 if (device->power.flags.power_resources) {
259 result = acpi_power_transition(device, state);
260 if (result)
261 goto end;
262 }
263 result = acpi_dev_pm_explicit_set(device, state);
264 if (result)
265 goto end;
266
267 if (cut_power) {
268 device->power.state = state;
269 state = ACPI_STATE_D3_COLD;
270 result = acpi_power_transition(device, state);
271 }
272
273 end:
274 if (result) {
275 printk(KERN_WARNING PREFIX
276 "Device [%s] failed to transition to %s\n",
277 device->pnp.bus_id,
278 acpi_power_state_string(state));
279 } else {
280 device->power.state = state;
281 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
282 "Device [%s] transitioned to %s\n",
283 device->pnp.bus_id,
284 acpi_power_state_string(state)));
285 }
286
287 return result;
288}
289EXPORT_SYMBOL(acpi_device_set_power);
290
291int acpi_bus_set_power(acpi_handle handle, int state)
292{
293 struct acpi_device *device;
294 int result;
295
296 result = acpi_bus_get_device(handle, &device);
297 if (result)
298 return result;
299
300 if (!device->flags.power_manageable) {
301 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
302 "Device [%s] is not power manageable\n",
303 dev_name(&device->dev)));
304 return -ENODEV;
305 }
306
307 return acpi_device_set_power(device, state);
308}
309EXPORT_SYMBOL(acpi_bus_set_power);
310
311int acpi_bus_init_power(struct acpi_device *device)
312{
313 int state;
314 int result;
315
316 if (!device)
317 return -EINVAL;
318
319 device->power.state = ACPI_STATE_UNKNOWN;
320
321 result = acpi_device_get_power(device, &state);
322 if (result)
323 return result;
324
325 if (state < ACPI_STATE_D3_COLD && device->power.flags.power_resources) {
326 result = acpi_power_on_resources(device, state);
327 if (result)
328 return result;
329
330 result = acpi_dev_pm_explicit_set(device, state);
331 if (result)
332 return result;
333 } else if (state == ACPI_STATE_UNKNOWN) {
334 /* No power resources and missing _PSC? Try to force D0. */
335 state = ACPI_STATE_D0;
336 result = acpi_dev_pm_explicit_set(device, state);
337 if (result)
338 return result;
339 }
340 device->power.state = state;
341 return 0;
342}
343
344int acpi_bus_update_power(acpi_handle handle, int *state_p)
345{
346 struct acpi_device *device;
347 int state;
348 int result;
349
350 result = acpi_bus_get_device(handle, &device);
351 if (result)
352 return result;
353
354 result = acpi_device_get_power(device, &state);
355 if (result)
356 return result;
357
358 if (state == ACPI_STATE_UNKNOWN)
359 state = ACPI_STATE_D0;
360
361 result = acpi_device_set_power(device, state);
362 if (!result && state_p)
363 *state_p = state;
364
365 return result;
366}
367EXPORT_SYMBOL_GPL(acpi_bus_update_power);
368
369bool acpi_bus_power_manageable(acpi_handle handle)
370{
371 struct acpi_device *device;
372 int result;
373
374 result = acpi_bus_get_device(handle, &device);
375 return result ? false : device->flags.power_manageable;
376}
377EXPORT_SYMBOL(acpi_bus_power_manageable);
378
379bool acpi_bus_can_wakeup(acpi_handle handle)
380{
381 struct acpi_device *device;
382 int result;
383
384 result = acpi_bus_get_device(handle, &device);
385 return result ? false : device->wakeup.flags.valid;
386}
387EXPORT_SYMBOL(acpi_bus_can_wakeup);
388
389/**
97 * acpi_device_power_state - Get preferred power state of ACPI device. 390 * acpi_device_power_state - Get preferred power state of ACPI device.
98 * @dev: Device whose preferred target power state to return. 391 * @dev: Device whose preferred target power state to return.
99 * @adev: ACPI device node corresponding to @dev. 392 * @adev: ACPI device node corresponding to @dev.
@@ -213,7 +506,7 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
213 acpi_handle handle = DEVICE_ACPI_HANDLE(dev); 506 acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
214 struct acpi_device *adev; 507 struct acpi_device *adev;
215 508
216 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { 509 if (!handle || acpi_bus_get_device(handle, &adev)) {
217 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); 510 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
218 return -ENODEV; 511 return -ENODEV;
219 } 512 }
@@ -290,7 +583,7 @@ int acpi_pm_device_run_wake(struct device *phys_dev, bool enable)
290 return -EINVAL; 583 return -EINVAL;
291 584
292 handle = DEVICE_ACPI_HANDLE(phys_dev); 585 handle = DEVICE_ACPI_HANDLE(phys_dev);
293 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { 586 if (!handle || acpi_bus_get_device(handle, &adev)) {
294 dev_dbg(phys_dev, "ACPI handle without context in %s!\n", 587 dev_dbg(phys_dev, "ACPI handle without context in %s!\n",
295 __func__); 588 __func__);
296 return -ENODEV; 589 return -ENODEV;
@@ -304,7 +597,7 @@ static inline void acpi_wakeup_device(acpi_handle handle, u32 event,
304 void *context) {} 597 void *context) {}
305#endif /* CONFIG_PM_RUNTIME */ 598#endif /* CONFIG_PM_RUNTIME */
306 599
307 #ifdef CONFIG_PM_SLEEP 600#ifdef CONFIG_PM_SLEEP
308/** 601/**
309 * __acpi_device_sleep_wake - Enable or disable device to wake up the system. 602 * __acpi_device_sleep_wake - Enable or disable device to wake up the system.
310 * @dev: Device to enable/desible to wake up the system. 603 * @dev: Device to enable/desible to wake up the system.
@@ -334,7 +627,7 @@ int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
334 return -EINVAL; 627 return -EINVAL;
335 628
336 handle = DEVICE_ACPI_HANDLE(dev); 629 handle = DEVICE_ACPI_HANDLE(dev);
337 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { 630 if (!handle || acpi_bus_get_device(handle, &adev)) {
338 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); 631 dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
339 return -ENODEV; 632 return -ENODEV;
340 } 633 }
@@ -353,7 +646,7 @@ int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
353 * acpi_dev_pm_get_node - Get ACPI device node for the given physical device. 646 * acpi_dev_pm_get_node - Get ACPI device node for the given physical device.
354 * @dev: Device to get the ACPI node for. 647 * @dev: Device to get the ACPI node for.
355 */ 648 */
356static struct acpi_device *acpi_dev_pm_get_node(struct device *dev) 649struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
357{ 650{
358 acpi_handle handle = DEVICE_ACPI_HANDLE(dev); 651 acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
359 struct acpi_device *adev; 652 struct acpi_device *adev;
@@ -665,3 +958,59 @@ void acpi_dev_pm_detach(struct device *dev, bool power_off)
665 } 958 }
666} 959}
667EXPORT_SYMBOL_GPL(acpi_dev_pm_detach); 960EXPORT_SYMBOL_GPL(acpi_dev_pm_detach);
961
962/**
963 * acpi_dev_pm_add_dependent - Add physical device depending for PM.
964 * @handle: Handle of ACPI device node.
965 * @depdev: Device depending on that node for PM.
966 */
967void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev)
968{
969 struct acpi_device_physical_node *dep;
970 struct acpi_device *adev;
971
972 if (!depdev || acpi_bus_get_device(handle, &adev))
973 return;
974
975 mutex_lock(&adev->physical_node_lock);
976
977 list_for_each_entry(dep, &adev->power_dependent, node)
978 if (dep->dev == depdev)
979 goto out;
980
981 dep = kzalloc(sizeof(*dep), GFP_KERNEL);
982 if (dep) {
983 dep->dev = depdev;
984 list_add_tail(&dep->node, &adev->power_dependent);
985 }
986
987 out:
988 mutex_unlock(&adev->physical_node_lock);
989}
990EXPORT_SYMBOL_GPL(acpi_dev_pm_add_dependent);
991
992/**
993 * acpi_dev_pm_remove_dependent - Remove physical device depending for PM.
994 * @handle: Handle of ACPI device node.
995 * @depdev: Device depending on that node for PM.
996 */
997void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev)
998{
999 struct acpi_device_physical_node *dep;
1000 struct acpi_device *adev;
1001
1002 if (!depdev || acpi_bus_get_device(handle, &adev))
1003 return;
1004
1005 mutex_lock(&adev->physical_node_lock);
1006
1007 list_for_each_entry(dep, &adev->power_dependent, node)
1008 if (dep->dev == depdev) {
1009 list_del(&dep->node);
1010 kfree(dep);
1011 break;
1012 }
1013
1014 mutex_unlock(&adev->physical_node_lock);
1015}
1016EXPORT_SYMBOL_GPL(acpi_dev_pm_remove_dependent);
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index f32bd47b35e0..4fdea381ef21 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -310,8 +310,6 @@ static int dock_present(struct dock_station *ds)
310static struct acpi_device * dock_create_acpi_device(acpi_handle handle) 310static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
311{ 311{
312 struct acpi_device *device; 312 struct acpi_device *device;
313 struct acpi_device *parent_device;
314 acpi_handle parent;
315 int ret; 313 int ret;
316 314
317 if (acpi_bus_get_device(handle, &device)) { 315 if (acpi_bus_get_device(handle, &device)) {
@@ -319,16 +317,11 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
319 * no device created for this object, 317 * no device created for this object,
320 * so we should create one. 318 * so we should create one.
321 */ 319 */
322 acpi_get_parent(handle, &parent); 320 ret = acpi_bus_scan(handle);
323 if (acpi_bus_get_device(parent, &parent_device)) 321 if (ret)
324 parent_device = NULL;
325
326 ret = acpi_bus_add(&device, parent_device, handle,
327 ACPI_BUS_TYPE_DEVICE);
328 if (ret) {
329 pr_debug("error adding bus, %x\n", -ret); 322 pr_debug("error adding bus, %x\n", -ret);
330 return NULL; 323
331 } 324 acpi_bus_get_device(handle, &device);
332 } 325 }
333 return device; 326 return device;
334} 327}
@@ -343,13 +336,9 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
343static void dock_remove_acpi_device(acpi_handle handle) 336static void dock_remove_acpi_device(acpi_handle handle)
344{ 337{
345 struct acpi_device *device; 338 struct acpi_device *device;
346 int ret;
347 339
348 if (!acpi_bus_get_device(handle, &device)) { 340 if (!acpi_bus_get_device(handle, &device))
349 ret = acpi_bus_trim(device, 1); 341 acpi_bus_trim(device);
350 if (ret)
351 pr_debug("error removing bus, %x\n", -ret);
352 }
353} 342}
354 343
355/** 344/**
@@ -755,7 +744,9 @@ static void acpi_dock_deferred_cb(void *context)
755{ 744{
756 struct dock_data *data = context; 745 struct dock_data *data = context;
757 746
747 acpi_scan_lock_acquire();
758 dock_notify(data->handle, data->event, data->ds); 748 dock_notify(data->handle, data->event, data->ds);
749 acpi_scan_lock_release();
759 kfree(data); 750 kfree(data);
760} 751}
761 752
@@ -768,20 +759,31 @@ static int acpi_dock_notifier_call(struct notifier_block *this,
768 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK 759 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
769 && event != ACPI_NOTIFY_EJECT_REQUEST) 760 && event != ACPI_NOTIFY_EJECT_REQUEST)
770 return 0; 761 return 0;
762
763 acpi_scan_lock_acquire();
764
771 list_for_each_entry(dock_station, &dock_stations, sibling) { 765 list_for_each_entry(dock_station, &dock_stations, sibling) {
772 if (dock_station->handle == handle) { 766 if (dock_station->handle == handle) {
773 struct dock_data *dd; 767 struct dock_data *dd;
768 acpi_status status;
774 769
775 dd = kmalloc(sizeof(*dd), GFP_KERNEL); 770 dd = kmalloc(sizeof(*dd), GFP_KERNEL);
776 if (!dd) 771 if (!dd)
777 return 0; 772 break;
773
778 dd->handle = handle; 774 dd->handle = handle;
779 dd->event = event; 775 dd->event = event;
780 dd->ds = dock_station; 776 dd->ds = dock_station;
781 acpi_os_hotplug_execute(acpi_dock_deferred_cb, dd); 777 status = acpi_os_hotplug_execute(acpi_dock_deferred_cb,
782 return 0 ; 778 dd);
779 if (ACPI_FAILURE(status))
780 kfree(dd);
781
782 break;
783 } 783 }
784 } 784 }
785
786 acpi_scan_lock_release();
785 return 0; 787 return 0;
786} 788}
787 789
@@ -836,7 +838,7 @@ static ssize_t show_docked(struct device *dev,
836 838
837 struct dock_station *dock_station = dev->platform_data; 839 struct dock_station *dock_station = dev->platform_data;
838 840
839 if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp))) 841 if (!acpi_bus_get_device(dock_station->handle, &tmp))
840 return snprintf(buf, PAGE_SIZE, "1\n"); 842 return snprintf(buf, PAGE_SIZE, "1\n");
841 return snprintf(buf, PAGE_SIZE, "0\n"); 843 return snprintf(buf, PAGE_SIZE, "0\n");
842} 844}
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 354007d490d1..d45b2871d33b 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -852,7 +852,7 @@ static int acpi_ec_add(struct acpi_device *device)
852 return ret; 852 return ret;
853} 853}
854 854
855static int acpi_ec_remove(struct acpi_device *device, int type) 855static int acpi_ec_remove(struct acpi_device *device)
856{ 856{
857 struct acpi_ec *ec; 857 struct acpi_ec *ec;
858 struct acpi_ec_query_handler *handler, *tmp; 858 struct acpi_ec_query_handler *handler, *tmp;
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 3bd6a54702d6..f815da82c765 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -45,7 +45,7 @@ MODULE_DESCRIPTION("ACPI Fan Driver");
45MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
46 46
47static int acpi_fan_add(struct acpi_device *device); 47static int acpi_fan_add(struct acpi_device *device);
48static int acpi_fan_remove(struct acpi_device *device, int type); 48static int acpi_fan_remove(struct acpi_device *device);
49 49
50static const struct acpi_device_id fan_device_ids[] = { 50static const struct acpi_device_id fan_device_ids[] = {
51 {"PNP0C0B", 0}, 51 {"PNP0C0B", 0},
@@ -172,7 +172,7 @@ static int acpi_fan_add(struct acpi_device *device)
172 return result; 172 return result;
173} 173}
174 174
175static int acpi_fan_remove(struct acpi_device *device, int type) 175static 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 = acpi_driver_data(device);
178 178
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 35da18113216..ef6f155469b5 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -68,6 +68,9 @@ static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
68{ 68{
69 struct acpi_bus_type *tmp, *ret = NULL; 69 struct acpi_bus_type *tmp, *ret = NULL;
70 70
71 if (!type)
72 return NULL;
73
71 down_read(&bus_type_sem); 74 down_read(&bus_type_sem);
72 list_for_each_entry(tmp, &bus_type_list, list) { 75 list_for_each_entry(tmp, &bus_type_list, list) {
73 if (tmp->bus == type) { 76 if (tmp->bus == type) {
@@ -95,40 +98,31 @@ static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle)
95 return ret; 98 return ret;
96} 99}
97 100
98/* Get device's handler per its address under its parent */ 101static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used,
99struct acpi_find_child { 102 void *addr_p, void **ret_p)
100 acpi_handle handle;
101 u64 address;
102};
103
104static acpi_status
105do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv)
106{ 103{
104 unsigned long long addr;
107 acpi_status status; 105 acpi_status status;
108 struct acpi_device_info *info; 106
109 struct acpi_find_child *find = context; 107 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr);
110 108 if (ACPI_SUCCESS(status) && addr == *((u64 *)addr_p)) {
111 status = acpi_get_object_info(handle, &info); 109 *ret_p = handle;
112 if (ACPI_SUCCESS(status)) { 110 return AE_CTRL_TERMINATE;
113 if ((info->address == find->address)
114 && (info->valid & ACPI_VALID_ADR))
115 find->handle = handle;
116 kfree(info);
117 } 111 }
118 return AE_OK; 112 return AE_OK;
119} 113}
120 114
121acpi_handle acpi_get_child(acpi_handle parent, u64 address) 115acpi_handle acpi_get_child(acpi_handle parent, u64 address)
122{ 116{
123 struct acpi_find_child find = { NULL, address }; 117 void *ret = NULL;
124 118
125 if (!parent) 119 if (!parent)
126 return NULL; 120 return NULL;
127 acpi_walk_namespace(ACPI_TYPE_DEVICE, parent,
128 1, do_acpi_find_child, NULL, &find, NULL);
129 return find.handle;
130}
131 121
122 acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, NULL,
123 do_acpi_find_child, &address, &ret);
124 return (acpi_handle)ret;
125}
132EXPORT_SYMBOL(acpi_get_child); 126EXPORT_SYMBOL(acpi_get_child);
133 127
134static int acpi_bind_one(struct device *dev, acpi_handle handle) 128static int acpi_bind_one(struct device *dev, acpi_handle handle)
@@ -269,28 +263,39 @@ static int acpi_platform_notify(struct device *dev)
269{ 263{
270 struct acpi_bus_type *type; 264 struct acpi_bus_type *type;
271 acpi_handle handle; 265 acpi_handle handle;
272 int ret = -EINVAL; 266 int ret;
273 267
274 ret = acpi_bind_one(dev, NULL); 268 ret = acpi_bind_one(dev, NULL);
275 if (!ret) 269 if (ret && (!dev->bus || !dev->parent)) {
276 goto out;
277
278 if (!dev->bus || !dev->parent) {
279 /* bridge devices genernally haven't bus or parent */ 270 /* bridge devices genernally haven't bus or parent */
280 ret = acpi_find_bridge_device(dev, &handle); 271 ret = acpi_find_bridge_device(dev, &handle);
281 goto end; 272 if (!ret) {
273 ret = acpi_bind_one(dev, handle);
274 if (ret)
275 goto out;
276 }
282 } 277 }
278
283 type = acpi_get_bus_type(dev->bus); 279 type = acpi_get_bus_type(dev->bus);
284 if (!type) { 280 if (ret) {
285 DBG("No ACPI bus support for %s\n", dev_name(dev)); 281 if (!type || !type->find_device) {
286 ret = -EINVAL; 282 DBG("No ACPI bus support for %s\n", dev_name(dev));
287 goto end; 283 ret = -EINVAL;
284 goto out;
285 }
286
287 ret = type->find_device(dev, &handle);
288 if (ret) {
289 DBG("Unable to get handle for %s\n", dev_name(dev));
290 goto out;
291 }
292 ret = acpi_bind_one(dev, handle);
293 if (ret)
294 goto out;
288 } 295 }
289 if ((ret = type->find_device(dev, &handle)) != 0) 296
290 DBG("Can't get handler for %s\n", dev_name(dev)); 297 if (type && type->setup)
291 end: 298 type->setup(dev);
292 if (!ret)
293 acpi_bind_one(dev, handle);
294 299
295 out: 300 out:
296#if ACPI_GLUE_DEBUG 301#if ACPI_GLUE_DEBUG
@@ -309,6 +314,12 @@ static int acpi_platform_notify(struct device *dev)
309 314
310static int acpi_platform_notify_remove(struct device *dev) 315static int acpi_platform_notify_remove(struct device *dev)
311{ 316{
317 struct acpi_bus_type *type;
318
319 type = acpi_get_bus_type(dev->bus);
320 if (type && type->cleanup)
321 type->cleanup(dev);
322
312 acpi_unbind_one(dev); 323 acpi_unbind_one(dev);
313 return 0; 324 return 0;
314} 325}
diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c
index a0cc796932f7..13b1d39d7cdf 100644
--- a/drivers/acpi/hed.c
+++ b/drivers/acpi/hed.c
@@ -70,7 +70,7 @@ static int acpi_hed_add(struct acpi_device *device)
70 return 0; 70 return 0;
71} 71}
72 72
73static int acpi_hed_remove(struct acpi_device *device, int type) 73static int acpi_hed_remove(struct acpi_device *device)
74{ 74{
75 hed_handle = NULL; 75 hed_handle = NULL;
76 return 0; 76 return 0;
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 3c407cdc1ec1..79092328cf06 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -25,7 +25,16 @@
25 25
26int init_acpi_device_notify(void); 26int init_acpi_device_notify(void);
27int acpi_scan_init(void); 27int acpi_scan_init(void);
28void acpi_pci_root_init(void);
29void acpi_pci_link_init(void);
30void acpi_platform_init(void);
28int acpi_sysfs_init(void); 31int acpi_sysfs_init(void);
32void acpi_csrt_init(void);
33#ifdef CONFIG_ACPI_CONTAINER
34void acpi_container_init(void);
35#else
36static inline void acpi_container_init(void) {}
37#endif
29 38
30#ifdef CONFIG_DEBUG_FS 39#ifdef CONFIG_DEBUG_FS
31extern struct dentry *acpi_debugfs_dir; 40extern struct dentry *acpi_debugfs_dir;
@@ -35,15 +44,33 @@ static inline void acpi_debugfs_init(void) { return; }
35#endif 44#endif
36 45
37/* -------------------------------------------------------------------------- 46/* --------------------------------------------------------------------------
47 Device Node Initialization / Removal
48 -------------------------------------------------------------------------- */
49#define ACPI_STA_DEFAULT (ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | \
50 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING)
51
52int acpi_device_add(struct acpi_device *device,
53 void (*release)(struct device *));
54void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
55 int type, unsigned long long sta);
56void acpi_device_add_finalize(struct acpi_device *device);
57void acpi_free_ids(struct acpi_device *device);
58
59/* --------------------------------------------------------------------------
38 Power Resource 60 Power Resource
39 -------------------------------------------------------------------------- */ 61 -------------------------------------------------------------------------- */
40int acpi_power_init(void); 62int acpi_power_init(void);
63void acpi_power_resources_list_free(struct list_head *list);
64int acpi_extract_power_resources(union acpi_object *package, unsigned int start,
65 struct list_head *list);
66int acpi_add_power_resource(acpi_handle handle);
67void acpi_power_add_remove_device(struct acpi_device *adev, bool add);
68int acpi_power_min_system_level(struct list_head *list);
41int acpi_device_sleep_wake(struct acpi_device *dev, 69int acpi_device_sleep_wake(struct acpi_device *dev,
42 int enable, int sleep_state, int dev_state); 70 int enable, int sleep_state, int dev_state);
43int acpi_power_get_inferred_state(struct acpi_device *device, int *state); 71int acpi_power_get_inferred_state(struct acpi_device *device, int *state);
44int acpi_power_on_resources(struct acpi_device *device, int state); 72int acpi_power_on_resources(struct acpi_device *device, int state);
45int acpi_power_transition(struct acpi_device *device, int state); 73int acpi_power_transition(struct acpi_device *device, int state);
46int acpi_bus_init_power(struct acpi_device *device);
47 74
48int acpi_wakeup_device_init(void); 75int acpi_wakeup_device_init(void);
49void acpi_early_processor_set_pdc(void); 76void acpi_early_processor_set_pdc(void);
@@ -98,6 +125,4 @@ static inline void suspend_nvs_restore(void) {}
98 -------------------------------------------------------------------------- */ 125 -------------------------------------------------------------------------- */
99struct platform_device; 126struct platform_device;
100 127
101struct platform_device *acpi_create_platform_device(struct acpi_device *adev);
102
103#endif /* _ACPI_INTERNAL_H_ */ 128#endif /* _ACPI_INTERNAL_H_ */
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index cb31298ca684..33e609f63585 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -116,14 +116,16 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header)
116 struct acpi_srat_mem_affinity *p = 116 struct acpi_srat_mem_affinity *p =
117 (struct acpi_srat_mem_affinity *)header; 117 (struct acpi_srat_mem_affinity *)header;
118 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 118 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
119 "SRAT Memory (0x%lx length 0x%lx) in proximity domain %d %s%s\n", 119 "SRAT Memory (0x%lx length 0x%lx) in proximity domain %d %s%s%s\n",
120 (unsigned long)p->base_address, 120 (unsigned long)p->base_address,
121 (unsigned long)p->length, 121 (unsigned long)p->length,
122 p->proximity_domain, 122 p->proximity_domain,
123 (p->flags & ACPI_SRAT_MEM_ENABLED)? 123 (p->flags & ACPI_SRAT_MEM_ENABLED)?
124 "enabled" : "disabled", 124 "enabled" : "disabled",
125 (p->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)? 125 (p->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE)?
126 " hot-pluggable" : "")); 126 " hot-pluggable" : "",
127 (p->flags & ACPI_SRAT_MEM_NON_VOLATILE)?
128 " non-volatile" : ""));
127 } 129 }
128#endif /* ACPI_DEBUG_OUTPUT */ 130#endif /* ACPI_DEBUG_OUTPUT */
129 break; 131 break;
@@ -273,7 +275,7 @@ static int __init acpi_parse_srat(struct acpi_table_header *table)
273 275
274static int __init 276static int __init
275acpi_table_parse_srat(enum acpi_srat_type id, 277acpi_table_parse_srat(enum acpi_srat_type id,
276 acpi_table_entry_handler handler, unsigned int max_entries) 278 acpi_tbl_entry_handler handler, unsigned int max_entries)
277{ 279{
278 return acpi_table_parse_entries(ACPI_SIG_SRAT, 280 return acpi_table_parse_entries(ACPI_SIG_SRAT,
279 sizeof(struct acpi_table_srat), id, 281 sizeof(struct acpi_table_srat), id,
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index bd22f8667eed..908b02d5da1b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -787,7 +787,7 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
787 787
788 acpi_irq_handler = handler; 788 acpi_irq_handler = handler;
789 acpi_irq_context = context; 789 acpi_irq_context = context;
790 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { 790 if (request_irq(irq, acpi_irq, IRQF_SHARED | IRQF_NO_SUSPEND, "acpi", acpi_irq)) {
791 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); 791 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
792 acpi_irq_handler = NULL; 792 acpi_irq_handler = NULL;
793 return AE_NOT_ACQUIRED; 793 return AE_NOT_ACQUIRED;
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
deleted file mode 100644
index a1dee29beed3..000000000000
--- a/drivers/acpi/pci_bind.c
+++ /dev/null
@@ -1,122 +0,0 @@
1/*
2 * pci_bind.c - ACPI PCI Device Binding ($Revision: 2 $)
3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
25
26#include <linux/kernel.h>
27#include <linux/types.h>
28#include <linux/pci.h>
29#include <linux/pci-acpi.h>
30#include <linux/acpi.h>
31#include <linux/pm_runtime.h>
32#include <acpi/acpi_bus.h>
33#include <acpi/acpi_drivers.h>
34
35#define _COMPONENT ACPI_PCI_COMPONENT
36ACPI_MODULE_NAME("pci_bind");
37
38static int acpi_pci_unbind(struct acpi_device *device)
39{
40 struct pci_dev *dev;
41
42 dev = acpi_get_pci_dev(device->handle);
43 if (!dev)
44 goto out;
45
46 device_set_run_wake(&dev->dev, false);
47 pci_acpi_remove_pm_notifier(device);
48 acpi_power_resource_unregister_device(&dev->dev, device->handle);
49
50 if (!dev->subordinate)
51 goto out;
52
53 acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number);
54
55 device->ops.bind = NULL;
56 device->ops.unbind = NULL;
57
58out:
59 pci_dev_put(dev);
60 return 0;
61}
62
63static int acpi_pci_bind(struct acpi_device *device)
64{
65 acpi_status status;
66 acpi_handle handle;
67 unsigned char bus;
68 struct pci_dev *dev;
69
70 dev = acpi_get_pci_dev(device->handle);
71 if (!dev)
72 return 0;
73
74 pci_acpi_add_pm_notifier(device, dev);
75 acpi_power_resource_register_device(&dev->dev, device->handle);
76 if (device->wakeup.flags.run_wake)
77 device_set_run_wake(&dev->dev, true);
78
79 /*
80 * Install the 'bind' function to facilitate callbacks for
81 * children of the P2P bridge.
82 */
83 if (dev->subordinate) {
84 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
85 "Device %04x:%02x:%02x.%d is a PCI bridge\n",
86 pci_domain_nr(dev->bus), dev->bus->number,
87 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)));
88 device->ops.bind = acpi_pci_bind;
89 device->ops.unbind = acpi_pci_unbind;
90 }
91
92 /*
93 * Evaluate and parse _PRT, if exists. This code allows parsing of
94 * _PRT objects within the scope of non-bridge devices. Note that
95 * _PRTs within the scope of a PCI bridge assume the bridge's
96 * subordinate bus number.
97 *
98 * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?
99 */
100 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
101 if (ACPI_FAILURE(status))
102 goto out;
103
104 if (dev->subordinate)
105 bus = dev->subordinate->number;
106 else
107 bus = dev->bus->number;
108
109 acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus);
110
111out:
112 pci_dev_put(dev);
113 return 0;
114}
115
116int acpi_pci_bind_root(struct acpi_device *device)
117{
118 device->ops.bind = acpi_pci_bind;
119 device->ops.unbind = acpi_pci_unbind;
120
121 return 0;
122}
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index a12808259dfb..ab764ed34a50 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -53,23 +53,19 @@ ACPI_MODULE_NAME("pci_link");
53#define ACPI_PCI_LINK_FILE_STATUS "state" 53#define ACPI_PCI_LINK_FILE_STATUS "state"
54#define ACPI_PCI_LINK_MAX_POSSIBLE 16 54#define ACPI_PCI_LINK_MAX_POSSIBLE 16
55 55
56static int acpi_pci_link_add(struct acpi_device *device); 56static int acpi_pci_link_add(struct acpi_device *device,
57static int acpi_pci_link_remove(struct acpi_device *device, int type); 57 const struct acpi_device_id *not_used);
58static void acpi_pci_link_remove(struct acpi_device *device);
58 59
59static const struct acpi_device_id link_device_ids[] = { 60static const struct acpi_device_id link_device_ids[] = {
60 {"PNP0C0F", 0}, 61 {"PNP0C0F", 0},
61 {"", 0}, 62 {"", 0},
62}; 63};
63MODULE_DEVICE_TABLE(acpi, link_device_ids);
64 64
65static struct acpi_driver acpi_pci_link_driver = { 65static struct acpi_scan_handler pci_link_handler = {
66 .name = "pci_link",
67 .class = ACPI_PCI_LINK_CLASS,
68 .ids = link_device_ids, 66 .ids = link_device_ids,
69 .ops = { 67 .attach = acpi_pci_link_add,
70 .add = acpi_pci_link_add, 68 .detach = acpi_pci_link_remove,
71 .remove = acpi_pci_link_remove,
72 },
73}; 69};
74 70
75/* 71/*
@@ -692,7 +688,8 @@ int acpi_pci_link_free_irq(acpi_handle handle)
692 Driver Interface 688 Driver Interface
693 -------------------------------------------------------------------------- */ 689 -------------------------------------------------------------------------- */
694 690
695static int acpi_pci_link_add(struct acpi_device *device) 691static int acpi_pci_link_add(struct acpi_device *device,
692 const struct acpi_device_id *not_used)
696{ 693{
697 int result; 694 int result;
698 struct acpi_pci_link *link; 695 struct acpi_pci_link *link;
@@ -746,7 +743,7 @@ static int acpi_pci_link_add(struct acpi_device *device)
746 if (result) 743 if (result)
747 kfree(link); 744 kfree(link);
748 745
749 return result; 746 return result < 0 ? result : 1;
750} 747}
751 748
752static int acpi_pci_link_resume(struct acpi_pci_link *link) 749static int acpi_pci_link_resume(struct acpi_pci_link *link)
@@ -766,7 +763,7 @@ static void irqrouter_resume(void)
766 } 763 }
767} 764}
768 765
769static int acpi_pci_link_remove(struct acpi_device *device, int type) 766static void acpi_pci_link_remove(struct acpi_device *device)
770{ 767{
771 struct acpi_pci_link *link; 768 struct acpi_pci_link *link;
772 769
@@ -777,7 +774,6 @@ static int acpi_pci_link_remove(struct acpi_device *device, int type)
777 mutex_unlock(&acpi_link_lock); 774 mutex_unlock(&acpi_link_lock);
778 775
779 kfree(link); 776 kfree(link);
780 return 0;
781} 777}
782 778
783/* 779/*
@@ -874,20 +870,10 @@ static struct syscore_ops irqrouter_syscore_ops = {
874 .resume = irqrouter_resume, 870 .resume = irqrouter_resume,
875}; 871};
876 872
877static int __init irqrouter_init_ops(void) 873void __init acpi_pci_link_init(void)
878{
879 if (!acpi_disabled && !acpi_noirq)
880 register_syscore_ops(&irqrouter_syscore_ops);
881
882 return 0;
883}
884
885device_initcall(irqrouter_init_ops);
886
887static int __init acpi_pci_link_init(void)
888{ 874{
889 if (acpi_noirq) 875 if (acpi_noirq)
890 return 0; 876 return;
891 877
892 if (acpi_irq_balance == -1) { 878 if (acpi_irq_balance == -1) {
893 /* no command line switch: enable balancing in IOAPIC mode */ 879 /* no command line switch: enable balancing in IOAPIC mode */
@@ -896,11 +882,6 @@ static int __init acpi_pci_link_init(void)
896 else 882 else
897 acpi_irq_balance = 0; 883 acpi_irq_balance = 0;
898 } 884 }
899 885 register_syscore_ops(&irqrouter_syscore_ops);
900 if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0) 886 acpi_scan_add_handler(&pci_link_handler);
901 return -ENODEV;
902
903 return 0;
904} 887}
905
906subsys_initcall(acpi_pci_link_init);
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 7928d4dc7056..b3cc69c5caf1 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -45,9 +45,9 @@
45ACPI_MODULE_NAME("pci_root"); 45ACPI_MODULE_NAME("pci_root");
46#define ACPI_PCI_ROOT_CLASS "pci_bridge" 46#define ACPI_PCI_ROOT_CLASS "pci_bridge"
47#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" 47#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge"
48static int acpi_pci_root_add(struct acpi_device *device); 48static int acpi_pci_root_add(struct acpi_device *device,
49static int acpi_pci_root_remove(struct acpi_device *device, int type); 49 const struct acpi_device_id *not_used);
50static int acpi_pci_root_start(struct acpi_device *device); 50static void acpi_pci_root_remove(struct acpi_device *device);
51 51
52#define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \ 52#define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \
53 | OSC_ACTIVE_STATE_PWR_SUPPORT \ 53 | OSC_ACTIVE_STATE_PWR_SUPPORT \
@@ -58,17 +58,11 @@ static const struct acpi_device_id root_device_ids[] = {
58 {"PNP0A03", 0}, 58 {"PNP0A03", 0},
59 {"", 0}, 59 {"", 0},
60}; 60};
61MODULE_DEVICE_TABLE(acpi, root_device_ids);
62 61
63static struct acpi_driver acpi_pci_root_driver = { 62static struct acpi_scan_handler pci_root_handler = {
64 .name = "pci_root",
65 .class = ACPI_PCI_ROOT_CLASS,
66 .ids = root_device_ids, 63 .ids = root_device_ids,
67 .ops = { 64 .attach = acpi_pci_root_add,
68 .add = acpi_pci_root_add, 65 .detach = acpi_pci_root_remove,
69 .remove = acpi_pci_root_remove,
70 .start = acpi_pci_root_start,
71 },
72}; 66};
73 67
74/* Lock to protect both acpi_pci_roots and acpi_pci_drivers lists */ 68/* Lock to protect both acpi_pci_roots and acpi_pci_drivers lists */
@@ -188,21 +182,6 @@ static acpi_status try_get_root_bridge_busnr(acpi_handle handle,
188 return AE_OK; 182 return AE_OK;
189} 183}
190 184
191static void acpi_pci_bridge_scan(struct acpi_device *device)
192{
193 int status;
194 struct acpi_device *child = NULL;
195
196 if (device->flags.bus_address)
197 if (device->parent && device->parent->ops.bind) {
198 status = device->parent->ops.bind(device);
199 if (!status) {
200 list_for_each_entry(child, &device->children, node)
201 acpi_pci_bridge_scan(child);
202 }
203 }
204}
205
206static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; 185static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766";
207 186
208static acpi_status acpi_pci_run_osc(acpi_handle handle, 187static acpi_status acpi_pci_run_osc(acpi_handle handle,
@@ -445,14 +424,15 @@ out:
445} 424}
446EXPORT_SYMBOL(acpi_pci_osc_control_set); 425EXPORT_SYMBOL(acpi_pci_osc_control_set);
447 426
448static int acpi_pci_root_add(struct acpi_device *device) 427static int acpi_pci_root_add(struct acpi_device *device,
428 const struct acpi_device_id *not_used)
449{ 429{
450 unsigned long long segment, bus; 430 unsigned long long segment, bus;
451 acpi_status status; 431 acpi_status status;
452 int result; 432 int result;
453 struct acpi_pci_root *root; 433 struct acpi_pci_root *root;
454 acpi_handle handle; 434 acpi_handle handle;
455 struct acpi_device *child; 435 struct acpi_pci_driver *driver;
456 u32 flags, base_flags; 436 u32 flags, base_flags;
457 bool is_osc_granted = false; 437 bool is_osc_granted = false;
458 438
@@ -603,21 +583,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
603 goto out_del_root; 583 goto out_del_root;
604 } 584 }
605 585
606 /*
607 * Attach ACPI-PCI Context
608 * -----------------------
609 * Thus binding the ACPI and PCI devices.
610 */
611 result = acpi_pci_bind_root(device);
612 if (result)
613 goto out_del_root;
614
615 /*
616 * Scan and bind all _ADR-Based Devices
617 */
618 list_for_each_entry(child, &device->children, node)
619 acpi_pci_bridge_scan(child);
620
621 /* ASPM setting */ 586 /* ASPM setting */
622 if (is_osc_granted) { 587 if (is_osc_granted) {
623 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) 588 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
@@ -632,24 +597,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
632 if (device->wakeup.flags.run_wake) 597 if (device->wakeup.flags.run_wake)
633 device_set_run_wake(root->bus->bridge, true); 598 device_set_run_wake(root->bus->bridge, true);
634 599
635 return 0;
636
637out_del_root:
638 mutex_lock(&acpi_pci_root_lock);
639 list_del(&root->node);
640 mutex_unlock(&acpi_pci_root_lock);
641
642 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
643end:
644 kfree(root);
645 return result;
646}
647
648static int acpi_pci_root_start(struct acpi_device *device)
649{
650 struct acpi_pci_root *root = acpi_driver_data(device);
651 struct acpi_pci_driver *driver;
652
653 if (system_state != SYSTEM_BOOTING) 600 if (system_state != SYSTEM_BOOTING)
654 pci_assign_unassigned_bus_resources(root->bus); 601 pci_assign_unassigned_bus_resources(root->bus);
655 602
@@ -664,11 +611,20 @@ static int acpi_pci_root_start(struct acpi_device *device)
664 pci_enable_bridges(root->bus); 611 pci_enable_bridges(root->bus);
665 612
666 pci_bus_add_devices(root->bus); 613 pci_bus_add_devices(root->bus);
614 return 1;
667 615
668 return 0; 616out_del_root:
617 mutex_lock(&acpi_pci_root_lock);
618 list_del(&root->node);
619 mutex_unlock(&acpi_pci_root_lock);
620
621 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
622end:
623 kfree(root);
624 return result;
669} 625}
670 626
671static int acpi_pci_root_remove(struct acpi_device *device, int type) 627static void acpi_pci_root_remove(struct acpi_device *device)
672{ 628{
673 acpi_status status; 629 acpi_status status;
674 acpi_handle handle; 630 acpi_handle handle;
@@ -696,21 +652,14 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
696 list_del(&root->node); 652 list_del(&root->node);
697 mutex_unlock(&acpi_pci_root_lock); 653 mutex_unlock(&acpi_pci_root_lock);
698 kfree(root); 654 kfree(root);
699 return 0;
700} 655}
701 656
702static int __init acpi_pci_root_init(void) 657void __init acpi_pci_root_init(void)
703{ 658{
704 acpi_hest_init(); 659 acpi_hest_init();
705 660
706 if (acpi_pci_disabled) 661 if (!acpi_pci_disabled) {
707 return 0; 662 pci_acpi_crs_quirks();
708 663 acpi_scan_add_handler(&pci_root_handler);
709 pci_acpi_crs_quirks(); 664 }
710 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0)
711 return -ENODEV;
712
713 return 0;
714} 665}
715
716subsys_initcall(acpi_pci_root_init);
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index d22585f21aeb..2c630c006c2f 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -50,13 +50,12 @@ module_param(debug, bool, 0644);
50ACPI_MODULE_NAME("pci_slot"); 50ACPI_MODULE_NAME("pci_slot");
51 51
52#define MY_NAME "pci_slot" 52#define MY_NAME "pci_slot"
53#define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) 53#define err(format, arg...) pr_err("%s: " format , MY_NAME , ## arg)
54#define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) 54#define info(format, arg...) pr_info("%s: " format , MY_NAME , ## arg)
55#define dbg(format, arg...) \ 55#define dbg(format, arg...) \
56 do { \ 56 do { \
57 if (debug) \ 57 if (debug) \
58 printk(KERN_DEBUG "%s: " format, \ 58 pr_debug("%s: " format, MY_NAME , ## arg); \
59 MY_NAME , ## arg); \
60 } while (0) 59 } while (0)
61 60
62#define SLOT_NAME_SIZE 21 /* Inspired by #define in acpiphp.h */ 61#define SLOT_NAME_SIZE 21 /* Inspired by #define in acpiphp.h */
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 6e7b9d523812..b820528a5fa3 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -41,6 +41,7 @@
41#include <linux/types.h> 41#include <linux/types.h>
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/pm_runtime.h> 43#include <linux/pm_runtime.h>
44#include <linux/sysfs.h>
44#include <acpi/acpi_bus.h> 45#include <acpi/acpi_bus.h>
45#include <acpi/acpi_drivers.h> 46#include <acpi/acpi_drivers.h>
46#include "sleep.h" 47#include "sleep.h"
@@ -58,88 +59,121 @@ ACPI_MODULE_NAME("power");
58#define ACPI_POWER_RESOURCE_STATE_ON 0x01 59#define ACPI_POWER_RESOURCE_STATE_ON 0x01
59#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF 60#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF
60 61
61static int acpi_power_add(struct acpi_device *device); 62struct acpi_power_dependent_device {
62static int acpi_power_remove(struct acpi_device *device, int type); 63 struct list_head node;
63 64 struct acpi_device *adev;
64static const struct acpi_device_id power_device_ids[] = { 65 struct work_struct work;
65 {ACPI_POWER_HID, 0},
66 {"", 0},
67};
68MODULE_DEVICE_TABLE(acpi, power_device_ids);
69
70#ifdef CONFIG_PM_SLEEP
71static int acpi_power_resume(struct device *dev);
72#endif
73static SIMPLE_DEV_PM_OPS(acpi_power_pm, NULL, acpi_power_resume);
74
75static struct acpi_driver acpi_power_driver = {
76 .name = "power",
77 .class = ACPI_POWER_CLASS,
78 .ids = power_device_ids,
79 .ops = {
80 .add = acpi_power_add,
81 .remove = acpi_power_remove,
82 },
83 .drv.pm = &acpi_power_pm,
84};
85
86/*
87 * A power managed device
88 * A device may rely on multiple power resources.
89 * */
90struct acpi_power_managed_device {
91 struct device *dev; /* The physical device */
92 acpi_handle *handle;
93};
94
95struct acpi_power_resource_device {
96 struct acpi_power_managed_device *device;
97 struct acpi_power_resource_device *next;
98}; 66};
99 67
100struct acpi_power_resource { 68struct acpi_power_resource {
101 struct acpi_device * device; 69 struct acpi_device device;
102 acpi_bus_id name; 70 struct list_head list_node;
71 struct list_head dependent;
72 char *name;
103 u32 system_level; 73 u32 system_level;
104 u32 order; 74 u32 order;
105 unsigned int ref_count; 75 unsigned int ref_count;
106 struct mutex resource_lock; 76 struct mutex resource_lock;
77};
107 78
108 /* List of devices relying on this power resource */ 79struct acpi_power_resource_entry {
109 struct acpi_power_resource_device *devices; 80 struct list_head node;
110 struct mutex devices_lock; 81 struct acpi_power_resource *resource;
111}; 82};
112 83
113static struct list_head acpi_power_resource_list; 84static LIST_HEAD(acpi_power_resource_list);
85static DEFINE_MUTEX(power_resource_list_lock);
114 86
115/* -------------------------------------------------------------------------- 87/* --------------------------------------------------------------------------
116 Power Resource Management 88 Power Resource Management
117 -------------------------------------------------------------------------- */ 89 -------------------------------------------------------------------------- */
118 90
119static int 91static inline
120acpi_power_get_context(acpi_handle handle, 92struct acpi_power_resource *to_power_resource(struct acpi_device *device)
121 struct acpi_power_resource **resource)
122{ 93{
123 int result = 0; 94 return container_of(device, struct acpi_power_resource, device);
124 struct acpi_device *device = NULL; 95}
96
97static struct acpi_power_resource *acpi_power_get_context(acpi_handle handle)
98{
99 struct acpi_device *device;
125 100
101 if (acpi_bus_get_device(handle, &device))
102 return NULL;
126 103
127 if (!resource) 104 return to_power_resource(device);
128 return -ENODEV; 105}
129 106
130 result = acpi_bus_get_device(handle, &device); 107static int acpi_power_resources_list_add(acpi_handle handle,
131 if (result) { 108 struct list_head *list)
132 printk(KERN_WARNING PREFIX "Getting context [%p]\n", handle); 109{
133 return result; 110 struct acpi_power_resource *resource = acpi_power_get_context(handle);
134 } 111 struct acpi_power_resource_entry *entry;
135 112
136 *resource = acpi_driver_data(device); 113 if (!resource || !list)
137 if (!*resource) 114 return -EINVAL;
138 return -ENODEV; 115
116 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
117 if (!entry)
118 return -ENOMEM;
119
120 entry->resource = resource;
121 if (!list_empty(list)) {
122 struct acpi_power_resource_entry *e;
139 123
124 list_for_each_entry(e, list, node)
125 if (e->resource->order > resource->order) {
126 list_add_tail(&entry->node, &e->node);
127 return 0;
128 }
129 }
130 list_add_tail(&entry->node, list);
140 return 0; 131 return 0;
141} 132}
142 133
134void acpi_power_resources_list_free(struct list_head *list)
135{
136 struct acpi_power_resource_entry *entry, *e;
137
138 list_for_each_entry_safe(entry, e, list, node) {
139 list_del(&entry->node);
140 kfree(entry);
141 }
142}
143
144int acpi_extract_power_resources(union acpi_object *package, unsigned int start,
145 struct list_head *list)
146{
147 unsigned int i;
148 int err = 0;
149
150 for (i = start; i < package->package.count; i++) {
151 union acpi_object *element = &package->package.elements[i];
152 acpi_handle rhandle;
153
154 if (element->type != ACPI_TYPE_LOCAL_REFERENCE) {
155 err = -ENODATA;
156 break;
157 }
158 rhandle = element->reference.handle;
159 if (!rhandle) {
160 err = -ENODEV;
161 break;
162 }
163 err = acpi_add_power_resource(rhandle);
164 if (err)
165 break;
166
167 err = acpi_power_resources_list_add(rhandle, list);
168 if (err)
169 break;
170 }
171 if (err)
172 acpi_power_resources_list_free(list);
173
174 return err;
175}
176
143static int acpi_power_get_state(acpi_handle handle, int *state) 177static int acpi_power_get_state(acpi_handle handle, int *state)
144{ 178{
145 acpi_status status = AE_OK; 179 acpi_status status = AE_OK;
@@ -167,31 +201,23 @@ static int acpi_power_get_state(acpi_handle handle, int *state)
167 return 0; 201 return 0;
168} 202}
169 203
170static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) 204static int acpi_power_get_list_state(struct list_head *list, int *state)
171{ 205{
206 struct acpi_power_resource_entry *entry;
172 int cur_state; 207 int cur_state;
173 int i = 0;
174 208
175 if (!list || !state) 209 if (!list || !state)
176 return -EINVAL; 210 return -EINVAL;
177 211
178 /* The state of the list is 'on' IFF all resources are 'on'. */ 212 /* The state of the list is 'on' IFF all resources are 'on'. */
179 213 list_for_each_entry(entry, list, node) {
180 for (i = 0; i < list->count; i++) { 214 struct acpi_power_resource *resource = entry->resource;
181 struct acpi_power_resource *resource; 215 acpi_handle handle = resource->device.handle;
182 acpi_handle handle = list->handles[i];
183 int result; 216 int result;
184 217
185 result = acpi_power_get_context(handle, &resource);
186 if (result)
187 return result;
188
189 mutex_lock(&resource->resource_lock); 218 mutex_lock(&resource->resource_lock);
190
191 result = acpi_power_get_state(handle, &cur_state); 219 result = acpi_power_get_state(handle, &cur_state);
192
193 mutex_unlock(&resource->resource_lock); 220 mutex_unlock(&resource->resource_lock);
194
195 if (result) 221 if (result)
196 return result; 222 return result;
197 223
@@ -203,54 +229,52 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
203 cur_state ? "on" : "off")); 229 cur_state ? "on" : "off"));
204 230
205 *state = cur_state; 231 *state = cur_state;
206
207 return 0; 232 return 0;
208} 233}
209 234
210/* Resume the device when all power resources in _PR0 are on */ 235static void acpi_power_resume_dependent(struct work_struct *work)
211static void acpi_power_on_device(struct acpi_power_managed_device *device)
212{ 236{
213 struct acpi_device *acpi_dev; 237 struct acpi_power_dependent_device *dep;
214 acpi_handle handle = device->handle; 238 struct acpi_device_physical_node *pn;
239 struct acpi_device *adev;
215 int state; 240 int state;
216 241
217 if (acpi_bus_get_device(handle, &acpi_dev)) 242 dep = container_of(work, struct acpi_power_dependent_device, work);
243 adev = dep->adev;
244 if (acpi_power_get_inferred_state(adev, &state))
218 return; 245 return;
219 246
220 if(acpi_power_get_inferred_state(acpi_dev, &state)) 247 if (state > ACPI_STATE_D0)
221 return; 248 return;
222 249
223 if (state == ACPI_STATE_D0 && pm_runtime_suspended(device->dev)) 250 mutex_lock(&adev->physical_node_lock);
224 pm_request_resume(device->dev); 251
252 list_for_each_entry(pn, &adev->physical_node_list, node)
253 pm_request_resume(pn->dev);
254
255 list_for_each_entry(pn, &adev->power_dependent, node)
256 pm_request_resume(pn->dev);
257
258 mutex_unlock(&adev->physical_node_lock);
225} 259}
226 260
227static int __acpi_power_on(struct acpi_power_resource *resource) 261static int __acpi_power_on(struct acpi_power_resource *resource)
228{ 262{
229 acpi_status status = AE_OK; 263 acpi_status status = AE_OK;
230 264
231 status = acpi_evaluate_object(resource->device->handle, "_ON", NULL, NULL); 265 status = acpi_evaluate_object(resource->device.handle, "_ON", NULL, NULL);
232 if (ACPI_FAILURE(status)) 266 if (ACPI_FAILURE(status))
233 return -ENODEV; 267 return -ENODEV;
234 268
235 /* Update the power resource's _device_ power state */
236 resource->device->power.state = ACPI_STATE_D0;
237
238 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Power resource [%s] turned on\n", 269 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Power resource [%s] turned on\n",
239 resource->name)); 270 resource->name));
240 271
241 return 0; 272 return 0;
242} 273}
243 274
244static int acpi_power_on(acpi_handle handle) 275static int acpi_power_on(struct acpi_power_resource *resource)
245{ 276{
246 int result = 0; 277 int result = 0;;
247 bool resume_device = false;
248 struct acpi_power_resource *resource = NULL;
249 struct acpi_power_resource_device *device_list;
250
251 result = acpi_power_get_context(handle, &resource);
252 if (result)
253 return result;
254 278
255 mutex_lock(&resource->resource_lock); 279 mutex_lock(&resource->resource_lock);
256 280
@@ -260,39 +284,38 @@ static int acpi_power_on(acpi_handle handle)
260 resource->name)); 284 resource->name));
261 } else { 285 } else {
262 result = __acpi_power_on(resource); 286 result = __acpi_power_on(resource);
263 if (result) 287 if (result) {
264 resource->ref_count--; 288 resource->ref_count--;
265 else 289 } else {
266 resume_device = true; 290 struct acpi_power_dependent_device *dep;
291
292 list_for_each_entry(dep, &resource->dependent, node)
293 schedule_work(&dep->work);
294 }
267 } 295 }
268 296
269 mutex_unlock(&resource->resource_lock); 297 mutex_unlock(&resource->resource_lock);
270 298
271 if (!resume_device) 299 return result;
272 return result; 300}
273
274 mutex_lock(&resource->devices_lock);
275 301
276 device_list = resource->devices; 302static int __acpi_power_off(struct acpi_power_resource *resource)
277 while (device_list) { 303{
278 acpi_power_on_device(device_list->device); 304 acpi_status status;
279 device_list = device_list->next;
280 }
281 305
282 mutex_unlock(&resource->devices_lock); 306 status = acpi_evaluate_object(resource->device.handle, "_OFF",
307 NULL, NULL);
308 if (ACPI_FAILURE(status))
309 return -ENODEV;
283 310
284 return result; 311 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Power resource [%s] turned off\n",
312 resource->name));
313 return 0;
285} 314}
286 315
287static int acpi_power_off(acpi_handle handle) 316static int acpi_power_off(struct acpi_power_resource *resource)
288{ 317{
289 int result = 0; 318 int result = 0;
290 acpi_status status = AE_OK;
291 struct acpi_power_resource *resource = NULL;
292
293 result = acpi_power_get_context(handle, &resource);
294 if (result)
295 return result;
296 319
297 mutex_lock(&resource->resource_lock); 320 mutex_lock(&resource->resource_lock);
298 321
@@ -307,19 +330,10 @@ static int acpi_power_off(acpi_handle handle)
307 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 330 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
308 "Power resource [%s] still in use\n", 331 "Power resource [%s] still in use\n",
309 resource->name)); 332 resource->name));
310 goto unlock;
311 }
312
313 status = acpi_evaluate_object(resource->device->handle, "_OFF", NULL, NULL);
314 if (ACPI_FAILURE(status)) {
315 result = -ENODEV;
316 } else { 333 } else {
317 /* Update the power resource's _device_ power state */ 334 result = __acpi_power_off(resource);
318 resource->device->power.state = ACPI_STATE_D3; 335 if (result)
319 336 resource->ref_count++;
320 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
321 "Power resource [%s] turned off\n",
322 resource->name));
323 } 337 }
324 338
325 unlock: 339 unlock:
@@ -328,148 +342,202 @@ static int acpi_power_off(acpi_handle handle)
328 return result; 342 return result;
329} 343}
330 344
331static void __acpi_power_off_list(struct acpi_handle_list *list, int num_res) 345static int acpi_power_off_list(struct list_head *list)
332{ 346{
333 int i; 347 struct acpi_power_resource_entry *entry;
348 int result = 0;
334 349
335 for (i = num_res - 1; i >= 0 ; i--) 350 list_for_each_entry_reverse(entry, list, node) {
336 acpi_power_off(list->handles[i]); 351 result = acpi_power_off(entry->resource);
337} 352 if (result)
353 goto err;
354 }
355 return 0;
338 356
339static void acpi_power_off_list(struct acpi_handle_list *list) 357 err:
340{ 358 list_for_each_entry_continue(entry, list, node)
341 __acpi_power_off_list(list, list->count); 359 acpi_power_on(entry->resource);
360
361 return result;
342} 362}
343 363
344static int acpi_power_on_list(struct acpi_handle_list *list) 364static int acpi_power_on_list(struct list_head *list)
345{ 365{
366 struct acpi_power_resource_entry *entry;
346 int result = 0; 367 int result = 0;
347 int i;
348 368
349 for (i = 0; i < list->count; i++) { 369 list_for_each_entry(entry, list, node) {
350 result = acpi_power_on(list->handles[i]); 370 result = acpi_power_on(entry->resource);
351 if (result) { 371 if (result)
352 __acpi_power_off_list(list, i); 372 goto err;
353 break;
354 }
355 } 373 }
374 return 0;
375
376 err:
377 list_for_each_entry_continue_reverse(entry, list, node)
378 acpi_power_off(entry->resource);
356 379
357 return result; 380 return result;
358} 381}
359 382
360static void __acpi_power_resource_unregister_device(struct device *dev, 383static void acpi_power_add_dependent(struct acpi_power_resource *resource,
361 acpi_handle res_handle) 384 struct acpi_device *adev)
362{ 385{
363 struct acpi_power_resource *resource = NULL; 386 struct acpi_power_dependent_device *dep;
364 struct acpi_power_resource_device *prev, *curr;
365 387
366 if (acpi_power_get_context(res_handle, &resource)) 388 mutex_lock(&resource->resource_lock);
367 return; 389
390 list_for_each_entry(dep, &resource->dependent, node)
391 if (dep->adev == adev)
392 goto out;
393
394 dep = kzalloc(sizeof(*dep), GFP_KERNEL);
395 if (!dep)
396 goto out;
397
398 dep->adev = adev;
399 INIT_WORK(&dep->work, acpi_power_resume_dependent);
400 list_add_tail(&dep->node, &resource->dependent);
368 401
369 mutex_lock(&resource->devices_lock); 402 out:
370 prev = NULL; 403 mutex_unlock(&resource->resource_lock);
371 curr = resource->devices; 404}
372 while (curr) { 405
373 if (curr->device->dev == dev) { 406static void acpi_power_remove_dependent(struct acpi_power_resource *resource,
374 if (!prev) 407 struct acpi_device *adev)
375 resource->devices = curr->next; 408{
376 else 409 struct acpi_power_dependent_device *dep;
377 prev->next = curr->next; 410 struct work_struct *work = NULL;
378 411
379 kfree(curr); 412 mutex_lock(&resource->resource_lock);
413
414 list_for_each_entry(dep, &resource->dependent, node)
415 if (dep->adev == adev) {
416 list_del(&dep->node);
417 work = &dep->work;
380 break; 418 break;
381 } 419 }
382 420
383 prev = curr; 421 mutex_unlock(&resource->resource_lock);
384 curr = curr->next; 422
423 if (work) {
424 cancel_work_sync(work);
425 kfree(dep);
385 } 426 }
386 mutex_unlock(&resource->devices_lock);
387} 427}
388 428
389/* Unlink dev from all power resources in _PR0 */ 429static struct attribute *attrs[] = {
390void acpi_power_resource_unregister_device(struct device *dev, acpi_handle handle) 430 NULL,
391{ 431};
392 struct acpi_device *acpi_dev;
393 struct acpi_handle_list *list;
394 int i;
395 432
396 if (!dev || !handle) 433static struct attribute_group attr_groups[] = {
397 return; 434 [ACPI_STATE_D0] = {
435 .name = "power_resources_D0",
436 .attrs = attrs,
437 },
438 [ACPI_STATE_D1] = {
439 .name = "power_resources_D1",
440 .attrs = attrs,
441 },
442 [ACPI_STATE_D2] = {
443 .name = "power_resources_D2",
444 .attrs = attrs,
445 },
446 [ACPI_STATE_D3_HOT] = {
447 .name = "power_resources_D3hot",
448 .attrs = attrs,
449 },
450};
398 451
399 if (acpi_bus_get_device(handle, &acpi_dev)) 452static void acpi_power_hide_list(struct acpi_device *adev, int state)
453{
454 struct acpi_device_power_state *ps = &adev->power.states[state];
455 struct acpi_power_resource_entry *entry;
456
457 if (list_empty(&ps->resources))
400 return; 458 return;
401 459
402 list = &acpi_dev->power.states[ACPI_STATE_D0].resources; 460 list_for_each_entry_reverse(entry, &ps->resources, node) {
461 struct acpi_device *res_dev = &entry->resource->device;
403 462
404 for (i = 0; i < list->count; i++) 463 sysfs_remove_link_from_group(&adev->dev.kobj,
405 __acpi_power_resource_unregister_device(dev, 464 attr_groups[state].name,
406 list->handles[i]); 465 dev_name(&res_dev->dev));
466 }
467 sysfs_remove_group(&adev->dev.kobj, &attr_groups[state]);
407} 468}
408EXPORT_SYMBOL_GPL(acpi_power_resource_unregister_device);
409 469
410static int __acpi_power_resource_register_device( 470static void acpi_power_expose_list(struct acpi_device *adev, int state)
411 struct acpi_power_managed_device *powered_device, acpi_handle handle)
412{ 471{
413 struct acpi_power_resource *resource = NULL; 472 struct acpi_device_power_state *ps = &adev->power.states[state];
414 struct acpi_power_resource_device *power_resource_device; 473 struct acpi_power_resource_entry *entry;
415 int result; 474 int ret;
416
417 result = acpi_power_get_context(handle, &resource);
418 if (result)
419 return result;
420 475
421 power_resource_device = kzalloc( 476 if (list_empty(&ps->resources))
422 sizeof(*power_resource_device), GFP_KERNEL); 477 return;
423 if (!power_resource_device)
424 return -ENOMEM;
425 478
426 power_resource_device->device = powered_device; 479 ret = sysfs_create_group(&adev->dev.kobj, &attr_groups[state]);
480 if (ret)
481 return;
427 482
428 mutex_lock(&resource->devices_lock); 483 list_for_each_entry(entry, &ps->resources, node) {
429 power_resource_device->next = resource->devices; 484 struct acpi_device *res_dev = &entry->resource->device;
430 resource->devices = power_resource_device;
431 mutex_unlock(&resource->devices_lock);
432 485
433 return 0; 486 ret = sysfs_add_link_to_group(&adev->dev.kobj,
487 attr_groups[state].name,
488 &res_dev->dev.kobj,
489 dev_name(&res_dev->dev));
490 if (ret) {
491 acpi_power_hide_list(adev, state);
492 break;
493 }
494 }
434} 495}
435 496
436/* Link dev to all power resources in _PR0 */ 497void acpi_power_add_remove_device(struct acpi_device *adev, bool add)
437int acpi_power_resource_register_device(struct device *dev, acpi_handle handle)
438{ 498{
439 struct acpi_device *acpi_dev; 499 struct acpi_device_power_state *ps;
440 struct acpi_handle_list *list; 500 struct acpi_power_resource_entry *entry;
441 struct acpi_power_managed_device *powered_device; 501 int state;
442 int i, ret;
443 502
444 if (!dev || !handle) 503 if (!adev->power.flags.power_resources)
445 return -ENODEV; 504 return;
446 505
447 ret = acpi_bus_get_device(handle, &acpi_dev); 506 ps = &adev->power.states[ACPI_STATE_D0];
448 if (ret || !acpi_dev->power.flags.power_resources) 507 list_for_each_entry(entry, &ps->resources, node) {
449 return -ENODEV; 508 struct acpi_power_resource *resource = entry->resource;
450 509
451 powered_device = kzalloc(sizeof(*powered_device), GFP_KERNEL); 510 if (add)
452 if (!powered_device) 511 acpi_power_add_dependent(resource, adev);
453 return -ENOMEM; 512 else
513 acpi_power_remove_dependent(resource, adev);
514 }
454 515
455 powered_device->dev = dev; 516 for (state = ACPI_STATE_D0; state <= ACPI_STATE_D3_HOT; state++) {
456 powered_device->handle = handle; 517 if (add)
518 acpi_power_expose_list(adev, state);
519 else
520 acpi_power_hide_list(adev, state);
521 }
522}
457 523
458 list = &acpi_dev->power.states[ACPI_STATE_D0].resources; 524int acpi_power_min_system_level(struct list_head *list)
525{
526 struct acpi_power_resource_entry *entry;
527 int system_level = 5;
459 528
460 for (i = 0; i < list->count; i++) { 529 list_for_each_entry(entry, list, node) {
461 ret = __acpi_power_resource_register_device(powered_device, 530 struct acpi_power_resource *resource = entry->resource;
462 list->handles[i]);
463 531
464 if (ret) { 532 if (system_level > resource->system_level)
465 acpi_power_resource_unregister_device(dev, handle); 533 system_level = resource->system_level;
466 break;
467 }
468 } 534 }
469 535 return system_level;
470 return ret;
471} 536}
472EXPORT_SYMBOL_GPL(acpi_power_resource_register_device); 537
538/* --------------------------------------------------------------------------
539 Device Power Management
540 -------------------------------------------------------------------------- */
473 541
474/** 542/**
475 * acpi_device_sleep_wake - execute _DSW (Device Sleep Wake) or (deprecated in 543 * acpi_device_sleep_wake - execute _DSW (Device Sleep Wake) or (deprecated in
@@ -542,7 +610,7 @@ int acpi_device_sleep_wake(struct acpi_device *dev,
542 */ 610 */
543int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) 611int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
544{ 612{
545 int i, err = 0; 613 int err = 0;
546 614
547 if (!dev || !dev->wakeup.flags.valid) 615 if (!dev || !dev->wakeup.flags.valid)
548 return -EINVAL; 616 return -EINVAL;
@@ -552,24 +620,17 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
552 if (dev->wakeup.prepare_count++) 620 if (dev->wakeup.prepare_count++)
553 goto out; 621 goto out;
554 622
555 /* Open power resource */ 623 err = acpi_power_on_list(&dev->wakeup.resources);
556 for (i = 0; i < dev->wakeup.resources.count; i++) { 624 if (err) {
557 int ret = acpi_power_on(dev->wakeup.resources.handles[i]); 625 dev_err(&dev->dev, "Cannot turn wakeup power resources on\n");
558 if (ret) { 626 dev->wakeup.flags.valid = 0;
559 printk(KERN_ERR PREFIX "Transition power state\n"); 627 } else {
560 dev->wakeup.flags.valid = 0; 628 /*
561 err = -ENODEV; 629 * Passing 3 as the third argument below means the device may be
562 goto err_out; 630 * put into arbitrary power state afterward.
563 } 631 */
632 err = acpi_device_sleep_wake(dev, 1, sleep_state, 3);
564 } 633 }
565
566 /*
567 * Passing 3 as the third argument below means the device may be placed
568 * in arbitrary power state afterwards.
569 */
570 err = acpi_device_sleep_wake(dev, 1, sleep_state, 3);
571
572 err_out:
573 if (err) 634 if (err)
574 dev->wakeup.prepare_count = 0; 635 dev->wakeup.prepare_count = 0;
575 636
@@ -586,7 +647,7 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
586 */ 647 */
587int acpi_disable_wakeup_device_power(struct acpi_device *dev) 648int acpi_disable_wakeup_device_power(struct acpi_device *dev)
588{ 649{
589 int i, err = 0; 650 int err = 0;
590 651
591 if (!dev || !dev->wakeup.flags.valid) 652 if (!dev || !dev->wakeup.flags.valid)
592 return -EINVAL; 653 return -EINVAL;
@@ -607,15 +668,10 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
607 if (err) 668 if (err)
608 goto out; 669 goto out;
609 670
610 /* Close power resource */ 671 err = acpi_power_off_list(&dev->wakeup.resources);
611 for (i = 0; i < dev->wakeup.resources.count; i++) { 672 if (err) {
612 int ret = acpi_power_off(dev->wakeup.resources.handles[i]); 673 dev_err(&dev->dev, "Cannot turn wakeup power resources off\n");
613 if (ret) { 674 dev->wakeup.flags.valid = 0;
614 printk(KERN_ERR PREFIX "Transition power state\n");
615 dev->wakeup.flags.valid = 0;
616 err = -ENODEV;
617 goto out;
618 }
619 } 675 }
620 676
621 out: 677 out:
@@ -623,14 +679,9 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
623 return err; 679 return err;
624} 680}
625 681
626/* --------------------------------------------------------------------------
627 Device Power Management
628 -------------------------------------------------------------------------- */
629
630int acpi_power_get_inferred_state(struct acpi_device *device, int *state) 682int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
631{ 683{
632 int result = 0; 684 int result = 0;
633 struct acpi_handle_list *list = NULL;
634 int list_state = 0; 685 int list_state = 0;
635 int i = 0; 686 int i = 0;
636 687
@@ -642,8 +693,9 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
642 * required for a given D-state are 'on'. 693 * required for a given D-state are 'on'.
643 */ 694 */
644 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++) { 695 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++) {
645 list = &device->power.states[i].resources; 696 struct list_head *list = &device->power.states[i].resources;
646 if (list->count < 1) 697
698 if (list_empty(list))
647 continue; 699 continue;
648 700
649 result = acpi_power_get_list_state(list, &list_state); 701 result = acpi_power_get_list_state(list, &list_state);
@@ -662,7 +714,7 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
662 714
663int acpi_power_on_resources(struct acpi_device *device, int state) 715int acpi_power_on_resources(struct acpi_device *device, int state)
664{ 716{
665 if (!device || state < ACPI_STATE_D0 || state > ACPI_STATE_D3) 717 if (!device || state < ACPI_STATE_D0 || state > ACPI_STATE_D3_HOT)
666 return -EINVAL; 718 return -EINVAL;
667 719
668 return acpi_power_on_list(&device->power.states[state].resources); 720 return acpi_power_on_list(&device->power.states[state].resources);
@@ -675,7 +727,7 @@ int acpi_power_transition(struct acpi_device *device, int state)
675 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD)) 727 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
676 return -EINVAL; 728 return -EINVAL;
677 729
678 if (device->power.state == state) 730 if (device->power.state == state || !device->flags.power_manageable)
679 return 0; 731 return 0;
680 732
681 if ((device->power.state < ACPI_STATE_D0) 733 if ((device->power.state < ACPI_STATE_D0)
@@ -703,118 +755,126 @@ int acpi_power_transition(struct acpi_device *device, int state)
703 return result; 755 return result;
704} 756}
705 757
706/* -------------------------------------------------------------------------- 758static void acpi_release_power_resource(struct device *dev)
707 Driver Interface 759{
708 -------------------------------------------------------------------------- */ 760 struct acpi_device *device = to_acpi_device(dev);
761 struct acpi_power_resource *resource;
762
763 resource = container_of(device, struct acpi_power_resource, device);
764
765 mutex_lock(&power_resource_list_lock);
766 list_del(&resource->list_node);
767 mutex_unlock(&power_resource_list_lock);
768
769 acpi_free_ids(device);
770 kfree(resource);
771}
709 772
710static int acpi_power_add(struct acpi_device *device) 773static ssize_t acpi_power_in_use_show(struct device *dev,
774 struct device_attribute *attr,
775 char *buf) {
776 struct acpi_power_resource *resource;
777
778 resource = to_power_resource(to_acpi_device(dev));
779 return sprintf(buf, "%u\n", !!resource->ref_count);
780}
781static DEVICE_ATTR(resource_in_use, 0444, acpi_power_in_use_show, NULL);
782
783static void acpi_power_sysfs_remove(struct acpi_device *device)
711{ 784{
712 int result = 0, state; 785 device_remove_file(&device->dev, &dev_attr_resource_in_use);
713 acpi_status status = AE_OK; 786}
714 struct acpi_power_resource *resource = NULL; 787
788int acpi_add_power_resource(acpi_handle handle)
789{
790 struct acpi_power_resource *resource;
791 struct acpi_device *device = NULL;
715 union acpi_object acpi_object; 792 union acpi_object acpi_object;
716 struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object }; 793 struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
794 acpi_status status;
795 int state, result = -ENODEV;
717 796
797 acpi_bus_get_device(handle, &device);
798 if (device)
799 return 0;
718 800
719 if (!device) 801 resource = kzalloc(sizeof(*resource), GFP_KERNEL);
720 return -EINVAL;
721
722 resource = kzalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
723 if (!resource) 802 if (!resource)
724 return -ENOMEM; 803 return -ENOMEM;
725 804
726 resource->device = device; 805 device = &resource->device;
806 acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER,
807 ACPI_STA_DEFAULT);
727 mutex_init(&resource->resource_lock); 808 mutex_init(&resource->resource_lock);
728 mutex_init(&resource->devices_lock); 809 INIT_LIST_HEAD(&resource->dependent);
729 strcpy(resource->name, device->pnp.bus_id); 810 resource->name = device->pnp.bus_id;
730 strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); 811 strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
731 strcpy(acpi_device_class(device), ACPI_POWER_CLASS); 812 strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
732 device->driver_data = resource; 813 device->power.state = ACPI_STATE_UNKNOWN;
733 814
734 /* Evalute the object to get the system level and resource order. */ 815 /* Evalute the object to get the system level and resource order. */
735 status = acpi_evaluate_object(device->handle, NULL, NULL, &buffer); 816 status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
736 if (ACPI_FAILURE(status)) { 817 if (ACPI_FAILURE(status))
737 result = -ENODEV; 818 goto err;
738 goto end; 819
739 }
740 resource->system_level = acpi_object.power_resource.system_level; 820 resource->system_level = acpi_object.power_resource.system_level;
741 resource->order = acpi_object.power_resource.resource_order; 821 resource->order = acpi_object.power_resource.resource_order;
742 822
743 result = acpi_power_get_state(device->handle, &state); 823 result = acpi_power_get_state(handle, &state);
744 if (result) 824 if (result)
745 goto end; 825 goto err;
746
747 switch (state) {
748 case ACPI_POWER_RESOURCE_STATE_ON:
749 device->power.state = ACPI_STATE_D0;
750 break;
751 case ACPI_POWER_RESOURCE_STATE_OFF:
752 device->power.state = ACPI_STATE_D3;
753 break;
754 default:
755 device->power.state = ACPI_STATE_UNKNOWN;
756 break;
757 }
758 826
759 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device), 827 printk(KERN_INFO PREFIX "%s [%s] (%s)\n", acpi_device_name(device),
760 acpi_device_bid(device), state ? "on" : "off"); 828 acpi_device_bid(device), state ? "on" : "off");
761 829
762 end: 830 device->flags.match_driver = true;
831 result = acpi_device_add(device, acpi_release_power_resource);
763 if (result) 832 if (result)
764 kfree(resource); 833 goto err;
765 834
766 return result; 835 if (!device_create_file(&device->dev, &dev_attr_resource_in_use))
767} 836 device->remove = acpi_power_sysfs_remove;
768
769static int acpi_power_remove(struct acpi_device *device, int type)
770{
771 struct acpi_power_resource *resource;
772
773 if (!device)
774 return -EINVAL;
775
776 resource = acpi_driver_data(device);
777 if (!resource)
778 return -EINVAL;
779
780 kfree(resource);
781 837
838 mutex_lock(&power_resource_list_lock);
839 list_add(&resource->list_node, &acpi_power_resource_list);
840 mutex_unlock(&power_resource_list_lock);
841 acpi_device_add_finalize(device);
782 return 0; 842 return 0;
843
844 err:
845 acpi_release_power_resource(&device->dev);
846 return result;
783} 847}
784 848
785#ifdef CONFIG_PM_SLEEP 849#ifdef CONFIG_ACPI_SLEEP
786static int acpi_power_resume(struct device *dev) 850void acpi_resume_power_resources(void)
787{ 851{
788 int result = 0, state;
789 struct acpi_device *device;
790 struct acpi_power_resource *resource; 852 struct acpi_power_resource *resource;
791 853
792 if (!dev) 854 mutex_lock(&power_resource_list_lock);
793 return -EINVAL;
794 855
795 device = to_acpi_device(dev); 856 list_for_each_entry(resource, &acpi_power_resource_list, list_node) {
796 resource = acpi_driver_data(device); 857 int result, state;
797 if (!resource)
798 return -EINVAL;
799 858
800 mutex_lock(&resource->resource_lock); 859 mutex_lock(&resource->resource_lock);
801 860
802 result = acpi_power_get_state(device->handle, &state); 861 result = acpi_power_get_state(resource->device.handle, &state);
803 if (result) 862 if (result)
804 goto unlock; 863 continue;
805 864
806 if (state == ACPI_POWER_RESOURCE_STATE_OFF && resource->ref_count) 865 if (state == ACPI_POWER_RESOURCE_STATE_OFF
807 result = __acpi_power_on(resource); 866 && resource->ref_count) {
867 dev_info(&resource->device.dev, "Turning ON\n");
868 __acpi_power_on(resource);
869 } else if (state == ACPI_POWER_RESOURCE_STATE_ON
870 && !resource->ref_count) {
871 dev_info(&resource->device.dev, "Turning OFF\n");
872 __acpi_power_off(resource);
873 }
808 874
809 unlock: 875 mutex_unlock(&resource->resource_lock);
810 mutex_unlock(&resource->resource_lock); 876 }
811 877
812 return result; 878 mutex_unlock(&power_resource_list_lock);
813} 879}
814#endif 880#endif
815
816int __init acpi_power_init(void)
817{
818 INIT_LIST_HEAD(&acpi_power_resource_list);
819 return acpi_bus_register_driver(&acpi_power_driver);
820}
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index ef98796b3824..52ce76725c20 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -311,11 +311,12 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
311 dev->pnp.bus_id, 311 dev->pnp.bus_id,
312 (u32) dev->wakeup.sleep_state); 312 (u32) dev->wakeup.sleep_state);
313 313
314 if (!dev->physical_node_count) 314 if (!dev->physical_node_count) {
315 seq_printf(seq, "%c%-8s\n", 315 seq_printf(seq, "%c%-8s\n",
316 dev->wakeup.flags.run_wake ? 316 dev->wakeup.flags.run_wake ? '*' : ' ',
317 '*' : ' ', "disabled"); 317 device_may_wakeup(&dev->dev) ?
318 else { 318 "enabled" : "disabled");
319 } else {
319 struct device *ldev; 320 struct device *ldev;
320 list_for_each_entry(entry, &dev->physical_node_list, 321 list_for_each_entry(entry, &dev->physical_node_list,
321 node) { 322 node) {
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index e83311bf1ebd..cbf1f122666b 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -81,7 +81,7 @@ MODULE_DESCRIPTION("ACPI Processor Driver");
81MODULE_LICENSE("GPL"); 81MODULE_LICENSE("GPL");
82 82
83static int acpi_processor_add(struct acpi_device *device); 83static int acpi_processor_add(struct acpi_device *device);
84static int acpi_processor_remove(struct acpi_device *device, int type); 84static int acpi_processor_remove(struct acpi_device *device);
85static void acpi_processor_notify(struct acpi_device *device, u32 event); 85static void acpi_processor_notify(struct acpi_device *device, u32 event);
86static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr); 86static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr);
87static int acpi_processor_handle_eject(struct acpi_processor *pr); 87static int acpi_processor_handle_eject(struct acpi_processor *pr);
@@ -610,7 +610,7 @@ err_free_pr:
610 return result; 610 return result;
611} 611}
612 612
613static int acpi_processor_remove(struct acpi_device *device, int type) 613static int acpi_processor_remove(struct acpi_device *device)
614{ 614{
615 struct acpi_processor *pr = NULL; 615 struct acpi_processor *pr = NULL;
616 616
@@ -623,7 +623,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
623 if (pr->id >= nr_cpu_ids) 623 if (pr->id >= nr_cpu_ids)
624 goto free; 624 goto free;
625 625
626 if (type == ACPI_BUS_REMOVAL_EJECT) { 626 if (device->removal_type == ACPI_BUS_REMOVAL_EJECT) {
627 if (acpi_processor_handle_eject(pr)) 627 if (acpi_processor_handle_eject(pr))
628 return -EINVAL; 628 return -EINVAL;
629 } 629 }
@@ -677,36 +677,17 @@ static int is_processor_present(acpi_handle handle)
677 return 0; 677 return 0;
678} 678}
679 679
680static
681int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
682{
683 acpi_handle phandle;
684 struct acpi_device *pdev;
685
686
687 if (acpi_get_parent(handle, &phandle)) {
688 return -ENODEV;
689 }
690
691 if (acpi_bus_get_device(phandle, &pdev)) {
692 return -ENODEV;
693 }
694
695 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
696 return -ENODEV;
697 }
698
699 return 0;
700}
701
702static void acpi_processor_hotplug_notify(acpi_handle handle, 680static void acpi_processor_hotplug_notify(acpi_handle handle,
703 u32 event, void *data) 681 u32 event, void *data)
704{ 682{
705 struct acpi_device *device = NULL; 683 struct acpi_device *device = NULL;
706 struct acpi_eject_event *ej_event = NULL; 684 struct acpi_eject_event *ej_event = NULL;
707 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ 685 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
686 acpi_status status;
708 int result; 687 int result;
709 688
689 acpi_scan_lock_acquire();
690
710 switch (event) { 691 switch (event) {
711 case ACPI_NOTIFY_BUS_CHECK: 692 case ACPI_NOTIFY_BUS_CHECK:
712 case ACPI_NOTIFY_DEVICE_CHECK: 693 case ACPI_NOTIFY_DEVICE_CHECK:
@@ -721,12 +702,16 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
721 if (!acpi_bus_get_device(handle, &device)) 702 if (!acpi_bus_get_device(handle, &device))
722 break; 703 break;
723 704
724 result = acpi_processor_device_add(handle, &device); 705 result = acpi_bus_scan(handle);
725 if (result) { 706 if (result) {
726 acpi_handle_err(handle, "Unable to add the device\n"); 707 acpi_handle_err(handle, "Unable to add the device\n");
727 break; 708 break;
728 } 709 }
729 710 result = acpi_bus_get_device(handle, &device);
711 if (result) {
712 acpi_handle_err(handle, "Missing device object\n");
713 break;
714 }
730 ost_code = ACPI_OST_SC_SUCCESS; 715 ost_code = ACPI_OST_SC_SUCCESS;
731 break; 716 break;
732 717
@@ -751,25 +736,32 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
751 break; 736 break;
752 } 737 }
753 738
754 ej_event->handle = handle; 739 get_device(&device->dev);
740 ej_event->device = device;
755 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 741 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
756 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, 742 /* The eject is carried out asynchronously. */
757 (void *)ej_event); 743 status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
758 744 ej_event);
759 /* eject is performed asynchronously */ 745 if (ACPI_FAILURE(status)) {
760 return; 746 put_device(&device->dev);
747 kfree(ej_event);
748 break;
749 }
750 goto out;
761 751
762 default: 752 default:
763 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 753 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
764 "Unsupported event [0x%x]\n", event)); 754 "Unsupported event [0x%x]\n", event));
765 755
766 /* non-hotplug event; possibly handled by other handler */ 756 /* non-hotplug event; possibly handled by other handler */
767 return; 757 goto out;
768 } 758 }
769 759
770 /* Inform firmware that the hotplug operation has completed */ 760 /* Inform firmware that the hotplug operation has completed */
771 (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL); 761 (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL);
772 return; 762
763 out:
764 acpi_scan_lock_release();
773} 765}
774 766
775static acpi_status is_processor_device(acpi_handle handle) 767static acpi_status is_processor_device(acpi_handle handle)
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index ed9a1cc690be..fc95308e9a11 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -28,19 +28,12 @@
28 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 28 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 */ 29 */
30 30
31#include <linux/kernel.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <linux/init.h>
34#include <linux/cpufreq.h>
35#include <linux/slab.h>
36#include <linux/acpi.h> 32#include <linux/acpi.h>
37#include <linux/dmi.h> 33#include <linux/dmi.h>
38#include <linux/moduleparam.h> 34#include <linux/sched.h> /* need_resched() */
39#include <linux/sched.h> /* need_resched() */
40#include <linux/pm_qos.h>
41#include <linux/clockchips.h> 35#include <linux/clockchips.h>
42#include <linux/cpuidle.h> 36#include <linux/cpuidle.h>
43#include <linux/irqflags.h>
44 37
45/* 38/*
46 * Include the apic definitions for x86 to have the APIC timer related defines 39 * Include the apic definitions for x86 to have the APIC timer related defines
@@ -52,22 +45,14 @@
52#include <asm/apic.h> 45#include <asm/apic.h>
53#endif 46#endif
54 47
55#include <asm/io.h>
56#include <asm/uaccess.h>
57
58#include <acpi/acpi_bus.h> 48#include <acpi/acpi_bus.h>
59#include <acpi/processor.h> 49#include <acpi/processor.h>
60#include <asm/processor.h>
61 50
62#define PREFIX "ACPI: " 51#define PREFIX "ACPI: "
63 52
64#define ACPI_PROCESSOR_CLASS "processor" 53#define ACPI_PROCESSOR_CLASS "processor"
65#define _COMPONENT ACPI_PROCESSOR_COMPONENT 54#define _COMPONENT ACPI_PROCESSOR_COMPONENT
66ACPI_MODULE_NAME("processor_idle"); 55ACPI_MODULE_NAME("processor_idle");
67#define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY)
68#define C2_OVERHEAD 1 /* 1us */
69#define C3_OVERHEAD 1 /* 1us */
70#define PM_TIMER_TICKS_TO_US(p) (((p) * 1000)/(PM_TIMER_FREQUENCY/1000))
71 56
72static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER; 57static unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER;
73module_param(max_cstate, uint, 0000); 58module_param(max_cstate, uint, 0000);
@@ -81,10 +66,11 @@ module_param(latency_factor, uint, 0644);
81 66
82static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device); 67static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device);
83 68
69static struct acpi_processor_cx *acpi_cstate[CPUIDLE_STATE_MAX];
70
84static int disabled_by_idle_boot_param(void) 71static int disabled_by_idle_boot_param(void)
85{ 72{
86 return boot_option_idle_override == IDLE_POLL || 73 return boot_option_idle_override == IDLE_POLL ||
87 boot_option_idle_override == IDLE_FORCE_MWAIT ||
88 boot_option_idle_override == IDLE_HALT; 74 boot_option_idle_override == IDLE_HALT;
89} 75}
90 76
@@ -736,8 +722,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
736 struct cpuidle_driver *drv, int index) 722 struct cpuidle_driver *drv, int index)
737{ 723{
738 struct acpi_processor *pr; 724 struct acpi_processor *pr;
739 struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 725 struct acpi_processor_cx *cx = acpi_cstate[index];
740 struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);
741 726
742 pr = __this_cpu_read(processors); 727 pr = __this_cpu_read(processors);
743 728
@@ -760,8 +745,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
760 */ 745 */
761static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) 746static int acpi_idle_play_dead(struct cpuidle_device *dev, int index)
762{ 747{
763 struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 748 struct acpi_processor_cx *cx = acpi_cstate[index];
764 struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);
765 749
766 ACPI_FLUSH_CPU_CACHE(); 750 ACPI_FLUSH_CPU_CACHE();
767 751
@@ -791,8 +775,7 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
791 struct cpuidle_driver *drv, int index) 775 struct cpuidle_driver *drv, int index)
792{ 776{
793 struct acpi_processor *pr; 777 struct acpi_processor *pr;
794 struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 778 struct acpi_processor_cx *cx = acpi_cstate[index];
795 struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);
796 779
797 pr = __this_cpu_read(processors); 780 pr = __this_cpu_read(processors);
798 781
@@ -850,8 +833,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
850 struct cpuidle_driver *drv, int index) 833 struct cpuidle_driver *drv, int index)
851{ 834{
852 struct acpi_processor *pr; 835 struct acpi_processor *pr;
853 struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 836 struct acpi_processor_cx *cx = acpi_cstate[index];
854 struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);
855 837
856 pr = __this_cpu_read(processors); 838 pr = __this_cpu_read(processors);
857 839
@@ -943,13 +925,13 @@ struct cpuidle_driver acpi_idle_driver = {
943 * device i.e. per-cpu data 925 * device i.e. per-cpu data
944 * 926 *
945 * @pr: the ACPI processor 927 * @pr: the ACPI processor
928 * @dev : the cpuidle device
946 */ 929 */
947static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr) 930static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
931 struct cpuidle_device *dev)
948{ 932{
949 int i, count = CPUIDLE_DRIVER_STATE_START; 933 int i, count = CPUIDLE_DRIVER_STATE_START;
950 struct acpi_processor_cx *cx; 934 struct acpi_processor_cx *cx;
951 struct cpuidle_state_usage *state_usage;
952 struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
953 935
954 if (!pr->flags.power_setup_done) 936 if (!pr->flags.power_setup_done)
955 return -EINVAL; 937 return -EINVAL;
@@ -968,7 +950,6 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr)
968 950
969 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { 951 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
970 cx = &pr->power.states[i]; 952 cx = &pr->power.states[i];
971 state_usage = &dev->states_usage[count];
972 953
973 if (!cx->valid) 954 if (!cx->valid)
974 continue; 955 continue;
@@ -979,8 +960,7 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr)
979 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED)) 960 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
980 continue; 961 continue;
981#endif 962#endif
982 963 acpi_cstate[count] = cx;
983 cpuidle_set_statedata(state_usage, cx);
984 964
985 count++; 965 count++;
986 if (count == CPUIDLE_STATE_MAX) 966 if (count == CPUIDLE_STATE_MAX)
@@ -1104,7 +1084,7 @@ int acpi_processor_hotplug(struct acpi_processor *pr)
1104 cpuidle_disable_device(dev); 1084 cpuidle_disable_device(dev);
1105 acpi_processor_get_power_info(pr); 1085 acpi_processor_get_power_info(pr);
1106 if (pr->flags.power) { 1086 if (pr->flags.power) {
1107 acpi_processor_setup_cpuidle_cx(pr); 1087 acpi_processor_setup_cpuidle_cx(pr, dev);
1108 ret = cpuidle_enable_device(dev); 1088 ret = cpuidle_enable_device(dev);
1109 } 1089 }
1110 cpuidle_resume_and_unlock(); 1090 cpuidle_resume_and_unlock();
@@ -1162,8 +1142,8 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1162 continue; 1142 continue;
1163 acpi_processor_get_power_info(_pr); 1143 acpi_processor_get_power_info(_pr);
1164 if (_pr->flags.power) { 1144 if (_pr->flags.power) {
1165 acpi_processor_setup_cpuidle_cx(_pr);
1166 dev = per_cpu(acpi_cpuidle_device, cpu); 1145 dev = per_cpu(acpi_cpuidle_device, cpu);
1146 acpi_processor_setup_cpuidle_cx(_pr, dev);
1167 cpuidle_enable_device(dev); 1147 cpuidle_enable_device(dev);
1168 } 1148 }
1169 } 1149 }
@@ -1232,7 +1212,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr)
1232 return -ENOMEM; 1212 return -ENOMEM;
1233 per_cpu(acpi_cpuidle_device, pr->id) = dev; 1213 per_cpu(acpi_cpuidle_device, pr->id) = dev;
1234 1214
1235 acpi_processor_setup_cpuidle_cx(pr); 1215 acpi_processor_setup_cpuidle_cx(pr, dev);
1236 1216
1237 /* Register per-cpu cpuidle_device. Cpuidle driver 1217 /* Register per-cpu cpuidle_device. Cpuidle driver
1238 * must already be registered before registering device 1218 * must already be registered before registering device
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index ff0740e0a9c2..e523245643ac 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -130,7 +130,7 @@ struct acpi_sbs {
130 130
131#define to_acpi_sbs(x) container_of(x, struct acpi_sbs, charger) 131#define to_acpi_sbs(x) container_of(x, struct acpi_sbs, charger)
132 132
133static int acpi_sbs_remove(struct acpi_device *device, int type); 133static int acpi_sbs_remove(struct acpi_device *device);
134static int acpi_battery_get_state(struct acpi_battery *battery); 134static int acpi_battery_get_state(struct acpi_battery *battery);
135 135
136static inline int battery_scale(int log) 136static inline int battery_scale(int log)
@@ -949,11 +949,11 @@ static int acpi_sbs_add(struct acpi_device *device)
949 acpi_smbus_register_callback(sbs->hc, acpi_sbs_callback, sbs); 949 acpi_smbus_register_callback(sbs->hc, acpi_sbs_callback, sbs);
950 end: 950 end:
951 if (result) 951 if (result)
952 acpi_sbs_remove(device, 0); 952 acpi_sbs_remove(device);
953 return result; 953 return result;
954} 954}
955 955
956static int acpi_sbs_remove(struct acpi_device *device, int type) 956static int acpi_sbs_remove(struct acpi_device *device)
957{ 957{
958 struct acpi_sbs *sbs; 958 struct acpi_sbs *sbs;
959 int id; 959 int id;
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index cf6129a8af7c..b78bc605837e 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -33,7 +33,7 @@ struct acpi_smb_hc {
33}; 33};
34 34
35static int acpi_smbus_hc_add(struct acpi_device *device); 35static int acpi_smbus_hc_add(struct acpi_device *device);
36static int acpi_smbus_hc_remove(struct acpi_device *device, int type); 36static int acpi_smbus_hc_remove(struct acpi_device *device);
37 37
38static const struct acpi_device_id sbs_device_ids[] = { 38static const struct acpi_device_id sbs_device_ids[] = {
39 {"ACPI0001", 0}, 39 {"ACPI0001", 0},
@@ -296,7 +296,7 @@ static int acpi_smbus_hc_add(struct acpi_device *device)
296 296
297extern void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit); 297extern void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
298 298
299static int acpi_smbus_hc_remove(struct acpi_device *device, int type) 299static int acpi_smbus_hc_remove(struct acpi_device *device)
300{ 300{
301 struct acpi_smb_hc *hc; 301 struct acpi_smb_hc *hc;
302 302
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index c88be6c37c30..daee7497efd3 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -29,29 +29,10 @@ extern struct acpi_device *acpi_root;
29 29
30static const char *dummy_hid = "device"; 30static const char *dummy_hid = "device";
31 31
32/*
33 * The following ACPI IDs are known to be suitable for representing as
34 * platform devices.
35 */
36static const struct acpi_device_id acpi_platform_device_ids[] = {
37
38 { "PNP0D40" },
39
40 /* Haswell LPSS devices */
41 { "INT33C0", 0 },
42 { "INT33C1", 0 },
43 { "INT33C2", 0 },
44 { "INT33C3", 0 },
45 { "INT33C4", 0 },
46 { "INT33C5", 0 },
47 { "INT33C6", 0 },
48 { "INT33C7", 0 },
49
50 { }
51};
52
53static LIST_HEAD(acpi_device_list); 32static LIST_HEAD(acpi_device_list);
54static LIST_HEAD(acpi_bus_id_list); 33static LIST_HEAD(acpi_bus_id_list);
34static DEFINE_MUTEX(acpi_scan_lock);
35static LIST_HEAD(acpi_scan_handlers_list);
55DEFINE_MUTEX(acpi_device_lock); 36DEFINE_MUTEX(acpi_device_lock);
56LIST_HEAD(acpi_wakeup_device_list); 37LIST_HEAD(acpi_wakeup_device_list);
57 38
@@ -61,6 +42,27 @@ struct acpi_device_bus_id{
61 struct list_head node; 42 struct list_head node;
62}; 43};
63 44
45void acpi_scan_lock_acquire(void)
46{
47 mutex_lock(&acpi_scan_lock);
48}
49EXPORT_SYMBOL_GPL(acpi_scan_lock_acquire);
50
51void acpi_scan_lock_release(void)
52{
53 mutex_unlock(&acpi_scan_lock);
54}
55EXPORT_SYMBOL_GPL(acpi_scan_lock_release);
56
57int acpi_scan_add_handler(struct acpi_scan_handler *handler)
58{
59 if (!handler || !handler->attach)
60 return -EINVAL;
61
62 list_add_tail(&handler->list_node, &acpi_scan_handlers_list);
63 return 0;
64}
65
64/* 66/*
65 * Creates hid/cid(s) string needed for modalias and uevent 67 * Creates hid/cid(s) string needed for modalias and uevent
66 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get: 68 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
@@ -115,39 +117,32 @@ static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
115 */ 117 */
116void acpi_bus_hot_remove_device(void *context) 118void acpi_bus_hot_remove_device(void *context)
117{ 119{
118 struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context; 120 struct acpi_eject_event *ej_event = context;
119 struct acpi_device *device; 121 struct acpi_device *device = ej_event->device;
120 acpi_handle handle = ej_event->handle; 122 acpi_handle handle = device->handle;
121 acpi_handle temp; 123 acpi_handle temp;
122 struct acpi_object_list arg_list; 124 struct acpi_object_list arg_list;
123 union acpi_object arg; 125 union acpi_object arg;
124 acpi_status status = AE_OK; 126 acpi_status status = AE_OK;
125 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ 127 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
126 128
127 if (acpi_bus_get_device(handle, &device)) 129 mutex_lock(&acpi_scan_lock);
128 goto err_out;
129 130
130 if (!device) 131 /* If there is no handle, the device node has been unregistered. */
131 goto err_out; 132 if (!device->handle) {
133 dev_dbg(&device->dev, "ACPI handle missing\n");
134 put_device(&device->dev);
135 goto out;
136 }
132 137
133 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 138 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
134 "Hot-removing device %s...\n", dev_name(&device->dev))); 139 "Hot-removing device %s...\n", dev_name(&device->dev)));
135 140
136 if (acpi_bus_trim(device, 1)) { 141 acpi_bus_trim(device);
137 printk(KERN_ERR PREFIX 142 /* Device node has been unregistered. */
138 "Removing device failed\n"); 143 put_device(&device->dev);
139 goto err_out;
140 }
141
142 /* device has been freed */
143 device = NULL; 144 device = NULL;
144 145
145 /* power off device */
146 status = acpi_evaluate_object(handle, "_PS3", NULL, NULL);
147 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
148 printk(KERN_WARNING PREFIX
149 "Power-off device failed\n");
150
151 if (ACPI_SUCCESS(acpi_get_handle(handle, "_LCK", &temp))) { 146 if (ACPI_SUCCESS(acpi_get_handle(handle, "_LCK", &temp))) {
152 arg_list.count = 1; 147 arg_list.count = 1;
153 arg_list.pointer = &arg; 148 arg_list.pointer = &arg;
@@ -167,23 +162,46 @@ void acpi_bus_hot_remove_device(void *context)
167 status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); 162 status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL);
168 if (ACPI_FAILURE(status)) { 163 if (ACPI_FAILURE(status)) {
169 if (status != AE_NOT_FOUND) 164 if (status != AE_NOT_FOUND)
170 printk(KERN_WARNING PREFIX 165 acpi_handle_warn(handle, "Eject failed\n");
171 "Eject device failed\n");
172 goto err_out;
173 }
174 166
175 kfree(context); 167 /* Tell the firmware the hot-remove operation has failed. */
176 return; 168 acpi_evaluate_hotplug_ost(handle, ej_event->event,
169 ost_code, NULL);
170 }
177 171
178err_out: 172 out:
179 /* Inform firmware the hot-remove operation has completed w/ error */ 173 mutex_unlock(&acpi_scan_lock);
180 (void) acpi_evaluate_hotplug_ost(handle,
181 ej_event->event, ost_code, NULL);
182 kfree(context); 174 kfree(context);
183 return; 175 return;
184} 176}
185EXPORT_SYMBOL(acpi_bus_hot_remove_device); 177EXPORT_SYMBOL(acpi_bus_hot_remove_device);
186 178
179static ssize_t real_power_state_show(struct device *dev,
180 struct device_attribute *attr, char *buf)
181{
182 struct acpi_device *adev = to_acpi_device(dev);
183 int state;
184 int ret;
185
186 ret = acpi_device_get_power(adev, &state);
187 if (ret)
188 return ret;
189
190 return sprintf(buf, "%s\n", acpi_power_state_string(state));
191}
192
193static DEVICE_ATTR(real_power_state, 0444, real_power_state_show, NULL);
194
195static ssize_t power_state_show(struct device *dev,
196 struct device_attribute *attr, char *buf)
197{
198 struct acpi_device *adev = to_acpi_device(dev);
199
200 return sprintf(buf, "%s\n", acpi_power_state_string(adev->power.state));
201}
202
203static DEVICE_ATTR(power_state, 0444, power_state_show, NULL);
204
187static ssize_t 205static ssize_t
188acpi_eject_store(struct device *d, struct device_attribute *attr, 206acpi_eject_store(struct device *d, struct device_attribute *attr,
189 const char *buf, size_t count) 207 const char *buf, size_t count)
@@ -197,12 +215,10 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
197 if ((!count) || (buf[0] != '1')) { 215 if ((!count) || (buf[0] != '1')) {
198 return -EINVAL; 216 return -EINVAL;
199 } 217 }
200#ifndef FORCE_EJECT 218 if (!acpi_device->driver && !acpi_device->handler) {
201 if (acpi_device->driver == NULL) {
202 ret = -ENODEV; 219 ret = -ENODEV;
203 goto err; 220 goto err;
204 } 221 }
205#endif
206 status = acpi_get_type(acpi_device->handle, &type); 222 status = acpi_get_type(acpi_device->handle, &type);
207 if (ACPI_FAILURE(status) || (!acpi_device->flags.ejectable)) { 223 if (ACPI_FAILURE(status) || (!acpi_device->flags.ejectable)) {
208 ret = -ENODEV; 224 ret = -ENODEV;
@@ -215,7 +231,8 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
215 goto err; 231 goto err;
216 } 232 }
217 233
218 ej_event->handle = acpi_device->handle; 234 get_device(&acpi_device->dev);
235 ej_event->device = acpi_device;
219 if (acpi_device->flags.eject_pending) { 236 if (acpi_device->flags.eject_pending) {
220 /* event originated from ACPI eject notification */ 237 /* event originated from ACPI eject notification */
221 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 238 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
@@ -223,11 +240,15 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
223 } else { 240 } else {
224 /* event originated from user */ 241 /* event originated from user */
225 ej_event->event = ACPI_OST_EC_OSPM_EJECT; 242 ej_event->event = ACPI_OST_EC_OSPM_EJECT;
226 (void) acpi_evaluate_hotplug_ost(ej_event->handle, 243 (void) acpi_evaluate_hotplug_ost(acpi_device->handle,
227 ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 244 ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
228 } 245 }
229 246
230 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, (void *)ej_event); 247 status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, ej_event);
248 if (ACPI_FAILURE(status)) {
249 put_device(&acpi_device->dev);
250 kfree(ej_event);
251 }
231err: 252err:
232 return ret; 253 return ret;
233} 254}
@@ -375,8 +396,22 @@ static int acpi_device_setup_files(struct acpi_device *dev)
375 * hot-removal function from userland. 396 * hot-removal function from userland.
376 */ 397 */
377 status = acpi_get_handle(dev->handle, "_EJ0", &temp); 398 status = acpi_get_handle(dev->handle, "_EJ0", &temp);
378 if (ACPI_SUCCESS(status)) 399 if (ACPI_SUCCESS(status)) {
379 result = device_create_file(&dev->dev, &dev_attr_eject); 400 result = device_create_file(&dev->dev, &dev_attr_eject);
401 if (result)
402 return result;
403 }
404
405 if (dev->flags.power_manageable) {
406 result = device_create_file(&dev->dev, &dev_attr_power_state);
407 if (result)
408 return result;
409
410 if (dev->power.flags.power_resources)
411 result = device_create_file(&dev->dev,
412 &dev_attr_real_power_state);
413 }
414
380end: 415end:
381 return result; 416 return result;
382} 417}
@@ -386,6 +421,13 @@ static void acpi_device_remove_files(struct acpi_device *dev)
386 acpi_status status; 421 acpi_status status;
387 acpi_handle temp; 422 acpi_handle temp;
388 423
424 if (dev->flags.power_manageable) {
425 device_remove_file(&dev->dev, &dev_attr_power_state);
426 if (dev->power.flags.power_resources)
427 device_remove_file(&dev->dev,
428 &dev_attr_real_power_state);
429 }
430
389 /* 431 /*
390 * If device has _STR, remove 'description' file 432 * If device has _STR, remove 'description' file
391 */ 433 */
@@ -454,9 +496,9 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
454 const struct device *dev) 496 const struct device *dev)
455{ 497{
456 struct acpi_device *adev; 498 struct acpi_device *adev;
499 acpi_handle handle = ACPI_HANDLE(dev);
457 500
458 if (!ids || !ACPI_HANDLE(dev) 501 if (!ids || !handle || acpi_bus_get_device(handle, &adev))
459 || ACPI_FAILURE(acpi_bus_get_device(ACPI_HANDLE(dev), &adev)))
460 return NULL; 502 return NULL;
461 503
462 return __acpi_match_device(adev, ids); 504 return __acpi_match_device(adev, ids);
@@ -470,7 +512,7 @@ int acpi_match_device_ids(struct acpi_device *device,
470} 512}
471EXPORT_SYMBOL(acpi_match_device_ids); 513EXPORT_SYMBOL(acpi_match_device_ids);
472 514
473static void acpi_free_ids(struct acpi_device *device) 515void acpi_free_ids(struct acpi_device *device)
474{ 516{
475 struct acpi_hardware_id *id, *tmp; 517 struct acpi_hardware_id *id, *tmp;
476 518
@@ -478,6 +520,23 @@ static void acpi_free_ids(struct acpi_device *device)
478 kfree(id->id); 520 kfree(id->id);
479 kfree(id); 521 kfree(id);
480 } 522 }
523 kfree(device->pnp.unique_id);
524}
525
526static void acpi_free_power_resources_lists(struct acpi_device *device)
527{
528 int i;
529
530 if (device->wakeup.flags.valid)
531 acpi_power_resources_list_free(&device->wakeup.resources);
532
533 if (!device->flags.power_manageable)
534 return;
535
536 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++) {
537 struct acpi_device_power_state *ps = &device->power.states[i];
538 acpi_power_resources_list_free(&ps->resources);
539 }
481} 540}
482 541
483static void acpi_device_release(struct device *dev) 542static void acpi_device_release(struct device *dev)
@@ -485,7 +544,7 @@ static void acpi_device_release(struct device *dev)
485 struct acpi_device *acpi_dev = to_acpi_device(dev); 544 struct acpi_device *acpi_dev = to_acpi_device(dev);
486 545
487 acpi_free_ids(acpi_dev); 546 acpi_free_ids(acpi_dev);
488 kfree(acpi_dev->pnp.unique_id); 547 acpi_free_power_resources_lists(acpi_dev);
489 kfree(acpi_dev); 548 kfree(acpi_dev);
490} 549}
491 550
@@ -494,7 +553,8 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv)
494 struct acpi_device *acpi_dev = to_acpi_device(dev); 553 struct acpi_device *acpi_dev = to_acpi_device(dev);
495 struct acpi_driver *acpi_drv = to_acpi_driver(drv); 554 struct acpi_driver *acpi_drv = to_acpi_driver(drv);
496 555
497 return !acpi_match_device_ids(acpi_dev, acpi_drv->ids); 556 return acpi_dev->flags.match_driver
557 && !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
498} 558}
499 559
500static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) 560static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
@@ -570,7 +630,6 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device)
570} 630}
571 631
572static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); 632static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *);
573static int acpi_start_single_object(struct acpi_device *);
574static int acpi_device_probe(struct device * dev) 633static int acpi_device_probe(struct device * dev)
575{ 634{
576 struct acpi_device *acpi_dev = to_acpi_device(dev); 635 struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -579,15 +638,13 @@ static int acpi_device_probe(struct device * dev)
579 638
580 ret = acpi_bus_driver_init(acpi_dev, acpi_drv); 639 ret = acpi_bus_driver_init(acpi_dev, acpi_drv);
581 if (!ret) { 640 if (!ret) {
582 if (acpi_dev->bus_ops.acpi_op_start)
583 acpi_start_single_object(acpi_dev);
584
585 if (acpi_drv->ops.notify) { 641 if (acpi_drv->ops.notify) {
586 ret = acpi_device_install_notify_handler(acpi_dev); 642 ret = acpi_device_install_notify_handler(acpi_dev);
587 if (ret) { 643 if (ret) {
588 if (acpi_drv->ops.remove) 644 if (acpi_drv->ops.remove)
589 acpi_drv->ops.remove(acpi_dev, 645 acpi_drv->ops.remove(acpi_dev);
590 acpi_dev->removal_type); 646 acpi_dev->driver = NULL;
647 acpi_dev->driver_data = NULL;
591 return ret; 648 return ret;
592 } 649 }
593 } 650 }
@@ -609,7 +666,7 @@ static int acpi_device_remove(struct device * dev)
609 if (acpi_drv->ops.notify) 666 if (acpi_drv->ops.notify)
610 acpi_device_remove_notify_handler(acpi_dev); 667 acpi_device_remove_notify_handler(acpi_dev);
611 if (acpi_drv->ops.remove) 668 if (acpi_drv->ops.remove)
612 acpi_drv->ops.remove(acpi_dev, acpi_dev->removal_type); 669 acpi_drv->ops.remove(acpi_dev);
613 } 670 }
614 acpi_dev->driver = NULL; 671 acpi_dev->driver = NULL;
615 acpi_dev->driver_data = NULL; 672 acpi_dev->driver_data = NULL;
@@ -626,12 +683,25 @@ struct bus_type acpi_bus_type = {
626 .uevent = acpi_device_uevent, 683 .uevent = acpi_device_uevent,
627}; 684};
628 685
629static int acpi_device_register(struct acpi_device *device) 686int acpi_device_add(struct acpi_device *device,
687 void (*release)(struct device *))
630{ 688{
631 int result; 689 int result;
632 struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id; 690 struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id;
633 int found = 0; 691 int found = 0;
634 692
693 if (device->handle) {
694 acpi_status status;
695
696 status = acpi_attach_data(device->handle, acpi_bus_data_handler,
697 device);
698 if (ACPI_FAILURE(status)) {
699 acpi_handle_err(device->handle,
700 "Unable to attach device data\n");
701 return -ENODEV;
702 }
703 }
704
635 /* 705 /*
636 * Linkage 706 * Linkage
637 * ------- 707 * -------
@@ -642,11 +712,13 @@ static int acpi_device_register(struct acpi_device *device)
642 INIT_LIST_HEAD(&device->wakeup_list); 712 INIT_LIST_HEAD(&device->wakeup_list);
643 INIT_LIST_HEAD(&device->physical_node_list); 713 INIT_LIST_HEAD(&device->physical_node_list);
644 mutex_init(&device->physical_node_lock); 714 mutex_init(&device->physical_node_lock);
715 INIT_LIST_HEAD(&device->power_dependent);
645 716
646 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); 717 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
647 if (!new_bus_id) { 718 if (!new_bus_id) {
648 printk(KERN_ERR PREFIX "Memory allocation error\n"); 719 pr_err(PREFIX "Memory allocation error\n");
649 return -ENOMEM; 720 result = -ENOMEM;
721 goto err_detach;
650 } 722 }
651 723
652 mutex_lock(&acpi_device_lock); 724 mutex_lock(&acpi_device_lock);
@@ -681,11 +753,11 @@ static int acpi_device_register(struct acpi_device *device)
681 if (device->parent) 753 if (device->parent)
682 device->dev.parent = &device->parent->dev; 754 device->dev.parent = &device->parent->dev;
683 device->dev.bus = &acpi_bus_type; 755 device->dev.bus = &acpi_bus_type;
684 device->dev.release = &acpi_device_release; 756 device->dev.release = release;
685 result = device_register(&device->dev); 757 result = device_add(&device->dev);
686 if (result) { 758 if (result) {
687 dev_err(&device->dev, "Error registering device\n"); 759 dev_err(&device->dev, "Error registering device\n");
688 goto end; 760 goto err;
689 } 761 }
690 762
691 result = acpi_device_setup_files(device); 763 result = acpi_device_setup_files(device);
@@ -695,16 +767,20 @@ static int acpi_device_register(struct acpi_device *device)
695 767
696 device->removal_type = ACPI_BUS_REMOVAL_NORMAL; 768 device->removal_type = ACPI_BUS_REMOVAL_NORMAL;
697 return 0; 769 return 0;
698end: 770
771 err:
699 mutex_lock(&acpi_device_lock); 772 mutex_lock(&acpi_device_lock);
700 if (device->parent) 773 if (device->parent)
701 list_del(&device->node); 774 list_del(&device->node);
702 list_del(&device->wakeup_list); 775 list_del(&device->wakeup_list);
703 mutex_unlock(&acpi_device_lock); 776 mutex_unlock(&acpi_device_lock);
777
778 err_detach:
779 acpi_detach_data(device->handle, acpi_bus_data_handler);
704 return result; 780 return result;
705} 781}
706 782
707static void acpi_device_unregister(struct acpi_device *device, int type) 783static void acpi_device_unregister(struct acpi_device *device)
708{ 784{
709 mutex_lock(&acpi_device_lock); 785 mutex_lock(&acpi_device_lock);
710 if (device->parent) 786 if (device->parent)
@@ -715,8 +791,20 @@ static void acpi_device_unregister(struct acpi_device *device, int type)
715 791
716 acpi_detach_data(device->handle, acpi_bus_data_handler); 792 acpi_detach_data(device->handle, acpi_bus_data_handler);
717 793
794 acpi_power_add_remove_device(device, false);
718 acpi_device_remove_files(device); 795 acpi_device_remove_files(device);
719 device_unregister(&device->dev); 796 if (device->remove)
797 device->remove(device);
798
799 device_del(&device->dev);
800 /*
801 * Transition the device to D3cold to drop the reference counts of all
802 * power resources the device depends on and turn off the ones that have
803 * no more references.
804 */
805 acpi_device_set_power(device, ACPI_STATE_D3_COLD);
806 device->handle = NULL;
807 put_device(&device->dev);
720} 808}
721 809
722/* -------------------------------------------------------------------------- 810/* --------------------------------------------------------------------------
@@ -760,24 +848,6 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
760 return 0; 848 return 0;
761} 849}
762 850
763static int acpi_start_single_object(struct acpi_device *device)
764{
765 int result = 0;
766 struct acpi_driver *driver;
767
768
769 if (!(driver = device->driver))
770 return 0;
771
772 if (driver->ops.start) {
773 result = driver->ops.start(device);
774 if (result && driver->ops.remove)
775 driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
776 }
777
778 return result;
779}
780
781/** 851/**
782 * acpi_bus_register_driver - register a driver with the ACPI bus 852 * acpi_bus_register_driver - register a driver with the ACPI bus
783 * @driver: driver being registered 853 * @driver: driver being registered
@@ -821,29 +891,23 @@ EXPORT_SYMBOL(acpi_bus_unregister_driver);
821 -------------------------------------------------------------------------- */ 891 -------------------------------------------------------------------------- */
822static struct acpi_device *acpi_bus_get_parent(acpi_handle handle) 892static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
823{ 893{
894 struct acpi_device *device = NULL;
824 acpi_status status; 895 acpi_status status;
825 int ret;
826 struct acpi_device *device;
827 896
828 /* 897 /*
829 * Fixed hardware devices do not appear in the namespace and do not 898 * Fixed hardware devices do not appear in the namespace and do not
830 * have handles, but we fabricate acpi_devices for them, so we have 899 * have handles, but we fabricate acpi_devices for them, so we have
831 * to deal with them specially. 900 * to deal with them specially.
832 */ 901 */
833 if (handle == NULL) 902 if (!handle)
834 return acpi_root; 903 return acpi_root;
835 904
836 do { 905 do {
837 status = acpi_get_parent(handle, &handle); 906 status = acpi_get_parent(handle, &handle);
838 if (status == AE_NULL_ENTRY)
839 return NULL;
840 if (ACPI_FAILURE(status)) 907 if (ACPI_FAILURE(status))
841 return acpi_root; 908 return status == AE_NULL_ENTRY ? NULL : acpi_root;
842 909 } while (acpi_bus_get_device(handle, &device));
843 ret = acpi_bus_get_device(handle, &device); 910 return device;
844 if (ret == 0)
845 return device;
846 } while (1);
847} 911}
848 912
849acpi_status 913acpi_status
@@ -877,52 +941,43 @@ void acpi_bus_data_handler(acpi_handle handle, void *context)
877 return; 941 return;
878} 942}
879 943
880static int acpi_bus_get_perf_flags(struct acpi_device *device) 944static int acpi_bus_extract_wakeup_device_power_package(acpi_handle handle,
881{ 945 struct acpi_device_wakeup *wakeup)
882 device->performance.state = ACPI_STATE_UNKNOWN;
883 return 0;
884}
885
886static acpi_status
887acpi_bus_extract_wakeup_device_power_package(acpi_handle handle,
888 struct acpi_device_wakeup *wakeup)
889{ 946{
890 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 947 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
891 union acpi_object *package = NULL; 948 union acpi_object *package = NULL;
892 union acpi_object *element = NULL; 949 union acpi_object *element = NULL;
893 acpi_status status; 950 acpi_status status;
894 int i = 0; 951 int err = -ENODATA;
895 952
896 if (!wakeup) 953 if (!wakeup)
897 return AE_BAD_PARAMETER; 954 return -EINVAL;
955
956 INIT_LIST_HEAD(&wakeup->resources);
898 957
899 /* _PRW */ 958 /* _PRW */
900 status = acpi_evaluate_object(handle, "_PRW", NULL, &buffer); 959 status = acpi_evaluate_object(handle, "_PRW", NULL, &buffer);
901 if (ACPI_FAILURE(status)) { 960 if (ACPI_FAILURE(status)) {
902 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRW")); 961 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRW"));
903 return status; 962 return err;
904 } 963 }
905 964
906 package = (union acpi_object *)buffer.pointer; 965 package = (union acpi_object *)buffer.pointer;
907 966
908 if (!package || (package->package.count < 2)) { 967 if (!package || package->package.count < 2)
909 status = AE_BAD_DATA;
910 goto out; 968 goto out;
911 }
912 969
913 element = &(package->package.elements[0]); 970 element = &(package->package.elements[0]);
914 if (!element) { 971 if (!element)
915 status = AE_BAD_DATA;
916 goto out; 972 goto out;
917 } 973
918 if (element->type == ACPI_TYPE_PACKAGE) { 974 if (element->type == ACPI_TYPE_PACKAGE) {
919 if ((element->package.count < 2) || 975 if ((element->package.count < 2) ||
920 (element->package.elements[0].type != 976 (element->package.elements[0].type !=
921 ACPI_TYPE_LOCAL_REFERENCE) 977 ACPI_TYPE_LOCAL_REFERENCE)
922 || (element->package.elements[1].type != ACPI_TYPE_INTEGER)) { 978 || (element->package.elements[1].type != ACPI_TYPE_INTEGER))
923 status = AE_BAD_DATA;
924 goto out; 979 goto out;
925 } 980
926 wakeup->gpe_device = 981 wakeup->gpe_device =
927 element->package.elements[0].reference.handle; 982 element->package.elements[0].reference.handle;
928 wakeup->gpe_number = 983 wakeup->gpe_number =
@@ -931,38 +986,35 @@ acpi_bus_extract_wakeup_device_power_package(acpi_handle handle,
931 wakeup->gpe_device = NULL; 986 wakeup->gpe_device = NULL;
932 wakeup->gpe_number = element->integer.value; 987 wakeup->gpe_number = element->integer.value;
933 } else { 988 } else {
934 status = AE_BAD_DATA;
935 goto out; 989 goto out;
936 } 990 }
937 991
938 element = &(package->package.elements[1]); 992 element = &(package->package.elements[1]);
939 if (element->type != ACPI_TYPE_INTEGER) { 993 if (element->type != ACPI_TYPE_INTEGER)
940 status = AE_BAD_DATA;
941 goto out; 994 goto out;
942 } 995
943 wakeup->sleep_state = element->integer.value; 996 wakeup->sleep_state = element->integer.value;
944 997
945 if ((package->package.count - 2) > ACPI_MAX_HANDLES) { 998 err = acpi_extract_power_resources(package, 2, &wakeup->resources);
946 status = AE_NO_MEMORY; 999 if (err)
947 goto out; 1000 goto out;
948 }
949 wakeup->resources.count = package->package.count - 2;
950 for (i = 0; i < wakeup->resources.count; i++) {
951 element = &(package->package.elements[i + 2]);
952 if (element->type != ACPI_TYPE_LOCAL_REFERENCE) {
953 status = AE_BAD_DATA;
954 goto out;
955 }
956 1001
957 wakeup->resources.handles[i] = element->reference.handle; 1002 if (!list_empty(&wakeup->resources)) {
958 } 1003 int sleep_state;
959 1004
1005 sleep_state = acpi_power_min_system_level(&wakeup->resources);
1006 if (sleep_state < wakeup->sleep_state) {
1007 acpi_handle_warn(handle, "Overriding _PRW sleep state "
1008 "(S%d) by S%d from power resources\n",
1009 (int)wakeup->sleep_state, sleep_state);
1010 wakeup->sleep_state = sleep_state;
1011 }
1012 }
960 acpi_setup_gpe_for_wake(handle, wakeup->gpe_device, wakeup->gpe_number); 1013 acpi_setup_gpe_for_wake(handle, wakeup->gpe_device, wakeup->gpe_number);
961 1014
962 out: 1015 out:
963 kfree(buffer.pointer); 1016 kfree(buffer.pointer);
964 1017 return err;
965 return status;
966} 1018}
967 1019
968static void acpi_bus_set_run_wake_flags(struct acpi_device *device) 1020static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
@@ -1002,17 +1054,17 @@ static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
1002{ 1054{
1003 acpi_handle temp; 1055 acpi_handle temp;
1004 acpi_status status = 0; 1056 acpi_status status = 0;
1005 int psw_error; 1057 int err;
1006 1058
1007 /* Presence of _PRW indicates wake capable */ 1059 /* Presence of _PRW indicates wake capable */
1008 status = acpi_get_handle(device->handle, "_PRW", &temp); 1060 status = acpi_get_handle(device->handle, "_PRW", &temp);
1009 if (ACPI_FAILURE(status)) 1061 if (ACPI_FAILURE(status))
1010 return; 1062 return;
1011 1063
1012 status = acpi_bus_extract_wakeup_device_power_package(device->handle, 1064 err = acpi_bus_extract_wakeup_device_power_package(device->handle,
1013 &device->wakeup); 1065 &device->wakeup);
1014 if (ACPI_FAILURE(status)) { 1066 if (err) {
1015 ACPI_EXCEPTION((AE_INFO, status, "Extracting _PRW package")); 1067 dev_err(&device->dev, "_PRW evaluation error: %d\n", err);
1016 return; 1068 return;
1017 } 1069 }
1018 1070
@@ -1025,20 +1077,73 @@ static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
1025 * So it is necessary to call _DSW object first. Only when it is not 1077 * So it is necessary to call _DSW object first. Only when it is not
1026 * present will the _PSW object used. 1078 * present will the _PSW object used.
1027 */ 1079 */
1028 psw_error = acpi_device_sleep_wake(device, 0, 0, 0); 1080 err = acpi_device_sleep_wake(device, 0, 0, 0);
1029 if (psw_error) 1081 if (err)
1030 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1082 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1031 "error in _DSW or _PSW evaluation\n")); 1083 "error in _DSW or _PSW evaluation\n"));
1032} 1084}
1033 1085
1034static void acpi_bus_add_power_resource(acpi_handle handle); 1086static void acpi_bus_init_power_state(struct acpi_device *device, int state)
1087{
1088 struct acpi_device_power_state *ps = &device->power.states[state];
1089 char pathname[5] = { '_', 'P', 'R', '0' + state, '\0' };
1090 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1091 acpi_handle handle;
1092 acpi_status status;
1093
1094 INIT_LIST_HEAD(&ps->resources);
1095
1096 /* Evaluate "_PRx" to get referenced power resources */
1097 status = acpi_evaluate_object(device->handle, pathname, NULL, &buffer);
1098 if (ACPI_SUCCESS(status)) {
1099 union acpi_object *package = buffer.pointer;
1100
1101 if (buffer.length && package
1102 && package->type == ACPI_TYPE_PACKAGE
1103 && package->package.count) {
1104 int err = acpi_extract_power_resources(package, 0,
1105 &ps->resources);
1106 if (!err)
1107 device->power.flags.power_resources = 1;
1108 }
1109 ACPI_FREE(buffer.pointer);
1110 }
1111
1112 /* Evaluate "_PSx" to see if we can do explicit sets */
1113 pathname[2] = 'S';
1114 status = acpi_get_handle(device->handle, pathname, &handle);
1115 if (ACPI_SUCCESS(status))
1116 ps->flags.explicit_set = 1;
1117
1118 /*
1119 * State is valid if there are means to put the device into it.
1120 * D3hot is only valid if _PR3 present.
1121 */
1122 if (!list_empty(&ps->resources)
1123 || (ps->flags.explicit_set && state < ACPI_STATE_D3_HOT)) {
1124 ps->flags.valid = 1;
1125 ps->flags.os_accessible = 1;
1126 }
1127
1128 ps->power = -1; /* Unknown - driver assigned */
1129 ps->latency = -1; /* Unknown - driver assigned */
1130}
1035 1131
1036static int acpi_bus_get_power_flags(struct acpi_device *device) 1132static void acpi_bus_get_power_flags(struct acpi_device *device)
1037{ 1133{
1038 acpi_status status = 0; 1134 acpi_status status;
1039 acpi_handle handle = NULL; 1135 acpi_handle handle;
1040 u32 i = 0; 1136 u32 i;
1137
1138 /* Presence of _PS0|_PR0 indicates 'power manageable' */
1139 status = acpi_get_handle(device->handle, "_PS0", &handle);
1140 if (ACPI_FAILURE(status)) {
1141 status = acpi_get_handle(device->handle, "_PR0", &handle);
1142 if (ACPI_FAILURE(status))
1143 return;
1144 }
1041 1145
1146 device->flags.power_manageable = 1;
1042 1147
1043 /* 1148 /*
1044 * Power Management Flags 1149 * Power Management Flags
@@ -1053,40 +1158,10 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
1053 /* 1158 /*
1054 * Enumerate supported power management states 1159 * Enumerate supported power management states
1055 */ 1160 */
1056 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++) { 1161 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++)
1057 struct acpi_device_power_state *ps = &device->power.states[i]; 1162 acpi_bus_init_power_state(device, i);
1058 char object_name[5] = { '_', 'P', 'R', '0' + i, '\0' };
1059
1060 /* Evaluate "_PRx" to se if power resources are referenced */
1061 acpi_evaluate_reference(device->handle, object_name, NULL,
1062 &ps->resources);
1063 if (ps->resources.count) {
1064 int j;
1065
1066 device->power.flags.power_resources = 1;
1067 for (j = 0; j < ps->resources.count; j++)
1068 acpi_bus_add_power_resource(ps->resources.handles[j]);
1069 }
1070 1163
1071 /* Evaluate "_PSx" to see if we can do explicit sets */ 1164 INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources);
1072 object_name[2] = 'S';
1073 status = acpi_get_handle(device->handle, object_name, &handle);
1074 if (ACPI_SUCCESS(status))
1075 ps->flags.explicit_set = 1;
1076
1077 /*
1078 * State is valid if there are means to put the device into it.
1079 * D3hot is only valid if _PR3 present.
1080 */
1081 if (ps->resources.count ||
1082 (ps->flags.explicit_set && i < ACPI_STATE_D3_HOT)) {
1083 ps->flags.valid = 1;
1084 ps->flags.os_accessible = 1;
1085 }
1086
1087 ps->power = -1; /* Unknown - driver assigned */
1088 ps->latency = -1; /* Unknown - driver assigned */
1089 }
1090 1165
1091 /* Set defaults for D0 and D3 states (always valid) */ 1166 /* Set defaults for D0 and D3 states (always valid) */
1092 device->power.states[ACPI_STATE_D0].flags.valid = 1; 1167 device->power.states[ACPI_STATE_D0].flags.valid = 1;
@@ -1103,17 +1178,17 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
1103 device->power.flags.power_resources) 1178 device->power.flags.power_resources)
1104 device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible = 1; 1179 device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible = 1;
1105 1180
1106 acpi_bus_init_power(device); 1181 if (acpi_bus_init_power(device)) {
1107 1182 acpi_free_power_resources_lists(device);
1108 return 0; 1183 device->flags.power_manageable = 0;
1184 }
1109} 1185}
1110 1186
1111static int acpi_bus_get_flags(struct acpi_device *device) 1187static void acpi_bus_get_flags(struct acpi_device *device)
1112{ 1188{
1113 acpi_status status = AE_OK; 1189 acpi_status status = AE_OK;
1114 acpi_handle temp = NULL; 1190 acpi_handle temp = NULL;
1115 1191
1116
1117 /* Presence of _STA indicates 'dynamic_status' */ 1192 /* Presence of _STA indicates 'dynamic_status' */
1118 status = acpi_get_handle(device->handle, "_STA", &temp); 1193 status = acpi_get_handle(device->handle, "_STA", &temp);
1119 if (ACPI_SUCCESS(status)) 1194 if (ACPI_SUCCESS(status))
@@ -1133,21 +1208,6 @@ static int acpi_bus_get_flags(struct acpi_device *device)
1133 if (ACPI_SUCCESS(status)) 1208 if (ACPI_SUCCESS(status))
1134 device->flags.ejectable = 1; 1209 device->flags.ejectable = 1;
1135 } 1210 }
1136
1137 /* Power resources cannot be power manageable. */
1138 if (device->device_type == ACPI_BUS_TYPE_POWER)
1139 return 0;
1140
1141 /* Presence of _PS0|_PR0 indicates 'power manageable' */
1142 status = acpi_get_handle(device->handle, "_PS0", &temp);
1143 if (ACPI_FAILURE(status))
1144 status = acpi_get_handle(device->handle, "_PR0", &temp);
1145 if (ACPI_SUCCESS(status))
1146 device->flags.power_manageable = 1;
1147
1148 /* TBD: Performance management */
1149
1150 return 0;
1151} 1211}
1152 1212
1153static void acpi_device_get_busid(struct acpi_device *device) 1213static void acpi_device_get_busid(struct acpi_device *device)
@@ -1372,56 +1432,32 @@ static void acpi_device_set_id(struct acpi_device *device)
1372 } 1432 }
1373} 1433}
1374 1434
1375static int acpi_device_set_context(struct acpi_device *device) 1435void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1436 int type, unsigned long long sta)
1376{ 1437{
1377 acpi_status status; 1438 INIT_LIST_HEAD(&device->pnp.ids);
1378 1439 device->device_type = type;
1379 /* 1440 device->handle = handle;
1380 * Context 1441 device->parent = acpi_bus_get_parent(handle);
1381 * ------- 1442 STRUCT_TO_INT(device->status) = sta;
1382 * Attach this 'struct acpi_device' to the ACPI object. This makes 1443 acpi_device_get_busid(device);
1383 * resolutions from handle->device very efficient. Fixed hardware 1444 acpi_device_set_id(device);
1384 * devices have no handles, so we skip them. 1445 acpi_bus_get_flags(device);
1385 */ 1446 device->flags.match_driver = false;
1386 if (!device->handle) 1447 device_initialize(&device->dev);
1387 return 0; 1448 dev_set_uevent_suppress(&device->dev, true);
1388
1389 status = acpi_attach_data(device->handle,
1390 acpi_bus_data_handler, device);
1391 if (ACPI_SUCCESS(status))
1392 return 0;
1393
1394 printk(KERN_ERR PREFIX "Error attaching device data\n");
1395 return -ENODEV;
1396} 1449}
1397 1450
1398static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) 1451void acpi_device_add_finalize(struct acpi_device *device)
1399{ 1452{
1400 if (!dev) 1453 device->flags.match_driver = true;
1401 return -EINVAL; 1454 dev_set_uevent_suppress(&device->dev, false);
1402 1455 kobject_uevent(&device->dev.kobj, KOBJ_ADD);
1403 dev->removal_type = ACPI_BUS_REMOVAL_EJECT;
1404 device_release_driver(&dev->dev);
1405
1406 if (!rmdevice)
1407 return 0;
1408
1409 /*
1410 * unbind _ADR-Based Devices when hot removal
1411 */
1412 if (dev->flags.bus_address) {
1413 if ((dev->parent) && (dev->parent->ops.unbind))
1414 dev->parent->ops.unbind(dev);
1415 }
1416 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
1417
1418 return 0;
1419} 1456}
1420 1457
1421static int acpi_add_single_object(struct acpi_device **child, 1458static int acpi_add_single_object(struct acpi_device **child,
1422 acpi_handle handle, int type, 1459 acpi_handle handle, int type,
1423 unsigned long long sta, 1460 unsigned long long sta)
1424 struct acpi_bus_ops *ops)
1425{ 1461{
1426 int result; 1462 int result;
1427 struct acpi_device *device; 1463 struct acpi_device *device;
@@ -1433,102 +1469,25 @@ static int acpi_add_single_object(struct acpi_device **child,
1433 return -ENOMEM; 1469 return -ENOMEM;
1434 } 1470 }
1435 1471
1436 INIT_LIST_HEAD(&device->pnp.ids); 1472 acpi_init_device_object(device, handle, type, sta);
1437 device->device_type = type; 1473 acpi_bus_get_power_flags(device);
1438 device->handle = handle;
1439 device->parent = acpi_bus_get_parent(handle);
1440 device->bus_ops = *ops; /* workround for not call .start */
1441 STRUCT_TO_INT(device->status) = sta;
1442
1443 acpi_device_get_busid(device);
1444
1445 /*
1446 * Flags
1447 * -----
1448 * Note that we only look for object handles -- cannot evaluate objects
1449 * until we know the device is present and properly initialized.
1450 */
1451 result = acpi_bus_get_flags(device);
1452 if (result)
1453 goto end;
1454
1455 /*
1456 * Initialize Device
1457 * -----------------
1458 * TBD: Synch with Core's enumeration/initialization process.
1459 */
1460 acpi_device_set_id(device);
1461
1462 /*
1463 * Power Management
1464 * ----------------
1465 */
1466 if (device->flags.power_manageable) {
1467 result = acpi_bus_get_power_flags(device);
1468 if (result)
1469 goto end;
1470 }
1471
1472 /*
1473 * Wakeup device management
1474 *-----------------------
1475 */
1476 acpi_bus_get_wakeup_device_flags(device); 1474 acpi_bus_get_wakeup_device_flags(device);
1477 1475
1478 /* 1476 result = acpi_device_add(device, acpi_device_release);
1479 * Performance Management 1477 if (result) {
1480 * ----------------------
1481 */
1482 if (device->flags.performance_manageable) {
1483 result = acpi_bus_get_perf_flags(device);
1484 if (result)
1485 goto end;
1486 }
1487
1488 if ((result = acpi_device_set_context(device)))
1489 goto end;
1490
1491 result = acpi_device_register(device);
1492
1493 /*
1494 * Bind _ADR-Based Devices when hot add
1495 */
1496 if (device->flags.bus_address) {
1497 if (device->parent && device->parent->ops.bind)
1498 device->parent->ops.bind(device);
1499 }
1500
1501end:
1502 if (!result) {
1503 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
1504 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1505 "Adding %s [%s] parent %s\n", dev_name(&device->dev),
1506 (char *) buffer.pointer,
1507 device->parent ? dev_name(&device->parent->dev) :
1508 "(null)"));
1509 kfree(buffer.pointer);
1510 *child = device;
1511 } else
1512 acpi_device_release(&device->dev); 1478 acpi_device_release(&device->dev);
1479 return result;
1480 }
1513 1481
1514 return result; 1482 acpi_power_add_remove_device(device, true);
1515} 1483 acpi_device_add_finalize(device);
1516 1484 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
1517#define ACPI_STA_DEFAULT (ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | \ 1485 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Added %s [%s] parent %s\n",
1518 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING) 1486 dev_name(&device->dev), (char *) buffer.pointer,
1519 1487 device->parent ? dev_name(&device->parent->dev) : "(null)"));
1520static void acpi_bus_add_power_resource(acpi_handle handle) 1488 kfree(buffer.pointer);
1521{ 1489 *child = device;
1522 struct acpi_bus_ops ops = { 1490 return 0;
1523 .acpi_op_add = 1,
1524 .acpi_op_start = 1,
1525 };
1526 struct acpi_device *device = NULL;
1527
1528 acpi_bus_get_device(handle, &device);
1529 if (!device)
1530 acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER,
1531 ACPI_STA_DEFAULT, &ops);
1532} 1491}
1533 1492
1534static int acpi_bus_type_and_status(acpi_handle handle, int *type, 1493static int acpi_bus_type_and_status(acpi_handle handle, int *type,
@@ -1570,218 +1529,248 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
1570 return 0; 1529 return 0;
1571} 1530}
1572 1531
1573static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, 1532static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1574 void *context, void **return_value) 1533 void *not_used, void **return_value)
1575{ 1534{
1576 struct acpi_bus_ops *ops = context; 1535 struct acpi_device *device = NULL;
1577 int type; 1536 int type;
1578 unsigned long long sta; 1537 unsigned long long sta;
1579 struct acpi_device *device;
1580 acpi_status status; 1538 acpi_status status;
1581 int result; 1539 int result;
1582 1540
1541 acpi_bus_get_device(handle, &device);
1542 if (device)
1543 goto out;
1544
1583 result = acpi_bus_type_and_status(handle, &type, &sta); 1545 result = acpi_bus_type_and_status(handle, &type, &sta);
1584 if (result) 1546 if (result)
1585 return AE_OK; 1547 return AE_OK;
1586 1548
1549 if (type == ACPI_BUS_TYPE_POWER) {
1550 acpi_add_power_resource(handle);
1551 return AE_OK;
1552 }
1553
1587 if (!(sta & ACPI_STA_DEVICE_PRESENT) && 1554 if (!(sta & ACPI_STA_DEVICE_PRESENT) &&
1588 !(sta & ACPI_STA_DEVICE_FUNCTIONING)) { 1555 !(sta & ACPI_STA_DEVICE_FUNCTIONING)) {
1589 struct acpi_device_wakeup wakeup; 1556 struct acpi_device_wakeup wakeup;
1590 acpi_handle temp; 1557 acpi_handle temp;
1591 1558
1592 status = acpi_get_handle(handle, "_PRW", &temp); 1559 status = acpi_get_handle(handle, "_PRW", &temp);
1593 if (ACPI_SUCCESS(status)) 1560 if (ACPI_SUCCESS(status)) {
1594 acpi_bus_extract_wakeup_device_power_package(handle, 1561 acpi_bus_extract_wakeup_device_power_package(handle,
1595 &wakeup); 1562 &wakeup);
1563 acpi_power_resources_list_free(&wakeup.resources);
1564 }
1596 return AE_CTRL_DEPTH; 1565 return AE_CTRL_DEPTH;
1597 } 1566 }
1598 1567
1599 /* 1568 acpi_add_single_object(&device, handle, type, sta);
1600 * We may already have an acpi_device from a previous enumeration. If
1601 * so, we needn't add it again, but we may still have to start it.
1602 */
1603 device = NULL;
1604 acpi_bus_get_device(handle, &device);
1605 if (ops->acpi_op_add && !device) {
1606 acpi_add_single_object(&device, handle, type, sta, ops);
1607 /* Is the device a known good platform device? */
1608 if (device
1609 && !acpi_match_device_ids(device, acpi_platform_device_ids))
1610 acpi_create_platform_device(device);
1611 }
1612
1613 if (!device) 1569 if (!device)
1614 return AE_CTRL_DEPTH; 1570 return AE_CTRL_DEPTH;
1615 1571
1616 if (ops->acpi_op_start && !(ops->acpi_op_add)) { 1572 out:
1617 status = acpi_start_single_object(device);
1618 if (ACPI_FAILURE(status))
1619 return AE_CTRL_DEPTH;
1620 }
1621
1622 if (!*return_value) 1573 if (!*return_value)
1623 *return_value = device; 1574 *return_value = device;
1575
1624 return AE_OK; 1576 return AE_OK;
1625} 1577}
1626 1578
1627static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops, 1579static int acpi_scan_do_attach_handler(struct acpi_device *device, char *id)
1628 struct acpi_device **child)
1629{ 1580{
1630 acpi_status status; 1581 struct acpi_scan_handler *handler;
1631 void *device = NULL;
1632 1582
1633 status = acpi_bus_check_add(handle, 0, ops, &device); 1583 list_for_each_entry(handler, &acpi_scan_handlers_list, list_node) {
1634 if (ACPI_SUCCESS(status)) 1584 const struct acpi_device_id *devid;
1635 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1636 acpi_bus_check_add, NULL, ops, &device);
1637 1585
1638 if (child) 1586 for (devid = handler->ids; devid->id[0]; devid++) {
1639 *child = device; 1587 int ret;
1640 1588
1641 if (device) 1589 if (strcmp((char *)devid->id, id))
1642 return 0; 1590 continue;
1643 else
1644 return -ENODEV;
1645}
1646 1591
1647/* 1592 ret = handler->attach(device, devid);
1648 * acpi_bus_add and acpi_bus_start 1593 if (ret > 0) {
1649 * 1594 device->handler = handler;
1650 * scan a given ACPI tree and (probably recently hot-plugged) 1595 return ret;
1651 * create and add or starts found devices. 1596 } else if (ret < 0) {
1652 * 1597 return ret;
1653 * If no devices were found -ENODEV is returned which does not 1598 }
1654 * mean that this is a real error, there just have been no suitable 1599 }
1655 * ACPI objects in the table trunk from which the kernel could create 1600 }
1656 * a device and add/start an appropriate driver. 1601 return 0;
1657 */ 1602}
1658 1603
1659int 1604static int acpi_scan_attach_handler(struct acpi_device *device)
1660acpi_bus_add(struct acpi_device **child,
1661 struct acpi_device *parent, acpi_handle handle, int type)
1662{ 1605{
1663 struct acpi_bus_ops ops; 1606 struct acpi_hardware_id *hwid;
1607 int ret = 0;
1664 1608
1665 memset(&ops, 0, sizeof(ops)); 1609 list_for_each_entry(hwid, &device->pnp.ids, list) {
1666 ops.acpi_op_add = 1; 1610 ret = acpi_scan_do_attach_handler(device, hwid->id);
1611 if (ret)
1612 break;
1667 1613
1668 return acpi_bus_scan(handle, &ops, child); 1614 }
1615 return ret;
1669} 1616}
1670EXPORT_SYMBOL(acpi_bus_add);
1671 1617
1672int acpi_bus_start(struct acpi_device *device) 1618static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
1619 void *not_used, void **ret_not_used)
1673{ 1620{
1674 struct acpi_bus_ops ops; 1621 struct acpi_device *device;
1675 int result; 1622 unsigned long long sta_not_used;
1676 1623 int ret;
1677 if (!device)
1678 return -EINVAL;
1679 1624
1680 memset(&ops, 0, sizeof(ops)); 1625 /*
1681 ops.acpi_op_start = 1; 1626 * Ignore errors ignored by acpi_bus_check_add() to avoid terminating
1627 * namespace walks prematurely.
1628 */
1629 if (acpi_bus_type_and_status(handle, &ret, &sta_not_used))
1630 return AE_OK;
1682 1631
1683 result = acpi_bus_scan(device->handle, &ops, NULL); 1632 if (acpi_bus_get_device(handle, &device))
1633 return AE_CTRL_DEPTH;
1684 1634
1685 acpi_update_all_gpes(); 1635 ret = acpi_scan_attach_handler(device);
1636 if (ret)
1637 return ret > 0 ? AE_OK : AE_CTRL_DEPTH;
1686 1638
1687 return result; 1639 ret = device_attach(&device->dev);
1640 return ret >= 0 ? AE_OK : AE_CTRL_DEPTH;
1688} 1641}
1689EXPORT_SYMBOL(acpi_bus_start);
1690 1642
1691int acpi_bus_trim(struct acpi_device *start, int rmdevice) 1643/**
1644 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
1645 * @handle: Root of the namespace scope to scan.
1646 *
1647 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
1648 * found devices.
1649 *
1650 * If no devices were found, -ENODEV is returned, but it does not mean that
1651 * there has been a real error. There just have been no suitable ACPI objects
1652 * in the table trunk from which the kernel could create a device and add an
1653 * appropriate driver.
1654 *
1655 * Must be called under acpi_scan_lock.
1656 */
1657int acpi_bus_scan(acpi_handle handle)
1692{ 1658{
1693 acpi_status status; 1659 void *device = NULL;
1694 struct acpi_device *parent, *child; 1660 int error = 0;
1695 acpi_handle phandle, chandle;
1696 acpi_object_type type;
1697 u32 level = 1;
1698 int err = 0;
1699 1661
1700 parent = start; 1662 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
1701 phandle = start->handle; 1663 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1702 child = chandle = NULL; 1664 acpi_bus_check_add, NULL, NULL, &device);
1703 1665
1704 while ((level > 0) && parent && (!err)) { 1666 if (!device)
1705 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, 1667 error = -ENODEV;
1706 chandle, &chandle); 1668 else if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
1669 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1670 acpi_bus_device_attach, NULL, NULL, NULL);
1707 1671
1708 /* 1672 return error;
1709 * If this scope is exhausted then move our way back up. 1673}
1710 */ 1674EXPORT_SYMBOL(acpi_bus_scan);
1711 if (ACPI_FAILURE(status)) {
1712 level--;
1713 chandle = phandle;
1714 acpi_get_parent(phandle, &phandle);
1715 child = parent;
1716 parent = parent->parent;
1717
1718 if (level == 0)
1719 err = acpi_bus_remove(child, rmdevice);
1720 else
1721 err = acpi_bus_remove(child, 1);
1722 1675
1723 continue; 1676static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
1724 } 1677 void *not_used, void **ret_not_used)
1678{
1679 struct acpi_device *device = NULL;
1725 1680
1726 status = acpi_get_type(chandle, &type); 1681 if (!acpi_bus_get_device(handle, &device)) {
1727 if (ACPI_FAILURE(status)) { 1682 struct acpi_scan_handler *dev_handler = device->handler;
1728 continue; 1683
1729 } 1684 device->removal_type = ACPI_BUS_REMOVAL_EJECT;
1730 /* 1685 if (dev_handler) {
1731 * If there is a device corresponding to chandle then 1686 if (dev_handler->detach)
1732 * parse it (depth-first). 1687 dev_handler->detach(device);
1733 */ 1688
1734 if (acpi_bus_get_device(chandle, &child) == 0) { 1689 device->handler = NULL;
1735 level++; 1690 } else {
1736 phandle = chandle; 1691 device_release_driver(&device->dev);
1737 chandle = NULL;
1738 parent = child;
1739 } 1692 }
1740 continue;
1741 } 1693 }
1742 return err; 1694 return AE_OK;
1695}
1696
1697static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
1698 void *not_used, void **ret_not_used)
1699{
1700 struct acpi_device *device = NULL;
1701
1702 if (!acpi_bus_get_device(handle, &device))
1703 acpi_device_unregister(device);
1704
1705 return AE_OK;
1706}
1707
1708/**
1709 * acpi_bus_trim - Remove ACPI device node and all of its descendants
1710 * @start: Root of the ACPI device nodes subtree to remove.
1711 *
1712 * Must be called under acpi_scan_lock.
1713 */
1714void acpi_bus_trim(struct acpi_device *start)
1715{
1716 /*
1717 * Execute acpi_bus_device_detach() as a post-order callback to detach
1718 * all ACPI drivers from the device nodes being removed.
1719 */
1720 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
1721 acpi_bus_device_detach, NULL, NULL);
1722 acpi_bus_device_detach(start->handle, 0, NULL, NULL);
1723 /*
1724 * Execute acpi_bus_remove() as a post-order callback to remove device
1725 * nodes in the given namespace scope.
1726 */
1727 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
1728 acpi_bus_remove, NULL, NULL);
1729 acpi_bus_remove(start->handle, 0, NULL, NULL);
1743} 1730}
1744EXPORT_SYMBOL_GPL(acpi_bus_trim); 1731EXPORT_SYMBOL_GPL(acpi_bus_trim);
1745 1732
1746static int acpi_bus_scan_fixed(void) 1733static int acpi_bus_scan_fixed(void)
1747{ 1734{
1748 int result = 0; 1735 int result = 0;
1749 struct acpi_device *device = NULL;
1750 struct acpi_bus_ops ops;
1751
1752 memset(&ops, 0, sizeof(ops));
1753 ops.acpi_op_add = 1;
1754 ops.acpi_op_start = 1;
1755 1736
1756 /* 1737 /*
1757 * Enumerate all fixed-feature devices. 1738 * Enumerate all fixed-feature devices.
1758 */ 1739 */
1759 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { 1740 if (!(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) {
1741 struct acpi_device *device = NULL;
1742
1760 result = acpi_add_single_object(&device, NULL, 1743 result = acpi_add_single_object(&device, NULL,
1761 ACPI_BUS_TYPE_POWER_BUTTON, 1744 ACPI_BUS_TYPE_POWER_BUTTON,
1762 ACPI_STA_DEFAULT, 1745 ACPI_STA_DEFAULT);
1763 &ops); 1746 if (result)
1747 return result;
1748
1749 result = device_attach(&device->dev);
1750 if (result < 0)
1751 return result;
1752
1764 device_init_wakeup(&device->dev, true); 1753 device_init_wakeup(&device->dev, true);
1765 } 1754 }
1766 1755
1767 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { 1756 if (!(acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON)) {
1757 struct acpi_device *device = NULL;
1758
1768 result = acpi_add_single_object(&device, NULL, 1759 result = acpi_add_single_object(&device, NULL,
1769 ACPI_BUS_TYPE_SLEEP_BUTTON, 1760 ACPI_BUS_TYPE_SLEEP_BUTTON,
1770 ACPI_STA_DEFAULT, 1761 ACPI_STA_DEFAULT);
1771 &ops); 1762 if (result)
1763 return result;
1764
1765 result = device_attach(&device->dev);
1772 } 1766 }
1773 1767
1774 return result; 1768 return result < 0 ? result : 0;
1775} 1769}
1776 1770
1777int __init acpi_scan_init(void) 1771int __init acpi_scan_init(void)
1778{ 1772{
1779 int result; 1773 int result;
1780 struct acpi_bus_ops ops;
1781
1782 memset(&ops, 0, sizeof(ops));
1783 ops.acpi_op_add = 1;
1784 ops.acpi_op_start = 1;
1785 1774
1786 result = bus_register(&acpi_bus_type); 1775 result = bus_register(&acpi_bus_type);
1787 if (result) { 1776 if (result) {
@@ -1789,20 +1778,33 @@ int __init acpi_scan_init(void)
1789 printk(KERN_ERR PREFIX "Could not register bus type\n"); 1778 printk(KERN_ERR PREFIX "Could not register bus type\n");
1790 } 1779 }
1791 1780
1792 acpi_power_init(); 1781 acpi_pci_root_init();
1782 acpi_pci_link_init();
1783 acpi_platform_init();
1784 acpi_csrt_init();
1785 acpi_container_init();
1793 1786
1787 mutex_lock(&acpi_scan_lock);
1794 /* 1788 /*
1795 * Enumerate devices in the ACPI namespace. 1789 * Enumerate devices in the ACPI namespace.
1796 */ 1790 */
1797 result = acpi_bus_scan(ACPI_ROOT_OBJECT, &ops, &acpi_root); 1791 result = acpi_bus_scan(ACPI_ROOT_OBJECT);
1798 1792 if (result)
1799 if (!result) 1793 goto out;
1800 result = acpi_bus_scan_fixed();
1801 1794
1795 result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
1802 if (result) 1796 if (result)
1803 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1797 goto out;
1804 else 1798
1805 acpi_update_all_gpes(); 1799 result = acpi_bus_scan_fixed();
1800 if (result) {
1801 acpi_device_unregister(acpi_root);
1802 goto out;
1803 }
1806 1804
1805 acpi_update_all_gpes();
1806
1807 out:
1808 mutex_unlock(&acpi_scan_lock);
1807 return result; 1809 return result;
1808} 1810}
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 2fcc67d34b11..6d3a06a629a1 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -177,6 +177,14 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
177 }, 177 },
178 { 178 {
179 .callback = init_nvs_nosave, 179 .callback = init_nvs_nosave,
180 .ident = "Sony Vaio VGN-FW41E_H",
181 .matches = {
182 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
183 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW41E_H"),
184 },
185 },
186 {
187 .callback = init_nvs_nosave,
180 .ident = "Sony Vaio VGN-FW21E", 188 .ident = "Sony Vaio VGN-FW21E",
181 .matches = { 189 .matches = {
182 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), 190 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
@@ -386,6 +394,8 @@ static void acpi_pm_finish(void)
386 394
387 acpi_target_sleep_state = ACPI_STATE_S0; 395 acpi_target_sleep_state = ACPI_STATE_S0;
388 396
397 acpi_resume_power_resources();
398
389 /* If we were woken with the fixed power button, provide a small 399 /* If we were woken with the fixed power button, provide a small
390 * hint to userspace in the form of a wakeup event on the fixed power 400 * hint to userspace in the form of a wakeup event on the fixed power
391 * button device (if it can be found). 401 * button device (if it can be found).
@@ -577,7 +587,28 @@ static const struct platform_suspend_ops acpi_suspend_ops_old = {
577 .end = acpi_pm_end, 587 .end = acpi_pm_end,
578 .recover = acpi_pm_finish, 588 .recover = acpi_pm_finish,
579}; 589};
580#endif /* CONFIG_SUSPEND */ 590
591static void acpi_sleep_suspend_setup(void)
592{
593 int i;
594
595 for (i = ACPI_STATE_S1; i < ACPI_STATE_S4; i++) {
596 acpi_status status;
597 u8 type_a, type_b;
598
599 status = acpi_get_sleep_type_data(i, &type_a, &type_b);
600 if (ACPI_SUCCESS(status)) {
601 sleep_states[i] = 1;
602 pr_cont(" S%d", i);
603 }
604 }
605
606 suspend_set_ops(old_suspend_ordering ?
607 &acpi_suspend_ops_old : &acpi_suspend_ops);
608}
609#else /* !CONFIG_SUSPEND */
610static inline void acpi_sleep_suspend_setup(void) {}
611#endif /* !CONFIG_SUSPEND */
581 612
582#ifdef CONFIG_HIBERNATION 613#ifdef CONFIG_HIBERNATION
583static unsigned long s4_hardware_signature; 614static unsigned long s4_hardware_signature;
@@ -698,7 +729,30 @@ static const struct platform_hibernation_ops acpi_hibernation_ops_old = {
698 .restore_cleanup = acpi_pm_thaw, 729 .restore_cleanup = acpi_pm_thaw,
699 .recover = acpi_pm_finish, 730 .recover = acpi_pm_finish,
700}; 731};
701#endif /* CONFIG_HIBERNATION */ 732
733static void acpi_sleep_hibernate_setup(void)
734{
735 acpi_status status;
736 u8 type_a, type_b;
737
738 status = acpi_get_sleep_type_data(ACPI_STATE_S4, &type_a, &type_b);
739 if (ACPI_FAILURE(status))
740 return;
741
742 hibernation_set_ops(old_suspend_ordering ?
743 &acpi_hibernation_ops_old : &acpi_hibernation_ops);
744 sleep_states[ACPI_STATE_S4] = 1;
745 pr_cont(KERN_CONT " S4");
746 if (nosigcheck)
747 return;
748
749 acpi_get_table(ACPI_SIG_FACS, 1, (struct acpi_table_header **)&facs);
750 if (facs)
751 s4_hardware_signature = facs->hardware_signature;
752}
753#else /* !CONFIG_HIBERNATION */
754static inline void acpi_sleep_hibernate_setup(void) {}
755#endif /* !CONFIG_HIBERNATION */
702 756
703int acpi_suspend(u32 acpi_state) 757int acpi_suspend(u32 acpi_state)
704{ 758{
@@ -734,9 +788,6 @@ int __init acpi_sleep_init(void)
734{ 788{
735 acpi_status status; 789 acpi_status status;
736 u8 type_a, type_b; 790 u8 type_a, type_b;
737#ifdef CONFIG_SUSPEND
738 int i = 0;
739#endif
740 791
741 if (acpi_disabled) 792 if (acpi_disabled)
742 return 0; 793 return 0;
@@ -744,45 +795,19 @@ int __init acpi_sleep_init(void)
744 acpi_sleep_dmi_check(); 795 acpi_sleep_dmi_check();
745 796
746 sleep_states[ACPI_STATE_S0] = 1; 797 sleep_states[ACPI_STATE_S0] = 1;
747 printk(KERN_INFO PREFIX "(supports S0"); 798 pr_info(PREFIX "(supports S0");
748
749#ifdef CONFIG_SUSPEND
750 for (i = ACPI_STATE_S1; i < ACPI_STATE_S4; i++) {
751 status = acpi_get_sleep_type_data(i, &type_a, &type_b);
752 if (ACPI_SUCCESS(status)) {
753 sleep_states[i] = 1;
754 printk(KERN_CONT " S%d", i);
755 }
756 }
757 799
758 suspend_set_ops(old_suspend_ordering ? 800 acpi_sleep_suspend_setup();
759 &acpi_suspend_ops_old : &acpi_suspend_ops); 801 acpi_sleep_hibernate_setup();
760#endif
761 802
762#ifdef CONFIG_HIBERNATION
763 status = acpi_get_sleep_type_data(ACPI_STATE_S4, &type_a, &type_b);
764 if (ACPI_SUCCESS(status)) {
765 hibernation_set_ops(old_suspend_ordering ?
766 &acpi_hibernation_ops_old : &acpi_hibernation_ops);
767 sleep_states[ACPI_STATE_S4] = 1;
768 printk(KERN_CONT " S4");
769 if (!nosigcheck) {
770 acpi_get_table(ACPI_SIG_FACS, 1,
771 (struct acpi_table_header **)&facs);
772 if (facs)
773 s4_hardware_signature =
774 facs->hardware_signature;
775 }
776 }
777#endif
778 status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); 803 status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
779 if (ACPI_SUCCESS(status)) { 804 if (ACPI_SUCCESS(status)) {
780 sleep_states[ACPI_STATE_S5] = 1; 805 sleep_states[ACPI_STATE_S5] = 1;
781 printk(KERN_CONT " S5"); 806 pr_cont(" S5");
782 pm_power_off_prepare = acpi_power_off_prepare; 807 pm_power_off_prepare = acpi_power_off_prepare;
783 pm_power_off = acpi_power_off; 808 pm_power_off = acpi_power_off;
784 } 809 }
785 printk(KERN_CONT ")\n"); 810 pr_cont(")\n");
786 /* 811 /*
787 * Register the tts_notifier to reboot notifier list so that the _TTS 812 * Register the tts_notifier to reboot notifier list so that the _TTS
788 * object can also be evaluated when the system enters S5. 813 * object can also be evaluated when the system enters S5.
diff --git a/drivers/acpi/sleep.h b/drivers/acpi/sleep.h
index 74d59c8f4678..0143540a2519 100644
--- a/drivers/acpi/sleep.h
+++ b/drivers/acpi/sleep.h
@@ -6,3 +6,5 @@ extern void acpi_disable_wakeup_devices(u8 sleep_state);
6 6
7extern struct list_head acpi_wakeup_device_list; 7extern struct list_head acpi_wakeup_device_list;
8extern struct mutex acpi_device_lock; 8extern struct mutex acpi_device_lock;
9
10extern void acpi_resume_power_resources(void);
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index ea61ca9129cd..41c0504470db 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -498,7 +498,7 @@ static int get_status(u32 index, acpi_event_status *status,
498 result = acpi_get_gpe_device(index, handle); 498 result = acpi_get_gpe_device(index, handle);
499 if (result) { 499 if (result) {
500 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND, 500 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
501 "Invalid GPE 0x%x\n", index)); 501 "Invalid GPE 0x%x", index));
502 goto end; 502 goto end;
503 } 503 }
504 result = acpi_get_gpe_status(*handle, index, status); 504 result = acpi_get_gpe_status(*handle, index, status);
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 2572d9715bda..d67a1fe07f0e 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -204,7 +204,7 @@ int __init
204acpi_table_parse_entries(char *id, 204acpi_table_parse_entries(char *id,
205 unsigned long table_size, 205 unsigned long table_size,
206 int entry_id, 206 int entry_id,
207 acpi_table_entry_handler handler, 207 acpi_tbl_entry_handler handler,
208 unsigned int max_entries) 208 unsigned int max_entries)
209{ 209{
210 struct acpi_table_header *table_header = NULL; 210 struct acpi_table_header *table_header = NULL;
@@ -269,7 +269,7 @@ err:
269 269
270int __init 270int __init
271acpi_table_parse_madt(enum acpi_madt_type id, 271acpi_table_parse_madt(enum acpi_madt_type id,
272 acpi_table_entry_handler handler, unsigned int max_entries) 272 acpi_tbl_entry_handler handler, unsigned int max_entries)
273{ 273{
274 return acpi_table_parse_entries(ACPI_SIG_MADT, 274 return acpi_table_parse_entries(ACPI_SIG_MADT,
275 sizeof(struct acpi_table_madt), id, 275 sizeof(struct acpi_table_madt), id,
@@ -285,7 +285,7 @@ acpi_table_parse_madt(enum acpi_madt_type id,
285 * Scan the ACPI System Descriptor Table (STD) for a table matching @id, 285 * Scan the ACPI System Descriptor Table (STD) for a table matching @id,
286 * run @handler on it. Return 0 if table found, return on if not. 286 * run @handler on it. Return 0 if table found, return on if not.
287 */ 287 */
288int __init acpi_table_parse(char *id, acpi_table_handler handler) 288int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
289{ 289{
290 struct acpi_table_header *table = NULL; 290 struct acpi_table_header *table = NULL;
291 acpi_size tbl_size; 291 acpi_size tbl_size;
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 506fbd4b5733..8470771e5eae 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -97,7 +97,7 @@ module_param(psv, int, 0644);
97MODULE_PARM_DESC(psv, "Disable or override all passive trip points."); 97MODULE_PARM_DESC(psv, "Disable or override all passive trip points.");
98 98
99static int acpi_thermal_add(struct acpi_device *device); 99static int acpi_thermal_add(struct acpi_device *device);
100static int acpi_thermal_remove(struct acpi_device *device, int type); 100static int acpi_thermal_remove(struct acpi_device *device);
101static void acpi_thermal_notify(struct acpi_device *device, u32 event); 101static void acpi_thermal_notify(struct acpi_device *device, u32 event);
102 102
103static const struct acpi_device_id thermal_device_ids[] = { 103static const struct acpi_device_id thermal_device_ids[] = {
@@ -288,7 +288,7 @@ do { \
288 if (flags != ACPI_TRIPS_INIT) \ 288 if (flags != ACPI_TRIPS_INIT) \
289 ACPI_EXCEPTION((AE_INFO, AE_ERROR, \ 289 ACPI_EXCEPTION((AE_INFO, AE_ERROR, \
290 "ACPI thermal trip point %s changed\n" \ 290 "ACPI thermal trip point %s changed\n" \
291 "Please send acpidump to linux-acpi@vger.kernel.org\n", str)); \ 291 "Please send acpidump to linux-acpi@vger.kernel.org", str)); \
292} while (0) 292} while (0)
293 293
294static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) 294static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
@@ -531,6 +531,10 @@ static void acpi_thermal_check(void *data)
531{ 531{
532 struct acpi_thermal *tz = data; 532 struct acpi_thermal *tz = data;
533 533
534 if (!tz->tz_enabled) {
535 pr_warn("thermal zone is disabled \n");
536 return;
537 }
534 thermal_zone_device_update(tz->thermal_zone); 538 thermal_zone_device_update(tz->thermal_zone);
535} 539}
536 540
@@ -1111,7 +1115,7 @@ end:
1111 return result; 1115 return result;
1112} 1116}
1113 1117
1114static int acpi_thermal_remove(struct acpi_device *device, int type) 1118static int acpi_thermal_remove(struct acpi_device *device)
1115{ 1119{
1116 struct acpi_thermal *tz = NULL; 1120 struct acpi_thermal *tz = NULL;
1117 1121
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index ac9a69cd45f5..313f959413dc 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -88,7 +88,7 @@ module_param(use_bios_initial_backlight, bool, 0644);
88 88
89static int register_count = 0; 89static int register_count = 0;
90static int acpi_video_bus_add(struct acpi_device *device); 90static int acpi_video_bus_add(struct acpi_device *device);
91static int acpi_video_bus_remove(struct acpi_device *device, int type); 91static int acpi_video_bus_remove(struct acpi_device *device);
92static void acpi_video_bus_notify(struct acpi_device *device, u32 event); 92static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
93 93
94static const struct acpi_device_id video_device_ids[] = { 94static const struct acpi_device_id video_device_ids[] = {
@@ -673,7 +673,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
673 br->levels[i] = br->levels[i - level_ac_battery]; 673 br->levels[i] = br->levels[i - level_ac_battery];
674 count += level_ac_battery; 674 count += level_ac_battery;
675 } else if (level_ac_battery > 2) 675 } else if (level_ac_battery > 2)
676 ACPI_ERROR((AE_INFO, "Too many duplicates in _BCL package\n")); 676 ACPI_ERROR((AE_INFO, "Too many duplicates in _BCL package"));
677 677
678 /* Check if the _BCL package is in a reversed order */ 678 /* Check if the _BCL package is in a reversed order */
679 if (max_level == br->levels[2]) { 679 if (max_level == br->levels[2]) {
@@ -682,7 +682,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
682 acpi_video_cmp_level, NULL); 682 acpi_video_cmp_level, NULL);
683 } else if (max_level != br->levels[count - 1]) 683 } else if (max_level != br->levels[count - 1])
684 ACPI_ERROR((AE_INFO, 684 ACPI_ERROR((AE_INFO,
685 "Found unordered _BCL package\n")); 685 "Found unordered _BCL package"));
686 686
687 br->count = count; 687 br->count = count;
688 device->brightness = br; 688 device->brightness = br;
@@ -1740,7 +1740,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
1740 return error; 1740 return error;
1741} 1741}
1742 1742
1743static int acpi_video_bus_remove(struct acpi_device *device, int type) 1743static int acpi_video_bus_remove(struct acpi_device *device)
1744{ 1744{
1745 struct acpi_video_bus *video = NULL; 1745 struct acpi_video_bus *video = NULL;
1746 1746
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ef01ac07502e..6fc67f7efb22 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -1029,30 +1029,20 @@ static void ata_acpi_register_power_resource(struct ata_device *dev)
1029{ 1029{
1030 struct scsi_device *sdev = dev->sdev; 1030 struct scsi_device *sdev = dev->sdev;
1031 acpi_handle handle; 1031 acpi_handle handle;
1032 struct device *device;
1033 1032
1034 handle = ata_dev_acpi_handle(dev); 1033 handle = ata_dev_acpi_handle(dev);
1035 if (!handle) 1034 if (handle)
1036 return; 1035 acpi_dev_pm_remove_dependent(handle, &sdev->sdev_gendev);
1037
1038 device = &sdev->sdev_gendev;
1039
1040 acpi_power_resource_register_device(device, handle);
1041} 1036}
1042 1037
1043static void ata_acpi_unregister_power_resource(struct ata_device *dev) 1038static void ata_acpi_unregister_power_resource(struct ata_device *dev)
1044{ 1039{
1045 struct scsi_device *sdev = dev->sdev; 1040 struct scsi_device *sdev = dev->sdev;
1046 acpi_handle handle; 1041 acpi_handle handle;
1047 struct device *device;
1048 1042
1049 handle = ata_dev_acpi_handle(dev); 1043 handle = ata_dev_acpi_handle(dev);
1050 if (!handle) 1044 if (handle)
1051 return; 1045 acpi_dev_pm_remove_dependent(handle, &sdev->sdev_gendev);
1052
1053 device = &sdev->sdev_gendev;
1054
1055 acpi_power_resource_unregister_device(device, handle);
1056} 1046}
1057 1047
1058void ata_acpi_bind(struct ata_device *dev) 1048void ata_acpi_bind(struct ata_device *dev)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index acc3a8ded29d..9a6b05a35603 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -433,8 +433,7 @@ static bool genpd_abort_poweroff(struct generic_pm_domain *genpd)
433 */ 433 */
434void genpd_queue_power_off_work(struct generic_pm_domain *genpd) 434void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
435{ 435{
436 if (!work_pending(&genpd->power_off_work)) 436 queue_work(pm_wq, &genpd->power_off_work);
437 queue_work(pm_wq, &genpd->power_off_work);
438} 437}
439 438
440/** 439/**
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 50b2831e027d..32ee0fc7ea54 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -162,7 +162,7 @@ unsigned long opp_get_voltage(struct opp *opp)
162 162
163 return v; 163 return v;
164} 164}
165EXPORT_SYMBOL(opp_get_voltage); 165EXPORT_SYMBOL_GPL(opp_get_voltage);
166 166
167/** 167/**
168 * opp_get_freq() - Gets the frequency corresponding to an available opp 168 * opp_get_freq() - Gets the frequency corresponding to an available opp
@@ -192,7 +192,7 @@ unsigned long opp_get_freq(struct opp *opp)
192 192
193 return f; 193 return f;
194} 194}
195EXPORT_SYMBOL(opp_get_freq); 195EXPORT_SYMBOL_GPL(opp_get_freq);
196 196
197/** 197/**
198 * opp_get_opp_count() - Get number of opps available in the opp list 198 * opp_get_opp_count() - Get number of opps available in the opp list
@@ -225,7 +225,7 @@ int opp_get_opp_count(struct device *dev)
225 225
226 return count; 226 return count;
227} 227}
228EXPORT_SYMBOL(opp_get_opp_count); 228EXPORT_SYMBOL_GPL(opp_get_opp_count);
229 229
230/** 230/**
231 * opp_find_freq_exact() - search for an exact frequency 231 * opp_find_freq_exact() - search for an exact frequency
@@ -276,7 +276,7 @@ struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq,
276 276
277 return opp; 277 return opp;
278} 278}
279EXPORT_SYMBOL(opp_find_freq_exact); 279EXPORT_SYMBOL_GPL(opp_find_freq_exact);
280 280
281/** 281/**
282 * opp_find_freq_ceil() - Search for an rounded ceil freq 282 * opp_find_freq_ceil() - Search for an rounded ceil freq
@@ -323,7 +323,7 @@ struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq)
323 323
324 return opp; 324 return opp;
325} 325}
326EXPORT_SYMBOL(opp_find_freq_ceil); 326EXPORT_SYMBOL_GPL(opp_find_freq_ceil);
327 327
328/** 328/**
329 * opp_find_freq_floor() - Search for a rounded floor freq 329 * opp_find_freq_floor() - Search for a rounded floor freq
@@ -374,7 +374,7 @@ struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq)
374 374
375 return opp; 375 return opp;
376} 376}
377EXPORT_SYMBOL(opp_find_freq_floor); 377EXPORT_SYMBOL_GPL(opp_find_freq_floor);
378 378
379/** 379/**
380 * opp_add() - Add an OPP table from a table definitions 380 * opp_add() - Add an OPP table from a table definitions
@@ -568,7 +568,7 @@ int opp_enable(struct device *dev, unsigned long freq)
568{ 568{
569 return opp_set_availability(dev, freq, true); 569 return opp_set_availability(dev, freq, true);
570} 570}
571EXPORT_SYMBOL(opp_enable); 571EXPORT_SYMBOL_GPL(opp_enable);
572 572
573/** 573/**
574 * opp_disable() - Disable a specific OPP 574 * opp_disable() - Disable a specific OPP
@@ -590,7 +590,7 @@ int opp_disable(struct device *dev, unsigned long freq)
590{ 590{
591 return opp_set_availability(dev, freq, false); 591 return opp_set_availability(dev, freq, false);
592} 592}
593EXPORT_SYMBOL(opp_disable); 593EXPORT_SYMBOL_GPL(opp_disable);
594 594
595#ifdef CONFIG_CPU_FREQ 595#ifdef CONFIG_CPU_FREQ
596/** 596/**
@@ -661,6 +661,7 @@ int opp_init_cpufreq_table(struct device *dev,
661 661
662 return 0; 662 return 0;
663} 663}
664EXPORT_SYMBOL_GPL(opp_init_cpufreq_table);
664 665
665/** 666/**
666 * opp_free_cpufreq_table() - free the cpufreq table 667 * opp_free_cpufreq_table() - free the cpufreq table
@@ -678,6 +679,7 @@ void opp_free_cpufreq_table(struct device *dev,
678 kfree(*table); 679 kfree(*table);
679 *table = NULL; 680 *table = NULL;
680} 681}
682EXPORT_SYMBOL_GPL(opp_free_cpufreq_table);
681#endif /* CONFIG_CPU_FREQ */ 683#endif /* CONFIG_CPU_FREQ */
682 684
683/** 685/**
@@ -738,4 +740,5 @@ int of_init_opp_table(struct device *dev)
738 740
739 return 0; 741 return 0;
740} 742}
743EXPORT_SYMBOL_GPL(of_init_opp_table);
741#endif 744#endif
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index e6ee5e80e546..79715e7fa43e 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -382,6 +382,12 @@ static void wakeup_source_activate(struct wakeup_source *ws)
382{ 382{
383 unsigned int cec; 383 unsigned int cec;
384 384
385 /*
386 * active wakeup source should bring the system
387 * out of PM_SUSPEND_FREEZE state
388 */
389 freeze_wake();
390
385 ws->active = true; 391 ws->active = true;
386 ws->active_count++; 392 ws->active_count++;
387 ws->last_time = ktime_get(); 393 ws->last_time = ktime_get();
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index fe6d4be48296..e3f9a99b8522 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -1041,7 +1041,7 @@ static int hpet_acpi_add(struct acpi_device *device)
1041 return hpet_alloc(&data); 1041 return hpet_alloc(&data);
1042} 1042}
1043 1043
1044static int hpet_acpi_remove(struct acpi_device *device, int type) 1044static int hpet_acpi_remove(struct acpi_device *device)
1045{ 1045{
1046 /* XXX need to unregister clocksource, dealloc mem, etc */ 1046 /* XXX need to unregister clocksource, dealloc mem, etc */
1047 return -EINVAL; 1047 return -EINVAL;
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index d780295a1473..6386a98e43c1 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -1142,7 +1142,7 @@ static int sonypi_acpi_add(struct acpi_device *device)
1142 return 0; 1142 return 0;
1143} 1143}
1144 1144
1145static int sonypi_acpi_remove(struct acpi_device *device, int type) 1145static int sonypi_acpi_remove(struct acpi_device *device)
1146{ 1146{
1147 sonypi_acpi_device = NULL; 1147 sonypi_acpi_device = NULL;
1148 return 0; 1148 return 0;
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 0ad642fbe794..14fde73ea6ff 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_MACH_LOONGSON1) += clk-ls1x.o
26obj-$(CONFIG_ARCH_U8500) += ux500/ 26obj-$(CONFIG_ARCH_U8500) += ux500/
27obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o 27obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
28obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o 28obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
29obj-$(CONFIG_X86) += x86/
29 30
30# Chip specific 31# Chip specific
31obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o 32obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
diff --git a/drivers/clk/clk-highbank.c b/drivers/clk/clk-highbank.c
index 5d1de2e11753..2e08cb001936 100644
--- a/drivers/clk/clk-highbank.c
+++ b/drivers/clk/clk-highbank.c
@@ -182,8 +182,10 @@ static int clk_pll_set_rate(struct clk_hw *hwclk, unsigned long rate,
182 reg |= HB_PLL_EXT_ENA; 182 reg |= HB_PLL_EXT_ENA;
183 reg &= ~HB_PLL_EXT_BYPASS; 183 reg &= ~HB_PLL_EXT_BYPASS;
184 } else { 184 } else {
185 writel(reg | HB_PLL_EXT_BYPASS, hbclk->reg);
185 reg &= ~HB_PLL_DIVQ_MASK; 186 reg &= ~HB_PLL_DIVQ_MASK;
186 reg |= divq << HB_PLL_DIVQ_SHIFT; 187 reg |= divq << HB_PLL_DIVQ_SHIFT;
188 writel(reg | HB_PLL_EXT_BYPASS, hbclk->reg);
187 } 189 }
188 writel(reg, hbclk->reg); 190 writel(reg, hbclk->reg);
189 191
diff --git a/drivers/clk/mvebu/clk-gating-ctrl.c b/drivers/clk/mvebu/clk-gating-ctrl.c
index 8fa5408b6c7d..ebf141d4374b 100644
--- a/drivers/clk/mvebu/clk-gating-ctrl.c
+++ b/drivers/clk/mvebu/clk-gating-ctrl.c
@@ -193,6 +193,7 @@ static const struct mvebu_soc_descr __initconst kirkwood_gating_descr[] = {
193 { "runit", NULL, 7 }, 193 { "runit", NULL, 7 },
194 { "xor0", NULL, 8 }, 194 { "xor0", NULL, 8 },
195 { "audio", NULL, 9 }, 195 { "audio", NULL, 9 },
196 { "powersave", "cpuclk", 11 },
196 { "sata0", NULL, 14 }, 197 { "sata0", NULL, 14 },
197 { "sata1", NULL, 15 }, 198 { "sata1", NULL, 15 },
198 { "xor1", NULL, 16 }, 199 { "xor1", NULL, 16 },
diff --git a/drivers/clk/x86/Makefile b/drivers/clk/x86/Makefile
new file mode 100644
index 000000000000..f9ba4fab0ddc
--- /dev/null
+++ b/drivers/clk/x86/Makefile
@@ -0,0 +1,2 @@
1clk-x86-lpss-objs := clk-lpss.o clk-lpt.o
2obj-$(CONFIG_X86_INTEL_LPSS) += clk-x86-lpss.o
diff --git a/drivers/clk/x86/clk-lpss.c b/drivers/clk/x86/clk-lpss.c
new file mode 100644
index 000000000000..b5e229f3c3d9
--- /dev/null
+++ b/drivers/clk/x86/clk-lpss.c
@@ -0,0 +1,99 @@
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
20static 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
26static 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 */
71struct 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
new file mode 100644
index 000000000000..e9460f442297
--- /dev/null
+++ b/drivers/clk/x86/clk-lpss.h
@@ -0,0 +1,36 @@
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
21extern 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
26static 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
new file mode 100644
index 000000000000..81298aeef7e3
--- /dev/null
+++ b/drivers/clk/x86/clk-lpt.c
@@ -0,0 +1,86 @@
1/*
2 * Intel Lynxpoint LPSS 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/clkdev.h>
16#include <linux/clk-provider.h>
17#include <linux/err.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20
21#include "clk-lpss.h"
22
23#define PRV_CLOCK_PARAMS 0x800
24
25static int lpt_clk_probe(struct platform_device *pdev)
26{
27 struct clk *clk;
28
29 /* LPSS free running clock */
30 clk = clk_register_fixed_rate(&pdev->dev, "lpss_clk", NULL, CLK_IS_ROOT,
31 100000000);
32 if (IS_ERR(clk))
33 return PTR_ERR(clk);
34
35 /* Shared DMA clock */
36 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;
72}
73
74static struct platform_driver lpt_clk_driver = {
75 .driver = {
76 .name = "clk-lpt",
77 .owner = THIS_MODULE,
78 },
79 .probe = lpt_clk_probe,
80};
81
82static int __init lpt_clk_init(void)
83{
84 return platform_driver_register(&lpt_clk_driver);
85}
86arch_initcall(lpt_clk_init);
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index e0a899f25e37..cbcb21e32771 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -185,7 +185,7 @@ config CPU_FREQ_GOV_CONSERVATIVE
185 If in doubt, say N. 185 If in doubt, say N.
186 186
187config GENERIC_CPUFREQ_CPU0 187config GENERIC_CPUFREQ_CPU0
188 bool "Generic CPU0 cpufreq driver" 188 tristate "Generic CPU0 cpufreq driver"
189 depends on HAVE_CLK && REGULATOR && PM_OPP && OF 189 depends on HAVE_CLK && REGULATOR && PM_OPP && OF
190 select CPU_FREQ_TABLE 190 select CPU_FREQ_TABLE
191 help 191 help
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index a0b3661d90b0..7f333af1c059 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -77,9 +77,39 @@ config ARM_EXYNOS5250_CPUFREQ
77 This adds the CPUFreq driver for Samsung EXYNOS5250 77 This adds the CPUFreq driver for Samsung EXYNOS5250
78 SoC. 78 SoC.
79 79
80config ARM_KIRKWOOD_CPUFREQ
81 def_bool ARCH_KIRKWOOD && OF
82 help
83 This adds the CPUFreq driver for Marvell Kirkwood
84 SoCs.
85
86config 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
80config ARM_SPEAR_CPUFREQ 95config ARM_SPEAR_CPUFREQ
81 bool "SPEAr CPUFreq support" 96 bool "SPEAr CPUFreq support"
82 depends on PLAT_SPEAR 97 depends on PLAT_SPEAR
83 default y 98 default y
84 help 99 help
85 This adds the CPUFreq driver support for SPEAr SOCs. 100 This adds the CPUFreq driver support for SPEAr SOCs.
101
102config 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.x86 b/drivers/cpufreq/Kconfig.x86
index 7227cd734042..98e5abbe8f26 100644
--- a/drivers/cpufreq/Kconfig.x86
+++ b/drivers/cpufreq/Kconfig.x86
@@ -2,6 +2,19 @@
2# x86 CPU Frequency scaling drivers 2# x86 CPU Frequency scaling drivers
3# 3#
4 4
5config X86_INTEL_PSTATE
6 bool "Intel P state control"
7 depends on X86
8 help
9 This driver provides a P state for Intel core processors.
10 The driver implements an internal governor and will become
11 the scaling driver and governor for Sandy bridge processors.
12
13 When this driver is enabled it will become the perferred
14 scaling driver for Sandy bridge processors.
15
16 If in doubt, say N.
17
5config X86_PCC_CPUFREQ 18config X86_PCC_CPUFREQ
6 tristate "Processor Clocking Control interface driver" 19 tristate "Processor Clocking Control interface driver"
7 depends on ACPI && ACPI_PROCESSOR 20 depends on ACPI && ACPI_PROCESSOR
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index fadc4d496e2f..5399c45ac311 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -19,11 +19,12 @@ obj-$(CONFIG_GENERIC_CPUFREQ_CPU0) += cpufreq-cpu0.o
19################################################################################## 19##################################################################################
20# x86 drivers. 20# x86 drivers.
21# Link order matters. K8 is preferred to ACPI because of firmware bugs in early 21# Link order matters. K8 is preferred to ACPI because of firmware bugs in early
22# K8 systems. ACPI is preferred to all other hardware-specific drivers. 22# K8 systems. This is still the case but acpi-cpufreq errors out so that
23# powernow-k8 can load then. ACPI is preferred to all other hardware-specific drivers.
23# speedstep-* is preferred over p4-clockmod. 24# speedstep-* is preferred over p4-clockmod.
24 25
25obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o
26obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o mperf.o 26obj-$(CONFIG_X86_ACPI_CPUFREQ) += acpi-cpufreq.o mperf.o
27obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o
27obj-$(CONFIG_X86_PCC_CPUFREQ) += pcc-cpufreq.o 28obj-$(CONFIG_X86_PCC_CPUFREQ) += pcc-cpufreq.o
28obj-$(CONFIG_X86_POWERNOW_K6) += powernow-k6.o 29obj-$(CONFIG_X86_POWERNOW_K6) += powernow-k6.o
29obj-$(CONFIG_X86_POWERNOW_K7) += powernow-k7.o 30obj-$(CONFIG_X86_POWERNOW_K7) += powernow-k7.o
@@ -39,6 +40,7 @@ obj-$(CONFIG_X86_SPEEDSTEP_SMI) += speedstep-smi.o
39obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o 40obj-$(CONFIG_X86_SPEEDSTEP_CENTRINO) += speedstep-centrino.o
40obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o 41obj-$(CONFIG_X86_P4_CLOCKMOD) += p4-clockmod.o
41obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o 42obj-$(CONFIG_X86_CPUFREQ_NFORCE2) += cpufreq-nforce2.o
43obj-$(CONFIG_X86_INTEL_PSTATE) += intel_pstate.o
42 44
43################################################################################## 45##################################################################################
44# ARM SoC drivers 46# ARM SoC drivers
@@ -50,8 +52,11 @@ obj-$(CONFIG_ARM_EXYNOS_CPUFREQ) += exynos-cpufreq.o
50obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o 52obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o
51obj-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ) += exynos4x12-cpufreq.o 53obj-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ) += exynos4x12-cpufreq.o
52obj-$(CONFIG_ARM_EXYNOS5250_CPUFREQ) += exynos5250-cpufreq.o 54obj-$(CONFIG_ARM_EXYNOS5250_CPUFREQ) += exynos5250-cpufreq.o
53obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o 55obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o
56obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o
54obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o 57obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o
58obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o
59obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o
55 60
56################################################################################## 61##################################################################################
57# PowerPC platform drivers 62# PowerPC platform drivers
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 7b0d49d78c61..937bc286591f 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -734,7 +734,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
734 734
735#ifdef CONFIG_SMP 735#ifdef CONFIG_SMP
736 dmi_check_system(sw_any_bug_dmi_table); 736 dmi_check_system(sw_any_bug_dmi_table);
737 if (bios_with_sw_any_bug && cpumask_weight(policy->cpus) == 1) { 737 if (bios_with_sw_any_bug && !policy_is_shared(policy)) {
738 policy->shared_type = CPUFREQ_SHARED_TYPE_ALL; 738 policy->shared_type = CPUFREQ_SHARED_TYPE_ALL;
739 cpumask_copy(policy->cpus, cpu_core_mask(cpu)); 739 cpumask_copy(policy->cpus, cpu_core_mask(cpu));
740 } 740 }
@@ -762,6 +762,12 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
762 762
763 switch (perf->control_register.space_id) { 763 switch (perf->control_register.space_id) {
764 case ACPI_ADR_SPACE_SYSTEM_IO: 764 case ACPI_ADR_SPACE_SYSTEM_IO:
765 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
766 boot_cpu_data.x86 == 0xf) {
767 pr_debug("AMD K8 systems must use native drivers.\n");
768 result = -ENODEV;
769 goto err_unreg;
770 }
765 pr_debug("SYSTEM IO addr space\n"); 771 pr_debug("SYSTEM IO addr space\n");
766 data->cpu_feature = SYSTEM_IO_CAPABLE; 772 data->cpu_feature = SYSTEM_IO_CAPABLE;
767 break; 773 break;
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index debc5a7c8db6..4e5b7fb8927c 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -12,12 +12,12 @@
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13 13
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/cpu.h>
16#include <linux/cpufreq.h> 15#include <linux/cpufreq.h>
17#include <linux/err.h> 16#include <linux/err.h>
18#include <linux/module.h> 17#include <linux/module.h>
19#include <linux/of.h> 18#include <linux/of.h>
20#include <linux/opp.h> 19#include <linux/opp.h>
20#include <linux/platform_device.h>
21#include <linux/regulator/consumer.h> 21#include <linux/regulator/consumer.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23 23
@@ -146,7 +146,6 @@ static int cpu0_cpufreq_init(struct cpufreq_policy *policy)
146 * share the clock and voltage and clock. Use cpufreq affected_cpus 146 * share the clock and voltage and clock. Use cpufreq affected_cpus
147 * interface to have all CPUs scaled together. 147 * interface to have all CPUs scaled together.
148 */ 148 */
149 policy->shared_type = CPUFREQ_SHARED_TYPE_ANY;
150 cpumask_setall(policy->cpus); 149 cpumask_setall(policy->cpus);
151 150
152 cpufreq_frequency_table_get_attr(freq_table, policy->cpu); 151 cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
@@ -177,34 +176,32 @@ static struct cpufreq_driver cpu0_cpufreq_driver = {
177 .attr = cpu0_cpufreq_attr, 176 .attr = cpu0_cpufreq_attr,
178}; 177};
179 178
180static int cpu0_cpufreq_driver_init(void) 179static int cpu0_cpufreq_probe(struct platform_device *pdev)
181{ 180{
182 struct device_node *np; 181 struct device_node *np;
183 int ret; 182 int ret;
184 183
185 np = of_find_node_by_path("/cpus/cpu@0"); 184 for_each_child_of_node(of_find_node_by_path("/cpus"), np) {
185 if (of_get_property(np, "operating-points", NULL))
186 break;
187 }
188
186 if (!np) { 189 if (!np) {
187 pr_err("failed to find cpu0 node\n"); 190 pr_err("failed to find cpu0 node\n");
188 return -ENOENT; 191 return -ENOENT;
189 } 192 }
190 193
191 cpu_dev = get_cpu_device(0); 194 cpu_dev = &pdev->dev;
192 if (!cpu_dev) {
193 pr_err("failed to get cpu0 device\n");
194 ret = -ENODEV;
195 goto out_put_node;
196 }
197
198 cpu_dev->of_node = np; 195 cpu_dev->of_node = np;
199 196
200 cpu_clk = clk_get(cpu_dev, NULL); 197 cpu_clk = devm_clk_get(cpu_dev, NULL);
201 if (IS_ERR(cpu_clk)) { 198 if (IS_ERR(cpu_clk)) {
202 ret = PTR_ERR(cpu_clk); 199 ret = PTR_ERR(cpu_clk);
203 pr_err("failed to get cpu0 clock: %d\n", ret); 200 pr_err("failed to get cpu0 clock: %d\n", ret);
204 goto out_put_node; 201 goto out_put_node;
205 } 202 }
206 203
207 cpu_reg = regulator_get(cpu_dev, "cpu0"); 204 cpu_reg = devm_regulator_get(cpu_dev, "cpu0");
208 if (IS_ERR(cpu_reg)) { 205 if (IS_ERR(cpu_reg)) {
209 pr_warn("failed to get cpu0 regulator\n"); 206 pr_warn("failed to get cpu0 regulator\n");
210 cpu_reg = NULL; 207 cpu_reg = NULL;
@@ -267,7 +264,24 @@ out_put_node:
267 of_node_put(np); 264 of_node_put(np);
268 return ret; 265 return ret;
269} 266}
270late_initcall(cpu0_cpufreq_driver_init); 267
268static int cpu0_cpufreq_remove(struct platform_device *pdev)
269{
270 cpufreq_unregister_driver(&cpu0_cpufreq_driver);
271 opp_free_cpufreq_table(cpu_dev, &freq_table);
272
273 return 0;
274}
275
276static struct platform_driver cpu0_cpufreq_platdrv = {
277 .driver = {
278 .name = "cpufreq-cpu0",
279 .owner = THIS_MODULE,
280 },
281 .probe = cpu0_cpufreq_probe,
282 .remove = cpu0_cpufreq_remove,
283};
284module_platform_driver(cpu0_cpufreq_platdrv);
271 285
272MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>"); 286MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>");
273MODULE_DESCRIPTION("Generic CPU0 cpufreq driver"); 287MODULE_DESCRIPTION("Generic CPU0 cpufreq driver");
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 1f93dbd72355..b02824d092e7 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -59,8 +59,6 @@ static DEFINE_SPINLOCK(cpufreq_driver_lock);
59 * mode before doing so. 59 * mode before doing so.
60 * 60 *
61 * Additional rules: 61 * Additional rules:
62 * - All holders of the lock should check to make sure that the CPU they
63 * are concerned with are online after they get the lock.
64 * - Governor routines that can be called in cpufreq hotplug path should not 62 * - Governor routines that can be called in cpufreq hotplug path should not
65 * take this sem as top level hotplug notifier handler takes this. 63 * take this sem as top level hotplug notifier handler takes this.
66 * - Lock should not be held across 64 * - Lock should not be held across
@@ -70,38 +68,28 @@ static DEFINE_PER_CPU(int, cpufreq_policy_cpu);
70static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); 68static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem);
71 69
72#define lock_policy_rwsem(mode, cpu) \ 70#define lock_policy_rwsem(mode, cpu) \
73static int lock_policy_rwsem_##mode \ 71static int lock_policy_rwsem_##mode(int cpu) \
74(int cpu) \
75{ \ 72{ \
76 int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); \ 73 int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); \
77 BUG_ON(policy_cpu == -1); \ 74 BUG_ON(policy_cpu == -1); \
78 down_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \ 75 down_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \
79 if (unlikely(!cpu_online(cpu))) { \
80 up_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \
81 return -1; \
82 } \
83 \ 76 \
84 return 0; \ 77 return 0; \
85} 78}
86 79
87lock_policy_rwsem(read, cpu); 80lock_policy_rwsem(read, cpu);
88
89lock_policy_rwsem(write, cpu); 81lock_policy_rwsem(write, cpu);
90 82
91static void unlock_policy_rwsem_read(int cpu) 83#define unlock_policy_rwsem(mode, cpu) \
92{ 84static void unlock_policy_rwsem_##mode(int cpu) \
93 int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); 85{ \
94 BUG_ON(policy_cpu == -1); 86 int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu); \
95 up_read(&per_cpu(cpu_policy_rwsem, policy_cpu)); 87 BUG_ON(policy_cpu == -1); \
96} 88 up_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \
97
98static void unlock_policy_rwsem_write(int cpu)
99{
100 int policy_cpu = per_cpu(cpufreq_policy_cpu, cpu);
101 BUG_ON(policy_cpu == -1);
102 up_write(&per_cpu(cpu_policy_rwsem, policy_cpu));
103} 89}
104 90
91unlock_policy_rwsem(read, cpu);
92unlock_policy_rwsem(write, cpu);
105 93
106/* internal prototypes */ 94/* internal prototypes */
107static int __cpufreq_governor(struct cpufreq_policy *policy, 95static int __cpufreq_governor(struct cpufreq_policy *policy,
@@ -180,6 +168,9 @@ err_out:
180 168
181struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) 169struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
182{ 170{
171 if (cpufreq_disabled())
172 return NULL;
173
183 return __cpufreq_cpu_get(cpu, false); 174 return __cpufreq_cpu_get(cpu, false);
184} 175}
185EXPORT_SYMBOL_GPL(cpufreq_cpu_get); 176EXPORT_SYMBOL_GPL(cpufreq_cpu_get);
@@ -198,6 +189,9 @@ static void __cpufreq_cpu_put(struct cpufreq_policy *data, bool sysfs)
198 189
199void cpufreq_cpu_put(struct cpufreq_policy *data) 190void cpufreq_cpu_put(struct cpufreq_policy *data)
200{ 191{
192 if (cpufreq_disabled())
193 return;
194
201 __cpufreq_cpu_put(data, false); 195 __cpufreq_cpu_put(data, false);
202} 196}
203EXPORT_SYMBOL_GPL(cpufreq_cpu_put); 197EXPORT_SYMBOL_GPL(cpufreq_cpu_put);
@@ -261,14 +255,21 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
261void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) 255void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
262{ 256{
263 struct cpufreq_policy *policy; 257 struct cpufreq_policy *policy;
258 unsigned long flags;
264 259
265 BUG_ON(irqs_disabled()); 260 BUG_ON(irqs_disabled());
266 261
262 if (cpufreq_disabled())
263 return;
264
267 freqs->flags = cpufreq_driver->flags; 265 freqs->flags = cpufreq_driver->flags;
268 pr_debug("notification %u of frequency transition to %u kHz\n", 266 pr_debug("notification %u of frequency transition to %u kHz\n",
269 state, freqs->new); 267 state, freqs->new);
270 268
269 spin_lock_irqsave(&cpufreq_driver_lock, flags);
271 policy = per_cpu(cpufreq_cpu_data, freqs->cpu); 270 policy = per_cpu(cpufreq_cpu_data, freqs->cpu);
271 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
272
272 switch (state) { 273 switch (state) {
273 274
274 case CPUFREQ_PRECHANGE: 275 case CPUFREQ_PRECHANGE:
@@ -294,7 +295,6 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
294 adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); 295 adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
295 pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new, 296 pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new,
296 (unsigned long)freqs->cpu); 297 (unsigned long)freqs->cpu);
297 trace_power_frequency(POWER_PSTATE, freqs->new, freqs->cpu);
298 trace_cpu_frequency(freqs->new, freqs->cpu); 298 trace_cpu_frequency(freqs->new, freqs->cpu);
299 srcu_notifier_call_chain(&cpufreq_transition_notifier_list, 299 srcu_notifier_call_chain(&cpufreq_transition_notifier_list,
300 CPUFREQ_POSTCHANGE, freqs); 300 CPUFREQ_POSTCHANGE, freqs);
@@ -543,8 +543,6 @@ static ssize_t show_cpus(const struct cpumask *mask, char *buf)
543 */ 543 */
544static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) 544static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf)
545{ 545{
546 if (cpumask_empty(policy->related_cpus))
547 return show_cpus(policy->cpus, buf);
548 return show_cpus(policy->related_cpus, buf); 546 return show_cpus(policy->related_cpus, buf);
549} 547}
550 548
@@ -700,87 +698,6 @@ static struct kobj_type ktype_cpufreq = {
700 .release = cpufreq_sysfs_release, 698 .release = cpufreq_sysfs_release,
701}; 699};
702 700
703/*
704 * Returns:
705 * Negative: Failure
706 * 0: Success
707 * Positive: When we have a managed CPU and the sysfs got symlinked
708 */
709static int cpufreq_add_dev_policy(unsigned int cpu,
710 struct cpufreq_policy *policy,
711 struct device *dev)
712{
713 int ret = 0;
714#ifdef CONFIG_SMP
715 unsigned long flags;
716 unsigned int j;
717#ifdef CONFIG_HOTPLUG_CPU
718 struct cpufreq_governor *gov;
719
720 gov = __find_governor(per_cpu(cpufreq_cpu_governor, cpu));
721 if (gov) {
722 policy->governor = gov;
723 pr_debug("Restoring governor %s for cpu %d\n",
724 policy->governor->name, cpu);
725 }
726#endif
727
728 for_each_cpu(j, policy->cpus) {
729 struct cpufreq_policy *managed_policy;
730
731 if (cpu == j)
732 continue;
733
734 /* Check for existing affected CPUs.
735 * They may not be aware of it due to CPU Hotplug.
736 * cpufreq_cpu_put is called when the device is removed
737 * in __cpufreq_remove_dev()
738 */
739 managed_policy = cpufreq_cpu_get(j);
740 if (unlikely(managed_policy)) {
741
742 /* Set proper policy_cpu */
743 unlock_policy_rwsem_write(cpu);
744 per_cpu(cpufreq_policy_cpu, cpu) = managed_policy->cpu;
745
746 if (lock_policy_rwsem_write(cpu) < 0) {
747 /* Should not go through policy unlock path */
748 if (cpufreq_driver->exit)
749 cpufreq_driver->exit(policy);
750 cpufreq_cpu_put(managed_policy);
751 return -EBUSY;
752 }
753
754 spin_lock_irqsave(&cpufreq_driver_lock, flags);
755 cpumask_copy(managed_policy->cpus, policy->cpus);
756 per_cpu(cpufreq_cpu_data, cpu) = managed_policy;
757 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
758
759 pr_debug("CPU already managed, adding link\n");
760 ret = sysfs_create_link(&dev->kobj,
761 &managed_policy->kobj,
762 "cpufreq");
763 if (ret)
764 cpufreq_cpu_put(managed_policy);
765 /*
766 * Success. We only needed to be added to the mask.
767 * Call driver->exit() because only the cpu parent of
768 * the kobj needed to call init().
769 */
770 if (cpufreq_driver->exit)
771 cpufreq_driver->exit(policy);
772
773 if (!ret)
774 return 1;
775 else
776 return ret;
777 }
778 }
779#endif
780 return ret;
781}
782
783
784/* symlink affected CPUs */ 701/* symlink affected CPUs */
785static int cpufreq_add_dev_symlink(unsigned int cpu, 702static int cpufreq_add_dev_symlink(unsigned int cpu,
786 struct cpufreq_policy *policy) 703 struct cpufreq_policy *policy)
@@ -794,8 +711,6 @@ static int cpufreq_add_dev_symlink(unsigned int cpu,
794 711
795 if (j == cpu) 712 if (j == cpu)
796 continue; 713 continue;
797 if (!cpu_online(j))
798 continue;
799 714
800 pr_debug("CPU %u already managed, adding link\n", j); 715 pr_debug("CPU %u already managed, adding link\n", j);
801 managed_policy = cpufreq_cpu_get(cpu); 716 managed_policy = cpufreq_cpu_get(cpu);
@@ -852,8 +767,6 @@ static int cpufreq_add_dev_interface(unsigned int cpu,
852 767
853 spin_lock_irqsave(&cpufreq_driver_lock, flags); 768 spin_lock_irqsave(&cpufreq_driver_lock, flags);
854 for_each_cpu(j, policy->cpus) { 769 for_each_cpu(j, policy->cpus) {
855 if (!cpu_online(j))
856 continue;
857 per_cpu(cpufreq_cpu_data, j) = policy; 770 per_cpu(cpufreq_cpu_data, j) = policy;
858 per_cpu(cpufreq_policy_cpu, j) = policy->cpu; 771 per_cpu(cpufreq_policy_cpu, j) = policy->cpu;
859 } 772 }
@@ -885,6 +798,42 @@ err_out_kobj_put:
885 return ret; 798 return ret;
886} 799}
887 800
801#ifdef CONFIG_HOTPLUG_CPU
802static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling,
803 struct device *dev)
804{
805 struct cpufreq_policy *policy;
806 int ret = 0;
807 unsigned long flags;
808
809 policy = cpufreq_cpu_get(sibling);
810 WARN_ON(!policy);
811
812 __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
813
814 lock_policy_rwsem_write(sibling);
815
816 spin_lock_irqsave(&cpufreq_driver_lock, flags);
817
818 cpumask_set_cpu(cpu, policy->cpus);
819 per_cpu(cpufreq_policy_cpu, cpu) = policy->cpu;
820 per_cpu(cpufreq_cpu_data, cpu) = policy;
821 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
822
823 unlock_policy_rwsem_write(sibling);
824
825 __cpufreq_governor(policy, CPUFREQ_GOV_START);
826 __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
827
828 ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq");
829 if (ret) {
830 cpufreq_cpu_put(policy);
831 return ret;
832 }
833
834 return 0;
835}
836#endif
888 837
889/** 838/**
890 * cpufreq_add_dev - add a CPU device 839 * cpufreq_add_dev - add a CPU device
@@ -897,12 +846,12 @@ err_out_kobj_put:
897 */ 846 */
898static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) 847static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
899{ 848{
900 unsigned int cpu = dev->id; 849 unsigned int j, cpu = dev->id;
901 int ret = 0, found = 0; 850 int ret = -ENOMEM;
902 struct cpufreq_policy *policy; 851 struct cpufreq_policy *policy;
903 unsigned long flags; 852 unsigned long flags;
904 unsigned int j;
905#ifdef CONFIG_HOTPLUG_CPU 853#ifdef CONFIG_HOTPLUG_CPU
854 struct cpufreq_governor *gov;
906 int sibling; 855 int sibling;
907#endif 856#endif
908 857
@@ -919,6 +868,19 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
919 cpufreq_cpu_put(policy); 868 cpufreq_cpu_put(policy);
920 return 0; 869 return 0;
921 } 870 }
871
872#ifdef CONFIG_HOTPLUG_CPU
873 /* Check if this cpu was hot-unplugged earlier and has siblings */
874 spin_lock_irqsave(&cpufreq_driver_lock, flags);
875 for_each_online_cpu(sibling) {
876 struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling);
877 if (cp && cpumask_test_cpu(cpu, cp->related_cpus)) {
878 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
879 return cpufreq_add_policy_cpu(cpu, sibling, dev);
880 }
881 }
882 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
883#endif
922#endif 884#endif
923 885
924 if (!try_module_get(cpufreq_driver->owner)) { 886 if (!try_module_get(cpufreq_driver->owner)) {
@@ -926,7 +888,6 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
926 goto module_out; 888 goto module_out;
927 } 889 }
928 890
929 ret = -ENOMEM;
930 policy = kzalloc(sizeof(struct cpufreq_policy), GFP_KERNEL); 891 policy = kzalloc(sizeof(struct cpufreq_policy), GFP_KERNEL);
931 if (!policy) 892 if (!policy)
932 goto nomem_out; 893 goto nomem_out;
@@ -938,66 +899,58 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
938 goto err_free_cpumask; 899 goto err_free_cpumask;
939 900
940 policy->cpu = cpu; 901 policy->cpu = cpu;
902 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
941 cpumask_copy(policy->cpus, cpumask_of(cpu)); 903 cpumask_copy(policy->cpus, cpumask_of(cpu));
942 904
943 /* Initially set CPU itself as the policy_cpu */ 905 /* Initially set CPU itself as the policy_cpu */
944 per_cpu(cpufreq_policy_cpu, cpu) = cpu; 906 per_cpu(cpufreq_policy_cpu, cpu) = cpu;
945 ret = (lock_policy_rwsem_write(cpu) < 0);
946 WARN_ON(ret);
947 907
948 init_completion(&policy->kobj_unregister); 908 init_completion(&policy->kobj_unregister);
949 INIT_WORK(&policy->update, handle_update); 909 INIT_WORK(&policy->update, handle_update);
950 910
951 /* Set governor before ->init, so that driver could check it */
952#ifdef CONFIG_HOTPLUG_CPU
953 for_each_online_cpu(sibling) {
954 struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling);
955 if (cp && cp->governor &&
956 (cpumask_test_cpu(cpu, cp->related_cpus))) {
957 policy->governor = cp->governor;
958 found = 1;
959 break;
960 }
961 }
962#endif
963 if (!found)
964 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
965 /* call driver. From then on the cpufreq must be able 911 /* call driver. From then on the cpufreq must be able
966 * to accept all calls to ->verify and ->setpolicy for this CPU 912 * to accept all calls to ->verify and ->setpolicy for this CPU
967 */ 913 */
968 ret = cpufreq_driver->init(policy); 914 ret = cpufreq_driver->init(policy);
969 if (ret) { 915 if (ret) {
970 pr_debug("initialization failed\n"); 916 pr_debug("initialization failed\n");
971 goto err_unlock_policy; 917 goto err_set_policy_cpu;
972 } 918 }
919
920 /* related cpus should atleast have policy->cpus */
921 cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);
922
923 /*
924 * affected cpus must always be the one, which are online. We aren't
925 * managing offline cpus here.
926 */
927 cpumask_and(policy->cpus, policy->cpus, cpu_online_mask);
928
973 policy->user_policy.min = policy->min; 929 policy->user_policy.min = policy->min;
974 policy->user_policy.max = policy->max; 930 policy->user_policy.max = policy->max;
975 931
976 blocking_notifier_call_chain(&cpufreq_policy_notifier_list, 932 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
977 CPUFREQ_START, policy); 933 CPUFREQ_START, policy);
978 934
979 ret = cpufreq_add_dev_policy(cpu, policy, dev); 935#ifdef CONFIG_HOTPLUG_CPU
980 if (ret) { 936 gov = __find_governor(per_cpu(cpufreq_cpu_governor, cpu));
981 if (ret > 0) 937 if (gov) {
982 /* This is a managed cpu, symlink created, 938 policy->governor = gov;
983 exit with 0 */ 939 pr_debug("Restoring governor %s for cpu %d\n",
984 ret = 0; 940 policy->governor->name, cpu);
985 goto err_unlock_policy;
986 } 941 }
942#endif
987 943
988 ret = cpufreq_add_dev_interface(cpu, policy, dev); 944 ret = cpufreq_add_dev_interface(cpu, policy, dev);
989 if (ret) 945 if (ret)
990 goto err_out_unregister; 946 goto err_out_unregister;
991 947
992 unlock_policy_rwsem_write(cpu);
993
994 kobject_uevent(&policy->kobj, KOBJ_ADD); 948 kobject_uevent(&policy->kobj, KOBJ_ADD);
995 module_put(cpufreq_driver->owner); 949 module_put(cpufreq_driver->owner);
996 pr_debug("initialization complete\n"); 950 pr_debug("initialization complete\n");
997 951
998 return 0; 952 return 0;
999 953
1000
1001err_out_unregister: 954err_out_unregister:
1002 spin_lock_irqsave(&cpufreq_driver_lock, flags); 955 spin_lock_irqsave(&cpufreq_driver_lock, flags);
1003 for_each_cpu(j, policy->cpus) 956 for_each_cpu(j, policy->cpus)
@@ -1007,8 +960,8 @@ err_out_unregister:
1007 kobject_put(&policy->kobj); 960 kobject_put(&policy->kobj);
1008 wait_for_completion(&policy->kobj_unregister); 961 wait_for_completion(&policy->kobj_unregister);
1009 962
1010err_unlock_policy: 963err_set_policy_cpu:
1011 unlock_policy_rwsem_write(cpu); 964 per_cpu(cpufreq_policy_cpu, cpu) = -1;
1012 free_cpumask_var(policy->related_cpus); 965 free_cpumask_var(policy->related_cpus);
1013err_free_cpumask: 966err_free_cpumask:
1014 free_cpumask_var(policy->cpus); 967 free_cpumask_var(policy->cpus);
@@ -1020,6 +973,22 @@ module_out:
1020 return ret; 973 return ret;
1021} 974}
1022 975
976static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu)
977{
978 int j;
979
980 policy->last_cpu = policy->cpu;
981 policy->cpu = cpu;
982
983 for_each_cpu(j, policy->cpus)
984 per_cpu(cpufreq_policy_cpu, j) = cpu;
985
986#ifdef CONFIG_CPU_FREQ_TABLE
987 cpufreq_frequency_table_update_policy_cpu(policy);
988#endif
989 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
990 CPUFREQ_UPDATE_POLICY_CPU, policy);
991}
1023 992
1024/** 993/**
1025 * __cpufreq_remove_dev - remove a CPU device 994 * __cpufreq_remove_dev - remove a CPU device
@@ -1030,129 +999,103 @@ module_out:
1030 */ 999 */
1031static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) 1000static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
1032{ 1001{
1033 unsigned int cpu = dev->id; 1002 unsigned int cpu = dev->id, ret, cpus;
1034 unsigned long flags; 1003 unsigned long flags;
1035 struct cpufreq_policy *data; 1004 struct cpufreq_policy *data;
1036 struct kobject *kobj; 1005 struct kobject *kobj;
1037 struct completion *cmp; 1006 struct completion *cmp;
1038#ifdef CONFIG_SMP
1039 struct device *cpu_dev; 1007 struct device *cpu_dev;
1040 unsigned int j;
1041#endif
1042 1008
1043 pr_debug("unregistering CPU %u\n", cpu); 1009 pr_debug("%s: unregistering CPU %u\n", __func__, cpu);
1044 1010
1045 spin_lock_irqsave(&cpufreq_driver_lock, flags); 1011 spin_lock_irqsave(&cpufreq_driver_lock, flags);
1012
1046 data = per_cpu(cpufreq_cpu_data, cpu); 1013 data = per_cpu(cpufreq_cpu_data, cpu);
1014 per_cpu(cpufreq_cpu_data, cpu) = NULL;
1015
1016 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1047 1017
1048 if (!data) { 1018 if (!data) {
1049 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1019 pr_debug("%s: No cpu_data found\n", __func__);
1050 unlock_policy_rwsem_write(cpu);
1051 return -EINVAL; 1020 return -EINVAL;
1052 } 1021 }
1053 per_cpu(cpufreq_cpu_data, cpu) = NULL;
1054 1022
1023 if (cpufreq_driver->target)
1024 __cpufreq_governor(data, CPUFREQ_GOV_STOP);
1055 1025
1056#ifdef CONFIG_SMP 1026#ifdef CONFIG_HOTPLUG_CPU
1057 /* if this isn't the CPU which is the parent of the kobj, we 1027 if (!cpufreq_driver->setpolicy)
1058 * only need to unlink, put and exit 1028 strncpy(per_cpu(cpufreq_cpu_governor, cpu),
1059 */ 1029 data->governor->name, CPUFREQ_NAME_LEN);
1060 if (unlikely(cpu != data->cpu)) {
1061 pr_debug("removing link\n");
1062 cpumask_clear_cpu(cpu, data->cpus);
1063 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1064 kobj = &dev->kobj;
1065 cpufreq_cpu_put(data);
1066 unlock_policy_rwsem_write(cpu);
1067 sysfs_remove_link(kobj, "cpufreq");
1068 return 0;
1069 }
1070#endif 1030#endif
1071 1031
1072#ifdef CONFIG_SMP 1032 WARN_ON(lock_policy_rwsem_write(cpu));
1033 cpus = cpumask_weight(data->cpus);
1034 cpumask_clear_cpu(cpu, data->cpus);
1035 unlock_policy_rwsem_write(cpu);
1073 1036
1074#ifdef CONFIG_HOTPLUG_CPU 1037 if (cpu != data->cpu) {
1075 strncpy(per_cpu(cpufreq_cpu_governor, cpu), data->governor->name, 1038 sysfs_remove_link(&dev->kobj, "cpufreq");
1076 CPUFREQ_NAME_LEN); 1039 } else if (cpus > 1) {
1077#endif 1040 /* first sibling now owns the new sysfs dir */
1041 cpu_dev = get_cpu_device(cpumask_first(data->cpus));
1042 sysfs_remove_link(&cpu_dev->kobj, "cpufreq");
1043 ret = kobject_move(&data->kobj, &cpu_dev->kobj);
1044 if (ret) {
1045 pr_err("%s: Failed to move kobj: %d", __func__, ret);
1078 1046
1079 /* if we have other CPUs still registered, we need to unlink them, 1047 WARN_ON(lock_policy_rwsem_write(cpu));
1080 * or else wait_for_completion below will lock up. Clean the 1048 cpumask_set_cpu(cpu, data->cpus);
1081 * per_cpu(cpufreq_cpu_data) while holding the lock, and remove
1082 * the sysfs links afterwards.
1083 */
1084 if (unlikely(cpumask_weight(data->cpus) > 1)) {
1085 for_each_cpu(j, data->cpus) {
1086 if (j == cpu)
1087 continue;
1088 per_cpu(cpufreq_cpu_data, j) = NULL;
1089 }
1090 }
1091 1049
1092 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1050 spin_lock_irqsave(&cpufreq_driver_lock, flags);
1051 per_cpu(cpufreq_cpu_data, cpu) = data;
1052 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1093 1053
1094 if (unlikely(cpumask_weight(data->cpus) > 1)) {
1095 for_each_cpu(j, data->cpus) {
1096 if (j == cpu)
1097 continue;
1098 pr_debug("removing link for cpu %u\n", j);
1099#ifdef CONFIG_HOTPLUG_CPU
1100 strncpy(per_cpu(cpufreq_cpu_governor, j),
1101 data->governor->name, CPUFREQ_NAME_LEN);
1102#endif
1103 cpu_dev = get_cpu_device(j);
1104 kobj = &cpu_dev->kobj;
1105 unlock_policy_rwsem_write(cpu); 1054 unlock_policy_rwsem_write(cpu);
1106 sysfs_remove_link(kobj, "cpufreq");
1107 lock_policy_rwsem_write(cpu);
1108 cpufreq_cpu_put(data);
1109 }
1110 }
1111#else
1112 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1113#endif
1114 1055
1115 if (cpufreq_driver->target) 1056 ret = sysfs_create_link(&cpu_dev->kobj, &data->kobj,
1116 __cpufreq_governor(data, CPUFREQ_GOV_STOP); 1057 "cpufreq");
1058 return -EINVAL;
1059 }
1117 1060
1118 kobj = &data->kobj; 1061 WARN_ON(lock_policy_rwsem_write(cpu));
1119 cmp = &data->kobj_unregister; 1062 update_policy_cpu(data, cpu_dev->id);
1120 unlock_policy_rwsem_write(cpu); 1063 unlock_policy_rwsem_write(cpu);
1121 kobject_put(kobj); 1064 pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n",
1065 __func__, cpu_dev->id, cpu);
1066 }
1122 1067
1123 /* we need to make sure that the underlying kobj is actually 1068 pr_debug("%s: removing link, cpu: %d\n", __func__, cpu);
1124 * not referenced anymore by anybody before we proceed with 1069 cpufreq_cpu_put(data);
1125 * unloading.
1126 */
1127 pr_debug("waiting for dropping of refcount\n");
1128 wait_for_completion(cmp);
1129 pr_debug("wait complete\n");
1130 1070
1131 lock_policy_rwsem_write(cpu); 1071 /* If cpu is last user of policy, free policy */
1132 if (cpufreq_driver->exit) 1072 if (cpus == 1) {
1133 cpufreq_driver->exit(data); 1073 lock_policy_rwsem_read(cpu);
1134 unlock_policy_rwsem_write(cpu); 1074 kobj = &data->kobj;
1075 cmp = &data->kobj_unregister;
1076 unlock_policy_rwsem_read(cpu);
1077 kobject_put(kobj);
1078
1079 /* we need to make sure that the underlying kobj is actually
1080 * not referenced anymore by anybody before we proceed with
1081 * unloading.
1082 */
1083 pr_debug("waiting for dropping of refcount\n");
1084 wait_for_completion(cmp);
1085 pr_debug("wait complete\n");
1135 1086
1136#ifdef CONFIG_HOTPLUG_CPU 1087 if (cpufreq_driver->exit)
1137 /* when the CPU which is the parent of the kobj is hotplugged 1088 cpufreq_driver->exit(data);
1138 * offline, check for siblings, and create cpufreq sysfs interface
1139 * and symlinks
1140 */
1141 if (unlikely(cpumask_weight(data->cpus) > 1)) {
1142 /* first sibling now owns the new sysfs dir */
1143 cpumask_clear_cpu(cpu, data->cpus);
1144 cpufreq_add_dev(get_cpu_device(cpumask_first(data->cpus)), NULL);
1145 1089
1146 /* finally remove our own symlink */ 1090 free_cpumask_var(data->related_cpus);
1147 lock_policy_rwsem_write(cpu); 1091 free_cpumask_var(data->cpus);
1148 __cpufreq_remove_dev(dev, sif); 1092 kfree(data);
1093 } else if (cpufreq_driver->target) {
1094 __cpufreq_governor(data, CPUFREQ_GOV_START);
1095 __cpufreq_governor(data, CPUFREQ_GOV_LIMITS);
1149 } 1096 }
1150#endif
1151
1152 free_cpumask_var(data->related_cpus);
1153 free_cpumask_var(data->cpus);
1154 kfree(data);
1155 1097
1098 per_cpu(cpufreq_policy_cpu, cpu) = -1;
1156 return 0; 1099 return 0;
1157} 1100}
1158 1101
@@ -1165,9 +1108,6 @@ static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
1165 if (cpu_is_offline(cpu)) 1108 if (cpu_is_offline(cpu))
1166 return 0; 1109 return 0;
1167 1110
1168 if (unlikely(lock_policy_rwsem_write(cpu)))
1169 BUG();
1170
1171 retval = __cpufreq_remove_dev(dev, sif); 1111 retval = __cpufreq_remove_dev(dev, sif);
1172 return retval; 1112 return retval;
1173} 1113}
@@ -1216,9 +1156,13 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq,
1216 */ 1156 */
1217unsigned int cpufreq_quick_get(unsigned int cpu) 1157unsigned int cpufreq_quick_get(unsigned int cpu)
1218{ 1158{
1219 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 1159 struct cpufreq_policy *policy;
1220 unsigned int ret_freq = 0; 1160 unsigned int ret_freq = 0;
1221 1161
1162 if (cpufreq_driver && cpufreq_driver->setpolicy && cpufreq_driver->get)
1163 return cpufreq_driver->get(cpu);
1164
1165 policy = cpufreq_cpu_get(cpu);
1222 if (policy) { 1166 if (policy) {
1223 ret_freq = policy->cur; 1167 ret_freq = policy->cur;
1224 cpufreq_cpu_put(policy); 1168 cpufreq_cpu_put(policy);
@@ -1386,6 +1330,20 @@ static struct syscore_ops cpufreq_syscore_ops = {
1386 .resume = cpufreq_bp_resume, 1330 .resume = cpufreq_bp_resume,
1387}; 1331};
1388 1332
1333/**
1334 * cpufreq_get_current_driver - return current driver's name
1335 *
1336 * Return the name string of the currently loaded cpufreq driver
1337 * or NULL, if none.
1338 */
1339const char *cpufreq_get_current_driver(void)
1340{
1341 if (cpufreq_driver)
1342 return cpufreq_driver->name;
1343
1344 return NULL;
1345}
1346EXPORT_SYMBOL_GPL(cpufreq_get_current_driver);
1389 1347
1390/********************************************************************* 1348/*********************************************************************
1391 * NOTIFIER LISTS INTERFACE * 1349 * NOTIFIER LISTS INTERFACE *
@@ -1408,6 +1366,9 @@ int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list)
1408{ 1366{
1409 int ret; 1367 int ret;
1410 1368
1369 if (cpufreq_disabled())
1370 return -EINVAL;
1371
1411 WARN_ON(!init_cpufreq_transition_notifier_list_called); 1372 WARN_ON(!init_cpufreq_transition_notifier_list_called);
1412 1373
1413 switch (list) { 1374 switch (list) {
@@ -1442,6 +1403,9 @@ int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list)
1442{ 1403{
1443 int ret; 1404 int ret;
1444 1405
1406 if (cpufreq_disabled())
1407 return -EINVAL;
1408
1445 switch (list) { 1409 switch (list) {
1446 case CPUFREQ_TRANSITION_NOTIFIER: 1410 case CPUFREQ_TRANSITION_NOTIFIER:
1447 ret = srcu_notifier_chain_unregister( 1411 ret = srcu_notifier_chain_unregister(
@@ -1487,7 +1451,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1487 if (target_freq == policy->cur) 1451 if (target_freq == policy->cur)
1488 return 0; 1452 return 0;
1489 1453
1490 if (cpu_online(policy->cpu) && cpufreq_driver->target) 1454 if (cpufreq_driver->target)
1491 retval = cpufreq_driver->target(policy, target_freq, relation); 1455 retval = cpufreq_driver->target(policy, target_freq, relation);
1492 1456
1493 return retval; 1457 return retval;
@@ -1522,7 +1486,10 @@ int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu)
1522{ 1486{
1523 int ret = 0; 1487 int ret = 0;
1524 1488
1525 if (!(cpu_online(cpu) && cpufreq_driver->getavg)) 1489 if (cpufreq_disabled())
1490 return ret;
1491
1492 if (!cpufreq_driver->getavg)
1526 return 0; 1493 return 0;
1527 1494
1528 policy = cpufreq_cpu_get(policy->cpu); 1495 policy = cpufreq_cpu_get(policy->cpu);
@@ -1577,6 +1544,11 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
1577 policy->cpu, event); 1544 policy->cpu, event);
1578 ret = policy->governor->governor(policy, event); 1545 ret = policy->governor->governor(policy, event);
1579 1546
1547 if (event == CPUFREQ_GOV_START)
1548 policy->governor->initialized++;
1549 else if (event == CPUFREQ_GOV_STOP)
1550 policy->governor->initialized--;
1551
1580 /* we keep one module reference alive for 1552 /* we keep one module reference alive for
1581 each CPU governed by this CPU */ 1553 each CPU governed by this CPU */
1582 if ((event != CPUFREQ_GOV_START) || ret) 1554 if ((event != CPUFREQ_GOV_START) || ret)
@@ -1600,6 +1572,7 @@ int cpufreq_register_governor(struct cpufreq_governor *governor)
1600 1572
1601 mutex_lock(&cpufreq_governor_mutex); 1573 mutex_lock(&cpufreq_governor_mutex);
1602 1574
1575 governor->initialized = 0;
1603 err = -EBUSY; 1576 err = -EBUSY;
1604 if (__find_governor(governor->name) == NULL) { 1577 if (__find_governor(governor->name) == NULL) {
1605 err = 0; 1578 err = 0;
@@ -1797,7 +1770,7 @@ int cpufreq_update_policy(unsigned int cpu)
1797 pr_debug("Driver did not initialize current freq"); 1770 pr_debug("Driver did not initialize current freq");
1798 data->cur = policy.cur; 1771 data->cur = policy.cur;
1799 } else { 1772 } else {
1800 if (data->cur != policy.cur) 1773 if (data->cur != policy.cur && cpufreq_driver->target)
1801 cpufreq_out_of_sync(cpu, data->cur, 1774 cpufreq_out_of_sync(cpu, data->cur,
1802 policy.cur); 1775 policy.cur);
1803 } 1776 }
@@ -1829,9 +1802,6 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
1829 break; 1802 break;
1830 case CPU_DOWN_PREPARE: 1803 case CPU_DOWN_PREPARE:
1831 case CPU_DOWN_PREPARE_FROZEN: 1804 case CPU_DOWN_PREPARE_FROZEN:
1832 if (unlikely(lock_policy_rwsem_write(cpu)))
1833 BUG();
1834
1835 __cpufreq_remove_dev(dev, NULL); 1805 __cpufreq_remove_dev(dev, NULL);
1836 break; 1806 break;
1837 case CPU_DOWN_FAILED: 1807 case CPU_DOWN_FAILED:
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 64ef737e7e72..4fd0006b1291 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -25,7 +25,7 @@
25 25
26#include "cpufreq_governor.h" 26#include "cpufreq_governor.h"
27 27
28/* Conservative governor macors */ 28/* Conservative governor macros */
29#define DEF_FREQUENCY_UP_THRESHOLD (80) 29#define DEF_FREQUENCY_UP_THRESHOLD (80)
30#define DEF_FREQUENCY_DOWN_THRESHOLD (20) 30#define DEF_FREQUENCY_DOWN_THRESHOLD (20)
31#define DEF_SAMPLING_DOWN_FACTOR (1) 31#define DEF_SAMPLING_DOWN_FACTOR (1)
@@ -113,17 +113,20 @@ static void cs_check_cpu(int cpu, unsigned int load)
113 113
114static void cs_dbs_timer(struct work_struct *work) 114static void cs_dbs_timer(struct work_struct *work)
115{ 115{
116 struct delayed_work *dw = to_delayed_work(work);
116 struct cs_cpu_dbs_info_s *dbs_info = container_of(work, 117 struct cs_cpu_dbs_info_s *dbs_info = container_of(work,
117 struct cs_cpu_dbs_info_s, cdbs.work.work); 118 struct cs_cpu_dbs_info_s, cdbs.work.work);
118 unsigned int cpu = dbs_info->cdbs.cpu; 119 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,
121 cpu);
119 int delay = delay_for_sampling_rate(cs_tuners.sampling_rate); 122 int delay = delay_for_sampling_rate(cs_tuners.sampling_rate);
120 123
121 mutex_lock(&dbs_info->cdbs.timer_mutex); 124 mutex_lock(&core_dbs_info->cdbs.timer_mutex);
125 if (need_load_eval(&core_dbs_info->cdbs, cs_tuners.sampling_rate))
126 dbs_check_cpu(&cs_dbs_data, cpu);
122 127
123 dbs_check_cpu(&cs_dbs_data, cpu); 128 schedule_delayed_work_on(smp_processor_id(), dw, delay);
124 129 mutex_unlock(&core_dbs_info->cdbs.timer_mutex);
125 schedule_delayed_work_on(cpu, &dbs_info->cdbs.work, delay);
126 mutex_unlock(&dbs_info->cdbs.timer_mutex);
127} 130}
128 131
129static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val, 132static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
@@ -141,7 +144,7 @@ static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
141 144
142 /* 145 /*
143 * we only care if our internally tracked freq moves outside the 'valid' 146 * we only care if our internally tracked freq moves outside the 'valid'
144 * ranges of freqency available to us otherwise we do not change it 147 * ranges of frequency available to us otherwise we do not change it
145 */ 148 */
146 if (dbs_info->requested_freq > policy->max 149 if (dbs_info->requested_freq > policy->max
147 || dbs_info->requested_freq < policy->min) 150 || dbs_info->requested_freq < policy->min)
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 6c5f1d383cdc..5a76086ff09b 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -161,25 +161,48 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu)
161} 161}
162EXPORT_SYMBOL_GPL(dbs_check_cpu); 162EXPORT_SYMBOL_GPL(dbs_check_cpu);
163 163
164static inline void dbs_timer_init(struct dbs_data *dbs_data, 164static inline void dbs_timer_init(struct dbs_data *dbs_data, int cpu,
165 struct cpu_dbs_common_info *cdbs, unsigned int sampling_rate) 165 unsigned int sampling_rate)
166{ 166{
167 int delay = delay_for_sampling_rate(sampling_rate); 167 int delay = delay_for_sampling_rate(sampling_rate);
168 struct cpu_dbs_common_info *cdbs = dbs_data->get_cpu_cdbs(cpu);
168 169
169 INIT_DEFERRABLE_WORK(&cdbs->work, dbs_data->gov_dbs_timer); 170 schedule_delayed_work_on(cpu, &cdbs->work, delay);
170 schedule_delayed_work_on(cdbs->cpu, &cdbs->work, delay);
171} 171}
172 172
173static inline void dbs_timer_exit(struct cpu_dbs_common_info *cdbs) 173static inline void dbs_timer_exit(struct dbs_data *dbs_data, int cpu)
174{ 174{
175 struct cpu_dbs_common_info *cdbs = dbs_data->get_cpu_cdbs(cpu);
176
175 cancel_delayed_work_sync(&cdbs->work); 177 cancel_delayed_work_sync(&cdbs->work);
176} 178}
177 179
180/* Will return if we need to evaluate cpu load again or not */
181bool need_load_eval(struct cpu_dbs_common_info *cdbs,
182 unsigned int sampling_rate)
183{
184 if (policy_is_shared(cdbs->cur_policy)) {
185 ktime_t time_now = ktime_get();
186 s64 delta_us = ktime_us_delta(time_now, cdbs->time_stamp);
187
188 /* Do nothing if we recently have sampled */
189 if (delta_us < (s64)(sampling_rate / 2))
190 return false;
191 else
192 cdbs->time_stamp = time_now;
193 }
194
195 return true;
196}
197EXPORT_SYMBOL_GPL(need_load_eval);
198
178int cpufreq_governor_dbs(struct dbs_data *dbs_data, 199int cpufreq_governor_dbs(struct dbs_data *dbs_data,
179 struct cpufreq_policy *policy, unsigned int event) 200 struct cpufreq_policy *policy, unsigned int event)
180{ 201{
181 struct od_cpu_dbs_info_s *od_dbs_info = NULL; 202 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
182 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL; 203 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
204 struct cs_ops *cs_ops = NULL;
205 struct od_ops *od_ops = NULL;
183 struct od_dbs_tuners *od_tuners = dbs_data->tuners; 206 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
184 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; 207 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
185 struct cpu_dbs_common_info *cpu_cdbs; 208 struct cpu_dbs_common_info *cpu_cdbs;
@@ -192,109 +215,111 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
192 cs_dbs_info = dbs_data->get_cpu_dbs_info_s(cpu); 215 cs_dbs_info = dbs_data->get_cpu_dbs_info_s(cpu);
193 sampling_rate = &cs_tuners->sampling_rate; 216 sampling_rate = &cs_tuners->sampling_rate;
194 ignore_nice = cs_tuners->ignore_nice; 217 ignore_nice = cs_tuners->ignore_nice;
218 cs_ops = dbs_data->gov_ops;
195 } else { 219 } else {
196 od_dbs_info = dbs_data->get_cpu_dbs_info_s(cpu); 220 od_dbs_info = dbs_data->get_cpu_dbs_info_s(cpu);
197 sampling_rate = &od_tuners->sampling_rate; 221 sampling_rate = &od_tuners->sampling_rate;
198 ignore_nice = od_tuners->ignore_nice; 222 ignore_nice = od_tuners->ignore_nice;
223 od_ops = dbs_data->gov_ops;
199 } 224 }
200 225
201 switch (event) { 226 switch (event) {
202 case CPUFREQ_GOV_START: 227 case CPUFREQ_GOV_START:
203 if ((!cpu_online(cpu)) || (!policy->cur)) 228 if (!policy->cur)
204 return -EINVAL; 229 return -EINVAL;
205 230
206 mutex_lock(&dbs_data->mutex); 231 mutex_lock(&dbs_data->mutex);
207 232
208 dbs_data->enable++;
209 cpu_cdbs->cpu = cpu;
210 for_each_cpu(j, policy->cpus) { 233 for_each_cpu(j, policy->cpus) {
211 struct cpu_dbs_common_info *j_cdbs; 234 struct cpu_dbs_common_info *j_cdbs =
212 j_cdbs = dbs_data->get_cpu_cdbs(j); 235 dbs_data->get_cpu_cdbs(j);
213 236
237 j_cdbs->cpu = j;
214 j_cdbs->cur_policy = policy; 238 j_cdbs->cur_policy = policy;
215 j_cdbs->prev_cpu_idle = get_cpu_idle_time(j, 239 j_cdbs->prev_cpu_idle = get_cpu_idle_time(j,
216 &j_cdbs->prev_cpu_wall); 240 &j_cdbs->prev_cpu_wall);
217 if (ignore_nice) 241 if (ignore_nice)
218 j_cdbs->prev_cpu_nice = 242 j_cdbs->prev_cpu_nice =
219 kcpustat_cpu(j).cpustat[CPUTIME_NICE]; 243 kcpustat_cpu(j).cpustat[CPUTIME_NICE];
220 }
221 244
222 /* 245 mutex_init(&j_cdbs->timer_mutex);
223 * Start the timerschedule work, when this governor is used for 246 INIT_DEFERRABLE_WORK(&j_cdbs->work,
224 * first time 247 dbs_data->gov_dbs_timer);
225 */
226 if (dbs_data->enable != 1)
227 goto second_time;
228
229 rc = sysfs_create_group(cpufreq_global_kobject,
230 dbs_data->attr_group);
231 if (rc) {
232 mutex_unlock(&dbs_data->mutex);
233 return rc;
234 } 248 }
235 249
236 /* policy latency is in nS. Convert it to uS first */ 250 if (!policy->governor->initialized) {
237 latency = policy->cpuinfo.transition_latency / 1000; 251 rc = sysfs_create_group(cpufreq_global_kobject,
238 if (latency == 0) 252 dbs_data->attr_group);
239 latency = 1; 253 if (rc) {
254 mutex_unlock(&dbs_data->mutex);
255 return rc;
256 }
257 }
240 258
241 /* 259 /*
242 * conservative does not implement micro like ondemand 260 * conservative does not implement micro like ondemand
243 * governor, thus we are bound to jiffes/HZ 261 * governor, thus we are bound to jiffes/HZ
244 */ 262 */
245 if (dbs_data->governor == GOV_CONSERVATIVE) { 263 if (dbs_data->governor == GOV_CONSERVATIVE) {
246 struct cs_ops *ops = dbs_data->gov_ops; 264 cs_dbs_info->down_skip = 0;
265 cs_dbs_info->enable = 1;
266 cs_dbs_info->requested_freq = policy->cur;
247 267
248 cpufreq_register_notifier(ops->notifier_block, 268 if (!policy->governor->initialized) {
249 CPUFREQ_TRANSITION_NOTIFIER); 269 cpufreq_register_notifier(cs_ops->notifier_block,
270 CPUFREQ_TRANSITION_NOTIFIER);
250 271
251 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * 272 dbs_data->min_sampling_rate =
252 jiffies_to_usecs(10); 273 MIN_SAMPLING_RATE_RATIO *
274 jiffies_to_usecs(10);
275 }
253 } else { 276 } else {
254 struct od_ops *ops = dbs_data->gov_ops; 277 od_dbs_info->rate_mult = 1;
278 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
279 od_ops->powersave_bias_init_cpu(cpu);
255 280
256 od_tuners->io_is_busy = ops->io_busy(); 281 if (!policy->governor->initialized)
282 od_tuners->io_is_busy = od_ops->io_busy();
257 } 283 }
258 284
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
259 /* Bring kernel and HW constraints together */ 293 /* Bring kernel and HW constraints together */
260 dbs_data->min_sampling_rate = max(dbs_data->min_sampling_rate, 294 dbs_data->min_sampling_rate = max(dbs_data->min_sampling_rate,
261 MIN_LATENCY_MULTIPLIER * latency); 295 MIN_LATENCY_MULTIPLIER * latency);
262 *sampling_rate = max(dbs_data->min_sampling_rate, latency * 296 *sampling_rate = max(dbs_data->min_sampling_rate, latency *
263 LATENCY_MULTIPLIER); 297 LATENCY_MULTIPLIER);
264 298unlock:
265second_time:
266 if (dbs_data->governor == GOV_CONSERVATIVE) {
267 cs_dbs_info->down_skip = 0;
268 cs_dbs_info->enable = 1;
269 cs_dbs_info->requested_freq = policy->cur;
270 } else {
271 struct od_ops *ops = dbs_data->gov_ops;
272 od_dbs_info->rate_mult = 1;
273 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
274 ops->powersave_bias_init_cpu(cpu);
275 }
276 mutex_unlock(&dbs_data->mutex); 299 mutex_unlock(&dbs_data->mutex);
277 300
278 mutex_init(&cpu_cdbs->timer_mutex); 301 /* Initiate timer time stamp */
279 dbs_timer_init(dbs_data, cpu_cdbs, *sampling_rate); 302 cpu_cdbs->time_stamp = ktime_get();
303
304 for_each_cpu(j, policy->cpus)
305 dbs_timer_init(dbs_data, j, *sampling_rate);
280 break; 306 break;
281 307
282 case CPUFREQ_GOV_STOP: 308 case CPUFREQ_GOV_STOP:
283 if (dbs_data->governor == GOV_CONSERVATIVE) 309 if (dbs_data->governor == GOV_CONSERVATIVE)
284 cs_dbs_info->enable = 0; 310 cs_dbs_info->enable = 0;
285 311
286 dbs_timer_exit(cpu_cdbs); 312 for_each_cpu(j, policy->cpus)
313 dbs_timer_exit(dbs_data, j);
287 314
288 mutex_lock(&dbs_data->mutex); 315 mutex_lock(&dbs_data->mutex);
289 mutex_destroy(&cpu_cdbs->timer_mutex); 316 mutex_destroy(&cpu_cdbs->timer_mutex);
290 dbs_data->enable--;
291 if (!dbs_data->enable) {
292 struct cs_ops *ops = dbs_data->gov_ops;
293 317
318 if (policy->governor->initialized == 1) {
294 sysfs_remove_group(cpufreq_global_kobject, 319 sysfs_remove_group(cpufreq_global_kobject,
295 dbs_data->attr_group); 320 dbs_data->attr_group);
296 if (dbs_data->governor == GOV_CONSERVATIVE) 321 if (dbs_data->governor == GOV_CONSERVATIVE)
297 cpufreq_unregister_notifier(ops->notifier_block, 322 cpufreq_unregister_notifier(cs_ops->notifier_block,
298 CPUFREQ_TRANSITION_NOTIFIER); 323 CPUFREQ_TRANSITION_NOTIFIER);
299 } 324 }
300 mutex_unlock(&dbs_data->mutex); 325 mutex_unlock(&dbs_data->mutex);
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
index f6616540c53d..d2ac91150600 100644
--- a/drivers/cpufreq/cpufreq_governor.h
+++ b/drivers/cpufreq/cpufreq_governor.h
@@ -82,6 +82,7 @@ struct cpu_dbs_common_info {
82 * the governor or limits. 82 * the governor or limits.
83 */ 83 */
84 struct mutex timer_mutex; 84 struct mutex timer_mutex;
85 ktime_t time_stamp;
85}; 86};
86 87
87struct od_cpu_dbs_info_s { 88struct od_cpu_dbs_info_s {
@@ -108,7 +109,7 @@ struct od_dbs_tuners {
108 unsigned int sampling_rate; 109 unsigned int sampling_rate;
109 unsigned int sampling_down_factor; 110 unsigned int sampling_down_factor;
110 unsigned int up_threshold; 111 unsigned int up_threshold;
111 unsigned int down_differential; 112 unsigned int adj_up_threshold;
112 unsigned int powersave_bias; 113 unsigned int powersave_bias;
113 unsigned int io_is_busy; 114 unsigned int io_is_busy;
114}; 115};
@@ -129,7 +130,6 @@ struct dbs_data {
129 #define GOV_CONSERVATIVE 1 130 #define GOV_CONSERVATIVE 1
130 int governor; 131 int governor;
131 unsigned int min_sampling_rate; 132 unsigned int min_sampling_rate;
132 unsigned int enable; /* number of CPUs using this policy */
133 struct attribute_group *attr_group; 133 struct attribute_group *attr_group;
134 void *tuners; 134 void *tuners;
135 135
@@ -171,6 +171,8 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate)
171 171
172u64 get_cpu_idle_time(unsigned int cpu, u64 *wall); 172u64 get_cpu_idle_time(unsigned int cpu, u64 *wall);
173void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); 173void dbs_check_cpu(struct dbs_data *dbs_data, int cpu);
174bool need_load_eval(struct cpu_dbs_common_info *cdbs,
175 unsigned int sampling_rate);
174int cpufreq_governor_dbs(struct dbs_data *dbs_data, 176int cpufreq_governor_dbs(struct dbs_data *dbs_data,
175 struct cpufreq_policy *policy, unsigned int event); 177 struct cpufreq_policy *policy, unsigned int event);
176#endif /* _CPUFREQ_GOVERNER_H */ 178#endif /* _CPUFREQ_GOVERNER_H */
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 7731f7c7e79a..f3eb26cd848f 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -26,7 +26,7 @@
26 26
27#include "cpufreq_governor.h" 27#include "cpufreq_governor.h"
28 28
29/* On-demand governor macors */ 29/* On-demand governor macros */
30#define DEF_FREQUENCY_DOWN_DIFFERENTIAL (10) 30#define DEF_FREQUENCY_DOWN_DIFFERENTIAL (10)
31#define DEF_FREQUENCY_UP_THRESHOLD (80) 31#define DEF_FREQUENCY_UP_THRESHOLD (80)
32#define DEF_SAMPLING_DOWN_FACTOR (1) 32#define DEF_SAMPLING_DOWN_FACTOR (1)
@@ -47,7 +47,8 @@ static struct cpufreq_governor cpufreq_gov_ondemand;
47static struct od_dbs_tuners od_tuners = { 47static struct od_dbs_tuners od_tuners = {
48 .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, 48 .up_threshold = DEF_FREQUENCY_UP_THRESHOLD,
49 .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, 49 .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR,
50 .down_differential = DEF_FREQUENCY_DOWN_DIFFERENTIAL, 50 .adj_up_threshold = DEF_FREQUENCY_UP_THRESHOLD -
51 DEF_FREQUENCY_DOWN_DIFFERENTIAL,
51 .ignore_nice = 0, 52 .ignore_nice = 0,
52 .powersave_bias = 0, 53 .powersave_bias = 0,
53}; 54};
@@ -65,7 +66,7 @@ static void ondemand_powersave_bias_init_cpu(int cpu)
65 * efficient idling at a higher frequency/voltage is. 66 * efficient idling at a higher frequency/voltage is.
66 * Pavel Machek says this is not so for various generations of AMD and old 67 * Pavel Machek says this is not so for various generations of AMD and old
67 * Intel systems. 68 * Intel systems.
68 * Mike Chan (androidlcom) calis this is also not true for ARM. 69 * Mike Chan (android.com) claims this is also not true for ARM.
69 * Because of this, whitelist specific known (series) of CPUs by default, and 70 * Because of this, whitelist specific known (series) of CPUs by default, and
70 * leave all others up to the user. 71 * leave all others up to the user.
71 */ 72 */
@@ -73,7 +74,7 @@ static int should_io_be_busy(void)
73{ 74{
74#if defined(CONFIG_X86) 75#if defined(CONFIG_X86)
75 /* 76 /*
76 * For Intel, Core 2 (model 15) andl later have an efficient idle. 77 * For Intel, Core 2 (model 15) and later have an efficient idle.
77 */ 78 */
78 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && 79 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
79 boot_cpu_data.x86 == 6 && 80 boot_cpu_data.x86 == 6 &&
@@ -158,8 +159,8 @@ static void dbs_freq_increase(struct cpufreq_policy *p, unsigned int freq)
158 159
159/* 160/*
160 * Every sampling_rate, we check, if current idle time is less than 20% 161 * Every sampling_rate, we check, if current idle time is less than 20%
161 * (default), then we try to increase frequency Every sampling_rate, we look for 162 * (default), then we try to increase frequency. Every sampling_rate, we look
162 * a the lowest frequency which can sustain the load while keeping idle time 163 * for the lowest frequency which can sustain the load while keeping idle time
163 * over 30%. If such a frequency exist, we try to decrease to this frequency. 164 * over 30%. If such a frequency exist, we try to decrease to this frequency.
164 * 165 *
165 * Any frequency increase takes it to the maximum frequency. Frequency reduction 166 * Any frequency increase takes it to the maximum frequency. Frequency reduction
@@ -192,11 +193,9 @@ static void od_check_cpu(int cpu, unsigned int load_freq)
192 * support the current CPU usage without triggering the up policy. To be 193 * support the current CPU usage without triggering the up policy. To be
193 * safe, we focus 10 points under the threshold. 194 * safe, we focus 10 points under the threshold.
194 */ 195 */
195 if (load_freq < (od_tuners.up_threshold - od_tuners.down_differential) * 196 if (load_freq < od_tuners.adj_up_threshold * policy->cur) {
196 policy->cur) {
197 unsigned int freq_next; 197 unsigned int freq_next;
198 freq_next = load_freq / (od_tuners.up_threshold - 198 freq_next = load_freq / od_tuners.adj_up_threshold;
199 od_tuners.down_differential);
200 199
201 /* No longer fully busy, reset rate_mult */ 200 /* No longer fully busy, reset rate_mult */
202 dbs_info->rate_mult = 1; 201 dbs_info->rate_mult = 1;
@@ -218,33 +217,42 @@ static void od_check_cpu(int cpu, unsigned int load_freq)
218 217
219static void od_dbs_timer(struct work_struct *work) 218static void od_dbs_timer(struct work_struct *work)
220{ 219{
220 struct delayed_work *dw = to_delayed_work(work);
221 struct od_cpu_dbs_info_s *dbs_info = 221 struct od_cpu_dbs_info_s *dbs_info =
222 container_of(work, struct od_cpu_dbs_info_s, cdbs.work.work); 222 container_of(work, struct od_cpu_dbs_info_s, cdbs.work.work);
223 unsigned int cpu = dbs_info->cdbs.cpu; 223 unsigned int cpu = dbs_info->cdbs.cur_policy->cpu;
224 int delay, sample_type = dbs_info->sample_type; 224 struct od_cpu_dbs_info_s *core_dbs_info = &per_cpu(od_cpu_dbs_info,
225 cpu);
226 int delay, sample_type = core_dbs_info->sample_type;
227 bool eval_load;
225 228
226 mutex_lock(&dbs_info->cdbs.timer_mutex); 229 mutex_lock(&core_dbs_info->cdbs.timer_mutex);
230 eval_load = need_load_eval(&core_dbs_info->cdbs,
231 od_tuners.sampling_rate);
227 232
228 /* Common NORMAL_SAMPLE setup */ 233 /* Common NORMAL_SAMPLE setup */
229 dbs_info->sample_type = OD_NORMAL_SAMPLE; 234 core_dbs_info->sample_type = OD_NORMAL_SAMPLE;
230 if (sample_type == OD_SUB_SAMPLE) { 235 if (sample_type == OD_SUB_SAMPLE) {
231 delay = dbs_info->freq_lo_jiffies; 236 delay = core_dbs_info->freq_lo_jiffies;
232 __cpufreq_driver_target(dbs_info->cdbs.cur_policy, 237 if (eval_load)
233 dbs_info->freq_lo, CPUFREQ_RELATION_H); 238 __cpufreq_driver_target(core_dbs_info->cdbs.cur_policy,
239 core_dbs_info->freq_lo,
240 CPUFREQ_RELATION_H);
234 } else { 241 } else {
235 dbs_check_cpu(&od_dbs_data, cpu); 242 if (eval_load)
236 if (dbs_info->freq_lo) { 243 dbs_check_cpu(&od_dbs_data, cpu);
244 if (core_dbs_info->freq_lo) {
237 /* Setup timer for SUB_SAMPLE */ 245 /* Setup timer for SUB_SAMPLE */
238 dbs_info->sample_type = OD_SUB_SAMPLE; 246 core_dbs_info->sample_type = OD_SUB_SAMPLE;
239 delay = dbs_info->freq_hi_jiffies; 247 delay = core_dbs_info->freq_hi_jiffies;
240 } else { 248 } else {
241 delay = delay_for_sampling_rate(od_tuners.sampling_rate 249 delay = delay_for_sampling_rate(od_tuners.sampling_rate
242 * dbs_info->rate_mult); 250 * core_dbs_info->rate_mult);
243 } 251 }
244 } 252 }
245 253
246 schedule_delayed_work_on(cpu, &dbs_info->cdbs.work, delay); 254 schedule_delayed_work_on(smp_processor_id(), dw, delay);
247 mutex_unlock(&dbs_info->cdbs.timer_mutex); 255 mutex_unlock(&core_dbs_info->cdbs.timer_mutex);
248} 256}
249 257
250/************************** sysfs interface ************************/ 258/************************** sysfs interface ************************/
@@ -259,7 +267,7 @@ static ssize_t show_sampling_rate_min(struct kobject *kobj,
259 * update_sampling_rate - update sampling rate effective immediately if needed. 267 * update_sampling_rate - update sampling rate effective immediately if needed.
260 * @new_rate: new sampling rate 268 * @new_rate: new sampling rate
261 * 269 *
262 * If new rate is smaller than the old, simply updaing 270 * If new rate is smaller than the old, simply updating
263 * dbs_tuners_int.sampling_rate might not be appropriate. For example, if the 271 * dbs_tuners_int.sampling_rate might not be appropriate. For example, if the
264 * original sampling_rate was 1 second and the requested new sampling rate is 10 272 * original sampling_rate was 1 second and the requested new sampling rate is 10
265 * ms because the user needs immediate reaction from ondemand governor, but not 273 * ms because the user needs immediate reaction from ondemand governor, but not
@@ -287,7 +295,7 @@ static void update_sampling_rate(unsigned int new_rate)
287 cpufreq_cpu_put(policy); 295 cpufreq_cpu_put(policy);
288 continue; 296 continue;
289 } 297 }
290 dbs_info = &per_cpu(od_cpu_dbs_info, policy->cpu); 298 dbs_info = &per_cpu(od_cpu_dbs_info, cpu);
291 cpufreq_cpu_put(policy); 299 cpufreq_cpu_put(policy);
292 300
293 mutex_lock(&dbs_info->cdbs.timer_mutex); 301 mutex_lock(&dbs_info->cdbs.timer_mutex);
@@ -306,8 +314,7 @@ static void update_sampling_rate(unsigned int new_rate)
306 cancel_delayed_work_sync(&dbs_info->cdbs.work); 314 cancel_delayed_work_sync(&dbs_info->cdbs.work);
307 mutex_lock(&dbs_info->cdbs.timer_mutex); 315 mutex_lock(&dbs_info->cdbs.timer_mutex);
308 316
309 schedule_delayed_work_on(dbs_info->cdbs.cpu, 317 schedule_delayed_work_on(cpu, &dbs_info->cdbs.work,
310 &dbs_info->cdbs.work,
311 usecs_to_jiffies(new_rate)); 318 usecs_to_jiffies(new_rate));
312 319
313 } 320 }
@@ -351,6 +358,10 @@ static ssize_t store_up_threshold(struct kobject *a, struct attribute *b,
351 input < MIN_FREQUENCY_UP_THRESHOLD) { 358 input < MIN_FREQUENCY_UP_THRESHOLD) {
352 return -EINVAL; 359 return -EINVAL;
353 } 360 }
361 /* Calculate the new adj_up_threshold */
362 od_tuners.adj_up_threshold += input;
363 od_tuners.adj_up_threshold -= od_tuners.up_threshold;
364
354 od_tuners.up_threshold = input; 365 od_tuners.up_threshold = input;
355 return count; 366 return count;
356} 367}
@@ -507,7 +518,8 @@ static int __init cpufreq_gov_dbs_init(void)
507 if (idle_time != -1ULL) { 518 if (idle_time != -1ULL) {
508 /* Idle micro accounting is supported. Use finer thresholds */ 519 /* Idle micro accounting is supported. Use finer thresholds */
509 od_tuners.up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; 520 od_tuners.up_threshold = MICRO_FREQUENCY_UP_THRESHOLD;
510 od_tuners.down_differential = MICRO_FREQUENCY_DOWN_DIFFERENTIAL; 521 od_tuners.adj_up_threshold = MICRO_FREQUENCY_UP_THRESHOLD -
522 MICRO_FREQUENCY_DOWN_DIFFERENTIAL;
511 /* 523 /*
512 * In nohz/micro accounting case we set the minimum frequency 524 * In nohz/micro accounting case we set the minimum frequency
513 * not depending on HZ, but fixed (very low). The deferred 525 * not depending on HZ, but fixed (very low). The deferred
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 9d7732b81044..2fd779eb1ed1 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -24,12 +24,6 @@
24 24
25static spinlock_t cpufreq_stats_lock; 25static spinlock_t cpufreq_stats_lock;
26 26
27#define CPUFREQ_STATDEVICE_ATTR(_name, _mode, _show) \
28static struct freq_attr _attr_##_name = {\
29 .attr = {.name = __stringify(_name), .mode = _mode, }, \
30 .show = _show,\
31};
32
33struct cpufreq_stats { 27struct cpufreq_stats {
34 unsigned int cpu; 28 unsigned int cpu;
35 unsigned int total_trans; 29 unsigned int total_trans;
@@ -136,17 +130,17 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
136 return PAGE_SIZE; 130 return PAGE_SIZE;
137 return len; 131 return len;
138} 132}
139CPUFREQ_STATDEVICE_ATTR(trans_table, 0444, show_trans_table); 133cpufreq_freq_attr_ro(trans_table);
140#endif 134#endif
141 135
142CPUFREQ_STATDEVICE_ATTR(total_trans, 0444, show_total_trans); 136cpufreq_freq_attr_ro(total_trans);
143CPUFREQ_STATDEVICE_ATTR(time_in_state, 0444, show_time_in_state); 137cpufreq_freq_attr_ro(time_in_state);
144 138
145static struct attribute *default_attrs[] = { 139static struct attribute *default_attrs[] = {
146 &_attr_total_trans.attr, 140 &total_trans.attr,
147 &_attr_time_in_state.attr, 141 &time_in_state.attr,
148#ifdef CONFIG_CPU_FREQ_STAT_DETAILS 142#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
149 &_attr_trans_table.attr, 143 &trans_table.attr,
150#endif 144#endif
151 NULL 145 NULL
152}; 146};
@@ -170,11 +164,13 @@ static int freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq)
170static void cpufreq_stats_free_table(unsigned int cpu) 164static void cpufreq_stats_free_table(unsigned int cpu)
171{ 165{
172 struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, cpu); 166 struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, cpu);
167
173 if (stat) { 168 if (stat) {
169 pr_debug("%s: Free stat table\n", __func__);
174 kfree(stat->time_in_state); 170 kfree(stat->time_in_state);
175 kfree(stat); 171 kfree(stat);
172 per_cpu(cpufreq_stats_table, cpu) = NULL;
176 } 173 }
177 per_cpu(cpufreq_stats_table, cpu) = NULL;
178} 174}
179 175
180/* must be called early in the CPU removal sequence (before 176/* must be called early in the CPU removal sequence (before
@@ -183,8 +179,14 @@ static void cpufreq_stats_free_table(unsigned int cpu)
183static void cpufreq_stats_free_sysfs(unsigned int cpu) 179static void cpufreq_stats_free_sysfs(unsigned int cpu)
184{ 180{
185 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); 181 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
186 if (policy && policy->cpu == cpu) 182
183 if (!cpufreq_frequency_get_table(cpu))
184 return;
185
186 if (policy && !policy_is_shared(policy)) {
187 pr_debug("%s: Free sysfs stat\n", __func__);
187 sysfs_remove_group(&policy->kobj, &stats_attr_group); 188 sysfs_remove_group(&policy->kobj, &stats_attr_group);
189 }
188 if (policy) 190 if (policy)
189 cpufreq_cpu_put(policy); 191 cpufreq_cpu_put(policy);
190} 192}
@@ -262,6 +264,19 @@ error_get_fail:
262 return ret; 264 return ret;
263} 265}
264 266
267static void cpufreq_stats_update_policy_cpu(struct cpufreq_policy *policy)
268{
269 struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table,
270 policy->last_cpu);
271
272 pr_debug("Updating stats_table for new_cpu %u from last_cpu %u\n",
273 policy->cpu, policy->last_cpu);
274 per_cpu(cpufreq_stats_table, policy->cpu) = per_cpu(cpufreq_stats_table,
275 policy->last_cpu);
276 per_cpu(cpufreq_stats_table, policy->last_cpu) = NULL;
277 stat->cpu = policy->cpu;
278}
279
265static int cpufreq_stat_notifier_policy(struct notifier_block *nb, 280static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
266 unsigned long val, void *data) 281 unsigned long val, void *data)
267{ 282{
@@ -269,6 +284,12 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
269 struct cpufreq_policy *policy = data; 284 struct cpufreq_policy *policy = data;
270 struct cpufreq_frequency_table *table; 285 struct cpufreq_frequency_table *table;
271 unsigned int cpu = policy->cpu; 286 unsigned int cpu = policy->cpu;
287
288 if (val == CPUFREQ_UPDATE_POLICY_CPU) {
289 cpufreq_stats_update_policy_cpu(policy);
290 return 0;
291 }
292
272 if (val != CPUFREQ_NOTIFY) 293 if (val != CPUFREQ_NOTIFY)
273 return 0; 294 return 0;
274 table = cpufreq_frequency_get_table(cpu); 295 table = cpufreq_frequency_get_table(cpu);
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c
index c8c3d293cc57..bbeb9c0720a6 100644
--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -118,8 +118,6 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
118 118
119 switch (event) { 119 switch (event) {
120 case CPUFREQ_GOV_START: 120 case CPUFREQ_GOV_START:
121 if (!cpu_online(cpu))
122 return -EINVAL;
123 BUG_ON(!policy->cur); 121 BUG_ON(!policy->cur);
124 mutex_lock(&userspace_mutex); 122 mutex_lock(&userspace_mutex);
125 123
diff --git a/drivers/cpufreq/db8500-cpufreq.c b/drivers/cpufreq/db8500-cpufreq.c
index 4f154bc0ebe4..79a84860ea56 100644
--- a/drivers/cpufreq/db8500-cpufreq.c
+++ b/drivers/cpufreq/db8500-cpufreq.c
@@ -128,9 +128,7 @@ static int __cpuinit db8500_cpufreq_init(struct cpufreq_policy *policy)
128 policy->cpuinfo.transition_latency = 20 * 1000; /* in ns */ 128 policy->cpuinfo.transition_latency = 20 * 1000; /* in ns */
129 129
130 /* policy sharing between dual CPUs */ 130 /* policy sharing between dual CPUs */
131 cpumask_copy(policy->cpus, cpu_present_mask); 131 cpumask_setall(policy->cpus);
132
133 policy->shared_type = CPUFREQ_SHARED_TYPE_ALL;
134 132
135 return 0; 133 return 0;
136} 134}
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 7012ea8bf1e7..69b676dd3358 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -42,51 +42,56 @@ static unsigned int exynos_getspeed(unsigned int cpu)
42 return clk_get_rate(exynos_info->cpu_clk) / 1000; 42 return clk_get_rate(exynos_info->cpu_clk) / 1000;
43} 43}
44 44
45static int exynos_target(struct cpufreq_policy *policy, 45static int exynos_cpufreq_get_index(unsigned int freq)
46 unsigned int target_freq, 46{
47 unsigned int relation) 47 struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
48 int index;
49
50 for (index = 0;
51 freq_table[index].frequency != CPUFREQ_TABLE_END; index++)
52 if (freq_table[index].frequency == freq)
53 break;
54
55 if (freq_table[index].frequency == CPUFREQ_TABLE_END)
56 return -EINVAL;
57
58 return index;
59}
60
61static int exynos_cpufreq_scale(unsigned int target_freq)
48{ 62{
49 unsigned int index, old_index;
50 unsigned int arm_volt, safe_arm_volt = 0;
51 int ret = 0;
52 struct cpufreq_frequency_table *freq_table = exynos_info->freq_table; 63 struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
53 unsigned int *volt_table = exynos_info->volt_table; 64 unsigned int *volt_table = exynos_info->volt_table;
65 struct cpufreq_policy *policy = cpufreq_cpu_get(0);
66 unsigned int arm_volt, safe_arm_volt = 0;
54 unsigned int mpll_freq_khz = exynos_info->mpll_freq_khz; 67 unsigned int mpll_freq_khz = exynos_info->mpll_freq_khz;
55 68 int index, old_index;
56 mutex_lock(&cpufreq_lock); 69 int ret = 0;
57 70
58 freqs.old = policy->cur; 71 freqs.old = policy->cur;
72 freqs.new = target_freq;
73 freqs.cpu = policy->cpu;
59 74
60 if (frequency_locked && target_freq != locking_frequency) { 75 if (freqs.new == freqs.old)
61 ret = -EAGAIN;
62 goto out; 76 goto out;
63 }
64 77
65 /* 78 /*
66 * The policy max have been changed so that we cannot get proper 79 * The policy max have been changed so that we cannot get proper
67 * old_index with cpufreq_frequency_table_target(). Thus, ignore 80 * old_index with cpufreq_frequency_table_target(). Thus, ignore
68 * policy and get the index from the raw freqeuncy table. 81 * policy and get the index from the raw freqeuncy table.
69 */ 82 */
70 for (old_index = 0; 83 old_index = exynos_cpufreq_get_index(freqs.old);
71 freq_table[old_index].frequency != CPUFREQ_TABLE_END; 84 if (old_index < 0) {
72 old_index++) 85 ret = old_index;
73 if (freq_table[old_index].frequency == freqs.old)
74 break;
75
76 if (freq_table[old_index].frequency == CPUFREQ_TABLE_END) {
77 ret = -EINVAL;
78 goto out; 86 goto out;
79 } 87 }
80 88
81 if (cpufreq_frequency_table_target(policy, freq_table, 89 index = exynos_cpufreq_get_index(target_freq);
82 target_freq, relation, &index)) { 90 if (index < 0) {
83 ret = -EINVAL; 91 ret = index;
84 goto out; 92 goto out;
85 } 93 }
86 94
87 freqs.new = freq_table[index].frequency;
88 freqs.cpu = policy->cpu;
89
90 /* 95 /*
91 * ARM clock source will be changed APLL to MPLL temporary 96 * ARM clock source will be changed APLL to MPLL temporary
92 * To support this level, need to control regulator for 97 * To support this level, need to control regulator for
@@ -106,15 +111,25 @@ static int exynos_target(struct cpufreq_policy *policy,
106 /* When the new frequency is higher than current frequency */ 111 /* When the new frequency is higher than current frequency */
107 if ((freqs.new > freqs.old) && !safe_arm_volt) { 112 if ((freqs.new > freqs.old) && !safe_arm_volt) {
108 /* Firstly, voltage up to increase frequency */ 113 /* Firstly, voltage up to increase frequency */
109 regulator_set_voltage(arm_regulator, arm_volt, 114 ret = regulator_set_voltage(arm_regulator, arm_volt, arm_volt);
110 arm_volt); 115 if (ret) {
116 pr_err("%s: failed to set cpu voltage to %d\n",
117 __func__, arm_volt);
118 goto out;
119 }
111 } 120 }
112 121
113 if (safe_arm_volt) 122 if (safe_arm_volt) {
114 regulator_set_voltage(arm_regulator, safe_arm_volt, 123 ret = regulator_set_voltage(arm_regulator, safe_arm_volt,
115 safe_arm_volt); 124 safe_arm_volt);
116 if (freqs.new != freqs.old) 125 if (ret) {
117 exynos_info->set_freq(old_index, index); 126 pr_err("%s: failed to set cpu voltage to %d\n",
127 __func__, safe_arm_volt);
128 goto out;
129 }
130 }
131
132 exynos_info->set_freq(old_index, index);
118 133
119 for_each_cpu(freqs.cpu, policy->cpus) 134 for_each_cpu(freqs.cpu, policy->cpus)
120 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 135 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
@@ -125,8 +140,44 @@ static int exynos_target(struct cpufreq_policy *policy,
125 /* down the voltage after frequency change */ 140 /* down the voltage after frequency change */
126 regulator_set_voltage(arm_regulator, arm_volt, 141 regulator_set_voltage(arm_regulator, arm_volt,
127 arm_volt); 142 arm_volt);
143 if (ret) {
144 pr_err("%s: failed to set cpu voltage to %d\n",
145 __func__, arm_volt);
146 goto out;
147 }
148 }
149
150out:
151
152 cpufreq_cpu_put(policy);
153
154 return ret;
155}
156
157static int exynos_target(struct cpufreq_policy *policy,
158 unsigned int target_freq,
159 unsigned int relation)
160{
161 struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
162 unsigned int index;
163 unsigned int new_freq;
164 int ret = 0;
165
166 mutex_lock(&cpufreq_lock);
167
168 if (frequency_locked)
169 goto out;
170
171 if (cpufreq_frequency_table_target(policy, freq_table,
172 target_freq, relation, &index)) {
173 ret = -EINVAL;
174 goto out;
128 } 175 }
129 176
177 new_freq = freq_table[index].frequency;
178
179 ret = exynos_cpufreq_scale(new_freq);
180
130out: 181out:
131 mutex_unlock(&cpufreq_lock); 182 mutex_unlock(&cpufreq_lock);
132 183
@@ -163,51 +214,26 @@ static int exynos_cpufreq_resume(struct cpufreq_policy *policy)
163static int exynos_cpufreq_pm_notifier(struct notifier_block *notifier, 214static int exynos_cpufreq_pm_notifier(struct notifier_block *notifier,
164 unsigned long pm_event, void *v) 215 unsigned long pm_event, void *v)
165{ 216{
166 struct cpufreq_policy *policy = cpufreq_cpu_get(0); /* boot CPU */ 217 int ret;
167 static unsigned int saved_frequency;
168 unsigned int temp;
169 218
170 mutex_lock(&cpufreq_lock);
171 switch (pm_event) { 219 switch (pm_event) {
172 case PM_SUSPEND_PREPARE: 220 case PM_SUSPEND_PREPARE:
173 if (frequency_locked) 221 mutex_lock(&cpufreq_lock);
174 goto out;
175
176 frequency_locked = true; 222 frequency_locked = true;
223 mutex_unlock(&cpufreq_lock);
177 224
178 if (locking_frequency) { 225 ret = exynos_cpufreq_scale(locking_frequency);
179 saved_frequency = exynos_getspeed(0); 226 if (ret < 0)
227 return NOTIFY_BAD;
180 228
181 mutex_unlock(&cpufreq_lock);
182 exynos_target(policy, locking_frequency,
183 CPUFREQ_RELATION_H);
184 mutex_lock(&cpufreq_lock);
185 }
186 break; 229 break;
187 230
188 case PM_POST_SUSPEND: 231 case PM_POST_SUSPEND:
189 if (saved_frequency) { 232 mutex_lock(&cpufreq_lock);
190 /*
191 * While frequency_locked, only locking_frequency
192 * is valid for target(). In order to use
193 * saved_frequency while keeping frequency_locked,
194 * we temporarly overwrite locking_frequency.
195 */
196 temp = locking_frequency;
197 locking_frequency = saved_frequency;
198
199 mutex_unlock(&cpufreq_lock);
200 exynos_target(policy, locking_frequency,
201 CPUFREQ_RELATION_H);
202 mutex_lock(&cpufreq_lock);
203
204 locking_frequency = temp;
205 }
206 frequency_locked = false; 233 frequency_locked = false;
234 mutex_unlock(&cpufreq_lock);
207 break; 235 break;
208 } 236 }
209out:
210 mutex_unlock(&cpufreq_lock);
211 237
212 return NOTIFY_OK; 238 return NOTIFY_OK;
213} 239}
@@ -222,35 +248,34 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
222 248
223 cpufreq_frequency_table_get_attr(exynos_info->freq_table, policy->cpu); 249 cpufreq_frequency_table_get_attr(exynos_info->freq_table, policy->cpu);
224 250
225 locking_frequency = exynos_getspeed(0);
226
227 /* set the transition latency value */ 251 /* set the transition latency value */
228 policy->cpuinfo.transition_latency = 100000; 252 policy->cpuinfo.transition_latency = 100000;
229 253
230 /* 254 cpumask_setall(policy->cpus);
231 * EXYNOS4 multi-core processors has 2 cores
232 * that the frequency cannot be set independently.
233 * Each cpu is bound to the same speed.
234 * So the affected cpu is all of the cpus.
235 */
236 if (num_online_cpus() == 1) {
237 cpumask_copy(policy->related_cpus, cpu_possible_mask);
238 cpumask_copy(policy->cpus, cpu_online_mask);
239 } else {
240 policy->shared_type = CPUFREQ_SHARED_TYPE_ANY;
241 cpumask_setall(policy->cpus);
242 }
243 255
244 return cpufreq_frequency_table_cpuinfo(policy, exynos_info->freq_table); 256 return cpufreq_frequency_table_cpuinfo(policy, exynos_info->freq_table);
245} 257}
246 258
259static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
260{
261 cpufreq_frequency_table_put_attr(policy->cpu);
262 return 0;
263}
264
265static struct freq_attr *exynos_cpufreq_attr[] = {
266 &cpufreq_freq_attr_scaling_available_freqs,
267 NULL,
268};
269
247static struct cpufreq_driver exynos_driver = { 270static struct cpufreq_driver exynos_driver = {
248 .flags = CPUFREQ_STICKY, 271 .flags = CPUFREQ_STICKY,
249 .verify = exynos_verify_speed, 272 .verify = exynos_verify_speed,
250 .target = exynos_target, 273 .target = exynos_target,
251 .get = exynos_getspeed, 274 .get = exynos_getspeed,
252 .init = exynos_cpufreq_cpu_init, 275 .init = exynos_cpufreq_cpu_init,
276 .exit = exynos_cpufreq_cpu_exit,
253 .name = "exynos_cpufreq", 277 .name = "exynos_cpufreq",
278 .attr = exynos_cpufreq_attr,
254#ifdef CONFIG_PM 279#ifdef CONFIG_PM
255 .suspend = exynos_cpufreq_suspend, 280 .suspend = exynos_cpufreq_suspend,
256 .resume = exynos_cpufreq_resume, 281 .resume = exynos_cpufreq_resume,
@@ -288,6 +313,8 @@ static int __init exynos_cpufreq_init(void)
288 goto err_vdd_arm; 313 goto err_vdd_arm;
289 } 314 }
290 315
316 locking_frequency = exynos_getspeed(0);
317
291 register_pm_notifier(&exynos_cpufreq_nb); 318 register_pm_notifier(&exynos_cpufreq_nb);
292 319
293 if (cpufreq_register_driver(&exynos_driver)) { 320 if (cpufreq_register_driver(&exynos_driver)) {
@@ -299,8 +326,7 @@ static int __init exynos_cpufreq_init(void)
299err_cpufreq: 326err_cpufreq:
300 unregister_pm_notifier(&exynos_cpufreq_nb); 327 unregister_pm_notifier(&exynos_cpufreq_nb);
301 328
302 if (!IS_ERR(arm_regulator)) 329 regulator_put(arm_regulator);
303 regulator_put(arm_regulator);
304err_vdd_arm: 330err_vdd_arm:
305 kfree(exynos_info); 331 kfree(exynos_info);
306 pr_debug("%s: failed initialization\n", __func__); 332 pr_debug("%s: failed initialization\n", __func__);
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c
index fb148fa27678..de91755e2556 100644
--- a/drivers/cpufreq/exynos4210-cpufreq.c
+++ b/drivers/cpufreq/exynos4210-cpufreq.c
@@ -20,97 +20,37 @@
20#include <mach/regs-clock.h> 20#include <mach/regs-clock.h>
21#include <mach/cpufreq.h> 21#include <mach/cpufreq.h>
22 22
23#define CPUFREQ_LEVEL_END L5
24
25static int max_support_idx = L0;
26static int min_support_idx = (CPUFREQ_LEVEL_END - 1);
27
28static struct clk *cpu_clk; 23static struct clk *cpu_clk;
29static struct clk *moutcore; 24static struct clk *moutcore;
30static struct clk *mout_mpll; 25static struct clk *mout_mpll;
31static struct clk *mout_apll; 26static struct clk *mout_apll;
32 27
33struct cpufreq_clkdiv { 28static unsigned int exynos4210_volt_table[] = {
34 unsigned int index;
35 unsigned int clkdiv;
36};
37
38static unsigned int exynos4210_volt_table[CPUFREQ_LEVEL_END] = {
39 1250000, 1150000, 1050000, 975000, 950000, 29 1250000, 1150000, 1050000, 975000, 950000,
40}; 30};
41 31
42
43static struct cpufreq_clkdiv exynos4210_clkdiv_table[CPUFREQ_LEVEL_END];
44
45static struct cpufreq_frequency_table exynos4210_freq_table[] = { 32static struct cpufreq_frequency_table exynos4210_freq_table[] = {
46 {L0, 1200*1000}, 33 {L0, 1200 * 1000},
47 {L1, 1000*1000}, 34 {L1, 1000 * 1000},
48 {L2, 800*1000}, 35 {L2, 800 * 1000},
49 {L3, 500*1000}, 36 {L3, 500 * 1000},
50 {L4, 200*1000}, 37 {L4, 200 * 1000},
51 {0, CPUFREQ_TABLE_END}, 38 {0, CPUFREQ_TABLE_END},
52}; 39};
53 40
54static unsigned int clkdiv_cpu0[CPUFREQ_LEVEL_END][7] = { 41static struct apll_freq apll_freq_4210[] = {
55 /* 42 /*
56 * Clock divider value for following 43 * values:
57 * { DIVCORE, DIVCOREM0, DIVCOREM1, DIVPERIPH, 44 * freq
58 * DIVATB, DIVPCLK_DBG, DIVAPLL } 45 * clock divider for CORE, COREM0, COREM1, PERIPH, ATB, PCLK_DBG, APLL, RESERVED
46 * clock divider for COPY, HPM, RESERVED
47 * PLL M, P, S
59 */ 48 */
60 49 APLL_FREQ(1200, 0, 3, 7, 3, 4, 1, 7, 0, 5, 0, 0, 150, 3, 1),
61 /* ARM L0: 1200MHz */ 50 APLL_FREQ(1000, 0, 3, 7, 3, 4, 1, 7, 0, 4, 0, 0, 250, 6, 1),
62 { 0, 3, 7, 3, 4, 1, 7 }, 51 APLL_FREQ(800, 0, 3, 7, 3, 3, 1, 7, 0, 3, 0, 0, 200, 6, 1),
63 52 APLL_FREQ(500, 0, 3, 7, 3, 3, 1, 7, 0, 3, 0, 0, 250, 6, 2),
64 /* ARM L1: 1000MHz */ 53 APLL_FREQ(200, 0, 1, 3, 1, 3, 1, 0, 0, 3, 0, 0, 200, 6, 3),
65 { 0, 3, 7, 3, 4, 1, 7 },
66
67 /* ARM L2: 800MHz */
68 { 0, 3, 7, 3, 3, 1, 7 },
69
70 /* ARM L3: 500MHz */
71 { 0, 3, 7, 3, 3, 1, 7 },
72
73 /* ARM L4: 200MHz */
74 { 0, 1, 3, 1, 3, 1, 0 },
75};
76
77static unsigned int clkdiv_cpu1[CPUFREQ_LEVEL_END][2] = {
78 /*
79 * Clock divider value for following
80 * { DIVCOPY, DIVHPM }
81 */
82
83 /* ARM L0: 1200MHz */
84 { 5, 0 },
85
86 /* ARM L1: 1000MHz */
87 { 4, 0 },
88
89 /* ARM L2: 800MHz */
90 { 3, 0 },
91
92 /* ARM L3: 500MHz */
93 { 3, 0 },
94
95 /* ARM L4: 200MHz */
96 { 3, 0 },
97};
98
99static unsigned int exynos4210_apll_pms_table[CPUFREQ_LEVEL_END] = {
100 /* APLL FOUT L0: 1200MHz */
101 ((150 << 16) | (3 << 8) | 1),
102
103 /* APLL FOUT L1: 1000MHz */
104 ((250 << 16) | (6 << 8) | 1),
105
106 /* APLL FOUT L2: 800MHz */
107 ((200 << 16) | (6 << 8) | 1),
108
109 /* APLL FOUT L3: 500MHz */
110 ((250 << 16) | (6 << 8) | 2),
111
112 /* APLL FOUT L4: 200MHz */
113 ((200 << 16) | (6 << 8) | 3),
114}; 54};
115 55
116static void exynos4210_set_clkdiv(unsigned int div_index) 56static void exynos4210_set_clkdiv(unsigned int div_index)
@@ -119,7 +59,7 @@ static void exynos4210_set_clkdiv(unsigned int div_index)
119 59
120 /* Change Divider - CPU0 */ 60 /* Change Divider - CPU0 */
121 61
122 tmp = exynos4210_clkdiv_table[div_index].clkdiv; 62 tmp = apll_freq_4210[div_index].clk_div_cpu0;
123 63
124 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU); 64 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU);
125 65
@@ -129,12 +69,7 @@ static void exynos4210_set_clkdiv(unsigned int div_index)
129 69
130 /* Change Divider - CPU1 */ 70 /* Change Divider - CPU1 */
131 71
132 tmp = __raw_readl(EXYNOS4_CLKDIV_CPU1); 72 tmp = apll_freq_4210[div_index].clk_div_cpu1;
133
134 tmp &= ~((0x7 << 4) | 0x7);
135
136 tmp |= ((clkdiv_cpu1[div_index][0] << 4) |
137 (clkdiv_cpu1[div_index][1] << 0));
138 73
139 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU1); 74 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU1);
140 75
@@ -162,7 +97,7 @@ static void exynos4210_set_apll(unsigned int index)
162 /* 3. Change PLL PMS values */ 97 /* 3. Change PLL PMS values */
163 tmp = __raw_readl(EXYNOS4_APLL_CON0); 98 tmp = __raw_readl(EXYNOS4_APLL_CON0);
164 tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0)); 99 tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0));
165 tmp |= exynos4210_apll_pms_table[index]; 100 tmp |= apll_freq_4210[index].mps;
166 __raw_writel(tmp, EXYNOS4_APLL_CON0); 101 __raw_writel(tmp, EXYNOS4_APLL_CON0);
167 102
168 /* 4. wait_lock_time */ 103 /* 4. wait_lock_time */
@@ -179,10 +114,10 @@ static void exynos4210_set_apll(unsigned int index)
179 } while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT)); 114 } while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT));
180} 115}
181 116
182bool exynos4210_pms_change(unsigned int old_index, unsigned int new_index) 117static bool exynos4210_pms_change(unsigned int old_index, unsigned int new_index)
183{ 118{
184 unsigned int old_pm = (exynos4210_apll_pms_table[old_index] >> 8); 119 unsigned int old_pm = apll_freq_4210[old_index].mps >> 8;
185 unsigned int new_pm = (exynos4210_apll_pms_table[new_index] >> 8); 120 unsigned int new_pm = apll_freq_4210[new_index].mps >> 8;
186 121
187 return (old_pm == new_pm) ? 0 : 1; 122 return (old_pm == new_pm) ? 0 : 1;
188} 123}
@@ -200,7 +135,7 @@ static void exynos4210_set_frequency(unsigned int old_index,
200 /* 2. Change just s value in apll m,p,s value */ 135 /* 2. Change just s value in apll m,p,s value */
201 tmp = __raw_readl(EXYNOS4_APLL_CON0); 136 tmp = __raw_readl(EXYNOS4_APLL_CON0);
202 tmp &= ~(0x7 << 0); 137 tmp &= ~(0x7 << 0);
203 tmp |= (exynos4210_apll_pms_table[new_index] & 0x7); 138 tmp |= apll_freq_4210[new_index].mps & 0x7;
204 __raw_writel(tmp, EXYNOS4_APLL_CON0); 139 __raw_writel(tmp, EXYNOS4_APLL_CON0);
205 } else { 140 } else {
206 /* Clock Configuration Procedure */ 141 /* Clock Configuration Procedure */
@@ -214,7 +149,7 @@ static void exynos4210_set_frequency(unsigned int old_index,
214 /* 1. Change just s value in apll m,p,s value */ 149 /* 1. Change just s value in apll m,p,s value */
215 tmp = __raw_readl(EXYNOS4_APLL_CON0); 150 tmp = __raw_readl(EXYNOS4_APLL_CON0);
216 tmp &= ~(0x7 << 0); 151 tmp &= ~(0x7 << 0);
217 tmp |= (exynos4210_apll_pms_table[new_index] & 0x7); 152 tmp |= apll_freq_4210[new_index].mps & 0x7;
218 __raw_writel(tmp, EXYNOS4_APLL_CON0); 153 __raw_writel(tmp, EXYNOS4_APLL_CON0);
219 154
220 /* 2. Change the system clock divider values */ 155 /* 2. Change the system clock divider values */
@@ -231,8 +166,6 @@ static void exynos4210_set_frequency(unsigned int old_index,
231 166
232int exynos4210_cpufreq_init(struct exynos_dvfs_info *info) 167int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
233{ 168{
234 int i;
235 unsigned int tmp;
236 unsigned long rate; 169 unsigned long rate;
237 170
238 cpu_clk = clk_get(NULL, "armclk"); 171 cpu_clk = clk_get(NULL, "armclk");
@@ -253,33 +186,9 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
253 if (IS_ERR(mout_apll)) 186 if (IS_ERR(mout_apll))
254 goto err_mout_apll; 187 goto err_mout_apll;
255 188
256 tmp = __raw_readl(EXYNOS4_CLKDIV_CPU);
257
258 for (i = L0; i < CPUFREQ_LEVEL_END; i++) {
259 tmp &= ~(EXYNOS4_CLKDIV_CPU0_CORE_MASK |
260 EXYNOS4_CLKDIV_CPU0_COREM0_MASK |
261 EXYNOS4_CLKDIV_CPU0_COREM1_MASK |
262 EXYNOS4_CLKDIV_CPU0_PERIPH_MASK |
263 EXYNOS4_CLKDIV_CPU0_ATB_MASK |
264 EXYNOS4_CLKDIV_CPU0_PCLKDBG_MASK |
265 EXYNOS4_CLKDIV_CPU0_APLL_MASK);
266
267 tmp |= ((clkdiv_cpu0[i][0] << EXYNOS4_CLKDIV_CPU0_CORE_SHIFT) |
268 (clkdiv_cpu0[i][1] << EXYNOS4_CLKDIV_CPU0_COREM0_SHIFT) |
269 (clkdiv_cpu0[i][2] << EXYNOS4_CLKDIV_CPU0_COREM1_SHIFT) |
270 (clkdiv_cpu0[i][3] << EXYNOS4_CLKDIV_CPU0_PERIPH_SHIFT) |
271 (clkdiv_cpu0[i][4] << EXYNOS4_CLKDIV_CPU0_ATB_SHIFT) |
272 (clkdiv_cpu0[i][5] << EXYNOS4_CLKDIV_CPU0_PCLKDBG_SHIFT) |
273 (clkdiv_cpu0[i][6] << EXYNOS4_CLKDIV_CPU0_APLL_SHIFT));
274
275 exynos4210_clkdiv_table[i].clkdiv = tmp;
276 }
277
278 info->mpll_freq_khz = rate; 189 info->mpll_freq_khz = rate;
279 info->pm_lock_idx = L2; 190 /* 800Mhz */
280 info->pll_safe_idx = L2; 191 info->pll_safe_idx = L2;
281 info->max_support_idx = max_support_idx;
282 info->min_support_idx = min_support_idx;
283 info->cpu_clk = cpu_clk; 192 info->cpu_clk = cpu_clk;
284 info->volt_table = exynos4210_volt_table; 193 info->volt_table = exynos4210_volt_table;
285 info->freq_table = exynos4210_freq_table; 194 info->freq_table = exynos4210_freq_table;
@@ -289,14 +198,11 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
289 return 0; 198 return 0;
290 199
291err_mout_apll: 200err_mout_apll:
292 if (!IS_ERR(mout_mpll)) 201 clk_put(mout_mpll);
293 clk_put(mout_mpll);
294err_mout_mpll: 202err_mout_mpll:
295 if (!IS_ERR(moutcore)) 203 clk_put(moutcore);
296 clk_put(moutcore);
297err_moutcore: 204err_moutcore:
298 if (!IS_ERR(cpu_clk)) 205 clk_put(cpu_clk);
299 clk_put(cpu_clk);
300 206
301 pr_debug("%s: failed initialization\n", __func__); 207 pr_debug("%s: failed initialization\n", __func__);
302 return -EINVAL; 208 return -EINVAL;
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 8c5a7afa5b0b..0661039e5d4a 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -20,26 +20,18 @@
20#include <mach/regs-clock.h> 20#include <mach/regs-clock.h>
21#include <mach/cpufreq.h> 21#include <mach/cpufreq.h>
22 22
23#define CPUFREQ_LEVEL_END (L13 + 1)
24
25static int max_support_idx;
26static int min_support_idx = (CPUFREQ_LEVEL_END - 1);
27
28static struct clk *cpu_clk; 23static struct clk *cpu_clk;
29static struct clk *moutcore; 24static struct clk *moutcore;
30static struct clk *mout_mpll; 25static struct clk *mout_mpll;
31static struct clk *mout_apll; 26static struct clk *mout_apll;
32 27
33struct cpufreq_clkdiv { 28static unsigned int exynos4x12_volt_table[] = {
34 unsigned int index; 29 1350000, 1287500, 1250000, 1187500, 1137500, 1087500, 1037500,
35 unsigned int clkdiv; 30 1000000, 987500, 975000, 950000, 925000, 900000, 900000
36 unsigned int clkdiv1;
37}; 31};
38 32
39static unsigned int exynos4x12_volt_table[CPUFREQ_LEVEL_END];
40
41static struct cpufreq_frequency_table exynos4x12_freq_table[] = { 33static struct cpufreq_frequency_table exynos4x12_freq_table[] = {
42 {L0, 1500 * 1000}, 34 {L0, CPUFREQ_ENTRY_INVALID},
43 {L1, 1400 * 1000}, 35 {L1, 1400 * 1000},
44 {L2, 1300 * 1000}, 36 {L2, 1300 * 1000},
45 {L3, 1200 * 1000}, 37 {L3, 1200 * 1000},
@@ -56,247 +48,54 @@ static struct cpufreq_frequency_table exynos4x12_freq_table[] = {
56 {0, CPUFREQ_TABLE_END}, 48 {0, CPUFREQ_TABLE_END},
57}; 49};
58 50
59static struct cpufreq_clkdiv exynos4x12_clkdiv_table[CPUFREQ_LEVEL_END]; 51static struct apll_freq *apll_freq_4x12;
60 52
61static unsigned int clkdiv_cpu0_4212[CPUFREQ_LEVEL_END][8] = { 53static struct apll_freq apll_freq_4212[] = {
62 /* 54 /*
63 * Clock divider value for following 55 * values:
64 * { DIVCORE, DIVCOREM0, DIVCOREM1, DIVPERIPH, 56 * freq
65 * DIVATB, DIVPCLK_DBG, DIVAPLL, DIVCORE2 } 57 * clock divider for CORE, COREM0, COREM1, PERIPH, ATB, PCLK_DBG, APLL, CORE2
58 * clock divider for COPY, HPM, RESERVED
59 * PLL M, P, S
66 */ 60 */
67 /* ARM L0: 1500 MHz */ 61 APLL_FREQ(1500, 0, 3, 7, 0, 6, 1, 2, 0, 6, 2, 0, 250, 4, 0),
68 { 0, 3, 7, 0, 6, 1, 2, 0 }, 62 APLL_FREQ(1400, 0, 3, 7, 0, 6, 1, 2, 0, 6, 2, 0, 175, 3, 0),
69 63 APLL_FREQ(1300, 0, 3, 7, 0, 5, 1, 2, 0, 5, 2, 0, 325, 6, 0),
70 /* ARM L1: 1400 MHz */ 64 APLL_FREQ(1200, 0, 3, 7, 0, 5, 1, 2, 0, 5, 2, 0, 200, 4, 0),
71 { 0, 3, 7, 0, 6, 1, 2, 0 }, 65 APLL_FREQ(1100, 0, 3, 6, 0, 4, 1, 2, 0, 4, 2, 0, 275, 6, 0),
72 66 APLL_FREQ(1000, 0, 2, 5, 0, 4, 1, 1, 0, 4, 2, 0, 125, 3, 0),
73 /* ARM L2: 1300 MHz */ 67 APLL_FREQ(900, 0, 2, 5, 0, 3, 1, 1, 0, 3, 2, 0, 150, 4, 0),
74 { 0, 3, 7, 0, 5, 1, 2, 0 }, 68 APLL_FREQ(800, 0, 2, 5, 0, 3, 1, 1, 0, 3, 2, 0, 100, 3, 0),
75 69 APLL_FREQ(700, 0, 2, 4, 0, 3, 1, 1, 0, 3, 2, 0, 175, 3, 1),
76 /* ARM L3: 1200 MHz */ 70 APLL_FREQ(600, 0, 2, 4, 0, 3, 1, 1, 0, 3, 2, 0, 200, 4, 1),
77 { 0, 3, 7, 0, 5, 1, 2, 0 }, 71 APLL_FREQ(500, 0, 2, 4, 0, 3, 1, 1, 0, 3, 2, 0, 125, 3, 1),
78 72 APLL_FREQ(400, 0, 2, 4, 0, 3, 1, 1, 0, 3, 2, 0, 100, 3, 1),
79 /* ARM L4: 1100 MHz */ 73 APLL_FREQ(300, 0, 2, 4, 0, 2, 1, 1, 0, 3, 2, 0, 200, 4, 2),
80 { 0, 3, 6, 0, 4, 1, 2, 0 }, 74 APLL_FREQ(200, 0, 1, 3, 0, 1, 1, 1, 0, 3, 2, 0, 100, 3, 2),
81
82 /* ARM L5: 1000 MHz */
83 { 0, 2, 5, 0, 4, 1, 1, 0 },
84
85 /* ARM L6: 900 MHz */
86 { 0, 2, 5, 0, 3, 1, 1, 0 },
87
88 /* ARM L7: 800 MHz */
89 { 0, 2, 5, 0, 3, 1, 1, 0 },
90
91 /* ARM L8: 700 MHz */
92 { 0, 2, 4, 0, 3, 1, 1, 0 },
93
94 /* ARM L9: 600 MHz */
95 { 0, 2, 4, 0, 3, 1, 1, 0 },
96
97 /* ARM L10: 500 MHz */
98 { 0, 2, 4, 0, 3, 1, 1, 0 },
99
100 /* ARM L11: 400 MHz */
101 { 0, 2, 4, 0, 3, 1, 1, 0 },
102
103 /* ARM L12: 300 MHz */
104 { 0, 2, 4, 0, 2, 1, 1, 0 },
105
106 /* ARM L13: 200 MHz */
107 { 0, 1, 3, 0, 1, 1, 1, 0 },
108}; 75};
109 76
110static unsigned int clkdiv_cpu0_4412[CPUFREQ_LEVEL_END][8] = { 77static struct apll_freq apll_freq_4412[] = {
111 /* 78 /*
112 * Clock divider value for following 79 * values:
113 * { DIVCORE, DIVCOREM0, DIVCOREM1, DIVPERIPH, 80 * freq
114 * DIVATB, DIVPCLK_DBG, DIVAPLL, DIVCORE2 } 81 * clock divider for CORE, COREM0, COREM1, PERIPH, ATB, PCLK_DBG, APLL, CORE2
115 */ 82 * clock divider for COPY, HPM, CORES
116 /* ARM L0: 1500 MHz */ 83 * PLL M, P, S
117 { 0, 3, 7, 0, 6, 1, 2, 0 },
118
119 /* ARM L1: 1400 MHz */
120 { 0, 3, 7, 0, 6, 1, 2, 0 },
121
122 /* ARM L2: 1300 MHz */
123 { 0, 3, 7, 0, 5, 1, 2, 0 },
124
125 /* ARM L3: 1200 MHz */
126 { 0, 3, 7, 0, 5, 1, 2, 0 },
127
128 /* ARM L4: 1100 MHz */
129 { 0, 3, 6, 0, 4, 1, 2, 0 },
130
131 /* ARM L5: 1000 MHz */
132 { 0, 2, 5, 0, 4, 1, 1, 0 },
133
134 /* ARM L6: 900 MHz */
135 { 0, 2, 5, 0, 3, 1, 1, 0 },
136
137 /* ARM L7: 800 MHz */
138 { 0, 2, 5, 0, 3, 1, 1, 0 },
139
140 /* ARM L8: 700 MHz */
141 { 0, 2, 4, 0, 3, 1, 1, 0 },
142
143 /* ARM L9: 600 MHz */
144 { 0, 2, 4, 0, 3, 1, 1, 0 },
145
146 /* ARM L10: 500 MHz */
147 { 0, 2, 4, 0, 3, 1, 1, 0 },
148
149 /* ARM L11: 400 MHz */
150 { 0, 2, 4, 0, 3, 1, 1, 0 },
151
152 /* ARM L12: 300 MHz */
153 { 0, 2, 4, 0, 2, 1, 1, 0 },
154
155 /* ARM L13: 200 MHz */
156 { 0, 1, 3, 0, 1, 1, 1, 0 },
157};
158
159static unsigned int clkdiv_cpu1_4212[CPUFREQ_LEVEL_END][2] = {
160 /* Clock divider value for following
161 * { DIVCOPY, DIVHPM }
162 */
163 /* ARM L0: 1500 MHz */
164 { 6, 0 },
165
166 /* ARM L1: 1400 MHz */
167 { 6, 0 },
168
169 /* ARM L2: 1300 MHz */
170 { 5, 0 },
171
172 /* ARM L3: 1200 MHz */
173 { 5, 0 },
174
175 /* ARM L4: 1100 MHz */
176 { 4, 0 },
177
178 /* ARM L5: 1000 MHz */
179 { 4, 0 },
180
181 /* ARM L6: 900 MHz */
182 { 3, 0 },
183
184 /* ARM L7: 800 MHz */
185 { 3, 0 },
186
187 /* ARM L8: 700 MHz */
188 { 3, 0 },
189
190 /* ARM L9: 600 MHz */
191 { 3, 0 },
192
193 /* ARM L10: 500 MHz */
194 { 3, 0 },
195
196 /* ARM L11: 400 MHz */
197 { 3, 0 },
198
199 /* ARM L12: 300 MHz */
200 { 3, 0 },
201
202 /* ARM L13: 200 MHz */
203 { 3, 0 },
204};
205
206static unsigned int clkdiv_cpu1_4412[CPUFREQ_LEVEL_END][3] = {
207 /* Clock divider value for following
208 * { DIVCOPY, DIVHPM, DIVCORES }
209 */ 84 */
210 /* ARM L0: 1500 MHz */ 85 APLL_FREQ(1500, 0, 3, 7, 0, 6, 1, 2, 0, 6, 0, 7, 250, 4, 0),
211 { 6, 0, 7 }, 86 APLL_FREQ(1400, 0, 3, 7, 0, 6, 1, 2, 0, 6, 0, 6, 175, 3, 0),
212 87 APLL_FREQ(1300, 0, 3, 7, 0, 5, 1, 2, 0, 5, 0, 6, 325, 6, 0),
213 /* ARM L1: 1400 MHz */ 88 APLL_FREQ(1200, 0, 3, 7, 0, 5, 1, 2, 0, 5, 0, 5, 200, 4, 0),
214 { 6, 0, 6 }, 89 APLL_FREQ(1100, 0, 3, 6, 0, 4, 1, 2, 0, 4, 0, 5, 275, 6, 0),
215 90 APLL_FREQ(1000, 0, 2, 5, 0, 4, 1, 1, 0, 4, 0, 4, 125, 3, 0),
216 /* ARM L2: 1300 MHz */ 91 APLL_FREQ(900, 0, 2, 5, 0, 3, 1, 1, 0, 3, 0, 4, 150, 4, 0),
217 { 5, 0, 6 }, 92 APLL_FREQ(800, 0, 2, 5, 0, 3, 1, 1, 0, 3, 0, 3, 100, 3, 0),
218 93 APLL_FREQ(700, 0, 2, 4, 0, 3, 1, 1, 0, 3, 0, 3, 175, 3, 1),
219 /* ARM L3: 1200 MHz */ 94 APLL_FREQ(600, 0, 2, 4, 0, 3, 1, 1, 0, 3, 0, 2, 200, 4, 1),
220 { 5, 0, 5 }, 95 APLL_FREQ(500, 0, 2, 4, 0, 3, 1, 1, 0, 3, 0, 2, 125, 3, 1),
221 96 APLL_FREQ(400, 0, 2, 4, 0, 3, 1, 1, 0, 3, 0, 1, 100, 3, 1),
222 /* ARM L4: 1100 MHz */ 97 APLL_FREQ(300, 0, 2, 4, 0, 2, 1, 1, 0, 3, 0, 1, 200, 4, 2),
223 { 4, 0, 5 }, 98 APLL_FREQ(200, 0, 1, 3, 0, 1, 1, 1, 0, 3, 0, 0, 100, 3, 2),
224
225 /* ARM L5: 1000 MHz */
226 { 4, 0, 4 },
227
228 /* ARM L6: 900 MHz */
229 { 3, 0, 4 },
230
231 /* ARM L7: 800 MHz */
232 { 3, 0, 3 },
233
234 /* ARM L8: 700 MHz */
235 { 3, 0, 3 },
236
237 /* ARM L9: 600 MHz */
238 { 3, 0, 2 },
239
240 /* ARM L10: 500 MHz */
241 { 3, 0, 2 },
242
243 /* ARM L11: 400 MHz */
244 { 3, 0, 1 },
245
246 /* ARM L12: 300 MHz */
247 { 3, 0, 1 },
248
249 /* ARM L13: 200 MHz */
250 { 3, 0, 0 },
251};
252
253static unsigned int exynos4x12_apll_pms_table[CPUFREQ_LEVEL_END] = {
254 /* APLL FOUT L0: 1500 MHz */
255 ((250 << 16) | (4 << 8) | (0x0)),
256
257 /* APLL FOUT L1: 1400 MHz */
258 ((175 << 16) | (3 << 8) | (0x0)),
259
260 /* APLL FOUT L2: 1300 MHz */
261 ((325 << 16) | (6 << 8) | (0x0)),
262
263 /* APLL FOUT L3: 1200 MHz */
264 ((200 << 16) | (4 << 8) | (0x0)),
265
266 /* APLL FOUT L4: 1100 MHz */
267 ((275 << 16) | (6 << 8) | (0x0)),
268
269 /* APLL FOUT L5: 1000 MHz */
270 ((125 << 16) | (3 << 8) | (0x0)),
271
272 /* APLL FOUT L6: 900 MHz */
273 ((150 << 16) | (4 << 8) | (0x0)),
274
275 /* APLL FOUT L7: 800 MHz */
276 ((100 << 16) | (3 << 8) | (0x0)),
277
278 /* APLL FOUT L8: 700 MHz */
279 ((175 << 16) | (3 << 8) | (0x1)),
280
281 /* APLL FOUT L9: 600 MHz */
282 ((200 << 16) | (4 << 8) | (0x1)),
283
284 /* APLL FOUT L10: 500 MHz */
285 ((125 << 16) | (3 << 8) | (0x1)),
286
287 /* APLL FOUT L11 400 MHz */
288 ((100 << 16) | (3 << 8) | (0x1)),
289
290 /* APLL FOUT L12: 300 MHz */
291 ((200 << 16) | (4 << 8) | (0x2)),
292
293 /* APLL FOUT L13: 200 MHz */
294 ((100 << 16) | (3 << 8) | (0x2)),
295};
296
297static const unsigned int asv_voltage_4x12[CPUFREQ_LEVEL_END] = {
298 1350000, 1287500, 1250000, 1187500, 1137500, 1087500, 1037500,
299 1000000, 987500, 975000, 950000, 925000, 900000, 900000
300}; 99};
301 100
302static void exynos4x12_set_clkdiv(unsigned int div_index) 101static void exynos4x12_set_clkdiv(unsigned int div_index)
@@ -306,7 +105,7 @@ static void exynos4x12_set_clkdiv(unsigned int div_index)
306 105
307 /* Change Divider - CPU0 */ 106 /* Change Divider - CPU0 */
308 107
309 tmp = exynos4x12_clkdiv_table[div_index].clkdiv; 108 tmp = apll_freq_4x12[div_index].clk_div_cpu0;
310 109
311 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU); 110 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU);
312 111
@@ -314,7 +113,7 @@ static void exynos4x12_set_clkdiv(unsigned int div_index)
314 cpu_relax(); 113 cpu_relax();
315 114
316 /* Change Divider - CPU1 */ 115 /* Change Divider - CPU1 */
317 tmp = exynos4x12_clkdiv_table[div_index].clkdiv1; 116 tmp = apll_freq_4x12[div_index].clk_div_cpu1;
318 117
319 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU1); 118 __raw_writel(tmp, EXYNOS4_CLKDIV_CPU1);
320 if (soc_is_exynos4212()) 119 if (soc_is_exynos4212())
@@ -341,14 +140,14 @@ static void exynos4x12_set_apll(unsigned int index)
341 } while (tmp != 0x2); 140 } while (tmp != 0x2);
342 141
343 /* 2. Set APLL Lock time */ 142 /* 2. Set APLL Lock time */
344 pdiv = ((exynos4x12_apll_pms_table[index] >> 8) & 0x3f); 143 pdiv = ((apll_freq_4x12[index].mps >> 8) & 0x3f);
345 144
346 __raw_writel((pdiv * 250), EXYNOS4_APLL_LOCK); 145 __raw_writel((pdiv * 250), EXYNOS4_APLL_LOCK);
347 146
348 /* 3. Change PLL PMS values */ 147 /* 3. Change PLL PMS values */
349 tmp = __raw_readl(EXYNOS4_APLL_CON0); 148 tmp = __raw_readl(EXYNOS4_APLL_CON0);
350 tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0)); 149 tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0));
351 tmp |= exynos4x12_apll_pms_table[index]; 150 tmp |= apll_freq_4x12[index].mps;
352 __raw_writel(tmp, EXYNOS4_APLL_CON0); 151 __raw_writel(tmp, EXYNOS4_APLL_CON0);
353 152
354 /* 4. wait_lock_time */ 153 /* 4. wait_lock_time */
@@ -367,10 +166,10 @@ static void exynos4x12_set_apll(unsigned int index)
367 } while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT)); 166 } while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT));
368} 167}
369 168
370bool exynos4x12_pms_change(unsigned int old_index, unsigned int new_index) 169static bool exynos4x12_pms_change(unsigned int old_index, unsigned int new_index)
371{ 170{
372 unsigned int old_pm = exynos4x12_apll_pms_table[old_index] >> 8; 171 unsigned int old_pm = apll_freq_4x12[old_index].mps >> 8;
373 unsigned int new_pm = exynos4x12_apll_pms_table[new_index] >> 8; 172 unsigned int new_pm = apll_freq_4x12[new_index].mps >> 8;
374 173
375 return (old_pm == new_pm) ? 0 : 1; 174 return (old_pm == new_pm) ? 0 : 1;
376} 175}
@@ -387,7 +186,7 @@ static void exynos4x12_set_frequency(unsigned int old_index,
387 /* 2. Change just s value in apll m,p,s value */ 186 /* 2. Change just s value in apll m,p,s value */
388 tmp = __raw_readl(EXYNOS4_APLL_CON0); 187 tmp = __raw_readl(EXYNOS4_APLL_CON0);
389 tmp &= ~(0x7 << 0); 188 tmp &= ~(0x7 << 0);
390 tmp |= (exynos4x12_apll_pms_table[new_index] & 0x7); 189 tmp |= apll_freq_4x12[new_index].mps & 0x7;
391 __raw_writel(tmp, EXYNOS4_APLL_CON0); 190 __raw_writel(tmp, EXYNOS4_APLL_CON0);
392 191
393 } else { 192 } else {
@@ -402,7 +201,7 @@ static void exynos4x12_set_frequency(unsigned int old_index,
402 /* 1. Change just s value in apll m,p,s value */ 201 /* 1. Change just s value in apll m,p,s value */
403 tmp = __raw_readl(EXYNOS4_APLL_CON0); 202 tmp = __raw_readl(EXYNOS4_APLL_CON0);
404 tmp &= ~(0x7 << 0); 203 tmp &= ~(0x7 << 0);
405 tmp |= (exynos4x12_apll_pms_table[new_index] & 0x7); 204 tmp |= apll_freq_4x12[new_index].mps & 0x7;
406 __raw_writel(tmp, EXYNOS4_APLL_CON0); 205 __raw_writel(tmp, EXYNOS4_APLL_CON0);
407 /* 2. Change the system clock divider values */ 206 /* 2. Change the system clock divider values */
408 exynos4x12_set_clkdiv(new_index); 207 exynos4x12_set_clkdiv(new_index);
@@ -416,27 +215,10 @@ static void exynos4x12_set_frequency(unsigned int old_index,
416 } 215 }
417} 216}
418 217
419static void __init set_volt_table(void)
420{
421 unsigned int i;
422
423 max_support_idx = L1;
424
425 /* Not supported */
426 exynos4x12_freq_table[L0].frequency = CPUFREQ_ENTRY_INVALID;
427
428 for (i = 0 ; i < CPUFREQ_LEVEL_END ; i++)
429 exynos4x12_volt_table[i] = asv_voltage_4x12[i];
430}
431
432int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info) 218int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
433{ 219{
434 int i;
435 unsigned int tmp;
436 unsigned long rate; 220 unsigned long rate;
437 221
438 set_volt_table();
439
440 cpu_clk = clk_get(NULL, "armclk"); 222 cpu_clk = clk_get(NULL, "armclk");
441 if (IS_ERR(cpu_clk)) 223 if (IS_ERR(cpu_clk))
442 return PTR_ERR(cpu_clk); 224 return PTR_ERR(cpu_clk);
@@ -455,66 +237,14 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
455 if (IS_ERR(mout_apll)) 237 if (IS_ERR(mout_apll))
456 goto err_mout_apll; 238 goto err_mout_apll;
457 239
458 for (i = L0; i < CPUFREQ_LEVEL_END; i++) { 240 if (soc_is_exynos4212())
459 241 apll_freq_4x12 = apll_freq_4212;
460 exynos4x12_clkdiv_table[i].index = i; 242 else
461 243 apll_freq_4x12 = apll_freq_4412;
462 tmp = __raw_readl(EXYNOS4_CLKDIV_CPU);
463
464 tmp &= ~(EXYNOS4_CLKDIV_CPU0_CORE_MASK |
465 EXYNOS4_CLKDIV_CPU0_COREM0_MASK |
466 EXYNOS4_CLKDIV_CPU0_COREM1_MASK |
467 EXYNOS4_CLKDIV_CPU0_PERIPH_MASK |
468 EXYNOS4_CLKDIV_CPU0_ATB_MASK |
469 EXYNOS4_CLKDIV_CPU0_PCLKDBG_MASK |
470 EXYNOS4_CLKDIV_CPU0_APLL_MASK);
471
472 if (soc_is_exynos4212()) {
473 tmp |= ((clkdiv_cpu0_4212[i][0] << EXYNOS4_CLKDIV_CPU0_CORE_SHIFT) |
474 (clkdiv_cpu0_4212[i][1] << EXYNOS4_CLKDIV_CPU0_COREM0_SHIFT) |
475 (clkdiv_cpu0_4212[i][2] << EXYNOS4_CLKDIV_CPU0_COREM1_SHIFT) |
476 (clkdiv_cpu0_4212[i][3] << EXYNOS4_CLKDIV_CPU0_PERIPH_SHIFT) |
477 (clkdiv_cpu0_4212[i][4] << EXYNOS4_CLKDIV_CPU0_ATB_SHIFT) |
478 (clkdiv_cpu0_4212[i][5] << EXYNOS4_CLKDIV_CPU0_PCLKDBG_SHIFT) |
479 (clkdiv_cpu0_4212[i][6] << EXYNOS4_CLKDIV_CPU0_APLL_SHIFT));
480 } else {
481 tmp &= ~EXYNOS4_CLKDIV_CPU0_CORE2_MASK;
482
483 tmp |= ((clkdiv_cpu0_4412[i][0] << EXYNOS4_CLKDIV_CPU0_CORE_SHIFT) |
484 (clkdiv_cpu0_4412[i][1] << EXYNOS4_CLKDIV_CPU0_COREM0_SHIFT) |
485 (clkdiv_cpu0_4412[i][2] << EXYNOS4_CLKDIV_CPU0_COREM1_SHIFT) |
486 (clkdiv_cpu0_4412[i][3] << EXYNOS4_CLKDIV_CPU0_PERIPH_SHIFT) |
487 (clkdiv_cpu0_4412[i][4] << EXYNOS4_CLKDIV_CPU0_ATB_SHIFT) |
488 (clkdiv_cpu0_4412[i][5] << EXYNOS4_CLKDIV_CPU0_PCLKDBG_SHIFT) |
489 (clkdiv_cpu0_4412[i][6] << EXYNOS4_CLKDIV_CPU0_APLL_SHIFT) |
490 (clkdiv_cpu0_4412[i][7] << EXYNOS4_CLKDIV_CPU0_CORE2_SHIFT));
491 }
492
493 exynos4x12_clkdiv_table[i].clkdiv = tmp;
494
495 tmp = __raw_readl(EXYNOS4_CLKDIV_CPU1);
496
497 if (soc_is_exynos4212()) {
498 tmp &= ~(EXYNOS4_CLKDIV_CPU1_COPY_MASK |
499 EXYNOS4_CLKDIV_CPU1_HPM_MASK);
500 tmp |= ((clkdiv_cpu1_4212[i][0] << EXYNOS4_CLKDIV_CPU1_COPY_SHIFT) |
501 (clkdiv_cpu1_4212[i][1] << EXYNOS4_CLKDIV_CPU1_HPM_SHIFT));
502 } else {
503 tmp &= ~(EXYNOS4_CLKDIV_CPU1_COPY_MASK |
504 EXYNOS4_CLKDIV_CPU1_HPM_MASK |
505 EXYNOS4_CLKDIV_CPU1_CORES_MASK);
506 tmp |= ((clkdiv_cpu1_4412[i][0] << EXYNOS4_CLKDIV_CPU1_COPY_SHIFT) |
507 (clkdiv_cpu1_4412[i][1] << EXYNOS4_CLKDIV_CPU1_HPM_SHIFT) |
508 (clkdiv_cpu1_4412[i][2] << EXYNOS4_CLKDIV_CPU1_CORES_SHIFT));
509 }
510 exynos4x12_clkdiv_table[i].clkdiv1 = tmp;
511 }
512 244
513 info->mpll_freq_khz = rate; 245 info->mpll_freq_khz = rate;
514 info->pm_lock_idx = L5; 246 /* 800Mhz */
515 info->pll_safe_idx = L7; 247 info->pll_safe_idx = L7;
516 info->max_support_idx = max_support_idx;
517 info->min_support_idx = min_support_idx;
518 info->cpu_clk = cpu_clk; 248 info->cpu_clk = cpu_clk;
519 info->volt_table = exynos4x12_volt_table; 249 info->volt_table = exynos4x12_volt_table;
520 info->freq_table = exynos4x12_freq_table; 250 info->freq_table = exynos4x12_freq_table;
diff --git a/drivers/cpufreq/exynos5250-cpufreq.c b/drivers/cpufreq/exynos5250-cpufreq.c
index e64c253cb169..b9344869f822 100644
--- a/drivers/cpufreq/exynos5250-cpufreq.c
+++ b/drivers/cpufreq/exynos5250-cpufreq.c
@@ -21,23 +21,18 @@
21#include <mach/regs-clock.h> 21#include <mach/regs-clock.h>
22#include <mach/cpufreq.h> 22#include <mach/cpufreq.h>
23 23
24#define CPUFREQ_LEVEL_END (L15 + 1)
25
26static int max_support_idx;
27static int min_support_idx = (CPUFREQ_LEVEL_END - 1);
28static struct clk *cpu_clk; 24static struct clk *cpu_clk;
29static struct clk *moutcore; 25static struct clk *moutcore;
30static struct clk *mout_mpll; 26static struct clk *mout_mpll;
31static struct clk *mout_apll; 27static struct clk *mout_apll;
32 28
33struct cpufreq_clkdiv { 29static unsigned int exynos5250_volt_table[] = {
34 unsigned int index; 30 1300000, 1250000, 1225000, 1200000, 1150000,
35 unsigned int clkdiv; 31 1125000, 1100000, 1075000, 1050000, 1025000,
36 unsigned int clkdiv1; 32 1012500, 1000000, 975000, 950000, 937500,
33 925000
37}; 34};
38 35
39static unsigned int exynos5250_volt_table[CPUFREQ_LEVEL_END];
40
41static struct cpufreq_frequency_table exynos5250_freq_table[] = { 36static struct cpufreq_frequency_table exynos5250_freq_table[] = {
42 {L0, 1700 * 1000}, 37 {L0, 1700 * 1000},
43 {L1, 1600 * 1000}, 38 {L1, 1600 * 1000},
@@ -47,8 +42,8 @@ static struct cpufreq_frequency_table exynos5250_freq_table[] = {
47 {L5, 1200 * 1000}, 42 {L5, 1200 * 1000},
48 {L6, 1100 * 1000}, 43 {L6, 1100 * 1000},
49 {L7, 1000 * 1000}, 44 {L7, 1000 * 1000},
50 {L8, 900 * 1000}, 45 {L8, 900 * 1000},
51 {L9, 800 * 1000}, 46 {L9, 800 * 1000},
52 {L10, 700 * 1000}, 47 {L10, 700 * 1000},
53 {L11, 600 * 1000}, 48 {L11, 600 * 1000},
54 {L12, 500 * 1000}, 49 {L12, 500 * 1000},
@@ -58,78 +53,30 @@ static struct cpufreq_frequency_table exynos5250_freq_table[] = {
58 {0, CPUFREQ_TABLE_END}, 53 {0, CPUFREQ_TABLE_END},
59}; 54};
60 55
61static struct cpufreq_clkdiv exynos5250_clkdiv_table[CPUFREQ_LEVEL_END]; 56static struct apll_freq apll_freq_5250[] = {
62
63static unsigned int clkdiv_cpu0_5250[CPUFREQ_LEVEL_END][8] = {
64 /* 57 /*
65 * Clock divider value for following 58 * values:
66 * { ARM, CPUD, ACP, PERIPH, ATB, PCLK_DBG, APLL, ARM2 } 59 * freq
67 */ 60 * clock divider for ARM, CPUD, ACP, PERIPH, ATB, PCLK_DBG, APLL, ARM2
68 { 0, 3, 7, 7, 7, 3, 5, 0 }, /* 1700 MHz */ 61 * clock divider for COPY, HPM, RESERVED
69 { 0, 3, 7, 7, 7, 1, 4, 0 }, /* 1600 MHz */ 62 * PLL M, P, S
70 { 0, 2, 7, 7, 7, 1, 4, 0 }, /* 1500 MHz */
71 { 0, 2, 7, 7, 6, 1, 4, 0 }, /* 1400 MHz */
72 { 0, 2, 7, 7, 6, 1, 3, 0 }, /* 1300 MHz */
73 { 0, 2, 7, 7, 5, 1, 3, 0 }, /* 1200 MHz */
74 { 0, 3, 7, 7, 5, 1, 3, 0 }, /* 1100 MHz */
75 { 0, 1, 7, 7, 4, 1, 2, 0 }, /* 1000 MHz */
76 { 0, 1, 7, 7, 4, 1, 2, 0 }, /* 900 MHz */
77 { 0, 1, 7, 7, 4, 1, 2, 0 }, /* 800 MHz */
78 { 0, 1, 7, 7, 3, 1, 1, 0 }, /* 700 MHz */
79 { 0, 1, 7, 7, 3, 1, 1, 0 }, /* 600 MHz */
80 { 0, 1, 7, 7, 2, 1, 1, 0 }, /* 500 MHz */
81 { 0, 1, 7, 7, 2, 1, 1, 0 }, /* 400 MHz */
82 { 0, 1, 7, 7, 1, 1, 1, 0 }, /* 300 MHz */
83 { 0, 1, 7, 7, 1, 1, 1, 0 }, /* 200 MHz */
84};
85
86static unsigned int clkdiv_cpu1_5250[CPUFREQ_LEVEL_END][2] = {
87 /* Clock divider value for following
88 * { COPY, HPM }
89 */ 63 */
90 { 0, 2 }, /* 1700 MHz */ 64 APLL_FREQ(1700, 0, 3, 7, 7, 7, 3, 5, 0, 0, 2, 0, 425, 6, 0),
91 { 0, 2 }, /* 1600 MHz */ 65 APLL_FREQ(1600, 0, 3, 7, 7, 7, 1, 4, 0, 0, 2, 0, 200, 3, 0),
92 { 0, 2 }, /* 1500 MHz */ 66 APLL_FREQ(1500, 0, 2, 7, 7, 7, 1, 4, 0, 0, 2, 0, 250, 4, 0),
93 { 0, 2 }, /* 1400 MHz */ 67 APLL_FREQ(1400, 0, 2, 7, 7, 6, 1, 4, 0, 0, 2, 0, 175, 3, 0),
94 { 0, 2 }, /* 1300 MHz */ 68 APLL_FREQ(1300, 0, 2, 7, 7, 6, 1, 3, 0, 0, 2, 0, 325, 6, 0),
95 { 0, 2 }, /* 1200 MHz */ 69 APLL_FREQ(1200, 0, 2, 7, 7, 5, 1, 3, 0, 0, 2, 0, 200, 4, 0),
96 { 0, 2 }, /* 1100 MHz */ 70 APLL_FREQ(1100, 0, 3, 7, 7, 5, 1, 3, 0, 0, 2, 0, 275, 6, 0),
97 { 0, 2 }, /* 1000 MHz */ 71 APLL_FREQ(1000, 0, 1, 7, 7, 4, 1, 2, 0, 0, 2, 0, 125, 3, 0),
98 { 0, 2 }, /* 900 MHz */ 72 APLL_FREQ(900, 0, 1, 7, 7, 4, 1, 2, 0, 0, 2, 0, 150, 4, 0),
99 { 0, 2 }, /* 800 MHz */ 73 APLL_FREQ(800, 0, 1, 7, 7, 4, 1, 2, 0, 0, 2, 0, 100, 3, 0),
100 { 0, 2 }, /* 700 MHz */ 74 APLL_FREQ(700, 0, 1, 7, 7, 3, 1, 1, 0, 0, 2, 0, 175, 3, 1),
101 { 0, 2 }, /* 600 MHz */ 75 APLL_FREQ(600, 0, 1, 7, 7, 3, 1, 1, 0, 0, 2, 0, 200, 4, 1),
102 { 0, 2 }, /* 500 MHz */ 76 APLL_FREQ(500, 0, 1, 7, 7, 2, 1, 1, 0, 0, 2, 0, 125, 3, 1),
103 { 0, 2 }, /* 400 MHz */ 77 APLL_FREQ(400, 0, 1, 7, 7, 2, 1, 1, 0, 0, 2, 0, 100, 3, 1),
104 { 0, 2 }, /* 300 MHz */ 78 APLL_FREQ(300, 0, 1, 7, 7, 1, 1, 1, 0, 0, 2, 0, 200, 4, 2),
105 { 0, 2 }, /* 200 MHz */ 79 APLL_FREQ(200, 0, 1, 7, 7, 1, 1, 1, 0, 0, 2, 0, 100, 3, 2),
106};
107
108static unsigned int exynos5_apll_pms_table[CPUFREQ_LEVEL_END] = {
109 ((425 << 16) | (6 << 8) | 0), /* 1700 MHz */
110 ((200 << 16) | (3 << 8) | 0), /* 1600 MHz */
111 ((250 << 16) | (4 << 8) | 0), /* 1500 MHz */
112 ((175 << 16) | (3 << 8) | 0), /* 1400 MHz */
113 ((325 << 16) | (6 << 8) | 0), /* 1300 MHz */
114 ((200 << 16) | (4 << 8) | 0), /* 1200 MHz */
115 ((275 << 16) | (6 << 8) | 0), /* 1100 MHz */
116 ((125 << 16) | (3 << 8) | 0), /* 1000 MHz */
117 ((150 << 16) | (4 << 8) | 0), /* 900 MHz */
118 ((100 << 16) | (3 << 8) | 0), /* 800 MHz */
119 ((175 << 16) | (3 << 8) | 1), /* 700 MHz */
120 ((200 << 16) | (4 << 8) | 1), /* 600 MHz */
121 ((125 << 16) | (3 << 8) | 1), /* 500 MHz */
122 ((100 << 16) | (3 << 8) | 1), /* 400 MHz */
123 ((200 << 16) | (4 << 8) | 2), /* 300 MHz */
124 ((100 << 16) | (3 << 8) | 2), /* 200 MHz */
125};
126
127/* ASV group voltage table */
128static const unsigned int asv_voltage_5250[CPUFREQ_LEVEL_END] = {
129 1300000, 1250000, 1225000, 1200000, 1150000,
130 1125000, 1100000, 1075000, 1050000, 1025000,
131 1012500, 1000000, 975000, 950000, 937500,
132 925000
133}; 80};
134 81
135static void set_clkdiv(unsigned int div_index) 82static void set_clkdiv(unsigned int div_index)
@@ -138,7 +85,7 @@ static void set_clkdiv(unsigned int div_index)
138 85
139 /* Change Divider - CPU0 */ 86 /* Change Divider - CPU0 */
140 87
141 tmp = exynos5250_clkdiv_table[div_index].clkdiv; 88 tmp = apll_freq_5250[div_index].clk_div_cpu0;
142 89
143 __raw_writel(tmp, EXYNOS5_CLKDIV_CPU0); 90 __raw_writel(tmp, EXYNOS5_CLKDIV_CPU0);
144 91
@@ -146,7 +93,7 @@ static void set_clkdiv(unsigned int div_index)
146 cpu_relax(); 93 cpu_relax();
147 94
148 /* Change Divider - CPU1 */ 95 /* Change Divider - CPU1 */
149 tmp = exynos5250_clkdiv_table[div_index].clkdiv1; 96 tmp = apll_freq_5250[div_index].clk_div_cpu1;
150 97
151 __raw_writel(tmp, EXYNOS5_CLKDIV_CPU1); 98 __raw_writel(tmp, EXYNOS5_CLKDIV_CPU1);
152 99
@@ -169,14 +116,14 @@ static void set_apll(unsigned int new_index,
169 } while (tmp != 0x2); 116 } while (tmp != 0x2);
170 117
171 /* 2. Set APLL Lock time */ 118 /* 2. Set APLL Lock time */
172 pdiv = ((exynos5_apll_pms_table[new_index] >> 8) & 0x3f); 119 pdiv = ((apll_freq_5250[new_index].mps >> 8) & 0x3f);
173 120
174 __raw_writel((pdiv * 250), EXYNOS5_APLL_LOCK); 121 __raw_writel((pdiv * 250), EXYNOS5_APLL_LOCK);
175 122
176 /* 3. Change PLL PMS values */ 123 /* 3. Change PLL PMS values */
177 tmp = __raw_readl(EXYNOS5_APLL_CON0); 124 tmp = __raw_readl(EXYNOS5_APLL_CON0);
178 tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0)); 125 tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0));
179 tmp |= exynos5_apll_pms_table[new_index]; 126 tmp |= apll_freq_5250[new_index].mps;
180 __raw_writel(tmp, EXYNOS5_APLL_CON0); 127 __raw_writel(tmp, EXYNOS5_APLL_CON0);
181 128
182 /* 4. wait_lock_time */ 129 /* 4. wait_lock_time */
@@ -196,10 +143,10 @@ static void set_apll(unsigned int new_index,
196 143
197} 144}
198 145
199bool exynos5250_pms_change(unsigned int old_index, unsigned int new_index) 146static bool exynos5250_pms_change(unsigned int old_index, unsigned int new_index)
200{ 147{
201 unsigned int old_pm = (exynos5_apll_pms_table[old_index] >> 8); 148 unsigned int old_pm = apll_freq_5250[old_index].mps >> 8;
202 unsigned int new_pm = (exynos5_apll_pms_table[new_index] >> 8); 149 unsigned int new_pm = apll_freq_5250[new_index].mps >> 8;
203 150
204 return (old_pm == new_pm) ? 0 : 1; 151 return (old_pm == new_pm) ? 0 : 1;
205} 152}
@@ -216,7 +163,7 @@ static void exynos5250_set_frequency(unsigned int old_index,
216 /* 2. Change just s value in apll m,p,s value */ 163 /* 2. Change just s value in apll m,p,s value */
217 tmp = __raw_readl(EXYNOS5_APLL_CON0); 164 tmp = __raw_readl(EXYNOS5_APLL_CON0);
218 tmp &= ~(0x7 << 0); 165 tmp &= ~(0x7 << 0);
219 tmp |= (exynos5_apll_pms_table[new_index] & 0x7); 166 tmp |= apll_freq_5250[new_index].mps & 0x7;
220 __raw_writel(tmp, EXYNOS5_APLL_CON0); 167 __raw_writel(tmp, EXYNOS5_APLL_CON0);
221 168
222 } else { 169 } else {
@@ -231,7 +178,7 @@ static void exynos5250_set_frequency(unsigned int old_index,
231 /* 1. Change just s value in apll m,p,s value */ 178 /* 1. Change just s value in apll m,p,s value */
232 tmp = __raw_readl(EXYNOS5_APLL_CON0); 179 tmp = __raw_readl(EXYNOS5_APLL_CON0);
233 tmp &= ~(0x7 << 0); 180 tmp &= ~(0x7 << 0);
234 tmp |= (exynos5_apll_pms_table[new_index] & 0x7); 181 tmp |= apll_freq_5250[new_index].mps & 0x7;
235 __raw_writel(tmp, EXYNOS5_APLL_CON0); 182 __raw_writel(tmp, EXYNOS5_APLL_CON0);
236 /* 2. Change the system clock divider values */ 183 /* 2. Change the system clock divider values */
237 set_clkdiv(new_index); 184 set_clkdiv(new_index);
@@ -245,24 +192,10 @@ static void exynos5250_set_frequency(unsigned int old_index,
245 } 192 }
246} 193}
247 194
248static void __init set_volt_table(void)
249{
250 unsigned int i;
251
252 max_support_idx = L0;
253
254 for (i = 0 ; i < CPUFREQ_LEVEL_END ; i++)
255 exynos5250_volt_table[i] = asv_voltage_5250[i];
256}
257
258int exynos5250_cpufreq_init(struct exynos_dvfs_info *info) 195int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
259{ 196{
260 int i;
261 unsigned int tmp;
262 unsigned long rate; 197 unsigned long rate;
263 198
264 set_volt_table();
265
266 cpu_clk = clk_get(NULL, "armclk"); 199 cpu_clk = clk_get(NULL, "armclk");
267 if (IS_ERR(cpu_clk)) 200 if (IS_ERR(cpu_clk))
268 return PTR_ERR(cpu_clk); 201 return PTR_ERR(cpu_clk);
@@ -281,44 +214,9 @@ int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
281 if (IS_ERR(mout_apll)) 214 if (IS_ERR(mout_apll))
282 goto err_mout_apll; 215 goto err_mout_apll;
283 216
284 for (i = L0; i < CPUFREQ_LEVEL_END; i++) {
285
286 exynos5250_clkdiv_table[i].index = i;
287
288 tmp = __raw_readl(EXYNOS5_CLKDIV_CPU0);
289
290 tmp &= ~((0x7 << 0) | (0x7 << 4) | (0x7 << 8) |
291 (0x7 << 12) | (0x7 << 16) | (0x7 << 20) |
292 (0x7 << 24) | (0x7 << 28));
293
294 tmp |= ((clkdiv_cpu0_5250[i][0] << 0) |
295 (clkdiv_cpu0_5250[i][1] << 4) |
296 (clkdiv_cpu0_5250[i][2] << 8) |
297 (clkdiv_cpu0_5250[i][3] << 12) |
298 (clkdiv_cpu0_5250[i][4] << 16) |
299 (clkdiv_cpu0_5250[i][5] << 20) |
300 (clkdiv_cpu0_5250[i][6] << 24) |
301 (clkdiv_cpu0_5250[i][7] << 28));
302
303 exynos5250_clkdiv_table[i].clkdiv = tmp;
304
305 tmp = __raw_readl(EXYNOS5_CLKDIV_CPU1);
306
307 tmp &= ~((0x7 << 0) | (0x7 << 4));
308
309 tmp |= ((clkdiv_cpu1_5250[i][0] << 0) |
310 (clkdiv_cpu1_5250[i][1] << 4));
311
312 exynos5250_clkdiv_table[i].clkdiv1 = tmp;
313 }
314
315 info->mpll_freq_khz = rate; 217 info->mpll_freq_khz = rate;
316 /* 1000Mhz */
317 info->pm_lock_idx = L7;
318 /* 800Mhz */ 218 /* 800Mhz */
319 info->pll_safe_idx = L9; 219 info->pll_safe_idx = L9;
320 info->max_support_idx = max_support_idx;
321 info->min_support_idx = min_support_idx;
322 info->cpu_clk = cpu_clk; 220 info->cpu_clk = cpu_clk;
323 info->volt_table = exynos5250_volt_table; 221 info->volt_table = exynos5250_volt_table;
324 info->freq_table = exynos5250_freq_table; 222 info->freq_table = exynos5250_freq_table;
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 49cda256efb2..d7a79662e24c 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -63,9 +63,6 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
63 pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", 63 pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n",
64 policy->min, policy->max, policy->cpu); 64 policy->min, policy->max, policy->cpu);
65 65
66 if (!cpu_online(policy->cpu))
67 return -EINVAL;
68
69 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, 66 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
70 policy->cpuinfo.max_freq); 67 policy->cpuinfo.max_freq);
71 68
@@ -121,9 +118,6 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
121 break; 118 break;
122 } 119 }
123 120
124 if (!cpu_online(policy->cpu))
125 return -EINVAL;
126
127 for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 121 for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
128 unsigned int freq = table[i].frequency; 122 unsigned int freq = table[i].frequency;
129 if (freq == CPUFREQ_ENTRY_INVALID) 123 if (freq == CPUFREQ_ENTRY_INVALID)
@@ -227,6 +221,15 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu)
227} 221}
228EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr); 222EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr);
229 223
224void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy)
225{
226 pr_debug("Updating show_table for new_cpu %u from last_cpu %u\n",
227 policy->cpu, policy->last_cpu);
228 per_cpu(cpufreq_show_table, policy->cpu) = per_cpu(cpufreq_show_table,
229 policy->last_cpu);
230 per_cpu(cpufreq_show_table, policy->last_cpu) = NULL;
231}
232
230struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) 233struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu)
231{ 234{
232 return per_cpu(cpufreq_show_table, cpu); 235 return per_cpu(cpufreq_show_table, cpu);
diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c
new file mode 100644
index 000000000000..66e3a71b81a3
--- /dev/null
+++ b/drivers/cpufreq/highbank-cpufreq.c
@@ -0,0 +1,120 @@
1/*
2 * Copyright (C) 2012 Calxeda, 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 * This driver provides the clk notifier callbacks that are used when
9 * the cpufreq-cpu0 driver changes to frequency to alert the highbank
10 * EnergyCore Management Engine (ECME) about the need to change
11 * voltage. The ECME interfaces with the actual voltage regulators.
12 */
13
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/clk.h>
19#include <linux/cpu.h>
20#include <linux/err.h>
21#include <linux/of.h>
22#include <linux/mailbox.h>
23#include <linux/platform_device.h>
24
25#define HB_CPUFREQ_CHANGE_NOTE 0x80000001
26#define HB_CPUFREQ_IPC_LEN 7
27#define HB_CPUFREQ_VOLT_RETRIES 15
28
29static int hb_voltage_change(unsigned int freq)
30{
31 int i;
32 u32 msg[HB_CPUFREQ_IPC_LEN];
33
34 msg[0] = HB_CPUFREQ_CHANGE_NOTE;
35 msg[1] = freq / 1000000;
36 for (i = 2; i < HB_CPUFREQ_IPC_LEN; i++)
37 msg[i] = 0;
38
39 return pl320_ipc_transmit(msg);
40}
41
42static int hb_cpufreq_clk_notify(struct notifier_block *nb,
43 unsigned long action, void *hclk)
44{
45 struct clk_notifier_data *clk_data = hclk;
46 int i = 0;
47
48 if (action == PRE_RATE_CHANGE) {
49 if (clk_data->new_rate > clk_data->old_rate)
50 while (hb_voltage_change(clk_data->new_rate))
51 if (i++ > HB_CPUFREQ_VOLT_RETRIES)
52 return NOTIFY_BAD;
53 } else if (action == POST_RATE_CHANGE) {
54 if (clk_data->new_rate < clk_data->old_rate)
55 while (hb_voltage_change(clk_data->new_rate))
56 if (i++ > HB_CPUFREQ_VOLT_RETRIES)
57 return NOTIFY_BAD;
58 }
59
60 return NOTIFY_DONE;
61}
62
63static struct notifier_block hb_cpufreq_clk_nb = {
64 .notifier_call = hb_cpufreq_clk_notify,
65};
66
67static int hb_cpufreq_driver_init(void)
68{
69 struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
70 struct device *cpu_dev;
71 struct clk *cpu_clk;
72 struct device_node *np;
73 int ret;
74
75 if (!of_machine_is_compatible("calxeda,highbank"))
76 return -ENODEV;
77
78 for_each_child_of_node(of_find_node_by_path("/cpus"), np)
79 if (of_get_property(np, "operating-points", NULL))
80 break;
81
82 if (!np) {
83 pr_err("failed to find highbank cpufreq node\n");
84 return -ENOENT;
85 }
86
87 cpu_dev = get_cpu_device(0);
88 if (!cpu_dev) {
89 pr_err("failed to get highbank cpufreq device\n");
90 ret = -ENODEV;
91 goto out_put_node;
92 }
93
94 cpu_dev->of_node = np;
95
96 cpu_clk = clk_get(cpu_dev, NULL);
97 if (IS_ERR(cpu_clk)) {
98 ret = PTR_ERR(cpu_clk);
99 pr_err("failed to get cpu0 clock: %d\n", ret);
100 goto out_put_node;
101 }
102
103 ret = clk_notifier_register(cpu_clk, &hb_cpufreq_clk_nb);
104 if (ret) {
105 pr_err("failed to register clk notifier: %d\n", ret);
106 goto out_put_node;
107 }
108
109 /* Instantiate cpufreq-cpu0 */
110 platform_device_register_full(&devinfo);
111
112out_put_node:
113 of_node_put(np);
114 return ret;
115}
116module_init(hb_cpufreq_driver_init);
117
118MODULE_AUTHOR("Mark Langsdorf <mark.langsdorf@calxeda.com>");
119MODULE_DESCRIPTION("Calxeda Highbank cpufreq driver");
120MODULE_LICENSE("GPL");
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
new file mode 100644
index 000000000000..d6b6ef350cb6
--- /dev/null
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -0,0 +1,336 @@
1/*
2 * Copyright (C) 2013 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/clk.h>
10#include <linux/cpufreq.h>
11#include <linux/delay.h>
12#include <linux/err.h>
13#include <linux/module.h>
14#include <linux/of.h>
15#include <linux/opp.h>
16#include <linux/platform_device.h>
17#include <linux/regulator/consumer.h>
18
19#define PU_SOC_VOLTAGE_NORMAL 1250000
20#define PU_SOC_VOLTAGE_HIGH 1275000
21#define FREQ_1P2_GHZ 1200000000
22
23static struct regulator *arm_reg;
24static struct regulator *pu_reg;
25static struct regulator *soc_reg;
26
27static struct clk *arm_clk;
28static struct clk *pll1_sys_clk;
29static struct clk *pll1_sw_clk;
30static struct clk *step_clk;
31static struct clk *pll2_pfd2_396m_clk;
32
33static struct device *cpu_dev;
34static struct cpufreq_frequency_table *freq_table;
35static unsigned int transition_latency;
36
37static int imx6q_verify_speed(struct cpufreq_policy *policy)
38{
39 return cpufreq_frequency_table_verify(policy, freq_table);
40}
41
42static unsigned int imx6q_get_speed(unsigned int cpu)
43{
44 return clk_get_rate(arm_clk) / 1000;
45}
46
47static int imx6q_set_target(struct cpufreq_policy *policy,
48 unsigned int target_freq, unsigned int relation)
49{
50 struct cpufreq_freqs freqs;
51 struct opp *opp;
52 unsigned long freq_hz, volt, volt_old;
53 unsigned int index, cpu;
54 int ret;
55
56 ret = cpufreq_frequency_table_target(policy, freq_table, target_freq,
57 relation, &index);
58 if (ret) {
59 dev_err(cpu_dev, "failed to match target frequency %d: %d\n",
60 target_freq, ret);
61 return ret;
62 }
63
64 freqs.new = freq_table[index].frequency;
65 freq_hz = freqs.new * 1000;
66 freqs.old = clk_get_rate(arm_clk) / 1000;
67
68 if (freqs.old == freqs.new)
69 return 0;
70
71 for_each_online_cpu(cpu) {
72 freqs.cpu = cpu;
73 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
74 }
75
76 rcu_read_lock();
77 opp = opp_find_freq_ceil(cpu_dev, &freq_hz);
78 if (IS_ERR(opp)) {
79 rcu_read_unlock();
80 dev_err(cpu_dev, "failed to find OPP for %ld\n", freq_hz);
81 return PTR_ERR(opp);
82 }
83
84 volt = opp_get_voltage(opp);
85 rcu_read_unlock();
86 volt_old = regulator_get_voltage(arm_reg);
87
88 dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n",
89 freqs.old / 1000, volt_old / 1000,
90 freqs.new / 1000, volt / 1000);
91
92 /* scaling up? scale voltage before frequency */
93 if (freqs.new > freqs.old) {
94 ret = regulator_set_voltage_tol(arm_reg, volt, 0);
95 if (ret) {
96 dev_err(cpu_dev,
97 "failed to scale vddarm up: %d\n", ret);
98 return ret;
99 }
100
101 /*
102 * Need to increase vddpu and vddsoc for safety
103 * if we are about to run at 1.2 GHz.
104 */
105 if (freqs.new == FREQ_1P2_GHZ / 1000) {
106 regulator_set_voltage_tol(pu_reg,
107 PU_SOC_VOLTAGE_HIGH, 0);
108 regulator_set_voltage_tol(soc_reg,
109 PU_SOC_VOLTAGE_HIGH, 0);
110 }
111 }
112
113 /*
114 * The setpoints are selected per PLL/PDF frequencies, so we need to
115 * reprogram PLL for frequency scaling. The procedure of reprogramming
116 * PLL1 is as below.
117 *
118 * - Enable pll2_pfd2_396m_clk and reparent pll1_sw_clk to it
119 * - Reprogram pll1_sys_clk and reparent pll1_sw_clk back to it
120 * - Disable pll2_pfd2_396m_clk
121 */
122 clk_prepare_enable(pll2_pfd2_396m_clk);
123 clk_set_parent(step_clk, pll2_pfd2_396m_clk);
124 clk_set_parent(pll1_sw_clk, step_clk);
125 if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk)) {
126 clk_set_rate(pll1_sys_clk, freqs.new * 1000);
127 /*
128 * If we are leaving 396 MHz set-point, we need to enable
129 * pll1_sys_clk and disable pll2_pfd2_396m_clk to keep
130 * their use count correct.
131 */
132 if (freqs.old * 1000 <= clk_get_rate(pll2_pfd2_396m_clk)) {
133 clk_prepare_enable(pll1_sys_clk);
134 clk_disable_unprepare(pll2_pfd2_396m_clk);
135 }
136 clk_set_parent(pll1_sw_clk, pll1_sys_clk);
137 clk_disable_unprepare(pll2_pfd2_396m_clk);
138 } else {
139 /*
140 * Disable pll1_sys_clk if pll2_pfd2_396m_clk is sufficient
141 * to provide the frequency.
142 */
143 clk_disable_unprepare(pll1_sys_clk);
144 }
145
146 /* Ensure the arm clock divider is what we expect */
147 ret = clk_set_rate(arm_clk, freqs.new * 1000);
148 if (ret) {
149 dev_err(cpu_dev, "failed to set clock rate: %d\n", ret);
150 regulator_set_voltage_tol(arm_reg, volt_old, 0);
151 return ret;
152 }
153
154 /* scaling down? scale voltage after frequency */
155 if (freqs.new < freqs.old) {
156 ret = regulator_set_voltage_tol(arm_reg, volt, 0);
157 if (ret)
158 dev_warn(cpu_dev,
159 "failed to scale vddarm down: %d\n", ret);
160
161 if (freqs.old == FREQ_1P2_GHZ / 1000) {
162 regulator_set_voltage_tol(pu_reg,
163 PU_SOC_VOLTAGE_NORMAL, 0);
164 regulator_set_voltage_tol(soc_reg,
165 PU_SOC_VOLTAGE_NORMAL, 0);
166 }
167 }
168
169 for_each_online_cpu(cpu) {
170 freqs.cpu = cpu;
171 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
172 }
173
174 return 0;
175}
176
177static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
178{
179 int ret;
180
181 ret = cpufreq_frequency_table_cpuinfo(policy, freq_table);
182 if (ret) {
183 dev_err(cpu_dev, "invalid frequency table: %d\n", ret);
184 return ret;
185 }
186
187 policy->cpuinfo.transition_latency = transition_latency;
188 policy->cur = clk_get_rate(arm_clk) / 1000;
189 cpumask_setall(policy->cpus);
190 cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
191
192 return 0;
193}
194
195static int imx6q_cpufreq_exit(struct cpufreq_policy *policy)
196{
197 cpufreq_frequency_table_put_attr(policy->cpu);
198 return 0;
199}
200
201static struct freq_attr *imx6q_cpufreq_attr[] = {
202 &cpufreq_freq_attr_scaling_available_freqs,
203 NULL,
204};
205
206static struct cpufreq_driver imx6q_cpufreq_driver = {
207 .verify = imx6q_verify_speed,
208 .target = imx6q_set_target,
209 .get = imx6q_get_speed,
210 .init = imx6q_cpufreq_init,
211 .exit = imx6q_cpufreq_exit,
212 .name = "imx6q-cpufreq",
213 .attr = imx6q_cpufreq_attr,
214};
215
216static int imx6q_cpufreq_probe(struct platform_device *pdev)
217{
218 struct device_node *np;
219 struct opp *opp;
220 unsigned long min_volt, max_volt;
221 int num, ret;
222
223 cpu_dev = &pdev->dev;
224
225 np = of_find_node_by_path("/cpus/cpu@0");
226 if (!np) {
227 dev_err(cpu_dev, "failed to find cpu0 node\n");
228 return -ENOENT;
229 }
230
231 cpu_dev->of_node = np;
232
233 arm_clk = devm_clk_get(cpu_dev, "arm");
234 pll1_sys_clk = devm_clk_get(cpu_dev, "pll1_sys");
235 pll1_sw_clk = devm_clk_get(cpu_dev, "pll1_sw");
236 step_clk = devm_clk_get(cpu_dev, "step");
237 pll2_pfd2_396m_clk = devm_clk_get(cpu_dev, "pll2_pfd2_396m");
238 if (IS_ERR(arm_clk) || IS_ERR(pll1_sys_clk) || IS_ERR(pll1_sw_clk) ||
239 IS_ERR(step_clk) || IS_ERR(pll2_pfd2_396m_clk)) {
240 dev_err(cpu_dev, "failed to get clocks\n");
241 ret = -ENOENT;
242 goto put_node;
243 }
244
245 arm_reg = devm_regulator_get(cpu_dev, "arm");
246 pu_reg = devm_regulator_get(cpu_dev, "pu");
247 soc_reg = devm_regulator_get(cpu_dev, "soc");
248 if (!arm_reg || !pu_reg || !soc_reg) {
249 dev_err(cpu_dev, "failed to get regulators\n");
250 ret = -ENOENT;
251 goto put_node;
252 }
253
254 /* We expect an OPP table supplied by platform */
255 num = opp_get_opp_count(cpu_dev);
256 if (num < 0) {
257 ret = num;
258 dev_err(cpu_dev, "no OPP table is found: %d\n", ret);
259 goto put_node;
260 }
261
262 ret = opp_init_cpufreq_table(cpu_dev, &freq_table);
263 if (ret) {
264 dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);
265 goto put_node;
266 }
267
268 if (of_property_read_u32(np, "clock-latency", &transition_latency))
269 transition_latency = CPUFREQ_ETERNAL;
270
271 /*
272 * OPP is maintained in order of increasing frequency, and
273 * freq_table initialised from OPP is therefore sorted in the
274 * same order.
275 */
276 rcu_read_lock();
277 opp = opp_find_freq_exact(cpu_dev,
278 freq_table[0].frequency * 1000, true);
279 min_volt = opp_get_voltage(opp);
280 opp = opp_find_freq_exact(cpu_dev,
281 freq_table[--num].frequency * 1000, true);
282 max_volt = opp_get_voltage(opp);
283 rcu_read_unlock();
284 ret = regulator_set_voltage_time(arm_reg, min_volt, max_volt);
285 if (ret > 0)
286 transition_latency += ret * 1000;
287
288 /* Count vddpu and vddsoc latency in for 1.2 GHz support */
289 if (freq_table[num].frequency == FREQ_1P2_GHZ / 1000) {
290 ret = regulator_set_voltage_time(pu_reg, PU_SOC_VOLTAGE_NORMAL,
291 PU_SOC_VOLTAGE_HIGH);
292 if (ret > 0)
293 transition_latency += ret * 1000;
294 ret = regulator_set_voltage_time(soc_reg, PU_SOC_VOLTAGE_NORMAL,
295 PU_SOC_VOLTAGE_HIGH);
296 if (ret > 0)
297 transition_latency += ret * 1000;
298 }
299
300 ret = cpufreq_register_driver(&imx6q_cpufreq_driver);
301 if (ret) {
302 dev_err(cpu_dev, "failed register driver: %d\n", ret);
303 goto free_freq_table;
304 }
305
306 of_node_put(np);
307 return 0;
308
309free_freq_table:
310 opp_free_cpufreq_table(cpu_dev, &freq_table);
311put_node:
312 of_node_put(np);
313 return ret;
314}
315
316static int imx6q_cpufreq_remove(struct platform_device *pdev)
317{
318 cpufreq_unregister_driver(&imx6q_cpufreq_driver);
319 opp_free_cpufreq_table(cpu_dev, &freq_table);
320
321 return 0;
322}
323
324static struct platform_driver imx6q_cpufreq_platdrv = {
325 .driver = {
326 .name = "imx6q-cpufreq",
327 .owner = THIS_MODULE,
328 },
329 .probe = imx6q_cpufreq_probe,
330 .remove = imx6q_cpufreq_remove,
331};
332module_platform_driver(imx6q_cpufreq_platdrv);
333
334MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>");
335MODULE_DESCRIPTION("Freescale i.MX6Q cpufreq driver");
336MODULE_LICENSE("GPL");
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
new file mode 100644
index 000000000000..096fde0ebcb5
--- /dev/null
+++ b/drivers/cpufreq/intel_pstate.c
@@ -0,0 +1,823 @@
1/*
2 * cpufreq_snb.c: Native P state management for Intel processors
3 *
4 * (C) Copyright 2012 Intel Corporation
5 * Author: Dirk Brandewie <dirk.j.brandewie@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; version 2
10 * of the License.
11 */
12
13#include <linux/kernel.h>
14#include <linux/kernel_stat.h>
15#include <linux/module.h>
16#include <linux/ktime.h>
17#include <linux/hrtimer.h>
18#include <linux/tick.h>
19#include <linux/slab.h>
20#include <linux/sched.h>
21#include <linux/list.h>
22#include <linux/cpu.h>
23#include <linux/cpufreq.h>
24#include <linux/sysfs.h>
25#include <linux/types.h>
26#include <linux/fs.h>
27#include <linux/debugfs.h>
28#include <trace/events/power.h>
29
30#include <asm/div64.h>
31#include <asm/msr.h>
32#include <asm/cpu_device_id.h>
33
34#define SAMPLE_COUNT 3
35
36#define FRAC_BITS 8
37#define int_tofp(X) ((int64_t)(X) << FRAC_BITS)
38#define fp_toint(X) ((X) >> FRAC_BITS)
39
40static inline int32_t mul_fp(int32_t x, int32_t y)
41{
42 return ((int64_t)x * (int64_t)y) >> FRAC_BITS;
43}
44
45static inline int32_t div_fp(int32_t x, int32_t y)
46{
47 return div_s64((int64_t)x << FRAC_BITS, (int64_t)y);
48}
49
50struct sample {
51 ktime_t start_time;
52 ktime_t end_time;
53 int core_pct_busy;
54 int pstate_pct_busy;
55 u64 duration_us;
56 u64 idletime_us;
57 u64 aperf;
58 u64 mperf;
59 int freq;
60};
61
62struct pstate_data {
63 int current_pstate;
64 int min_pstate;
65 int max_pstate;
66 int turbo_pstate;
67};
68
69struct _pid {
70 int setpoint;
71 int32_t integral;
72 int32_t p_gain;
73 int32_t i_gain;
74 int32_t d_gain;
75 int deadband;
76 int last_err;
77};
78
79struct cpudata {
80 int cpu;
81
82 char name[64];
83
84 struct timer_list timer;
85
86 struct pstate_adjust_policy *pstate_policy;
87 struct pstate_data pstate;
88 struct _pid pid;
89 struct _pid idle_pid;
90
91 int min_pstate_count;
92 int idle_mode;
93
94 ktime_t prev_sample;
95 u64 prev_idle_time_us;
96 u64 prev_aperf;
97 u64 prev_mperf;
98 int sample_ptr;
99 struct sample samples[SAMPLE_COUNT];
100};
101
102static struct cpudata **all_cpu_data;
103struct pstate_adjust_policy {
104 int sample_rate_ms;
105 int deadband;
106 int setpoint;
107 int p_gain_pct;
108 int d_gain_pct;
109 int i_gain_pct;
110};
111
112static struct pstate_adjust_policy default_policy = {
113 .sample_rate_ms = 10,
114 .deadband = 0,
115 .setpoint = 109,
116 .p_gain_pct = 17,
117 .d_gain_pct = 0,
118 .i_gain_pct = 4,
119};
120
121struct perf_limits {
122 int no_turbo;
123 int max_perf_pct;
124 int min_perf_pct;
125 int32_t max_perf;
126 int32_t min_perf;
127};
128
129static struct perf_limits limits = {
130 .no_turbo = 0,
131 .max_perf_pct = 100,
132 .max_perf = int_tofp(1),
133 .min_perf_pct = 0,
134 .min_perf = 0,
135};
136
137static inline void pid_reset(struct _pid *pid, int setpoint, int busy,
138 int deadband, int integral) {
139 pid->setpoint = setpoint;
140 pid->deadband = deadband;
141 pid->integral = int_tofp(integral);
142 pid->last_err = setpoint - busy;
143}
144
145static inline void pid_p_gain_set(struct _pid *pid, int percent)
146{
147 pid->p_gain = div_fp(int_tofp(percent), int_tofp(100));
148}
149
150static inline void pid_i_gain_set(struct _pid *pid, int percent)
151{
152 pid->i_gain = div_fp(int_tofp(percent), int_tofp(100));
153}
154
155static inline void pid_d_gain_set(struct _pid *pid, int percent)
156{
157
158 pid->d_gain = div_fp(int_tofp(percent), int_tofp(100));
159}
160
161static signed int pid_calc(struct _pid *pid, int busy)
162{
163 signed int err, result;
164 int32_t pterm, dterm, fp_error;
165 int32_t integral_limit;
166
167 err = pid->setpoint - busy;
168 fp_error = int_tofp(err);
169
170 if (abs(err) <= pid->deadband)
171 return 0;
172
173 pterm = mul_fp(pid->p_gain, fp_error);
174
175 pid->integral += fp_error;
176
177 /* limit the integral term */
178 integral_limit = int_tofp(30);
179 if (pid->integral > integral_limit)
180 pid->integral = integral_limit;
181 if (pid->integral < -integral_limit)
182 pid->integral = -integral_limit;
183
184 dterm = mul_fp(pid->d_gain, (err - pid->last_err));
185 pid->last_err = err;
186
187 result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm;
188
189 return (signed int)fp_toint(result);
190}
191
192static inline void intel_pstate_busy_pid_reset(struct cpudata *cpu)
193{
194 pid_p_gain_set(&cpu->pid, cpu->pstate_policy->p_gain_pct);
195 pid_d_gain_set(&cpu->pid, cpu->pstate_policy->d_gain_pct);
196 pid_i_gain_set(&cpu->pid, cpu->pstate_policy->i_gain_pct);
197
198 pid_reset(&cpu->pid,
199 cpu->pstate_policy->setpoint,
200 100,
201 cpu->pstate_policy->deadband,
202 0);
203}
204
205static inline void intel_pstate_idle_pid_reset(struct cpudata *cpu)
206{
207 pid_p_gain_set(&cpu->idle_pid, cpu->pstate_policy->p_gain_pct);
208 pid_d_gain_set(&cpu->idle_pid, cpu->pstate_policy->d_gain_pct);
209 pid_i_gain_set(&cpu->idle_pid, cpu->pstate_policy->i_gain_pct);
210
211 pid_reset(&cpu->idle_pid,
212 75,
213 50,
214 cpu->pstate_policy->deadband,
215 0);
216}
217
218static inline void intel_pstate_reset_all_pid(void)
219{
220 unsigned int cpu;
221 for_each_online_cpu(cpu) {
222 if (all_cpu_data[cpu])
223 intel_pstate_busy_pid_reset(all_cpu_data[cpu]);
224 }
225}
226
227/************************** debugfs begin ************************/
228static int pid_param_set(void *data, u64 val)
229{
230 *(u32 *)data = val;
231 intel_pstate_reset_all_pid();
232 return 0;
233}
234static int pid_param_get(void *data, u64 *val)
235{
236 *val = *(u32 *)data;
237 return 0;
238}
239DEFINE_SIMPLE_ATTRIBUTE(fops_pid_param, pid_param_get,
240 pid_param_set, "%llu\n");
241
242struct pid_param {
243 char *name;
244 void *value;
245};
246
247static struct pid_param pid_files[] = {
248 {"sample_rate_ms", &default_policy.sample_rate_ms},
249 {"d_gain_pct", &default_policy.d_gain_pct},
250 {"i_gain_pct", &default_policy.i_gain_pct},
251 {"deadband", &default_policy.deadband},
252 {"setpoint", &default_policy.setpoint},
253 {"p_gain_pct", &default_policy.p_gain_pct},
254 {NULL, NULL}
255};
256
257static struct dentry *debugfs_parent;
258static void intel_pstate_debug_expose_params(void)
259{
260 int i = 0;
261
262 debugfs_parent = debugfs_create_dir("pstate_snb", NULL);
263 if (IS_ERR_OR_NULL(debugfs_parent))
264 return;
265 while (pid_files[i].name) {
266 debugfs_create_file(pid_files[i].name, 0660,
267 debugfs_parent, pid_files[i].value,
268 &fops_pid_param);
269 i++;
270 }
271}
272
273/************************** debugfs end ************************/
274
275/************************** sysfs begin ************************/
276#define show_one(file_name, object) \
277 static ssize_t show_##file_name \
278 (struct kobject *kobj, struct attribute *attr, char *buf) \
279 { \
280 return sprintf(buf, "%u\n", limits.object); \
281 }
282
283static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
284 const char *buf, size_t count)
285{
286 unsigned int input;
287 int ret;
288 ret = sscanf(buf, "%u", &input);
289 if (ret != 1)
290 return -EINVAL;
291 limits.no_turbo = clamp_t(int, input, 0 , 1);
292
293 return count;
294}
295
296static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
297 const char *buf, size_t count)
298{
299 unsigned int input;
300 int ret;
301 ret = sscanf(buf, "%u", &input);
302 if (ret != 1)
303 return -EINVAL;
304
305 limits.max_perf_pct = clamp_t(int, input, 0 , 100);
306 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
307 return count;
308}
309
310static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
311 const char *buf, size_t count)
312{
313 unsigned int input;
314 int ret;
315 ret = sscanf(buf, "%u", &input);
316 if (ret != 1)
317 return -EINVAL;
318 limits.min_perf_pct = clamp_t(int, input, 0 , 100);
319 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100));
320
321 return count;
322}
323
324show_one(no_turbo, no_turbo);
325show_one(max_perf_pct, max_perf_pct);
326show_one(min_perf_pct, min_perf_pct);
327
328define_one_global_rw(no_turbo);
329define_one_global_rw(max_perf_pct);
330define_one_global_rw(min_perf_pct);
331
332static struct attribute *intel_pstate_attributes[] = {
333 &no_turbo.attr,
334 &max_perf_pct.attr,
335 &min_perf_pct.attr,
336 NULL
337};
338
339static struct attribute_group intel_pstate_attr_group = {
340 .attrs = intel_pstate_attributes,
341};
342static struct kobject *intel_pstate_kobject;
343
344static void intel_pstate_sysfs_expose_params(void)
345{
346 int rc;
347
348 intel_pstate_kobject = kobject_create_and_add("intel_pstate",
349 &cpu_subsys.dev_root->kobj);
350 BUG_ON(!intel_pstate_kobject);
351 rc = sysfs_create_group(intel_pstate_kobject,
352 &intel_pstate_attr_group);
353 BUG_ON(rc);
354}
355
356/************************** sysfs end ************************/
357
358static int intel_pstate_min_pstate(void)
359{
360 u64 value;
361 rdmsrl(0xCE, value);
362 return (value >> 40) & 0xFF;
363}
364
365static int intel_pstate_max_pstate(void)
366{
367 u64 value;
368 rdmsrl(0xCE, value);
369 return (value >> 8) & 0xFF;
370}
371
372static int intel_pstate_turbo_pstate(void)
373{
374 u64 value;
375 int nont, ret;
376 rdmsrl(0x1AD, value);
377 nont = intel_pstate_max_pstate();
378 ret = ((value) & 255);
379 if (ret <= nont)
380 ret = nont;
381 return ret;
382}
383
384static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
385{
386 int max_perf = cpu->pstate.turbo_pstate;
387 int min_perf;
388 if (limits.no_turbo)
389 max_perf = cpu->pstate.max_pstate;
390
391 max_perf = fp_toint(mul_fp(int_tofp(max_perf), limits.max_perf));
392 *max = clamp_t(int, max_perf,
393 cpu->pstate.min_pstate, cpu->pstate.turbo_pstate);
394
395 min_perf = fp_toint(mul_fp(int_tofp(max_perf), limits.min_perf));
396 *min = clamp_t(int, min_perf,
397 cpu->pstate.min_pstate, max_perf);
398}
399
400static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
401{
402 int max_perf, min_perf;
403
404 intel_pstate_get_min_max(cpu, &min_perf, &max_perf);
405
406 pstate = clamp_t(int, pstate, min_perf, max_perf);
407
408 if (pstate == cpu->pstate.current_pstate)
409 return;
410
411#ifndef MODULE
412 trace_cpu_frequency(pstate * 100000, cpu->cpu);
413#endif
414 cpu->pstate.current_pstate = pstate;
415 wrmsrl(MSR_IA32_PERF_CTL, pstate << 8);
416
417}
418
419static inline void intel_pstate_pstate_increase(struct cpudata *cpu, int steps)
420{
421 int target;
422 target = cpu->pstate.current_pstate + steps;
423
424 intel_pstate_set_pstate(cpu, target);
425}
426
427static inline void intel_pstate_pstate_decrease(struct cpudata *cpu, int steps)
428{
429 int target;
430 target = cpu->pstate.current_pstate - steps;
431 intel_pstate_set_pstate(cpu, target);
432}
433
434static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
435{
436 sprintf(cpu->name, "Intel 2nd generation core");
437
438 cpu->pstate.min_pstate = intel_pstate_min_pstate();
439 cpu->pstate.max_pstate = intel_pstate_max_pstate();
440 cpu->pstate.turbo_pstate = intel_pstate_turbo_pstate();
441
442 /*
443 * goto max pstate so we don't slow up boot if we are built-in if we are
444 * a module we will take care of it during normal operation
445 */
446 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate);
447}
448
449static inline void intel_pstate_calc_busy(struct cpudata *cpu,
450 struct sample *sample)
451{
452 u64 core_pct;
453 sample->pstate_pct_busy = 100 - div64_u64(
454 sample->idletime_us * 100,
455 sample->duration_us);
456 core_pct = div64_u64(sample->aperf * 100, sample->mperf);
457 sample->freq = cpu->pstate.turbo_pstate * core_pct * 1000;
458
459 sample->core_pct_busy = div_s64((sample->pstate_pct_busy * core_pct),
460 100);
461}
462
463static inline void intel_pstate_sample(struct cpudata *cpu)
464{
465 ktime_t now;
466 u64 idle_time_us;
467 u64 aperf, mperf;
468
469 now = ktime_get();
470 idle_time_us = get_cpu_idle_time_us(cpu->cpu, NULL);
471
472 rdmsrl(MSR_IA32_APERF, aperf);
473 rdmsrl(MSR_IA32_MPERF, mperf);
474 /* for the first sample, don't actually record a sample, just
475 * set the baseline */
476 if (cpu->prev_idle_time_us > 0) {
477 cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT;
478 cpu->samples[cpu->sample_ptr].start_time = cpu->prev_sample;
479 cpu->samples[cpu->sample_ptr].end_time = now;
480 cpu->samples[cpu->sample_ptr].duration_us =
481 ktime_us_delta(now, cpu->prev_sample);
482 cpu->samples[cpu->sample_ptr].idletime_us =
483 idle_time_us - cpu->prev_idle_time_us;
484
485 cpu->samples[cpu->sample_ptr].aperf = aperf;
486 cpu->samples[cpu->sample_ptr].mperf = mperf;
487 cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf;
488 cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf;
489
490 intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]);
491 }
492
493 cpu->prev_sample = now;
494 cpu->prev_idle_time_us = idle_time_us;
495 cpu->prev_aperf = aperf;
496 cpu->prev_mperf = mperf;
497}
498
499static inline void intel_pstate_set_sample_time(struct cpudata *cpu)
500{
501 int sample_time, delay;
502
503 sample_time = cpu->pstate_policy->sample_rate_ms;
504 delay = msecs_to_jiffies(sample_time);
505 delay -= jiffies % delay;
506 mod_timer_pinned(&cpu->timer, jiffies + delay);
507}
508
509static inline void intel_pstate_idle_mode(struct cpudata *cpu)
510{
511 cpu->idle_mode = 1;
512}
513
514static inline void intel_pstate_normal_mode(struct cpudata *cpu)
515{
516 cpu->idle_mode = 0;
517}
518
519static inline int intel_pstate_get_scaled_busy(struct cpudata *cpu)
520{
521 int32_t busy_scaled;
522 int32_t core_busy, turbo_pstate, current_pstate;
523
524 core_busy = int_tofp(cpu->samples[cpu->sample_ptr].core_pct_busy);
525 turbo_pstate = int_tofp(cpu->pstate.turbo_pstate);
526 current_pstate = int_tofp(cpu->pstate.current_pstate);
527 busy_scaled = mul_fp(core_busy, div_fp(turbo_pstate, current_pstate));
528
529 return fp_toint(busy_scaled);
530}
531
532static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu)
533{
534 int busy_scaled;
535 struct _pid *pid;
536 signed int ctl = 0;
537 int steps;
538
539 pid = &cpu->pid;
540 busy_scaled = intel_pstate_get_scaled_busy(cpu);
541
542 ctl = pid_calc(pid, busy_scaled);
543
544 steps = abs(ctl);
545 if (ctl < 0)
546 intel_pstate_pstate_increase(cpu, steps);
547 else
548 intel_pstate_pstate_decrease(cpu, steps);
549}
550
551static inline void intel_pstate_adjust_idle_pstate(struct cpudata *cpu)
552{
553 int busy_scaled;
554 struct _pid *pid;
555 int ctl = 0;
556 int steps;
557
558 pid = &cpu->idle_pid;
559
560 busy_scaled = intel_pstate_get_scaled_busy(cpu);
561
562 ctl = pid_calc(pid, 100 - busy_scaled);
563
564 steps = abs(ctl);
565 if (ctl < 0)
566 intel_pstate_pstate_decrease(cpu, steps);
567 else
568 intel_pstate_pstate_increase(cpu, steps);
569
570 if (cpu->pstate.current_pstate == cpu->pstate.min_pstate)
571 intel_pstate_normal_mode(cpu);
572}
573
574static void intel_pstate_timer_func(unsigned long __data)
575{
576 struct cpudata *cpu = (struct cpudata *) __data;
577
578 intel_pstate_sample(cpu);
579
580 if (!cpu->idle_mode)
581 intel_pstate_adjust_busy_pstate(cpu);
582 else
583 intel_pstate_adjust_idle_pstate(cpu);
584
585#if defined(XPERF_FIX)
586 if (cpu->pstate.current_pstate == cpu->pstate.min_pstate) {
587 cpu->min_pstate_count++;
588 if (!(cpu->min_pstate_count % 5)) {
589 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate);
590 intel_pstate_idle_mode(cpu);
591 }
592 } else
593 cpu->min_pstate_count = 0;
594#endif
595 intel_pstate_set_sample_time(cpu);
596}
597
598#define ICPU(model, policy) \
599 { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned long)&policy }
600
601static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
602 ICPU(0x2a, default_policy),
603 ICPU(0x2d, default_policy),
604 {}
605};
606MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids);
607
608static int intel_pstate_init_cpu(unsigned int cpunum)
609{
610
611 const struct x86_cpu_id *id;
612 struct cpudata *cpu;
613
614 id = x86_match_cpu(intel_pstate_cpu_ids);
615 if (!id)
616 return -ENODEV;
617
618 all_cpu_data[cpunum] = kzalloc(sizeof(struct cpudata), GFP_KERNEL);
619 if (!all_cpu_data[cpunum])
620 return -ENOMEM;
621
622 cpu = all_cpu_data[cpunum];
623
624 intel_pstate_get_cpu_pstates(cpu);
625
626 cpu->cpu = cpunum;
627 cpu->pstate_policy =
628 (struct pstate_adjust_policy *)id->driver_data;
629 init_timer_deferrable(&cpu->timer);
630 cpu->timer.function = intel_pstate_timer_func;
631 cpu->timer.data =
632 (unsigned long)cpu;
633 cpu->timer.expires = jiffies + HZ/100;
634 intel_pstate_busy_pid_reset(cpu);
635 intel_pstate_idle_pid_reset(cpu);
636 intel_pstate_sample(cpu);
637 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate);
638
639 add_timer_on(&cpu->timer, cpunum);
640
641 pr_info("Intel pstate controlling: cpu %d\n", cpunum);
642
643 return 0;
644}
645
646static unsigned int intel_pstate_get(unsigned int cpu_num)
647{
648 struct sample *sample;
649 struct cpudata *cpu;
650
651 cpu = all_cpu_data[cpu_num];
652 if (!cpu)
653 return 0;
654 sample = &cpu->samples[cpu->sample_ptr];
655 return sample->freq;
656}
657
658static int intel_pstate_set_policy(struct cpufreq_policy *policy)
659{
660 struct cpudata *cpu;
661 int min, max;
662
663 cpu = all_cpu_data[policy->cpu];
664
665 intel_pstate_get_min_max(cpu, &min, &max);
666
667 limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
668 limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100);
669 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100));
670
671 limits.max_perf_pct = policy->max * 100 / policy->cpuinfo.max_freq;
672 limits.max_perf_pct = clamp_t(int, limits.max_perf_pct, 0 , 100);
673 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
674
675 if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) {
676 limits.min_perf_pct = 100;
677 limits.min_perf = int_tofp(1);
678 limits.max_perf_pct = 100;
679 limits.max_perf = int_tofp(1);
680 limits.no_turbo = 0;
681 }
682
683 return 0;
684}
685
686static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
687{
688 cpufreq_verify_within_limits(policy,
689 policy->cpuinfo.min_freq,
690 policy->cpuinfo.max_freq);
691
692 if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) &&
693 (policy->policy != CPUFREQ_POLICY_PERFORMANCE))
694 return -EINVAL;
695
696 return 0;
697}
698
699static int __cpuinit intel_pstate_cpu_exit(struct cpufreq_policy *policy)
700{
701 int cpu = policy->cpu;
702
703 del_timer(&all_cpu_data[cpu]->timer);
704 kfree(all_cpu_data[cpu]);
705 all_cpu_data[cpu] = NULL;
706 return 0;
707}
708
709static int __cpuinit intel_pstate_cpu_init(struct cpufreq_policy *policy)
710{
711 int rc, min_pstate, max_pstate;
712 struct cpudata *cpu;
713
714 rc = intel_pstate_init_cpu(policy->cpu);
715 if (rc)
716 return rc;
717
718 cpu = all_cpu_data[policy->cpu];
719
720 if (!limits.no_turbo &&
721 limits.min_perf_pct == 100 && limits.max_perf_pct == 100)
722 policy->policy = CPUFREQ_POLICY_PERFORMANCE;
723 else
724 policy->policy = CPUFREQ_POLICY_POWERSAVE;
725
726 intel_pstate_get_min_max(cpu, &min_pstate, &max_pstate);
727 policy->min = min_pstate * 100000;
728 policy->max = max_pstate * 100000;
729
730 /* cpuinfo and default policy values */
731 policy->cpuinfo.min_freq = cpu->pstate.min_pstate * 100000;
732 policy->cpuinfo.max_freq = cpu->pstate.turbo_pstate * 100000;
733 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
734 cpumask_set_cpu(policy->cpu, policy->cpus);
735
736 return 0;
737}
738
739static struct cpufreq_driver intel_pstate_driver = {
740 .flags = CPUFREQ_CONST_LOOPS,
741 .verify = intel_pstate_verify_policy,
742 .setpolicy = intel_pstate_set_policy,
743 .get = intel_pstate_get,
744 .init = intel_pstate_cpu_init,
745 .exit = intel_pstate_cpu_exit,
746 .name = "intel_pstate",
747 .owner = THIS_MODULE,
748};
749
750static void intel_pstate_exit(void)
751{
752 int cpu;
753
754 sysfs_remove_group(intel_pstate_kobject,
755 &intel_pstate_attr_group);
756 debugfs_remove_recursive(debugfs_parent);
757
758 cpufreq_unregister_driver(&intel_pstate_driver);
759
760 if (!all_cpu_data)
761 return;
762
763 get_online_cpus();
764 for_each_online_cpu(cpu) {
765 if (all_cpu_data[cpu]) {
766 del_timer_sync(&all_cpu_data[cpu]->timer);
767 kfree(all_cpu_data[cpu]);
768 }
769 }
770
771 put_online_cpus();
772 vfree(all_cpu_data);
773}
774module_exit(intel_pstate_exit);
775
776static int __initdata no_load;
777
778static int __init intel_pstate_init(void)
779{
780 int rc = 0;
781 const struct x86_cpu_id *id;
782
783 if (no_load)
784 return -ENODEV;
785
786 id = x86_match_cpu(intel_pstate_cpu_ids);
787 if (!id)
788 return -ENODEV;
789
790 pr_info("Intel P-state driver initializing.\n");
791
792 all_cpu_data = vmalloc(sizeof(void *) * num_possible_cpus());
793 if (!all_cpu_data)
794 return -ENOMEM;
795 memset(all_cpu_data, 0, sizeof(void *) * num_possible_cpus());
796
797 rc = cpufreq_register_driver(&intel_pstate_driver);
798 if (rc)
799 goto out;
800
801 intel_pstate_debug_expose_params();
802 intel_pstate_sysfs_expose_params();
803 return rc;
804out:
805 intel_pstate_exit();
806 return -ENODEV;
807}
808device_initcall(intel_pstate_init);
809
810static int __init intel_pstate_setup(char *str)
811{
812 if (!str)
813 return -EINVAL;
814
815 if (!strcmp(str, "disable"))
816 no_load = 1;
817 return 0;
818}
819early_param("intel_pstate", intel_pstate_setup);
820
821MODULE_AUTHOR("Dirk Brandewie <dirk.j.brandewie@intel.com>");
822MODULE_DESCRIPTION("'intel_pstate' - P state driver Intel Core processors");
823MODULE_LICENSE("GPL");
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
new file mode 100644
index 000000000000..0e83e3c24f5b
--- /dev/null
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -0,0 +1,259 @@
1/*
2 * kirkwood_freq.c: cpufreq driver for the Marvell kirkwood
3 *
4 * Copyright (C) 2013 Andrew Lunn <andrew@lunn.ch>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/clk.h>
15#include <linux/clk-provider.h>
16#include <linux/cpufreq.h>
17#include <linux/of.h>
18#include <linux/platform_device.h>
19#include <linux/io.h>
20#include <asm/proc-fns.h>
21
22#define CPU_SW_INT_BLK BIT(28)
23
24static struct priv
25{
26 struct clk *cpu_clk;
27 struct clk *ddr_clk;
28 struct clk *powersave_clk;
29 struct device *dev;
30 void __iomem *base;
31} priv;
32
33#define STATE_CPU_FREQ 0x01
34#define STATE_DDR_FREQ 0x02
35
36/*
37 * Kirkwood can swap the clock to the CPU between two clocks:
38 *
39 * - cpu clk
40 * - ddr clk
41 *
42 * The frequencies are set at runtime before registering this *
43 * table.
44 */
45static struct cpufreq_frequency_table kirkwood_freq_table[] = {
46 {STATE_CPU_FREQ, 0}, /* CPU uses cpuclk */
47 {STATE_DDR_FREQ, 0}, /* CPU uses ddrclk */
48 {0, CPUFREQ_TABLE_END},
49};
50
51static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu)
52{
53 if (__clk_is_enabled(priv.powersave_clk))
54 return kirkwood_freq_table[1].frequency;
55 return kirkwood_freq_table[0].frequency;
56}
57
58static void kirkwood_cpufreq_set_cpu_state(unsigned int index)
59{
60 struct cpufreq_freqs freqs;
61 unsigned int state = kirkwood_freq_table[index].index;
62 unsigned long reg;
63
64 freqs.old = kirkwood_cpufreq_get_cpu_frequency(0);
65 freqs.new = kirkwood_freq_table[index].frequency;
66 freqs.cpu = 0; /* Kirkwood is UP */
67
68 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
69
70 dev_dbg(priv.dev, "Attempting to set frequency to %i KHz\n",
71 kirkwood_freq_table[index].frequency);
72 dev_dbg(priv.dev, "old frequency was %i KHz\n",
73 kirkwood_cpufreq_get_cpu_frequency(0));
74
75 if (freqs.old != freqs.new) {
76 local_irq_disable();
77
78 /* Disable interrupts to the CPU */
79 reg = readl_relaxed(priv.base);
80 reg |= CPU_SW_INT_BLK;
81 writel_relaxed(reg, priv.base);
82
83 switch (state) {
84 case STATE_CPU_FREQ:
85 clk_disable(priv.powersave_clk);
86 break;
87 case STATE_DDR_FREQ:
88 clk_enable(priv.powersave_clk);
89 break;
90 }
91
92 /* Wait-for-Interrupt, while the hardware changes frequency */
93 cpu_do_idle();
94
95 /* Enable interrupts to the CPU */
96 reg = readl_relaxed(priv.base);
97 reg &= ~CPU_SW_INT_BLK;
98 writel_relaxed(reg, priv.base);
99
100 local_irq_enable();
101 }
102 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
103};
104
105static int kirkwood_cpufreq_verify(struct cpufreq_policy *policy)
106{
107 return cpufreq_frequency_table_verify(policy, kirkwood_freq_table);
108}
109
110static int kirkwood_cpufreq_target(struct cpufreq_policy *policy,
111 unsigned int target_freq,
112 unsigned int relation)
113{
114 unsigned int index = 0;
115
116 if (cpufreq_frequency_table_target(policy, kirkwood_freq_table,
117 target_freq, relation, &index))
118 return -EINVAL;
119
120 kirkwood_cpufreq_set_cpu_state(index);
121
122 return 0;
123}
124
125/* Module init and exit code */
126static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy)
127{
128 int result;
129
130 /* cpuinfo and default policy values */
131 policy->cpuinfo.transition_latency = 5000; /* 5uS */
132 policy->cur = kirkwood_cpufreq_get_cpu_frequency(0);
133
134 result = cpufreq_frequency_table_cpuinfo(policy, kirkwood_freq_table);
135 if (result)
136 return result;
137
138 cpufreq_frequency_table_get_attr(kirkwood_freq_table, policy->cpu);
139
140 return 0;
141}
142
143static int kirkwood_cpufreq_cpu_exit(struct cpufreq_policy *policy)
144{
145 cpufreq_frequency_table_put_attr(policy->cpu);
146 return 0;
147}
148
149static struct freq_attr *kirkwood_cpufreq_attr[] = {
150 &cpufreq_freq_attr_scaling_available_freqs,
151 NULL,
152};
153
154static struct cpufreq_driver kirkwood_cpufreq_driver = {
155 .get = kirkwood_cpufreq_get_cpu_frequency,
156 .verify = kirkwood_cpufreq_verify,
157 .target = kirkwood_cpufreq_target,
158 .init = kirkwood_cpufreq_cpu_init,
159 .exit = kirkwood_cpufreq_cpu_exit,
160 .name = "kirkwood-cpufreq",
161 .owner = THIS_MODULE,
162 .attr = kirkwood_cpufreq_attr,
163};
164
165static int kirkwood_cpufreq_probe(struct platform_device *pdev)
166{
167 struct device_node *np;
168 struct resource *res;
169 int err;
170
171 priv.dev = &pdev->dev;
172
173 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
174 if (!res) {
175 dev_err(&pdev->dev, "Cannot get memory resource\n");
176 return -ENODEV;
177 }
178 priv.base = devm_request_and_ioremap(&pdev->dev, res);
179 if (!priv.base) {
180 dev_err(&pdev->dev, "Cannot ioremap\n");
181 return -EADDRNOTAVAIL;
182 }
183
184 np = of_find_node_by_path("/cpus/cpu@0");
185 if (!np)
186 return -ENODEV;
187
188 priv.cpu_clk = of_clk_get_by_name(np, "cpu_clk");
189 if (IS_ERR(priv.cpu_clk)) {
190 dev_err(priv.dev, "Unable to get cpuclk");
191 return PTR_ERR(priv.cpu_clk);
192 }
193
194 clk_prepare_enable(priv.cpu_clk);
195 kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
196
197 priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
198 if (IS_ERR(priv.ddr_clk)) {
199 dev_err(priv.dev, "Unable to get ddrclk");
200 err = PTR_ERR(priv.ddr_clk);
201 goto out_cpu;
202 }
203
204 clk_prepare_enable(priv.ddr_clk);
205 kirkwood_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
206
207 priv.powersave_clk = of_clk_get_by_name(np, "powersave");
208 if (IS_ERR(priv.powersave_clk)) {
209 dev_err(priv.dev, "Unable to get powersave");
210 err = PTR_ERR(priv.powersave_clk);
211 goto out_ddr;
212 }
213 clk_prepare(priv.powersave_clk);
214
215 of_node_put(np);
216 np = NULL;
217
218 err = cpufreq_register_driver(&kirkwood_cpufreq_driver);
219 if (!err)
220 return 0;
221
222 dev_err(priv.dev, "Failed to register cpufreq driver");
223
224 clk_disable_unprepare(priv.powersave_clk);
225out_ddr:
226 clk_disable_unprepare(priv.ddr_clk);
227out_cpu:
228 clk_disable_unprepare(priv.cpu_clk);
229 of_node_put(np);
230
231 return err;
232}
233
234static int kirkwood_cpufreq_remove(struct platform_device *pdev)
235{
236 cpufreq_unregister_driver(&kirkwood_cpufreq_driver);
237
238 clk_disable_unprepare(priv.powersave_clk);
239 clk_disable_unprepare(priv.ddr_clk);
240 clk_disable_unprepare(priv.cpu_clk);
241
242 return 0;
243}
244
245static struct platform_driver kirkwood_cpufreq_platform_driver = {
246 .probe = kirkwood_cpufreq_probe,
247 .remove = kirkwood_cpufreq_remove,
248 .driver = {
249 .name = "kirkwood-cpufreq",
250 .owner = THIS_MODULE,
251 },
252};
253
254module_platform_driver(kirkwood_cpufreq_platform_driver);
255
256MODULE_LICENSE("GPL v2");
257MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch");
258MODULE_DESCRIPTION("cpufreq driver for Marvell's kirkwood CPU");
259MODULE_ALIAS("platform:kirkwood-cpufreq");
diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index 89b178a3f849..d4c4989823dc 100644
--- a/drivers/cpufreq/maple-cpufreq.c
+++ b/drivers/cpufreq/maple-cpufreq.c
@@ -181,7 +181,7 @@ static int maple_cpufreq_cpu_init(struct cpufreq_policy *policy)
181 /* secondary CPUs are tied to the primary one by the 181 /* secondary CPUs are tied to the primary one by the
182 * cpufreq core if in the secondary policy we tell it that 182 * cpufreq core if in the secondary policy we tell it that
183 * it actually must be one policy together with all others. */ 183 * it actually must be one policy together with all others. */
184 cpumask_copy(policy->cpus, cpu_online_mask); 184 cpumask_setall(policy->cpus);
185 cpufreq_frequency_table_get_attr(maple_cpu_freqs, policy->cpu); 185 cpufreq_frequency_table_get_attr(maple_cpu_freqs, policy->cpu);
186 186
187 return cpufreq_frequency_table_cpuinfo(policy, 187 return cpufreq_frequency_table_cpuinfo(policy,
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index 97102b05843f..9128c07bafba 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -214,10 +214,8 @@ static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy)
214 * interface to handle this scenario. Additional is_smp() check 214 * interface to handle this scenario. Additional is_smp() check
215 * is to keep SMP_ON_UP build working. 215 * is to keep SMP_ON_UP build working.
216 */ 216 */
217 if (is_smp()) { 217 if (is_smp())
218 policy->shared_type = CPUFREQ_SHARED_TYPE_ANY;
219 cpumask_setall(policy->cpus); 218 cpumask_setall(policy->cpus);
220 }
221 219
222 /* FIXME: what's the actual transition time? */ 220 /* FIXME: what's the actual transition time? */
223 policy->cpuinfo.transition_latency = 300 * 1000; 221 policy->cpuinfo.transition_latency = 300 * 1000;
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 056faf6af1a9..d13a13678b5f 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1249,39 +1249,59 @@ static struct cpufreq_driver cpufreq_amd64_driver = {
1249 .attr = powernow_k8_attr, 1249 .attr = powernow_k8_attr,
1250}; 1250};
1251 1251
1252static void __request_acpi_cpufreq(void)
1253{
1254 const char *cur_drv, *drv = "acpi-cpufreq";
1255
1256 cur_drv = cpufreq_get_current_driver();
1257 if (!cur_drv)
1258 goto request;
1259
1260 if (strncmp(cur_drv, drv, min_t(size_t, strlen(cur_drv), strlen(drv))))
1261 pr_warn(PFX "WTF driver: %s\n", cur_drv);
1262
1263 return;
1264
1265 request:
1266 pr_warn(PFX "This CPU is not supported anymore, using acpi-cpufreq instead.\n");
1267 request_module(drv);
1268}
1269
1252/* driver entry point for init */ 1270/* driver entry point for init */
1253static int __cpuinit powernowk8_init(void) 1271static int __cpuinit powernowk8_init(void)
1254{ 1272{
1255 unsigned int i, supported_cpus = 0; 1273 unsigned int i, supported_cpus = 0;
1256 int rv; 1274 int ret;
1257 1275
1258 if (static_cpu_has(X86_FEATURE_HW_PSTATE)) { 1276 if (static_cpu_has(X86_FEATURE_HW_PSTATE)) {
1259 pr_warn(PFX "this CPU is not supported anymore, using acpi-cpufreq instead.\n"); 1277 __request_acpi_cpufreq();
1260 request_module("acpi-cpufreq");
1261 return -ENODEV; 1278 return -ENODEV;
1262 } 1279 }
1263 1280
1264 if (!x86_match_cpu(powernow_k8_ids)) 1281 if (!x86_match_cpu(powernow_k8_ids))
1265 return -ENODEV; 1282 return -ENODEV;
1266 1283
1284 get_online_cpus();
1267 for_each_online_cpu(i) { 1285 for_each_online_cpu(i) {
1268 int rc; 1286 smp_call_function_single(i, check_supported_cpu, &ret, 1);
1269 smp_call_function_single(i, check_supported_cpu, &rc, 1); 1287 if (!ret)
1270 if (rc == 0)
1271 supported_cpus++; 1288 supported_cpus++;
1272 } 1289 }
1273 1290
1274 if (supported_cpus != num_online_cpus()) 1291 if (supported_cpus != num_online_cpus()) {
1292 put_online_cpus();
1275 return -ENODEV; 1293 return -ENODEV;
1294 }
1295 put_online_cpus();
1276 1296
1277 rv = cpufreq_register_driver(&cpufreq_amd64_driver); 1297 ret = cpufreq_register_driver(&cpufreq_amd64_driver);
1298 if (ret)
1299 return ret;
1278 1300
1279 if (!rv) 1301 pr_info(PFX "Found %d %s (%d cpu cores) (" VERSION ")\n",
1280 pr_info(PFX "Found %d %s (%d cpu cores) (" VERSION ")\n", 1302 num_online_nodes(), boot_cpu_data.x86_model_id, supported_cpus);
1281 num_online_nodes(), boot_cpu_data.x86_model_id,
1282 supported_cpus);
1283 1303
1284 return rv; 1304 return ret;
1285} 1305}
1286 1306
1287/* driver entry point for term */ 1307/* driver entry point for term */
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 4575cfe41755..7e4d77327957 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -30,7 +30,7 @@ static struct {
30 u32 cnt; 30 u32 cnt;
31} spear_cpufreq; 31} spear_cpufreq;
32 32
33int spear_cpufreq_verify(struct cpufreq_policy *policy) 33static int spear_cpufreq_verify(struct cpufreq_policy *policy)
34{ 34{
35 return cpufreq_frequency_table_verify(policy, spear_cpufreq.freq_tbl); 35 return cpufreq_frequency_table_verify(policy, spear_cpufreq.freq_tbl);
36} 36}
@@ -157,7 +157,9 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,
157 157
158 freqs.new = newfreq / 1000; 158 freqs.new = newfreq / 1000;
159 freqs.new /= mult; 159 freqs.new /= mult;
160 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 160
161 for_each_cpu(freqs.cpu, policy->cpus)
162 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
161 163
162 if (mult == 2) 164 if (mult == 2)
163 ret = spear1340_set_cpu_rate(srcclk, newfreq); 165 ret = spear1340_set_cpu_rate(srcclk, newfreq);
@@ -170,7 +172,8 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,
170 freqs.new = clk_get_rate(spear_cpufreq.clk) / 1000; 172 freqs.new = clk_get_rate(spear_cpufreq.clk) / 1000;
171 } 173 }
172 174
173 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 175 for_each_cpu(freqs.cpu, policy->cpus)
176 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
174 return ret; 177 return ret;
175} 178}
176 179
@@ -188,8 +191,7 @@ static int spear_cpufreq_init(struct cpufreq_policy *policy)
188 policy->cpuinfo.transition_latency = spear_cpufreq.transition_latency; 191 policy->cpuinfo.transition_latency = spear_cpufreq.transition_latency;
189 policy->cur = spear_cpufreq_get(0); 192 policy->cur = spear_cpufreq_get(0);
190 193
191 cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu)); 194 cpumask_setall(policy->cpus);
192 cpumask_copy(policy->related_cpus, policy->cpus);
193 195
194 return 0; 196 return 0;
195} 197}
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index e1f6860e069c..eba69290e074 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -144,7 +144,6 @@ int cpuidle_idle_call(void)
144 return 0; 144 return 0;
145 } 145 }
146 146
147 trace_power_start_rcuidle(POWER_CSTATE, next_state, dev->cpu);
148 trace_cpu_idle_rcuidle(next_state, dev->cpu); 147 trace_cpu_idle_rcuidle(next_state, dev->cpu);
149 148
150 if (cpuidle_state_is_coupled(dev, drv, next_state)) 149 if (cpuidle_state_is_coupled(dev, drv, next_state))
@@ -153,7 +152,6 @@ int cpuidle_idle_call(void)
153 else 152 else
154 entered_state = cpuidle_enter_state(dev, drv, next_state); 153 entered_state = cpuidle_enter_state(dev, drv, next_state);
155 154
156 trace_power_end_rcuidle(dev->cpu);
157 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); 155 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu);
158 156
159 /* give the governor an opportunity to reflect on the outcome */ 157 /* give the governor an opportunity to reflect on the outcome */
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 1672e2a5db46..6351aba8819c 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -911,7 +911,7 @@ exit:
911 return res; 911 return res;
912} 912}
913 913
914static int acpi_power_meter_remove(struct acpi_device *device, int type) 914static int acpi_power_meter_remove(struct acpi_device *device)
915{ 915{
916 struct acpi_power_meter_resource *resource; 916 struct acpi_power_meter_resource *resource;
917 917
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index 56dbcfb3e301..b25c64302cbc 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -190,7 +190,7 @@ struct atk_acpi_input_buf {
190}; 190};
191 191
192static int atk_add(struct acpi_device *device); 192static int atk_add(struct acpi_device *device);
193static int atk_remove(struct acpi_device *device, int type); 193static int atk_remove(struct acpi_device *device);
194static void atk_print_sensor(struct atk_data *data, union acpi_object *obj); 194static void atk_print_sensor(struct atk_data *data, union acpi_object *obj);
195static int atk_read_value(struct atk_sensor_data *sensor, u64 *value); 195static int atk_read_value(struct atk_sensor_data *sensor, u64 *value);
196static void atk_free_sensors(struct atk_data *data); 196static void atk_free_sensors(struct atk_data *data);
@@ -1416,7 +1416,7 @@ out:
1416 return err; 1416 return err;
1417} 1417}
1418 1418
1419static int atk_remove(struct acpi_device *device, int type) 1419static int atk_remove(struct acpi_device *device)
1420{ 1420{
1421 struct atk_data *data = device->driver_data; 1421 struct atk_data *data = device->driver_data;
1422 dev_dbg(&device->dev, "removing...\n"); 1422 dev_dbg(&device->dev, "removing...\n");
diff --git a/drivers/i2c/busses/i2c-scmi.c b/drivers/i2c/busses/i2c-scmi.c
index 6aafa3d88ff0..c447e8d40b78 100644
--- a/drivers/i2c/busses/i2c-scmi.c
+++ b/drivers/i2c/busses/i2c-scmi.c
@@ -406,7 +406,7 @@ err:
406 return -EIO; 406 return -EIO;
407} 407}
408 408
409static int acpi_smbus_cmi_remove(struct acpi_device *device, int type) 409static int acpi_smbus_cmi_remove(struct acpi_device *device)
410{ 410{
411 struct acpi_smbus_cmi *smbus_cmi = acpi_driver_data(device); 411 struct acpi_smbus_cmi *smbus_cmi = acpi_driver_data(device);
412 412
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 2df9414a72f7..5d6675013864 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -74,7 +74,7 @@ static struct cpuidle_driver intel_idle_driver = {
74 .en_core_tk_irqen = 1, 74 .en_core_tk_irqen = 1,
75}; 75};
76/* intel_idle.max_cstate=0 disables driver */ 76/* intel_idle.max_cstate=0 disables driver */
77static int max_cstate = MWAIT_MAX_NUM_CSTATES - 1; 77static int max_cstate = CPUIDLE_STATE_MAX - 1;
78 78
79static unsigned int mwait_substates; 79static unsigned int mwait_substates;
80 80
@@ -90,6 +90,7 @@ struct idle_cpu {
90 * Indicate which enable bits to clear here. 90 * Indicate which enable bits to clear here.
91 */ 91 */
92 unsigned long auto_demotion_disable_flags; 92 unsigned long auto_demotion_disable_flags;
93 bool disable_promotion_to_c1e;
93}; 94};
94 95
95static const struct idle_cpu *icpu; 96static const struct idle_cpu *icpu;
@@ -109,162 +110,206 @@ static struct cpuidle_state *cpuidle_state_table;
109#define CPUIDLE_FLAG_TLB_FLUSHED 0x10000 110#define CPUIDLE_FLAG_TLB_FLUSHED 0x10000
110 111
111/* 112/*
113 * MWAIT takes an 8-bit "hint" in EAX "suggesting"
114 * the C-state (top nibble) and sub-state (bottom nibble)
115 * 0x00 means "MWAIT(C1)", 0x10 means "MWAIT(C2)" etc.
116 *
117 * We store the hint at the top of our "flags" for each state.
118 */
119#define flg2MWAIT(flags) (((flags) >> 24) & 0xFF)
120#define MWAIT2flg(eax) ((eax & 0xFF) << 24)
121
122/*
112 * States are indexed by the cstate number, 123 * States are indexed by the cstate number,
113 * which is also the index into the MWAIT hint array. 124 * which is also the index into the MWAIT hint array.
114 * Thus C0 is a dummy. 125 * Thus C0 is a dummy.
115 */ 126 */
116static struct cpuidle_state nehalem_cstates[MWAIT_MAX_NUM_CSTATES] = { 127static struct cpuidle_state nehalem_cstates[CPUIDLE_STATE_MAX] = {
117 { /* MWAIT C0 */ }, 128 {
118 { /* MWAIT C1 */
119 .name = "C1-NHM", 129 .name = "C1-NHM",
120 .desc = "MWAIT 0x00", 130 .desc = "MWAIT 0x00",
121 .flags = CPUIDLE_FLAG_TIME_VALID, 131 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
122 .exit_latency = 3, 132 .exit_latency = 3,
123 .target_residency = 6, 133 .target_residency = 6,
124 .enter = &intel_idle }, 134 .enter = &intel_idle },
125 { /* MWAIT C2 */ 135 {
136 .name = "C1E-NHM",
137 .desc = "MWAIT 0x01",
138 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
139 .exit_latency = 10,
140 .target_residency = 20,
141 .enter = &intel_idle },
142 {
126 .name = "C3-NHM", 143 .name = "C3-NHM",
127 .desc = "MWAIT 0x10", 144 .desc = "MWAIT 0x10",
128 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 145 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
129 .exit_latency = 20, 146 .exit_latency = 20,
130 .target_residency = 80, 147 .target_residency = 80,
131 .enter = &intel_idle }, 148 .enter = &intel_idle },
132 { /* MWAIT C3 */ 149 {
133 .name = "C6-NHM", 150 .name = "C6-NHM",
134 .desc = "MWAIT 0x20", 151 .desc = "MWAIT 0x20",
135 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 152 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
136 .exit_latency = 200, 153 .exit_latency = 200,
137 .target_residency = 800, 154 .target_residency = 800,
138 .enter = &intel_idle }, 155 .enter = &intel_idle },
156 {
157 .enter = NULL }
139}; 158};
140 159
141static struct cpuidle_state snb_cstates[MWAIT_MAX_NUM_CSTATES] = { 160static struct cpuidle_state snb_cstates[CPUIDLE_STATE_MAX] = {
142 { /* MWAIT C0 */ }, 161 {
143 { /* MWAIT C1 */
144 .name = "C1-SNB", 162 .name = "C1-SNB",
145 .desc = "MWAIT 0x00", 163 .desc = "MWAIT 0x00",
146 .flags = CPUIDLE_FLAG_TIME_VALID, 164 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
147 .exit_latency = 1, 165 .exit_latency = 2,
148 .target_residency = 1, 166 .target_residency = 2,
149 .enter = &intel_idle }, 167 .enter = &intel_idle },
150 { /* MWAIT C2 */ 168 {
169 .name = "C1E-SNB",
170 .desc = "MWAIT 0x01",
171 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
172 .exit_latency = 10,
173 .target_residency = 20,
174 .enter = &intel_idle },
175 {
151 .name = "C3-SNB", 176 .name = "C3-SNB",
152 .desc = "MWAIT 0x10", 177 .desc = "MWAIT 0x10",
153 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 178 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
154 .exit_latency = 80, 179 .exit_latency = 80,
155 .target_residency = 211, 180 .target_residency = 211,
156 .enter = &intel_idle }, 181 .enter = &intel_idle },
157 { /* MWAIT C3 */ 182 {
158 .name = "C6-SNB", 183 .name = "C6-SNB",
159 .desc = "MWAIT 0x20", 184 .desc = "MWAIT 0x20",
160 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 185 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
161 .exit_latency = 104, 186 .exit_latency = 104,
162 .target_residency = 345, 187 .target_residency = 345,
163 .enter = &intel_idle }, 188 .enter = &intel_idle },
164 { /* MWAIT C4 */ 189 {
165 .name = "C7-SNB", 190 .name = "C7-SNB",
166 .desc = "MWAIT 0x30", 191 .desc = "MWAIT 0x30",
167 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 192 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
168 .exit_latency = 109, 193 .exit_latency = 109,
169 .target_residency = 345, 194 .target_residency = 345,
170 .enter = &intel_idle }, 195 .enter = &intel_idle },
196 {
197 .enter = NULL }
171}; 198};
172 199
173static struct cpuidle_state ivb_cstates[MWAIT_MAX_NUM_CSTATES] = { 200static struct cpuidle_state ivb_cstates[CPUIDLE_STATE_MAX] = {
174 { /* MWAIT C0 */ }, 201 {
175 { /* MWAIT C1 */
176 .name = "C1-IVB", 202 .name = "C1-IVB",
177 .desc = "MWAIT 0x00", 203 .desc = "MWAIT 0x00",
178 .flags = CPUIDLE_FLAG_TIME_VALID, 204 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
179 .exit_latency = 1, 205 .exit_latency = 1,
180 .target_residency = 1, 206 .target_residency = 1,
181 .enter = &intel_idle }, 207 .enter = &intel_idle },
182 { /* MWAIT C2 */ 208 {
209 .name = "C1E-IVB",
210 .desc = "MWAIT 0x01",
211 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
212 .exit_latency = 10,
213 .target_residency = 20,
214 .enter = &intel_idle },
215 {
183 .name = "C3-IVB", 216 .name = "C3-IVB",
184 .desc = "MWAIT 0x10", 217 .desc = "MWAIT 0x10",
185 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 218 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
186 .exit_latency = 59, 219 .exit_latency = 59,
187 .target_residency = 156, 220 .target_residency = 156,
188 .enter = &intel_idle }, 221 .enter = &intel_idle },
189 { /* MWAIT C3 */ 222 {
190 .name = "C6-IVB", 223 .name = "C6-IVB",
191 .desc = "MWAIT 0x20", 224 .desc = "MWAIT 0x20",
192 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 225 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
193 .exit_latency = 80, 226 .exit_latency = 80,
194 .target_residency = 300, 227 .target_residency = 300,
195 .enter = &intel_idle }, 228 .enter = &intel_idle },
196 { /* MWAIT C4 */ 229 {
197 .name = "C7-IVB", 230 .name = "C7-IVB",
198 .desc = "MWAIT 0x30", 231 .desc = "MWAIT 0x30",
199 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 232 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
200 .exit_latency = 87, 233 .exit_latency = 87,
201 .target_residency = 300, 234 .target_residency = 300,
202 .enter = &intel_idle }, 235 .enter = &intel_idle },
236 {
237 .enter = NULL }
203}; 238};
204 239
205static struct cpuidle_state atom_cstates[MWAIT_MAX_NUM_CSTATES] = { 240static struct cpuidle_state hsw_cstates[CPUIDLE_STATE_MAX] = {
206 { /* MWAIT C0 */ }, 241 {
207 { /* MWAIT C1 */ 242 .name = "C1-HSW",
208 .name = "C1-ATM",
209 .desc = "MWAIT 0x00", 243 .desc = "MWAIT 0x00",
210 .flags = CPUIDLE_FLAG_TIME_VALID, 244 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
211 .exit_latency = 1, 245 .exit_latency = 2,
212 .target_residency = 4, 246 .target_residency = 2,
247 .enter = &intel_idle },
248 {
249 .name = "C1E-HSW",
250 .desc = "MWAIT 0x01",
251 .flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_TIME_VALID,
252 .exit_latency = 10,
253 .target_residency = 20,
254 .enter = &intel_idle },
255 {
256 .name = "C3-HSW",
257 .desc = "MWAIT 0x10",
258 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
259 .exit_latency = 33,
260 .target_residency = 100,
261 .enter = &intel_idle },
262 {
263 .name = "C6-HSW",
264 .desc = "MWAIT 0x20",
265 .flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
266 .exit_latency = 133,
267 .target_residency = 400,
268 .enter = &intel_idle },
269 {
270 .name = "C7s-HSW",
271 .desc = "MWAIT 0x32",
272 .flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
273 .exit_latency = 166,
274 .target_residency = 500,
275 .enter = &intel_idle },
276 {
277 .enter = NULL }
278};
279
280static struct cpuidle_state atom_cstates[CPUIDLE_STATE_MAX] = {
281 {
282 .name = "C1E-ATM",
283 .desc = "MWAIT 0x00",
284 .flags = MWAIT2flg(0x00) | CPUIDLE_FLAG_TIME_VALID,
285 .exit_latency = 10,
286 .target_residency = 20,
213 .enter = &intel_idle }, 287 .enter = &intel_idle },
214 { /* MWAIT C2 */ 288 {
215 .name = "C2-ATM", 289 .name = "C2-ATM",
216 .desc = "MWAIT 0x10", 290 .desc = "MWAIT 0x10",
217 .flags = CPUIDLE_FLAG_TIME_VALID, 291 .flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TIME_VALID,
218 .exit_latency = 20, 292 .exit_latency = 20,
219 .target_residency = 80, 293 .target_residency = 80,
220 .enter = &intel_idle }, 294 .enter = &intel_idle },
221 { /* MWAIT C3 */ }, 295 {
222 { /* MWAIT C4 */
223 .name = "C4-ATM", 296 .name = "C4-ATM",
224 .desc = "MWAIT 0x30", 297 .desc = "MWAIT 0x30",
225 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 298 .flags = MWAIT2flg(0x30) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
226 .exit_latency = 100, 299 .exit_latency = 100,
227 .target_residency = 400, 300 .target_residency = 400,
228 .enter = &intel_idle }, 301 .enter = &intel_idle },
229 { /* MWAIT C5 */ }, 302 {
230 { /* MWAIT C6 */
231 .name = "C6-ATM", 303 .name = "C6-ATM",
232 .desc = "MWAIT 0x52", 304 .desc = "MWAIT 0x52",
233 .flags = CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED, 305 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TIME_VALID | CPUIDLE_FLAG_TLB_FLUSHED,
234 .exit_latency = 140, 306 .exit_latency = 140,
235 .target_residency = 560, 307 .target_residency = 560,
236 .enter = &intel_idle }, 308 .enter = &intel_idle },
309 {
310 .enter = NULL }
237}; 311};
238 312
239static long get_driver_data(int cstate)
240{
241 int driver_data;
242 switch (cstate) {
243
244 case 1: /* MWAIT C1 */
245 driver_data = 0x00;
246 break;
247 case 2: /* MWAIT C2 */
248 driver_data = 0x10;
249 break;
250 case 3: /* MWAIT C3 */
251 driver_data = 0x20;
252 break;
253 case 4: /* MWAIT C4 */
254 driver_data = 0x30;
255 break;
256 case 5: /* MWAIT C5 */
257 driver_data = 0x40;
258 break;
259 case 6: /* MWAIT C6 */
260 driver_data = 0x52;
261 break;
262 default:
263 driver_data = 0x00;
264 }
265 return driver_data;
266}
267
268/** 313/**
269 * intel_idle 314 * intel_idle
270 * @dev: cpuidle_device 315 * @dev: cpuidle_device
@@ -278,8 +323,7 @@ static int intel_idle(struct cpuidle_device *dev,
278{ 323{
279 unsigned long ecx = 1; /* break on interrupt flag */ 324 unsigned long ecx = 1; /* break on interrupt flag */
280 struct cpuidle_state *state = &drv->states[index]; 325 struct cpuidle_state *state = &drv->states[index];
281 struct cpuidle_state_usage *state_usage = &dev->states_usage[index]; 326 unsigned long eax = flg2MWAIT(state->flags);
282 unsigned long eax = (unsigned long)cpuidle_get_statedata(state_usage);
283 unsigned int cstate; 327 unsigned int cstate;
284 int cpu = smp_processor_id(); 328 int cpu = smp_processor_id();
285 329
@@ -362,10 +406,19 @@ static void auto_demotion_disable(void *dummy)
362 msr_bits &= ~(icpu->auto_demotion_disable_flags); 406 msr_bits &= ~(icpu->auto_demotion_disable_flags);
363 wrmsrl(MSR_NHM_SNB_PKG_CST_CFG_CTL, msr_bits); 407 wrmsrl(MSR_NHM_SNB_PKG_CST_CFG_CTL, msr_bits);
364} 408}
409static void c1e_promotion_disable(void *dummy)
410{
411 unsigned long long msr_bits;
412
413 rdmsrl(MSR_IA32_POWER_CTL, msr_bits);
414 msr_bits &= ~0x2;
415 wrmsrl(MSR_IA32_POWER_CTL, msr_bits);
416}
365 417
366static const struct idle_cpu idle_cpu_nehalem = { 418static const struct idle_cpu idle_cpu_nehalem = {
367 .state_table = nehalem_cstates, 419 .state_table = nehalem_cstates,
368 .auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE, 420 .auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE,
421 .disable_promotion_to_c1e = true,
369}; 422};
370 423
371static const struct idle_cpu idle_cpu_atom = { 424static const struct idle_cpu idle_cpu_atom = {
@@ -379,10 +432,17 @@ static const struct idle_cpu idle_cpu_lincroft = {
379 432
380static const struct idle_cpu idle_cpu_snb = { 433static const struct idle_cpu idle_cpu_snb = {
381 .state_table = snb_cstates, 434 .state_table = snb_cstates,
435 .disable_promotion_to_c1e = true,
382}; 436};
383 437
384static const struct idle_cpu idle_cpu_ivb = { 438static const struct idle_cpu idle_cpu_ivb = {
385 .state_table = ivb_cstates, 439 .state_table = ivb_cstates,
440 .disable_promotion_to_c1e = true,
441};
442
443static const struct idle_cpu idle_cpu_hsw = {
444 .state_table = hsw_cstates,
445 .disable_promotion_to_c1e = true,
386}; 446};
387 447
388#define ICPU(model, cpu) \ 448#define ICPU(model, cpu) \
@@ -402,6 +462,9 @@ static const struct x86_cpu_id intel_idle_ids[] = {
402 ICPU(0x2d, idle_cpu_snb), 462 ICPU(0x2d, idle_cpu_snb),
403 ICPU(0x3a, idle_cpu_ivb), 463 ICPU(0x3a, idle_cpu_ivb),
404 ICPU(0x3e, idle_cpu_ivb), 464 ICPU(0x3e, idle_cpu_ivb),
465 ICPU(0x3c, idle_cpu_hsw),
466 ICPU(0x3f, idle_cpu_hsw),
467 ICPU(0x45, idle_cpu_hsw),
405 {} 468 {}
406}; 469};
407MODULE_DEVICE_TABLE(x86cpu, intel_idle_ids); 470MODULE_DEVICE_TABLE(x86cpu, intel_idle_ids);
@@ -484,32 +547,31 @@ static int intel_idle_cpuidle_driver_init(void)
484 547
485 drv->state_count = 1; 548 drv->state_count = 1;
486 549
487 for (cstate = 1; cstate < MWAIT_MAX_NUM_CSTATES; ++cstate) { 550 for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
488 int num_substates; 551 int num_substates, mwait_hint, mwait_cstate, mwait_substate;
489 552
490 if (cstate > max_cstate) { 553 if (cpuidle_state_table[cstate].enter == NULL)
554 break;
555
556 if (cstate + 1 > max_cstate) {
491 printk(PREFIX "max_cstate %d reached\n", 557 printk(PREFIX "max_cstate %d reached\n",
492 max_cstate); 558 max_cstate);
493 break; 559 break;
494 } 560 }
495 561
562 mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
563 mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint);
564 mwait_substate = MWAIT_HINT2SUBSTATE(mwait_hint);
565
496 /* does the state exist in CPUID.MWAIT? */ 566 /* does the state exist in CPUID.MWAIT? */
497 num_substates = (mwait_substates >> ((cstate) * 4)) 567 num_substates = (mwait_substates >> ((mwait_cstate + 1) * 4))
498 & MWAIT_SUBSTATE_MASK; 568 & MWAIT_SUBSTATE_MASK;
499 if (num_substates == 0) 569
500 continue; 570 /* if sub-state in table is not enumerated by CPUID */
501 /* is the state not enabled? */ 571 if ((mwait_substate + 1) > num_substates)
502 if (cpuidle_state_table[cstate].enter == NULL) {
503 /* does the driver not know about the state? */
504 if (*cpuidle_state_table[cstate].name == '\0')
505 pr_debug(PREFIX "unaware of model 0x%x"
506 " MWAIT %d please"
507 " contact lenb@kernel.org\n",
508 boot_cpu_data.x86_model, cstate);
509 continue; 572 continue;
510 }
511 573
512 if ((cstate > 2) && 574 if (((mwait_cstate + 1) > 2) &&
513 !boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) 575 !boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
514 mark_tsc_unstable("TSC halts in idle" 576 mark_tsc_unstable("TSC halts in idle"
515 " states deeper than C2"); 577 " states deeper than C2");
@@ -523,6 +585,9 @@ static int intel_idle_cpuidle_driver_init(void)
523 if (icpu->auto_demotion_disable_flags) 585 if (icpu->auto_demotion_disable_flags)
524 on_each_cpu(auto_demotion_disable, NULL, 1); 586 on_each_cpu(auto_demotion_disable, NULL, 1);
525 587
588 if (icpu->disable_promotion_to_c1e) /* each-cpu is redundant */
589 on_each_cpu(c1e_promotion_disable, NULL, 1);
590
526 return 0; 591 return 0;
527} 592}
528 593
@@ -541,25 +606,28 @@ static int intel_idle_cpu_init(int cpu)
541 606
542 dev->state_count = 1; 607 dev->state_count = 1;
543 608
544 for (cstate = 1; cstate < MWAIT_MAX_NUM_CSTATES; ++cstate) { 609 for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
545 int num_substates; 610 int num_substates, mwait_hint, mwait_cstate, mwait_substate;
611
612 if (cpuidle_state_table[cstate].enter == NULL)
613 continue;
546 614
547 if (cstate > max_cstate) { 615 if (cstate + 1 > max_cstate) {
548 printk(PREFIX "max_cstate %d reached\n", max_cstate); 616 printk(PREFIX "max_cstate %d reached\n", max_cstate);
549 break; 617 break;
550 } 618 }
551 619
620 mwait_hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
621 mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint);
622 mwait_substate = MWAIT_HINT2SUBSTATE(mwait_hint);
623
552 /* does the state exist in CPUID.MWAIT? */ 624 /* does the state exist in CPUID.MWAIT? */
553 num_substates = (mwait_substates >> ((cstate) * 4)) 625 num_substates = (mwait_substates >> ((mwait_cstate + 1) * 4))
554 & MWAIT_SUBSTATE_MASK; 626 & MWAIT_SUBSTATE_MASK;
555 if (num_substates == 0)
556 continue;
557 /* is the state not enabled? */
558 if (cpuidle_state_table[cstate].enter == NULL)
559 continue;
560 627
561 dev->states_usage[dev->state_count].driver_data = 628 /* if sub-state in table is not enumerated by CPUID */
562 (void *)get_driver_data(cstate); 629 if ((mwait_substate + 1) > num_substates)
630 continue;
563 631
564 dev->state_count += 1; 632 dev->state_count += 1;
565 } 633 }
diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c
index 26f13131639a..5d4402365a52 100644
--- a/drivers/input/misc/atlas_btns.c
+++ b/drivers/input/misc/atlas_btns.c
@@ -121,7 +121,7 @@ static int atlas_acpi_button_add(struct acpi_device *device)
121 return err; 121 return err;
122} 122}
123 123
124static int atlas_acpi_button_remove(struct acpi_device *device, int type) 124static int atlas_acpi_button_remove(struct acpi_device *device)
125{ 125{
126 acpi_status status; 126 acpi_status status;
127 127
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
new file mode 100644
index 000000000000..9545c9f03809
--- /dev/null
+++ b/drivers/mailbox/Kconfig
@@ -0,0 +1,19 @@
1menuconfig MAILBOX
2 bool "Mailbox Hardware Support"
3 help
4 Mailbox is a framework to control hardware communication between
5 on-chip processors through queued messages and interrupt driven
6 signals. Say Y if your platform supports hardware mailboxes.
7
8if MAILBOX
9config PL320_MBOX
10 bool "ARM PL320 Mailbox"
11 depends on ARM_AMBA
12 help
13 An implementation of the ARM PL320 Interprocessor Communication
14 Mailbox (IPCM), tailored for the Calxeda Highbank. It is used to
15 send short messages between Highbank's A9 cores and the EnergyCore
16 Management Engine, primarily for cpufreq. Say Y here if you want
17 to use the PL320 IPCM support.
18
19endif
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
new file mode 100644
index 000000000000..543ad6a79505
--- /dev/null
+++ b/drivers/mailbox/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_PL320_MBOX) += pl320-ipc.o
diff --git a/drivers/mailbox/pl320-ipc.c b/drivers/mailbox/pl320-ipc.c
new file mode 100644
index 000000000000..c45b3aedafba
--- /dev/null
+++ b/drivers/mailbox/pl320-ipc.c
@@ -0,0 +1,199 @@
1/*
2 * Copyright 2012 Calxeda, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include <linux/types.h>
17#include <linux/err.h>
18#include <linux/delay.h>
19#include <linux/export.h>
20#include <linux/io.h>
21#include <linux/interrupt.h>
22#include <linux/completion.h>
23#include <linux/mutex.h>
24#include <linux/notifier.h>
25#include <linux/spinlock.h>
26#include <linux/device.h>
27#include <linux/amba/bus.h>
28
29#include <linux/mailbox.h>
30
31#define IPCMxSOURCE(m) ((m) * 0x40)
32#define IPCMxDSET(m) (((m) * 0x40) + 0x004)
33#define IPCMxDCLEAR(m) (((m) * 0x40) + 0x008)
34#define IPCMxDSTATUS(m) (((m) * 0x40) + 0x00C)
35#define IPCMxMODE(m) (((m) * 0x40) + 0x010)
36#define IPCMxMSET(m) (((m) * 0x40) + 0x014)
37#define IPCMxMCLEAR(m) (((m) * 0x40) + 0x018)
38#define IPCMxMSTATUS(m) (((m) * 0x40) + 0x01C)
39#define IPCMxSEND(m) (((m) * 0x40) + 0x020)
40#define IPCMxDR(m, dr) (((m) * 0x40) + ((dr) * 4) + 0x024)
41
42#define IPCMMIS(irq) (((irq) * 8) + 0x800)
43#define IPCMRIS(irq) (((irq) * 8) + 0x804)
44
45#define MBOX_MASK(n) (1 << (n))
46#define IPC_TX_MBOX 1
47#define IPC_RX_MBOX 2
48
49#define CHAN_MASK(n) (1 << (n))
50#define A9_SOURCE 1
51#define M3_SOURCE 0
52
53static void __iomem *ipc_base;
54static int ipc_irq;
55static DEFINE_MUTEX(ipc_m1_lock);
56static DECLARE_COMPLETION(ipc_completion);
57static ATOMIC_NOTIFIER_HEAD(ipc_notifier);
58
59static inline void set_destination(int source, int mbox)
60{
61 __raw_writel(CHAN_MASK(source), ipc_base + IPCMxDSET(mbox));
62 __raw_writel(CHAN_MASK(source), ipc_base + IPCMxMSET(mbox));
63}
64
65static inline void clear_destination(int source, int mbox)
66{
67 __raw_writel(CHAN_MASK(source), ipc_base + IPCMxDCLEAR(mbox));
68 __raw_writel(CHAN_MASK(source), ipc_base + IPCMxMCLEAR(mbox));
69}
70
71static void __ipc_send(int mbox, u32 *data)
72{
73 int i;
74 for (i = 0; i < 7; i++)
75 __raw_writel(data[i], ipc_base + IPCMxDR(mbox, i));
76 __raw_writel(0x1, ipc_base + IPCMxSEND(mbox));
77}
78
79static u32 __ipc_rcv(int mbox, u32 *data)
80{
81 int i;
82 for (i = 0; i < 7; i++)
83 data[i] = __raw_readl(ipc_base + IPCMxDR(mbox, i));
84 return data[1];
85}
86
87/* blocking implmentation from the A9 side, not usuable in interrupts! */
88int pl320_ipc_transmit(u32 *data)
89{
90 int ret;
91
92 mutex_lock(&ipc_m1_lock);
93
94 init_completion(&ipc_completion);
95 __ipc_send(IPC_TX_MBOX, data);
96 ret = wait_for_completion_timeout(&ipc_completion,
97 msecs_to_jiffies(1000));
98 if (ret == 0) {
99 ret = -ETIMEDOUT;
100 goto out;
101 }
102
103 ret = __ipc_rcv(IPC_TX_MBOX, data);
104out:
105 mutex_unlock(&ipc_m1_lock);
106 return ret;
107}
108EXPORT_SYMBOL_GPL(pl320_ipc_transmit);
109
110static irqreturn_t ipc_handler(int irq, void *dev)
111{
112 u32 irq_stat;
113 u32 data[7];
114
115 irq_stat = __raw_readl(ipc_base + IPCMMIS(1));
116 if (irq_stat & MBOX_MASK(IPC_TX_MBOX)) {
117 __raw_writel(0, ipc_base + IPCMxSEND(IPC_TX_MBOX));
118 complete(&ipc_completion);
119 }
120 if (irq_stat & MBOX_MASK(IPC_RX_MBOX)) {
121 __ipc_rcv(IPC_RX_MBOX, data);
122 atomic_notifier_call_chain(&ipc_notifier, data[0], data + 1);
123 __raw_writel(2, ipc_base + IPCMxSEND(IPC_RX_MBOX));
124 }
125
126 return IRQ_HANDLED;
127}
128
129int pl320_ipc_register_notifier(struct notifier_block *nb)
130{
131 return atomic_notifier_chain_register(&ipc_notifier, nb);
132}
133EXPORT_SYMBOL_GPL(pl320_ipc_register_notifier);
134
135int pl320_ipc_unregister_notifier(struct notifier_block *nb)
136{
137 return atomic_notifier_chain_unregister(&ipc_notifier, nb);
138}
139EXPORT_SYMBOL_GPL(pl320_ipc_unregister_notifier);
140
141static int __init pl320_probe(struct amba_device *adev,
142 const struct amba_id *id)
143{
144 int ret;
145
146 ipc_base = ioremap(adev->res.start, resource_size(&adev->res));
147 if (ipc_base == NULL)
148 return -ENOMEM;
149
150 __raw_writel(0, ipc_base + IPCMxSEND(IPC_TX_MBOX));
151
152 ipc_irq = adev->irq[0];
153 ret = request_irq(ipc_irq, ipc_handler, 0, dev_name(&adev->dev), NULL);
154 if (ret < 0)
155 goto err;
156
157 /* Init slow mailbox */
158 __raw_writel(CHAN_MASK(A9_SOURCE),
159 ipc_base + IPCMxSOURCE(IPC_TX_MBOX));
160 __raw_writel(CHAN_MASK(M3_SOURCE),
161 ipc_base + IPCMxDSET(IPC_TX_MBOX));
162 __raw_writel(CHAN_MASK(M3_SOURCE) | CHAN_MASK(A9_SOURCE),
163 ipc_base + IPCMxMSET(IPC_TX_MBOX));
164
165 /* Init receive mailbox */
166 __raw_writel(CHAN_MASK(M3_SOURCE),
167 ipc_base + IPCMxSOURCE(IPC_RX_MBOX));
168 __raw_writel(CHAN_MASK(A9_SOURCE),
169 ipc_base + IPCMxDSET(IPC_RX_MBOX));
170 __raw_writel(CHAN_MASK(M3_SOURCE) | CHAN_MASK(A9_SOURCE),
171 ipc_base + IPCMxMSET(IPC_RX_MBOX));
172
173 return 0;
174err:
175 iounmap(ipc_base);
176 return ret;
177}
178
179static struct amba_id pl320_ids[] = {
180 {
181 .id = 0x00041320,
182 .mask = 0x000fffff,
183 },
184 { 0, 0 },
185};
186
187static struct amba_driver pl320_driver = {
188 .drv = {
189 .name = "pl320",
190 },
191 .id_table = pl320_ids,
192 .probe = pl320_probe,
193};
194
195static int __init ipc_init(void)
196{
197 return amba_driver_register(&pl320_driver);
198}
199module_init(ipc_init);
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 3d6d4fd1e3c5..a951c22921d1 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -734,34 +734,24 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
734 */ 734 */
735static int acpiphp_bus_add(struct acpiphp_func *func) 735static int acpiphp_bus_add(struct acpiphp_func *func)
736{ 736{
737 acpi_handle phandle; 737 struct acpi_device *device;
738 struct acpi_device *device, *pdevice;
739 int ret_val; 738 int ret_val;
740 739
741 acpi_get_parent(func->handle, &phandle);
742 if (acpi_bus_get_device(phandle, &pdevice)) {
743 dbg("no parent device, assuming NULL\n");
744 pdevice = NULL;
745 }
746 if (!acpi_bus_get_device(func->handle, &device)) { 740 if (!acpi_bus_get_device(func->handle, &device)) {
747 dbg("bus exists... trim\n"); 741 dbg("bus exists... trim\n");
748 /* this shouldn't be in here, so remove 742 /* this shouldn't be in here, so remove
749 * the bus then re-add it... 743 * the bus then re-add it...
750 */ 744 */
751 ret_val = acpi_bus_trim(device, 1); 745 acpi_bus_trim(device);
752 dbg("acpi_bus_trim return %x\n", ret_val);
753 } 746 }
754 747
755 ret_val = acpi_bus_add(&device, pdevice, func->handle, 748 ret_val = acpi_bus_scan(func->handle);
756 ACPI_BUS_TYPE_DEVICE); 749 if (!ret_val)
757 if (ret_val) { 750 ret_val = acpi_bus_get_device(func->handle, &device);
758 dbg("error adding bus, %x\n", 751
759 -ret_val); 752 if (ret_val)
760 goto acpiphp_bus_add_out; 753 dbg("error adding bus, %x\n", -ret_val);
761 }
762 ret_val = acpi_bus_start(device);
763 754
764acpiphp_bus_add_out:
765 return ret_val; 755 return ret_val;
766} 756}
767 757
@@ -781,11 +771,8 @@ static int acpiphp_bus_trim(acpi_handle handle)
781 return retval; 771 return retval;
782 } 772 }
783 773
784 retval = acpi_bus_trim(device, 1); 774 acpi_bus_trim(device);
785 if (retval) 775 return 0;
786 err("cannot remove from acpi list\n");
787
788 return retval;
789} 776}
790 777
791static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) 778static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
@@ -1130,8 +1117,7 @@ static int acpiphp_configure_bridge (acpi_handle handle)
1130 1117
1131static void handle_bridge_insertion(acpi_handle handle, u32 type) 1118static void handle_bridge_insertion(acpi_handle handle, u32 type)
1132{ 1119{
1133 struct acpi_device *device, *pdevice; 1120 struct acpi_device *device;
1134 acpi_handle phandle;
1135 1121
1136 if ((type != ACPI_NOTIFY_BUS_CHECK) && 1122 if ((type != ACPI_NOTIFY_BUS_CHECK) &&
1137 (type != ACPI_NOTIFY_DEVICE_CHECK)) { 1123 (type != ACPI_NOTIFY_DEVICE_CHECK)) {
@@ -1139,17 +1125,15 @@ static void handle_bridge_insertion(acpi_handle handle, u32 type)
1139 return; 1125 return;
1140 } 1126 }
1141 1127
1142 acpi_get_parent(handle, &phandle); 1128 if (acpi_bus_scan(handle)) {
1143 if (acpi_bus_get_device(phandle, &pdevice)) {
1144 dbg("no parent device, assuming NULL\n");
1145 pdevice = NULL;
1146 }
1147 if (acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE)) {
1148 err("cannot add bridge to acpi list\n"); 1129 err("cannot add bridge to acpi list\n");
1149 return; 1130 return;
1150 } 1131 }
1151 if (!acpiphp_configure_bridge(handle) && 1132 if (acpi_bus_get_device(handle, &device)) {
1152 !acpi_bus_start(device)) 1133 err("ACPI device object missing\n");
1134 return;
1135 }
1136 if (!acpiphp_configure_bridge(handle))
1153 add_bridge(handle); 1137 add_bridge(handle);
1154 else 1138 else
1155 err("cannot configure and start bridge\n"); 1139 err("cannot configure and start bridge\n");
@@ -1234,6 +1218,8 @@ static void _handle_hotplug_event_bridge(struct work_struct *work)
1234 handle = hp_work->handle; 1218 handle = hp_work->handle;
1235 type = hp_work->type; 1219 type = hp_work->type;
1236 1220
1221 acpi_scan_lock_acquire();
1222
1237 if (acpi_bus_get_device(handle, &device)) { 1223 if (acpi_bus_get_device(handle, &device)) {
1238 /* This bridge must have just been physically inserted */ 1224 /* This bridge must have just been physically inserted */
1239 handle_bridge_insertion(handle, type); 1225 handle_bridge_insertion(handle, type);
@@ -1311,6 +1297,7 @@ static void _handle_hotplug_event_bridge(struct work_struct *work)
1311 } 1297 }
1312 1298
1313out: 1299out:
1300 acpi_scan_lock_release();
1314 kfree(hp_work); /* allocated in handle_hotplug_event_bridge */ 1301 kfree(hp_work); /* allocated in handle_hotplug_event_bridge */
1315} 1302}
1316 1303
@@ -1357,6 +1344,8 @@ static void _handle_hotplug_event_func(struct work_struct *work)
1357 1344
1358 func = (struct acpiphp_func *)context; 1345 func = (struct acpiphp_func *)context;
1359 1346
1347 acpi_scan_lock_acquire();
1348
1360 switch (type) { 1349 switch (type) {
1361 case ACPI_NOTIFY_BUS_CHECK: 1350 case ACPI_NOTIFY_BUS_CHECK:
1362 /* bus re-enumerate */ 1351 /* bus re-enumerate */
@@ -1387,6 +1376,7 @@ static void _handle_hotplug_event_func(struct work_struct *work)
1387 break; 1376 break;
1388 } 1377 }
1389 1378
1379 acpi_scan_lock_release();
1390 kfree(hp_work); /* allocated in handle_hotplug_event_func */ 1380 kfree(hp_work); /* allocated in handle_hotplug_event_func */
1391} 1381}
1392 1382
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index f64ca92253da..574421bc2fa6 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -412,7 +412,6 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
412 if (SN_ACPI_BASE_SUPPORT() && ssdt) { 412 if (SN_ACPI_BASE_SUPPORT() && ssdt) {
413 unsigned long long adr; 413 unsigned long long adr;
414 struct acpi_device *pdevice; 414 struct acpi_device *pdevice;
415 struct acpi_device *device;
416 acpi_handle phandle; 415 acpi_handle phandle;
417 acpi_handle chandle = NULL; 416 acpi_handle chandle = NULL;
418 acpi_handle rethandle; 417 acpi_handle rethandle;
@@ -426,6 +425,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
426 pdevice = NULL; 425 pdevice = NULL;
427 } 426 }
428 427
428 acpi_scan_lock_acquire();
429 /* 429 /*
430 * Walk the rootbus node's immediate children looking for 430 * Walk the rootbus node's immediate children looking for
431 * the slot's device node(s). There can be more than 431 * the slot's device node(s). There can be more than
@@ -448,20 +448,18 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
448 if (ACPI_SUCCESS(ret) && 448 if (ACPI_SUCCESS(ret) &&
449 (adr>>16) == (slot->device_num + 1)) { 449 (adr>>16) == (slot->device_num + 1)) {
450 450
451 ret = acpi_bus_add(&device, pdevice, chandle, 451 ret = acpi_bus_scan(chandle);
452 ACPI_BUS_TYPE_DEVICE);
453 if (ACPI_FAILURE(ret)) { 452 if (ACPI_FAILURE(ret)) {
454 printk(KERN_ERR "%s: acpi_bus_add " 453 printk(KERN_ERR "%s: acpi_bus_scan "
455 "failed (0x%x) for slot %d " 454 "failed (0x%x) for slot %d "
456 "func %d\n", __func__, 455 "func %d\n", __func__,
457 ret, (int)(adr>>16), 456 ret, (int)(adr>>16),
458 (int)(adr&0xffff)); 457 (int)(adr&0xffff));
459 /* try to continue on */ 458 /* try to continue on */
460 } else {
461 acpi_bus_start(device);
462 } 459 }
463 } 460 }
464 } 461 }
462 acpi_scan_lock_release();
465 } 463 }
466 464
467 /* Call the driver for the new device */ 465 /* Call the driver for the new device */
@@ -512,6 +510,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot)
512 /* Get the rootbus node pointer */ 510 /* Get the rootbus node pointer */
513 phandle = PCI_CONTROLLER(slot->pci_bus)->acpi_handle; 511 phandle = PCI_CONTROLLER(slot->pci_bus)->acpi_handle;
514 512
513 acpi_scan_lock_acquire();
515 /* 514 /*
516 * Walk the rootbus node's immediate children looking for 515 * Walk the rootbus node's immediate children looking for
517 * the slot's device node(s). There can be more than 516 * the slot's device node(s). There can be more than
@@ -539,10 +538,10 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot)
539 ret = acpi_bus_get_device(chandle, 538 ret = acpi_bus_get_device(chandle,
540 &device); 539 &device);
541 if (ACPI_SUCCESS(ret)) 540 if (ACPI_SUCCESS(ret))
542 acpi_bus_trim(device, 1); 541 acpi_bus_trim(device);
543 } 542 }
544 } 543 }
545 544 acpi_scan_lock_release();
546 } 545 }
547 546
548 /* Free the SN resources assigned to the Linux device.*/ 547 /* Free the SN resources assigned to the Linux device.*/
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 1af4008182fd..e407c61559ca 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -283,7 +283,6 @@ static struct pci_platform_pm_ops acpi_pci_platform_pm = {
283 .is_manageable = acpi_pci_power_manageable, 283 .is_manageable = acpi_pci_power_manageable,
284 .set_state = acpi_pci_set_power_state, 284 .set_state = acpi_pci_set_power_state,
285 .choose_state = acpi_pci_choose_state, 285 .choose_state = acpi_pci_choose_state,
286 .can_wakeup = acpi_pci_can_wakeup,
287 .sleep_wake = acpi_pci_sleep_wake, 286 .sleep_wake = acpi_pci_sleep_wake,
288 .run_wake = acpi_pci_run_wake, 287 .run_wake = acpi_pci_run_wake,
289}; 288};
@@ -321,10 +320,65 @@ static int acpi_pci_find_root_bridge(struct device *dev, acpi_handle *handle)
321 return 0; 320 return 0;
322} 321}
323 322
323static void pci_acpi_setup(struct device *dev)
324{
325 struct pci_dev *pci_dev = to_pci_dev(dev);
326 acpi_handle handle = ACPI_HANDLE(dev);
327 struct acpi_device *adev;
328 acpi_status status;
329 acpi_handle dummy;
330
331 /*
332 * Evaluate and parse _PRT, if exists. This code allows parsing of
333 * _PRT objects within the scope of non-bridge devices. Note that
334 * _PRTs within the scope of a PCI bridge assume the bridge's
335 * subordinate bus number.
336 *
337 * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?
338 */
339 status = acpi_get_handle(handle, METHOD_NAME__PRT, &dummy);
340 if (ACPI_SUCCESS(status)) {
341 unsigned char bus;
342
343 bus = pci_dev->subordinate ?
344 pci_dev->subordinate->number : pci_dev->bus->number;
345 acpi_pci_irq_add_prt(handle, pci_domain_nr(pci_dev->bus), bus);
346 }
347
348 if (acpi_bus_get_device(handle, &adev) || !adev->wakeup.flags.valid)
349 return;
350
351 device_set_wakeup_capable(dev, true);
352 acpi_pci_sleep_wake(pci_dev, false);
353
354 pci_acpi_add_pm_notifier(adev, pci_dev);
355 if (adev->wakeup.flags.run_wake)
356 device_set_run_wake(dev, true);
357}
358
359static void pci_acpi_cleanup(struct device *dev)
360{
361 struct pci_dev *pci_dev = to_pci_dev(dev);
362 acpi_handle handle = ACPI_HANDLE(dev);
363 struct acpi_device *adev;
364
365 if (!acpi_bus_get_device(handle, &adev) && adev->wakeup.flags.valid) {
366 device_set_wakeup_capable(dev, false);
367 device_set_run_wake(dev, false);
368 pci_acpi_remove_pm_notifier(adev);
369 }
370
371 if (pci_dev->subordinate)
372 acpi_pci_irq_del_prt(pci_domain_nr(pci_dev->bus),
373 pci_dev->subordinate->number);
374}
375
324static struct acpi_bus_type acpi_pci_bus = { 376static struct acpi_bus_type acpi_pci_bus = {
325 .bus = &pci_bus_type, 377 .bus = &pci_bus_type,
326 .find_device = acpi_pci_find_device, 378 .find_device = acpi_pci_find_device,
327 .find_bridge = acpi_pci_find_root_bridge, 379 .find_bridge = acpi_pci_find_root_bridge,
380 .setup = pci_acpi_setup,
381 .cleanup = pci_acpi_cleanup,
328}; 382};
329 383
330static int __init acpi_pci_init(void) 384static int __init acpi_pci_init(void)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 5cb5820fae40..0c4f641b7be1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -450,7 +450,7 @@ static struct pci_platform_pm_ops *pci_platform_pm;
450int pci_set_platform_pm(struct pci_platform_pm_ops *ops) 450int pci_set_platform_pm(struct pci_platform_pm_ops *ops)
451{ 451{
452 if (!ops->is_manageable || !ops->set_state || !ops->choose_state 452 if (!ops->is_manageable || !ops->set_state || !ops->choose_state
453 || !ops->sleep_wake || !ops->can_wakeup) 453 || !ops->sleep_wake)
454 return -EINVAL; 454 return -EINVAL;
455 pci_platform_pm = ops; 455 pci_platform_pm = ops;
456 return 0; 456 return 0;
@@ -473,11 +473,6 @@ static inline pci_power_t platform_pci_choose_state(struct pci_dev *dev)
473 pci_platform_pm->choose_state(dev) : PCI_POWER_ERROR; 473 pci_platform_pm->choose_state(dev) : PCI_POWER_ERROR;
474} 474}
475 475
476static inline bool platform_pci_can_wakeup(struct pci_dev *dev)
477{
478 return pci_platform_pm ? pci_platform_pm->can_wakeup(dev) : false;
479}
480
481static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable) 476static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable)
482{ 477{
483 return pci_platform_pm ? 478 return pci_platform_pm ?
@@ -1985,25 +1980,6 @@ void pci_pm_init(struct pci_dev *dev)
1985 } 1980 }
1986} 1981}
1987 1982
1988/**
1989 * platform_pci_wakeup_init - init platform wakeup if present
1990 * @dev: PCI device
1991 *
1992 * Some devices don't have PCI PM caps but can still generate wakeup
1993 * events through platform methods (like ACPI events). If @dev supports
1994 * platform wakeup events, set the device flag to indicate as much. This
1995 * may be redundant if the device also supports PCI PM caps, but double
1996 * initialization should be safe in that case.
1997 */
1998void platform_pci_wakeup_init(struct pci_dev *dev)
1999{
2000 if (!platform_pci_can_wakeup(dev))
2001 return;
2002
2003 device_set_wakeup_capable(&dev->dev, true);
2004 platform_pci_sleep_wake(dev, false);
2005}
2006
2007static void pci_add_saved_cap(struct pci_dev *pci_dev, 1983static void pci_add_saved_cap(struct pci_dev *pci_dev,
2008 struct pci_cap_saved_state *new_cap) 1984 struct pci_cap_saved_state *new_cap)
2009{ 1985{
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index e8518292826f..adfd172c5b9b 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -43,9 +43,6 @@ int pci_probe_reset_function(struct pci_dev *dev);
43 * platform; to be used during system-wide transitions from a 43 * platform; to be used during system-wide transitions from a
44 * sleeping state to the working state and vice versa 44 * sleeping state to the working state and vice versa
45 * 45 *
46 * @can_wakeup: returns 'true' if given device is capable of waking up the
47 * system from a sleeping state
48 *
49 * @sleep_wake: enables/disables the system wake up capability of given device 46 * @sleep_wake: enables/disables the system wake up capability of given device
50 * 47 *
51 * @run_wake: enables/disables the platform to generate run-time wake-up events 48 * @run_wake: enables/disables the platform to generate run-time wake-up events
@@ -59,7 +56,6 @@ struct pci_platform_pm_ops {
59 bool (*is_manageable)(struct pci_dev *dev); 56 bool (*is_manageable)(struct pci_dev *dev);
60 int (*set_state)(struct pci_dev *dev, pci_power_t state); 57 int (*set_state)(struct pci_dev *dev, pci_power_t state);
61 pci_power_t (*choose_state)(struct pci_dev *dev); 58 pci_power_t (*choose_state)(struct pci_dev *dev);
62 bool (*can_wakeup)(struct pci_dev *dev);
63 int (*sleep_wake)(struct pci_dev *dev, bool enable); 59 int (*sleep_wake)(struct pci_dev *dev, bool enable);
64 int (*run_wake)(struct pci_dev *dev, bool enable); 60 int (*run_wake)(struct pci_dev *dev, bool enable);
65}; 61};
@@ -74,7 +70,6 @@ extern void pci_wakeup_bus(struct pci_bus *bus);
74extern void pci_config_pm_runtime_get(struct pci_dev *dev); 70extern void pci_config_pm_runtime_get(struct pci_dev *dev);
75extern void pci_config_pm_runtime_put(struct pci_dev *dev); 71extern void pci_config_pm_runtime_put(struct pci_dev *dev);
76extern void pci_pm_init(struct pci_dev *dev); 72extern void pci_pm_init(struct pci_dev *dev);
77extern void platform_pci_wakeup_init(struct pci_dev *dev);
78extern void pci_allocate_cap_save_buffers(struct pci_dev *dev); 73extern void pci_allocate_cap_save_buffers(struct pci_dev *dev);
79void pci_free_cap_save_buffers(struct pci_dev *dev); 74void pci_free_cap_save_buffers(struct pci_dev *dev);
80 75
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6186f03d84f3..2dcd22d9c816 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1280,7 +1280,6 @@ static void pci_init_capabilities(struct pci_dev *dev)
1280 1280
1281 /* Power Management */ 1281 /* Power Management */
1282 pci_pm_init(dev); 1282 pci_pm_init(dev);
1283 platform_pci_wakeup_init(dev);
1284 1283
1285 /* Vital Product Data */ 1284 /* Vital Product Data */
1286 pci_vpd_pci22_init(dev); 1285 pci_vpd_pci22_init(dev);
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index fcde4e528819..d9f9a0dbc6f3 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -1910,7 +1910,7 @@ fail_platform:
1910 return result; 1910 return result;
1911} 1911}
1912 1912
1913static int asus_acpi_remove(struct acpi_device *device, int type) 1913static int asus_acpi_remove(struct acpi_device *device)
1914{ 1914{
1915 struct asus_laptop *asus = acpi_driver_data(device); 1915 struct asus_laptop *asus = acpi_driver_data(device);
1916 1916
diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index c87ff16873f9..36e5e6c13db4 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -432,7 +432,7 @@ failed_sensitivity:
432 return error; 432 return error;
433} 433}
434 434
435static int cmpc_accel_remove_v4(struct acpi_device *acpi, int type) 435static int cmpc_accel_remove_v4(struct acpi_device *acpi)
436{ 436{
437 struct input_dev *inputdev; 437 struct input_dev *inputdev;
438 struct cmpc_accel *accel; 438 struct cmpc_accel *accel;
@@ -668,7 +668,7 @@ failed_file:
668 return error; 668 return error;
669} 669}
670 670
671static int cmpc_accel_remove(struct acpi_device *acpi, int type) 671static int cmpc_accel_remove(struct acpi_device *acpi)
672{ 672{
673 struct input_dev *inputdev; 673 struct input_dev *inputdev;
674 struct cmpc_accel *accel; 674 struct cmpc_accel *accel;
@@ -753,7 +753,7 @@ static int cmpc_tablet_add(struct acpi_device *acpi)
753 cmpc_tablet_idev_init); 753 cmpc_tablet_idev_init);
754} 754}
755 755
756static int cmpc_tablet_remove(struct acpi_device *acpi, int type) 756static int cmpc_tablet_remove(struct acpi_device *acpi)
757{ 757{
758 return cmpc_remove_acpi_notify_device(acpi); 758 return cmpc_remove_acpi_notify_device(acpi);
759} 759}
@@ -1000,7 +1000,7 @@ out_bd:
1000 return retval; 1000 return retval;
1001} 1001}
1002 1002
1003static int cmpc_ipml_remove(struct acpi_device *acpi, int type) 1003static int cmpc_ipml_remove(struct acpi_device *acpi)
1004{ 1004{
1005 struct ipml200_dev *ipml; 1005 struct ipml200_dev *ipml;
1006 1006
@@ -1079,7 +1079,7 @@ static int cmpc_keys_add(struct acpi_device *acpi)
1079 cmpc_keys_idev_init); 1079 cmpc_keys_idev_init);
1080} 1080}
1081 1081
1082static int cmpc_keys_remove(struct acpi_device *acpi, int type) 1082static int cmpc_keys_remove(struct acpi_device *acpi)
1083{ 1083{
1084 return cmpc_remove_acpi_notify_device(acpi); 1084 return cmpc_remove_acpi_notify_device(acpi);
1085} 1085}
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index a5da0b594f71..5d26e70bed6c 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -1501,7 +1501,7 @@ fail_platform:
1501 return result; 1501 return result;
1502} 1502}
1503 1503
1504static int eeepc_acpi_remove(struct acpi_device *device, int type) 1504static int eeepc_acpi_remove(struct acpi_device *device)
1505{ 1505{
1506 struct eeepc_laptop *eeepc = acpi_driver_data(device); 1506 struct eeepc_laptop *eeepc = acpi_driver_data(device);
1507 1507
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index c4c1a5444b38..1c9386e7c58c 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -733,7 +733,7 @@ err_stop:
733 return result; 733 return result;
734} 734}
735 735
736static int acpi_fujitsu_remove(struct acpi_device *device, int type) 736static int acpi_fujitsu_remove(struct acpi_device *device)
737{ 737{
738 struct fujitsu_t *fujitsu = acpi_driver_data(device); 738 struct fujitsu_t *fujitsu = acpi_driver_data(device);
739 struct input_dev *input = fujitsu->input; 739 struct input_dev *input = fujitsu->input;
@@ -938,7 +938,7 @@ err_stop:
938 return result; 938 return result;
939} 939}
940 940
941static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type) 941static int acpi_fujitsu_hotkey_remove(struct acpi_device *device)
942{ 942{
943 struct fujitsu_hotkey_t *fujitsu_hotkey = acpi_driver_data(device); 943 struct fujitsu_hotkey_t *fujitsu_hotkey = acpi_driver_data(device);
944 struct input_dev *input = fujitsu_hotkey->input; 944 struct input_dev *input = fujitsu_hotkey->input;
diff --git a/drivers/platform/x86/fujitsu-tablet.c b/drivers/platform/x86/fujitsu-tablet.c
index 174ca01c4aa7..570926c10014 100644
--- a/drivers/platform/x86/fujitsu-tablet.c
+++ b/drivers/platform/x86/fujitsu-tablet.c
@@ -431,7 +431,7 @@ static int acpi_fujitsu_add(struct acpi_device *adev)
431 return 0; 431 return 0;
432} 432}
433 433
434static int acpi_fujitsu_remove(struct acpi_device *adev, int type) 434static int acpi_fujitsu_remove(struct acpi_device *adev)
435{ 435{
436 free_irq(fujitsu.irq, fujitsu_interrupt); 436 free_irq(fujitsu.irq, fujitsu_interrupt);
437 release_region(fujitsu.io_base, fujitsu.io_length); 437 release_region(fujitsu.io_base, fujitsu.io_length);
diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
index 18d74f29dcb2..e64a7a870d42 100644
--- a/drivers/platform/x86/hp_accel.c
+++ b/drivers/platform/x86/hp_accel.c
@@ -337,7 +337,7 @@ static int lis3lv02d_add(struct acpi_device *device)
337 return ret; 337 return ret;
338} 338}
339 339
340static int lis3lv02d_remove(struct acpi_device *device, int type) 340static int lis3lv02d_remove(struct acpi_device *device)
341{ 341{
342 if (!device) 342 if (!device)
343 return -EINVAL; 343 return -EINVAL;
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 64bfb30a52e9..17f00b8dc5cb 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -834,7 +834,7 @@ platform_failed:
834 return ret; 834 return ret;
835} 835}
836 836
837static int ideapad_acpi_remove(struct acpi_device *adevice, int type) 837static int ideapad_acpi_remove(struct acpi_device *adevice)
838{ 838{
839 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev); 839 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
840 int i; 840 int i;
diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
index 3271ac85115e..d6cfc1558c2f 100644
--- a/drivers/platform/x86/intel_menlow.c
+++ b/drivers/platform/x86/intel_menlow.c
@@ -200,7 +200,7 @@ static int intel_menlow_memory_add(struct acpi_device *device)
200 200
201} 201}
202 202
203static int intel_menlow_memory_remove(struct acpi_device *device, int type) 203static int intel_menlow_memory_remove(struct acpi_device *device)
204{ 204{
205 struct thermal_cooling_device *cdev = acpi_driver_data(device); 205 struct thermal_cooling_device *cdev = acpi_driver_data(device);
206 206
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index 8e8caa767d6a..4add9a31bf60 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -176,7 +176,7 @@ enum SINF_BITS { SINF_NUM_BATTERIES = 0,
176/* R1 handles SINF_AC_CUR_BRIGHT as SINF_CUR_BRIGHT, doesn't know AC state */ 176/* R1 handles SINF_AC_CUR_BRIGHT as SINF_CUR_BRIGHT, doesn't know AC state */
177 177
178static int acpi_pcc_hotkey_add(struct acpi_device *device); 178static int acpi_pcc_hotkey_add(struct acpi_device *device);
179static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type); 179static int acpi_pcc_hotkey_remove(struct acpi_device *device);
180static void acpi_pcc_hotkey_notify(struct acpi_device *device, u32 event); 180static void acpi_pcc_hotkey_notify(struct acpi_device *device, u32 event);
181 181
182static const struct acpi_device_id pcc_device_ids[] = { 182static const struct acpi_device_id pcc_device_ids[] = {
@@ -663,7 +663,7 @@ static int __init acpi_pcc_init(void)
663 return 0; 663 return 0;
664} 664}
665 665
666static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type) 666static int acpi_pcc_hotkey_remove(struct acpi_device *device)
667{ 667{
668 struct pcc_acpi *pcc = acpi_driver_data(device); 668 struct pcc_acpi *pcc = acpi_driver_data(device);
669 669
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index b8ad71f7863f..ceb41eff4230 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -2740,7 +2740,7 @@ outwalk:
2740 return result; 2740 return result;
2741} 2741}
2742 2742
2743static int sony_nc_remove(struct acpi_device *device, int type) 2743static int sony_nc_remove(struct acpi_device *device)
2744{ 2744{
2745 struct sony_nc_value *item; 2745 struct sony_nc_value *item;
2746 2746
@@ -4111,7 +4111,7 @@ found:
4111 * ACPI driver 4111 * ACPI driver
4112 * 4112 *
4113 *****************/ 4113 *****************/
4114static int sony_pic_remove(struct acpi_device *device, int type) 4114static int sony_pic_remove(struct acpi_device *device)
4115{ 4115{
4116 struct sony_pic_ioport *io, *tmp_io; 4116 struct sony_pic_ioport *io, *tmp_io;
4117 struct sony_pic_irq *irq, *tmp_irq; 4117 struct sony_pic_irq *irq, *tmp_irq;
diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c
index d727bfee89a6..4ab618c63b45 100644
--- a/drivers/platform/x86/topstar-laptop.c
+++ b/drivers/platform/x86/topstar-laptop.c
@@ -157,7 +157,7 @@ add_err:
157 return -ENODEV; 157 return -ENODEV;
158} 158}
159 159
160static int acpi_topstar_remove(struct acpi_device *device, int type) 160static int acpi_topstar_remove(struct acpi_device *device)
161{ 161{
162 struct topstar_hkey *tps_hkey = acpi_driver_data(device); 162 struct topstar_hkey *tps_hkey = acpi_driver_data(device);
163 163
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index c2727895794c..904476b2fa8f 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1118,7 +1118,7 @@ static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev *dev)
1118 return 0; 1118 return 0;
1119} 1119}
1120 1120
1121static int toshiba_acpi_remove(struct acpi_device *acpi_dev, int type) 1121static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
1122{ 1122{
1123 struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); 1123 struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
1124 1124
@@ -1250,7 +1250,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
1250 return 0; 1250 return 0;
1251 1251
1252error: 1252error:
1253 toshiba_acpi_remove(acpi_dev, 0); 1253 toshiba_acpi_remove(acpi_dev);
1254 return ret; 1254 return ret;
1255} 1255}
1256 1256
diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c
index e95be0b74859..74dd01ae343b 100644
--- a/drivers/platform/x86/toshiba_bluetooth.c
+++ b/drivers/platform/x86/toshiba_bluetooth.c
@@ -32,7 +32,7 @@ MODULE_LICENSE("GPL");
32 32
33 33
34static int toshiba_bt_rfkill_add(struct acpi_device *device); 34static int toshiba_bt_rfkill_add(struct acpi_device *device);
35static int toshiba_bt_rfkill_remove(struct acpi_device *device, int type); 35static int toshiba_bt_rfkill_remove(struct acpi_device *device);
36static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event); 36static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event);
37 37
38static const struct acpi_device_id bt_device_ids[] = { 38static const struct acpi_device_id bt_device_ids[] = {
@@ -122,7 +122,7 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device)
122 return result; 122 return result;
123} 123}
124 124
125static int toshiba_bt_rfkill_remove(struct acpi_device *device, int type) 125static int toshiba_bt_rfkill_remove(struct acpi_device *device)
126{ 126{
127 /* clean up */ 127 /* clean up */
128 return 0; 128 return 0;
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 42a4dcc25f92..e4ac38aca580 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -92,7 +92,7 @@ module_param(debug_dump_wdg, bool, 0444);
92MODULE_PARM_DESC(debug_dump_wdg, 92MODULE_PARM_DESC(debug_dump_wdg,
93 "Dump available WMI interfaces [0/1]"); 93 "Dump available WMI interfaces [0/1]");
94 94
95static int acpi_wmi_remove(struct acpi_device *device, int type); 95static int acpi_wmi_remove(struct acpi_device *device);
96static int acpi_wmi_add(struct acpi_device *device); 96static int acpi_wmi_add(struct acpi_device *device);
97static void acpi_wmi_notify(struct acpi_device *device, u32 event); 97static void acpi_wmi_notify(struct acpi_device *device, u32 event);
98 98
@@ -917,7 +917,7 @@ static void acpi_wmi_notify(struct acpi_device *device, u32 event)
917 } 917 }
918} 918}
919 919
920static int acpi_wmi_remove(struct acpi_device *device, int type) 920static int acpi_wmi_remove(struct acpi_device *device)
921{ 921{
922 acpi_remove_address_space_handler(device->handle, 922 acpi_remove_address_space_handler(device->handle,
923 ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler); 923 ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler);
diff --git a/drivers/platform/x86/xo15-ebook.c b/drivers/platform/x86/xo15-ebook.c
index 16d340c3b852..4b1377bd5944 100644
--- a/drivers/platform/x86/xo15-ebook.c
+++ b/drivers/platform/x86/xo15-ebook.c
@@ -150,7 +150,7 @@ static int ebook_switch_add(struct acpi_device *device)
150 return error; 150 return error;
151} 151}
152 152
153static int ebook_switch_remove(struct acpi_device *device, int type) 153static int ebook_switch_remove(struct acpi_device *device)
154{ 154{
155 struct ebook_switch *button = acpi_driver_data(device); 155 struct ebook_switch *button = acpi_driver_data(device);
156 156
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 72e822e17d47..8813fc03aa09 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -90,7 +90,7 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
90 pnp_dbg(&dev->dev, "set resources\n"); 90 pnp_dbg(&dev->dev, "set resources\n");
91 91
92 handle = DEVICE_ACPI_HANDLE(&dev->dev); 92 handle = DEVICE_ACPI_HANDLE(&dev->dev);
93 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &acpi_dev))) { 93 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) {
94 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 94 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
95 return -ENODEV; 95 return -ENODEV;
96 } 96 }
@@ -123,7 +123,7 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
123 dev_dbg(&dev->dev, "disable resources\n"); 123 dev_dbg(&dev->dev, "disable resources\n");
124 124
125 handle = DEVICE_ACPI_HANDLE(&dev->dev); 125 handle = DEVICE_ACPI_HANDLE(&dev->dev);
126 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &acpi_dev))) { 126 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) {
127 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 127 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
128 return 0; 128 return 0;
129 } 129 }
@@ -145,7 +145,7 @@ static bool pnpacpi_can_wakeup(struct pnp_dev *dev)
145 acpi_handle handle; 145 acpi_handle handle;
146 146
147 handle = DEVICE_ACPI_HANDLE(&dev->dev); 147 handle = DEVICE_ACPI_HANDLE(&dev->dev);
148 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &acpi_dev))) { 148 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) {
149 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 149 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
150 return false; 150 return false;
151 } 151 }
@@ -160,7 +160,7 @@ static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
160 int error = 0; 160 int error = 0;
161 161
162 handle = DEVICE_ACPI_HANDLE(&dev->dev); 162 handle = DEVICE_ACPI_HANDLE(&dev->dev);
163 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &acpi_dev))) { 163 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) {
164 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 164 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
165 return 0; 165 return 0;
166 } 166 }
@@ -197,7 +197,7 @@ static int pnpacpi_resume(struct pnp_dev *dev)
197 acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev); 197 acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
198 int error = 0; 198 int error = 0;
199 199
200 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &acpi_dev))) { 200 if (!handle || acpi_bus_get_device(handle, &acpi_dev)) {
201 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); 201 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
202 return -ENODEV; 202 return -ENODEV;
203 } 203 }
diff --git a/drivers/pnp/pnpbios/Kconfig b/drivers/pnp/pnpbios/Kconfig
index b986d9fa3b9a..50c3dd065e03 100644
--- a/drivers/pnp/pnpbios/Kconfig
+++ b/drivers/pnp/pnpbios/Kconfig
@@ -2,8 +2,8 @@
2# Plug and Play BIOS configuration 2# Plug and Play BIOS configuration
3# 3#
4config PNPBIOS 4config PNPBIOS
5 bool "Plug and Play BIOS support (EXPERIMENTAL)" 5 bool "Plug and Play BIOS support"
6 depends on ISA && X86 && EXPERIMENTAL 6 depends on ISA && X86
7 default n 7 default n
8 ---help--- 8 ---help---
9 Linux uses the PNPBIOS as defined in "Plug and Play BIOS 9 Linux uses the PNPBIOS as defined in "Plug and Play BIOS
diff --git a/drivers/staging/quickstart/quickstart.c b/drivers/staging/quickstart/quickstart.c
index cac320738142..adb8da564cf6 100644
--- a/drivers/staging/quickstart/quickstart.c
+++ b/drivers/staging/quickstart/quickstart.c
@@ -296,7 +296,7 @@ fail_config:
296 return ret; 296 return ret;
297} 297}
298 298
299static int quickstart_acpi_remove(struct acpi_device *device, int type) 299static int quickstart_acpi_remove(struct acpi_device *device)
300{ 300{
301 acpi_status status; 301 acpi_status status;
302 struct quickstart_acpi *quickstart; 302 struct quickstart_acpi *quickstart;
diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c
index f088d4c07381..d84329676689 100644
--- a/drivers/video/backlight/apple_bl.c
+++ b/drivers/video/backlight/apple_bl.c
@@ -196,7 +196,7 @@ static int apple_bl_add(struct acpi_device *dev)
196 return 0; 196 return 0;
197} 197}
198 198
199static int apple_bl_remove(struct acpi_device *dev, int type) 199static int apple_bl_remove(struct acpi_device *dev)
200{ 200{
201 backlight_device_unregister(apple_backlight_device); 201 backlight_device_unregister(apple_backlight_device);
202 202
diff --git a/drivers/xen/xen-acpi-pad.c b/drivers/xen/xen-acpi-pad.c
index da39191e7278..c763479ed85e 100644
--- a/drivers/xen/xen-acpi-pad.c
+++ b/drivers/xen/xen-acpi-pad.c
@@ -140,8 +140,7 @@ static int acpi_pad_add(struct acpi_device *device)
140 return 0; 140 return 0;
141} 141}
142 142
143static int acpi_pad_remove(struct acpi_device *device, 143static int acpi_pad_remove(struct acpi_device *device)
144 int type)
145{ 144{
146 mutex_lock(&xen_cpu_lock); 145 mutex_lock(&xen_cpu_lock);
147 xen_acpi_pad_idle_cpus(0); 146 xen_acpi_pad_idle_cpus(0);
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 2df555c66d57..aec3d5c98c94 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -205,6 +205,48 @@ void sysfs_unmerge_group(struct kobject *kobj,
205} 205}
206EXPORT_SYMBOL_GPL(sysfs_unmerge_group); 206EXPORT_SYMBOL_GPL(sysfs_unmerge_group);
207 207
208/**
209 * sysfs_add_link_to_group - add a symlink to an attribute group.
210 * @kobj: The kobject containing the group.
211 * @group_name: The name of the group.
212 * @target: The target kobject of the symlink to create.
213 * @link_name: The name of the symlink to create.
214 */
215int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name,
216 struct kobject *target, const char *link_name)
217{
218 struct sysfs_dirent *dir_sd;
219 int error = 0;
220
221 dir_sd = sysfs_get_dirent(kobj->sd, NULL, group_name);
222 if (!dir_sd)
223 return -ENOENT;
224
225 error = sysfs_create_link_sd(dir_sd, target, link_name);
226 sysfs_put(dir_sd);
227
228 return error;
229}
230EXPORT_SYMBOL_GPL(sysfs_add_link_to_group);
231
232/**
233 * sysfs_remove_link_from_group - remove a symlink from an attribute group.
234 * @kobj: The kobject containing the group.
235 * @group_name: The name of the group.
236 * @link_name: The name of the symlink to remove.
237 */
238void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
239 const char *link_name)
240{
241 struct sysfs_dirent *dir_sd;
242
243 dir_sd = sysfs_get_dirent(kobj->sd, NULL, group_name);
244 if (dir_sd) {
245 sysfs_hash_and_remove(dir_sd, NULL, link_name);
246 sysfs_put(dir_sd);
247 }
248}
249EXPORT_SYMBOL_GPL(sysfs_remove_link_from_group);
208 250
209EXPORT_SYMBOL_GPL(sysfs_create_group); 251EXPORT_SYMBOL_GPL(sysfs_create_group);
210EXPORT_SYMBOL_GPL(sysfs_update_group); 252EXPORT_SYMBOL_GPL(sysfs_update_group);
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 3c9eb5624f5e..8c940df97a52 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -21,26 +21,17 @@
21 21
22#include "sysfs.h" 22#include "sysfs.h"
23 23
24static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target, 24static int sysfs_do_create_link_sd(struct sysfs_dirent *parent_sd,
25 const char *name, int warn) 25 struct kobject *target,
26 const char *name, int warn)
26{ 27{
27 struct sysfs_dirent *parent_sd = NULL;
28 struct sysfs_dirent *target_sd = NULL; 28 struct sysfs_dirent *target_sd = NULL;
29 struct sysfs_dirent *sd = NULL; 29 struct sysfs_dirent *sd = NULL;
30 struct sysfs_addrm_cxt acxt; 30 struct sysfs_addrm_cxt acxt;
31 enum kobj_ns_type ns_type; 31 enum kobj_ns_type ns_type;
32 int error; 32 int error;
33 33
34 BUG_ON(!name); 34 BUG_ON(!name || !parent_sd);
35
36 if (!kobj)
37 parent_sd = &sysfs_root;
38 else
39 parent_sd = kobj->sd;
40
41 error = -EFAULT;
42 if (!parent_sd)
43 goto out_put;
44 35
45 /* target->sd can go away beneath us but is protected with 36 /* target->sd can go away beneath us but is protected with
46 * sysfs_assoc_lock. Fetch target_sd from it. 37 * sysfs_assoc_lock. Fetch target_sd from it.
@@ -96,6 +87,34 @@ static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target,
96} 87}
97 88
98/** 89/**
90 * sysfs_create_link_sd - create symlink to a given object.
91 * @sd: directory we're creating the link in.
92 * @target: object we're pointing to.
93 * @name: name of the symlink.
94 */
95int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target,
96 const char *name)
97{
98 return sysfs_do_create_link_sd(sd, target, name, 1);
99}
100
101static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target,
102 const char *name, int warn)
103{
104 struct sysfs_dirent *parent_sd = NULL;
105
106 if (!kobj)
107 parent_sd = &sysfs_root;
108 else
109 parent_sd = kobj->sd;
110
111 if (!parent_sd)
112 return -EFAULT;
113
114 return sysfs_do_create_link_sd(parent_sd, target, name, warn);
115}
116
117/**
99 * sysfs_create_link - create symlink between two objects. 118 * sysfs_create_link - create symlink between two objects.
100 * @kobj: object whose directory we're creating the link in. 119 * @kobj: object whose directory we're creating the link in.
101 * @target: object we're pointing to. 120 * @target: object we're pointing to.
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index d73c0932bbd6..d1e4043eb0c3 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -240,3 +240,5 @@ void unmap_bin_file(struct sysfs_dirent *attr_sd);
240 * symlink.c 240 * symlink.c
241 */ 241 */
242extern const struct inode_operations sysfs_symlink_inode_operations; 242extern const struct inode_operations sysfs_symlink_inode_operations;
243int sysfs_create_link_sd(struct sysfs_dirent *sd, struct kobject *target,
244 const char *name);
diff --git a/include/acpi/acbuffer.h b/include/acpi/acbuffer.h
index a1e45cdd729a..c927a0b1de78 100644
--- a/include/acpi/acbuffer.h
+++ b/include/acpi/acbuffer.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index 0943457e0fa5..14ceff788c40 100644
--- a/include/acpi/acconfig.h
+++ b/include/acpi/acconfig.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -138,7 +138,7 @@
138 138
139/* Maximum sleep allowed via Sleep() operator */ 139/* Maximum sleep allowed via Sleep() operator */
140 140
141#define ACPI_MAX_SLEEP 2000 /* Two seconds */ 141#define ACPI_MAX_SLEEP 2000 /* 2000 millisec == two seconds */
142 142
143/* Address Range lists are per-space_id (Memory and I/O only) */ 143/* Address Range lists are per-space_id (Memory and I/O only) */
144 144
@@ -150,11 +150,6 @@
150 * 150 *
151 *****************************************************************************/ 151 *****************************************************************************/
152 152
153/* Number of distinct GPE register blocks and register width */
154
155#define ACPI_MAX_GPE_BLOCKS 2
156#define ACPI_GPE_REGISTER_WIDTH 8
157
158/* Method info (in WALK_STATE), containing local variables and argumetns */ 153/* Method info (in WALK_STATE), containing local variables and argumetns */
159 154
160#define ACPI_METHOD_NUM_LOCALS 8 155#define ACPI_METHOD_NUM_LOCALS 8
@@ -163,12 +158,6 @@
163#define ACPI_METHOD_NUM_ARGS 7 158#define ACPI_METHOD_NUM_ARGS 7
164#define ACPI_METHOD_MAX_ARG 6 159#define ACPI_METHOD_MAX_ARG 6
165 160
166/* Length of _HID, _UID, _CID, and UUID values */
167
168#define ACPI_DEVICE_ID_LENGTH 0x09
169#define ACPI_MAX_CID_LENGTH 48
170#define ACPI_UUID_LENGTH 16
171
172/* 161/*
173 * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG 162 * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG
174 */ 163 */
@@ -186,17 +175,6 @@
186 */ 175 */
187#define ACPI_RESULTS_OBJ_NUM_MAX 255 176#define ACPI_RESULTS_OBJ_NUM_MAX 255
188 177
189/* Names within the namespace are 4 bytes long */
190
191#define ACPI_NAME_SIZE 4
192#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */
193#define ACPI_PATH_SEPARATOR '.'
194
195/* Sizes for ACPI table headers */
196
197#define ACPI_OEM_ID_SIZE 6
198#define ACPI_OEM_TABLE_ID_SIZE 8
199
200/* Constants used in searching for the RSDP in low memory */ 178/* Constants used in searching for the RSDP in low memory */
201 179
202#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ 180#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */
@@ -213,6 +191,7 @@
213/* Maximum space_ids for Operation Regions */ 191/* Maximum space_ids for Operation Regions */
214 192
215#define ACPI_MAX_ADDRESS_SPACE 255 193#define ACPI_MAX_ADDRESS_SPACE 255
194#define ACPI_NUM_DEFAULT_SPACES 4
216 195
217/* Array sizes. Used for range checking also */ 196/* Array sizes. Used for range checking also */
218 197
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index 6c3890e02140..9bf59d0e8aaa 100644
--- a/include/acpi/acexcep.h
+++ b/include/acpi/acexcep.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h
index 7665df663284..ce08ef7d969c 100644
--- a/include/acpi/acnames.h
+++ b/include/acpi/acnames.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h
index 2457ac849655..9885276178e0 100644
--- a/include/acpi/acoutput.h
+++ b/include/acpi/acoutput.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -72,6 +72,7 @@
72#define ACPI_EXAMPLE 0x00004000 72#define ACPI_EXAMPLE 0x00004000
73#define ACPI_DRIVER 0x00008000 73#define ACPI_DRIVER 0x00008000
74#define DT_COMPILER 0x00010000 74#define DT_COMPILER 0x00010000
75#define ASL_PREPROCESSOR 0x00020000
75 76
76#define ACPI_ALL_COMPONENTS 0x0001FFFF 77#define ACPI_ALL_COMPONENTS 0x0001FFFF
77#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) 78#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS)
@@ -262,18 +263,140 @@
262 * Common parameters used for debug output functions: 263 * Common parameters used for debug output functions:
263 * line number, function name, module(file) name, component ID 264 * line number, function name, module(file) name, component ID
264 */ 265 */
265#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT 266#define ACPI_DEBUG_PARAMETERS \
267 __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT
268
269/* Check if debug output is currently dynamically enabled */
270
271#define ACPI_IS_DEBUG_ENABLED(level, component) \
272 ((level & acpi_dbg_level) && (component & acpi_dbg_layer))
266 273
267/* 274/*
268 * Master debug print macros 275 * Master debug print macros
269 * Print message if and only if: 276 * Print message if and only if:
270 * 1) Debug print for the current component is enabled 277 * 1) Debug print for the current component is enabled
271 * 2) Debug error level or trace level for the print statement is enabled 278 * 2) Debug error level or trace level for the print statement is enabled
279 *
280 * November 2012: Moved the runtime check for whether to actually emit the
281 * debug message outside of the print function itself. This improves overall
282 * performance at a relatively small code cost. Implementation involves the
283 * use of variadic macros supported by C99.
284 *
285 * Note: the ACPI_DO_WHILE0 macro is used to prevent some compilers from
286 * complaining about these constructs. On other compilers the do...while
287 * adds some extra code, so this feature is optional.
272 */ 288 */
273#define ACPI_DEBUG_PRINT(plist) acpi_debug_print plist 289#ifdef ACPI_USE_DO_WHILE_0
274#define ACPI_DEBUG_PRINT_RAW(plist) acpi_debug_print_raw plist 290#define ACPI_DO_WHILE0(a) do a while(0)
275
276#else 291#else
292#define ACPI_DO_WHILE0(a) a
293#endif
294
295/* DEBUG_PRINT functions */
296
297#define ACPI_DEBUG_PRINT(plist) ACPI_ACTUAL_DEBUG plist
298#define ACPI_DEBUG_PRINT_RAW(plist) ACPI_ACTUAL_DEBUG_RAW plist
299
300/* Helper macros for DEBUG_PRINT */
301
302#define ACPI_DO_DEBUG_PRINT(function, level, line, filename, modulename, component, ...) \
303 ACPI_DO_WHILE0 ({ \
304 if (ACPI_IS_DEBUG_ENABLED (level, component)) \
305 { \
306 function (level, line, filename, modulename, component, __VA_ARGS__); \
307 } \
308 })
309
310#define ACPI_ACTUAL_DEBUG(level, line, filename, modulename, component, ...) \
311 ACPI_DO_DEBUG_PRINT (acpi_debug_print, level, line, \
312 filename, modulename, component, __VA_ARGS__)
313
314#define ACPI_ACTUAL_DEBUG_RAW(level, line, filename, modulename, component, ...) \
315 ACPI_DO_DEBUG_PRINT (acpi_debug_print_raw, level, line, \
316 filename, modulename, component, __VA_ARGS__)
317
318/*
319 * Function entry tracing
320 *
321 * The name of the function is emitted as a local variable that is
322 * intended to be used by both the entry trace and the exit trace.
323 */
324
325/* Helper macro */
326
327#define ACPI_TRACE_ENTRY(name, function, cast, param) \
328 ACPI_FUNCTION_NAME (name) \
329 function (ACPI_DEBUG_PARAMETERS, cast (param))
330
331/* The actual entry trace macros */
332
333#define ACPI_FUNCTION_TRACE(name) \
334 ACPI_FUNCTION_NAME(name) \
335 acpi_ut_trace (ACPI_DEBUG_PARAMETERS)
336
337#define ACPI_FUNCTION_TRACE_PTR(name, pointer) \
338 ACPI_TRACE_ENTRY (name, acpi_ut_trace_ptr, (void *), pointer)
339
340#define ACPI_FUNCTION_TRACE_U32(name, value) \
341 ACPI_TRACE_ENTRY (name, acpi_ut_trace_u32, (u32), value)
342
343#define ACPI_FUNCTION_TRACE_STR(name, string) \
344 ACPI_TRACE_ENTRY (name, acpi_ut_trace_str, (char *), string)
345
346#define ACPI_FUNCTION_ENTRY() \
347 acpi_ut_track_stack_ptr()
348
349/*
350 * Function exit tracing
351 *
352 * These macros include a return statement. This is usually considered
353 * bad form, but having a separate exit macro before the actual return
354 * is very ugly and difficult to maintain.
355 *
356 * One of the FUNCTION_TRACE macros above must be used in conjunction
357 * with these macros so that "_AcpiFunctionName" is defined.
358 */
359
360/* Exit trace helper macro */
361
362#define ACPI_TRACE_EXIT(function, cast, param) \
363 ACPI_DO_WHILE0 ({ \
364 function (ACPI_DEBUG_PARAMETERS, cast (param)); \
365 return ((param)); \
366 })
367
368/* The actual exit macros */
369
370#define return_VOID \
371 ACPI_DO_WHILE0 ({ \
372 acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \
373 return; \
374 })
375
376#define return_ACPI_STATUS(status) \
377 ACPI_TRACE_EXIT (acpi_ut_status_exit, (acpi_status), status)
378
379#define return_PTR(pointer) \
380 ACPI_TRACE_EXIT (acpi_ut_ptr_exit, (u8 *), pointer)
381
382#define return_VALUE(value) \
383 ACPI_TRACE_EXIT (acpi_ut_value_exit, (u64), value)
384
385/* Conditional execution */
386
387#define ACPI_DEBUG_EXEC(a) a
388#define ACPI_DEBUG_ONLY_MEMBERS(a) a;
389#define _VERBOSE_STRUCTURES
390
391/* Various object display routines for debug */
392
393#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0)
394#define ACPI_DUMP_OPERANDS(a, b ,c) acpi_ex_dump_operands(a, b, c)
395#define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b)
396#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d)
397#define ACPI_DUMP_BUFFER(a, b) acpi_ut_debug_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
398
399#else /* ACPI_DEBUG_OUTPUT */
277/* 400/*
278 * This is the non-debug case -- make everything go away, 401 * This is the non-debug case -- make everything go away,
279 * leaving no executable debug code! 402 * leaving no executable debug code!
@@ -281,6 +404,32 @@
281#define ACPI_FUNCTION_NAME(a) 404#define ACPI_FUNCTION_NAME(a)
282#define ACPI_DEBUG_PRINT(pl) 405#define ACPI_DEBUG_PRINT(pl)
283#define ACPI_DEBUG_PRINT_RAW(pl) 406#define ACPI_DEBUG_PRINT_RAW(pl)
407#define ACPI_DEBUG_EXEC(a)
408#define ACPI_DEBUG_ONLY_MEMBERS(a)
409#define ACPI_FUNCTION_TRACE(a)
410#define ACPI_FUNCTION_TRACE_PTR(a, b)
411#define ACPI_FUNCTION_TRACE_U32(a, b)
412#define ACPI_FUNCTION_TRACE_STR(a, b)
413#define ACPI_FUNCTION_EXIT
414#define ACPI_FUNCTION_STATUS_EXIT(s)
415#define ACPI_FUNCTION_VALUE_EXIT(s)
416#define ACPI_FUNCTION_ENTRY()
417#define ACPI_DUMP_STACK_ENTRY(a)
418#define ACPI_DUMP_OPERANDS(a, b, c)
419#define ACPI_DUMP_ENTRY(a, b)
420#define ACPI_DUMP_TABLES(a, b)
421#define ACPI_DUMP_PATHNAME(a, b, c, d)
422#define ACPI_DUMP_BUFFER(a, b)
423#define ACPI_DEBUG_PRINT(pl)
424#define ACPI_DEBUG_PRINT_RAW(pl)
425#define ACPI_IS_DEBUG_ENABLED(level, component) 0
426
427/* Return macros must have a return statement at the minimum */
428
429#define return_VOID return
430#define return_ACPI_STATUS(s) return(s)
431#define return_VALUE(s) return(s)
432#define return_PTR(s) return(s)
284 433
285#endif /* ACPI_DEBUG_OUTPUT */ 434#endif /* ACPI_DEBUG_OUTPUT */
286 435
diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
index c1ea8436961f..618787715d56 100644
--- a/include/acpi/acpi.h
+++ b/include/acpi/acpi.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 7ced5dc20dd3..227ba7dc293d 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -84,28 +84,29 @@ struct acpi_driver;
84struct acpi_device; 84struct acpi_device;
85 85
86/* 86/*
87 * ACPI Scan Handler
88 * -----------------
89 */
90
91struct acpi_scan_handler {
92 const struct acpi_device_id *ids;
93 struct list_head list_node;
94 int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
95 void (*detach)(struct acpi_device *dev);
96};
97
98/*
87 * ACPI Driver 99 * ACPI Driver
88 * ----------- 100 * -----------
89 */ 101 */
90 102
91typedef int (*acpi_op_add) (struct acpi_device * device); 103typedef int (*acpi_op_add) (struct acpi_device * device);
92typedef int (*acpi_op_remove) (struct acpi_device * device, int type); 104typedef int (*acpi_op_remove) (struct acpi_device * device);
93typedef int (*acpi_op_start) (struct acpi_device * device);
94typedef int (*acpi_op_bind) (struct acpi_device * device);
95typedef int (*acpi_op_unbind) (struct acpi_device * device);
96typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event); 105typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event);
97 106
98struct acpi_bus_ops {
99 u32 acpi_op_add:1;
100 u32 acpi_op_start:1;
101};
102
103struct acpi_device_ops { 107struct acpi_device_ops {
104 acpi_op_add add; 108 acpi_op_add add;
105 acpi_op_remove remove; 109 acpi_op_remove remove;
106 acpi_op_start start;
107 acpi_op_bind bind;
108 acpi_op_unbind unbind;
109 acpi_op_notify notify; 110 acpi_op_notify notify;
110}; 111};
111 112
@@ -148,7 +149,8 @@ struct acpi_device_flags {
148 u32 power_manageable:1; 149 u32 power_manageable:1;
149 u32 performance_manageable:1; 150 u32 performance_manageable:1;
150 u32 eject_pending:1; 151 u32 eject_pending:1;
151 u32 reserved:24; 152 u32 match_driver:1;
153 u32 reserved:23;
152}; 154};
153 155
154/* File System */ 156/* File System */
@@ -207,7 +209,7 @@ struct acpi_device_power_state {
207 } flags; 209 } flags;
208 int power; /* % Power (compared to D0) */ 210 int power; /* % Power (compared to D0) */
209 int latency; /* Dx->D0 time (microseconds) */ 211 int latency; /* Dx->D0 time (microseconds) */
210 struct acpi_handle_list resources; /* Power resources referenced */ 212 struct list_head resources; /* Power resources referenced */
211}; 213};
212 214
213struct acpi_device_power { 215struct acpi_device_power {
@@ -250,7 +252,7 @@ struct acpi_device_wakeup {
250 acpi_handle gpe_device; 252 acpi_handle gpe_device;
251 u64 gpe_number; 253 u64 gpe_number;
252 u64 sleep_state; 254 u64 sleep_state;
253 struct acpi_handle_list resources; 255 struct list_head resources;
254 struct acpi_device_wakeup_flags flags; 256 struct acpi_device_wakeup_flags flags;
255 int prepare_count; 257 int prepare_count;
256}; 258};
@@ -279,16 +281,17 @@ struct acpi_device {
279 struct acpi_device_wakeup wakeup; 281 struct acpi_device_wakeup wakeup;
280 struct acpi_device_perf performance; 282 struct acpi_device_perf performance;
281 struct acpi_device_dir dir; 283 struct acpi_device_dir dir;
282 struct acpi_device_ops ops; 284 struct acpi_scan_handler *handler;
283 struct acpi_driver *driver; 285 struct acpi_driver *driver;
284 void *driver_data; 286 void *driver_data;
285 struct device dev; 287 struct device dev;
286 struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */
287 enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ 288 enum acpi_bus_removal_type removal_type; /* indicate for different removal type */
288 u8 physical_node_count; 289 u8 physical_node_count;
289 struct list_head physical_node_list; 290 struct list_head physical_node_list;
290 struct mutex physical_node_lock; 291 struct mutex physical_node_lock;
291 DECLARE_BITMAP(physical_node_id_bitmap, ACPI_MAX_PHYSICAL_NODE); 292 DECLARE_BITMAP(physical_node_id_bitmap, ACPI_MAX_PHYSICAL_NODE);
293 struct list_head power_dependent;
294 void (*remove)(struct acpi_device *);
292}; 295};
293 296
294static inline void *acpi_driver_data(struct acpi_device *d) 297static inline void *acpi_driver_data(struct acpi_device *d)
@@ -316,7 +319,7 @@ struct acpi_bus_event {
316}; 319};
317 320
318struct acpi_eject_event { 321struct acpi_eject_event {
319 acpi_handle handle; 322 struct acpi_device *device;
320 u32 event; 323 u32 event;
321}; 324};
322 325
@@ -339,13 +342,51 @@ void acpi_bus_data_handler(acpi_handle handle, void *context);
339acpi_status acpi_bus_get_status_handle(acpi_handle handle, 342acpi_status acpi_bus_get_status_handle(acpi_handle handle,
340 unsigned long long *sta); 343 unsigned long long *sta);
341int acpi_bus_get_status(struct acpi_device *device); 344int acpi_bus_get_status(struct acpi_device *device);
345
346#ifdef CONFIG_PM
342int acpi_bus_set_power(acpi_handle handle, int state); 347int acpi_bus_set_power(acpi_handle handle, int state);
348const char *acpi_power_state_string(int state);
349int acpi_device_get_power(struct acpi_device *device, int *state);
343int acpi_device_set_power(struct acpi_device *device, int state); 350int acpi_device_set_power(struct acpi_device *device, int state);
351int acpi_bus_init_power(struct acpi_device *device);
344int acpi_bus_update_power(acpi_handle handle, int *state_p); 352int acpi_bus_update_power(acpi_handle handle, int *state_p);
345bool acpi_bus_power_manageable(acpi_handle handle); 353bool acpi_bus_power_manageable(acpi_handle handle);
346bool acpi_bus_can_wakeup(acpi_handle handle); 354bool acpi_bus_can_wakeup(acpi_handle handle);
347int acpi_power_resource_register_device(struct device *dev, acpi_handle handle); 355#else /* !CONFIG_PM */
348void acpi_power_resource_unregister_device(struct device *dev, acpi_handle handle); 356static inline int acpi_bus_set_power(acpi_handle handle, int state)
357{
358 return 0;
359}
360static inline const char *acpi_power_state_string(int state)
361{
362 return "D0";
363}
364static inline int acpi_device_get_power(struct acpi_device *device, int *state)
365{
366 return 0;
367}
368static inline int acpi_device_set_power(struct acpi_device *device, int state)
369{
370 return 0;
371}
372static inline int acpi_bus_init_power(struct acpi_device *device)
373{
374 return 0;
375}
376static inline int acpi_bus_update_power(acpi_handle handle, int *state_p)
377{
378 return 0;
379}
380static inline bool acpi_bus_power_manageable(acpi_handle handle)
381{
382 return false;
383}
384static inline bool acpi_bus_can_wakeup(acpi_handle handle)
385{
386 return false;
387}
388#endif /* !CONFIG_PM */
389
349#ifdef CONFIG_ACPI_PROC_EVENT 390#ifdef CONFIG_ACPI_PROC_EVENT
350int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data); 391int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data);
351int acpi_bus_generate_proc_event4(const char *class, const char *bid, u8 type, int data); 392int acpi_bus_generate_proc_event4(const char *class, const char *bid, u8 type, int data);
@@ -354,13 +395,15 @@ int acpi_bus_receive_event(struct acpi_bus_event *event);
354static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data) 395static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data)
355 { return 0; } 396 { return 0; }
356#endif 397#endif
398
399void acpi_scan_lock_acquire(void);
400void acpi_scan_lock_release(void);
401int acpi_scan_add_handler(struct acpi_scan_handler *handler);
357int acpi_bus_register_driver(struct acpi_driver *driver); 402int acpi_bus_register_driver(struct acpi_driver *driver);
358void acpi_bus_unregister_driver(struct acpi_driver *driver); 403void acpi_bus_unregister_driver(struct acpi_driver *driver);
359int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, 404int acpi_bus_scan(acpi_handle handle);
360 acpi_handle handle, int type);
361void acpi_bus_hot_remove_device(void *context); 405void acpi_bus_hot_remove_device(void *context);
362int acpi_bus_trim(struct acpi_device *start, int rmdevice); 406void acpi_bus_trim(struct acpi_device *start);
363int acpi_bus_start(struct acpi_device *device);
364acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd); 407acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
365int acpi_match_device_ids(struct acpi_device *device, 408int acpi_match_device_ids(struct acpi_device *device,
366 const struct acpi_device_id *ids); 409 const struct acpi_device_id *ids);
@@ -390,6 +433,8 @@ struct acpi_bus_type {
390 int (*find_device) (struct device *, acpi_handle *); 433 int (*find_device) (struct device *, acpi_handle *);
391 /* For bridges, such as PCI root bridge, IDE controller */ 434 /* For bridges, such as PCI root bridge, IDE controller */
392 int (*find_bridge) (struct device *, acpi_handle *); 435 int (*find_bridge) (struct device *, acpi_handle *);
436 void (*setup)(struct device *);
437 void (*cleanup)(struct device *);
393}; 438};
394int register_acpi_bus_type(struct acpi_bus_type *); 439int register_acpi_bus_type(struct acpi_bus_type *);
395int unregister_acpi_bus_type(struct acpi_bus_type *); 440int unregister_acpi_bus_type(struct acpi_bus_type *);
@@ -397,7 +442,6 @@ int unregister_acpi_bus_type(struct acpi_bus_type *);
397struct acpi_pci_root { 442struct acpi_pci_root {
398 struct list_head node; 443 struct list_head node;
399 struct acpi_device * device; 444 struct acpi_device * device;
400 struct acpi_pci_id id;
401 struct pci_bus *bus; 445 struct pci_bus *bus;
402 u16 segment; 446 u16 segment;
403 struct resource secondary; /* downstream bus range */ 447 struct resource secondary; /* downstream bus range */
@@ -425,6 +469,8 @@ acpi_status acpi_remove_pm_notifier(struct acpi_device *adev,
425int acpi_device_power_state(struct device *dev, struct acpi_device *adev, 469int acpi_device_power_state(struct device *dev, struct acpi_device *adev,
426 u32 target_state, int d_max_in, int *d_min_p); 470 u32 target_state, int d_max_in, int *d_min_p);
427int acpi_pm_device_sleep_state(struct device *, int *, int); 471int acpi_pm_device_sleep_state(struct device *, int *, int);
472void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev);
473void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev);
428#else 474#else
429static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev, 475static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev,
430 acpi_notify_handler handler, 476 acpi_notify_handler handler,
@@ -454,6 +500,10 @@ static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m)
454{ 500{
455 return __acpi_device_power_state(m, p); 501 return __acpi_device_power_state(m, p);
456} 502}
503static inline void acpi_dev_pm_add_dependent(acpi_handle handle,
504 struct device *depdev) {}
505static inline void acpi_dev_pm_remove_dependent(acpi_handle handle,
506 struct device *depdev) {}
457#endif 507#endif
458 508
459#ifdef CONFIG_PM_RUNTIME 509#ifdef CONFIG_PM_RUNTIME
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 43152742b46f..7d2a9eaab9eb 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2012, Intel Corp. 10 * Copyright (C) 2000 - 2013, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
@@ -102,10 +102,8 @@ acpi_os_physical_table_override(struct acpi_table_header *existing_table,
102/* 102/*
103 * Spinlock primitives 103 * Spinlock primitives
104 */ 104 */
105
106#ifndef acpi_os_create_lock 105#ifndef acpi_os_create_lock
107acpi_status 106acpi_status acpi_os_create_lock(acpi_spinlock * out_handle);
108acpi_os_create_lock(acpi_spinlock *out_handle);
109#endif 107#endif
110 108
111void acpi_os_delete_lock(acpi_spinlock handle); 109void acpi_os_delete_lock(acpi_spinlock handle);
@@ -148,6 +146,8 @@ void acpi_os_release_mutex(acpi_mutex handle);
148 */ 146 */
149void *acpi_os_allocate(acpi_size size); 147void *acpi_os_allocate(acpi_size size);
150 148
149void acpi_os_free(void *memory);
150
151void __iomem *acpi_os_map_memory(acpi_physical_address where, 151void __iomem *acpi_os_map_memory(acpi_physical_address where,
152 acpi_size length); 152 acpi_size length);
153 153
@@ -180,12 +180,13 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object);
180 * Interrupt handlers 180 * Interrupt handlers
181 */ 181 */
182acpi_status 182acpi_status
183acpi_os_install_interrupt_handler(u32 gsi, 183acpi_os_install_interrupt_handler(u32 interrupt_number,
184 acpi_osd_handler service_routine, 184 acpi_osd_handler service_routine,
185 void *context); 185 void *context);
186 186
187acpi_status 187acpi_status
188acpi_os_remove_interrupt_handler(u32 gsi, acpi_osd_handler service_routine); 188acpi_os_remove_interrupt_handler(u32 interrupt_number,
189 acpi_osd_handler service_routine);
189 190
190void acpi_os_gpe_count(u32 gpe_number); 191void acpi_os_gpe_count(u32 gpe_number);
191void acpi_os_fixed_event_count(u32 fixed_event_number); 192void acpi_os_fixed_event_count(u32 fixed_event_number);
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 3d88395d4d6f..03322dddd88e 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -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 0x20121018 49#define ACPI_CA_VERSION 0x20130117
50 50
51#include <acpi/acconfig.h> 51#include <acpi/acconfig.h>
52#include <acpi/actypes.h> 52#include <acpi/actypes.h>
@@ -56,11 +56,20 @@
56extern u8 acpi_gbl_permanent_mmap; 56extern u8 acpi_gbl_permanent_mmap;
57 57
58/* 58/*
59 * Globals that are publicly available, allowing for 59 * Globals that are publically available
60 * run time configuration
61 */ 60 */
61extern u32 acpi_current_gpe_count;
62extern struct acpi_table_fadt acpi_gbl_FADT;
63extern u8 acpi_gbl_system_awake_and_running;
64extern u8 acpi_gbl_reduced_hardware; /* ACPI 5.0 */
65
66/* Runtime configuration of debug print levels */
67
62extern u32 acpi_dbg_level; 68extern u32 acpi_dbg_level;
63extern u32 acpi_dbg_layer; 69extern u32 acpi_dbg_layer;
70
71/* ACPICA runtime options */
72
64extern u8 acpi_gbl_enable_interpreter_slack; 73extern u8 acpi_gbl_enable_interpreter_slack;
65extern u8 acpi_gbl_all_methods_serialized; 74extern u8 acpi_gbl_all_methods_serialized;
66extern u8 acpi_gbl_create_osi_method; 75extern u8 acpi_gbl_create_osi_method;
@@ -99,14 +108,9 @@ extern u8 acpi_gbl_disable_auto_repair;
99 108
100#endif /* !ACPI_REDUCED_HARDWARE */ 109#endif /* !ACPI_REDUCED_HARDWARE */
101 110
102extern u32 acpi_current_gpe_count;
103extern struct acpi_table_fadt acpi_gbl_FADT;
104extern u8 acpi_gbl_system_awake_and_running;
105extern u8 acpi_gbl_reduced_hardware; /* ACPI 5.0 */
106
107extern u32 acpi_rsdt_forced; 111extern u32 acpi_rsdt_forced;
108/* 112/*
109 * Global interfaces 113 * Initialization
110 */ 114 */
111acpi_status 115acpi_status
112acpi_initialize_tables(struct acpi_table_desc *initial_storage, 116acpi_initialize_tables(struct acpi_table_desc *initial_storage,
@@ -120,13 +124,15 @@ acpi_status acpi_initialize_objects(u32 flags);
120 124
121acpi_status acpi_terminate(void); 125acpi_status acpi_terminate(void);
122 126
127/*
128 * Miscellaneous global interfaces
129 */
130ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void))
131ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void))
123#ifdef ACPI_FUTURE_USAGE 132#ifdef ACPI_FUTURE_USAGE
124acpi_status acpi_subsystem_status(void); 133acpi_status acpi_subsystem_status(void);
125#endif 134#endif
126 135
127ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable(void))
128ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable(void))
129
130#ifdef ACPI_FUTURE_USAGE 136#ifdef ACPI_FUTURE_USAGE
131acpi_status acpi_get_system_info(struct acpi_buffer *ret_buffer); 137acpi_status acpi_get_system_info(struct acpi_buffer *ret_buffer);
132#endif 138#endif
@@ -191,9 +197,9 @@ acpi_status
191acpi_get_table_by_index(u32 table_index, struct acpi_table_header **out_table); 197acpi_get_table_by_index(u32 table_index, struct acpi_table_header **out_table);
192 198
193acpi_status 199acpi_status
194acpi_install_table_handler(acpi_tbl_handler handler, void *context); 200acpi_install_table_handler(acpi_table_handler handler, void *context);
195 201
196acpi_status acpi_remove_table_handler(acpi_tbl_handler handler); 202acpi_status acpi_remove_table_handler(acpi_table_handler handler);
197 203
198/* 204/*
199 * Namespace and name interfaces 205 * Namespace and name interfaces
@@ -438,6 +444,11 @@ acpi_get_event_resources(acpi_handle device_handle,
438 struct acpi_buffer *ret_buffer); 444 struct acpi_buffer *ret_buffer);
439 445
440acpi_status 446acpi_status
447acpi_walk_resource_buffer(struct acpi_buffer *buffer,
448 acpi_walk_resource_callback user_function,
449 void *context);
450
451acpi_status
441acpi_walk_resources(acpi_handle device, 452acpi_walk_resources(acpi_handle device,
442 char *name, 453 char *name,
443 acpi_walk_resource_callback user_function, void *context); 454 acpi_walk_resource_callback user_function, void *context);
@@ -462,6 +473,10 @@ acpi_buffer_to_resource(u8 *aml_buffer,
462 */ 473 */
463acpi_status acpi_reset(void); 474acpi_status acpi_reset(void);
464 475
476acpi_status acpi_read(u64 *value, struct acpi_generic_address *reg);
477
478acpi_status acpi_write(u64 value, struct acpi_generic_address *reg);
479
465ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 480ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
466 acpi_read_bit_register(u32 register_id, 481 acpi_read_bit_register(u32 register_id,
467 u32 *return_value)) 482 u32 *return_value))
@@ -470,20 +485,6 @@ ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
470 acpi_write_bit_register(u32 register_id, 485 acpi_write_bit_register(u32 register_id,
471 u32 value)) 486 u32 value))
472 487
473ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
474 acpi_set_firmware_waking_vector(u32
475 physical_address))
476
477#if ACPI_MACHINE_WIDTH == 64
478ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
479 acpi_set_firmware_waking_vector64(u64
480 physical_address))
481#endif
482
483acpi_status acpi_read(u64 *value, struct acpi_generic_address *reg);
484
485acpi_status acpi_write(u64 value, struct acpi_generic_address *reg);
486
487/* 488/*
488 * Sleep/Wake interfaces 489 * Sleep/Wake interfaces
489 */ 490 */
@@ -500,6 +501,15 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state);
500 501
501acpi_status acpi_leave_sleep_state(u8 sleep_state); 502acpi_status acpi_leave_sleep_state(u8 sleep_state);
502 503
504ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
505 acpi_set_firmware_waking_vector(u32
506 physical_address))
507
508#if ACPI_MACHINE_WIDTH == 64
509ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status
510 acpi_set_firmware_waking_vector64(u64
511 physical_address))
512#endif
503/* 513/*
504 * ACPI Timer interfaces 514 * ACPI Timer interfaces
505 */ 515 */
diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h
index 40349ae65464..cbf4bf977f75 100644
--- a/include/acpi/acrestyp.h
+++ b/include/acpi/acrestyp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -102,8 +102,11 @@ typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (Length+3) = (6
102 102
103#define ACPI_EXCLUSIVE (u8) 0x00 103#define ACPI_EXCLUSIVE (u8) 0x00
104#define ACPI_SHARED (u8) 0x01 104#define ACPI_SHARED (u8) 0x01
105#define ACPI_EXCLUSIVE_AND_WAKE (u8) 0x02 105
106#define ACPI_SHARED_AND_WAKE (u8) 0x03 106/* Wake */
107
108#define ACPI_NOT_WAKE_CAPABLE (u8) 0x00
109#define ACPI_WAKE_CAPABLE (u8) 0x01
107 110
108/* 111/*
109 * DMA Attributes 112 * DMA Attributes
@@ -171,6 +174,7 @@ struct acpi_resource_irq {
171 u8 triggering; 174 u8 triggering;
172 u8 polarity; 175 u8 polarity;
173 u8 sharable; 176 u8 sharable;
177 u8 wake_capable;
174 u8 interrupt_count; 178 u8 interrupt_count;
175 u8 interrupts[1]; 179 u8 interrupts[1];
176}; 180};
@@ -346,6 +350,7 @@ struct acpi_resource_extended_irq {
346 u8 triggering; 350 u8 triggering;
347 u8 polarity; 351 u8 polarity;
348 u8 sharable; 352 u8 sharable;
353 u8 wake_capable;
349 u8 interrupt_count; 354 u8 interrupt_count;
350 struct acpi_resource_source resource_source; 355 struct acpi_resource_source resource_source;
351 u32 interrupts[1]; 356 u32 interrupts[1];
@@ -365,6 +370,7 @@ struct acpi_resource_gpio {
365 u8 producer_consumer; /* For values, see Producer/Consumer above */ 370 u8 producer_consumer; /* For values, see Producer/Consumer above */
366 u8 pin_config; 371 u8 pin_config;
367 u8 sharable; /* For values, see Interrupt Attributes above */ 372 u8 sharable; /* For values, see Interrupt Attributes above */
373 u8 wake_capable; /* For values, see Interrupt Attributes above */
368 u8 io_restriction; 374 u8 io_restriction;
369 u8 triggering; /* For values, see Interrupt Attributes above */ 375 u8 triggering; /* For values, see Interrupt Attributes above */
370 u8 polarity; /* For values, see Interrupt Attributes above */ 376 u8 polarity; /* For values, see Interrupt Attributes above */
@@ -591,7 +597,10 @@ struct acpi_resource {
591#define ACPI_RS_SIZE_MIN (u32) ACPI_ROUND_UP_TO_NATIVE_WORD (12) 597#define ACPI_RS_SIZE_MIN (u32) ACPI_ROUND_UP_TO_NATIVE_WORD (12)
592#define ACPI_RS_SIZE(type) (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type)) 598#define ACPI_RS_SIZE(type) (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type))
593 599
594#define ACPI_NEXT_RESOURCE(res) (struct acpi_resource *)((u8 *) res + res->length) 600/* Macro for walking resource templates with multiple descriptors */
601
602#define ACPI_NEXT_RESOURCE(res) \
603 ACPI_ADD_PTR (struct acpi_resource, (res), (res)->length)
595 604
596struct acpi_pci_routing_table { 605struct acpi_pci_routing_table {
597 u32 length; 606 u32 length;
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 4f94b1d812d5..9b58a8f43771 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -326,8 +326,6 @@ enum acpi_preferred_pm_profiles {
326 326
327#pragma pack() 327#pragma pack()
328 328
329#define ACPI_FADT_OFFSET(f) (u16) ACPI_OFFSET (struct acpi_table_fadt, f)
330
331/* 329/*
332 * Internal table-related structures 330 * Internal table-related structures
333 */ 331 */
@@ -359,11 +357,14 @@ struct acpi_table_desc {
359/* 357/*
360 * Get the remaining ACPI tables 358 * Get the remaining ACPI tables
361 */ 359 */
362
363#include <acpi/actbl1.h> 360#include <acpi/actbl1.h>
364#include <acpi/actbl2.h> 361#include <acpi/actbl2.h>
365#include <acpi/actbl3.h> 362#include <acpi/actbl3.h>
366 363
364/* Macros used to generate offsets to specific table fields */
365
366#define ACPI_FADT_OFFSET(f) (u16) ACPI_OFFSET (struct acpi_table_fadt, f)
367
367/* 368/*
368 * Sizes of the various flavors of FADT. We need to look closely 369 * Sizes of the various flavors of FADT. We need to look closely
369 * at the FADT length because the version number essentially tells 370 * at the FADT length because the version number essentially tells
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index 280fc45b59dd..0bd750ebeb49 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -768,7 +768,7 @@ struct acpi_madt_interrupt_source {
768 768
769struct acpi_madt_local_x2apic { 769struct acpi_madt_local_x2apic {
770 struct acpi_subtable_header header; 770 struct acpi_subtable_header header;
771 u16 reserved; /* Reserved - must be zero */ 771 u16 reserved; /* reserved - must be zero */
772 u32 local_apic_id; /* Processor x2APIC ID */ 772 u32 local_apic_id; /* Processor x2APIC ID */
773 u32 lapic_flags; 773 u32 lapic_flags;
774 u32 uid; /* ACPI processor UID */ 774 u32 uid; /* ACPI processor UID */
@@ -781,14 +781,14 @@ struct acpi_madt_local_x2apic_nmi {
781 u16 inti_flags; 781 u16 inti_flags;
782 u32 uid; /* ACPI processor UID */ 782 u32 uid; /* ACPI processor UID */
783 u8 lint; /* LINTn to which NMI is connected */ 783 u8 lint; /* LINTn to which NMI is connected */
784 u8 reserved[3]; 784 u8 reserved[3]; /* reserved - must be zero */
785}; 785};
786 786
787/* 11: Generic Interrupt (ACPI 5.0) */ 787/* 11: Generic Interrupt (ACPI 5.0) */
788 788
789struct acpi_madt_generic_interrupt { 789struct acpi_madt_generic_interrupt {
790 struct acpi_subtable_header header; 790 struct acpi_subtable_header header;
791 u16 reserved; /* Reserved - must be zero */ 791 u16 reserved; /* reserved - must be zero */
792 u32 gic_id; 792 u32 gic_id;
793 u32 uid; 793 u32 uid;
794 u32 flags; 794 u32 flags;
diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index 1b2b356486d1..77dc7a4099a3 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -261,9 +261,28 @@ struct acpi_csrt_group {
261 u16 subdevice_id; 261 u16 subdevice_id;
262 u16 revision; 262 u16 revision;
263 u16 reserved; 263 u16 reserved;
264 u32 info_length; 264 u32 shared_info_length;
265 265
266 /* Shared data (length = info_length) immediately follows */ 266 /* Shared data immediately follows (Length = shared_info_length) */
267};
268
269/* Shared Info subtable */
270
271struct acpi_csrt_shared_info {
272 u16 major_version;
273 u16 minor_version;
274 u32 mmio_base_low;
275 u32 mmio_base_high;
276 u32 gsi_interrupt;
277 u8 interrupt_polarity;
278 u8 interrupt_mode;
279 u8 num_channels;
280 u8 dma_address_width;
281 u16 base_request_line;
282 u16 num_handshake_signals;
283 u32 max_block_size;
284
285 /* Resource descriptors immediately follow (Length = Group length - shared_info_length) */
267}; 286};
268 287
269/* Resource Descriptor subtable */ 288/* Resource Descriptor subtable */
diff --git a/include/acpi/actbl3.h b/include/acpi/actbl3.h
index 6585141e4b97..332b17e3bec8 100644
--- a/include/acpi/actbl3.h
+++ b/include/acpi/actbl3.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -68,13 +68,13 @@
68#define ACPI_SIG_PCCT "PCCT" /* Platform Communications Channel Table */ 68#define ACPI_SIG_PCCT "PCCT" /* Platform Communications Channel Table */
69#define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */ 69#define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */
70#define ACPI_SIG_RASF "RASF" /* RAS Feature table */ 70#define ACPI_SIG_RASF "RASF" /* RAS Feature table */
71#define ACPI_SIG_TPM2 "TPM2" /* Trusted Platform Module 2.0 H/W interface table */
71 72
72#define ACPI_SIG_S3PT "S3PT" /* S3 Performance (sub)Table */ 73#define ACPI_SIG_S3PT "S3PT" /* S3 Performance (sub)Table */
73#define ACPI_SIG_PCCS "PCC" /* PCC Shared Memory Region */ 74#define ACPI_SIG_PCCS "PCC" /* PCC Shared Memory Region */
74 75
75/* Reserved table signatures */ 76/* Reserved table signatures */
76 77
77#define ACPI_SIG_CSRT "CSRT" /* Core System Resources Table */
78#define ACPI_SIG_MATR "MATR" /* Memory Address Translation Table */ 78#define ACPI_SIG_MATR "MATR" /* Memory Address Translation Table */
79#define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */ 79#define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */
80#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */ 80#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */
@@ -550,6 +550,36 @@ enum acpi_rasf_status {
550#define ACPI_RASF_ERROR (1<<2) 550#define ACPI_RASF_ERROR (1<<2)
551#define ACPI_RASF_STATUS (0x1F<<3) 551#define ACPI_RASF_STATUS (0x1F<<3)
552 552
553/*******************************************************************************
554 *
555 * TPM2 - Trusted Platform Module (TPM) 2.0 Hardware Interface Table
556 * Version 3
557 *
558 * Conforms to "TPM 2.0 Hardware Interface Table (TPM2)" 29 November 2011
559 *
560 ******************************************************************************/
561
562struct acpi_table_tpm2 {
563 struct acpi_table_header header; /* Common ACPI table header */
564 u32 flags;
565 u64 control_address;
566 u32 start_method;
567};
568
569/* Control area structure (not part of table, pointed to by control_address) */
570
571struct acpi_tpm2_control {
572 u32 reserved;
573 u32 error;
574 u32 cancel;
575 u32 start;
576 u64 interrupt_control;
577 u32 command_size;
578 u64 command_address;
579 u32 response_size;
580 u64 response_address;
581};
582
553/* Reset to default packing */ 583/* Reset to default packing */
554 584
555#pragma pack() 585#pragma pack()
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 4f43f1fba132..845e75f1ffd8 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -341,7 +341,7 @@ typedef u32 acpi_physical_address;
341 341
342/* PM Timer ticks per second (HZ) */ 342/* PM Timer ticks per second (HZ) */
343 343
344#define PM_TIMER_FREQUENCY 3579545 344#define ACPI_PM_TIMER_FREQUENCY 3579545
345 345
346/******************************************************************************* 346/*******************************************************************************
347 * 347 *
@@ -373,6 +373,21 @@ typedef u32 acpi_name; /* 4-byte ACPI name */
373typedef char *acpi_string; /* Null terminated ASCII string */ 373typedef char *acpi_string; /* Null terminated ASCII string */
374typedef void *acpi_handle; /* Actually a ptr to a NS Node */ 374typedef void *acpi_handle; /* Actually a ptr to a NS Node */
375 375
376/* Time constants for timer calculations */
377
378#define ACPI_MSEC_PER_SEC 1000L
379
380#define ACPI_USEC_PER_MSEC 1000L
381#define ACPI_USEC_PER_SEC 1000000L
382
383#define ACPI_100NSEC_PER_USEC 10L
384#define ACPI_100NSEC_PER_MSEC 10000L
385#define ACPI_100NSEC_PER_SEC 10000000L
386
387#define ACPI_NSEC_PER_USEC 1000L
388#define ACPI_NSEC_PER_MSEC 1000000L
389#define ACPI_NSEC_PER_SEC 1000000000L
390
376/* Owner IDs are used to track namespace nodes for selective deletion */ 391/* Owner IDs are used to track namespace nodes for selective deletion */
377 392
378typedef u8 acpi_owner_id; 393typedef u8 acpi_owner_id;
@@ -390,10 +405,6 @@ typedef u8 acpi_owner_id;
390#define ACPI_MAX16_DECIMAL_DIGITS 5 405#define ACPI_MAX16_DECIMAL_DIGITS 5
391#define ACPI_MAX8_DECIMAL_DIGITS 3 406#define ACPI_MAX8_DECIMAL_DIGITS 3
392 407
393/* PM Timer ticks per second (HZ) */
394
395#define PM_TIMER_FREQUENCY 3579545
396
397/* 408/*
398 * Constants with special meanings 409 * Constants with special meanings
399 */ 410 */
@@ -474,6 +485,7 @@ typedef u64 acpi_integer;
474 */ 485 */
475#define ACPI_FULL_INITIALIZATION 0x00 486#define ACPI_FULL_INITIALIZATION 0x00
476#define ACPI_NO_ADDRESS_SPACE_INIT 0x01 487#define ACPI_NO_ADDRESS_SPACE_INIT 0x01
488#define ACPI_NO_HARDWARE_INIT 0x02
477#define ACPI_NO_EVENT_INIT 0x04 489#define ACPI_NO_EVENT_INIT 0x04
478#define ACPI_NO_HANDLER_INIT 0x08 490#define ACPI_NO_HANDLER_INIT 0x08
479#define ACPI_NO_ACPI_ENABLE 0x10 491#define ACPI_NO_ACPI_ENABLE 0x10
@@ -595,7 +607,7 @@ typedef u32 acpi_object_type;
595 607
596/* 608/*
597 * These are special object types that never appear in 609 * These are special object types that never appear in
598 * a Namespace node, only in a union acpi_operand_object 610 * a Namespace node, only in an object of union acpi_operand_object
599 */ 611 */
600#define ACPI_TYPE_LOCAL_EXTRA 0x1C 612#define ACPI_TYPE_LOCAL_EXTRA 0x1C
601#define ACPI_TYPE_LOCAL_DATA 0x1D 613#define ACPI_TYPE_LOCAL_DATA 0x1D
@@ -662,7 +674,7 @@ typedef u32 acpi_event_status;
662#define ACPI_GPE_MAX 0xFF 674#define ACPI_GPE_MAX 0xFF
663#define ACPI_NUM_GPE 256 675#define ACPI_NUM_GPE 256
664 676
665/* Actions for acpi_set_gpe_wake_mask, acpi_hw_low_set_gpe */ 677/* Actions for acpi_set_gpe, acpi_gpe_wakeup, acpi_hw_low_set_gpe */
666 678
667#define ACPI_GPE_ENABLE 0 679#define ACPI_GPE_ENABLE 0
668#define ACPI_GPE_DISABLE 1 680#define ACPI_GPE_DISABLE 1
@@ -880,6 +892,10 @@ struct acpi_buffer {
880 void *pointer; /* pointer to buffer */ 892 void *pointer; /* pointer to buffer */
881}; 893};
882 894
895/* Free a buffer created in an struct acpi_buffer via ACPI_ALLOCATE_LOCAL_BUFFER */
896
897#define ACPI_FREE_BUFFER(b) ACPI_FREE(b.pointer)
898
883/* 899/*
884 * name_type for acpi_get_name 900 * name_type for acpi_get_name
885 */ 901 */
@@ -968,7 +984,11 @@ acpi_status(*acpi_exception_handler) (acpi_status aml_status,
968/* Table Event handler (Load, load_table, etc.) and types */ 984/* Table Event handler (Load, load_table, etc.) and types */
969 985
970typedef 986typedef
971acpi_status(*acpi_tbl_handler) (u32 event, void *table, void *context); 987acpi_status(*acpi_table_handler) (u32 event, void *table, void *context);
988
989#define ACPI_TABLE_LOAD 0x0
990#define ACPI_TABLE_UNLOAD 0x1
991#define ACPI_NUM_TABLE_EVENTS 2
972 992
973/* Address Spaces (For Operation Regions) */ 993/* Address Spaces (For Operation Regions) */
974 994
diff --git a/include/acpi/container.h b/include/acpi/container.h
deleted file mode 100644
index a703f14e049e..000000000000
--- a/include/acpi/container.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#ifndef __ACPI_CONTAINER_H
2#define __ACPI_CONTAINER_H
3
4#include <linux/kernel.h>
5
6struct acpi_container {
7 acpi_handle handle;
8 unsigned long sun;
9 int state;
10};
11
12#endif /* __ACPI_CONTAINER_H */
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index 89cee88dd2a5..ef04b36ca6ed 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -1,11 +1,11 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Name: acenv.h - Generation environment specific items 3 * Name: acenv.h - Host and compiler configuration
4 * 4 *
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,12 @@
44#ifndef __ACENV_H__ 44#ifndef __ACENV_H__
45#define __ACENV_H__ 45#define __ACENV_H__
46 46
47/*
48 * Environment configuration. The purpose of this file is to interface ACPICA
49 * to the local environment. This includes compiler-specific, OS-specific,
50 * and machine-specific configuration.
51 */
52
47/* Types for ACPI_MUTEX_TYPE */ 53/* Types for ACPI_MUTEX_TYPE */
48 54
49#define ACPI_BINARY_SEMAPHORE 0 55#define ACPI_BINARY_SEMAPHORE 0
@@ -60,139 +66,170 @@
60 * 66 *
61 *****************************************************************************/ 67 *****************************************************************************/
62 68
63#ifdef ACPI_LIBRARY 69/* iASL configuration */
64/*
65 * Note: The non-debug version of the acpi_library does not contain any
66 * debug support, for minimal size. The debug version uses ACPI_FULL_DEBUG
67 */
68#define ACPI_USE_LOCAL_CACHE
69#endif
70 70
71#ifdef ACPI_ASL_COMPILER 71#ifdef ACPI_ASL_COMPILER
72#define ACPI_DEBUG_OUTPUT
73#define ACPI_APPLICATION 72#define ACPI_APPLICATION
74#define ACPI_DISASSEMBLER 73#define ACPI_DISASSEMBLER
74#define ACPI_DEBUG_OUTPUT
75#define ACPI_CONSTANT_EVAL_ONLY 75#define ACPI_CONSTANT_EVAL_ONLY
76#define ACPI_LARGE_NAMESPACE_NODE 76#define ACPI_LARGE_NAMESPACE_NODE
77#define ACPI_DATA_TABLE_DISASSEMBLY 77#define ACPI_DATA_TABLE_DISASSEMBLY
78#define ACPI_SINGLE_THREADED
78#endif 79#endif
79 80
81/* acpi_exec configuration. Multithreaded with full AML debugger */
82
80#ifdef ACPI_EXEC_APP 83#ifdef ACPI_EXEC_APP
81#undef DEBUGGER_THREADING
82#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
83#define ACPI_FULL_DEBUG
84#define ACPI_APPLICATION 84#define ACPI_APPLICATION
85#define ACPI_DEBUGGER 85#define ACPI_FULL_DEBUG
86#define ACPI_MUTEX_DEBUG 86#define ACPI_MUTEX_DEBUG
87#define ACPI_DBG_TRACK_ALLOCATIONS 87#define ACPI_DBG_TRACK_ALLOCATIONS
88#endif 88#endif
89 89
90/* acpi_names configuration. Single threaded with debugger output enabled. */
91
92#ifdef ACPI_NAMES_APP
93#define ACPI_DEBUGGER
94#define ACPI_APPLICATION
95#define ACPI_SINGLE_THREADED
96#endif
97
98/*
99 * acpi_bin/acpi_help/acpi_src configuration. All single threaded, with
100 * no debug output.
101 */
102#if (defined ACPI_BIN_APP) || \
103 (defined ACPI_SRC_APP) || \
104 (defined ACPI_XTRACT_APP)
105#define ACPI_APPLICATION
106#define ACPI_SINGLE_THREADED
107#endif
108
109#ifdef ACPI_HELP_APP
110#define ACPI_APPLICATION
111#define ACPI_SINGLE_THREADED
112#define ACPI_NO_ERROR_MESSAGES
113#endif
114
115/* Linkable ACPICA library */
116
117#ifdef ACPI_LIBRARY
118#define ACPI_USE_LOCAL_CACHE
119#define ACPI_FUTURE_USAGE
120#endif
121
122/* Common for all ACPICA applications */
123
90#ifdef ACPI_APPLICATION 124#ifdef ACPI_APPLICATION
91#define ACPI_USE_SYSTEM_CLIBRARY 125#define ACPI_USE_SYSTEM_CLIBRARY
92#define ACPI_USE_LOCAL_CACHE 126#define ACPI_USE_LOCAL_CACHE
93#endif 127#endif
94 128
129/* Common debug support */
130
95#ifdef ACPI_FULL_DEBUG 131#ifdef ACPI_FULL_DEBUG
96#define ACPI_DEBUGGER 132#define ACPI_DEBUGGER
97#define ACPI_DEBUG_OUTPUT 133#define ACPI_DEBUG_OUTPUT
98#define ACPI_DISASSEMBLER 134#define ACPI_DISASSEMBLER
99#endif 135#endif
100 136
101/*
102 * Environment configuration. The purpose of this file is to interface to the
103 * local generation environment.
104 *
105 * 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library.
106 * Otherwise, local versions of string/memory functions will be used.
107 * 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and
108 * the standard header files may be used.
109 *
110 * The ACPI subsystem only uses low level C library functions that do not call
111 * operating system services and may therefore be inlined in the code.
112 *
113 * It may be necessary to tailor these include files to the target
114 * generation environment.
115 *
116 *
117 * Functions and constants used from each header:
118 *
119 * string.h: memcpy
120 * memset
121 * strcat
122 * strcmp
123 * strcpy
124 * strlen
125 * strncmp
126 * strncat
127 * strncpy
128 *
129 * stdlib.h: strtoul
130 *
131 * stdarg.h: va_list
132 * va_arg
133 * va_start
134 * va_end
135 *
136 */
137 137
138/*! [Begin] no source code translation */ 138/*! [Begin] no source code translation */
139 139
140/******************************************************************************
141 *
142 * Host configuration files. The compiler configuration files are included
143 * by the host files.
144 *
145 *****************************************************************************/
146
140#if defined(_LINUX) || defined(__linux__) 147#if defined(_LINUX) || defined(__linux__)
141#include <acpi/platform/aclinux.h> 148#include <acpi/platform/aclinux.h>
142 149
143#elif defined(_AED_EFI)
144#include "acefi.h"
145
146#elif defined(WIN32)
147#include "acwin.h"
148
149#elif defined(WIN64)
150#include "acwin64.h"
151
152#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */
153#include "acdos16.h"
154
155#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) 150#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
156#include "acfreebsd.h" 151#include "acfreebsd.h"
157 152
158#elif defined(__NetBSD__) 153#elif defined(__NetBSD__)
159#include "acnetbsd.h" 154#include "acnetbsd.h"
160 155
156#elif defined(__sun)
157#include "acsolaris.h"
158
161#elif defined(MODESTO) 159#elif defined(MODESTO)
162#include "acmodesto.h" 160#include "acmodesto.h"
163 161
164#elif defined(NETWARE) 162#elif defined(NETWARE)
165#include "acnetware.h" 163#include "acnetware.h"
166 164
167#elif defined(__sun) 165#elif defined(_CYGWIN)
168#include "acsolaris.h" 166#include "accygwin.h"
169 167
170#else 168#elif defined(WIN32)
169#include "acwin.h"
170
171#elif defined(WIN64)
172#include "acwin64.h"
171 173
172/* All other environments */ 174#elif defined(_WRS_LIB_BUILD)
175#include "acvxworks.h"
173 176
174#define ACPI_USE_STANDARD_HEADERS 177#elif defined(__OS2__)
178#include "acos2.h"
175 179
176#define COMPILER_DEPENDENT_INT64 long long 180#elif defined(_AED_EFI)
177#define COMPILER_DEPENDENT_UINT64 unsigned long long 181#include "acefi.h"
182
183#elif defined(__HAIKU__)
184#include "achaiku.h"
178 185
186#else
187
188/* Unknown environment */
189
190#error Unknown target environment
179#endif 191#endif
180 192
181/*! [End] no source code translation !*/ 193/*! [End] no source code translation !*/
182 194
183/****************************************************************************** 195/******************************************************************************
184 * 196 *
185 * Miscellaneous configuration 197 * Setup defaults for the required symbols that were not defined in one of
198 * the host/compiler files above.
186 * 199 *
187 *****************************************************************************/ 200 *****************************************************************************/
188 201
189/* 202/* 64-bit data types */
190 * Are mutexes supported by the host? default is no, use binary semaphores. 203
191 */ 204#ifndef COMPILER_DEPENDENT_INT64
205#define COMPILER_DEPENDENT_INT64 long long
206#endif
207
208#ifndef COMPILER_DEPENDENT_UINT64
209#define COMPILER_DEPENDENT_UINT64 unsigned long long
210#endif
211
212/* Type of mutex supported by host. Default is binary semaphores. */
192#ifndef ACPI_MUTEX_TYPE 213#ifndef ACPI_MUTEX_TYPE
193#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE 214#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE
194#endif 215#endif
195 216
217/* Global Lock acquire/release */
218
219#ifndef ACPI_ACQUIRE_GLOBAL_LOCK
220#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acquired) acquired = 1
221#endif
222
223#ifndef ACPI_RELEASE_GLOBAL_LOCK
224#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, pending) pending = 0
225#endif
226
227/* Flush CPU cache - used when going to sleep. Wbinvd or similar. */
228
229#ifndef ACPI_FLUSH_CPU_CACHE
230#define ACPI_FLUSH_CPU_CACHE()
231#endif
232
196/* "inline" keywords - configurable since inline is not standardized */ 233/* "inline" keywords - configurable since inline is not standardized */
197 234
198#ifndef ACPI_INLINE 235#ifndef ACPI_INLINE
@@ -200,6 +237,30 @@
200#endif 237#endif
201 238
202/* 239/*
240 * Configurable calling conventions:
241 *
242 * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
243 * ACPI_EXTERNAL_XFACE - External ACPI interfaces
244 * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
245 * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
246 */
247#ifndef ACPI_SYSTEM_XFACE
248#define ACPI_SYSTEM_XFACE
249#endif
250
251#ifndef ACPI_EXTERNAL_XFACE
252#define ACPI_EXTERNAL_XFACE
253#endif
254
255#ifndef ACPI_INTERNAL_XFACE
256#define ACPI_INTERNAL_XFACE
257#endif
258
259#ifndef ACPI_INTERNAL_VAR_XFACE
260#define ACPI_INTERNAL_VAR_XFACE
261#endif
262
263/*
203 * Debugger threading model 264 * Debugger threading model
204 * Use single threaded if the entire subsystem is contained in an application 265 * Use single threaded if the entire subsystem is contained in an application
205 * Use multiple threaded when the subsystem is running in the kernel. 266 * Use multiple threaded when the subsystem is running in the kernel.
@@ -222,17 +283,26 @@
222 * 283 *
223 *****************************************************************************/ 284 *****************************************************************************/
224 285
225#define ACPI_IS_ASCII(c) ((c) < 0x80)
226
227#ifdef ACPI_USE_SYSTEM_CLIBRARY
228/* 286/*
229 * Use the standard C library headers. 287 * ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library.
230 * We want to keep these to a minimum. 288 * Otherwise, local versions of string/memory functions will be used.
289 * ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and
290 * the standard header files may be used.
291 *
292 * The ACPICA subsystem only uses low level C library functions that do not call
293 * operating system services and may therefore be inlined in the code.
294 *
295 * It may be necessary to tailor these include files to the target
296 * generation environment.
231 */ 297 */
298#ifdef ACPI_USE_SYSTEM_CLIBRARY
299
300/* Use the standard C library headers. We want to keep these to a minimum. */
301
232#ifdef ACPI_USE_STANDARD_HEADERS 302#ifdef ACPI_USE_STANDARD_HEADERS
233/* 303
234 * Use the standard headers from the standard locations 304/* Use the standard headers from the standard locations */
235 */ 305
236#include <stdarg.h> 306#include <stdarg.h>
237#include <stdlib.h> 307#include <stdlib.h>
238#include <string.h> 308#include <string.h>
@@ -240,9 +310,8 @@
240 310
241#endif /* ACPI_USE_STANDARD_HEADERS */ 311#endif /* ACPI_USE_STANDARD_HEADERS */
242 312
243/* 313/* We will be linking to the standard Clib functions */
244 * We will be linking to the standard Clib functions 314
245 */
246#define ACPI_STRSTR(s1,s2) strstr((s1), (s2)) 315#define ACPI_STRSTR(s1,s2) strstr((s1), (s2))
247#define ACPI_STRCHR(s1,c) strchr((s1), (c)) 316#define ACPI_STRCHR(s1,c) strchr((s1), (c))
248#define ACPI_STRLEN(s) (acpi_size) strlen((s)) 317#define ACPI_STRLEN(s) (acpi_size) strlen((s))
@@ -274,13 +343,12 @@
274 * 343 *
275 *****************************************************************************/ 344 *****************************************************************************/
276 345
277 /* 346/*
278 * Use local definitions of C library macros and functions 347 * Use local definitions of C library macros and functions. These function
279 * NOTE: The function implementations may not be as efficient 348 * implementations may not be as efficient as an inline or assembly code
280 * as an inline or assembly code implementation provided by a 349 * implementation provided by a native C library, but they are functionally
281 * native C library. 350 * equivalent.
282 */ 351 */
283
284#ifndef va_arg 352#ifndef va_arg
285 353
286#ifndef _VALIST 354#ifndef _VALIST
@@ -288,22 +356,22 @@
288typedef char *va_list; 356typedef char *va_list;
289#endif /* _VALIST */ 357#endif /* _VALIST */
290 358
291/* 359/* Storage alignment properties */
292 * Storage alignment properties 360
293 */
294#define _AUPBND (sizeof (acpi_native_int) - 1) 361#define _AUPBND (sizeof (acpi_native_int) - 1)
295#define _ADNBND (sizeof (acpi_native_int) - 1) 362#define _ADNBND (sizeof (acpi_native_int) - 1)
296 363
297/* 364/* Variable argument list macro definitions */
298 * Variable argument list macro definitions 365
299 */
300#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd))) 366#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
301#define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND)))) 367#define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND))))
302#define va_end(ap) (void) 0 368#define va_end(ap) (ap = (va_list) NULL)
303#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND)))) 369#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))
304 370
305#endif /* va_arg */ 371#endif /* va_arg */
306 372
373/* Use the local (ACPICA) definitions of the clib functions */
374
307#define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2)) 375#define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2))
308#define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c)) 376#define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c))
309#define ACPI_STRLEN(s) (acpi_size) acpi_ut_strlen ((s)) 377#define ACPI_STRLEN(s) (acpi_size) acpi_ut_strlen ((s))
@@ -322,59 +390,4 @@ typedef char *va_list;
322 390
323#endif /* ACPI_USE_SYSTEM_CLIBRARY */ 391#endif /* ACPI_USE_SYSTEM_CLIBRARY */
324 392
325/******************************************************************************
326 *
327 * Assembly code macros
328 *
329 *****************************************************************************/
330
331/*
332 * Handle platform- and compiler-specific assembly language differences.
333 * These should already have been defined by the platform includes above.
334 *
335 * Notes:
336 * 1) Interrupt 3 is used to break into a debugger
337 * 2) Interrupts are turned off during ACPI register setup
338 */
339
340/* Unrecognized compiler, use defaults */
341
342#ifndef ACPI_ASM_MACROS
343
344/*
345 * Calling conventions:
346 *
347 * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
348 * ACPI_EXTERNAL_XFACE - External ACPI interfaces
349 * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
350 * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
351 */
352#define ACPI_SYSTEM_XFACE
353#define ACPI_EXTERNAL_XFACE
354#define ACPI_INTERNAL_XFACE
355#define ACPI_INTERNAL_VAR_XFACE
356
357#define ACPI_ASM_MACROS
358#define BREAKPOINT3
359#define ACPI_DISABLE_IRQS()
360#define ACPI_ENABLE_IRQS()
361#define ACPI_ACQUIRE_GLOBAL_LOCK(Glptr, acq)
362#define ACPI_RELEASE_GLOBAL_LOCK(Glptr, acq)
363
364#endif /* ACPI_ASM_MACROS */
365
366#ifdef ACPI_APPLICATION
367
368/* Don't want software interrupts within a ring3 application */
369
370#undef BREAKPOINT3
371#define BREAKPOINT3
372#endif
373
374/******************************************************************************
375 *
376 * Compiler-specific information is contained in the compiler-specific
377 * headers.
378 *
379 *****************************************************************************/
380#endif /* __ACENV_H__ */ 393#endif /* __ACENV_H__ */
diff --git a/include/acpi/platform/acgcc.h b/include/acpi/platform/acgcc.h
index 72553b0c9f33..e077ce6c38ca 100644
--- a/include/acpi/platform/acgcc.h
+++ b/include/acpi/platform/acgcc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -64,8 +64,4 @@
64 */ 64 */
65#define ACPI_UNUSED_VAR __attribute__ ((unused)) 65#define ACPI_UNUSED_VAR __attribute__ ((unused))
66 66
67#ifdef _ANSI
68#define inline
69#endif
70
71#endif /* __ACGCC_H__ */ 67#endif /* __ACGCC_H__ */
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 85d5d8f38452..68534ef86ec8 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -108,7 +108,6 @@
108 108
109#include <acpi/platform/acgcc.h> 109#include <acpi/platform/acgcc.h>
110 110
111
112#ifdef __KERNEL__ 111#ifdef __KERNEL__
113#include <acpi/actypes.h> 112#include <acpi/actypes.h>
114/* 113/*
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 3994d7790b23..bcbdd7484e58 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -74,9 +74,10 @@ enum acpi_address_range_id {
74 74
75/* Table Handlers */ 75/* Table Handlers */
76 76
77typedef int (*acpi_table_handler) (struct acpi_table_header *table); 77typedef int (*acpi_tbl_table_handler)(struct acpi_table_header *table);
78 78
79typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end); 79typedef int (*acpi_tbl_entry_handler)(struct acpi_subtable_header *header,
80 const unsigned long end);
80 81
81#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE 82#ifdef CONFIG_ACPI_INITRD_TABLE_OVERRIDE
82void acpi_initrd_override(void *data, size_t size); 83void acpi_initrd_override(void *data, size_t size);
@@ -95,10 +96,14 @@ int acpi_mps_check (void);
95int acpi_numa_init (void); 96int acpi_numa_init (void);
96 97
97int acpi_table_init (void); 98int acpi_table_init (void);
98int acpi_table_parse (char *id, acpi_table_handler handler); 99int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
99int __init acpi_table_parse_entries(char *id, unsigned long table_size, 100int __init acpi_table_parse_entries(char *id, unsigned long table_size,
100 int entry_id, acpi_table_entry_handler handler, unsigned int max_entries); 101 int entry_id,
101int acpi_table_parse_madt (enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries); 102 acpi_tbl_entry_handler handler,
103 unsigned int max_entries);
104int acpi_table_parse_madt(enum acpi_madt_type id,
105 acpi_tbl_entry_handler handler,
106 unsigned int max_entries);
102int acpi_parse_mcfg (struct acpi_table_header *header); 107int acpi_parse_mcfg (struct acpi_table_header *header);
103void acpi_table_print_madt_entry (struct acpi_subtable_header *madt); 108void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
104 109
@@ -358,8 +363,7 @@ extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
358#if defined(CONFIG_ACPI_HOTPLUG_CPU) && \ 363#if defined(CONFIG_ACPI_HOTPLUG_CPU) && \
359 (defined(CONFIG_ACPI_HOTPLUG_MEMORY) || \ 364 (defined(CONFIG_ACPI_HOTPLUG_MEMORY) || \
360 defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)) && \ 365 defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)) && \
361 (defined(CONFIG_ACPI_CONTAINER) || \ 366 defined(CONFIG_ACPI_CONTAINER)
362 defined(CONFIG_ACPI_CONTAINER_MODULE))
363#define ACPI_HOTPLUG_OST 367#define ACPI_HOTPLUG_OST
364#endif 368#endif
365 369
@@ -511,7 +515,7 @@ static inline int acpi_subsys_runtime_suspend(struct device *dev) { return 0; }
511static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; } 515static inline int acpi_subsys_runtime_resume(struct device *dev) { return 0; }
512#endif 516#endif
513 517
514#ifdef CONFIG_ACPI_SLEEP 518#if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
515int acpi_dev_suspend_late(struct device *dev); 519int acpi_dev_suspend_late(struct device *dev);
516int acpi_dev_resume_early(struct device *dev); 520int acpi_dev_resume_early(struct device *dev);
517int acpi_subsys_prepare(struct device *dev); 521int acpi_subsys_prepare(struct device *dev);
@@ -526,9 +530,14 @@ static inline int acpi_subsys_resume_early(struct device *dev) { return 0; }
526#endif 530#endif
527 531
528#if defined(CONFIG_ACPI) && defined(CONFIG_PM) 532#if defined(CONFIG_ACPI) && defined(CONFIG_PM)
533struct acpi_device *acpi_dev_pm_get_node(struct device *dev);
529int acpi_dev_pm_attach(struct device *dev, bool power_on); 534int acpi_dev_pm_attach(struct device *dev, bool power_on);
530void acpi_dev_pm_detach(struct device *dev, bool power_off); 535void acpi_dev_pm_detach(struct device *dev, bool power_off);
531#else 536#else
537static inline struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
538{
539 return NULL;
540}
532static inline int acpi_dev_pm_attach(struct device *dev, bool power_on) 541static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
533{ 542{
534 return -ENODEV; 543 return -ENODEV;
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index a55b88eaf96a..a22944ca0526 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -89,11 +89,15 @@ struct cpufreq_real_policy {
89}; 89};
90 90
91struct cpufreq_policy { 91struct cpufreq_policy {
92 cpumask_var_t cpus; /* CPUs requiring sw coordination */ 92 /* CPUs sharing clock, require sw coordination */
93 cpumask_var_t related_cpus; /* CPUs with any coordination */ 93 cpumask_var_t cpus; /* Online CPUs only */
94 unsigned int shared_type; /* ANY or ALL affected CPUs 94 cpumask_var_t related_cpus; /* Online + Offline CPUs */
95
96 unsigned int shared_type; /* ACPI: ANY or ALL affected CPUs
95 should set cpufreq */ 97 should set cpufreq */
96 unsigned int cpu; /* cpu nr of registered CPU */ 98 unsigned int cpu; /* cpu nr of CPU managing this policy */
99 unsigned int last_cpu; /* cpu nr of previous CPU that managed
100 * this policy */
97 struct cpufreq_cpuinfo cpuinfo;/* see above */ 101 struct cpufreq_cpuinfo cpuinfo;/* see above */
98 102
99 unsigned int min; /* in kHz */ 103 unsigned int min; /* in kHz */
@@ -112,16 +116,23 @@ struct cpufreq_policy {
112 struct completion kobj_unregister; 116 struct completion kobj_unregister;
113}; 117};
114 118
115#define CPUFREQ_ADJUST (0) 119#define CPUFREQ_ADJUST (0)
116#define CPUFREQ_INCOMPATIBLE (1) 120#define CPUFREQ_INCOMPATIBLE (1)
117#define CPUFREQ_NOTIFY (2) 121#define CPUFREQ_NOTIFY (2)
118#define CPUFREQ_START (3) 122#define CPUFREQ_START (3)
123#define CPUFREQ_UPDATE_POLICY_CPU (4)
119 124
125/* Only for ACPI */
120#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */ 126#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
121#define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */ 127#define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */
122#define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */ 128#define CPUFREQ_SHARED_TYPE_ALL (2) /* All dependent CPUs should set freq */
123#define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/ 129#define CPUFREQ_SHARED_TYPE_ANY (3) /* Freq can be set from any dependent CPU*/
124 130
131static inline bool policy_is_shared(struct cpufreq_policy *policy)
132{
133 return cpumask_weight(policy->cpus) > 1;
134}
135
125/******************** cpufreq transition notifiers *******************/ 136/******************** cpufreq transition notifiers *******************/
126 137
127#define CPUFREQ_PRECHANGE (0) 138#define CPUFREQ_PRECHANGE (0)
@@ -173,6 +184,7 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu
173 184
174struct cpufreq_governor { 185struct cpufreq_governor {
175 char name[CPUFREQ_NAME_LEN]; 186 char name[CPUFREQ_NAME_LEN];
187 int initialized;
176 int (*governor) (struct cpufreq_policy *policy, 188 int (*governor) (struct cpufreq_policy *policy,
177 unsigned int event); 189 unsigned int event);
178 ssize_t (*show_setspeed) (struct cpufreq_policy *policy, 190 ssize_t (*show_setspeed) (struct cpufreq_policy *policy,
@@ -308,6 +320,9 @@ __ATTR(_name, 0444, show_##_name, NULL)
308static struct global_attr _name = \ 320static struct global_attr _name = \
309__ATTR(_name, 0644, show_##_name, store_##_name) 321__ATTR(_name, 0644, show_##_name, store_##_name)
310 322
323struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu);
324void cpufreq_cpu_put(struct cpufreq_policy *data);
325const char *cpufreq_get_current_driver(void);
311 326
312/********************************************************************* 327/*********************************************************************
313 * CPUFREQ 2.6. INTERFACE * 328 * CPUFREQ 2.6. INTERFACE *
@@ -397,14 +412,13 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
397 412
398/* the following 3 funtions are for cpufreq core use only */ 413/* the following 3 funtions are for cpufreq core use only */
399struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu); 414struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu);
400struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu);
401void cpufreq_cpu_put(struct cpufreq_policy *data);
402 415
403/* the following are really really optional */ 416/* the following are really really optional */
404extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; 417extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;
405 418
406void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, 419void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
407 unsigned int cpu); 420 unsigned int cpu);
421void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy);
408 422
409void cpufreq_frequency_table_put_attr(unsigned int cpu); 423void cpufreq_frequency_table_put_attr(unsigned int cpu);
410#endif /* _LINUX_CPUFREQ_H */ 424#endif /* _LINUX_CPUFREQ_H */
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 24cd1037b6d6..480c14dc1ddd 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -32,8 +32,6 @@ struct cpuidle_driver;
32 ****************************/ 32 ****************************/
33 33
34struct cpuidle_state_usage { 34struct cpuidle_state_usage {
35 void *driver_data;
36
37 unsigned long long disable; 35 unsigned long long disable;
38 unsigned long long usage; 36 unsigned long long usage;
39 unsigned long long time; /* in US */ 37 unsigned long long time; /* in US */
@@ -62,26 +60,6 @@ struct cpuidle_state {
62 60
63#define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000) 61#define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000)
64 62
65/**
66 * cpuidle_get_statedata - retrieves private driver state data
67 * @st_usage: the state usage statistics
68 */
69static inline void *cpuidle_get_statedata(struct cpuidle_state_usage *st_usage)
70{
71 return st_usage->driver_data;
72}
73
74/**
75 * cpuidle_set_statedata - stores private driver state data
76 * @st_usage: the state usage statistics
77 * @data: the private data
78 */
79static inline void
80cpuidle_set_statedata(struct cpuidle_state_usage *st_usage, void *data)
81{
82 st_usage->driver_data = data;
83}
84
85struct cpuidle_device { 63struct cpuidle_device {
86 unsigned int registered:1; 64 unsigned int registered:1;
87 unsigned int enabled:1; 65 unsigned int enabled:1;
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index e4238ceaa4d6..e70df40d84f6 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -13,6 +13,11 @@ extern bool pm_freezing; /* PM freezing in effect */
13extern bool pm_nosig_freezing; /* PM nosig freezing in effect */ 13extern bool pm_nosig_freezing; /* PM nosig freezing in effect */
14 14
15/* 15/*
16 * Timeout for stopping processes
17 */
18extern unsigned int freeze_timeout_msecs;
19
20/*
16 * Check if a process has been frozen 21 * Check if a process has been frozen
17 */ 22 */
18static inline bool frozen(struct task_struct *p) 23static inline bool frozen(struct task_struct *p)
diff --git a/include/linux/mailbox.h b/include/linux/mailbox.h
new file mode 100644
index 000000000000..5161f63ec1c8
--- /dev/null
+++ b/include/linux/mailbox.h
@@ -0,0 +1,17 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms and conditions of the GNU General Public License,
4 * version 2, as published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope it will be useful, but WITHOUT
7 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
9 * more details.
10 *
11 * You should have received a copy of the GNU General Public License along with
12 * this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14
15int pl320_ipc_transmit(u32 *data);
16int pl320_ipc_register_notifier(struct notifier_block *nb);
17int pl320_ipc_unregister_notifier(struct notifier_block *nb);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 03d7bb145311..97bcf23e045a 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -31,7 +31,6 @@
31/* 31/*
32 * Callbacks for platform drivers to implement. 32 * Callbacks for platform drivers to implement.
33 */ 33 */
34extern void (*pm_idle)(void);
35extern void (*pm_power_off)(void); 34extern void (*pm_power_off)(void);
36extern void (*pm_power_off_prepare)(void); 35extern void (*pm_power_off_prepare)(void);
37 36
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index f271860c78d5..c785c215abfc 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -80,6 +80,12 @@ static inline bool pm_runtime_suspended(struct device *dev)
80 && !dev->power.disable_depth; 80 && !dev->power.disable_depth;
81} 81}
82 82
83static inline bool pm_runtime_active(struct device *dev)
84{
85 return dev->power.runtime_status == RPM_ACTIVE
86 || dev->power.disable_depth;
87}
88
83static inline bool pm_runtime_status_suspended(struct device *dev) 89static inline bool pm_runtime_status_suspended(struct device *dev)
84{ 90{
85 return dev->power.runtime_status == RPM_SUSPENDED; 91 return dev->power.runtime_status == RPM_SUSPENDED;
@@ -132,6 +138,7 @@ static inline void pm_runtime_put_noidle(struct device *dev) {}
132static inline bool device_run_wake(struct device *dev) { return false; } 138static inline bool device_run_wake(struct device *dev) { return false; }
133static inline void device_set_run_wake(struct device *dev, bool enable) {} 139static inline void device_set_run_wake(struct device *dev, bool enable) {}
134static inline bool pm_runtime_suspended(struct device *dev) { return false; } 140static inline bool pm_runtime_suspended(struct device *dev) { return false; }
141static inline bool pm_runtime_active(struct device *dev) { return true; }
135static inline bool pm_runtime_status_suspended(struct device *dev) { return false; } 142static inline bool pm_runtime_status_suspended(struct device *dev) { return false; }
136static inline bool pm_runtime_enabled(struct device *dev) { return false; } 143static inline bool pm_runtime_enabled(struct device *dev) { return false; }
137 144
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 0c808d7fa579..d4e3f16d5e89 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -34,8 +34,10 @@ static inline void pm_restore_console(void)
34typedef int __bitwise suspend_state_t; 34typedef int __bitwise suspend_state_t;
35 35
36#define PM_SUSPEND_ON ((__force suspend_state_t) 0) 36#define PM_SUSPEND_ON ((__force suspend_state_t) 0)
37#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 1) 37#define PM_SUSPEND_FREEZE ((__force suspend_state_t) 1)
38#define PM_SUSPEND_STANDBY ((__force suspend_state_t) 2)
38#define PM_SUSPEND_MEM ((__force suspend_state_t) 3) 39#define PM_SUSPEND_MEM ((__force suspend_state_t) 3)
40#define PM_SUSPEND_MIN PM_SUSPEND_FREEZE
39#define PM_SUSPEND_MAX ((__force suspend_state_t) 4) 41#define PM_SUSPEND_MAX ((__force suspend_state_t) 4)
40 42
41enum suspend_stat_step { 43enum suspend_stat_step {
@@ -192,6 +194,7 @@ struct platform_suspend_ops {
192 */ 194 */
193extern void suspend_set_ops(const struct platform_suspend_ops *ops); 195extern void suspend_set_ops(const struct platform_suspend_ops *ops);
194extern int suspend_valid_only_mem(suspend_state_t state); 196extern int suspend_valid_only_mem(suspend_state_t state);
197extern void freeze_wake(void);
195 198
196/** 199/**
197 * arch_suspend_disable_irqs - disable IRQs for suspend 200 * arch_suspend_disable_irqs - disable IRQs for suspend
@@ -217,6 +220,7 @@ extern int pm_suspend(suspend_state_t state);
217 220
218static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {} 221static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
219static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; } 222static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
223static inline void freeze_wake(void) {}
220#endif /* !CONFIG_SUSPEND */ 224#endif /* !CONFIG_SUSPEND */
221 225
222/* struct pbe is used for creating lists of pages that should be restored 226/* struct pbe is used for creating lists of pages that should be restored
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 381f06db2fe5..e2cee22f578a 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -181,6 +181,10 @@ int sysfs_merge_group(struct kobject *kobj,
181 const struct attribute_group *grp); 181 const struct attribute_group *grp);
182void sysfs_unmerge_group(struct kobject *kobj, 182void sysfs_unmerge_group(struct kobject *kobj,
183 const struct attribute_group *grp); 183 const struct attribute_group *grp);
184int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name,
185 struct kobject *target, const char *link_name);
186void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
187 const char *link_name);
184 188
185void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); 189void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
186void sysfs_notify_dirent(struct sysfs_dirent *sd); 190void sysfs_notify_dirent(struct sysfs_dirent *sd);
@@ -326,6 +330,18 @@ static inline void sysfs_unmerge_group(struct kobject *kobj,
326{ 330{
327} 331}
328 332
333static inline int sysfs_add_link_to_group(struct kobject *kobj,
334 const char *group_name, struct kobject *target,
335 const char *link_name)
336{
337 return 0;
338}
339
340static inline void sysfs_remove_link_from_group(struct kobject *kobj,
341 const char *group_name, const char *link_name)
342{
343}
344
329static inline void sysfs_notify(struct kobject *kobj, const char *dir, 345static inline void sysfs_notify(struct kobject *kobj, const char *dir,
330 const char *attr) 346 const char *attr)
331{ 347{
diff --git a/include/trace/events/power.h b/include/trace/events/power.h
index 0c9783841a30..427acab5d69a 100644
--- a/include/trace/events/power.h
+++ b/include/trace/events/power.h
@@ -99,98 +99,6 @@ DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
99 TP_ARGS(name, state) 99 TP_ARGS(name, state)
100); 100);
101 101
102#ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
103
104/*
105 * The power events are used for cpuidle & suspend (power_start, power_end)
106 * and for cpufreq (power_frequency)
107 */
108DECLARE_EVENT_CLASS(power,
109
110 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
111
112 TP_ARGS(type, state, cpu_id),
113
114 TP_STRUCT__entry(
115 __field( u64, type )
116 __field( u64, state )
117 __field( u64, cpu_id )
118 ),
119
120 TP_fast_assign(
121 __entry->type = type;
122 __entry->state = state;
123 __entry->cpu_id = cpu_id;
124 ),
125
126 TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
127 (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
128);
129
130DEFINE_EVENT(power, power_start,
131
132 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
133
134 TP_ARGS(type, state, cpu_id)
135);
136
137DEFINE_EVENT(power, power_frequency,
138
139 TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
140
141 TP_ARGS(type, state, cpu_id)
142);
143
144TRACE_EVENT(power_end,
145
146 TP_PROTO(unsigned int cpu_id),
147
148 TP_ARGS(cpu_id),
149
150 TP_STRUCT__entry(
151 __field( u64, cpu_id )
152 ),
153
154 TP_fast_assign(
155 __entry->cpu_id = cpu_id;
156 ),
157
158 TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
159
160);
161
162/* Deprecated dummy functions must be protected against multi-declartion */
163#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
164#define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
165
166enum {
167 POWER_NONE = 0,
168 POWER_CSTATE = 1,
169 POWER_PSTATE = 2,
170};
171#endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
172
173#else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
174
175#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
176#define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
177enum {
178 POWER_NONE = 0,
179 POWER_CSTATE = 1,
180 POWER_PSTATE = 2,
181};
182
183/* These dummy declaration have to be ripped out when the deprecated
184 events get removed */
185static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
186static inline void trace_power_end(u64 cpuid) {};
187static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
188static inline void trace_power_end_rcuidle(u64 cpuid) {};
189static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
190#endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
191
192#endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
193
194/* 102/*
195 * The clock events are used for clock enable/disable and for 103 * The clock events are used for clock enable/disable and for
196 * clock rate change 104 * clock rate change
diff --git a/kernel/power/autosleep.c b/kernel/power/autosleep.c
index ca304046d9e2..c6422ffeda9a 100644
--- a/kernel/power/autosleep.c
+++ b/kernel/power/autosleep.c
@@ -66,7 +66,7 @@ static DECLARE_WORK(suspend_work, try_to_suspend);
66 66
67void queue_up_suspend_work(void) 67void queue_up_suspend_work(void)
68{ 68{
69 if (!work_pending(&suspend_work) && autosleep_state > PM_SUSPEND_ON) 69 if (autosleep_state > PM_SUSPEND_ON)
70 queue_work(autosleep_wq, &suspend_work); 70 queue_work(autosleep_wq, &suspend_work);
71} 71}
72 72
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 1c16f9167de1..d77663bfedeb 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -313,7 +313,7 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
313static suspend_state_t decode_state(const char *buf, size_t n) 313static suspend_state_t decode_state(const char *buf, size_t n)
314{ 314{
315#ifdef CONFIG_SUSPEND 315#ifdef CONFIG_SUSPEND
316 suspend_state_t state = PM_SUSPEND_STANDBY; 316 suspend_state_t state = PM_SUSPEND_MIN;
317 const char * const *s; 317 const char * const *s;
318#endif 318#endif
319 char *p; 319 char *p;
@@ -553,6 +553,30 @@ power_attr(pm_trace_dev_match);
553 553
554#endif /* CONFIG_PM_TRACE */ 554#endif /* CONFIG_PM_TRACE */
555 555
556#ifdef CONFIG_FREEZER
557static ssize_t pm_freeze_timeout_show(struct kobject *kobj,
558 struct kobj_attribute *attr, char *buf)
559{
560 return sprintf(buf, "%u\n", freeze_timeout_msecs);
561}
562
563static ssize_t pm_freeze_timeout_store(struct kobject *kobj,
564 struct kobj_attribute *attr,
565 const char *buf, size_t n)
566{
567 unsigned long val;
568
569 if (kstrtoul(buf, 10, &val))
570 return -EINVAL;
571
572 freeze_timeout_msecs = val;
573 return n;
574}
575
576power_attr(pm_freeze_timeout);
577
578#endif /* CONFIG_FREEZER*/
579
556static struct attribute * g[] = { 580static struct attribute * g[] = {
557 &state_attr.attr, 581 &state_attr.attr,
558#ifdef CONFIG_PM_TRACE 582#ifdef CONFIG_PM_TRACE
@@ -576,6 +600,9 @@ static struct attribute * g[] = {
576 &pm_print_times_attr.attr, 600 &pm_print_times_attr.attr,
577#endif 601#endif
578#endif 602#endif
603#ifdef CONFIG_FREEZER
604 &pm_freeze_timeout_attr.attr,
605#endif
579 NULL, 606 NULL,
580}; 607};
581 608
diff --git a/kernel/power/process.c b/kernel/power/process.c
index d5a258b60c6f..98088e0e71e8 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -21,7 +21,7 @@
21/* 21/*
22 * Timeout for stopping processes 22 * Timeout for stopping processes
23 */ 23 */
24#define TIMEOUT (20 * HZ) 24unsigned int __read_mostly freeze_timeout_msecs = 20 * MSEC_PER_SEC;
25 25
26static int try_to_freeze_tasks(bool user_only) 26static int try_to_freeze_tasks(bool user_only)
27{ 27{
@@ -36,7 +36,7 @@ static int try_to_freeze_tasks(bool user_only)
36 36
37 do_gettimeofday(&start); 37 do_gettimeofday(&start);
38 38
39 end_time = jiffies + TIMEOUT; 39 end_time = jiffies + msecs_to_jiffies(freeze_timeout_msecs);
40 40
41 if (!user_only) 41 if (!user_only)
42 freeze_workqueues_begin(); 42 freeze_workqueues_begin();
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 9322ff7eaad6..587dddeebf15 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -359,8 +359,7 @@ void pm_qos_update_request(struct pm_qos_request *req,
359 return; 359 return;
360 } 360 }
361 361
362 if (delayed_work_pending(&req->work)) 362 cancel_delayed_work_sync(&req->work);
363 cancel_delayed_work_sync(&req->work);
364 363
365 if (new_value != req->node.prio) 364 if (new_value != req->node.prio)
366 pm_qos_update_target( 365 pm_qos_update_target(
@@ -386,8 +385,7 @@ void pm_qos_update_request_timeout(struct pm_qos_request *req, s32 new_value,
386 "%s called for unknown object.", __func__)) 385 "%s called for unknown object.", __func__))
387 return; 386 return;
388 387
389 if (delayed_work_pending(&req->work)) 388 cancel_delayed_work_sync(&req->work);
390 cancel_delayed_work_sync(&req->work);
391 389
392 if (new_value != req->node.prio) 390 if (new_value != req->node.prio)
393 pm_qos_update_target( 391 pm_qos_update_target(
@@ -416,8 +414,7 @@ void pm_qos_remove_request(struct pm_qos_request *req)
416 return; 414 return;
417 } 415 }
418 416
419 if (delayed_work_pending(&req->work)) 417 cancel_delayed_work_sync(&req->work);
420 cancel_delayed_work_sync(&req->work);
421 418
422 pm_qos_update_target(pm_qos_array[req->pm_qos_class]->constraints, 419 pm_qos_update_target(pm_qos_array[req->pm_qos_class]->constraints,
423 &req->node, PM_QOS_REMOVE_REQ, 420 &req->node, PM_QOS_REMOVE_REQ,
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index c8b7446b27df..d4feda084a3a 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -30,12 +30,38 @@
30#include "power.h" 30#include "power.h"
31 31
32const char *const pm_states[PM_SUSPEND_MAX] = { 32const char *const pm_states[PM_SUSPEND_MAX] = {
33 [PM_SUSPEND_FREEZE] = "freeze",
33 [PM_SUSPEND_STANDBY] = "standby", 34 [PM_SUSPEND_STANDBY] = "standby",
34 [PM_SUSPEND_MEM] = "mem", 35 [PM_SUSPEND_MEM] = "mem",
35}; 36};
36 37
37static const struct platform_suspend_ops *suspend_ops; 38static const struct platform_suspend_ops *suspend_ops;
38 39
40static bool need_suspend_ops(suspend_state_t state)
41{
42 return !!(state > PM_SUSPEND_FREEZE);
43}
44
45static DECLARE_WAIT_QUEUE_HEAD(suspend_freeze_wait_head);
46static bool suspend_freeze_wake;
47
48static void freeze_begin(void)
49{
50 suspend_freeze_wake = false;
51}
52
53static void freeze_enter(void)
54{
55 wait_event(suspend_freeze_wait_head, suspend_freeze_wake);
56}
57
58void freeze_wake(void)
59{
60 suspend_freeze_wake = true;
61 wake_up(&suspend_freeze_wait_head);
62}
63EXPORT_SYMBOL_GPL(freeze_wake);
64
39/** 65/**
40 * suspend_set_ops - Set the global suspend method table. 66 * suspend_set_ops - Set the global suspend method table.
41 * @ops: Suspend operations to use. 67 * @ops: Suspend operations to use.
@@ -50,8 +76,11 @@ EXPORT_SYMBOL_GPL(suspend_set_ops);
50 76
51bool valid_state(suspend_state_t state) 77bool valid_state(suspend_state_t state)
52{ 78{
79 if (state == PM_SUSPEND_FREEZE)
80 return true;
53 /* 81 /*
54 * All states need lowlevel support and need to be valid to the lowlevel 82 * PM_SUSPEND_STANDBY and PM_SUSPEND_MEMORY states need lowlevel
83 * support and need to be valid to the lowlevel
55 * implementation, no valid callback implies that none are valid. 84 * implementation, no valid callback implies that none are valid.
56 */ 85 */
57 return suspend_ops && suspend_ops->valid && suspend_ops->valid(state); 86 return suspend_ops && suspend_ops->valid && suspend_ops->valid(state);
@@ -89,11 +118,11 @@ static int suspend_test(int level)
89 * hibernation). Run suspend notifiers, allocate the "suspend" console and 118 * hibernation). Run suspend notifiers, allocate the "suspend" console and
90 * freeze processes. 119 * freeze processes.
91 */ 120 */
92static int suspend_prepare(void) 121static int suspend_prepare(suspend_state_t state)
93{ 122{
94 int error; 123 int error;
95 124
96 if (!suspend_ops || !suspend_ops->enter) 125 if (need_suspend_ops(state) && (!suspend_ops || !suspend_ops->enter))
97 return -EPERM; 126 return -EPERM;
98 127
99 pm_prepare_console(); 128 pm_prepare_console();
@@ -137,7 +166,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
137{ 166{
138 int error; 167 int error;
139 168
140 if (suspend_ops->prepare) { 169 if (need_suspend_ops(state) && suspend_ops->prepare) {
141 error = suspend_ops->prepare(); 170 error = suspend_ops->prepare();
142 if (error) 171 if (error)
143 goto Platform_finish; 172 goto Platform_finish;
@@ -149,12 +178,23 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
149 goto Platform_finish; 178 goto Platform_finish;
150 } 179 }
151 180
152 if (suspend_ops->prepare_late) { 181 if (need_suspend_ops(state) && suspend_ops->prepare_late) {
153 error = suspend_ops->prepare_late(); 182 error = suspend_ops->prepare_late();
154 if (error) 183 if (error)
155 goto Platform_wake; 184 goto Platform_wake;
156 } 185 }
157 186
187 /*
188 * PM_SUSPEND_FREEZE equals
189 * frozen processes + suspended devices + idle processors.
190 * Thus we should invoke freeze_enter() soon after
191 * all the devices are suspended.
192 */
193 if (state == PM_SUSPEND_FREEZE) {
194 freeze_enter();
195 goto Platform_wake;
196 }
197
158 if (suspend_test(TEST_PLATFORM)) 198 if (suspend_test(TEST_PLATFORM))
159 goto Platform_wake; 199 goto Platform_wake;
160 200
@@ -182,13 +222,13 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
182 enable_nonboot_cpus(); 222 enable_nonboot_cpus();
183 223
184 Platform_wake: 224 Platform_wake:
185 if (suspend_ops->wake) 225 if (need_suspend_ops(state) && suspend_ops->wake)
186 suspend_ops->wake(); 226 suspend_ops->wake();
187 227
188 dpm_resume_start(PMSG_RESUME); 228 dpm_resume_start(PMSG_RESUME);
189 229
190 Platform_finish: 230 Platform_finish:
191 if (suspend_ops->finish) 231 if (need_suspend_ops(state) && suspend_ops->finish)
192 suspend_ops->finish(); 232 suspend_ops->finish();
193 233
194 return error; 234 return error;
@@ -203,11 +243,11 @@ int suspend_devices_and_enter(suspend_state_t state)
203 int error; 243 int error;
204 bool wakeup = false; 244 bool wakeup = false;
205 245
206 if (!suspend_ops) 246 if (need_suspend_ops(state) && !suspend_ops)
207 return -ENOSYS; 247 return -ENOSYS;
208 248
209 trace_machine_suspend(state); 249 trace_machine_suspend(state);
210 if (suspend_ops->begin) { 250 if (need_suspend_ops(state) && suspend_ops->begin) {
211 error = suspend_ops->begin(state); 251 error = suspend_ops->begin(state);
212 if (error) 252 if (error)
213 goto Close; 253 goto Close;
@@ -226,7 +266,7 @@ int suspend_devices_and_enter(suspend_state_t state)
226 266
227 do { 267 do {
228 error = suspend_enter(state, &wakeup); 268 error = suspend_enter(state, &wakeup);
229 } while (!error && !wakeup 269 } while (!error && !wakeup && need_suspend_ops(state)
230 && suspend_ops->suspend_again && suspend_ops->suspend_again()); 270 && suspend_ops->suspend_again && suspend_ops->suspend_again());
231 271
232 Resume_devices: 272 Resume_devices:
@@ -236,13 +276,13 @@ int suspend_devices_and_enter(suspend_state_t state)
236 ftrace_start(); 276 ftrace_start();
237 resume_console(); 277 resume_console();
238 Close: 278 Close:
239 if (suspend_ops->end) 279 if (need_suspend_ops(state) && suspend_ops->end)
240 suspend_ops->end(); 280 suspend_ops->end();
241 trace_machine_suspend(PWR_EVENT_EXIT); 281 trace_machine_suspend(PWR_EVENT_EXIT);
242 return error; 282 return error;
243 283
244 Recover_platform: 284 Recover_platform:
245 if (suspend_ops->recover) 285 if (need_suspend_ops(state) && suspend_ops->recover)
246 suspend_ops->recover(); 286 suspend_ops->recover();
247 goto Resume_devices; 287 goto Resume_devices;
248} 288}
@@ -278,12 +318,15 @@ static int enter_state(suspend_state_t state)
278 if (!mutex_trylock(&pm_mutex)) 318 if (!mutex_trylock(&pm_mutex))
279 return -EBUSY; 319 return -EBUSY;
280 320
321 if (state == PM_SUSPEND_FREEZE)
322 freeze_begin();
323
281 printk(KERN_INFO "PM: Syncing filesystems ... "); 324 printk(KERN_INFO "PM: Syncing filesystems ... ");
282 sys_sync(); 325 sys_sync();
283 printk("done.\n"); 326 printk("done.\n");
284 327
285 pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]); 328 pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
286 error = suspend_prepare(); 329 error = suspend_prepare(state);
287 if (error) 330 if (error)
288 goto Unlock; 331 goto Unlock;
289 332
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 36567564e221..192473b22799 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -81,21 +81,6 @@ config EVENT_TRACING
81 select CONTEXT_SWITCH_TRACER 81 select CONTEXT_SWITCH_TRACER
82 bool 82 bool
83 83
84config EVENT_POWER_TRACING_DEPRECATED
85 depends on EVENT_TRACING
86 bool "Deprecated power event trace API, to be removed"
87 default y
88 help
89 Provides old power event types:
90 C-state/idle accounting events:
91 power:power_start
92 power:power_end
93 and old cpufreq accounting event:
94 power:power_frequency
95 This is for userspace compatibility
96 and will vanish after 5 kernel iterations,
97 namely 3.1.
98
99config CONTEXT_SWITCH_TRACER 84config CONTEXT_SWITCH_TRACER
100 bool 85 bool
101 86
diff --git a/kernel/trace/power-traces.c b/kernel/trace/power-traces.c
index f55fcf61b223..1c71382b283d 100644
--- a/kernel/trace/power-traces.c
+++ b/kernel/trace/power-traces.c
@@ -13,8 +13,5 @@
13#define CREATE_TRACE_POINTS 13#define CREATE_TRACE_POINTS
14#include <trace/events/power.h> 14#include <trace/events/power.h>
15 15
16#ifdef EVENT_POWER_TRACING_DEPRECATED
17EXPORT_TRACEPOINT_SYMBOL_GPL(power_start);
18#endif
19EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_idle); 16EXPORT_TRACEPOINT_SYMBOL_GPL(cpu_idle);
20 17
diff --git a/tools/power/acpi/Makefile b/tools/power/acpi/Makefile
index 6b9cf7a987c7..bafeb8d662a3 100644
--- a/tools/power/acpi/Makefile
+++ b/tools/power/acpi/Makefile
@@ -13,6 +13,6 @@ clean :
13 rm -f $(CLEANFILES) $(patsubst %.c,%.o, $(SRCS)) *~ 13 rm -f $(CLEANFILES) $(patsubst %.c,%.o, $(SRCS)) *~
14 14
15install : 15install :
16 install acpidump /usr/bin/acpidump 16 install acpidump /usr/sbin/acpidump
17 install acpidump.8 /usr/share/man/man8 17 install acpidump.8 /usr/share/man/man8
18 18
diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8
index 0d7dc2cfefb5..b4ddb748356c 100644
--- a/tools/power/x86/turbostat/turbostat.8
+++ b/tools/power/x86/turbostat/turbostat.8
@@ -31,8 +31,6 @@ The \fB-S\fP option limits output to a 1-line System Summary for each interval.
31.PP 31.PP
32The \fB-v\fP option increases verbosity. 32The \fB-v\fP option increases verbosity.
33.PP 33.PP
34The \fB-s\fP option prints the SMI counter, equivalent to "-c 0x34"
35.PP
36The \fB-c MSR#\fP option includes the delta of the specified 32-bit MSR counter. 34The \fB-c MSR#\fP option includes the delta of the specified 32-bit MSR counter.
37.PP 35.PP
38The \fB-C MSR#\fP option includes the delta of the specified 64-bit MSR counter. 36The \fB-C MSR#\fP option includes the delta of the specified 64-bit MSR counter.
@@ -186,26 +184,24 @@ This is a weighted average, where the weight is %c0. ie. it is the total number
186un-halted cycles elapsed per time divided by the number of CPUs. 184un-halted cycles elapsed per time divided by the number of CPUs.
187.SH SMI COUNTING EXAMPLE 185.SH SMI COUNTING EXAMPLE
188On Intel Nehalem and newer processors, MSR 0x34 is a System Management Mode Interrupt (SMI) counter. 186On Intel Nehalem and newer processors, MSR 0x34 is a System Management Mode Interrupt (SMI) counter.
189Using the -m option, you can display how many SMIs have fired since reset, or if there 187This counter is shown by default under the "SMI" column.
190are SMIs during the measurement interval, you can display the delta using the -d option.
191.nf 188.nf
192[root@x980 ~]# turbostat -m 0x34 189[root@x980 ~]# turbostat
193cor CPU %c0 GHz TSC MSR 0x034 %c1 %c3 %c6 %pc3 %pc6 190cor CPU %c0 GHz TSC SMI %c1 %c3 %c6 CTMP %pc3 %pc6
194 1.41 1.82 3.38 0x00000000 8.92 37.82 51.85 17.37 0.55 191 0.11 1.91 3.38 0 1.84 0.26 97.79 29 0.82 83.87
195 0 0 3.73 2.03 3.38 0x00000055 1.72 48.25 46.31 17.38 0.55 192 0 0 0.40 1.63 3.38 0 10.27 0.12 89.20 20 0.82 83.88
196 0 6 0.14 1.63 3.38 0x00000056 5.30 193 0 6 0.06 1.63 3.38 0 10.61
197 1 2 2.51 1.80 3.38 0x00000056 15.65 29.33 52.52 194 1 2 0.37 2.63 3.38 0 0.02 0.10 99.51 22
198 1 8 0.10 1.65 3.38 0x00000056 18.05 195 1 8 0.01 1.62 3.38 0 0.39
199 2 4 1.16 1.68 3.38 0x00000056 5.87 24.47 68.50 196 2 4 0.07 1.62 3.38 0 0.04 0.07 99.82 23
200 2 10 0.10 1.63 3.38 0x00000056 6.93 197 2 10 0.02 1.62 3.38 0 0.09
201 8 1 3.84 1.91 3.38 0x00000056 1.36 50.65 44.16 198 8 1 0.23 1.64 3.38 0 0.10 1.07 98.60 24
202 8 7 0.08 1.64 3.38 0x00000056 5.12 199 8 7 0.02 1.64 3.38 0 0.31
203 9 3 1.82 1.73 3.38 0x00000056 7.59 24.21 66.38 200 9 3 0.03 1.62 3.38 0 0.03 0.05 99.89 29
204 9 9 0.09 1.68 3.38 0x00000056 9.32 201 9 9 0.02 1.62 3.38 0 0.05
205 10 5 1.66 1.65 3.38 0x00000056 15.10 50.00 33.23 202 10 5 0.07 1.62 3.38 0 0.08 0.12 99.73 27
206 10 11 1.72 1.65 3.38 0x00000056 15.05 203 10 11 0.03 1.62 3.38 0 0.13
207^C 204^C
208[root@x980 ~]#
209.fi 205.fi
210.SH NOTES 206.SH NOTES
211 207
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index ce6d46038f74..6f3214ed4444 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -58,6 +58,7 @@ unsigned int extra_msr_offset32;
58unsigned int extra_msr_offset64; 58unsigned int extra_msr_offset64;
59unsigned int extra_delta_offset32; 59unsigned int extra_delta_offset32;
60unsigned int extra_delta_offset64; 60unsigned int extra_delta_offset64;
61int do_smi;
61double bclk; 62double bclk;
62unsigned int show_pkg; 63unsigned int show_pkg;
63unsigned int show_core; 64unsigned int show_core;
@@ -99,6 +100,7 @@ struct thread_data {
99 unsigned long long extra_delta64; 100 unsigned long long extra_delta64;
100 unsigned long long extra_msr32; 101 unsigned long long extra_msr32;
101 unsigned long long extra_delta32; 102 unsigned long long extra_delta32;
103 unsigned int smi_count;
102 unsigned int cpu_id; 104 unsigned int cpu_id;
103 unsigned int flags; 105 unsigned int flags;
104#define CPU_IS_FIRST_THREAD_IN_CORE 0x2 106#define CPU_IS_FIRST_THREAD_IN_CORE 0x2
@@ -248,6 +250,8 @@ void print_header(void)
248 if (has_aperf) 250 if (has_aperf)
249 outp += sprintf(outp, " GHz"); 251 outp += sprintf(outp, " GHz");
250 outp += sprintf(outp, " TSC"); 252 outp += sprintf(outp, " TSC");
253 if (do_smi)
254 outp += sprintf(outp, " SMI");
251 if (extra_delta_offset32) 255 if (extra_delta_offset32)
252 outp += sprintf(outp, " count 0x%03X", extra_delta_offset32); 256 outp += sprintf(outp, " count 0x%03X", extra_delta_offset32);
253 if (extra_delta_offset64) 257 if (extra_delta_offset64)
@@ -314,6 +318,8 @@ int dump_counters(struct thread_data *t, struct core_data *c,
314 extra_msr_offset32, t->extra_msr32); 318 extra_msr_offset32, t->extra_msr32);
315 fprintf(stderr, "msr0x%x: %016llX\n", 319 fprintf(stderr, "msr0x%x: %016llX\n",
316 extra_msr_offset64, t->extra_msr64); 320 extra_msr_offset64, t->extra_msr64);
321 if (do_smi)
322 fprintf(stderr, "SMI: %08X\n", t->smi_count);
317 } 323 }
318 324
319 if (c) { 325 if (c) {
@@ -352,6 +358,7 @@ int dump_counters(struct thread_data *t, struct core_data *c,
352 * RAM_W: %5.2 358 * RAM_W: %5.2
353 * GHz: "GHz" 3 columns %3.2 359 * GHz: "GHz" 3 columns %3.2
354 * TSC: "TSC" 3 columns %3.2 360 * TSC: "TSC" 3 columns %3.2
361 * SMI: "SMI" 4 columns %4d
355 * percentage " %pc3" %6.2 362 * percentage " %pc3" %6.2
356 * Perf Status percentage: %5.2 363 * Perf Status percentage: %5.2
357 * "CTMP" 4 columns %4d 364 * "CTMP" 4 columns %4d
@@ -431,6 +438,10 @@ int format_counters(struct thread_data *t, struct core_data *c,
431 /* TSC */ 438 /* TSC */
432 outp += sprintf(outp, "%5.2f", 1.0 * t->tsc/units/interval_float); 439 outp += sprintf(outp, "%5.2f", 1.0 * t->tsc/units/interval_float);
433 440
441 /* SMI */
442 if (do_smi)
443 outp += sprintf(outp, "%4d", t->smi_count);
444
434 /* delta */ 445 /* delta */
435 if (extra_delta_offset32) 446 if (extra_delta_offset32)
436 outp += sprintf(outp, " %11llu", t->extra_delta32); 447 outp += sprintf(outp, " %11llu", t->extra_delta32);
@@ -645,6 +656,9 @@ delta_thread(struct thread_data *new, struct thread_data *old,
645 */ 656 */
646 old->extra_msr32 = new->extra_msr32; 657 old->extra_msr32 = new->extra_msr32;
647 old->extra_msr64 = new->extra_msr64; 658 old->extra_msr64 = new->extra_msr64;
659
660 if (do_smi)
661 old->smi_count = new->smi_count - old->smi_count;
648} 662}
649 663
650int delta_cpu(struct thread_data *t, struct core_data *c, 664int delta_cpu(struct thread_data *t, struct core_data *c,
@@ -672,6 +686,7 @@ void clear_counters(struct thread_data *t, struct core_data *c, struct pkg_data
672 t->mperf = 0; 686 t->mperf = 0;
673 t->c1 = 0; 687 t->c1 = 0;
674 688
689 t->smi_count = 0;
675 t->extra_delta32 = 0; 690 t->extra_delta32 = 0;
676 t->extra_delta64 = 0; 691 t->extra_delta64 = 0;
677 692
@@ -802,6 +817,11 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
802 return -4; 817 return -4;
803 } 818 }
804 819
820 if (do_smi) {
821 if (get_msr(cpu, MSR_SMI_COUNT, &msr))
822 return -5;
823 t->smi_count = msr & 0xFFFFFFFF;
824 }
805 if (extra_delta_offset32) { 825 if (extra_delta_offset32) {
806 if (get_msr(cpu, extra_delta_offset32, &msr)) 826 if (get_msr(cpu, extra_delta_offset32, &msr))
807 return -5; 827 return -5;
@@ -908,8 +928,7 @@ void print_verbose_header(void)
908 928
909 get_msr(0, MSR_NHM_PLATFORM_INFO, &msr); 929 get_msr(0, MSR_NHM_PLATFORM_INFO, &msr);
910 930
911 if (verbose) 931 fprintf(stderr, "cpu0: MSR_NHM_PLATFORM_INFO: 0x%08llx\n", msr);
912 fprintf(stderr, "cpu0: MSR_NHM_PLATFORM_INFO: 0x%08llx\n", msr);
913 932
914 ratio = (msr >> 40) & 0xFF; 933 ratio = (msr >> 40) & 0xFF;
915 fprintf(stderr, "%d * %.0f = %.0f MHz max efficiency\n", 934 fprintf(stderr, "%d * %.0f = %.0f MHz max efficiency\n",
@@ -919,13 +938,16 @@ void print_verbose_header(void)
919 fprintf(stderr, "%d * %.0f = %.0f MHz TSC frequency\n", 938 fprintf(stderr, "%d * %.0f = %.0f MHz TSC frequency\n",
920 ratio, bclk, ratio * bclk); 939 ratio, bclk, ratio * bclk);
921 940
941 get_msr(0, MSR_IA32_POWER_CTL, &msr);
942 fprintf(stderr, "cpu0: MSR_IA32_POWER_CTL: 0x%08llx (C1E: %sabled)\n",
943 msr, msr & 0x2 ? "EN" : "DIS");
944
922 if (!do_ivt_turbo_ratio_limit) 945 if (!do_ivt_turbo_ratio_limit)
923 goto print_nhm_turbo_ratio_limits; 946 goto print_nhm_turbo_ratio_limits;
924 947
925 get_msr(0, MSR_IVT_TURBO_RATIO_LIMIT, &msr); 948 get_msr(0, MSR_IVT_TURBO_RATIO_LIMIT, &msr);
926 949
927 if (verbose) 950 fprintf(stderr, "cpu0: MSR_IVT_TURBO_RATIO_LIMIT: 0x%08llx\n", msr);
928 fprintf(stderr, "cpu0: MSR_IVT_TURBO_RATIO_LIMIT: 0x%08llx\n", msr);
929 951
930 ratio = (msr >> 56) & 0xFF; 952 ratio = (msr >> 56) & 0xFF;
931 if (ratio) 953 if (ratio)
@@ -1016,8 +1038,7 @@ print_nhm_turbo_ratio_limits:
1016 1038
1017 get_msr(0, MSR_NHM_TURBO_RATIO_LIMIT, &msr); 1039 get_msr(0, MSR_NHM_TURBO_RATIO_LIMIT, &msr);
1018 1040
1019 if (verbose) 1041 fprintf(stderr, "cpu0: MSR_NHM_TURBO_RATIO_LIMIT: 0x%08llx\n", msr);
1020 fprintf(stderr, "cpu0: MSR_NHM_TURBO_RATIO_LIMIT: 0x%08llx\n", msr);
1021 1042
1022 ratio = (msr >> 56) & 0xFF; 1043 ratio = (msr >> 56) & 0xFF;
1023 if (ratio) 1044 if (ratio)
@@ -1397,6 +1418,9 @@ int has_nehalem_turbo_ratio_limit(unsigned int family, unsigned int model)
1397 case 0x2D: /* SNB Xeon */ 1418 case 0x2D: /* SNB Xeon */
1398 case 0x3A: /* IVB */ 1419 case 0x3A: /* IVB */
1399 case 0x3E: /* IVB Xeon */ 1420 case 0x3E: /* IVB Xeon */
1421 case 0x3C: /* HSW */
1422 case 0x3F: /* HSW */
1423 case 0x45: /* HSW */
1400 return 1; 1424 return 1;
1401 case 0x2E: /* Nehalem-EX Xeon - Beckton */ 1425 case 0x2E: /* Nehalem-EX Xeon - Beckton */
1402 case 0x2F: /* Westmere-EX Xeon - Eagleton */ 1426 case 0x2F: /* Westmere-EX Xeon - Eagleton */
@@ -1488,6 +1512,9 @@ void rapl_probe(unsigned int family, unsigned int model)
1488 switch (model) { 1512 switch (model) {
1489 case 0x2A: 1513 case 0x2A:
1490 case 0x3A: 1514 case 0x3A:
1515 case 0x3C: /* HSW */
1516 case 0x3F: /* HSW */
1517 case 0x45: /* HSW */
1491 do_rapl = RAPL_PKG | RAPL_CORES | RAPL_GFX; 1518 do_rapl = RAPL_PKG | RAPL_CORES | RAPL_GFX;
1492 break; 1519 break;
1493 case 0x2D: 1520 case 0x2D:
@@ -1724,6 +1751,9 @@ int is_snb(unsigned int family, unsigned int model)
1724 case 0x2D: 1751 case 0x2D:
1725 case 0x3A: /* IVB */ 1752 case 0x3A: /* IVB */
1726 case 0x3E: /* IVB Xeon */ 1753 case 0x3E: /* IVB Xeon */
1754 case 0x3C: /* HSW */
1755 case 0x3F: /* HSW */
1756 case 0x45: /* HSW */
1727 return 1; 1757 return 1;
1728 } 1758 }
1729 return 0; 1759 return 0;
@@ -1883,6 +1913,7 @@ void check_cpuid()
1883 1913
1884 do_nehalem_platform_info = genuine_intel && has_invariant_tsc; 1914 do_nehalem_platform_info = genuine_intel && has_invariant_tsc;
1885 do_nhm_cstates = genuine_intel; /* all Intel w/ non-stop TSC have NHM counters */ 1915 do_nhm_cstates = genuine_intel; /* all Intel w/ non-stop TSC have NHM counters */
1916 do_smi = do_nhm_cstates;
1886 do_snb_cstates = is_snb(family, model); 1917 do_snb_cstates = is_snb(family, model);
1887 bclk = discover_bclk(family, model); 1918 bclk = discover_bclk(family, model);
1888 1919
@@ -2219,9 +2250,6 @@ void cmdline(int argc, char **argv)
2219 case 'c': 2250 case 'c':
2220 sscanf(optarg, "%x", &extra_delta_offset32); 2251 sscanf(optarg, "%x", &extra_delta_offset32);
2221 break; 2252 break;
2222 case 's':
2223 extra_delta_offset32 = 0x34; /* SMI counter */
2224 break;
2225 case 'C': 2253 case 'C':
2226 sscanf(optarg, "%x", &extra_delta_offset64); 2254 sscanf(optarg, "%x", &extra_delta_offset64);
2227 break; 2255 break;
@@ -2248,7 +2276,7 @@ int main(int argc, char **argv)
2248 cmdline(argc, argv); 2276 cmdline(argc, argv);
2249 2277
2250 if (verbose) 2278 if (verbose)
2251 fprintf(stderr, "turbostat v3.0 November 23, 2012" 2279 fprintf(stderr, "turbostat v3.2 February 11, 2013"
2252 " - Len Brown <lenb@kernel.org>\n"); 2280 " - Len Brown <lenb@kernel.org>\n");
2253 2281
2254 turbostat_init(); 2282 turbostat_init();