@@ -24,6 +24,66 @@ 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 - GAS 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_generic_address * reg )
44+ {
45+ acpi_status status ;
46+ u32 value32 ;
47+
48+ if (reg -> space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY ) {
49+ return acpi_os_read_memory ((acpi_physical_address )reg -> address ,
50+ value , ACPI_GPE_REGISTER_WIDTH );
51+ }
52+
53+ status = acpi_os_read_port ((acpi_io_address )reg -> address ,
54+ & value32 , ACPI_GPE_REGISTER_WIDTH );
55+ if (ACPI_FAILURE (status ))
56+ return_ACPI_STATUS (status );
57+
58+ * value = (u64 )value32 ;
59+
60+ return_ACPI_STATUS (AE_OK );
61+ }
62+
63+ /******************************************************************************
64+ *
65+ * FUNCTION: acpi_hw_gpe_write
66+ *
67+ * PARAMETERS: value - Value to be written
68+ * reg - GAS register structure
69+ *
70+ * RETURN: Status
71+ *
72+ * DESCRIPTION: Write to a GPE register in either memory or IO space.
73+ *
74+ ******************************************************************************/
75+
76+ acpi_status acpi_hw_gpe_write (u64 value , struct acpi_generic_address * reg )
77+ {
78+ if (reg -> space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY ) {
79+ return acpi_os_write_memory ((acpi_physical_address )reg -> address ,
80+ value , ACPI_GPE_REGISTER_WIDTH );
81+ }
82+
83+ return acpi_os_write_port ((acpi_io_address )reg -> address , (u32 )value ,
84+ ACPI_GPE_REGISTER_WIDTH );
85+ }
86+
2787/******************************************************************************
2888 *
2989 * FUNCTION: acpi_hw_get_gpe_register_bit
@@ -79,7 +139,8 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
79139
80140 /* Get current value of the enable register that contains this GPE */
81141
82- status = acpi_hw_read (& enable_mask , & gpe_register_info -> enable_address );
142+ status = acpi_hw_gpe_read (& enable_mask ,
143+ & gpe_register_info -> enable_address );
83144 if (ACPI_FAILURE (status )) {
84145 return (status );
85146 }
@@ -118,9 +179,8 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action)
118179
119180 /* Write the updated enable mask */
120181
121- status =
122- acpi_hw_write (enable_mask ,
123- & gpe_register_info -> enable_address );
182+ status = acpi_hw_gpe_write (enable_mask ,
183+ & gpe_register_info -> enable_address );
124184 }
125185 return (status );
126186}
@@ -158,8 +218,8 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info *gpe_event_info)
158218 */
159219 register_bit = acpi_hw_get_gpe_register_bit (gpe_event_info );
160220
161- status =
162- acpi_hw_write ( register_bit , & gpe_register_info -> status_address );
221+ status = acpi_hw_gpe_write ( register_bit ,
222+ & gpe_register_info -> status_address );
163223 return (status );
164224}
165225
@@ -227,7 +287,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info,
227287
228288 /* GPE currently enabled (enable bit == 1)? */
229289
230- status = acpi_hw_read (& in_byte , & gpe_register_info -> enable_address );
290+ status = acpi_hw_gpe_read (& in_byte , & gpe_register_info -> enable_address );
231291 if (ACPI_FAILURE (status )) {
232292 return (status );
233293 }
@@ -238,7 +298,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info,
238298
239299 /* GPE currently active (status bit == 1)? */
240300
241- status = acpi_hw_read (& in_byte , & gpe_register_info -> status_address );
301+ status = acpi_hw_gpe_read (& in_byte , & gpe_register_info -> status_address );
242302 if (ACPI_FAILURE (status )) {
243303 return (status );
244304 }
@@ -274,7 +334,8 @@ acpi_hw_gpe_enable_write(u8 enable_mask,
274334
275335 gpe_register_info -> enable_mask = enable_mask ;
276336
277- status = acpi_hw_write (enable_mask , & gpe_register_info -> enable_address );
337+ status = acpi_hw_gpe_write (enable_mask ,
338+ & gpe_register_info -> enable_address );
278339 return (status );
279340}
280341
@@ -341,9 +402,8 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
341402
342403 /* Clear status on all GPEs in this register */
343404
344- status =
345- acpi_hw_write (0xFF ,
346- & gpe_block -> register_info [i ].status_address );
405+ status = acpi_hw_gpe_write (0xFF ,
406+ & gpe_block -> register_info [i ].status_address );
347407 if (ACPI_FAILURE (status )) {
348408 return (status );
349409 }
@@ -481,14 +541,14 @@ acpi_hw_get_gpe_block_status(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
481541 for (i = 0 ; i < gpe_block -> register_count ; i ++ ) {
482542 gpe_register_info = & gpe_block -> register_info [i ];
483543
484- status = acpi_hw_read (& in_enable ,
485- & gpe_register_info -> enable_address );
544+ status = acpi_hw_gpe_read (& in_enable ,
545+ & gpe_register_info -> enable_address );
486546 if (ACPI_FAILURE (status )) {
487547 continue ;
488548 }
489549
490- status = acpi_hw_read (& in_status ,
491- & gpe_register_info -> status_address );
550+ status = acpi_hw_gpe_read (& in_status ,
551+ & gpe_register_info -> status_address );
492552 if (ACPI_FAILURE (status )) {
493553 continue ;
494554 }
0 commit comments