Пример #1
0
RET_CODE usb_test_stop(void)
{
	UINT32 base_addr = 0xb800F000;
	
	if (sys_ic_is_M3202())//(sys_ic_get_chip_id() == ALI_M3202)
		base_addr = HC_M3202_BASE_ADDR;
	else if( (sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()>=IC_REV_5))
		base_addr = HC_S3329E5_BASE_ADDR;
	else if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()<IC_REV_5))
		base_addr = HC_S3329E_BASE_ADDR;
	else  if (sys_ic_get_chip_id() == ALI_S3602)
		base_addr = HC_S3602_BASE_ADDR;
	else  if (sys_ic_get_chip_id() == ALI_S3602F)
	{
		if(s3602f_test_port == IF_FRONT_PROT)
			base_addr = HC_S3602F_BASE_ADDR;
		else if(s3602f_test_port == IF_REAR_PROT)
			base_addr = HC_S3602F_BASE_ADDR1;

	}
	else
		return !RET_SUCCESS; // usb invalid chip id
//	usb_hw_init(base_addr);
	//usb_hw_init(base_addr);
	if((usb_if_test_flag != IF_TEST_GET_DESC)&&(usb_if_test_flag != IF_TEST_GET_DESC_DATA))
	{
		if (sys_ic_get_chip_id() == ALI_M3329E)
		{
			*((volatile UINT32 *)0xb8000060) = (*((UINT32 *)0xb8000060) | (1<<10));	
			osal_delay(1);
			*((volatile UINT32 *)0xb8000060) = (*((UINT32 *)0xb8000060) & (~(1<<10)));
		}
		else  if (sys_ic_get_chip_id() == ALI_S3602F)
		{
			*((volatile UINT32 *) 0xb8000080) = (*((UINT32 *) 0xb8000080) | 0x10000000);	
			osal_delay(1);
			*((volatile UINT32 *) 0xb8000080) = (*((UINT32 *) 0xb8000080) & 0xEFFFFFFF);
			
			*((volatile UINT32 *) 0xb8000080) = (*((UINT32 *) 0xb8000080) | 0x20000000);	
			osal_delay(1);
			*((volatile UINT32 *) 0xb8000080) = (*((UINT32 *) 0xb8000080) & 0xDFFFFFFF);
			
			*((volatile UINT8 *) (base_addr + 0xf2)) = 0x07;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
			osal_delay(2);
			*((volatile UINT8 *) (base_addr + 0xf2)) = 0x00;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
		}
	}
	//disable int
	*((volatile unsigned char *)(base_addr+0x1E))= 0x00;
	*((volatile unsigned char *)(base_addr+0x1F))= 0x00;
	*((volatile unsigned char *)(base_addr+0x62))= 0xFF;
	return RET_SUCCESS;
}
Пример #2
0
INT32 wait_ep0_finish(UINT32 base_addr)
{
	volatile unsigned char host_int_flag2;
	UINT32 i;
	
	i = 0;
	while(1)
	{
		osal_delay(1);
		//host_int_flg2 = *((volatile unsigned char *)0xb800F021);
		host_int_flag2 = get_host_int_flag2(base_addr);
		if(host_int_flag2&B_EP0_FSHOK_INT)
			break;
		if(host_int_flag2&B_EP0_FSHERR_INT)
		{
			USB_LOGO_PRINTF("EP0 err 0x21: 0x%02x",host_int_flag2);
			return !RET_SUCCESS;
		}
		if(i++ > 0x2FFFFF)
		{
			USB_LOGO_PRINTF("EP0 timeout 0x21: 0x%02x",host_int_flag2);
			return !RET_SUCCESS;
		}
	}
	return RET_SUCCESS;
}
Пример #3
0
void rt_gps_thread_entry (void *parameter) 
{
    rt_device_t dev ;
    int time = 0;
    uint8_t cfg_flag = 0;
    
    
    dev = rt_device_find(RT_GPS_DEVICE_NAME);
    rt_device_open(dev, RT_DEVICE_OFLAG_RDWR);

    while(1)
    {
        gps_read_data(dev);
        
        if(!cfg_flag)
        {
            if (get_gps)
            {
                gps_chip_config(5);
                
                /* config host uart baudrate to 115200. */
                gps_set_host_baudrate(BAUD_RATE_115200);

                osal_delay(1);                
                cfg_flag = 1;
                time = 0;
            }
            else
            {
                if (time++ > SECOND_TO_TICK(6))
                {
                    /* 初始设备串口波特率9600而PC的GPS模拟工具115200,
                       time>6s 未能解析出正确GPS NMEA则判断为PC GPS工具输入, 
                       set host uart1 baud to 115200 */
                    gps_set_host_baudrate(BAUD_RATE_115200);
                    cfg_flag = 1;
                }           
            }
        }
        
        osal_delay(1);
	}
}
Пример #4
0
//joey, 20120503, for idle reset proc service.
INT32 nim_s3821_idle_reset_proc(struct nim_device *dev)
{
    UINT8 data = 0;

   //joey, 20120504, add for only act as C3811 needs.
    nim_s3821_read(dev, 0x3b, &data, 1);
    if (MAGIC_CONST_1 == data) // check if S3811/C3811.
    {
        nim_s3821_read(dev, 0x147, &data, 1);
        if (data > MAGIC_CONST_0) // denote for C3811.
        {
           //joey, 20120613, for register access protection when HW operation.

            struct nim_s3821_private *dev_priv = (struct nim_s3821_private *)(dev->priv);
	    UINT32 tmp_data = 0;

            osal_mutex_lock(dev_priv->nim_s3821_i2c_mutex, OSAL_WAIT_FOREVER_TIME);

            //libc_printf("----------------80/40 whole chip reset!\n");
            //step 1: do the COFDM whole reset.
            tmp_data = *(volatile UINT32 *)0xb8000084;
            osal_delay(10);

            tmp_data = tmp_data | (1 << 22);
            *(volatile UINT32 *)0xb8000084 = tmp_data;
            osal_delay(10);

            tmp_data = tmp_data & (~(1 << 22));
            *(volatile UINT32 *)0xb8000084 = tmp_data;
            osal_delay(10);

            //joey, 20120613, for register access protection when HW operation.
            osal_mutex_unlock(dev_priv->nim_s3821_i2c_mutex);

            // step 2: store in the init register values.
            nim_s3821_init_config(dev);
        }
    }

    return SUCCESS;

}
Пример #5
0
void show_current_epg_detail_win(void)
{	
	UINT16 curitem;
	date_time start_dt,end_dt;
	date_time sch_first_time,sch_second_time,sch_third_time,sch_fourth_time;
	date_time start_time;
	INT32 event_num;
	eit_event_info_t* sch_event = NULL;
	struct win_epg_item_info epg_eve_list_info;
	struct winepginfo current_hl_item;
	SYSTEM_DATA* sys_data;
	
	sys_data = sys_data_get();
	
	if(sys_data->local_time.buseGMT == TRUE)
		get_UTC(&sch_first_time);
	else
		get_STC_time(&sch_first_time);

	if(sch_first_time.min>= 30)
		sch_first_time.min= 30;
	else
		sch_first_time.min = 0;
	win_epg_get_hour_offset(&sch_first_time,&sch_second_time,&sch_third_time,&sch_fourth_time);
	//----------------------
	start_dt =sch_first_time;
	end_dt=sch_fourth_time;

	if(end_dt.min==0)
		end_dt.min=29;
	else
		end_dt.min=59;

	start_dt.sec = 0;
	end_dt.sec = 0;

	curitem = sys_data_get_cur_group_cur_mode_channel();
	libc_printf("curitem = %d \n",curitem);
	sch_event=epg_get_cur_service_event((INT32)curitem, SCHEDULE_EVENT, &sch_first_time, &end_dt, &event_num, FALSE);
	osal_delay(300);
	//--------------------------
	libc_printf("sch_event->event_id = %d \n",sch_event->event_id);
//	if(sch_event->event_id == INVALID_ID)
//		return;
	if(event_num > 0 && sch_event != NULL)
	{
		current_hl_item.event_idx= sch_event->event_id;
		current_hl_item.start = start_dt;
		current_hl_item.end = end_dt;
		current_hl_item.pos =1;
	libc_printf("sch_event = %d \n",sch_event);
		win_epg_detail_open(curitem, &current_hl_item);
	}
}
Пример #6
0
void f_TC90512_dump_register(struct nim_device *dev)
{
		UINT8  i=0;
		UINT8 data[5];
		for(i=0;i<=0xff;i++)
		{
			f_TC90512_read(dev->base_addr,i,data,1);
		 	NIM_TC90512_PRINTF("reg=0x%x, data=0x%x\n",i,data[0]);
			 osal_delay(100);
		} 

}
Пример #7
0
INT32 wait_bus_reset_finish(UINT32 base_addr)
{
	volatile unsigned char host_int_flag1;
	UINT32 i;
	
	i = 0;
	while(1)
	{
		osal_delay(1);
		//host_int_flg2 = *((volatile unsigned char *)0xb800F021);
		host_int_flag1 = get_host_int_flag1(base_addr);
		if(host_int_flag1&B_USB_RST_INT)
			break;
		if(i++ > 0x2FFFFF)
		{
			USB_LOGO_PRINTF("reset bus timeout 0x21: 0x%02x",host_int_flag1);
			return !RET_SUCCESS;
		}
	}
	return RET_SUCCESS;
}
Пример #8
0
//joey, 20120503, for unlock interrupt proc service.
//joey, 20120614, for add-in tf exp interrupt proc service.
static INT32 nim_s3821_unlock_int_proc(struct nim_device *dev)
{
    UINT8 data = 0;
	
    // step A. read out interrupt information.
    nim_s3821_read(dev, 0x02, &data, 1);

    // Step B. check if unlock or tf buffer exception.
    if ((0x40 == (data & 0x40)) || (0x20 == (data & 0x20)))
    {
        //libc_printf("----------------unlock interrupt whole chip reset!\n");
        //find the interrupt
        struct nim_s3821_private *dev_priv = (struct nim_s3821_private *)(dev->priv);

        UINT32 tmp_data = 0;

        //joey, 20120613, for register access protection when HW operation.
        osal_mutex_lock(dev_priv->nim_s3821_i2c_mutex, OSAL_WAIT_FOREVER_TIME);

        //step 1: do the COFDM whole reset.
        
        tmp_data = *(volatile UINT32 *)0xb8000084;
        osal_delay(10);

        tmp_data = tmp_data | (1 << 22);
        *(volatile UINT32 *)0xb8000084 = tmp_data;
        osal_delay(10);

        tmp_data = tmp_data & (~(1 << 22));
        *(volatile UINT32 *)0xb8000084 = tmp_data;
        osal_delay(10);

        //joey, 20120613, for register access protection when HW operation.
        osal_mutex_unlock(dev_priv->nim_s3821_i2c_mutex);

       // step 2: store in the init register values.
        nim_s3821_init_config(dev);

        //set back the channel bw.
        //bandwidth setting.
        nim_s3821_read(dev, 0x13, &data, 1);
        data &= 0xcf;		// clear the bit[5:4], chan_bw

        switch(dev_priv->s3821_cur_channel_info.channel_bw)
        {
        case BW_6M:
            data |= (S3821_BW_6M << 4);
            break;
        case BW_7M:
            data |= (S3821_BW_7M << 4);
            break;
        case BW_8M:
            data |= (S3821_BW_8M << 4);
            break;
        default:
            data |= (S3821_BW_8M << 4);
            if(dev_priv->log_en)
            {
				NIM_S3821_DEBUG("Error! UnKnown bandwidth mode\n");
            } 	
            break;
        }

        nim_s3821_write(dev, 0x13, &data, 1);
        // step 3: 80/40 the COFDM.
        data = 0x80;
        nim_s3821_write(dev, 0x00, &data, 1);
        data = 0x40;
        nim_s3821_write(dev, 0x00, &data, 1);

        NIM_S3821_DEBUG("Finish TF exception interrupt process!\n");
    }
 
    return SUCCESS;

}
Пример #9
0
void p2p_delay_10ms(void)
{
	osal_delay(10000);
}
Пример #10
0
void p2p_delay(void)
{
    osal_delay(50000);
    osal_delay(50000);
}
Пример #11
0
static int SetSSIGap(unsigned int argc, unsigned char *argv[])
{
	UINT32 gap;
	struct nim_device *nim_dev = dev_get_by_id(HLD_DEV_TYPE_NIM, nim_id);
	
	if (argc != 2)
	{
	    SH_PRINTF("Usage: SetPara <clk>\n");
	    return -1;
	}
	else if(nim_dev == NULL)
	{
	    SH_PRINTF("Nim1 status error\n");
	    return -1;
	}

	if(strcasecmp("gap",argv[1]))
	{
		gap = ATOI(&(argv[1][3]));
		nim_io_control(nim_dev, NIM_DRIVER_CHANGE_TS_GAP, gap);
	}
	else
	{
		SH_PRINTF("parameter error\n");
		return -3;
	}

#if 1//path for lock delay
	UINT8	lock;
	UINT32 pre_tick = osal_get_tick();

	while((osal_get_tick()-pre_tick)>=SSI_GAP_TIMEOUT)
	{
		nim_get_lock(nim_dev,&lock);
		if(lock)
			break;

		osal_delay(30);
	}
#endif
	
	LIB_ASH_OC('S');
	LIB_ASH_OC('e');        
	LIB_ASH_OC('t');
	LIB_ASH_OC(' ');        
	LIB_ASH_OC('S');        
	LIB_ASH_OC('S');        	
	LIB_ASH_OC('I');       
	LIB_ASH_OC(' ');           	
	LIB_ASH_OC('G');          	
	LIB_ASH_OC('a');          	
	LIB_ASH_OC('p');          	
	LIB_ASH_OC(' ');          	
	LIB_ASH_OC('t');          	
	LIB_ASH_OC('o');          	
	LIB_ASH_OC(' ');          	
	LIB_ASH_OC('g');          	
	LIB_ASH_OC('a');          	
	LIB_ASH_OC('p');
	if(gap<10)
	{
		LIB_ASH_OC((gap + '0'));	
	}
	else
	{
		LIB_ASH_OC(((UINT8)gap/10 + '0'));	
		LIB_ASH_OC(((UINT8)gap%10 + '0'));	
	}

	LIB_ASH_OC('\r'); 
	LIB_ASH_OC('\n'); 	

	reset_perflag();
	return 0;    
}
Пример #12
0
void power_switch(UINT32 mode)
{
	unsigned long keycode;
	SYSTEM_DATA* sys_data;
	UINT32 vkey;
	UINT32 times = 0,display_type=0;
	date_time dt;
	UINT32 hh,mm,ss;
	char time_str[10];
	struct pan_key key_struct;
	UINT32 timer;
	struct sf_panel_attr panel_attr;
/*alfred.wu 1.0版本的MCU程序因为待机时间不能超过256小时*/
#ifdef MCUSTANDBY
	struct sf_panel_time time;
	date_time sRecentTime;	
	UINT32 nDurationTime = 0;
	UINT32 nYear = 0;
	UINT32 nMonth = 0;
	UINT32 nDay = 0;
	UINT32 nHour = 0;
	UINT32 nMin = 0;
	UINT32 nSec = 0;
	struct sf_standby_param standby_param;
	/*Note: For the limited memory size of MCU, if using led panel, the maximum IR key num is 5 and for vfd panel the size is 2. */
	struct sf_power_ir_key ir_key[] = \
		{
#ifdef RC04_A
			{0x007f, 0x1c}, /*RC04_A*/
#endif
#ifdef RC09_A
			{0x00FD, 0x1A}, /*RC09_A*/
#endif
#ifdef RC11_A
			{0x00ff, 0x54}, /*RC11_A*/	
#endif
#ifdef RC19_D
			{0x01fe, 0x00}, /*RC11_A*/	
#endif
#ifdef RC01_A_02
			{0x807f, 0x0a}, /*RC01_A_02*/	
#endif
#ifdef ORDER_GZ1010001
			{0x007f, 0x1c}, /*RC04_A*/
#else
			{0x007f, 0x0a}, /*RC01_A*/
#endif
			{0x01FE, 0x01}, /*REMOTE02420100*/
			{0x06FB, 0x0E}, /*ALI_RCU_60_KEY*/
		};
#endif
	sys_data = sys_data_get();
	sys_data->bstandmode = 1;
	sys_data_save(1);
	system_state = SYS_STATE_POWER_OFF;

/*Archer:The following process is unnessary when using mcu standby resolution.*/
#if 0
	power_off_process();
	power_off_process2();
#endif
#ifndef MCUSTANDBY
    if(mode != 1)
		key_pan_display("off ", 4);
	key_pan_display_standby(1);
	key_pan_display_lock(0);

    api_standby_led_onoff(TRUE);
#else
#if 0
    get_local_time(&dt);
    nDurationTime = api_get_recently_timer();
	POWER_PRINTF("nDurationTime = 0x%x\n",nDurationTime);
	if(0 != nDurationTime)
	{
		sRecentTime.year = YEAR(nDurationTime);
		sRecentTime.month= MONTH(nDurationTime);
		sRecentTime.day= DAY(nDurationTime);
		sRecentTime.hour= HOUR(nDurationTime);
		sRecentTime.min= MIN(nDurationTime);
		sRecentTime.sec= SEC(nDurationTime);

		POWER_PRINTF("RecentTime:%d-%d-%d %d:%d:%d\n",sRecentTime.year,sRecentTime.month,\
							sRecentTime.day, sRecentTime.hour,sRecentTime.min,sRecentTime.sec);
		
		get_time_offset(&dt,&sRecentTime,&nDay,&nHour,&nMin,&nSec);
		//standby_param.standby_time_sec = nHour*60*60+nMin*60;
		standby_param.standby_time_sec = 60;
		POWER_PRINTF("standby:hour:%d, minute:%d, total secs:%d\n",nHour,nMin, standby_param.standby_time_sec);
		//pan_set_standby_time((struct pan_device*)dev_get_by_id(HLD_DEV_TYPE_PAN,0),&sPanelTime);
	}
	else
	{
		POWER_PRINTF("no timer\n");
	}
#endif

	//pan_display(g_pan_dev, "        ", 8);//albert.li del 2011.1.25
	
	/*albert.li add 2011.1.25*/
	get_local_time(&dt);
	time.hour = dt.hour;
	time.min= dt.min;
	time.sec = dt.sec;
#ifndef FAKE_STANDBY	

	sf_panel_clear();
	reset_sf_panel_all_led();
	/*albert.li add end*/

	sf_panel_display_time(&time);

	sf_panel_term();
#else	
	pan_io_control(g_pan_dev, PAN_DRIVER_GET_ATTRIBUTE, &panel_attr);
	if (panel_attr.type == SF_PANEL_TYPE_LED)
	{
		pan_display(g_pan_dev,"OFF ", 4);
	}
	else
	{
		pan_display(g_pan_dev,"STANDBY", 7);
	}
#endif	
	power_off_process();
	//S5PanelStandby(g_pan_dev,(const)&sPanIRSpecialKey,2);//guop edit
	standby_param.ir_key_num = sizeof(ir_key)/sizeof(struct sf_power_ir_key);
	standby_param.ir_key_list = ir_key;
	standby_param.standby_time_sec = 0;
#ifndef FAKE_STANDBY
	sf_power_down(&standby_param);
#else	 //zhouxp fake standby
	{
		while (1)
		{
			ControlMsg_t msg;
			times++;
			times = times % 100; 
			osal_delay(5000);
						
			vkey = V_KEY_NULL;
			if(key_get_key(&key_struct,0))
			{
				keycode = scan_code_to_msg_code(&key_struct);
				ap_hk_to_vk(0, keycode, &vkey);
			}
			else
				keycode = PAN_KEY_INVALID;
			if(vkey == V_KEY_POWER)
			{
				power_on_process();
			}
			ap_receive_msg( &msg, 10);
			libc_printf("got msg type=%d\n",msg.msgType);
			if(msg.msgType== CTRL_MSG_SUBTYPE_CMD_TIMER_WAKEUP)
				power_on_process();
				
		}
	}
#endif		

#endif
#ifndef MCUSTANDBY
	if(1)	/* Real Standby*//*alfred.wu ali的IC真待机处理流程在MCUSTANDBY后不会执行*/
	{
		UINT32	cur_time, target_time;

		get_local_time(&dt);
		pan_close(g_pan_dev);
        timer = api_get_recently_timer();
		// disable interrupt
		osal_interrupt_disable();

		cur_time = (dt.sec & 0x3F ) | ((dt.min & 0x3F )<<6)  | ((dt.hour & 0x1F )<<12) | ((dt.day & 0x1F)<<17)
			| ((dt.month & 0xF) << 22) | (((dt.year % 100) & 0x3F)<<26);

		sys_ic_enter_standby(timer, cur_time);
		// enable interrupt
		osal_interrupt_enable();
	}	
    
     
    while (1)
    {
		times++;
		times = times % 100; 
		osal_delay(5000);
    				
		if(times==0)
		{
			//get_cur_time(&hh,&mm,&ss);
			get_local_time(&dt);
			hh = dt.hour;
			mm = dt.min;

			if(display_type==0)
			    sprintf(time_str,"%02d%02d ",hh,mm);
			else
				sprintf(time_str,"%02d.%02d",hh,mm);

			key_pan_display(time_str, 5);
			display_type++;
			display_type %= 2;
		}
		
		vkey = V_KEY_NULL;
		if(key_get_key(&key_struct,0))
		{
			keycode = scan_code_to_msg_code(&key_struct);
			ap_hk_to_vk(0, keycode, &vkey);
		}
		else
			keycode = PAN_KEY_INVALID;
		if(vkey == V_KEY_POWER)
		{
			power_on_process();
		}
	}
#endif	
}
Пример #13
0
void test_suspend_resume(UINT32 base_addr)
{
	volatile unsigned char usb_intf_int_flag,host_int_flag1;
	UINT32 i;
	UINT32 bus_speed;
			
	get_usb_intf_int_status(base_addr);
	get_host_int_flag1(base_addr);
	
	osal_task_sleep(5000);
	osal_task_sleep(5000);
	osal_task_sleep(5000);
//	issue_host_suspend(base_addr);	
	USB_LOGO_PRINTF("suspend...  \n");
	if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()<IC_REV_5))
	{
		*((volatile unsigned char *)0xb800007C) |= 0x0C;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
	}
	*((volatile unsigned char *)(base_addr+0x10)) |= 0x40;
	i=0;
	while(1)
	{
		osal_delay(100);
		usb_intf_int_flag = get_usb_intf_int_status(base_addr);
		host_int_flag1 = get_host_int_flag1(base_addr);
		if(host_int_flag1 != 0) 
			USB_LOGO_PRINTF(" fg1:%02x \n",host_int_flag1);
		if(host_int_flag1&B_H_SUSREM_INT)
			break;
		i++;
		if(i > 1000) break;
	}
	usb_test_show_txt("suspend done!");
	USB_LOGO_PRINTF("suspend done! %02x  i:%d \n",host_int_flag1,i);
	osal_task_sleep(5000);
	osal_task_sleep(5000);
	osal_task_sleep(5000);
//	issue_host_resume(base_addr);	
	USB_LOGO_PRINTF("resume...  \n");
	*((volatile unsigned char *)(base_addr+0x10)) |= 0x80;
	if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()<IC_REV_5))
	{
		*((volatile unsigned char *)0xb800007C) &= ~(0x0C);	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
	}
	i=0;
	while(1)
	{
		osal_delay(100);
		usb_intf_int_flag = get_usb_intf_int_status(base_addr);
		host_int_flag1 = get_host_int_flag1(base_addr);
		if(host_int_flag1 != 0) 
			USB_LOGO_PRINTF(" fg1:%02x \n",host_int_flag1);
		if(host_int_flag1&B_H_SUSREM_INT)
			break;
		i++;
		if(i > 1000) break;
	}
	usb_test_show_txt("resume done!");
	USB_LOGO_PRINTF("resume done! %02x i:%d \n",host_int_flag1,i);
	return;
}
Пример #14
0
void usb_hw_init(UINT32 base_addr)
{	
	/*issue resume to clear suspend state */
	//issue_host_resume();

	//usb system reset
	if (sys_ic_get_chip_id() == ALI_M3329E)
	{
		*((UINT32 *)0xb8000060) = (*((UINT32 *)0xb8000060) | (1<<10));	
		osal_delay(1);
		*((UINT32 *)0xb8000060) = (*((UINT32 *)0xb8000060) & (~(1<<10)));
	}
	 if (sys_ic_get_chip_id() == ALI_S3602)
	{
		*((UINT32 *)0xb8000080) = (*((UINT32 *)0xb8000080) | 0x10000000);	
		osal_delay(1);
		*((UINT32 *)0xb8000080) = (*((UINT32 *)0xb8000080) & 0xEFFFFFFF);
	}
	if(sys_ic_is_M3202())//( sys_ic_get_chip_id() == ALI_M3202)	//M3202
	{
		*((UINT32 *)0xb8000060) = (*((UINT32 *)0xb8000060) | (1<<31));	
		osal_delay(1);
		*((UINT32 *)0xb8000060) = (*((UINT32 *)0xb8000060) & (~(1<<31)));
	}
	if( (sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()<IC_REV_5))
	{
		*((UINT8 *)0xb800007C) = 0x73;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
		osal_delay(1);
		*((UINT8 *)0xb800007C) = 0x03;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
	}
	if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()>=IC_REV_5))
	{
		*((UINT8 *)0xb800007E) = 0x07;	//USB_PLL_SEL: Reserved	Reserved	Reserved	Reserved	DISC_SEL	PD_HS	PD_FS	PD_PLL
		osal_delay(1);
		*((UINT8 *)0xb800007E) = 0x00;	//USB_PLL_SEL: Reserved	Reserved	Reserved	Reserved	DISC_SEL	PD_HS	PD_FS	PD_PLL
		*((UINT8 *)0xb800007C) = 0x0b;	//PLL LPF control
		*((UINT8 *)0xb800007D) = 0x7C;	//Bit 7-4: For squelch level Control  Bit 3-2: TX Driving Current Control
	}
	if ((sys_ic_get_rev_id() < IC_REV_2) && (sys_ic_get_chip_id() == ALI_S3602))
	{
	      *((UINT8 *)0xb800000C) = 0x07;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
	      osal_delay(2);
	      *((UINT8 *)0xb800000C) = 0x00;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
	}
	if ((sys_ic_get_rev_id() >= IC_REV_2) && (sys_ic_get_chip_id() == ALI_S3602))
	{
	      *((UINT8 *)0xb8000064) = 0x07;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
	      osal_delay(2);
	      *((UINT8 *)0xb8000064) = 0x00;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
	}
	if(sys_ic_get_chip_id() == ALI_S3602F)
	{
        	if(base_addr == HC_S3602F_BASE_ADDR)
        	{
			*((UINT32 *) 0xb8000080) = (*((UINT32 *) 0xb8000080) | 0x10000000);	
			osal_delay(1);
			*((UINT32 *) 0xb8000080) = (*((UINT32 *) 0xb8000080) & 0xEFFFFFFF);
        	}
        	if(base_addr == HC_S3602F_BASE_ADDR1)
        	{
			*((UINT32 *) 0xb8000080) = (*((UINT32 *) 0xb8000080) | 0x20000000);	
			osal_delay(1);
			*((UINT32 *) 0xb8000080) = (*((UINT32 *) 0xb8000080) & 0xDFFFFFFF);
        	}
		*((UINT8 *) 0xb8000064) = 0x07;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
		osal_delay(2);
		*((UINT8 *) 0xb8000064) = 0x00;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
	}
	/* software reset USB host IP */
	software_rst_usbip(base_addr);
	
	/* clear suspend state */
	clear_host_suspend(base_addr);

	/* EPA auto force enable when DMA counter down counts form 1 to 0, or EOT event */
	en_epa_auto_force(base_addr);

	/* set OTG to host mode */
	set_usbip_host_mode(base_addr);

	/* EPA type is Bulk OUT, fifo type is ping-pong */
	set_ep_transfer_type(base_addr, HEPASETR, B_EPTYPE_BULK);
	set_fifo_type(base_addr, HEPASETR,B_FIFO_PINGPONG);
		
	/* EPB type is Bulk IN, fifo type is ping-pong */
	set_ep_transfer_type(base_addr, HEPBSETR, B_EPTYPE_BULK);
	set_fifo_type(base_addr, HEPBSETR,B_FIFO_PINGPONG);
	
	/* EPC type is Intr, fifo type is ping-pong */
	set_ep_transfer_type(base_addr, HEPCSETR, B_EPTYPE_INTR);
	set_fifo_type(base_addr, HEPCSETR,B_FIFO_PINGPONG);
	
	/* init EP0's fifo */
	init_ep_fifo(base_addr, HEP0FCTR);
	/* init EPA's fifo */
	init_ep_fifo(base_addr, HEPAFCTR);
	/* init EPB's fifo */
	init_ep_fifo(base_addr, HEPBFCTR);
	/* init EPC's fifo */
	init_ep_fifo(base_addr, HEPCFCTR);

	/* read all interrupt flag first to make sure no previous state occur */
	get_host_int_flag1(base_addr);
	get_host_int_flag2(base_addr);
	get_usb_intf_int_status(base_addr);

	/* enable usb host interrupt except SOF int*/
//	en_host_int_flag1(base_addr, B_OVERCUR_IE|B_BABBLE_IE|B_H_SUSREM_IE|B_USB_RST_IE|B_CONN_DSCN_IE);
	en_host_int_flag1(base_addr, B_BABBLE_IE|B_H_SUSREM_IE|B_USB_RST_IE|B_CONN_DSCN_IE);
	en_host_int_flag2(base_addr, B_H_INT2_ALL_IE);

	/* enable usb interface interrupt */
	enable_all_usb_intf_int(base_addr);

}