[ patch .24-rc0 2/5 ] SuperIO locks coordinator - use in hwmon/w83627hf
02 - use superio-locks in drivers/hwmon/w83627hf.c tested on an AMD-Barton mobo. Signed-off-by: Jim Cromie <[EMAIL PROTECTED]> --- hwmon-superio-w83627hf Kconfig|1 w83627hf.c | 140 - 2 files changed, 58 insertions(+), 83 deletions(-) diff -ruNp -X dontdiff -X exclude-diffs hwmon-fan-push-offset/drivers/hwmon/Kconfig hwmon-superio.old/drivers/hwmon/Kconfig --- hwmon-fan-push-offset/drivers/hwmon/Kconfig 2007-10-14 13:00:24.0 -0600 +++ hwmon-superio.old/drivers/hwmon/Kconfig 2007-10-14 17:22:23.0 -0600 @@ -675,6 +688,7 @@ config SENSORS_W83L785TS config SENSORS_W83627HF tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF" select HWMON_VID + select SUPERIO_LOCKS help If you say yes here you get support for the Winbond W836X7 series of sensor chips: the W83627HF, W83627THF, W83637HF, W83687THF and diff -ruNp -X dontdiff -X exclude-diffs hwmon-fan-push-offset/drivers/hwmon/w83627hf.c hwmon-superio.old/drivers/hwmon/w83627hf.c --- hwmon-fan-push-offset/drivers/hwmon/w83627hf.c 2007-10-14 17:13:47.0 -0600 +++ hwmon-superio.old/drivers/hwmon/w83627hf.c 2007-10-14 17:22:23.0 -0600 @@ -50,6 +50,7 @@ #include #include #include +#include #include #include "lm75.h" @@ -75,11 +76,6 @@ static int init = 1; module_param(init, bool, 0); MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization"); -/* modified from kernel/include/traps.c */ -static int REG;/* The register to read/write */ -#defineDEV 0x07/* Register: Logical device select */ -static int VAL;/* The value to read/write */ - /* logical device numbers for superio_select (below) */ #define W83627HF_LD_FDC 0x00 #define W83627HF_LD_PRT 0x01 @@ -97,8 +93,6 @@ static int VAL; /* The value to read/wr #define W83627HF_LD_ACPI0x0a #define W83627HF_LD_HWM 0x0b -#defineDEVID 0x20/* Register: Device ID */ - #define W83627THF_GPIO5_EN 0x30 /* w83627thf only */ #define W83627THF_GPIO5_IOSR0xf3 /* w83627thf only */ #define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */ @@ -107,47 +101,25 @@ static int VAL; /* The value to read/wr #define W83687THF_VID_CFG 0xF0 /* w83687thf only */ #define W83687THF_VID_DATA 0xF1 /* w83687thf only */ -static inline void -superio_outb(int reg, int val) -{ - outb(reg, REG); - outb(val, VAL); -} - -static inline int -superio_inb(int reg) -{ - outb(reg, REG); - return inb(VAL); -} - -static inline void -superio_select(int ld) -{ - outb(DEV, REG); - outb(ld, VAL); -} - -static inline void -superio_enter(void) -{ - outb(0x87, REG); - outb(0x87, REG); -} - -static inline void -superio_exit(void) -{ - outb(0xAA, REG); -} +#define W627_DEVID 0x52 +#define W627THF_DEVID 0x82 +#define W697_DEVID 0x60 +#define W637_DEVID 0x70 +#define W687THF_DEVID 0x85 + +#define WINB_ACT_REG 0x30 +#define WINB_BASE_REG 0x60 + +static struct superio* gate; + +static __devinit struct superio_search where = { + .cmdreg_addrs = { 0x2e, 0x4e }, + .device_ids = { W627_DEVID, W627THF_DEVID, W697_DEVID, + W637_DEVID, W687THF_DEVID, 0 }, + .enter_seq= { 0x87, 0x87, 0 }, + .exit_seq = { 0xAA, 0 } +}; -#define W627_DEVID 0x52 -#define W627THF_DEVID 0x82 -#define W697_DEVID 0x60 -#define W637_DEVID 0x70 -#define W687THF_DEVID 0x85 -#define WINB_ACT_REG 0x30 -#define WINB_BASE_REG 0x60 /* Constants specified below */ /* Alignment of the base address */ @@ -995,12 +967,10 @@ show_name(struct device *dev, struct dev return sprintf(buf, "%s\n", data->name); } static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); - -static int __init w83627hf_find(int sioaddr, unsigned short *addr, - struct w83627hf_sio_data *sio_data) + +static u16 __init w83627hf_find(struct w83627hf_sio_data *sio_data) { - int err = -ENODEV; - u16 val; + u16 val, addr = 0; static const __initdata char *names[] = { "W83627HF", @@ -1010,11 +980,15 @@ static int __init w83627hf_find(int sioa "W83687THF", }; - REG = sioaddr; - VAL = sioaddr + 1; + gate = superio_find(); + if (!gate) { + printk(KERN_WARNING DRVNAME ": superio port not detected, " + "module not intalled.\n"); + return 0; + } + superio_enter(gate); + val = superio_devid(gate); - superio_enter(); - val= superio_inb(DEVID); switch (val) { case W627_DEVID: sio_data->type = w83627hf; @@ -1038,36 +1012,34 @@ static int __init w83627hf_find(int sioa
[ patch .24-rc0 2/5 ] SuperIO locks coordinator - use in hwmon/w83627hf
02 - use superio-locks in drivers/hwmon/w83627hf.c tested on an AMD-Barton mobo. Signed-off-by: Jim Cromie [EMAIL PROTECTED] --- hwmon-superio-w83627hf Kconfig|1 w83627hf.c | 140 - 2 files changed, 58 insertions(+), 83 deletions(-) diff -ruNp -X dontdiff -X exclude-diffs hwmon-fan-push-offset/drivers/hwmon/Kconfig hwmon-superio.old/drivers/hwmon/Kconfig --- hwmon-fan-push-offset/drivers/hwmon/Kconfig 2007-10-14 13:00:24.0 -0600 +++ hwmon-superio.old/drivers/hwmon/Kconfig 2007-10-14 17:22:23.0 -0600 @@ -675,6 +688,7 @@ config SENSORS_W83L785TS config SENSORS_W83627HF tristate Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF select HWMON_VID + select SUPERIO_LOCKS help If you say yes here you get support for the Winbond W836X7 series of sensor chips: the W83627HF, W83627THF, W83637HF, W83687THF and diff -ruNp -X dontdiff -X exclude-diffs hwmon-fan-push-offset/drivers/hwmon/w83627hf.c hwmon-superio.old/drivers/hwmon/w83627hf.c --- hwmon-fan-push-offset/drivers/hwmon/w83627hf.c 2007-10-14 17:13:47.0 -0600 +++ hwmon-superio.old/drivers/hwmon/w83627hf.c 2007-10-14 17:22:23.0 -0600 @@ -50,6 +50,7 @@ #include linux/err.h #include linux/mutex.h #include linux/ioport.h +#include linux/superio-locks.h #include asm/io.h #include lm75.h @@ -75,11 +76,6 @@ static int init = 1; module_param(init, bool, 0); MODULE_PARM_DESC(init, Set to zero to bypass chip initialization); -/* modified from kernel/include/traps.c */ -static int REG;/* The register to read/write */ -#defineDEV 0x07/* Register: Logical device select */ -static int VAL;/* The value to read/write */ - /* logical device numbers for superio_select (below) */ #define W83627HF_LD_FDC 0x00 #define W83627HF_LD_PRT 0x01 @@ -97,8 +93,6 @@ static int VAL; /* The value to read/wr #define W83627HF_LD_ACPI0x0a #define W83627HF_LD_HWM 0x0b -#defineDEVID 0x20/* Register: Device ID */ - #define W83627THF_GPIO5_EN 0x30 /* w83627thf only */ #define W83627THF_GPIO5_IOSR0xf3 /* w83627thf only */ #define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */ @@ -107,47 +101,25 @@ static int VAL; /* The value to read/wr #define W83687THF_VID_CFG 0xF0 /* w83687thf only */ #define W83687THF_VID_DATA 0xF1 /* w83687thf only */ -static inline void -superio_outb(int reg, int val) -{ - outb(reg, REG); - outb(val, VAL); -} - -static inline int -superio_inb(int reg) -{ - outb(reg, REG); - return inb(VAL); -} - -static inline void -superio_select(int ld) -{ - outb(DEV, REG); - outb(ld, VAL); -} - -static inline void -superio_enter(void) -{ - outb(0x87, REG); - outb(0x87, REG); -} - -static inline void -superio_exit(void) -{ - outb(0xAA, REG); -} +#define W627_DEVID 0x52 +#define W627THF_DEVID 0x82 +#define W697_DEVID 0x60 +#define W637_DEVID 0x70 +#define W687THF_DEVID 0x85 + +#define WINB_ACT_REG 0x30 +#define WINB_BASE_REG 0x60 + +static struct superio* gate; + +static __devinit struct superio_search where = { + .cmdreg_addrs = { 0x2e, 0x4e }, + .device_ids = { W627_DEVID, W627THF_DEVID, W697_DEVID, + W637_DEVID, W687THF_DEVID, 0 }, + .enter_seq= { 0x87, 0x87, 0 }, + .exit_seq = { 0xAA, 0 } +}; -#define W627_DEVID 0x52 -#define W627THF_DEVID 0x82 -#define W697_DEVID 0x60 -#define W637_DEVID 0x70 -#define W687THF_DEVID 0x85 -#define WINB_ACT_REG 0x30 -#define WINB_BASE_REG 0x60 /* Constants specified below */ /* Alignment of the base address */ @@ -995,12 +967,10 @@ show_name(struct device *dev, struct dev return sprintf(buf, %s\n, data-name); } static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); - -static int __init w83627hf_find(int sioaddr, unsigned short *addr, - struct w83627hf_sio_data *sio_data) + +static u16 __init w83627hf_find(struct w83627hf_sio_data *sio_data) { - int err = -ENODEV; - u16 val; + u16 val, addr = 0; static const __initdata char *names[] = { W83627HF, @@ -1010,11 +980,15 @@ static int __init w83627hf_find(int sioa W83687THF, }; - REG = sioaddr; - VAL = sioaddr + 1; + gate = superio_find(where); + if (!gate) { + printk(KERN_WARNING DRVNAME : superio port not detected, + module not intalled.\n); + return 0; + } + superio_enter(gate); + val = superio_devid(gate); - superio_enter(); - val= superio_inb(DEVID); switch (val) { case W627_DEVID: sio_data-type = w83627hf; @@ -1038,36 +1012,34 @@ static