{
dwc_otg_core_if_t *core_if = GET_CORE_IF(pcd);
dwc_otg_disable_global_interrupts( core_if );
- //
#ifdef CONFIG_ARCH_RK29
cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_AHB_BUS, true);
cru_set_soft_reset(SOFT_RST_USB_OTG_2_0_PHY, true);
dwc_otg_device_t *otg_dev = (dwc_otg_device_t *)(*((uint32_t *)_dev->platform_data));
dwc_otg_pcd_t * _pcd = otg_dev->pcd;
unsigned long flags;
-
- local_irq_save(flags);
+ local_irq_save(flags);
_pcd->check_vbus_timer.expires = jiffies + (HZ); /* 1 s */
- if(!pldata->get_status(USB_STATUS_ID)){ // id low
- if( pldata->phy_status){
+ if(!pldata->get_status(USB_STATUS_ID))
+ { // id low
+ if( pldata->dwc_otg_uart_mode != NULL )
+ {//exit phy bypass to uart & enable usb phy
+ pldata->dwc_otg_uart_mode( pldata, PHY_USB_MODE);
+ }
+ if( pldata->phy_status)
+ {
pldata->clock_enable( pldata, 1);
pldata->phy_suspend(pldata, USB_PHY_ENABLED);
}
}
- else if(pldata->get_status(USB_STATUS_BVABLID)){ // bvalid
+ else if(pldata->get_status(USB_STATUS_BVABLID))
+ { // bvalid
/* if usb not connect before ,then start connect */
- if( _pcd->vbus_status == 0 ) {
+ if( _pcd->vbus_status == 0 )
+ {
DWC_PRINT("********vbus detect*********************************************\n");
_pcd->vbus_status = 1;
if(_pcd->conn_en)
goto connect;
- else if( pldata->phy_status == USB_PHY_ENABLED ){
+ else if( pldata->phy_status == USB_PHY_ENABLED )
+ {
// not connect, suspend phy
pldata->phy_suspend(pldata, USB_PHY_SUSPEND);
udelay(3);
pldata->clock_enable( pldata, 0);
}
}
- else if((_pcd->conn_en)&&(_pcd->conn_status>=0)&&(_pcd->conn_status <3)){
+ else if((_pcd->conn_en)&&(_pcd->conn_status>=0)&&(_pcd->conn_status <3))
+ {
DWC_PRINT("********soft reconnect******************************************\n");
goto connect;
}
- else if(_pcd->conn_status ==3){
+ else if(_pcd->conn_status ==3)
+ {
//*Á¬½Ó²»ÉÏʱÊÍ·ÅËø£¬ÔÊÐíϵͳ½øÈë¶þ¼¶Ë¯Ãߣ¬yk@rk,20100331*//
dwc_otg_msc_unlock(_pcd);
_pcd->conn_status++;
_pcd->vbus_status = 2;
// not connect, suspend phy
- if( pldata->phy_status == USB_PHY_ENABLED ){
+ if( pldata->phy_status == USB_PHY_ENABLED )
+ {
pldata->phy_suspend(pldata, USB_PHY_SUSPEND);
udelay(3);
pldata->clock_enable( pldata, 0);
}
}
- }else {
+ }
+ else
+ {
_pcd->vbus_status = 0;
- if(_pcd->conn_status){
+ if(_pcd->conn_status)
+ {
_pcd->conn_status = 0;
dwc_otg_msc_unlock(_pcd);
}
- else if( pldata->phy_status == USB_PHY_ENABLED ){
+ else if( pldata->phy_status == USB_PHY_ENABLED )
+ {
/* no vbus detect here , close usb phy */
pldata->phy_suspend(pldata, USB_PHY_SUSPEND);
udelay(3);
- pldata->clock_enable( pldata, 0);
- }
+ pldata->clock_enable( pldata, 0);
+ /* usb phy bypass to uart mode */
+ if( pldata->dwc_otg_uart_mode != NULL )
+ pldata->dwc_otg_uart_mode( pldata, PHY_UART_MODE);
+ }
}
add_timer(&_pcd->check_vbus_timer);
local_irq_restore(flags);
connect:
if(_pcd->conn_status==0)
dwc_otg_msc_lock(_pcd);
- if( pldata->phy_status){
+ if( pldata->phy_status)
+ {
pldata->clock_enable( pldata, 1);
pldata->phy_suspend(pldata, USB_PHY_ENABLED);
}
static char pcd_name[] = "dwc_otg_pcd";
dwc_otg_pcd_t *pcd;
dwc_otg_device_t *otg_dev = (dwc_otg_device_t *)(*((uint32_t *)dev->platform_data));
- dwc_otg_core_if_t *core_if = otg_dev->core_if;
+ dwc_otg_core_if_t *core_if = otg_dev->core_if;
+ struct dwc_otg_platform_data *pldata = dev->platform_data;
int retval = 0;
int irq;
/*
INIT_DELAYED_WORK(&pcd->reconnect , dwc_phy_reconnect);
pcd->vbus_status = 0;
- pcd->phy_suspend = 0;
- if(dwc_otg_is_device_mode(core_if))
- mod_timer(&pcd->check_vbus_timer, jiffies+(HZ<<4)); // delay 16 S
+ pcd->phy_suspend = 0;
+ if(dwc_otg_is_device_mode(core_if)){
+#ifdef CONFIG_RK_USB_UART
+ if(pldata->get_status(USB_STATUS_BVABLID))
+ {
+ pldata->dwc_otg_uart_mode(pldata, PHY_USB_MODE);
+ }//phy usb mode
+ else
+ {
+ pldata->phy_suspend(pldata,USB_PHY_SUSPEND);
+ pldata->dwc_otg_uart_mode(pldata, PHY_UART_MODE);
+ }//phy bypass to uart mode
+#endif
+ mod_timer(&pcd->check_vbus_timer, jiffies+(HZ<<4)); // delay 16 S
+ }
+#ifdef CONFIG_RK_USB_UART
+ else if(pldata->dwc_otg_uart_mode != NULL)
+ pldata->dwc_otg_uart_mode(pldata, PHY_USB_MODE);//disable phy bypass uart
+#endif
+
return 0;
}
/**
#define USB_PHY_ENABLED 0\r
#define USB_PHY_SUSPEND 1\r
\r
-#define USB_STATUS_BVABLID 1\r
-#define USB_STATUS_DPDM 2\r
-#define USB_STATUS_ID 3\r
+#define PHY_USB_MODE 0\r
+#define PHY_UART_MODE 1\r
+\r
+#define USB_STATUS_BVABLID 1\r
+#define USB_STATUS_DPDM 2\r
+#define USB_STATUS_ID 3\r
+#define USB_STATUS_UARTMODE 4\r
\r
struct dwc_otg_platform_data {\r
void *privdata;\r
void (*clock_init)(void* pdata);\r
void (*clock_enable)(void* pdata, int enable);\r
void (*power_enable)(int enable);\r
+ void (*dwc_otg_uart_mode)(void* pdata, int enter_usb_uart_mode);\r
int (*get_status)(int id);\r
-};
\ No newline at end of file
+};\r
#define USBOTG_SIZE RK2928_USBOTG20_SIZE\r
#define USBGRF_SOC_STATUS0 (GRF_REG_BASE+0x14c)\r
#define USBGRF_UOC0_CON5 (GRF_REG_BASE+0x17c)\r
+#define USBGRF_UOC1_CON4 (GRF_REG_BASE+0X190)\r
#define USBGRF_UOC1_CON5 (GRF_REG_BASE+0x194)\r
\r
-\r
int dwc_otg_check_dpdm(void)\r
{\r
static uint8_t * reg_base = 0;\r
volatile unsigned int * otg_gotgctl;\r
volatile unsigned int * otg_hprt0;\r
int bus_status = 0;\r
- unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC0_CON5);//@lyz modify UOC0_CON2 to CON5\r
+ unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC0_CON5) ;\r
\r
- // softreset & clockgate //@lyz modify RK2928_CRU_BASE\r
*(unsigned int*)(RK2928_CRU_BASE+0x120) = ((7<<5)<<16)|(7<<5); // otg0 phy clkgate\r
udelay(3);\r
*(unsigned int*)(RK2928_CRU_BASE+0x120) = ((7<<5)<<16)|(0<<5); // otg0 phy clkgate\r
dsb();\r
*(unsigned int*)(RK2928_CRU_BASE+0xd4) = ((1<<5)<<16); // otg0 phy clkgate\r
*(unsigned int*)(RK2928_CRU_BASE+0xe4) = ((1<<13)<<16); // otg0 hclk clkgate\r
- *(unsigned int*)(RK2928_CRU_BASE+0xf4) = ((3<<10)<<16); // hclk usb clkgate//@lyz to be check\r
- \r
+ *(unsigned int*)(RK2928_CRU_BASE+0xf4) = ((3<<10)<<16); // hclk usb clkgat\r
+ \r
// exit phy suspend \r
- *otg_phy_con1 = ((0x01<<0)<<16); // exit suspend.@lyz\r
+ *otg_phy_con1 = ((0x01<<0)<<16); \r
\r
// soft connect\r
if(reg_base == 0){\r
- reg_base = ioremap(RK2928_USBOTG20_PHYS,USBOTG_SIZE);//@lyz\r
+ reg_base = ioremap(RK2928_USBOTG20_PHYS,USBOTG_SIZE);\r
if(!reg_base){\r
bus_status = -1;\r
goto out;\r
struct dwc_otg_platform_data *usbpdata=pdata;\r
unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC0_CON5);\r
if(suspend){\r
- *otg_phy_con1 = 0x1D5 |(0x1ff<<16); // enter suspend.\r
+ *otg_phy_con1 = 0x55 |(0x7f<<16); // enter suspend.\r
usbpdata->phy_status = 1;\r
}\r
else{\r
{\r
int ret = -1;\r
unsigned int usbgrf_status = *(unsigned int*)(USBGRF_SOC_STATUS0);\r
+ unsigned int uoc1_con4 = *(unsigned int*)(USBGRF_UOC1_CON4);\r
switch(id)\r
{\r
case USB_STATUS_BVABLID:\r
// id in grf\r
ret = (usbgrf_status &(1<<10));\r
break;\r
+ case USB_STATUS_UARTMODE:\r
+ // usb_uart_mode in grf\r
+ ret = (uoc1_con4 &(1<<13));\r
default:\r
break;\r
}\r
return ret;\r
}\r
+void dwc_otg_uart_mode(void* pdata, int enter_usb_uart_mode)\r
+{\r
+#ifdef CONFIG_RK_USB_UART\r
+ //struct dwc_otg_platform_data *usbpdata=pdata;//1:uart 0:usb\r
+ unsigned int * otg_phy_con1 = (unsigned int*)(USBGRF_UOC1_CON4);\r
+ //printk("usb_uart_mode = %d,enter_usb_uart_mode = %d\n",otg_phy_con1,enter_usb_uart_mode);\r
+ if(1 == enter_usb_uart_mode) //uart mode\r
+ {\r
+ *otg_phy_con1 = (0x03 << 12 | (0x03<<(16+12)));//bypass dm\r
+ //printk("phy enter uart mode USBGRF_UOC1_CON4 = %08x\n",*otg_phy_con1);\r
+ \r
+ }\r
+ if(0 == enter_usb_uart_mode) //usb mode\r
+ { \r
+ *otg_phy_con1 = (0x03<<(12+16)); //bypass dm disable \r
+ //printk("phy enter usb mode USBGRF_UOC1_CON4 = %8x\n",*otg_phy_con1);\r
+ }\r
+#endif\r
+}\r
+\r
void usb20otg_power_enable(int enable)\r
{\r
}\r
.clock_init=usb20otg_clock_init,\r
.clock_enable=usb20otg_clock_enable,\r
.get_status=usb20otg_get_status,\r
+ .dwc_otg_uart_mode=dwc_otg_uart_mode,\r
};\r
\r
struct platform_device device_usb20_otg = {\r