Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * ACPI Hardware Error Device (PNP0C33) Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2010, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *	Author: Huang Ying <ying.huang@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * ACPI Hardware Error Device is used to report some hardware errors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  * notified via SCI, mainly the corrected errors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <acpi/hed.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static const struct acpi_device_id acpi_hed_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	{"PNP0C33", 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	{"", 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) MODULE_DEVICE_TABLE(acpi, acpi_hed_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static acpi_handle hed_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static BLOCKING_NOTIFIER_HEAD(acpi_hed_notify_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int register_acpi_hed_notifier(struct notifier_block *nb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	return blocking_notifier_chain_register(&acpi_hed_notify_list, nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) EXPORT_SYMBOL_GPL(register_acpi_hed_notifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) void unregister_acpi_hed_notifier(struct notifier_block *nb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	blocking_notifier_chain_unregister(&acpi_hed_notify_list, nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) EXPORT_SYMBOL_GPL(unregister_acpi_hed_notifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)  * SCI to report hardware error is forwarded to the listeners of HED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)  * it is used by HEST Generic Hardware Error Source with notify type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)  * SCI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static void acpi_hed_notify(struct acpi_device *device, u32 event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static int acpi_hed_add(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	/* Only one hardware error device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	if (hed_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	hed_handle = device->handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static int acpi_hed_remove(struct acpi_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	hed_handle = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static struct acpi_driver acpi_hed_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	.name = "hardware_error_device",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	.class = "hardware_error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	.ids = acpi_hed_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	.ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		.add = acpi_hed_add,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 		.remove = acpi_hed_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 		.notify = acpi_hed_notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) module_acpi_driver(acpi_hed_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) ACPI_MODULE_NAME("hed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) MODULE_AUTHOR("Huang Ying");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) MODULE_DESCRIPTION("ACPI Hardware Error Device Driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) MODULE_LICENSE("GPL");