acpi.c (129804) | acpi.c (129805) |
---|---|
1/*- 2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org> 3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> 4 * Copyright (c) 2000, 2001 Michael Smith 5 * Copyright (c) 2000 BSDi 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org> 3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> 4 * Copyright (c) 2000, 2001 Michael Smith 5 * Copyright (c) 2000 BSDi 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/dev/acpica/acpi.c 129804 2004-05-28 06:32:16Z njl $ | 29 * $FreeBSD: head/sys/dev/acpica/acpi.c 129805 2004-05-28 07:04:09Z njl $ |
30 */ 31 32#include "opt_acpi.h" 33#include <sys/param.h> 34#include <sys/kernel.h> 35#include <sys/proc.h> 36#include <sys/fcntl.h> 37#include <sys/malloc.h> --- 1793 unchanged lines hidden (view full) --- 1831} 1832 1833/* Configure a device's GPE appropriately for the new sleep state. */ 1834int 1835acpi_wake_sleep_prep(device_t dev, int sstate) 1836{ 1837 struct acpi_prw_data prw; 1838 ACPI_HANDLE handle; | 30 */ 31 32#include "opt_acpi.h" 33#include <sys/param.h> 34#include <sys/kernel.h> 35#include <sys/proc.h> 36#include <sys/fcntl.h> 37#include <sys/malloc.h> --- 1793 unchanged lines hidden (view full) --- 1831} 1832 1833/* Configure a device's GPE appropriately for the new sleep state. */ 1834int 1835acpi_wake_sleep_prep(device_t dev, int sstate) 1836{ 1837 struct acpi_prw_data prw; 1838 ACPI_HANDLE handle; |
1839 int flags; |
|
1839 1840 /* Check that this is an ACPI device and get its GPE. */ | 1840 1841 /* Check that this is an ACPI device and get its GPE. */ |
1842 flags = device_get_flags(dev); |
|
1841 handle = acpi_get_handle(dev); | 1843 handle = acpi_get_handle(dev); |
1842 if (handle == NULL) | 1844 if ((flags & ACPI_FLAG_WAKE_CAPABLE) == 0 || handle == NULL) |
1843 return (ENXIO); | 1845 return (ENXIO); |
1846 1847 /* Evaluate _PRW to find the GPE. */ |
|
1844 if (acpi_parse_prw(handle, &prw) != 0) 1845 return (ENXIO); 1846 1847 /* | 1848 if (acpi_parse_prw(handle, &prw) != 0) 1849 return (ENXIO); 1850 1851 /* |
1848 * The sleeping state being entered must be less than (i.e., higher power) 1849 * or equal to the value specified by _PRW. If not, disable this GPE. | 1852 * TBD: All Power Resources referenced by elements 2 through N 1853 * of the _PRW object are put into the ON state. |
1850 */ | 1854 */ |
1851 if (sstate > prw.lowest_wake) { | 1855 1856 /* 1857 * If the user requested that this device wake the system and the next 1858 * sleep state is valid for this GPE, enable it and the device's wake 1859 * capability. The sleep state must be less than (i.e., higher power) 1860 * or equal to the value specified by _PRW. Return early, leaving 1861 * the appropriate power resources enabled. 1862 */ 1863 if ((flags & ACPI_FLAG_WAKE_ENABLED) != 0 && 1864 sstate <= prw.lowest_wake) { |
1852 if (bootverbose) | 1865 if (bootverbose) |
1853 device_printf(dev, "wake_prep disabled gpe %#x for state %d\n", | 1866 device_printf(dev, "wake_prep enabled gpe %#x for state %d\n", |
1854 prw.gpe_bit, sstate); | 1867 prw.gpe_bit, sstate); |
1855 AcpiDisableGpe(prw.gpe_handle, prw.gpe_bit, ACPI_NOT_ISR); 1856 acpi_SetInteger(handle, "_PSW", 0); | 1868 AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit, ACPI_NOT_ISR); 1869 acpi_SetInteger(handle, "_PSW", 1); |
1857 return (0); 1858 } 1859 1860 /* | 1870 return (0); 1871 } 1872 1873 /* |
1861 * If requested, enable the device's wake capability. 1862 * | 1874 * If the device wake was disabled or this sleep state is too low for 1875 * this device, disable its wake capability and GPE. 1876 */ 1877 AcpiDisableGpe(prw.gpe_handle, prw.gpe_bit, ACPI_NOT_ISR); 1878 acpi_SetInteger(handle, "_PSW", 0); 1879 if (bootverbose) 1880 device_printf(dev, "wake_prep disabled gpe %#x for state %d\n", 1881 prw.gpe_bit, sstate); 1882 1883 /* |
1863 * TBD: All Power Resources referenced by elements 2 through N | 1884 * TBD: All Power Resources referenced by elements 2 through N |
1864 * of the _PRW object are put into the ON state. 1865 */ 1866 if ((device_get_flags(dev) & ACPI_FLAG_WAKE_ENABLED) != 0) { 1867 if (bootverbose) 1868 device_printf(dev, "wake_prep enabled _PSW for state %d\n", sstate); 1869 acpi_SetInteger(handle, "_PSW", 1); 1870 } | 1885 * of the _PRW object are put into the OFF state. 1886 */ |
1871 1872 return (0); 1873} 1874 | 1887 1888 return (0); 1889} 1890 |
1891/* Re-enable GPEs after wake. */ 1892int 1893acpi_wake_run_prep(device_t dev) 1894{ 1895 struct acpi_prw_data prw; 1896 ACPI_HANDLE handle; 1897 int flags; 1898 1899 /* Check that this is an ACPI device and get its GPE. */ 1900 flags = device_get_flags(dev); 1901 handle = acpi_get_handle(dev); 1902 if ((flags & ACPI_FLAG_WAKE_CAPABLE) == 0 || handle == NULL) 1903 return (ENXIO); 1904 1905 /* Evaluate _PRW to find the GPE. */ 1906 if (acpi_parse_prw(handle, &prw) != 0) 1907 return (ENXIO); 1908 1909 /* 1910 * TBD: Be sure all Power Resources referenced by elements 2 through N 1911 * of the _PRW object are in the ON state. 1912 */ 1913 1914 /* Disable wake capability and if the user requested, enable the GPE. */ 1915 acpi_SetInteger(handle, "_PSW", 0); 1916 if ((flags & ACPI_FLAG_WAKE_ENABLED) != 0) 1917 AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit, ACPI_NOT_ISR); 1918 return (0); 1919} 1920 |
|
1875static ACPI_STATUS 1876acpi_wake_limit(ACPI_HANDLE h, UINT32 level, void *context, void **status) 1877{ 1878 struct acpi_prw_data prw; 1879 int *sstate; 1880 1881 /* It's ok not to have _PRW if the device can't wake the system. */ 1882 if (acpi_parse_prw(h, &prw) != 0) --- 861 unchanged lines hidden --- | 1921static ACPI_STATUS 1922acpi_wake_limit(ACPI_HANDLE h, UINT32 level, void *context, void **status) 1923{ 1924 struct acpi_prw_data prw; 1925 int *sstate; 1926 1927 /* It's ok not to have _PRW if the device can't wake the system. */ 1928 if (acpi_parse_prw(h, &prw) != 0) --- 861 unchanged lines hidden --- |