static inline int platform_read_i2c_block(struct i2c_adapter *i2c_bus
		, u8 page
		, u8 offset
		, u8 count
		, u8 *values
		)
{
#if 0
	struct i2c_msg msg[2];

	msg[0].flags = 0;
	msg[0].addr = page >> 1;
	msg[0].buf = &offset;
	msg[0].len = 1;

	msg[1].flags = I2C_M_RD;
	msg[1].addr = page >> 1;
	msg[1].buf = values;
	msg[1].len = count;

	return i2c_transfer(i2c_bus_adapter, msg, 2);
#endif
   
	I2C_ReadBlock(page, offset,values, count);
	///printk("%s:%d I2c read page:0x%02x,offset:0x%02x,values:0x%02X,count:0x%02X\n"
    ///                ,__FUNCTION__,__LINE__, page, offset, values, count);
    return 2;
    
}
Beispiel #2
0
unsigned char I2C_ReadSegmentBlock(unsigned char deviceID, unsigned char segment, unsigned char offset, unsigned char *buffer, unsigned int length)
{
//	I2C_WriteByte(deviceID , 0x01, segment);
	I2C_ReadBlock(deviceID, offset, buffer, length);
	
	return 0;
}
Beispiel #3
0
//------------------------------------------------------------------------------
// Function: I2C_ReadByte
// Description: Read one byte from the spacifed I2C slave address at the specified offset.
//              The offset address is one byte (8 bit offset only).
//              The read data is returned.  There is no indication in case of error.
//------------------------------------------------------------------------------
BYTE I2C_ReadByte(BYTE deviceID, BYTE offset)
{
    BYTE returnData = 0;

    I2C_ReadBlock( deviceID, offset, &returnData, 1 );

    return( returnData );
}
Beispiel #4
0
//------------------------------------------------------------------------------
// Function: I2C_ReadByte
// Description: Read one byte from the spacifed I2C slave address at the specified offset.
//              The offset address is one byte (8 bit offset only).
//              The read data is returned.  There is no indication in case of error.
//------------------------------------------------------------------------------
uint8_t I2C_ReadByte(uint8_t deviceID, uint8_t offset)
{
    uint8_t returnData = 0;

    I2C_ReadBlock( deviceID, offset, &returnData, 1 );

    return( returnData );
}
Beispiel #5
0
void ExtEeprom_ReadBlock(uns8 *array, const uns8 adress, const uns8 length) {
	if (adress <= EEPROM_MEMORY_END_ADRESS) {
		if (g_ExtEepromDetected) {
			I2C_ReadBlock(EEPROM_ADRESS, array, adress, length);
		}
	} else {
		Trace_String("invalid ext eeprom adress");
	}
}
long SiiMhlIoctl(struct file *pFile, unsigned int ioctlCode, unsigned long ioctlParam)
{
	long retStatus = 0;
	Register_t RegisterInfo;
	uint8_t reg;
	UserControl_t user_control;
	if (HalAcquireIsrLock() != HAL_RET_SUCCESS) {
		return -ERESTARTSYS;
	}
	switch (ioctlCode) {
	case SII_IOCTRL_REGISTER_READ:
		retStatus = copy_from_user(&RegisterInfo, (Register_t *) ioctlParam,
					   sizeof(Register_t));
		if (!retStatus) {
			RegisterInfo.value =
			    I2C_ReadByte(RegisterInfo.dev_address, RegisterInfo.subaddr);
			retStatus =
			    copy_to_user((Register_t *) ioctlParam, &RegisterInfo,
					 sizeof(Register_t));
		} else {
			pr_info("register read error!\n");
		}
		break;
	case SII_IOCTRL_REGISTER_WRITE:
		retStatus = copy_from_user(&RegisterInfo, (Register_t *) ioctlParam,
					   sizeof(Register_t));
		reg = I2C_ReadByte(RegisterInfo.dev_address, RegisterInfo.subaddr);
		reg = (reg & (~RegisterInfo.mask)) | (RegisterInfo.mask & RegisterInfo.value);
		I2C_WriteByte(RegisterInfo.dev_address, RegisterInfo.subaddr, reg);
		break;
	case SII_IOCTRL_USER:
		retStatus = copy_from_user(&user_control, (UserControl_t *) ioctlParam,
					   sizeof(UserControl_t));
		switch (user_control.ControlID) {
		case USER_GPIO_GET:
			/* HalGpioGetPin(user_control.SubCommand.GpioCtrl.GpioIndex, &user_control.SubCommand.GpioCtrl.Value); */
			break;
		case USER_GPIO_SET:
			/* HalGpioSetPin(user_control.SubCommand.GpioCtrl.GpioIndex, user_control.SubCommand.GpioCtrl.Value); */
			break;
		case USER_TRIGGER_EXT_INT:
			/* SiiTriggerExtInt(); */
			break;
		case USER_TRIGGER_MHL_INT:
			{
				if (TestDelay != NULL) {
					SiiOsTimerDelete(TestDelay);
					TestDelay = NULL;
				}
				SiiOsTimerCreate("Abort Time Out", SiiMhlTimerTestCB, NULL, true,
						 2000, false, &TestDelay);
			}
			break;
		case USER_ON_OFF_MHL_INT:
			HalEnableIrq(user_control.SubCommand.iSubCommand ? 1 : 0);
			break;
		case USER_RESET_MHL_CHIP:
			SiiMhlTxInitialize(EVENT_POLL_INTERVAL_MS);
			break;
		case USER_READ_SINK_EDID:
			{
#define _MASK_(aByte, bitMask, setBits) ((setBits) ? (aByte | bitMask) : (aByte & ~bitMask))
				int RepeatNums = 5, i;
				int iRepeatCnt = 0;
				uint8_t reg;
				uint8_t reg_save;
				reg_save = reg = I2C_ReadByte(0x72, 0xC7);
				reg = _MASK_(reg, BIT0, 1);
				I2C_WriteByte(0x72, 0xc7, reg);
				do {
					if (++iRepeatCnt > RepeatNums)
						break;
					reg = I2C_ReadByte(0x72, 0xC7);
					HalTimerWait(10);
				} while (!(reg & BIT1));
				if (iRepeatCnt > RepeatNums) {
					printk("try time out\n");
				} else {
					reg = I2C_ReadByte(0x72, 0xC7);
					reg = _MASK_(reg, BIT2, 1);
					I2C_WriteByte(0x72, 0xc7, reg);
					for (i = 0; i < 256; i++) {
					}
					I2C_ReadBlock(0xa0, 0, user_control.SubCommand.EDID, 128);
					I2C_ReadBlock(0xa0, 128, &user_control.SubCommand.EDID[128],
						      128);
					I2C_WriteByte(0x72, 0xc7, reg_save);
				}
			}
			break;
		}
		retStatus = copy_to_user((UserControl_t *) ioctlParam,
					 &user_control, sizeof(UserControl_t));
		break;
	default:
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,
				"SiiMhlIoctl, unrecognized ioctlCode 0x%0x received!\n", ioctlCode);
		retStatus = -EINVAL;
		break;
	}
	HalReleaseIsrLock();
	return retStatus;
}