int fc8050_i2c_bulkread(HANDLE hDevice, u16 addr, u8 *data, u16 length) { int res; u8 command = HPIC_READ | HPIC_AINC | HPIC_BMODE | HPIC_ENDIAN; res = i2c_bulkwrite(hDevice, BBM_COMMAND_REG, &command, 1); res |= i2c_bulkwrite(hDevice, BBM_ADDRESS_REG, (u8 *)&addr, 2); res |= i2c_bulkread(hDevice, BBM_DATA_REG, data, length); return res; }
int fc8050_i2c_longwrite(HANDLE hDevice, u16 addr, u32 data) { int res; u8 command = HPIC_WRITE | HPIC_AINC | HPIC_BMODE | HPIC_ENDIAN; res = i2c_bulkwrite(hDevice, BBM_COMMAND_REG, &command, 1); res |= i2c_bulkwrite(hDevice, BBM_ADDRESS_REG, (u8 *)&addr, 2); res |= i2c_bulkwrite(hDevice, BBM_DATA_REG, (u8 *)&data, 4); return res; }
int fc8050_i2c_longread(HANDLE hDevice, fci_u16 addr, fci_u32 *data) { int res; fci_u8 command = HPIC_READ | HPIC_AINC | HPIC_BMODE | HPIC_ENDIAN; res = i2c_bulkwrite(hDevice, BBM_COMMAND_REG, &command, 1); res |= i2c_bulkwrite(hDevice, BBM_ADDRESS_REG, (fci_u8*)&addr, 2); res |= i2c_bulkread(hDevice, BBM_DATA_REG, (fci_u8*)data, 4); return res; }
int fc8050_i2c_bulkwrite(HANDLE hDevice, fci_u16 addr, fci_u8* data, fci_u16 length) { int res; fci_u8 command = HPIC_WRITE | HPIC_AINC | HPIC_BMODE | HPIC_ENDIAN; res = i2c_bulkwrite(hDevice, BBM_COMMAND_REG, &command, 1); res |= i2c_bulkwrite(hDevice, BBM_ADDRESS_REG, (fci_u8*)&addr, 2); res |= i2c_bulkwrite(hDevice, BBM_DATA_REG, data, length); return res; }
int fc8050_i2c_wordread(HANDLE hDevice, fci_u16 addr, fci_u16 *data) { int res; fci_u8 command = HPIC_READ | HPIC_AINC | HPIC_BMODE | HPIC_ENDIAN; if(BBM_SCI_DATA <= addr && BBM_SCI_SYNCRX >= addr) command = HPIC_READ | HPIC_WMODE | HPIC_ENDIAN; res = i2c_bulkwrite(hDevice, BBM_COMMAND_REG, &command, 1); res |= i2c_bulkwrite(hDevice, BBM_ADDRESS_REG, (fci_u8*)&addr, 2); res |= i2c_bulkread(hDevice, BBM_DATA_REG, (fci_u8*)data, 2); return res; }
int fc8150_i2c_byteread(HANDLE hDevice, u16 addr, u8 *data) { int res; u8 command = HPIC_READ | HPIC_BMODE | HPIC_ENDIAN; OAL_OBTAIN_SEMAPHORE(); res = i2c_bulkwrite(hDevice, CHIP_ADDR, BBM_ADDRESS_REG , (u8 *)&addr, 2); res |= i2c_bulkwrite(hDevice, CHIP_ADDR, BBM_COMMAND_REG, &command, 1); res |= i2c_bulkread(hDevice, CHIP_ADDR, BBM_DATA_REG, data, 1); OAL_RELEASE_SEMAPHORE(); return res; }
int fc8150_i2c_longwrite(HANDLE hDevice, u16 addr, u32 data) { int res; u8 command = HPIC_WRITE | HPIC_AINC | HPIC_BMODE | HPIC_ENDIAN; OAL_OBTAIN_SEMAPHORE(); res = i2c_bulkwrite(hDevice, CHIP_ADDR, BBM_ADDRESS_REG , (u8 *)&addr, 2); res |= i2c_bulkwrite(hDevice, CHIP_ADDR, BBM_COMMAND_REG, &command, 1); res |= i2c_bulkwrite(hDevice, CHIP_ADDR, BBM_DATA_REG, (u8 *)&data, 4); OAL_RELEASE_SEMAPHORE(); return res; }
int fc8150_i2c_dataread(HANDLE hDevice, u16 addr, u8 *data, u32 length) { int res; u8 command = HPIC_READ | HPIC_BMODE | HPIC_ENDIAN; mutex_lock(&fci_i2c_lock); res = i2c_bulkwrite(hDevice, CHIP_ADDR, BBM_ADDRESS_REG , (u8 *)&addr, 2); res |= i2c_bulkwrite(hDevice, CHIP_ADDR, BBM_COMMAND_REG, &command, 1); res |= i2c_dataread(hDevice, CHIP_ADDR, BBM_DATA_REG, data, length); mutex_unlock(&fci_i2c_lock); return res; }
int fc8150_i2c_wordwrite(HANDLE hDevice, u16 addr, u16 data) { int res; u8 command = HPIC_WRITE | HPIC_AINC | HPIC_BMODE | HPIC_ENDIAN; mutex_lock(&fci_i2c_lock); res = i2c_bulkwrite(hDevice, CHIP_ADDR, BBM_ADDRESS_REG , (u8 *)&addr, 2); res |= i2c_bulkwrite(hDevice, CHIP_ADDR, BBM_COMMAND_REG, &command, 1); res |= i2c_bulkwrite(hDevice, CHIP_ADDR, BBM_DATA_REG, (u8 *)&data, 2); mutex_unlock(&fci_i2c_lock); return res; }
int fc8050_i2c_wordwrite(HANDLE hDevice, u16 addr, u16 data) { int res; u8 command = HPIC_WRITE | HPIC_AINC | HPIC_BMODE | HPIC_ENDIAN; if (BBM_SCI_DATA <= addr && BBM_SCI_SYNCRX >= addr) command = HPIC_WRITE | HPIC_WMODE | HPIC_ENDIAN; res = i2c_bulkwrite(hDevice, BBM_COMMAND_REG, &command, 1); res |= i2c_bulkwrite(hDevice, BBM_ADDRESS_REG, (u8 *)&addr, 2); res |= i2c_bulkwrite(hDevice, BBM_DATA_REG, (u8 *)&data, 2); return res; }
int fc8150_bypass_write(HANDLE hDevice, u8 chip, u8 addr, u8 *data, u16 length) { int res; u8 bypass_addr = 0x03; u8 bypass_data = 1; u8 bypass_len = 1; OAL_OBTAIN_SEMAPHORE(); res = i2c_bulkwrite(hDevice, CHIP_ADDR, bypass_addr , &bypass_data, bypass_len); res |= i2c_bulkwrite(hDevice, chip, addr, data, length); OAL_RELEASE_SEMAPHORE(); return res; }
int fc8150_bypass_write(HANDLE hDevice, u8 chip, u8 addr, u8 *data, u16 length) { int res; u8 bypass_addr = 0x03; u8 bypass_data = 1; u8 bypass_len = 1; mutex_lock(&fci_i2c_lock); res = i2c_bulkwrite(hDevice, CHIP_ADDR, bypass_addr , &bypass_data, bypass_len); res |= i2c_bulkwrite(hDevice, chip, addr, data, length); mutex_unlock(&fci_i2c_lock); return res; }
s32 fc8080_i2c_bulkwrite(HANDLE handle, u16 addr, u8 *data, u16 length) { s32 res; mutex_lock(&lock); res = i2c_bulkwrite(handle, (u8) CHIP_ADDR, addr, (u8 *) &data, length); mutex_unlock(&lock); return res; }
s32 fc8080_i2c_longwrite(HANDLE handle, u16 addr, u32 data) { s32 res; mutex_lock(&lock); res = i2c_bulkwrite(handle, (u8) CHIP_ADDR, addr, (u8 *) &data, 4); mutex_unlock(&lock); return res; }