[coreboot] [PATCH] Enable or disable the power button in Kconfig

Peter Stuge peter at stuge.se
Fri Oct 1 21:46:10 CEST 2010


Please see the attached patch. I would like to especially ask those
who have worked on boards which use the 5536 to check if maybe their
board should select a different POWER_BUTTON_* now. Again, existing
behavior should be unchanged from previous except on ALIX.1.

Jens, please confirm if my understanding of the old vs. new
hurricane-lx board version vs. power button behavior is correct.


Thanks!

//Peter
-------------- next part --------------
Enable or disable the power button in Kconfig

Some mainboards need to disable the power button to avoid turning off
shortly after being turned on. Other boards ship with a jumper over
the power button and should allow the user to configure the behavior.

The patch adds infrastructure in the form of four mutually exclusive
options which can be selected in a mainboard Kconfig (power button
forced on/off, and user-controllable with default on/off) and one
result bool which source code can test. (Enable the button or not.)

The options have been implemented in CS5536 code and all mainboards
which select SOUTHBRIDGE_AMD_CS5536, but should be used also by other
chipsets where applicable. Note that if chipset code uses the result
bool ENABLE_POWER_BUTTON, then every board using that chipset must
select one out of the four control options.

All touched boards should have unchanged behavior, except ALIX.1[CD]
where the power button can now be configured by the user.

Build tested for alix1c, alix2d, hurricane-lx and wyse-s50. Confirmed
to work as advertised on alix1c both with button enabled and disabled.

Signed-off-by: Peter Stuge <peter at stuge.se>

Index: src/southbridge/amd/cs5536/cs5536_early_setup.c
===================================================================
--- src/southbridge/amd/cs5536/cs5536_early_setup.c	(revision 5901)
+++ src/southbridge/amd/cs5536/cs5536_early_setup.c	(working copy)
@@ -92,8 +92,9 @@
 
 static void cs5536_setup_power_button(void)
 {
-	/*      Power Button Setup */
+#if CONFIG_ENABLE_POWER_BUTTON
 	outl(0x40020000, PMS_IO_BASE + 0x40);
+#endif
 
 	/* setup WORK_AUX/GPIO24, it is the external signal for 5536
 	 * vsb_work_aux controls all voltage rails except Vstandby & Vmem.
Index: src/Kconfig
===================================================================
--- src/Kconfig	(revision 5901)
+++ src/Kconfig	(working copy)
@@ -732,4 +732,43 @@
 	hex
 	default 0x10
 
+# The four POWER_BUTTON_DEFAULT_ENABLE, POWER_BUTTON_DEFAULT_DISABLE,
+# POWER_BUTTON_FORCE_ENABLE and POWER_BUTTON_FORCE_DISBALE options are
+# mutually exclusive. One of these options must be selected in the
+# mainboard Kconfig if the chipset supports enabling and disabling of
+# the power button. Chipset code uses the ENABLE_POWER_BUTTON option set
+# in mainboard/Kconfig to know if the button should be enabled or not.
+
+config POWER_BUTTON_DEFAULT_ENABLE
+	def_bool n
+	help
+	  Select when the board has a power button which can optionally be
+	  disabled by the user.
+
+config POWER_BUTTON_DEFAULT_DISABLE
+	def_bool n
+	help
+	  Select when the board has a power button which can optionally be
+	  enabled by the user, e.g. when the board ships with a jumper over
+	  the power switch contacts.
+
+config POWER_BUTTON_FORCE_ENABLE
+	def_bool n
+	help
+	  Select when the board requires that the power button is always
+	  enabled.
+
+config POWER_BUTTON_FORCE_DISABLE
+	def_bool n
+	help
+	  Select when the board requires that the power button is always
+	  disabled, e.g. when it has been hardwired to ground.
+
+config POWER_BUTTON_IS_OPTIONAL
+	bool
+	default y if POWER_BUTTON_DEFAULT_ENABLE || POWER_BUTTON_DEFAULT_DISABLE
+	default n if !(POWER_BUTTON_DEFAULT_ENABLE || POWER_BUTTON_DEFAULT_DISABLE)
+	help
+	  Internal option that controls ENABLE_POWER_BUTTON visibility.
+
 source src/Kconfig.deprecated_options
Index: src/mainboard/Kconfig
===================================================================
--- src/mainboard/Kconfig	(revision 5901)
+++ src/mainboard/Kconfig	(working copy)
@@ -247,4 +247,22 @@
 	default 0x200000 if COREBOOT_ROMSIZE_KB_2048
 	default 0x400000 if COREBOOT_ROMSIZE_KB_4096
 
+config ENABLE_POWER_BUTTON
+	bool "Enable the power button" if POWER_BUTTON_IS_OPTIONAL
+	default y if POWER_BUTTON_DEFAULT_ENABLE
+	default n if POWER_BUTTON_DEFAULT_DISABLE
+	help
+	  The selected mainboard can have the power button semi-permanently
+	  connected to ground (typically with a jumper) so that the button
+	  appears to be constantly depressed. If this option is enabled on
+	  a board with the jumper connected then the board will turn on, but
+	  automatically turn off after a short timeout, usually 4 seconds.
+
+	  Select Y here if you have removed the jumper and want to use an
+	  actual power button with this board.
+
+config ENABLE_POWER_BUTTON
+	def_bool y if !POWER_BUTTON_IS_OPTIONAL && POWER_BUTTON_FORCE_ENABLE
+	def_bool n if !POWER_BUTTON_IS_OPTIONAL && POWER_BUTTON_FORCE_DISABLE
+
 endmenu
Index: src/mainboard/wyse/s50/Kconfig
===================================================================
--- src/mainboard/wyse/s50/Kconfig	(revision 5901)
+++ src/mainboard/wyse/s50/Kconfig	(working copy)
@@ -28,6 +28,7 @@
 	select HAVE_PIRQ_TABLE
 	select PIRQ_ROUTE
 	select BOARD_ROMSIZE_KB_256
+	select POWER_BUTTON_FORCE_DISABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/wyse/s50/romstage.c
===================================================================
--- src/mainboard/wyse/s50/romstage.c	(revision 5901)
+++ src/mainboard/wyse/s50/romstage.c	(working copy)
@@ -134,9 +134,6 @@
 
 	cs5536_early_setup();
 	
-	/* disable the power button */
-	outl(0x00, PMS_IO_BASE + 0x40);
-
 	/* cs5536_disable_internal_uart	 disable them. Set them up now... */
 	cs5536_setup_onchipuart(1);
 
Index: src/mainboard/digitallogic/msm800sev/Kconfig
===================================================================
--- src/mainboard/digitallogic/msm800sev/Kconfig	(revision 5901)
+++ src/mainboard/digitallogic/msm800sev/Kconfig	(working copy)
@@ -11,6 +11,7 @@
 	select PIRQ_ROUTE
 	select UDELAY_TSC
 	select BOARD_ROMSIZE_KB_256
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/traverse/geos/Kconfig
===================================================================
--- src/mainboard/traverse/geos/Kconfig	(revision 5901)
+++ src/mainboard/traverse/geos/Kconfig	(working copy)
@@ -10,6 +10,7 @@
 	select PIRQ_ROUTE
 	select UDELAY_TSC
 	select BOARD_ROMSIZE_KB_1024
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/amd/rumba/Kconfig
===================================================================
--- src/mainboard/amd/rumba/Kconfig	(revision 5901)
+++ src/mainboard/amd/rumba/Kconfig	(working copy)
@@ -27,6 +27,7 @@
 	select UDELAY_TSC
 	select HAVE_PIRQ_TABLE
 	select BOARD_ROMSIZE_KB_256
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/amd/norwich/Kconfig
===================================================================
--- src/mainboard/amd/norwich/Kconfig	(revision 5901)
+++ src/mainboard/amd/norwich/Kconfig	(working copy)
@@ -10,6 +10,7 @@
 	select PIRQ_ROUTE
 	select UDELAY_TSC
 	select BOARD_ROMSIZE_KB_256
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/amd/db800/Kconfig
===================================================================
--- src/mainboard/amd/db800/Kconfig	(revision 5901)
+++ src/mainboard/amd/db800/Kconfig	(working copy)
@@ -11,6 +11,7 @@
 	select PIRQ_ROUTE
 	select UDELAY_TSC
 	select BOARD_ROMSIZE_KB_256
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/iei/pcisa-lx-800-r10/Kconfig
===================================================================
--- src/mainboard/iei/pcisa-lx-800-r10/Kconfig	(revision 5901)
+++ src/mainboard/iei/pcisa-lx-800-r10/Kconfig	(working copy)
@@ -10,6 +10,7 @@
 	select HAVE_PIRQ_TABLE
 	select PIRQ_ROUTE
 	select BOARD_ROMSIZE_KB_256
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/artecgroup/dbe61/Kconfig
===================================================================
--- src/mainboard/artecgroup/dbe61/Kconfig	(revision 5901)
+++ src/mainboard/artecgroup/dbe61/Kconfig	(working copy)
@@ -10,6 +10,7 @@
 	select PIRQ_ROUTE
 	select UDELAY_TSC
 	select BOARD_ROMSIZE_KB_256
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/pcengines/alix1c/Kconfig
===================================================================
--- src/mainboard/pcengines/alix1c/Kconfig	(revision 5901)
+++ src/mainboard/pcengines/alix1c/Kconfig	(working copy)
@@ -11,6 +11,7 @@
 	select PIRQ_ROUTE
 	select UDELAY_TSC
 	select BOARD_ROMSIZE_KB_512
+	select POWER_BUTTON_DEFAULT_DISABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/pcengines/alix2d/Kconfig
===================================================================
--- src/mainboard/pcengines/alix2d/Kconfig	(revision 5901)
+++ src/mainboard/pcengines/alix2d/Kconfig	(working copy)
@@ -10,6 +10,7 @@
 	select PIRQ_ROUTE
 	select UDELAY_TSC
 	select BOARD_ROMSIZE_KB_512
+	select POWER_BUTTON_FORCE_DISABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/pcengines/alix2d/romstage.c
===================================================================
--- src/mainboard/pcengines/alix2d/romstage.c	(revision 5901)
+++ src/mainboard/pcengines/alix2d/romstage.c	(working copy)
@@ -120,12 +120,6 @@
 static void mb_gpio_init(void)
 {
 	/*
-	 * Disable power button, since it is hardwired to ground on this board,
-	 * and the power would be cut off atfer a 4-second delay otherwise.
-	 */
-	outl(0x00020000, PMS_IO_BASE + 0x40);
-
-	/*
 	 * Enable LEDs GPIO outputs to light up the leds
 	 * This is how the original tinyBIOS sets them after boot.
 	 * Info: GPIO_IO_BASE, 0x6100, is only valid before PCI init, so it
Index: src/mainboard/lippert/roadrunner-lx/Kconfig
===================================================================
--- src/mainboard/lippert/roadrunner-lx/Kconfig	(revision 5901)
+++ src/mainboard/lippert/roadrunner-lx/Kconfig	(working copy)
@@ -13,6 +13,7 @@
 	# Standard chip is a 512 KB FWH. Replacing it with a 1 MB
 	# SST 49LF008A is possible.
 	select BOARD_ROMSIZE_KB_512
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/lippert/hurricane-lx/Kconfig
===================================================================
--- src/mainboard/lippert/hurricane-lx/Kconfig	(revision 5901)
+++ src/mainboard/lippert/hurricane-lx/Kconfig	(working copy)
@@ -29,11 +29,19 @@
 config BOARD_OLD_REVISION
 	bool "Board is old pre-3.0 revision"
 	default n
+	select POWER_BUTTON_FORCE_DISABLE
 	help
 	  Look on the bottom side for a number like 406-0001-30.  The last 2
 	  digits state the PCB revision (3.0 in this example).  For 2.0 or older
 	  boards choose Y, for 3.0 and newer say N.
 
+	  Old revision boards need a jumper shorting the power button to
+	  power on automatically. So we must disable the button's fail-safe
+	  function, or the board will shut down after 4 s.
+
+config POWER_BUTTON_FORCE_ENABLE
+	def_bool y if !BOARD_OLD_REVISION
+
 config ONBOARD_UARTS_RS485
 	bool "Switch on-board serial ports to RS485"
 	default n
Index: src/mainboard/lippert/hurricane-lx/romstage.c
===================================================================
--- src/mainboard/lippert/hurricane-lx/romstage.c	(revision 5901)
+++ src/mainboard/lippert/hurricane-lx/romstage.c	(working copy)
@@ -148,14 +148,7 @@
 
 	cpuRegInit(0, DIMM0, DIMM1, DRAM_TERMINATED);
 
-#if CONFIG_BOARD_OLD_REVISION
-	/*
-	 * Old revision boards need a jumper shorting the power button to power
-	 * on automatically. So we must disable the button's fail-safe function,
-	 * or the board will shut down after 4 s.
-	 */
-	outl(0, PMS_IO_BASE + PM_FSD); // Fail-Save Delay register
-#else
+#if !CONFIG_BOARD_OLD_REVISION
 	int err;
 	/* bit0 = Spread Spectrum */
 	if ((err = smc_send_config(SMC_CONFIG))) {
Index: src/mainboard/lippert/spacerunner-lx/Kconfig
===================================================================
--- src/mainboard/lippert/spacerunner-lx/Kconfig	(revision 5901)
+++ src/mainboard/lippert/spacerunner-lx/Kconfig	(working copy)
@@ -14,6 +14,7 @@
 	# Board is equipped with a 1 MB SPI flash, however, due to limitations
 	# of the IT8712F Super I/O, only the top 512 KB are directly mapped.
 	select BOARD_ROMSIZE_KB_512
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/lippert/literunner-lx/Kconfig
===================================================================
--- src/mainboard/lippert/literunner-lx/Kconfig	(revision 5901)
+++ src/mainboard/lippert/literunner-lx/Kconfig	(working copy)
@@ -14,6 +14,7 @@
 	# Board is equipped with a 1 MB SPI flash, however, due to limitations
 	# of the IT8712F Super I/O, only the top 512 KB are directly mapped.
 	select BOARD_ROMSIZE_KB_512
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string
Index: src/mainboard/winent/pl6064/Kconfig
===================================================================
--- src/mainboard/winent/pl6064/Kconfig	(revision 5901)
+++ src/mainboard/winent/pl6064/Kconfig	(working copy)
@@ -11,6 +11,7 @@
 	select PIRQ_ROUTE
 	select UDELAY_TSC
 	select BOARD_ROMSIZE_KB_512
+	select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
 	string


More information about the coreboot mailing list