Skip to content

Commit 9a15da1

Browse files
committed
Merge back earlier ACPICA-related changes for 5.10.
2 parents 2bfdb7b + 85f9402 commit 9a15da1

12 files changed

Lines changed: 202 additions & 49 deletions

File tree

drivers/acpi/acpica/acglobal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ ACPI_GLOBAL(struct acpi_generic_address, acpi_gbl_xpm1a_enable);
4242
ACPI_GLOBAL(struct acpi_generic_address, acpi_gbl_xpm1b_status);
4343
ACPI_GLOBAL(struct acpi_generic_address, acpi_gbl_xpm1b_enable);
4444

45+
#ifdef ACPI_GPE_USE_LOGICAL_ADDRESSES
46+
ACPI_GLOBAL(unsigned long, acpi_gbl_xgpe0_block_logical_address);
47+
ACPI_GLOBAL(unsigned long, acpi_gbl_xgpe1_block_logical_address);
48+
49+
#endif /* ACPI_GPE_USE_LOGICAL_ADDRESSES */
50+
4551
/*
4652
* Handle both ACPI 1.0 and ACPI 2.0+ Integer widths. The integer width is
4753
* determined by the revision of the DSDT: If the DSDT revision is less than

drivers/acpi/acpica/achware.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,15 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width);
7373

7474
acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width);
7575

76+
acpi_status acpi_hw_validate_io_block(u64 address, u32 bit_width, u32 count);
77+
7678
/*
7779
* hwgpe - GPE support
7880
*/
81+
acpi_status acpi_hw_gpe_read(u64 *value, struct acpi_gpe_address *reg);
82+
83+
acpi_status acpi_hw_gpe_write(u64 value, struct acpi_gpe_address *reg);
84+
7985
u32 acpi_hw_get_gpe_register_bit(struct acpi_gpe_event_info *gpe_event_info);
8086

8187
acpi_status

drivers/acpi/acpica/aclocal.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,18 @@ struct acpi_gpe_event_info {
454454
u8 disable_for_dispatch; /* Masked during dispatching */
455455
};
456456

457+
/* GPE register address */
458+
459+
struct acpi_gpe_address {
460+
u8 space_id; /* Address space where the register exists */
461+
u64 address; /* 64-bit address of the register */
462+
};
463+
457464
/* Information about a GPE register pair, one per each status/enable pair in an array */
458465

459466
struct acpi_gpe_register_info {
460-
struct acpi_generic_address status_address; /* Address of status reg */
461-
struct acpi_generic_address enable_address; /* Address of enable reg */
467+
struct acpi_gpe_address status_address; /* Address of status reg */
468+
struct acpi_gpe_address enable_address; /* Address of enable reg */
462469
u16 base_gpe_number; /* Base GPE number for this register */
463470
u8 enable_for_wake; /* GPEs to keep enabled when sleeping */
464471
u8 enable_for_run; /* GPEs to keep enabled when running */

drivers/acpi/acpica/evgpe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,14 +656,14 @@ acpi_ev_detect_gpe(struct acpi_namespace_node *gpe_device,
656656

657657
/* GPE currently enabled (enable bit == 1)? */
658658

659-
status = acpi_hw_read(&enable_reg, &gpe_register_info->enable_address);
659+
status = acpi_hw_gpe_read(&enable_reg, &gpe_register_info->enable_address);
660660
if (ACPI_FAILURE(status)) {
661661
goto error_exit;
662662
}
663663

664664
/* GPE currently active (status bit == 1)? */
665665

666-
status = acpi_hw_read(&status_reg, &gpe_register_info->status_address);
666+
status = acpi_hw_gpe_read(&status_reg, &gpe_register_info->status_address);
667667
if (ACPI_FAILURE(status)) {
668668
goto error_exit;
669669
}

drivers/acpi/acpica/evgpeblk.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,6 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
233233

234234
this_register->status_address.space_id = gpe_block->space_id;
235235
this_register->enable_address.space_id = gpe_block->space_id;
236-
this_register->status_address.bit_width =
237-
ACPI_GPE_REGISTER_WIDTH;
238-
this_register->enable_address.bit_width =
239-
ACPI_GPE_REGISTER_WIDTH;
240-
this_register->status_address.bit_offset = 0;
241-
this_register->enable_address.bit_offset = 0;
242236

243237
/* Init the event_info for each GPE within this register */
244238

@@ -251,14 +245,14 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
251245

252246
/* Disable all GPEs within this register */
253247

254-
status = acpi_hw_write(0x00, &this_register->enable_address);
248+
status = acpi_hw_gpe_write(0x00, &this_register->enable_address);
255249
if (ACPI_FAILURE(status)) {
256250
goto error_exit;
257251
}
258252

259253
/* Clear any pending GPE events within this register */
260254

261-
status = acpi_hw_write(0xFF, &this_register->status_address);
255+
status = acpi_hw_gpe_write(0xFF, &this_register->status_address);
262256
if (ACPI_FAILURE(status)) {
263257
goto error_exit;
264258
}
@@ -317,6 +311,23 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
317311
return_ACPI_STATUS(AE_OK);
318312
}
319313

314+
/* Validate the space_ID */
315+
316+
if ((space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
317+
(space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
318+
ACPI_ERROR((AE_INFO,
319+
"Unsupported address space: 0x%X", space_id));
320+
return_ACPI_STATUS(AE_SUPPORT);
321+
}
322+
323+
if (space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
324+
status = acpi_hw_validate_io_block(address,
325+
ACPI_GPE_REGISTER_WIDTH,
326+
register_count);
327+
if (ACPI_FAILURE(status))
328+
return_ACPI_STATUS(status);
329+
}
330+
320331
/* Allocate a new GPE block */
321332

322333
gpe_block = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_block_info));

drivers/acpi/acpica/evgpeinit.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ ACPI_MODULE_NAME("evgpeinit")
3232
* kernel boot time as well.
3333
*/
3434

35+
#ifdef ACPI_GPE_USE_LOGICAL_ADDRESSES
36+
#define ACPI_FADT_GPE_BLOCK_ADDRESS(N) \
37+
acpi_gbl_FADT.xgpe##N##_block.space_id == \
38+
ACPI_ADR_SPACE_SYSTEM_MEMORY ? \
39+
(u64)acpi_gbl_xgpe##N##_block_logical_address : \
40+
acpi_gbl_FADT.xgpe##N##_block.address
41+
#else
42+
#define ACPI_FADT_GPE_BLOCK_ADDRESS(N) acpi_gbl_FADT.xgpe##N##_block.address
43+
#endif /* ACPI_GPE_USE_LOGICAL_ADDRESSES */
44+
3545
/*******************************************************************************
3646
*
3747
* FUNCTION: acpi_ev_gpe_initialize
@@ -49,6 +59,7 @@ acpi_status acpi_ev_gpe_initialize(void)
4959
u32 register_count1 = 0;
5060
u32 gpe_number_max = 0;
5161
acpi_status status;
62+
u64 address;
5263

5364
ACPI_FUNCTION_TRACE(ev_gpe_initialize);
5465

@@ -85,8 +96,9 @@ acpi_status acpi_ev_gpe_initialize(void)
8596
* If EITHER the register length OR the block address are zero, then that
8697
* particular block is not supported.
8798
*/
88-
if (acpi_gbl_FADT.gpe0_block_length &&
89-
acpi_gbl_FADT.xgpe0_block.address) {
99+
address = ACPI_FADT_GPE_BLOCK_ADDRESS(0);
100+
101+
if (acpi_gbl_FADT.gpe0_block_length && address) {
90102

91103
/* GPE block 0 exists (has both length and address > 0) */
92104

@@ -97,7 +109,6 @@ acpi_status acpi_ev_gpe_initialize(void)
97109
/* Install GPE Block 0 */
98110

99111
status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
100-
acpi_gbl_FADT.xgpe0_block.
101112
address,
102113
acpi_gbl_FADT.xgpe0_block.
103114
space_id, register_count0, 0,
@@ -110,8 +121,9 @@ acpi_status acpi_ev_gpe_initialize(void)
110121
}
111122
}
112123

113-
if (acpi_gbl_FADT.gpe1_block_length &&
114-
acpi_gbl_FADT.xgpe1_block.address) {
124+
address = ACPI_FADT_GPE_BLOCK_ADDRESS(1);
125+
126+
if (acpi_gbl_FADT.gpe1_block_length && address) {
115127

116128
/* GPE block 1 exists (has both length and address > 0) */
117129

@@ -137,7 +149,6 @@ acpi_status acpi_ev_gpe_initialize(void)
137149

138150
status =
139151
acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
140-
acpi_gbl_FADT.xgpe1_block.
141152
address,
142153
acpi_gbl_FADT.xgpe1_block.
143154
space_id, register_count1,

drivers/acpi/acpica/hwgpe.c

Lines changed: 86 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,76 @@ static acpi_status
2424
acpi_hw_gpe_enable_write(u8 enable_mask,
2525
struct acpi_gpe_register_info *gpe_register_info);
2626

27+
/******************************************************************************
28+
*
29+
* FUNCTION: acpi_hw_gpe_read
30+
*
31+
* PARAMETERS: value - Where the value is returned
32+
* reg - GPE register structure
33+
*
34+
* RETURN: Status
35+
*
36+
* DESCRIPTION: Read from a GPE register in either memory or IO space.
37+
*
38+
* LIMITATIONS: <These limitations also apply to acpi_hw_gpe_write>
39+
* space_ID must be system_memory or system_IO.
40+
*
41+
******************************************************************************/
42+
43+
acpi_status acpi_hw_gpe_read(u64 *value, struct acpi_gpe_address *reg)
44+
{
45+
acpi_status status;
46+
u32 value32;
47+
48+
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
49+
#ifdef ACPI_GPE_USE_LOGICAL_ADDRESSES
50+
*value = (u64)ACPI_GET8(reg->address);
51+
return_ACPI_STATUS(AE_OK);
52+
#else
53+
return acpi_os_read_memory((acpi_physical_address)reg->address,
54+
value, ACPI_GPE_REGISTER_WIDTH);
55+
#endif
56+
}
57+
58+
status = acpi_os_read_port((acpi_io_address)reg->address,
59+
&value32, ACPI_GPE_REGISTER_WIDTH);
60+
if (ACPI_FAILURE(status))
61+
return_ACPI_STATUS(status);
62+
63+
*value = (u64)value32;
64+
65+
return_ACPI_STATUS(AE_OK);
66+
}
67+
68+
/******************************************************************************
69+
*
70+
* FUNCTION: acpi_hw_gpe_write
71+
*
72+
* PARAMETERS: value - Value to be written
73+
* reg - GPE register structure
74+
*
75+
* RETURN: Status
76+
*
77+
* DESCRIPTION: Write to a GPE register in either memory or IO space.
78+
*
79+
******************************************************************************/
80+
81+
acpi_status acpi_hw_gpe_write(u64 value, struct acpi_gpe_address *reg)
82+
{
83+
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
84+
#ifdef ACPI_GPE_USE_LOGICAL_ADDRESSES
85+
ACPI_SET8(reg->address, value);
86+
return_ACPI_STATUS(AE_OK);
87+
#else
88+
return acpi_os_write_memory((acpi_physical_address)reg->address,
89+
value, ACPI_GPE_REGISTER_WIDTH);
90+
#endif
91+
}
92+
93+
return acpi_os_write_port((acpi_io_address)reg->address, (u32)value,
94+
ACPI_GPE_REGISTER_WIDTH);
95+
}
96+
2797
/******************************************************************************
2898
*
2999
* FUNCTION: acpi_hw_get_gpe_register_bit
@@ -79,7 +149,8 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
79149

80150
/* Get current value of the enable register that contains this GPE */
81151

82-
status = acpi_hw_read(&enable_mask, &gpe_register_info->enable_address);
152+
status = acpi_hw_gpe_read(&enable_mask,
153+
&gpe_register_info->enable_address);
83154
if (ACPI_FAILURE(status)) {
84155
return (status);
85156
}
@@ -118,9 +189,8 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
118189

119190
/* Write the updated enable mask */
120191

121-
status =
122-
acpi_hw_write(enable_mask,
123-
&gpe_register_info->enable_address);
192+
status = acpi_hw_gpe_write(enable_mask,
193+
&gpe_register_info->enable_address);
124194
}
125195
return (status);
126196
}
@@ -158,8 +228,8 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info *gpe_event_info)
158228
*/
159229
register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
160230

161-
status =
162-
acpi_hw_write(register_bit, &gpe_register_info->status_address);
231+
status = acpi_hw_gpe_write(register_bit,
232+
&gpe_register_info->status_address);
163233
return (status);
164234
}
165235

@@ -227,7 +297,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info,
227297

228298
/* GPE currently enabled (enable bit == 1)? */
229299

230-
status = acpi_hw_read(&in_byte, &gpe_register_info->enable_address);
300+
status = acpi_hw_gpe_read(&in_byte, &gpe_register_info->enable_address);
231301
if (ACPI_FAILURE(status)) {
232302
return (status);
233303
}
@@ -238,7 +308,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info,
238308

239309
/* GPE currently active (status bit == 1)? */
240310

241-
status = acpi_hw_read(&in_byte, &gpe_register_info->status_address);
311+
status = acpi_hw_gpe_read(&in_byte, &gpe_register_info->status_address);
242312
if (ACPI_FAILURE(status)) {
243313
return (status);
244314
}
@@ -274,7 +344,8 @@ acpi_hw_gpe_enable_write(u8 enable_mask,
274344

275345
gpe_register_info->enable_mask = enable_mask;
276346

277-
status = acpi_hw_write(enable_mask, &gpe_register_info->enable_address);
347+
status = acpi_hw_gpe_write(enable_mask,
348+
&gpe_register_info->enable_address);
278349
return (status);
279350
}
280351

@@ -341,9 +412,8 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
341412

342413
/* Clear status on all GPEs in this register */
343414

344-
status =
345-
acpi_hw_write(0xFF,
346-
&gpe_block->register_info[i].status_address);
415+
status = acpi_hw_gpe_write(0xFF,
416+
&gpe_block->register_info[i].status_address);
347417
if (ACPI_FAILURE(status)) {
348418
return (status);
349419
}
@@ -481,14 +551,14 @@ acpi_hw_get_gpe_block_status(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
481551
for (i = 0; i < gpe_block->register_count; i++) {
482552
gpe_register_info = &gpe_block->register_info[i];
483553

484-
status = acpi_hw_read(&in_enable,
485-
&gpe_register_info->enable_address);
554+
status = acpi_hw_gpe_read(&in_enable,
555+
&gpe_register_info->enable_address);
486556
if (ACPI_FAILURE(status)) {
487557
continue;
488558
}
489559

490-
status = acpi_hw_read(&in_status,
491-
&gpe_register_info->status_address);
560+
status = acpi_hw_gpe_read(&in_status,
561+
&gpe_register_info->status_address);
492562
if (ACPI_FAILURE(status)) {
493563
continue;
494564
}

drivers/acpi/acpica/hwvalid.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,33 @@ acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width)
292292

293293
return (AE_OK);
294294
}
295+
296+
/******************************************************************************
297+
*
298+
* FUNCTION: acpi_hw_validate_io_block
299+
*
300+
* PARAMETERS: Address Address of I/O port/register blobk
301+
* bit_width Number of bits (8,16,32) in each register
302+
* count Number of registers in the block
303+
*
304+
* RETURN: Status
305+
*
306+
* DESCRIPTION: Validates a block of I/O ports/registers.
307+
*
308+
******************************************************************************/
309+
310+
acpi_status acpi_hw_validate_io_block(u64 address, u32 bit_width, u32 count)
311+
{
312+
acpi_status status;
313+
314+
while (count--) {
315+
status = acpi_hw_validate_io_request((acpi_io_address)address,
316+
bit_width);
317+
if (ACPI_FAILURE(status))
318+
return_ACPI_STATUS(status);
319+
320+
address += ACPI_DIV_8(bit_width);
321+
}
322+
323+
return_ACPI_STATUS(AE_OK);
324+
}

0 commit comments

Comments
 (0)