/******************************************************************************
 *
 *      RamWriteAddr() - Writes one quadword to board RAM
 *
 * Description:
 *      Write one quadword to board RAM.
 *      For Yukon Extreme, if Addr == 2^29 then the qword
 *      at the current position of the hardware pointer is read.
 *
 * Returns:
 *      0 on success, 1 on error
 */
static int RamWriteAddr(
SK_AC   *pAC,                    /* Adapter context */
SK_U32  Addr,                   /* Address to be write at */
SK_U32  LowDword,               /* Lower Dword to be write */
SK_U32  HighDword,              /* Upper Dword to be write */
int     SelectedRam)            /* Selected RAM buffer 0, 1 or 3 */
{
        /* Support for Yukon Extreme and Supreme */
        if ((pAC->GIni.GIChipId == CHIP_ID_YUKON_EX) ||
                (pAC->FwApp.ChipMode == SK_GEASF_CHIP_SU)) {
                if (Addr == BIT_29) {
                        Addr = SelectedRam << 30;
                }
                else {
                        /* Use given address (lower 8 bits for TX, lower 9 bits for RX). */
                        Addr = (Addr & 0x7fffL) | BIT_29 | (SelectedRam << 30);
                }
                SelectedRam = 0;
        }
        else {
                return(1);
        }

        SK_OUT32(pAC->IoBase, SELECT_RAM_BUFFER(SelectedRam, B3_RAM_ADDR), Addr);
        SK_OUT32(pAC->IoBase, SELECT_RAM_BUFFER(SelectedRam, B3_RAM_DATA_LO), LowDword);
        SK_OUT32(pAC->IoBase, SELECT_RAM_BUFFER(SelectedRam, B3_RAM_DATA_HI), HighDword);

        return(0);
}
/*
 *
 * Start hardware timer (clock ticks are 16us).
 *
 */
void	SkHwtStart(
SK_AC	*pAC,	/* Adapters context */
SK_IOC	Ioc,	/* IoContext */
SK_U32	Time)	/* Time in units of 16us to load the timer with. */
{
	SK_U32	Cnt;

	if (Time > SK_HWT_MAX)
		Time = SK_HWT_MAX;

	pAC->Hwt.TStart = Time;
	pAC->Hwt.TStop = 0L;

	Cnt = Time;

	/*
	 * if time < 16 us
	 *	time = 16 us
	 */
	if (!Cnt) {
		Cnt++;
	}

	SK_OUT32(Ioc, B2_TI_INI, Cnt * SK_HWT_FAC);
	
	SK_OUT16(Ioc, B2_TI_CTRL, TIM_START);	/* Start timer. */

	pAC->Hwt.TActive = SK_TRUE;
}
/*****************************************************************************
 *
 * SkPflCommand - Executes a command at the parallel flash
 *
 * Description:
 *	This function will send a command to the parallel flash
 *	and wait for it to complete.
 *
 * Returns:
 *	Nothing
 */
static void SkPflCommand(
SK_AC	*pAC,
SK_IOC	IoC,
int		Part,
SK_U8	Cmd,	/* comand code */
SK_U16	Data)	/* data for command (if needed) */
{
	SK_OUT32(IoC, FCU_WR_DATA, BIT_31 | (Cmd << 16) | Data);

	/* bits 31..29 == 101: write access to parallel flash register. */
	/* bits 26..24 == 010: 32-bit access. */
	/* bits 7..0: register address */
	SK_OUT32(IoC, FCU_MEM_CTRL, BIT_31 | BIT_29 | (2 << 24) | 0);

	/* wait for the parallel flash to finish the command */
	SK_PFL_WAIT_FINISH_CMD(pAC, IoC);
}	/* SkPflCommand */
static void 
DisableIntMod(SK_AC *pAC) {

    SK_OUT32(pAC->IoBase, B2_IRQM_CTRL, TIM_STOP);
    if (M_DIMINFO.DisplayStats) {
        printk("Disabled interrupt moderation\n");
    }
} 
/*****************************************************************************
 *
 * SkPflWriteDword - Writes a dword into the parallel flash
 *
 * Description:
 *	This function writes the specified dword into the specified parallel flash
 *	location. The parallel flash should have been put previously in write enable
 *	mode and the target sector erased for the access to succeed.
 *
 * Returns:
 *	Nothing
 */
static void SkPflWriteDword(
SK_AC	*pAC,
SK_IOC	IoC,
int		Part,		/* Info or main part */
SK_U32	Addr,		/* Address to write to */
SK_U32	Val)		/* New value to be written */
{
	Addr &= (1 << 20) - 1;
	Addr |= BIT_31;
	Addr |= (2 << 24);
	/* bits 31..29 == 100: write access to information memory. */
	/* bits 26..24 == 010: 32-bit access. */
	Addr |= (Part << 30);

	SK_OUT32(IoC, FCU_WR_DATA, Val);
	SK_OUT32(IoC, FCU_MEM_CTRL, Addr);
	SK_PFL_WAIT_FINISH_WR(pAC, IoC);
}
static void
EnableIntMod(SK_AC *pAC) {
    unsigned long ModBase;

    if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
       ModBase = C_CLK_FREQ_GENESIS / pAC->DynIrqModInfo.MaxModIntsPerSec;
    } else {
       ModBase = C_CLK_FREQ_YUKON / pAC->DynIrqModInfo.MaxModIntsPerSec;
    }

    SK_OUT32(pAC->IoBase, B2_IRQM_INI,  ModBase);
    SK_OUT32(pAC->IoBase, B2_IRQM_MSK,  pAC->DynIrqModInfo.MaskIrqModeration);
    SK_OUT32(pAC->IoBase, B2_IRQM_CTRL, TIM_START);
    if (M_DIMINFO.DisplayStats) {
        printk("Enabled interrupt moderation (%i ints/sec)\n",
               M_DIMINFO.MaxModIntsPerSec);
    }
}
/*****************************************************************************
 *
 * SkPflCheck - Determines whether a parallel flash is present
 *
 * Description:
 *	This function determines whether a parallel flash is present.
 *
 * Returns:
 *	0	No parallel flash
 *	1	Parallel flash detected
 */
int SkPflCheck(
SK_AC	*pAC,
SK_IOC	IoC)
{
#ifdef XXX
	unsigned long opcodes;
#endif	/* XXX */

	SK_IN8(IoC, B2_CHIP_ID, &pAC->pfl.YkChipId);
	if (pAC->pfl.YkChipId == CHIP_ID_YUKON_SUPR) {

		SkPflSetDevPtr(pAC, IoC);
		if (pAC->pfl.pPflDev == NULL) {
			/* unknown or no flash */
			fl_print("\nFlash device\t: none\n");
			return (0);
		}

#ifdef XXX
		/*
		 * set the opcodes for the SPI flash found
		 */
		SK_IN32(IoC, SPI_Y2_OPCODE_REG1, &opcodes);

		opcodes &= 0x000000ffL;
		opcodes |= ((((unsigned long)(pAC->pfl.pPflDev->opcodes.op_read)) << 8) |
					(((unsigned long)(pAC->pfl.pPflDev->opcodes.op_read_id)) << 16) |
					(((unsigned long)(pAC->pfl.pPflDev->opcodes.op_read_status)) << 24));

		SK_OUT32(IoC, SPI_Y2_OPCODE_REG1, opcodes);

		opcodes = (((unsigned long)(pAC->pfl.pPflDev->opcodes.op_write_enable)) |
				   (((unsigned long)(pAC->pfl.pPflDev->opcodes.op_write)) << 8) |
				   (((unsigned long)(pAC->pfl.pPflDev->opcodes.op_sector_erase)) << 16) |
				   (((unsigned long)(pAC->pfl.pPflDev->opcodes.op_chip_erase)) << 24));

		SK_OUT32(IoC, SPI_Y2_OPCODE_REG2, opcodes);
#endif	/* XXX */

		return (1);
	}

	return (0);
}
示例#8
0
/*
 * writes a single byte or 4 bytes into the I2C device
 *
 * returns	0:	success
 *			1:	error
 */
int SkI2cWrite(
    SK_AC	*pAC,		/* Adapter Context */
    SK_IOC	IoC,		/* I/O Context */
    SK_U32	I2cData,	/* I2C Data to write */
    int		I2cDev,		/* I2C Device Address */
    int		I2cReg,		/* I2C Device Register Address */
    int		I2cBurst)	/* I2C Burst Flag ( 0 || I2C_BURST ) */
{
    SK_OUT32(IoC, B2_I2C_DATA, I2cData);
    SK_I2C_CTL(IoC, I2C_WRITE, I2cDev, I2cReg, I2cBurst);
    return(SkI2cWait(pAC, IoC, I2C_WRITE));
}	/* SkI2cWrite*/
示例#9
0
/*
 * Interrupt service function for the I2C Interface
 *
 * Clears the Interrupt source
 *
 * Reads the register and check it for sending a trap.
 *
 * Starts the timer if necessary.
 */
void SkI2cIsr(
SK_AC	*pAC,	/* Adapter Context */
SK_IOC	IoC)	/* I/O Context */
{
	SK_EVPARA	Para;

	/* Clear I2C IRQ */
	SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);

	Para.Para64 = 0;
	SkEventQueue(pAC, SKGE_I2C, SK_I2CEV_IRQ, Para);
}	/* SkI2cIsr */
/*****************************************************************************
 *
 * SkPflReadChipId - Reads parallel flash IDs
 *
 * Description:
 *	This function reads the IDs of the parallel flash.
 *
 * Returns:
 *	Nothing (parallel flash manufacturer and device ID in parameters)
 */
static void SkPflReadChipId(
SK_AC	*pAC,
SK_IOC	IoC,
SK_U32	*pManId,
SK_U16	*pDevId)
{
	/* Put manufacturer and device ID into proper registers. */
	SkPflCommand(pAC, IoC, -1, pAC->pfl.pPflDev->opcodes.OpReadManDev, 0);

	/* bits 31..29 == 001: read access to parallel flash register. */
	/* bits 26..24 == 010: 32-bit access. */
	/* bits 7..0: register address */
	SK_OUT32(IoC, FCU_MEM_CTRL, BIT_29 | (2 << 24) | 0x18);
	SK_PFL_WAIT_FINISH_RD(pAC, IoC);
	SK_IN32(IoC, FCU_RD_DATA, pManId);
	*pManId = FL_SWAP32(*pManId);

	SK_OUT32(IoC, FCU_MEM_CTRL, BIT_29 | (2 << 24) | 0x1C);
	SK_PFL_WAIT_FINISH_RD(pAC, IoC);
	SK_IN16(IoC, FCU_RD_DATA, pDevId);
	*pDevId = FL_SWAP16(*pDevId);

	return;
}
示例#11
0
文件: ski2c.c 项目: robacklin/ts7800
/*
 * writes a single byte or 4 bytes into the I2C device
 *
 * returns	0:	success
 *			1:	error
 */
static int SkI2cWrite(
SK_AC	*pAC,		/* Adapter Context */
SK_IOC	IoC,		/* I/O Context */
SK_U32	I2cData,	/* I2C Data to write */
int		I2cDev,		/* I2C Device Address */
int		I2cDevSize, /* I2C Device Size (e.g. I2C_025K_DEV or I2C_2K_DEV) */
int		I2cReg,		/* I2C Device Register Address */
int		I2cBurst)	/* I2C Burst Flag */
{
	SK_OUT32(IoC, B2_I2C_DATA, I2cData);
	
	SK_I2C_CTL(IoC, I2C_WRITE, I2cDev, I2cDevSize, I2cReg, I2cBurst);
	
	return(SkI2cWait(pAC, IoC, I2C_WRITE));
}	/* SkI2cWrite*/
示例#12
0
/*
 * reads a single byte or 4 bytes from the I2C device
 *
 * returns	the word read
 */
SK_U32 SkI2cRead(
    SK_AC	*pAC,		/* Adapter Context */
    SK_IOC	IoC,		/* I/O Context */
    int		I2cDev,		/* I2C Device Address */
    int		I2cReg,		/* I2C Device Register Address */
    int		I2cBurst)	/* I2C Burst Flag ( 0 || I2C_BURST ) */
{
    SK_U32	Data;

    SK_OUT32(IoC, B2_I2C_DATA, 0);
    SK_I2C_CTL(IoC, I2C_READ, I2cDev, I2cReg, I2cBurst);
    if (SkI2cWait(pAC, IoC, I2C_READ)) {
        w_print("I2C Transfer Timeout!\n");
    }
    SK_IN32(IoC, B2_I2C_DATA, &Data);
    return(Data);
}	/* SkI2cRead */
示例#13
0
/*
 * reads a single byte or 4 bytes from the I2C device
 *
 * returns	the word read
 */
SK_U32 SkI2cRead(
SK_AC	*pAC,		/* Adapter Context */
SK_IOC	IoC,		/* I/O Context */
int		I2cDev,		/* I2C Device Address */
int		I2cReg,		/* I2C Device Register Address */
int		I2cBurst)	/* I2C Burst Flag */
{
	SK_U32	Data;

	SK_OUT32(IoC, B2_I2C_DATA, 0);
	SK_I2C_CTL(IoC, I2C_READ, I2cDev, I2cReg, I2cBurst);

	if (SkI2cWait(pAC, IoC, I2C_READ) != 0) {
		w_print("%s\n", SKERR_I2C_E002MSG);
	}

	SK_IN32(IoC, B2_I2C_DATA, &Data);
	return(Data);
}	/* SkI2cRead */
/*****************************************************************************
 *
 * SkPflReadDword - Reads a dword from the parallel flash
 *
 * Description:
 *	The function reads a dword from the specified address in the parallel flash.
 *
 * Returns:
 *	The DWord read
 */
static SK_U32 SkPflReadDword(
SK_AC	*pAC,
SK_IOC	IoC,
int		Part,
SK_U32	Addr)		/* address in the parallel flash to read from */
{
	SK_U32	Val;

	Addr &= (1 << 20) - 1;
	Addr |= (2 << 24);
	/* bits 31..29 == 000: read access to information memory. */
	/* bits 26..24 == 010: 32-bit access. */
	Addr |= (Part << 30);

	SK_OUT32(IoC, FCU_MEM_CTRL, Addr);
	SK_PFL_WAIT_FINISH_RD(pAC, IoC);
	SK_IN32(IoC, FCU_RD_DATA, &Val);

	return (Val);
}
/*
 *
 * Start hardware timer (clock ticks are HW-dependent).
 *
 */
void SkHwtStart(
SK_AC	*pAC,	/* Adapter Context */
SK_IOC	IoC,	/* I/O Context */
SK_U32	Time)	/* Time in usec to load the timer */
{
	if (Time > SK_HWT_MAX) {
		Time = SK_HWT_MAX;
	}

	pAC->Hwt.TStart = Time;
	pAC->Hwt.TStop = 0L;

	if (!Time) {
		Time = 1L;
	}

	SK_OUT32(IoC, B2_TI_INI, Time * SK_HWT_FAC);

	SK_OUT16(IoC, B2_TI_CTRL, TIM_START);	/* Start timer */

	pAC->Hwt.TActive = SK_TRUE;
}
示例#16
0
/*
 * Do the init state 1 initialization
 *
 * initialize the following register of the LM80:
 * Configuration register:
 * - START, noINT, activeLOW, noINT#Clear, noRESET, noCI, noGPO#, noINIT
 *
 * Interrupt Mask Register 1:
 * - all interrupts are Disabled (0xff)
 *
 * Interrupt Mask Register 2:
 * - all interrupts are Disabled (0xff) Interrupt modi doesn't matter.
 *
 * Fan Divisor/RST_OUT register:
 * - Divisors set to 1 (bits 00), all others 0s.
 *
 * OS# Configuration/Temperature resolution Register:
 * - all 0s
 *
 */
static int SkI2cInit1(
SK_AC	*pAC,	/* Adapter Context */
SK_IOC	IoC)	/* I/O Context */
{
    int i;
    SK_U8 I2cSwCtrl;
	SK_GEPORT *pPrt;	/* GIni Port struct pointer */

	if (pAC->I2c.InitLevel != SK_INIT_DATA) {
		/* ReInit not needed in I2C module */
		return(0);
	}

    /* Set the Direction of I2C-Data Pin to IN */
    SK_I2C_CLR_BIT(IoC, I2C_DATA_DIR | I2C_DATA);
    /* Check for 32-Bit Yukon with Low at I2C-Data Pin */
	SK_I2C_GET_SW(IoC, &I2cSwCtrl);

	if ((I2cSwCtrl & I2C_DATA) == 0) {
		/* this is a 32-Bit board */
		pAC->GIni.GIYukon32Bit = SK_TRUE;
        return(0);
    }

	/* Check for 64 Bit Yukon without sensors */
	if (SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_CFG, 0) != 0) {
        return(0);
    }

	(void)SkI2cWrite(pAC, IoC, 0xffUL, LM80_ADDR, I2C_025K_DEV, LM80_IMSK_1, 0);
	
	(void)SkI2cWrite(pAC, IoC, 0xffUL, LM80_ADDR, I2C_025K_DEV, LM80_IMSK_2, 0);
	
	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_FAN_CTRL, 0);
	
	(void)SkI2cWrite(pAC, IoC, 0, LM80_ADDR, I2C_025K_DEV, LM80_TEMP_CTRL, 0);
	
	(void)SkI2cWrite(pAC, IoC, (SK_U32)LM80_CFG_START, LM80_ADDR, I2C_025K_DEV,
		LM80_CFG, 0);
	
	/*
	 * MaxSens has to be updated here, because PhyType is not
	 * set when performing Init Level 0
	 */
    pAC->I2c.MaxSens = 5;
	
	pPrt = &pAC->GIni.GP[0];
	
	if (pAC->GIni.GIGenesis) {
		if (pPrt->PhyType == SK_PHY_BCOM) {
			if (pAC->GIni.GIMacsFound == 1) {
				pAC->I2c.MaxSens += 1;
			}
			else {
				pAC->I2c.MaxSens += 3;
			}
		}
	}
	else {
		pAC->I2c.MaxSens += 3;
	}
	
	for (i = 0; i < pAC->I2c.MaxSens; i++) {
		switch (i) {
		case 0:
			pAC->I2c.SenTable[i].SenDesc = "Temperature";
			pAC->I2c.SenTable[i].SenType = SK_SEN_TEMP;
			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_TEMP_HIGH_ERR;
			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_TEMP_HIGH_WARN;
			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_TEMP_LOW_WARN;
			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_TEMP_LOW_ERR;
			pAC->I2c.SenTable[i].SenReg = LM80_TEMP_IN;
			break;
		case 1:
			pAC->I2c.SenTable[i].SenDesc = "Voltage PCI";
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PCI_5V_HIGH_ERR;
			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PCI_5V_HIGH_WARN;
			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PCI_5V_LOW_WARN;
			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PCI_5V_LOW_ERR;
			pAC->I2c.SenTable[i].SenReg = LM80_VT0_IN;
			break;
		case 2:
			pAC->I2c.SenTable[i].SenDesc = "Voltage PCI-IO";
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PCI_IO_5V_HIGH_ERR;
			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PCI_IO_5V_HIGH_WARN;
			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PCI_IO_3V3_LOW_WARN;
			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PCI_IO_3V3_LOW_ERR;
			pAC->I2c.SenTable[i].SenReg = LM80_VT1_IN;
			pAC->I2c.SenTable[i].SenInit = SK_SEN_DYN_INIT_PCI_IO;
			break;
		case 3:
			pAC->I2c.SenTable[i].SenDesc = "Voltage ASIC";
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_VDD_HIGH_ERR;
			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_VDD_HIGH_WARN;
			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_VDD_LOW_WARN;
			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_VDD_LOW_ERR;
			pAC->I2c.SenTable[i].SenReg = LM80_VT2_IN;
			break;
		case 4:
			if (pAC->GIni.GIGenesis) {
				if (pPrt->PhyType == SK_PHY_BCOM) {
					pAC->I2c.SenTable[i].SenDesc = "Voltage PHY A PLL";
					pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
					pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
					pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
					pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
				}
				else {
					pAC->I2c.SenTable[i].SenDesc = "Voltage PMA";
					pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
					pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
					pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
					pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
				}
			}
			else {
				pAC->I2c.SenTable[i].SenDesc = "Voltage VAUX";
				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_VAUX_3V3_HIGH_ERR;
				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_VAUX_3V3_HIGH_WARN;
				if (pAC->GIni.GIVauxAvail) {
					pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_VAUX_3V3_LOW_WARN;
					pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_VAUX_3V3_LOW_ERR;
				}
				else {
					pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_VAUX_0V_WARN_ERR;
					pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_VAUX_0V_WARN_ERR;
				}
			}
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
			pAC->I2c.SenTable[i].SenReg = LM80_VT3_IN;
			break;
		case 5:
			if (pAC->GIni.GIGenesis) {
				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY 2V5";
				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PHY_2V5_HIGH_ERR;
				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PHY_2V5_HIGH_WARN;
				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PHY_2V5_LOW_WARN;
				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PHY_2V5_LOW_ERR;
			}
			else {
				pAC->I2c.SenTable[i].SenDesc = "Voltage Core 1V5";
				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_CORE_1V5_HIGH_ERR;
				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_CORE_1V5_HIGH_WARN;
				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_CORE_1V5_LOW_WARN;
				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_CORE_1V5_LOW_ERR;
			}
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
			pAC->I2c.SenTable[i].SenReg = LM80_VT4_IN;
			break;
		case 6:
			if (pAC->GIni.GIGenesis) {
				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY B PLL";
			}
			else {
				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY 3V3";
			}
			pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
			pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PLL_3V3_HIGH_ERR;
			pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PLL_3V3_HIGH_WARN;
			pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PLL_3V3_LOW_WARN;
			pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PLL_3V3_LOW_ERR;
			pAC->I2c.SenTable[i].SenReg = LM80_VT5_IN;
			break;
		case 7:
			if (pAC->GIni.GIGenesis) {
				pAC->I2c.SenTable[i].SenDesc = "Speed Fan";
				pAC->I2c.SenTable[i].SenType = SK_SEN_FAN;
				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_FAN_HIGH_ERR;
				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_FAN_HIGH_WARN;
				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_FAN_LOW_WARN;
				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_FAN_LOW_ERR;
				pAC->I2c.SenTable[i].SenReg = LM80_FAN2_IN;
			}
			else {
				pAC->I2c.SenTable[i].SenDesc = "Voltage PHY 2V5";
				pAC->I2c.SenTable[i].SenType = SK_SEN_VOLT;
				pAC->I2c.SenTable[i].SenThreErrHigh = SK_SEN_PHY_2V5_HIGH_ERR;
				pAC->I2c.SenTable[i].SenThreWarnHigh = SK_SEN_PHY_2V5_HIGH_WARN;
				pAC->I2c.SenTable[i].SenThreWarnLow = SK_SEN_PHY_2V5_LOW_WARN;
				pAC->I2c.SenTable[i].SenThreErrLow = SK_SEN_PHY_2V5_LOW_ERR;
				pAC->I2c.SenTable[i].SenReg = LM80_VT6_IN;
			}
			break;
		default:
			SK_ERR_LOG(pAC, SK_ERRCL_INIT | SK_ERRCL_SW,
				SKERR_I2C_E001, SKERR_I2C_E001MSG);
			break;
		}

		pAC->I2c.SenTable[i].SenValue = 0;
		pAC->I2c.SenTable[i].SenErrFlag = SK_SEN_ERR_OK;
		pAC->I2c.SenTable[i].SenErrCts = 0;
		pAC->I2c.SenTable[i].SenBegErrTS = 0;
		pAC->I2c.SenTable[i].SenState = SK_SEN_IDLE;
		pAC->I2c.SenTable[i].SenRead = SkLm80ReadSensor;
		pAC->I2c.SenTable[i].SenDev = LM80_ADDR;
	}

#ifndef SK_DIAG
	pAC->I2c.DummyReads = pAC->I2c.MaxSens;
#endif /* !SK_DIAG */
	
	/* Clear I2C IRQ */
	SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
	
	/* Now we are I/O initialized */
	pAC->I2c.InitLevel = SK_INIT_IO;
	return(0);
}	/* SkI2cInit1 */
示例#17
0
/*
 * Do the init state 1 initialization
 *
 * initialize the following register of the LM80:
 * Configuration register:
 * - START, noINT, activeLOW, noINT#Clear, noRESET, noCI, noGPO#, noINIT
 *
 * Interrupt Mask Register 1:
 * - all interrupts are Disabled (0xff)
 *
 * Interrupt Mask Register 2:
 * - all interrupts are Disabled (0xff) Interrupt modi doesn't matter.
 *
 * Fan Divisor/RST_OUT register:
 * - Divisors set to 1 (bits 00), all others 0s.
 *
 * OS# Configuration/Temperature resolution Register:
 * - all 0s
 *
 */
static	int	SkI2cInit1(
    SK_AC	*pAC,	/* Adapter Context */
    SK_IOC	IoC)	/* I/O Context */
{
    if (pAC->I2c.InitLevel != SK_INIT_DATA) {
        /* ReInit not needed in I2C module */
        return(0);
    }

    SK_OUT32(IoC, B2_I2C_DATA, 0);
    SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_CFG, 0);
    (void)SkI2cWait(pAC, IoC, I2C_WRITE);

    SK_OUT32(IoC, B2_I2C_DATA, 0xff);
    SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_IMSK_1, 0);
    (void)SkI2cWait(pAC, IoC, I2C_WRITE);

    SK_OUT32(IoC, B2_I2C_DATA, 0xff);
    SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_IMSK_2, 0);
    (void)SkI2cWait(pAC, IoC, I2C_WRITE);

    SK_OUT32(IoC, B2_I2C_DATA, 0x0);
    SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_FAN_CTRL, 0);
    (void)SkI2cWait(pAC, IoC, I2C_WRITE);

    SK_OUT32(IoC, B2_I2C_DATA, 0);
    SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_TEMP_CTRL, 0);
    (void)SkI2cWait(pAC, IoC, I2C_WRITE);

    SK_OUT32(IoC, B2_I2C_DATA, LM80_CFG_START);
    SK_I2C_CTL(IoC, I2C_WRITE, LM80_ADDR, LM80_CFG, 0);
    (void)SkI2cWait(pAC, IoC, I2C_WRITE);

    /*
     * MaxSens has to be initialized here, because PhyType is not
     * set when performing Init Level 1
     */
    switch (pAC->GIni.GP[0].PhyType) {
    case SK_PHY_XMAC:
        pAC->I2c.MaxSens = 5;
        break;
    case SK_PHY_BCOM:
        pAC->I2c.SenTable[4].SenDesc = "Voltage PHY A PLL";
        if (pAC->GIni.GIMacsFound == 1) {
            pAC->I2c.MaxSens = 6;
        }
        else {
            pAC->I2c.MaxSens = 8;
        }
        break;
    case SK_PHY_LONE:
        pAC->I2c.MaxSens = 5;
        break;
    }

#ifndef	SK_DIAG
    pAC->I2c.DummyReads = pAC->I2c.MaxSens;

    /* Clear the interrupt source */
    SK_OUT32(IoC, B2_I2C_IRQ, I2C_CLR_IRQ);
#endif	/* !SK_DIAG */

    /* Now we are I/O initialized */
    pAC->I2c.InitLevel = SK_INIT_IO;
    return(0);
}	/* SkI2cInit1 */
示例#18
0
static void 
ResizeDimTimerDuration(SK_AC *pAC) {
    SK_BOOL IncreaseTimerDuration;
    int     TotalMaxNbrDescr;
    int     UsedDescrRatio;
    int     RatioDiffAbs;
    int     RatioDiffRel;
    int     NewMaxModIntsPerSec;
    int     ModAdjValue;
    long    ModBase;

    /*
    ** Check first if we are allowed to perform any modification
    */
    if (IsIntModEnabled(pAC)) { 
        if (M_DIMINFO.IntModTypeSelect != C_INT_MOD_DYNAMIC) {
            return; 
        } else {
            if (M_DIMINFO.ModJustEnabled) {
                M_DIMINFO.ModJustEnabled = SK_FALSE;
                return;
            }
        }
    }

    /*
    ** If we got until here, we have to evaluate the amount of the
    ** descriptor ratio change...
    */
    TotalMaxNbrDescr = pAC->RxDescrPerRing * GetRxCalls(pAC);
    UsedDescrRatio   = (M_DIMINFO.NbrProcessedDescr * 100) / TotalMaxNbrDescr;

    if (UsedDescrRatio > M_DIMINFO.PrevUsedDescrRatio) {
        RatioDiffAbs = (UsedDescrRatio - M_DIMINFO.PrevUsedDescrRatio);
        RatioDiffRel = (RatioDiffAbs * 100) / UsedDescrRatio;
        M_DIMINFO.PrevUsedDescrRatio = UsedDescrRatio;
        IncreaseTimerDuration = SK_FALSE;  /* in other words: DECREASE */
    } else if (UsedDescrRatio < M_DIMINFO.PrevUsedDescrRatio) {
        RatioDiffAbs = (M_DIMINFO.PrevUsedDescrRatio - UsedDescrRatio);
        RatioDiffRel = (RatioDiffAbs * 100) / M_DIMINFO.PrevUsedDescrRatio;
        M_DIMINFO.PrevUsedDescrRatio = UsedDescrRatio;
        IncreaseTimerDuration = SK_TRUE;   /* in other words: INCREASE */
    } else {
        RatioDiffAbs = (M_DIMINFO.PrevUsedDescrRatio - UsedDescrRatio);
        RatioDiffRel = (RatioDiffAbs * 100) / M_DIMINFO.PrevUsedDescrRatio;
        M_DIMINFO.PrevUsedDescrRatio = UsedDescrRatio;
        IncreaseTimerDuration = SK_TRUE;   /* in other words: INCREASE */
    }

    /*
    ** Now we can determine the change in percent
    */
    if ((RatioDiffRel >= 0) && (RatioDiffRel <= 5) ) {
       ModAdjValue = 1;  /*  1% change - maybe some other value in future */
    } else if ((RatioDiffRel > 5) && (RatioDiffRel <= 10) ) {
       ModAdjValue = 1;  /*  1% change - maybe some other value in future */
    } else if ((RatioDiffRel > 10) && (RatioDiffRel <= 15) ) {
       ModAdjValue = 1;  /*  1% change - maybe some other value in future */
    } else {
       ModAdjValue = 1;  /*  1% change - maybe some other value in future */
    }

    if (IncreaseTimerDuration) {
       NewMaxModIntsPerSec =  M_DIMINFO.MaxModIntsPerSec +
                             (M_DIMINFO.MaxModIntsPerSec * ModAdjValue) / 100;
    } else {
       NewMaxModIntsPerSec =  M_DIMINFO.MaxModIntsPerSec -
                             (M_DIMINFO.MaxModIntsPerSec * ModAdjValue) / 100;
    }

    /* 
    ** Check if we exceed boundaries...
    */
    if ( (NewMaxModIntsPerSec > M_DIMINFO.MaxModIntsPerSecUpperLimit) ||
         (NewMaxModIntsPerSec < M_DIMINFO.MaxModIntsPerSecLowerLimit)) {
        if (M_DIMINFO.DisplayStats) {
            printk("Cannot change ModTim from %i to %i ints/sec\n",
                   M_DIMINFO.MaxModIntsPerSec, NewMaxModIntsPerSec);
        }
        return;
    } else {
        if (M_DIMINFO.DisplayStats) {
            printk("Resized ModTim from %i to %i ints/sec\n",
                   M_DIMINFO.MaxModIntsPerSec, NewMaxModIntsPerSec);
        }
    }

    M_DIMINFO.MaxModIntsPerSec = NewMaxModIntsPerSec;

    if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
        ModBase = C_CLK_FREQ_GENESIS / pAC->DynIrqModInfo.MaxModIntsPerSec;
    } else {
        ModBase = C_CLK_FREQ_YUKON / pAC->DynIrqModInfo.MaxModIntsPerSec;
    }

    /* 
    ** We do not need to touch any other registers
    */
    SK_OUT32(pAC->IoBase, B2_IRQM_INI, ModBase);
}