u8 csi_event_enable(u32 mask, u8 err_reg_no) { switch (err_reg_no) { case 1: return csi_core_write(MASK1, (~mask) & csi_core_read(MASK1)); case 2: return csi_core_write(MASK2, (~mask) & csi_core_read(MASK2)); default: return ERR_OUT_OF_BOUND; } }
u32 csi_event_get_source(u8 err_reg_no) { switch (err_reg_no) { case 1: return csi_core_read(ERR1); case 2: return csi_core_read(ERR2); default: return ERR_OUT_OF_BOUND; } }
void check_csi_error(void) { unsigned int temp1, temp2; while(1){ dump_csi_reg(); temp1 = csi_core_read(ERR1); temp2 = csi_core_read(ERR2); if(temp1 != 0) ISP_PRINT(ISP_INFO,"error-------- 1:0x%08x\n", temp1); if(temp2 != 0) ISP_PRINT(ISP_INFO,"error-------- 2:0x%08x\n", temp2); } }
static unsigned char csi_event_disable(unsigned int mask, unsigned char err_reg_no) { switch (err_reg_no) { case 1: csi_core_write(MASK1, mask | csi_core_read(MASK1)); break; case 2: csi_core_write(MASK2, mask | csi_core_read(MASK2)); break; default: return ERR_OUT_OF_BOUND; } return 0; }
u8 csi_init(u32 base_address) { csi_error_t e = SUCCESS; do { if (csi_core_initialized == 0) { access_init((u32*)base_address); if (csi_core_read(VERSION) == (u32)(CURRENT_VERSION)) { csi_core_initialized = 1; break; } else { LOG_ERROR("Driver not compatible with core"); e = ERR_NOT_COMPATIBLE; break; } } else { LOG_ERROR("driver already initialised"); e = ERR_ALREADY_INIT; break; } } while(0); return e; }
u8 csi_core_write_part(csi_registers_t address, u32 data, u8 shift, u8 width) { u32 mask = (1 << width) - 1; u32 temp = csi_core_read(address); temp &= ~(mask << shift); temp |= (data & mask) << shift; return csi_core_write(address, temp); }
static unsigned char csi_core_write_part(unsigned int address, unsigned int data, unsigned char shift, unsigned char width) { unsigned int mask = (1 << width) - 1; unsigned int temp = csi_core_read(address); temp &= ~(mask << shift); temp |= (data & mask) << shift; csi_core_write(address, temp); return 0; }
static int csi_phy_ready(unsigned int id) { int ready; // TODO: phy0: lane0 is ready. need to be update for other lane ready = csi_core_read(PHY_STATE); #if 0 ISP_PRINT(ISP_INFO,"%s:phy state ready:0x%08x\n", __func__, ready); #endif if ((ready & (1 << 10 )) && (ready & (1<<4))) return 1; return 0; }