Beispiel #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;
}
Beispiel #2
0
/* pin mux */
void pin_mux_config(UINT32 param1, UINT32 param2)
{
	*((volatile UINT32*)0xb8000028) |= ((1 << 18) | (1 << 17) | (1 << 1) | (1 << 16)); /* RF_AGC_PDM[b17&b18],GPIO2[b1],GPIO7[b16] */
	*((volatile UINT32*)0xb800002c) |= (1 << 6); //SPIDF[b6]

#if(CAS_TYPE==CAS_IRDETO)
	*((volatile UINT32*)0xb8000028) |= ( (1 << 21)|(1 << 22));//gpio18,17 as i2c[b22,21]	
#endif

	//enable hw7816 1, reserve for future use
	//*(volatile unsigned long*)(0xb800002c) |=(1<<2);

	//enable hw7816 2
	*(volatile unsigned long*)(0xb800002c) |= (1 << 3);

    if(IC_REV_0!=sys_ic_get_rev_id())
    {
        /*uart1     tx/eeprom_addr[13], pin52, (2ch[1:0]  1:tx, 2:rx, 3:txrx )
                       rx/eeprom_addr[12], pin53, (28h[10:9] 0:tx, 1:rx, 2:txrx )*/
        *((volatile UINT8 *)0xb800002c) &= (~0x03);
        *((volatile UINT8 *)0xb800002c) |= 0x01;
        *((volatile UINT8 *)0xb8000029) &= (~0x06);
        *((volatile UINT8 *)0xb8000029) |= 0x02;
    }        
}
Beispiel #3
0
/**********************************************************
 * 	Name		:   	hcdi_s3602_open
 *	Description	:   	usb host controller s3602 device initialization
 *	Parameter	:	hc_dev : usb host controller device pointer
 *	Return		:	RET_SUCCESS: success
 * 					RET_FAILURE: error
 ***********************************************************/
RET_CODE hcdi_s3602_open_ex(struct usb_hc_device* hc_dev)
{
	struct hc_s3602_private* p_priv = hc_dev->priv_ctrl;

	p_priv->hc_dev = hc_dev;

	if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id() >=IC_REV_5))
		p_priv->int_id = USB_HC_M3329E5_INTERRUPT_ID;
	else   if (sys_ic_get_chip_id() == ALI_S3602)
		p_priv->int_id = USB_HC_S3602_INTERRUPT_ID;
	else
		return !RET_SUCCESS; // usb invalid chip id




	hcd_s3602_sw_init_ex(p_priv);
	hcd_s3602_hw_init_ex(p_priv);
	osal_interrupt_register_lsr(p_priv->int_id, (ISR_PROC) hcd_s3602_isr_ex,
		(UINT32) hc_dev);

	return RET_SUCCESS;
}
Beispiel #4
0
void test_reset_bus(UINT32 base_addr)
{
	UINT32 bus_speed;
	
	usb_hw_init(base_addr);
	osal_task_sleep(500);
	//disable int
	*((volatile unsigned char *)(base_addr+0x1E))= 0x00;
	*((volatile unsigned char *)(base_addr+0x1F))= 0x00;
	*((volatile unsigned char *)(base_addr+0x62))= 0xFF;
	//TX_DRIVING +10%
	if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()<IC_REV_5))
		*((volatile unsigned char *)0xb800007C) = 0x03;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -

	USB_LOGO_PRINTF("1.reset usb bus!\n");
	issue_reset_to_device(base_addr);	
	if(wait_bus_reset_finish(base_addr) != RET_SUCCESS)
		goto err;
	osal_task_sleep(500);
	USB_LOGO_PRINTF("get device speed");
	bus_speed = get_device_speed(base_addr);
	if (bus_speed & B_OPER_FS)
	{
		USB_LOGO_PRINTF("Device is in FS mode!\n");
	}
	else if (bus_speed & B_OPER_LS)
	{
		USB_LOGO_PRINTF("Device is in LS mode!\n");
	}
	else 
	{
		USB_LOGO_PRINTF("Device is in HS mode!\n");
	}
err:
	return;
}
Beispiel #5
0
/**********************************************************
 * 	Name		:   	hcdi_s3602_attach
 *	Description	:   	usb host controller s3602 device attach
 *	Parameter	:	notify: HC event notify callback to USBD
 *	Return		:	RET_SUCCESS: success
 * 					RET_FAILURE: error
 ***********************************************************/
RET_CODE hcdi_s3602_attach_ex(HC_NOTIFY_CB notify)
{
	struct usb_hc_device* dev;
	struct hc_s3602_private* priv ;	
	void* priv_mem_ctrl;
	void* priv_mem_bulk;
	void* priv_mem_bulk_out;
	void* priv_mem_opt_bulk;
	void* priv_mem_int_c;
	void* priv_mem_int_d;
	UINT32 base_address;
	UINT16 i = 0;


	dev = (struct usb_hc_device *) dev_alloc(hc_s3602_name_ex,
									HLD_DEV_TYPE_USB_HOST,
									sizeof(struct usb_hc_device));
	if (dev == NULL)
	{
		HCDI_CMD_PRINTF("Error: Alloc usb host controller device error!\n");
		HCDI_CMD_ASSERT(0);
		return RET_FAILURE;
	}

	/* Alloc structure space of private  ctrl*/
	priv_mem_ctrl = (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f);
	if (priv_mem_ctrl == NULL)
	{
		dev_free(dev);
		HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n");
		HCDI_CMD_ASSERT(0);
		return RET_FAILURE;
	}
	/* Private date struct 16 bytes aligen */
	dev->priv_ctrl= priv = (void *) (((UINT32) priv_mem_ctrl+ 0x0f) & (~0x0f));
	/* Init priv element */
	MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private));
	priv->priv_addr = priv_mem_ctrl;		/* Unaligned address of struct real located */
	priv->priv_type = USB_CONTROL_TRANSFER_MODE ;


	/* Alloc structure space of private bulk */
	priv_mem_bulk = (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f);
	if (priv_mem_bulk== NULL)
	{
		FREE(priv_mem_ctrl);
		dev_free(dev);
		HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n");
		HCDI_CMD_ASSERT(0);
		return RET_FAILURE;
	}
	/* Private date struct 16 bytes aligen */
	dev->priv_bulk= priv = (void *) (((UINT32) priv_mem_bulk+ 0x0f) & (~0x0f));
	/* Init priv element */
	MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private));
	priv->priv_addr = priv_mem_bulk;		/* Unaligned address of struct real located */
	priv->priv_type = USB_BULK_IN_TRANSFER_MODE ;


	/* Alloc structure space of private bulk_out */
	priv_mem_bulk_out = (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f);
	if (priv_mem_bulk_out== NULL)
	{
		FREE(priv_mem_ctrl);
		FREE(priv_mem_bulk);
		dev_free(dev);
		HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n");
		HCDI_CMD_ASSERT(0);
		return RET_FAILURE;
	}
	/* Private date struct 16 bytes aligen */
	dev->priv_bulk_out= priv = (void *) (((UINT32) priv_mem_bulk_out+ 0x0f) & (~0x0f));
	/* Init priv element */
	MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private));
	priv->priv_addr = priv_mem_bulk_out;		/* Unaligned address of struct real located */
	priv->priv_type = USB_BULK_OUT_TRANSFER_MODE ;

	
	/* Alloc structure space of private opt_bulk */
	priv_mem_opt_bulk = (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f);
	if (priv_mem_opt_bulk== NULL)
	{
		FREE(priv_mem_ctrl);
		FREE(priv_mem_bulk);
		FREE(priv_mem_bulk_out);
		dev_free(dev);
		HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n");
		HCDI_CMD_ASSERT(0);
		return RET_FAILURE;
	}
	/* Private date struct 16 bytes aligen */
	dev->priv_opt_bulk = priv = (void *) (((UINT32) priv_mem_opt_bulk+ 0x0f) & (~0x0f));
	/* Init priv element */
	MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private));
	priv->priv_addr = priv_mem_opt_bulk;		/* Unaligned address of struct real located */
	priv->priv_type = USB_OPT_BULK_TRANSFER_MODE ;
	

	/* Alloc structure space of private int_c*/
	priv_mem_int_c= (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f);
	if (priv_mem_int_c == NULL)
	{
		
		FREE(priv_mem_bulk);
		FREE(priv_mem_ctrl);
		dev_free(dev);
		HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n");
		HCDI_CMD_ASSERT(0);
		return RET_FAILURE;
	}
	/* Private date struct 16 bytes aligen */
	dev->priv_int_c= priv = (void *) (((UINT32) priv_mem_int_c+ 0x0f) & (~0x0f));
	/* Init priv element */
	MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private));
	priv->priv_addr = priv_mem_int_c;		/* Unaligned address of struct real located */
	priv->priv_type = USB_INTERRUPT_TRANSFER_MODE ;


	/* Alloc structure space of private int d*/
	priv_mem_int_d= (void *) MALLOC(sizeof(struct hc_s3602_private) + 0x0f);
	if (priv_mem_int_d == NULL)
	{
		FREE(priv_mem_int_c);
		FREE(priv_mem_bulk);
		FREE(priv_mem_ctrl);
		dev_free(dev);
		HCDI_CMD_PRINTF("Alloc usb host controller device prive memory error!\n");
		HCDI_CMD_ASSERT(0);
		return RET_FAILURE;
	}
	/* Private date struct 16 bytes aligen */
	dev->priv_int_d= priv = (void *) (((UINT32) priv_mem_int_d+ 0x0f) & (~0x0f));
	/* Init priv element */
	MEMSET((UINT8 *) priv, 0, sizeof(struct hc_s3602_private));
	priv->priv_addr = priv_mem_int_d;		/* Unaligned address of struct real located */
	priv->priv_type = USB_HUB_TRANSFER_MODE ;

	/* Function point init */
	if( (sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id() >=IC_REV_5))
		dev->base_addr = HC_S3329E5_BASE_ADDR;
	else  if (sys_ic_get_chip_id() == ALI_S3602)
		dev->base_addr = HC_S3602_BASE_ADDR;
	else
		return !RET_SUCCESS; // usb invalid chip id
		

	//dev->base_addr = base_address;
	dev->init = hcdi_s3602_attach_ex;
	dev->open = hcdi_s3602_open_ex;
	dev->close = hcdi_s3602_close_ex;

	dev->submit_upt = hcdi_s3602_submit_upt_ex;
	dev->cancel_upt = hcdi_s3602_cancel_upt_ex;
	dev->suspend = hcdi_s3602_suspend_ex;
	dev->resume = hcdi_s3602_resume_ex;
	dev->reset = hcdi_s3602_reset_ex;
	dev->io_control = hcdi_s3602_ioctl_ex;

	dev->hc_notify_uplayer = notify;

	dev->rh_port_num = 1;
	//dev->curr_upt = NULL;
	dev->curr_upt_bulk= NULL;
	dev->curr_upt_ctl= NULL;
	dev->curr_upt_int_c= NULL;
	dev->curr_upt_int_d= NULL;

	for (i = 0; i < USB_MAX_DEVICES; i++)
		dev->adrsVec[i] = 0;

	dev->pRoot = NULL ;

	dev->nanSeconds = 0;

	/* Add this device to queue */
	if (dev_register(dev) != SUCCESS)
	{
		HCDI_CMD_PRINTF("Error: Register usb host controller device error!\n");
		FREE(priv_mem_int_d);
		FREE(priv_mem_int_c);
		FREE(priv_mem_bulk);
		FREE(priv_mem_ctrl);
		dev_free(dev);
		HCDI_CMD_ASSERT(0);
		return RET_FAILURE;
	}

	return RET_SUCCESS;
}
Beispiel #6
0
RET_CODE usb_test_ui_enum(struct usb_device_descriptor *dev_descriptor )
{
	UINT32 ret = RET_SUCCESS;
	UINT8 cmd_set_dev_addr[]={0x00,0x05,0x02,0x00,0x00,0x00,0x00,0x00 }; //addr: 0x02
	UINT8 cmd_get_dev_desc[]={0x80,0x06,0x00,0x01,0x00,0x00,0x12,0x00 };
	UINT8 temp_buff[8];
	UINT32 bus_speed;
	UINT32 base_addr = 0xb800F000;
		
	usb_if_test_flag = IF_TEST_PACKET;
	
	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_test_show_txt("enumeration...");

	usb_hw_init(base_addr);
	osal_task_sleep(2);
//	osal_delay(100);
	//disable int
	*((volatile unsigned char *)(base_addr+0x1E))= 0x00;
	*((volatile unsigned char *)(base_addr+0x1F))= 0x00;
	*((volatile unsigned char *)(base_addr+0x62))= 0xFF;
	//TX_DRIVING +10%
	if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()<IC_REV_5))
		*((volatile unsigned char *)0xb800007C) = 0x03;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -

	USB_LOGO_PRINTF("\n 1.reset usb bus!\n");
	issue_reset_to_device(base_addr);	
	if(wait_bus_reset_finish(base_addr) != RET_SUCCESS)
	{
		ret = !RET_SUCCESS;
		goto err;
	}
	osal_task_sleep(500);
	USB_LOGO_PRINTF("get device speed");
	bus_speed = get_device_speed(base_addr);
	if (bus_speed & B_OPER_FS)
	{
		USB_LOGO_PRINTF("Device is in FS mode!\n");
	}
	else if (bus_speed & B_OPER_LS)
	{
		USB_LOGO_PRINTF("Device is in LS mode!\n");
	}
	else 
	{
		USB_LOGO_PRINTF("Device is in HS mode!\n");
	}
	osal_task_sleep(2000);

//	usbd_set_dev_address(new_dev) ;
	USB_LOGO_PRINTF("\n 2.set_dev_address!\n");
		
	if(ep0_setup(base_addr,cmd_set_dev_addr,8) != RET_SUCCESS)
	{
		ret = !RET_SUCCESS;
		goto err;
	}
	USB_LOGO_PRINTF("control SETUP phase OK!\n");
			
	if(ep0_in_data(base_addr,temp_buff,0) != RET_SUCCESS)
	{
		ret = !RET_SUCCESS;
		goto err;
	}
//	if(ep0_status(base_addr, B_TOKEN_IN) != RET_SUCCESS)
//		goto err;
	USB_LOGO_PRINTF("control STATUS phase OK!\n");

//	usbd_get_descriptor()
	USB_LOGO_PRINTF("\n 3.get dev descriptor!\n");

	set_device_address(base_addr,2);
	if(ep0_setup(base_addr,cmd_get_dev_desc,8) != RET_SUCCESS)
	{
		ret = !RET_SUCCESS;
		goto err;
	}
	USB_LOGO_PRINTF("control SETUP phase OK!\n");
			
	if(ep0_in_data(base_addr,((UINT8*)&test_device_descriptor),18) != RET_SUCCESS)
	{
		ret = !RET_SUCCESS;
		goto err;
	}
	USB_LOGO_PRINTF("control DATA phase OK!\n");
	


	if(ep0_status(base_addr, B_TOKEN_OUT) != RET_SUCCESS)
	{
		ret = !RET_SUCCESS;
		goto err;
	}
	USB_LOGO_PRINTF("control STATUS phase OK!\n");
	MEMCPY(dev_descriptor , &test_device_descriptor  ,18) ;
	
err:	
	if(ret  != RET_SUCCESS)
	{
		usb_test_show_txt("Enum Fail , Please check usb port");
	}else{
		usb_test_show_txt("enumeration success");
		
	}
	bus_enum_success = TRUE ;
	//usb_test_show_hex("dev_desc:",((UINT8*)&test_device_descriptor),18);
	return ret;
	
}
Beispiel #7
0
/******************************************
* deal with event from usb_if_test UI, do usb_if_test thing 
*
******************************************/
RET_CODE  usb_test_ui_event_ex(IfEvtMsg_t  ui_event_msg)
{
	unsigned long i;
	volatile unsigned long j;
	UINT32 base_addr = 0xb800F000;
	UINT32 vid = ui_event_msg.vid ,
		    pid = ui_event_msg.pid ,
		    port_id = ui_event_msg.port_id ;
	
	USB_LOGO_PRINTF("USB IF test mode...\n");
	USB_LOGO_PRINTF("VID:0x%04x PID:0x%04x\n",vid,pid);
	//usb_if_test_info_show(vid,pid);
	
	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);
	//disable int
	*((volatile unsigned char *)(base_addr+0x1E))= 0x00;
	*((volatile unsigned char *)(base_addr+0x1F))= 0x00;
	*((volatile unsigned char *)(base_addr+0x62))= 0xFF;
	//TX_DRIVING +10%
	if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()<IC_REV_5))
	{
		*((volatile unsigned char *)0xb800007C) = 0x03;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
	}
	if (sys_ic_get_chip_id() == ALI_S3602F)
 	{
		*((volatile unsigned char *)(base_addr+0xF1))= 0x79;	//UTMI_REGCTL[15:12] Squelch Level Control, UTMI_REGCTL[11:10]	TX Driving Current Control, UTMI_REGCTL[9]	Slew Rate control for TX.
		*((volatile unsigned char *)(base_addr+0xF0))= 0x14;	//Bit 8-6: Reserved Bit 5: Turn OFF MOS NC in PLL's CHPUP  UTMI_REGCTL[4:2]	PLL Loop filter control  UTMI_REGCTL[1:0]	PLL Charge Pump selection
 	}
	 switch(pid)
	 {
		case PID_test_se0:
			usb_if_test_flag = IF_TEST_SE0;
			USB_LOGO_PRINTF("Test SE0_NAK...\n");
			//Test SE-> 
			if (sys_ic_get_chip_id() == ALI_S3602F)
				*((volatile unsigned char *)(base_addr))= 0x20;
			*((volatile unsigned char *)(base_addr+0x3b))= 0x04;
			*((volatile unsigned char *)(base_addr+0x33))= 0x48;
			for(i=0;i<0xFFFF;i++) j=i;
			*((volatile unsigned char *)(base_addr+0x33))= 0x40;
			*((volatile unsigned char *)(base_addr+0x3F))= 0x44;
			break;
		case PID_test_J:
			usb_if_test_flag = IF_TEST_J;
			USB_LOGO_PRINTF("Test J...\n");
			//Test J->
			if (sys_ic_get_chip_id() == ALI_S3602F)
				*((volatile unsigned char *)(base_addr))= 0x20;
			*((volatile unsigned char *)(base_addr+0x3b))= 0x04;
			*((volatile unsigned char *)(base_addr+0x33))= 0x48;
			for(i=0;i<0xFFFF;i++) j=i;
			*((volatile unsigned char *)(base_addr+0x33))= 0x40;
			*((volatile unsigned char *)(base_addr+0x3F))= 0x41;
			break;
		case PID_test_K:
			usb_if_test_flag = IF_TEST_K;
			USB_LOGO_PRINTF("Test K...\n");
			//Test K->
			if (sys_ic_get_chip_id() == ALI_S3602F)
				*((volatile unsigned char *)(base_addr))= 0x20;
			*((volatile unsigned char *)(base_addr+0x3b))=0x04;
			*((volatile unsigned char *)(base_addr+0x33))= 0x48;
			for(i=0;i<0xFFFF;i++) j=i;
			*((volatile unsigned char *)(base_addr+0x33))= 0x40;
			*((volatile unsigned char *)(base_addr+0x3F))= 0x42;
			break;
		case PID_test_packet:
			usb_if_test_flag = IF_TEST_PACKET;
			USB_LOGO_PRINTF("Test Packet...\n");
			//Test Packet->
			if (sys_ic_get_chip_id() == ALI_S3602F)
				*((volatile unsigned char *)(base_addr))= 0x20;
			*((volatile unsigned char *)(base_addr+0x3b))= 0x04;
			*((volatile unsigned char *)(base_addr+0x33))= 0x48;
			for(i=0;i<0xFFFF;i++) j=i;
			*((volatile unsigned char *)(base_addr+0x33))= 0x40;
			*((volatile unsigned char *)(base_addr+0x3F))= 0x48;
			break;
		case PID_test_suspend:
			usb_if_test_flag = IF_TEST_SUSPEND;
			USB_LOGO_PRINTF("TEST_HS_HOST_PORT_SUSPEND_RESUME...\n");
			if ((sys_ic_get_chip_id() == ALI_M3329E)&&(sys_ic_get_rev_id()<IC_REV_5))
				*((volatile unsigned char *)0xb800007C) = 0x00;	//USB_PLL_SEL: DISC_SEL/PD_HS/PD_FS/PD_PLL . SQUELCH_LEVEL -/TX_DRIVING -
			test_suspend_resume(base_addr);
			break;
		case PID_test_get_desc:
			usb_if_test_flag = IF_TEST_GET_DESC;
			USB_LOGO_PRINTF("TEST_SINGLE_STEP_GET_DEVIC_DESCRIPTOR...\n");
			test_step_get_desc(base_addr);
			break;
		case PID_test_get_desc_data:
			usb_if_test_flag = IF_TEST_GET_DESC_DATA;
			USB_LOGO_PRINTF("TEST_SINGLE_STEP_GET_DEVIC_DESCRIPTOR_DATA...\n");
			test_step_get_desc_data(base_addr);
			break;
		case PID_test_bus_enumeration:
			usb_if_test_flag = IF_TEST_GET_DESC_DATA;
			USB_LOGO_PRINTF("test_bus_enumeration...\n");
			//usb_test_bus_enum();
			osal_task_sleep(2000);
			USB_LOGO_PRINTF("test_bus_enumeration...\n");
			//usb_test_bus_enum();
			osal_task_sleep(2000);
			USB_LOGO_PRINTF("test_bus_enumeration...\n");
			//usb_test_bus_enum();
			break;
		default:
			USB_LOGO_PRINTF("PID err VID:0x%04x PID:0x%04x\n",vid,pid);
			break;
	 }
	 return RET_SUCCESS;	
}
Beispiel #8
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;
}
Beispiel #9
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);

}