Patchwork [1/2] SMM: add mainboard_apm_cnt() callback

login
register
about
Submitter Sven Schnelle
Date 2011-06-04 17:47:34
Message ID <1307209655-14859-1-git-send-email-svens@stackframe.org>
Download mbox | patch
Permalink /patch/3045/
State New, archived
Headers show

Comments

Sven Schnelle - 2011-06-04 17:47:34
motherboards can use this hook to get notified if someone writes
to the APM_CNT port (0xb2). If the hook returns 1, the chipset
specific hook is also skipped.

Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
 src/include/cpu/x86/smm.h                   |    2 +-
 src/southbridge/intel/i82801gx/smihandler.c |    3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)
Stefan Reinauer - 2011-06-05 01:32:52
On 6/4/11 10:47 AM, Sven Schnelle wrote:
> motherboards can use this hook to get notified if someone writes
> to the APM_CNT port (0xb2). If the hook returns 1, the chipset
> specific hook is also skipped.
>
> Signed-off-by: Sven Schnelle<svens@stackframe.org>
Acked-by: Stefan Reinauer <stefan.reinauer@coreboot.org>


> ---
>   src/include/cpu/x86/smm.h                   |    2 +-
>   src/southbridge/intel/i82801gx/smihandler.c |    3 +++
>   2 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h
> index ad0984e..559b1b7 100644
> --- a/src/include/cpu/x86/smm.h
> +++ b/src/include/cpu/x86/smm.h
> @@ -263,4 +263,4 @@ void __attribute__((weak)) northbridge_smi_handler(unsigned int node, smm_state_
>   void __attribute__((weak)) southbridge_smi_handler(unsigned int node, smm_state_save_area_t *state_save);
>
>   void __attribute__((weak)) mainboard_smi_gpi(u16 gpi_sts);
> -
> +int __attribute__((weak)) mainboard_apm_cnt(u8 data);
> diff --git a/src/southbridge/intel/i82801gx/smihandler.c b/src/southbridge/intel/i82801gx/smihandler.c
> index aefa283..bccf6d5 100644
> --- a/src/southbridge/intel/i82801gx/smihandler.c
> +++ b/src/southbridge/intel/i82801gx/smihandler.c
> @@ -362,6 +362,9 @@ static void southbridge_smi_apmc(unsigned int node, smm_state_save_area_t *state
>   	/* Emulate B2 register as the FADT / Linux expects it */
>
>   	reg8 = inb(APM_CNT);
> +	if (mainboard_apm_cnt&&  mainboard_apm_cnt(reg8))
> +		return;

Is it on purpose that the mainboard_apm_cnt function can prevent the 
generic 82801gx code (including the not implemented C state 
coordination) from running?

> +
>   	switch (reg8) {
>   	case CST_CONTROL:
>   		/* Calling this function seems to cause
Sven Schnelle - 2011-06-05 18:06:57
Stefan Reinauer <stefan.reinauer@coreboot.org> writes:

>> --- a/src/southbridge/intel/i82801gx/smihandler.c
>> +++ b/src/southbridge/intel/i82801gx/smihandler.c
>> @@ -362,6 +362,9 @@ static void southbridge_smi_apmc(unsigned int node, smm_state_save_area_t *state
>>   	/* Emulate B2 register as the FADT / Linux expects it */
>>
>>   	reg8 = inb(APM_CNT);
>> +	if (mainboard_apm_cnt&&  mainboard_apm_cnt(reg8))
>> +		return;
>
> Is it on purpose that the mainboard_apm_cnt function can prevent the
> generic 82801gx code (including the not implemented C state
> coordination) from running?

Yes, that's intentional. If one mainboard doesn't like the way how the
i82801gx handles some APM_CNT, it could say so and does it's own
implementation. Most callbacks will probably simply return 0, but's IMHO
it's nice to have this option.

Sven

Patch

diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h
index ad0984e..559b1b7 100644
--- a/src/include/cpu/x86/smm.h
+++ b/src/include/cpu/x86/smm.h
@@ -263,4 +263,4 @@  void __attribute__((weak)) northbridge_smi_handler(unsigned int node, smm_state_
 void __attribute__((weak)) southbridge_smi_handler(unsigned int node, smm_state_save_area_t *state_save);
 
 void __attribute__((weak)) mainboard_smi_gpi(u16 gpi_sts);
-
+int __attribute__((weak)) mainboard_apm_cnt(u8 data);
diff --git a/src/southbridge/intel/i82801gx/smihandler.c b/src/southbridge/intel/i82801gx/smihandler.c
index aefa283..bccf6d5 100644
--- a/src/southbridge/intel/i82801gx/smihandler.c
+++ b/src/southbridge/intel/i82801gx/smihandler.c
@@ -362,6 +362,9 @@  static void southbridge_smi_apmc(unsigned int node, smm_state_save_area_t *state
 	/* Emulate B2 register as the FADT / Linux expects it */
 
 	reg8 = inb(APM_CNT);
+	if (mainboard_apm_cnt && mainboard_apm_cnt(reg8))
+		return;
+
 	switch (reg8) {
 	case CST_CONTROL:
 		/* Calling this function seems to cause