@@ -24,6 +24,76 @@ static acpi_status
2424acpi_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 }
0 commit comments