forked from luck/tmp_suning_uos_patched
eec15edbb0
ACPI can be used to enumerate PNP devices, but the code does not handle this in the right way currently. Namely, if an ACPI device object 1. Has a _CRS method, 2. Has an identification of "three capital characters followed by four hex digits", 3. Is not in the excluded IDs list, it will be enumerated to PNP bus (that is, a PNP device object will be create for it). This means that, actually, the PNP bus type is used as the default bus type for enumerating _HID devices in ACPI. However, more and more _HID devices need to be enumerated to the platform bus instead (that is, platform device objects need to be created for them). As a result, the device ID list in acpi_platform.c is used to enforce creating platform device objects rather than PNP device objects for matching devices. That list has been continuously growing recently, unfortunately, and it is pretty much guaranteed to grow even more in the future. To address that problem it is better to enumerate _HID devices as platform devices by default. To this end, change the way of enumerating PNP devices by adding a PNP ACPI scan handler that will use a device ID list to create PNP devices for the ACPI device objects whose device IDs are present in that list. The initial device ID list in the PNP ACPI scan handler contains all of the pnp_device_id strings from all the existing PNP drivers, so this change should be transparent to the PNP core and all of the PNP drivers. Still, in the future it should be possible to reduce its size by converting PNP drivers that need not be PNP for any technical reasons into platform drivers. Signed-off-by: Zhang Rui <rui.zhang@intel.com> [rjw: Rewrote the changelog, modified the PNP ACPI scan handler code] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
91 lines
2.1 KiB
C
91 lines
2.1 KiB
C
/*
|
|
* ACPI support for CMOS RTC Address Space access
|
|
*
|
|
* Copyright (C) 2013, Intel Corporation
|
|
* Authors: Lan Tianyu <tianyu.lan@intel.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include <linux/acpi.h>
|
|
#include <linux/device.h>
|
|
#include <linux/err.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <asm-generic/rtc.h>
|
|
|
|
#include "internal.h"
|
|
|
|
ACPI_MODULE_NAME("cmos rtc");
|
|
|
|
static const struct acpi_device_id acpi_cmos_rtc_ids[] = {
|
|
{ "PNP0B00" },
|
|
{ "PNP0B01" },
|
|
{ "PNP0B02" },
|
|
{}
|
|
};
|
|
|
|
static acpi_status
|
|
acpi_cmos_rtc_space_handler(u32 function, acpi_physical_address address,
|
|
u32 bits, u64 *value64,
|
|
void *handler_context, void *region_context)
|
|
{
|
|
int i;
|
|
u8 *value = (u8 *)&value64;
|
|
|
|
if (address > 0xff || !value64)
|
|
return AE_BAD_PARAMETER;
|
|
|
|
if (function != ACPI_WRITE && function != ACPI_READ)
|
|
return AE_BAD_PARAMETER;
|
|
|
|
spin_lock_irq(&rtc_lock);
|
|
|
|
for (i = 0; i < DIV_ROUND_UP(bits, 8); ++i, ++address, ++value)
|
|
if (function == ACPI_READ)
|
|
*value = CMOS_READ(address);
|
|
else
|
|
CMOS_WRITE(*value, address);
|
|
|
|
spin_unlock_irq(&rtc_lock);
|
|
|
|
return AE_OK;
|
|
}
|
|
|
|
static int acpi_install_cmos_rtc_space_handler(struct acpi_device *adev,
|
|
const struct acpi_device_id *id)
|
|
{
|
|
acpi_status status;
|
|
|
|
status = acpi_install_address_space_handler(adev->handle,
|
|
ACPI_ADR_SPACE_CMOS,
|
|
&acpi_cmos_rtc_space_handler,
|
|
NULL, NULL);
|
|
if (ACPI_FAILURE(status)) {
|
|
pr_err(PREFIX "Error installing CMOS-RTC region handler\n");
|
|
return -ENODEV;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
static void acpi_remove_cmos_rtc_space_handler(struct acpi_device *adev)
|
|
{
|
|
if (ACPI_FAILURE(acpi_remove_address_space_handler(adev->handle,
|
|
ACPI_ADR_SPACE_CMOS, &acpi_cmos_rtc_space_handler)))
|
|
pr_err(PREFIX "Error removing CMOS-RTC region handler\n");
|
|
}
|
|
|
|
static struct acpi_scan_handler cmos_rtc_handler = {
|
|
.ids = acpi_cmos_rtc_ids,
|
|
.attach = acpi_install_cmos_rtc_space_handler,
|
|
.detach = acpi_remove_cmos_rtc_space_handler,
|
|
};
|
|
|
|
void __init acpi_cmos_rtc_init(void)
|
|
{
|
|
acpi_scan_add_handler(&cmos_rtc_handler);
|
|
}
|