Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: PCI quirk for hwmon access on MSI MS-7031 board

The MSI MS-7031 is based on an ATI IXP300 south bridge. On this south
bridge, accessible I/O ports must be enabled explicitly. Unfortunately
the BIOS forgets to enable access to the hardware monitoring chip I/O
ports, so hardware monitoring fails.

Add a quirk enabling access to the required ports (0x295-0x296). This
is exactly what MSI's own hardware monitoring application is doing, so
it has to be the right way.

Signed-off-by: Jean Delvare <khali@linux-fr.org>

+29
+29
drivers/hwmon/hwmon.c
··· 18 18 #include <linux/hwmon.h> 19 19 #include <linux/gfp.h> 20 20 #include <linux/spinlock.h> 21 + #include <linux/pci.h> 21 22 22 23 #define HWMON_ID_PREFIX "hwmon" 23 24 #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d" ··· 87 86 "hwmon_device_unregister() failed: bad class ID!\n"); 88 87 } 89 88 89 + static void __init hwmon_pci_quirks(void) 90 + { 91 + #if defined CONFIG_X86 && defined CONFIG_PCI 92 + struct pci_dev *sb; 93 + u16 base; 94 + u8 enable; 95 + 96 + /* Open access to 0x295-0x296 on MSI MS-7031 */ 97 + sb = pci_get_device(PCI_VENDOR_ID_ATI, 0x436c, NULL); 98 + if (sb && 99 + (sb->subsystem_vendor == 0x1462 && /* MSI */ 100 + sb->subsystem_device == 0x0031)) { /* MS-7031 */ 101 + 102 + pci_read_config_byte(sb, 0x48, &enable); 103 + pci_read_config_word(sb, 0x64, &base); 104 + 105 + if (base == 0 && !(enable & BIT(2))) { 106 + dev_info(&sb->dev, 107 + "Opening wide generic port at 0x295\n"); 108 + pci_write_config_word(sb, 0x64, 0x295); 109 + pci_write_config_byte(sb, 0x48, enable | BIT(2)); 110 + } 111 + } 112 + #endif 113 + } 114 + 90 115 static int __init hwmon_init(void) 91 116 { 117 + hwmon_pci_quirks(); 118 + 92 119 hwmon_class = class_create(THIS_MODULE, "hwmon"); 93 120 if (IS_ERR(hwmon_class)) { 94 121 printk(KERN_ERR "hwmon.c: couldn't create sysfs class\n");