Enable or disable the power button in Kconfig
authorPeter Stuge <peter@stuge.se>
Wed, 13 Oct 2010 06:23:02 +0000 (06:23 +0000)
committerPeter Stuge <peter@stuge.se>
Wed, 13 Oct 2010 06:23:02 +0000 (06:23 +0000)
Some mainboards need to disable the power button to avoid turning off
right after being turned on, while other boards ship with a jumper over
the power button and should allow the user to configure the behavior.

This 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 for 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 in order to build.

All touched boards should have unchanged behavior, except
pcengines/alix1c, traverse/geos and lippert/hurricane-lx 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.

Includes additional traverse/geos changes from Nathan and
lippert/hurricane-lx changes from Jens to correctly use the new
feature on those boards.

Signed-off-by: Peter Stuge <peter@stuge.se>
Acked-by: Aurelien Guillaume <aurelien@iwi.me>
Acked-by: Nils Jacobs <njacobs8@hetnet.nl>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5948 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

21 files changed:
src/Kconfig
src/mainboard/Kconfig
src/mainboard/amd/db800/Kconfig
src/mainboard/amd/norwich/Kconfig
src/mainboard/amd/rumba/Kconfig
src/mainboard/artecgroup/dbe61/Kconfig
src/mainboard/digitallogic/msm800sev/Kconfig
src/mainboard/iei/pcisa-lx-800-r10/Kconfig
src/mainboard/lippert/hurricane-lx/Kconfig
src/mainboard/lippert/hurricane-lx/romstage.c
src/mainboard/lippert/literunner-lx/Kconfig
src/mainboard/lippert/roadrunner-lx/Kconfig
src/mainboard/lippert/spacerunner-lx/Kconfig
src/mainboard/pcengines/alix1c/Kconfig
src/mainboard/pcengines/alix2d/Kconfig
src/mainboard/pcengines/alix2d/romstage.c
src/mainboard/traverse/geos/Kconfig
src/mainboard/winent/pl6064/Kconfig
src/mainboard/wyse/s50/Kconfig
src/mainboard/wyse/s50/romstage.c
src/southbridge/amd/cs5536/cs5536_early_setup.c

index 690a1d486401216e5221cc36a32ec74fb0716182..a61efe1a8e7025d0b88d1fb16b05975b12f136df 100644 (file)
@@ -736,4 +736,43 @@ config ID_SECTION_OFFSET
        hex
        default 0x10
 
+# The four POWER_BUTTON_DEFAULT_ENABLE, POWER_BUTTON_DEFAULT_DISABLE,
+# POWER_BUTTON_FORCE_ENABLE and POWER_BUTTON_FORCE_DISABLE 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 db1112826d3101ba1daa7e276126488b1ce80e9a..ca0d74d45deeca956426c745394f86e0c84b70e0 100644 (file)
@@ -247,4 +247,22 @@ config ROM_SIZE
        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 optionally have the power button tied
+         to ground with a jumper so that the button appears to be
+         constantly depressed. If this option is enabled and the jumper is
+         installed then the board will turn on, but turn off again after a
+         short timeout, usually 4 seconds.
+
+         Select Y here if you have removed the jumper and want to use an
+         actual power button. Select N if you have the jumper installed.
+
+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 e1b94e9011ab062f60dadf90710b72406e05bae5..834e08589c832f7fdaac766a461b57717701fb25 100644 (file)
@@ -11,6 +11,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select PIRQ_ROUTE
        select UDELAY_TSC
        select BOARD_ROMSIZE_KB_256
+       select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
        string
index 3dc214f00d63e355bfba669071e9ec6814cdf465..b265eeb103aa1c5a5c1588aa7a4a9aca5cf11666 100644 (file)
@@ -10,6 +10,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select PIRQ_ROUTE
        select UDELAY_TSC
        select BOARD_ROMSIZE_KB_256
+       select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
        string
index beda2bd5b2468ed03f671abde7613ec6b3c52a09..a06650cc0f01a5581973db29666fec02f8e82739 100644 (file)
@@ -27,6 +27,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select UDELAY_TSC
        select HAVE_PIRQ_TABLE
        select BOARD_ROMSIZE_KB_256
+       select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
        string
index 52669294f70e9796d22885752ca3a03744b264f5..846000ccad58403ebfc7077d1855d9aaffbd6e5d 100644 (file)
@@ -10,6 +10,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select PIRQ_ROUTE
        select UDELAY_TSC
        select BOARD_ROMSIZE_KB_256
+       select POWER_BUTTON_FORCE_DISABLE
 
 config MAINBOARD_DIR
        string
index a082b1fe01cd69f39b4e9766e94bef78f59d542b..444023b2bdc426cb6aa8cc19512bbfd9a49a0224 100644 (file)
@@ -11,6 +11,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select PIRQ_ROUTE
        select UDELAY_TSC
        select BOARD_ROMSIZE_KB_256
+       select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
        string
index a6f512663391ad55d40e068e6ac2613925ae6af4..e393609c88b463f2468b07d6618d596a3d9cedb4 100644 (file)
@@ -10,6 +10,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select HAVE_PIRQ_TABLE
        select PIRQ_ROUTE
        select BOARD_ROMSIZE_KB_256
+       select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
        string
index 027988f959658ecf1d1fd3ab7fda1b1868b684a1..9b20aa07597f12d97cccc29baf8fbf7a5e75860c 100644 (file)
@@ -29,11 +29,20 @@ config IRQ_SLOT_COUNT
 config BOARD_OLD_REVISION
        bool "Board is old pre-3.0 revision"
        default n
+       select POWER_BUTTON_DEFAULT_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.  You may enable the button only after this
+         jumper has been removed.  New revision boards are not restricted
+         in this way, and always have the power button enabled.
+
+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 018f353fd021ee345c2418b3304944465e124685..b7314bf06f7cc3c0a310df7c1d709a179bce169d 100644 (file)
@@ -147,14 +147,7 @@ void main(unsigned long bist)
 
        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 482f571e8da5bee735eb3148043295c74126a27e..7b45d36ea1ddc05820026f9253315d808481dab3 100644 (file)
@@ -14,6 +14,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        # 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 44326d193f1446bf7980bb102fe99c2c19db501e..4e29742b81d83ca4b02afeaf1723d32fb07233b4 100644 (file)
@@ -13,6 +13,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        # 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 7526d1ecb43763cdfa73d5cc8edaf509b1e241b9..f273d6cf56c2178dcd38e71425a136d593daf683 100644 (file)
@@ -14,6 +14,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        # 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 b10095c902726aa335098fce0f1bd55499d9afcc..0a016a54f56ff9b66ba87e4099d245938d5213cf 100644 (file)
@@ -11,6 +11,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select PIRQ_ROUTE
        select UDELAY_TSC
        select BOARD_ROMSIZE_KB_512
+       select POWER_BUTTON_DEFAULT_DISABLE
 
 config MAINBOARD_DIR
        string
index bb54d1cad118c4cf6d793b82bc47b3125755f2f7..264f5d9e9770520b23ab44dc7694d2c706112a78 100644 (file)
@@ -10,6 +10,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select PIRQ_ROUTE
        select UDELAY_TSC
        select BOARD_ROMSIZE_KB_512
+       select POWER_BUTTON_FORCE_DISABLE
 
 config MAINBOARD_DIR
        string
index aa5f7a0fc40ed58b0549876360f420bdbf2b91cb..10ab27d6627ef0afda622f6d3bd2f1cc1e8b7f83 100644 (file)
@@ -119,12 +119,6 @@ static u8 spd_read_byte(u8 device, u8 address)
 /** Early mainboard specific GPIO setup. */
 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.
index 1c85149671d44a75653845c1f5ed31f0e836a955..dd6c8dd9fae649f4153d2af4a6f44426e38d3594 100644 (file)
@@ -10,6 +10,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select PIRQ_ROUTE
        select UDELAY_TSC
        select BOARD_ROMSIZE_KB_1024
+       select POWER_BUTTON_DEFAULT_DISABLE
 
 config MAINBOARD_DIR
        string
index 1ec56929d50d64b9c6f8d403269d0c0e9d13e0fe..4f367f1fab5c18957edc9d6fcf9c48558b3c2144 100644 (file)
@@ -11,6 +11,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select PIRQ_ROUTE
        select UDELAY_TSC
        select BOARD_ROMSIZE_KB_512
+       select POWER_BUTTON_FORCE_ENABLE
 
 config MAINBOARD_DIR
        string
index 75b533571748c99ece614d936f99cc6b6cd03588..dae8cdb2a2a91f1b71b76347f05acf2e1f42b3da 100644 (file)
@@ -28,6 +28,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select HAVE_PIRQ_TABLE
        select PIRQ_ROUTE
        select BOARD_ROMSIZE_KB_256
+       select POWER_BUTTON_FORCE_DISABLE
 
 config MAINBOARD_DIR
        string
index d36173cee15fcb7fc263441d5efe8b3e042a0262..a77760d6ef73fad8f763be3183ec82686b200743 100644 (file)
@@ -134,9 +134,6 @@ void main(unsigned long bist)
 
        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 452e530f41a47d4b7bb795140c60104f7cbb58a0..047c1a21a09f6af1227bf75f7c67ddea3f8e4148 100644 (file)
@@ -92,8 +92,9 @@ static void cs5536_setup_iobase(void)
 
 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.