W83697HG GPIO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Does current release of lm-sensors support GPIO for W83697HG chip?
BTW I have attached some information form MB manufacturing.

BR
static unsigned char wdt_timeout = 0;

/* modified from kernel/include/traps.c */
#define	MASTERREG 0x2e /* The register to read/write */
#define	MASTERVAL 0x2f /* The value to read/write */
#define	SLAVEREG 0x4e /* The register to read/write */
#define	SLAVEVAL 0x4f /* The value to read/write */
#define	DEV 0x07 /* Register: Logical device select */
#define PME 0x0b /* The device with the hardware monitor */
#define WDT 0x08 /* The device with the wdt */
#define	DEVID 0x20 /* Register: Device ID */


#define W697F_DEVID 0x60	//W83697F & W83697HF & W83697HG
#define W697SF_DEVID 0x68	//W83697SF & W83697UF

#define WINB_ACT_REG 0x30
#define WINB_BASE_REG 0x60

/* Length of ISA address segment */
#define WINB_EXTENT 8

u16 RegIndex97, RegVal97;

static inline void superio_enter(void)
{
	outb(0x87, RegIndex97);
	outb(0x87, RegIndex97);
}

static inline u8 superio_inb(u8 reg)
{
	outb(reg, RegIndex97);
	return inb(RegVal97);
}

static inline void superio_select(int mode)
{
	outb(DEV, RegIndex97);
	switch (mode) {
	case 7: // //logical device 7 - gpio1 for digital IO,
		outb(7, RegVal97);  
		break;
	case 8: // wdt, logical device 8-wdt
		outb(WDT, RegVal97);
		break;
	default:
		outb(PME, RegVal97);
		break;
	}

}

static inline void superio_exit(void)
{
	outb(0xAA, RegIndex97);
}

EXTERN_C void W83697HF_WDT_Set_Timeout(unsigned char sec)
{
	wdt_timeout = sec;
}

EXTERN_C void W83697HF_WDT_Start()
{
	DbgPrint("Function Start");
	//select the logic device 8
	superio_enter();
	superio_select(8);
	//clear the MIDI port base address and IRQ resouce for MIDI port
	//==============================================================
	outb(0x60, RegIndex97);
	outb(0, RegVal97);
	outb(0x61, RegIndex97);
	outb(0, RegVal97);
	outb(0x70, RegIndex97);
	outb(0, RegVal97);
	//==============================================================
	//MIDI/GP5 port is activate
	//=========================
	outb(0x30, RegIndex97);
	outb(1, RegVal97);
	//=========================
	outb(0xf4, RegIndex97);
	outb(wdt_timeout, RegVal97);
	superio_exit();
}

EXTERN_C void W83697HF_WDT_Stop()
{
	// wdt_timeout = 0; 
	superio_enter();
	superio_select(8);
	outb(0xf4, RegIndex97);
	outb(0, RegVal97);	// wdt_timeout = 0;
	superio_exit();
}

EXTERN_C int Init_W83697HF_WDT()
{
	u8 val;

	// set up port addresses for master super IO chip
	RegIndex97 = MASTERREG;
	RegVal97 = MASTERVAL;

	superio_enter();
	val= superio_inb(DEVID);
	DbgPrint("Device ID:0x%x\n",val);
	superio_exit();
	
	// support W83697 series
	if (val == W697F_DEVID) 
	{
		DbgPrint("Device W83697 Found!!");
		return 0;
	}

	// set up port addresses for slave super IO chip
	RegIndex97 = SLAVEREG;
	RegVal97 = SLAVEVAL;

	superio_enter();
	val= superio_inb(DEVID);
	superio_exit();

	if (val == W697F_DEVID) 
	{
#ifdef LINUX
		printk(KERN_NOTICE "WDT: W83697 detected and initialized\n");
#elif defined(WINSYS)
		DbgPrint("WDT: W83697 detected\n");
#endif
		return 0;
	}
/*
	Support W83697 series
	if (val != W697F_DEVID && val != W697SF_DEVID) {
		superio_exit();
		return -1;
	}
*/
	return -1; // not found
}

EXTERN_C unsigned char W83697HF_DIO_Read(unsigned char data_a)
{
	unsigned char data_b=0;
	//DbgPrint("W83697HG_DIO_Read\n");
	superio_enter();
	superio_select(7); //Logical device 7 (Game port, MIDI port, GPIO port1)
	outb(0x30, RegIndex97); //CR30
	outb(1, RegVal97); //"1" active
	outb(0xf1, RegIndex97); //CRF1 GP10-GP17 data register
	data_b=inb(RegVal97);
	superio_exit();
	DbgPrint("W83697HF_DIO_Read data_b=0x%x\n",data_b);
	return data_b;
}

EXTERN_C void W83697HF_DIO_Write(unsigned char data_b)
{
	DbgPrint("W83697HF_DIO_Write\n");
	superio_enter();
	superio_select(7);
	outb(0x30, RegIndex97);
	outb(1, RegVal97); //enable logical device
	outb(0xf0, RegIndex97);
	outb(0x0f, RegVal97); // gp10~13:input gp14~17:output
	outb(0xf1, RegIndex97);
	outb(data_b<<4, RegVal97);
	superio_exit();
}
_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux