Пример #1
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*/
Пример #2
0
/*
 * 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*/
Пример #3
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 */
Пример #4
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 */
Пример #5
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 */