root/drivers/watchdog/iTCO_vendor_support.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. supermicro_old_pre_start
  2. supermicro_old_pre_stop
  3. broken_bios_start
  4. broken_bios_stop
  5. iTCO_vendor_pre_start
  6. iTCO_vendor_pre_stop
  7. iTCO_vendor_check_noreboot_on
  8. iTCO_vendor_init_module
  9. iTCO_vendor_exit_module

   1 // SPDX-License-Identifier: GPL-2.0+
   2 /*
   3  *      intel TCO vendor specific watchdog driver support
   4  *
   5  *      (c) Copyright 2006-2009 Wim Van Sebroeck <wim@iguana.be>.
   6  *
   7  *      Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor
   8  *      provide warranty for any of this software. This material is
   9  *      provided "AS-IS" and at no charge.
  10  */
  11 
  12 /*
  13  *      Includes, defines, variables, module parameters, ...
  14  */
  15 
  16 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  17 
  18 /* Module and version information */
  19 #define DRV_NAME        "iTCO_vendor_support"
  20 #define DRV_VERSION     "1.04"
  21 
  22 /* Includes */
  23 #include <linux/module.h>               /* For module specific items */
  24 #include <linux/moduleparam.h>          /* For new moduleparam's */
  25 #include <linux/types.h>                /* For standard types (like size_t) */
  26 #include <linux/errno.h>                /* For the -ENODEV/... values */
  27 #include <linux/kernel.h>               /* For printk/panic/... */
  28 #include <linux/init.h>                 /* For __init/__exit/... */
  29 #include <linux/ioport.h>               /* For io-port access */
  30 #include <linux/io.h>                   /* For inb/outb/... */
  31 
  32 #include "iTCO_vendor.h"
  33 
  34 /* List of vendor support modes */
  35 /* SuperMicro Pentium 3 Era 370SSE+-OEM1/P3TSSE */
  36 #define SUPERMICRO_OLD_BOARD    1
  37 /* SuperMicro Pentium 4 / Xeon 4 / EMT64T Era Systems - no longer supported */
  38 #define SUPERMICRO_NEW_BOARD    2
  39 /* Broken BIOS */
  40 #define BROKEN_BIOS             911
  41 
  42 int iTCO_vendorsupport;
  43 EXPORT_SYMBOL(iTCO_vendorsupport);
  44 
  45 module_param_named(vendorsupport, iTCO_vendorsupport, int, 0);
  46 MODULE_PARM_DESC(vendorsupport, "iTCO vendor specific support mode, default="
  47                         "0 (none), 1=SuperMicro Pent3, 911=Broken SMI BIOS");
  48 
  49 /*
  50  *      Vendor Specific Support
  51  */
  52 
  53 /*
  54  *      Vendor Support: 1
  55  *      Board: Super Micro Computer Inc. 370SSE+-OEM1/P3TSSE
  56  *      iTCO chipset: ICH2
  57  *
  58  *      Code contributed by: R. Seretny <lkpatches@paypc.com>
  59  *      Documentation obtained by R. Seretny from SuperMicro Technical Support
  60  *
  61  *      To enable Watchdog function:
  62  *          BIOS setup -> Power -> TCO Logic SMI Enable -> Within5Minutes
  63  *          This setting enables SMI to clear the watchdog expired flag.
  64  *          If BIOS or CPU fail which may cause SMI hang, then system will
  65  *          reboot. When application starts to use watchdog function,
  66  *          application has to take over the control from SMI.
  67  *
  68  *          For P3TSSE, J36 jumper needs to be removed to enable the Watchdog
  69  *          function.
  70  *
  71  *          Note: The system will reboot when Expire Flag is set TWICE.
  72  *          So, if the watchdog timer is 20 seconds, then the maximum hang
  73  *          time is about 40 seconds, and the minimum hang time is about
  74  *          20.6 seconds.
  75  */
  76 
  77 static void supermicro_old_pre_start(struct resource *smires)
  78 {
  79         unsigned long val32;
  80 
  81         /* Bit 13: TCO_EN -> 0 = Disables TCO logic generating an SMI# */
  82         val32 = inl(smires->start);
  83         val32 &= 0xffffdfff;    /* Turn off SMI clearing watchdog */
  84         outl(val32, smires->start);     /* Needed to activate watchdog */
  85 }
  86 
  87 static void supermicro_old_pre_stop(struct resource *smires)
  88 {
  89         unsigned long val32;
  90 
  91         /* Bit 13: TCO_EN -> 1 = Enables the TCO logic to generate SMI# */
  92         val32 = inl(smires->start);
  93         val32 |= 0x00002000;    /* Turn on SMI clearing watchdog */
  94         outl(val32, smires->start);     /* Needed to deactivate watchdog */
  95 }
  96 
  97 /*
  98  *      Vendor Support: 911
  99  *      Board: Some Intel ICHx based motherboards
 100  *      iTCO chipset: ICH7+
 101  *
 102  *      Some Intel motherboards have a broken BIOS implementation: i.e.
 103  *      the SMI handler clear's the TIMEOUT bit in the TC01_STS register
 104  *      and does not reload the time. Thus the TCO watchdog does not reboot
 105  *      the system.
 106  *
 107  *      These are the conclusions of Andriy Gapon <avg@icyb.net.ua> after
 108  *      debugging: the SMI handler is quite simple - it tests value in
 109  *      TCO1_CNT against 0x800, i.e. checks TCO_TMR_HLT. If the bit is set
 110  *      the handler goes into an infinite loop, apparently to allow the
 111  *      second timeout and reboot. Otherwise it simply clears TIMEOUT bit
 112  *      in TCO1_STS and that's it.
 113  *      So the logic seems to be reversed, because it is hard to see how
 114  *      TIMEOUT can get set to 1 and SMI generated when TCO_TMR_HLT is set
 115  *      (other than a transitional effect).
 116  *
 117  *      The only fix found to get the motherboard(s) to reboot is to put
 118  *      the glb_smi_en bit to 0. This is a dirty hack that bypasses the
 119  *      broken code by disabling Global SMI.
 120  *
 121  *      WARNING: globally disabling SMI could possibly lead to dramatic
 122  *      problems, especially on laptops! I.e. various ACPI things where
 123  *      SMI is used for communication between OS and firmware.
 124  *
 125  *      Don't use this fix if you don't need to!!!
 126  */
 127 
 128 static void broken_bios_start(struct resource *smires)
 129 {
 130         unsigned long val32;
 131 
 132         val32 = inl(smires->start);
 133         /* Bit 13: TCO_EN     -> 0 = Disables TCO logic generating an SMI#
 134            Bit  0: GBL_SMI_EN -> 0 = No SMI# will be generated by ICH. */
 135         val32 &= 0xffffdffe;
 136         outl(val32, smires->start);
 137 }
 138 
 139 static void broken_bios_stop(struct resource *smires)
 140 {
 141         unsigned long val32;
 142 
 143         val32 = inl(smires->start);
 144         /* Bit 13: TCO_EN     -> 1 = Enables TCO logic generating an SMI#
 145            Bit  0: GBL_SMI_EN -> 1 = Turn global SMI on again. */
 146         val32 |= 0x00002001;
 147         outl(val32, smires->start);
 148 }
 149 
 150 /*
 151  *      Generic Support Functions
 152  */
 153 
 154 void iTCO_vendor_pre_start(struct resource *smires,
 155                            unsigned int heartbeat)
 156 {
 157         switch (iTCO_vendorsupport) {
 158         case SUPERMICRO_OLD_BOARD:
 159                 supermicro_old_pre_start(smires);
 160                 break;
 161         case BROKEN_BIOS:
 162                 broken_bios_start(smires);
 163                 break;
 164         }
 165 }
 166 EXPORT_SYMBOL(iTCO_vendor_pre_start);
 167 
 168 void iTCO_vendor_pre_stop(struct resource *smires)
 169 {
 170         switch (iTCO_vendorsupport) {
 171         case SUPERMICRO_OLD_BOARD:
 172                 supermicro_old_pre_stop(smires);
 173                 break;
 174         case BROKEN_BIOS:
 175                 broken_bios_stop(smires);
 176                 break;
 177         }
 178 }
 179 EXPORT_SYMBOL(iTCO_vendor_pre_stop);
 180 
 181 int iTCO_vendor_check_noreboot_on(void)
 182 {
 183         switch (iTCO_vendorsupport) {
 184         case SUPERMICRO_OLD_BOARD:
 185                 return 0;
 186         default:
 187                 return 1;
 188         }
 189 }
 190 EXPORT_SYMBOL(iTCO_vendor_check_noreboot_on);
 191 
 192 static int __init iTCO_vendor_init_module(void)
 193 {
 194         if (iTCO_vendorsupport == SUPERMICRO_NEW_BOARD) {
 195                 pr_warn("Option vendorsupport=%d is no longer supported, "
 196                         "please use the w83627hf_wdt driver instead\n",
 197                         SUPERMICRO_NEW_BOARD);
 198                 return -EINVAL;
 199         }
 200         pr_info("vendor-support=%d\n", iTCO_vendorsupport);
 201         return 0;
 202 }
 203 
 204 static void __exit iTCO_vendor_exit_module(void)
 205 {
 206         pr_info("Module Unloaded\n");
 207 }
 208 
 209 module_init(iTCO_vendor_init_module);
 210 module_exit(iTCO_vendor_exit_module);
 211 
 212 MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>, "
 213                 "R. Seretny <lkpatches@paypc.com>");
 214 MODULE_DESCRIPTION("Intel TCO Vendor Specific WatchDog Timer Driver Support");
 215 MODULE_VERSION(DRV_VERSION);
 216 MODULE_LICENSE("GPL");

/* [<][>][^][v][top][bottom][index][help] */