This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I need to start CAMSS module of AM5708 under RTOS. I took as a base of Linux driver for CSI2_PHY. I can't understand what I should do flag RESET_DONE set in register CAL_CSI2_COMPLEXIO_CFG_0 .
For the first I configure module CSI2_PHY
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
HW_WR_REG32(0x4845B330, 0x00000001); // CAL_CSI2_CTX0_0
// DT DT type: MIPI CSI-2 Specs
// 0x1: All - DT filter is disabled
// 0x24: RGB888 1 pixel = 3 bytes
// 0x2B: RAW10 4 pixels = 5 bytes
// 0x2A: RAW8 1 pixel = 1 byte
// 0x1E: YUV422 2 pixels = 4 bytes
// VC (Virtual Channel) is 0
// NUM_LINES_PER_FRAME => 0 means auto detect
HW_WR_REG32(0x4845B304, 0x00000123); // CAL_CSI2_COMPLEXIO_CFG_0
// Clock - pos 3
// Data[0] - pos 2
// Data[1] - pos 1
// Enable IRQ_WDMA_END 0 / 1
HW_WR_REG32(0x4845B028 + 0x10, 0x00000001); // CAL_HL_IRQENABLE_SET_1
// Enable IRQ_WDMA_START 0 / 1
HW_WR_REG32(0x4845B028 + 0x20, 0x00000001); // CAL_HL_IRQENABLE_SET_1
// Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling
HW_WR_REG32(0x4845B318, 0xFF000000); // CAL_CSI2_VC_IRQENABLE_0
/* Steps
* 1. Configure D-PHY mode and enable required lanes
* 2. Reset complex IO - Wait for completion of reset
* Note if the external sensor is not sending byte clock,
* the reset will timeout
* 3 Program Stop States
* A. Program THS_TERM, THS_SETTLE, etc... Timings parameters
* in terms of DDR clock periods
* B. Enable stop state transition timeouts
* 4.Force FORCERXMODE
* D. Enable pull down using pad control
* E. Power up PHY
* F. Wait for power up completion
* G. Wait for all enabled lane to reach stop state
* H. Disable pull down using pad control
*/
/* 1. Configure D-PHY mode and enable required lanes */
HW_WR_REG32(0x4A002E94, 0x00026400); // CTRL_CORE_CAMERRX_CONTROL
// CSI_CTRLCLKEN = 1
// CSI0_CAMMODE = 0 (DPHY mode)
// CSI0_LANEENABLE = 3 (2 lanes enable)
// CSI0_MODE = 1
UARTConfigPrintf(DEBUG_UART_BASE, "CTRL_CORE_CAMERRX_CONTROL(0x4A002E94): %08X\n", HW_RD_REG32(0x4A002E94));
/* 2. Reset complex IO - Do not wait for reset completion */
dwTmp = HW_RD_REG32(0x4845B304);
HW_WR_REG32(0x4845B304, dwTmp | 0x40000000); // CAL_CSI2_COMPLEXIO_CFG_0
// RESET_CTRL = 1 (Complex IO reset de-asserted)
dwTmp = HW_RD_REG32(0x4845B304); // Dummy read to allow SCP to complete
UARTConfigPrintf(DEBUG_UART_BASE, "CAL_CSI2_COMPLEXIO_CFG_0(0x4845B304): %08X\n", dwTmp);
/* 3.A. Program Phy Timing Parameters */
//UARTConfigPrintf(DEBUG_UART_BASE, "REG0(0x4845B800): %08X\n", HW_RD_REG32(0x4845B800));
HW_WR_REG32(0x4845B800, 0x01000427); // THS_SETTLE = 0x27 (for 400 MHz) Programmed value = floor(105 ns/DDRClk period) + 4
// THS_TERM = 0x04 (for 400 MHz) Programmed value = floor(20 ns/DDRClk period)
// HSCLOCKCONFIG = 1 (Disable clock missing detector)
UARTConfigPrintf(DEBUG_UART_BASE, "REG0(0x4845B800): %08X\n", HW_RD_REG32(0x4845B800));
//UARTConfigPrintf(DEBUG_UART_BASE, "REG1(0x4845B804): %08X\n", HW_RD_REG32(0x4845B804));
HW_WR_REG32(0x4845B804, 0x0002E10E); // Default Value
UARTConfigPrintf(DEBUG_UART_BASE, "REG1(0x4845B804): %08X\n", HW_RD_REG32(0x4845B804));
/* 3.B. Program Stop States */
HW_WR_REG32(0x4845B314, 0x00004197); // CAL_CSI2_TIMING_0
// STOP_STATE_COUNTER_IO1 = 0x197
// STOP_STATE_X4_IO1 = 0
// STOP_STATE_X16_IO1 = 1
UARTConfigPrintf(DEBUG_UART_BASE, "CAL_CSI2_TIMING_0 (0x4845B314): %08X\n", HW_RD_REG32(0x4845B314));
/* 4. Force FORCERXMODE */
dwTmp = HW_RD_REG32(0x4845B314);
dwTmp |= 0x00008000;
HW_WR_REG32(0x4845B314, dwTmp);
UARTConfigPrintf(DEBUG_UART_BASE, "CAL_CSI2_TIMING_0 (0x4845B314): %08X\n", HW_RD_REG32(0x4845B314));
/* E. Power up the PHY using the complex IO */
dwTmp = HW_RD_REG32(0x4845B304);
dwTmp |= 0x08000000; // PWR_CMD = 1
HW_WR_REG32(0x4845B304, dwTmp);
UARTConfigPrintf(DEBUG_UART_BASE, "CAL_CSI2_COMPLEXIO_CFG_0 (0x4845B304): %08X\n", HW_RD_REG32(0x4845B304));
/* F. Wait for power up completion */
for(dwTmp = 0;dwTmp < 10;dwTmp++)
{
if((HW_RD_REG32(0x4845B304) & 0x02000000) != 0)
break; // Waiting for Power On
Osal_delay(1);
}
if(dwTmp < 10)
UARTConfigPuts(DEBUG_UART_BASE, "CSI-2 Powered Up\n", -1);
else
UARTConfigPuts(DEBUG_UART_BASE, "CSI-2 timeout\n", -1);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
As a result CSI-2 powered up well. Then I start up the CSI2 source (1080p) and waiting for flag RESET_DONE.
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
/* 2. Wait for reset completion */
for (dwTmp = 0; dwTmp < 250; dwTmp++)
{
dwReg = HW_RD_REG32(0x4845B304);
if((dwReg & 0x20000000) != 0) // CAL_CSI2_COMPLEXIO_CFG_0 (RESET_DONE bit)
break;
Osal_delay(1);
}
if(dwTmp < 250)
UARTConfigPuts(DEBUG_UART_BASE, "CSI-2 Complex IO Reset Done\n", -1);
else
UARTConfigPuts(DEBUG_UART_BASE, "CSI-2 Reset timeout\n", -1);
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
But flag doesn't set. Is this the problem with a signal or it's wrong initialization sequence?
Thank you for your help in advance!
Regards, Andrei
Hi,
Sorry we don't have CSI2 driver in RTOS and can't provide much input here. Please consider using the Linux OS, or trying to port Linux code into RTOS as you did. As you can't see the flag set, please make sure the Linux driver worked and use the same signal input to rule out the signal problem. As for the initialization sequence, please refer to TRM.
Regards, Eric
Hi!
I'm not sure if it's your case, but might be the following:
To complete reset, CSI receiver has to see STOP STATE (LP11, I think) on all MIPI lines, including MIPI clock.
If you started your image sensor to early, and keep only data lines in stop, but clock is running, your CSI PHY
will not complete reset.
Put sensor in sleep and turn it on right before "wait for reset"
Regards
Hi, German,
I have the following below configuration of lanes:
dx2, dy2 - clock lane
dx1, dy1 - data 0 lane
dx0, dy0 - data 1 lane
At the beginning all lanes of CSI-2 I hold at the level 1,2V. Then I write the registers of CSI as shown below:
CAL_CSI2_CTX0_0(0x4845B330): 1
CM_CAM_CAL_CLKCTRL(0x4A009028): 40001
CAL_CSI2_COMPLEXIO_CFG_0(0x4845B304): 123
CTRL_CORE_CAMERRX_CONTROL(0x4A002E94): 26400
CAL_CSI2_COMPLEXIO_CFG_0(0x4845B304): 40000123
REG0(0x4845B800): 1000427
REG1(0x4845B804): e002e10e
CAL_CSI2_TIMING_0 (0x4845B314): 4197
CAL_CSI2_TIMING_0 (0x4845B314): c197
CAL_CSI2_COMPLEXIO_CFG_0 (0x4845B304): 48000123
CSI-2 Powered Up
CAL_CSI2_COMPLEXIO_CFG_0 (0x4845B304): 4a000123
CSI_2_Start_Streaming()
Delay_100_ms()
Check_For_Reset_250_ms()
CSI-2 Reset timeout
CAL_CSI2_COMPLEXIO_CFG_0 (0x4845B304): 4a000123
As you wrote I start the sourse before checking loop for reset: Check_For_Reset_250_ms().
The reset status is invalid.
I supply clock and two data lanes as I can't supply only clock lane. May be is that reason?
I acctualy don't understand what does "byte clock" mean. Is this the frequency CSI-2_clock_lane / 8?
Can I supply normal video signal via all lanes in this case?
Regards
Hi!
a)
Haven't you tried to release COMLEXIO reset later? In your sequence
CM_CAM_CAL_CLKCTRL(0x4A009028): 40001
CAL_CSI2_COMPLEXIO_CFG_0(0x4845B304): 123
CTRL_CORE_CAMERRX_CONTROL(0x4A002E94): 26400
CAL_CSI2_COMPLEXIO_CFG_0(0x4845B304): 40000123 <--- comlexio reset is released here.
How about to move it to the point after "CSI-2 Powered Up"?
Something like that
CAL_CSI2_COMPLEXIO_CFG_0 (0x4845B304): 8000123
CSI-2 Powered Up
CAL_CSI2_COMPLEXIO_CFG_0 (0x4845B304): 4a000123
b) I keep all MIPI lines in LP00 (0V) until after compexio reset release.
That is, it looks like that:
MIPI -> LP00
Hold COMPLEXIO in reset
initialize and power up CSI PHY
release COMPLEXIO reset
MIPI -> LP11
(In that point we suppose to run FORCERX stuff, but I observe driver which works without it. Sometimes
I think that FORCERX is just TI guy's joke to have fun on designers)
start transmission
check for reset
I don't know if this LP00 state is really required. My attempts to get answers from TI
about require states of MIPI lines during initialization failed.
c) "byte clock"
From MIPI spec
The RxByteClkHS is generated
by dividing the received High-Speed DDR clock
Unless TI invented their own meaning
(Only not "/8", but "/4" -we have DDR bus here)
Regards
Hi German,
>> Can we get probably more detailed instructions then in spruhl6a with requirements to signals and timing, if they exist?
Can you please create a separate thread for this topic rather than hijacking this thread? This thread started out as an RTOS thread, but your question is more about hardware documentation. A separate thread will make it easier to track this related, but separate topic.
Thanks,
Frank
Hello!
Below is my vision of TI's CSI PHY start procedure.
I'm not related to TI. This is my personal experience, it can contain mistakes.
I'm working with DM385 processor, but I think CSI procedures can be similar in some other cases.
Hi, German,
Thanks for your support!
I tride your variant of sequence of initialization but when I do point 4 power status failed. In my case it works if finaly I make point 5. It seems that I have other SoC.
Then I'll try to set up module under Linux and I'll have a look inside setup process by emulator. Maybe this problem with CSI-2 signal level.
I'll inform you by email some later
Kind regards,
Andrei