/*
 * Function starts Read and write operation and transfers received data to TTY core. It pulls down MRDY signal
 * in case of single frame transfer then sets "ifx_read_write_completion" to indicate transfer complete.
 */
static void
ifx_spi_send_and_receive_data(struct ifx_spi_data *spi_data)
{
	unsigned int rx_valid_buf_size;
	int status = 0;
	int recieve_copied ;

	//printk("ifx_spi_sync_read_write %d \n ", ifx_current_frame_size+IFX_SPI_HEADER_SIZE) ;
	status = ifx_spi_sync_read_write(spi_data, ifx_current_frame_size+IFX_SPI_HEADER_SIZE); /* 4 bytes for header */
	if(status > 0){
		memset(ifx_tx_buffer,0,IFX_SPI_MAX_BUF_SIZE+IFX_SPI_HEADER_SIZE);
		ifx_ret_count = ifx_ret_count + ifx_valid_frame_size;
	}

	// hgahn
	if(memcmp(rx_dummy1, ifx_rx_buffer, IFX_SPI_HEADER_SIZE) ==0) {
		ifx_receiver_buf_size = 0;
		if (!ifx_master_initiated_transfer)
			printk(">> spi dummy \n") ;
		return;
	}else if(memcmp(rx_dummy2, ifx_rx_buffer, IFX_SPI_HEADER_SIZE) ==0) {
		ifx_receiver_buf_size = 0;
		// printk("received dummy2  err") ;
		return;
	}

	/* Handling Received data */
	ifx_receiver_buf_size = ifx_spi_get_header_info(&rx_valid_buf_size);


// hgahn
	if((spi_data->throttle == 0) && (rx_valid_buf_size != 0)){ //&& !(spi_data->ifx_spi_lock)){
		if(spi_data->ifx_tty){
			recieve_copied = tty_insert_flip_string(spi_data->ifx_tty, ifx_rx_buffer+IFX_SPI_HEADER_SIZE, rx_valid_buf_size);

			// if(recieve_copied)
				tty_flip_buffer_push(spi_data->ifx_tty);
			//else
			//	printk("tty_insert_flip_string err") ;
		}
		else {
			printk("no tty err \n") ;
		}
	}
	/*else
  	{
	handle RTS and CTS in SPI flow control
	Reject the packet as of now
	}*/
}
Ejemplo n.º 2
0
/*
 * Function starts Read and write operation and transfers received data to TTY core. It pulls down MRDY signal
 * in case of single frame transfer then sets "ifx_read_write_completion" to indicate transfer complete.
 */
static void 
ifx_spi_send_and_receive_data(struct ifx_spi_data *spi_data)
{
	unsigned int rx_valid_buf_size;
	int status = 0; 

	status = ifx_spi_sync_read_write(spi_data, ifx_current_frame_size+IFX_SPI_HEADER_SIZE); /* 4 bytes for header */                         
	if(status > 0){
#if defined(LGE_DUMP_SPI_BUFFER)
    dump_spi_buffer("ifx_spi_send_and_receive_data()[Trans]", &(ifx_tx_buffer[4]), COL_SIZE);
#elif defined(LGE_VT_DATA_DUMP)
    dump_spi_wr_buffer(&(ifx_tx_buffer[4]), ifx_valid_frame_size + 4);
#endif

		memset(ifx_tx_buffer,0,IFX_SPI_MAX_BUF_SIZE+IFX_SPI_HEADER_SIZE);
		ifx_ret_count = ifx_ret_count + ifx_valid_frame_size;
	}

	// hgahn
	if(memcmp(rx_dummy, ifx_rx_buffer, IFX_SPI_HEADER_SIZE) ==0) {

		ifx_receiver_buf_size = 0;
		return;
	}

	/* Handling Received data */
	ifx_receiver_buf_size = ifx_spi_get_header_info(&rx_valid_buf_size);


// hgahn
	if((spi_data->throttle == 0) && (rx_valid_buf_size != 0) && !(spi_data->ifx_spi_lock)){
#ifdef LGE_DUMP_SPI_BUFFER
    dump_spi_buffer("ifx_spi_send_and_receive_data()[Recev]", &(ifx_rx_buffer[4]), COL_SIZE);
#elif defined(LGE_VT_DATA_DUMP)
    //dump_spi_rd_buffer(&(ifx_rx_buffer[4]), rx_valid_buf_size-2); /* MUX에서의 Ctrl & Flag Byte 제거 */
#endif

		tty_insert_flip_string(spi_data->ifx_tty, ifx_rx_buffer+IFX_SPI_HEADER_SIZE, rx_valid_buf_size);
		tty_flip_buffer_push(spi_data->ifx_tty);
	}  
	/*else
  	{ 
	handle RTS and CTS in SPI flow control
	Reject the packet as of now 
	}*/
}
Ejemplo n.º 3
0
/*
 * Function starts Read and write operation and transfers received data to TTY core. It pulls down MRDY signal
 * in case of single frame transfer then sets "ifx_read_write_completion" to indicate transfer complete.
 */
static void ifx_spi_send_and_receive_data(struct ifx_spi_data *spi_data)
{
	unsigned int rx_valid_buf_size;
	int status = 0; 
	int recieve_copied ;
	
	IFX_SPI_DEBUG(" curr frame size = %d, total size=%d\n ",
					spi_data->ifx_current_frame_size, spi_data->ifx_current_frame_size+IFX_SPI_HEADER_SIZE) ;
	
	status = ifx_spi_sync_read_write(spi_data, spi_data->ifx_current_frame_size+IFX_SPI_HEADER_SIZE); /* 4 bytes for header */ 
	IFX_SPI_DEBUG("status = %d ", status);	

#ifdef IFX_SPI_DUMP_LOG
		IFX_SPI_PRINTK("SPI TX	----------------- ");
		ifx_dump_atcmd(spi_data->ifx_tx_buffer+IFX_SPI_HEADER_SIZE+2);	
#endif	
	
	if(status > 0)
	{
		memset(spi_data->ifx_tx_buffer,0,IFX_SPI_MAX_BUF_SIZE+IFX_SPI_HEADER_SIZE);
		spi_data->ifx_ret_count = spi_data->ifx_ret_count + spi_data->ifx_valid_frame_size;
	}

       //ifx modem에서만 rx buf에 data 없으면 return... 
	if (*((int*)spi_data->ifx_rx_buffer) == 0xFFFFFFFF)
	{
		spi_data->ifx_receiver_buf_size = 0;
	        IFX_SPI_DEBUG("received data is nothing..");
			
		return;
	}

	/* Handling Received data */
	spi_data->ifx_receiver_buf_size = ifx_spi_get_header_info(spi_data->ifx_rx_buffer, &rx_valid_buf_size);

        // spi에서 rx data가 존재하면 tty 로 전송
	if((spi_data->throttle == 0) && (rx_valid_buf_size != 0))
	{ 
		if(spi_data->ifx_tty)
		{
#if defined(LGE_DUMP_SPI_BUFFER)
		dump_spi_buffer("SPI RX", &spi_data->ifx_rx_buffer[4], COL_SIZE);
#endif		
#ifdef IFX_SPI_DUMP_LOG
		 IFX_SPI_PRINTK("SPI RX ----------------- ");
		 ifx_dump_atcmd(spi_data->ifx_rx_buffer+IFX_SPI_HEADER_SIZE+2) ;	 
#endif	

		 /* spi에서 rx data가 존재하면 tty 로 전송	*/
#ifdef IFX_SPI_SPEED_MEASUREMENT
			uiRxlen[spi_data->ifx_tty->index] = rx_valid_buf_size+IFX_SPI_HEADER_SIZE;
#endif		
			recieve_copied = tty_insert_flip_string(spi_data->ifx_tty,
											(spi_data->ifx_rx_buffer+IFX_SPI_HEADER_SIZE),
											rx_valid_buf_size);
			// if(recieve_copied)
			tty_flip_buffer_push(spi_data->ifx_tty);
			//else 
			//	printk("tty_insert_flip_string err") ;
		}
		else 
		{
			IFX_SPI_DEBUG("no tty err ") ;
		}
	}  
	/*else
  	{ 
	handle RTS and CTS in SPI flow control
	Reject the packet as of now 
	}*/
#ifdef WAKE_LOCK_RESUME
	if(spi_data->wake_lock_flag)
	{
		spi_data->wake_lock_flag = 0;
	}
#endif	
}