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: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Module Name: tbfadt   - FADT table utilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "actables.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define _COMPONENT          ACPI_TABLES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) ACPI_MODULE_NAME("tbfadt")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /* Local prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 			     u8 space_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 			     u8 byte_width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 			     u64 address, const char *register_name, u8 flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static void acpi_tb_convert_fadt(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) static void acpi_tb_setup_fadt_registers(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static u64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) acpi_tb_select_address(char *register_name, u32 address32, u64 address64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) /* Table for conversion of FADT to common internal format and FADT validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) typedef struct acpi_fadt_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	u16 address64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	u16 address32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	u16 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	u8 default_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	u8 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) } acpi_fadt_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define ACPI_FADT_OPTIONAL          0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define ACPI_FADT_REQUIRED          1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define ACPI_FADT_SEPARATE_LENGTH   2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define ACPI_FADT_GPE_REGISTER      4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) static struct acpi_fadt_info fadt_info_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	{"Pm1aEventBlock",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	 ACPI_FADT_OFFSET(xpm1a_event_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	 ACPI_FADT_OFFSET(pm1a_event_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	 ACPI_FADT_OFFSET(pm1_event_length),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	 ACPI_PM1_REGISTER_WIDTH * 2,	/* Enable + Status register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	 ACPI_FADT_REQUIRED},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	{"Pm1bEventBlock",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	 ACPI_FADT_OFFSET(xpm1b_event_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	 ACPI_FADT_OFFSET(pm1b_event_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	 ACPI_FADT_OFFSET(pm1_event_length),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	 ACPI_PM1_REGISTER_WIDTH * 2,	/* Enable + Status register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	 ACPI_FADT_OPTIONAL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	{"Pm1aControlBlock",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	 ACPI_FADT_OFFSET(xpm1a_control_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	 ACPI_FADT_OFFSET(pm1a_control_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	 ACPI_FADT_OFFSET(pm1_control_length),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	 ACPI_PM1_REGISTER_WIDTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	 ACPI_FADT_REQUIRED},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	{"Pm1bControlBlock",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	 ACPI_FADT_OFFSET(xpm1b_control_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	 ACPI_FADT_OFFSET(pm1b_control_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	 ACPI_FADT_OFFSET(pm1_control_length),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	 ACPI_PM1_REGISTER_WIDTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	 ACPI_FADT_OPTIONAL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	{"Pm2ControlBlock",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	 ACPI_FADT_OFFSET(xpm2_control_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	 ACPI_FADT_OFFSET(pm2_control_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 ACPI_FADT_OFFSET(pm2_control_length),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	 ACPI_PM2_REGISTER_WIDTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	 ACPI_FADT_SEPARATE_LENGTH},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	{"PmTimerBlock",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	 ACPI_FADT_OFFSET(xpm_timer_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	 ACPI_FADT_OFFSET(pm_timer_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	 ACPI_FADT_OFFSET(pm_timer_length),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 ACPI_PM_TIMER_WIDTH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	 ACPI_FADT_SEPARATE_LENGTH},	/* ACPI 5.0A: Timer is optional */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	{"Gpe0Block",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	 ACPI_FADT_OFFSET(xgpe0_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	 ACPI_FADT_OFFSET(gpe0_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	 ACPI_FADT_OFFSET(gpe0_block_length),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	 ACPI_FADT_SEPARATE_LENGTH | ACPI_FADT_GPE_REGISTER},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	{"Gpe1Block",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	 ACPI_FADT_OFFSET(xgpe1_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	 ACPI_FADT_OFFSET(gpe1_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	 ACPI_FADT_OFFSET(gpe1_block_length),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	 ACPI_FADT_SEPARATE_LENGTH | ACPI_FADT_GPE_REGISTER}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define ACPI_FADT_INFO_ENTRIES \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			(sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* Table used to split Event Blocks into separate status/enable registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) typedef struct acpi_fadt_pm_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct acpi_generic_address *target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	u16 source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	u8 register_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) } acpi_fadt_pm_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static struct acpi_fadt_pm_info fadt_pm_info_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	{&acpi_gbl_xpm1a_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	 ACPI_FADT_OFFSET(xpm1a_event_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	{&acpi_gbl_xpm1a_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	 ACPI_FADT_OFFSET(xpm1a_event_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	 1},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	{&acpi_gbl_xpm1b_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	 ACPI_FADT_OFFSET(xpm1b_event_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	{&acpi_gbl_xpm1b_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	 ACPI_FADT_OFFSET(xpm1b_event_block),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	 1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define ACPI_FADT_PM_INFO_ENTRIES \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			(sizeof (fadt_pm_info_table) / sizeof (struct acpi_fadt_pm_info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  * FUNCTION:    acpi_tb_init_generic_address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  * PARAMETERS:  generic_address     - GAS struct to be initialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)  *              space_id            - ACPI Space ID for this register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)  *              byte_width          - Width of this register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)  *              address             - Address of the register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)  *              register_name       - ASCII name of the ACPI register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * DESCRIPTION: Initialize a Generic Address Structure (GAS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  *              See the ACPI specification for a full description and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  *              definition of this structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 			     u8 space_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 			     u8 byte_width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 			     u64 address, const char *register_name, u8 flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	u8 bit_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	 * Bit width field in the GAS is only one byte long, 255 max.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	 * Check for bit_width overflow in GAS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	bit_width = (u8)(byte_width * 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	if (byte_width > 31) {	/* (31*8)=248, (32*8)=256 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		 * No error for GPE blocks, because we do not use the bit_width
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		 * for GPEs, the legacy length (byte_width) is used instead to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		 * allow for a large number of GPEs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		if (!(flags & ACPI_FADT_GPE_REGISTER)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			ACPI_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 				    "%s - 32-bit FADT register is too long (%u bytes, %u bits) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 				    "to convert to GAS struct - 255 bits max, truncating",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 				    register_name, byte_width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 				    (byte_width * 8)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		bit_width = 255;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	 * The 64-bit Address field is non-aligned in the byte packed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	 * GAS struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	ACPI_MOVE_64_TO_64(&generic_address->address, &address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	/* All other fields are byte-wide */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	generic_address->space_id = space_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	generic_address->bit_width = bit_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	generic_address->bit_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	generic_address->access_width = 0;	/* Access width ANY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  * FUNCTION:    acpi_tb_select_address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)  * PARAMETERS:  register_name       - ASCII name of the ACPI register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)  *              address32           - 32-bit address of the register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  *              address64           - 64-bit address of the register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  * RETURN:      The resolved 64-bit address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  * DESCRIPTION: Select between 32-bit and 64-bit versions of addresses within
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  *              the FADT. Used for the FACS and DSDT addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  * NOTES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  * Check for FACS and DSDT address mismatches. An address mismatch between
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  * DSDT/X_DSDT) could be a corrupted address field or it might indicate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  * the presence of two FACS or two DSDT tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  * November 2013:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  * By default, as per the ACPICA specification, a valid 64-bit address is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  * used regardless of the value of the 32-bit address. However, this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * behavior can be overridden via the acpi_gbl_use32_bit_fadt_addresses flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static u64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) acpi_tb_select_address(char *register_name, u32 address32, u64 address64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	if (!address64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		/* 64-bit address is zero, use 32-bit address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		return ((u64)address32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	if (address32 && (address64 != (u64)address32)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		/* Address mismatch between 32-bit and 64-bit versions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		ACPI_BIOS_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 				   "32/64X %s address mismatch in FADT: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 				   "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 				   register_name, address32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 				   ACPI_FORMAT_UINT64(address64),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 				   acpi_gbl_use32_bit_fadt_addresses ? 32 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 				   64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		/* 32-bit address override */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		if (acpi_gbl_use32_bit_fadt_addresses) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 			return ((u64)address32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	/* Default is to use the 64-bit address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	return (address64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)  * FUNCTION:    acpi_tb_parse_fadt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  * PARAMETERS:  None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  *              (FADT contains the addresses of the DSDT and FACS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) void acpi_tb_parse_fadt(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	u32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	struct acpi_table_header *table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	struct acpi_table_desc *fadt_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	 * The FADT has multiple versions with different lengths,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	 * and it contains pointers to both the DSDT and FACS tables.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	 * Get a local copy of the FADT and convert it to a common format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	 * Map entire FADT, assumed to be smaller than one page.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	fadt_desc = &acpi_gbl_root_table_list.tables[acpi_gbl_fadt_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	status = acpi_tb_get_table(fadt_desc, &table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	length = fadt_desc->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	 * Validate the FADT checksum before we copy the table. Ignore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	 * checksum error as we want to try to get the DSDT and FACS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	(void)acpi_tb_verify_checksum(table, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	/* Create a local copy of the FADT in common ACPI 2.0+ format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	acpi_tb_create_local_fadt(table, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	/* All done with the real FADT, unmap it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	acpi_tb_put_table(fadt_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	/* Obtain the DSDT and FACS tables via their addresses within the FADT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	acpi_tb_install_standard_table((acpi_physical_address)acpi_gbl_FADT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 				       Xdsdt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 				       ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 				       FALSE, TRUE, &acpi_gbl_dsdt_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	/* If Hardware Reduced flag is set, there is no FACS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	if (!acpi_gbl_reduced_hardware) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		if (acpi_gbl_FADT.facs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 			acpi_tb_install_standard_table((acpi_physical_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 						       acpi_gbl_FADT.facs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 						       ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 						       FALSE, TRUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 						       &acpi_gbl_facs_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		if (acpi_gbl_FADT.Xfacs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 			acpi_tb_install_standard_table((acpi_physical_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 						       acpi_gbl_FADT.Xfacs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 						       ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 						       FALSE, TRUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 						       &acpi_gbl_xfacs_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)  * FUNCTION:    acpi_tb_create_local_fadt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)  * PARAMETERS:  table               - Pointer to BIOS FADT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)  *              length              - Length of the table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)  * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)  *              Performs validation on some important FADT fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)  * NOTE:        We create a local copy of the FADT regardless of the version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	 * Check if the FADT is larger than the largest table that we expect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	 * (typically the current ACPI specification version). If so, truncate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	 * the table, and issue a warning.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	if (length > sizeof(struct acpi_table_fadt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		ACPI_BIOS_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 				   "FADT (revision %u) is longer than %s length, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 				   "truncating length %u to %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 				   table->revision, ACPI_FADT_CONFORMANCE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 				   length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 				   (u32)sizeof(struct acpi_table_fadt)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	/* Clear the entire local FADT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	memset(&acpi_gbl_FADT, 0, sizeof(struct acpi_table_fadt));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	/* Copy the original FADT, up to sizeof (struct acpi_table_fadt) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	memcpy(&acpi_gbl_FADT, table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	       ACPI_MIN(length, sizeof(struct acpi_table_fadt)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	/* Take a copy of the Hardware Reduced flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	acpi_gbl_reduced_hardware = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	if (acpi_gbl_FADT.flags & ACPI_FADT_HW_REDUCED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		acpi_gbl_reduced_hardware = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	/* Convert the local copy of the FADT to the common internal format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	acpi_tb_convert_fadt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	/* Initialize the global ACPI register structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	acpi_tb_setup_fadt_registers();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)  * FUNCTION:    acpi_tb_convert_fadt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)  * PARAMETERS:  none - acpi_gbl_FADT is used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)  * DESCRIPTION: Converts all versions of the FADT to a common internal format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)  *              Expand 32-bit addresses to 64-bit as necessary. Also validate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)  *              important fields within the FADT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)  * NOTE:        acpi_gbl_FADT must be of size (struct acpi_table_fadt), and must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)  *              contain a copy of the actual BIOS-provided FADT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)  * Notes on 64-bit register addresses:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)  * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)  * fields of the FADT for all ACPI register addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)  * The 64-bit X fields are optional extensions to the original 32-bit FADT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)  * V1.0 fields. Even if they are present in the FADT, they are optional and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)  * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)  * 32-bit V1.0 fields to the 64-bit X fields if the 64-bit X field is originally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)  * zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)  * For ACPI 1.0 FADTs (that contain no 64-bit addresses), all 32-bit address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)  * fields are expanded to the corresponding 64-bit X fields in the internal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)  * common FADT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)  * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)  * to the corresponding 64-bit X fields, if the 64-bit field is originally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)  * zero. Adhering to the ACPI specification, we completely ignore the 32-bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)  * field if the 64-bit field is valid, regardless of whether the host OS is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)  * 32-bit or 64-bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)  * Possible additional checks:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)  *  (acpi_gbl_FADT.pm1_event_length >= 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)  *  (acpi_gbl_FADT.pm1_control_length >= 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)  *  (acpi_gbl_FADT.pm_timer_length >= 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)  *  Gpe block lengths must be multiple of 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) static void acpi_tb_convert_fadt(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	struct acpi_generic_address *address64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	u32 address32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	u8 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	u8 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	 * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	 * should be zero are indeed zero. This will workaround BIOSs that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	 * inadvertently place values in these fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	 * at offset 45, 55, 95, and the word located at offset 109, 110.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	 * Note: The FADT revision value is unreliable. Only the length can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	 * trusted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	if (acpi_gbl_FADT.header.length <= ACPI_FADT_V2_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 		acpi_gbl_FADT.preferred_profile = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		acpi_gbl_FADT.pstate_control = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 		acpi_gbl_FADT.cst_control = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 		acpi_gbl_FADT.boot_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	 * Now we can update the local FADT length to the length of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	 * current FADT version as defined by the ACPI specification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	 * Thus, we will have a common FADT internally.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	 * Expand the 32-bit DSDT addresses to 64-bit as necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	 * Later ACPICA code will always use the X 64-bit field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	acpi_gbl_FADT.Xdsdt = acpi_tb_select_address("DSDT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 						     acpi_gbl_FADT.dsdt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 						     acpi_gbl_FADT.Xdsdt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	/* If Hardware Reduced flag is set, we are all done */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	if (acpi_gbl_reduced_hardware) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	/* Examine all of the 64-bit extended address fields (X fields) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 		 * Get the 32-bit and 64-bit addresses, as well as the register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		 * length and register name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		address32 = *ACPI_ADD_PTR(u32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 					  &acpi_gbl_FADT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 					  fadt_info_table[i].address32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		address64 = ACPI_ADD_PTR(struct acpi_generic_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 					 &acpi_gbl_FADT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 					 fadt_info_table[i].address64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		length = *ACPI_ADD_PTR(u8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 				       &acpi_gbl_FADT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 				       fadt_info_table[i].length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		name = fadt_info_table[i].name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 		flags = fadt_info_table[i].flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		 * generic address structures as necessary. Later code will always use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		 * the 64-bit address structures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		 * November 2013:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		 * Now always use the 64-bit address if it is valid (non-zero), in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 		 * accordance with the ACPI specification which states that a 64-bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 		 * address supersedes the 32-bit version. This behavior can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 		 * overridden by the acpi_gbl_use32_bit_fadt_addresses flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		 * During 64-bit address construction and verification,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 		 * these cases are handled:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 		 * Address32 zero, Address64 [don't care]   - Use Address64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 		 * No override: if acpi_gbl_use32_bit_fadt_addresses is FALSE, and:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 		 * Address32 non-zero, Address64 zero       - Copy/use Address32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 		 * Address32 non-zero == Address64 non-zero - Use Address64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 		 * Address32 non-zero != Address64 non-zero - Warning, use Address64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 		 * Override: if acpi_gbl_use32_bit_fadt_addresses is TRUE, and:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 		 * Address32 non-zero, Address64 zero       - Copy/use Address32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 		 * Address32 non-zero == Address64 non-zero - Copy/use Address32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 		 * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 		 * Note: space_id is always I/O for 32-bit legacy address fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 		if (address32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 			if (address64->address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 				if (address64->address != (u64)address32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 					/* Address mismatch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 					ACPI_BIOS_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 							   "32/64X address mismatch in FADT/%s: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 							   "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 							   name, address32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 							   ACPI_FORMAT_UINT64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 							   (address64->address),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 							   acpi_gbl_use32_bit_fadt_addresses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 							   ? 32 : 64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 				 * For each extended field, check for length mismatch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 				 * between the legacy length field and the corresponding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 				 * 64-bit X length field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 				 * Note: If the legacy length field is > 0xFF bits, ignore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 				 * this check. (GPE registers can be larger than the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 				 * 64-bit GAS structure can accommodate, 0xFF bits).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 				if ((ACPI_MUL_8(length) <= ACPI_UINT8_MAX) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 				    (address64->bit_width !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 				     ACPI_MUL_8(length))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 					ACPI_BIOS_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 							   "32/64X length mismatch in FADT/%s: %u/%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 							   name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 							   ACPI_MUL_8(length),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 							   address64->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 							   bit_width));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 			 * Hardware register access code always uses the 64-bit fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 			 * So if the 64-bit field is zero or is to be overridden,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 			 * initialize it with the 32-bit fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 			 * Note that when the 32-bit address favor is specified, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 			 * 64-bit fields are always re-initialized so that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 			 * access_size/bit_width/bit_offset fields can be correctly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 			 * configured to the values to trigger a 32-bit compatible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 			 * access mode in the hardware register access code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 			if (!address64->address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 			    || acpi_gbl_use32_bit_fadt_addresses) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 				acpi_tb_init_generic_address(address64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 							     ACPI_ADR_SPACE_SYSTEM_IO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 							     length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 							     (u64)address32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 							     name, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 		if (fadt_info_table[i].flags & ACPI_FADT_REQUIRED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 			 * Field is required (Pm1a_event, Pm1a_control).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 			 * Both the address and length must be non-zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 			if (!address64->address || !length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 				ACPI_BIOS_ERROR((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 						 "Required FADT field %s has zero address and/or length: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 						 "0x%8.8X%8.8X/0x%X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 						 name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 						 ACPI_FORMAT_UINT64(address64->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 								    address),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 						 length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 		} else if (fadt_info_table[i].flags & ACPI_FADT_SEPARATE_LENGTH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 			 * Field is optional (Pm2_control, GPE0, GPE1) AND has its own
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 			 * length field. If present, both the address and length must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 			 * be valid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 			if ((address64->address && !length) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 			    (!address64->address && length)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 				ACPI_BIOS_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 						   "Optional FADT field %s has valid %s but zero %s: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 						   "0x%8.8X%8.8X/0x%X", name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 						   (length ? "Length" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 						    "Address"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 						   (length ? "Address" :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 						    "Length"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 						   ACPI_FORMAT_UINT64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 						   (address64->address),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 						   length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)  * FUNCTION:    acpi_tb_setup_fadt_registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)  * PARAMETERS:  None, uses acpi_gbl_FADT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)  * RETURN:      None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)  * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)  *              force FADT register definitions to their default lengths.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) static void acpi_tb_setup_fadt_registers(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	struct acpi_generic_address *target64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	struct acpi_generic_address *source64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	u8 pm1_register_byte_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 	u32 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 	 * Optionally check all register lengths against the default values and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 	 * update them if they are incorrect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	if (acpi_gbl_use_default_register_widths) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 		for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 			target64 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 			    ACPI_ADD_PTR(struct acpi_generic_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 					 &acpi_gbl_FADT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 					 fadt_info_table[i].address64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 			 * If a valid register (Address != 0) and the (default_length > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 			 * (Not a GPE register), then check the width against the default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 			if ((target64->address) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 			    (fadt_info_table[i].default_length > 0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 			    (fadt_info_table[i].default_length !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 			     target64->bit_width)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 				ACPI_BIOS_WARNING((AE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 						   "Invalid length for FADT/%s: %u, using default %u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 						   fadt_info_table[i].name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 						   target64->bit_width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 						   fadt_info_table[i].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 						   default_length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 				/* Incorrect size, set width to the default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 				target64->bit_width =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 				    fadt_info_table[i].default_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 	 * Get the length of the individual PM1 registers (enable and status).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 	 * Each register is defined to be (event block length / 2). Extra divide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 	 * by 8 converts bits to bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 	pm1_register_byte_width = (u8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 	    ACPI_DIV_16(acpi_gbl_FADT.xpm1a_event_block.bit_width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 	 * Calculate separate GAS structs for the PM1x (A/B) Status and Enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 	 * registers. These addresses do not appear (directly) in the FADT, so it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 	 * is useful to pre-calculate them from the PM1 Event Block definitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 	 * The PM event blocks are split into two register blocks, first is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 	 * PM Status Register block, followed immediately by the PM Enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 	 * Register block. Each is of length (pm1_event_length/2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 	 * Note: The PM1A event block is required by the ACPI specification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 	 * However, the PM1B event block is optional and is rarely, if ever,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 	 * used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 	for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 		source64 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 		    ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 				 fadt_pm_info_table[i].source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 		if (source64->address) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 			acpi_tb_init_generic_address(fadt_pm_info_table[i].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 						     target, source64->space_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 						     pm1_register_byte_width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 						     source64->address +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 						     (fadt_pm_info_table[i].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 						      register_num *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 						      pm1_register_byte_width),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 						     "PmRegisters", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) }