2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* pnpacpi -- PnP ACPI driver
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr>
|
|
|
|
* Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com>
|
2007-05-08 15:28:35 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2007-05-08 15:28:35 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/acpi.h>
|
|
|
|
#include <linux/pnp.h>
|
2007-07-23 20:43:51 +08:00
|
|
|
#include <linux/mod_devicetable.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <acpi/acpi_bus.h>
|
2007-07-23 20:43:51 +08:00
|
|
|
|
2008-04-29 06:33:51 +08:00
|
|
|
#include "../base.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "pnpacpi.h"
|
|
|
|
|
|
|
|
static int num = 0;
|
|
|
|
|
2006-01-06 14:31:00 +08:00
|
|
|
/* We need only to blacklist devices that have already an acpi driver that
|
|
|
|
* can't use pnp layer. We don't need to blacklist device that are directly
|
|
|
|
* used by the kernel (PCI root, ...), as it is harmless and there were
|
|
|
|
* already present in pnpbios. But there is an exception for devices that
|
|
|
|
* have irqs (PIC, Timer) because we call acpi_register_gsi.
|
2007-07-27 01:41:21 +08:00
|
|
|
* Finally, only devices that have a CRS method need to be in this list.
|
2006-01-06 14:31:00 +08:00
|
|
|
*/
|
2008-02-11 23:05:35 +08:00
|
|
|
static struct acpi_device_id excluded_id_list[] __initdata = {
|
2007-07-27 01:41:20 +08:00
|
|
|
{"PNP0C09", 0}, /* EC */
|
|
|
|
{"PNP0C0F", 0}, /* Link device */
|
|
|
|
{"PNP0000", 0}, /* PIC */
|
|
|
|
{"PNP0100", 0}, /* Timer */
|
2007-07-23 20:43:51 +08:00
|
|
|
{"", 0},
|
|
|
|
};
|
|
|
|
|
2008-04-30 04:52:01 +08:00
|
|
|
static inline int __init is_exclusive_device(struct acpi_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-07-23 20:43:51 +08:00
|
|
|
return (!acpi_match_device_ids(dev, excluded_id_list));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compatible Device IDs
|
|
|
|
*/
|
|
|
|
#define TEST_HEX(c) \
|
|
|
|
if (!(('0' <= (c) && (c) <= '9') || ('A' <= (c) && (c) <= 'F'))) \
|
|
|
|
return 0
|
|
|
|
#define TEST_ALPHA(c) \
|
|
|
|
if (!('@' <= (c) || (c) <= 'Z')) \
|
|
|
|
return 0
|
|
|
|
static int __init ispnpidacpi(char *id)
|
|
|
|
{
|
|
|
|
TEST_ALPHA(id[0]);
|
|
|
|
TEST_ALPHA(id[1]);
|
|
|
|
TEST_ALPHA(id[2]);
|
|
|
|
TEST_HEX(id[3]);
|
|
|
|
TEST_HEX(id[4]);
|
|
|
|
TEST_HEX(id[5]);
|
|
|
|
TEST_HEX(id[6]);
|
|
|
|
if (id[7] != '\0')
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-04-29 06:34:05 +08:00
|
|
|
static int pnpacpi_get_resources(struct pnp_dev *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-08-20 06:53:47 +08:00
|
|
|
pnp_dbg(&dev->dev, "get resources\n");
|
2008-04-29 06:34:39 +08:00
|
|
|
return pnpacpi_parse_allocated_resource(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-04-29 06:34:05 +08:00
|
|
|
static int pnpacpi_set_resources(struct pnp_dev *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-11-18 08:05:14 +08:00
|
|
|
struct acpi_device *acpi_dev = dev->data;
|
|
|
|
acpi_handle handle = acpi_dev->handle;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct acpi_buffer buffer;
|
2008-04-29 06:34:03 +08:00
|
|
|
int ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-08-20 06:53:47 +08:00
|
|
|
pnp_dbg(&dev->dev, "set resources\n");
|
2008-04-29 06:34:03 +08:00
|
|
|
ret = pnpacpi_build_resource_template(dev, &buffer);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2008-04-29 06:34:06 +08:00
|
|
|
ret = pnpacpi_encode_resources(dev, &buffer);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ret) {
|
|
|
|
kfree(buffer.pointer);
|
|
|
|
return ret;
|
|
|
|
}
|
Enable PNPACPI _PSx Support, v3
(This is an update to the patch presented earlier in
http://lkml.org/lkml/2008/12/8/284, with new error handling.)
This patch sets the power of PnP ACPI devices to D0 when they
are activated and to D3 when they are disabled. The latter is
in correspondence with the ACPI 3.0 specification, whereas the
former is added in order to be able to power up a device after
it has been previously disabled (or when booting up a system).
(As a consequence, the patch makes the PnP ACPI code more ACPI
compliant.)
Section 6.2.2 of the ACPI Specification (at least versions 1.0b
and 3.0a) states: "Prior to running this control method [_DIS],
the OS[PM] will have already put the device in the D3 state."
Unfortunately, there is no clear statement as to when to put
a device in the D0 state. :-( Therefore, the patch executes the
method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the
device is disabled, _SRS enables the device at the specified
resources." (From the ACPI 3.0a Specification.)
The patch fixes a problem with some IBM ThinkPads (at least the
600E and the 600X) where the serial ports have a dedicated
power source that needs to be brought up before the serial port
can be used. Without this patch, the serial port is enabled
but has no power. (In the past, the tpctl utility had to be
utilized to turn on the power, but support for this feature
stopped with version 5.9 as it did not support the more recent
kernel versions.)
The error handlers that handle any errors that can occur during
the power up/power down phases return the error codes to the
caller directly. Comments welcome! :-)
No regressions were observed on hardware that does not require
this patch.
The patch is applied against 2.6.27.x.
Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net>
Acked-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-03-31 01:31:06 +08:00
|
|
|
if (ACPI_FAILURE(acpi_set_current_resources(handle, &buffer)))
|
2005-04-17 06:20:36 +08:00
|
|
|
ret = -EINVAL;
|
Enable PNPACPI _PSx Support, v3
(This is an update to the patch presented earlier in
http://lkml.org/lkml/2008/12/8/284, with new error handling.)
This patch sets the power of PnP ACPI devices to D0 when they
are activated and to D3 when they are disabled. The latter is
in correspondence with the ACPI 3.0 specification, whereas the
former is added in order to be able to power up a device after
it has been previously disabled (or when booting up a system).
(As a consequence, the patch makes the PnP ACPI code more ACPI
compliant.)
Section 6.2.2 of the ACPI Specification (at least versions 1.0b
and 3.0a) states: "Prior to running this control method [_DIS],
the OS[PM] will have already put the device in the D3 state."
Unfortunately, there is no clear statement as to when to put
a device in the D0 state. :-( Therefore, the patch executes the
method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the
device is disabled, _SRS enables the device at the specified
resources." (From the ACPI 3.0a Specification.)
The patch fixes a problem with some IBM ThinkPads (at least the
600E and the 600X) where the serial ports have a dedicated
power source that needs to be brought up before the serial port
can be used. Without this patch, the serial port is enabled
but has no power. (In the past, the tpctl utility had to be
utilized to turn on the power, but support for this feature
stopped with version 5.9 as it did not support the more recent
kernel versions.)
The error handlers that handle any errors that can occur during
the power up/power down phases return the error codes to the
caller directly. Comments welcome! :-)
No regressions were observed on hardware that does not require
this patch.
The patch is applied against 2.6.27.x.
Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net>
Acked-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-03-31 01:31:06 +08:00
|
|
|
else if (acpi_bus_power_manageable(handle))
|
|
|
|
ret = acpi_bus_set_power(handle, ACPI_STATE_D0);
|
2005-04-17 06:20:36 +08:00
|
|
|
kfree(buffer.pointer);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pnpacpi_disable_resources(struct pnp_dev *dev)
|
|
|
|
{
|
2009-11-18 08:05:14 +08:00
|
|
|
struct acpi_device *acpi_dev = dev->data;
|
|
|
|
acpi_handle handle = acpi_dev->handle;
|
Enable PNPACPI _PSx Support, v3
(This is an update to the patch presented earlier in
http://lkml.org/lkml/2008/12/8/284, with new error handling.)
This patch sets the power of PnP ACPI devices to D0 when they
are activated and to D3 when they are disabled. The latter is
in correspondence with the ACPI 3.0 specification, whereas the
former is added in order to be able to power up a device after
it has been previously disabled (or when booting up a system).
(As a consequence, the patch makes the PnP ACPI code more ACPI
compliant.)
Section 6.2.2 of the ACPI Specification (at least versions 1.0b
and 3.0a) states: "Prior to running this control method [_DIS],
the OS[PM] will have already put the device in the D3 state."
Unfortunately, there is no clear statement as to when to put
a device in the D0 state. :-( Therefore, the patch executes the
method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the
device is disabled, _SRS enables the device at the specified
resources." (From the ACPI 3.0a Specification.)
The patch fixes a problem with some IBM ThinkPads (at least the
600E and the 600X) where the serial ports have a dedicated
power source that needs to be brought up before the serial port
can be used. Without this patch, the serial port is enabled
but has no power. (In the past, the tpctl utility had to be
utilized to turn on the power, but support for this feature
stopped with version 5.9 as it did not support the more recent
kernel versions.)
The error handlers that handle any errors that can occur during
the power up/power down phases return the error codes to the
caller directly. Comments welcome! :-)
No regressions were observed on hardware that does not require
this patch.
The patch is applied against 2.6.27.x.
Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net>
Acked-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-03-31 01:31:06 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
dev_dbg(&dev->dev, "disable resources\n");
|
2007-05-08 15:28:35 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* acpi_unregister_gsi(pnp_irq(dev, 0)); */
|
Enable PNPACPI _PSx Support, v3
(This is an update to the patch presented earlier in
http://lkml.org/lkml/2008/12/8/284, with new error handling.)
This patch sets the power of PnP ACPI devices to D0 when they
are activated and to D3 when they are disabled. The latter is
in correspondence with the ACPI 3.0 specification, whereas the
former is added in order to be able to power up a device after
it has been previously disabled (or when booting up a system).
(As a consequence, the patch makes the PnP ACPI code more ACPI
compliant.)
Section 6.2.2 of the ACPI Specification (at least versions 1.0b
and 3.0a) states: "Prior to running this control method [_DIS],
the OS[PM] will have already put the device in the D3 state."
Unfortunately, there is no clear statement as to when to put
a device in the D0 state. :-( Therefore, the patch executes the
method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the
device is disabled, _SRS enables the device at the specified
resources." (From the ACPI 3.0a Specification.)
The patch fixes a problem with some IBM ThinkPads (at least the
600E and the 600X) where the serial ports have a dedicated
power source that needs to be brought up before the serial port
can be used. Without this patch, the serial port is enabled
but has no power. (In the past, the tpctl utility had to be
utilized to turn on the power, but support for this feature
stopped with version 5.9 as it did not support the more recent
kernel versions.)
The error handlers that handle any errors that can occur during
the power up/power down phases return the error codes to the
caller directly. Comments welcome! :-)
No regressions were observed on hardware that does not require
this patch.
The patch is applied against 2.6.27.x.
Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net>
Acked-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-03-31 01:31:06 +08:00
|
|
|
ret = 0;
|
2009-05-08 12:22:29 +08:00
|
|
|
if (acpi_bus_power_manageable(handle))
|
|
|
|
acpi_bus_set_power(handle, ACPI_STATE_D3);
|
|
|
|
/* continue even if acpi_bus_set_power() fails */
|
Enable PNPACPI _PSx Support, v3
(This is an update to the patch presented earlier in
http://lkml.org/lkml/2008/12/8/284, with new error handling.)
This patch sets the power of PnP ACPI devices to D0 when they
are activated and to D3 when they are disabled. The latter is
in correspondence with the ACPI 3.0 specification, whereas the
former is added in order to be able to power up a device after
it has been previously disabled (or when booting up a system).
(As a consequence, the patch makes the PnP ACPI code more ACPI
compliant.)
Section 6.2.2 of the ACPI Specification (at least versions 1.0b
and 3.0a) states: "Prior to running this control method [_DIS],
the OS[PM] will have already put the device in the D3 state."
Unfortunately, there is no clear statement as to when to put
a device in the D0 state. :-( Therefore, the patch executes the
method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the
device is disabled, _SRS enables the device at the specified
resources." (From the ACPI 3.0a Specification.)
The patch fixes a problem with some IBM ThinkPads (at least the
600E and the 600X) where the serial ports have a dedicated
power source that needs to be brought up before the serial port
can be used. Without this patch, the serial port is enabled
but has no power. (In the past, the tpctl utility had to be
utilized to turn on the power, but support for this feature
stopped with version 5.9 as it did not support the more recent
kernel versions.)
The error handlers that handle any errors that can occur during
the power up/power down phases return the error codes to the
caller directly. Comments welcome! :-)
No regressions were observed on hardware that does not require
this patch.
The patch is applied against 2.6.27.x.
Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net>
Acked-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-03-31 01:31:06 +08:00
|
|
|
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DIS", NULL, NULL)))
|
|
|
|
ret = -ENODEV;
|
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-07-28 15:33:16 +08:00
|
|
|
#ifdef CONFIG_ACPI_SLEEP
|
2007-07-20 10:03:20 +08:00
|
|
|
static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
|
|
|
|
{
|
2009-11-18 08:05:14 +08:00
|
|
|
struct acpi_device *acpi_dev = dev->data;
|
|
|
|
acpi_handle handle = acpi_dev->handle;
|
2007-10-17 14:31:06 +08:00
|
|
|
int power_state;
|
|
|
|
|
2008-06-05 07:15:40 +08:00
|
|
|
power_state = acpi_pm_device_sleep_state(&dev->dev, NULL);
|
2007-10-17 14:31:06 +08:00
|
|
|
if (power_state < 0)
|
|
|
|
power_state = (state.event == PM_EVENT_ON) ?
|
|
|
|
ACPI_STATE_D0 : ACPI_STATE_D3;
|
|
|
|
|
2009-11-18 08:05:14 +08:00
|
|
|
return acpi_bus_set_power(handle, power_state);
|
2007-07-20 10:03:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int pnpacpi_resume(struct pnp_dev *dev)
|
|
|
|
{
|
2009-11-18 08:05:14 +08:00
|
|
|
struct acpi_device *acpi_dev = dev->data;
|
|
|
|
acpi_handle handle = acpi_dev->handle;
|
|
|
|
|
|
|
|
return acpi_bus_set_power(handle, ACPI_STATE_D0);
|
2007-07-20 10:03:20 +08:00
|
|
|
}
|
2007-07-28 15:33:16 +08:00
|
|
|
#endif
|
2007-07-20 10:03:20 +08:00
|
|
|
|
2009-11-18 08:05:19 +08:00
|
|
|
struct pnp_protocol pnpacpi_protocol = {
|
2007-07-27 01:41:21 +08:00
|
|
|
.name = "Plug and Play ACPI",
|
|
|
|
.get = pnpacpi_get_resources,
|
|
|
|
.set = pnpacpi_set_resources,
|
2005-04-17 06:20:36 +08:00
|
|
|
.disable = pnpacpi_disable_resources,
|
2007-07-28 15:33:16 +08:00
|
|
|
#ifdef CONFIG_ACPI_SLEEP
|
2007-07-20 10:03:20 +08:00
|
|
|
.suspend = pnpacpi_suspend,
|
|
|
|
.resume = pnpacpi_resume,
|
2007-07-28 15:33:16 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
2009-11-18 08:05:19 +08:00
|
|
|
EXPORT_SYMBOL(pnpacpi_protocol);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int __init pnpacpi_add_device(struct acpi_device *device)
|
|
|
|
{
|
|
|
|
acpi_handle temp = NULL;
|
|
|
|
acpi_status status;
|
|
|
|
struct pnp_dev *dev;
|
2009-09-22 03:35:19 +08:00
|
|
|
struct acpi_hardware_id *id;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-08-11 13:40:22 +08:00
|
|
|
/*
|
|
|
|
* If a PnPacpi device is not present , the device
|
|
|
|
* driver should not be loaded.
|
|
|
|
*/
|
2006-01-06 14:31:00 +08:00
|
|
|
status = acpi_get_handle(device->handle, "_CRS", &temp);
|
|
|
|
if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) ||
|
2008-08-11 13:40:22 +08:00
|
|
|
is_exclusive_device(device) || (!device->status.present))
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
|
2008-04-29 06:33:54 +08:00
|
|
|
dev = pnp_alloc_dev(&pnpacpi_protocol, num, acpi_device_hid(device));
|
|
|
|
if (!dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENOMEM;
|
2008-04-29 06:33:54 +08:00
|
|
|
|
2009-11-18 08:05:14 +08:00
|
|
|
dev->data = device;
|
2007-07-27 01:41:21 +08:00
|
|
|
/* .enabled means the device can decode the resources */
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->active = device->status.enabled;
|
|
|
|
status = acpi_get_handle(device->handle, "_SRS", &temp);
|
|
|
|
if (ACPI_SUCCESS(status))
|
|
|
|
dev->capabilities |= PNP_CONFIGURABLE;
|
|
|
|
dev->capabilities |= PNP_READ;
|
2008-01-13 08:37:49 +08:00
|
|
|
if (device->flags.dynamic_status && (dev->capabilities & PNP_CONFIGURABLE))
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->capabilities |= PNP_WRITE;
|
|
|
|
if (device->flags.removable)
|
|
|
|
dev->capabilities |= PNP_REMOVABLE;
|
|
|
|
status = acpi_get_handle(device->handle, "_DIS", &temp);
|
|
|
|
if (ACPI_SUCCESS(status))
|
|
|
|
dev->capabilities |= PNP_DISABLE;
|
|
|
|
|
|
|
|
if (strlen(acpi_device_name(device)))
|
|
|
|
strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
|
|
|
|
else
|
|
|
|
strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
|
|
|
|
|
2008-04-29 06:34:39 +08:00
|
|
|
if (dev->active)
|
|
|
|
pnpacpi_parse_allocated_resource(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-29 06:34:39 +08:00
|
|
|
if (dev->capabilities & PNP_CONFIGURABLE)
|
|
|
|
pnpacpi_parse_resource_option_data(dev);
|
2007-05-08 15:28:35 +08:00
|
|
|
|
2009-09-22 03:35:19 +08:00
|
|
|
list_for_each_entry(id, &device->pnp.ids, list) {
|
|
|
|
if (!strcmp(id->id, acpi_device_hid(device)))
|
|
|
|
continue;
|
|
|
|
if (!ispnpidacpi(id->id))
|
|
|
|
continue;
|
|
|
|
pnp_add_id(dev, id->id);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clear out the damaged flags */
|
|
|
|
if (!dev->active)
|
2008-04-29 06:34:09 +08:00
|
|
|
pnp_init_resources(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
pnp_add_device(dev);
|
2007-07-27 01:41:20 +08:00
|
|
|
num++;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
|
2007-07-27 01:41:20 +08:00
|
|
|
u32 lvl, void *context,
|
|
|
|
void **rv)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct acpi_device *device;
|
|
|
|
|
|
|
|
if (!acpi_bus_get_device(handle, &device))
|
|
|
|
pnpacpi_add_device(device);
|
|
|
|
else
|
|
|
|
return AE_CTRL_DEPTH;
|
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
2007-05-08 15:28:35 +08:00
|
|
|
static int __init acpi_pnp_match(struct device *dev, void *_pnp)
|
|
|
|
{
|
2007-07-27 01:41:20 +08:00
|
|
|
struct acpi_device *acpi = to_acpi_device(dev);
|
|
|
|
struct pnp_dev *pnp = _pnp;
|
2007-05-08 15:28:35 +08:00
|
|
|
|
|
|
|
/* true means it matched */
|
2009-09-22 03:35:29 +08:00
|
|
|
return !acpi_get_physical_device(acpi->handle)
|
2009-09-22 03:35:09 +08:00
|
|
|
&& compare_pnp_id(pnp->id, acpi_device_hid(acpi));
|
2007-05-08 15:28:35 +08:00
|
|
|
}
|
|
|
|
|
2007-07-27 01:41:20 +08:00
|
|
|
static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle)
|
2007-05-08 15:28:35 +08:00
|
|
|
{
|
2007-07-27 01:41:20 +08:00
|
|
|
struct device *adev;
|
|
|
|
struct acpi_device *acpi;
|
2007-05-08 15:28:35 +08:00
|
|
|
|
|
|
|
adev = bus_find_device(&acpi_bus_type, NULL,
|
2007-07-27 01:41:20 +08:00
|
|
|
to_pnp_dev(dev), acpi_pnp_match);
|
2007-05-08 15:28:35 +08:00
|
|
|
if (!adev)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
acpi = to_acpi_device(adev);
|
|
|
|
*handle = acpi->handle;
|
|
|
|
put_device(adev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* complete initialization of a PNPACPI device includes having
|
|
|
|
* pnpdev->dev.archdata.acpi_handle point to its ACPI sibling.
|
|
|
|
*/
|
|
|
|
static struct acpi_bus_type __initdata acpi_pnp_bus = {
|
2007-07-27 01:41:21 +08:00
|
|
|
.bus = &pnp_bus_type,
|
2007-05-08 15:28:35 +08:00
|
|
|
.find_device = acpi_pnp_find_device,
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
int pnpacpi_disabled __initdata;
|
2005-11-07 17:01:48 +08:00
|
|
|
static int __init pnpacpi_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
if (acpi_disabled || pnpacpi_disabled) {
|
2008-08-20 06:53:26 +08:00
|
|
|
printk(KERN_INFO "pnp: PnP ACPI: disabled\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2008-08-20 06:53:26 +08:00
|
|
|
printk(KERN_INFO "pnp: PnP ACPI init\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
pnp_register_protocol(&pnpacpi_protocol);
|
2007-05-08 15:28:35 +08:00
|
|
|
register_acpi_bus_type(&acpi_pnp_bus);
|
2005-04-17 06:20:36 +08:00
|
|
|
acpi_get_devices(NULL, pnpacpi_add_device_handler, NULL, NULL);
|
2008-08-20 06:53:26 +08:00
|
|
|
printk(KERN_INFO "pnp: PnP ACPI: found %d devices\n", num);
|
2007-05-08 15:28:35 +08:00
|
|
|
unregister_acpi_bus_type(&acpi_pnp_bus);
|
2007-05-08 15:35:54 +08:00
|
|
|
pnp_platform_devices = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2007-07-27 01:41:20 +08:00
|
|
|
|
2008-10-10 23:00:17 +08:00
|
|
|
fs_initcall(pnpacpi_init);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int __init pnpacpi_setup(char *str)
|
|
|
|
{
|
|
|
|
if (str == NULL)
|
|
|
|
return 1;
|
|
|
|
if (!strncmp(str, "off", 3))
|
|
|
|
pnpacpi_disabled = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
2007-07-27 01:41:20 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
__setup("pnpacpi=", pnpacpi_setup);
|