From: Ding Tianhong dingtianhong@huawei.com
ascend inclusion category: feature bugzilla: NA CVE: NA
-------------------------------------------------
The Ascend910 platform only use the acpi mode to boot system, the oem message is recorded in the oem_table_id of IORT table, so use the oem message to enable the ascend features.
Signed-off-by: Ding Tianhong dingtianhong@huawei.com Reviewed-by: Hanjun Guo guohanjun@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- arch/arm64/mm/init.c | 7 ++++++- drivers/acpi/arm64/iort.c | 24 ++++++++++++++++++++++++ include/linux/init.h | 7 +++++++ 3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 883350f9cc42..f23da539a476 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -769,7 +769,7 @@ __setup("keepinitrd", keepinitrd_setup); #endif
#ifdef CONFIG_ASCEND_FEATURES -static int __init ascend_enable_setup(char *__unused) +void ascend_enable_all_features(void) { if (IS_ENABLED(CONFIG_ASCEND_DVPP_MMAP)) enable_mmap_dvpp = 1; @@ -782,6 +782,11 @@ static int __init ascend_enable_setup(char *__unused)
if (IS_ENABLED(CONFIG_SUSPEND)) mem_sleep_current = PM_SUSPEND_ON; +} + +static int __init ascend_enable_setup(char *__unused) +{ + ascend_enable_all_features();
return 1; } diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 5a724bdb4a4d..7408ffab7303 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -25,6 +25,7 @@ #include <linux/pci.h> #include <linux/platform_device.h> #include <linux/slab.h> +#include <linux/init.h>
#define IORT_TYPE_MASK(type) (1 << (type)) #define IORT_MSI_TYPE (1 << ACPI_IORT_NODE_ITS_GROUP) @@ -1639,6 +1640,26 @@ static void __init iort_init_platform_devices(void) } }
+/* + * This function detects the ascend platform by oem table id. + */ +static bool ascend_platform_detected(struct acpi_table_header *h) +{ + if (!memcmp(h->oem_table_id, "HI19801P", ACPI_OEM_TABLE_ID_SIZE)) + return true; + + if (!memcmp(h->oem_table_id, "HI19802P", ACPI_OEM_TABLE_ID_SIZE)) + return true; + + if (!memcmp(h->oem_table_id, "HI19804P", ACPI_OEM_TABLE_ID_SIZE)) + return true; + + if (!memcmp(h->oem_table_id, "HI1980\0\0", ACPI_OEM_TABLE_ID_SIZE)) + return true; + + return false; +} + void __init acpi_iort_init(void) { acpi_status status; @@ -1654,5 +1675,8 @@ void __init acpi_iort_init(void) return; }
+ if (ascend_platform_detected(iort_table)) + ascend_enable_all_features(); + iort_init_platform_devices(); } diff --git a/include/linux/init.h b/include/linux/init.h index 2538d176dd1f..e6f970ac7bf4 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -306,4 +306,11 @@ void __init parse_early_options(char *cmdline); #define __exit_p(x) NULL #endif
+#ifndef __ASSEMBLY__ +#ifdef CONFIG_ASCEND_FEATURES +extern void ascend_enable_all_features(void); +#else +static inline void ascend_enable_all_features(void) { } +#endif +#endif #endif /* _LINUX_INIT_H */