/* vxbIntelTCOWatchdogTimerK.h - header for the Intel TCO watchdog driver */

/* Copyright 2010 Kontron Modular Computers GmbH */

/*
modification history
--------------------
02a,23jul10,edv custom method declaration
01a,09jul10,edv initially created
*/

#ifndef __INCintelTCOWatchdogDrvK_h
#define __INCintelTCOWatchdogDrvK_h

#ifdef __cplusplus
extern "C" {
#endif

/* includes */

#include <vxWorks.h>
#include <ioLib.h>
#include <vxBusLib.h>
#include <vxbTimerLib.h>
#include "versionK.h"

/* defines */

KONTRON_VERSION(intelTCOWatchdogDrvK_h,01c)			/* version identifier */

#define TCO_WATCHDOG_NAME		"iTCOWdgK"
#define TCO_WATCHDOG_MAX_COUNT	0x3FF
#define TCO_WATCHDOG_DEFAULT_TICK	1 /* 0.6 actually */
#define TCO_WATCHDOG_CLK_RATE_MIN	SYSCLK_MINFRQ_LIMIT
#define TCO_WATCHDOG_CLK_RATE_MAX	SYSCLK_MAXFRQ_LIMIT

/* template timer register offset definitions */

/* Address definitions for the TCO */

/* TCO offset from ACPI BASE */
#define TCOOFFSET		(0x60)
/* SMI Control and Enable Register offset from ACPI BASE */
#define SMI_EN_OFF	(0x30)

#define TCO_RLD		(TCOOFFSET + 0x00) /* TCO Timer Reload and Curr. Value */
#define TCO_DAT_IN	(TCOOFFSET + 0x02) /* TCO Data In Register	*/
#define TCO_DAT_OUT	(TCOOFFSET + 0x03) /* TCO Data Out Register	*/
#define TCO2_STS	(TCOOFFSET + 0x06) /* TCO2 Status Register	*/
#define TCO_CNT	    (TCOOFFSET + 0x08) /* TCO Control Register	*/
#define TCOv2_TMR	(TCOOFFSET + 0x12) /* TCOv2 Timer Initial Value	*/

#define GCS_OFFCET (0x3410) /* offset from RCBA */

/* template timer register bit definitions */

/* CPM Timer Bit Definitions */

/* Timer Global Configuration Register Bit Definitions */

/* Timer Mode Register Bit Definitions */

/* Timer Event Register Bit Definitions */

/* template timer clock frequency adjust macro */

#define TCO_WATCHDOG_FREQ_ADJUST(data)	(((data) * 10) / 6)

/* structure to store the timer information */

typedef struct iTCOWatchdogData
    {
    struct vxbTimerFunctionality 	timerFunc;
    void				(* pIsrFunc)(int);
    int					arg;
    UINT32				maxCount;
    UINT32				clkFreq;
#ifndef	TCO_WATCHDOG_REG_DIRECT_ACCESS
    void *				templateHandle;
#endif	/* !TCO_WATCHDOG_REG_DIRECT_ACCESS */
    VXB_DEVICE_ID			pInst;
    BOOL				intConnected;
    BOOL				healthy;
    UINT16         devId;
    UINT16         acpibase; /* ACPIBASE in IO space */    
    UINT32 *      gcs; /* ICHx_GCS(0x3410) */ 
    } TCO_WATCHDOG_DATA;
		
/* function declarations */

#if defined(__STDC__) || defined(__cplusplus)

METHOD_DECL(wdAllocate)
METHOD_DECL(wdRelease)
METHOD_DECL(wdStart)
METHOD_DECL(wdStop)
METHOD_DECL(wdCountGet)
METHOD_DECL(wdReload)
    
IMPORT void vxbITCOWatchdogDrvRegister(void);
IMPORT STATUS intelTCOWatchdogIoInit(void);

#else

IMPORT void vxbITCOWatchdogDrvRegister();
IMPORT STATUS intelTCOWatchdogIoInit();

#endif	/* __STDC__ */

#ifdef __cplusplus
}
#endif

#endif /* __INCintelTCOWatchdogDrvK_h */

/* eof */
