#include <asm/arch/virtual_com.h>
#include <asm/arch/packet.h>
#include <asm/arch/usb20_reg_v3.h>
+#include <linux/usb/ch9.h>
#define USB_DEBUG
int check_usb_reconnected = 0;
extern void usb_power_on(void);
+extern void usb_power_off(void);
+extern unsigned char *thor_get_device_desc(unsigned int speed);
+extern unsigned char *thor_get_config_desc(unsigned int speed);
+extern unsigned char *thor_get_string_desc(unsigned char index);
+extern unsigned char *thor_get_qualifer_desc(void);
+extern unsigned char *thor_get_other_speed_config_desc(void);
extern void Dcache_InvalRegion(unsigned int addr, unsigned int length);
extern void Dcache_CleanRegion(unsigned int addr, unsigned int length);
case USB_DEVICE_DESCRIPTOR_TYPE:
send_data = (uint8 *) thor_get_device_desc(enum_speed);
- EPI0_config (0x12, 0x1, TRUE, (uint32 *) send_data);
+ /*
+ * only send less or equal than requested length.
+ * no need to care about larger reqeust than possible
+ * descriptor length because of zero-length packet
+ * generated by usb controller
+ */
+ EPI0_config (min(USB_DT_DEVICE_SIZE, length), 0x1, TRUE, (uint32 *) send_data);
break;
case USB_CONFIGURATION_DESCRIPTOR_TYPE:
/*****************************************************************************/
PUBLIC void usb_set_feature (void)
{
- volatile USB_DCFG_U *dcfg_ptr = (volatile USB_DCFG_U *) USB_DCFG;
volatile USB_DCTL_U *dctl_ptr = (volatile USB_DCTL_U *) USB_DCTL;
- USB_REQUEST_1_U *request1;
USB_REQUEST_2_U *request2;
- USB_REQUEST_1_U request1_u;
USB_REQUEST_2_U request2_u;
- request1_u.dwValue = s_setup_packet[0];
request2_u.dwValue = s_setup_packet[1];
- request1= &request1_u;
request2= &request2_u;
EPI0_config (0x0, 0x1, FALSE, NULL);
{
volatile USB_INTSTS_U *usb_int_ptr = (USB_INTSTS_U *) USB_GINTSTS;
volatile USB_INTSTS_U usb_int;
- uint32 i=0;
- char string[64] ={0,};
usb_int.dwValue = usb_int_ptr->dwValue;
// in endpoint interrupt
{
volatile USB_DOEPINT_U *doepint_ptr = (USB_DOEPINT_U *) USB_DOEPINT (EP_OUT);
volatile USB_DOEPTSIZ_U *doeptsiz_ptr = (USB_DOEPTSIZ_U *) USB_DOEPTSIZ (EP_OUT);
- int i;
if(recv_length == 0)
{
// Note:
/*****************************************************************************/
+__align(64) unsigned char sprd_thor_setup_buf[512] = {0,};
+
+static int s_usb_connected = 0;
+
+extern int thor_handle(void);
+
+void sprd_usb_thor_start(void)
+{
+ g_usb_status = USB_STARTED;
+
+ do {
+ if (s_usb_connected == 0) {
+ USB_ReadEx_Internal(sprd_thor_setup_buf, sizeof(sprd_thor_setup_buf));
+
+ if (g_usb_status == USB_DETACHED_AFTER_USB_MODE_START)
+ return;
+
+ if (!strncmp((char *)sprd_thor_setup_buf, "THOR", strlen("THOR")))
+ {
+ usb_debug("- thor is connected!\n");
+ USB_WriteEx((uint8 *)"ROHT", strlen("ROHT"));
+ usb_debug("thor Setup Complete\n");
+ s_usb_connected = 1;
+ break;
+ } else{
+ usb_debug("thor_seup error - Not receiving THOR\n");
+ s_usb_connected = 0;
+ }
+ }
+ } while(1);
+
+ thor_handle();
+
+ usb_debug("%s : exit \n", __func__);
+ return;
+}
+
/* Enter point */
void thor_USB_Init(void)
{
usb_debug("%s : enter\n", __func__);
- unsigned int len = 0;
usb_power_on();
usb_core_init();
usb_power_off();
}
-__align(64) unsigned char sprd_thor_setup_buf[512] = {0,};
-
-static int s_usb_connected = 0;
-
/************************************************
*
* Register call back function for v3_protocol.
}
#endif
-extern int thor_handle(void);
-
-void sprd_usb_thor_start()
-{
- g_usb_status = USB_STARTED;
-
- do {
- if (s_usb_connected == 0) {
- USB_ReadEx_Internal(sprd_thor_setup_buf, sizeof(sprd_thor_setup_buf));
-
- if (g_usb_status == USB_DETACHED_AFTER_USB_MODE_START)
- return -1;
-
- if (!strncmp(sprd_thor_setup_buf, "THOR", strlen("THOR")))
- {
- usb_debug("- thor is connected!\n");
- USB_WriteEx("ROHT", strlen("ROHT"));
- usb_debug("thor Setup Complete\n");
- s_usb_connected = 1;
- break;
- } else{
- usb_debug("thor_seup error - Not receiving THOR\n");
- s_usb_connected = 0;
- }
- }
- } while(1);
-
- thor_handle();
-
- usb_debug("%s : exit \n", __func__);
- return 0;
-}
-
void disconnect_usb(void)
{
s_usb_connected = 0;